Upload tizen_2.2 source
authorkh5325.kim <kh5325.kim@samsung.com>
Tue, 18 Jun 2013 01:12:02 +0000 (10:12 +0900)
committerkh5325.kim <kh5325.kim@samsung.com>
Tue, 18 Jun 2013 01:12:02 +0000 (10:12 +0900)
Change-Id: I4dd528522cfeef4728505c758cfbd0a5aa6a6ee2

245 files changed:
LICENSE-2.0.htm [deleted file]
LICENSE.APLv2 [new file with mode: 0644]
NOTICE
add-ons/dropins/EGit/features/org.eclipse.egit_2.3.1.201302201838-r/META-INF/ECLIPSE_.RSA [new file with mode: 0644]
add-ons/dropins/EGit/features/org.eclipse.egit_2.3.1.201302201838-r/META-INF/ECLIPSE_.SF [new file with mode: 0644]
add-ons/dropins/EGit/features/org.eclipse.egit_2.3.1.201302201838-r/META-INF/MANIFEST.MF [new file with mode: 0644]
add-ons/dropins/EGit/features/org.eclipse.egit_2.3.1.201302201838-r/META-INF/eclipse.inf [new file with mode: 0644]
add-ons/dropins/EGit/features/org.eclipse.egit_2.3.1.201302201838-r/META-INF/maven/org.eclipse.egit.feature/org.eclipse.egit/pom.properties [new file with mode: 0644]
add-ons/dropins/EGit/features/org.eclipse.egit_2.3.1.201302201838-r/META-INF/maven/org.eclipse.egit.feature/org.eclipse.egit/pom.xml [new file with mode: 0644]
add-ons/dropins/EGit/features/org.eclipse.egit_2.3.1.201302201838-r/epl-v10.html [new file with mode: 0644]
add-ons/dropins/EGit/features/org.eclipse.egit_2.3.1.201302201838-r/feature.properties [new file with mode: 0644]
add-ons/dropins/EGit/features/org.eclipse.egit_2.3.1.201302201838-r/feature.xml [new file with mode: 0644]
add-ons/dropins/EGit/features/org.eclipse.egit_2.3.1.201302201838-r/license.html [new file with mode: 0644]
add-ons/dropins/EGit/features/org.eclipse.jgit_2.3.1.201302201838-r/META-INF/ECLIPSE_.RSA [new file with mode: 0644]
add-ons/dropins/EGit/features/org.eclipse.jgit_2.3.1.201302201838-r/META-INF/ECLIPSE_.SF [new file with mode: 0644]
add-ons/dropins/EGit/features/org.eclipse.jgit_2.3.1.201302201838-r/META-INF/MANIFEST.MF [new file with mode: 0644]
add-ons/dropins/EGit/features/org.eclipse.jgit_2.3.1.201302201838-r/META-INF/eclipse.inf [new file with mode: 0644]
add-ons/dropins/EGit/features/org.eclipse.jgit_2.3.1.201302201838-r/META-INF/maven/org.eclipse.jgit.feature/org.eclipse.jgit/pom.properties [new file with mode: 0644]
add-ons/dropins/EGit/features/org.eclipse.jgit_2.3.1.201302201838-r/META-INF/maven/org.eclipse.jgit.feature/org.eclipse.jgit/pom.xml [new file with mode: 0644]
add-ons/dropins/EGit/features/org.eclipse.jgit_2.3.1.201302201838-r/edl-v10.html [new file with mode: 0644]
add-ons/dropins/EGit/features/org.eclipse.jgit_2.3.1.201302201838-r/feature.properties [new file with mode: 0644]
add-ons/dropins/EGit/features/org.eclipse.jgit_2.3.1.201302201838-r/feature.xml [new file with mode: 0644]
add-ons/dropins/EGit/features/org.eclipse.jgit_2.3.1.201302201838-r/license.html [new file with mode: 0644]
add-ons/dropins/EGit/plugins/org.eclipse.egit.core_2.3.1.201302201838-r.jar [new file with mode: 0644]
add-ons/dropins/EGit/plugins/org.eclipse.egit.doc_2.3.1.201302201838-r.jar [new file with mode: 0644]
add-ons/dropins/EGit/plugins/org.eclipse.egit.ui_2.3.1.201302201838-r.jar [new file with mode: 0644]
add-ons/dropins/EGit/plugins/org.eclipse.egit_2.3.1.201302201838-r.jar [new file with mode: 0644]
add-ons/dropins/EGit/plugins/org.eclipse.jgit_2.3.1.201302201838-r.jar [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CDocHover.java
org.eclipse.wst.jsdt.web.core.patch/.classpath [new file with mode: 0644]
org.eclipse.wst.jsdt.web.core.patch/.project [new file with mode: 0644]
org.eclipse.wst.jsdt.web.core.patch/.settings/org.eclipse.jdt.core.prefs [new file with mode: 0644]
org.eclipse.wst.jsdt.web.core.patch/META-INF/MANIFEST.MF [new file with mode: 0644]
org.eclipse.wst.jsdt.web.core.patch/build.properties [new file with mode: 0644]
org.eclipse.wst.jsdt.web.core.patch/src/org/eclipse/wst/jsdt/web/core/javascript/JsTranslation.java [new file with mode: 0644]
org.eclipse.wst.jsdt.web.core/.classpath [new file with mode: 0644]
org.eclipse.wst.jsdt.web.core/.options [new file with mode: 0644]
org.eclipse.wst.jsdt.web.core/.project [new file with mode: 0644]
org.eclipse.wst.jsdt.web.core/.settings/org.eclipse.core.resources.prefs [new file with mode: 0644]
org.eclipse.wst.jsdt.web.core/.settings/org.eclipse.core.runtime.prefs [new file with mode: 0644]
org.eclipse.wst.jsdt.web.core/.settings/org.eclipse.jdt.core.prefs [new file with mode: 0644]
org.eclipse.wst.jsdt.web.core/.settings/org.eclipse.jdt.ui.prefs [new file with mode: 0644]
org.eclipse.wst.jsdt.web.core/.settings/org.eclipse.ltk.core.refactoring.prefs [new file with mode: 0644]
org.eclipse.wst.jsdt.web.core/.settings/org.eclipse.pde.prefs [new file with mode: 0644]
org.eclipse.wst.jsdt.web.core/META-INF/MANIFEST.MF [new file with mode: 0644]
org.eclipse.wst.jsdt.web.core/about.html [new file with mode: 0644]
org.eclipse.wst.jsdt.web.core/build.properties [new file with mode: 0644]
org.eclipse.wst.jsdt.web.core/component.xml [new file with mode: 0644]
org.eclipse.wst.jsdt.web.core/plugin.properties [new file with mode: 0644]
org.eclipse.wst.jsdt.web.core/plugin.xml [new file with mode: 0644]
org.eclipse.wst.jsdt.web.core/schema/javascriptPreProcessor.exsd [new file with mode: 0644]
org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/IncrementalBuilder.java [new file with mode: 0644]
org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/JSPCorePluginResources.properties [new file with mode: 0644]
org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/JSWebResourceEventManager.java [new file with mode: 0644]
org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/JsCoreMessages.java [new file with mode: 0644]
org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/JsCorePlugin.java [new file with mode: 0644]
org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/Logger.java [new file with mode: 0644]
org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/PathUtils.java [new file with mode: 0644]
org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/modelhandler/IWebDocumentChangeListener.java [new file with mode: 0644]
org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/modelhandler/IWebResourceChangedListener.java [new file with mode: 0644]
org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/modelhandler/Messages.java [new file with mode: 0644]
org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/modelhandler/WebResourceChangeHandler.java [new file with mode: 0644]
org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/modelhandler/messages.properties [new file with mode: 0644]
org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/project/ConvertJob.java [new file with mode: 0644]
org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/project/FacetedProjectListener.java [new file with mode: 0644]
org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/project/JsNatureInstaller.java [new file with mode: 0644]
org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/project/JsNatureUninstaller.java [new file with mode: 0644]
org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/project/JsWebNature.java [new file with mode: 0644]
org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/project/Messages.java [new file with mode: 0644]
org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/project/ModuleCoreSupport.java [new file with mode: 0644]
org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/project/ModuleCoreSupportDelegate.java [new file with mode: 0644]
org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/project/ModuleSourcePathProvider.java [new file with mode: 0644]
org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/project/WebProjectJsGlobalScopeContainerInitializer.java [new file with mode: 0644]
org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/project/messages.properties [new file with mode: 0644]
org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/provisional/contenttype/ContentTypeIdForEmbededJs.java [new file with mode: 0644]
org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/provisional/contenttype/IContentDescriptionForJSP.java [new file with mode: 0644]
org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/validation/JsValidator.java [new file with mode: 0644]
org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/validation/Util.java [new file with mode: 0644]
org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/javascript/CompilationUnitHelper.java [new file with mode: 0644]
org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/javascript/DocumentChangeListenerToTextEdit.java [new file with mode: 0644]
org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/javascript/HTML40Namespace.java [new file with mode: 0644]
org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/javascript/IJsTranslation.java [new file with mode: 0644]
org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/javascript/IJsTranslator.java [new file with mode: 0644]
org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/javascript/JsDataTypes.java [new file with mode: 0644]
org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/javascript/JsNameManglerUtil.java [new file with mode: 0644]
org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/javascript/JsProblemRequestor.java [new file with mode: 0644]
org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/javascript/JsTranslation.java [new file with mode: 0644]
org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/javascript/JsTranslationAdapter.java [new file with mode: 0644]
org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/javascript/JsTranslationAdapterFactory.java [new file with mode: 0644]
org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/javascript/JsTranslator.java [new file with mode: 0644]
org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/javascript/Messages.java [new file with mode: 0644]
org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/javascript/NodeHelper.java [new file with mode: 0644]
org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/javascript/Util.java [new file with mode: 0644]
org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/javascript/WebRootFinder.java [new file with mode: 0644]
org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/javascript/messages.properties [new file with mode: 0644]
org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/javascript/search/IndexWorkspaceJob.java [new file with mode: 0644]
org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/javascript/search/JSDTSearchDocumentDelegate.java [new file with mode: 0644]
org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/javascript/search/JsIndexManager.java [new file with mode: 0644]
org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/javascript/search/JsPathIndexer.java [new file with mode: 0644]
org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/javascript/search/JsSearchDocument.java [new file with mode: 0644]
org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/javascript/search/JsSearchParticipant.java [new file with mode: 0644]
org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/javascript/search/JsSearchScope.java [new file with mode: 0644]
org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/javascript/search/JsSearchSupport.java [new file with mode: 0644]
org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/javascript/search/NullSearchDocument.java [new file with mode: 0644]
org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/text/IJsPartitions.java [new file with mode: 0644]
org.eclipse.wst.jsdt.web.ui.patch/.classpath [new file with mode: 0644]
org.eclipse.wst.jsdt.web.ui.patch/.project [new file with mode: 0644]
org.eclipse.wst.jsdt.web.ui.patch/.settings/org.eclipse.jdt.core.prefs [new file with mode: 0644]
org.eclipse.wst.jsdt.web.ui.patch/META-INF/MANIFEST.MF [new file with mode: 0644]
org.eclipse.wst.jsdt.web.ui.patch/build.properties [new file with mode: 0644]
org.eclipse.wst.jsdt.web.ui.patch/src/org/eclipse/wst/jsdt/web/ui/internal/hyperlink/ExternalFileEditorInput.java [new file with mode: 0644]
org.eclipse.wst.jsdt.web.ui.patch/src/org/eclipse/wst/jsdt/web/ui/internal/hyperlink/ExternalFileHyperlink.java [new file with mode: 0644]
org.eclipse.wst.jsdt.web.ui.patch/src/org/eclipse/wst/jsdt/web/ui/internal/hyperlink/JSDTHyperlink.java [new file with mode: 0644]
org.eclipse.wst.jsdt.web.ui.patch/src/org/eclipse/wst/jsdt/web/ui/internal/hyperlink/JSDTHyperlinkDetector.java [new file with mode: 0644]
org.eclipse.wst.jsdt.web.ui.patch/src/org/eclipse/wst/jsdt/web/ui/internal/hyperlink/WorkspaceFileHyperlink.java [new file with mode: 0644]
org.eclipse.wst.jsdt.web.ui.patch/src/org/eclipse/wst/jsdt/web/ui/internal/hyperlink/XMLHyperlinkDetector.java [new file with mode: 0644]
org.eclipse.wst.jsdt.web.ui/.classpath [new file with mode: 0644]
org.eclipse.wst.jsdt.web.ui/.project [new file with mode: 0644]
org.eclipse.wst.jsdt.web.ui/.settings/org.eclipse.core.resources.prefs [new file with mode: 0644]
org.eclipse.wst.jsdt.web.ui/.settings/org.eclipse.core.runtime.prefs [new file with mode: 0644]
org.eclipse.wst.jsdt.web.ui/.settings/org.eclipse.jdt.core.prefs [new file with mode: 0644]
org.eclipse.wst.jsdt.web.ui/.settings/org.eclipse.jdt.ui.prefs [new file with mode: 0644]
org.eclipse.wst.jsdt.web.ui/.settings/org.eclipse.ltk.core.refactoring.prefs [new file with mode: 0644]
org.eclipse.wst.jsdt.web.ui/.settings/org.eclipse.pde.prefs [new file with mode: 0644]
org.eclipse.wst.jsdt.web.ui/META-INF/MANIFEST.MF [new file with mode: 0644]
org.eclipse.wst.jsdt.web.ui/about.html [new file with mode: 0644]
org.eclipse.wst.jsdt.web.ui/build.properties [new file with mode: 0644]
org.eclipse.wst.jsdt.web.ui/icons/eye_icon.gif [new file with mode: 0644]
org.eclipse.wst.jsdt.web.ui/icons/full/elcl16/javaassist_co.gif [new file with mode: 0644]
org.eclipse.wst.jsdt.web.ui/plugin.properties [new file with mode: 0644]
org.eclipse.wst.jsdt.web.ui/plugin.xml [new file with mode: 0644]
org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/Messages.java [new file with mode: 0644]
org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/SetupProjectsWizzard.java [new file with mode: 0644]
org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/StructuredTextViewerConfigurationJSDT.java [new file with mode: 0644]
org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/WebProjectJsGlobalScopeUIInitializer.java [new file with mode: 0644]
org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/actions/AddJavaDocStubAction.java [new file with mode: 0644]
org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/actions/AddJavaDocStubOperation.java [new file with mode: 0644]
org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/actions/FindReferencesAction.java [new file with mode: 0644]
org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/actions/FindReferencesInWorkingSetAction.java [new file with mode: 0644]
org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/actions/JsElementActionProxy.java [new file with mode: 0644]
org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/actions/Messages.java [new file with mode: 0644]
org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/actions/OpenCallHierarchyAction.java [new file with mode: 0644]
org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/actions/OpenTypeHierarchy.java [new file with mode: 0644]
org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/actions/ShowHistoryAction.java [new file with mode: 0644]
org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/actions/ShowInNavigatorAction.java [new file with mode: 0644]
org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/actions/ShowInScriptExplorerAction.java [new file with mode: 0644]
org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/actions/SimpleJSDTActionProxy.java [new file with mode: 0644]
org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/actions/SourceActionsAction.java [new file with mode: 0644]
org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/actions/StandardEditorActionsAction.java [new file with mode: 0644]
org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/actions/messages.properties [new file with mode: 0644]
org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/contentassist/JSDTAutoActivationDelegate.java [new file with mode: 0644]
org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/IActionConstantsJs.java [new file with mode: 0644]
org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/IActionDefinitionIdsJs.java [new file with mode: 0644]
org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/JSPUIPluginResources.properties [new file with mode: 0644]
org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/JsUIMessages.java [new file with mode: 0644]
org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/JsUIPlugin.java [new file with mode: 0644]
org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/Logger.java [new file with mode: 0644]
org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/autoedit/AutoEditStrategyForJs.java [new file with mode: 0644]
org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/autoedit/AutoEditStrategyForTabs.java [new file with mode: 0644]
org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/contentassist/JSDTCompletionProposal.java [new file with mode: 0644]
org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/contentassist/JSDTContentAssistant.java [new file with mode: 0644]
org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/contentassist/JSDTContentAssistantProcessor.java [new file with mode: 0644]
org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/contentassist/JSDTContetAssistInvocationContext.java [new file with mode: 0644]
org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/contentassist/JSDTHtmlCompletionProcessor.java [new file with mode: 0644]
org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/contentassist/JSDTProposalCollector.java [new file with mode: 0644]
org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/contentassist/JSDTTemplateAssistProcessor.java [new file with mode: 0644]
org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/contentassist/Messages.java [new file with mode: 0644]
org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/contentassist/messages.properties [new file with mode: 0644]
org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/derived/SingleCharReader.java [new file with mode: 0644]
org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/editor/ActionContributorJSP.java [new file with mode: 0644]
org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/editor/IHelpContextIds.java [new file with mode: 0644]
org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/format/FormattingStrategyJSDT.java [new file with mode: 0644]
org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/hyperlink/ExternalFileEditorInput.java [new file with mode: 0644]
org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/hyperlink/ExternalFileHyperlink.java [new file with mode: 0644]
org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/hyperlink/JSDTHyperlink.java [new file with mode: 0644]
org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/hyperlink/JSDTHyperlinkDetector.java [new file with mode: 0644]
org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/hyperlink/WorkspaceFileHyperlink.java [new file with mode: 0644]
org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/hyperlink/XMLHyperlinkDetector.java [new file with mode: 0644]
org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/refactoring/BasicRefactorSearchRequestor.java [new file with mode: 0644]
org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/refactoring/JSPJavaSelectionProvider.java [new file with mode: 0644]
org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/refactoring/JSPMethodRenameChange.java [new file with mode: 0644]
org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/refactoring/JSPMethodRenameParticipant.java [new file with mode: 0644]
org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/refactoring/JSPMethodRenameRequestor.java [new file with mode: 0644]
org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/refactoring/JSPMoveElementActionDelegate.java [new file with mode: 0644]
org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/refactoring/JSPPackageRenameChange.java [new file with mode: 0644]
org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/refactoring/JSPPackageRenameParticipant.java [new file with mode: 0644]
org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/refactoring/JSPPackageRenameRequestor.java [new file with mode: 0644]
org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/refactoring/JSPRenameElementActionDelegate.java [new file with mode: 0644]
org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/refactoring/JSPTypeMoveChange.java [new file with mode: 0644]
org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/refactoring/JSPTypeMoveParticipant.java [new file with mode: 0644]
org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/refactoring/JSPTypeMoveRequestor.java [new file with mode: 0644]
org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/refactoring/JSPTypeRenameChange.java [new file with mode: 0644]
org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/refactoring/JSPTypeRenameParticipant.java [new file with mode: 0644]
org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/refactoring/JSPTypeRenameRequestor.java [new file with mode: 0644]
org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/search/BasicJsSearchRequestor.java [new file with mode: 0644]
org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/search/JsFindOccurrencesActionDelegate.java [new file with mode: 0644]
org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/search/JsFindOccurrencesProcessor.java [new file with mode: 0644]
org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/search/JsOccurrencesSearchResult.java [new file with mode: 0644]
org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/search/JsSearchQuery.java [new file with mode: 0644]
org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/search/JsSearchRequestor.java [new file with mode: 0644]
org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/search/JsSingleFileSearchRequestor.java [new file with mode: 0644]
org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/search/ui/JsMatchPresentation.java [new file with mode: 0644]
org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/search/ui/JsQueryParticipant.java [new file with mode: 0644]
org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/registry/AdapterFactoryProviderForJSDT.java [new file with mode: 0644]
org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/style/IStyleConstantsJs.java [new file with mode: 0644]
org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/style/java/IStyleConstantsJSDT.java [new file with mode: 0644]
org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/style/java/JSDTCodeScanner.java [new file with mode: 0644]
org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/style/java/JavaWordDetector.java [new file with mode: 0644]
org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/style/java/LineStyleProviderForJSDT.java [new file with mode: 0644]
org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/taginfo/HTMLPrinter.java [new file with mode: 0644]
org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/taginfo/JSDTHoverProcessor.java [new file with mode: 0644]
org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/taginfo/JsWordFinder.java [new file with mode: 0644]
org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/text/JsCharacterPairInserter.java [new file with mode: 0644]
org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/text/JsCodeReader.java [new file with mode: 0644]
org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/text/JsDocumentRegionEdgeMatcher.java [new file with mode: 0644]
org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/text/JsPairMatcher.java [new file with mode: 0644]
org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/messages.properties [new file with mode: 0644]
org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/rino.jpg [new file with mode: 0644]
org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/views/contentoutline/IJavaWebNode.java [new file with mode: 0644]
org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/views/contentoutline/JFaceNodeAdapterFactoryForJSDT.java [new file with mode: 0644]
org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/views/contentoutline/JFaceNodeAdapterForJs.java [new file with mode: 0644]
org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/views/contentoutline/JsJfaceNode.java [new file with mode: 0644]
org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/views/contentoutline/Messages.java [new file with mode: 0644]
org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/views/contentoutline/messages.properties [new file with mode: 0644]
org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/views/provisional/contentoutline/JFaceNodeAdapterForJs.java [new file with mode: 0644]
org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/views/provisional/contentoutline/JsContentOutlineConfig.java [new file with mode: 0644]
org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/views/provisional/contentoutline/JsLabelProvider.java [new file with mode: 0644]
org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/views/provisional/contentoutline/JsMenuListener.java [new file with mode: 0644]
org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/views/provisional/contentoutline/JsWebElementProvider.java [new file with mode: 0644]
org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/views/provisional/contentoutline/XMLLabelProvider.java [new file with mode: 0644]
org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/web1.GIF [new file with mode: 0644]
org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/web1.JPG [new file with mode: 0644]
org.tizen.base.feature/feature.xml
org.tizen.base.feature/rootfiles_for_linux/startup.sh
org.tizen.base.platform/TizenIDE_base_linux.product
org.tizen.base.platform/TizenIDE_base_macos.product
org.tizen.base.platform/TizenIDE_base_windows.product
org.tizen.base.platform/content/home.html
org.tizen.base.platform/plugin_customization.ini
org.tizen.base.platform/src/org/tizen/base/platform/InitPreferences.java [deleted file]
package/base-ide-product.remove.linux
package/base-ide-product.remove.windows
package/build.linux
package/changelog
package/pkginfo.manifest

diff --git a/LICENSE-2.0.htm b/LICENSE-2.0.htm
deleted file mode 100644 (file)
index 3866874..0000000
+++ /dev/null
@@ -1,388 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">\r
-<html lang="en">\r
-  <head>\r
-    <title>Apache License, Version 2.0</title>\r
-\r
-    <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">\r
-    <meta property="og:image" content="http://www.apache.org/images/asf_logo.gif" />\r
-\r
-    <link rel="stylesheet" type="text/css" media="screen" href="/css/style.css">\r
-    <link rel="stylesheet" type="text/css" media="screen" href="/css/code.css">\r
-\r
-    <script type="text/javascript" src="/js/jquery.js"></script>\r
-    <script type="text/javascript" src="/js/apache_boot.js"></script>\r
-\r
-    \r
-\r
-    \r
-    <!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements.  See the NOTICE file distributed with this work for additional information regarding copyright ownership.  The ASF licenses this file to you under the Apache License, Version 2.0 (the &quot;License&quot;); you may not use this file except in compliance with the License.  You may obtain a copy of the License at . http://www.apache.org/licenses/LICENSE-2.0 . Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an &quot;AS IS&quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the License for the specific language governing permissions and limitations under the License. -->\r
-  </head>\r
-\r
-  <body>\r
-    <div id="page" class="container_16">\r
-      <div id="header" class="grid_8">\r
-        <img src="/images/feather-small.gif" alt="The Apache Software Foundation">\r
-        <h1>The Apache Software Foundation</h1>\r
-        <h2>Apache License, Version 2.0</h2>\r
-      </div>\r
-      <div id="nav" class="grid_8">\r
-        <ul>\r
-          <!-- <li><a href="/" title="Welcome!">Home</a></li> -->\r
-          <li><a href="/foundation/" title="The Foundation">Foundation</a></li>\r
-          <li><a href="http://projects.apache.org" title="The Projects">Projects</a></li>\r
-          <li><a href="http://people.apache.org" title="The People">People</a></li>\r
-          <li><a href="/foundation/getinvolved.html" title="Get Involved">Get Involved</a></li>\r
-          <li><a href="/dyn/closer.cgi" title="Download">Download</a></li>\r
-          <li><a href="/foundation/sponsorship.html" title="Support Apache">Support Apache</a></li>\r
-        </ul>\r
-        <p><a href="/">Home</a>&nbsp;&raquo&nbsp;<a href="/licenses/">Licenses</a></p>\r
-        <form name="search" id="search" action="http://www.google.com/search" method="get">\r
-          <input value="*.apache.org" name="sitesearch" type="hidden"/>\r
-          <input type="text" name="q" id="query">\r
-          <input type="submit" id="submit" value="Search">\r
-        </form>\r
-      </div>\r
-      <div class="clear"></div>\r
-      <div id="content" class="grid_16"><div class="section-content"><p>Apache License<br></br>Version 2.0, January 2004<br></br>\r
-<a href="http://www.apache.org/licenses/">http://www.apache.org/licenses/</a> </p>\r
-<p>TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION</p>\r
-<p><strong><a name="definitions">1. Definitions</a></strong>.</p>\r
-<p>"License" shall mean the terms and conditions for use, reproduction, and\r
-distribution as defined by Sections 1 through 9 of this document.</p>\r
-<p>"Licensor" shall mean the copyright owner or entity authorized by the\r
-copyright owner that is granting the License.</p>\r
-<p>"Legal Entity" shall mean the union of the acting entity and all other\r
-entities that control, are controlled by, or are under common control with\r
-that entity. For the purposes of this definition, "control" means (i) the\r
-power, direct or indirect, to cause the direction or management of such\r
-entity, whether by contract or otherwise, or (ii) ownership of fifty\r
-percent (50%) or more of the outstanding shares, or (iii) beneficial\r
-ownership of such entity.</p>\r
-<p>"You" (or "Your") shall mean an individual or Legal Entity exercising\r
-permissions granted by this License.</p>\r
-<p>"Source" form shall mean the preferred form for making modifications,\r
-including but not limited to software source code, documentation source,\r
-and configuration files.</p>\r
-<p>"Object" form shall mean any form resulting from mechanical transformation\r
-or translation of a Source form, including but not limited to compiled\r
-object code, generated documentation, and conversions to other media types.</p>\r
-<p>"Work" shall mean the work of authorship, whether in Source or Object form,\r
-made available under the License, as indicated by a copyright notice that\r
-is included in or attached to the work (an example is provided in the\r
-Appendix below).</p>\r
-<p>"Derivative Works" shall mean any work, whether in Source or Object form,\r
-that is based on (or derived from) the Work and for which the editorial\r
-revisions, annotations, elaborations, or other modifications represent, as\r
-a whole, an original work of authorship. For the purposes of this License,\r
-Derivative Works shall not include works that remain separable from, or\r
-merely link (or bind by name) to the interfaces of, the Work and Derivative\r
-Works thereof.</p>\r
-<p>"Contribution" shall mean any work of authorship, including the original\r
-version of the Work and any modifications or additions to that Work or\r
-Derivative Works thereof, that is intentionally submitted to Licensor for\r
-inclusion in the Work by the copyright owner or by an individual or Legal\r
-Entity authorized to submit on behalf of the copyright owner. For the\r
-purposes of this definition, "submitted" means any form of electronic,\r
-verbal, or written communication sent to the Licensor or its\r
-representatives, including but not limited to communication on electronic\r
-mailing lists, source code control systems, and issue tracking systems that\r
-are managed by, or on behalf of, the Licensor for the purpose of discussing\r
-and improving the Work, but excluding communication that is conspicuously\r
-marked or otherwise designated in writing by the copyright owner as "Not a\r
-Contribution."</p>\r
-<p>"Contributor" shall mean Licensor and any individual or Legal Entity on\r
-behalf of whom a Contribution has been received by Licensor and\r
-subsequently incorporated within the Work.</p>\r
-<p><strong><a name="copyright">2. Grant of Copyright License</a></strong>. Subject to the\r
-terms and conditions of this License, each Contributor hereby grants to You\r
-a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable\r
-copyright license to reproduce, prepare Derivative Works of, publicly\r
-display, publicly perform, sublicense, and distribute the Work and such\r
-Derivative Works in Source or Object form.</p>\r
-<p><strong><a name="patent">3. Grant of Patent License</a></strong>. Subject to the terms\r
-and conditions of this License, each Contributor hereby grants to You a\r
-perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable\r
-(except as stated in this section) patent license to make, have made, use,\r
-offer to sell, sell, import, and otherwise transfer the Work, where such\r
-license applies only to those patent claims licensable by such Contributor\r
-that are necessarily infringed by their Contribution(s) alone or by\r
-combination of their Contribution(s) with the Work to which such\r
-Contribution(s) was submitted. If You institute patent litigation against\r
-any entity (including a cross-claim or counterclaim in a lawsuit) alleging\r
-that the Work or a Contribution incorporated within the Work constitutes\r
-direct or contributory patent infringement, then any patent licenses\r
-granted to You under this License for that Work shall terminate as of the\r
-date such litigation is filed.</p>\r
-<p><strong><a name="redistribution">4. Redistribution</a></strong>. You may reproduce and\r
-distribute copies of the Work or Derivative Works thereof in any medium,\r
-with or without modifications, and in Source or Object form, provided that\r
-You meet the following conditions:</p>\r
-<ol>\r
-<li>\r
-<p>You must give any other recipients of the Work or Derivative Works a\r
-copy of this License; and</p>\r
-</li>\r
-<li>\r
-<p>You must cause any modified files to carry prominent notices stating\r
-that You changed the files; and</p>\r
-</li>\r
-<li>\r
-<p>You must retain, in the Source form of any Derivative Works that You\r
-distribute, all copyright, patent, trademark, and attribution notices from\r
-the Source form of the Work, excluding those notices that do not pertain to\r
-any part of the Derivative Works; and</p>\r
-</li>\r
-<li>\r
-<p>If the Work includes a "NOTICE" text file as part of its distribution,\r
-then any Derivative Works that You distribute must include a readable copy\r
-of the attribution notices contained within such NOTICE file, excluding\r
-those notices that do not pertain to any part of the Derivative Works, in\r
-at least one of the following places: within a NOTICE text file distributed\r
-as part of the Derivative Works; within the Source form or documentation,\r
-if provided along with the Derivative Works; or, within a display generated\r
-by the Derivative Works, if and wherever such third-party notices normally\r
-appear. The contents of the NOTICE file are for informational purposes only\r
-and do not modify the License. You may add Your own attribution notices\r
-within Derivative Works that You distribute, alongside or as an addendum to\r
-the NOTICE text from the Work, provided that such additional attribution\r
-notices cannot be construed as modifying the License.\r
-You may add Your own copyright statement to Your modifications and may\r
-provide additional or different license terms and conditions for use,\r
-reproduction, or distribution of Your modifications, or for any such\r
-Derivative Works as a whole, provided Your use, reproduction, and\r
-distribution of the Work otherwise complies with the conditions stated in\r
-this License.</p>\r
-</li>\r
-</ol>\r
-<p><strong><a name="contributions">5. Submission of Contributions</a></strong>. Unless You\r
-explicitly state otherwise, any Contribution intentionally submitted for\r
-inclusion in the Work by You to the Licensor shall be under the terms and\r
-conditions of this License, without any additional terms or conditions.\r
-Notwithstanding the above, nothing herein shall supersede or modify the\r
-terms of any separate license agreement you may have executed with Licensor\r
-regarding such Contributions.</p>\r
-<p><strong><a name="trademarks">6. Trademarks</a></strong>. This License does not grant\r
-permission to use the trade names, trademarks, service marks, or product\r
-names of the Licensor, except as required for reasonable and customary use\r
-in describing the origin of the Work and reproducing the content of the\r
-NOTICE file.</p>\r
-<p><strong><a name="no-warranty">7. Disclaimer of Warranty</a></strong>. Unless required by\r
-applicable law or agreed to in writing, Licensor provides the Work (and\r
-each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT\r
-WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including,\r
-without limitation, any warranties or conditions of TITLE,\r
-NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You\r
-are solely responsible for determining the appropriateness of using or\r
-redistributing the Work and assume any risks associated with Your exercise\r
-of permissions under this License.</p>\r
-<p><strong><a name="no-liability">8. Limitation of Liability</a></strong>. In no event and\r
-under no legal theory, whether in tort (including negligence), contract, or\r
-otherwise, unless required by applicable law (such as deliberate and\r
-grossly negligent acts) or agreed to in writing, shall any Contributor be\r
-liable to You for damages, including any direct, indirect, special,\r
-incidental, or consequential damages of any character arising as a result\r
-of this License or out of the use or inability to use the Work (including\r
-but not limited to damages for loss of goodwill, work stoppage, computer\r
-failure or malfunction, or any and all other commercial damages or losses),\r
-even if such Contributor has been advised of the possibility of such\r
-damages.</p>\r
-<p><strong><a name="additional">9. Accepting Warranty or Additional Liability</a></strong>.\r
-While redistributing the Work or Derivative Works thereof, You may choose\r
-to offer, and charge a fee for, acceptance of support, warranty, indemnity,\r
-or other liability obligations and/or rights consistent with this License.\r
-However, in accepting such obligations, You may act only on Your own behalf\r
-and on Your sole responsibility, not on behalf of any other Contributor,\r
-and only if You agree to indemnify, defend, and hold each Contributor\r
-harmless for any liability incurred by, or claims asserted against, such\r
-Contributor by reason of your accepting any such warranty or additional\r
-liability.</p>\r
-<p>END OF TERMS AND CONDITIONS</p>\r
-<h1 id="apply">APPENDIX: How to apply the Apache License to your work</h1>\r
-<p>To apply the Apache License to your work, attach the following boilerplate\r
-notice, with the fields enclosed by brackets "[]" replaced with your own\r
-identifying information. (Don't include the brackets!) The text should be\r
-enclosed in the appropriate comment syntax for the file format. We also\r
-recommend that a file or class name and description of purpose be included\r
-on the same "printed page" as the copyright notice for easier\r
-identification within third-party archives.</p>\r
-<div class="codehilite"><pre>   Copyright [yyyy] [name of copyright owner]\r
-\r
-   Licensed under the Apache License, Version 2.0 (the &quot;License&quot;);\r
-   you may not use this file except in compliance with the License.\r
-   You may obtain a copy of the License at\r
-\r
-       http://www.apache.org/licenses/LICENSE-2.0\r
-\r
-   Unless required by applicable law or agreed to in writing, software\r
-   distributed under the License is distributed on an &quot;AS IS&quot; BASIS,\r
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-   See the License for the specific language governing permissions and\r
-   limitations under the License.\r
-</pre></div></div></div>\r
-      <div class="clear"></div>\r
-    </div>\r
-    <div id="footer" class="container_16">\r
-      <div class="links grid_16">\r
-      <div class="grid_3">\r
-        <h4>Projects</h4>\r
-        <ul>\r
-<li><a href="http://httpd.apache.org/" title="Apache Web Server (httpd)">HTTP Server</a></li>\r
-<li><a href="http://abdera.apache.org/" title="Atom Publishing Protocol Implementation">Abdera</a></li>\r
-<li><a href="http://activemq.apache.org/" title="Distributed Messaging System">ActiveMQ</a></li>\r
-<li><a href="http://ant.apache.org/" title="Java-based build tool">Ant</a></li>\r
-<li><a href="http://apr.apache.org/" title="Apache Portable Runtime libraries">APR</a></li>\r
-<li><a href="http://archiva.apache.org/" title="Build Artifact Repository Manager">Archiva</a></li>\r
-<li><a href="http://aries.apache.org/" title="Enterprise OSGi application programming model">Aries</a></li>\r
-<li><a href="http://avro.apache.org/" title="A Serialization System">Avro</a></li>\r
-<li><a href="http://axis.apache.org/" title="Java SOAP Engine">Axis</a></li>\r
-<li><a href="http://buildr.apache.org/" title="Simple and intuitive build system for Java applications">Buildr</a></li>\r
-<li><a href="http://camel.apache.org/" title="Spring based Integration Framework which implements the Enterprise Integration Patterns">Camel</a></li>\r
-<li><a href="http://cassandra.apache.org/" title="Highly scalable second-generation distributed database">Cassandra</a></li>\r
-<li><a href="http://cayenne.apache.org/" title="User-friendly Java ORM with Tools">Cayenne</a></li>\r
-<li><a href="http://chemistry.apache.org/" title="CMIS (Content Managment Interoperability Services) Clients and Servers">Chemistry</a></li>\r
-<li><a href="http://click.apache.org/" title="User-friendly page and component oriented web framework">Click</a></li>\r
-<li><a href="http://cocoon.apache.org/" title="Web development framework: separation of concerns, component-based">Cocoon</a></li>\r
-<li><a href="http://commons.apache.org/" title="Reusable Java components">Commons</a></li>\r
-<li><a href="http://continuum.apache.org/" title="Continuous Integration and Build Server">Continuum</a></li>\r
-<li><a href="http://couchdb.apache.org/" title="RESTful document database">CouchDB</a></li>\r
-<li><a href="http://cxf.apache.org/" title="Service Framework">CXF</a></li>\r
-<li><a href="http://db.apache.org/" title="Database access">DB</a></li>\r
-<li><a href="http://deltacloud.apache.org/" title="RESTful cloud management interface">Deltacloud</a></li>\r
-<li><a href="http://directory.apache.org/" title="Apache Directory Server">Directory</a></li>\r
-<li><a href="http://esme.apache.org/" title="Enterprise Social Messaging Environment">ESME</a></li>\r
-<li><a href="http://felix.apache.org/" title="OSGi Framework and components.">Felix</a></li>\r
-<li><a href="http://forrest.apache.org/" title="Aggregated multi-channel documentation, separation of concerns">Forrest</a></li>\r
-<li><a href="http://geronimo.apache.org/" title="Java2, Enterprise Edition (J2EE) container">Geronimo</a></li>\r
-<li><a href="http://gump.apache.org/" title="Continuous integration of open source projects">Gump</a></li>\r
-<li><a href="http://hadoop.apache.org/" title="Distributed computing platform">Hadoop</a></li>\r
-<li><a href="http://hbase.apache.org/" title="Hadoop Database">HBase</a></li>\r
-<li><a href="http://hive.apache.org/" title="Data warehouse infrastructure using the Hadoop Database">Hive</a></li>\r
-<li><a href="http://hc.apache.org/" title="Java toolset of low level HTTP components">HttpComponents</a></li>\r
-<li><a href="http://jackrabbit.apache.org/" title="Content Repository for Java">Jackrabbit</a></li>\r
-<li><a href="http://jakarta.apache.org/" title="Server-side Java">Jakarta</a></li>\r
-<li><a href="http://james.apache.org/" title="Java Apache Mail Enterprise Server">James</a></li>\r
-<li><a href="http://jmeter.apache.org/" title="Java performance and functional testing">JMeter</a></li>\r
-<li><a href="http://juddi.apache.org/" title="Java implementation of the Universal Description, Discovery, and Integration specification">jUDDI</a></li>\r
-<li><a href="http://karaf.apache.org/" title="Server-side OSGi distribution">Karaf</a></li>\r
-<li><a href="http://lenya.apache.org/" title="Content Management System">Lenya</a></li>\r
-<li><a href="http://libcloud.apache.org/" title="Unified interface to the cloud">Libcloud</a></li>\r
-<li><a href="http://logging.apache.org/" title="Cross-language logging services">Logging</a></li>\r
-<li><a href="http://lucene.apache.org/" title="Search engine library">Lucene</a></li>\r
-<li><a href="http://mahout.apache.org/" title="Scalable machine learning library">Mahout</a></li>\r
-<li><a href="http://maven.apache.org/" title="Java project management and comprehension tools">Maven</a></li>\r
-<li><a href="http://mina.apache.org/" title="Multipurpose Infrastructure for Network Application">MINA</a></li>\r
-<li><a href="http://myfaces.apache.org/" title="JavaServer(tm) Faces implementation and components">MyFaces</a></li>\r
-<li><a href="http://nutch.apache.org/" title="Open Source Web Search Software">Nutch</a></li>\r
-<li><a href="http://ode.apache.org/" title="Orchestration Director Engine: Business Process Management (BPM), Process Orchestration and Workflow through service compositioni.">ODE</a></li>\r
-<li><a href="http://oodt.apache.org/" title="Object Oriented Data Technology (middleware metadata)">OODT</a></li>\r
-<li><a href="http://ofbiz.apache.org/" title="Open for Business: enterprise automation software">OFBiz</a></li>\r
-<li><a href="http://openejb.apache.org/" title="OpenEJB: a modular, configurable, and extendable EJB Container System and Server">OpenEJB</a></li>\r
-<li><a href="http://openjpa.apache.org/" title="OpenJPA: Object Relational Mapping for Java">OpenJPA</a></li>\r
-<li><a href="http://openwebbeans.apache.org/" title="OpenWebBeans: JSR-299 Context and Dependency Injection for Java EE Platform Implementation">OpenWebBeans</a></li>\r
-<li><a href="http://pdfbox.apache.org/" title="Java library for working with PDF documents">PDFBox</a></li>\r
-<li><a href="http://perl.apache.org/" title="Dynamic websites using Perl">Perl</a></li>\r
-<li><a href="http://pig.apache.org/" title="Platform for analyzing large data sets">Pig</a></li>\r
-<li><a href="http://pivot.apache.org/" title="Rich Internet applications in Java">Pivot</a></li>\r
-<li><a href="http://poi.apache.org/" title="Java API for OLE 2 Compound and OOXML Documents">POI</a></li>\r
-<li><a href="http://portals.apache.org/" title="Portal technology">Portals</a></li>\r
-<li><a href="http://qpid.apache.org/" title="Multiple language implementation of the latest Advanced Message Queuing Protocol (AMQP)">Qpid</a></li>\r
-<li><a href="http://river.apache.org/" title="Jini service oriented architecture">River</a></li>\r
-<li><a href="http://roller.apache.org/" title="Java blog server">Roller</a></li>\r
-<li><a href="http://santuario.apache.org/" title="XML Security in Java and C++">Santuario</a></li>\r
-<li><a href="http://servicemix.apache.org/" title="Enterprise Service Bus">ServiceMix</a></li>\r
-<li><a href="http://shindig.apache.org/" title="Opensocial Reference Implementation">Shindig</a></li>\r
-<li><a href="http://shiro.apache.org/" title="Powerful and easy-to-use application security framework">Shiro</a></li>\r
-<li><a href="http://sling.apache.org/" title="Web Framework for JCR Content Repositories">Sling</a></li>\r
-<li><a href="http://spamassassin.apache.org/" title="Mail filter to identify spam">SpamAssassin</a></li>\r
-<li><a href="http://stdcxx.apache.org/" title="Apache C++ Standard Library">STDCXX</a></li>\r
-<li><a href="http://struts.apache.org/" title="Model 2 framework for building Java web applications">Struts</a></li>\r
-<li><a href="http://subversion.apache.org/" title="Version Control">Subversion</a></li>\r
-<li><a href="http://synapse.apache.org/" title="Enterprise Service Bus and Mediation Framework">Synapse</a></li>\r
-<li><a href="http://tapestry.apache.org/" title="Component-based Java Web Application Framework">Tapestry</a></li>\r
-<li><a href="http://tcl.apache.org/" title="Dynamic websites using TCL">Tcl</a></li>\r
-<li><a href="http://thrift.apache.org/" title="Framework for scalable cross-language services development">Thrift</a></li>\r
-<li><a href="http://tika.apache.org" title="Content Analysis and Detection Toolkit">Tika</a></li>\r
-<li><a href="http://tiles.apache.org/" title="A templating framework for web application user interfaces">Tiles</a></li>\r
-<li><a href="http://tomcat.apache.org/" title="A Java Servlet and JSP Container">Tomcat</a></li>\r
-<li><a href="http://trafficserver.apache.org/" title="A fast, scalable and extensible HTTP/1.1 compliant caching proxy server">Traffic Server</a></li>\r
-<li><a href="http://turbine.apache.org/" title="A Java Servlet Web Application Framework and associated component library">Turbine</a></li>\r
-<li><a href="http://tuscany.apache.org/" title="An SCA based Service Composition Framework">Tuscany</a></li>\r
-<li><a href="http://uima.apache.org/" title="Framework and annotators for unstructured information analysis">UIMA</a></li>\r
-<li><a href="http://velocity.apache.org/" title="A Java Templating Engine">Velocity</a></li>\r
-<li><a href="http://ws.apache.org/">Web Services</a></li>\r
-<li><a href="http://whirr.apache.org/" title="Libraries for running Cloud Services">Whirr</a></li>\r
-<li><a href="http://wicket.apache.org/" title="Component-based Java Web Application Framework.">Wicket</a></li>\r
-<li><a href="http://xalan.apache.org/" title="XSLT processors in Java and C++">Xalan</a></li>\r
-<li><a href="http://xerces.apache.org/" title="XML parsers in Java, C++ and Perl">Xerces</a></li>\r
-<li><a href="http://xml.apache.org/" title="XML solutions focused on the web">XML</a></li>\r
-<li><a href="http://xmlbeans.apache.org/" title="XML-Java binding tool">XMLBeans</a></li>\r
-<li><a href="http://xmlgraphics.apache.org/" title="Conversion from XML to graphical output">XML Graphics</a></li>\r
-<li><a href="http://zookeeper.apache.org/" title="Centralized service for maintaining configuration information">ZooKeeper</a></li>\r
-</ul>\r
-      </div>\r
-      <div class="grid_3">\r
-        <h4>Foundation</h4>\r
-        <ul>\r
-          <li><a href="/foundation/faq.html">FAQ</a></li> \r
-          <li><a href="/licenses/" title="Overview of the Apache Licenese">Licenses</a></li> \r
-          <li><a href="/foundation/marks/" title="Apache marks policies and listing">Trademarks</a></li>  \r
-          <li><a href="/foundation/news.html" title="Official news feed of Foundation announcements">News</a></li> \r
-          <li><a href="/press/" title="Press, Media, and Analyst contact">Press Inquiries</a></li> \r
-          <li><a href="/foundation/records/" title="Formal corporate records and board meeting minutes">Public Records</a></li> \r
-          <li><a href="/foundation/sponsorship.html" title="Sponsor the Foundation">Sponsorship</a></li> \r
-          <li><a href="/foundation/contributing.html" title="Donate to the Foundation">Donations</a></li> \r
-          <li><a href="/foundation/buy_stuff.html" title="Buy Apache branded merchandise">Buy Stuff</a></li> \r
-          <li><a href="/foundation/thanks.html" title="Thank you to our Sponsors">Thanks</a></li> \r
-          <li><a href="/foundation/contact.html" title="Contact Us">Contact</a></li> \r
-        </ul>\r
-      </div>\r
-      <div class="grid_3 suffix_1">\r
-        <h4>Foundation Projects</h4>\r
-        <ul>\r
-          <li><a href="http://attic.apache.org/" title="Inactive projects repository">Attic</a></li> \r
-          <li><a href="/foundation/conferences.html" title="Meetings of developers and users">Conferences</a></li> \r
-          <li><a href="http://community.apache.org/" title="Helping newcomers to the ASF">Community Development</a></li> \r
-          <li><a href="http://incubator.apache.org/" title="Shepherd for new projects">Incubator</a></li> \r
-          <li><a href="/dev/" title="ASF Infrastructure: Operations and howto documents for PMCs and contributors">Infrastructure</a></li> \r
-          <li><a href="/jcp/" title="Apache and the Java Community Process">JCP</a></li> \r
-          <li><a href="http://labs.apache.org/" title="The Innovation Laboratories of the Apache Software Foundation">Labs</a></li> \r
-          <li><a href="/legal/" title="Legal Affairs">Legal Affairs</a></li> \r
-          <li><a href="/press/" title="Public Relations">Public Relations</a></li> \r
-          <li><a href="/security/" title="Security">Security</a></li> \r
-          <li><a href="/travel/" title="Travel Assistance">Travel Assistance</a></li> \r
-        </ul>\r
-      </div>\r
-      \r
-      <div class="grid_3">\r
-        <h4>Community</h4>\r
-        <ul>\r
-          <li><a href="http://people.apache.org/" title="Apache committer homepages">People</a></li> \r
-          <li><a href="/memorials/" title="In memoriam of past committers">Memorials</a></li> \r
-          <li><a href="http://feathercast.org/" title="Apache Podcasts">Feathercast</a></li> \r
-          <li><a href="http://blogs.apache.org/" title="Apache Project Blogs">Project Blogs</a></li> \r
-          <li><a href="http://planet.apache.org/committers/" title="Apache Committers' Blogs">PlanetApache</a></li> \r
-        </ul>\r
-      </div>\r
-      <div class="grid_3">\r
-        <h4>How It Works</h4>\r
-        <ul>\r
-          <li><a href="/foundation/how-it-works.html">Introduction</a></li> \r
-          <li><a href="/foundation/how-it-works.html#meritocracy">Meritocracy</a></li> \r
-          <li><a href="/foundation/how-it-works.html#structure">Structure</a></li> \r
-          <li><a href="/foundation/how-it-works.html#roles">Roles</a></li> \r
-          <li><a href="/foundation/how-it-works.html#management">Collaboration</a></li> \r
-          <li><a href="/foundation/how-it-works.html#incubator">Incubator</a></li> \r
-          <li><a href="/foundation/how-it-works.html#other">Other entities</a></li> \r
-          <li><a href="/foundation/glossary.html">Glossary</a></li> \r
-          <li><a href="/foundation/voting.html">Voting</a></li> \r
-        </ul>\r
-      </div>\r
-    </div>\r
-    <div class="clear"></div>\r
-    \r
-    </div>\r
-    <div id="copyright" class="container_16">\r
-      <p>Copyright &#169; 2011 The Apache Software Foundation, Licensed under the <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.<br/>Apache and the Apache feather logo are trademarks of The Apache Software Foundation.</p>\r
-    </div>\r
-  </body>\r
-</html>\r
diff --git a/LICENSE.APLv2 b/LICENSE.APLv2
new file mode 100644 (file)
index 0000000..5554685
--- /dev/null
@@ -0,0 +1,204 @@
+                                 Apache License\r
+                           Version 2.0, January 2004\r
+                        http://www.apache.org/licenses/\r
+\r
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION\r
+\r
+   1. Definitions.\r
+\r
+      "License" shall mean the terms and conditions for use, reproduction,\r
+      and distribution as defined by Sections 1 through 9 of this document.\r
+\r
+      "Licensor" shall mean the copyright owner or entity authorized by\r
+      the copyright owner that is granting the License.\r
+\r
+      "Legal Entity" shall mean the union of the acting entity and all\r
+      other entities that control, are controlled by, or are under common\r
+      control with that entity. For the purposes of this definition,\r
+      "control" means (i) the power, direct or indirect, to cause the\r
+      direction or management of such entity, whether by contract or\r
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the\r
+      outstanding shares, or (iii) beneficial ownership of such entity.\r
+\r
+      "You" (or "Your") shall mean an individual or Legal Entity\r
+      exercising permissions granted by this License.\r
+\r
+      "Source" form shall mean the preferred form for making modifications,\r
+      including but not limited to software source code, documentation\r
+      source, and configuration files.\r
+\r
+      "Object" form shall mean any form resulting from mechanical\r
+      transformation or translation of a Source form, including but\r
+      not limited to compiled object code, generated documentation,\r
+      and conversions to other media types.\r
+\r
+      "Work" shall mean the work of authorship, whether in Source or\r
+      Object form, made available under the License, as indicated by a\r
+      copyright notice that is included in or attached to the work\r
+      (an example is provided in the Appendix below).\r
+\r
+      "Derivative Works" shall mean any work, whether in Source or Object\r
+      form, that is based on (or derived from) the Work and for which the\r
+      editorial revisions, annotations, elaborations, or other modifications\r
+      represent, as a whole, an original work of authorship. For the purposes\r
+      of this License, Derivative Works shall not include works that remain\r
+      separable from, or merely link (or bind by name) to the interfaces of,\r
+      the Work and Derivative Works thereof.\r
+\r
+      "Contribution" shall mean any work of authorship, including\r
+      the original version of the Work and any modifications or additions\r
+      to that Work or Derivative Works thereof, that is intentionally\r
+      submitted to Licensor for inclusion in the Work by the copyright owner\r
+      or by an individual or Legal Entity authorized to submit on behalf of\r
+      the copyright owner. For the purposes of this definition, "submitted"\r
+      means any form of electronic, verbal, or written communication sent\r
+      to the Licensor or its representatives, including but not limited to\r
+      communication on electronic mailing lists, source code control systems,\r
+      and issue tracking systems that are managed by, or on behalf of, the\r
+      Licensor for the purpose of discussing and improving the Work, but\r
+      excluding communication that is conspicuously marked or otherwise\r
+      designated in writing by the copyright owner as "Not a Contribution."\r
+\r
+      "Contributor" shall mean Licensor and any individual or Legal Entity\r
+      on behalf of whom a Contribution has been received by Licensor and\r
+      subsequently incorporated within the Work.\r
+\r
+   2. Grant of Copyright License. Subject to the terms and conditions of\r
+      this License, each Contributor hereby grants to You a perpetual,\r
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable\r
+      copyright license to reproduce, prepare Derivative Works of,\r
+      publicly display, publicly perform, sublicense, and distribute the\r
+      Work and such Derivative Works in Source or Object form.\r
+\r
+   3. Grant of Patent License. Subject to the terms and conditions of\r
+      this License, each Contributor hereby grants to You a perpetual,\r
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable\r
+      (except as stated in this section) patent license to make, have made,\r
+      use, offer to sell, sell, import, and otherwise transfer the Work,\r
+      where such license applies only to those patent claims licensable\r
+      by such Contributor that are necessarily infringed by their\r
+      Contribution(s) alone or by combination of their Contribution(s)\r
+      with the Work to which such Contribution(s) was submitted. If You\r
+      institute patent litigation against any entity (including a\r
+      cross-claim or counterclaim in a lawsuit) alleging that the Work\r
+      or a Contribution incorporated within the Work constitutes direct\r
+      or contributory patent infringement, then any patent licenses\r
+      granted to You under this License for that Work shall terminate\r
+      as of the date such litigation is filed.\r
+\r
+   4. Redistribution. You may reproduce and distribute copies of the\r
+      Work or Derivative Works thereof in any medium, with or without\r
+      modifications, and in Source or Object form, provided that You\r
+      meet the following conditions:\r
+\r
+      (a) You must give any other recipients of the Work or\r
+          Derivative Works a copy of this License; and\r
+\r
+      (b) You must cause any modified files to carry prominent notices\r
+          stating that You changed the files; and\r
+\r
+      (c) You must retain, in the Source form of any Derivative Works\r
+          that You distribute, all copyright, patent, trademark, and\r
+          attribution notices from the Source form of the Work,\r
+          excluding those notices that do not pertain to any part of\r
+          the Derivative Works; and\r
+\r
+      (d) If the Work includes a "NOTICE" text file as part of its\r
+          distribution, then any Derivative Works that You distribute must\r
+          include a readable copy of the attribution notices contained\r
+          within such NOTICE file, excluding those notices that do not\r
+          pertain to any part of the Derivative Works, in at least one\r
+          of the following places: within a NOTICE text file distributed\r
+          as part of the Derivative Works; within the Source form or\r
+          documentation, if provided along with the Derivative Works; or,\r
+          within a display generated by the Derivative Works, if and\r
+          wherever such third-party notices normally appear. The contents\r
+          of the NOTICE file are for informational purposes only and\r
+          do not modify the License. You may add Your own attribution\r
+          notices within Derivative Works that You distribute, alongside\r
+          or as an addendum to the NOTICE text from the Work, provided\r
+          that such additional attribution notices cannot be construed\r
+          as modifying the License.\r
+\r
+      You may add Your own copyright statement to Your modifications and\r
+      may provide additional or different license terms and conditions\r
+      for use, reproduction, or distribution of Your modifications, or\r
+      for any such Derivative Works as a whole, provided Your use,\r
+      reproduction, and distribution of the Work otherwise complies with\r
+      the conditions stated in this License.\r
+\r
+   5. Submission of Contributions. Unless You explicitly state otherwise,\r
+      any Contribution intentionally submitted for inclusion in the Work\r
+      by You to the Licensor shall be under the terms and conditions of\r
+      this License, without any additional terms or conditions.\r
+      Notwithstanding the above, nothing herein shall supersede or modify\r
+      the terms of any separate license agreement you may have executed\r
+      with Licensor regarding such Contributions.\r
+\r
+   6. Trademarks. This License does not grant permission to use the trade\r
+      names, trademarks, service marks, or product names of the Licensor,\r
+      except as required for reasonable and customary use in describing the\r
+      origin of the Work and reproducing the content of the NOTICE file.\r
+\r
+   7. Disclaimer of Warranty. Unless required by applicable law or\r
+      agreed to in writing, Licensor provides the Work (and each\r
+      Contributor provides its Contributions) on an "AS IS" BASIS,\r
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or\r
+      implied, including, without limitation, any warranties or conditions\r
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A\r
+      PARTICULAR PURPOSE. You are solely responsible for determining the\r
+      appropriateness of using or redistributing the Work and assume any\r
+      risks associated with Your exercise of permissions under this License.\r
+\r
+   8. Limitation of Liability. In no event and under no legal theory,\r
+      whether in tort (including negligence), contract, or otherwise,\r
+      unless required by applicable law (such as deliberate and grossly\r
+      negligent acts) or agreed to in writing, shall any Contributor be\r
+      liable to You for damages, including any direct, indirect, special,\r
+      incidental, or consequential damages of any character arising as a\r
+      result of this License or out of the use or inability to use the\r
+      Work (including but not limited to damages for loss of goodwill,\r
+      work stoppage, computer failure or malfunction, or any and all\r
+      other commercial damages or losses), even if such Contributor\r
+      has been advised of the possibility of such damages.\r
+\r
+   9. Accepting Warranty or Additional Liability. While redistributing\r
+      the Work or Derivative Works thereof, You may choose to offer,\r
+      and charge a fee for, acceptance of support, warranty, indemnity,\r
+      or other liability obligations and/or rights consistent with this\r
+      License. However, in accepting such obligations, You may act only\r
+      on Your own behalf and on Your sole responsibility, not on behalf\r
+      of any other Contributor, and only if You agree to indemnify,\r
+      defend, and hold each Contributor harmless for any liability\r
+      incurred by, or claims asserted against, such Contributor by reason\r
+      of your accepting any such warranty or additional liability.\r
+\r
+   END OF TERMS AND CONDITIONS\r
+\r
+   APPENDIX: How to apply the Apache License to your work.\r
+\r
+      To apply the Apache License to your work, attach the following\r
+      boilerplate notice, with the fields enclosed by brackets "[]"\r
+      replaced with your own identifying information. (Don't include\r
+      the brackets!)  The text should be enclosed in the appropriate\r
+      comment syntax for the file format. We also recommend that a\r
+      file or class name and description of purpose be included on the\r
+      same "printed page" as the copyright notice for easier\r
+      identification within third-party archives.\r
+\r
+   Copyright [yyyy] [name of copyright owner]\r
+\r
+   Licensed under the Apache License, Version 2.0 (the "License");\r
+   you may not use this file except in compliance with the License.\r
+   You may obtain a copy of the License at\r
+\r
+       http://www.apache.org/licenses/LICENSE-2.0\r
+\r
+   Unless required by applicable law or agreed to in writing, software\r
+   distributed under the License is distributed on an "AS IS" BASIS,\r
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+   See the License for the specific language governing permissions and\r
+   limitations under the License.\r
+\r
+\r
+\r
diff --git a/NOTICE b/NOTICE
index f085dc6..235672e 100644 (file)
--- a/NOTICE
+++ b/NOTICE
@@ -1 +1,3 @@
-Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+Copyright (c) 2013 Samsung Electronics Co., Ltd. All rights reserved.\r
+Except as noted, this software is licensed under Apache License, Version 2.\r
+Please, see the LICENSE.APLv2 file for Apache License terms and conditions.\r
diff --git a/add-ons/dropins/EGit/features/org.eclipse.egit_2.3.1.201302201838-r/META-INF/ECLIPSE_.RSA b/add-ons/dropins/EGit/features/org.eclipse.egit_2.3.1.201302201838-r/META-INF/ECLIPSE_.RSA
new file mode 100644 (file)
index 0000000..68969eb
Binary files /dev/null and b/add-ons/dropins/EGit/features/org.eclipse.egit_2.3.1.201302201838-r/META-INF/ECLIPSE_.RSA differ
diff --git a/add-ons/dropins/EGit/features/org.eclipse.egit_2.3.1.201302201838-r/META-INF/ECLIPSE_.SF b/add-ons/dropins/EGit/features/org.eclipse.egit_2.3.1.201302201838-r/META-INF/ECLIPSE_.SF
new file mode 100644 (file)
index 0000000..c54021c
--- /dev/null
@@ -0,0 +1,27 @@
+Signature-Version: 1.0\r
+SHA1-Digest-Manifest: YvlqK5TJXcfXpcxfhPQFbcXgWsc=\r
+Created-By: 1.6.0 (IBM Corporation)\r
+SHA1-Digest-Manifest-Main-Attributes: ofgHCuMzh9XF5aPhQMIbNJsn5DA=\r
+\r
+Name: epl-v10.html\r
+SHA1-Digest: uDz8V2kxLlCqSde5IA9Y8doImhc=\r
+\r
+Name: META-INF/eclipse.inf\r
+SHA1-Digest: QdryQvJlVywlE0MGLuwYCkmkyWk=\r
+\r
+Name: META-INF/maven/org.eclipse.egit.feature/org.eclipse.egit/pom.xml\r
+SHA1-Digest: YhLAG1G6AWk5uDOt8Yfm5CxiedY=\r
+\r
+Name: META-INF/maven/org.eclipse.egit.feature/org.eclipse.egit/pom.pro\r
+ perties\r
+SHA1-Digest: UmxqVbTyD8zyDVyRX+nA28Z7jgY=\r
+\r
+Name: license.html\r
+SHA1-Digest: Rp9AnRyeUIxNWe10fjaMDkQB8rU=\r
+\r
+Name: feature.properties\r
+SHA1-Digest: BJZZd1YdAFv3D+fIxaUU/p/dgC0=\r
+\r
+Name: feature.xml\r
+SHA1-Digest: +wGNsDvV7mZ8x07SsLGHRWJvBo8=\r
+\r
diff --git a/add-ons/dropins/EGit/features/org.eclipse.egit_2.3.1.201302201838-r/META-INF/MANIFEST.MF b/add-ons/dropins/EGit/features/org.eclipse.egit_2.3.1.201302201838-r/META-INF/MANIFEST.MF
new file mode 100644 (file)
index 0000000..6065a62
--- /dev/null
@@ -0,0 +1,28 @@
+Manifest-Version: 1.0\r
+Build-Jdk: 1.6.0_21\r
+Built-By: hudsonbuild\r
+Archiver-Version: Plexus Archiver\r
+Created-By: Apache Maven\r
+\r
+Name: epl-v10.html\r
+SHA1-Digest: bx0mOF9dhyxxuvsPcbYVCs4pNz4=\r
+\r
+Name: META-INF/eclipse.inf\r
+SHA1-Digest: 09gN05tobgS/MdtqyTNQhOhB73M=\r
+\r
+Name: META-INF/maven/org.eclipse.egit.feature/org.eclipse.egit/pom.pro\r
+ perties\r
+SHA1-Digest: 1YCmS9JnW9uJOOpw8WU5mQ6gh/U=\r
+\r
+Name: META-INF/maven/org.eclipse.egit.feature/org.eclipse.egit/pom.xml\r
+SHA1-Digest: eA1aVjBjqfzThht2sXJJrkUzP0E=\r
+\r
+Name: license.html\r
+SHA1-Digest: /vLZjlHkZSXMSfPrWwNqOUDqqbM=\r
+\r
+Name: feature.properties\r
+SHA1-Digest: OLtCjrfkq2AFalciI4cyHT2RWsU=\r
+\r
+Name: feature.xml\r
+SHA1-Digest: 1RmjhwFR5ntkohYMtwGRg3pn544=\r
+\r
diff --git a/add-ons/dropins/EGit/features/org.eclipse.egit_2.3.1.201302201838-r/META-INF/eclipse.inf b/add-ons/dropins/EGit/features/org.eclipse.egit_2.3.1.201302201838-r/META-INF/eclipse.inf
new file mode 100644 (file)
index 0000000..92ffed2
--- /dev/null
@@ -0,0 +1,2 @@
+#Processed using Jarprocessor
+pack200.conditioned = true
diff --git a/add-ons/dropins/EGit/features/org.eclipse.egit_2.3.1.201302201838-r/META-INF/maven/org.eclipse.egit.feature/org.eclipse.egit/pom.properties b/add-ons/dropins/EGit/features/org.eclipse.egit_2.3.1.201302201838-r/META-INF/maven/org.eclipse.egit.feature/org.eclipse.egit/pom.properties
new file mode 100644 (file)
index 0000000..e86cfde
--- /dev/null
@@ -0,0 +1,5 @@
+#Generated by Maven
+#Wed Feb 20 19:55:57 EST 2013
+version=2.3.1.201302201838-r
+groupId=org.eclipse.egit.feature
+artifactId=org.eclipse.egit
diff --git a/add-ons/dropins/EGit/features/org.eclipse.egit_2.3.1.201302201838-r/META-INF/maven/org.eclipse.egit.feature/org.eclipse.egit/pom.xml b/add-ons/dropins/EGit/features/org.eclipse.egit_2.3.1.201302201838-r/META-INF/maven/org.eclipse.egit.feature/org.eclipse.egit/pom.xml
new file mode 100644 (file)
index 0000000..d7e6ab8
--- /dev/null
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+   Copyright (C) 2009, Igor Fedorenko <igor@ifedorenko.com>
+
+   All rights reserved. This program and the accompanying materials
+   are made available under the terms of the Eclipse Public License v1.0
+   which accompanies this distribution, and is available at
+   http://www.eclipse.org/legal/epl-v10.html
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <parent>
+    <groupId>org.eclipse.egit</groupId>
+    <artifactId>egit-parent</artifactId>
+    <version>2.3.1.201302201838-r</version>
+  </parent>
+
+  <groupId>org.eclipse.egit.feature</groupId>
+  <artifactId>org.eclipse.egit</artifactId>
+  <packaging>eclipse-feature</packaging>
+
+  <name>Eclipse EGit Feature</name>
+
+</project>
diff --git a/add-ons/dropins/EGit/features/org.eclipse.egit_2.3.1.201302201838-r/epl-v10.html b/add-ons/dropins/EGit/features/org.eclipse.egit_2.3.1.201302201838-r/epl-v10.html
new file mode 100644 (file)
index 0000000..6d5bbe8
--- /dev/null
@@ -0,0 +1,261 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
+<title>Eclipse Public License - Version 1.0</title>
+<style type="text/css">
+  body {
+    size: 8.5in 11.0in;
+    margin: 0.25in 0.5in 0.25in 0.5in;
+    tab-interval: 0.5in;
+    }
+  p {
+    margin-left: auto;
+    margin-top:  0.5em;
+    margin-bottom: 0.5em;
+    }
+  p.list {
+    margin-left: 0.5in;
+    margin-top:  0.05em;
+    margin-bottom: 0.05em;
+    }
+  </style>
+
+</head>
+
+<body lang="EN-US">
+
+<h2>Eclipse Public License - v 1.0</h2>
+
+<p>THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE
+PUBLIC LICENSE (&quot;AGREEMENT&quot;). ANY USE, REPRODUCTION OR
+DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS
+AGREEMENT.</p>
+
+<p><b>1. DEFINITIONS</b></p>
+
+<p>&quot;Contribution&quot; means:</p>
+
+<p class="list">a) in the case of the initial Contributor, the initial
+code and documentation distributed under this Agreement, and</p>
+<p class="list">b) in the case of each subsequent Contributor:</p>
+<p class="list">i) changes to the Program, and</p>
+<p class="list">ii) additions to the Program;</p>
+<p class="list">where such changes and/or additions to the Program
+originate from and are distributed by that particular Contributor. A
+Contribution 'originates' from a Contributor if it was added to the
+Program by such Contributor itself or anyone acting on such
+Contributor's behalf. Contributions do not include additions to the
+Program which: (i) are separate modules of software distributed in
+conjunction with the Program under their own license agreement, and (ii)
+are not derivative works of the Program.</p>
+
+<p>&quot;Contributor&quot; means any person or entity that distributes
+the Program.</p>
+
+<p>&quot;Licensed Patents&quot; mean patent claims licensable by a
+Contributor which are necessarily infringed by the use or sale of its
+Contribution alone or when combined with the Program.</p>
+
+<p>&quot;Program&quot; means the Contributions distributed in accordance
+with this Agreement.</p>
+
+<p>&quot;Recipient&quot; means anyone who receives the Program under
+this Agreement, including all Contributors.</p>
+
+<p><b>2. GRANT OF RIGHTS</b></p>
+
+<p class="list">a) Subject to the terms of this Agreement, each
+Contributor hereby grants Recipient a non-exclusive, worldwide,
+royalty-free copyright license to reproduce, prepare derivative works
+of, publicly display, publicly perform, distribute and sublicense the
+Contribution of such Contributor, if any, and such derivative works, in
+source code and object code form.</p>
+
+<p class="list">b) Subject to the terms of this Agreement, each
+Contributor hereby grants Recipient a non-exclusive, worldwide,
+royalty-free patent license under Licensed Patents to make, use, sell,
+offer to sell, import and otherwise transfer the Contribution of such
+Contributor, if any, in source code and object code form. This patent
+license shall apply to the combination of the Contribution and the
+Program if, at the time the Contribution is added by the Contributor,
+such addition of the Contribution causes such combination to be covered
+by the Licensed Patents. The patent license shall not apply to any other
+combinations which include the Contribution. No hardware per se is
+licensed hereunder.</p>
+
+<p class="list">c) Recipient understands that although each Contributor
+grants the licenses to its Contributions set forth herein, no assurances
+are provided by any Contributor that the Program does not infringe the
+patent or other intellectual property rights of any other entity. Each
+Contributor disclaims any liability to Recipient for claims brought by
+any other entity based on infringement of intellectual property rights
+or otherwise. As a condition to exercising the rights and licenses
+granted hereunder, each Recipient hereby assumes sole responsibility to
+secure any other intellectual property rights needed, if any. For
+example, if a third party patent license is required to allow Recipient
+to distribute the Program, it is Recipient's responsibility to acquire
+that license before distributing the Program.</p>
+
+<p class="list">d) Each Contributor represents that to its knowledge it
+has sufficient copyright rights in its Contribution, if any, to grant
+the copyright license set forth in this Agreement.</p>
+
+<p><b>3. REQUIREMENTS</b></p>
+
+<p>A Contributor may choose to distribute the Program in object code
+form under its own license agreement, provided that:</p>
+
+<p class="list">a) it complies with the terms and conditions of this
+Agreement; and</p>
+
+<p class="list">b) its license agreement:</p>
+
+<p class="list">i) effectively disclaims on behalf of all Contributors
+all warranties and conditions, express and implied, including warranties
+or conditions of title and non-infringement, and implied warranties or
+conditions of merchantability and fitness for a particular purpose;</p>
+
+<p class="list">ii) effectively excludes on behalf of all Contributors
+all liability for damages, including direct, indirect, special,
+incidental and consequential damages, such as lost profits;</p>
+
+<p class="list">iii) states that any provisions which differ from this
+Agreement are offered by that Contributor alone and not by any other
+party; and</p>
+
+<p class="list">iv) states that source code for the Program is available
+from such Contributor, and informs licensees how to obtain it in a
+reasonable manner on or through a medium customarily used for software
+exchange.</p>
+
+<p>When the Program is made available in source code form:</p>
+
+<p class="list">a) it must be made available under this Agreement; and</p>
+
+<p class="list">b) a copy of this Agreement must be included with each
+copy of the Program.</p>
+
+<p>Contributors may not remove or alter any copyright notices contained
+within the Program.</p>
+
+<p>Each Contributor must identify itself as the originator of its
+Contribution, if any, in a manner that reasonably allows subsequent
+Recipients to identify the originator of the Contribution.</p>
+
+<p><b>4. COMMERCIAL DISTRIBUTION</b></p>
+
+<p>Commercial distributors of software may accept certain
+responsibilities with respect to end users, business partners and the
+like. While this license is intended to facilitate the commercial use of
+the Program, the Contributor who includes the Program in a commercial
+product offering should do so in a manner which does not create
+potential liability for other Contributors. Therefore, if a Contributor
+includes the Program in a commercial product offering, such Contributor
+(&quot;Commercial Contributor&quot;) hereby agrees to defend and
+indemnify every other Contributor (&quot;Indemnified Contributor&quot;)
+against any losses, damages and costs (collectively &quot;Losses&quot;)
+arising from claims, lawsuits and other legal actions brought by a third
+party against the Indemnified Contributor to the extent caused by the
+acts or omissions of such Commercial Contributor in connection with its
+distribution of the Program in a commercial product offering. The
+obligations in this section do not apply to any claims or Losses
+relating to any actual or alleged intellectual property infringement. In
+order to qualify, an Indemnified Contributor must: a) promptly notify
+the Commercial Contributor in writing of such claim, and b) allow the
+Commercial Contributor to control, and cooperate with the Commercial
+Contributor in, the defense and any related settlement negotiations. The
+Indemnified Contributor may participate in any such claim at its own
+expense.</p>
+
+<p>For example, a Contributor might include the Program in a commercial
+product offering, Product X. That Contributor is then a Commercial
+Contributor. If that Commercial Contributor then makes performance
+claims, or offers warranties related to Product X, those performance
+claims and warranties are such Commercial Contributor's responsibility
+alone. Under this section, the Commercial Contributor would have to
+defend claims against the other Contributors related to those
+performance claims and warranties, and if a court requires any other
+Contributor to pay any damages as a result, the Commercial Contributor
+must pay those damages.</p>
+
+<p><b>5. NO WARRANTY</b></p>
+
+<p>EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS
+PROVIDED ON AN &quot;AS IS&quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS
+OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION,
+ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY
+OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely
+responsible for determining the appropriateness of using and
+distributing the Program and assumes all risks associated with its
+exercise of rights under this Agreement , including but not limited to
+the risks and costs of program errors, compliance with applicable laws,
+damage to or loss of data, programs or equipment, and unavailability or
+interruption of operations.</p>
+
+<p><b>6. DISCLAIMER OF LIABILITY</b></p>
+
+<p>EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT
+NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING
+WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR
+DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED
+HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.</p>
+
+<p><b>7. GENERAL</b></p>
+
+<p>If any provision of this Agreement is invalid or unenforceable under
+applicable law, it shall not affect the validity or enforceability of
+the remainder of the terms of this Agreement, and without further action
+by the parties hereto, such provision shall be reformed to the minimum
+extent necessary to make such provision valid and enforceable.</p>
+
+<p>If Recipient institutes patent litigation against any entity
+(including a cross-claim or counterclaim in a lawsuit) alleging that the
+Program itself (excluding combinations of the Program with other
+software or hardware) infringes such Recipient's patent(s), then such
+Recipient's rights granted under Section 2(b) shall terminate as of the
+date such litigation is filed.</p>
+
+<p>All Recipient's rights under this Agreement shall terminate if it
+fails to comply with any of the material terms or conditions of this
+Agreement and does not cure such failure in a reasonable period of time
+after becoming aware of such noncompliance. If all Recipient's rights
+under this Agreement terminate, Recipient agrees to cease use and
+distribution of the Program as soon as reasonably practicable. However,
+Recipient's obligations under this Agreement and any licenses granted by
+Recipient relating to the Program shall continue and survive.</p>
+
+<p>Everyone is permitted to copy and distribute copies of this
+Agreement, but in order to avoid inconsistency the Agreement is
+copyrighted and may only be modified in the following manner. The
+Agreement Steward reserves the right to publish new versions (including
+revisions) of this Agreement from time to time. No one other than the
+Agreement Steward has the right to modify this Agreement. The Eclipse
+Foundation is the initial Agreement Steward. The Eclipse Foundation may
+assign the responsibility to serve as the Agreement Steward to a
+suitable separate entity. Each new version of the Agreement will be
+given a distinguishing version number. The Program (including
+Contributions) may always be distributed subject to the version of the
+Agreement under which it was received. In addition, after a new version
+of the Agreement is published, Contributor may elect to distribute the
+Program (including its Contributions) under the new version. Except as
+expressly stated in Sections 2(a) and 2(b) above, Recipient receives no
+rights or licenses to the intellectual property of any Contributor under
+this Agreement, whether expressly, by implication, estoppel or
+otherwise. All rights in the Program not expressly granted under this
+Agreement are reserved.</p>
+
+<p>This Agreement is governed by the laws of the State of New York and
+the intellectual property laws of the United States of America. No party
+to this Agreement will bring a legal action under this Agreement more
+than one year after the cause of action arose. Each party waives its
+rights to a jury trial in any resulting litigation.</p>
+
+</body>
+
+</html>
diff --git a/add-ons/dropins/EGit/features/org.eclipse.egit_2.3.1.201302201838-r/feature.properties b/add-ons/dropins/EGit/features/org.eclipse.egit_2.3.1.201302201838-r/feature.properties
new file mode 100644 (file)
index 0000000..3d317fb
--- /dev/null
@@ -0,0 +1,159 @@
+###############################################################################
+# Copyright (c) 2000, 2010 IBM Corporation and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+###############################################################################
+
+featureName=Eclipse EGit
+providerName=Eclipse EGit
+
+updateSiteName=Eclipse EGit Update Site
+
+# description property - text of the "Feature Descrption"
+description=\
+An Eclipse Git Team provider in pure Java.\n
+################ end of description property ##################################
+
+# "copyright" property - text of the "Feature Update Copyright"
+copyright=\
+Copyright (c) 2005, 2009 Shawn Pearce, Robin Rosenberg, et.al.\n\
+All rights reserved. This program and the accompanying materials\n\
+are made available under the terms of the Eclipse Public License v1.0\n\
+which accompanies this distribution, and is available at\n\
+http://www.eclipse.org/legal/epl-v10.html\n
+################ end of copyright property ####################################
+
+# "licenseURL" property - URL of the "Feature License"
+# do not translate value - just change to point to a locale-specific HTML page
+licenseURL=license.html
+
+# "license" property - text of the "Feature Update License"
+# should be plain text version of license agreement pointed to be "licenseURL"
+license=\
+Eclipse Foundation Software User Agreement\n\
+February 1, 2011\n\
+\n\
+Usage Of Content\n\
+\n\
+THE ECLIPSE FOUNDATION MAKES AVAILABLE SOFTWARE, DOCUMENTATION, INFORMATION AND/OR\n\
+OTHER MATERIALS FOR OPEN SOURCE PROJECTS (COLLECTIVELY "CONTENT").\n\
+USE OF THE CONTENT IS GOVERNED BY THE TERMS AND CONDITIONS OF THIS\n\
+AGREEMENT AND/OR THE TERMS AND CONDITIONS OF LICENSE AGREEMENTS OR\n\
+NOTICES INDICATED OR REFERENCED BELOW.  BY USING THE CONTENT, YOU\n\
+AGREE THAT YOUR USE OF THE CONTENT IS GOVERNED BY THIS AGREEMENT\n\
+AND/OR THE TERMS AND CONDITIONS OF ANY APPLICABLE LICENSE AGREEMENTS\n\
+OR NOTICES INDICATED OR REFERENCED BELOW.  IF YOU DO NOT AGREE TO THE\n\
+TERMS AND CONDITIONS OF THIS AGREEMENT AND THE TERMS AND CONDITIONS\n\
+OF ANY APPLICABLE LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED\n\
+BELOW, THEN YOU MAY NOT USE THE CONTENT.\n\
+\n\
+Applicable Licenses\n\
+\n\
+Unless otherwise indicated, all Content made available by the\n\
+Eclipse Foundation is provided to you under the terms and conditions of\n\
+the Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is\n\
+provided with this Content and is also available at http://www.eclipse.org/legal/epl-v10.html.\n\
+For purposes of the EPL, "Program" will mean the Content.\n\
+\n\
+Content includes, but is not limited to, source code, object code,\n\
+documentation and other files maintained in the Eclipse Foundation source code\n\
+repository ("Repository") in software modules ("Modules") and made available\n\
+as downloadable archives ("Downloads").\n\
+\n\
+       - Content may be structured and packaged into modules to facilitate delivering,\n\
+         extending, and upgrading the Content. Typical modules may include plug-ins ("Plug-ins"),\n\
+         plug-in fragments ("Fragments"), and features ("Features").\n\
+       - Each Plug-in or Fragment may be packaged as a sub-directory or JAR (Java(TM) ARchive)\n\
+         in a directory named "plugins".\n\
+       - A Feature is a bundle of one or more Plug-ins and/or Fragments and associated material.\n\
+         Each Feature may be packaged as a sub-directory in a directory named "features".\n\
+         Within a Feature, files named "feature.xml" may contain a list of the names and version\n\
+         numbers of the Plug-ins and/or Fragments associated with that Feature.\n\
+       - Features may also include other Features ("Included Features"). Within a Feature, files\n\
+         named "feature.xml" may contain a list of the names and version numbers of Included Features.\n\
+\n\
+The terms and conditions governing Plug-ins and Fragments should be\n\
+contained in files named "about.html" ("Abouts"). The terms and\n\
+conditions governing Features and Included Features should be contained\n\
+in files named "license.html" ("Feature Licenses"). Abouts and Feature\n\
+Licenses may be located in any directory of a Download or Module\n\
+including, but not limited to the following locations:\n\
+\n\
+       - The top-level (root) directory\n\
+       - Plug-in and Fragment directories\n\
+       - Inside Plug-ins and Fragments packaged as JARs\n\
+       - Sub-directories of the directory named "src" of certain Plug-ins\n\
+       - Feature directories\n\
+\n\
+Note: if a Feature made available by the Eclipse Foundation is installed using the\n\
+Provisioning Technology (as defined below), you must agree to a license ("Feature \n\
+Update License") during the installation process. If the Feature contains\n\
+Included Features, the Feature Update License should either provide you\n\
+with the terms and conditions governing the Included Features or inform\n\
+you where you can locate them. Feature Update Licenses may be found in\n\
+the "license" property of files named "feature.properties" found within a Feature.\n\
+Such Abouts, Feature Licenses, and Feature Update Licenses contain the\n\
+terms and conditions (or references to such terms and conditions) that\n\
+govern your use of the associated Content in that directory.\n\
+\n\
+THE ABOUTS, FEATURE LICENSES, AND FEATURE UPDATE LICENSES MAY REFER\n\
+TO THE EPL OR OTHER LICENSE AGREEMENTS, NOTICES OR TERMS AND CONDITIONS.\n\
+SOME OF THESE OTHER LICENSE AGREEMENTS MAY INCLUDE (BUT ARE NOT LIMITED TO):\n\
+\n\
+       - Eclipse Distribution License Version 1.0 (available at http://www.eclipse.org/licenses/edl-v1.0.html)\n\
+       - Common Public License Version 1.0 (available at http://www.eclipse.org/legal/cpl-v10.html)\n\
+       - Apache Software License 1.1 (available at http://www.apache.org/licenses/LICENSE)\n\
+       - Apache Software License 2.0 (available at http://www.apache.org/licenses/LICENSE-2.0)\n\
+       - Metro Link Public License 1.00 (available at http://www.opengroup.org/openmotif/supporters/metrolink/license.html)\n\
+       - Mozilla Public License Version 1.1 (available at http://www.mozilla.org/MPL/MPL-1.1.html)\n\
+\n\
+IT IS YOUR OBLIGATION TO READ AND ACCEPT ALL SUCH TERMS AND CONDITIONS PRIOR\n\
+TO USE OF THE CONTENT. If no About, Feature License, or Feature Update License\n\
+is provided, please contact the Eclipse Foundation to determine what terms and conditions\n\
+govern that particular Content.\n\
+\n\
+\n\Use of Provisioning Technology\n\
+\n\
+The Eclipse Foundation makes available provisioning software, examples of which include,\n\
+but are not limited to, p2 and the Eclipse Update Manager ("Provisioning Technology") for\n\
+the purpose of allowing users to install software, documentation, information and/or\n\
+other materials (collectively "Installable Software"). This capability is provided with\n\
+the intent of allowing such users to install, extend and update Eclipse-based products.\n\
+Information about packaging Installable Software is available at\n\
+http://eclipse.org/equinox/p2/repository_packaging.html ("Specification").\n\
+\n\
+You may use Provisioning Technology to allow other parties to install Installable Software.\n\
+You shall be responsible for enabling the applicable license agreements relating to the\n\
+Installable Software to be presented to, and accepted by, the users of the Provisioning Technology\n\
+in accordance with the Specification. By using Provisioning Technology in such a manner and\n\
+making it available in accordance with the Specification, you further acknowledge your\n\
+agreement to, and the acquisition of all necessary rights to permit the following:\n\
+\n\
+       1. A series of actions may occur ("Provisioning Process") in which a user may execute\n\
+          the Provisioning Technology on a machine ("Target Machine") with the intent of installing,\n\
+          extending or updating the functionality of an Eclipse-based product.\n\
+       2. During the Provisioning Process, the Provisioning Technology may cause third party\n\
+          Installable Software or a portion thereof to be accessed and copied to the Target Machine.\n\
+       3. Pursuant to the Specification, you will provide to the user the terms and conditions that\n\
+          govern the use of the Installable Software ("Installable Software Agreement") and such\n\
+          Installable Software Agreement shall be accessed from the Target Machine in accordance\n\
+          with the Specification. Such Installable Software Agreement must inform the user of the\n\
+          terms and conditions that govern the Installable Software and must solicit acceptance by\n\
+          the end user in the manner prescribed in such Installable Software Agreement. Upon such\n\
+          indication of agreement by the user, the provisioning Technology will complete installation\n\
+          of the Installable Software.\n\
+\n\
+Cryptography\n\
+\n\
+Content may contain encryption software. The country in which you are\n\
+currently may have restrictions on the import, possession, and use,\n\
+and/or re-export to another country, of encryption software. BEFORE\n\
+using any encryption software, please check the country's laws,\n\
+regulations and policies concerning the import, possession, or use, and\n\
+re-export of encryption software, to see if this is permitted.\n\
+\n\
+Java and all Java-based trademarks are trademarks of Oracle Corporation in the United States, other countries, or both.\n
+########### end of license property ##########################################
+
diff --git a/add-ons/dropins/EGit/features/org.eclipse.egit_2.3.1.201302201838-r/feature.xml b/add-ons/dropins/EGit/features/org.eclipse.egit_2.3.1.201302201838-r/feature.xml
new file mode 100644 (file)
index 0000000..e340ba5
--- /dev/null
@@ -0,0 +1,71 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<feature
+      id="org.eclipse.egit"
+      label="%featureName"
+      version="2.3.1.201302201838-r"
+      provider-name="%providerName"
+      plugin="org.eclipse.egit">
+
+   <description url="http://www.eclipse.org/egit/">
+     %description
+   </description>
+
+   <copyright>
+     %copyright
+   </copyright>
+
+   <license url="%licenseURL">
+     %license
+   </license>
+
+   <url>
+      <update label="%updateSiteName" url="http://download.eclipse.org/egit/updates"/>
+      <discovery label="%updateSiteName" url="http://download.eclipse.org/egit/updates"/>
+   </url>
+
+   <requires>
+      <import plugin="org.eclipse.core.runtime" version="3.7" match="compatible"/>
+      <import plugin="org.eclipse.core.resources" version="3.4.0" match="compatible"/>
+      <import plugin="org.eclipse.core.filesystem" version="1.1.0" match="compatible"/>
+      <import plugin="org.eclipse.ui" version="3.4.0" match="compatible"/>
+      <import plugin="org.eclipse.team.ui" version="3.4.0" match="compatible"/>
+      <import plugin="org.eclipse.jface.text" version="3.4.0" match="compatible"/>
+      <import plugin="org.eclipse.ui.ide" version="3.4.0" match="compatible"/>
+      <import plugin="org.eclipse.ui.workbench.texteditor" version="3.4.0" match="compatible"/>
+      <import plugin="org.eclipse.compare" version="3.4.0" match="compatible"/>
+      <import plugin="org.eclipse.core.net" version="1.1.0" match="compatible"/>
+      <import plugin="org.eclipse.team.core" version="3.4.0" match="compatible"/>
+      <import plugin="org.eclipse.jsch.ui" version="1.1.100" match="compatible"/>
+      <import plugin="org.eclipse.jsch.core" version="1.1.100" match="compatible"/>
+      <import plugin="com.jcraft.jsch" version="0.1.37" match="compatible"/>
+      <import feature="org.eclipse.jgit" version="2.3.1" match="equivalent"/>
+   </requires>
+
+   <plugin
+         id="org.eclipse.egit.core"
+         download-size="312"
+         install-size="657"
+         version="2.3.1.201302201838-r"
+         unpack="false"/>
+
+   <plugin
+         id="org.eclipse.egit.ui"
+         download-size="2195"
+         install-size="4643"
+         version="2.3.1.201302201838-r"
+         unpack="false"/>
+
+   <plugin
+         id="org.eclipse.egit"
+         download-size="5"
+         install-size="5"
+         version="2.3.1.201302201838-r"
+         unpack="false"/>
+
+   <plugin
+         id="org.eclipse.egit.doc"
+         download-size="3030"
+         install-size="3293"
+         version="2.3.1.201302201838-r"
+         unpack="false"/>
+</feature>
diff --git a/add-ons/dropins/EGit/features/org.eclipse.egit_2.3.1.201302201838-r/license.html b/add-ons/dropins/EGit/features/org.eclipse.egit_2.3.1.201302201838-r/license.html
new file mode 100644 (file)
index 0000000..f19c483
--- /dev/null
@@ -0,0 +1,108 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
+<title>Eclipse Foundation Software User Agreement</title>
+</head>
+
+<body lang="EN-US">
+<h2>Eclipse Foundation Software User Agreement</h2>
+<p>February 1, 2011</p>
+
+<h3>Usage Of Content</h3>
+
+<p>THE ECLIPSE FOUNDATION MAKES AVAILABLE SOFTWARE, DOCUMENTATION, INFORMATION AND/OR OTHER MATERIALS FOR OPEN SOURCE PROJECTS
+   (COLLECTIVELY &quot;CONTENT&quot;).  USE OF THE CONTENT IS GOVERNED BY THE TERMS AND CONDITIONS OF THIS AGREEMENT AND/OR THE TERMS AND
+   CONDITIONS OF LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED BELOW.  BY USING THE CONTENT, YOU AGREE THAT YOUR USE
+   OF THE CONTENT IS GOVERNED BY THIS AGREEMENT AND/OR THE TERMS AND CONDITIONS OF ANY APPLICABLE LICENSE AGREEMENTS OR
+   NOTICES INDICATED OR REFERENCED BELOW.  IF YOU DO NOT AGREE TO THE TERMS AND CONDITIONS OF THIS AGREEMENT AND THE TERMS AND
+   CONDITIONS OF ANY APPLICABLE LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED BELOW, THEN YOU MAY NOT USE THE CONTENT.</p>
+
+<h3>Applicable Licenses</h3>
+
+<p>Unless otherwise indicated, all Content made available by the Eclipse Foundation is provided to you under the terms and conditions of the Eclipse Public License Version 1.0
+   (&quot;EPL&quot;).  A copy of the EPL is provided with this Content and is also available at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
+   For purposes of the EPL, &quot;Program&quot; will mean the Content.</p>
+
+<p>Content includes, but is not limited to, source code, object code, documentation and other files maintained in the Eclipse Foundation source code
+   repository (&quot;Repository&quot;) in software modules (&quot;Modules&quot;) and made available as downloadable archives (&quot;Downloads&quot;).</p>
+
+<ul>
+       <li>Content may be structured and packaged into modules to facilitate delivering, extending, and upgrading the Content.  Typical modules may include plug-ins (&quot;Plug-ins&quot;), plug-in fragments (&quot;Fragments&quot;), and features (&quot;Features&quot;).</li>
+       <li>Each Plug-in or Fragment may be packaged as a sub-directory or JAR (Java&trade; ARchive) in a directory named &quot;plugins&quot;.</li>
+       <li>A Feature is a bundle of one or more Plug-ins and/or Fragments and associated material.  Each Feature may be packaged as a sub-directory in a directory named &quot;features&quot;.  Within a Feature, files named &quot;feature.xml&quot; may contain a list of the names and version numbers of the Plug-ins
+      and/or Fragments associated with that Feature.</li>
+       <li>Features may also include other Features (&quot;Included Features&quot;). Within a Feature, files named &quot;feature.xml&quot; may contain a list of the names and version numbers of Included Features.</li>
+</ul>
+
+<p>The terms and conditions governing Plug-ins and Fragments should be contained in files named &quot;about.html&quot; (&quot;Abouts&quot;). The terms and conditions governing Features and
+Included Features should be contained in files named &quot;license.html&quot; (&quot;Feature Licenses&quot;).  Abouts and Feature Licenses may be located in any directory of a Download or Module
+including, but not limited to the following locations:</p>
+
+<ul>
+       <li>The top-level (root) directory</li>
+       <li>Plug-in and Fragment directories</li>
+       <li>Inside Plug-ins and Fragments packaged as JARs</li>
+       <li>Sub-directories of the directory named &quot;src&quot; of certain Plug-ins</li>
+       <li>Feature directories</li>
+</ul>
+
+<p>Note: if a Feature made available by the Eclipse Foundation is installed using the Provisioning Technology (as defined below), you must agree to a license (&quot;Feature Update License&quot;) during the
+installation process.  If the Feature contains Included Features, the Feature Update License should either provide you with the terms and conditions governing the Included Features or
+inform you where you can locate them.  Feature Update Licenses may be found in the &quot;license&quot; property of files named &quot;feature.properties&quot; found within a Feature.
+Such Abouts, Feature Licenses, and Feature Update Licenses contain the terms and conditions (or references to such terms and conditions) that govern your use of the associated Content in
+that directory.</p>
+
+<p>THE ABOUTS, FEATURE LICENSES, AND FEATURE UPDATE LICENSES MAY REFER TO THE EPL OR OTHER LICENSE AGREEMENTS, NOTICES OR TERMS AND CONDITIONS.  SOME OF THESE
+OTHER LICENSE AGREEMENTS MAY INCLUDE (BUT ARE NOT LIMITED TO):</p>
+
+<ul>
+       <li>Eclipse Distribution License Version 1.0 (available at <a href="http://www.eclipse.org/licenses/edl-v10.html">http://www.eclipse.org/licenses/edl-v1.0.html</a>)</li>
+       <li>Common Public License Version 1.0 (available at <a href="http://www.eclipse.org/legal/cpl-v10.html">http://www.eclipse.org/legal/cpl-v10.html</a>)</li>
+       <li>Apache Software License 1.1 (available at <a href="http://www.apache.org/licenses/LICENSE">http://www.apache.org/licenses/LICENSE</a>)</li>
+       <li>Apache Software License 2.0 (available at <a href="http://www.apache.org/licenses/LICENSE-2.0">http://www.apache.org/licenses/LICENSE-2.0</a>)</li>
+       <li>Metro Link Public License 1.00 (available at <a href="http://www.opengroup.org/openmotif/supporters/metrolink/license.html">http://www.opengroup.org/openmotif/supporters/metrolink/license.html</a>)</li>
+       <li>Mozilla Public License Version 1.1 (available at <a href="http://www.mozilla.org/MPL/MPL-1.1.html">http://www.mozilla.org/MPL/MPL-1.1.html</a>)</li>
+</ul>
+
+<p>IT IS YOUR OBLIGATION TO READ AND ACCEPT ALL SUCH TERMS AND CONDITIONS PRIOR TO USE OF THE CONTENT.  If no About, Feature License, or Feature Update License is provided, please
+contact the Eclipse Foundation to determine what terms and conditions govern that particular Content.</p>
+
+
+<h3>Use of Provisioning Technology</h3>
+
+<p>The Eclipse Foundation makes available provisioning software, examples of which include, but are not limited to, p2 and the Eclipse
+   Update Manager (&quot;Provisioning Technology&quot;) for the purpose of allowing users to install software, documentation, information and/or
+   other materials (collectively &quot;Installable Software&quot;). This capability is provided with the intent of allowing such users to
+   install, extend and update Eclipse-based products. Information about packaging Installable Software is available at <a
+       href="http://eclipse.org/equinox/p2/repository_packaging.html">http://eclipse.org/equinox/p2/repository_packaging.html</a>
+   (&quot;Specification&quot;).</p>
+
+<p>You may use Provisioning Technology to allow other parties to install Installable Software. You shall be responsible for enabling the
+   applicable license agreements relating to the Installable Software to be presented to, and accepted by, the users of the Provisioning Technology
+   in accordance with the Specification. By using Provisioning Technology in such a manner and making it available in accordance with the
+   Specification, you further acknowledge your agreement to, and the acquisition of all necessary rights to permit the following:</p>
+
+<ol>
+       <li>A series of actions may occur (&quot;Provisioning Process&quot;) in which a user may execute the Provisioning Technology
+       on a machine (&quot;Target Machine&quot;) with the intent of installing, extending or updating the functionality of an Eclipse-based
+       product.</li>
+       <li>During the Provisioning Process, the Provisioning Technology may cause third party Installable Software or a portion thereof to be
+       accessed and copied to the Target Machine.</li>
+       <li>Pursuant to the Specification, you will provide to the user the terms and conditions that govern the use of the Installable
+       Software (&quot;Installable Software Agreement&quot;) and such Installable Software Agreement shall be accessed from the Target
+       Machine in accordance with the Specification. Such Installable Software Agreement must inform the user of the terms and conditions that govern
+       the Installable Software and must solicit acceptance by the end user in the manner prescribed in such Installable Software Agreement. Upon such
+       indication of agreement by the user, the provisioning Technology will complete installation of the Installable Software.</li>
+</ol>
+
+<h3>Cryptography</h3>
+
+<p>Content may contain encryption software. The country in which you are currently may have restrictions on the import, possession, and use, and/or re-export to
+   another country, of encryption software. BEFORE using any encryption software, please check the country's laws, regulations and policies concerning the import,
+   possession, or use, and re-export of encryption software, to see if this is permitted.</p>
+
+<p><small>Java and all Java-based trademarks are trademarks of Oracle Corporation in the United States, other countries, or both.</small></p>
+</body>
+</html>
diff --git a/add-ons/dropins/EGit/features/org.eclipse.jgit_2.3.1.201302201838-r/META-INF/ECLIPSE_.RSA b/add-ons/dropins/EGit/features/org.eclipse.jgit_2.3.1.201302201838-r/META-INF/ECLIPSE_.RSA
new file mode 100644 (file)
index 0000000..4b6363a
Binary files /dev/null and b/add-ons/dropins/EGit/features/org.eclipse.jgit_2.3.1.201302201838-r/META-INF/ECLIPSE_.RSA differ
diff --git a/add-ons/dropins/EGit/features/org.eclipse.jgit_2.3.1.201302201838-r/META-INF/ECLIPSE_.SF b/add-ons/dropins/EGit/features/org.eclipse.jgit_2.3.1.201302201838-r/META-INF/ECLIPSE_.SF
new file mode 100644 (file)
index 0000000..24cb0a3
--- /dev/null
@@ -0,0 +1,27 @@
+Signature-Version: 1.0\r
+SHA1-Digest-Manifest: Jg9DsXlMBRwrOZjXB+RyoLwEvcU=\r
+Created-By: 1.6.0 (IBM Corporation)\r
+SHA1-Digest-Manifest-Main-Attributes: ofgHCuMzh9XF5aPhQMIbNJsn5DA=\r
+\r
+Name: edl-v10.html\r
+SHA1-Digest: sEcge6qpnHmO4EjAOv/JTq0L/dg=\r
+\r
+Name: META-INF/eclipse.inf\r
+SHA1-Digest: QdryQvJlVywlE0MGLuwYCkmkyWk=\r
+\r
+Name: META-INF/maven/org.eclipse.jgit.feature/org.eclipse.jgit/pom.xml\r
+SHA1-Digest: 9UsNgMqATomih4usshOippE22BM=\r
+\r
+Name: META-INF/maven/org.eclipse.jgit.feature/org.eclipse.jgit/pom.pro\r
+ perties\r
+SHA1-Digest: LReJrV6e3QGwWLmQrbHgJZtrwG8=\r
+\r
+Name: license.html\r
+SHA1-Digest: Rp9AnRyeUIxNWe10fjaMDkQB8rU=\r
+\r
+Name: feature.properties\r
+SHA1-Digest: 3w7MvZELUVqxSTWR6JPtLMOsUHg=\r
+\r
+Name: feature.xml\r
+SHA1-Digest: hUCtaoGrHVk5ThSfCfSZMBJAC94=\r
+\r
diff --git a/add-ons/dropins/EGit/features/org.eclipse.jgit_2.3.1.201302201838-r/META-INF/MANIFEST.MF b/add-ons/dropins/EGit/features/org.eclipse.jgit_2.3.1.201302201838-r/META-INF/MANIFEST.MF
new file mode 100644 (file)
index 0000000..44e7ff5
--- /dev/null
@@ -0,0 +1,28 @@
+Manifest-Version: 1.0\r
+Build-Jdk: 1.6.0_21\r
+Built-By: hudsonbuild\r
+Archiver-Version: Plexus Archiver\r
+Created-By: Apache Maven\r
+\r
+Name: META-INF/eclipse.inf\r
+SHA1-Digest: 09gN05tobgS/MdtqyTNQhOhB73M=\r
+\r
+Name: edl-v10.html\r
+SHA1-Digest: /Ofgzk+HfH3lV4dQ6x65yE/YtRQ=\r
+\r
+Name: META-INF/maven/org.eclipse.jgit.feature/org.eclipse.jgit/pom.pro\r
+ perties\r
+SHA1-Digest: QjUrEpguIvSmsCuKIV//6CiasHI=\r
+\r
+Name: META-INF/maven/org.eclipse.jgit.feature/org.eclipse.jgit/pom.xml\r
+SHA1-Digest: j2khB008CNCwKfgX2fVpS5L2GBo=\r
+\r
+Name: license.html\r
+SHA1-Digest: /vLZjlHkZSXMSfPrWwNqOUDqqbM=\r
+\r
+Name: feature.properties\r
+SHA1-Digest: HxGN3Zzxhs7x9MWBpZ7leqTMXXw=\r
+\r
+Name: feature.xml\r
+SHA1-Digest: 5SR7rYhzKI8443pCJ+H8Cc/CGuI=\r
+\r
diff --git a/add-ons/dropins/EGit/features/org.eclipse.jgit_2.3.1.201302201838-r/META-INF/eclipse.inf b/add-ons/dropins/EGit/features/org.eclipse.jgit_2.3.1.201302201838-r/META-INF/eclipse.inf
new file mode 100644 (file)
index 0000000..92ffed2
--- /dev/null
@@ -0,0 +1,2 @@
+#Processed using Jarprocessor
+pack200.conditioned = true
diff --git a/add-ons/dropins/EGit/features/org.eclipse.jgit_2.3.1.201302201838-r/META-INF/maven/org.eclipse.jgit.feature/org.eclipse.jgit/pom.properties b/add-ons/dropins/EGit/features/org.eclipse.jgit_2.3.1.201302201838-r/META-INF/maven/org.eclipse.jgit.feature/org.eclipse.jgit/pom.properties
new file mode 100644 (file)
index 0000000..7b4d1b4
--- /dev/null
@@ -0,0 +1,5 @@
+#Generated by Maven
+#Wed Feb 20 19:45:36 EST 2013
+version=2.3.1.201302201838-r
+groupId=org.eclipse.jgit.feature
+artifactId=org.eclipse.jgit
diff --git a/add-ons/dropins/EGit/features/org.eclipse.jgit_2.3.1.201302201838-r/META-INF/maven/org.eclipse.jgit.feature/org.eclipse.jgit/pom.xml b/add-ons/dropins/EGit/features/org.eclipse.jgit_2.3.1.201302201838-r/META-INF/maven/org.eclipse.jgit.feature/org.eclipse.jgit/pom.xml
new file mode 100644 (file)
index 0000000..53bf31b
--- /dev/null
@@ -0,0 +1,70 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+   Copyright (C) 2009-2012, Matthias Sohn <matthias.sohn@sap.com>
+   and other copyright owners as documented in the project's IP log.
+
+   This program and the accompanying materials are made available
+   under the terms of the Eclipse Distribution License v1.0 which
+   accompanies this distribution, is reproduced below, and is
+   available at http://www.eclipse.org/org/documents/edl-v10.php
+
+   All rights reserved.
+
+   Redistribution and use in source and binary forms, with or
+   without modification, are permitted provided that the following
+   conditions are met:
+
+   - Redistributions of source code must retain the above copyright
+     notice, this list of conditions and the following disclaimer.
+
+   - Redistributions in binary form must reproduce the above
+     copyright notice, this list of conditions and the following
+     disclaimer in the documentation and/or other materials provided
+     with the distribution.
+
+   - Neither the name of the Eclipse Foundation, Inc. nor the
+     names of its contributors may be used to endorse or promote
+     products derived from this software without specific prior
+     written permission.
+
+   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+   CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+   INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+   OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+   ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+   CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+   NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+   LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+   CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+   STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+   ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+   ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <parent>
+    <groupId>org.eclipse.jgit</groupId>
+    <artifactId>jgit.tycho.parent</artifactId>
+    <version>2.3.1.201302201838-r</version>
+  </parent>
+
+  <groupId>org.eclipse.jgit.feature</groupId>
+  <artifactId>org.eclipse.jgit</artifactId>
+  <packaging>eclipse-feature</packaging>
+
+  <name>JGit Feature</name>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.eclipse.jgit</groupId>
+      <artifactId>org.eclipse.jgit</artifactId>
+      <version>2.3.1.201302201838-r</version>
+    </dependency>
+  </dependencies>
+
+</project>
diff --git a/add-ons/dropins/EGit/features/org.eclipse.jgit_2.3.1.201302201838-r/edl-v10.html b/add-ons/dropins/EGit/features/org.eclipse.jgit_2.3.1.201302201838-r/edl-v10.html
new file mode 100644 (file)
index 0000000..01a2671
--- /dev/null
@@ -0,0 +1,59 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
+<title>Eclipse Distribution License - Version 1.0</title>
+<style type="text/css">
+  body {
+    size: 8.5in 11.0in;
+    margin: 0.25in 0.5in 0.25in 0.5in;
+    tab-interval: 0.5in;
+    }
+  p {          
+    margin-left: auto;
+    margin-top:  0.5em;
+    margin-bottom: 0.5em;
+    }
+  p.list {
+       margin-left: 0.5in;
+    margin-top:  0.05em;
+    margin-bottom: 0.05em;
+    }
+  </style>
+
+</head>
+
+<body lang="EN-US">
+
+<p><b>Eclipse Distribution License - v 1.0</b></p>
+
+<p>Copyright (c) 2007, Eclipse Foundation, Inc. and its licensors. </p>
+
+<p>All rights reserved.</p>
+<p>Redistribution and use in source and binary forms, with or without modification, 
+       are permitted provided that the following conditions are met:
+<ul><li>Redistributions of source code must retain the above copyright notice, 
+       this list of conditions and the following disclaimer. </li>
+<li>Redistributions in binary form must reproduce the above copyright notice, 
+       this list of conditions and the following disclaimer in the documentation 
+       and/or other materials provided with the distribution. </li>
+<li>Neither the name of the Eclipse Foundation, Inc. nor the names of its 
+       contributors may be used to endorse or promote products derived from 
+       this software without specific prior written permission. </li></ul>
+</p>
+<p>THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
+IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
+POSSIBILITY OF SUCH DAMAGE.</p>
+
+</body>
+
+</html>
diff --git a/add-ons/dropins/EGit/features/org.eclipse.jgit_2.3.1.201302201838-r/feature.properties b/add-ons/dropins/EGit/features/org.eclipse.jgit_2.3.1.201302201838-r/feature.properties
new file mode 100644 (file)
index 0000000..442a76e
--- /dev/null
@@ -0,0 +1,160 @@
+###############################################################################
+# Copyright (c) 2000, 2010 IBM Corporation and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+###############################################################################
+
+featureName=Eclipse JGit
+providerName=Eclipse JGit
+
+updateSiteName=Eclipse JGit Update Site
+
+# description property - text of the "Feature Description"
+description=\
+A pure Java implementation of the Git version control system.\n
+################ end of description property ##################################
+
+# "copyright" property - text of the "Feature Update Copyright"
+copyright=\
+Copyright (c) 2005, 2010 Shawn Pearce, Robin Rosenberg, et.al.\n\
+All rights reserved. This program and the accompanying materials\n\
+are made available under the terms of the Eclipse Distribution License v1.0\n\
+which accompanies this distribution, and is available at\n\
+http://www.eclipse.org/org/documents/edl-v10.html\n
+################ end of copyright property ####################################
+
+# "licenseURL" property - URL of the "Feature License"
+# do not translate value - just change to point to a locale-specific HTML page
+licenseURL=license.html
+
+# "license" property - text of the "Feature Update License"
+# should be plain text version of license agreement pointed to be "licenseURL"
+license=\
+Eclipse Foundation Software User Agreement\n\
+February 1, 2011\n\
+\n\
+Usage Of Content\n\
+\n\
+THE ECLIPSE FOUNDATION MAKES AVAILABLE SOFTWARE, DOCUMENTATION, INFORMATION AND/OR\n\
+OTHER MATERIALS FOR OPEN SOURCE PROJECTS (COLLECTIVELY "CONTENT").\n\
+USE OF THE CONTENT IS GOVERNED BY THE TERMS AND CONDITIONS OF THIS\n\
+AGREEMENT AND/OR THE TERMS AND CONDITIONS OF LICENSE AGREEMENTS OR\n\
+NOTICES INDICATED OR REFERENCED BELOW.  BY USING THE CONTENT, YOU\n\
+AGREE THAT YOUR USE OF THE CONTENT IS GOVERNED BY THIS AGREEMENT\n\
+AND/OR THE TERMS AND CONDITIONS OF ANY APPLICABLE LICENSE AGREEMENTS\n\
+OR NOTICES INDICATED OR REFERENCED BELOW.  IF YOU DO NOT AGREE TO THE\n\
+TERMS AND CONDITIONS OF THIS AGREEMENT AND THE TERMS AND CONDITIONS\n\
+OF ANY APPLICABLE LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED\n\
+BELOW, THEN YOU MAY NOT USE THE CONTENT.\n\
+\n\
+Applicable Licenses\n\
+\n\
+Unless otherwise indicated, all Content made available by the\n\
+Eclipse Foundation is provided to you under the terms and conditions of\n\
+the Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is\n\
+provided with this Content and is also available at http://www.eclipse.org/legal/epl-v10.html.\n\
+For purposes of the EPL, "Program" will mean the Content.\n\
+\n\
+Content includes, but is not limited to, source code, object code,\n\
+documentation and other files maintained in the Eclipse Foundation source code\n\
+repository ("Repository") in software modules ("Modules") and made available\n\
+as downloadable archives ("Downloads").\n\
+\n\
+       - Content may be structured and packaged into modules to facilitate delivering,\n\
+         extending, and upgrading the Content. Typical modules may include plug-ins ("Plug-ins"),\n\
+         plug-in fragments ("Fragments"), and features ("Features").\n\
+       - Each Plug-in or Fragment may be packaged as a sub-directory or JAR (Java(TM) ARchive)\n\
+         in a directory named "plugins".\n\
+       - A Feature is a bundle of one or more Plug-ins and/or Fragments and associated material.\n\
+         Each Feature may be packaged as a sub-directory in a directory named "features".\n\
+         Within a Feature, files named "feature.xml" may contain a list of the names and version\n\
+         numbers of the Plug-ins and/or Fragments associated with that Feature.\n\
+       - Features may also include other Features ("Included Features"). Within a Feature, files\n\
+         named "feature.xml" may contain a list of the names and version numbers of Included Features.\n\
+\n\
+The terms and conditions governing Plug-ins and Fragments should be\n\
+contained in files named "about.html" ("Abouts"). The terms and\n\
+conditions governing Features and Included Features should be contained\n\
+in files named "license.html" ("Feature Licenses"). Abouts and Feature\n\
+Licenses may be located in any directory of a Download or Module\n\
+including, but not limited to the following locations:\n\
+\n\
+       - The top-level (root) directory\n\
+       - Plug-in and Fragment directories\n\
+       - Inside Plug-ins and Fragments packaged as JARs\n\
+       - Sub-directories of the directory named "src" of certain Plug-ins\n\
+       - Feature directories\n\
+\n\
+Note: if a Feature made available by the Eclipse Foundation is installed using the\n\
+Provisioning Technology (as defined below), you must agree to a license ("Feature \n\
+Update License") during the installation process. If the Feature contains\n\
+Included Features, the Feature Update License should either provide you\n\
+with the terms and conditions governing the Included Features or inform\n\
+you where you can locate them. Feature Update Licenses may be found in\n\
+the "license" property of files named "feature.properties" found within a Feature.\n\
+Such Abouts, Feature Licenses, and Feature Update Licenses contain the\n\
+terms and conditions (or references to such terms and conditions) that\n\
+govern your use of the associated Content in that directory.\n\
+\n\
+THE ABOUTS, FEATURE LICENSES, AND FEATURE UPDATE LICENSES MAY REFER\n\
+TO THE EPL OR OTHER LICENSE AGREEMENTS, NOTICES OR TERMS AND CONDITIONS.\n\
+SOME OF THESE OTHER LICENSE AGREEMENTS MAY INCLUDE (BUT ARE NOT LIMITED TO):\n\
+\n\
+       - Eclipse Distribution License Version 1.0 (available at http://www.eclipse.org/licenses/edl-v1.0.html)\n\
+       - Common Public License Version 1.0 (available at http://www.eclipse.org/legal/cpl-v10.html)\n\
+       - Apache Software License 1.1 (available at http://www.apache.org/licenses/LICENSE)\n\
+       - Apache Software License 2.0 (available at http://www.apache.org/licenses/LICENSE-2.0)\n\
+       - Metro Link Public License 1.00 (available at http://www.opengroup.org/openmotif/supporters/metrolink/license.html)\n\
+       - Mozilla Public License Version 1.1 (available at http://www.mozilla.org/MPL/MPL-1.1.html)\n\
+\n\
+IT IS YOUR OBLIGATION TO READ AND ACCEPT ALL SUCH TERMS AND CONDITIONS PRIOR\n\
+TO USE OF THE CONTENT. If no About, Feature License, or Feature Update License\n\
+is provided, please contact the Eclipse Foundation to determine what terms and conditions\n\
+govern that particular Content.\n\
+\n\
+\n\Use of Provisioning Technology\n\
+\n\
+The Eclipse Foundation makes available provisioning software, examples of which include,\n\
+but are not limited to, p2 and the Eclipse Update Manager ("Provisioning Technology") for\n\
+the purpose of allowing users to install software, documentation, information and/or\n\
+other materials (collectively "Installable Software"). This capability is provided with\n\
+the intent of allowing such users to install, extend and update Eclipse-based products.\n\
+Information about packaging Installable Software is available at\n\
+http://eclipse.org/equinox/p2/repository_packaging.html ("Specification").\n\
+\n\
+You may use Provisioning Technology to allow other parties to install Installable Software.\n\
+You shall be responsible for enabling the applicable license agreements relating to the\n\
+Installable Software to be presented to, and accepted by, the users of the Provisioning Technology\n\
+in accordance with the Specification. By using Provisioning Technology in such a manner and\n\
+making it available in accordance with the Specification, you further acknowledge your\n\
+agreement to, and the acquisition of all necessary rights to permit the following:\n\
+\n\
+       1. A series of actions may occur ("Provisioning Process") in which a user may execute\n\
+          the Provisioning Technology on a machine ("Target Machine") with the intent of installing,\n\
+          extending or updating the functionality of an Eclipse-based product.\n\
+       2. During the Provisioning Process, the Provisioning Technology may cause third party\n\
+          Installable Software or a portion thereof to be accessed and copied to the Target Machine.\n\
+       3. Pursuant to the Specification, you will provide to the user the terms and conditions that\n\
+          govern the use of the Installable Software ("Installable Software Agreement") and such\n\
+          Installable Software Agreement shall be accessed from the Target Machine in accordance\n\
+          with the Specification. Such Installable Software Agreement must inform the user of the\n\
+          terms and conditions that govern the Installable Software and must solicit acceptance by\n\
+          the end user in the manner prescribed in such Installable Software Agreement. Upon such\n\
+          indication of agreement by the user, the provisioning Technology will complete installation\n\
+          of the Installable Software.\n\
+\n\
+Cryptography\n\
+\n\
+Content may contain encryption software. The country in which you are\n\
+currently may have restrictions on the import, possession, and use,\n\
+and/or re-export to another country, of encryption software. BEFORE\n\
+using any encryption software, please check the country's laws,\n\
+regulations and policies concerning the import, possession, or use, and\n\
+re-export of encryption software, to see if this is permitted.\n\
+\n\
+Java and all Java-based trademarks are trademarks of Oracle Corporation in the United States, other countries, or both.\n
+########### end of license property ##########################################
diff --git a/add-ons/dropins/EGit/features/org.eclipse.jgit_2.3.1.201302201838-r/feature.xml b/add-ons/dropins/EGit/features/org.eclipse.jgit_2.3.1.201302201838-r/feature.xml
new file mode 100644 (file)
index 0000000..0a1b75d
--- /dev/null
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<feature
+      id="org.eclipse.jgit"
+      label="%featureName"
+      version="2.3.1.201302201838-r"
+      provider-name="%providerName">
+
+   <description url="http://www.eclipse.org/jgit/">
+      %description
+   </description>
+
+   <copyright>
+      %copyright
+   </copyright>
+
+   <license url="%licenseURL">
+      %license
+   </license>
+
+   <url>
+      <update label="%updateSiteName" url="http://download.eclipse.org/egit/updates"/>
+      <discovery label="%updateSiteName" url="http://download.eclipse.org/egit/updates"/>
+   </url>
+
+   <plugin
+         id="org.eclipse.jgit"
+         download-size="1609"
+         install-size="3145"
+         version="2.3.1.201302201838-r"
+         unpack="false"/>
+
+   <plugin
+         id="com.jcraft.jsch"
+         download-size="235"
+         install-size="432"
+         version="0.1.46.v201205102330"
+         unpack="false"/>
+</feature>
diff --git a/add-ons/dropins/EGit/features/org.eclipse.jgit_2.3.1.201302201838-r/license.html b/add-ons/dropins/EGit/features/org.eclipse.jgit_2.3.1.201302201838-r/license.html
new file mode 100644 (file)
index 0000000..f19c483
--- /dev/null
@@ -0,0 +1,108 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
+<title>Eclipse Foundation Software User Agreement</title>
+</head>
+
+<body lang="EN-US">
+<h2>Eclipse Foundation Software User Agreement</h2>
+<p>February 1, 2011</p>
+
+<h3>Usage Of Content</h3>
+
+<p>THE ECLIPSE FOUNDATION MAKES AVAILABLE SOFTWARE, DOCUMENTATION, INFORMATION AND/OR OTHER MATERIALS FOR OPEN SOURCE PROJECTS
+   (COLLECTIVELY &quot;CONTENT&quot;).  USE OF THE CONTENT IS GOVERNED BY THE TERMS AND CONDITIONS OF THIS AGREEMENT AND/OR THE TERMS AND
+   CONDITIONS OF LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED BELOW.  BY USING THE CONTENT, YOU AGREE THAT YOUR USE
+   OF THE CONTENT IS GOVERNED BY THIS AGREEMENT AND/OR THE TERMS AND CONDITIONS OF ANY APPLICABLE LICENSE AGREEMENTS OR
+   NOTICES INDICATED OR REFERENCED BELOW.  IF YOU DO NOT AGREE TO THE TERMS AND CONDITIONS OF THIS AGREEMENT AND THE TERMS AND
+   CONDITIONS OF ANY APPLICABLE LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED BELOW, THEN YOU MAY NOT USE THE CONTENT.</p>
+
+<h3>Applicable Licenses</h3>
+
+<p>Unless otherwise indicated, all Content made available by the Eclipse Foundation is provided to you under the terms and conditions of the Eclipse Public License Version 1.0
+   (&quot;EPL&quot;).  A copy of the EPL is provided with this Content and is also available at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
+   For purposes of the EPL, &quot;Program&quot; will mean the Content.</p>
+
+<p>Content includes, but is not limited to, source code, object code, documentation and other files maintained in the Eclipse Foundation source code
+   repository (&quot;Repository&quot;) in software modules (&quot;Modules&quot;) and made available as downloadable archives (&quot;Downloads&quot;).</p>
+
+<ul>
+       <li>Content may be structured and packaged into modules to facilitate delivering, extending, and upgrading the Content.  Typical modules may include plug-ins (&quot;Plug-ins&quot;), plug-in fragments (&quot;Fragments&quot;), and features (&quot;Features&quot;).</li>
+       <li>Each Plug-in or Fragment may be packaged as a sub-directory or JAR (Java&trade; ARchive) in a directory named &quot;plugins&quot;.</li>
+       <li>A Feature is a bundle of one or more Plug-ins and/or Fragments and associated material.  Each Feature may be packaged as a sub-directory in a directory named &quot;features&quot;.  Within a Feature, files named &quot;feature.xml&quot; may contain a list of the names and version numbers of the Plug-ins
+      and/or Fragments associated with that Feature.</li>
+       <li>Features may also include other Features (&quot;Included Features&quot;). Within a Feature, files named &quot;feature.xml&quot; may contain a list of the names and version numbers of Included Features.</li>
+</ul>
+
+<p>The terms and conditions governing Plug-ins and Fragments should be contained in files named &quot;about.html&quot; (&quot;Abouts&quot;). The terms and conditions governing Features and
+Included Features should be contained in files named &quot;license.html&quot; (&quot;Feature Licenses&quot;).  Abouts and Feature Licenses may be located in any directory of a Download or Module
+including, but not limited to the following locations:</p>
+
+<ul>
+       <li>The top-level (root) directory</li>
+       <li>Plug-in and Fragment directories</li>
+       <li>Inside Plug-ins and Fragments packaged as JARs</li>
+       <li>Sub-directories of the directory named &quot;src&quot; of certain Plug-ins</li>
+       <li>Feature directories</li>
+</ul>
+
+<p>Note: if a Feature made available by the Eclipse Foundation is installed using the Provisioning Technology (as defined below), you must agree to a license (&quot;Feature Update License&quot;) during the
+installation process.  If the Feature contains Included Features, the Feature Update License should either provide you with the terms and conditions governing the Included Features or
+inform you where you can locate them.  Feature Update Licenses may be found in the &quot;license&quot; property of files named &quot;feature.properties&quot; found within a Feature.
+Such Abouts, Feature Licenses, and Feature Update Licenses contain the terms and conditions (or references to such terms and conditions) that govern your use of the associated Content in
+that directory.</p>
+
+<p>THE ABOUTS, FEATURE LICENSES, AND FEATURE UPDATE LICENSES MAY REFER TO THE EPL OR OTHER LICENSE AGREEMENTS, NOTICES OR TERMS AND CONDITIONS.  SOME OF THESE
+OTHER LICENSE AGREEMENTS MAY INCLUDE (BUT ARE NOT LIMITED TO):</p>
+
+<ul>
+       <li>Eclipse Distribution License Version 1.0 (available at <a href="http://www.eclipse.org/licenses/edl-v10.html">http://www.eclipse.org/licenses/edl-v1.0.html</a>)</li>
+       <li>Common Public License Version 1.0 (available at <a href="http://www.eclipse.org/legal/cpl-v10.html">http://www.eclipse.org/legal/cpl-v10.html</a>)</li>
+       <li>Apache Software License 1.1 (available at <a href="http://www.apache.org/licenses/LICENSE">http://www.apache.org/licenses/LICENSE</a>)</li>
+       <li>Apache Software License 2.0 (available at <a href="http://www.apache.org/licenses/LICENSE-2.0">http://www.apache.org/licenses/LICENSE-2.0</a>)</li>
+       <li>Metro Link Public License 1.00 (available at <a href="http://www.opengroup.org/openmotif/supporters/metrolink/license.html">http://www.opengroup.org/openmotif/supporters/metrolink/license.html</a>)</li>
+       <li>Mozilla Public License Version 1.1 (available at <a href="http://www.mozilla.org/MPL/MPL-1.1.html">http://www.mozilla.org/MPL/MPL-1.1.html</a>)</li>
+</ul>
+
+<p>IT IS YOUR OBLIGATION TO READ AND ACCEPT ALL SUCH TERMS AND CONDITIONS PRIOR TO USE OF THE CONTENT.  If no About, Feature License, or Feature Update License is provided, please
+contact the Eclipse Foundation to determine what terms and conditions govern that particular Content.</p>
+
+
+<h3>Use of Provisioning Technology</h3>
+
+<p>The Eclipse Foundation makes available provisioning software, examples of which include, but are not limited to, p2 and the Eclipse
+   Update Manager (&quot;Provisioning Technology&quot;) for the purpose of allowing users to install software, documentation, information and/or
+   other materials (collectively &quot;Installable Software&quot;). This capability is provided with the intent of allowing such users to
+   install, extend and update Eclipse-based products. Information about packaging Installable Software is available at <a
+       href="http://eclipse.org/equinox/p2/repository_packaging.html">http://eclipse.org/equinox/p2/repository_packaging.html</a>
+   (&quot;Specification&quot;).</p>
+
+<p>You may use Provisioning Technology to allow other parties to install Installable Software. You shall be responsible for enabling the
+   applicable license agreements relating to the Installable Software to be presented to, and accepted by, the users of the Provisioning Technology
+   in accordance with the Specification. By using Provisioning Technology in such a manner and making it available in accordance with the
+   Specification, you further acknowledge your agreement to, and the acquisition of all necessary rights to permit the following:</p>
+
+<ol>
+       <li>A series of actions may occur (&quot;Provisioning Process&quot;) in which a user may execute the Provisioning Technology
+       on a machine (&quot;Target Machine&quot;) with the intent of installing, extending or updating the functionality of an Eclipse-based
+       product.</li>
+       <li>During the Provisioning Process, the Provisioning Technology may cause third party Installable Software or a portion thereof to be
+       accessed and copied to the Target Machine.</li>
+       <li>Pursuant to the Specification, you will provide to the user the terms and conditions that govern the use of the Installable
+       Software (&quot;Installable Software Agreement&quot;) and such Installable Software Agreement shall be accessed from the Target
+       Machine in accordance with the Specification. Such Installable Software Agreement must inform the user of the terms and conditions that govern
+       the Installable Software and must solicit acceptance by the end user in the manner prescribed in such Installable Software Agreement. Upon such
+       indication of agreement by the user, the provisioning Technology will complete installation of the Installable Software.</li>
+</ol>
+
+<h3>Cryptography</h3>
+
+<p>Content may contain encryption software. The country in which you are currently may have restrictions on the import, possession, and use, and/or re-export to
+   another country, of encryption software. BEFORE using any encryption software, please check the country's laws, regulations and policies concerning the import,
+   possession, or use, and re-export of encryption software, to see if this is permitted.</p>
+
+<p><small>Java and all Java-based trademarks are trademarks of Oracle Corporation in the United States, other countries, or both.</small></p>
+</body>
+</html>
diff --git a/add-ons/dropins/EGit/plugins/org.eclipse.egit.core_2.3.1.201302201838-r.jar b/add-ons/dropins/EGit/plugins/org.eclipse.egit.core_2.3.1.201302201838-r.jar
new file mode 100644 (file)
index 0000000..297642a
Binary files /dev/null and b/add-ons/dropins/EGit/plugins/org.eclipse.egit.core_2.3.1.201302201838-r.jar differ
diff --git a/add-ons/dropins/EGit/plugins/org.eclipse.egit.doc_2.3.1.201302201838-r.jar b/add-ons/dropins/EGit/plugins/org.eclipse.egit.doc_2.3.1.201302201838-r.jar
new file mode 100644 (file)
index 0000000..59accc0
Binary files /dev/null and b/add-ons/dropins/EGit/plugins/org.eclipse.egit.doc_2.3.1.201302201838-r.jar differ
diff --git a/add-ons/dropins/EGit/plugins/org.eclipse.egit.ui_2.3.1.201302201838-r.jar b/add-ons/dropins/EGit/plugins/org.eclipse.egit.ui_2.3.1.201302201838-r.jar
new file mode 100644 (file)
index 0000000..98d2168
Binary files /dev/null and b/add-ons/dropins/EGit/plugins/org.eclipse.egit.ui_2.3.1.201302201838-r.jar differ
diff --git a/add-ons/dropins/EGit/plugins/org.eclipse.egit_2.3.1.201302201838-r.jar b/add-ons/dropins/EGit/plugins/org.eclipse.egit_2.3.1.201302201838-r.jar
new file mode 100644 (file)
index 0000000..5d3edc5
Binary files /dev/null and b/add-ons/dropins/EGit/plugins/org.eclipse.egit_2.3.1.201302201838-r.jar differ
diff --git a/add-ons/dropins/EGit/plugins/org.eclipse.jgit_2.3.1.201302201838-r.jar b/add-ons/dropins/EGit/plugins/org.eclipse.jgit_2.3.1.201302201838-r.jar
new file mode 100644 (file)
index 0000000..42d6913
Binary files /dev/null and b/add-ons/dropins/EGit/plugins/org.eclipse.jgit_2.3.1.201302201838-r.jar differ
index b565cf1..1b2ca19 100644 (file)
@@ -13,6 +13,7 @@ package org.eclipse.cdt.internal.ui.text.c.hover;
 
 import java.io.BufferedReader;
 import java.io.File;
+import java.io.FileNotFoundException;
 import java.io.FileReader;
 import java.io.IOException;
 import java.util.Set;
@@ -22,6 +23,14 @@ import org.eclipse.cdt.core.dom.ast.DOMException;
 import org.eclipse.cdt.core.dom.ast.IASTName;
 import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
 import org.eclipse.cdt.core.dom.ast.IBinding;
+import org.eclipse.cdt.core.dom.ast.IEnumeration;
+import org.eclipse.cdt.core.dom.ast.IFunction;
+import org.eclipse.cdt.core.dom.ast.IParameter;
+import org.eclipse.cdt.core.dom.ast.ITypedef;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace;
 import org.eclipse.cdt.core.model.CModelException;
 import org.eclipse.cdt.core.model.ILanguage;
 import org.eclipse.cdt.core.model.ITranslationUnit;
@@ -80,6 +89,7 @@ import org.eclipse.ui.editors.text.EditorsUI;
  */
 public class CDocHover extends AbstractCEditorTextHover {
     private static String TIZEN_API_ROOT_NAMESPACE = "Tizen";
+    private static String TIZEN_API_NAMSPACE_DELIMITER = "::";
        private static String doxygenDirectoryPath;
 
        /**
@@ -678,39 +688,151 @@ public class CDocHover extends AbstractCEditorTextHover {
                        return htmlFileName;
                }
 
+        private IBinding getBinding(IASTTranslationUnit ast) {
+            if (ast == null) {
+                return null;
+            }
+
+            IASTName name = ast.getNodeSelector(null).findEnclosingName(
+                    fTextRegion.getOffset(), fTextRegion.getLength());
+            if (name == null) {
+                return null;
+            }
+
+            IBinding binding = name.resolveBinding();
+            return binding;
+        }
+
+        /**
+         * This method return full name
+         * @param binding
+         * @return It returns name including namespace of parents and class(when binding is method).
+         *         If binding is namespace, it returns namespace including namespace of parents.
+         *              (ex. Tizen::App::UiApp)
+         *         If binding is class, it returns class including namespace of parents.
+         *              (ex. Tizen::App::UiApp::Execute)
+         */
+        private String getFullName(IBinding binding) {
+            String owner = "";
+            
+            if (binding.getOwner() != null) {
+                owner = tokenizeString(binding.getOwner().toString())[0]
+                        + TIZEN_API_NAMSPACE_DELIMITER + binding.getName();
+            } else {
+                owner = binding.getName();
+            }
+            return owner;
+        }
+
+        private String getHoverLinkInternal(ICPPClassType binding) {
+            // String indexingFile = doxygenDirectoryPath+"annotated.html";
+            // return getHoverLink(indexingFile, hoverText);
+            
+            String hoverText = getFullName(binding);
+            return "class"
+            + hoverText
+                    .replaceAll(TIZEN_API_NAMSPACE_DELIMITER, "_1_1")
+            + ".html";
+        }
+
+        private String getHoverLinkInternal(ICPPNamespace binding) {
+            // String indexingFile = doxygenDirectoryPath+"namespaces.html";
+            // return getHoverLink(indexingFile, hoverText);
+
+            String hoverText = getFullName(binding);
+            
+            return "namespace"
+                    + hoverText
+                            .replaceAll(TIZEN_API_NAMSPACE_DELIMITER, "_1_1")
+                    + ".html";
+        }
+
+        private String getHoverLink(IBinding binding) throws FileNotFoundException, IOException, DOMException {
+            if (binding == null) {
+                return null;
+            }
+
+            String referenceLink = null;
+
+            if (binding instanceof IFunction) { //method, function
+                //TODO: implement
+            } else if (binding instanceof IParameter) { //parameter
+                //TODO: implement
+            } else if (binding instanceof ITypedef) { //typedef
+                //TODO: implement
+            } else if (binding instanceof IEnumeration) {
+                //TODO: implement
+            } else if (binding instanceof ICPPNamespace) {
+                referenceLink = getHoverLinkInternal((ICPPNamespace) binding);
+            } else if (binding instanceof ICPPClassType) {
+                referenceLink = getHoverLinkInternal((ICPPClassType) binding);
+            } 
+            return referenceLink;
+               }
+
+        protected String getHoverLink(IASTTranslationUnit ast) throws FileNotFoundException, IOException, DOMException {
+            if ( ast == null ) {
+                return null;
+            }
+            IASTName name = ast.getNodeSelector(null).findEnclosingName(
+                    fTextRegion.getOffset(), fTextRegion.getLength());  //ASTPreprocessorName(header file) || ASTMacroReferenceName(typedef) || CPPASTName(method, parameter,,,) || ASTPreprocessorDefinition(define)
+            if (name == null) {
+                return null;
+            }
+
+            return getHoverLink(name.resolveBinding());
+        }
+               
                /*
                 * @see org.eclipse.cdt.internal.core.model.ASTCache.ASTRunnable#runOnAST(org.eclipse.cdt.core.dom.ast.IASTTranslationUnit)
                 */
                public IStatus runOnAST(ILanguage lang, IASTTranslationUnit ast) {
-                       if (ast != null) {
-                               try {
-                                       IASTName name= ast.getNodeSelector(null).findEnclosingName(fTextRegion.getOffset(), fTextRegion.getLength());
-                                       if (name != null) {
-                                               IBinding binding= name.resolveBinding();
-
-                                               if (binding != null) {
-                                                       String htmlFileName = null;
-                                                       boolean isExist = false;
-
-                                                       if (binding.getOwner() == null) {
-                                                               String stringOfBinding[] = tokenizeString(binding.toString());
-                                                               if (stringOfBinding.length == 2) { /* Case 1-1. using root namespace in source file */
-                                                                       if (stringOfBinding[0].equals(TIZEN_API_ROOT_NAMESPACE) && stringOfBinding[1].equals("CPPNAMESPACE")) {
-                                                                               htmlFileName = "namespaceOsp.html";
-                                                                               isExist = checkHTMLFileExistence(htmlFileName);
-                                                                       }
-                                                               } else if (stringOfBinding.length == 1) {  /* Case 1-2. declaration root namespace in header or source file */
-                                                                       if (stringOfBinding[0].equals(TIZEN_API_ROOT_NAMESPACE)) {
-                                                                               htmlFileName = "namespaceOsp.html";
-                                                                               isExist = checkHTMLFileExistence(htmlFileName);
+                       try {
+                               String htmlFileName = null;
+                               boolean isExist = false;
+
+                               htmlFileName = getHoverLink(ast);
+                               if ( (htmlFileName != null) && checkHTMLFileExistence(htmlFileName) ) {
+                                       fSource = htmlFileName;
+                                       return Status.OK_STATUS;
+                               }
+
+                               IBinding binding = getBinding(ast); //must remove.
+                               if (binding==null) {
+                                   return Status.CANCEL_STATUS;
+                               }
+
+                               if (binding.getOwner() != null) {
+                                       String stringOfOwner[] = tokenizeString(binding.getOwner().toString());
+                                       if (stringOfOwner.length == 3) {
+                                               if (stringOfOwner[2].equals("CPPENUMERATION")) {
+                                                       String stringOfBinding[] = tokenizeString(binding.toString());
+                                                       if (stringOfBinding[1].equals("CPPENUMERATOR")) { /* Case 2-0. enumerator in source file */
+                                                               char firstChar = stringOfBinding[0].charAt(0);
+                                                               if (firstChar == 'A') {
+                                                                       htmlFileName = "namespacemembers_eval.html";
+                                                               } else {
+                                                                       for (int i = 66; i < 91; i++) {
+                                                                               if ((int)firstChar == i) {
+                                                                                       htmlFileName = "namespacemembers_eval_0x" + Integer.toHexString(i + 32) + ".html";
+                                                                               }
                                                                        }
                                                                }
-                                                       } else if (binding.getOwner() != null) {
-                                                               String stringOfOwner[] = tokenizeString(binding.getOwner().toString());
-                                                               if (stringOfOwner.length == 3) {
-                                                                       if (stringOfOwner[2].equals("CPPENUMERATION")) {
-                                                                               String stringOfBinding[] = tokenizeString(binding.toString());
-                                                                               if (stringOfBinding[1].equals("CPPENUMERATOR")) { /* Case 2-0. enumerator in source file */
+
+                                                               String htmlFileName2 = null;
+                                                               if ( (htmlFileName2 = searchEnumerator(htmlFileName, binding, methodInSource)) != null) {
+                                                                       isExist = true;
+                                                                       htmlFileName = htmlFileName2;
+                                                               }
+                                                       }
+                                               }
+                                       } else if (stringOfOwner.length == 2) {
+                                               if (stringOfOwner[1].equals("CPPNAMESPACE")) {
+                                                       String stringOfBinding[] = tokenizeString(binding.toString());
+                                                       if (stringOfBinding[1].equals("CPP_CLASS_TEMPLATE")) { /* Case 2-1-3. class template in source file */
+                                                               htmlFileName = "class" + stringOfBinding[0].replaceAll("::", "_1_1") + ".html";
+                                                               isExist = checkHTMLFileExistence(htmlFileName); /* check HTML file existence */
+                                                       } /*else if (stringOfBinding[1].equals("CPPENUMERATOR")) { Case 2-1-4. enumerator in source file
                                                                                        char firstChar = stringOfBinding[0].charAt(0);
                                                                                        if (firstChar == 'A') {
                                                                                                htmlFileName = "namespacemembers_eval.html";
@@ -727,265 +849,226 @@ public class CDocHover extends AbstractCEditorTextHover {
                                                                                                isExist = true;
                                                                                                htmlFileName = htmlFileName2;
                                                                                        }
+                                                       }*/ else if (stringOfBinding.length == 3 && stringOfBinding[2].equals("CPPENUMERATION")) { /* Case 2-1-5. enumeration used as parameter variable in header file */
+                                                               char firstChar = stringOfBinding[1].charAt(0);
+                                                               if (firstChar == 'A') {
+                                                                       htmlFileName = "namespacemembers_enum.html";
+                                                               } else {
+                                                                       for (int i = 66; i < 91; i++) {
+                                                                               if ((int)firstChar == i) {
+                                                                                       htmlFileName = "namespacemembers_enum_0x" + Integer.toHexString(i + 32) + ".html";
                                                                                }
                                                                        }
-                                                               } else if (stringOfOwner.length == 2) {
-                                                                       if (stringOfOwner[1].equals("CPPNAMESPACE")) {
-                                                                               String stringOfBinding[] = tokenizeString(binding.toString());
-                                                                               if (stringOfBinding[1].equals("CPPNAMESPACE")) { /* Case 2-1-1. using namespace in source file */
-                                                                                       htmlFileName = "namespace" + tokenizeString(binding.toString())[0].replaceAll("::", "_1_1") + ".html";
-                                                                                       isExist = checkHTMLFileExistence(htmlFileName);
-                                                                               } else if (stringOfBinding[1].equals("CPPCLASSTYPE")) { /* Case 2-1-2. class in source file */
-                                                                                       htmlFileName = "class" + stringOfBinding[0].replaceAll("::", "_1_1") + ".html";
-                                                                                       isExist = checkHTMLFileExistence(htmlFileName); /* check HTML file existence */
-                                                                               } else if (stringOfBinding[1].equals("CPP_CLASS_TEMPLATE")) { /* Case 2-1-3. class template in source file */
-                                                                                       htmlFileName = "class" + stringOfBinding[0].replaceAll("::", "_1_1") + ".html";
-                                                                                       isExist = checkHTMLFileExistence(htmlFileName); /* check HTML file existence */
-                                                                               } /*else if (stringOfBinding[1].equals("CPPENUMERATOR")) { Case 2-1-4. enumerator in source file
-                                                                                       char firstChar = stringOfBinding[0].charAt(0);
-                                                                                       if (firstChar == 'A') {
-                                                                                               htmlFileName = "namespacemembers_eval.html";
-                                                                                       } else {
-                                                                                               for (int i = 66; i < 91; i++) {
-                                                                                                       if ((int)firstChar == i) {
-                                                                                                               htmlFileName = "namespacemembers_eval_0x" + Integer.toHexString(i + 32) + ".html";
-                                                                                                       }
-                                                                                               }
-                                                                                       }
-
-                                                                                       String htmlFileName2 = null;
-                                                                                       if ( (htmlFileName2 = searchEnumerator(htmlFileName, binding, methodInSource)) != null) {
-                                                                                               isExist = true;
-                                                                                               htmlFileName = htmlFileName2;
-                                                                                       }
-                                                                               }*/ else if (stringOfBinding.length == 3 && stringOfBinding[2].equals("CPPENUMERATION")) { /* Case 2-1-5. enumeration used as parameter variable in header file */
-                                                                                       char firstChar = stringOfBinding[1].charAt(0);
-                                                                                       if (firstChar == 'A') {
-                                                                                               htmlFileName = "namespacemembers_enum.html";
-                                                                                       } else {
-                                                                                               for (int i = 66; i < 91; i++) {
-                                                                                                       if ((int)firstChar == i) {
-                                                                                                               htmlFileName = "namespacemembers_enum_0x" + Integer.toHexString(i + 32) + ".html";
-                                                                                                       }
-                                                                                               }
-                                                                                       }
-
-                                                                                       String htmlFileName2 = null;
-                                                                                       if ( (htmlFileName2 = searchEnumeration(htmlFileName, binding)) != null) {
-                                                                                               isExist = true;
-                                                                                               htmlFileName = htmlFileName2;
-                                                                                       }
-                                                                               } else if (binding.toString().contains("CPPTYPEDEF") && binding.toString().contains("enum")) { /* Case 2-1-6. typedef enumeration used as parameter variable in header file */
-                                                                                       char firstChar = stringOfBinding[0].charAt(0);
-                                                                                       if (firstChar == 'A') {
-                                                                                               htmlFileName = "namespacemembers_enum.html";
-                                                                                       } else {
-                                                                                               for (int i = 66; i < 91; i++) {
-                                                                                                       if ((int)firstChar == i) {
-                                                                                                               htmlFileName = "namespacemembers_enum_0x" + Integer.toHexString(i + 32) + ".html";
-                                                                                                       }
-                                                                                               }
-                                                                                       }
+                                                               }
 
-                                                                                       String htmlFileName2 = null;
-                                                                                       if ( (htmlFileName2 = searchEnumeration(htmlFileName, binding)) != null) {
-                                                                                               isExist = true;
-                                                                                               htmlFileName = htmlFileName2;
-                                                                                       }
-                                                                               }
-                                                                       } else if (stringOfOwner[1].equals("CPPCLASSTYPE")) { /* Case 2-2. constructor or member method in source file */
-                                                                               String tokenOfStringOfOwner[] = tokenizeStringWithDelimiter(stringOfOwner[0], "::");
-                                                                               if ( checkIsInterface(tokenOfStringOfOwner) == false ) { /* Case 2-2-1. constructor or member method of class in source file */
-                                                                                       htmlFileName = "class" + stringOfOwner[0].replaceAll("::", "_1_1") + "-members.html";
-
-                                                                                       isExist = checkHTMLFileExistence(htmlFileName); /* check HTML file existence */
-
-                                                                                       if (isExist == true) {
-                                                                                               BufferedReader reader = new BufferedReader(new FileReader(doxygenDirectoryPath + "/" + htmlFileName));
-                                                                                               String tempString = null;
-                                                                                               String htmlFileName2 = null;
-                                                                                               while ( (tempString = reader.readLine()) != null) {
-                                                                                                       if ( (htmlFileName2 = searchMethodLocationOfClass(tempString, binding, methodInSource, true)) != null) {
-                                                                                                               break;
-                                                                                                       }
-                                                                                               }
-                                                                                               reader.close();
-                                                                                               htmlFileName = htmlFileName2;
-                                                                                       }
-                                                                               } else if ( checkIsInterface(tokenOfStringOfOwner) == true ) { /* Case 2-2-2. constructor or member method of interface in source file */
-                                                                                       htmlFileName = "interface" + stringOfOwner[0].replaceAll("::", "_1_1") + "-members.html";
-
-                                                                                       isExist = checkHTMLFileExistence(htmlFileName); /* check HTML file existence */
-
-                                                                                       if (isExist == true) {
-                                                                                               BufferedReader reader = new BufferedReader(new FileReader(doxygenDirectoryPath + "/" + htmlFileName));
-                                                                                               String tempString = null;
-                                                                                               String htmlFileName2 = null;
-                                                                                               while ( (tempString = reader.readLine()) != null) {
-                                                                                                       if ( (htmlFileName2 = searchMethodLocationOfClass(tempString, binding, methodInSource, false)) != null) {
-                                                                                                               break;
-                                                                                                       }
-                                                                                               }
-                                                                                               reader.close();
-                                                                                               htmlFileName = htmlFileName2;
-                                                                                       }
-                                                                               }
-                                                                       } else if (stringOfOwner[1].equals("CPP_CLASS_INSTANCE")) { /* Case 2-3. member method with <type> in source file */
-                                                                               String tokenOfStringOfOwner[] = tokenizeStringWithDelimiter(stringOfOwner[0], "::");
-                                                                               if ( checkIsInterface(tokenOfStringOfOwner) == false ) { /* Case 2-3-1. member method with <type> of class in source file */
-                                                                                       String owner = stringOfOwner[0].substring(0, stringOfOwner[0].indexOf("<"));
-                                                                                       htmlFileName = "class" + owner.replaceAll("::", "_1_1") + "-members.html";
-
-                                                                                       isExist = checkHTMLFileExistence(htmlFileName); /* check HTML file existence */
-
-                                                                                       if (isExist == true) {
-                                                                                               BufferedReader reader = new BufferedReader(new FileReader(doxygenDirectoryPath + "/" + htmlFileName));
-                                                                                               String tempString = null;
-                                                                                               String htmlFileName2 = null;
-                                                                                               while ( (tempString = reader.readLine()) != null) {
-                                                                                                       if ( (htmlFileName2 = searchMethodLocationOfClass(tempString, binding, methodInSource, true)) != null) {
-                                                                                                               break;
-                                                                                                       }
-                                                                                               }
-                                                                                               reader.close();
-                                                                                               htmlFileName = htmlFileName2;
-                                                                                       }
-                                                                               } else if ( checkIsInterface(tokenOfStringOfOwner) == true ) { /* Case 2-3-2. member method with <type> of interface in source file */
-                                                                                       String owner = stringOfOwner[0].substring(0, stringOfOwner[0].indexOf("<"));
-                                                                                       htmlFileName = "interface" + owner.replaceAll("::", "_1_1") + "-members.html";
-
-                                                                                       isExist = checkHTMLFileExistence(htmlFileName); /* check HTML file existence */
-
-                                                                                       if (isExist == true) {
-                                                                                               BufferedReader reader = new BufferedReader(new FileReader(doxygenDirectoryPath + "/" + htmlFileName));
-                                                                                               String tempString = null;
-                                                                                               String htmlFileName2 = null;
-                                                                                               while ( (tempString = reader.readLine()) != null) {
-                                                                                                       if ( (htmlFileName2 = searchMethodLocationOfClass(tempString, binding, methodInSource, false)) != null) {
-                                                                                                               break;
-                                                                                                       }
-                                                                                               }
-                                                                                               reader.close();
-                                                                                               htmlFileName = htmlFileName2;
-                                                                                       }
+                                                               String htmlFileName2 = null;
+                                                               if ( (htmlFileName2 = searchEnumeration(htmlFileName, binding)) != null) {
+                                                                       isExist = true;
+                                                                       htmlFileName = htmlFileName2;
+                                                               }
+                                                       } else if (binding.toString().contains("CPPTYPEDEF") && binding.toString().contains("enum")) { /* Case 2-1-6. typedef enumeration used as parameter variable in header file */
+                                                               char firstChar = stringOfBinding[0].charAt(0);
+                                                               if (firstChar == 'A') {
+                                                                       htmlFileName = "namespacemembers_enum.html";
+                                                               } else {
+                                                                       for (int i = 66; i < 91; i++) {
+                                                                               if ((int)firstChar == i) {
+                                                                                       htmlFileName = "namespacemembers_enum_0x" + Integer.toHexString(i + 32) + ".html";
                                                                                }
-
                                                                        }
-                                                               } else if (stringOfOwner.length == 1) {
-                                                                       String stringOfClass[] = tokenizeStringWithDelimiter(binding.getClass().toString(), ".");
-                                                                       if ( stringOfClass[stringOfClass.length - 1].equals("CPPNamespace") ) { /* Case 3-1-1. declaration namespace in header or source file */
-                                                                               htmlFileName = "namespace" + binding.toString().replaceAll("::", "_1_1") + ".html";
-                                                                               isExist = checkHTMLFileExistence(htmlFileName); /* check HTML file existence */
-                                                                       } else if ( stringOfClass[stringOfClass.length - 1].equals("CPPClassType") ) { /* Case 3-1-2. class in header file */
-                                                                               htmlFileName = "class" + binding.getOwner().toString().replaceAll("::", "_1_1") + "_1_1" + binding.toString() + ".html";
-                                                                               isExist = checkHTMLFileExistence(htmlFileName); /* check HTML file existence */
-                                                                       } /*else if ( stringOfClass[stringOfClass.length - 1].equals("CPPEnumerator") ) {  Case 3-1-3. enumerator in header file 
-                                                                               char firstChar = binding.getName().charAt(0);
-                                                                               if (firstChar == 'A') {
-                                                                                       htmlFileName = "namespacemembers_eval.html";
-                                                                               } else {
-                                                                                       for (int i = 66; i < 91; i++) {
-                                                                                               if ((int)firstChar == i) {
-                                                                                                       htmlFileName = "namespacemembers_eval_0x" + Integer.toHexString(i + 32) + ".html";
-                                                                                               }
-                                                                                       }
-                                                                               }
+                                                               }
 
-                                                                               String htmlFileName2 = null;
-                                                                               if ( (htmlFileName2 = searchEnumerator(htmlFileName, binding, methodInHeader)) != null) {
-                                                                                       isExist = true;
-                                                                                       htmlFileName = htmlFileName2;
-                                                                               }
-                                                                       }*/ else if ( stringOfClass[stringOfClass.length - 1].equals("CPPEnumeration") ) { /* Case 3-1-4. declared enumeration in header file */
-                                                                               char firstChar = binding.getName().charAt(0);
-                                                                               if (firstChar == 'A') {
-                                                                                       htmlFileName = "namespacemembers_enum.html";
-                                                                               } else {
-                                                                                       for (int i = 66; i < 91; i++) {
-                                                                                               if ((int)firstChar == i) {
-                                                                                                       htmlFileName = "namespacemembers_enum_0x" + Integer.toHexString(i + 32) + ".html";
-                                                                                               }
-                                                                                       }
+                                                               String htmlFileName2 = null;
+                                                               if ( (htmlFileName2 = searchEnumeration(htmlFileName, binding)) != null) {
+                                                                       isExist = true;
+                                                                       htmlFileName = htmlFileName2;
+                                                               }
+                                                       }
+                                               } else if (stringOfOwner[1].equals("CPPCLASSTYPE")) { /* Case 2-2. constructor or member method in source file */
+                                                       String tokenOfStringOfOwner[] = tokenizeStringWithDelimiter(stringOfOwner[0], "::");
+                                                       if ( checkIsInterface(tokenOfStringOfOwner) == false ) { /* Case 2-2-1. constructor or member method of class in source file */
+                                                               htmlFileName = "class" + stringOfOwner[0].replaceAll("::", "_1_1") + "-members.html";
+
+                                                               isExist = checkHTMLFileExistence(htmlFileName); /* check HTML file existence */
+
+                                                               if (isExist == true) {
+                                                                       BufferedReader reader = new BufferedReader(new FileReader(doxygenDirectoryPath + "/" + htmlFileName));
+                                                                       String tempString = null;
+                                                                       String htmlFileName2 = null;
+                                                                       while ( (tempString = reader.readLine()) != null) {
+                                                                               if ( (htmlFileName2 = searchMethodLocationOfClass(tempString, binding, methodInSource, true)) != null) {
+                                                                                       break;
                                                                                }
-
-                                                                               String htmlFileName2 = null;
-                                                                               if ( (htmlFileName2 = searchEnumeration(htmlFileName, binding)) != null) {
-                                                                                       isExist = true;
-                                                                                       htmlFileName = htmlFileName2;
+                                                                       }
+                                                                       reader.close();
+                                                                       htmlFileName = htmlFileName2;
+                                                               }
+                                                       } else if ( checkIsInterface(tokenOfStringOfOwner) == true ) { /* Case 2-2-2. constructor or member method of interface in source file */
+                                                               htmlFileName = "interface" + stringOfOwner[0].replaceAll("::", "_1_1") + "-members.html";
+
+                                                               isExist = checkHTMLFileExistence(htmlFileName); /* check HTML file existence */
+
+                                                               if (isExist == true) {
+                                                                       BufferedReader reader = new BufferedReader(new FileReader(doxygenDirectoryPath + "/" + htmlFileName));
+                                                                       String tempString = null;
+                                                                       String htmlFileName2 = null;
+                                                                       while ( (tempString = reader.readLine()) != null) {
+                                                                               if ( (htmlFileName2 = searchMethodLocationOfClass(tempString, binding, methodInSource, false)) != null) {
+                                                                                       break;
                                                                                }
-                                                                       } else if ( stringOfClass[stringOfClass.length - 1].equals("CPPTypedef") ) { /* Case 3-1-5. typedef declared enumeration in header file */
-                                                                               char firstChar = binding.getName().charAt(0);
-                                                                               if (firstChar == 'A') {
-                                                                                       htmlFileName = "namespacemembers_enum.html";
-                                                                               } else {
-                                                                                       for (int i = 66; i < 91; i++) {
-                                                                                               if ((int)firstChar == i) {
-                                                                                                       htmlFileName = "namespacemembers_enum_0x" + Integer.toHexString(i + 32) + ".html";
-                                                                                               }
-                                                                                       }
+                                                                       }
+                                                                       reader.close();
+                                                                       htmlFileName = htmlFileName2;
+                                                               }
+                                                       }
+                                               } else if (stringOfOwner[1].equals("CPP_CLASS_INSTANCE")) { /* Case 2-3. member method with <type> in source file */
+                                                       String tokenOfStringOfOwner[] = tokenizeStringWithDelimiter(stringOfOwner[0], "::");
+                                                       if ( checkIsInterface(tokenOfStringOfOwner) == false ) { /* Case 2-3-1. member method with <type> of class in source file */
+                                                               String owner = stringOfOwner[0].substring(0, stringOfOwner[0].indexOf("<"));
+                                                               htmlFileName = "class" + owner.replaceAll("::", "_1_1") + "-members.html";
+
+                                                               isExist = checkHTMLFileExistence(htmlFileName); /* check HTML file existence */
+
+                                                               if (isExist == true) {
+                                                                       BufferedReader reader = new BufferedReader(new FileReader(doxygenDirectoryPath + "/" + htmlFileName));
+                                                                       String tempString = null;
+                                                                       String htmlFileName2 = null;
+                                                                       while ( (tempString = reader.readLine()) != null) {
+                                                                               if ( (htmlFileName2 = searchMethodLocationOfClass(tempString, binding, methodInSource, true)) != null) {
+                                                                                       break;
                                                                                }
-
-                                                                               String htmlFileName2 = null;
-                                                                               if ( (htmlFileName2 = searchEnumeration(htmlFileName, binding)) != null) {
-                                                                                       isExist = true;
-                                                                                       htmlFileName = htmlFileName2;
+                                                                       }
+                                                                       reader.close();
+                                                                       htmlFileName = htmlFileName2;
+                                                               }
+                                                       } else if ( checkIsInterface(tokenOfStringOfOwner) == true ) { /* Case 2-3-2. member method with <type> of interface in source file */
+                                                               String owner = stringOfOwner[0].substring(0, stringOfOwner[0].indexOf("<"));
+                                                               htmlFileName = "interface" + owner.replaceAll("::", "_1_1") + "-members.html";
+
+                                                               isExist = checkHTMLFileExistence(htmlFileName); /* check HTML file existence */
+
+                                                               if (isExist == true) {
+                                                                       BufferedReader reader = new BufferedReader(new FileReader(doxygenDirectoryPath + "/" + htmlFileName));
+                                                                       String tempString = null;
+                                                                       String htmlFileName2 = null;
+                                                                       while ( (tempString = reader.readLine()) != null) {
+                                                                               if ( (htmlFileName2 = searchMethodLocationOfClass(tempString, binding, methodInSource, false)) != null) {
+                                                                                       break;
                                                                                }
-                                                                       } else if ( stringOfClass[stringOfClass.length - 1].equals("CPPClassType") || stringOfClass[stringOfClass.length - 1].equals("CPPMethod") ) { /* Case 3-1-6. constructor or member method in header file */
-                                                                               htmlFileName = "classes.html";
+                                                                       }
+                                                                       reader.close();
+                                                                       htmlFileName = htmlFileName2;
+                                                               }
+                                                       }
 
-                                                                               isExist = checkHTMLFileExistence(htmlFileName); /* check HTML file existence */
+                                               }
+                                       } else if (stringOfOwner.length == 1) {
+                                               String stringOfClass[] = tokenizeStringWithDelimiter(binding.getClass().toString(), ".");
+                                               /*else if ( stringOfClass[stringOfClass.length - 1].equals("CPPEnumerator") ) {  Case 3-1-3. enumerator in header file 
+                                                       char firstChar = binding.getName().charAt(0);
+                                                       if (firstChar == 'A') {
+                                                               htmlFileName = "namespacemembers_eval.html";
+                                                       } else {
+                                                               for (int i = 66; i < 91; i++) {
+                                                                       if ((int)firstChar == i) {
+                                                                               htmlFileName = "namespacemembers_eval_0x" + Integer.toHexString(i + 32) + ".html";
+                                                                       }
+                                                               }
+                                                       }
 
-                                                                               if (isExist == true) {
-                                                                                       BufferedReader reader = new BufferedReader(new FileReader(doxygenDirectoryPath + "/" + htmlFileName));
-                                                                                       String tempString = null;
-                                                                                       String htmlFileName2 = null;
-                                                                                       while ( (tempString = reader.readLine()) != null) {
-                                                                                               if ( (htmlFileName2 = searchMethod(tempString, binding)) != null) {
-                                                                                                       break;
-                                                                                               }
-                                                                                       }
-                                                                                       reader.close();
-                                                                                       htmlFileName = htmlFileName2;
-                                                                               }
+                                                       String htmlFileName2 = null;
+                                                       if ( (htmlFileName2 = searchEnumerator(htmlFileName, binding, methodInHeader)) != null) {
+                                                               isExist = true;
+                                                               htmlFileName = htmlFileName2;
+                                                       }
+                                               }*/ if ( stringOfClass[stringOfClass.length - 1].equals("CPPEnumeration") ) { /* Case 3-1-4. declared enumeration in header file */
+                                                       char firstChar = binding.getName().charAt(0);
+                                                       if (firstChar == 'A') {
+                                                               htmlFileName = "namespacemembers_enum.html";
+                                                       } else {
+                                                               for (int i = 66; i < 91; i++) {
+                                                                       if ((int)firstChar == i) {
+                                                                               htmlFileName = "namespacemembers_enum_0x" + Integer.toHexString(i + 32) + ".html";
                                                                        }
-                                                               } else if (stringOfOwner.length == 0) {
-                                                                       String stringOfClass[] = tokenizeStringWithDelimiter(binding.getClass().toString(), ".");
-                                                                       if ( stringOfClass[stringOfClass.length - 1].equals("CPPEnumerator") ) { /* Case 4-1. enumerator in header file */
-                                                                               char firstChar = binding.getName().charAt(0);
-                                                                               if (firstChar == 'A') {
-                                                                                       htmlFileName = "namespacemembers_eval.html";
-                                                                               } else {
-                                                                                       for (int i = 66; i < 91; i++) {
-                                                                                               if ((int)firstChar == i) {
-                                                                                                       htmlFileName = "namespacemembers_eval_0x" + Integer.toHexString(i + 32) + ".html";
-                                                                                               }
-                                                                                       }
-                                                                               }
+                                                               }
+                                                       }
 
-                                                                               String htmlFileName2 = null;
-                                                                               if ( (htmlFileName2 = searchEnumerator(htmlFileName, binding, methodInHeader)) != null) {
-                                                                                       isExist = true;
-                                                                                       htmlFileName = htmlFileName2;
-                                                                               }
+                                                       String htmlFileName2 = null;
+                                                       if ( (htmlFileName2 = searchEnumeration(htmlFileName, binding)) != null) {
+                                                               isExist = true;
+                                                               htmlFileName = htmlFileName2;
+                                                       }
+                                               } else if ( stringOfClass[stringOfClass.length - 1].equals("CPPTypedef") ) { /* Case 3-1-5. typedef declared enumeration in header file */
+                                                       char firstChar = binding.getName().charAt(0);
+                                                       if (firstChar == 'A') {
+                                                               htmlFileName = "namespacemembers_enum.html";
+                                                       } else {
+                                                               for (int i = 66; i < 91; i++) {
+                                                                       if ((int)firstChar == i) {
+                                                                               htmlFileName = "namespacemembers_enum_0x" + Integer.toHexString(i + 32) + ".html";
                                                                        }
                                                                }
                                                        }
 
+                                                       String htmlFileName2 = null;
+                                                       if ( (htmlFileName2 = searchEnumeration(htmlFileName, binding)) != null) {
+                                                               isExist = true;
+                                                               htmlFileName = htmlFileName2;
+                                                       }
+                                               } else if ( stringOfClass[stringOfClass.length - 1].equals("CPPClassType") || stringOfClass[stringOfClass.length - 1].equals("CPPMethod") ) { /* Case 3-1-6. constructor or member method in header file */
+                                                       htmlFileName = "classes.html";
+
+                                                       isExist = checkHTMLFileExistence(htmlFileName); /* check HTML file existence */
+
                                                        if (isExist == true) {
-                                                               fSource = htmlFileName;
+                                                               BufferedReader reader = new BufferedReader(new FileReader(doxygenDirectoryPath + "/" + htmlFileName));
+                                                               String tempString = null;
+                                                               String htmlFileName2 = null;
+                                                               while ( (tempString = reader.readLine()) != null) {
+                                                                       if ( (htmlFileName2 = searchMethod(tempString, binding)) != null) {
+                                                                               break;
+                                                                       }
+                                                               }
+                                                               reader.close();
+                                                               htmlFileName = htmlFileName2;
+                                                       }
+                                               }
+                                       } else if (stringOfOwner.length == 0) {
+                                               String stringOfClass[] = tokenizeStringWithDelimiter(binding.getClass().toString(), ".");
+                                               if ( stringOfClass[stringOfClass.length - 1].equals("CPPEnumerator") ) { /* Case 4-1. enumerator in header file */
+                                                       char firstChar = binding.getName().charAt(0);
+                                                       if (firstChar == 'A') {
+                                                               htmlFileName = "namespacemembers_eval.html";
+                                                       } else {
+                                                               for (int i = 66; i < 91; i++) {
+                                                                       if ((int)firstChar == i) {
+                                                                               htmlFileName = "namespacemembers_eval_0x" + Integer.toHexString(i + 32) + ".html";
+                                                                       }
+                                                               }
                                                        }
-                                                       /* TODO Modify End */
 
-                                                       if (fSource != null) {
-                                                               return Status.OK_STATUS;
+                                                       String htmlFileName2 = null;
+                                                       if ( (htmlFileName2 = searchEnumerator(htmlFileName, binding, methodInHeader)) != null) {
+                                                               isExist = true;
+                                                               htmlFileName = htmlFileName2;
                                                        }
                                                }
                                        }
-                               } catch (DOMException exc) {
-                                       return new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID, "Internal Error", exc); //$NON-NLS-1$
-                               } catch (Exception e) {
-                                       //
                                }
+
+                               if (isExist == true) {
+                                       fSource = htmlFileName;
+                               }
+                               /* TODO Modify End */
+
+                               if (fSource != null) {
+                                       return Status.OK_STATUS;
+                               }
+                       } catch (DOMException exc) {
+                               return new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID, "Internal Error", exc); //$NON-NLS-1$
+                       } catch (Exception e) {
+                               //
+                               return Status.CANCEL_STATUS;
                        }
                        return Status.CANCEL_STATUS;
                }
@@ -996,7 +1079,6 @@ public class CDocHover extends AbstractCEditorTextHover {
                public String getSource() {
                        return fSource;
                }
-
        }
 
        /* (non-Javadoc)
@@ -1274,7 +1356,7 @@ public class CDocHover extends AbstractCEditorTextHover {
        private static String getBackForwardElementName(String htmlName) {
                String elementName = "";
                try {
-                       if (htmlName.equals("namespaceOsp.html")) {
+                       if (htmlName.equals("namespaceTizen.html")) {
                                elementName = TIZEN_API_ROOT_NAMESPACE;
                        } else if (htmlName.equals("privlevel.html")) {
                                elementName = "Privilege Level";
diff --git a/org.eclipse.wst.jsdt.web.core.patch/.classpath b/org.eclipse.wst.jsdt.web.core.patch/.classpath
new file mode 100644 (file)
index 0000000..2fbb7a2
--- /dev/null
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+       <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.4"/>
+       <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+       <classpathentry kind="src" path="src"/>
+       <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/org.eclipse.wst.jsdt.web.core.patch/.project b/org.eclipse.wst.jsdt.web.core.patch/.project
new file mode 100644 (file)
index 0000000..4c6ad7f
--- /dev/null
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+       <name>org.eclipse.wst.jsdt.web.core.patch</name>
+       <comment></comment>
+       <projects>
+       </projects>
+       <buildSpec>
+               <buildCommand>
+                       <name>org.eclipse.jdt.core.javabuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+               <buildCommand>
+                       <name>org.eclipse.pde.ManifestBuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+               <buildCommand>
+                       <name>org.eclipse.pde.SchemaBuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+       </buildSpec>
+       <natures>
+               <nature>org.eclipse.pde.PluginNature</nature>
+               <nature>org.eclipse.jdt.core.javanature</nature>
+       </natures>
+</projectDescription>
diff --git a/org.eclipse.wst.jsdt.web.core.patch/.settings/org.eclipse.jdt.core.prefs b/org.eclipse.wst.jsdt.web.core.patch/.settings/org.eclipse.jdt.core.prefs
new file mode 100644 (file)
index 0000000..d243776
--- /dev/null
@@ -0,0 +1,6 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.2
+org.eclipse.jdt.core.compiler.compliance=1.4
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=warning
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=warning
+org.eclipse.jdt.core.compiler.source=1.3
diff --git a/org.eclipse.wst.jsdt.web.core.patch/META-INF/MANIFEST.MF b/org.eclipse.wst.jsdt.web.core.patch/META-INF/MANIFEST.MF
new file mode 100644 (file)
index 0000000..0f8cd9a
--- /dev/null
@@ -0,0 +1,10 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Patch
+Bundle-SymbolicName: org.eclipse.wst.jsdt.web.core.patch
+Bundle-Version: 1.0.401.qualifier
+Fragment-Host: org.eclipse.wst.jsdt.web.core;bundle-version="1.0.401"
+Bundle-RequiredExecutionEnvironment: J2SE-1.4
+Eclipse-PatchFragment: true
+Bundle-ClassPath: library.jar,
+ .
diff --git a/org.eclipse.wst.jsdt.web.core.patch/build.properties b/org.eclipse.wst.jsdt.web.core.patch/build.properties
new file mode 100644 (file)
index 0000000..c378cc2
--- /dev/null
@@ -0,0 +1,4 @@
+bin.includes = META-INF/,\
+               library.jar
+source.library.jar = src/
+jars.compile.order = library.jar
diff --git a/org.eclipse.wst.jsdt.web.core.patch/src/org/eclipse/wst/jsdt/web/core/javascript/JsTranslation.java b/org.eclipse.wst.jsdt.web.core.patch/src/org/eclipse/wst/jsdt/web/core/javascript/JsTranslation.java
new file mode 100644 (file)
index 0000000..7e6cccf
--- /dev/null
@@ -0,0 +1,591 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     bug:244839 - eugene@genuitec.com
+ *     
+ * Provisional API: This class/interface is part of an interim API that is still under development and expected to 
+ * change significantly before reaching stability. It is being made available at this early stage to solicit feedback 
+ * from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken 
+ * (repeatedly) as the API evolves.
+ *     
+ *     
+ *******************************************************************************/
+
+
+package org.eclipse.wst.jsdt.web.core.javascript;
+
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.util.List;
+import java.util.Vector;
+
+import org.eclipse.core.filebuffers.FileBuffers;
+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.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.Position;
+import org.eclipse.jface.text.Region;
+import org.eclipse.wst.jsdt.core.IBuffer;
+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.IPackageFragmentRoot;
+import org.eclipse.wst.jsdt.core.ISourceRange;
+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.core.DocumentContextFragmentRoot;
+import org.eclipse.wst.jsdt.internal.core.Member;
+import org.eclipse.wst.jsdt.internal.core.SourceRefElement;
+import org.eclipse.wst.jsdt.web.core.internal.Logger;
+import org.eclipse.wst.jsdt.web.core.internal.project.JsWebNature;
+import org.eclipse.wst.sse.core.StructuredModelManager;
+import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
+
+/**
+*
+
+* Provisional API: This class/interface is part of an interim API that is still under development and expected to
+* change significantly before reaching stability. It is being made available at this early stage to solicit feedback
+* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
+* (repeatedly) as the API evolves.
+*/
+public class JsTranslation implements IJsTranslation {
+
+       private static final boolean DEBUG;
+       static {
+               String value = Platform.getDebugOption("org.eclipse.wst.jsdt.web.core/debug/jstranslation"); //$NON-NLS-1$
+               DEBUG = value != null && value.equalsIgnoreCase("true"); //$NON-NLS-1$
+       }
+
+       private IJavaScriptUnit fCompilationUnit = null;
+       private DocumentContextFragmentRoot fDocumentScope;
+       private IJavaScriptProject fJavaProject = null;
+       private byte[] fLock = null;
+       private IProgressMonitor fProgressMonitor = null;
+       protected IStructuredDocument fHtmlDocument;
+       protected String fModelBaseLocation;
+
+
+//     private static final String SUPER_TYPE_NAME = "Window"; //$NON-NLS-1$
+//     private static final String SUPER_TYPE_LIBRARY = "org.eclipse.wst.jsdt.launching.baseBrowserLibrary"; //$NON-NLS-1$
+
+       protected IJsTranslator fTranslator;
+
+       private String mangledName;
+       protected boolean listenForChanges;
+
+       public JsTranslation() {
+               /* do nothing */
+       }
+       
+       public IJsTranslator getTranslator() {
+               if(fTranslator!=null) {
+                       return fTranslator;
+               }
+               
+               fTranslator = new JsTranslator(fHtmlDocument, fModelBaseLocation, listenForChanges);
+               return this.fTranslator;
+       }
+       
+
+       
+       protected JsTranslation(IStructuredDocument htmlDocument, IJavaScriptProject javaProj, boolean listenForChanges) {
+               fLock = new byte[0];
+               fJavaProject = javaProj;
+               fHtmlDocument = htmlDocument;
+               setBaseLocation();
+               mangledName = createMangledName();
+               this.listenForChanges=listenForChanges;
+       }
+
+       public IJsTranslation getInstance(IStructuredDocument htmlDocument, IJavaScriptProject javaProj, boolean listenForChanges) {
+               return new JsTranslation(htmlDocument,javaProj, listenForChanges);
+       }
+       
+       /* (non-Javadoc)
+        * @see org.eclipse.wst.jsdt.web.core.internal.java.IJsTranslation#getJavaProject()
+        */
+       public IJavaScriptProject getJavaProject() {
+               return fJavaProject;
+       }
+
+       private IPackageFragmentRoot getDocScope(boolean reset) {
+               if (fDocumentScope == null) {
+                       // IProject project = getJavaProject().getProject();
+                       // IResource absoluteRoot =
+                       // ((IContainer)getJavaProject().getResource()).findMember(
+                       // WebRootFinder.getWebContentFolder(fJavaProject.getProject()));
+                       fDocumentScope = new DocumentContextFragmentRoot(fJavaProject, getFile(), WebRootFinder.getWebContentFolder(fJavaProject.getProject()), WebRootFinder.getServerContextRoot(fJavaProject.getProject()), JsWebNature.VIRTUAL_SCOPE_ENTRY);
+                       fDocumentScope.setIncludedFiles(getTranslator().getRawImports());
+                       return fDocumentScope;
+               }
+
+               if (reset)
+                       fDocumentScope.setIncludedFiles(getTranslator().getRawImports());
+               return fDocumentScope;
+       }
+
+       private void setBaseLocation() {
+               IDOMModel xmlModel = null;
+               try {
+                       xmlModel = (IDOMModel) StructuredModelManager.getModelManager().getExistingModelForRead(fHtmlDocument);
+                       if (xmlModel == null) {
+                               xmlModel = (IDOMModel) StructuredModelManager.getModelManager().getModelForRead(fHtmlDocument);
+                       }
+                       fModelBaseLocation = xmlModel.getBaseLocation();
+               }
+               finally {
+                       if (xmlModel != null)
+                               xmlModel.releaseFromRead();
+               }
+               // return xmlModel;
+       }
+
+       public IFile getFile() {
+               return FileBuffers.getWorkspaceFileAtLocation(new Path(fModelBaseLocation));
+       }
+
+
+       /* (non-Javadoc)
+        * @see org.eclipse.wst.jsdt.web.core.internal.java.IJsTranslation#getHtmlDocument()
+        */
+       public IDocument getHtmlDocument() {
+               return fHtmlDocument;
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.wst.jsdt.web.core.internal.java.IJsTranslation#getMissingTagStart()
+        */
+       public int getMissingTagStart() {
+               return getTranslator().getMissingEndTagRegionStart();
+       }
+
+       private IPath getWebRoot() {
+               return WebRootFinder.getWebContentFolder(fJavaProject.getProject());
+       }
+
+
+       public String getDirectoryUnderRoot() {
+               IPath webRoot = getWebRoot();
+               IPath projectWebRootPath = getJavaProject().getPath().append(webRoot);
+               IPath filePath = new Path(fModelBaseLocation).removeLastSegments(1);
+               return filePath.removeFirstSegments(projectWebRootPath.matchingFirstSegments(filePath)).toString();
+       }
+
+       /**
+        * Originally from ReconcileStepForJava. Creates an IJavaScriptUnit from
+        * the contents of the JSP document.
+        * 
+        * @return an IJavaScriptUnit from the contents of the JSP document
+        */
+       private IJavaScriptUnit createCompilationUnit() throws JavaScriptModelException {
+               IPackageFragmentRoot root = getDocScope(true);
+               IJavaScriptUnit cu = root.getPackageFragment("").getJavaScriptUnit(getMangledName() + JsDataTypes.BASE_FILE_EXTENSION).getWorkingCopy(getWorkingCopyOwner(), getProgressMonitor()); //$NON-NLS-1$
+               IBuffer buffer;
+               try {
+                       buffer = cu.getBuffer();
+               }
+               catch (JavaScriptModelException e) {
+                       e.printStackTrace();
+                       buffer = null;
+               }
+               if (buffer != null) {
+                       getTranslator().setBuffer(buffer);
+               }
+               return cu;
+       }
+
+       public String fixupMangledName(String displayString) {
+               if (displayString == null) {
+                       return null;
+               }
+               return displayString.replaceAll(getMangledName() + ".js", getHtmlPageName()); //$NON-NLS-1$
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.wst.jsdt.web.core.internal.java.IJsTranslation#getAllElementsInJsRange(int, int)
+        */
+       public IJavaScriptElement[] getAllElementsInJsRange(int javaPositionStart, int javaPositionEnd) {
+               IJavaScriptElement[] EMTPY_RESULT_SET = new IJavaScriptElement[0];
+               IJavaScriptElement[] result = EMTPY_RESULT_SET;
+               IJavaScriptElement[] allChildren = null;
+               try {
+                       allChildren = getCompilationUnit().getChildren();
+               }
+               catch (JavaScriptModelException e) {
+               }
+               Vector validChildren = new Vector();
+               for (int i = 0; i < allChildren.length; i++) {
+                       ISourceRange range = getJSSourceRangeOf(allChildren[i]);
+                       if (javaPositionStart <= range.getOffset() && range.getLength() + range.getOffset() <= (javaPositionEnd)) {
+                               validChildren.add(allChildren[i]);
+                       }
+                       else if (allChildren[i].getElementType() == IJavaScriptElement.TYPE) {
+                               validChildren.add(allChildren[i]);
+                       }
+               }
+               if (validChildren.size() > 0) {
+                       result = (IJavaScriptElement[]) validChildren.toArray(new IJavaScriptElement[]{});
+               }
+               if (result == null || result.length == 0) {
+                       return EMTPY_RESULT_SET;
+               }
+               return result;
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.wst.jsdt.web.core.internal.java.IJsTranslation#getCompilationUnit()
+        */
+       public IJavaScriptUnit getCompilationUnit() {
+        // Genuitec Begin Fix 6149: Exception opening external HTML file
+           if (!getJavaProject().exists()) {
+               return null;
+           }
+           // Genuitec End Fix 6149: Exception opening external HTML file
+               synchronized (fLock) {
+                       try {
+                               if (fCompilationUnit == null) {
+                                       fCompilationUnit = createCompilationUnit();
+                                       return fCompilationUnit;
+                               }
+
+                       }
+                       catch (JavaScriptModelException jme) {
+                               if (JsTranslation.DEBUG) {
+                                       Logger.logException("error creating JSP working copy... ", jme); //$NON-NLS-1$
+                               }
+                       }
+
+               }
+               getDocScope(true);
+               try {
+                       fCompilationUnit = fCompilationUnit.getWorkingCopy(getWorkingCopyOwner(), getProgressMonitor());
+                       // fCompilationUnit.makeConsistent(getProgressMonitor());
+               }
+               catch (JavaScriptModelException ex) {
+                       // TODO Auto-generated catch block
+                       ex.printStackTrace();
+               }
+               return fCompilationUnit;
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.wst.jsdt.web.core.internal.java.IJsTranslation#getElementsFromJsRange(int, int)
+        */
+       public IJavaScriptElement[] getElementsFromJsRange(int javaPositionStart, int javaPositionEnd) {
+               IJavaScriptElement[] EMTPY_RESULT_SET = new IJavaScriptElement[0];
+               IJavaScriptElement[] result = EMTPY_RESULT_SET;
+               try {
+                       IJavaScriptUnit cu = getCompilationUnit();
+
+                       if (cu != null) {
+                               cu.makeConsistent(getProgressMonitor());        // update JavaModelManager
+                               synchronized (fLock) {
+                                       int cuDocLength = cu.getBuffer().getLength();
+                                       int javaLength = javaPositionEnd - javaPositionStart;
+                                       if (cuDocLength > 0 && javaPositionStart >= 0 && javaLength >= 0 && javaPositionEnd <= cuDocLength) {
+                                               result = cu.codeSelect(javaPositionStart, javaLength, getWorkingCopyOwner());
+                                       }
+                               }
+                       }
+                       if (result == null || result.length == 0) {
+                               return EMTPY_RESULT_SET;
+                       }
+               }
+               catch (JavaScriptModelException x) {
+                       Logger.logException(x);
+               }
+               return result;
+       }
+
+       private String getHtmlPageName() {
+               IPath path = new Path(fModelBaseLocation);
+               return path.lastSegment();
+
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.wst.jsdt.web.core.internal.java.IJsTranslation#getHtmlText()
+        */
+       public String getHtmlText() {
+               return fHtmlDocument.get();
+       }
+
+       public String getJavaPath() {
+               IPath rootPath = new Path(fModelBaseLocation).removeLastSegments(1);
+               String cuPath = rootPath.append("/" + getMangledName() + JsDataTypes.BASE_FILE_EXTENSION).toString(); //$NON-NLS-1$
+               return cuPath;
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.wst.jsdt.web.core.internal.java.IJsTranslation#getJsElementAtOffset(int)
+        */
+       public IJavaScriptElement getJsElementAtOffset(int jsOffset) {
+               IJavaScriptElement elements = null;
+               try {
+                       elements = getCompilationUnit().getElementAt(jsOffset);
+               }
+               catch (JavaScriptModelException e) {
+                       // TODO Auto-generated catch block
+                       if (JsTranslation.DEBUG) {
+                               Logger.logException("error retrieving java elemtnt from compilation unit... ", e); //$NON-NLS-1$
+                       }
+                       // }
+               }
+               return elements;
+       }
+
+       private ISourceRange getJSSourceRangeOf(IJavaScriptElement element) {
+               // returns the offset in html of given element
+               ISourceRange range = null;
+               if (element instanceof Member) {
+                       try {
+                               range = ((Member) element).getNameRange();
+                       } catch (JavaScriptModelException e) {
+                               // TODO Auto-generated catch block
+                               e.printStackTrace();
+                       }
+               }else if (element instanceof SourceRefElement) {
+                       try {
+                               range = ((SourceRefElement) element).getSourceRange();
+                       }
+                       catch (JavaScriptModelException e) {
+                               e.printStackTrace();
+                       }
+               }
+               return range;
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.wst.jsdt.web.core.internal.java.IJsTranslation#getJsText()
+        */
+       public String getJsText() {
+               return getTranslator().getJsText();
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.wst.jsdt.web.core.internal.java.IJsTranslation#getScriptPositions()
+        */
+       public Position[] getScriptPositions() {
+               return getTranslator().getHtmlLocations();
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.wst.jsdt.web.core.internal.java.IJsTranslation#insertInFirstScriptRegion(java.lang.String)
+        */
+       public void insertInFirstScriptRegion(String text) {
+               Position pos[] = getScriptPositions();
+               int scriptStartOffset = 0;
+               if(pos!=null && pos.length>0) {
+                       scriptStartOffset = pos[0].getOffset();
+                       
+               }
+               String insertText = (scriptStartOffset==0?"":"\n") + text;
+               insertScript(scriptStartOffset,insertText);
+               
+       }
+       
+       /* (non-Javadoc)
+        * @see org.eclipse.wst.jsdt.web.core.internal.java.IJsTranslation#insertScript(int, java.lang.String)
+        */
+       public void insertScript(int offset, String text) {
+
+               IDOMModel xmlModel = null;
+               Position[] inHtml = getScriptPositions();
+               boolean isInsideExistingScriptRegion = false;
+               for (int i = 0; i < inHtml.length; i++) {
+                       if (inHtml[i].overlapsWith(offset, 1)) {
+                               // * inserting into a script region
+                               isInsideExistingScriptRegion = true;
+                       }
+               }
+
+               String insertText = null;
+
+               if (isInsideExistingScriptRegion) {
+                       insertText = text;
+               }
+               else {
+                       insertText = offset != 0 ? "\n" : "" + "<script type=\"text/javascript\">\n" + text + "\n</script>\n";
+               }
+       //      translator.documentAboutToBeChanged(null);
+
+               synchronized (fLock) {
+                       try {
+                               xmlModel = (IDOMModel) StructuredModelManager.getModelManager().getExistingModelForEdit(fHtmlDocument);
+                               if (xmlModel == null) {
+                                       xmlModel = (IDOMModel) StructuredModelManager.getModelManager().getModelForEdit(fHtmlDocument);
+                               }
+                               if (xmlModel != null) {
+
+
+                                       xmlModel.aboutToChangeModel();
+                                       xmlModel.getDocument().getStructuredDocument().replaceText(this, offset, 0, insertText);
+                                       xmlModel.changedModel();
+                                       try {
+                                               xmlModel.save();
+                                       }
+
+                                       catch (UnsupportedEncodingException e) {}
+                                       catch (IOException e) {}
+                                       catch (CoreException e) {}
+                               }
+                       }
+                       finally {
+                               if (xmlModel != null)
+                                       xmlModel.releaseFromEdit();
+                       }
+               }
+
+       //      translator.documentChanged(null);
+
+       }
+
+       public String getMangledName() {
+               return this.mangledName;
+       }
+
+       private String createMangledName() {
+               return JsNameManglerUtil.mangle(fModelBaseLocation);
+       }
+
+       /**
+        * 
+        * @return the problem requestor for the JavaScriptUnit in this
+        *         JsTranslation
+        */
+       private JsProblemRequestor getProblemRequestor() {
+               return CompilationUnitHelper.getInstance().getProblemRequestor();
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.wst.jsdt.web.core.internal.java.IJsTranslation#getProblems()
+        */
+       public List getProblems() {
+               List problemList = getProblemRequestor().getCollectedProblems();
+               getProblemRequestor().endReporting();
+               IProblem[] problems = null;
+               if (problemList == null)
+                       problems = new IProblem[0];
+               else 
+                       problems = (IProblem[]) problemList.toArray(new IProblem[problemList.size()]);
+               
+               IJsTranslator translator = getTranslator();
+               if (translator instanceof JsTranslator && problems.length > 0) {
+                       Region[] generatedRanges = ((JsTranslator) translator).getGeneratedRanges();
+                       for (int i = 0; i < problems.length; i++) {
+                               for (int j = 0; j < generatedRanges.length; j++) {
+                                       // remove any problems that are fully reported within a region generated by the translator
+                                       if (problems[i].getSourceStart() >= generatedRanges[j].getOffset() && problems[i].getSourceEnd() <= (generatedRanges[j].getOffset() + generatedRanges[j].getLength())) {
+                                               problemList.remove(problems[i]);
+                                       }
+                               }
+                       }
+               }
+               return problemList;
+       }
+
+       private IProgressMonitor getProgressMonitor() {
+               if (fProgressMonitor == null) {
+                       fProgressMonitor = new NullProgressMonitor();
+               }
+               return fProgressMonitor;
+       }
+
+       public WorkingCopyOwner getWorkingCopyOwner() {
+               return CompilationUnitHelper.getInstance().getWorkingCopyOwner();
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.wst.jsdt.web.core.internal.java.IJsTranslation#ifOffsetInImportNode(int)
+        */
+       public boolean ifOffsetInImportNode(int offset) {
+               Position[] importRanges = getTranslator().getImportHtmlRanges();
+               for (int i = 0; i < importRanges.length; i++) {
+                       if (importRanges[i].includes(offset)) {
+                               return true;
+                       }
+               }
+               return false;
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.wst.jsdt.web.core.internal.java.IJsTranslation#reconcileCompilationUnit()
+        */
+       public void reconcileCompilationUnit() {
+               // if(true) return;
+               IJavaScriptUnit cu = getCompilationUnit();
+               if (fCompilationUnit == null) {
+                       return;
+               }
+               if (cu != null) {
+                       try {
+                               synchronized (fLock) {
+                                       // clear out old validation messages
+                                       WorkingCopyOwner workingCopyOwner = getWorkingCopyOwner();
+                                       JsProblemRequestor problemRequestor = (JsProblemRequestor) workingCopyOwner.getProblemRequestor(cu.getWorkingCopy(getProgressMonitor()));
+                                       if(problemRequestor != null && problemRequestor.getCollectedProblems() != null)
+                                               problemRequestor.getCollectedProblems().clear();
+                                       cu.reconcile(IJavaScriptUnit.NO_AST, true, true, getWorkingCopyOwner(), getProgressMonitor());
+                               }
+                       }
+                       catch (JavaScriptModelException e) {
+                               Logger.logException(e);
+                       }
+               }
+       }
+
+
+       /* (non-Javadoc)
+        * @see org.eclipse.wst.jsdt.web.core.internal.java.IJsTranslation#release()
+        */
+       public void release() {
+               if (getTranslator() != null)
+                       getTranslator().release();
+               synchronized (fLock) {
+                       if (fCompilationUnit != null) {
+                               try {
+                                       if (JsTranslation.DEBUG) {
+                                               System.out.println("------------------------------------------------------------------"); //$NON-NLS-1$
+                                               System.out.println("(-) JsTranslation [" + this + "] discarding JavaScriptUnit: " + fCompilationUnit); //$NON-NLS-1$ //$NON-NLS-2$
+                                               System.out.println("------------------------------------------------------------------"); //$NON-NLS-1$
+                                       }
+                                       fCompilationUnit.discardWorkingCopy();
+                               }
+                               catch (JavaScriptModelException e) {
+                                       // we're done w/ it anyway
+                               }
+                       }
+               }
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.wst.jsdt.web.core.internal.java.IJsTranslation#setProblemCollectingActive(boolean)
+        */
+       public void setProblemCollectingActive(boolean collect) {
+               IJavaScriptUnit cu = getCompilationUnit();
+               if (cu != null) {
+                       getProblemRequestor().setIsActive(collect);
+               }
+       }
+
+       public void classpathChange() {
+
+               if (fDocumentScope != null) {
+                       fDocumentScope.classpathChange();
+               }
+       }
+}
\ No newline at end of file
diff --git a/org.eclipse.wst.jsdt.web.core/.classpath b/org.eclipse.wst.jsdt.web.core/.classpath
new file mode 100644 (file)
index 0000000..52165ec
--- /dev/null
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+       <classpathentry kind="src" path="src/"/>
+       <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.4"/>
+       <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+       <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/org.eclipse.wst.jsdt.web.core/.options b/org.eclipse.wst.jsdt.web.core/.options
new file mode 100644 (file)
index 0000000..4ac5072
--- /dev/null
@@ -0,0 +1,12 @@
+org.eclipse.wst.jsdt.web.core/debug=true
+org.eclipse.wst.jsdt.web.core/debug/tracefilter=
+org.eclipse.wst.jsdt.web.core/debug/jsindexmanager=false
+org.eclipse.wst.jsdt.web.core/debug/jstranslation=false
+org.eclipse.wst.jsdt.web.core/debug/jstranslationstodisk=false
+org.eclipse.wst.jsdt.web.core/debug/jssearch=false
+
+org.eclipse.wst.jsdt.web.core/taglib/resolve=false
+
+org.eclipse.wst.jsdt.web.core/debug/jsjavamapping=false
+
+org.eclipse.wst.jsdt.web.core/debug/jsvalidator=false
\ No newline at end of file
diff --git a/org.eclipse.wst.jsdt.web.core/.project b/org.eclipse.wst.jsdt.web.core/.project
new file mode 100644 (file)
index 0000000..22cb875
--- /dev/null
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+       <name>org.eclipse.wst.jsdt.web.core</name>
+       <comment></comment>
+       <projects>
+       </projects>
+       <buildSpec>
+               <buildCommand>
+                       <name>org.eclipse.jdt.core.javabuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+               <buildCommand>
+                       <name>org.eclipse.pde.ManifestBuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+               <buildCommand>
+                       <name>org.eclipse.pde.SchemaBuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+       </buildSpec>
+       <natures>
+               <nature>org.eclipse.jdt.core.javanature</nature>
+               <nature>org.eclipse.pde.PluginNature</nature>
+       </natures>
+</projectDescription>
diff --git a/org.eclipse.wst.jsdt.web.core/.settings/org.eclipse.core.resources.prefs b/org.eclipse.wst.jsdt.web.core/.settings/org.eclipse.core.resources.prefs
new file mode 100644 (file)
index 0000000..afa5c91
--- /dev/null
@@ -0,0 +1,3 @@
+#Tue Apr 04 03:36:32 EDT 2006
+eclipse.preferences.version=1
+encoding/<project>=ISO-8859-1
diff --git a/org.eclipse.wst.jsdt.web.core/.settings/org.eclipse.core.runtime.prefs b/org.eclipse.wst.jsdt.web.core/.settings/org.eclipse.core.runtime.prefs
new file mode 100644 (file)
index 0000000..7ec5750
--- /dev/null
@@ -0,0 +1,3 @@
+#Mon Apr 17 01:48:39 EDT 2006
+eclipse.preferences.version=1
+line.separator=\r\n
diff --git a/org.eclipse.wst.jsdt.web.core/.settings/org.eclipse.jdt.core.prefs b/org.eclipse.wst.jsdt.web.core/.settings/org.eclipse.jdt.core.prefs
new file mode 100644 (file)
index 0000000..6e07215
--- /dev/null
@@ -0,0 +1,96 @@
+#Wed Oct 24 19:49:45 EDT 2007
+eclipse.preferences.version=1
+org.eclipse.jdt.core.builder.cleanOutputFolder=clean
+org.eclipse.jdt.core.builder.duplicateResourceTask=warning
+org.eclipse.jdt.core.builder.invalidClasspath=ignore
+org.eclipse.jdt.core.builder.resourceCopyExclusionFilter=*.launch
+org.eclipse.jdt.core.circularClasspath=error
+org.eclipse.jdt.core.classpath.exclusionPatterns=enabled
+org.eclipse.jdt.core.classpath.multipleOutputLocations=enabled
+org.eclipse.jdt.core.codeComplete.argumentPrefixes=
+org.eclipse.jdt.core.codeComplete.argumentSuffixes=
+org.eclipse.jdt.core.codeComplete.fieldPrefixes=
+org.eclipse.jdt.core.codeComplete.fieldSuffixes=
+org.eclipse.jdt.core.codeComplete.localPrefixes=
+org.eclipse.jdt.core.codeComplete.localSuffixes=
+org.eclipse.jdt.core.codeComplete.staticFieldPrefixes=
+org.eclipse.jdt.core.codeComplete.staticFieldSuffixes=
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=disabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.2
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.4
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.doc.comment.support=enabled
+org.eclipse.jdt.core.compiler.maxProblemPerUnit=100
+org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=warning
+org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
+org.eclipse.jdt.core.compiler.problem.deprecation=ignore
+org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
+org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=enabled
+org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
+org.eclipse.jdt.core.compiler.problem.emptyStatement=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=warning
+org.eclipse.jdt.core.compiler.problem.fallthroughCase=warning
+org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled
+org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore
+org.eclipse.jdt.core.compiler.problem.finalParameterBound=ignore
+org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=error
+org.eclipse.jdt.core.compiler.problem.forbiddenReference=error
+org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning
+org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
+org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore
+org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=error
+org.eclipse.jdt.core.compiler.problem.invalidJavadoc=ignore
+org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsDeprecatedRef=enabled
+org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsNotVisibleRef=enabled
+org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility=private
+org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore
+org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=error
+org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore
+org.eclipse.jdt.core.compiler.problem.missingJavadocComments=ignore
+org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsOverriding=enabled
+org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsVisibility=public
+org.eclipse.jdt.core.compiler.problem.missingJavadocTags=ignore
+org.eclipse.jdt.core.compiler.problem.missingJavadocTagsOverriding=enabled
+org.eclipse.jdt.core.compiler.problem.missingJavadocTagsVisibility=private
+org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore
+org.eclipse.jdt.core.compiler.problem.missingSerialVersion=error
+org.eclipse.jdt.core.compiler.problem.noEffectAssignment=error
+org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
+org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore
+org.eclipse.jdt.core.compiler.problem.nullReference=ignore
+org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning
+org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore
+org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=error
+org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore
+org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning
+org.eclipse.jdt.core.compiler.problem.redundantNullCheck=warning
+org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=enabled
+org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=error
+org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
+org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore
+org.eclipse.jdt.core.compiler.problem.typeParameterHiding=ignore
+org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
+org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
+org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
+org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
+org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning
+org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled
+org.eclipse.jdt.core.compiler.problem.unusedImport=error
+org.eclipse.jdt.core.compiler.problem.unusedLabel=error
+org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
+org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore
+org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled
+org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
+org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
+org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
+org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
+org.eclipse.jdt.core.compiler.source=1.3
+org.eclipse.jdt.core.incompatibleJDKLevel=ignore
+org.eclipse.jdt.core.incompleteClasspath=error
diff --git a/org.eclipse.wst.jsdt.web.core/.settings/org.eclipse.jdt.ui.prefs b/org.eclipse.wst.jsdt.web.core/.settings/org.eclipse.jdt.ui.prefs
new file mode 100644 (file)
index 0000000..c91d09d
--- /dev/null
@@ -0,0 +1,51 @@
+#Wed Oct 24 19:41:31 EDT 2007
+cleanup.add_default_serial_version_id=true
+cleanup.add_generated_serial_version_id=false
+cleanup.add_missing_annotations=false
+cleanup.add_missing_deprecated_annotations=true
+cleanup.add_missing_nls_tags=false
+cleanup.add_missing_override_annotations=true
+cleanup.add_serial_version_id=true
+cleanup.always_use_blocks=true
+cleanup.always_use_parentheses_in_expressions=true
+cleanup.always_use_this_for_non_static_field_access=false
+cleanup.always_use_this_for_non_static_method_access=false
+cleanup.convert_to_enhanced_for_loop=false
+cleanup.format_source_code=false
+cleanup.make_local_variable_final=true
+cleanup.make_parameters_final=false
+cleanup.make_private_fields_final=true
+cleanup.make_variable_declarations_final=false
+cleanup.never_use_blocks=false
+cleanup.never_use_parentheses_in_expressions=false
+cleanup.organize_imports=true
+cleanup.qualify_static_field_accesses_with_declaring_class=false
+cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true
+cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true
+cleanup.qualify_static_member_accesses_with_declaring_class=true
+cleanup.qualify_static_method_accesses_with_declaring_class=false
+cleanup.remove_private_constructors=true
+cleanup.remove_unnecessary_casts=true
+cleanup.remove_unnecessary_nls_tags=true
+cleanup.remove_unused_imports=true
+cleanup.remove_unused_local_variables=false
+cleanup.remove_unused_private_fields=true
+cleanup.remove_unused_private_members=true
+cleanup.remove_unused_private_methods=true
+cleanup.remove_unused_private_types=true
+cleanup.use_blocks=true
+cleanup.use_blocks_only_for_return_and_throw=false
+cleanup.use_parentheses_in_expressions=true
+cleanup.use_this_for_non_static_field_access=false
+cleanup.use_this_for_non_static_field_access_only_if_necessary=true
+cleanup.use_this_for_non_static_method_access=false
+cleanup.use_this_for_non_static_method_access_only_if_necessary=true
+cleanup_profile=_SSE Team Styles
+cleanup_settings_version=2
+eclipse.preferences.version=1
+internal.default.compliance=default
+org.eclipse.jdt.ui.exception.name=e
+org.eclipse.jdt.ui.gettersetter.use.is=true
+org.eclipse.jdt.ui.keywordthis=false
+org.eclipse.jdt.ui.overrideannotation=false
+org.eclipse.jdt.ui.text.custom_code_templates=<?xml version\="1.0" encoding\="UTF-8"?><templates/>
diff --git a/org.eclipse.wst.jsdt.web.core/.settings/org.eclipse.ltk.core.refactoring.prefs b/org.eclipse.wst.jsdt.web.core/.settings/org.eclipse.ltk.core.refactoring.prefs
new file mode 100644 (file)
index 0000000..c59368c
--- /dev/null
@@ -0,0 +1,3 @@
+#Tue Apr 04 03:36:32 EDT 2006
+eclipse.preferences.version=1
+org.eclipse.ltk.core.refactoring.enable.project.refactoring.history=false
diff --git a/org.eclipse.wst.jsdt.web.core/.settings/org.eclipse.pde.prefs b/org.eclipse.wst.jsdt.web.core/.settings/org.eclipse.pde.prefs
new file mode 100644 (file)
index 0000000..fc522bb
--- /dev/null
@@ -0,0 +1,16 @@
+#Mon Apr 17 02:01:33 EDT 2006
+compilers.incompatible-environment=0
+compilers.p.build=0
+compilers.p.deprecated=1
+compilers.p.illegal-att-value=0
+compilers.p.no-required-att=0
+compilers.p.not-externalized-att=0
+compilers.p.unknown-attribute=0
+compilers.p.unknown-class=0
+compilers.p.unknown-element=0
+compilers.p.unknown-resource=0
+compilers.p.unresolved-ex-points=0
+compilers.p.unresolved-import=0
+compilers.p.unused-element-or-attribute=0
+compilers.use-project=true
+eclipse.preferences.version=1
diff --git a/org.eclipse.wst.jsdt.web.core/META-INF/MANIFEST.MF b/org.eclipse.wst.jsdt.web.core/META-INF/MANIFEST.MF
new file mode 100644 (file)
index 0000000..4b20fc1
--- /dev/null
@@ -0,0 +1,37 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: %Bundle-Name.0
+Bundle-SymbolicName: org.eclipse.wst.jsdt.web.core;singleton:=true
+Bundle-Version: 1.0.401.v201108152113_patch
+Bundle-Activator: org.eclipse.wst.jsdt.web.core.internal.JsCorePlugin
+Bundle-Vendor: %Bundle-Vendor.0
+Bundle-Localization: plugin
+Export-Package: org.eclipse.wst.jsdt.web.core.internal;x-internal:=true,
+ org.eclipse.wst.jsdt.web.core.internal.modelhandler;x-internal:=true,
+ org.eclipse.wst.jsdt.web.core.internal.project;x-internal:=true;
+  uses:="org.eclipse.wst.common.project.facet.core,
+   org.eclipse.wst.jsdt.internal.core,
+   org.eclipse.wst.jsdt.core,
+   org.eclipse.core.resources,
+   org.eclipse.core.runtime",
+ org.eclipse.wst.jsdt.web.core.internal.provisional.contenttype;x-internal:=true,
+ org.eclipse.wst.jsdt.web.core.internal.validation;x-internal:=true,
+ org.eclipse.wst.jsdt.web.core.javascript,
+ org.eclipse.wst.jsdt.web.core.javascript.search,
+ org.eclipse.wst.jsdt.web.core.text
+Import-Package: com.ibm.icu.util; version="3.8"
+Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.5.0,4.0.0)",
+ org.eclipse.core.resources;bundle-version="[3.5.0,4.0.0)",
+ org.eclipse.core.filebuffers;bundle-version="[3.5.0,4.0.0)",
+ org.eclipse.wst.sse.core;bundle-version="[1.1.504,1.2.0)",
+ org.eclipse.wst.xml.core;bundle-version="[1.1.500,1.2.0)",
+ org.eclipse.wst.html.core;bundle-version="[1.1.400,1.2.0)",
+ org.eclipse.wst.validation;bundle-version="[1.2.100,2.0.0)",
+ org.eclipse.wst.jsdt.core;bundle-version="[1.1.0,2.0.0)",
+ org.eclipse.wst.common.project.facet.core;bundle-version="[1.4.0,2.0.0)";resolution:=optional,
+ org.eclipse.wst.common.modulecore;bundle-version="[1.1.0,2.0.0)";resolution:=optional
+Bundle-RequiredExecutionEnvironment: J2SE-1.4
+Bundle-ActivationPolicy: lazy;exclude:="org.eclipse.wst.jsdt.web.core.internal.project"
+Eclipse-ExtensibleAPI: true
+Bundle-ClassPath: library.jar,
+ .
diff --git a/org.eclipse.wst.jsdt.web.core/about.html b/org.eclipse.wst.jsdt.web.core/about.html
new file mode 100644 (file)
index 0000000..4602330
--- /dev/null
@@ -0,0 +1,28 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
+<title>About</title>
+</head>
+<body lang="EN-US">
+<h2>About This Content</h2>
+<p>June 2, 2006</p>    
+<h3>License</h3>
+
+<p>The Eclipse Foundation makes available all content in this plug-in (&quot;Content&quot;).  Unless otherwise 
+indicated below, the Content is provided to you under the terms and conditions of the
+Eclipse Public License Version 1.0 (&quot;EPL&quot;).  A copy of the EPL is available 
+at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
+For purposes of the EPL, &quot;Program&quot; will mean the Content.</p>
+
+<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is 
+being redistributed by another party (&quot;Redistributor&quot;) and different terms and conditions may
+apply to your use of any object code in the Content.  Check the Redistributor's license that was 
+provided with the Content.  If no such license exists, contact the Redistributor.  Unless otherwise
+indicated below, the terms and conditions of the EPL still apply to any source code in the Content
+and such source code may be obtained at <a href="http://www.eclipse.org">http://www.eclipse.org</a>.</p>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/org.eclipse.wst.jsdt.web.core/build.properties b/org.eclipse.wst.jsdt.web.core/build.properties
new file mode 100644 (file)
index 0000000..062187d
--- /dev/null
@@ -0,0 +1,21 @@
+###############################################################################
+# 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
+###############################################################################
+source.. = src/
+bin.includes = .options,\
+               META-INF/,\
+               .,\
+               plugin.properties,\
+               plugin.xml,\
+               component.xml,\
+               about.html
+src.includes = component.xml
+jars.compile.order = .
+              
\ No newline at end of file
diff --git a/org.eclipse.wst.jsdt.web.core/component.xml b/org.eclipse.wst.jsdt.web.core/component.xml
new file mode 100644 (file)
index 0000000..0d66ac2
--- /dev/null
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<component xmlns="http://eclipse.org/wtp/releng/tools/component-model" name="org.eclipse.wst.jsdt.web">
+       <component-depends unrestricted="true" />
+       <plugin id="org.eclipse.wst.jsdt.web.core" fragment="false" />
+       <package name="org.eclipse.wst.jsdt.web.core.taglib" api="false">
+               <type name="IJarRecord" implement="false" />
+               <!-- <type name="ITagDirRecord" implement="false" /> -->
+               <!-- <type name="ITaglibIndexListener" implement="true" /> -->
+               <type name="ITaglibDescriptor" implement="false" />
+               <type name="ITaglibRecord" implement="false" />
+               <!-- <type name="ITaglibRecordEvent" implement="false" /> -->
+               <type name="ITLDRecord" implement="false" />
+               <type name="IURLRecord" implement="false" />
+               <type name="TaglibIndex" subclass="false" instantiate="false" />
+       </package>
+       <plugin id="org.eclipse.wst.jsdt.web.ui" fragment="false" />
+       <package name="org.eclipse.wst.jsdt.web.ui" api="false">
+               <type name="StructuredTextViewerConfigurationJSP" subclass="true" instantiate="true" />
+       </package>
+       <package name="org.eclipse.wst.jsdt.web.ui.views.contentoutline" api="false">
+               <type name="JSPContentOutlineConfiguration" subclass="true" instantiate="true" />
+       </package>
+       <plugin id="org.eclipse.wst.jsdt.web.ui.infopop" fragment="false" />
+       <description url="http://eclipse.org/webtools/jst/components/jsp/overview.html" />
+</component>
\ No newline at end of file
diff --git a/org.eclipse.wst.jsdt.web.core/plugin.properties b/org.eclipse.wst.jsdt.web.core/plugin.properties
new file mode 100644 (file)
index 0000000..c204259
--- /dev/null
@@ -0,0 +1,23 @@
+###############################################################################
+# Copyright (c) 2000, 2011 IBM Corporation and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+#     IBM Corporation - initial API and implementation
+###############################################################################
+
+pluginName= JavaScript Support
+providerName= Eclipse Web Tools Platform
+Bundle-Name.0 = JSDT Web Support Core 
+Bundle-Vendor.0 = Eclipse.org
+extension.name.0 = JavaScript Embedded
+extension.name.1 = Embedded JavaScript Builder
+extension-point.name.0 = JavaScript Pre Processing
+javascript.validator= Client-side JavaScript Validator
+problemMarker.name=Client-side JavaScript Problem
+facet.label=JavaScript
+facet.description=Enables JavaScript development using multiple source files in a configurable Include Path.
+
diff --git a/org.eclipse.wst.jsdt.web.core/plugin.xml b/org.eclipse.wst.jsdt.web.core/plugin.xml
new file mode 100644 (file)
index 0000000..6aa4408
--- /dev/null
@@ -0,0 +1,137 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.0"?>
+<plugin>
+   <extension-point id="javascriptPreProcessor" name="%extension-point.name.0" schema="schema/javascriptPreProcessor.exsd"/>
+   
+   <!-- Full blown JSDT FACET -->
+   <extension point="org.eclipse.wst.common.project.facet.core.facets">
+               <project-facet id="wst.jsdt.web">
+                       <label>%facet.label</label>
+                       <description>%facet.description</description>
+                       <default-version version="1.0"/>
+               </project-facet>
+       
+               <project-facet-version facet="wst.jsdt.web" version="1.0" />
+       
+               <action facet="wst.jsdt.web" type="install" id="wst.jsdt.web.install" version="1.0">
+                       <delegate class="org.eclipse.wst.jsdt.web.core.internal.project.JsNatureInstaller"/>
+               </action>
+       
+               <action facet="wst.jsdt.web" type="uninstall" id="wst.jsdt.web.uninstall" version="1.0">
+                       <delegate class="org.eclipse.wst.jsdt.web.core.internal.project.JsNatureUninstaller"/>
+               </action>
+       
+       </extension>
+       
+       <extension point="org.eclipse.wst.common.project.facet.core.runtimes">
+         <supported>
+           <facet id="wst.jsdt.web"/>
+           <runtime-component any="true"/>
+         </supported>
+
+       </extension>
+   
+   <extension point="org.eclipse.wst.jsdt.web.core.javascriptPreProcessor">
+               <javascriptPreProcessor
+                       class="org.eclipse.wst.jsdt.web.core.javascript.JsTranslation"
+                       priority="1" />
+   </extension>
+   
+   <!-- Install Handler for web JSDT.. Piggybacks on wst.web/jst.web facet-->
+   <extension point="org.eclipse.wst.common.project.facet.core.listeners">
+      <listener class="org.eclipse.wst.jsdt.web.core.internal.project.FacetedProjectListener" eventTypes="POST_INSTALL"/>
+   </extension>
+   
+  <!--
+   <extension point="org.eclipse.wst.common.project.facet.core.facets">
+   
+               <event-handler facet="wst.web" type="POST_INSTALL" version="[1.0">
+                       <delegate class="org.eclipse.wst.jsdt.web.core.internal.project.JsNatureInstaller"/>
+               </event-handler>
+       
+               <event-handler facet="wst.web" type="POST_UNINSTALL" version="[1.0">
+                       <delegate class="org.eclipse.wst.jsdt.web.core.internal.project.JsNatureUninstaller"/>
+               </event-handler>
+
+       </extension>
+       -->
+       <!-- removed due to JUnit failures during initial WTP build
+          <extension id="embeded.jsNature" name="%extension.name.0" point="org.eclipse.core.resources.natures"> 
+                  <runtime>          
+                       <run class="org.eclipse.wst.jsdt.web.core.internal.project.JsWebNature"/>       
+                  </runtime>       
+                  <builder id="org.eclipse.wst.jsdt.web.core.embeded.javascript"/>    
+          </extension> 
+       -->   
+
+               <!-- 
+               Not using this at the moment, but everythings in place if we need in the future. 
+           -->  
+          
+          <extension id="embeded.javascript" name="%extension.name.1" point="org.eclipse.core.resources.builders">       
+                       <builder hasNature="true" callOnEmptyDelta="true">                            
+                       <run class="org.eclipse.wst.jsdt.web.core.internal.IncrementalBuilder"/>      
+                  </builder>    
+          </extension>
+
+    <extension id="problem" point="org.eclipse.core.resources.markers" name="%problemMarker.name">
+        <super type="org.eclipse.wst.jsdt.core.problem"/>
+        <super type="org.eclipse.core.resources.problemmarker"/>
+        <super type="org.eclipse.core.resources.textmarker"/>
+        <persistent value="true"/>
+        <attribute name="id"/>
+        <attribute name="flags"/>
+        <attribute name="arguments"/>
+        <attribute name="categoryId"/>
+    </extension>   
+       
+       <!--======================================================================================-->
+       <!-- JS batch validation in Web files                                                     -->
+       <!--======================================================================================-->
+       <extension
+               id="JsBatchValidator"
+               name="%javascript.validator"
+               point="org.eclipse.wst.validation.validatorV2">
+      <validator
+            build="false"
+                       class="org.eclipse.wst.jsdt.web.core.internal.validation.JsValidator"
+            manual="false"
+            sourceid="org.eclipse.wst.jsdt.web.jssourcevalidator"
+            version="2"
+            markerId="org.eclipse.wst.jsdt.web.core.problem">
+         <include>
+            <rules>
+                               <projectNature id="org.eclipse.wst.jsdt.core.jsNature" />
+                       </rules>
+         </include>
+         <include>
+            <rules>
+                               <fileext caseSensitive="false" ext="html"/>
+                               <fileext caseSensitive="false" ext="xhtml"/>
+                               <fileext caseSensitive="false" ext="htm"/>
+                               <fileext caseSensitive="false" ext="htpl"/>
+                               <fileext caseSensitive="false" ext="jsp"/>
+                               <fileext caseSensitive="false" ext="jsf"/>
+                               <fileext caseSensitive="false" ext="jsv"/>
+                               <fileext caseSensitive="false" ext="jtpl"/>
+                               <contentType id="org.eclipse.wst.html.core.htmlsource"/>
+                               <contentType id="org.eclipse.jst.jsp.core.jspsource"/>
+                       </rules>
+         </include>
+         <group id="org.eclipse.wst.sse.core.structuredModelGroup"/>
+      </validator>
+       </extension>
+       
+       <extension  point="org.eclipse.wst.jsdt.core.JsGlobalScopeContainerInitializer">
+             <JsGlobalScopeContainerInitializer
+                   class="org.eclipse.wst.jsdt.web.core.internal.project.WebProjectJsGlobalScopeContainerInitializer"
+                   id="org.eclipse.wst.jsdt.launching.WebProject">
+             </JsGlobalScopeContainerInitializer>
+        </extension>
+       
+       <extension
+               id="webSourcePathProvider"
+               point="org.eclipse.wst.jsdt.core.sourcePathProvider">
+               <provider class="org.eclipse.wst.jsdt.web.core.internal.project.ModuleSourcePathProvider"/>
+       </extension>
+</plugin>
diff --git a/org.eclipse.wst.jsdt.web.core/schema/javascriptPreProcessor.exsd b/org.eclipse.wst.jsdt.web.core/schema/javascriptPreProcessor.exsd
new file mode 100644 (file)
index 0000000..82f6f30
--- /dev/null
@@ -0,0 +1,104 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.wst.jsdt.web.core" xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+      <appinfo>
+         <meta.schema plugin="org.eclipse.wst.jsdt.web.core" id="javascriptPreProcessor" name="JavaScript Pre Processing"/>
+      </appinfo>
+      <documentation>
+         [Enter description of this extension point.]
+      </documentation>
+   </annotation>
+
+   <element name="extension">
+      <complexType>
+         <sequence>
+            <element ref="javascriptPreProcessor"/>
+         </sequence>
+         <attribute name="point" type="string" use="required">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+            </annotation>
+         </attribute>
+         <attribute name="id" type="string">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+            </annotation>
+         </attribute>
+         <attribute name="name" type="string">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+               <appinfo>
+                  <meta.attribute translatable="true"/>
+               </appinfo>
+            </annotation>
+         </attribute>
+      </complexType>
+   </element>
+
+   <element name="javascriptPreProcessor">
+      <complexType>
+         <attribute name="class" type="string">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+               <appinfo>
+                  <meta.attribute kind="java" basedOn=":org.eclipse.wst.jsdt.web.core.javascript.IJsTranslation"/>
+               </appinfo>
+            </annotation>
+         </attribute>
+         <attribute name="priority" type="string">
+            <annotation>
+               <documentation>
+                  loading priority. the highest number wins.
+               </documentation>
+            </annotation>
+         </attribute>
+      </complexType>
+   </element>
+
+   <annotation>
+      <appinfo>
+         <meta.section type="since"/>
+      </appinfo>
+      <documentation>
+         [Enter the first release in which this extension point appears.]
+      </documentation>
+   </annotation>
+
+   <annotation>
+      <appinfo>
+         <meta.section type="examples"/>
+      </appinfo>
+      <documentation>
+         [Enter extension point usage example here.]
+      </documentation>
+   </annotation>
+
+   <annotation>
+      <appinfo>
+         <meta.section type="apiinfo"/>
+      </appinfo>
+      <documentation>
+         [Enter API information here.]
+      </documentation>
+   </annotation>
+
+   <annotation>
+      <appinfo>
+         <meta.section type="implementation"/>
+      </appinfo>
+      <documentation>
+         [Enter information about supplied implementation of this extension point.]
+      </documentation>
+   </annotation>
+
+
+</schema>
diff --git a/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/IncrementalBuilder.java b/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/IncrementalBuilder.java
new file mode 100644 (file)
index 0000000..443bdb7
--- /dev/null
@@ -0,0 +1,47 @@
+/*******************************************************************************
+ * 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.web.core.internal;
+
+import java.util.Map;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IncrementalProjectBuilder;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+
+/**
+*
+* Provisional API: This class/interface is part of an interim API that is still under development and expected to
+* change significantly before reaching stability. It is being made available at this early stage to solicit feedback
+* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
+* (repeatedly) as the API evolves.
+*/
+public class IncrementalBuilder extends IncrementalProjectBuilder {
+       public IncrementalBuilder() {
+               System.out.println("Unimplemented method:IncrementalProjectBuilder()"); //$NON-NLS-1$
+       }
+       
+       /*
+        * (non-Javadoc)
+        * 
+        * @see org.eclipse.core.resources.IncrementalProjectBuilder#build(int,
+        *      java.util.Map, org.eclipse.core.runtime.IProgressMonitor)
+        */
+       
+       protected IProject[] build(int kind, Map args, IProgressMonitor monitor) throws CoreException {
+               // TODO Auto-generated method stub
+               System.out.println("Unimplemented method:IncrementalBuilder.build"); //$NON-NLS-1$
+               return null;
+       }
+}
diff --git a/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/JSPCorePluginResources.properties b/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/JSPCorePluginResources.properties
new file mode 100644 (file)
index 0000000..06df843
--- /dev/null
@@ -0,0 +1,26 @@
+###############################################################################
+# Copyright (c) 2004, 2011 IBM Corporation and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+# 
+# Contributors:
+#     IBM Corporation - initial API and implementation
+###############################################################################
+JSPIndexManager_0=Updating JavaScript Index
+JSPIndexManager_2=JavaScript Indexer indexing {0} files
+JSP_Search=JavaScript Search - 
+JSPDocumentLoader_1=Program Error: structured model had no structuredDocument
+JSPEL_Syntax=EL Syntax Error 
+JSPEL_Token=Unable to analyse EL expression due to lexical analysis error
+MESSAGE_JSP_VALIDATING_MESSAGE_UI_=JavaScript Validator validating {0}
+JSPFContentPropertiesManager_Updating=Updating JavaScript Fragment Content Settings
+JSPFContentPropertiesManager_Problems_Updating=Problem saving JavaScript Fragment Content Settings for {0}
+JSPDirectiveValidator_0={0} is a reserved prefix.  Try another
+JSPDirectiveValidator_1=Cannot find the tag library descriptor for {0}
+JSPDirectiveValidator_2=The prefix {0} is used more than once
+JSPDirectiveValidator_3=A {0} value is required in this directive
+JSPBatchValidator_0=Gathering files in {0}
+#
+model_initialization=Initializing Client-side JavaScript tooling
\ No newline at end of file
diff --git a/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/JSWebResourceEventManager.java b/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/JSWebResourceEventManager.java
new file mode 100644 (file)
index 0000000..c762a74
--- /dev/null
@@ -0,0 +1,257 @@
+/*******************************************************************************
+ * Copyright (c) 2011 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.web.core.internal;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.wst.common.componentcore.ComponentCore;
+import org.eclipse.wst.common.componentcore.ModuleCoreNature;
+import org.eclipse.wst.common.componentcore.resources.IVirtualFile;
+import org.eclipse.wst.jsdt.core.IIncludePathAttribute;
+import org.eclipse.wst.jsdt.core.IIncludePathEntry;
+import org.eclipse.wst.jsdt.core.JavaScriptCore;
+import org.eclipse.wst.jsdt.internal.core.ClasspathEntry;
+import org.eclipse.wst.jsdt.internal.core.JavaProject;
+import org.eclipse.wst.jsdt.internal.core.util.Messages;
+import org.eclipse.wst.jsdt.web.core.internal.project.ModuleSourcePathProvider;
+import org.eclipse.wst.sse.core.indexing.AbstractIndexManager;
+
+/**
+ * <p>This is an implementation of the {@link AbstractIndexManager} for the JavaScript Web core plugin.</p>
+ * 
+ * <p>Current Uses:
+ * <ul>
+ * <li>listen for .project changes so that JavaScript class paths can be updated
+ * if the module core nature is added to a project</li>
+ * </ul></p>
+ * 
+ * <p><b>NOTE:</b> If any other file resource change listening needs to take place in the future
+ * in this plugin it should be done here.</p>
+ */
+public class JSWebResourceEventManager extends AbstractIndexManager {
+       /** the singleton instance of the {@link JSWebResourceEventManager} */
+       private static JSWebResourceEventManager INSTANCE;
+       
+       /** the name of the ".project" file where natures are stored */
+       private static final String DOT_PROJECT_FILE_NAME = ".project"; //$NON-NLS-1$
+       
+       /** the location to store state */
+       private IPath fWorkingLocation;
+       
+       /**
+        * <p>Private constructor for the resource event manager</p>
+        */
+       private JSWebResourceEventManager() {
+               super(Messages.build_analyzingDeltas, Messages.build_analyzingDeltas,
+                               JsCoreMessages.model_initialization, Messages.manager_filesToIndex);
+       }
+       
+       /**
+        * @return the singleton instance of the {@link JSWebResourceEventManager}
+        */
+       public static JSWebResourceEventManager getDefault() {
+               return INSTANCE != null ? INSTANCE : (INSTANCE = new JSWebResourceEventManager());
+       }
+
+       /**
+        * @see org.eclipse.wst.sse.core.indexing.AbstractIndexManager#isResourceToIndex(int, org.eclipse.core.runtime.IPath)
+        */
+       protected boolean isResourceToIndex(int type, IPath path) {
+               return 
+                       type == IResource.ROOT ||
+                       type == IResource.PROJECT || 
+                       (type == IResource.FILE && DOT_PROJECT_FILE_NAME.equals(path.lastSegment()));
+       }
+
+       /**
+        * @see org.eclipse.wst.sse.core.indexing.AbstractIndexManager#performAction(byte, byte, org.eclipse.core.resources.IResource, org.eclipse.core.runtime.IPath)
+        */
+       protected void performAction(byte source, byte action, IResource resource,
+                       IPath movePath) {
+               
+               switch(action) {
+                       case(AbstractIndexManager.ACTION_ADD): {
+                               if(resource.getName().equals(DOT_PROJECT_FILE_NAME)) {
+                                       updateClassPathEntries(resource.getProject());
+                               }
+                               break;
+                       }
+               }
+
+       }
+
+       /**
+        * @see org.eclipse.wst.sse.core.indexing.AbstractIndexManager#getWorkingLocation()
+        */
+       protected IPath getWorkingLocation() {
+               if(this.fWorkingLocation == null) {
+                       //create path to working area
+               IPath workingLocation =
+                       JsCorePlugin.getDefault().getStateLocation().append("resourceEventManager"); //$NON-NLS-1$
+
+            // ensure that it exists on disk
+            File folder = new File(workingLocation.toOSString());
+               if (!folder.isDirectory()) {
+                       try {
+                               folder.mkdir();
+                       }
+                       catch (SecurityException e) {
+                               Logger.logException(this.getName() +
+                                               ": Error while creating state location: " + folder + //$NON-NLS-1$
+                                               " This renders the index manager irrevocably broken for this workspace session", //$NON-NLS-1$
+                                               e);
+                       }
+               }
+               
+               this.fWorkingLocation = workingLocation;
+       }
+       
+        return this.fWorkingLocation;
+       }
+       
+       /**
+        * <p>Updates the JavaScript class path entries for the given project if
+        * both the Module core and JavaScript natures are installed on that project.</p>
+        *
+        * @param project {@link IProject} to update the JavaScript class path entries for
+        */
+       private static void updateClassPathEntries(IProject project) {
+               try {
+                       /*
+                        * if a JS project with Module Core nature, check if include path
+                        * needs to be updated
+                        */
+                       if (project.hasNature(JavaScriptCore.NATURE_ID) && ModuleCoreNature.isFlexibleProject(project)) {
+                               JavaProject jsProject = (JavaProject) JavaScriptCore.create(project);
+
+                               IIncludePathEntry[] oldEntries = jsProject.getRawIncludepath();
+                               List updatedEntries = new ArrayList();
+                               boolean updateIncludePath = false;
+
+                               for (int oldEntry = 0; oldEntry < oldEntries.length; ++oldEntry) {
+                                       IIncludePathAttribute[] entryAttributes = oldEntries[oldEntry].getExtraAttributes();
+
+                                       boolean isProvidedEntry = false;
+                                       for (int attribute = 0; attribute < entryAttributes.length; ++attribute) {
+                                               isProvidedEntry = entryAttributes[attribute].getName().equals(ModuleSourcePathProvider.PROVIDER_ATTRIBUTE_KEY_NAME) && entryAttributes[attribute].getValue().equals(ModuleSourcePathProvider.PROVIDER_ATTRIBUTE_KEY_VALUE);
+                                               updateIncludePath |= isProvidedEntry;
+                                               if (isProvidedEntry) {
+                                                       /*
+                                                        * create updated exclusion paths that are not
+                                                        * relative to the parent entry
+                                                        */
+                                                       IPath[] nonRelativeExclusionPaths = oldEntries[oldEntry].getExclusionPatterns();
+                                                       for (int i = 0; i < nonRelativeExclusionPaths.length; ++i) {
+                                                               nonRelativeExclusionPaths[i] = oldEntries[oldEntry].getPath().append(nonRelativeExclusionPaths[i]);
+                                                       }
+
+                                                       /*
+                                                        * create updated inclusion paths that are not
+                                                        * relative to the parent entry
+                                                        */
+                                                       IPath[] nonRelativeInclusionPaths = oldEntries[oldEntry].getInclusionPatterns();
+                                                       for (int i = 0; i < nonRelativeInclusionPaths.length; ++i) {
+                                                               nonRelativeInclusionPaths[i] = oldEntries[oldEntry].getPath().append(nonRelativeInclusionPaths[i]);
+                                                       }
+
+                                                       IResource[] roots = getRoots(project);
+                                                       IIncludePathEntry[] resolvedEntries = jsProject.getResolvedClasspath();
+                                                       for (int root = 0; root < roots.length; ++root) {
+                                                               IPath rootPath = roots[root].getFullPath();
+                                                               
+                                                               // make sure we do not create a source entry that conflicts with an existing library
+                                                               boolean foundMatch = false;
+                                                               for(int k = 0; k < resolvedEntries.length; k++) {
+                                                                       if(resolvedEntries[k].getPath().equals(rootPath)) {
+                                                                               foundMatch = true;
+                                                                               break;
+                                                                       }
+                                                               }
+                                                               if(foundMatch)
+                                                                       continue;
+
+                                                               /*
+                                                                * find matching pre-existing exclusion
+                                                                * patterns
+                                                                */
+                                                               List exclusionPatterns = new ArrayList();
+                                                               for (int i = 0; i < nonRelativeExclusionPaths.length; ++i) {
+                                                                       IPath parentRelativeExclusionPattern = PathUtils.makePatternRelativeToParent(nonRelativeExclusionPaths[i], rootPath);
+                                                                       if (parentRelativeExclusionPattern != null) {
+                                                                               exclusionPatterns.add(parentRelativeExclusionPattern);
+                                                                       }
+                                                               }
+
+                                                               /*
+                                                                * find matching pre-existing inclusion
+                                                                * patterns
+                                                                */
+                                                               List inclusionPatterns = new ArrayList();
+                                                               for (int i = 0; i < nonRelativeInclusionPaths.length; ++i) {
+                                                                       IPath parentRelativeInclusionPattern = PathUtils.makePatternRelativeToParent(nonRelativeInclusionPaths[i], rootPath);
+                                                                       if (parentRelativeInclusionPattern != null) {
+                                                                               inclusionPatterns.add(parentRelativeInclusionPattern);
+                                                                       }
+                                                               }
+
+                                                               // create new inclusion/exclusion rules
+                                                               IPath[] exclusionPaths = exclusionPatterns.isEmpty() ? ClasspathEntry.EXCLUDE_NONE : (IPath[]) exclusionPatterns.toArray(new IPath[exclusionPatterns.size()]);
+                                                               IPath[] inclusionPaths = inclusionPatterns.isEmpty() ? ClasspathEntry.INCLUDE_ALL : (IPath[]) inclusionPatterns.toArray(new IPath[inclusionPatterns.size()]);
+
+                                                               IIncludePathEntry newEntry = JavaScriptCore.newSourceEntry(rootPath, inclusionPaths, exclusionPaths, null);
+                                                               updatedEntries.add(newEntry);
+                                                       }
+                                               }
+                                       }
+                                       if (!isProvidedEntry) {
+                                               updatedEntries.add(oldEntries[oldEntry]);
+                                       }
+                               }
+
+                               /*
+                                * if found that a default source path was added, replace with
+                                * module core determined path
+                                */
+                               if (updateIncludePath) {
+                                       // commit the updated include path
+                                       jsProject.setRawIncludepath((IIncludePathEntry[]) updatedEntries.toArray(new IIncludePathEntry[updatedEntries.size()]), jsProject.getOutputLocation(), null);
+                               }
+                       }
+               }
+               catch (CoreException e) {
+                       Logger.logException("Error while updating JavaScript includepath", e); //$NON-NLS-1$
+               }
+       }
+       
+       /**
+        * <p>Uses module core to get the roots of the given project.</p>
+        *
+        * @param project find the module core roots for this {@link IProject}
+        * @return the module core roots for the given {@link IProject
+        */
+       private static IResource[] getRoots(IProject project) {
+               IVirtualFile root = ComponentCore.createFile(project, Path.ROOT);
+               IResource[] underlyingResources = root.getUnderlyingResources();
+               if (underlyingResources == null || underlyingResources.length == 0) {
+                       underlyingResources = new IResource[]{root.getUnderlyingResource()};
+               }
+               
+               return underlyingResources;
+       }
+}
\ No newline at end of file
diff --git a/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/JsCoreMessages.java b/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/JsCoreMessages.java
new file mode 100644 (file)
index 0000000..28adafc
--- /dev/null
@@ -0,0 +1,48 @@
+/*******************************************************************************
+ * 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.web.core.internal;
+
+import org.eclipse.osgi.util.NLS;
+/**
+*
+* Provisional API: This class/interface is part of an interim API that is still under development and expected to
+* change significantly before reaching stability. It is being made available at this early stage to solicit feedback
+* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
+* (repeatedly) as the API evolves.
+*/
+public class JsCoreMessages extends NLS {
+       private static final String BUNDLE_NAME = "org.eclipse.wst.jsdt.web.core.internal.JSPCorePluginResources"; //$NON-NLS-1$
+       public static String JSP_Search;
+       public static String JSPBatchValidator_0;
+       public static String JSPDirectiveValidator_0;
+       public static String JSPDirectiveValidator_1;
+       public static String JSPDirectiveValidator_2;
+       public static String JSPDirectiveValidator_3;
+       public static String JSPDocumentLoader_1;
+       public static String JSPEL_Syntax;
+       public static String JSPEL_Token;
+       public static String JSPFContentPropertiesManager_Problems_Updating;
+       public static String JSPFContentPropertiesManager_Updating;
+       public static String JSPIndexManager_0;
+       public static String JSPIndexManager_2;
+       public static String model_initialization;
+       /**
+        * @deprecated
+        */
+
+       public static String MESSAGE_JSP_VALIDATING_MESSAGE_UI_;
+       static {
+               // initialize resource bundle
+               NLS.initializeMessages(JsCoreMessages.BUNDLE_NAME, JsCoreMessages.class);
+       }
+       
+       private JsCoreMessages() {}
+}
diff --git a/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/JsCorePlugin.java b/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/JsCorePlugin.java
new file mode 100644 (file)
index 0000000..6fd1201
--- /dev/null
@@ -0,0 +1,220 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2011 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.web.core.internal;
+
+import org.eclipse.core.resources.IResourceChangeEvent;
+import org.eclipse.core.resources.IResourceChangeListener;
+import org.eclipse.core.resources.ISaveContext;
+import org.eclipse.core.resources.ISaveParticipant;
+import org.eclipse.core.resources.ISavedState;
+import org.eclipse.core.resources.IWorkspace;
+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.Plugin;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.wst.jsdt.web.core.javascript.search.JsIndexManager;
+import org.osgi.framework.BundleContext;
+
+public class JsCorePlugin extends Plugin {
+       /**
+        * <p>
+        * A {@link Job} used to perform delayed initialization for the plug-in
+        * </p>
+        */
+       private static class PluginInitializerJob extends Job {
+               /**
+                * <p>
+                * Default constructor to set up this {@link Job} as a long running
+                * system {@link Job}
+                * </p>
+                */
+               PluginInitializerJob() {
+                       super(JsCoreMessages.model_initialization);
+
+                       this.setUser(false);
+                       this.setSystem(true);
+                       this.setPriority(Job.LONG);
+               }
+
+               /**
+                * <p>
+                * Perform delayed initialization for the plugin
+                * </p>
+                * 
+                * @see org.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime.IProgressMonitor)
+                */
+               protected IStatus run(IProgressMonitor monitor) {
+                       IStatus status = Status.OK_STATUS;
+                       final IWorkspace workspace = ResourcesPlugin.getWorkspace();
+                       try {
+                               /*
+                                * Restore save state and process any events that happened
+                                * before plug-in loaded. Don't do it immediately since adding
+                                * the save participant requires a lock on the workspace to
+                                * compute the accumulated deltas, and if the tree is not
+                                * already locked it becomes a blocking call.
+                                */
+                               IWorkspaceRunnable registerParticipant = new IWorkspaceRunnable() {
+                                       public void run(final IProgressMonitor monitor) throws CoreException {
+                                               ISavedState savedState = null;
+
+                                               try {
+                                                       // add the save participant for this bundle
+                                                       savedState = ResourcesPlugin.getWorkspace().addSaveParticipant(JsCorePlugin.PLUGIN_ID, new SaveParticipant());
+                                               }
+                                               catch (CoreException e) {
+                                                       Logger.logException("JavaScript Web Core failed loading previously saved state; it will be recalculated for this workspace.", e); //$NON-NLS-1$
+                                               }
+
+                                               /*
+                                                * if there is a saved state start up using that, else
+                                                * start up cold
+                                                */
+                                               if (savedState != null) {
+                                                       try {
+                                                               Thread.currentThread().setPriority(Thread.MIN_PRIORITY);
+                                                       }
+                                                       finally {
+                                                               savedState.processResourceChangeEvents(new IResourceChangeListener() {
+                                                                       /**
+                                                                        * @see org.eclipse.core.resources.IResourceChangeListener#resourceChanged(org.eclipse.core.resources.IResourceChangeEvent)
+                                                                        */
+                                                                       public void resourceChanged(IResourceChangeEvent event) {
+                                                                               JSWebResourceEventManager.getDefault().start(event.getDelta(), monitor);
+                                                                       }
+                                                               });
+                                                       }
+                                               }
+                                               else {
+                                                       JSWebResourceEventManager.getDefault().start(null, monitor);
+                                               }
+                                       }
+                               };
+                               workspace.run(registerParticipant, monitor);
+                       }
+                       catch (CoreException e) {
+                               status = e.getStatus();
+                       }
+
+                       return status;
+               }
+
+       }
+
+       /**
+        * Used so that all of the IResourceChangeEvents that occurred before this
+        * plugin loaded can be processed.
+        */
+       private static class SaveParticipant implements ISaveParticipant {
+               /**
+                * <p>
+                * Default constructor
+                * </p>
+                */
+               protected SaveParticipant() {
+               }
+
+               /**
+                * @see org.eclipse.core.resources.ISaveParticipant#doneSaving(org.eclipse.core.resources.ISaveContext)
+                */
+               public void doneSaving(ISaveContext context) {
+                       // ignore
+               }
+
+               /**
+                * @see org.eclipse.core.resources.ISaveParticipant#prepareToSave(org.eclipse.core.resources.ISaveContext)
+                */
+               public void prepareToSave(ISaveContext context) throws CoreException {
+                       // ignore
+               }
+
+               /**
+                * @see org.eclipse.core.resources.ISaveParticipant#rollback(org.eclipse.core.resources.ISaveContext)
+                */
+               public void rollback(ISaveContext context) {
+                       // ignore
+               }
+
+               /**
+                * @see org.eclipse.core.resources.ISaveParticipant#saving(org.eclipse.core.resources.ISaveContext)
+                */
+               public void saving(ISaveContext context) throws CoreException {
+                       context.needDelta();
+               }
+       }
+
+       // The shared instance.
+       private static JsCorePlugin plugin;
+       public static final String PLUGIN_ID = "org.eclipse.wst.jsdt.web.core"; //$NON-NLS-1$
+
+       /**
+        * <p>
+        * Job used to finish tasks needed to start up the plugin but that did not
+        * have to block the plugin start up process.
+        * </p>
+        */
+       private Job fPluginInitializerJob;
+
+       /**
+        * Returns the shared instance.
+        * 
+        * @deprecated - will be removed. Currently used to get
+        *             "model preferences", but there are other, better ways.
+        */
+
+       public static JsCorePlugin getDefault() {
+               return JsCorePlugin.plugin;
+       }
+
+       public JsCorePlugin() {
+               super();
+               JsCorePlugin.plugin = this;
+               this.fPluginInitializerJob = new PluginInitializerJob();
+       }
+
+       /*
+        * (non-Javadoc)
+        * 
+        * @see
+        * org.eclipse.core.runtime.Plugin#start(org.osgi.framework.BundleContext)
+        */
+
+       public void start(BundleContext context) throws Exception {
+               super.start(context);
+               // listen for include path changes
+               JsIndexManager.getInstance().initialize();
+
+               // schedule delayed initialization of our save participant
+               this.fPluginInitializerJob.schedule(2000);
+       }
+
+       /*
+        * (non-Javadoc)
+        * 
+        * @see
+        * org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext)
+        */
+
+       public void stop(BundleContext context) throws Exception {
+               /*
+                * stop listening for resource changes and interacting with the JS
+                * IndexManager
+                */
+               JsIndexManager.getInstance().shutdown();
+               /* Stop the resource event manager */
+               JSWebResourceEventManager.getDefault().stop();
+               super.stop(context);
+       }
+}
diff --git a/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/Logger.java b/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/Logger.java
new file mode 100644 (file)
index 0000000..50ac416
--- /dev/null
@@ -0,0 +1,155 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.web.core.internal;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Status;
+import org.osgi.framework.Bundle;
+
+import com.ibm.icu.util.StringTokenizer;
+
+/**
+*
+* Provisional API: This class/interface is part of an interim API that is still under development and expected to
+* change significantly before reaching stability. It is being made available at this early stage to solicit feedback
+* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
+* (repeatedly) as the API evolves.
+*/
+public class Logger {
+       public static final int ERROR = IStatus.ERROR; // 4
+       public static final int ERROR_DEBUG = 200 + Logger.ERROR;
+       public static final int INFO = IStatus.INFO; // 1
+       public static final int INFO_DEBUG = 200 + Logger.INFO;
+       public static final int OK = IStatus.OK; // 0
+       public static final int OK_DEBUG = 200 + Logger.OK;
+       private static final String PLUGIN_ID = "org.eclipse.wst.jsdt.web.core"; //$NON-NLS-1$
+       private static final String TRACEFILTER_LOCATION = "/debug/tracefilter"; //$NON-NLS-1$
+       public static final int WARNING = IStatus.WARNING; // 2
+       public static final int WARNING_DEBUG = 200 + Logger.WARNING;
+       
+       /**
+        * Adds message to log.
+        * 
+        * @param level
+        *            severity level of the message (OK, INFO, WARNING, ERROR,
+        *            OK_DEBUG, INFO_DEBUG, WARNING_DEBUG, ERROR_DEBUG)
+        * @param message
+        *            text to add to the log
+        * @param exception
+        *            exception thrown
+        */
+       protected static void _log(int level, String message, Throwable exception) {
+               if (level == Logger.OK_DEBUG || level == Logger.INFO_DEBUG || level == Logger.WARNING_DEBUG || level == Logger.ERROR_DEBUG) {
+                       if (!Logger.isDebugging()) {
+                               return;
+                       }
+               }
+               int severity = IStatus.OK;
+               switch (level) {
+                       case INFO_DEBUG:
+                       case INFO:
+                               severity = IStatus.INFO;
+                       break;
+                       case WARNING_DEBUG:
+                       case WARNING:
+                               severity = IStatus.WARNING;
+                       break;
+                       case ERROR_DEBUG:
+                       case ERROR:
+                               severity = IStatus.ERROR;
+               }
+               message = (message != null) ? message : "null"; //$NON-NLS-1$
+               Status statusObj = new Status(severity, Logger.PLUGIN_ID, severity, message, exception);
+               Bundle bundle = Platform.getBundle(Logger.PLUGIN_ID);
+               if (bundle != null) {
+                       Platform.getLog(bundle).log(statusObj);
+               }
+       }
+       
+       /**
+        * Prints message to log if category matches /debug/tracefilter option.
+        * 
+        * @param message
+        *            text to print
+        * @param category
+        *            category of the message, to be compared with
+        *            /debug/tracefilter
+        */
+       protected static void _trace(String category, String message, Throwable exception) {
+               if (Logger.isTracing(category)) {
+                       message = (message != null) ? message : "null"; //$NON-NLS-1$
+                       Status statusObj = new Status(IStatus.OK, Logger.PLUGIN_ID, IStatus.OK, message, exception);
+                       Bundle bundle = Platform.getBundle(Logger.PLUGIN_ID);
+                       if (bundle != null) {
+                               Platform.getLog(bundle).log(statusObj);
+                       }
+               }
+       }
+       
+       /**
+        * @return true if the platform is debugging
+        */
+       public static boolean isDebugging() {
+               return Platform.inDebugMode();
+       }
+       
+       /**
+        * Determines if currently tracing a category
+        * 
+        * @param category
+        * @return true if tracing category, false otherwise
+        */
+       public static boolean isTracing(String category) {
+               if (!Logger.isDebugging()) {
+                       return false;
+               }
+               String traceFilter = Platform.getDebugOption(Logger.PLUGIN_ID + Logger.TRACEFILTER_LOCATION);
+               if (traceFilter != null) {
+                       StringTokenizer tokenizer = new StringTokenizer(traceFilter, ","); //$NON-NLS-1$
+                       while (tokenizer.hasMoreTokens()) {
+                               String cat = tokenizer.nextToken().trim();
+                               if (category.equals(cat)) {
+                                       return true;
+                               }
+                       }
+               }
+               return false;
+       }
+       
+       public static void log(int level, String message) {
+               Logger._log(level, message, null);
+       }
+       
+       public static void log(int level, String message, Throwable exception) {
+               Logger._log(level, message, exception);
+       }
+       
+       public static void logException(String message, Throwable exception) {
+               Logger._log(Logger.ERROR, message, exception);
+       }
+       
+       public static void logException(Throwable exception) {
+               Logger._log(Logger.ERROR, exception.getMessage(), exception);
+       }
+       
+       public static void trace(String category, String message) {
+               Logger._trace(category, message, null);
+       }
+       
+       public static void traceException(String category, String message, Throwable exception) {
+               Logger._trace(category, message, exception);
+       }
+       
+       public static void traceException(String category, Throwable exception) {
+               Logger._trace(category, exception.getMessage(), exception);
+       }
+}
diff --git a/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/PathUtils.java b/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/PathUtils.java
new file mode 100644 (file)
index 0000000..5d8670e
--- /dev/null
@@ -0,0 +1,146 @@
+/*******************************************************************************
+ * Copyright (c) 2011 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.web.core.internal;
+
+import java.io.File;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.wst.jsdt.core.compiler.CharOperation;
+
+/**
+ * <p>Utility class dealing with {@link IPath}s.</p>
+ */
+public class PathUtils {
+       /** represents the * pattern in a path pattern */
+       private static final String STAR = "*"; //$NON-NLS-1$
+       
+       /** represents the ** pattern in a path pattern */
+       private static final String STAR_STAR = "**"; //$NON-NLS-1$
+       
+       /**
+        * <p>Counts the number of segments in a given pattern that match segments in a given parent path.
+        * This counting takes place from the beginning of both the pattern and parent and stops when
+        * they no longer match.  The pattern can contain **, * and ? wild cards.</p>
+        *
+        * @param pattern count the number of segments of this pattern that match the given <code>parent</code>
+        * @param parent count the number of segments in the given <code>pattern</code> that match this path
+        * @return the number of segments from the beginning of the given <code>pattern</code> {@link IPath}
+        * that match the beginning segments of the given <code>parent</code> {@link IPath}
+        */
+       public static int countPatternSegmentsThatMatchParent(IPath pattern, IPath parent) {
+               int matchingSegments = 0;
+               
+               //ignore a pattern that is just ** or *
+               if(!(pattern.segmentCount() == 1 &&
+                               (pattern.segment(0).equals(STAR_STAR) || pattern.segment(0).equals(STAR)))) {
+                       
+                       int patternSegmentIndex = 0;
+                       int parentSegmentIndex = 0;
+                       boolean starStarMode = false;
+                       while(patternSegmentIndex < pattern.segmentCount() &&
+                                       parentSegmentIndex < parent.segmentCount()) {
+                               
+                               String patternSegment = pattern.segment(patternSegmentIndex);
+                               String parentSegment = parent.segment(parentSegmentIndex);
+                               
+                               /* if matching on wild
+                                * else if wild match on multiple path segments
+                                * else if wild match on one path segment or path segments are equal
+                                * else not equal so stop comparing
+                                */
+                               if(starStarMode) {
+                                       /* if parent segment equals first pattern segment after a ** stop matching on it
+                                        * else still matching on **
+                                        */
+                                       if(pathSegmentMatchesPattern(patternSegment, parentSegment)) {
+                                               starStarMode = false;
+                                               matchingSegments++;
+                                               patternSegmentIndex++;
+                                               parentSegmentIndex++;
+                                       } else {
+                                               parentSegmentIndex++;
+                                       }
+                               
+                               } else if(patternSegment.equals(STAR_STAR)) { //$NON-NLS-1$
+                                       starStarMode = true;
+                                       
+                                       //find the first pattern segment after the ** that is not another ** or *
+                                       matchingSegments++;
+                                       parentSegmentIndex++;
+                                       
+                                       for(int i = patternSegmentIndex+1; i < pattern.segmentCount(); ++i) {
+                                               
+                                               if(!(pattern.segment(i).equals(STAR_STAR) || //$NON-NLS-1$
+                                                               pattern.segment(i).equals(STAR))) { //$NON-NLS-1$
+                                                       
+                                                       patternSegmentIndex = i;
+                                                       break;
+                                               }
+                                       }
+                               } else if(patternSegment.equals("*") || //$NON-NLS-1$
+                                               pathSegmentMatchesPattern(patternSegment, parentSegment)){
+                                       
+                                       matchingSegments++;
+                                       patternSegmentIndex++;
+                                       parentSegmentIndex++;
+                               } else {
+                                       break;
+                               }
+                       }
+               }
+               
+               return matchingSegments;
+       }
+       
+       /**
+        * <p>Given a pattern path and a parent path attempts to truncate the given pattern path such
+        * that it is relative to the given parent path.</p>
+        *
+        * @param pattern attempt to truncate this {@link IPath} such that it is relative to the given
+        * <code>parent</code> {@link IPath}
+        * @param parent attempt to truncate the given <code>pattern</code> {@link IPath} such that it
+        * is relative to this {@link IPath}
+        * @return either a truncated version of the given <code>pattern</code> {@link IPath} that is
+        * relative to the given <code>parent</code> {@link IPath}, or <code>null</code> if the given
+        * <code>pattern</code> {@link IPath} could not be truncated to be relative to the given
+        * <code>parent</code> {@link IPath}
+        */
+       public static IPath makePatternRelativeToParent(IPath pattern, IPath parent) {
+               int matchedSegments = countPatternSegmentsThatMatchParent(pattern, parent);
+               
+               IPath relativePattern = null;
+               if(matchedSegments != 0) {
+                       relativePattern = pattern.removeFirstSegments(matchedSegments);
+                       
+                       if(relativePattern.segmentCount() == 0) {
+                               relativePattern = null;
+                       } else {
+                               relativePattern.makeRelative();
+                       }
+               }
+               
+               return relativePattern;
+       }
+       
+       /**
+        * <p>A convenience method for checking the matching of one segment from a pattern path with
+        * one segment from a path.</p>
+        *Bug 334922 - CharOperation#match does not work as expected when isCaseSensitive is passed as false
+        * @param patternSegment check if this pattern segment is a match with the given path segment.
+        * @param segment check if this path segment matches with the given pattern segment
+        * @return <code>true</code> if the segments match, <code>false</code> otherwise
+        */
+       private static boolean pathSegmentMatchesPattern(String patternSegment, String segment) {
+               return CharOperation.pathMatch(patternSegment.toCharArray(), segment.toCharArray(),
+                               false, File.separatorChar);
+       }
+}
diff --git a/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/modelhandler/IWebDocumentChangeListener.java b/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/modelhandler/IWebDocumentChangeListener.java
new file mode 100644 (file)
index 0000000..9d4edd7
--- /dev/null
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * 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.web.core.internal.modelhandler;
+
+/**
+*
+* Provisional API: This class/interface is part of an interim API that is still under development and expected to
+* change significantly before reaching stability. It is being made available at this early stage to solicit feedback
+* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
+* (repeatedly) as the API evolves.
+*/
+public interface IWebDocumentChangeListener extends IWebResourceChangedListener {
+       public static final int BORING = 0;
+       public static final int DIRTY_DOC = 1;
+       public static final int DIRTY_MODEL = 2;
+       
+       public int getIntrestLevelAtOffset(int documentOffset);
+}
diff --git a/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/modelhandler/IWebResourceChangedListener.java b/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/modelhandler/IWebResourceChangedListener.java
new file mode 100644 (file)
index 0000000..4084e8b
--- /dev/null
@@ -0,0 +1,25 @@
+/*******************************************************************************
+ * 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.web.core.internal.modelhandler;
+
+/**
+*
+* Provisional API: This class/interface is part of an interim API that is still under development and expected to
+* change significantly before reaching stability. It is being made available at this early stage to solicit feedback
+* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
+* (repeatedly) as the API evolves.
+*/
+public interface IWebResourceChangedListener {
+       public void resourceChanged();
+}
diff --git a/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/modelhandler/Messages.java b/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/modelhandler/Messages.java
new file mode 100644 (file)
index 0000000..889438f
--- /dev/null
@@ -0,0 +1,41 @@
+/*******************************************************************************
+ * 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.web.core.internal.modelhandler;
+
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+/**
+*
+* Provisional API: This class/interface is part of an interim API that is still under development and expected to
+* change significantly before reaching stability. It is being made available at this early stage to solicit feedback
+* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
+* (repeatedly) as the API evolves.
+*/
+public class Messages {
+       private static final String BUNDLE_NAME = "org.eclipse.wst.jsdt.web.core.internal.modelhandler.messages"; //$NON-NLS-1$
+
+       private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME);
+
+       private Messages() {
+       }
+
+       public static String getString(String key) {
+               try {
+                       return RESOURCE_BUNDLE.getString(key);
+               }
+               catch (MissingResourceException e) {
+                       return '!' + key + '!';
+               }
+       }
+}
diff --git a/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/modelhandler/WebResourceChangeHandler.java b/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/modelhandler/WebResourceChangeHandler.java
new file mode 100644 (file)
index 0000000..106843f
--- /dev/null
@@ -0,0 +1,211 @@
+/*******************************************************************************
+ * Copyright (c) 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.web.core.internal.modelhandler;
+
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.Hashtable;
+
+import org.eclipse.core.filebuffers.FileBuffers;
+import org.eclipse.core.resources.IResourceChangeEvent;
+import org.eclipse.core.resources.IResourceChangeListener;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.jface.text.DocumentEvent;
+import org.eclipse.jface.text.IDocumentListener;
+import org.eclipse.wst.sse.core.internal.model.ModelLifecycleEvent;
+import org.eclipse.wst.sse.core.internal.provisional.IModelLifecycleListener;
+import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
+import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument;
+/**
+*
+* Provisional API: This class/interface is part of an interim API that is still under development and expected to
+* change significantly before reaching stability. It is being made available at this early stage to solicit feedback
+* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
+* (repeatedly) as the API evolves.
+*/
+public class WebResourceChangeHandler implements IResourceChangeListener, IDocumentListener, IModelLifecycleListener {
+       /*
+        * Check the level of dirty regions when signaling for document events.
+        * 
+        * sometimes the SSE editor doesn't re-validate regions when text is
+        * inserted, so setting this to false causes every document change event to
+        * trigger a revalidation.
+        * 
+        * setting to true may speed things up.
+        * 
+        */
+//     private static final boolean CHECK_INTREST_LEVEL = false;
+       private static Hashtable instances = new Hashtable();
+       private static final boolean SIGNAL_MODEL = false;
+       
+       public static WebResourceChangeHandler getInstance(IStructuredModel xmlModel, IWebResourceChangedListener changeListener) {
+               WebResourceChangeHandler handler = null;
+               synchronized (WebResourceChangeHandler.instances) {
+                       Enumeration values = WebResourceChangeHandler.instances.elements();
+                       while (values.hasMoreElements()) {
+                               Object model = values.nextElement();
+                               if (model == xmlModel) {
+                                       handler = (WebResourceChangeHandler) WebResourceChangeHandler.instances.get(model);
+                               }
+                       }
+                       if (handler == null) {
+                               handler = new WebResourceChangeHandler();
+                               WebResourceChangeHandler.instances.put(handler, xmlModel);
+                       }
+               }
+               handler.initialize();
+               handler.fchangeListener.add(changeListener);
+               return handler;
+       }
+       private class ModelIrritantThread implements Runnable {
+               public void run() {
+                       signalAllDirtyModel();
+               }
+               
+               public void signalAllDirtyModel() {
+                       for (int i = 0; i < fchangeListener.size(); i++) {
+                               ((IWebResourceChangedListener) fchangeListener.get(i)).resourceChanged();
+                       }
+                       if (!WebResourceChangeHandler.SIGNAL_MODEL) {
+                               return;
+                       }
+                       IStructuredModel xmlModel = null;
+                       Object modelRef = getModel();
+                       if (modelRef == null) {
+                               return;
+                       }
+                       try {
+// for(int i =0;i<fchangeListener.size();i++) {
+// ((IWebResourceChangedListener)fchangeListener.get(i)).resourceChanged();
+// }
+                               xmlModel = (IStructuredModel) modelRef;//(IDOMModel) StructuredModelManager.getModelManager().getExistingModelForEdit(((IStructuredModel) modelRef).getBaseLocation());
+                               if (xmlModel != null) {
+                                       IStructuredDocument doc = xmlModel.getStructuredDocument();
+                                       try {
+                                               xmlModel.aboutToChangeModel();
+                                       // xmlModel.setReinitializeNeeded(true);
+                                       // (doc).replace(0, doc.getLength(),doc.get());
+                                       }
+                                       finally {
+                                               xmlModel.changedModel();
+                                       }
+                               }
+                       } catch (Exception e) {
+                               System.out.println(Messages.getString("WebResourceChangeHandler.0")); //$NON-NLS-1$
+                       } finally {
+                               if (xmlModel != null) {
+//                                     xmlModel.releaseFromEdit();
+                               }
+                       }
+               }
+       }
+       private ArrayList fchangeListener = new ArrayList();
+       private ModelIrritantThread irritator;
+       
+       private WebResourceChangeHandler() {}
+       
+       /*
+        * (non-Javadoc)
+        * 
+        * @see org.eclipse.jface.text.IDocumentListener#documentAboutToBeChanged(org.eclipse.jface.text.DocumentEvent)
+        */
+       public void documentAboutToBeChanged(DocumentEvent event) {}
+       
+       /*
+        * (non-Javadoc)
+        * 
+        * @see org.eclipse.jface.text.IDocumentListener#documentChanged(org.eclipse.jface.text.DocumentEvent)
+        */
+       public void documentChanged(DocumentEvent event) {
+//             if (WebResourceChangeHandler.CHECK_INTREST_LEVEL) {
+//                     for (int i = 0; i < fchangeListener.size(); i++) {
+//                             Object o = fchangeListener.get(i);
+//                             if (o instanceof IWebDocumentChangeListener) {
+//                                     int intrest = ((IWebDocumentChangeListener) o).getIntrestLevelAtOffset(event.fOffset);
+//                                     switch (intrest) {
+//                                             case IWebDocumentChangeListener.DIRTY_MODEL:
+//                                                     irritator.signalAllDirtyModel();
+//                                                     return;
+//                                             case IWebDocumentChangeListener.DIRTY_DOC:
+//                                                     ((IWebDocumentChangeListener) o).resourceChanged();
+//                                             break;
+//                                     }
+//                                     return;
+//                             }
+//                     }
+//             } else {
+                       irritator.signalAllDirtyModel();
+               //}
+       }
+       
+       
+       public boolean equals(Object o) {
+               return (o instanceof WebResourceChangeHandler && ((WebResourceChangeHandler) o).fchangeListener == this.fchangeListener);
+       }
+       
+       
+       public void finalize() {
+               ResourcesPlugin.getWorkspace().removeResourceChangeListener(this);
+               if (WebResourceChangeHandler.instances == null) {
+                       return;
+               }
+               Object o = null;
+               synchronized (WebResourceChangeHandler.instances) {
+                       o = WebResourceChangeHandler.instances.get(this);
+                       WebResourceChangeHandler.instances.remove(this);
+               }
+               if (o != null) {
+                       IStructuredModel fXMLModel = (IStructuredModel) o;
+                       IStructuredDocument fJspDocument = fXMLModel.getStructuredDocument();
+                       if (fJspDocument != null) {
+                               fJspDocument.removeDocumentListener(this);
+                       }
+               }
+       }
+       
+       private IStructuredModel getModel() {
+               if (WebResourceChangeHandler.instances == null) {
+                       return null;
+               }
+               return (IStructuredModel) WebResourceChangeHandler.instances.get(this);
+       }
+       
+       private void initialize() {
+               IStructuredModel xmlModel = getModel();
+               ResourcesPlugin.getWorkspace().addResourceChangeListener(this, IResourceChangeEvent.POST_CHANGE);
+               xmlModel.addModelLifecycleListener(this);
+               IStructuredDocument fJspDocument = xmlModel.getStructuredDocument();
+               if (fJspDocument != null) {
+                       fJspDocument.addDocumentListener(this);
+               }
+               irritator = new ModelIrritantThread();
+       }
+       
+       public void processPostModelEvent(ModelLifecycleEvent event) {
+               if (irritator != null) {
+                       irritator.signalAllDirtyModel();
+               }
+               if (WebResourceChangeHandler.instances == null) {
+                       return;
+               }
+               if (event.getType() == ModelLifecycleEvent.MODEL_RELEASED) {
+                       synchronized (WebResourceChangeHandler.instances) {
+                               WebResourceChangeHandler.instances.remove(this);
+                       }
+               }
+       }
+       
+       public void processPreModelEvent(ModelLifecycleEvent event) {}
+       
+       public void resourceChanged(IResourceChangeEvent event) {
+               FileBuffers.getTextFileBufferManager().execute(irritator);
+       }
+}
diff --git a/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/modelhandler/messages.properties b/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/modelhandler/messages.properties
new file mode 100644 (file)
index 0000000..c06bf5d
--- /dev/null
@@ -0,0 +1,11 @@
+###############################################################################
+# 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
+###############################################################################
+WebResourceChangeHandler.0=Error when updating the model.
diff --git a/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/project/ConvertJob.java b/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/project/ConvertJob.java
new file mode 100644 (file)
index 0000000..5824025
--- /dev/null
@@ -0,0 +1,86 @@
+/*******************************************************************************\r
+ * Copyright (c) 2010 IBM Corporation and others.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ * \r
+ * Contributors:\r
+ *     IBM Corporation - initial API and implementation\r
+ *******************************************************************************/\r
+\r
+package org.eclipse.wst.jsdt.web.core.internal.project;\r
+\r
+import java.util.HashSet;\r
+import java.util.Set;\r
+\r
+import org.eclipse.core.resources.IProject;\r
+import org.eclipse.core.resources.WorkspaceJob;\r
+import org.eclipse.core.runtime.CoreException;\r
+import org.eclipse.core.runtime.IProgressMonitor;\r
+import org.eclipse.core.runtime.IStatus;\r
+import org.eclipse.core.runtime.NullProgressMonitor;\r
+import org.eclipse.core.runtime.Status;\r
+import org.eclipse.wst.common.project.facet.core.IFacetedProject;\r
+import org.eclipse.wst.common.project.facet.core.IFacetedProjectWorkingCopy;\r
+import org.eclipse.wst.common.project.facet.core.IProjectFacet;\r
+import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion;\r
+import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager;\r
+import org.eclipse.wst.jsdt.internal.core.util.Messages;\r
+import org.eclipse.wst.jsdt.web.core.internal.Logger;\r
+\r
+/**\r
+ * Installs the JSDT facet, if asked, and setting it as a "fixed" facet.\r
+ * \r
+ */\r
+class ConvertJob extends WorkspaceJob {\r
+       final static String JSDT_FACET = "wst.jsdt.web";\r
+       private IProject fProject;\r
+       private boolean fInstall = true;\r
+       private boolean fUseExplicitWorkingCopy = false;\r
+\r
+       ConvertJob(IProject project, boolean install, boolean useExplicitWorkingCopy) {\r
+               super(Messages.converter_ConfiguringForJavaScript);\r
+               fProject = project;\r
+               fInstall = install;\r
+               fUseExplicitWorkingCopy = useExplicitWorkingCopy;\r
+       }\r
+\r
+       public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {\r
+               try {\r
+                       IProjectFacet projectFacet = ProjectFacetsManager.getProjectFacet(JSDT_FACET);\r
+                       IFacetedProject facetedProject = ProjectFacetsManager.create(fProject);\r
+\r
+                       if (facetedProject != null && fProject.isAccessible()) {\r
+                               if (fInstall) {\r
+                                       IProjectFacetVersion latestVersion = projectFacet.getLatestVersion();\r
+                                       facetedProject.installProjectFacet(latestVersion, null, monitor);\r
+                               }\r
+\r
+\r
+                               if (fUseExplicitWorkingCopy) {\r
+                                       IFacetedProjectWorkingCopy copy = facetedProject.createWorkingCopy();\r
+                                       Set fixed = new HashSet(facetedProject.getFixedProjectFacets());\r
+                                       fixed.add(projectFacet);\r
+                                       copy.setFixedProjectFacets(fixed);\r
+                                       copy.commitChanges(new NullProgressMonitor());\r
+                               }\r
+                               else {\r
+                                       Set fixed = new HashSet(facetedProject.getFixedProjectFacets());\r
+                                       if (!fixed.contains(projectFacet)) {\r
+                                               fixed.add(projectFacet);\r
+                                               facetedProject.setFixedProjectFacets(fixed);\r
+                                       }\r
+                               }\r
+                       }\r
+               }\r
+               catch (IllegalArgumentException e) {\r
+                       // unknown facet ID, bad installation configuration?\r
+               }\r
+               catch (Exception e) {\r
+                       Logger.logException(e);\r
+               }\r
+               return Status.OK_STATUS;\r
+       }\r
+\r
+}
\ No newline at end of file
diff --git a/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/project/FacetedProjectListener.java b/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/project/FacetedProjectListener.java
new file mode 100644 (file)
index 0000000..d1a9abc
--- /dev/null
@@ -0,0 +1,47 @@
+/*******************************************************************************\r
+ * Copyright (c) 2010 IBM Corporation and others.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ * \r
+ * Contributors:\r
+ *     IBM Corporation - initial API and implementation\r
+ *******************************************************************************/\r
+\r
+package org.eclipse.wst.jsdt.web.core.internal.project;\r
+\r
+import java.util.Arrays;\r
+import java.util.Collection;\r
+\r
+import org.eclipse.wst.common.project.facet.core.events.IFacetedProjectEvent;\r
+import org.eclipse.wst.common.project.facet.core.events.IFacetedProjectListener;\r
+import org.eclipse.wst.common.project.facet.core.events.IProjectFacetActionEvent;\r
+\r
+public class FacetedProjectListener implements IFacetedProjectListener {\r
+       final static Collection INTERESTING_FACETS = Arrays.asList(new Object[]{"wst.web", "jst.web"});\r
+\r
+       /**\r
+        * \r
+        */\r
+       public FacetedProjectListener() {\r
+       }\r
+\r
+       /*\r
+        * (non-Javadoc)\r
+        * \r
+        * @see\r
+        * org.eclipse.wst.common.project.facet.core.events.IFacetedProjectListener\r
+        * #handleEvent(org.eclipse.wst.common.project.facet.core.events.\r
+        * IFacetedProjectEvent)\r
+        */\r
+       public void handleEvent(IFacetedProjectEvent event) {\r
+               if (event.getType() == IFacetedProjectEvent.Type.POST_INSTALL) {\r
+                       IProjectFacetActionEvent actionEvent = (IProjectFacetActionEvent) event;\r
+                       if (INTERESTING_FACETS.contains(actionEvent.getProjectFacet().getId())) {\r
+                               new ConvertJob(event.getProject().getProject(), true, true).schedule(1000);\r
+                       }\r
+               }\r
+       }\r
+\r
+}\r
diff --git a/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/project/JsNatureInstaller.java b/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/project/JsNatureInstaller.java
new file mode 100644 (file)
index 0000000..d9b36d3
--- /dev/null
@@ -0,0 +1,58 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2011 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.web.core.internal.project;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.wst.common.project.facet.core.IDelegate;
+import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion;
+import org.eclipse.wst.jsdt.web.core.internal.JsCorePlugin;
+/**
+*
+* Provisional API: This class/interface is part of an interim API that is still under development and expected to
+* change significantly before reaching stability. It is being made available at this early stage to solicit feedback
+* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
+* (repeatedly) as the API evolves.
+*/
+public class JsNatureInstaller implements IDelegate {
+       public void execute(IProject project, IProjectFacetVersion fv, Object config, IProgressMonitor monitor) throws CoreException {
+               if (monitor == null) {
+                       monitor = new NullProgressMonitor();
+               }
+               monitor.beginTask("Installing Facet for JavaScript Development Tools" + ".", 100); //$NON-NLS-1$ //$NON-NLS-2$
+               try {
+                       if(!JsWebNature.hasNature(project))
+                               installNature(project, monitor);
+               } finally {
+                       monitor.done();
+               }
+       }
+       
+       public void installNature(IProject project, IProgressMonitor monitor) throws CoreException {
+               monitor.beginTask(Messages.getString("JsNatureInstaller.1"), 100); //$NON-NLS-1$
+               monitor.subTask(Messages.getString("JsNatureInstaller.2")); //$NON-NLS-1$
+               try {
+                       monitor.worked(20);
+                       JsWebNature jsNature = new JsWebNature(project, monitor);
+                       monitor.worked(20);
+                       jsNature.configure();
+                       monitor.worked(40);
+                       
+                       new ConvertJob(project, false, true).schedule(1000);
+               } catch (Exception e) {
+                       throw new CoreException(new Status(IStatus.ERROR, JsCorePlugin.PLUGIN_ID, IStatus.OK, Messages.getString("JsNatureInstaller.3"), e)); //$NON-NLS-1$
+               }
+       }
+}
diff --git a/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/project/JsNatureUninstaller.java b/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/project/JsNatureUninstaller.java
new file mode 100644 (file)
index 0000000..c59fc6d
--- /dev/null
@@ -0,0 +1,60 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2009 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.web.core.internal.project;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IProjectNature;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.wst.common.project.facet.core.IDelegate;
+import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion;
+import org.eclipse.wst.jsdt.web.core.internal.JsCorePlugin;
+/**
+*
+* Provisional API: This class/interface is part of an interim API that is still under development and expected to
+* change significantly before reaching stability. It is being made available at this early stage to solicit feedback
+* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
+* (repeatedly) as the API evolves.
+*/
+public class JsNatureUninstaller implements IDelegate {
+       public void execute(IProject project, IProjectFacetVersion fv, Object config, IProgressMonitor monitor) throws CoreException {
+               if (monitor == null) {
+                       monitor = new NullProgressMonitor();
+               }
+               monitor.beginTask("Uninstalling Facet for JavaScript Development Tools" + ".", 100); //$NON-NLS-1$ //$NON-NLS-2$
+               try {
+                       uninstallNature(project, monitor);
+               } finally {
+                       monitor.done();
+               }
+       }
+       
+       public void uninstallNature(IProject project, IProgressMonitor monitor) throws CoreException {
+               monitor.beginTask(Messages.getString("JsNatureUninstaller.1"), 100); //$NON-NLS-1$
+               // by using natures we can leverage the precondition support
+               monitor.subTask(Messages.getString("JsNatureUninstaller.2")); //$NON-NLS-1$
+               if (!JsWebNature.hasNature(project)) {
+                       return;
+               }
+               try {
+                       IProjectNature jsNature = new JsWebNature(project, monitor);
+                       monitor.worked(20);
+                       monitor.worked(50);
+                       jsNature.deconfigure();
+                       monitor.worked(20);
+               } catch (CoreException e) {
+                       throw new CoreException(new Status(IStatus.ERROR, JsCorePlugin.PLUGIN_ID, IStatus.OK, Messages.getString("JsNatureUninstaller.3"), e)); //$NON-NLS-1$
+               }
+       }
+}
diff --git a/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/project/JsWebNature.java b/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/project/JsWebNature.java
new file mode 100644 (file)
index 0000000..d8c3448
--- /dev/null
@@ -0,0 +1,288 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.web.core.internal.project;
+
+import java.util.Arrays;
+import java.util.Vector;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IProjectDescription;
+import org.eclipse.core.resources.IProjectNature;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.wst.jsdt.core.IAccessRule;
+import org.eclipse.wst.jsdt.core.IIncludePathAttribute;
+import org.eclipse.wst.jsdt.core.IIncludePathEntry;
+import org.eclipse.wst.jsdt.core.JavaScriptCore;
+import org.eclipse.wst.jsdt.core.LibrarySuperType;
+import org.eclipse.wst.jsdt.internal.core.JavaProject;
+import org.eclipse.wst.jsdt.internal.core.util.ConvertUtility;
+//import org.eclipse.wst.jsdt.ui.PreferenceConstants;
+/**
+*
+* Provisional API: This class/interface is part of an interim API that is still under development and expected to
+* change significantly before reaching stability. It is being made available at this early stage to solicit feedback
+* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
+* (repeatedly) as the API evolves.
+*/
+public class JsWebNature implements IProjectNature {
+       //private static final String FILENAME_CLASSPATH = ".classpath"; //$NON-NLS-1$
+       // private static final String NATURE_IDS[] =
+       // {"org.eclipse.wst.jsdt.web.core.embeded.jsNature",JavaScriptCore.NATURE_ID};
+       // //$NON-NLS-1$
+       private static final String NATURE_IDS[] = { JavaScriptCore.NATURE_ID };
+
+       public static final IPath VIRTUAL_BROWSER_CLASSPATH = new Path("org.eclipse.wst.jsdt.launching.baseBrowserLibrary"); //$NON-NLS-1$
+       public static final String VIRTUAL_CONTAINER = "org.eclipse.wst.jsdt.launching.WebProject"; //$NON-NLS-1$
+       public static final IIncludePathEntry VIRTUAL_SCOPE_ENTRY = JavaScriptCore.newContainerEntry(new Path(VIRTUAL_CONTAINER),  new IAccessRule[0], new IIncludePathAttribute[] {IIncludePathAttribute.HIDE}, false);
+       private static final String SUPER_TYPE_NAME = "Window"; //$NON-NLS-1$
+       private static final String SUPER_TYPE_LIBRARY = "org.eclipse.wst.jsdt.launching.baseBrowserLibrary"; //$NON-NLS-1$
+       
+       /* Default JRE entry */
+       private static final String DEFAULT_JRE_PATH = "org.eclipse.wst.jsdt.launching.JRE_CONTAINER"; //$NON-NLS-1$
+       
+       public static void addJsNature(IProject project, IProgressMonitor monitor) throws CoreException {
+               if (monitor != null && monitor.isCanceled()) {
+                       throw new OperationCanceledException();
+               }
+               if (!JsWebNature.hasNature(project)) {
+                       IProjectDescription description = project.getDescription();
+                       String[] prevNatures = description.getNatureIds();
+                       String[] newNatures = new String[prevNatures.length + JsWebNature.NATURE_IDS.length];
+                       System.arraycopy(prevNatures, 0, newNatures, 0, prevNatures.length);
+                       // newNatures[prevNatures.length] = JavaScriptCore.NATURE_ID;
+                       for (int i = 0; i < JsWebNature.NATURE_IDS.length; i++) {
+                               newNatures[prevNatures.length + i] = JsWebNature.NATURE_IDS[i];
+                       }
+                       description.setNatureIds(newNatures);
+                       project.setDescription(description, monitor);
+               } else {
+                       if (monitor != null) {
+                               monitor.worked(1);
+                       }
+               }
+       }
+       
+       public static boolean hasNature(IProject project) {
+               try {
+                       for (int i = 0; i < JsWebNature.NATURE_IDS.length; i++) {
+                               if (!project.hasNature(JsWebNature.NATURE_IDS[i])) {
+                                       return false;
+                               }
+                       }
+               } catch (CoreException ex) {
+                       return false;
+               }
+               return true;
+       }
+       
+       public static void removeJsNature(IProject project, IProgressMonitor monitor) throws CoreException {
+               if (monitor != null && monitor.isCanceled()) {
+                       throw new OperationCanceledException();
+               }
+               if (JsWebNature.hasNature(project)) {
+                       IProjectDescription description = project.getDescription();
+                       String[] prevNatures = description.getNatureIds();
+                       String[] newNatures = new String[prevNatures.length - JsWebNature.NATURE_IDS.length];
+                       int k = 0;
+                       head: for (int i = 0; i < prevNatures.length; i++) {
+                               for (int j = 0; j < JsWebNature.NATURE_IDS.length; j++) {
+                                       if (prevNatures[i].equals(JsWebNature.NATURE_IDS[j])) {
+                                               continue head;
+                                       }
+                               }
+                               newNatures[k++] = prevNatures[i];
+                       }
+                       description.setNatureIds(newNatures);
+                       project.setDescription(description, monitor);
+               } else {
+                       if (monitor != null) {
+                               monitor.worked(1);
+                       }
+               }
+       }
+       private Vector classPathEntries = new Vector();
+       private boolean DEBUG = false;
+       private IProject fCurrProject;
+       private JavaProject fJavaProject;
+       private IPath fOutputLocation;
+       private IProgressMonitor monitor;
+       
+       public JsWebNature() {
+               monitor = new NullProgressMonitor();
+       }
+       
+       public JsWebNature(IProject project, IProgressMonitor monitor) {
+               fCurrProject = project;
+               if (monitor != null) {
+                       this.monitor = monitor;
+               } else {
+                       monitor = new NullProgressMonitor();
+               }
+       }
+       
+       public void configure() throws CoreException {
+
+               initOutputPath();
+               createSourceClassPath();
+               initJREEntry();
+               initLocalClassPath();
+               
+               if (hasProjectClassPathFile()) {
+                       IIncludePathEntry[] entries = getRawClassPath();
+                       if (entries != null && entries.length > 0) {
+                               classPathEntries.removeAll(Arrays.asList(entries));
+                               classPathEntries.addAll(Arrays.asList(entries));
+                       }
+               }
+               
+               JsWebNature.addJsNature(fCurrProject, monitor);
+               fJavaProject = (JavaProject) JavaScriptCore.create(fCurrProject);
+               fJavaProject.setProject(fCurrProject);
+               try {
+                       // , fOutputLocation
+                       if (!hasProjectClassPathFile()) {
+                               fJavaProject.setRawIncludepath((IIncludePathEntry[]) classPathEntries.toArray(new IIncludePathEntry[] {}), fOutputLocation, monitor);
+                       }else{
+                               fJavaProject.setRawIncludepath((IIncludePathEntry[]) classPathEntries.toArray(new IIncludePathEntry[] {}), monitor);
+                       }
+               } catch (Exception e) {
+                       System.out.println(e);
+               }
+               LibrarySuperType superType = new LibrarySuperType(new Path( SUPER_TYPE_LIBRARY),  getJavaProject(), SUPER_TYPE_NAME);
+               getJavaProject().setCommonSuperType(superType);
+               // getJavaProject().addToBuildSpec(BUILDER_ID);
+               fCurrProject.refreshLocal(IResource.DEPTH_INFINITE, monitor);
+       }
+       
+       private void createSourceClassPath() {
+               if (hasAValidSourcePath()) {
+                       return;
+               }
+               IIncludePathEntry[] entries = new ConvertUtility(fCurrProject).getDefaultSourcePaths(fCurrProject);
+               for (int i = 0; i < entries.length; i++) {
+                       classPathEntries.add(entries[i]);
+               }
+               // IPath projectPath = fCurrProject.getFullPath();
+               // classPathEntries.add(JavaScriptCore.newSourceEntry(projectPath));
+       }
+       
+       public void deconfigure() throws CoreException {
+               Vector badEntries = new Vector();
+               IIncludePathEntry defaultJRELibrary =  getJreEntry();
+               IIncludePathEntry[] localEntries = initLocalClassPath();
+               badEntries.add(defaultJRELibrary);
+               badEntries.addAll(Arrays.asList(localEntries));
+               IIncludePathEntry[] entries = getRawClassPath();
+               Vector goodEntries = new Vector();
+               for (int i = 0; i < entries.length; i++) {
+                       if (!badEntries.contains(entries[i])) {
+                               goodEntries.add(entries[i]);
+                       }
+               }
+               // getJavaProject().removeFromBuildSpec(BUILDER_ID);
+               IPath outputLocation = getJavaProject().getOutputLocation();
+               getJavaProject().setRawIncludepath((IIncludePathEntry[]) goodEntries.toArray(new IIncludePathEntry[] {}), outputLocation, monitor);
+               getJavaProject().deconfigure();
+               JsWebNature.removeJsNature(fCurrProject, monitor);
+               fCurrProject.refreshLocal(IResource.DEPTH_INFINITE, monitor);
+       }
+       
+       public JavaProject getJavaProject() {
+               if (fJavaProject == null) {
+                       fJavaProject = (JavaProject) JavaScriptCore.create(fCurrProject);
+                       fJavaProject.setProject(fCurrProject);
+               }
+               return fJavaProject;
+       }
+       
+       public IProject getProject() {
+               return this.fCurrProject;
+       }
+       
+       private IIncludePathEntry[] getRawClassPath() {
+               JavaProject proj = new JavaProject();
+               proj.setProject(fCurrProject);
+               return proj.readRawIncludepath();
+       }
+       
+       private boolean hasAValidSourcePath() {
+               if (hasProjectClassPathFile()) {
+                       try {
+                               IIncludePathEntry[] entries = getRawClassPath();
+                               for (int i = 0; i < entries.length; i++) {
+                                       if (entries[i].getEntryKind() == IIncludePathEntry.CPE_SOURCE) {
+                                               return true;
+                                       }
+                               }
+                       } catch (Exception e) {
+                               if (DEBUG) {
+                                       System.out.println(Messages.getString("JsWebNature.5") + e); //$NON-NLS-1$
+                               }
+                       }
+               }
+               return false;
+       }
+       
+       private boolean hasProjectClassPathFile() {
+               if (fCurrProject == null) {
+                       return false;
+               }
+               return fCurrProject.getFolder(JavaProject.DEFAULT_PREFERENCES_DIRNAME).getFile(JavaProject.CLASSPATH_FILENAME).exists();
+       }
+       
+       private IIncludePathEntry getJreEntry() {
+               return JavaScriptCore.newContainerEntry(new Path(DEFAULT_JRE_PATH));
+       }
+       
+       private void initJREEntry() {
+               IIncludePathEntry defaultJRELibrary =  getJreEntry();
+               try {
+                       IIncludePathEntry[] entries = getRawClassPath();
+                       for (int i = 0; i < entries.length; i++) {
+                               if (entries[i] == defaultJRELibrary) {
+                                       return;
+                               }
+                       }
+                       classPathEntries.add(defaultJRELibrary);
+               } catch (Exception e) {
+                       if (DEBUG) {
+                               System.out.println(Messages.getString("JsWebNature.6") + e); //$NON-NLS-1$
+                       }
+               }
+       }
+       
+       private IIncludePathEntry[] initLocalClassPath() {
+               
+               classPathEntries.add(JsWebNature.VIRTUAL_SCOPE_ENTRY);
+               IIncludePathEntry browserLibrary = JavaScriptCore.newContainerEntry( VIRTUAL_BROWSER_CLASSPATH);
+               classPathEntries.add(browserLibrary);
+               //IPath webRoot = WebRootFinder.getWebContentFolder(fCurrProject);
+       //      IIncludePathEntry source = JavaScriptCore.newSourceEntry(fCurrProject.getFullPath().append(webRoot).append("/"));
+       //      classPathEntries.add(source);
+               return new IIncludePathEntry[] { JsWebNature.VIRTUAL_SCOPE_ENTRY , browserLibrary/*,source*/};
+       }
+       
+       private void initOutputPath() {
+               if (fOutputLocation == null) {
+                       fOutputLocation = fCurrProject.getFullPath();
+               }
+       }
+       
+       public void setProject(IProject project) {
+               this.fCurrProject = project;
+       }
+}
diff --git a/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/project/Messages.java b/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/project/Messages.java
new file mode 100644 (file)
index 0000000..3c2697f
--- /dev/null
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ * 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.web.core.internal.project;
+
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+/**
+*
+* Provisional API: This class/interface is part of an interim API that is still under development and expected to
+* change significantly before reaching stability. It is being made available at this early stage to solicit feedback
+* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
+* (repeatedly) as the API evolves.
+*/
+public class Messages {
+       private static final String BUNDLE_NAME = "org.eclipse.wst.jsdt.web.core.internal.project.messages"; //$NON-NLS-1$
+
+       private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME);
+
+       private Messages() {
+       }
+
+       public static String getString(String key) {
+               try {
+                       return RESOURCE_BUNDLE.getString(key);
+               }
+               catch (MissingResourceException e) {
+                       return '!' + key + '!';
+               }
+       }
+}
diff --git a/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/project/ModuleCoreSupport.java b/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/project/ModuleCoreSupport.java
new file mode 100644 (file)
index 0000000..d841af8
--- /dev/null
@@ -0,0 +1,198 @@
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2008 IBM Corporation and others.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ * \r
+ * Contributors:\r
+ *     IBM Corporation - initial API and implementation\r
+ *******************************************************************************/\r
+package org.eclipse.wst.jsdt.web.core.internal.project;\r
+\r
+import org.eclipse.core.filebuffers.FileBuffers;\r
+import org.eclipse.core.resources.IContainer;\r
+import org.eclipse.core.resources.IFile;\r
+import org.eclipse.core.resources.IFolder;\r
+import org.eclipse.core.resources.IProject;\r
+import org.eclipse.core.resources.IResource;\r
+import org.eclipse.core.resources.IWorkspaceRoot;\r
+import org.eclipse.core.resources.ResourcesPlugin;\r
+import org.eclipse.core.runtime.IPath;\r
+import org.eclipse.core.runtime.Path;\r
+\r
+/**\r
+ * This class encapsulates any used Module Core APIs along with fallbacks for\r
+ * use on non-compliant projects and when those services are not available at\r
+ * runtime.\r
+ * \r
+ * Because ModuleCore API calls can result in locks needing to be acquired,\r
+ * none of these methods should be called while other thread locks have\r
+ * already been acquired.\r
+ */\r
+public final class ModuleCoreSupport {\r
+       static final boolean _dump_NCDFE = false;\r
+       private static final String WEB_INF = "WEB-INF"; //$NON-NLS-1$\r
+       private static final IPath WEB_INF_PATH = new Path(WEB_INF);\r
+\r
+       /**\r
+        * @param project\r
+        * @return the computed IPath to the "root" of the web contents, either\r
+        *         from facet knowledge or hueristics, or null if one can not be\r
+        *         determined\r
+        */\r
+       public static IPath computeWebContentRootPath(IPath path) {\r
+               IPath root = null;\r
+               try {\r
+                       root = ModuleCoreSupportDelegate.getWebContentRootPath(ResourcesPlugin.getWorkspace().getRoot().getProject(path.segment(0)));\r
+               }\r
+               catch (NoClassDefFoundError e) {\r
+                       if (_dump_NCDFE)\r
+                               e.printStackTrace();\r
+               }\r
+               if (root == null) {\r
+                       /*\r
+                        * https://bugs.eclipse.org/bugs/show_bug.cgi?id=213245\r
+                        * \r
+                        * NPE in JSPTaglibDirectiveContentAssistProcessor with\r
+                        * non-faceted project\r
+                        */\r
+                       root = getLocalRoot(path);\r
+               }\r
+               return root;\r
+       }\r
+\r
+       /**\r
+        * @param project\r
+        * @return the IPath to the "root" of the web contents\r
+        */\r
+       public static IPath getWebContentRootPath(IProject project) {\r
+               if (project == null)\r
+                       return null;\r
+\r
+               IPath path = project.getFullPath();\r
+               try {\r
+                       path = ModuleCoreSupportDelegate.getWebContentRootPath(project);\r
+               }\r
+               catch (NoClassDefFoundError e) {\r
+                       if (_dump_NCDFE)\r
+                               e.printStackTrace();\r
+               }\r
+               return path;\r
+       }\r
+\r
+       /**\r
+        * @param path\r
+        *            - the full path to a resource within the workspace\r
+        * @return - the runtime path of the resource if one exists, null\r
+        *         otherwise\r
+        */\r
+       public static IPath getRuntimePath(IPath path) {\r
+               IPath result = null;\r
+               try {\r
+                       result = ModuleCoreSupportDelegate.getRuntimePath(path);\r
+               }\r
+               catch (NoClassDefFoundError e) {\r
+                       if (_dump_NCDFE)\r
+                               e.printStackTrace();\r
+               }\r
+               if (result == null) {\r
+                       IPath root = getLocalRoot(path);\r
+                       result = path.removeFirstSegments(root.segmentCount()).makeAbsolute();\r
+               }\r
+               return result;\r
+       }\r
+\r
+       /**\r
+        * @param basePath\r
+        *            - the full path to a resource within the workspace\r
+        * @param reference\r
+        *            - the reference string to resolve\r
+        * @return - the full path within the workspace that corresponds to the\r
+        *         given reference according to the virtual pathing support\r
+        */\r
+       public static IPath resolve(IPath basePath, String reference) {\r
+               IPath resolvedPath = null;\r
+               try {\r
+                       resolvedPath = ModuleCoreSupportDelegate.resolve(basePath, reference);\r
+               }\r
+               catch (NoClassDefFoundError e) {\r
+                       if (_dump_NCDFE)\r
+                               e.printStackTrace();\r
+               }\r
+\r
+               if (resolvedPath == null) {\r
+                       IPath rootPath = getLocalRoot(basePath);\r
+                       if (reference.startsWith(Path.ROOT.toString())) {\r
+                               resolvedPath = rootPath.append(reference);\r
+                       }\r
+                       else {\r
+                               resolvedPath = basePath.removeLastSegments(1).append(reference);\r
+                       }\r
+               }\r
+\r
+               return resolvedPath;\r
+       }\r
+\r
+       /**\r
+        * @param basePath\r
+        * @return the applicable Web context root path, if one exists\r
+        */\r
+       private static IPath getLocalRoot(IPath basePath) {\r
+               IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();\r
+\r
+               // existing workspace resources - this is the 93% case\r
+               IResource file = FileBuffers.getWorkspaceFileAtLocation(basePath);\r
+\r
+               // Try the base path as a folder first\r
+               if (file == null && basePath.segmentCount() > 1) {\r
+                       file = workspaceRoot.getFolder(basePath);\r
+               }\r
+               // If not a folder, then try base path as a file\r
+               if (file != null && !file.exists() && basePath.segmentCount() > 1) {\r
+                       file = workspaceRoot.getFile(basePath);\r
+               }\r
+\r
+               if (file == null && basePath.segmentCount() == 1) {\r
+                       file = workspaceRoot.getProject(basePath.segment(0));\r
+               }\r
+\r
+               if (file == null) {\r
+                       /*\r
+                        * https://bugs.eclipse.org/bugs/show_bug.cgi?id=116529\r
+                        * \r
+                        * This method produces a less accurate result, but doesn't\r
+                        * require that the file exist yet.\r
+                        */\r
+                       IFile[] files = ResourcesPlugin.getWorkspace().getRoot().findFilesForLocation(basePath);\r
+                       if (files.length > 0)\r
+                               file = files[0];\r
+               }\r
+\r
+               while (file != null) {\r
+                       /**\r
+                        * Treat any parent folder with a WEB-INF subfolder as a web-app\r
+                        * root\r
+                        */\r
+                       IContainer folder = null;\r
+                       if ((file.getType() & IResource.FOLDER) != 0) {\r
+                               folder = (IContainer) file;\r
+                       }\r
+                       else {\r
+                               folder = file.getParent();\r
+                       }\r
+                       // getFolder on a workspace root must use a full path, skip\r
+                       if (folder != null && (folder.getType() & IResource.ROOT) == 0) {\r
+                               IFolder webinf = folder.getFolder(WEB_INF_PATH);\r
+                               if (webinf != null && webinf.exists()) {\r
+                                       return folder.getFullPath();\r
+                               }\r
+                       }\r
+                       file = file.getParent();\r
+               }\r
+\r
+               return basePath.uptoSegment(1);\r
+       }\r
+\r
+\r
+}\r
diff --git a/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/project/ModuleCoreSupportDelegate.java b/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/project/ModuleCoreSupportDelegate.java
new file mode 100644 (file)
index 0000000..e8b6112
--- /dev/null
@@ -0,0 +1,151 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2009 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.web.core.internal.project;
+
+import java.lang.ref.Reference;
+import java.lang.ref.SoftReference;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.wst.common.componentcore.ComponentCore;
+import org.eclipse.wst.common.componentcore.ModuleCoreNature;
+import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
+import org.eclipse.wst.common.componentcore.resources.IVirtualFile;
+import org.eclipse.wst.common.componentcore.resources.IVirtualResource;
+
+/**
+ * Wrapper class for all Facet and ModuleCore-related calls. If the Facet or
+ * ModuleCore bundles are not available, this class will not load, or if it
+ * does, its methods will cause NoClassDefFoundErrors. This allows us to
+ * compartmentalize the dependencies.
+ * 
+ */
+final class ModuleCoreSupportDelegate {
+       private static final String SLASH = "/";
+       private static Map fResolvedMap = new HashMap();
+
+       /**
+        * @param path
+        *            - the full path to a resource within the workspace
+        * @return - the runtime path of the resource if one exists, null
+        *         otherwise
+        */
+       static IPath getRuntimePath(IPath path) {
+               if (path == null)
+                       return null;
+
+               IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(path.segment(0));
+
+               if (!ModuleCoreNature.isFlexibleProject(project))
+                       return null;
+
+               IVirtualResource[] virtualResources = ComponentCore.createResources(ResourcesPlugin.getWorkspace().getRoot().getFile(path));
+               if (virtualResources != null && virtualResources.length > 0) {
+                       return virtualResources[0].getRuntimePath();
+               }
+               return null;
+       }
+
+       /**
+        * @param project
+        * @return the IPath to the "root" of the web contents
+        */
+       static IPath getWebContentRootPath(IProject project) {
+               if (project == null)
+                       return null;
+
+               if (!ModuleCoreNature.isFlexibleProject(project))
+                       return null;
+
+               IPath path = null;
+               IVirtualComponent component = ComponentCore.createComponent(project);
+               if (component != null && component.exists()) {
+                       path = component.getRootFolder().getWorkspaceRelativePath();
+               }
+               return path;
+       }
+
+       /**
+        * @param basePath
+        *            - the full path to a resource within the workspace
+        * @param reference
+        *            - the reference string to resolve
+        * @return - the full path within the workspace that corresponds to the
+        *         given reference according to the virtual pathing support
+        */
+       static IPath resolve(IPath basePath, String reference) {
+               if (reference == null || basePath == null || basePath.segmentCount() == 0)
+                       return null;
+
+               IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(basePath.segment(0));
+
+               if (!ModuleCoreNature.isFlexibleProject(project))
+                       return null;
+
+               if (basePath.segmentCount() > 1) {
+                       /*
+                        * It can take the better part of a full second to do this, so
+                        * cache the result.
+                        */
+                       IPath resolved = null;
+                       Map mapForBaseResource = null;
+                       mapForBaseResource = (Map) fResolvedMap.get(basePath);
+                       if (mapForBaseResource != null) {
+                               Reference resolvedReference = (Reference) mapForBaseResource.get(reference);
+                               if (resolvedReference != null)
+                                       resolved = (IPath) resolvedReference.get();
+                       }
+                       else {
+                               mapForBaseResource = new HashMap();
+                               fResolvedMap.put(basePath, mapForBaseResource);
+                       }
+
+                       if (resolved == null) {
+                               IFile baseFile = ResourcesPlugin.getWorkspace().getRoot().getFile(basePath);
+                               IVirtualResource[] virtualResources = ComponentCore.createResources(baseFile);
+                               for (int i = 0; i < virtualResources.length; i++) {
+                                       IPath baseRuntimePath = virtualResources[i].getRuntimePath();
+                                       IPath referenceRuntimePath = null;
+                                       if (reference.startsWith(SLASH)) {
+                                               referenceRuntimePath = new Path(reference);
+                                       }
+                                       else {
+                                               referenceRuntimePath = baseRuntimePath.removeLastSegments(1).append(reference);
+                                       }
+                                       IVirtualFile virtualFile = ComponentCore.createFile(project, referenceRuntimePath);
+                                       if (virtualFile != null && virtualFile.exists()) {
+                                               IFile[] underlyingFiles = virtualFile.getUnderlyingFiles();
+                                               for (int j = 0; j < underlyingFiles.length; j++) {
+                                                       if (underlyingFiles[j].getProject().equals(project) && underlyingFiles[j].exists()) {
+                                                               mapForBaseResource.put(reference, new SoftReference(underlyingFiles[j].getFullPath()));
+                                                               resolved = underlyingFiles[j].getFullPath();
+                                                       }
+
+                                               }
+                                       }
+                               }
+                       }
+                       return resolved;
+               }
+               else {
+                       IVirtualFile virtualFile = ComponentCore.createFile(project, new Path(reference));
+                       if (virtualFile != null && virtualFile.exists()) {
+                               return virtualFile.getUnderlyingFile().getFullPath();
+                       }
+               }
+               return null;
+       }
+}
diff --git a/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/project/ModuleSourcePathProvider.java b/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/project/ModuleSourcePathProvider.java
new file mode 100644 (file)
index 0000000..1183854
--- /dev/null
@@ -0,0 +1,60 @@
+/*******************************************************************************\r
+ * Copyright (c) 2010, 2011 IBM Corporation and others.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ * \r
+ * Contributors:\r
+ *     IBM Corporation - initial API and implementation\r
+ *******************************************************************************/\r
+package org.eclipse.wst.jsdt.web.core.internal.project;\r
+\r
+import org.eclipse.core.resources.IProject;\r
+import org.eclipse.core.resources.IResource;\r
+import org.eclipse.core.runtime.IPath;\r
+import org.eclipse.core.runtime.Path;\r
+import org.eclipse.wst.common.componentcore.ComponentCore;\r
+import org.eclipse.wst.common.componentcore.ModuleCoreNature;\r
+import org.eclipse.wst.common.componentcore.resources.IVirtualFile;\r
+import org.eclipse.wst.jsdt.core.IIncludePathAttribute;\r
+import org.eclipse.wst.jsdt.core.IIncludePathEntry;\r
+import org.eclipse.wst.jsdt.core.JavaScriptCore;\r
+import org.eclipse.wst.jsdt.internal.core.ClasspathEntry;\r
+import org.eclipse.wst.jsdt.internal.core.util.DefaultSourcePathProvider;\r
+\r
+public class ModuleSourcePathProvider extends DefaultSourcePathProvider {\r
+\r
+       public static final String PROVIDER_ATTRIBUTE_KEY_NAME = "provider"; //$NON-NLS-1$\r
+       public static final String PROVIDER_ATTRIBUTE_KEY_VALUE = ModuleSourcePathProvider.class.getName(); //$NON-NLS-1$\r
+       \r
+       public ModuleSourcePathProvider() {\r
+       }\r
+\r
+       public IIncludePathEntry[] getDefaultSourcePaths(IProject p) {\r
+               if (ModuleCoreNature.isFlexibleProject(p)) {\r
+                       IVirtualFile root = ComponentCore.createFile(p, Path.ROOT);\r
+                       IResource[] underlyingResources = root.getUnderlyingResources();\r
+                       if (underlyingResources == null || underlyingResources.length == 0) {\r
+                               underlyingResources = new IResource[]{root.getUnderlyingResource()};\r
+                       }\r
+                       if (underlyingResources.length > 0 && underlyingResources[0] != null) {\r
+                               IPath[] paths = new IPath[underlyingResources.length];\r
+                               for (int i = 0; i < underlyingResources.length; i++) {\r
+                                       paths[i] = underlyingResources[i].getFullPath();\r
+                               }\r
+                               if (paths.length > 0) {\r
+                                       IIncludePathEntry[] entries = new IIncludePathEntry[paths.length];\r
+                                       for (int i = 0; i < paths.length; i++) {\r
+                                               entries[i] = JavaScriptCore.newSourceEntry(paths[i]);\r
+                                       }\r
+                                       return entries;\r
+                               }\r
+                       }\r
+               }\r
+               \r
+               return new IIncludePathEntry[]{JavaScriptCore.newSourceEntry(p.getFullPath(),\r
+                               ClasspathEntry.INCLUDE_ALL,ClasspathEntry.EXCLUDE_NONE,null,\r
+                               new IIncludePathAttribute[]{JavaScriptCore.newIncludepathAttribute(PROVIDER_ATTRIBUTE_KEY_NAME, PROVIDER_ATTRIBUTE_KEY_VALUE)})};\r
+       }\r
+}\r
diff --git a/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/project/WebProjectJsGlobalScopeContainerInitializer.java b/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/project/WebProjectJsGlobalScopeContainerInitializer.java
new file mode 100644 (file)
index 0000000..ba256bd
--- /dev/null
@@ -0,0 +1,237 @@
+/*******************************************************************************
+ * 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.web.core.internal.project;
+
+import java.net.URI;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.wst.jsdt.core.IIncludePathEntry;
+import org.eclipse.wst.jsdt.core.IJavaScriptProject;
+import org.eclipse.wst.jsdt.core.IJsGlobalScopeContainer;
+import org.eclipse.wst.jsdt.core.JsGlobalScopeContainerInitializer;
+import org.eclipse.wst.jsdt.core.compiler.libraries.LibraryLocation;
+import org.eclipse.wst.jsdt.web.core.javascript.JsNameManglerUtil;
+import org.eclipse.wst.jsdt.web.core.javascript.WebRootFinder;
+
+/**
+*
+* Provisional API: This class/interface is part of an interim API that is still under development and expected to
+* change significantly before reaching stability. It is being made available at this early stage to solicit feedback
+* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
+* (repeatedly) as the API evolves.
+*/
+public class WebProjectJsGlobalScopeContainerInitializer extends JsGlobalScopeContainerInitializer  {
+       private static final String CONTAINER_DESCRIPTION = Messages.getString("WebProjectJsGlobalScopeContainerInitializer.0"); //$NON-NLS-1$
+       
+       public static final char[] LIB_NAME = {'b','r','o','w','s','e','r','W','i','n','d','o','w','.','j','s'};
+       /* Some tokens for us to identify mangled paths */
+       private static final String MANGLED_BUTT1 = "htm"; //$NON-NLS-1$
+       private static final String MANGLED_BUTT2 = ".js"; //$NON-NLS-1$
+       
+       //private IJavaScriptProject javaProject;
+       
+       
+       private static String getUnmangedHtmlPath(String containerPathString) {
+               if (containerPathString == null) {
+                       return null;
+               }
+               if (containerPathString.toLowerCase().indexOf(WebProjectJsGlobalScopeContainerInitializer.MANGLED_BUTT1) != -1 && containerPathString.toLowerCase().indexOf(WebProjectJsGlobalScopeContainerInitializer.MANGLED_BUTT2) != -1) {
+                       return JsNameManglerUtil.unmangle(containerPathString);
+               }
+               return null;
+       }
+       public LibraryLocation getLibraryLocation() {
+               return null;
+       }
+       
+       
+       
+       /*
+        * (non-Javadoc)
+        * 
+        * @see org.eclipse.wst.jsdt.core.JsGlobalScopeContainerInitializer#canUpdateJsGlobalScopeContainer(org.eclipse.core.runtime.IPath,
+        *      org.eclipse.wst.jsdt.core.IJavaScriptProject)
+        */
+       
+       public boolean canUpdateJsGlobalScopeContainer(IPath containerPath, IJavaScriptProject project) {
+               /* dont remove from this project */
+               return false;
+       }
+       
+       
+       protected IJsGlobalScopeContainer getContainer(IPath containerPath, IJavaScriptProject project) {
+               return this;
+       }
+       
+       
+       public String getDescription() {
+               return WebProjectJsGlobalScopeContainerInitializer.CONTAINER_DESCRIPTION;
+       }
+       
+       /*
+        * (non-Javadoc)
+        * 
+        * @see org.eclipse.wst.jsdt.core.JsGlobalScopeContainerInitializer#getDescription(org.eclipse.core.runtime.IPath,
+        *      org.eclipse.wst.jsdt.core.IJavaScriptProject)
+        */
+       
+       public String getDescription(IPath containerPath, IJavaScriptProject javaProject) {
+               if (containerPath.equals(new Path(JsWebNature.VIRTUAL_CONTAINER))) {
+                       return WebProjectJsGlobalScopeContainerInitializer.CONTAINER_DESCRIPTION;
+               }
+               
+               String containerPathString = containerPath.toString();
+               IPath webContext = getWebContextRoot(javaProject);
+               String fileExtension = containerPath.getFileExtension();
+               if(containerPath.equals(getWebContextRoot(javaProject)) || (fileExtension!=null && fileExtension.equals("js"))) { //$NON-NLS-1$
+                       return webContext.toString();
+               }
+               String unmangled = WebProjectJsGlobalScopeContainerInitializer.getUnmangedHtmlPath(containerPathString);
+               if (unmangled != null) {
+                       IPath projectPath = javaProject.getPath();
+                       /* Replace the project path with the project name */
+                       if (unmangled.indexOf(projectPath.toString()) >= 0) {
+                               unmangled = javaProject.getDisplayName() + ":" + unmangled.substring(projectPath.toString().length()); //$NON-NLS-1$
+                       }
+                       return unmangled;
+               }
+               return containerPathString;
+       }
+       
+       /*
+        * (non-Javadoc)
+        * 
+        * @see org.eclipse.wst.jsdt.core.JsGlobalScopeContainerInitializer#getHostPath(org.eclipse.core.runtime.IPath)
+        */
+       
+       public URI getHostPath(IPath path, IJavaScriptProject project) {
+               // TODO Auto-generated method stub
+               String htmlPath = WebProjectJsGlobalScopeContainerInitializer.getUnmangedHtmlPath(path.toString());
+               if (htmlPath != null) {
+                       URI fileUri =  new Path(htmlPath).toFile().toURI();
+                       return fileUri;
+                       //                      try {
+//                             return new URI(htmlPath);
+//                     } catch (URISyntaxException ex) {
+//                             ex.printStackTrace();
+//                     }
+               }
+//             else {
+//                     try {
+//                             return new URI(path.toString());
+//                     } catch (URISyntaxException ex) {
+//                             // TODO Auto-generated catch block
+//                             ex.printStackTrace();
+//                     }
+//             }
+               return null;
+       }
+       
+       
+       public int getKind() {
+               return IJsGlobalScopeContainer.K_SYSTEM;
+       }
+       
+       
+       public IPath getPath() {
+               return new Path(JsWebNature.VIRTUAL_CONTAINER);
+       }
+
+       /**
+        * @deprecated Use {@link #getIncludepathEntries()} instead
+        */
+       public IIncludePathEntry[] getClasspathEntries() {
+               return getIncludepathEntries();
+       }
+       public IIncludePathEntry[] getIncludepathEntries() {
+               
+               //IIncludePathEntry entry=null;
+               
+       return new IIncludePathEntry[0];
+//             try {
+//             
+//                     
+//                     
+//                     IPath contextPath = getWebContextRoot(javaProject);
+//                     //entry =JavaScriptCore.newLibraryEntry(contextPath.makeAbsolute(), null,null, new IAccessRule[0], new IIncludePathAttribute[0], true);
+//                     //entry =JavaScriptCore.newLibraryEntry(contextPath.makeAbsolute(), null, null, new IAccessRule[0], new IIncludePathAttribute[0], true);
+//                     //entry =JavaScriptCore.newSourceEntry(contextPath.makeAbsolute());
+//                     entry = new ClasspathEntry(
+//                                     IPackageFragmentRoot.K_SOURCE,
+//                                     IIncludePathEntry.CPE_SOURCE,
+//                                     contextPath.makeAbsolute(),
+//                                     ClasspathEntry.INCLUDE_ALL, ClasspathEntry.EXCLUDE_NONE,
+//                                     null, // source attachment
+//                                     null, // source attachment root
+//                                     null, // custom output location
+//                                     false,
+//                                     null,
+//                                     false, // no access rules to combine
+//                                     new IIncludePathAttribute[] {ClasspathEntry.EXCLUDE_VALIDATE}); 
+//                     
+//             } catch (RuntimeException ex) {
+//                     // TODO Auto-generated catch block
+//                     ex.printStackTrace();
+//             }
+//             
+//             if(entry!=null) return new IIncludePathEntry[] {entry};
+//             return new IIncludePathEntry[0];
+       }
+       public void initialize(IPath containerPath, IJavaScriptProject project) throws CoreException {
+               //this.javaProject = project;
+               super.initialize(containerPath, project);
+               
+       }
+       
+       public static IPath getWebContextRoot(IJavaScriptProject javaProject) {
+               IPath projectRelativeWebRoot = WebRootFinder.getWebContentFolder(javaProject.getProject());     
+               IPath webRootPath = javaProject.getPath().append(projectRelativeWebRoot);
+               return webRootPath;
+       }
+       
+//     public IPath[] getAllHtmlInProject() {
+//             final ArrayList found = new ArrayList();
+//             String webRoot = getWebContextRoot(javaProject).toString();     
+//                     IResourceProxyVisitor visitor = new IResourceProxyVisitor()
+//                     {
+//                             public boolean visit( IResourceProxy proxy ) throws CoreException
+//                             {
+//                                     if ( proxy.getName().endsWith( ".htm" ) )
+//                                     {
+//                                             IPath path = proxy.requestResource().getLocation();
+//                                             found.add(path);
+//                                             //IIncludePathEntry newLibraryEntry = JavaScriptCore.newLibraryEntry( path,null, null, new IAccessRule[ 0 ], new IIncludePathAttribute[ 0 ], true );
+//                                             //entries.add( newLibraryEntry );
+//                                             return false;
+//                                     }
+//                                     
+//                                     return true;
+//                             }
+//                     };
+//                     try
+//                     {
+//                             javaProject.getProject().findMember( new Path(webRoot) ).accept( visitor, 0 );
+//                     }
+//                     catch ( CoreException e )
+//                     {
+//                     }
+//             
+//             
+//             return (IPath[])found.toArray(new IPath[found.size()]);
+//     
+//     }
+       
+}
diff --git a/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/project/messages.properties b/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/project/messages.properties
new file mode 100644 (file)
index 0000000..6801bd8
--- /dev/null
@@ -0,0 +1,19 @@
+###############################################################################
+# 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
+###############################################################################
+JsNatureUninstaller.1=Uninstalling JavaScript Development Tools...
+JsNatureUninstaller.2=Removing JavaScript Development Tools Nature...
+JsNatureUninstaller.3=Error installing runtime\! JavaScript Development Tools could not be removed, or is not present in target project..
+JsNatureInstaller.1=Installing JavaScript Development Tools...
+JsNatureInstaller.2=Adding JavaScript Development Toolkit Nature...
+JsNatureInstaller.3=Error installing runtime\! JavaScript Development Tools could not be added..
+JsWebNature.5=Error checking sourcepath:
+JsWebNature.6=Error checking sourcepath:
+WebProjectJsGlobalScopeContainerInitializer.0=JavaScript Web Project support
diff --git a/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/provisional/contenttype/ContentTypeIdForEmbededJs.java b/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/provisional/contenttype/ContentTypeIdForEmbededJs.java
new file mode 100644 (file)
index 0000000..f4f8734
--- /dev/null
@@ -0,0 +1,35 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.web.core.internal.provisional.contenttype;
+/**
+*
+* Provisional API: This class/interface is part of an interim API that is still under development and expected to
+* change significantly before reaching stability. It is being made available at this early stage to solicit feedback
+* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
+* (repeatedly) as the API evolves.
+*/
+public class ContentTypeIdForEmbededJs {
+       /**
+        * The value of the contenttype id field must match what is specified in
+        * plugin.xml file. Note: this value is intentially set with default
+        * protected method so it will not be inlined.
+        */
+       public final static String[] ContentTypeIds = ContentTypeIdForEmbededJs. getJsConstantString();
+
+       static String[] getJsConstantString() {
+               return new String[] {"org.eclipse.wst.html.core.htmlsource","org.eclipse.jst.jsp.core.jspsource"}; //$NON-NLS-1$ //$NON-NLS-2$
+       }
+       
+       private ContentTypeIdForEmbededJs() {
+               super();
+       }
+}
diff --git a/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/provisional/contenttype/IContentDescriptionForJSP.java b/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/provisional/contenttype/IContentDescriptionForJSP.java
new file mode 100644 (file)
index 0000000..2b48f85
--- /dev/null
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.web.core.internal.provisional.contenttype;
+
+import org.eclipse.core.runtime.QualifiedName;
+import org.eclipse.wst.sse.core.internal.encoding.ICodedResourcePlugin;
+/**
+*
+* Provisional API: This class/interface is part of an interim API that is still under development and expected to
+* change significantly before reaching stability. It is being made available at this early stage to solicit feedback
+* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
+* (repeatedly) as the API evolves.
+*/
+public interface IContentDescriptionForJSP {
+       public final static QualifiedName CONTENT_FAMILY_ATTRIBUTE = new QualifiedName(ICodedResourcePlugin.ID, "contentFamilyAttribute"); //$NON-NLS-1$;
+       /**
+        * Extra properties as part of ContentDescription, if the content is JSP.
+        */
+       public final static QualifiedName CONTENT_TYPE_ATTRIBUTE = new QualifiedName(ICodedResourcePlugin.ID, "contentTypeAttribute"); //$NON-NLS-1$
+       public final static QualifiedName LANGUAGE_ATTRIBUTE = new QualifiedName(ICodedResourcePlugin.ID, "languageAttribute"); //$NON-NLS-1$
+}
diff --git a/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/validation/JsValidator.java b/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/validation/JsValidator.java
new file mode 100644 (file)
index 0000000..9a24fd5
--- /dev/null
@@ -0,0 +1,368 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.web.core.internal.validation;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Locale;
+import java.util.Set;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IResourceProxy;
+import org.eclipse.core.resources.IResourceProxyVisitor;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExecutableExtension;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.wst.jsdt.core.compiler.IProblem;
+import org.eclipse.wst.jsdt.web.core.internal.Logger;
+import org.eclipse.wst.jsdt.web.core.javascript.IJsTranslation;
+import org.eclipse.wst.jsdt.web.core.javascript.JsTranslationAdapter;
+import org.eclipse.wst.jsdt.web.core.javascript.JsTranslationAdapterFactory;
+import org.eclipse.wst.sse.core.StructuredModelManager;
+import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
+import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument;
+import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
+import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion;
+import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionCollection;
+import org.eclipse.wst.validation.AbstractValidator;
+import org.eclipse.wst.validation.ValidationResult;
+import org.eclipse.wst.validation.ValidationState;
+import org.eclipse.wst.validation.internal.core.Message;
+import org.eclipse.wst.validation.internal.core.ValidationException;
+import org.eclipse.wst.validation.internal.operations.IWorkbenchContext;
+import org.eclipse.wst.validation.internal.provisional.core.IMessage;
+import org.eclipse.wst.validation.internal.provisional.core.IReporter;
+import org.eclipse.wst.validation.internal.provisional.core.IValidationContext;
+import org.eclipse.wst.validation.internal.provisional.core.IValidator;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
+
+public class JsValidator extends AbstractValidator implements IValidator, IExecutableExtension {
+       private static final boolean DEBUG = Boolean.valueOf(Platform.getDebugOption("org.eclipse.wst.jsdt.web.core/debug/jsvalidator")).booleanValue(); //$NON-NLS-1$
+       private IValidator fMessageOriginator;
+       private Set fValidFileExts = new HashSet();
+       
+       private static final String[] METADATA_FILES = new String[]{".settings/.jsdtscope",".settings/org.eclipse.wst.jsdt.ui.superType.container",".settings/org.eclipse.wst.jsdt.ui.superType.name"};
+       
+//     private static String [] jsdtValidator = {"org.eclipse.wst.jsdt.web.core.internal.validation.JsBatchValidator"}; //$NON-NLS-1$
+
+       
+       protected class LocalizedMessage extends Message {
+               private String _message = null;
+               
+               public LocalizedMessage(int severity, String messageText) {
+                       this(severity, messageText, null);
+               }
+               
+               public LocalizedMessage(int severity, String messageText, IResource targetObject) {
+                       this(severity, messageText, (Object) targetObject);
+               }
+               
+               public LocalizedMessage(int severity, String messageText, Object targetObject) {
+                       super(null, severity, null);
+                       setLocalizedMessage(messageText);
+                       setTargetObject(targetObject);
+               }
+               
+               public String getLocalizedMessage() {
+                       return _message;
+               }
+               
+               
+               public String getText() {
+                       return getLocalizedMessage();
+               }
+               
+               
+               public String getText(ClassLoader cl) {
+                       return getLocalizedMessage();
+               }
+               
+               
+               public String getText(Locale l) {
+                       return getLocalizedMessage();
+               }
+               
+               
+               public String getText(Locale l, ClassLoader cl) {
+                       return getLocalizedMessage();
+               }
+               
+               public void setLocalizedMessage(String message) {
+                       _message = message;
+               }
+       }
+       public JsValidator() {
+               this.fMessageOriginator = this;
+       }
+       
+       /**
+        * Creates an IMessage from an IProblem
+        * 
+        * @param problem
+        * @param f
+        * @param translation
+        * @param textDoc
+        * @return message representation of the problem, or null if it could not
+        *         create one
+        */
+       private IMessage createMessageFromProblem(IProblem problem, IFile f, IJsTranslation translation, IDocument textDoc) {
+               int sourceStart = problem.getSourceStart();
+               int sourceEnd = problem.getSourceEnd();
+               if (sourceStart == -1) {
+                       return null;
+               }
+               
+               /*
+                * Bug 241794 - Validation shows errors when using JSP Expressions
+                * inside JavaScript code
+                */
+               IStructuredDocument doc = (IStructuredDocument) textDoc;
+               IStructuredDocumentRegion documentRegion = doc.getRegionAtCharacterOffset(sourceStart);
+               if (documentRegion != null) {
+                       ITextRegion textRegion = documentRegion.getRegionAtCharacterOffset(sourceStart);
+                       /*
+                        * Filter out problems from areas that aren't simple JavaScript,
+                        * e.g. JSP.
+                        */
+                       if (textRegion != null && textRegion instanceof ITextRegionCollection)
+                               return null;
+               }
+
+               int sev = problem.isError() ? IMessage.HIGH_SEVERITY : (problem.isWarning() ? IMessage.NORMAL_SEVERITY : IMessage.LOW_SEVERITY);
+               IMessage m = new LocalizedMessage(sev, problem.getMessage(), f);
+               // line numbers for marker starts @ 1
+               // line numbers from document starts @ 0
+               try {
+                       int lineNo = textDoc.getLineOfOffset(sourceStart) + 1;
+                       m.setLineNo(lineNo);
+                       m.setOffset(sourceStart);
+                       m.setLength(sourceEnd - sourceStart + 1);
+               }
+               catch (BadLocationException e) {
+                       Logger.logException(e);
+               }
+               return m;
+       }
+       
+       void performValidation(IFile f, IReporter reporter, IStructuredModel model, boolean inBatch) {
+               if (model instanceof IDOMModel) {
+                       IDOMModel domModel = (IDOMModel) model;
+                       setupAdapterFactory(domModel);
+                       IDOMDocument xmlDoc = domModel.getDocument();
+                       JsTranslationAdapter translationAdapter = (JsTranslationAdapter) xmlDoc.getAdapterFor(IJsTranslation.class);
+                       //translationAdapter.resourceChanged();
+                       IJsTranslation translation = translationAdapter.getJsTranslation(false);
+                       if (!reporter.isCancelled()) {
+                               translation.setProblemCollectingActive(true);
+                               translation.reconcileCompilationUnit();
+                               List problems = translation.getProblems();
+//                             if(!inBatch) reporter.removeAllMessages(this, f);
+                               // add new messages
+                               for (int i = 0; i < problems.size() && !reporter.isCancelled(); i++) {
+                                       IMessage m = createMessageFromProblem((IProblem) problems.get(i), f, translation, domModel.getStructuredDocument());
+                                       if (m != null) {
+                                               reporter.addMessage(fMessageOriginator, m);
+                                       }
+                               }
+                       }
+               }
+       }
+       
+       /* Read the definition for this validator and the declared valid file extensions
+        * @see org.eclipse.core.runtime.IExecutableExtension#setInitializationData(org.eclipse.core.runtime.IConfigurationElement, java.lang.String, java.lang.Object)
+        */
+       public void setInitializationData(IConfigurationElement config, String propertyName, Object data) throws CoreException {
+               IConfigurationElement[] includes = config.getChildren("include"); //$NON-NLS-1$
+               for (int i = 0; i < includes.length; i++) {
+                       IConfigurationElement[] fileexts = includes[i].getChildren("fileext"); //$NON-NLS-1$
+                       for (int j = 0; j < fileexts.length; j++) {
+                               String fileext = fileexts[j].getAttribute("ext"); //$NON-NLS-1$
+                               if (fileext != null) {
+                                       fValidFileExts.add(fileext);
+                               }
+                       }
+               }
+       }
+       
+       /**
+        * Ensures that our translation adapter is present before we try to use it
+        * 
+        * @param sm
+        */
+       private void setupAdapterFactory(IStructuredModel sm) {
+               if (sm.getFactoryRegistry().getFactoryFor(IJsTranslation.class) == null) {
+                       JsTranslationAdapterFactory factory = new JsTranslationAdapterFactory();
+                       sm.getFactoryRegistry().addFactory(factory);
+               }
+       }
+       
+       boolean shouldValidate(IFile file) {
+               IResource resource = file;
+               do {
+                       if (resource.isDerived() || resource.isTeamPrivateMember() || !resource.isAccessible() || resource.getName().charAt(0) == '.') {
+                               return false;
+                       }
+                       resource = resource.getParent();
+               } while ((resource.getType() & IResource.PROJECT) == 0);
+               return fValidFileExts.isEmpty() || fValidFileExts.contains(file.getFileExtension());
+       }
+       
+       public void validate(IValidationContext helper, IReporter reporter) throws ValidationException {
+               /* Added by BC ---- */
+               // if(true) return;
+               /* end Added by BC ---- */
+               
+               String[] uris = helper.getURIs();
+               if (uris.length > 0) {
+                       IWorkspaceRoot wsRoot = ResourcesPlugin.getWorkspace().getRoot();
+                       IFile currentFile = null;
+                       for (int i = 0; i < uris.length && !reporter.isCancelled(); i++) {
+                               currentFile = wsRoot.getFile(new Path(uris[i]));
+                               reporter.removeAllMessages(this, currentFile);
+                               if (currentFile != null && currentFile.exists()) {
+                                       if (shouldValidate(currentFile) ){ //&& fragmentCheck(currentFile)) {
+                                               int percent = (i * 100) / uris.length + 1;
+                                               IMessage message = new LocalizedMessage(IMessage.LOW_SEVERITY, percent + "% " + uris[i]); //$NON-NLS-1$
+                                               reporter.displaySubtask(this, message);
+                                               validateFile(currentFile, reporter);
+                                       }
+                                       if (DEBUG) {
+                                               System.out.println("validating: [" + uris[i] + "]"); //$NON-NLS-1$ //$NON-NLS-2$
+                                       }
+                               }
+                       }
+               } else {
+                       // if uris[] length 0 -> validate() gets called for each project
+                       if (helper instanceof IWorkbenchContext) {
+                               IProject project = ((IWorkbenchContext) helper).getProject();
+                               JSFileVisitor visitor = new JSFileVisitor(reporter);
+                               try {
+                                       // collect all jsp files for the project
+                                       project.accept(visitor, IResource.DEPTH_INFINITE);
+                               } catch (CoreException e) {
+                                       if (DEBUG) {
+                                               e.printStackTrace();
+                                       }
+                               }
+                               IFile[] files = visitor.getFiles();
+                               for (int i = 0; i < files.length && !reporter.isCancelled(); i++) {
+                                       int percent = (i * 100) / files.length + 1;
+                                       IMessage message = new LocalizedMessage(IMessage.LOW_SEVERITY, percent + "% " + files[i].getFullPath().toString()); //$NON-NLS-1$
+                                       reporter.displaySubtask(this, message);
+                                       validateFile(files[i], reporter);
+                                       if (DEBUG) {
+                                               System.out.println("validating: [" + files[i] + "]"); //$NON-NLS-1$ //$NON-NLS-2$
+                                       }
+                               }
+                       }
+               }
+       }
+
+       protected class JSFileVisitor implements IResourceProxyVisitor {
+               private List fFiles = new ArrayList();
+               private IReporter fReporter = null;
+               
+               public JSFileVisitor(IReporter reporter) {
+                       fReporter = reporter;
+               }
+               
+               public final IFile[] getFiles() {
+                       return (IFile[]) fFiles.toArray(new IFile[fFiles.size()]);
+               }
+               
+               
+               public boolean visit(IResourceProxy proxy) throws CoreException {
+                       // check validation
+                       if (fReporter.isCancelled()) {
+                               return false;
+                       }
+                       if (proxy.getType() == IResource.FILE) {
+                               if (Util.isJsType(proxy.getName())) {
+                                       IFile file = (IFile) proxy.requestResource();
+                                       if (file.exists() && shouldValidate(file)) {
+                                               if (DEBUG) {
+                                                       System.out.println("(+) JSPValidator adding file: " + file.getName()); //$NON-NLS-1$
+                                               }
+                                               fFiles.add(file);
+                                               // don't search deeper for files
+                                               return false;
+                                       }
+                               }
+                       }
+                       return true;
+               }
+       }
+       public void cleanup(IReporter reporter) {
+               // nothing to do
+       }
+       /**
+        * Validate one file. It's assumed that the file has JSP content type.
+        * 
+        * @param f
+        * @param reporter
+        */
+       
+       protected void validateFile(IFile f, IReporter reporter) {
+               if (JsValidator.DEBUG) {
+                       Logger.log(Logger.INFO, getClass().getName() + " validating: " + f); //$NON-NLS-1$
+               }
+               IStructuredModel model = null;
+               try {
+                       // get jsp model, get tranlsation
+                       model = StructuredModelManager.getModelManager().getModelForRead(f);
+                       if (!reporter.isCancelled() && model != null) {
+                               // get DOM model then translation
+                               //WorkbenchReporter.removeAllMessages(f.getProject(), jsdtValidator, f.toString());
+                               //reporter.removeAllMessages(fMessageOriginator, f);
+                               performValidation(f, reporter, model, false);
+                       }
+               } catch (IOException e) {
+                       Logger.logException(e);
+               } catch (CoreException e) {
+                       Logger.logException(e);
+               } finally {
+                       if (model != null) {
+                               model.releaseFromRead();
+                       }
+               }
+       }
+       public ValidationResult validate(IResource resource, int kind, ValidationState state, IProgressMonitor monitor) {
+               if (resource.getType() != IResource.FILE || !shouldValidate((IFile) resource))
+                       return null;
+               ValidationResult result = new ValidationResult();
+               IReporter reporter = result.getReporter(monitor);
+               IFile file = (IFile) resource;
+               validateFile(file, reporter);
+               result.setDependsOn(createDependencies(file));
+               return result;
+       }
+
+       private IResource[] createDependencies(IFile file) {
+               IFile[] depends = new IFile[METADATA_FILES.length];
+               for (int i = 0; i < METADATA_FILES.length; i++) {
+                       depends[i] = file.getProject().getFile(METADATA_FILES[i]);
+               }
+               return depends;
+       }
+}
diff --git a/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/validation/Util.java b/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/validation/Util.java
new file mode 100644 (file)
index 0000000..5e84a72
--- /dev/null
@@ -0,0 +1,57 @@
+/*******************************************************************************
+ * 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.web.core.internal.validation;
+
+import java.util.ArrayList;
+
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.content.IContentType;
+import org.eclipse.wst.jsdt.web.core.internal.provisional.contenttype.ContentTypeIdForEmbededJs;
+/**
+*
+
+* Provisional API: This class/interface is part of an interim API that is still under development and expected to
+* change significantly before reaching stability. It is being made available at this early stage to solicit feedback
+* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
+* (repeatedly) as the API evolves.
+*/
+public class Util {
+       
+       public static boolean isJsType(String fileName) {
+               if(fileName==null) return false;
+               boolean valid = false;
+               IContentType[] types =getJavascriptContentTypes();
+               int i = 0;
+               while (types!=null && i < types.length && !valid) {
+                       valid = types[i]!=null && types[i].isAssociatedWith(fileName);
+                       ++i;
+               }
+               return valid;
+               
+       }
+       
+       public static IContentType[] getJavascriptContentTypes() {
+
+               String[] contentTypeIds = ContentTypeIdForEmbededJs.ContentTypeIds;
+               ArrayList fContentTypes = new ArrayList();
+               
+               
+               for(int i = 0;i<contentTypeIds.length;i++) {
+                       IContentType ct =  Platform.getContentTypeManager().getContentType(contentTypeIds[i]);
+                       if(ct!=null) fContentTypes.add(ct);
+               }
+               
+               return (IContentType[])fContentTypes.toArray(new IContentType[fContentTypes.size()]);
+       }
+}
diff --git a/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/javascript/CompilationUnitHelper.java b/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/javascript/CompilationUnitHelper.java
new file mode 100644 (file)
index 0000000..8dbeb85
--- /dev/null
@@ -0,0 +1,71 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2009 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.web.core.javascript;
+
+import org.eclipse.wst.jsdt.core.IJavaScriptUnit;
+import org.eclipse.wst.jsdt.core.IProblemRequestor;
+import org.eclipse.wst.jsdt.core.WorkingCopyOwner;
+
+/**
+
+
+
+
+ * Provisional API: This class/interface is part of an interim API that is still under development and expected to
+ * change significantly before reaching stability. It is being made available at this early stage to solicit feedback
+ * from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
+ * (repeatedly) as the API evolves.
+ * 
+ * <br><br> this code was taken from the JSP plugin.  This class is to ensure only one copy of the compilation unit exits.
+ * 
+ * @author pavery
+ */
+public class CompilationUnitHelper {
+       private static CompilationUnitHelper instance;
+       
+       public synchronized static final CompilationUnitHelper getInstance() {
+               if (CompilationUnitHelper.instance == null) {
+                       CompilationUnitHelper.instance = new CompilationUnitHelper();
+               }
+               return CompilationUnitHelper.instance;
+       }
+       private JsProblemRequestor fProblemRequestor = null;
+       private WorkingCopyOwner fWorkingCopyOwner = null;
+       
+       private CompilationUnitHelper() {
+       // force use of instance
+       }
+       
+       public JsProblemRequestor getProblemRequestor() {
+               if (fProblemRequestor == null) {
+                       fProblemRequestor = new JsProblemRequestor();
+               }
+               return fProblemRequestor;
+       }
+       
+       public WorkingCopyOwner getWorkingCopyOwner() {
+               if (fWorkingCopyOwner == null) {
+                       fWorkingCopyOwner = new WorkingCopyOwner() {
+                               /* (non-Javadoc)
+                                * @see org.eclipse.wst.jsdt.core.WorkingCopyOwner#getProblemRequestor(org.eclipse.wst.jsdt.core.IJavaScriptUnit)
+                                */
+                               public IProblemRequestor getProblemRequestor(IJavaScriptUnit workingCopy) {
+                                       return CompilationUnitHelper.this.getProblemRequestor();
+                               }
+                               
+                               public String toString() {
+                                       return "Client JavaScript WorkingCopyOwner"; //$NON-NLS-1$
+                               }
+                       };
+               }
+               return fWorkingCopyOwner;
+       }
+}
diff --git a/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/javascript/DocumentChangeListenerToTextEdit.java b/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/javascript/DocumentChangeListenerToTextEdit.java
new file mode 100644 (file)
index 0000000..7320ba9
--- /dev/null
@@ -0,0 +1,77 @@
+/*******************************************************************************
+ * 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.web.core.javascript;
+
+import org.eclipse.jface.text.DocumentEvent;
+import org.eclipse.jface.text.IDocumentListener;
+import org.eclipse.text.edits.DeleteEdit;
+import org.eclipse.text.edits.InsertEdit;
+import org.eclipse.text.edits.MultiTextEdit;
+import org.eclipse.text.edits.ReplaceEdit;
+
+/**
+*
+
+* Provisional API: This class/interface is part of an interim API that is still under development and expected to
+* change significantly before reaching stability. It is being made available at this early stage to solicit feedback
+* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
+* (repeatedly) as the API evolves.
+* <br><br>
+* 
+* this class attaches to a "cloned" document, listens for changes to that document then translates
+* the changes to text edits.  these changes can then be applied back to the original document.
+* 
+*
+*/
+public class DocumentChangeListenerToTextEdit implements IDocumentListener {
+       private MultiTextEdit textEdit;
+       
+       public DocumentChangeListenerToTextEdit() {
+               textEdit = new MultiTextEdit();
+       }
+       
+       public void documentAboutToBeChanged(DocumentEvent event) {
+       // System.out.println("Unimplemented
+       // method:DocumentChangeListenerToTextEdit.documentAboutToBeChanged");
+       }
+       
+       public void documentChanged(DocumentEvent event) {
+               int length = event.getLength();
+               int offset = event.getOffset();
+               String text = event.getText();
+               if (length < 0) {
+                       return;
+               }
+               if (length == 0) {
+                       /* inserting text operation */
+                       InsertEdit edit = new InsertEdit(offset, text);
+                       textEdit.addChild(edit);
+                       
+               } else if (text == null || text.equals("")) { //$NON-NLS-1$
+                       /* delete operation */
+                       DeleteEdit edit = new DeleteEdit(offset, length);
+                       textEdit.addChild(edit);
+                       
+               } else if (length > 0) {
+                       /* replace text operation */
+                       ReplaceEdit edit = new ReplaceEdit(offset, length, text);
+                       textEdit.addChild(edit);
+               
+               }
+       }
+       
+       public MultiTextEdit getTextEdits() {
+               return textEdit;
+       }
+}
diff --git a/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/javascript/HTML40Namespace.java b/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/javascript/HTML40Namespace.java
new file mode 100644 (file)
index 0000000..e34d226
--- /dev/null
@@ -0,0 +1,679 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.web.core.javascript;
+/**
+*
+
+* Provisional API: This class/interface is part of an interim API that is still under development and expected to
+* change significantly before reaching stability. It is being made available at this early stage to solicit feedback
+* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
+* (repeatedly) as the API evolves.
+*/
+public interface HTML40Namespace {
+
+       // Element names
+       public static interface ElementName {
+               public static final String A = "A"; //$NON-NLS-1$
+               public static final String ABBR = "ABBR"; //$NON-NLS-1$
+               public static final String ACRONYM = "ACRONYM"; //$NON-NLS-1$
+               public static final String ADDRESS = "ADDRESS"; //$NON-NLS-1$
+               public static final String APPLET = "APPLET"; //$NON-NLS-1$
+               public static final String AREA = "AREA"; //$NON-NLS-1$
+               public static final String B = "B"; //$NON-NLS-1$
+               public static final String BASE = "BASE"; //$NON-NLS-1$
+               public static final String BASEFONT = "BASEFONT"; //$NON-NLS-1$
+               public static final String BDO = "BDO"; //$NON-NLS-1$
+               public static final String BGSOUND = "BGSOUND"; // D205513 //$NON-NLS-1$
+               public static final String BIG = "BIG"; //$NON-NLS-1$
+               public static final String BLINK = "BLINK"; //$NON-NLS-1$
+               public static final String BLOCKQUOTE = "BLOCKQUOTE"; //$NON-NLS-1$
+               public static final String BODY = "BODY"; //$NON-NLS-1$
+               public static final String BR = "BR"; //$NON-NLS-1$
+               public static final String BUTTON = "BUTTON"; //$NON-NLS-1$
+               public static final String CAPTION = "CAPTION"; //$NON-NLS-1$
+               public static final String CENTER = "CENTER"; //$NON-NLS-1$
+               public static final String CITE = "CITE"; //$NON-NLS-1$
+               public static final String CODE = "CODE"; //$NON-NLS-1$
+               public static final String COL = "COL"; //$NON-NLS-1$
+               public static final String COLGROUP = "COLGROUP"; //$NON-NLS-1$
+               public static final String DD = "DD"; //$NON-NLS-1$
+               public static final String DEL = "DEL"; //$NON-NLS-1$
+               public static final String DFN = "DFN"; //$NON-NLS-1$
+               public static final String DIR = "DIR"; //$NON-NLS-1$
+               public static final String DIV = "DIV"; //$NON-NLS-1$
+               public static final String DL = "DL"; //$NON-NLS-1$
+               public static final String DT = "DT"; //$NON-NLS-1$
+               public static final String EM = "EM"; //$NON-NLS-1$
+               public static final String EMBED = "EMBED"; //$NON-NLS-1$
+               public static final String FIELDSET = "FIELDSET"; //$NON-NLS-1$
+               public static final String FONT = "FONT"; //$NON-NLS-1$
+               public static final String FORM = "FORM"; //$NON-NLS-1$
+               public static final String FRAME = "FRAME"; //$NON-NLS-1$
+               public static final String FRAMESET = "FRAMESET"; //$NON-NLS-1$
+               public static final String H1 = "H1"; //$NON-NLS-1$
+               public static final String H2 = "H2"; //$NON-NLS-1$
+               public static final String H3 = "H3"; //$NON-NLS-1$
+               public static final String H4 = "H4"; //$NON-NLS-1$
+               public static final String H5 = "H5"; //$NON-NLS-1$
+               public static final String H6 = "H6"; //$NON-NLS-1$
+               public static final String HEAD = "HEAD"; //$NON-NLS-1$
+               public static final String HR = "HR"; //$NON-NLS-1$
+               public static final String HTML = "HTML"; //$NON-NLS-1$
+               public static final String I = "I"; //$NON-NLS-1$
+               public static final String IFRAME = "IFRAME"; //$NON-NLS-1$
+               public static final String IMG = "IMG"; //$NON-NLS-1$
+               public static final String INPUT = "INPUT"; //$NON-NLS-1$
+               public static final String INS = "INS"; //$NON-NLS-1$
+               public static final String ISINDEX = "ISINDEX"; //$NON-NLS-1$
+               public static final String KBD = "KBD"; //$NON-NLS-1$
+               public static final String LABEL = "LABEL"; //$NON-NLS-1$
+               public static final String LEGEND = "LEGEND"; //$NON-NLS-1$
+               public static final String LI = "LI"; //$NON-NLS-1$
+               public static final String LINK = "LINK"; //$NON-NLS-1$
+               public static final String MAP = "MAP"; //$NON-NLS-1$
+               public static final String MENU = "MENU"; //$NON-NLS-1$
+               public static final String META = "META"; //$NON-NLS-1$
+               public static final String NOBR = "NOBR"; // D205513 //$NON-NLS-1$
+               public static final String NOEMBED = "NOEMBED"; //$NON-NLS-1$
+               public static final String NOFRAMES = "NOFRAMES"; //$NON-NLS-1$
+               public static final String NOSCRIPT = "NOSCRIPT"; //$NON-NLS-1$
+               public static final String OBJECT = "OBJECT"; //$NON-NLS-1$
+               public static final String OL = "OL"; //$NON-NLS-1$
+               public static final String OPTGROUP = "OPTGROUP"; //$NON-NLS-1$
+               public static final String OPTION = "OPTION"; //$NON-NLS-1$
+               public static final String P = "P"; //$NON-NLS-1$
+               public static final String PARAM = "PARAM"; //$NON-NLS-1$
+               public static final String PRE = "PRE"; //$NON-NLS-1$
+               public static final String Q = "Q"; //$NON-NLS-1$
+               public static final String S = "S"; //$NON-NLS-1$
+               public static final String SAMP = "SAMP"; //$NON-NLS-1$
+               public static final String SCRIPT = "SCRIPT"; //$NON-NLS-1$
+               public static final String SELECT = "SELECT"; //$NON-NLS-1$
+               public static final String SMALL = "SMALL"; //$NON-NLS-1$
+               public static final String SPAN = "SPAN"; //$NON-NLS-1$
+               public static final String STRIKE = "STRIKE"; //$NON-NLS-1$
+               public static final String STRONG = "STRONG"; //$NON-NLS-1$
+               public static final String STYLE = "STYLE"; //$NON-NLS-1$
+               public static final String SUB = "SUB"; //$NON-NLS-1$
+               public static final String SUP = "SUP"; //$NON-NLS-1$
+               public static final String TABLE = "TABLE"; //$NON-NLS-1$
+               public static final String TBODY = "TBODY"; //$NON-NLS-1$
+               public static final String TD = "TD"; //$NON-NLS-1$
+               public static final String TEXTAREA = "TEXTAREA"; //$NON-NLS-1$
+               public static final String TFOOT = "TFOOT"; //$NON-NLS-1$
+               public static final String TH = "TH"; //$NON-NLS-1$
+               public static final String THEAD = "THEAD"; //$NON-NLS-1$
+               public static final String TITLE = "TITLE"; //$NON-NLS-1$
+               public static final String TR = "TR"; //$NON-NLS-1$
+               public static final String TT = "TT"; //$NON-NLS-1$
+               public static final String U = "U"; //$NON-NLS-1$
+               public static final String UL = "UL"; //$NON-NLS-1$
+               public static final String VAR = "VAR"; //$NON-NLS-1$
+               public static final String WBR = "WBR"; // D205513 //$NON-NLS-1$
+               public static final String MARQUEE = "MARQUEE"; //$NON-NLS-1$
+               public static final String SSI_CONFIG = "SSI:CONFIG"; // D210393 //$NON-NLS-1$
+               public static final String SSI_ECHO = "SSI:ECHO"; //$NON-NLS-1$
+               public static final String SSI_EXEC = "SSI:EXEC"; //$NON-NLS-1$
+               public static final String SSI_FSIZE = "SSI:FSIZE"; //$NON-NLS-1$
+               public static final String SSI_FLASTMOD = "SSI:FLASTMOD"; //$NON-NLS-1$
+               public static final String SSI_INCLUDE = "SSI:INCLUDE"; //$NON-NLS-1$
+               public static final String SSI_PRINTENV = "SSI:PRINTENV"; //$NON-NLS-1$
+               public static final String SSI_SET = "SSI:SET"; //$NON-NLS-1$
+               public static final String WML_WML = "wml"; //$NON-NLS-1$
+               public static final String WML_CARD = "card"; //$NON-NLS-1$
+               public static final String WML_TEMPLATE = "template"; //$NON-NLS-1$
+               public static final String WML_ACCESS = "access"; //$NON-NLS-1$
+               public static final String WML_DO = "do"; //$NON-NLS-1$
+               public static final String WML_ONEVENT = "onevent"; //$NON-NLS-1$
+               public static final String WML_TIMER = "timer"; //$NON-NLS-1$
+               public static final String WML_ANCHOR = "anchor"; //$NON-NLS-1$
+               public static final String WML_PREV = "prev"; //$NON-NLS-1$
+               public static final String WML_REFRESH = "refresh"; //$NON-NLS-1$
+               public static final String WML_GO = "go"; //$NON-NLS-1$
+               public static final String WML_NOOP = "noop"; //$NON-NLS-1$
+               public static final String WML_SETVAR = "setvar"; //$NON-NLS-1$
+               public static final String WML_POSTFIELD = "postfield"; //$NON-NLS-1$
+       }
+
+       // Character Entities
+       public static interface EntityName {
+               public static final String AACUTE_U = "Aacute"; //$NON-NLS-1$
+               public static final String AACUTE_L = "aacute"; //$NON-NLS-1$
+               public static final String ACIRC_U = "Acirc"; //$NON-NLS-1$
+               public static final String ACIRC_L = "acirc"; //$NON-NLS-1$
+               public static final String ACUTE = "acute"; //$NON-NLS-1$
+               public static final String AELIG_U = "AElig"; //$NON-NLS-1$
+               public static final String AELIG_L = "aelig"; //$NON-NLS-1$
+               public static final String AGRAVE_U = "Agrave"; //$NON-NLS-1$
+               public static final String AGRAVE_L = "agrave"; //$NON-NLS-1$
+               public static final String ALEFSYM = "alefsym"; //$NON-NLS-1$
+               public static final String ALPHA_U = "Alpha"; //$NON-NLS-1$
+               public static final String ALPHA_L = "alpha"; //$NON-NLS-1$
+               public static final String AMP = "amp"; //$NON-NLS-1$
+               public static final String AND = "and"; //$NON-NLS-1$
+               public static final String ANG = "ang"; //$NON-NLS-1$
+               public static final String ARING_U = "Aring"; //$NON-NLS-1$
+               public static final String ARING_L = "aring"; //$NON-NLS-1$
+               public static final String ASYMP = "asymp"; //$NON-NLS-1$
+               public static final String ATILDE_U = "Atilde"; //$NON-NLS-1$
+               public static final String ATILDE_L = "atilde"; //$NON-NLS-1$
+               public static final String AUML_U = "Auml"; //$NON-NLS-1$
+               public static final String AUML_L = "auml"; //$NON-NLS-1$
+               public static final String BDQUO = "bdquo"; //$NON-NLS-1$
+               public static final String BETA_U = "Beta"; //$NON-NLS-1$
+               public static final String BETA_L = "beta"; //$NON-NLS-1$
+               public static final String BRVBAR = "brvbar"; //$NON-NLS-1$
+               public static final String BULL = "bull"; //$NON-NLS-1$
+               public static final String CAP = "cap"; //$NON-NLS-1$
+               public static final String CCEDIL_U = "Ccedil"; //$NON-NLS-1$
+               public static final String CCEDIL_L = "ccedil"; //$NON-NLS-1$
+               public static final String CEDIL = "cedil"; //$NON-NLS-1$
+               public static final String CENT = "cent"; //$NON-NLS-1$
+               public static final String CHI_U = "Chi"; //$NON-NLS-1$
+               public static final String CHI_L = "chi"; //$NON-NLS-1$
+               public static final String CIRC = "circ"; //$NON-NLS-1$
+               public static final String CLUBS = "clubs"; //$NON-NLS-1$
+               public static final String CONG = "cong"; //$NON-NLS-1$
+               public static final String COPY = "copy"; //$NON-NLS-1$
+               public static final String CRARR = "crarr"; //$NON-NLS-1$
+               public static final String CUP = "cup"; //$NON-NLS-1$
+               public static final String CURREN = "curren"; //$NON-NLS-1$
+               public static final String DAGGER_U = "Dagger"; //$NON-NLS-1$
+               public static final String DAGGER_L = "dagger"; //$NON-NLS-1$
+               public static final String DARR_U = "dArr"; //$NON-NLS-1$
+               public static final String DARR_L = "darr"; //$NON-NLS-1$
+               public static final String DEG = "deg"; //$NON-NLS-1$
+               public static final String DELTA_U = "Delta"; //$NON-NLS-1$
+               public static final String DELTA_L = "delta"; //$NON-NLS-1$
+               public static final String DIAMS = "diams"; //$NON-NLS-1$
+               public static final String DIVIDE = "divide"; //$NON-NLS-1$
+               public static final String EACUTE_U = "Eacute"; //$NON-NLS-1$
+               public static final String EACUTE_L = "eacute"; //$NON-NLS-1$
+               public static final String ECIRC_U = "Ecirc"; //$NON-NLS-1$
+               public static final String ECIRC_L = "ecirc"; //$NON-NLS-1$
+               public static final String EGRAVE_U = "Egrave"; //$NON-NLS-1$
+               public static final String EGRAVE_L = "egrave"; //$NON-NLS-1$
+               public static final String EMPTY = "empty"; //$NON-NLS-1$
+               public static final String EMSP = "emsp"; //$NON-NLS-1$
+               public static final String ENSP = "ensp"; //$NON-NLS-1$
+               public static final String EPSILON_U = "Epsilon"; //$NON-NLS-1$
+               public static final String EPSILON_L = "epsilon"; //$NON-NLS-1$
+               public static final String EQUIV = "equiv"; //$NON-NLS-1$
+               public static final String ETA_U = "Eta"; //$NON-NLS-1$
+               public static final String ETA_L = "eta"; //$NON-NLS-1$
+               public static final String ETH_U = "ETH"; //$NON-NLS-1$
+               public static final String ETH_L = "eth"; //$NON-NLS-1$
+               public static final String EUML_U = "Euml"; //$NON-NLS-1$
+               public static final String EUML_L = "euml"; //$NON-NLS-1$
+               public static final String EURO = "euro"; //$NON-NLS-1$
+               public static final String EXIST = "exist"; //$NON-NLS-1$
+               public static final String FNOF = "fnof"; //$NON-NLS-1$
+               public static final String FORALL = "forall"; //$NON-NLS-1$
+               public static final String FRAC12 = "frac12"; //$NON-NLS-1$
+               public static final String FRAC14 = "frac14"; //$NON-NLS-1$
+               public static final String FRAC34 = "frac34"; //$NON-NLS-1$
+               public static final String FRASL = "frasl"; //$NON-NLS-1$
+               public static final String GAMMA_U = "Gamma"; //$NON-NLS-1$
+               public static final String GAMMA_L = "gamma"; //$NON-NLS-1$
+               public static final String GE = "ge"; //$NON-NLS-1$
+               public static final String GT = "gt"; //$NON-NLS-1$
+               public static final String HARR_U = "hArr"; //$NON-NLS-1$
+               public static final String HARR_L = "harr"; //$NON-NLS-1$
+               public static final String HEARTS = "hearts"; //$NON-NLS-1$
+               public static final String HELLIP = "hellip"; //$NON-NLS-1$
+               public static final String IACUTE_U = "Iacute"; //$NON-NLS-1$
+               public static final String IACUTE_L = "iacute"; //$NON-NLS-1$
+               public static final String ICIRC_U = "Icirc"; //$NON-NLS-1$
+               public static final String ICIRC_L = "icirc"; //$NON-NLS-1$
+               public static final String IEXCL = "iexcl"; //$NON-NLS-1$
+               public static final String IGRAVE_U = "Igrave"; //$NON-NLS-1$
+               public static final String IGRAVE_L = "igrave"; //$NON-NLS-1$
+               public static final String IMAGE = "image"; //$NON-NLS-1$
+               public static final String INFIN = "infin"; //$NON-NLS-1$
+               public static final String INT = "int"; //$NON-NLS-1$
+               public static final String IOTA_U = "Iota"; //$NON-NLS-1$
+               public static final String IOTA_L = "iota"; //$NON-NLS-1$
+               public static final String IQUEST = "iquest"; //$NON-NLS-1$
+               public static final String ISIN = "isin"; //$NON-NLS-1$
+               public static final String IUML_U = "Iuml"; //$NON-NLS-1$
+               public static final String IUML_L = "iuml"; //$NON-NLS-1$
+               public static final String KAPPA_U = "Kappa"; //$NON-NLS-1$
+               public static final String KAPPA_L = "kappa"; //$NON-NLS-1$
+               public static final String LAMBDA_U = "Lambda"; //$NON-NLS-1$
+               public static final String LAMBDA_L = "lambda"; //$NON-NLS-1$
+               public static final String LANG = "lang"; //$NON-NLS-1$
+               public static final String LAQUO = "laquo"; //$NON-NLS-1$
+               public static final String LARR_U = "lArr"; //$NON-NLS-1$
+               public static final String LARR_L = "larr"; //$NON-NLS-1$
+               public static final String LCEIL = "lceil"; //$NON-NLS-1$
+               public static final String LDQUO = "ldquo"; //$NON-NLS-1$
+               public static final String LE = "le"; //$NON-NLS-1$
+               public static final String LFLOOR = "lfloor"; //$NON-NLS-1$
+               public static final String LOWAST = "lowast"; //$NON-NLS-1$
+               public static final String LOZ = "loz"; //$NON-NLS-1$
+               public static final String LRM = "lrm"; //$NON-NLS-1$
+               public static final String LSAQUO = "lsaquo"; //$NON-NLS-1$
+               public static final String LSQUO = "lsquo"; //$NON-NLS-1$
+               public static final String LT = "lt"; //$NON-NLS-1$
+               public static final String MACR = "macr"; //$NON-NLS-1$
+               public static final String MDASH = "mdash"; //$NON-NLS-1$
+               public static final String MICRO = "micro"; //$NON-NLS-1$
+               public static final String MIDDOT = "middot"; //$NON-NLS-1$
+               public static final String MINUS = "minus"; //$NON-NLS-1$
+               public static final String MU_U = "Mu"; //$NON-NLS-1$
+               public static final String MU_L = "mu"; //$NON-NLS-1$
+               public static final String NABLA = "nabla"; //$NON-NLS-1$
+               public static final String NBSP = "nbsp"; //$NON-NLS-1$
+               public static final String NDASH = "ndash"; //$NON-NLS-1$
+               public static final String NE = "ne"; //$NON-NLS-1$
+               public static final String NI = "ni"; //$NON-NLS-1$
+               public static final String NOT = "not"; //$NON-NLS-1$
+               public static final String NOTIN = "notin"; //$NON-NLS-1$
+               public static final String NSUB = "nsub"; //$NON-NLS-1$
+               public static final String NTILDE_U = "Ntilde"; //$NON-NLS-1$
+               public static final String NTILDE_L = "ntilde"; //$NON-NLS-1$
+               public static final String NU_U = "Nu"; //$NON-NLS-1$
+               public static final String NU_L = "nu"; //$NON-NLS-1$
+               public static final String OACUTE_U = "Oacute"; //$NON-NLS-1$
+               public static final String OACUTE_L = "oacute"; //$NON-NLS-1$
+               public static final String OCIRC_U = "Ocirc"; //$NON-NLS-1$
+               public static final String OCIRC_L = "ocirc"; //$NON-NLS-1$
+               public static final String OELIG_U = "OElig"; //$NON-NLS-1$
+               public static final String OELIG_L = "oelig"; //$NON-NLS-1$
+               public static final String OGRAVE_U = "Ograve"; //$NON-NLS-1$
+               public static final String OGRAVE_L = "ograve"; //$NON-NLS-1$
+               public static final String OLINE = "oline"; //$NON-NLS-1$
+               public static final String OMEGA_U = "Omega"; //$NON-NLS-1$
+               public static final String OMEGA_L = "omega"; //$NON-NLS-1$
+               public static final String OMICRON_U = "Omicron"; //$NON-NLS-1$
+               public static final String OMICRON_L = "omicron"; //$NON-NLS-1$
+               public static final String OPLUS = "oplus"; //$NON-NLS-1$
+               public static final String OR = "or"; //$NON-NLS-1$
+               public static final String ORDF = "ordf"; //$NON-NLS-1$
+               public static final String ORDM = "ordm"; //$NON-NLS-1$
+               public static final String OSLASH_U = "Oslash"; //$NON-NLS-1$
+               public static final String OSLASH_L = "oslash"; //$NON-NLS-1$
+               public static final String OTILDE_U = "Otilde"; //$NON-NLS-1$
+               public static final String OTILDE_L = "otilde"; //$NON-NLS-1$
+               public static final String OTIMES = "otimes"; //$NON-NLS-1$
+               public static final String OUML_U = "Ouml"; //$NON-NLS-1$
+               public static final String OUML_L = "ouml"; //$NON-NLS-1$
+               public static final String PARA = "para"; //$NON-NLS-1$
+               public static final String PART = "part"; //$NON-NLS-1$
+               public static final String PERMIL = "permil"; //$NON-NLS-1$
+               public static final String PERP = "perp"; //$NON-NLS-1$
+               public static final String PHI_U = "Phi"; //$NON-NLS-1$
+               public static final String PHI_L = "phi"; //$NON-NLS-1$
+               public static final String PI_U = "Pi"; //$NON-NLS-1$
+               public static final String PI_L = "pi"; //$NON-NLS-1$
+               public static final String PIV = "piv"; //$NON-NLS-1$
+               public static final String PLUSMN = "plusmn"; //$NON-NLS-1$
+               public static final String POUND = "pound"; //$NON-NLS-1$
+               public static final String PRIME_U = "Prime"; //$NON-NLS-1$
+               public static final String PRIME_L = "prime"; //$NON-NLS-1$
+               public static final String PROD = "prod"; //$NON-NLS-1$
+               public static final String PROP = "prop"; //$NON-NLS-1$
+               public static final String PSI_U = "Psi"; //$NON-NLS-1$
+               public static final String PSI_L = "psi"; //$NON-NLS-1$
+               public static final String QUOT = "quot"; //$NON-NLS-1$
+               public static final String RADIC = "radic"; //$NON-NLS-1$
+               public static final String RANG = "rang"; //$NON-NLS-1$
+               public static final String RAQUO = "raquo"; //$NON-NLS-1$
+               public static final String RARR_U = "rArr"; //$NON-NLS-1$
+               public static final String RARR_L = "rarr"; //$NON-NLS-1$
+               public static final String RCEIL = "rceil"; //$NON-NLS-1$
+               public static final String RDQUO = "rdquo"; //$NON-NLS-1$
+               public static final String REAL = "real"; //$NON-NLS-1$
+               public static final String REG = "reg"; //$NON-NLS-1$
+               public static final String RFLOOR = "rfloor"; //$NON-NLS-1$
+               public static final String RHO_U = "Rho"; //$NON-NLS-1$
+               public static final String RHO_L = "rho"; //$NON-NLS-1$
+               public static final String RLM = "rlm"; //$NON-NLS-1$
+               public static final String RSAQUO = "rsaquo"; //$NON-NLS-1$
+               public static final String RSQUO = "rsquo"; //$NON-NLS-1$
+               public static final String SBQUO = "sbquo"; //$NON-NLS-1$
+               public static final String SCARON_U = "Scaron"; //$NON-NLS-1$
+               public static final String SCARON_L = "scaron"; //$NON-NLS-1$
+               public static final String SDOT = "sdot"; //$NON-NLS-1$
+               public static final String SECT = "sect"; //$NON-NLS-1$
+               public static final String SHY = "shy"; //$NON-NLS-1$
+               public static final String SIGMA_U = "Sigma"; //$NON-NLS-1$
+               public static final String SIGMA_L = "sigma"; //$NON-NLS-1$
+               public static final String SIGMAF = "sigmaf"; //$NON-NLS-1$
+               public static final String SIM = "sim"; //$NON-NLS-1$
+               public static final String SPADES = "spades"; //$NON-NLS-1$
+               public static final String SUB = "sub"; //$NON-NLS-1$
+               public static final String SUBE = "sube"; //$NON-NLS-1$
+               public static final String SUM = "sum"; //$NON-NLS-1$
+               public static final String SUP = "sup"; //$NON-NLS-1$
+               public static final String SUP1 = "sup1"; //$NON-NLS-1$
+               public static final String SUP2 = "sup2"; //$NON-NLS-1$
+               public static final String SUP3 = "sup3"; //$NON-NLS-1$
+               public static final String SUPE = "supe"; //$NON-NLS-1$
+               public static final String SZLIG = "szlig"; //$NON-NLS-1$
+               public static final String TAU_U = "Tau"; //$NON-NLS-1$
+               public static final String TAU_L = "tau"; //$NON-NLS-1$
+               public static final String THERE4 = "there4"; //$NON-NLS-1$
+               public static final String THETA_U = "Theta"; //$NON-NLS-1$
+               public static final String THETA_L = "theta"; //$NON-NLS-1$
+               public static final String THETASYM = "thetasym"; //$NON-NLS-1$
+               public static final String THINSP = "thinsp"; //$NON-NLS-1$
+               public static final String THORN_U = "THORN"; //$NON-NLS-1$
+               public static final String THORN_L = "thorn"; //$NON-NLS-1$
+               public static final String TILDE = "tilde"; //$NON-NLS-1$
+               public static final String TIMES = "times"; //$NON-NLS-1$
+               public static final String TRADE = "trade"; //$NON-NLS-1$
+               public static final String UACUTE_U = "Uacute"; //$NON-NLS-1$
+               public static final String UACUTE_L = "uacute"; //$NON-NLS-1$
+               public static final String UARR_U = "uArr"; //$NON-NLS-1$
+               public static final String UARR_L = "uarr"; //$NON-NLS-1$
+               public static final String UCIRC_U = "Ucirc"; //$NON-NLS-1$
+               public static final String UCIRC_L = "ucirc"; //$NON-NLS-1$
+               public static final String UGRAVE_U = "Ugrave"; //$NON-NLS-1$
+               public static final String UGRAVE_L = "ugrave"; //$NON-NLS-1$
+               public static final String UML = "uml"; //$NON-NLS-1$
+               public static final String UPSIH = "upsih"; //$NON-NLS-1$
+               public static final String UPSILON_U = "Upsilon"; //$NON-NLS-1$
+               public static final String UPSILON_L = "upsilon"; //$NON-NLS-1$
+               public static final String UUML_U = "Uuml"; //$NON-NLS-1$
+               public static final String UUML_L = "uuml"; //$NON-NLS-1$
+               public static final String WEIERP = "weierp"; //$NON-NLS-1$
+               public static final String XI_U = "Xi"; //$NON-NLS-1$
+               public static final String XI_L = "xi"; //$NON-NLS-1$
+               public static final String YACUTE_U = "Yacute"; //$NON-NLS-1$
+               public static final String YACUTE_L = "yacute"; //$NON-NLS-1$
+               public static final String YEN = "yen"; //$NON-NLS-1$
+               public static final String YUML_U = "Yuml"; //$NON-NLS-1$
+               public static final String YUML_L = "yuml"; //$NON-NLS-1$
+               public static final String ZETA_U = "Zeta"; //$NON-NLS-1$
+               public static final String ZETA_L = "zeta"; //$NON-NLS-1$
+               public static final String ZWJ = "zwj"; //$NON-NLS-1$
+               public static final String ZWNJ = "zwnj"; //$NON-NLS-1$
+       }
+
+       public static final String HTML40_URI = "http://www.w3.org/TR/REC-html40/frameset.dtd"; //$NON-NLS-1$
+       public static final String HTML40_TAG_PREFIX = ""; //$NON-NLS-1$
+       // global attribute names
+       public static final String ATTR_NAME_ID = "id"; // %coreattrs; //$NON-NLS-1$
+       public static final String ATTR_NAME_CLASS = "class"; // %coreattrs; //$NON-NLS-1$
+       public static final String ATTR_NAME_STYLE = "style"; // %coreattrs; //$NON-NLS-1$
+       public static final String ATTR_NAME_TITLE = "title"; // %coreattrs; //$NON-NLS-1$
+       public static final String ATTR_NAME_LANG = "lang"; // %i18n; //$NON-NLS-1$
+       public static final String ATTR_NAME_DIR = "dir"; // %i18n; //$NON-NLS-1$
+       public static final String ATTR_NAME_ONCLICK = "onclick"; // %events; //$NON-NLS-1$
+       public static final String ATTR_NAME_ONDBLCLICK = "ondblclick"; // %events; //$NON-NLS-1$
+       public static final String ATTR_NAME_ONMOUSEDOWN = "onmousedown"; // %events; //$NON-NLS-1$
+       public static final String ATTR_NAME_ONMOUSEUP = "onmouseup"; // %events; //$NON-NLS-1$
+       public static final String ATTR_NAME_ONMOUSEOVER = "onmouseover"; // %events; //$NON-NLS-1$
+       public static final String ATTR_NAME_ONMOUSEMOVE = "onmousemove"; // %events; //$NON-NLS-1$
+       public static final String ATTR_NAME_ONMOUSEOUT = "onmouseout"; // %events; //$NON-NLS-1$
+       public static final String ATTR_NAME_ONKEYPRESS = "onkeypress"; // %events; //$NON-NLS-1$
+       public static final String ATTR_NAME_ONKEYDOWN = "onkeydown"; // %events; //$NON-NLS-1$
+       public static final String ATTR_NAME_ONKEYUP = "onkeyup"; // %events; //$NON-NLS-1$
+       public static final String ATTR_NAME_ONHELP = "onhelp"; // %events; //$NON-NLS-1$
+       public static final String ATTR_NAME_BGCOLOR = "bgcolor"; // %bodycolor;, TABLE //$NON-NLS-1$
+       public static final String ATTR_NAME_TEXT = "text"; // %bodycolor; //$NON-NLS-1$
+       public static final String ATTR_NAME_LINK = "link"; // %bodycolor; //$NON-NLS-1$
+       public static final String ATTR_NAME_VLINK = "vlink"; // %bodycolor; //$NON-NLS-1$
+       public static final String ATTR_NAME_ALINK = "alink"; // %bodycolor; //$NON-NLS-1$
+       public static final String ATTR_NAME_VERSION = "version"; // HTML //$NON-NLS-1$
+       public static final String ATTR_NAME_PROFILE = "profile"; // HEAD //$NON-NLS-1$
+       public static final String ATTR_NAME_ONLOAD = "onload"; // BODY //$NON-NLS-1$
+       public static final String ATTR_NAME_ONUNLOAD = "onunload"; // BODY //$NON-NLS-1$
+       public static final String ATTR_NAME_BACKGROUND = "background"; // BODY, TABLE //$NON-NLS-1$
+       public static final String ATTR_NAME_SRC = "src"; // IMG //$NON-NLS-1$
+       public static final String ATTR_NAME_ALT = "alt"; // IMG,AREA //$NON-NLS-1$
+       public static final String ATTR_NAME_LONGDESC = "longdesc"; // IMG //$NON-NLS-1$
+       public static final String ATTR_NAME_NAME = "name"; // IMG //$NON-NLS-1$
+       public static final String ATTR_NAME_HEIGHT = "height"; // IMG, TABLE //$NON-NLS-1$
+       public static final String ATTR_NAME_WIDTH = "width"; // IMG, TABLE,HR //$NON-NLS-1$
+       public static final String ATTR_NAME_USEMAP = "usemap"; // IMG //$NON-NLS-1$
+       public static final String ATTR_NAME_ISMAP = "ismap"; // IMG //$NON-NLS-1$
+       public static final String ATTR_NAME_ALIGN = "align"; // IMG, TABLE,HR //$NON-NLS-1$
+       public static final String ATTR_NAME_BORDER = "border"; // IMG, TABLE //$NON-NLS-1$
+       public static final String ATTR_NAME_HSPACE = "hspace"; // IMG //$NON-NLS-1$
+       public static final String ATTR_NAME_VSPACE = "vspace"; // IMG //$NON-NLS-1$
+       public static final String ATTR_NAME_MAPFILE = "mapfile"; // IMG //$NON-NLS-1$
+       public static final String ATTR_NAME_SUMMARY = "summary"; // TABLE //$NON-NLS-1$
+       public static final String ATTR_NAME_FRAME = "frame"; // TABLE //$NON-NLS-1$
+       public static final String ATTR_NAME_RULES = "rules"; // TABLE //$NON-NLS-1$
+       public static final String ATTR_NAME_CELLSPACING = "cellspacing"; // TABLE //$NON-NLS-1$
+       public static final String ATTR_NAME_CELLPADDING = "cellpadding"; // TABLE //$NON-NLS-1$
+       public static final String ATTR_NAME_DATAPAGESIZE = "datapagesize"; // TABLE,HR //$NON-NLS-1$
+       public static final String ATTR_NAME_COLOR = "color"; // BASEFONT,FONT //$NON-NLS-1$
+       public static final String ATTR_NAME_FACE = "face"; // BASEFONT,FONT //$NON-NLS-1$
+       public static final String ATTR_NAME_SIZE = "size"; // BASEFONT,FONT //$NON-NLS-1$
+       public static final String ATTR_NAME_CLEAR = "clear"; // BR //$NON-NLS-1$
+       public static final String ATTR_NAME_SHAPE = "shape"; // AREA //$NON-NLS-1$
+       public static final String ATTR_NAME_COORDS = "coords"; // AREA //$NON-NLS-1$
+       public static final String ATTR_NAME_HREF = "href"; // AREA //$NON-NLS-1$
+       public static final String ATTR_NAME_TARGET = "target"; // AREA //$NON-NLS-1$
+       public static final String ATTR_NAME_NOHREF = "nohref"; // AREA //$NON-NLS-1$
+       public static final String ATTR_NAME_TABINDEX = "tabindex"; // AREA //$NON-NLS-1$
+       public static final String ATTR_NAME_ACCESSKEY = "accesskey"; // AREA //$NON-NLS-1$
+       public static final String ATTR_NAME_ONFOCUS = "onfocus"; // AREA //$NON-NLS-1$
+       public static final String ATTR_NAME_ONBLUR = "onblur"; // AREA //$NON-NLS-1$
+       public static final String ATTR_NAME_CHARSET = "charset"; // LINK //$NON-NLS-1$
+       public static final String ATTR_NAME_HREFLANG = "hreflang"; // LINK //$NON-NLS-1$
+       public static final String ATTR_NAME_TYPE = "type"; // LINK //$NON-NLS-1$
+       public static final String ATTR_NAME_REL = "rel"; // LINK //$NON-NLS-1$
+       public static final String ATTR_NAME_REV = "rev"; // LINK //$NON-NLS-1$
+       public static final String ATTR_NAME_MEDIA = "media"; // LINK //$NON-NLS-1$
+       public static final String ATTR_NAME_VALUE = "value"; // PARAM //$NON-NLS-1$
+       public static final String ATTR_NAME_VALUETYPE = "valuetype"; // PARAM //$NON-NLS-1$
+       public static final String ATTR_NAME_NOSHADE = "noshade"; // HR //$NON-NLS-1$
+       public static final String ATTR_NAME_CHECKED = "checked"; // INPUT //$NON-NLS-1$
+       public static final String ATTR_NAME_DISABLED = "disabled"; // INPUT //$NON-NLS-1$
+       public static final String ATTR_NAME_READONLY = "readonly"; // INPUT //$NON-NLS-1$
+       public static final String ATTR_NAME_MAXLENGTH = "maxlength"; // INPUT //$NON-NLS-1$
+       public static final String ATTR_NAME_ONSELECT = "onselect"; // INPUT //$NON-NLS-1$
+       public static final String ATTR_NAME_ONCHANGE = "onchange"; // INPUT //$NON-NLS-1$
+       public static final String ATTR_NAME_ACCEPT = "accept"; // INPUT //$NON-NLS-1$
+       public static final String ATTR_NAME_ISTYLE = "istyle"; // INPUT //$NON-NLS-1$
+       public static final String ATTR_NAME_CHAR = "char"; // COL //$NON-NLS-1$
+       public static final String ATTR_NAME_CHAROFF = "charoff"; // COL //$NON-NLS-1$
+       public static final String ATTR_NAME_VALIGN = "valign"; // COL //$NON-NLS-1$
+       public static final String ATTR_NAME_SPAN = "span"; // COL //$NON-NLS-1$
+       public static final String ATTR_NAME_FRAMEBORDER = "frameborder"; // FRAME //$NON-NLS-1$
+       public static final String ATTR_NAME_MARGINWIDTH = "marginwidth"; // FRAME //$NON-NLS-1$
+       public static final String ATTR_NAME_MARGINHEIGHT = "marginheight"; // FRAME //$NON-NLS-1$
+       public static final String ATTR_NAME_NORESIZE = "noresize"; // FRAME //$NON-NLS-1$
+       public static final String ATTR_NAME_SCROLLING = "scrolling"; // FRAME //$NON-NLS-1$
+       public static final String ATTR_NAME_PROMPT = "prompt"; // ISINDEX //$NON-NLS-1$
+       public static final String ATTR_NAME_HTTP_EQUIV = "http-equiv"; // META //$NON-NLS-1$
+       public static final String ATTR_NAME_CONTENT = "content"; // META //$NON-NLS-1$
+       public static final String ATTR_NAME_SCHEME = "scheme"; // META //$NON-NLS-1$
+       public static final String ATTR_NAME_ERRMSG = "errmsg"; // ssi:config //$NON-NLS-1$
+       public static final String ATTR_NAME_SIZEFMT = "sizefmt"; // ssi:config //$NON-NLS-1$
+       public static final String ATTR_NAME_TIMEFMT = "timefmt"; // ssi:config //$NON-NLS-1$
+       public static final String ATTR_NAME_VAR = "var"; // ssi:echo //$NON-NLS-1$
+       public static final String ATTR_NAME_CGI = "cgi"; // ssi:exec //$NON-NLS-1$
+       public static final String ATTR_NAME_CMD = "cmd"; // ssi:exec //$NON-NLS-1$
+       public static final String ATTR_NAME_FILE = "file"; // ssi:fsize //$NON-NLS-1$
+       public static final String ATTR_NAME_VIRTUAL = "virtual"; // ssi:fsize //$NON-NLS-1$
+       public static final String ATTR_NAME_SELECTED = "selected"; // OPTION //$NON-NLS-1$
+       public static final String ATTR_NAME_LABEL = "label"; // OPTION //$NON-NLS-1$
+       public static final String ATTR_NAME_ROWS = "rows"; // TEXTAREA //$NON-NLS-1$
+       public static final String ATTR_NAME_COLS = "cols"; // TEXTAREA //$NON-NLS-1$
+       public static final String ATTR_NAME_LANGUAGE = "language"; // SCRIPT //$NON-NLS-1$
+       public static final String ATTR_NAME_DEFER = "defer"; // SCRIPT //$NON-NLS-1$
+       public static final String ATTR_NAME_EVENT = "event"; // SCRIPT //$NON-NLS-1$
+       public static final String ATTR_NAME_FOR = "for"; // SCRIPT //$NON-NLS-1$
+       public static final String ATTR_NAME_COMPACT = "compact"; // OL/UL //$NON-NLS-1$
+       public static final String ATTR_NAME_START = "start"; // OL/UL //$NON-NLS-1$
+       public static final String ATTR_NAME_DIRECTKEY = "directkey"; // A //$NON-NLS-1$
+       public static final String ATTR_NAME_CODEBASE = "codebase"; // APPLET //$NON-NLS-1$
+       public static final String ATTR_NAME_ARCHIVE = "archive"; // APPLET //$NON-NLS-1$
+       public static final String ATTR_NAME_CODE = "code"; // APPLET //$NON-NLS-1$
+       public static final String ATTR_NAME_OBJECT = "object"; // APPLET //$NON-NLS-1$
+       public static final String ATTR_NAME_MAYSCRIPT = "mayscript"; // APPLET //$NON-NLS-1$
+       public static final String ATTR_NAME_CITE = "cite"; // BLOCKQUOTE //$NON-NLS-1$
+       public static final String ATTR_NAME_MACRO = "macro"; // D2W //$NON-NLS-1$
+       public static final String ATTR_NAME_DATETIME = "datetime"; // INS/DEL //$NON-NLS-1$
+       public static final String ATTR_NAME_LOOP = "loop"; // EMBED //$NON-NLS-1$
+       public static final String ATTR_NAME_HIDDEN = "hidden"; // EMBED //$NON-NLS-1$
+       public static final String ATTR_NAME_VOLUME = "volume"; // EMBED //$NON-NLS-1$
+       public static final String ATTR_NAME_AUTOSTART = "autostart"; // EMBED //$NON-NLS-1$
+       public static final String ATTR_NAME_AUTOPLAY = "autoplay"; // EMBED //$NON-NLS-1$
+       public static final String ATTR_NAME_AUTOSIZE = "autosize"; // EMBED //$NON-NLS-1$
+       public static final String ATTR_NAME_CONTROLLER = "controller";// EMBED //$NON-NLS-1$
+       public static final String ATTR_NAME_SCALE = "scale"; // EMBED //$NON-NLS-1$
+       public static final String ATTR_NAME_SHOWCONTROLS = "showcontrols";// EMBED //$NON-NLS-1$
+       public static final String ATTR_NAME_PLAYCOUNT = "playcount"; // EMBED //$NON-NLS-1$
+       public static final String ATTR_NAME_REPEAT = "repeat"; // EMBED //$NON-NLS-1$
+       public static final String ATTR_NAME_PANEL = "panel"; // EMBED //$NON-NLS-1$
+       public static final String ATTR_NAME_PALETTE = "palette"; // EMBED //$NON-NLS-1$
+       public static final String ATTR_NAME_TEXTFOCUS = "textfocus"; // EMBED //$NON-NLS-1$
+       public static final String ATTR_NAME_ACTION = "action"; // FORM //$NON-NLS-1$
+       public static final String ATTR_NAME_METHOD = "method"; // FORM //$NON-NLS-1$
+       public static final String ATTR_NAME_ENCTYPE = "enctype"; // FORM //$NON-NLS-1$
+       public static final String ATTR_NAME_ONSUBMIT = "onsubmit"; // FORM //$NON-NLS-1$
+       public static final String ATTR_NAME_ONRESET = "onreset"; // FORM //$NON-NLS-1$
+       public static final String ATTR_NAME_ACCEPT_CHARSET = "accept-charset";// FORM //$NON-NLS-1$
+       public static final String ATTR_NAME_BEHAVIOR = "behavior"; // MARQUEE //$NON-NLS-1$
+       public static final String ATTR_NAME_DIRECTION = "direction"; // MARQUEE //$NON-NLS-1$
+       public static final String ATTR_NAME_SCROLLAMOUNT = "scrollamount";// MARQUEE //$NON-NLS-1$
+       public static final String ATTR_NAME_SCROLLDELAY = "scrolldelay";// MARQUEE //$NON-NLS-1$
+       public static final String ATTR_NAME_TRUESPEED = "truespeed"; // MARQUEE //$NON-NLS-1$
+       public static final String ATTR_NAME_DECLARE = "declare"; // OBJECT //$NON-NLS-1$
+       public static final String ATTR_NAME_CLASSID = "classid"; // OBJECT //$NON-NLS-1$
+       public static final String ATTR_NAME_DATA = "data"; // OBJECT //$NON-NLS-1$
+       public static final String ATTR_NAME_CODETYPE = "codetype"; // OBJECT //$NON-NLS-1$
+       public static final String ATTR_NAME_STANDBY = "standby"; // OBJECT //$NON-NLS-1$
+       public static final String ATTR_NAME_MULTIPLE = "multiple"; // SELECT //$NON-NLS-1$
+       public static final String ATTR_NAME_ABBR = "abbr"; // TH/TD //$NON-NLS-1$
+       public static final String ATTR_NAME_AXIS = "axis"; // TH/TD //$NON-NLS-1$
+       public static final String ATTR_NAME_HEADERS = "headers"; // TH/TD //$NON-NLS-1$
+       public static final String ATTR_NAME_SCOPE = "scope"; // TH/TD //$NON-NLS-1$
+       public static final String ATTR_NAME_ROWSPAN = "rowspan"; // TH/TD //$NON-NLS-1$
+       public static final String ATTR_NAME_COLSPAN = "colspan"; // TH/TD //$NON-NLS-1$
+       public static final String ATTR_NAME_NOWRAP = "nowrap"; // TH/TD //$NON-NLS-1$
+       // <<D205514
+       public static final String ATTR_NAME_TOPMARGIN = "topmargin"; // BODY //$NON-NLS-1$
+       public static final String ATTR_NAME_BOTTOMMARGIN = "bottommargin"; // BODY //$NON-NLS-1$
+       public static final String ATTR_NAME_LEFTMARGIN = "leftmargin"; // BODY //$NON-NLS-1$
+       public static final String ATTR_NAME_RIGHTMARGIN = "rightmargin"; // BODY //$NON-NLS-1$
+       public static final String ATTR_NAME_BORDERCOLOR = "bordercolor"; // TABLE/TR/TH/TD/FRAMESET/FRAME //$NON-NLS-1$
+       // for WML
+       public static final String WML_ATTR_NAME_TITLE = "title"; // card //$NON-NLS-1$
+       public static final String WML_ATTR_NAME_DOMAIN = "domain"; // access //$NON-NLS-1$
+       public static final String WML_ATTR_NAME_PATH = "path"; // access //$NON-NLS-1$
+       public static final String WML_ATTR_NAME_ONENTERFORWARD = "onenterforward"; // template,card //$NON-NLS-1$
+       public static final String WML_ATTR_NAME_ONENTERBACKWARD = "onenterbackward"; // template,card //$NON-NLS-1$
+       public static final String WML_ATTR_NAME_ONPICK = "onpick"; // option //$NON-NLS-1$
+       public static final String WML_ATTR_NAME_ONTIMER = "ontimer"; // template,card //$NON-NLS-1$
+       public static final String WML_ATTR_NAME_NEWCONTEXT = "newcontext"; // card //$NON-NLS-1$
+       public static final String WML_ATTR_NAME_ORDERED = "ordered"; // card //$NON-NLS-1$
+       public static final String WML_ATTR_NAME_OPTIONAL = "optional"; // do //$NON-NLS-1$
+       public static final String WML_ATTR_NAME_CACHE_CONTROL = "cache-control"; // go //$NON-NLS-1$
+       public static final String WML_ATTR_NAME_SENDREFERER = "sendreferer"; // go //$NON-NLS-1$
+       public static final String WML_ATTR_NAME_METHOD = "method"; // go //$NON-NLS-1$
+       public static final String WML_ATTR_NAME_ENCTYPE = "enctype"; // go //$NON-NLS-1$
+       public static final String WML_ATTR_NAME_ACCEPT_CHARSET = "accept-charset"; // go //$NON-NLS-1$
+       public static final String WML_ATTR_NAME_COLUMNS = "columns"; // table //$NON-NLS-1$    
+       // D205514
+       //<<D215684
+       public static final String ATTR_NAME_FRAMESPACING = "framespacing"; // FRAMESET //$NON-NLS-1$
+       //D215684
+       // global attribute values; mainly used in enumeration.
+       public static final String ATTR_VALUE_VERSION_TRANSITIONAL = "-//W3C//DTD HTML 4.01 Transitional//EN"; //$NON-NLS-1$
+       public static final String ATTR_VALUE_VERSION_FRAMESET = "-//W3C//DTD HTML 4.01 Frameset//EN"; //$NON-NLS-1$
+       public static final String ATTR_VALUE_LTR = "ltr"; // dir //$NON-NLS-1$
+       public static final String ATTR_VALUE_RTL = "rtl"; // dir //$NON-NLS-1$
+       //   for align (top|middle|bottom|left|right)
+       public static final String ATTR_VALUE_TOP = "top"; // align //$NON-NLS-1$
+       public static final String ATTR_VALUE_MIDDLE = "middle"; // align //$NON-NLS-1$
+       public static final String ATTR_VALUE_BOTTOM = "bottom"; // align //$NON-NLS-1$
+       public static final String ATTR_VALUE_LEFT = "left"; // align //$NON-NLS-1$
+       public static final String ATTR_VALUE_CENTER = "center"; // align //$NON-NLS-1$
+       public static final String ATTR_VALUE_RIGHT = "right"; // align //$NON-NLS-1$
+       public static final String ATTR_VALUE_JUSTIFY = "justify"; // align //$NON-NLS-1$
+       public static final String ATTR_VALUE_CHAR = "char"; // align //$NON-NLS-1$
+       //   for valign (baseline)
+       public static final String ATTR_VALUE_BASELINE = "baseline"; // valign //$NON-NLS-1$
+       //   for clear (left|all|right|none): left and right are already defined above.
+       public static final String ATTR_VALUE_ALL = "all"; // clear //$NON-NLS-1$
+       public static final String ATTR_VALUE_NONE = "none"; // clear //$NON-NLS-1$
+       //   for shape (rect|circle|poly|default)
+       public static final String ATTR_VALUE_RECT = "rect"; // shape //$NON-NLS-1$
+       public static final String ATTR_VALUE_CIRCLE = "circle"; // shape //$NON-NLS-1$
+       public static final String ATTR_VALUE_POLY = "poly"; // shape //$NON-NLS-1$
+       public static final String ATTR_VALUE_DEFAULT = "default"; // shape //$NON-NLS-1$
+       //   for valuetype (data|ref|object)
+       public static final String ATTR_VALUE_DATA = "data"; // valuetype //$NON-NLS-1$
+       public static final String ATTR_VALUE_REF = "ref"; // valuetype //$NON-NLS-1$
+       public static final String ATTR_VALUE_OBJECT = "object"; // valuetype //$NON-NLS-1$
+       //   for type of INPUT
+       //       (text | password | checkbox | radio | submit | reset |
+       //        file | hidden | image | button)
+       public static final String ATTR_VALUE_TEXT = "text"; // INPUT:type //$NON-NLS-1$
+       public static final String ATTR_VALUE_PASSWORD = "password"; // INPUT:type //$NON-NLS-1$
+       public static final String ATTR_VALUE_CHECKBOX = "checkbox"; // INPUT:type //$NON-NLS-1$
+       public static final String ATTR_VALUE_RADIO = "radio"; // INPUT:type //$NON-NLS-1$
+       public static final String ATTR_VALUE_SUBMIT = "submit"; // INPUT:type //$NON-NLS-1$
+       public static final String ATTR_VALUE_RESET = "reset"; // INPUT:type //$NON-NLS-1$
+       public static final String ATTR_VALUE_FILE = "file"; // INPUT:type //$NON-NLS-1$
+       public static final String ATTR_VALUE_HIDDEN = "hidden"; // INPUT:type //$NON-NLS-1$
+       public static final String ATTR_VALUE_IMAGE = "image"; // INPUT:type //$NON-NLS-1$
+       public static final String ATTR_VALUE_BUTTON = "button"; // INPUT:type //$NON-NLS-1$
+       //   for span, colspan, rowspan
+       public static final String ATTR_VALUE_1 = "1"; // span //$NON-NLS-1$
+       //   for frameborder
+       public static final String ATTR_VALUE_0 = "0"; // FRAME //$NON-NLS-1$
+       //   for scrolling
+       public static final String ATTR_VALUE_YES = "yes"; // FRAME //$NON-NLS-1$
+       public static final String ATTR_VALUE_NO = "no"; // FRAME //$NON-NLS-1$
+       public static final String ATTR_VALUE_AUTO = "auto"; // FRAME //$NON-NLS-1$
+       //   for UL
+       public static final String ATTR_VALUE_DISC = "disc"; // UL:type //$NON-NLS-1$
+       public static final String ATTR_VALUE_SQUARE = "square"; // UL:type //$NON-NLS-1$
+       //   for frame of TABLE
+       public static final String ATTR_VALUE_VOID = "void"; // TABLE:frame //$NON-NLS-1$
+       public static final String ATTR_VALUE_ABOVE = "above"; // TABLE:frame //$NON-NLS-1$
+       public static final String ATTR_VALUE_BELOW = "below"; // TABLE:frame //$NON-NLS-1$
+       public static final String ATTR_VALUE_HSIDES = "hsides"; // TABLE:frame //$NON-NLS-1$
+       public static final String ATTR_VALUE_LHS = "lhs"; // TABLE:frame //$NON-NLS-1$
+       public static final String ATTR_VALUE_RHS = "rhs"; // TABLE:frame //$NON-NLS-1$
+       public static final String ATTR_VALUE_VSIDES = "vsides"; // TABLE:frame //$NON-NLS-1$
+       public static final String ATTR_VALUE_BOX = "box"; // TABLE:frame //$NON-NLS-1$
+       public static final String ATTR_VALUE_BORDER = "border"; // TABLE:frame //$NON-NLS-1$
+       //   for rules of TABLE
+       public static final String ATTR_VALUE_GROUPS = "groups"; // TABLE:rules //$NON-NLS-1$
+       public static final String ATTR_VALUE_ROWS = "rows"; // TEXTAREA //$NON-NLS-1$
+       public static final String ATTR_VALUE_COLS = "cols"; // TEXTAREA //$NON-NLS-1$
+       //   for method of FORM
+       public static final String ATTR_VALUE_GET = "get"; // FORM //$NON-NLS-1$
+       public static final String ATTR_VALUE_POST = "post"; // FORM //$NON-NLS-1$
+       public static final String ATTR_VALUE_WWW_FORM_URLENCODED = "application/x-www-form-urlencoded"; //$NON-NLS-1$
+       //   for scope of (TH | TD)
+       public static final String ATTR_VALUE_ROW = "row"; // (TH|TD):scope //$NON-NLS-1$
+       public static final String ATTR_VALUE_COL = "col"; // (TH|TD):scope //$NON-NLS-1$
+       public static final String ATTR_VALUE_ROWGROUP = "rowgroup";// (TH|TD):scope //$NON-NLS-1$
+       public static final String ATTR_VALUE_COLGROUP = "colgroup";// (TH|TD):scope //$NON-NLS-1$
+       //   for auto?? of EMBED
+       public static final String ATTR_VALUE_TRUE = "true"; // EMBED //$NON-NLS-1$
+       public static final String ATTR_VALUE_FALSE = "false"; // EMBED //$NON-NLS-1$
+       //   for behaviro of MARQUEE
+       public static final String ATTR_VALUE_SCROLL = "scroll"; // MARQUEE //$NON-NLS-1$
+       public static final String ATTR_VALUE_SLIDE = "slide"; // MARQUEE //$NON-NLS-1$
+       public static final String ATTR_VALUE_ALTERNATE = "alternate"; // MARQUEE //$NON-NLS-1$
+       //   for direction of MARQUEE
+       public static final String ATTR_VALUE_UP = "up"; // MARQUEE //$NON-NLS-1$
+       public static final String ATTR_VALUE_DOWN = "down"; // MARQUEE //$NON-NLS-1$
+       //   for type of LI (D19924)
+       public static final String ATTR_VALUE_NUMBER = "1"; // LI //$NON-NLS-1$
+       public static final String ATTR_VALUE_LOWER_ALPHA = "a"; // LI //$NON-NLS-1$\0}} //$NON-NLS-1$ //$NON-NLS-1$ //$NON-NLS-1$
+       public static final String ATTR_VALUE_UPPER_ALPHA = "A"; // LI //$NON-NLS-1$\0}} //$NON-NLS-1$
+       public static final String ATTR_VALUE_LOWER_ROMAN = "i"; // LI //$NON-NLS-1$\0}} //$NON-NLS-1$ //$NON-NLS-1$
+       public static final String ATTR_VALUE_UPPER_ROMAN = "I"; // LI //$NON-NLS-1$\0}} //$NON-NLS-1$ //$NON-NLS-1$ //$NON-NLS-1$ //$NON-NLS-1$ //$NON-NLS-1$ //$NON-NLS-1$ //$NON-NLS-1$
+       //   for loop of BGSOUND (D205513)
+       public static final String ATTR_VALUE_INFINITE = "infinite"; // BGSOUND //$NON-NLS-1$
+}
diff --git a/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/javascript/IJsTranslation.java b/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/javascript/IJsTranslation.java
new file mode 100644 (file)
index 0000000..5a6dd23
--- /dev/null
@@ -0,0 +1,167 @@
+/*******************************************************************************
+ * Copyright (c) 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     
+ * Provisional API: This class/interface is part of an interim API that is still under development and expected to 
+ * change significantly before reaching stability. It is being made available at this early stage to solicit feedback 
+ * from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken 
+ * (repeatedly) as the API evolves.
+ *     
+ *     
+ *******************************************************************************/
+
+
+package org.eclipse.wst.jsdt.web.core.javascript;
+
+import java.util.List;
+
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.Position;
+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.sse.core.internal.provisional.text.IStructuredDocument;
+
+
+
+/**
+*
+
+* Provisional API: This class/interface is part of an interim API that is still under development and expected to
+* change significantly before reaching stability. It is being made available at this early stage to solicit feedback
+* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
+* (repeatedly) as the API evolves.<br>
+* 
+*/
+public interface IJsTranslation {
+
+       /**
+        * @return IJavaScriptProject that this translation belongs to
+        */
+       public IJavaScriptProject getJavaProject();
+
+       /**
+        * @return Original HTML document from the translation.
+        */
+       public IDocument getHtmlDocument();
+
+       /**
+        * @return integer position of a missing </script> tag (the document isn't well formed and resulted in translation error.).
+        * 
+        */
+       public int getMissingTagStart();
+
+       /**
+        * @param javaPositionStart
+        * @param javaPositionEnd
+        * @return all javascript elements within the given range
+        */
+       public IJavaScriptElement[] getAllElementsInJsRange(int javaPositionStart, int javaPositionEnd);
+
+       /**
+        * @return the javascript unit from the jsdt.core
+        */
+       public IJavaScriptUnit getCompilationUnit();
+
+       /**
+        * @param javaPositionStart
+        * @param javaPositionEnd
+        * @return
+        */
+       public IJavaScriptElement[] getElementsFromJsRange(int javaPositionStart, int javaPositionEnd);
+
+       /**
+        * @return string of the document.
+        */
+       public String getHtmlText();
+
+       /**
+        * @param jsOffset
+        * @return a single javascript element at the given offset.
+        */
+       public IJavaScriptElement getJsElementAtOffset(int jsOffset);
+
+       /**
+        * @return only the translated javascript text
+        */
+       public String getJsText();
+
+       /**
+        * @return a list of the script regions within the translation.
+        */
+       public Position[] getScriptPositions();
+
+       /**
+        * @param text
+        */
+       public void insertInFirstScriptRegion(String text);
+
+       /**
+        * insert javascript at the given offset.  method should ensure the documents well-formedness and proper script region.
+        * 
+        * @param offset
+        * @param text
+        */
+       public void insertScript(int offset, String text);
+
+       /**
+        * @return a list of javascript errors
+        */
+       public List getProblems();
+
+       /**
+        * @param offset
+        * @return if the offset is within a script import node.
+        */
+       public boolean ifOffsetInImportNode(int offset);
+
+       /**
+        * checks the CU for errors/consistancy.
+        */
+       public void reconcileCompilationUnit();
+
+       /**
+        * release the translation.  always a good idea to do when you're done.  you may notice document and model locks if not.
+        */
+       public void release();
+       
+       /**
+        * fixes a mangled html--> pure js name.
+        * @param displayString
+        * @return
+        */
+       public String fixupMangledName(String displayString); 
+       
+       /**
+        * start/stop collecting problems within the javascript unit.
+        * @param collect
+        */
+       public void setProblemCollectingActive(boolean collect);
+       
+       /**
+        * @return
+        */
+       public String getJavaPath();
+       
+       /**
+        * 
+        * 
+        * @param htmlDocument
+        * @param javaProj
+        * @param listenForChanges
+        * @return
+        */
+       public IJsTranslation getInstance(IStructuredDocument htmlDocument, IJavaScriptProject javaProj, boolean listenForChanges) ;
+
+       /**
+        * notify the translation to update any external dependancies that are created during translation
+        * 
+        */
+       public void classpathChange() ;
+}
\ No newline at end of file
diff --git a/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/javascript/IJsTranslator.java b/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/javascript/IJsTranslator.java
new file mode 100644 (file)
index 0000000..8726cab
--- /dev/null
@@ -0,0 +1,100 @@
+/*******************************************************************************
+ * Copyright (c) 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     
+ * Provisional API: This class/interface is part of an interim API that is still under development and expected to 
+ * change significantly before reaching stability. It is being made available at this early stage to solicit feedback 
+ * from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken 
+ * (repeatedly) as the API evolves.
+ *     
+ *     
+ *******************************************************************************/
+
+
+package org.eclipse.wst.jsdt.web.core.javascript;
+
+import org.eclipse.jface.text.IDocumentListener;
+import org.eclipse.jface.text.Position;
+import org.eclipse.wst.jsdt.core.IBuffer;
+import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
+
+
+
+/**
+*
+
+* Provisional API: This class/interface is part of an interim API that is still under development and expected to
+* change significantly before reaching stability. It is being made available at this early stage to solicit feedback
+* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
+* (repeatedly) as the API evolves.
+*/
+public interface IJsTranslator extends IDocumentListener{
+
+       /**
+        * @return string of javascript from the document
+        */
+       public String getJsText();
+
+       /**
+        * sets the javascript unit buffer
+        * @param buffer
+        */
+       public void setBuffer(IBuffer buffer);
+
+       /**
+        * 
+        * @return a list of html locations within the docuemnt.
+        */
+       public Position[] getHtmlLocations();
+
+       /**
+        * @return the region of a missing </script> tag
+        */
+       public int getMissingEndTagRegionStart();
+
+       /**
+        * @return position array of <script src=".."> within the doc.
+        */
+       public Position[] getImportHtmlRanges();
+
+       /**
+        * @return raw/unresolved <script imports>
+        */
+       public String[] getRawImports();
+
+       /**
+        *  begin translating the document.
+        */
+       public void translate();
+
+       /**
+        * translates an inline (event="..") js container region and adds it to the document text.  must be called in order
+        * @param container
+        */
+       public void translateInlineJSNode(IStructuredDocumentRegion container);
+
+       /**
+        * translates a script block.  must be called in the order it appears within the document.
+        * @param container
+        */
+       public void translateJSNode(IStructuredDocumentRegion container);
+
+       /**
+        * translates a <script src=".."> element, parsing out an import.
+        * @param region
+        */
+       public void translateScriptImportNode(IStructuredDocumentRegion region);
+
+       /**
+        * release any resources the translation is holding onto.
+        * 
+        */
+       public void release();
+
+}
\ No newline at end of file
diff --git a/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/javascript/JsDataTypes.java b/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/javascript/JsDataTypes.java
new file mode 100644 (file)
index 0000000..8bd2ae1
--- /dev/null
@@ -0,0 +1,47 @@
+/*******************************************************************************
+ * 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.web.core.javascript;
+
+
+import org.eclipse.wst.html.core.text.IHTMLPartitions;
+/**
+*
+
+* Provisional API: This class/interface is part of an interim API that is still under development and expected to
+* change significantly before reaching stability. It is being made available at this early stage to solicit feedback
+* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
+* (repeatedly) as the API evolves.
+*/
+public interface JsDataTypes extends HTML40Namespace {
+       /*
+        * remove when when we refactor (need to add this content type to many
+        * project types in wst)
+        */
+       public static final String BASE_FILE_EXTENSION = ".js"; //$NON-NLS-1$
+       public static String[] CONSTANTS = { "false", "null", "true" }; //$NON-NLS-3$//$NON-NLS-2$//$NON-NLS-1$
+       public static final String[] EVENTS = { HTML40Namespace.ATTR_NAME_ONCLICK, HTML40Namespace.ATTR_NAME_ONDBLCLICK, HTML40Namespace.ATTR_NAME_ONMOUSEDOWN,
+                       HTML40Namespace.ATTR_NAME_ONMOUSEUP, HTML40Namespace.ATTR_NAME_ONMOUSEOVER, HTML40Namespace.ATTR_NAME_ONMOUSEMOVE,
+                       HTML40Namespace.ATTR_NAME_ONMOUSEOUT, HTML40Namespace.ATTR_NAME_ONKEYPRESS, HTML40Namespace.ATTR_NAME_ONKEYDOWN, HTML40Namespace.ATTR_NAME_ONKEYUP,
+                       HTML40Namespace.ATTR_NAME_ONHELP };
+       public static final String[] HTMLATREVENTS = { "onload ", "onunload", "onclick", "onmousedown", "onmouseup", "onmouseover", "onmousemove", "onmouseout", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$
+                       "onfocus", "onblur", "onkeypress", "onkeydown", "onkeyup", "onsubmit", "onreset", "onselect", "onchange", }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$
+       public static final String[] JSVALIDDATATYPES = { "JAVASCRIPT", "TEXT/JAVASCRIPT" }; //$NON-NLS-1$ //$NON-NLS-2$
+       public static String[] KEYWORDS = { "abstract", "break", "case", "catch", "class", "const", "continue", "debugger", "default", "delete", "do", "else", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$ //$NON-NLS-10$ //$NON-NLS-11$ //$NON-NLS-12$
+                       "enum", "export", "extends", "final", "finally", "for", "function", "goto", "if", "implements", "import", "in", "instanceof", "interface", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$ //$NON-NLS-10$ //$NON-NLS-11$ //$NON-NLS-12$ //$NON-NLS-13$ //$NON-NLS-14$
+                       "native", "new", "package", "private", "protected", "public", "return", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$
+                       "static", "super", "switch", "synchronized", "this", "throw", "throws", "transient", "try", "typeof", "volatile", "while", "with" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$ //$NON-NLS-10$ //$NON-NLS-11$ //$NON-NLS-12$ //$NON-NLS-13$
+       // public static final String
+       // NEW_PARTITION_TYPE="org.eclipse.wst.jsdt.StructuredJs";
+       // public static final String NEW_PARTITION_TYPE=IHTMLPartitions.SCRIPT;
+       public static final String NEW_PARTITION_TYPE = IHTMLPartitions.SCRIPT;
+       public static final String[] TAKEOVER_PARTITION_TYPES = { "none" }; //$NON-NLS-1$
+       public static String[] TYPES = { "boolean", "byte", "char", "double", "int", "long", "short", "float", "var", "void" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$ //$NON-NLS-10$
+}
diff --git a/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/javascript/JsNameManglerUtil.java b/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/javascript/JsNameManglerUtil.java
new file mode 100644 (file)
index 0000000..40cee8f
--- /dev/null
@@ -0,0 +1,135 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.web.core.javascript;
+
+import java.io.File;
+
+/**
+*
+
+* Provisional API: This class/interface is part of an interim API that is still under development and expected to
+* change significantly before reaching stability. It is being made available at this early stage to solicit feedback
+* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
+* (repeatedly) as the API evolves.
+*/
+public class JsNameManglerUtil {
+       /**
+        * Determine if given string is a valid Hex representation of an ASCII
+        * character (eg. 2F -> /)
+        * 
+        * @param possible
+        * @return
+        */
+       private static boolean isValid(String possible) {
+               boolean result = false;
+               if (possible.length() == 2) {
+                       char c1 = possible.charAt(0);
+                       char c2 = possible.charAt(1);
+                       // 1st character must be a digit
+                       if (Character.isDigit(c1)) {
+                               // 2nd character must be digit or upper case letter A-F
+                               if (Character.isDigit(c2)) {
+                                       result = true;
+                               } else if (Character.isUpperCase(c2) && (c2 == 'A' || c2 == 'B' || c2 == 'C' || c2 == 'D' || c2 == 'E' || c2 == 'F')) {
+                                       result = true;
+                               }
+                       }
+               }
+               return result;
+       }
+       
+       /**
+        * Mangle string to WAS-like specifications
+        * 
+        */
+       public final static String mangle(String name) {
+               StringBuffer modifiedName = new StringBuffer();
+               // extension (.jsp, .jspf, .jspx, etc...) should already be encoded in
+               // name
+               int length = name.length();
+               // in case name is forbidden (a number, class, for, etc...)
+               modifiedName.append('_');
+               // ensure rest of characters are valid
+               for (int i = 0; i < length; i++) {
+                       char currentChar = name.charAt(i);
+                       if (Character.isJavaIdentifierPart(currentChar) == true) {
+                               modifiedName.append(currentChar);
+                       } else {
+                               modifiedName.append(JsNameManglerUtil.mangleChar(currentChar));
+                       }
+               }
+               return modifiedName.toString();
+       }
+       
+       /**
+        * take a character and return its hex equivalent
+        */
+       private final static String mangleChar(char ch) {
+               if (ch == File.separatorChar) {
+                       ch = '/';
+               }
+               if (Character.isLetterOrDigit(ch) == true) {
+                       return "" + ch; //$NON-NLS-1$
+               }
+               return "_" + Integer.toHexString(ch).toUpperCase() + "_"; //$NON-NLS-1$ //$NON-NLS-2$
+       }
+       
+       /**
+        * WAS mangles Tom&Jerry as: _Tom_26_Jerry; this takes in the mangled name
+        * and returns the original name.
+        * 
+        * Unmangles the qualified type name. If an underscore is found it is
+        * assumed to be a mangled representation of a non-alpha, non-digit
+        * character of the form _NN_, where NN are hex digits representing the
+        * encoded character. This routine converts it back to the original
+        * character.
+        */
+       public final static String unmangle(String qualifiedTypeName) {
+               if (qualifiedTypeName.charAt(0) != '_') {
+                       return qualifiedTypeName;
+               }
+               StringBuffer buf = new StringBuffer();
+               String possible = ""; //$NON-NLS-1$
+               // remove the .java extension if there is one
+               if (qualifiedTypeName.endsWith(".js")) { //$NON-NLS-1$
+                       qualifiedTypeName = qualifiedTypeName.substring(0, qualifiedTypeName.length() - 3);
+               }
+               for (int i = 1; i < qualifiedTypeName.length(); i++) { // start at
+                       // index 1 b/c
+                       // 1st char is
+                       // always '_'
+                       char c = qualifiedTypeName.charAt(i);
+                       if (c == '_') {
+                               int endIndex = qualifiedTypeName.indexOf('_', i + 1);
+                               if (endIndex == -1) {
+                                       buf.append(c);
+                               } else {
+                                       char unmangled;
+                                       try {
+                                               possible = qualifiedTypeName.substring(i + 1, endIndex);
+                                               if (JsNameManglerUtil.isValid(possible)) {
+                                                       unmangled = (char) Integer.decode("0x" + possible).intValue();//$NON-NLS-1$
+                                                       i = endIndex;
+                                               } else {
+                                                       unmangled = c;
+                                               }
+                                       } catch (NumberFormatException e) {
+                                               unmangled = c;
+                                       }
+                                       buf.append(unmangled);
+                               }
+                       } else {
+                               buf.append(c);
+                       }
+               }
+               return buf.toString();
+       }
+}
diff --git a/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/javascript/JsProblemRequestor.java b/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/javascript/JsProblemRequestor.java
new file mode 100644 (file)
index 0000000..ac94dd0
--- /dev/null
@@ -0,0 +1,86 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2009 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.web.core.javascript;
+
+/**
+*
+
+* Provisional API: This class/interface is part of an interim API that is still under development and expected to
+* change significantly before reaching stability. It is being made available at this early stage to solicit feedback
+* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
+* (repeatedly) as the API evolves.
+*/
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.wst.jsdt.core.IProblemRequestor;
+import org.eclipse.wst.jsdt.core.compiler.IProblem;
+
+class JsProblemRequestor implements IProblemRequestor {
+       private List fCollectedProblems;
+       private boolean fIsActive = false;
+       private boolean fIsRunning = false;
+       
+       public void acceptProblem(IProblem problem) {
+               if (isActive()) {
+                       getCollectedProblems().add(problem);
+               }
+       }
+       
+       public void beginReporting() {
+               fIsRunning = true;
+       }
+       
+       public void endReporting() {
+               fIsRunning = false;
+       }
+       
+       /**
+        * @return the list of collected problems
+        */
+       public List getCollectedProblems() {
+               if (fCollectedProblems == null)
+                       fCollectedProblems = new ArrayList();
+               return fCollectedProblems;
+       }
+       
+       public boolean isActive() {
+               return fIsActive;
+       }
+       
+       public boolean isRunning() {
+               return fIsRunning;
+       }
+       
+       /**
+        * Sets the active state of this problem requestor.
+        * 
+        * @param isActive
+        *            the state of this problem requestor
+        */
+       public void setIsActive(boolean isActive) {
+               fIsActive = isActive;
+       }
+       
+       /**
+        * Tells this annotation model to collect temporary problems from now on.
+        */
+       private void startCollectingProblems() {
+               getCollectedProblems().clear();
+       }
+       
+       /**
+        * Tells this annotation model to no longer collect temporary problems.
+        */
+       private void stopCollectingProblems() {
+       // do nothing
+       }
+}
diff --git a/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/javascript/JsTranslation.java b/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/javascript/JsTranslation.java
new file mode 100644 (file)
index 0000000..060769e
--- /dev/null
@@ -0,0 +1,589 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     bug:244839 - eugene@genuitec.com
+ *     
+ * Provisional API: This class/interface is part of an interim API that is still under development and expected to 
+ * change significantly before reaching stability. It is being made available at this early stage to solicit feedback 
+ * from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken 
+ * (repeatedly) as the API evolves.
+ *     
+ *     
+ *******************************************************************************/
+
+
+package org.eclipse.wst.jsdt.web.core.javascript;
+
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.util.List;
+import java.util.Vector;
+
+import org.eclipse.core.filebuffers.FileBuffers;
+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.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.Position;
+import org.eclipse.jface.text.Region;
+import org.eclipse.wst.jsdt.core.IBuffer;
+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.IPackageFragmentRoot;
+import org.eclipse.wst.jsdt.core.ISourceRange;
+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.core.DocumentContextFragmentRoot;
+import org.eclipse.wst.jsdt.internal.core.Member;
+import org.eclipse.wst.jsdt.internal.core.SourceRefElement;
+import org.eclipse.wst.jsdt.web.core.internal.Logger;
+import org.eclipse.wst.jsdt.web.core.internal.project.JsWebNature;
+import org.eclipse.wst.sse.core.StructuredModelManager;
+import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
+
+/**
+*
+
+* Provisional API: This class/interface is part of an interim API that is still under development and expected to
+* change significantly before reaching stability. It is being made available at this early stage to solicit feedback
+* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
+* (repeatedly) as the API evolves.
+*/
+public class JsTranslation implements IJsTranslation {
+
+       private static final boolean DEBUG;
+       static {
+               String value = Platform.getDebugOption("org.eclipse.wst.jsdt.web.core/debug/jstranslation"); //$NON-NLS-1$
+               DEBUG = value != null && value.equalsIgnoreCase("true"); //$NON-NLS-1$
+       }
+
+       private IJavaScriptUnit fCompilationUnit = null;
+       private DocumentContextFragmentRoot fDocumentScope;
+       private IJavaScriptProject fJavaProject = null;
+       private byte[] fLock = null;
+       private IProgressMonitor fProgressMonitor = null;
+       protected IStructuredDocument fHtmlDocument;
+       protected String fModelBaseLocation;
+
+
+//     private static final String SUPER_TYPE_NAME = "Window"; //$NON-NLS-1$
+//     private static final String SUPER_TYPE_LIBRARY = "org.eclipse.wst.jsdt.launching.baseBrowserLibrary"; //$NON-NLS-1$
+
+       protected IJsTranslator fTranslator;
+
+       private String mangledName;
+       protected boolean listenForChanges;
+
+       public JsTranslation() {
+               /* do nothing */
+       }
+       
+       public IJsTranslator getTranslator() {
+               if(fTranslator!=null) {
+                       return fTranslator;
+               }
+               
+               fTranslator = new JsTranslator(fHtmlDocument, fModelBaseLocation, listenForChanges);
+               return this.fTranslator;
+       }
+       
+
+       
+       protected JsTranslation(IStructuredDocument htmlDocument, IJavaScriptProject javaProj, boolean listenForChanges) {
+               fLock = new byte[0];
+               fJavaProject = javaProj;
+               fHtmlDocument = htmlDocument;
+               setBaseLocation();
+               mangledName = createMangledName();
+               this.listenForChanges=listenForChanges;
+       }
+
+       public IJsTranslation getInstance(IStructuredDocument htmlDocument, IJavaScriptProject javaProj, boolean listenForChanges) {
+               return new JsTranslation(htmlDocument,javaProj, listenForChanges);
+       }
+       
+       /* (non-Javadoc)
+        * @see org.eclipse.wst.jsdt.web.core.internal.java.IJsTranslation#getJavaProject()
+        */
+       public IJavaScriptProject getJavaProject() {
+               return fJavaProject;
+       }
+
+       private IPackageFragmentRoot getDocScope(boolean reset) {
+               if (fDocumentScope == null) {
+                       // IProject project = getJavaProject().getProject();
+                       // IResource absoluteRoot =
+                       // ((IContainer)getJavaProject().getResource()).findMember(
+                       // WebRootFinder.getWebContentFolder(fJavaProject.getProject()));
+                       fDocumentScope = new DocumentContextFragmentRoot(fJavaProject, getFile(), WebRootFinder.getWebContentFolder(fJavaProject.getProject()), WebRootFinder.getServerContextRoot(fJavaProject.getProject()), JsWebNature.VIRTUAL_SCOPE_ENTRY);
+                       fDocumentScope.setIncludedFiles(getTranslator().getRawImports());
+                       return fDocumentScope;
+               }
+
+               if (reset)
+                       fDocumentScope.setIncludedFiles(getTranslator().getRawImports());
+               return fDocumentScope;
+       }
+
+       private void setBaseLocation() {
+               IDOMModel xmlModel = null;
+               try {
+                       xmlModel = (IDOMModel) StructuredModelManager.getModelManager().getExistingModelForRead(fHtmlDocument);
+                       if (xmlModel == null) {
+                               xmlModel = (IDOMModel) StructuredModelManager.getModelManager().getModelForRead(fHtmlDocument);
+                       }
+                       fModelBaseLocation = xmlModel.getBaseLocation();
+               }
+               finally {
+                       if (xmlModel != null)
+                               xmlModel.releaseFromRead();
+               }
+               // return xmlModel;
+       }
+
+       public IFile getFile() {
+               return FileBuffers.getWorkspaceFileAtLocation(new Path(fModelBaseLocation));
+       }
+
+
+       /* (non-Javadoc)
+        * @see org.eclipse.wst.jsdt.web.core.internal.java.IJsTranslation#getHtmlDocument()
+        */
+       public IDocument getHtmlDocument() {
+               return fHtmlDocument;
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.wst.jsdt.web.core.internal.java.IJsTranslation#getMissingTagStart()
+        */
+       public int getMissingTagStart() {
+               return getTranslator().getMissingEndTagRegionStart();
+       }
+
+       private IPath getWebRoot() {
+               return WebRootFinder.getWebContentFolder(fJavaProject.getProject());
+       }
+
+
+       public String getDirectoryUnderRoot() {
+               IPath webRoot = getWebRoot();
+               IPath projectWebRootPath = getJavaProject().getPath().append(webRoot);
+               IPath filePath = new Path(fModelBaseLocation).removeLastSegments(1);
+               return filePath.removeFirstSegments(projectWebRootPath.matchingFirstSegments(filePath)).toString();
+       }
+
+       /**
+        * Originally from ReconcileStepForJava. Creates an IJavaScriptUnit from
+        * the contents of the JSP document.
+        * 
+        * @return an IJavaScriptUnit from the contents of the JSP document
+        */
+       private IJavaScriptUnit createCompilationUnit() throws JavaScriptModelException {
+               IPackageFragmentRoot root = getDocScope(true);
+               IJavaScriptUnit cu = root.getPackageFragment("").getJavaScriptUnit(getMangledName() + JsDataTypes.BASE_FILE_EXTENSION).getWorkingCopy(getWorkingCopyOwner(), getProgressMonitor()); //$NON-NLS-1$
+               IBuffer buffer;
+               try {
+                       buffer = cu.getBuffer();
+               }
+               catch (JavaScriptModelException e) {
+                       e.printStackTrace();
+                       buffer = null;
+               }
+               if (buffer != null) {
+                       getTranslator().setBuffer(buffer);
+               }
+               return cu;
+       }
+
+       public String fixupMangledName(String displayString) {
+               if (displayString == null) {
+                       return null;
+               }
+               return displayString.replaceAll(getMangledName() + ".js", getHtmlPageName()); //$NON-NLS-1$
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.wst.jsdt.web.core.internal.java.IJsTranslation#getAllElementsInJsRange(int, int)
+        */
+       public IJavaScriptElement[] getAllElementsInJsRange(int javaPositionStart, int javaPositionEnd) {
+               IJavaScriptElement[] EMTPY_RESULT_SET = new IJavaScriptElement[0];
+               IJavaScriptElement[] result = EMTPY_RESULT_SET;
+               IJavaScriptElement[] allChildren = null;
+               try {
+                       allChildren = getCompilationUnit().getChildren();
+               }
+               catch (JavaScriptModelException e) {
+               }
+               Vector validChildren = new Vector();
+               for (int i = 0; i < allChildren.length; i++) {
+                       ISourceRange range = getJSSourceRangeOf(allChildren[i]);
+                       if (javaPositionStart <= range.getOffset() && range.getLength() + range.getOffset() <= (javaPositionEnd)) {
+                               validChildren.add(allChildren[i]);
+                       }
+                       else if (allChildren[i].getElementType() == IJavaScriptElement.TYPE) {
+                               validChildren.add(allChildren[i]);
+                       }
+               }
+               if (validChildren.size() > 0) {
+                       result = (IJavaScriptElement[]) validChildren.toArray(new IJavaScriptElement[]{});
+               }
+               if (result == null || result.length == 0) {
+                       return EMTPY_RESULT_SET;
+               }
+               return result;
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.wst.jsdt.web.core.internal.java.IJsTranslation#getCompilationUnit()
+        */
+       public IJavaScriptUnit getCompilationUnit() {
+        // Genuitec Begin Fix 6149: Exception opening external HTML file
+           if (!getJavaProject().exists()) {
+               return null;
+           }
+           // Genuitec End Fix 6149: Exception opening external HTML file
+               synchronized (fLock) {
+                       try {
+                               if (fCompilationUnit == null) {
+                                       fCompilationUnit = createCompilationUnit();
+                                       return fCompilationUnit;
+                               }
+
+                       }
+                       catch (JavaScriptModelException jme) {
+                               if (JsTranslation.DEBUG) {
+                                       Logger.logException("error creating JSP working copy... ", jme); //$NON-NLS-1$
+                               }
+                       }
+
+               }
+               getDocScope(true);
+               try {
+                       fCompilationUnit = fCompilationUnit.getWorkingCopy(getWorkingCopyOwner(), getProgressMonitor());
+                       // fCompilationUnit.makeConsistent(getProgressMonitor());
+               }
+               catch (JavaScriptModelException ex) {
+                       // TODO Auto-generated catch block
+                       ex.printStackTrace();
+               }
+               return fCompilationUnit;
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.wst.jsdt.web.core.internal.java.IJsTranslation#getElementsFromJsRange(int, int)
+        */
+       public IJavaScriptElement[] getElementsFromJsRange(int javaPositionStart, int javaPositionEnd) {
+               IJavaScriptElement[] EMTPY_RESULT_SET = new IJavaScriptElement[0];
+               IJavaScriptElement[] result = EMTPY_RESULT_SET;
+               try {
+                       IJavaScriptUnit cu = getCompilationUnit();
+                       if (cu != null) {
+                               synchronized (fLock) {
+                                       int cuDocLength = cu.getBuffer().getLength();
+                                       int javaLength = javaPositionEnd - javaPositionStart;
+                                       if (cuDocLength > 0 && javaPositionStart >= 0 && javaLength >= 0 && javaPositionEnd <= cuDocLength) {
+                                               result = cu.codeSelect(javaPositionStart, javaLength, getWorkingCopyOwner());
+                                       }
+                               }
+                       }
+                       if (result == null || result.length == 0) {
+                               return EMTPY_RESULT_SET;
+                       }
+               }
+               catch (JavaScriptModelException x) {
+                       Logger.logException(x);
+               }
+               return result;
+       }
+
+       private String getHtmlPageName() {
+               IPath path = new Path(fModelBaseLocation);
+               return path.lastSegment();
+
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.wst.jsdt.web.core.internal.java.IJsTranslation#getHtmlText()
+        */
+       public String getHtmlText() {
+               return fHtmlDocument.get();
+       }
+
+       public String getJavaPath() {
+               IPath rootPath = new Path(fModelBaseLocation).removeLastSegments(1);
+               String cuPath = rootPath.append("/" + getMangledName() + JsDataTypes.BASE_FILE_EXTENSION).toString(); //$NON-NLS-1$
+               return cuPath;
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.wst.jsdt.web.core.internal.java.IJsTranslation#getJsElementAtOffset(int)
+        */
+       public IJavaScriptElement getJsElementAtOffset(int jsOffset) {
+               IJavaScriptElement elements = null;
+               try {
+                       elements = getCompilationUnit().getElementAt(jsOffset);
+               }
+               catch (JavaScriptModelException e) {
+                       // TODO Auto-generated catch block
+                       if (JsTranslation.DEBUG) {
+                               Logger.logException("error retrieving java elemtnt from compilation unit... ", e); //$NON-NLS-1$
+                       }
+                       // }
+               }
+               return elements;
+       }
+
+       private ISourceRange getJSSourceRangeOf(IJavaScriptElement element) {
+               // returns the offset in html of given element
+               ISourceRange range = null;
+               if (element instanceof Member) {
+                       try {
+                               range = ((Member) element).getNameRange();
+                       } catch (JavaScriptModelException e) {
+                               // TODO Auto-generated catch block
+                               e.printStackTrace();
+                       }
+               }else if (element instanceof SourceRefElement) {
+                       try {
+                               range = ((SourceRefElement) element).getSourceRange();
+                       }
+                       catch (JavaScriptModelException e) {
+                               e.printStackTrace();
+                       }
+               }
+               return range;
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.wst.jsdt.web.core.internal.java.IJsTranslation#getJsText()
+        */
+       public String getJsText() {
+               return getTranslator().getJsText();
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.wst.jsdt.web.core.internal.java.IJsTranslation#getScriptPositions()
+        */
+       public Position[] getScriptPositions() {
+               return getTranslator().getHtmlLocations();
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.wst.jsdt.web.core.internal.java.IJsTranslation#insertInFirstScriptRegion(java.lang.String)
+        */
+       public void insertInFirstScriptRegion(String text) {
+               Position pos[] = getScriptPositions();
+               int scriptStartOffset = 0;
+               if(pos!=null && pos.length>0) {
+                       scriptStartOffset = pos[0].getOffset();
+                       
+               }
+               String insertText = (scriptStartOffset==0?"":"\n") + text;
+               insertScript(scriptStartOffset,insertText);
+               
+       }
+       
+       /* (non-Javadoc)
+        * @see org.eclipse.wst.jsdt.web.core.internal.java.IJsTranslation#insertScript(int, java.lang.String)
+        */
+       public void insertScript(int offset, String text) {
+
+               IDOMModel xmlModel = null;
+               Position[] inHtml = getScriptPositions();
+               boolean isInsideExistingScriptRegion = false;
+               for (int i = 0; i < inHtml.length; i++) {
+                       if (inHtml[i].overlapsWith(offset, 1)) {
+                               // * inserting into a script region
+                               isInsideExistingScriptRegion = true;
+                       }
+               }
+
+               String insertText = null;
+
+               if (isInsideExistingScriptRegion) {
+                       insertText = text;
+               }
+               else {
+                       insertText = offset != 0 ? "\n" : "" + "<script type=\"text/javascript\">\n" + text + "\n</script>\n";
+               }
+       //      translator.documentAboutToBeChanged(null);
+
+               synchronized (fLock) {
+                       try {
+                               xmlModel = (IDOMModel) StructuredModelManager.getModelManager().getExistingModelForEdit(fHtmlDocument);
+                               if (xmlModel == null) {
+                                       xmlModel = (IDOMModel) StructuredModelManager.getModelManager().getModelForEdit(fHtmlDocument);
+                               }
+                               if (xmlModel != null) {
+
+
+                                       xmlModel.aboutToChangeModel();
+                                       xmlModel.getDocument().getStructuredDocument().replaceText(this, offset, 0, insertText);
+                                       xmlModel.changedModel();
+                                       try {
+                                               xmlModel.save();
+                                       }
+
+                                       catch (UnsupportedEncodingException e) {}
+                                       catch (IOException e) {}
+                                       catch (CoreException e) {}
+                               }
+                       }
+                       finally {
+                               if (xmlModel != null)
+                                       xmlModel.releaseFromEdit();
+                       }
+               }
+
+       //      translator.documentChanged(null);
+
+       }
+
+       public String getMangledName() {
+               return this.mangledName;
+       }
+
+       private String createMangledName() {
+               return JsNameManglerUtil.mangle(fModelBaseLocation);
+       }
+
+       /**
+        * 
+        * @return the problem requestor for the JavaScriptUnit in this
+        *         JsTranslation
+        */
+       private JsProblemRequestor getProblemRequestor() {
+               return CompilationUnitHelper.getInstance().getProblemRequestor();
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.wst.jsdt.web.core.internal.java.IJsTranslation#getProblems()
+        */
+       public List getProblems() {
+               List problemList = getProblemRequestor().getCollectedProblems();
+               getProblemRequestor().endReporting();
+               IProblem[] problems = null;
+               if (problemList == null)
+                       problems = new IProblem[0];
+               else 
+                       problems = (IProblem[]) problemList.toArray(new IProblem[problemList.size()]);
+               
+               IJsTranslator translator = getTranslator();
+               if (translator instanceof JsTranslator && problems.length > 0) {
+                       Region[] generatedRanges = ((JsTranslator) translator).getGeneratedRanges();
+                       for (int i = 0; i < problems.length; i++) {
+                               for (int j = 0; j < generatedRanges.length; j++) {
+                                       // remove any problems that are fully reported within a region generated by the translator
+                                       if (problems[i].getSourceStart() >= generatedRanges[j].getOffset() && problems[i].getSourceEnd() <= (generatedRanges[j].getOffset() + generatedRanges[j].getLength())) {
+                                               problemList.remove(problems[i]);
+                                       }
+                               }
+                       }
+               }
+               return problemList;
+       }
+
+       private IProgressMonitor getProgressMonitor() {
+               if (fProgressMonitor == null) {
+                       fProgressMonitor = new NullProgressMonitor();
+               }
+               return fProgressMonitor;
+       }
+
+       public WorkingCopyOwner getWorkingCopyOwner() {
+               return CompilationUnitHelper.getInstance().getWorkingCopyOwner();
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.wst.jsdt.web.core.internal.java.IJsTranslation#ifOffsetInImportNode(int)
+        */
+       public boolean ifOffsetInImportNode(int offset) {
+               Position[] importRanges = getTranslator().getImportHtmlRanges();
+               for (int i = 0; i < importRanges.length; i++) {
+                       if (importRanges[i].includes(offset)) {
+                               return true;
+                       }
+               }
+               return false;
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.wst.jsdt.web.core.internal.java.IJsTranslation#reconcileCompilationUnit()
+        */
+       public void reconcileCompilationUnit() {
+               // if(true) return;
+               IJavaScriptUnit cu = getCompilationUnit();
+               if (fCompilationUnit == null) {
+                       return;
+               }
+               if (cu != null) {
+                       try {
+                               synchronized (fLock) {
+                                       // clear out old validation messages
+                                       WorkingCopyOwner workingCopyOwner = getWorkingCopyOwner();
+                                       JsProblemRequestor problemRequestor = (JsProblemRequestor) workingCopyOwner.getProblemRequestor(cu.getWorkingCopy(getProgressMonitor()));
+                                       if(problemRequestor != null && problemRequestor.getCollectedProblems() != null)
+                                               problemRequestor.getCollectedProblems().clear();
+                                       cu.reconcile(IJavaScriptUnit.NO_AST, true, true, getWorkingCopyOwner(), getProgressMonitor());
+                               }
+                       }
+                       catch (JavaScriptModelException e) {
+                               Logger.logException(e);
+                       }
+               }
+       }
+
+
+       /* (non-Javadoc)
+        * @see org.eclipse.wst.jsdt.web.core.internal.java.IJsTranslation#release()
+        */
+       public void release() {
+               if (getTranslator() != null)
+                       getTranslator().release();
+               synchronized (fLock) {
+                       if (fCompilationUnit != null) {
+                               try {
+                                       if (JsTranslation.DEBUG) {
+                                               System.out.println("------------------------------------------------------------------"); //$NON-NLS-1$
+                                               System.out.println("(-) JsTranslation [" + this + "] discarding JavaScriptUnit: " + fCompilationUnit); //$NON-NLS-1$ //$NON-NLS-2$
+                                               System.out.println("------------------------------------------------------------------"); //$NON-NLS-1$
+                                       }
+                                       fCompilationUnit.discardWorkingCopy();
+                               }
+                               catch (JavaScriptModelException e) {
+                                       // we're done w/ it anyway
+                               }
+                       }
+               }
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.wst.jsdt.web.core.internal.java.IJsTranslation#setProblemCollectingActive(boolean)
+        */
+       public void setProblemCollectingActive(boolean collect) {
+               IJavaScriptUnit cu = getCompilationUnit();
+               if (cu != null) {
+                       getProblemRequestor().setIsActive(collect);
+               }
+       }
+
+       public void classpathChange() {
+
+               if (fDocumentScope != null) {
+                       fDocumentScope.classpathChange();
+               }
+       }
+}
\ No newline at end of file
diff --git a/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/javascript/JsTranslationAdapter.java b/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/javascript/JsTranslationAdapter.java
new file mode 100644 (file)
index 0000000..61aa63d
--- /dev/null
@@ -0,0 +1,173 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     
+ * Provisional API: This class/interface is part of an interim API that is still under development and expected to 
+ * change significantly before reaching stability. It is being made available at this early stage to solicit feedback 
+ * from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken 
+ * (repeatedly) as the API evolves.
+ *     
+ *     
+ *******************************************************************************/
+
+package org.eclipse.wst.jsdt.web.core.javascript;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResourceChangeEvent;
+import org.eclipse.core.resources.IResourceChangeListener;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.IExtensionRegistry;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.wst.jsdt.core.IJavaScriptProject;
+import org.eclipse.wst.jsdt.core.JavaScriptCore;
+import org.eclipse.wst.jsdt.web.core.internal.Logger;
+import org.eclipse.wst.sse.core.internal.provisional.INodeAdapter;
+import org.eclipse.wst.sse.core.internal.provisional.INodeNotifier;
+import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
+
+/**
+*
+
+* Provisional API: This class/interface is part of an interim API that is still under development and expected to
+* change significantly before reaching stability. It is being made available at this early stage to solicit feedback
+* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
+* (repeatedly) as the API evolves.
+
+ * <br><br> this adapter loads translation information from extension points.  this is to allow more complicated html/js translations through extensions.
+ * @author pavery
+ */
+public class JsTranslationAdapter implements INodeAdapter, IResourceChangeListener {
+
+       private static final boolean DEBUG = "true".equalsIgnoreCase(Platform.getDebugOption("org.eclipse.wst.jsdt.web.core/debug/jstranslation")); //$NON-NLS-1$  //$NON-NLS-2$
+       private IStructuredDocument fHtmlDocument = null;
+       private IJsTranslation fJSTranslation = null;
+       private NullProgressMonitor fTranslationMonitor = null;
+       private String baseLocation;
+       private boolean listenForChanges=false;
+       private static final String PRIORITY_ATTRIB = "priority";
+       private IJsTranslation fTranslationAsFactory;
+       
+       public JsTranslationAdapter(IDOMModel xmlModel) {
+               fHtmlDocument = xmlModel.getStructuredDocument();
+               baseLocation = xmlModel.getBaseLocation();
+               initializeJavaPlugins();
+               
+               
+       }
+       public void shouldListenForChanges(boolean listenForProjectChanges) {
+               if(listenForProjectChanges) {
+                       ResourcesPlugin.getWorkspace().addResourceChangeListener(this, IResourceChangeEvent.POST_CHANGE);
+               }
+       }
+
+       public IJavaScriptProject getJavaProject() {
+               IJavaScriptProject javaProject = null;
+               IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
+               IPath filePath = new Path(baseLocation);
+               IProject project = null;
+               if (filePath.segmentCount() > 0) {
+                       project = root.getProject(filePath.segment(0));
+               }
+               if (project != null) {
+                       javaProject = JavaScriptCore.create(project);
+               }
+               
+               return javaProject;
+       }
+       
+       /**
+        * Returns the IJsTranslation for this adapter.
+        * 
+        * @return a IJsTranslation
+        */
+       public IJsTranslation getJsTranslation(boolean listenForChanges) {
+               /*
+                * If no translation exists or switching from not listening to
+                * listening
+                */
+               if (fJSTranslation == null || (!this.listenForChanges && listenForChanges)) {
+                       if (fJSTranslation != null)
+                               fJSTranslation.release();
+                       if (fTranslationAsFactory == null) {
+                               /* load the translation factory from the extension point */
+                               try {
+                                       IExtensionRegistry registry = Platform.getExtensionRegistry();
+                                       IExtensionPoint extensionPoint = registry.getExtensionPoint("org.eclipse.wst.jsdt.web.core.javascriptPreProcessor");
+                                       IConfigurationElement points[] = extensionPoint.getConfigurationElements();
+
+                                       int highestPriorityValue = -1;
+                                       int highestPriorityIndex = -1;
+
+                                       for (int i = 0; i < points.length; i++) {
+                                               String priority = points[i].getAttribute(PRIORITY_ATTRIB);
+                                               int value = Integer.parseInt(priority);
+                                               if (value > highestPriorityValue) {
+                                                       highestPriorityIndex = i;
+                                                       highestPriorityValue = value;
+                                               }
+                                       }
+                                       fTranslationAsFactory = (IJsTranslation) points[highestPriorityIndex].createExecutableExtension("class");
+                               }
+                               catch (Exception e) {
+                                       Logger.logException(e);
+                               }
+                       }
+                       if (fTranslationAsFactory != null) {
+                               fJSTranslation = fTranslationAsFactory.getInstance(fHtmlDocument, getJavaProject(), listenForChanges);
+                       }
+                       else {
+                               fJSTranslation = new JsTranslation(fHtmlDocument, getJavaProject(), listenForChanges);
+                       }
+                       this.listenForChanges = listenForChanges;
+               }
+               shouldListenForChanges(listenForChanges);
+               return fJSTranslation;
+       }
+       
+       
+       private void initializeJavaPlugins() {
+               JavaScriptCore.getPlugin();
+       }
+       
+       public boolean isAdapterForType(Object type) {
+               return type.equals(IJsTranslation.class);
+       }
+       
+       public void notifyChanged(INodeNotifier notifier, int eventType, Object changedFeature, Object oldValue, Object newValue, int pos) {}
+       
+       public void release() {
+               if (fTranslationMonitor != null) {
+                       fTranslationMonitor.setCanceled(true);
+               }
+               ResourcesPlugin.getWorkspace().removeResourceChangeListener(this);
+               if (fJSTranslation != null) {
+                       if (JsTranslationAdapter.DEBUG) {
+                               System.out.println("JSTranslationAdapter releasing:" + fJSTranslation); //$NON-NLS-1$
+                       }
+                       fJSTranslation.release();
+               }
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.core.resources.IResourceChangeListener#resourceChanged(org.eclipse.core.resources.IResourceChangeEvent)
+        */
+       public void resourceChanged(IResourceChangeEvent event) {
+               IProject changedProject = (event==null || event.getResource()==null)?null:event.getResource().getProject();
+               if(changedProject!=null && getJavaProject().getProject().equals(changedProject) && fJSTranslation!=null){
+                       fJSTranslation.classpathChange();
+               }       
+       }
+}
\ No newline at end of file
diff --git a/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/javascript/JsTranslationAdapterFactory.java b/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/javascript/JsTranslationAdapterFactory.java
new file mode 100644 (file)
index 0000000..b621153
--- /dev/null
@@ -0,0 +1,89 @@
+package org.eclipse.wst.jsdt.web.core.javascript;
+
+/*******************************************************************************
+ * Copyright (c) 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     
+ * Provisional API: This class/interface is part of an interim API that is still under development and expected to 
+ * change significantly before reaching stability. It is being made available at this early stage to solicit feedback 
+ * from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken 
+ * (repeatedly) as the API evolves.
+ *     
+ *     
+ *******************************************************************************/
+
+
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.wst.sse.core.internal.provisional.AbstractAdapterFactory;
+import org.eclipse.wst.sse.core.internal.provisional.INodeAdapter;
+import org.eclipse.wst.sse.core.internal.provisional.INodeAdapterFactory;
+import org.eclipse.wst.sse.core.internal.provisional.INodeNotifier;
+import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
+
+/**
+*
+
+* Provisional API: This class/interface is part of an interim API that is still under development and expected to
+* change significantly before reaching stability. It is being made available at this early stage to solicit feedback
+* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
+* (repeatedly) as the API evolves.
+
+ * @author pavery
+ * 
+ */
+public class JsTranslationAdapterFactory extends AbstractAdapterFactory {
+       // for debugging
+       private static final boolean DEBUG;
+       
+       static {
+               String value = Platform.getDebugOption("org.eclipse.wst.jsdt.web.core/debug/jstranslation"); //$NON-NLS-1$
+               DEBUG = value != null && value.equalsIgnoreCase("true"); //$NON-NLS-1$
+       }
+       private JsTranslationAdapter fAdapter = null;
+       
+       public JsTranslationAdapterFactory() {
+               super(IJsTranslation.class, true);
+       }
+       
+       
+       public INodeAdapterFactory copy() {
+               return new JsTranslationAdapterFactory();
+       }
+       
+       
+       protected INodeAdapter createAdapter(INodeNotifier target) {
+               if (target instanceof IDOMNode && fAdapter == null) {
+                       fAdapter = new JsTranslationAdapter(((IDOMNode) target).getModel());
+                       if (JsTranslationAdapterFactory.DEBUG) {
+                               System.out.println("(+) JSPTranslationAdapterFactory [" + this + "] created adapter: " + fAdapter); //$NON-NLS-1$ //$NON-NLS-2$
+                       }
+               }
+               return fAdapter;
+       }
+       
+       
+       public void release() {
+               if (fAdapter != null) {
+                       if (JsTranslationAdapterFactory.DEBUG) {
+                               System.out.println("(-) JSPTranslationAdapterFactory [" + this + "] releasing adapter: " + fAdapter); //$NON-NLS-1$ //$NON-NLS-2$
+                       }
+                       fAdapter.release();
+               }
+               super.release();
+       }
+       
+       public static void setupAdapterFactory(IStructuredModel sm) {
+               if (sm.getFactoryRegistry().getFactoryFor(IJsTranslation.class) == null) {
+                       JsTranslationAdapterFactory factory = new JsTranslationAdapterFactory();
+                       sm.getFactoryRegistry().addFactory(factory);
+               }
+       }
+       
+}
\ No newline at end of file
diff --git a/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/javascript/JsTranslator.java b/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/javascript/JsTranslator.java
new file mode 100644 (file)
index 0000000..18896cf
--- /dev/null
@@ -0,0 +1,724 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2011 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     
+ * Provisional API: This class/interface is part of an interim API that is still under development and expected to 
+ * change significantly before reaching stability. It is being made available at this early stage to solicit feedback 
+ * from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken 
+ * (repeatedly) as the API evolves.
+ *     
+ *******************************************************************************/
+
+
+package org.eclipse.wst.jsdt.web.core.javascript;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+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.jobs.Job;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.DocumentEvent;
+import org.eclipse.jface.text.DocumentRewriteSessionEvent;
+import org.eclipse.jface.text.IDocumentExtension4;
+import org.eclipse.jface.text.IDocumentListener;
+import org.eclipse.jface.text.IDocumentRewriteSessionListener;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.Position;
+import org.eclipse.jface.text.Region;
+import org.eclipse.wst.jsdt.core.IBuffer;
+import org.eclipse.wst.jsdt.web.core.internal.Logger;
+import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument;
+import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
+import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion;
+import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionCollection;
+import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionContainer;
+import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionList;
+import org.eclipse.wst.sse.core.utils.StringUtils;
+import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext;
+/**
+*
+
+* Provisional API: This class/interface is part of an interim API that is still under development and expected to
+* change significantly before reaching stability. It is being made available at this early stage to solicit feedback
+* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
+* (repeatedly) as the API evolves.
+
+ * Translates a web page into its JavaScript pieces. 
+ * 
+ */
+public class JsTranslator extends Job implements IJsTranslator, IDocumentListener {
+       
+       protected static final boolean DEBUG;
+       private static final boolean DEBUG_SAVE_OUTPUT = false;  //"true".equalsIgnoreCase(Platform.getDebugOption("org.eclipse.wst.jsdt.web.core/debug/jstranslationstodisk")); //$NON-NLS-1$  //$NON-NLS-2$
+//     private static final String ENDL = "\n"; //$NON-NLS-1$
+       
+       private static final String XML_COMMENT_START = "<!--"; //$NON-NLS-1$
+//     private static final String XML_COMMENT_END = "-->"; //$NON-NLS-1$
+       
+       private static final String CDATA_START = "<![CDATA["; //$NON-NLS-1$
+       private static final String CDATA_START_PAD = new String(Util.getPad(CDATA_START.length()));
+       private static final String CDATA_END = "]]>"; //$NON-NLS-1$
+       private static final String CDATA_END_PAD = new String(Util.getPad(CDATA_END.length()));
+       
+       
+       //TODO: should be an inclusive rule rather than exclusive
+       private static final Pattern fClientSideTagPattern = Pattern.compile("<[^<%?)!>]+/?>"); //$NON-NLS-1$
+
+       // FIXME: Workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=307401
+       private String[][] fServerSideDelimiters = new String[][]{{"<%","%>"},{"<?","?>"}};
+       private int fShortestServerSideDelimiterPairLength = 4;
+       
+       static {
+               String value = Platform.getDebugOption("org.eclipse.wst.jsdt.web.core/debug/jsjavamapping"); //$NON-NLS-1$
+               DEBUG = value != null && value.equalsIgnoreCase("true"); //$NON-NLS-1$
+       }
+       
+       private class DocumentRewriteSessionListener implements IDocumentRewriteSessionListener {
+               public void documentRewriteSessionChanged(DocumentRewriteSessionEvent event) {
+                       if (DocumentRewriteSessionEvent.SESSION_START.equals(event.getChangeType())) {
+                               fIsInRewriteSession = true;
+                       }
+                       else if (DocumentRewriteSessionEvent.SESSION_STOP.equals(event.getChangeType())) {
+                               fIsInRewriteSession = false;
+                               schedule();
+                       }
+               }               
+       }
+
+       private IStructuredDocumentRegion fCurrentNode;
+       boolean fIsInRewriteSession = false;
+       protected StringBuffer fScriptText = new StringBuffer();
+       protected IStructuredDocument fStructuredDocument = null;
+       protected ArrayList importLocationsInHtml = new ArrayList();
+       /* use java script by default */
+       protected boolean fIsGlobalJs = true;
+       protected ArrayList rawImports = new ArrayList(); // translated
+       protected ArrayList scriptLocationInHtml = new ArrayList();
+       protected int scriptOffset = 0;
+       
+       protected byte[] fLock = new byte[0];
+       protected byte[] finished = new byte[0];
+       
+       protected IBuffer fCompUnitBuff;
+       protected boolean cancelParse = false;
+       protected int missingEndTagRegionStart = -1;
+       protected static final boolean ADD_SEMICOLON_AT_INLINE=true;
+       private IDocumentRewriteSessionListener fDocumentRewriteSessionListener = new DocumentRewriteSessionListener();
+
+       /*
+        * org.eclipse.jface.text.Regions that contain purely generated code, for
+        * which no validation messages should be reported to the user
+        */
+       private List fGeneratedRanges = new ArrayList();
+       
+       protected boolean isGlobalJs() {
+               return fIsGlobalJs;
+       }
+       
+       protected IBuffer getCompUnitBuffer() {
+               return fCompUnitBuff;
+       }
+       
+       protected StringBuffer getScriptTextBuffer() {
+               return fScriptText;
+       }
+       
+       
+       protected void setIsGlobalJs(boolean value) {
+               this.fIsGlobalJs = value;
+       }
+       
+       protected void advanceNextNode() {
+               setCurrentNode(getCurrentNode().getNext());
+       }       
+       
+       public JsTranslator(IStructuredDocument document,       String fileName) {
+               this(document, fileName, false);
+       }
+       
+       /**
+        * @deprecated
+        */
+       public JsTranslator() {
+               super("JavaScript Translation");
+       }
+       
+       public JsTranslator(IStructuredDocument document,       String fileName, boolean listenForChanges) {
+               super("JavaScript translation for : " + fileName); //$NON-NLS-1$
+               fStructuredDocument = document;
+               if (listenForChanges) {
+                       fStructuredDocument.addDocumentListener(this);
+                       if (fStructuredDocument instanceof IDocumentExtension4) {
+                               ((IDocumentExtension4) fStructuredDocument).addDocumentRewriteSessionListener(fDocumentRewriteSessionListener);
+                       }
+                       setPriority(Job.LONG);
+                       setSystem(true);
+                       schedule();
+               }
+               reset();
+       }
+       
+       /* (non-Javadoc)
+        * @see org.eclipse.wst.jsdt.web.core.javascript.IJsTranslator#getJsText()
+        */
+       public String getJsText() {
+               synchronized(finished) {
+                       /* if mid re-write session doc changes have been ignored,
+                        * but if jsText is specifically request we should re-translate
+                        * to pick up any changes thus far
+                        */
+                       if(this.fIsInRewriteSession) {
+                               this.reset();
+                       }
+                       
+                       return fScriptText.toString();
+               }
+       }
+       
+       /* (non-Javadoc)
+        * @see org.eclipse.wst.jsdt.web.core.javascript.IJsTranslator#getCurrentNode()
+        */
+       protected final IStructuredDocumentRegion getCurrentNode() {
+               
+               return fCurrentNode;
+       }
+       
+       /* (non-Javadoc)
+        * @see org.eclipse.wst.jsdt.web.core.javascript.IJsTranslator#setBuffer(org.eclipse.wst.jsdt.core.IBuffer)
+        */
+       public void setBuffer(IBuffer buffer) {
+               fCompUnitBuff = buffer;
+               synchronized(finished) {
+                       fCompUnitBuff.setContents(fScriptText.toString());
+               }
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.wst.jsdt.web.core.javascript.IJsTranslator#getHtmlLocations()
+        */
+       public Position[] getHtmlLocations() {
+               synchronized(finished) {
+                       return (Position[]) scriptLocationInHtml.toArray(new Position[scriptLocationInHtml.size()]);
+               }
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.wst.jsdt.web.core.javascript.IJsTranslator#getMissingEndTagRegionStart()
+        */
+       public int getMissingEndTagRegionStart() {
+               return missingEndTagRegionStart;
+       }
+       
+       /* (non-Javadoc)
+        * @see org.eclipse.wst.jsdt.web.core.javascript.IJsTranslator#getImportHtmlRanges()
+        */
+       public Position[] getImportHtmlRanges() {
+               synchronized(finished) {
+                       return (Position[]) importLocationsInHtml.toArray(new Position[importLocationsInHtml.size()]);
+               }
+       }
+       
+
+       
+       /* (non-Javadoc)
+        * @see org.eclipse.wst.jsdt.web.core.javascript.IJsTranslator#getRawImports()
+        */
+       public String[] getRawImports() {
+               synchronized(finished) {
+                       return (String[]) this.rawImports.toArray(new String[rawImports.size()]);
+               }
+       }
+
+               
+       
+       /**
+        * 
+        * @return the status of the translator's progrss monitor, false if the
+        *         monitor is null
+        */
+       protected boolean isCanceled() {
+               return cancelParse;
+       }
+       
+       /**
+        * Reinitialize some fields
+        */
+       protected void reset() {
+               synchronized (finished) {
+                       synchronized (fLock) {
+                               scriptOffset = 0;
+                               // reset progress monitor
+                               fScriptText = new StringBuffer();
+                               fCurrentNode = fStructuredDocument.getFirstStructuredDocumentRegion();
+                               rawImports.clear();
+                               importLocationsInHtml.clear();
+                               scriptLocationInHtml.clear();
+                               missingEndTagRegionStart = -1;
+                               cancelParse = false;
+                               fGeneratedRanges.clear();
+                       }
+                       translate();
+               }
+       }
+
+
+       
+       protected IStructuredDocumentRegion setCurrentNode(IStructuredDocumentRegion currentNode) {
+               synchronized(fLock) {
+                       return this.fCurrentNode = currentNode;
+               }
+       }
+       
+       /* (non-Javadoc)
+        * @see org.eclipse.wst.jsdt.web.core.javascript.IJsTranslator#translate()
+        */
+       public void translate() {
+               //setCurrentNode(fStructuredDocument.getFirstStructuredDocumentRegion());
+               
+               synchronized(finished) {
+                       if(getCurrentNode() != null) {
+                       NodeHelper nh = new NodeHelper(getCurrentNode());
+                       while (getCurrentNode() != null && !isCanceled()) {
+                               nh.setDocumentRegion(getCurrentNode());
+                               
+                               // System.out.println("Translator Looking at Node
+                               // type:"+getCurrentNode().getType()+"---------------------------------:");
+                               // System.out.println(new NodeHelper(getCurrentNode()));
+                               // i.println("/---------------------------------------------------");
+                               if (getCurrentNode().getType() == DOMRegionContext.XML_TAG_NAME) {
+                                       if ((!nh.isEndTag() || nh.isSelfClosingTag()) && nh.nameEquals("script")) { //$NON-NLS-1$
+                                               /*
+                                                * Handles the following cases: <script
+                                                * type="javascriptype"> <script language="javascriptype>
+                                                * <script src='' type=javascriptype> <script src=''
+                                                * language=javascripttype <script src=''> global js type.
+                                                * <script> (global js type)
+                                                */
+                                               if (NodeHelper.isInArray(JsDataTypes.JSVALIDDATATYPES, nh.getAttributeValue("type")) || NodeHelper.isInArray(JsDataTypes.JSVALIDDATATYPES, nh.getAttributeValue("language")) || (nh.getAttributeValue("type")==null && nh.getAttributeValue("language")==null && isGlobalJs())) { //$NON-NLS-1$ //$NON-NLS-2$
+                                                       if (nh.containsAttribute(new String[] { "src" })) { //$NON-NLS-1$
+                                                               // Handle import
+                                                               translateScriptImportNode(getCurrentNode());
+                                                       }
+                                                       // } else {
+                                                       // handle script section
+                                                       
+                                                       if (getCurrentNode().getNext() != null /*&& getCurrentNode().getNext().getType() == DOMRegionContext.BLOCK_TEXT*/) {
+                                                               translateJSNode(getCurrentNode().getNext());
+                                                       }
+                                               } // End search for <script> sections
+                                       } else if (nh.containsAttribute(JsDataTypes.HTMLATREVENTS)) {
+                                               /* Check for embedded JS events in any tags */
+                                               translateInlineJSNode(getCurrentNode());
+                                       } else if (nh.nameEquals("META") && nh.attrEquals("http-equiv", "Content-Script-Type") && nh.containsAttribute(new String[] { "content" })) { //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+                                               // <META http-equiv="Content-Script-Type" content="type">
+                                               setIsGlobalJs( NodeHelper.isInArray(JsDataTypes.JSVALIDDATATYPES, nh.getAttributeValue("content"))); //$NON-NLS-1$
+                                       } // End big if of JS types
+                               }
+                               if (getCurrentNode() != null) {
+                                       advanceNextNode();
+                               }
+                       } // end while loop
+                       if(getCompUnitBuffer()!=null) getCompUnitBuffer().setContents(fScriptText.toString());
+               }
+               finishedTranslation();
+               }
+       }
+       
+       protected void finishedTranslation() {}
+       
+       /* (non-Javadoc)
+        * @see org.eclipse.wst.jsdt.web.core.javascript.IJsTranslator#translateInlineJSNode(org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion)
+        */
+       public void translateInlineJSNode(IStructuredDocumentRegion container) {
+               // System.out
+               // .println("JSPTranslator.translateInlineJSNode Entered
+               // w/ScriptOffset:"
+               // + scriptOffset);
+               
+                       //NodeHelper nh = new NodeHelper(container);
+                       // System.out.println("inline js node looking at:\n" + nh);
+                       /* start a function header.. will amend later */
+                       ITextRegionList t = container.getRegions();
+                       ITextRegion r;
+                       Iterator regionIterator = t.iterator();
+                       while (regionIterator.hasNext() && !isCanceled() ) {
+                               r = (ITextRegion) regionIterator.next();
+                               if (r.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_NAME) {
+                                       int start = r.getStart();
+                                       int offset = r.getTextEnd();
+                                       String tagAttrname = container.getText().substring(start, offset).trim();
+                                       /*
+                                        * Attribute values aren't case sensative, also make sure next
+                                        * region is attrib value
+                                        */
+                                       if (NodeHelper.isInArray(JsDataTypes.HTMLATREVENTS, tagAttrname)) {
+                                               if (regionIterator.hasNext()) {
+                                                       regionIterator.next();
+                                               }
+                                               if (regionIterator.hasNext()) {
+                                                       r = ((ITextRegion) regionIterator.next());
+                                               }
+                                               if (r.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE) {
+                                                       int valStartOffset = container.getStartOffset(r);
+                                                       // int valEndOffset = r.getTextEnd();
+                                                       String rawText = container.getText().substring(r.getStart(), r.getTextEnd());
+                                                       if (rawText == null || rawText.length() == 0) {
+                                                               return;
+                                                       }
+                                                       /* Strip quotes */
+                                                       switch (rawText.charAt(0)) {
+                                                               case '\'':
+                                                               case '"':
+                                                                       rawText = rawText.substring(1);
+                                                                       valStartOffset++;
+                                                       }
+                                                       if (rawText == null || rawText.length() == 0) {
+                                                               return;
+                                                       }
+                                                       switch (rawText.charAt(rawText.length() - 1)) {
+                                                               case '\'':
+                                                               case '"':
+                                                                       rawText = rawText.substring(0, rawText.length() - 1);
+                                                       }
+                                                       // Position inScript = new Position(scriptOffset,
+                                                       // rawText.length());
+                                                       /* Quoted text starts +1 and ends -1 char */
+                                                       if(ADD_SEMICOLON_AT_INLINE) rawText = rawText + ";"; //$NON-NLS-1$
+                                                       Position inHtml = new Position(valStartOffset, rawText.length());
+                                                       scriptLocationInHtml.add(inHtml);
+                                                       /* need to pad the script text with spaces */
+                                                       char[] spaces = Util.getPad(valStartOffset - scriptOffset);
+                                                       fScriptText.append(spaces);
+                                                       fScriptText.append(rawText);
+                                                       scriptOffset = fScriptText.length();
+                                               }
+                                       }
+                               }
+                       }
+               }
+       
+       
+       /* (non-Javadoc)
+        * @see org.eclipse.wst.jsdt.web.core.javascript.IJsTranslator#translateJSNode(org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion)
+        */
+       public void translateJSNode(IStructuredDocumentRegion container) {
+               ITextRegionCollection containerRegion = container;
+               Iterator regions = containerRegion.getRegions().iterator();
+               ITextRegion region = null;
+               
+               if(container==null) return;
+               
+               char[] spaces = Util.getPad(container.getStartOffset() - scriptOffset);
+               fScriptText.append(spaces);
+               scriptOffset = container.getStartOffset();
+       
+               if(container.getType()!=DOMRegionContext.BLOCK_TEXT && container.getType()!= DOMRegionContext.XML_CDATA_TEXT) {
+                       return;
+               }
+               
+               while (regions.hasNext() && !isCanceled()) {
+                       region = (ITextRegion) regions.next();
+                       String type = region.getType();
+                       // content assist was not showing up in JSP inside a javascript
+                       // region
+                       
+                       //System.out.println("Region text: " + container.getText().substring(region.getStart(), region.getEnd()));
+                       boolean isContainerRegion = region instanceof ITextRegionContainer;
+                       /* make sure its not a sub container region, probably JSP */
+                       if (type == DOMRegionContext.BLOCK_TEXT ) {
+                               int scriptStart = container.getStartOffset();
+                               int scriptTextLength = container.getLength();
+                               String regionText = container.getFullText(region);
+                               regionText = StringUtils.replace(regionText, CDATA_START, CDATA_START_PAD);
+                               regionText = StringUtils.replace(regionText, CDATA_END, CDATA_END_PAD);
+                               int regionLength = region.getLength();
+                               
+                               spaces = Util.getPad(scriptStart - scriptOffset);
+                               fScriptText.append(spaces);     
+                               // skip over XML/HTML comment starts
+                               if (regionText.indexOf(XML_COMMENT_START) >= 0) {
+                                       int index = regionText.indexOf(XML_COMMENT_START);
+                                       
+                                       boolean replaceCommentStart = true;
+                                       for (int i = 0; i < index; i++) {
+                                               /*
+                                                * replace the comment start in the translation when
+                                                * it's preceded only by white space
+                                                */
+                                               replaceCommentStart = replaceCommentStart && Character.isWhitespace(regionText.charAt(i));
+                                       }
+                                       
+                                       if (replaceCommentStart) {
+                                               IRegion line;
+                                               int end;
+                                               int length;
+                                               try {
+                                                       line = container.getParentDocument().getLineInformationOfOffset(index + scriptStart);
+                                                       end = line.getOffset() + line.getLength() - scriptStart;
+                                                       if(end > regionText.length()) {
+                                                               end = regionText.length()-1;
+                                                       }
+                                                       length = end - index;
+                                               } catch (BadLocationException e) {
+                                                       Logger.logException("Could not get HTML style comment line information", e); //$NON-NLS-1$
+                                                       
+                                                       end = index + XML_COMMENT_START.length();
+                                                       length = XML_COMMENT_START.length();
+                                               }
+                                               
+                                               StringBuffer newRegionText = new StringBuffer(regionText.substring(0, index));
+                                               spaces = Util.getPad(length);
+                                               newRegionText.append(spaces);
+                                               newRegionText.append(regionText.substring(end));
+                                               regionText = newRegionText.toString();
+                                       }
+                               }
+                               // server-side code
+//                             else {
+                                       /*
+                                        * Fix for
+                                        * https://bugs.eclipse.org/bugs/show_bug.cgi?id=284774
+                                        * end of last valid JS source, start of next content to
+                                        * skip
+                                        */
+                                       // last offset of valid JS source, after which there's server-side stuff
+                                       int validJSend = 0;
+                                       // start of next valid JS source, last offset of content that was skipped
+                                       int validJSstart = 0;
+
+                                       Matcher matcher = fClientSideTagPattern.matcher(regionText);
+                                       // note the start of a HTML tag if one's present
+                                       int clientMatchStart = matcher.find() ? matcher.start() : -1;
+
+                                       StringBuffer contents = new StringBuffer();
+                                       
+                                       int serverSideStart = -1;
+                                       int serverSideDelimiter = 0;
+
+                                       // find any instance of server code blocks in the region text
+                                       for (int i = 0; i < fServerSideDelimiters.length; i++) {
+                                               int index = regionText.indexOf(fServerSideDelimiters[i][0]);
+                                               if (serverSideStart < 0) {
+                                                       serverSideStart = index;
+                                                       serverSideDelimiter = i;
+                                               }
+                                               else if (index >= 0) {
+                                                       serverSideStart = Math.min(serverSideStart, index);
+                                                       if (serverSideStart == index) {
+                                                               serverSideDelimiter = i;
+                                                       }
+                                               }
+                                       }
+                                       // contains something other than pure JavaScript
+                                       while (serverSideStart > -1 || clientMatchStart > -1) { //$NON-NLS-1$
+                                               validJSend = validJSstart;
+                                               boolean biasClient = false;
+                                               boolean biasServer = false;
+                                               // update the start of content to skip
+                                               if (clientMatchStart > -1 && serverSideStart > -1) {
+                                                       validJSend = Math.min(clientMatchStart, serverSideStart);
+                                                       biasClient = validJSend == clientMatchStart;
+                                                       biasServer = validJSend == serverSideStart;
+                                               }
+                                               else if (clientMatchStart > -1 && serverSideStart < 0) {
+                                                       validJSend = clientMatchStart;
+                                                       biasClient = true;
+                                               }
+                                               else if (clientMatchStart < 0 && serverSideStart > -1) {
+                                                       validJSend = serverSideStart;
+                                                       biasServer = true;
+                                               }
+                                               
+                                               // append if there's something we want to include
+                                               if (-1 < validJSstart && -1 < validJSend) {
+                                                       // append what we want to include
+                                                       contents.append(regionText.substring(validJSstart, validJSend));
+                                                       
+                                                       // change the skipped content to a valid variable name and append it as a placeholder
+                                                       int startOffset = container.getStartOffset(region) + validJSend;
+
+                                                       String serverEnd = fServerSideDelimiters[serverSideDelimiter][1];
+                                                       int serverSideEnd = (regionLength > validJSend + serverEnd.length()) ? regionText.indexOf(serverEnd, validJSend + fServerSideDelimiters[serverSideDelimiter][1].length()) : -1;
+                                                       if (serverSideEnd > -1)
+                                                               serverSideEnd += serverEnd.length();
+                                                       int clientMatchEnd = matcher.find(validJSend) ? matcher.end() : -1;
+                                                       // update end of what we skipped
+                                                       validJSstart = -1;
+                                                       if (clientMatchEnd > validJSend && serverSideEnd > validJSend) {
+                                                               if (biasClient)
+                                                                       validJSstart = clientMatchEnd;
+                                                               else if (biasServer)
+                                                                       validJSstart = serverSideEnd;
+                                                               else
+                                                                       validJSstart = Math.min(clientMatchEnd, serverSideEnd);
+                                                       }
+                                                       if (clientMatchEnd >= validJSend && serverSideEnd < 0)
+                                                               validJSstart = matcher.end();
+                                                       if (clientMatchEnd < 0 && serverSideEnd >= validJSend)
+                                                               validJSstart = serverSideEnd;
+                                                       int line = container.getParentDocument().getLineOfOffset(startOffset);
+                                                       int column;
+                                                       try {
+                                                               column = startOffset - container.getParentDocument().getLineOffset(line);
+                                                       }
+                                                       catch (BadLocationException e) {
+                                                               column = -1;
+                                                       }
+                                                       // substituted text length much match original length exactly, find text of the right length
+                                                       int start = validJSend + container.getStartOffset(region);
+                                                       contents.append('_');
+                                                       for (int i = validJSend + 1; i < validJSstart; i++) {
+                                                               switch (i - validJSend) {
+                                                                       case 1 :
+                                                                               contents.append('$');
+                                                                               break;
+                                                                       case 2 :
+                                                                               contents.append('t');
+                                                                               break;
+                                                                       case 3 :
+                                                                               contents.append('a');
+                                                                               break;
+                                                                       case 4 :
+                                                                               contents.append('g');
+                                                                               break;
+                                                                       default :
+                                                                               contents.append('_');
+                                                               }
+                                                       }
+                                                       int end = validJSstart + container.getStartOffset(region);
+                                                       // remember that this source range w
+                                                       fGeneratedRanges.add(new Region(start, end - start));
+                                               }
+                                               // set up to end while if no end for valid
+                                               if (validJSstart > 0) {
+                                                       int serverSideStartGuess = -1;
+                                                       for (int i = 0; i < fServerSideDelimiters.length; i++) {
+                                                               int index = regionText.indexOf(fServerSideDelimiters[i][0], validJSstart);
+                                                               if (serverSideStartGuess < 0) {
+                                                                       serverSideStartGuess = index;
+                                                                       serverSideDelimiter = i;
+                                                               }
+                                                               else if (index >= 0) {
+                                                                       serverSideStartGuess = Math.min(serverSideStartGuess, index);
+                                                                       if (serverSideStartGuess == index) {
+                                                                               serverSideDelimiter = i;
+                                                                       }
+                                                               }
+                                                       }
+                                                       serverSideStart = validJSstart < regionLength - fShortestServerSideDelimiterPairLength ? serverSideStartGuess : -1;
+                                                       clientMatchStart = validJSstart < regionLength ? (matcher.find(validJSstart) ? matcher.start() : -1) : -1;
+                                               }
+                                               else {
+                                                       serverSideStart = clientMatchStart = -1;
+                                               }
+                                       }
+                                       if (validJSstart >= 0) {
+                                               contents.append(regionText.substring(validJSstart));
+                                       }
+                                       if (contents.length() != 0) {
+                                               fScriptText.append(contents.toString());
+                                       }
+                                       else {
+                                               fScriptText.append(regionText);
+                                       }
+                                       Position inHtml = new Position(scriptStart, scriptTextLength);
+                                       scriptLocationInHtml.add(inHtml);
+//                             }
+                                                               
+                               scriptOffset = fScriptText.length();
+                       }
+               }
+               
+               IStructuredDocumentRegion endTag = container.getNext();
+               
+               if(endTag==null) {
+                       missingEndTagRegionStart = container.getStartOffset();
+               }else if(endTag!=null) {
+                       NodeHelper nh = new NodeHelper(endTag);
+                       String name = nh.getTagName();
+                       
+                       if(name==null || !name.trim().equalsIgnoreCase("script") || !nh.isEndTag()) { //$NON-NLS-1$
+                               missingEndTagRegionStart = container.getStartOffset();
+                       }
+               }
+       }
+       
+       /* (non-Javadoc)
+        * @see org.eclipse.wst.jsdt.web.core.javascript.IJsTranslator#translateScriptImportNode(org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion)
+        */
+       public void translateScriptImportNode(IStructuredDocumentRegion region) {
+               NodeHelper nh = new NodeHelper(region);
+               String importName = nh.getAttributeValue("src"); //$NON-NLS-1$
+               if (importName != null && !importName.equals("")) { //$NON-NLS-1$
+                       rawImports.add(importName);
+                       Position inHtml = new Position(region.getStartOffset(), region.getEndOffset());
+                       importLocationsInHtml.add(inHtml);
+               }
+       }
+
+
+
+       /* (non-Javadoc)
+        * @see org.eclipse.jface.text.IDocumentListener#documentAboutToBeChanged(org.eclipse.jface.text.DocumentEvent)
+        */
+       /* (non-Javadoc)
+        * @see org.eclipse.wst.jsdt.web.core.javascript.IJsTranslator#documentAboutToBeChanged(org.eclipse.jface.text.DocumentEvent)
+        */
+       public void documentAboutToBeChanged(DocumentEvent event) {
+               cancelParse = true;
+               
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.jface.text.IDocumentListener#documentChanged(org.eclipse.jface.text.DocumentEvent)
+        */
+       /* (non-Javadoc)
+        * @see org.eclipse.wst.jsdt.web.core.javascript.IJsTranslator#documentChanged(org.eclipse.jface.text.DocumentEvent)
+        */
+       public void documentChanged(DocumentEvent event) {
+               if (fIsInRewriteSession) {
+                       return;
+               }
+
+               cancel();
+               schedule();
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime.IProgressMonitor)
+        */
+       protected IStatus run(IProgressMonitor monitor) {
+               reset();
+               return Status.OK_STATUS;
+       }
+       
+       /* (non-Javadoc)
+        * @see org.eclipse.wst.jsdt.web.core.javascript.IJsTranslator#release()
+        */
+       public void release() {
+               fStructuredDocument.removeDocumentListener(this);
+               if (fStructuredDocument instanceof IDocumentExtension4) {
+                       ((IDocumentExtension4) fStructuredDocument).removeDocumentRewriteSessionListener(fDocumentRewriteSessionListener);
+               }
+       }
+
+       /**
+        * @return the fGeneratedRanges
+        */
+       public Region[] getGeneratedRanges() {
+               return (Region[]) fGeneratedRanges.toArray(new Region[fGeneratedRanges.size()]);
+       }
+}
\ No newline at end of file
diff --git a/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/javascript/Messages.java b/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/javascript/Messages.java
new file mode 100644 (file)
index 0000000..4b0baff
--- /dev/null
@@ -0,0 +1,46 @@
+/*******************************************************************************
+ * 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.web.core.javascript;
+
+import org.eclipse.osgi.util.NLS;
+
+/**
+ * 
+ * 
+ * Provisional API: This class/interface is part of an interim API that is
+ * still under development and expected to change significantly before
+ * reaching stability. It is being made available at this early stage to
+ * solicit feedback from pioneering adopters on the understanding that any
+ * code that uses this API will almost certainly be broken (repeatedly) as the
+ * API evolves.
+ * 
+ */
+public class Messages extends NLS {
+       private static final String BUNDLE_NAME = "org.eclipse.wst.jsdt.web.core.internal.java.messages"; //$NON-NLS-1$
+
+       private Messages() {
+       }
+
+       static {
+               // initialize resource bundle
+               NLS.initializeMessages(Messages.BUNDLE_NAME, Messages.class);
+       }
+
+       public static String NodeHelper00;
+       public static String NodeHelper01;
+       public static String NodeHelper03;
+       public static String NodeHelper11;
+       public static String NodeHelper12;
+
+}
diff --git a/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/javascript/NodeHelper.java b/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/javascript/NodeHelper.java
new file mode 100644 (file)
index 0000000..8afd83e
--- /dev/null
@@ -0,0 +1,245 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     
+ * Provisional API: This class/interface is part of an interim API that is still under development and expected to 
+ * change significantly before reaching stability. It is being made available at this early stage to solicit feedback 
+ * from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken 
+ * (repeatedly) as the API evolves.
+ *     
+ *     
+ *******************************************************************************/
+
+
+package org.eclipse.wst.jsdt.web.core.javascript;
+
+import java.util.Iterator;
+
+import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
+import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion;
+import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionList;
+import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext;
+/**
+*
+
+* Provisional API: This class/interface is part of an interim API that is still under development and expected to
+* change significantly before reaching stability. It is being made available at this early stage to solicit feedback
+* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
+* (repeatedly) as the API evolves.
+*/
+public class NodeHelper {
+       protected static final char DOUBLE_QUOTE_CHAR = '\"';
+       protected static final String DOUBLE_QUOTE_ENTITY = "&quot;"; //$NON-NLS-1$
+       protected static final char SINGLE_QUOTE_CHAR = '\'';
+       protected static final String SINGLE_QUOTE_ENTITY = "&#039;"; //$NON-NLS-1$
+       
+       public static boolean isInArray(String StringArray[], String text) {
+               if (StringArray == null || text == null) {
+                       return false;
+               }
+               for (int i = 0; i < StringArray.length; i++) {
+                       if (StringArray[i].equalsIgnoreCase(text.trim())) {
+                               return true;
+                       }
+               }
+               return false;
+       }
+       
+       public static boolean isQuoted(String string) {
+               if ((string == null) || (string.length() < 2)) {
+                       return false;
+               }
+               int lastIndex = string.length() - 1;
+               char firstChar = string.charAt(0);
+               char lastChar = string.charAt(lastIndex);
+               return (((firstChar == NodeHelper.SINGLE_QUOTE_CHAR) && (lastChar == NodeHelper.SINGLE_QUOTE_CHAR)) || ((firstChar == NodeHelper.DOUBLE_QUOTE_CHAR) && (lastChar == NodeHelper.DOUBLE_QUOTE_CHAR)));
+       }
+       protected IStructuredDocumentRegion region;
+       
+       public NodeHelper(IStructuredDocumentRegion region) {
+               this.region = region;
+       }
+       
+       public boolean attrEquals(String attribute, String value) {
+               String attValue = getAttributeValue(attribute);
+               if(attValue==null) return false;
+               return attValue.equalsIgnoreCase(value);
+       }
+       
+       public String AttrToString() {
+               if (region == null) {
+                       return null;
+               }
+               // For debugging
+               ITextRegionList t = region.getRegions();
+               ITextRegion r;
+               Iterator regionIterator = t.iterator();
+               String StructuredValue = Messages.NodeHelper00 + getTagName() + Messages.NodeHelper01; //$NON-NLS-1$ //$NON-NLS-2$
+               while (regionIterator.hasNext()) {
+                       r = (ITextRegion) regionIterator.next();
+                       if (r.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_NAME) {
+                               StructuredValue += "\t\t" + region.getText(r); //$NON-NLS-1$
+                               /*
+                                * Theres a XML_TAG_ATTRIBUTE_EQUALS after the
+                                * XML_TAG_ATTRIBUTE_NAME we have to get rid of
+                                */
+                               if (regionIterator.hasNext()) {
+                                       regionIterator.next();
+                               }
+                               if (r.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_EQUALS) {
+                                       if (regionIterator.hasNext()) {
+                                               r = ((ITextRegion) regionIterator.next());
+                                       }
+                                       if (r.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE) {
+                                               StructuredValue += "\t\t" + stripEndQuotes(region.getText(r)) + "\n"; //$NON-NLS-1$ //$NON-NLS-2$
+                                       }
+                               }
+                       }
+               }
+               return StructuredValue;
+       }
+       
+       public boolean containsAttribute(String name[]) {
+               if (name == null) {
+                       return false;
+               }
+               if (region == null) {
+                       return false;
+               }
+               ITextRegionList t = region.getRegions();
+               ITextRegion r;
+               Iterator regionIterator = t.iterator();
+               while (regionIterator.hasNext()) {
+                       r = (ITextRegion) regionIterator.next();
+                       if (r.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_NAME) {
+                               String tagname = region.getText(r).trim();
+                               /* Attribute values aren't case sensative */
+                               if (NodeHelper.isInArray(name, tagname)) {
+                                       return true;
+                               }
+                       }
+               }
+               return false;
+       }
+       
+       public String getAttributeValue(String name) {
+               if (region == null) {
+                       return null;
+               }
+               if (name == null) {
+                       return null;
+               }
+               ITextRegionList t = region.getRegions();
+               ITextRegion r;
+               Iterator regionIterator = t.iterator();
+               while (regionIterator.hasNext()) {
+                       r = (ITextRegion) regionIterator.next();
+                       if (r.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_NAME) {
+                               String tagname = region.getText(r).trim();
+                               /*
+                                * Attribute values aren't case sensative, also make sure next
+                                * region is attrib value
+                                */
+                               if (tagname.equalsIgnoreCase(name)) {
+                                       if (regionIterator.hasNext()) {
+                                               regionIterator.next();
+                                       }
+                                       if (regionIterator.hasNext()) {
+                                               r = ((ITextRegion) regionIterator.next());
+                                       }
+                                       if (r.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE) {
+                                               return stripEndQuotes(region.getText(r));
+                                       }
+                               }
+                       }
+               }
+               return null;
+       }
+       
+       public String getElementAsFlatString() {
+               /*
+                * Returns a full string of this element minus and 'illegal' characters
+                * (usefull for identifying the HTML element in a generic JS function)
+                */
+               if (region == null) {
+                       return null;
+               }
+               String fullRegionText = region.getFullText();
+               if (fullRegionText == null) {
+                       return null;
+               }
+               return fullRegionText.replaceAll("[^a-zA-Z0-9]", ""); //$NON-NLS-1$ //$NON-NLS-2$
+       }
+       
+       public String getTagName() {
+               if (region == null) {
+                       return null;
+               }
+               ITextRegionList t = region.getRegions();
+               ITextRegion r;
+               Iterator regionIterator = t.iterator();
+               while (regionIterator.hasNext()) {
+                       r = (ITextRegion) regionIterator.next();
+                       if (r.getType() == DOMRegionContext.XML_TAG_NAME) {
+                               return region.getText(r);
+                       }
+               }
+               return null;
+       }
+       
+       public boolean isEndTag() {
+               if (region == null) {
+                       return false;
+               }
+               return DOMRegionContext.XML_END_TAG_OPEN.equals(region.getFirstRegion().getType());
+       }
+       
+       public boolean isSelfClosingTag() {
+               if (region == null) {
+                       return false;
+               }
+               return DOMRegionContext.XML_EMPTY_TAG_CLOSE.equals(region.getLastRegion().getType());
+       }
+       
+       public boolean nameEquals(String name) {
+               if (region == null || name == null) {
+                       return false;
+               }
+               return name.equalsIgnoreCase(getTagName());
+       }
+       
+       public void setDocumentRegion(IStructuredDocumentRegion newRegion) {
+               if (newRegion == null)
+                       throw new IllegalArgumentException();
+               region = newRegion;
+       }
+       
+       public String stripEndQuotes(String text) {
+               if (text == null) {
+                       return null;
+               }
+               if (NodeHelper.isQuoted(text)) {
+                       return text.substring(1, text.length() - 1);
+               }
+               return text;
+       }
+       
+       
+       public String toString() {
+               ITextRegionList t = region.getRegions();
+               Iterator regionIterator = t.iterator();
+               String nodeText = new String();
+               while (regionIterator.hasNext()) {
+                       ITextRegion r = (ITextRegion) regionIterator.next();
+                       String nodeType = r.getType();
+                       nodeText += (Messages.NodeHelper11 + nodeType + Messages.NodeHelper12 + region.getText(r) + "\n"); //$NON-NLS-1$
+               }
+               return nodeText;
+       }
+}
\ No newline at end of file
diff --git a/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/javascript/Util.java b/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/javascript/Util.java
new file mode 100644 (file)
index 0000000..a42aead
--- /dev/null
@@ -0,0 +1,54 @@
+/*******************************************************************************
+ * Copyright (c) 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     
+ * Provisional API: This class/interface is part of an interim API that is still under development and expected to 
+ * change significantly before reaching stability. It is being made available at this early stage to solicit feedback 
+ * from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken 
+ * (repeatedly) as the API evolves.
+ *     
+ *     
+ *******************************************************************************/
+
+
+package org.eclipse.wst.jsdt.web.core.javascript;
+
+import java.util.Arrays;
+
+/**
+*
+
+* Provisional API: This class/interface is part of an interim API that is still under development and expected to
+* change significantly before reaching stability. It is being made available at this early stage to solicit feedback
+* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
+* (repeatedly) as the API evolves.
+*
+ * @author childsb
+ *
+ */
+public class Util {
+       public static char[] getPad(int numberOfChars) {
+               if(numberOfChars < 0) return new char[0];
+               final char[] spaceArray = new char[numberOfChars];
+               Arrays.fill(spaceArray, ' ');
+               return spaceArray;
+       }
+       
+       public static String removeAll(String source, char remove) {
+               
+               String newString = "";
+               
+               char[] oldStringArray = source.toCharArray();
+               
+               for(int i = 0;i<oldStringArray.length;i++) {
+                       if(oldStringArray[i]!=remove) newString+=oldStringArray[i];
+               }
+               return newString;
+       }
+}
diff --git a/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/javascript/WebRootFinder.java b/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/javascript/WebRootFinder.java
new file mode 100644 (file)
index 0000000..5d958e5
--- /dev/null
@@ -0,0 +1,57 @@
+/*******************************************************************************
+ * Copyright (c) 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     
+ * Provisional API: This class/interface is part of an interim API that is still under development and expected to 
+ * change significantly before reaching stability. It is being made available at this early stage to solicit feedback 
+ * from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken 
+ * (repeatedly) as the API evolves.
+ *     
+ *     
+ *******************************************************************************/
+
+
+
+package org.eclipse.wst.jsdt.web.core.javascript;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.wst.jsdt.web.core.internal.project.ModuleCoreSupport;
+/**
+*
+
+* Provisional API: This class/interface is part of an interim API that is still under development and expected to
+* change significantly before reaching stability. It is being made available at this early stage to solicit feedback
+* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
+* (repeatedly) as the API evolves.
+*/
+public class WebRootFinder {
+       public static IPath getServerContextRoot(IProject project) {
+               IPath root = ModuleCoreSupport.getWebContentRootPath(project);
+               if (root != null)
+                       return root;
+               return Path.ROOT;
+       }
+       
+       /**
+        * @param project
+        * @return project-relative path to the web content root
+        */
+       public static IPath getWebContentFolder(IProject project) {
+               IPath root = ModuleCoreSupport.getWebContentRootPath(project);
+               if (root != null)
+                       return root.removeFirstSegments(1);
+               return Path.ROOT;
+       }
+       
+       public static String getWebContext(IProject project) {
+               return null;
+       }
+}
diff --git a/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/javascript/messages.properties b/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/javascript/messages.properties
new file mode 100644 (file)
index 0000000..ebccdda
--- /dev/null
@@ -0,0 +1,15 @@
+###############################################################################
+# 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
+###############################################################################
+NodeHelper.0=Tag name:
+NodeHelper.1=\tAttribute\tValue\n
+NodeHelper.3=attrib type
+NodeHelper.11=\tNode Type:
+NodeHelper.12=\ \t\tValue:
diff --git a/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/javascript/search/IndexWorkspaceJob.java b/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/javascript/search/IndexWorkspaceJob.java
new file mode 100644 (file)
index 0000000..83d1ed4
--- /dev/null
@@ -0,0 +1,168 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2011 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.web.core.javascript.search;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IResourceProxy;
+import org.eclipse.core.resources.IResourceProxyVisitor;
+import org.eclipse.core.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.Platform;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.wst.jsdt.web.core.internal.JsCoreMessages;
+import org.eclipse.wst.jsdt.web.core.internal.validation.Util;
+
+/**
+*
+
+* Provisional API: This class/interface is part of an interim API that is still under development and expected to
+* change significantly before reaching stability. It is being made available at this early stage to solicit feedback
+* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
+* (repeatedly) as the API evolves.
+* (copied from JSP)
+ * Re-indexes the entire workspace.
+ * Ensures the JSP Index is in a stable state before performing a search.
+ * (like after a crash or if previous indexing was canceled)
+ * 
+ * @author pavery
+ */
+public class IndexWorkspaceJob extends Job {
+
+       // for debugging
+       static final boolean DEBUG;
+       static {
+               String value = Platform.getDebugOption("org.eclipse.wst.jsdt.web.core/debug/jsindexmanager"); //$NON-NLS-1$
+               DEBUG = value != null && value.equalsIgnoreCase("true"); //$NON-NLS-1$
+       }
+       
+       /**
+        * Visitor that retrieves project paths for all web page files in the workspace,
+        * and adds the files to be indexed as they are encountered
+        */
+       private class WebFileVisitor implements IResourceProxyVisitor {
+           private List files = new ArrayList(); 
+               
+               // monitor from the Job
+               IProgressMonitor fMonitor = null;
+               public WebFileVisitor(IProgressMonitor monitor) {
+                       this.fMonitor = monitor;
+               }
+               
+               public boolean visit(IResourceProxy proxy) throws CoreException {
+                       // check job canceled
+                       if ((this.fMonitor != null) && this.fMonitor.isCanceled()) {
+                               setCanceledState();
+                               return false;
+                       }
+                       
+                       // check search support canceled
+                       if(JsSearchSupport.getInstance().isCanceled()) {
+                               setCanceledState();
+                               return false;
+                       }
+                       // skip hidden, unreadable, or derived files
+                       if (proxy.getType() == IResource.FILE && !proxy.isDerived() && !proxy.isHidden() && proxy.isAccessible()) {
+                               // https://w3.opensource.ibm.com/bugzilla/show_bug.cgi?id=3553
+                               // check this before description
+                               // check name before actually getting the file (less work)
+                               if(Util.isJsType(proxy.getName())) {
+                                       this.fMonitor.subTask(proxy.getName());
+                                       IFile file = (IFile) proxy.requestResource();
+
+                                       if (DEBUG) {
+                                               System.out.println("(+) IndexWorkspaceJob adding file: " + file.getName()); //$NON-NLS-1$
+                                       }
+                                       // this call will check the ContentTypeDescription, so don't need to do it here.
+                                       //JSPSearchSupport.getInstance().addJspFile(file);
+                                       this.files.add(file);
+                                       
+                                       // don't search deeper for files
+                                       return false;
+                               }
+                       }
+                       return !proxy.getName().startsWith(".");
+               }
+               
+               public final IFile[] getFiles() {
+                   return (IFile[])this.files.toArray(new IFile[this.files.size()]);
+               }
+       }
+       
+       //private IContentType fContentTypeJSP = null;
+       
+       public IndexWorkspaceJob() {
+               // pa_TODO may want to say something like "Rebuilding JSP Index" to be more
+               // descriptive instead of "Updating JSP Index" since they are 2 different things
+               super(JsCoreMessages.JSPIndexManager_0);
+               setPriority(Job.LONG);
+               setSystem(true);
+       }
+
+//     IContentType getJspContentType() {
+//             if(this.fContentTypeJSP == null)
+//                     this.fContentTypeJSP = Platform.getContentTypeManager().getContentType(ContentTypeIdForJSP.ContentTypeID_JSP);
+//             return this.fContentTypeJSP;
+//     }
+       
+       /**
+        * @see org eclipse.core.internal.jobs.InternalJob#run(org.eclipse.core.runtime.IProgressMonitor) 
+        * for similar method
+        */
+       protected IStatus run(IProgressMonitor monitor) {
+               
+               IStatus status = Status.OK_STATUS;
+               
+               if(monitor.isCanceled()) {
+                       setCanceledState();
+                       return Status.CANCEL_STATUS;
+               }
+               
+               if(DEBUG) {
+                       System.out.println(" ^ IndexWorkspaceJob started: "); //$NON-NLS-1$
+               }
+               
+               long start = System.currentTimeMillis();
+               
+               try {
+                   WebFileVisitor visitor = new WebFileVisitor(monitor);
+                   // collect all jsp files
+                       ResourcesPlugin.getWorkspace().getRoot().accept(visitor, IResource.DEPTH_INFINITE);
+                       // request indexing
+                       // this is pretty much like faking an entire workspace resource delta
+                       JsIndexManager.getInstance().indexFiles(visitor.getFiles());
+               }
+               catch (CoreException e) {
+                       if(DEBUG) {
+                               e.printStackTrace();
+                       }
+               }
+               finally {
+                       monitor.done();
+               }
+               long finish = System.currentTimeMillis();
+               if(DEBUG) {
+                       System.out.println(" ^ IndexWorkspaceJob finished\n   total time running: " + (finish - start)); //$NON-NLS-1$
+               }
+               
+               return status;
+       }
+       
+       void setCanceledState() {
+               JsIndexManager.getInstance().setIndexState(JsIndexManager.S_CANCELED);
+       }
+}
diff --git a/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/javascript/search/JSDTSearchDocumentDelegate.java b/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/javascript/search/JSDTSearchDocumentDelegate.java
new file mode 100644 (file)
index 0000000..0862b4b
--- /dev/null
@@ -0,0 +1,84 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.web.core.javascript.search;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.wst.jsdt.core.IJavaScriptElement;
+import org.eclipse.wst.jsdt.internal.core.search.JavaSearchDocument;
+import org.eclipse.wst.jsdt.web.core.javascript.IJsTranslation;
+
+/**
+*
+
+* Provisional API: This class/interface is part of an interim API that is still under development and expected to
+* change significantly before reaching stability. It is being made available at this early stage to solicit feedback
+* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
+* (repeatedly) as the API evolves.
+*(copied from JSP)
+ * Wrapper method to set getPath() path to be the path of the compilation unit 
+ * for the jsp file. (since it's a final method, it needs to be set via constructor)
+ * 
+ * @author pavery
+ */
+public class JSDTSearchDocumentDelegate extends JavaSearchDocument {
+       
+       private JsSearchDocument fJSPSearchDoc = null;
+       
+       public JSDTSearchDocumentDelegate(JsSearchDocument jspSearchDoc) {
+               
+               super(jspSearchDoc.getPath(), jspSearchDoc.getParticipant());
+               this.fJSPSearchDoc = jspSearchDoc;
+       }
+
+       public byte[] getByteContents() {
+               
+               return this.fJSPSearchDoc.getByteContents();
+       }
+
+       public char[] getCharContents() {
+               
+               return this.fJSPSearchDoc.getCharContents();
+       }
+       
+       public String getJavaText() {
+               return this.fJSPSearchDoc.getJavaText();
+       }
+
+       public String getEncoding() {
+               
+               return this.fJSPSearchDoc.getEncoding();
+       }
+       
+       public IFile getFile() {
+               
+               return this.fJSPSearchDoc.getFile();
+       }
+       
+       public IJsTranslation getJspTranslation() {
+               
+               return this.fJSPSearchDoc.getJSTranslation();
+       }
+       
+//     public int getJspOffset(int javaOffset) {
+//             
+//             return this.fJSPSearchDoc.getJspOffset(javaOffset);
+//     }
+       
+       public void release() {
+               this.fJSPSearchDoc.release();
+       }
+       public IJavaScriptElement getJavaElement() {
+               return getJspTranslation().getCompilationUnit();
+       }
+       public boolean isVirtual() {
+               return true;
+       }
+}
diff --git a/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/javascript/search/JsIndexManager.java b/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/javascript/search/JsIndexManager.java
new file mode 100644 (file)
index 0000000..b503069
--- /dev/null
@@ -0,0 +1,772 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2011 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.web.core.javascript.search;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IResourceChangeEvent;
+import org.eclipse.core.resources.IResourceChangeListener;
+import org.eclipse.core.resources.IResourceDelta;
+import org.eclipse.core.resources.IResourceDeltaVisitor;
+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.Path;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Plugin;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.IJobChangeEvent;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.core.runtime.jobs.JobChangeAdapter;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.wst.jsdt.core.IJavaScriptProject;
+import org.eclipse.wst.jsdt.core.JavaScriptCore;
+import org.eclipse.wst.jsdt.internal.core.JavaModelManager;
+import org.eclipse.wst.jsdt.internal.core.index.Index;
+import org.eclipse.wst.jsdt.internal.core.search.indexing.IndexManager;
+import org.eclipse.wst.jsdt.internal.core.search.indexing.IndexRequest;
+import org.eclipse.wst.jsdt.internal.core.search.indexing.ReadWriteMonitor;
+import org.eclipse.wst.jsdt.web.core.internal.JsCoreMessages;
+import org.eclipse.wst.jsdt.web.core.internal.JsCorePlugin;
+import org.eclipse.wst.jsdt.web.core.internal.Logger;
+import org.eclipse.wst.jsdt.web.core.internal.project.JsWebNature;
+import org.eclipse.wst.jsdt.web.core.internal.validation.Util;
+import org.osgi.framework.Bundle;
+
+/**
+ *
+ * Provisional API: This class/interface is part of an interim API that is still under development and expected to
+ * change significantly before reaching stability. It is being made available at this early stage to solicit feedback
+ * from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
+ * (repeatedly) as the API evolves.
+ *(copied from JSP)
+ * Responsible for keeping the JS index up to date.
+ * 
+ */
+public class JsIndexManager {
+
+       // for debugging
+       // TODO move this to Logger, as we have in SSE
+       static final boolean DEBUG;
+       static {
+               String value = Platform.getDebugOption("org.eclipse.wst.jsdt.web.core/debug/jsindexmanager"); //$NON-NLS-1$
+               DEBUG = value != null && value.equalsIgnoreCase("true"); //$NON-NLS-1$
+       }
+
+       private static final String PKEY_INDEX_STATE = "jspIndexState"; //$NON-NLS-1$
+
+       private IndexWorkspaceJob indexingJob = new IndexWorkspaceJob();
+
+
+
+       // TODO: consider enumeration for these int constants
+       // set to S_UPDATING once a resource change comes in
+       // set to S_STABLE if:
+       // - we know we aren't interested in the resource change
+       // - or the ProcessFilesJob completes
+       // set to S_CANCELED if an indexing job is canceled
+       // set to S_REBUILDING if re-indexing the entire workspace
+
+       // the int '0' is reserved for the default value if a preference is not
+       // there
+       /** index is reliable to use */
+       public static final int S_STABLE = 1;
+       /** index is being updated (from a resource delta) */
+       public static final int S_UPDATING = 2;
+       /** entire index is being rebuilt */
+       public static final int S_REBUILDING = 3;
+       /**
+        * indexing job was canceled in the middle of it, index needs to be
+        * rebuilt
+        */
+       public static final int S_CANCELED = 4;
+
+       /** symbolic name for OSGI framework */
+       private final String OSGI_FRAMEWORK_ID = "org.eclipse.osgi"; //$NON-NLS-1$
+
+       /**
+        * Collects web page files from a resource delta. Derived resources should
+        * be included to handle resources whose derived flag is being toggled.
+        */
+       private class JSResourceDeltaVisitor implements IResourceDeltaVisitor {
+               // using hash map ensures only one of each file
+               // must be reset before every use
+               private HashMap webPageFiles = null;
+
+               public JSResourceDeltaVisitor() {
+                       this.webPageFiles = new HashMap();
+               }
+
+               public boolean visit(IResourceDelta delta) throws CoreException {
+
+                       // in case JS search was canceled (eg. when closing the editor)
+                       if (JsSearchSupport.getInstance().isCanceled() || frameworkIsShuttingDown()) {
+                               setCanceledState();
+                               return false;
+                       }
+
+                       try {
+                               // skip anything hidden by name
+                               if (isHiddenResource(delta.getFullPath())) {
+                                       return false;
+                               }
+
+                               int kind = delta.getKind();
+                               int flags = delta.getFlags();
+                               boolean added = (kind & IResourceDelta.ADDED) == IResourceDelta.ADDED;
+                               boolean isInterestingChange = false;
+                               if ((kind & IResourceDelta.CHANGED) == IResourceDelta.CHANGED) {
+                                       // ignore things like marker changes
+                                       isInterestingChange = (flags & IResourceDelta.CONTENT) > 0 || (flags & IResourceDelta.REPLACED) > 0 || (flags & IResourceDelta.TYPE) > 0 || (flags & IResourceDelta.MOVED_FROM) > 0;
+                               }
+                               boolean removed = (kind & IResourceDelta.REMOVED) == IResourceDelta.REMOVED;
+                               if (added || isInterestingChange) {
+                                       visitAdded(delta);
+                               }
+                               else if (removed) {
+                                       visitRemoved(delta);
+                               }
+                       }
+                       catch (Exception e) {
+                               // need to set state here somehow, and reindex
+                               // otherwise index will be unreliable
+                               if (DEBUG) {
+                                       Logger.logException("Delta analysis may not be complete", e); //$NON-NLS-1$
+                               }
+                       }
+                       // if the delta has children, continue to add/remove files
+                       return true;
+               }
+
+               private void visitRemoved(IResourceDelta delta) {
+                       // handle cleanup
+                       if (delta.getResource() != null) {
+                               IResource r = delta.getResource();
+                               if ((r.getType() == IResource.FOLDER) && r.exists()) {
+                                       deleteIndex((IFolder) r);
+                               }
+                               if ((r.getType() == IResource.FILE) && r.exists()) {
+                                       deleteIndex((IFile) r);
+                               }
+                       }
+               }
+
+               private void visitAdded(IResourceDelta delta) {
+                       // https://w3.opensource.ibm.com/bugzilla/show_bug.cgi?id=3553
+                       // quick check if it's even web page related to improve
+                       // performance
+                       // checking name from the delta before getting
+                       // resource because it's lighter
+                       String filename = delta.getFullPath().lastSegment();
+                       if (filename != null && Util.isJsType(filename)) {
+                               IResource r = delta.getResource();
+                               if (r.isAccessible() && r.getType() == IResource.FILE) {
+                                       this.webPageFiles.put(r.getFullPath(), r);
+                               }
+                       }
+               }
+
+               // https://bugs.eclipse.org/bugs/show_bug.cgi?id=93463
+               private boolean isHiddenResource(IPath p) {
+                       return p.segmentCount() > 0 && p.lastSegment().startsWith(".");
+               }
+
+               private void deleteIndex(IFolder folder) {
+                       // cleanup index
+                       IndexManager im = JavaModelManager.getJavaModelManager().getIndexManager();
+                       IPath folderPath = folder.getFullPath();
+                       IPath indexLocation = JsSearchSupport.getInstance().computeIndexLocation(folderPath);
+                       im.removeIndex(indexLocation);
+                       // im.indexLocations.removeKey(folderPath);
+                       // im.indexLocations.removeValue(indexLocation);
+                       File f = indexLocation.toFile();
+                       f.delete();
+               }
+
+               private void deleteIndex(IFile file) {
+                       // have to use our own job to compute the correct index location
+                       RemoveFileFromIndex removeFileFromIndex = new RemoveFileFromIndex(file.getFullPath());
+                       JavaModelManager.getJavaModelManager().getIndexManager().request(removeFileFromIndex);
+               }
+
+               public IFile[] getFiles() {
+                       return (IFile[]) this.webPageFiles.values().toArray(new IFile[this.webPageFiles.size()]);
+               }
+
+               public void reset() {
+                       this.webPageFiles.clear();
+               }
+       }
+
+
+       /**
+        * schedules web pages for indexing
+        */
+       private class ProcessFilesJob extends Job {
+               List fileList = null;
+               // keep track of how many files we've indexed
+               int lastFileCursor = 0;
+
+               ProcessFilesJob(String taskName) {
+                       super(taskName);
+                       fileList = new ArrayList();
+               }
+
+               synchronized void process(IFile[] files) {
+                       for (int i = 0; i < files.length; i++) {
+                               fileList.add(files[i]);
+                       }
+                       if (DEBUG) {
+                               System.out.println("JSIndexManager queuing " + files.length + " files"); //$NON-NLS-2$ //$NON-NLS-1$
+                       }
+               }
+
+               synchronized IFile[] getFiles() {
+                       return (IFile[]) fileList.toArray(new IFile[fileList.size()]);
+               }
+
+               synchronized void clearFiles() {
+                       fileList.clear();
+                       lastFileCursor = 0;
+                       //System.out.println("cleared files");
+               }
+
+               protected IStatus run(IProgressMonitor monitor) {
+                       // System.out.println("indexer monitor" + monitor);
+                       if (isCanceled(monitor) || frameworkIsShuttingDown()) {
+                               setCanceledState();
+                               return Status.CANCEL_STATUS;
+                       }
+
+                       long start = System.currentTimeMillis();
+
+                       try {
+                               IFile[] filesToBeProcessed = getFiles();
+
+                               if (DEBUG) {
+                                       System.out.println("JSIndexManager indexing " + filesToBeProcessed.length + " files"); //$NON-NLS-2$ //$NON-NLS-1$
+                               }
+                               // API indicates that monitor is never null
+                               monitor.beginTask("", filesToBeProcessed.length); //$NON-NLS-1$
+                               JsSearchSupport ss = JsSearchSupport.getInstance();
+                               String processingNFiles = ""; //$NON-NLS-1$
+
+
+                               for (;lastFileCursor < filesToBeProcessed.length; lastFileCursor++) {
+
+                                       if (isCanceled(monitor) || frameworkIsShuttingDown()) {
+                                               setCanceledState();
+                                               return Status.CANCEL_STATUS;
+                                       }
+                                       IFile file = filesToBeProcessed[lastFileCursor];
+                                       // do not add files that are derived
+                                       if(!file.isDerived()) {
+                                               try {
+                                                       IJavaScriptProject project = JavaScriptCore.create(file.getProject());
+                                                       if (project.exists()) {
+                                                               ss.addJspFile(file);
+                                                               // JS Indexer processing n files
+                                                               processingNFiles = NLS.bind(JsCoreMessages.JSPIndexManager_2, new String[]{Integer.toString((filesToBeProcessed.length - lastFileCursor))});
+                                                               monitor.subTask(processingNFiles + " - " + file.getName()); //$NON-NLS-1$
+                                                               monitor.worked(1);
+       
+                                                               if (DEBUG) {
+                                                                       System.out.println("JSIndexManager Job added file: " + file.getName()); //$NON-NLS-1$
+                                                               }
+                                                       }
+                                               }
+                                               catch (Exception e) {
+                                                       // RATLC00284776
+                                                       // ISSUE: we probably shouldn't be catching EVERY
+                                                       // exception, but
+                                                       // the framework only allows to return IStatus in
+                                                       // order to communicate
+                                                       // that something went wrong, which means the loop
+                                                       // won't complete, and we would hit the same problem
+                                                       // the next time.
+                                                       // 
+                                                       // a possible solution is to keep track of the
+                                                       // exceptions logged
+                                                       // and only log a certain amt of the same one,
+                                                       // otherwise skip it.
+                                                       if (!frameworkIsShuttingDown()) {
+                                                               String filename = file != null ? file.getFullPath().toString() : ""; //$NON-NLS-1$
+                                                               Logger.logException("JSIndexer problem indexing:" + filename, e); //$NON-NLS-1$
+                                                       }
+                                               }
+                                       }
+                               } // end for
+                       }
+                       finally {
+                               // just in case something didn't follow API (monitor is null)
+                               if (monitor != null) {
+                                       monitor.done();
+                               }
+                       }
+
+                       // successfully finished, clear files list
+                       clearFiles();
+                       
+                       long finish = System.currentTimeMillis();
+                       long diff = finish - start;
+                       if (DEBUG) {
+                               fTotalTime += diff;
+                               System.out.println("============================================================================"); //$NON-NLS-1$
+                               System.out.println("this time: " + diff + " cumulative time for resource changed: " + fTotalTime); //$NON-NLS-1$ //$NON-NLS-2$
+                               System.out.println("============================================================================"); //$NON-NLS-1$
+                       }
+                       return Status.OK_STATUS;
+               }
+
+               private boolean isCanceled(IProgressMonitor runMonitor) {
+                       boolean canceled = false;
+                       // check specific monitor passed into run method (the progress
+                       // group in this case)
+                       // check main search support canceled
+                       if ((runMonitor != null) && runMonitor.isCanceled()) {
+                               canceled = true;
+                       } else if (JsSearchSupport.getInstance().isCanceled()) {
+                               canceled = true;
+                               if (runMonitor != null) {
+                                       runMonitor.setCanceled(true);
+                               }
+                       }
+                       return canceled;
+               }
+               
+       }
+
+       // end class ProcessFilesJob
+
+       class RemoveFileFromIndex extends IndexRequest {
+               IPath filePath;
+
+               public RemoveFileFromIndex(IPath filePath) {
+                       super(filePath.removeLastSegments(1), JavaModelManager.getJavaModelManager().getIndexManager());
+               }
+               public boolean execute(IProgressMonitor progressMonitor) {
+
+                       if (this.isCancelled || progressMonitor != null && progressMonitor.isCanceled()) return true;
+
+                       /* ensure no concurrent write access to index */
+                       Index index = this.manager.getIndex(this.containerPath, JsSearchSupport.getInstance().computeIndexLocation(filePath.removeLastSegments(1)), true, /*reuse index file*/ false /*create if none*/);
+                       if (index == null) return true;
+                       ReadWriteMonitor monitor = index.monitor;
+                       if (monitor == null) return true; // index got deleted since acquired
+
+                       try {
+                               monitor.enterWrite(); // ask permission to write
+                               index.remove(filePath.lastSegment());
+                       } finally {
+                               monitor.exitWrite(); // free write lock
+                       }
+                       return true;
+               }
+               public String toString() {
+                       return "removing " + filePath.lastSegment() + " from index " + this.containerPath; //$NON-NLS-1$ //$NON-NLS-2$
+               }
+       }
+
+       private static JsIndexManager fSingleton = null;
+       private boolean initialized;
+       private boolean initializing = true;
+
+       private IndexJobCoordinator indexJobCoordinator;
+       private IResourceChangeListener jsResourceChangeListener;
+
+       private JSResourceDeltaVisitor fVisitor = null;
+       static long fTotalTime = 0;
+
+       // Job for processing resource delta
+       private ProcessFilesJob processFilesJob = null;
+
+       private JsIndexManager() {
+               processFilesJob = new ProcessFilesJob(JsCoreMessages.JSPIndexManager_0);
+               // only show in verbose mode
+               processFilesJob.setSystem(true);
+               processFilesJob.setPriority(Job.LONG);
+               processFilesJob.addJobChangeListener(new JobChangeAdapter() {
+                       public void done(IJobChangeEvent event) {
+                               super.done(event);
+                               setStableState();
+                       }
+               });
+       }
+
+       public synchronized static JsIndexManager getInstance() {
+               if (fSingleton == null) {
+                       fSingleton = new JsIndexManager();
+               }
+               return fSingleton;
+       }
+
+       public void initialize() {
+               JsIndexManager singleInstance = getInstance();
+
+               if (!singleInstance.initialized) {
+                       singleInstance.initialized = true;
+
+                       singleInstance.indexJobCoordinator = new IndexJobCoordinator();
+                       singleInstance.jsResourceChangeListener = new JSResourceChangeListener();
+
+                       // added as JobChange listener so JSIndexManager can be smarter
+                       // about when it runs
+                       Job.getJobManager().addJobChangeListener(singleInstance.indexJobCoordinator);
+
+                       // add JSIndexManager to keep JSP Index up to date
+                       // listening for IResourceChangeEvent.PRE_DELETE and
+                       // IResourceChangeEvent.POST_CHANGE
+                       ResourcesPlugin.getWorkspace().addResourceChangeListener(jsResourceChangeListener, IResourceChangeEvent.POST_CHANGE);
+
+                       // https://w3.opensource.ibm.com/bugzilla/show_bug.cgi?id=5091
+                       // makes sure IndexManager is aware of our indexes
+                       saveIndexes();
+                       //rebuildIndexIfNeeded();
+                       singleInstance.initializing = false;
+
+               }
+
+       }
+       
+       synchronized void setIndexState(int state) {
+               if (DEBUG) {
+                       System.out.println("JSIndexManager setting index state to: " + state2String(state)); //$NON-NLS-1$
+               }
+               Plugin jspModelPlugin = JsCorePlugin.getDefault();
+               jspModelPlugin.getPluginPreferences().setValue(PKEY_INDEX_STATE, state);
+               jspModelPlugin.savePluginPreferences();
+
+       }
+
+       private String state2String(int state) {
+               String s = "UNKNOWN"; //$NON-NLS-1$
+               switch (state) {
+                       case (S_STABLE) :
+                               s = "S_STABLE"; //$NON-NLS-1$
+                               break;
+                       case (S_UPDATING) :
+                               s = "S_UPDATING"; //$NON-NLS-1$
+                               break;
+                       case (S_CANCELED) :
+                               s = "S_CANCELED"; //$NON-NLS-1$
+                               break;
+                       case (S_REBUILDING) :
+                               s = "S_REBUILDING"; //$NON-NLS-1$
+                               break;
+               }
+               return s;
+       }
+
+       int getIndexState() {
+               return JsCorePlugin.getDefault().getPluginPreferences().getInt(PKEY_INDEX_STATE);
+       }
+
+       void setUpdatingState() {
+               //if (getIndexState() != S_CANCELED)
+               setIndexState(S_UPDATING);
+       }
+
+       void setCanceledState() {
+               setIndexState(JsIndexManager.S_CANCELED);
+       }
+
+       void setStableState() {
+               //if (getIndexState() != S_CANCELED)
+               setIndexState(S_STABLE);
+       }
+
+       void setRebuildingState() {
+               setIndexState(S_REBUILDING);
+       }
+
+       synchronized void rebuildIndexIfNeeded() {
+               if (getIndexState() != S_STABLE) {
+                       rebuildIndex();
+               }
+       }
+
+       void rebuildIndex() {
+
+               if (DEBUG) {
+                       System.out.println("*** JS web page Index unstable, requesting re-indexing"); //$NON-NLS-1$
+               }
+
+               getIndexingJob().addJobChangeListener(new JobChangeAdapter() {
+                       public void aboutToRun(IJobChangeEvent event) {
+                               super.aboutToRun(event);
+                               setRebuildingState();
+                       }
+
+                       public void done(IJobChangeEvent event) {
+                               super.done(event);
+                               setStableState();
+                               getIndexingJob().removeJobChangeListener(this);
+                       }
+               });
+               // we're about to reindex everything anyway
+               getProcessFilesJob().clearFiles();
+               getIndexingJob().schedule();
+
+       }
+
+       /**
+        * Creates and schedules a Job to process collected files. All JSP
+        * indexing should be done through this method or processFiles(IFile file)
+        * 
+        * @param files
+        */
+       final void indexFiles(IFile[] files) {
+               // don't use this rule
+               // https://w3.opensource.ibm.com/bugzilla/show_bug.cgi?id=4931
+               // processFiles.setRule(new IndexFileRule());
+               processFilesJob.process(files);
+       }
+
+
+       /**
+        * Package protected for access by inner Job class in resourceChanged(...)
+        * 
+        * @return
+        */
+       JSResourceDeltaVisitor getVisitor() {
+
+               if (this.fVisitor == null) {
+                       this.fVisitor = new JSResourceDeltaVisitor();
+               }
+               return this.fVisitor;
+       }
+       void saveIndexes() {
+               IndexManager indexManager = JavaModelManager.getJavaModelManager().getIndexManager();
+               IProject[] allProjects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
+               for (int j = 0; j < allProjects.length; j++) {
+                       if (!JsWebNature.hasNature(allProjects[j]) || !allProjects[j].isOpen()) {
+                               continue;
+                       }
+                       IPath jsModelWorkingLocation = JsSearchSupport.getInstance().getModelJspPluginWorkingLocation(allProjects[j]);
+                       File folder = new File(jsModelWorkingLocation.toOSString());
+                       String[] files = folder.list();
+                       String locay = ""; //$NON-NLS-1$
+                       try {
+                               for (int i = 0; i < files.length; i++) {
+                                       if (files[i].toLowerCase().endsWith(".index")) { //$NON-NLS-1$
+                                               locay = jsModelWorkingLocation.toString() + "/" + files[i]; //$NON-NLS-1$
+                                               // XXX: might not be the right container path, check IndexManager.indexLocations ?
+                                               indexManager.getIndex(allProjects[j].getFullPath(), new Path(locay), true, false);
+                                               // indexManager.saveIndex(index);
+                                       }
+                               }
+                       } catch (Exception e) {
+                               // we should be shutting down, want to shut down quietly
+                               if (JsIndexManager.DEBUG) {
+                                       e.printStackTrace();
+                               }
+                       }
+               }
+       }
+
+       /**
+        * A check to see if the OSGI framework is shutting down.
+        * 
+        * @return true if the System Bundle is stopped (ie. the framework is
+        *         shutting down)
+        */
+       boolean frameworkIsShuttingDown() {
+               // in the Framework class there's a note:
+               // set the state of the System Bundle to STOPPING.
+               // this must be done first according to section 4.19.2 from the OSGi
+               // R3 spec.
+               boolean shuttingDown = Platform.getBundle(OSGI_FRAMEWORK_ID).getState() == Bundle.STOPPING;
+               if (DEBUG && shuttingDown) {
+                       System.out.println("JSIndexManager: system is shutting down!"); //$NON-NLS-1$
+               }
+               return shuttingDown;
+       }
+
+
+       public void shutdown() {
+
+               // stop listening
+               ResourcesPlugin.getWorkspace().removeResourceChangeListener(jsResourceChangeListener);
+
+
+               // stop any searching
+               JsSearchSupport.getInstance().setCanceled(true);
+
+               // stop listening to jobs
+               Job.getJobManager().removeJobChangeListener(indexJobCoordinator);
+
+
+               int maxwait = 5000;
+               if (processFilesJob != null) {
+                       processFilesJob.cancel();
+               }
+               // attempt to make sure this indexing job is litterally
+               // done before continuing, since we are shutting down
+               waitTillNotRunning(maxwait, processFilesJob);
+
+               if (indexingJob != null) {
+                       indexingJob.cancel();
+               }
+               waitTillNotRunning(maxwait, processFilesJob);
+       }
+
+       private void waitTillNotRunning(int maxSeconds, Job job) {
+               int pauseTime = 10;
+               int maxtries = maxSeconds / pauseTime;
+               int count = 0;
+               while ((count++ < maxtries) && (job.getState() == Job.RUNNING)) {
+                       try {
+                               Thread.sleep(pauseTime);
+                               // System.out.println("count: " + count + " max: " +
+                               // maxtries);
+                       }
+                       catch (InterruptedException e) {
+                               Logger.logException(e);
+                       }
+               }
+       }
+
+       private class IndexJobCoordinator extends JobChangeAdapter {
+               
+               public void aboutToRun(IJobChangeEvent event) {
+                       Job jobToCoordinate = event.getJob();
+                       if (isJobToAvoid(jobToCoordinate)) {
+                               // job will be rescheduled when the job we
+                               // are avoiding (eg. build) is done
+                               getProcessFilesJob().cancel();
+                               //System.out.println("cancel:" + jobToCoordinate.getName());
+                       }
+               }
+
+               public void done(IJobChangeEvent event) {
+
+                       Job jobToCoordinate = event.getJob();
+                       if (isJobToAvoid(jobToCoordinate)) {
+                               if (getProcessFilesJob().getFiles().length > 0) {
+                                       getProcessFilesJob().schedule(500);
+                                       //System.out.println("schedule:" + jobToCoordinate.getName());
+                               }
+                                       
+
+                       }
+               }
+
+               private boolean isJobToAvoid(Job jobToCoordinate) {
+                       boolean result = false;
+                       if (jobToCoordinate.belongsTo(ResourcesPlugin.FAMILY_AUTO_BUILD) || jobToCoordinate.belongsTo(ResourcesPlugin.FAMILY_MANUAL_BUILD) || jobToCoordinate.belongsTo(ResourcesPlugin.FAMILY_AUTO_REFRESH)) {
+                               result = true;
+                       }
+                       return result;
+
+               }
+
+       }
+
+       private class JSResourceChangeListener implements IResourceChangeListener {
+
+
+               /**
+                * @see org.eclipse.core.resources.IResourceChangeListener#resourceChanged(org.eclipse.core.resources.IResourceChangeEvent)
+                */
+               public void resourceChanged(IResourceChangeEvent event) {
+
+                       if (isInitializing()) {
+                               return;
+                       }
+
+                       // ignore resource changes if already rebuilding
+                       if (getIndexState() == S_REBUILDING) {
+                               return;
+                       }
+                       // previously canceled, needs entire index rebuild
+                       if (getIndexState() == S_CANCELED) {
+                               // rebuildIndex();
+                               // just resume indexing
+                               getProcessFilesJob().schedule(500);
+                               //System.out.println("schedule: resource changed, previously canceled");
+                               return;
+                       }
+
+                       IResourceDelta delta = event.getDelta();
+                       if (delta != null) {
+                               // only care about adds or changes right now...
+                               int kind = delta.getKind();
+                               boolean added = (kind & IResourceDelta.ADDED) == IResourceDelta.ADDED;
+                               boolean changed = (kind & IResourceDelta.CHANGED) == IResourceDelta.CHANGED;
+                               if (added || changed) {
+
+                                       // only analyze the full (starting at root) delta
+                                       // hierarchy
+                                       if (delta.getFullPath().toString().equals("/")) { //$NON-NLS-1$
+                                               try {
+                                                       JSResourceDeltaVisitor v = getVisitor();
+                                                       // clear from last run
+                                                       v.reset();
+                                                       // count files, possibly do this in a job too...
+                                                       // don't include PHANTOM resources
+                                                       delta.accept(v, false);
+
+                                                       // process files from this delta
+                                                       IFile[] files = v.getFiles();
+                                                       if (files.length > 0) {
+                                                               /*
+                                                                * Job change listener should set back to
+                                                                * stable when finished
+                                                                */
+                                                               setUpdatingState();
+                                                               // processFiles(files);
+                                                               indexFiles(files);
+                                                       }
+                                               }
+                                               catch (CoreException e) {
+                                                       // need to set state here somehow, and reindex
+                                                       // otherwise index will be unreliable
+                                                       if (DEBUG) {
+                                                               Logger.logException(e);
+                                                       }
+                                               }
+                                               catch (Exception e) {
+                                                       // need to set state here somehow, and reindex
+                                                       // otherwise index will be unreliable
+                                                       if (DEBUG) {
+                                                               Logger.logException(e);
+                                                       }
+                                               }
+                                       }
+                               }
+
+                       }
+               }
+
+       }
+
+       IndexWorkspaceJob getIndexingJob() {
+               return indexingJob;
+       }
+
+       ProcessFilesJob getProcessFilesJob() {
+               return processFilesJob;
+       }
+
+       boolean isInitializing() {
+               return initializing;
+       }
+
+}
diff --git a/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/javascript/search/JsPathIndexer.java b/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/javascript/search/JsPathIndexer.java
new file mode 100644 (file)
index 0000000..b1ebaad
--- /dev/null
@@ -0,0 +1,119 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2009 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.web.core.javascript.search;
+
+import java.util.HashMap;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IResourceProxy;
+import org.eclipse.core.resources.IResourceProxyVisitor;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.wst.jsdt.core.search.IJavaScriptSearchScope;
+import org.eclipse.wst.jsdt.core.search.SearchPattern;
+import org.eclipse.wst.jsdt.web.core.internal.validation.Util;
+
+/**
+*
+
+* Provisional API: This class/interface is part of an interim API that is still under development and expected to
+* change significantly before reaching stability. It is being made available at this early stage to solicit feedback
+* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
+* (repeatedly) as the API evolves.
+*(copied from JSP)
+ * pa_TODO Still need to take into consideration:
+ *     - focus in workspace
+ *  - search pattern
+ * 
+ * @author pavery
+ */
+public class JsPathIndexer {
+
+       // for debugging
+       static final boolean DEBUG;
+       static {
+               
+               String value = Platform.getDebugOption("org.eclipse.wst.jsdt.web.core/debug/jssearch"); //$NON-NLS-1$
+               DEBUG = value != null && value.equalsIgnoreCase("true"); //$NON-NLS-1$
+
+       }
+       
+       // visitor that retrieves jsp project paths for all jsp files in the workspace
+       class JSPFileVisitor implements IResourceProxyVisitor {
+               // hash map forces only one of each file
+               private HashMap fPaths = new HashMap();
+               IJavaScriptSearchScope fScope = null;
+               SearchPattern fPattern = null;
+
+               public JSPFileVisitor(SearchPattern pattern, IJavaScriptSearchScope scope) {
+                       this.fPattern = pattern;
+                       this.fScope = scope;
+               }
+
+               public boolean visit(IResourceProxy proxy) throws CoreException {
+                       
+                       if(JsSearchSupport.getInstance().isCanceled()) {
+                               return false;
+                       }
+                       
+                       if (proxy.getType() == IResource.FILE) {
+
+                               //IContentType contentTypeJSP = Platform.getContentTypeManager().getContentType(ContentTypeIdForJSP.ContentTypeID_JSP);
+                               // https://w3.opensource.ibm.com/bugzilla/show_bug.cgi?id=3553
+                               // check this before description
+                               // check name before actually getting the file (less work)
+                               //if(contentTypeJSP.isAssociatedWith(proxy.getName())) {
+                               if(Util.isJsType(proxy.getName())){     
+                                       IFile file = (IFile)proxy.requestResource();
+                                       //IContentDescription contentDescription = file.getContentDescription();
+                                       //String ctId = null;
+//                                     if (contentDescription != null) {
+//                                             ctId = contentDescription.getContentType().getId();
+//                                     }
+                                       //if (ContentTypeIdForJSP.ContentTypeID_JSP.equals(ctId)) {
+                                       //if(Util.isJsType(file.getName())){
+                                               if (this.fScope.encloses(proxy.requestFullPath().toString())) {
+       
+                                                       if (DEBUG) {
+                                                               System.out.println("adding selected index path:" + file.getParent().getFullPath()); //$NON-NLS-1$
+                                                       }
+
+                                                       fPaths.put(file.getParent().getFullPath(), JsSearchSupport.getInstance().computeIndexLocation(file.getParent().getFullPath()));
+                                               }
+                                       //}
+                               }
+                               // don't search deeper for files
+                               return false;
+                       }
+                       return true;
+               }
+
+               public IPath[] getPaths() {
+                       return (IPath[]) fPaths.values().toArray(new IPath[fPaths.size()]);
+               }
+       }
+
+       public IPath[] getVisibleJspPaths(SearchPattern pattern, IJavaScriptSearchScope scope) {
+
+               JSPFileVisitor jspFileVisitor = new JSPFileVisitor(pattern, scope);
+               try {
+                       ResourcesPlugin.getWorkspace().getRoot().accept(jspFileVisitor, 0);
+               }
+               catch (CoreException e) {
+                       e.printStackTrace();
+               }
+               return jspFileVisitor.getPaths();
+       }
+}
+
diff --git a/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/javascript/search/JsSearchDocument.java b/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/javascript/search/JsSearchDocument.java
new file mode 100644 (file)
index 0000000..ce87bb1
--- /dev/null
@@ -0,0 +1,261 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.web.core.javascript.search;
+
+import java.io.IOException;
+
+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.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.wst.jsdt.core.search.SearchParticipant;
+import org.eclipse.wst.jsdt.web.core.internal.Logger;
+import org.eclipse.wst.jsdt.web.core.javascript.IJsTranslation;
+import org.eclipse.wst.jsdt.web.core.javascript.JsTranslationAdapter;
+import org.eclipse.wst.jsdt.web.core.javascript.JsTranslationAdapterFactory;
+import org.eclipse.wst.sse.core.StructuredModelManager;
+import org.eclipse.wst.sse.core.internal.exceptions.UnsupportedCharsetExceptionWithDetail;
+import org.eclipse.wst.sse.core.internal.provisional.IModelManager;
+import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
+
+/**
+*
+
+* Provisional API: This class/interface is part of an interim API that is still under development and expected to
+* change significantly before reaching stability. It is being made available at this early stage to solicit feedback
+* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
+* (repeatedly) as the API evolves.
+*(copied from JSP)
+ * Created with a .jsp file, but should appear to be a .java file for indexing
+ * and searching purposes. There are purposely few fields in this class, and
+ * those fields are lightweight since it's possible for many JSP search
+ * documents to exist in memory at one time (eg. after importing a project
+ * with a large number of JSP files)
+ * 
+ * @author pavery
+ */
+public class JsSearchDocument {
+
+       private String UNKNOWN_PATH = "**path unknown**"; //$NON-NLS-1$
+       private String fJSPPathString = UNKNOWN_PATH;
+       private String fCUPath = UNKNOWN_PATH;
+       private SearchParticipant fParticipant = null;
+       private long fLastModifiedStamp;
+       private char[] fCachedCharContents;
+       
+       /**
+        * @param file
+        * @param participant
+        * @throws CoreException
+        */
+       public JsSearchDocument(String filePath, SearchParticipant participant) {
+
+               this.fJSPPathString = filePath;
+               this.fParticipant = participant;
+       }
+
+       public SearchParticipant getParticipant() {
+               return this.fParticipant;
+       }
+
+       /**
+        * @see org.eclipse.jdt.core.search.SearchDocument#getCharContents()
+        */
+       public char[] getCharContents() {
+               
+               if((fCachedCharContents == null) || isDirty()) {
+                   IJsTranslation trans = getJSTranslation();    
+                   fCachedCharContents = trans != null ? trans.getJsText().toCharArray() : new char[0];
+                   fCUPath = trans.getJavaPath();
+               }
+               return fCachedCharContents;
+       }
+
+       public String getJavaText() {
+               return new String(getCharContents());
+       }
+
+       private IModelManager getModelManager() {
+               return StructuredModelManager.getModelManager();
+       }
+
+       /**
+        * It's not recommended for clients to hold on to this JSPTranslation
+        * since it's kind of large. If possible, hold on to the
+        * JSPSearchDocument, which is more of a lightweight proxy.
+        * 
+        * @return the JSPTranslation for the jsp file, or null if it's an
+        *         unsupported file.
+        */
+       public final IJsTranslation getJSTranslation() {
+               IJsTranslation translation = null;
+               IFile jspFile = getFile();
+               if (!JsSearchSupport.isJsp(jspFile)) {
+                       return translation;
+               }
+
+               IStructuredModel model = null;
+               try {
+                       // get existing model for read, then get document from it
+                       IModelManager modelManager = getModelManager();
+                       if (modelManager != null) {
+                               jspFile.refreshLocal(IResource.DEPTH_ZERO, new NullProgressMonitor());
+                               model = modelManager.getModelForRead(jspFile);
+                       }
+                       // handle unsupported
+                       if (model instanceof IDOMModel) {
+                               IDOMModel xmlModel = (IDOMModel)model;
+                               setupAdapterFactory(xmlModel);
+                               IDOMDocument doc = xmlModel.getDocument();
+                               JsTranslationAdapter adapter = (JsTranslationAdapter) doc.getAdapterFor(IJsTranslation.class);
+                               translation = adapter.getJsTranslation(false);
+                       }
+               }
+               catch (IOException e) {
+                       Logger.logException(e);
+               }
+               catch (CoreException e) {
+                       Logger.logException(e);
+               }
+               catch (UnsupportedCharsetExceptionWithDetail e) {
+                       // no need to log this. Just consider it an invalid file for our
+                       // purposes.
+                       // Logger.logException(e);
+               }
+               finally {
+                       if (model != null) {
+                               model.releaseFromRead();
+                       }
+               }
+               return translation;
+       }
+
+       /**
+        * add the factory for JSPTranslationAdapter here
+        * 
+        * @param sm
+        */
+       private void setupAdapterFactory(IStructuredModel sm) {
+               JsTranslationAdapterFactory.setupAdapterFactory(sm);
+       }
+
+       /**
+        * the path to the Java compilation unit
+        * 
+        * @see org.eclipse.jdt.core.search.SearchDocument#getPath()
+        */
+       public String getPath() {
+           // caching the path since it's expensive to get translation
+               // important that isDirty() check is second to cache modification stamp
+           if((this.fCUPath == null) || isDirty() || (this.fCUPath == UNKNOWN_PATH)) {
+               IJsTranslation trans = getJSTranslation();
+               if(trans != null) {
+                   this.fCUPath = trans.getJavaPath();
+                   // save since it's expensive to calculate again later
+                   fCachedCharContents = trans.getJsText().toCharArray();
+               }
+           }
+               return fCUPath != null ? fCUPath : UNKNOWN_PATH;
+       }
+
+//     public int getJspOffset(int javaOffset) {
+//             // copied from JSPTranslation
+//             int result = -1;
+//             int offsetInRange = 0;
+//             Position jspPos, javaPos = null;
+//             IJsTranslation trans = getJSPTranslation();
+//             if (trans != null) {
+//                     HashMap java2jspMap = trans.getJava2JspMap();
+//
+//                     // iterate all mapped java ranges
+//                     Iterator it = java2jspMap.keySet().iterator();
+//                     while (it.hasNext()) {
+//                             javaPos = (Position) it.next();
+//                             // need to count the last position as included
+//                             if (!javaPos.includes(javaOffset) && !(javaPos.offset + javaPos.length == javaOffset))
+//                                     continue;
+//
+//                             offsetInRange = javaOffset - javaPos.offset;
+//                             jspPos = (Position) java2jspMap.get(javaPos);
+//
+//                             if (jspPos != null)
+//                                     result = jspPos.offset + offsetInRange;
+//                             else {
+//                                     Logger.log(Logger.ERROR, "jspPosition was null!" + javaOffset); //$NON-NLS-1$
+//                             }
+//                             break;
+//                     }
+//             }
+//             return result;
+//     }
+
+       public IFile getFile() {
+               IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
+               IPath jspPath = new Path(this.fJSPPathString);
+               IFile jspFile = root.getFile(jspPath);
+               if (!jspFile.exists()) {
+                       // possibly outside workspace
+                       jspFile = root.getFileForLocation(jspPath);
+               }
+               return jspFile;
+       }
+
+       
+       private boolean isDirty() {
+               boolean modified = false;
+               IFile f = getFile();
+               if(f != null) {
+                       long currentStamp = f.getModificationStamp();
+                       if(currentStamp != fLastModifiedStamp) {
+                               modified = true;
+                       }
+                       fLastModifiedStamp = currentStamp;
+               }
+               return modified;
+       }
+       
+       public void release() {
+               // nothing to do now since JSPTranslation is created on the fly
+       }
+
+       /**
+        * for debugging
+        */
+       public String toString() {
+               return "[JSPSearchDocument:" + this.fJSPPathString + "]"; //$NON-NLS-1$ //$NON-NLS-2$ 
+       }
+
+       /*
+        * (non-Javadoc)
+        * 
+        * @see org.eclipse.jdt.core.search.SearchDocument#getEncoding()
+        */
+       public String getEncoding() {
+               // TODO Auto-generated method stub
+               return null;
+       }
+
+       /*
+        * (non-Javadoc)
+        * 
+        * @see org.eclipse.jdt.core.search.SearchDocument#getByteContents()
+        */
+       public byte[] getByteContents() {
+               // TODO Auto-generated method stub
+               return null;
+       }
+}
diff --git a/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/javascript/search/JsSearchParticipant.java b/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/javascript/search/JsSearchParticipant.java
new file mode 100644 (file)
index 0000000..88ac3a1
--- /dev/null
@@ -0,0 +1,117 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.web.core.javascript.search;
+
+import java.util.ArrayList;
+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.Platform;
+import org.eclipse.wst.jsdt.core.search.IJavaScriptSearchScope;
+import org.eclipse.wst.jsdt.core.search.SearchDocument;
+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.core.search.SearchRequestor;
+
+/**
+*
+
+* Provisional API: This class/interface is part of an interim API that is still under development and expected to
+* change significantly before reaching stability. It is being made available at this early stage to solicit feedback
+* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
+* (repeatedly) as the API evolves.
+*(copied from JSP)
+ * Integration of JSP w/ java search.
+ * 
+ * @author pavery
+ */
+public class JsSearchParticipant extends SearchParticipant {
+
+       // for debugging
+       private static final boolean DEBUG = calculateValue();
+
+       private static boolean calculateValue() {
+               String value = Platform.getDebugOption("org.eclipse.jst.jsp.core/debug/jspsearch"); //$NON-NLS-1$
+               boolean debug = (value != null) && value.equalsIgnoreCase("true"); //$NON-NLS-1$
+               return debug;
+       }
+
+       /**
+        * Important to never return null here or else Java search participation
+        * will break.
+        */
+       public SearchDocument getDocument(String documentPath) {
+               SearchDocument sDoc = JsSearchSupport.getInstance().getSearchDocument(documentPath);
+
+               if (sDoc == null) {
+                       // return a dummy doc here so search participation doesn't break
+                       return new NullSearchDocument(documentPath);
+               }
+               return sDoc;
+       }
+
+       public String getDescription() {
+               return "Embeded JavaScript"; //$NON-NLS-1$
+       }
+
+       public IPath[] selectIndexes(SearchPattern pattern, IJavaScriptSearchScope scope) {
+               JsPathIndexer indexer = new JsPathIndexer();
+               return indexer.getVisibleJspPaths(pattern, scope);
+       }
+
+       public void indexDocument(SearchDocument document, IPath indexPath) {
+               if (!(document instanceof JSDTSearchDocumentDelegate)) {
+                       return;
+               }
+
+               // use Java search indexing
+               SearchEngine.getDefaultSearchParticipant().indexDocument(document, indexPath);
+       }
+
+       public void locateMatches(SearchDocument[] indexMatches, SearchPattern pattern, IJavaScriptSearchScope scope, SearchRequestor requestor, IProgressMonitor monitor) throws CoreException {
+
+               if ((monitor != null) && monitor.isCanceled()) {
+                       return;
+               }
+
+               // filter out null matches
+               List filtered = new ArrayList();
+               SearchDocument match = null;
+               for (int i = 0; i < indexMatches.length; i++) {
+                       if (DEBUG) {
+                               System.out.println("found possible matching JavaSearchDocumentDelegate: " + indexMatches[i]); //$NON-NLS-1$
+                       }
+                       match = indexMatches[i];
+                       if (match != null) {
+                               // some matches may be null, or if the index is out of date,
+                               // the file may not even exist
+                               if ((match instanceof JSDTSearchDocumentDelegate) && ((JSDTSearchDocumentDelegate) match).getFile().exists()) {
+                                       filtered.add(match);
+                               }
+                       }
+               }
+
+               indexMatches = (SearchDocument[]) filtered.toArray(new SearchDocument[filtered.size()]);
+               SearchEngine.getDefaultSearchParticipant().locateMatches(indexMatches, pattern, scope, requestor, monitor);
+       }
+
+       /**
+        * @see org.eclipse.jdt.core.search.SearchParticipant#getDocument(org.eclipse.core.resources.IFile)
+        */
+       public SearchDocument getDocument(IFile file) {
+               // never gets called?
+               return null;
+       }
+}
diff --git a/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/javascript/search/JsSearchScope.java b/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/javascript/search/JsSearchScope.java
new file mode 100644 (file)
index 0000000..815e7f7
--- /dev/null
@@ -0,0 +1,124 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.web.core.javascript.search;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.eclipse.core.resources.IResourceProxy;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.wst.jsdt.core.IJavaScriptElement;
+import org.eclipse.wst.jsdt.core.search.IJavaScriptSearchScope;
+/**
+*
+
+* Provisional API: This class/interface is part of an interim API that is still under development and expected to
+* change significantly before reaching stability. It is being made available at this early stage to solicit feedback
+* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
+* (repeatedly) as the API evolves.
+*(copied from JSP)
+ * Used to constrain JSP/java search to certain paths and elements.
+ * @author pavery
+ */
+public class JsSearchScope implements IJavaScriptSearchScope {
+
+       private boolean fEnclosesAll = false;
+       private List fResourcePaths = null;
+       private List fJavaElements = null;
+
+       public JsSearchScope() {
+               // empty constructor just returns true for everything
+               // everything is in scope
+               this.fEnclosesAll = true;
+               init();
+       }
+
+       public JsSearchScope(String[] resourceStringPath) {
+               init();
+               fResourcePaths.addAll(Arrays.asList(resourceStringPath));
+       }
+
+       public JsSearchScope(IJavaScriptElement[] javaElement) {
+               init();
+               fJavaElements.addAll(Arrays.asList(javaElement));
+       }
+
+       private void init() {
+               this.fResourcePaths = new ArrayList();
+               this.fJavaElements = new ArrayList();
+       }
+
+       public boolean encloses(String resourcePathString) {
+
+               if (this.fEnclosesAll) {
+                       return true;
+               } else if (enclosesPath(resourcePathString)) {
+                       return true;
+               }
+
+               return false;
+       }
+
+       public boolean encloses(IJavaScriptElement element) {
+
+               // pa_TOD implement
+               if (this.fEnclosesAll) {
+                       return true;
+               }
+
+               return true;
+       }
+
+       public boolean encloses(IResourceProxy element) {
+
+               if (this.fEnclosesAll) {
+                       return true;
+               } else if (enclosesPath(element.requestFullPath().toOSString())) {
+                       return true;
+               }
+
+               return true;
+       }
+
+       public void addPath(String path) {
+               this.fResourcePaths.add(path);
+       }
+
+       public void addElement(IJavaScriptElement element) {
+               this.fJavaElements.add(element);
+       }
+
+       private boolean enclosesPath(String possible) {
+
+               String[] paths = (String[]) fResourcePaths.toArray(new String[fResourcePaths.size()]);
+               for (int i = 0; i < paths.length; i++) {
+                       if (possible.equals(paths[i])) {
+                               return true;
+                       }
+               }
+               return false;
+       }
+
+       public String getDescription() {
+
+               return "JavaScript Search Scope"; //$NON-NLS-1$
+       }
+
+       public IPath[] enclosingProjectsAndJars() {
+               return (IPath[]) fResourcePaths.toArray(new IPath[fResourcePaths.size()]);
+       }
+
+       public boolean shouldExclude(String container, String resourceName) {
+               /* auto gen */
+               return false;
+       }
+}
diff --git a/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/javascript/search/JsSearchSupport.java b/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/javascript/search/JsSearchSupport.java
new file mode 100644 (file)
index 0000000..ae94888
--- /dev/null
@@ -0,0 +1,594 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2011 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.web.core.javascript.search;
+
+import java.io.File;
+import java.util.zip.CRC32;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IWorkspaceRunnable;
+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.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.wst.jsdt.core.IJavaScriptElement;
+import org.eclipse.wst.jsdt.core.search.IJavaScriptSearchConstants;
+import org.eclipse.wst.jsdt.core.search.IJavaScriptSearchScope;
+import org.eclipse.wst.jsdt.core.search.SearchDocument;
+import org.eclipse.wst.jsdt.core.search.SearchEngine;
+import org.eclipse.wst.jsdt.core.search.SearchPattern;
+import org.eclipse.wst.jsdt.core.search.SearchRequestor;
+import org.eclipse.wst.jsdt.internal.core.JavaModelManager;
+import org.eclipse.wst.jsdt.web.core.internal.JsCoreMessages;
+import org.eclipse.wst.jsdt.web.core.internal.JsCorePlugin;
+import org.eclipse.wst.jsdt.web.core.internal.Logger;
+import org.eclipse.wst.jsdt.web.core.internal.validation.Util;
+import org.eclipse.wst.jsdt.web.core.javascript.JsNameManglerUtil;
+/**
+*
+
+* Provisional API: This class/interface is part of an interim API that is still under development and expected to
+* change significantly before reaching stability. It is being made available at this early stage to solicit feedback
+* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
+* (repeatedly) as the API evolves.
+*(copied from JSP)
+ * Central access to java indexing and search. All contact between JDT indexing
+ * and Searching should be done through here.
+ * 
+ * Clients should access the methods of this class via the single instance via
+ * <code>getInstance()</code>.
+ * 
+ * @author pavery
+ */
+public class JsSearchSupport {
+
+    // for debugging
+    static final boolean DEBUG;
+    static {
+       String value = Platform.getDebugOption("org.eclipse.wst.jsdt.web.core/debug/jssearch"); //$NON-NLS-1$
+               DEBUG = value != null && value.equalsIgnoreCase("true"); //$NON-NLS-1$
+    }
+
+    private static JsSearchSupport singleton = null;
+
+    private JsSearchParticipant fParticipant = null;
+
+    private IPath fJsPluginLocation = null;
+
+    // pa_TODO may be slow (esp for indexing entire workspace)
+    private final CRC32 fChecksumCalculator = new CRC32();
+
+    /** main cancel montior for all search support */
+    private final IProgressMonitor fMonitor = new NullProgressMonitor();
+
+    private JsSearchSupport() {
+        // force use of single instance
+    }
+
+    /**
+     * This operation ensures that the live resource's search markers show up in
+     * the open editor. It also allows the ability to pass in a ProgressMonitor
+     */
+    private class SearchJob extends Job implements IJavaScriptSearchConstants {
+
+        String fSearchText = ""; //$NON-NLS-1$
+
+        IJavaScriptSearchScope fScope = null;
+
+        int fSearchFor = FIELD;
+
+        int fLimitTo = ALL_OCCURRENCES;
+
+        int fMatchMode = SearchPattern.R_PATTERN_MATCH;
+
+       // boolean fIsCaseSensitive = false;
+
+        SearchRequestor fRequestor = null;
+
+        IJavaScriptElement fElement = null;
+
+        // constructor w/ java element
+        public SearchJob(IJavaScriptElement element, IJavaScriptSearchScope scope, SearchRequestor requestor) {
+
+            super(JsCoreMessages.JSP_Search + element.getElementName());
+            this.fElement = element;
+            this.fScope = scope;
+            this.fRequestor = requestor;
+        }
+
+        // constructor w/ search text
+        public SearchJob(String searchText, IJavaScriptSearchScope scope, int searchFor, int limitTo, int matchMode, boolean isCaseSensitive, SearchRequestor requestor) {
+
+            super(JsCoreMessages.JSP_Search + searchText);
+            this.fSearchText = searchText;
+            this.fScope = scope;
+            this.fSearchFor = searchFor;
+            this.fLimitTo = limitTo;
+            this.fMatchMode = matchMode;
+           // this.fIsCaseSensitive = isCaseSensitive;
+            this.fRequestor = requestor;
+        }
+
+        public IStatus run(IProgressMonitor jobMonitor) {
+
+            if ((jobMonitor != null) && jobMonitor.isCanceled()) {
+                               return Status.CANCEL_STATUS;
+                       }
+            if (JsSearchSupport.getInstance().isCanceled()) {
+                               return Status.CANCEL_STATUS;
+                       }
+
+            SearchPattern javaSearchPattern = null;
+            // if an element is available, use that to create search pattern
+            // (eg. LocalVariable)
+            // otherwise use the text and other paramters
+            if (this.fElement != null) {
+                               javaSearchPattern = SearchPattern.createPattern(this.fElement, this.fLimitTo);
+                       } else {
+                               javaSearchPattern = SearchPattern.createPattern(this.fSearchText, this.fSearchFor, this.fLimitTo, this.fMatchMode);
+                       }
+
+            if (javaSearchPattern != null) {
+                JsSearchParticipant[] participants = { getSearchParticipant() };
+                SearchEngine engine = new SearchEngine();
+                try {
+                    if (jobMonitor != null) {
+                                               jobMonitor.beginTask("", IProgressMonitor.UNKNOWN); //$NON-NLS-1$
+                                       }
+                    engine.search(javaSearchPattern, participants, this.fScope, this.fRequestor, jobMonitor);
+                } catch (CoreException e) {
+                    if (DEBUG) {
+                                               Logger.logException(e);
+                                       }
+                }
+                // non-CoreExceptions will permanently stall the Worker thread
+                catch (Exception e) {
+                    if (DEBUG) {
+                                               Logger.logException(e);
+                                       }
+                } finally {
+                    if (jobMonitor != null) {
+                                               jobMonitor.done();
+                                       }
+                }
+            }
+            return Status.OK_STATUS;
+        }
+    }
+
+    // end SearchJob
+    /**
+     * Runnable forces caller to wait until finished (as opposed to using a Job)
+     */
+    private class SearchRunnable implements IWorkspaceRunnable, IJavaScriptSearchConstants {
+
+        String fSearchText = ""; //$NON-NLS-1$
+
+        IJavaScriptSearchScope fScope = null;
+
+        int fSearchFor = FIELD;
+
+        int fLimitTo = ALL_OCCURRENCES;
+
+        int fMatchMode = SearchPattern.R_PATTERN_MATCH;
+
+        //boolean fIsCaseSensitive = false;
+
+        SearchRequestor fRequestor = null;
+
+        IJavaScriptElement fElement = null;
+
+        // constructor w/ java element
+        public SearchRunnable(IJavaScriptElement element, IJavaScriptSearchScope scope, SearchRequestor requestor) {
+
+            this.fElement = element;
+            this.fScope = scope;
+            this.fRequestor = requestor;
+        }
+
+        // constructor w/ search text
+//        public SearchRunnable(String searchText, IJavaScriptSearchScope scope, int searchFor, int limitTo, int matchMode, boolean isCaseSensitive, SearchRequestor requestor) {
+//
+//            this.fSearchText = searchText;
+//            this.fScope = scope;
+//            this.fSearchFor = searchFor;
+//            this.fLimitTo = limitTo;
+//            this.fMatchMode = matchMode;
+//            this.fIsCaseSensitive = isCaseSensitive;
+//            this.fRequestor = requestor;
+//        }
+
+        public void run(IProgressMonitor monitor) throws CoreException {
+
+            if ((monitor != null) && monitor.isCanceled()) {
+                               return;
+                       }
+            if (JsSearchSupport.getInstance().isCanceled()) {
+                               return;
+                       }
+
+            SearchPattern javaSearchPattern = null;
+            // if an element is available, use that to create search pattern
+            // (eg. LocalVariable)
+            // otherwise use the text and other paramters
+            if (this.fElement != null) {
+                               javaSearchPattern = SearchPattern.createPattern(this.fElement, fLimitTo);
+                       } else {
+                               javaSearchPattern = SearchPattern.createPattern(fSearchText, fSearchFor, fLimitTo, fMatchMode);
+                       }
+
+            if (javaSearchPattern != null) {
+                JsSearchParticipant[] participants = { getSearchParticipant() };
+                SearchEngine engine = new SearchEngine();
+                try {
+                    if (monitor != null) {
+                                               monitor.beginTask("", 0); //$NON-NLS-1$
+                                       }
+                    engine.search(javaSearchPattern, participants, fScope, fRequestor, monitor);
+                } catch (CoreException e) {
+                    Logger.logException(e);
+                    //throw e;
+                }
+                // non-CoreExceptions will permanently stall the Worker thread
+                catch (Exception e) {
+                    Logger.logException(e);
+                } finally {
+                    if (monitor != null) {
+                                               monitor.done();
+                                       }
+                }
+            }
+        }
+    }
+
+    // end SearchRunnable
+
+    /**
+     * Clients should access the methods of this class via the single instance
+     * via getInstance()
+     * 
+     * @return
+     */
+    public synchronized static JsSearchSupport getInstance() {
+
+        if (singleton == null) {
+                       singleton = new JsSearchSupport();
+               }
+        return singleton;
+    }
+
+    /**
+     * Utility method to check if a file is a jsp file (since this is done
+     * frequently)
+     */
+    public static boolean isJsp(IFile file) {
+       return Util.isJsType(file.getName());
+       // (pa) 20051025 removing deep content type check
+       // because this method is called frequently
+       // and IO is expensive
+//        boolean isJsp = false;
+//
+//        if (file != null && file.exists()) {
+//             
+//            IContentType contentTypeJSP = Platform.getContentTypeManager().getContentType(ContentTypeIdForJSP.ContentTypeID_JSP);
+//            // check this before description, it's less expensive
+//            if (contentTypeJSP.isAssociatedWith(file.getName())) {
+//             isJsp = true;
+//            }
+//        }
+//
+//        return isJsp;
+    }
+
+    /**
+     * schedules a search document representing this JSP file for indexing (by
+     * the java indexer)
+     * 
+     * @param file
+     *            the JSP file
+     * @return true if indexing was successful, false otherwise
+     * @throws CoreException
+     */
+    public SearchDocument addJspFile(IFile file) {
+        if (JsSearchSupport.getInstance().isCanceled() || !file.isAccessible()) {
+            return null;
+        }
+
+        if (DEBUG) {
+                       System.out.println("adding web page file:" + file.getFullPath()); //$NON-NLS-1$
+               }
+
+        // create
+        SearchDocument delegate = createSearchDocument(file);
+        // null if not a jsp file
+        if (delegate != null) {
+            try {
+                getSearchParticipant().scheduleDocumentIndexing(delegate, computeIndexLocation(file.getParent().getFullPath()));
+            } catch (Exception e) {
+                // ensure that failure here doesn't keep other documents from
+                // being indexed
+                // if peformed in a batch call (like JSPIndexManager)
+                if (DEBUG) {
+                                       e.printStackTrace();
+                               }
+            }
+        }
+
+        if (DEBUG) {
+                       System.out.println("scheduled" + delegate + "for indexing"); //$NON-NLS-1$ //$NON-NLS-2$
+               }
+
+        return delegate;
+    }
+    
+    /**
+     * Perform a java search w/ the given parameters. Runs in a background Job
+     * (results may still come in after this method call)
+     * 
+     * @param searchText
+     *            the string of text to search on
+     * @param searchFor
+     *            IJavaScriptSearchConstants.TYPE, METHOD, FIELD, PACKAGE, etc...
+     * @param limitTo
+     *            IJavaScriptSearchConstants.DECLARATIONS,
+     *            IJavaScriptSearchConstants.REFERENCES,
+     *            IJavaScriptSearchConstants.IMPLEMENTORS, or
+     *            IJavaScriptSearchConstants.ALL_OCCURRENCES
+     * @param matchMode
+     *            allow * wildcards or not
+     * @param isCaseSensitive
+     * @param requestor
+     *            passed in to accept search matches (and do "something" with
+     *            them)
+     */
+    public void search(String searchText, IJavaScriptSearchScope scope, int searchFor, int limitTo, int matchMode, boolean isCaseSensitive, SearchRequestor requestor) {
+
+        JsIndexManager.getInstance().rebuildIndexIfNeeded();
+
+        SearchJob job = new SearchJob(searchText, scope, searchFor, limitTo, matchMode, isCaseSensitive, requestor);
+        setCanceled(false);
+        job.setUser(true);
+        // https://w3.opensource.ibm.com/bugzilla/show_bug.cgi?id=5032
+        // pops up user operation blocked dialog if you perform a long search,
+        // then open a file because it locks the workspace
+        //job.setRule(ResourcesPlugin.getWorkspace().getRoot());
+        job.schedule();
+    }
+
+    /**
+     * Search for an IJavaScriptElement, constrained by the given parameters. Runs in
+     * a background Job (results may still come in after this method call)
+     * 
+     * @param element
+     * @param scope
+     * @param requestor
+     */
+    public void search(IJavaScriptElement element, IJavaScriptSearchScope scope, SearchRequestor requestor) {
+
+        JsIndexManager.getInstance().rebuildIndexIfNeeded();
+
+        SearchJob job = new SearchJob(element, scope, requestor);
+        setCanceled(false);
+        job.setUser(true);
+        // https://w3.opensource.ibm.com/bugzilla/show_bug.cgi?id=5032
+        //job.setRule(ResourcesPlugin.getWorkspace().getRoot());
+        job.schedule();
+    }
+
+    /**
+     * Search for an IJavaScriptElement, constrained by the given parameters. Runs in
+     * an IWorkspace runnable (results will be reported by the end of this
+     * method)
+     * 
+     * @param element
+     * @param scope
+     * @param requestor
+     */
+    public void searchRunnable(IJavaScriptElement element, IJavaScriptSearchScope scope, SearchRequestor requestor) {
+
+        JsIndexManager.getInstance().rebuildIndexIfNeeded();
+
+        SearchRunnable searchRunnable = new SearchRunnable(element, scope, requestor);
+        try {
+            setCanceled(false);
+            ResourcesPlugin.getWorkspace().run(searchRunnable, JsSearchSupport.getInstance().getProgressMonitor());
+        } catch (CoreException e) {
+            e.printStackTrace();
+        }
+    }
+
+    /**
+     * @param jsFile
+     * @return SearchDocument if the file is not null, exists, and is a JSP
+     *         file, otherwise null.
+     */
+    private SearchDocument createSearchDocument(IFile jsFile) {
+
+        JSDTSearchDocumentDelegate delegate = null;
+        if ((jsFile != null) && jsFile.exists() && isJsp(jsFile)) {
+
+            delegate = new JSDTSearchDocumentDelegate(new JsSearchDocument(jsFile.getFullPath().toString(), getSearchParticipant()));
+        }
+        return delegate;
+
+    }
+
+    /**
+     * Centralized place to access JSPSearchDocuments (used by
+     * JSPSearchParticipant and JSPSearchRequestor)
+     * 
+     * @param searchDocPath
+     * @param doc
+     * @return the JSPSearchDocument or null if one is not found
+     */
+    public SearchDocument getSearchDocument(String searchDocPath) {
+         
+        SearchDocument delegate = null;
+        IFile f = fileForCUPath(searchDocPath);
+        if (f != null) {
+            delegate = createSearchDocument(f);
+        } else {
+            // handle failure case... (file deleted maybe?)
+        }
+        return delegate;
+    }
+
+    /**
+     * Unmangles the searchDocPath and returns the corresponding JSP file.
+     * 
+     * @param searchDocPath
+     */
+    private IFile fileForCUPath(String searchDocPath) {
+    
+        String[] split = searchDocPath.split("/"); //$NON-NLS-1$
+        String classname = split[split.length - 1];
+
+        // ignore anything but .java matches (like .class binary matches)
+        if(!searchDocPath.endsWith(".js")) { //$NON-NLS-1$
+            return null;
+        }
+
+        String filePath = JsNameManglerUtil.unmangle(classname);
+       
+        // try absolute path
+        IFile f = ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(new Path(filePath));
+        // workspace relative then
+        if(f == null) {
+            // https://bugs.eclipse.org/bugs/show_bug.cgi?id=86009
+            // must have a project name as well
+            // which would mean >= 2 path segments
+            IPath path = new Path(filePath);
+            if(path.segmentCount() >= 2) {
+                f = ResourcesPlugin.getWorkspace().getRoot().getFile(path);
+            }
+        }
+        return f;
+    }
+
+    JsSearchParticipant getSearchParticipant() {
+
+        if (this.fParticipant == null) {
+                       this.fParticipant = new JsSearchParticipant();
+               }
+        return this.fParticipant;
+    }
+
+    // This is called from JSPPathIndexer
+    // pa_TODO
+    //how can we make sure participant indexLocations are updated at startup?
+    public final IPath computeIndexLocation(IPath containerPath) {
+
+        IPath indexLocation = null;
+        // we don't want to inadvertently use a JDT Index
+        // we want to be sure to use the Index from the JSP location
+        //Object obj = indexLocations.get(containerPath);
+        //if (obj != null) {
+        //    indexLocation = (String) obj;
+        //} else {
+            // create index entry
+            String pathString = containerPath.toOSString();
+            this.fChecksumCalculator.reset();
+            this.fChecksumCalculator.update(pathString.getBytes());
+            String fileName = Long.toString(this.fChecksumCalculator.getValue()) + ".index"; //$NON-NLS-1$
+            // this is the only difference from
+            // IndexManager#computeIndexLocation(...)
+            indexLocation = getModelJspPluginWorkingLocation().append(fileName);
+
+            // pa_TODO need to add to java path too, so JDT search support knows
+            // there should be a non internal way to do this.
+            // https://bugs.eclipse.org/bugs/show_bug.cgi?id=77564
+            JavaModelManager.getJavaModelManager().getIndexManager().indexLocations.put(containerPath, indexLocation);
+        //}
+        return indexLocation;
+    }
+       public IPath getModelJspPluginWorkingLocation(IProject project) {
+               if (project == null) {
+                       System.out.println("Null project"); //$NON-NLS-1$
+               }
+               IPath workingLocationFile = project.getWorkingLocation(JsCorePlugin.PLUGIN_ID).append("jssearch"); //$NON-NLS-1$
+               // ensure that it exists on disk
+               File folder = new File(workingLocationFile.toOSString());
+               if (!folder.isDirectory()) {
+                       try {
+                               folder.mkdir();
+                       } catch (SecurityException e) {
+                       }
+               }
+               return workingLocationFile;
+       }
+    // copied from JDT IndexManager
+    public IPath getModelJspPluginWorkingLocation() {
+
+        if (this.fJsPluginLocation != null) {
+                       return this.fJsPluginLocation;
+               }
+
+        // Append the folder name "jssearch" to keep the state location area cleaner
+        IPath stateLocation = JsCorePlugin.getDefault().getStateLocation().addTrailingSeparator().append("jssearch"); //$NON-NLS-1$
+
+        // pa_TODO workaround for
+        // https://bugs.eclipse.org/bugs/show_bug.cgi?id=62267
+        // copied from IndexManager
+        String device = stateLocation.getDevice();
+        if ((device != null) && (device.charAt(0) == '/')) {
+                       stateLocation = stateLocation.setDevice(device.substring(1));
+               }
+
+        // ensure that it exists on disk
+        File folder = new File(stateLocation.toOSString());
+               if (!folder.isDirectory()) {
+                       try {
+                               folder.mkdir();
+                       }
+                       catch (SecurityException e) {
+                       }
+               }
+
+        return this.fJsPluginLocation = stateLocation;
+    }
+
+    /**
+     * JSP Indexing and Search jobs check this
+     * 
+     * @return
+     */
+    public synchronized final void setCanceled(boolean cancel) {
+       //System.out.println("search support monitor" + fMonitor);
+        fMonitor.setCanceled(cancel);
+    }
+
+    /**
+     * JSP Indexing and Search jobs check this
+     * 
+     * @return
+     */
+    public synchronized final boolean isCanceled() {
+
+        return fMonitor.isCanceled();
+    }
+
+    /**
+     * JSP Indexing and Search jobs check this
+     * 
+     * @return
+     */
+    public final IProgressMonitor getProgressMonitor() {
+
+        return this.fMonitor;
+    }
+}
diff --git a/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/javascript/search/NullSearchDocument.java b/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/javascript/search/NullSearchDocument.java
new file mode 100644 (file)
index 0000000..7f1ce79
--- /dev/null
@@ -0,0 +1,49 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.web.core.javascript.search;
+
+import org.eclipse.wst.jsdt.core.search.SearchDocument;
+
+
+/**
+*
+
+* Provisional API: This class/interface is part of an interim API that is still under development and expected to
+* change significantly before reaching stability. It is being made available at this early stage to solicit feedback
+* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
+* (repeatedly) as the API evolves.
+*
+ * An empty servlet, safe for Java search participation
+ * 
+ * @author pavery
+ */
+public class NullSearchDocument extends SearchDocument {
+       
+       StringBuffer fEmptyServletBuffer = null;
+       
+       public NullSearchDocument(String documentPath) {
+               super(documentPath, new JsSearchParticipant()); 
+               this.fEmptyServletBuffer = new StringBuffer();
+       }
+       
+       public byte[] getByteContents() {
+               return this.fEmptyServletBuffer.toString().getBytes();
+       }
+       
+       public char[] getCharContents() {
+               return this.fEmptyServletBuffer.toString().toCharArray();
+       }
+       
+       public String getEncoding() {
+               return null;
+       }
+
+}
diff --git a/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/text/IJsPartitions.java b/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/text/IJsPartitions.java
new file mode 100644 (file)
index 0000000..44ab14b
--- /dev/null
@@ -0,0 +1,26 @@
+/*******************************************************************************
+ * 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.web.core.text;
+
+import org.eclipse.wst.html.core.text.IHTMLPartitions;
+
+/**
+*
+
+* Provisional API: This class/interface is part of an interim API that is still under development and expected to
+* change significantly before reaching stability. It is being made available at this early stage to solicit feedback
+* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
+* (repeatedly) as the API evolves.
+*/
+public interface IJsPartitions {
+       String HtmlJsPartition = IHTMLPartitions.SCRIPT;
+       //$NON-NLS-1$
+}
diff --git a/org.eclipse.wst.jsdt.web.ui.patch/.classpath b/org.eclipse.wst.jsdt.web.ui.patch/.classpath
new file mode 100644 (file)
index 0000000..2fbb7a2
--- /dev/null
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+       <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.4"/>
+       <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+       <classpathentry kind="src" path="src"/>
+       <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/org.eclipse.wst.jsdt.web.ui.patch/.project b/org.eclipse.wst.jsdt.web.ui.patch/.project
new file mode 100644 (file)
index 0000000..3b4c45d
--- /dev/null
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+       <name>org.eclipse.wst.jsdt.web.ui.patch</name>
+       <comment></comment>
+       <projects>
+       </projects>
+       <buildSpec>
+               <buildCommand>
+                       <name>org.eclipse.jdt.core.javabuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+               <buildCommand>
+                       <name>org.eclipse.pde.ManifestBuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+               <buildCommand>
+                       <name>org.eclipse.pde.SchemaBuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+       </buildSpec>
+       <natures>
+               <nature>org.eclipse.pde.PluginNature</nature>
+               <nature>org.eclipse.jdt.core.javanature</nature>
+       </natures>
+</projectDescription>
diff --git a/org.eclipse.wst.jsdt.web.ui.patch/.settings/org.eclipse.jdt.core.prefs b/org.eclipse.wst.jsdt.web.ui.patch/.settings/org.eclipse.jdt.core.prefs
new file mode 100644 (file)
index 0000000..4934385
--- /dev/null
@@ -0,0 +1,7 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.2
+org.eclipse.jdt.core.compiler.compliance=1.4
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=warning
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=warning
+org.eclipse.jdt.core.compiler.source=1.3
diff --git a/org.eclipse.wst.jsdt.web.ui.patch/META-INF/MANIFEST.MF b/org.eclipse.wst.jsdt.web.ui.patch/META-INF/MANIFEST.MF
new file mode 100644 (file)
index 0000000..5d2e317
--- /dev/null
@@ -0,0 +1,10 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Patch
+Bundle-SymbolicName: org.eclipse.wst.jsdt.web.ui.patch
+Bundle-Version: 1.0.401.qualifier
+Fragment-Host: org.eclipse.wst.jsdt.web.ui;bundle-version="1.0.401"
+Bundle-RequiredExecutionEnvironment: J2SE-1.4
+Eclipse-PatchFragment: true
+Bundle-ClassPath: library.jar,
+ .
diff --git a/org.eclipse.wst.jsdt.web.ui.patch/build.properties b/org.eclipse.wst.jsdt.web.ui.patch/build.properties
new file mode 100644 (file)
index 0000000..c378cc2
--- /dev/null
@@ -0,0 +1,4 @@
+bin.includes = META-INF/,\
+               library.jar
+source.library.jar = src/
+jars.compile.order = library.jar
diff --git a/org.eclipse.wst.jsdt.web.ui.patch/src/org/eclipse/wst/jsdt/web/ui/internal/hyperlink/ExternalFileEditorInput.java b/org.eclipse.wst.jsdt.web.ui.patch/src/org/eclipse/wst/jsdt/web/ui/internal/hyperlink/ExternalFileEditorInput.java
new file mode 100644 (file)
index 0000000..018c424
--- /dev/null
@@ -0,0 +1,174 @@
+/*******************************************************************************
+ * 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.web.ui.internal.hyperlink;
+
+import java.io.File;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IPathEditorInput;
+import org.eclipse.ui.IPersistableElement;
+import org.eclipse.ui.editors.text.ILocationProvider;
+import org.eclipse.ui.model.IWorkbenchAdapter;
+
+/**
+*
+
+* Provisional API: This class/interface is part of an interim API that is still under development and expected to
+* change significantly before reaching stability. It is being made available at this early stage to solicit feedback
+* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
+* (repeatedly) as the API evolves.
+*/
+class ExternalFileEditorInput implements IEditorInput, ILocationProvider {
+       // copies of this class exist in:
+       // org.eclipse.wst.xml.ui.internal.hyperlink
+       // org.eclipse.wst.html.ui.internal.hyperlink
+       // org.eclipse.wst.jsdt.web.ui.internal.hyperlink
+       /**
+        * The workbench adapter which simply provides the label.
+        * 
+        * @see Eclipse 3.1
+        */
+       private class WorkbenchAdapter implements IWorkbenchAdapter {
+               /*
+                * @see org.eclipse.ui.model.IWorkbenchAdapter#getChildren(java.lang.Object)
+                */
+               public Object[] getChildren(Object o) {
+                       return null;
+               }
+               
+               /*
+                * @see org.eclipse.ui.model.IWorkbenchAdapter#getImageDescriptor(java.lang.Object)
+                */
+               public ImageDescriptor getImageDescriptor(Object object) {
+                       return null;
+               }
+               
+               /*
+                * @see org.eclipse.ui.model.IWorkbenchAdapter#getLabel(java.lang.Object)
+                */
+               public String getLabel(Object o) {
+                       return ((ExternalFileEditorInput) o).getName();
+               }
+               
+               /*
+                * @see org.eclipse.ui.model.IWorkbenchAdapter#getParent(java.lang.Object)
+                */
+               public Object getParent(Object o) {
+                       return null;
+               }
+       }
+       private File fFile;
+       private WorkbenchAdapter fWorkbenchAdapter = new WorkbenchAdapter();
+       
+       public ExternalFileEditorInput(File file) {
+               super();
+               fFile = file;
+               fWorkbenchAdapter = new WorkbenchAdapter();
+       }
+       
+       /*
+        * @see java.lang.Object#equals(java.lang.Object)
+        */
+       
+       public boolean equals(Object o) {
+               if (o == this) {
+                       return true;
+               }
+               if (o instanceof ExternalFileEditorInput) {
+                       ExternalFileEditorInput input = (ExternalFileEditorInput) o;
+                       return fFile.equals(input.fFile);
+               }
+               if (o instanceof IPathEditorInput) {
+                       IPathEditorInput input = (IPathEditorInput) o;
+                       return getPath().equals(input.getPath());
+               }
+               return false;
+       }
+       
+       /*
+        * @see org.eclipse.ui.IEditorInput#exists()
+        */
+       public boolean exists() {
+               return fFile.exists();
+       }
+       
+       /*
+        * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
+        */
+       public Object getAdapter(Class adapter) {
+               if (ILocationProvider.class.equals(adapter)) {
+                       return this;
+               }
+               if (IWorkbenchAdapter.class.equals(adapter)) {
+                       return fWorkbenchAdapter;
+               }
+               return Platform.getAdapterManager().getAdapter(this, adapter);
+       }
+       
+       /*
+        * @see org.eclipse.ui.IEditorInput#getImageDescriptor()
+        */
+       public ImageDescriptor getImageDescriptor() {
+               return null;
+       }
+       
+       /*
+        * @see org.eclipse.ui.IEditorInput#getName()
+        */
+       public String getName() {
+               return fFile.getName();
+       }
+       
+       /*
+        * @see org.eclipse.ui.IPathEditorInput#getPath()
+        * @since 3.1
+        */
+       public IPath getPath() {
+               return Path.fromOSString(fFile.getAbsolutePath());
+       }
+       
+       /*
+        * @see org.eclipse.ui.editors.text.ILocationProvider#getPath(java.lang.Object)
+        */
+       public IPath getPath(Object element) {
+               if (element instanceof ExternalFileEditorInput) {
+                       ExternalFileEditorInput input = (ExternalFileEditorInput) element;
+                       return Path.fromOSString(input.fFile.getAbsolutePath());
+               }
+               return null;
+       }
+       
+       /*
+        * @see org.eclipse.ui.IEditorInput#getPersistable()
+        */
+       public IPersistableElement getPersistable() {
+               return null;
+       }
+       
+       /*
+        * @see org.eclipse.ui.IEditorInput#getToolTipText()
+        */
+       public String getToolTipText() {
+               return fFile.getAbsolutePath();
+       }
+       
+       /*
+        * @see java.lang.Object#hashCode()
+        */
+       
+       public int hashCode() {
+               return fFile.hashCode();
+       }
+}
diff --git a/org.eclipse.wst.jsdt.web.ui.patch/src/org/eclipse/wst/jsdt/web/ui/internal/hyperlink/ExternalFileHyperlink.java b/org.eclipse.wst.jsdt.web.ui.patch/src/org/eclipse/wst/jsdt/web/ui/internal/hyperlink/ExternalFileHyperlink.java
new file mode 100644 (file)
index 0000000..d8905ef
--- /dev/null
@@ -0,0 +1,79 @@
+/*******************************************************************************
+ * 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.web.ui.internal.hyperlink;
+
+import java.io.File;
+
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.hyperlink.IHyperlink;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.ui.IEditorDescriptor;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.ide.IDE;
+import org.eclipse.wst.html.ui.internal.HTMLUIMessages;
+import org.eclipse.wst.jsdt.web.ui.internal.Logger;
+
+/**
+*
+
+* Provisional API: This class/interface is part of an interim API that is still under development and expected to
+* change significantly before reaching stability. It is being made available at this early stage to solicit feedback
+* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
+* (repeatedly) as the API evolves.
+*/
+class ExternalFileHyperlink implements IHyperlink {
+       // copies of this class exist in:
+       // org.eclipse.wst.xml.ui.internal.hyperlink
+       // org.eclipse.wst.html.ui.internal.hyperlink
+       // org.eclipse.wst.jsdt.web.ui.internal.hyperlink
+       private File fHyperlinkFile;
+       private IRegion fHyperlinkRegion;
+       
+       public ExternalFileHyperlink(IRegion region, File file) {
+               fHyperlinkFile = file;
+               fHyperlinkRegion = region;
+       }
+       
+       public IRegion getHyperlinkRegion() {
+               return fHyperlinkRegion;
+       }
+       
+       public String getHyperlinkText() {
+               String path = fHyperlinkFile.getPath();
+               if (path.length() > 60) {
+                       path = path.substring(0, 25) + "..." + path.substring(path.length() - 25, path.length());
+               }
+               return NLS.bind(HTMLUIMessages.Open, path);
+       }
+       
+       public String getTypeLabel() {
+               return null;
+       }
+       
+       public void open() {
+               if (fHyperlinkFile != null) {
+                       IEditorInput input = new ExternalFileEditorInput(fHyperlinkFile);
+                       IEditorDescriptor descriptor;
+                       try {
+                               descriptor = IDE.getEditorDescriptor(input.getName(), true);
+                               if (descriptor != null) {
+                                       IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
+                                       IDE.openEditor(page, input, descriptor.getId(), true);
+                               }
+                       } catch (PartInitException e) {
+                               Logger.log(Logger.WARNING_DEBUG, e.getMessage(), e);
+                       }
+               }
+       }
+}
diff --git a/org.eclipse.wst.jsdt.web.ui.patch/src/org/eclipse/wst/jsdt/web/ui/internal/hyperlink/JSDTHyperlink.java b/org.eclipse.wst.jsdt.web.ui.patch/src/org/eclipse/wst/jsdt/web/ui/internal/hyperlink/JSDTHyperlink.java
new file mode 100644 (file)
index 0000000..2dbb3fd
--- /dev/null
@@ -0,0 +1,81 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2011 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.web.ui.internal.hyperlink;
+
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.hyperlink.IHyperlink;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.wst.html.ui.internal.HTMLUIMessages;
+import org.eclipse.wst.jsdt.core.IJavaScriptElement;
+import org.eclipse.wst.jsdt.internal.ui.actions.ActionMessages;
+import org.eclipse.wst.jsdt.ui.JavaScriptUI;
+import org.eclipse.wst.jsdt.web.ui.internal.Logger;
+/**
+*
+
+* Provisional API: This class/interface is part of an interim API that is still under development and expected to
+* change significantly before reaching stability. It is being made available at this early stage to solicit feedback
+* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
+* (repeatedly) as the API evolves.
+*/
+class JSDTHyperlink implements IHyperlink {
+       private IJavaScriptElement fElement;
+       private IRegion fRegion;
+       
+       public JSDTHyperlink(IRegion region, IJavaScriptElement element) {
+               fRegion = region;
+               fElement = element;
+       }
+       
+       /*
+        * (non-Javadoc)
+        * 
+        * @see org.eclipse.jface.text.hyperlink.IHyperlink#getHyperlinkRegion()
+        */
+       public IRegion getHyperlinkRegion() {
+               return fRegion;
+       }
+       
+       /*
+        * (non-Javadoc)
+        * 
+        * @see org.eclipse.jface.text.hyperlink.IHyperlink#getHyperlinkText()
+        */
+       public String getHyperlinkText() {
+               return fElement != null ? NLS.bind(HTMLUIMessages.Open, fElement.getDisplayName()) : ActionMessages.OpenAction_declaration_label;
+       }
+       
+       /*
+        * (non-Javadoc)
+        * 
+        * @see org.eclipse.jface.text.hyperlink.IHyperlink#getTypeLabel()
+        */
+       public String getTypeLabel() {
+               return null;
+       }
+       
+       /*
+        * (non-Javadoc)
+        * 
+        * @see org.eclipse.jface.text.hyperlink.IHyperlink#open()
+        */
+       public void open() {
+               try {
+                       IEditorPart editor = JavaScriptUI.openInEditor(fElement);
+                       if (editor != null) {
+                               JavaScriptUI.revealInEditor(editor, fElement);
+                       }
+               } catch (Exception e) {
+                       Logger.log(Logger.WARNING_DEBUG, e.getMessage(), e);
+               }
+       }
+}
diff --git a/org.eclipse.wst.jsdt.web.ui.patch/src/org/eclipse/wst/jsdt/web/ui/internal/hyperlink/JSDTHyperlinkDetector.java b/org.eclipse.wst.jsdt.web.ui.patch/src/org/eclipse/wst/jsdt/web/ui/internal/hyperlink/JSDTHyperlinkDetector.java
new file mode 100644 (file)
index 0000000..debd073
--- /dev/null
@@ -0,0 +1,268 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2009 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.web.ui.internal.hyperlink;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.ITextViewer;
+import org.eclipse.jface.text.Region;
+import org.eclipse.jface.text.hyperlink.AbstractHyperlinkDetector;
+import org.eclipse.jface.text.hyperlink.IHyperlink;
+import org.eclipse.wst.jsdt.core.IClassFile;
+import org.eclipse.wst.jsdt.core.IField;
+import org.eclipse.wst.jsdt.core.IFunction;
+import org.eclipse.wst.jsdt.core.IJavaScriptElement;
+import org.eclipse.wst.jsdt.core.IJavaScriptUnit;
+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.JavaScriptModelException;
+import org.eclipse.wst.jsdt.internal.core.JavaElement;
+import org.eclipse.wst.jsdt.web.core.javascript.IJsTranslation;
+import org.eclipse.wst.jsdt.web.core.javascript.JsTranslationAdapter;
+import org.eclipse.wst.jsdt.web.ui.internal.Logger;
+import org.eclipse.wst.sse.core.StructuredModelManager;
+import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
+
+/**
+*
+
+* Provisional API: This class/interface is part of an interim API that is still under development and expected to
+* change significantly before reaching stability. It is being made available at this early stage to solicit feedback
+* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
+* (repeatedly) as the API evolves.
+*/
+public class JSDTHyperlinkDetector extends AbstractHyperlinkDetector {
+       private IHyperlink createHyperlink(IJavaScriptElement element, IRegion region, IDocument document) {
+               IHyperlink link = null;
+               if (region != null) {
+                       // open local variable in the JSP file...
+                       if (element instanceof ISourceReference) {
+                               IFile file = null;
+                               IPath outsidePath = null;
+                               int jspOffset = 0;
+                               IStructuredModel sModel = null;
+                               // try to locate the file in the workspace
+                               try {
+                                       sModel = StructuredModelManager.getModelManager().getExistingModelForRead(document);
+                                       if (sModel != null) {
+                                               //URIResolver resolver = sModel.getResolver();
+                                               //if (resolver != null) {
+                                               //      String uriString = resolver.getFileBaseLocation();
+                                               String uriString = sModel.getBaseLocation();
+                                                       file = getFile(uriString);
+                                       //      }
+                                       }
+                               } finally {
+                                       if (sModel != null) {
+                                               sModel.releaseFromRead();
+                                       }
+                               }
+                               // get Java range, translate coordinate to JSP
+                               try {
+                                       ISourceRange range = null;
+                                       IJsTranslation jspTranslation = getJsTranslation(document);
+                                       if (jspTranslation != null) {
+                                               // link to local variable definitions
+                                               if (element instanceof ILocalVariable) {
+                                                       range = ((ILocalVariable) element).getNameRange();
+                                                       IJavaScriptElement unit=((ILocalVariable) element).getParent();
+                                                       IJavaScriptUnit myUnit = jspTranslation.getCompilationUnit();
+                                                       
+                                                       while(!(unit instanceof IJavaScriptUnit || unit instanceof IClassFile || unit==null)) {
+                                                               unit = ((JavaElement) unit).getParent();
+                                                       }
+                                                       if(unit instanceof IJavaScriptUnit) {
+                                                               IJavaScriptUnit cu = (IJavaScriptUnit)unit;
+                                                               if(cu!=myUnit) {
+                                                                       file = getFile(cu.getPath().toString());
+                                                                       if(file==null) {
+                                                                               outsidePath = cu.getPath();
+                                                                       }
+                                                               }
+                                                       }else if(unit instanceof IClassFile) {
+                                                               IClassFile cu = (IClassFile)unit;
+                                                               if(cu!=myUnit) {
+                                                                       file = getFile(cu.getPath().toString());
+                                                                       if(file==null) {
+                                                                               outsidePath = cu.getPath();
+                                                                       }
+                                                               }
+                                                       }
+                                                       
+                                               }
+                                               // linking to fields of the same compilation unit
+                                               else if (element.getElementType() == IJavaScriptElement.FIELD) {
+                                                       Object cu = ((IField) element).getJavaScriptUnit();
+                                                       if (cu != null && cu.equals(jspTranslation.getCompilationUnit())) {
+                                                               // Fixed bug for RM 8591
+                                                               // range = ((ISourceReference) element).getSourceRange();
+                                                               range = ((IMember) element).getNameRange();
+                                                       }
+                                               }
+                                               // linking to methods of the same compilation unit
+                                               else if (element.getElementType() == IJavaScriptElement.METHOD) {
+                                                       Object cu = ((IFunction) element).getJavaScriptUnit();
+                                                       if (cu != null && cu.equals(jspTranslation.getCompilationUnit())) {
+                                                               // Fixed bug for RM 8591
+                                                               // range = ((ISourceReference) element).getSourceRange();
+                                                               range = ((IMember) element).getNameRange();
+                                                       }
+                                               }
+                                       }
+                                       if (range != null && file != null) {
+                                               jspOffset = range.getOffset();
+                                               if (jspOffset >= 0) {
+                                                       link = new WorkspaceFileHyperlink(region, file, new Region(jspOffset, range.getLength()));
+                                               }
+                                       }else if (range!=null && outsidePath!=null) {
+                                               jspOffset = range.getOffset();
+                                               if (jspOffset >= 0) {
+                                                       link = new ExternalFileHyperlink(region,outsidePath.toFile());
+                                               }
+                                       }
+                               } catch (JavaScriptModelException jme) {
+                                       Logger.log(Logger.WARNING_DEBUG, jme.getMessage(), jme);
+                               }
+                       }
+                       if (link == null) {
+                               link = new JSDTHyperlink(region, element);
+                       }
+               }
+               return link;
+       }
+       
+       /*
+        * (non-Javadoc)
+        * 
+        * @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) {
+               List hyperlinks = new ArrayList(0);
+               if (region != null && textViewer != null) {
+                       IDocument document = textViewer.getDocument();
+                       IJsTranslation jsTranslation = getJsTranslation(document);
+                       if (jsTranslation != null) {
+                               IJavaScriptElement[] elements = jsTranslation.getElementsFromJsRange(region.getOffset(), region.getOffset() + region.getLength());
+                               if (elements != null && elements.length > 0) {
+                                       // create a hyperlink for each JavaScript element
+                                       for (int i = 0; i < elements.length; ++i) {
+                                               IJavaScriptElement element = elements[i];
+                                               // find hyperlink range for Java element
+                                               IRegion hyperlinkRegion = selectWord(document, region.getOffset());
+                                               IHyperlink link = createHyperlink(element, hyperlinkRegion, document);
+                                               if (link != null) {
+                                                       hyperlinks.add(link);
+                                               }
+                                       }
+                               }
+                       }
+               }
+               if (hyperlinks.size() == 0) {
+                       return null;
+               }
+               return (IHyperlink[]) hyperlinks.toArray(new IHyperlink[0]);
+       }
+       
+       /**
+        * Returns an IFile from the given uri if possible, null if cannot find file
+        * from uri.
+        * 
+        * @param fileString
+        *            file system path
+        * @return returns IFile if fileString exists in the workspace
+        */
+       private IFile getFile(String fileString) {
+               IFile file = null;
+               if (fileString != null) {
+                       IResource resource  = ResourcesPlugin.getWorkspace().getRoot().findMember(fileString);
+                       if(resource!=null && resource instanceof IFile) {
+                               file = (IFile)resource;
+                       }
+               }
+               return file;
+       }
+       
+       /**
+        * Get JSP translation object
+        * 
+        * @return JSPTranslation if one exists, null otherwise
+        */
+       private IJsTranslation getJsTranslation(IDocument document) {
+               IJsTranslation translation = null;
+               IDOMModel xmlModel = null;
+               try {
+                       xmlModel = (IDOMModel) StructuredModelManager.getModelManager().getExistingModelForRead(document);
+                       if (xmlModel != null) {
+                               IDOMDocument xmlDoc = xmlModel.getDocument();
+                               JsTranslationAdapter adapter = (JsTranslationAdapter) xmlDoc.getAdapterFor(IJsTranslation.class);
+                               if (adapter != null) {
+                                       translation = adapter.getJsTranslation(true);
+                               }
+                       }
+               } finally {
+                       if (xmlModel != null) {
+                               xmlModel.releaseFromRead();
+                       }
+               }
+               return translation;
+       }
+       
+       /**
+        * Java always selects word when defining region
+        * 
+        * @param document
+        * @param anchor
+        * @return IRegion
+        */
+       private IRegion selectWord(IDocument document, int anchor) {
+               try {
+                       int offset = anchor;
+                       char c;
+                       while (offset >= 0) {
+                               c = document.getChar(offset);
+                               if (!Character.isJavaIdentifierPart(c)) {
+                                       break;
+                               }
+                               --offset;
+                       }
+                       int start = offset;
+                       offset = anchor;
+                       int length = document.getLength();
+                       while (offset < length) {
+                               c = document.getChar(offset);
+                               if (!Character.isJavaIdentifierPart(c)) {
+                                       break;
+                               }
+                               ++offset;
+                       }
+                       int end = offset;
+                       if (start == end) {
+                               return new Region(start, 0);
+                       }
+                       return new Region(start + 1, end - start - 1);
+               } catch (BadLocationException x) {
+                       return null;
+               }
+       }
+}
diff --git a/org.eclipse.wst.jsdt.web.ui.patch/src/org/eclipse/wst/jsdt/web/ui/internal/hyperlink/WorkspaceFileHyperlink.java b/org.eclipse.wst.jsdt.web.ui.patch/src/org/eclipse/wst/jsdt/web/ui/internal/hyperlink/WorkspaceFileHyperlink.java
new file mode 100644 (file)
index 0000000..da1ee7c
--- /dev/null
@@ -0,0 +1,95 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2009 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.web.ui.internal.hyperlink;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.hyperlink.IHyperlink;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.ide.IDE;
+import org.eclipse.ui.texteditor.ITextEditor;
+import org.eclipse.wst.html.ui.internal.HTMLUIMessages;
+import org.eclipse.wst.jsdt.web.ui.internal.Logger;
+import org.eclipse.wst.sse.ui.StructuredTextEditor;
+
+class WorkspaceFileHyperlink implements IHyperlink {
+       // copies of this class exist in:
+       // org.eclipse.wst.xml.ui.internal.hyperlink
+       // org.eclipse.wst.html.ui.internal.hyperlink
+       // org.eclipse.wst.jsdt.web.ui.internal.hyperlink
+       private IFile fFile;
+       private IRegion fHighlightRange;
+       private IRegion fRegion;
+       
+       public WorkspaceFileHyperlink(IRegion region, IFile file) {
+               fRegion = region;
+               fFile = file;
+       }
+       
+       public WorkspaceFileHyperlink(IRegion region, IFile file, IRegion range) {
+               fRegion = region;
+               fFile = file;
+               fHighlightRange = range;
+       }
+       
+       public IRegion getHyperlinkRegion() {
+               return fRegion;
+       }
+       
+       /*
+        * (non-Javadoc)
+        * 
+        * @see org.eclipse.jface.text.hyperlink.IHyperlink#getHyperlinkText()
+        */
+       public String getHyperlinkText() {
+               String path = fFile.getFullPath().toString();
+               if (path.length() > 60) {
+                       path = path.substring(0, 25) + "..." + path.substring(path.length() - 25, path.length());
+               }
+               return NLS.bind(HTMLUIMessages.Open, path);
+       }
+       
+       /*
+        * (non-Javadoc)
+        * 
+        * @see org.eclipse.jface.text.hyperlink.IHyperlink#getTypeLabel()
+        */
+       public String getTypeLabel() {
+               // TODO Auto-generated method stub
+               return null;
+       }
+       
+       public void open() {
+               if (fFile != null && fFile.exists()) {
+                       try {
+                               IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
+                               IEditorPart editor = IDE.openEditor(page, fFile, true);
+                               // highlight range in editor if possible
+                               
+                               // Fixed bug for RM 8591
+                               if (fHighlightRange != null && editor instanceof ITextEditor) {
+                                       ((ITextEditor) editor).selectAndReveal(fHighlightRange.getOffset(), fHighlightRange.getLength());
+                               } else {
+                                       Object ste = editor.getAdapter(StructuredTextEditor.class);
+                                       if (fHighlightRange != null && ste instanceof ITextEditor) {
+                                               ((ITextEditor) ste).selectAndReveal(fHighlightRange.getOffset(), fHighlightRange.getLength());
+                                       }
+                               }
+                       } catch (PartInitException pie) {
+                               Logger.log(Logger.WARNING_DEBUG, pie.getMessage(), pie);
+                       }
+               }
+       }
+}
diff --git a/org.eclipse.wst.jsdt.web.ui.patch/src/org/eclipse/wst/jsdt/web/ui/internal/hyperlink/XMLHyperlinkDetector.java b/org.eclipse.wst.jsdt.web.ui.patch/src/org/eclipse/wst/jsdt/web/ui/internal/hyperlink/XMLHyperlinkDetector.java
new file mode 100644 (file)
index 0000000..bf603d0
--- /dev/null
@@ -0,0 +1,502 @@
+/*******************************************************************************
+ * 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.web.ui.internal.hyperlink;
+
+import java.io.File;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.List;
+
+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.jface.text.IDocument;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.ITextViewer;
+import org.eclipse.jface.text.Region;
+import org.eclipse.jface.text.hyperlink.IHyperlink;
+import org.eclipse.jface.text.hyperlink.IHyperlinkDetector;
+import org.eclipse.jface.text.hyperlink.URLHyperlink;
+import org.eclipse.wst.common.uriresolver.internal.provisional.URIResolverPlugin;
+import org.eclipse.wst.sse.core.StructuredModelManager;
+import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
+import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion;
+import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion;
+import org.eclipse.wst.sse.core.utils.StringUtils;
+import org.eclipse.wst.xml.core.internal.contentmodel.CMAttributeDeclaration;
+import org.eclipse.wst.xml.core.internal.contentmodel.CMDataType;
+import org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration;
+import org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQuery;
+import org.eclipse.wst.xml.core.internal.contentmodel.util.DOMNamespaceHelper;
+import org.eclipse.wst.xml.core.internal.modelquery.ModelQueryUtil;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMAttr;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
+import org.w3c.dom.Attr;
+import org.w3c.dom.DocumentType;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+
+import com.ibm.icu.util.StringTokenizer;
+
+/**
+*
+
+* Provisional API: This class/interface is part of an interim API that is still under development and expected to
+* change significantly before reaching stability. It is being made available at this early stage to solicit feedback
+* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
+* (repeatedly) as the API evolves.
+*/
+public class XMLHyperlinkDetector implements IHyperlinkDetector {
+       // copies of this class exist in:
+       // org.eclipse.wst.xml.ui.internal.hyperlink
+       // org.eclipse.wst.html.ui.internal.hyperlink
+       // org.eclipse.wst.jsdt.web.ui.internal.hyperlink
+       private final String HTTP_PROTOCOL = "http://";//$NON-NLS-1$
+       private final String NO_NAMESPACE_SCHEMA_LOCATION = "noNamespaceSchemaLocation"; //$NON-NLS-1$
+       private final String SCHEMA_LOCATION = "schemaLocation"; //$NON-NLS-1$
+       private final String XMLNS = "xmlns"; //$NON-NLS-1$
+       private final String XSI_NAMESPACE_URI = "http://www.w3.org/2001/XMLSchema-instance"; //$NON-NLS-1$
+       
+       /**
+        * Create the appropriate hyperlink
+        * 
+        * @param uriString
+        * @param hyperlinkRegion
+        * @return IHyperlink
+        */
+       private IHyperlink createHyperlink(String uriString, IRegion hyperlinkRegion, IDocument document, Node node) {
+               IHyperlink link = null;
+               if (isHttp(uriString)) {
+                       link = new URLHyperlink(hyperlinkRegion, uriString);
+               } else {
+                       // try to locate the file in the workspace
+                       File systemFile = getFileFromUriString(uriString);
+                       if (systemFile != null) {
+                               String systemPath = systemFile.getPath();
+                               IFile file = getFile(systemPath);
+                               if (file != null) {
+                                       // this is a WorkspaceFileHyperlink since file exists in
+                                       // workspace
+                                       link = new WorkspaceFileHyperlink(hyperlinkRegion, file);
+                               } else {
+                                       // this is an ExternalFileHyperlink since file does not
+                                       // exist in workspace
+                                       link = new ExternalFileHyperlink(hyperlinkRegion, systemFile);
+                               }
+                       }
+               }
+               return link;
+       }
+       
+       public IHyperlink[] detectHyperlinks(ITextViewer textViewer, IRegion region, boolean canShowMultipleHyperlinks) {
+               // for now, only capable of creating 1 hyperlink
+               List hyperlinks = new ArrayList(0);
+               if (region != null && textViewer != null) {
+                       IDocument document = textViewer.getDocument();
+                       Node currentNode = getCurrentNode(document, region.getOffset());
+                       if (currentNode != null) {
+                               String uriString = null;
+                               if (currentNode.getNodeType() == Node.DOCUMENT_TYPE_NODE) {
+                                       // doctype nodes
+                                       uriString = getURIString(currentNode, document);
+                               } else if (currentNode.getNodeType() == Node.ELEMENT_NODE) {
+                                       // element nodes
+                                       Attr currentAttr = getCurrentAttrNode(currentNode, region.getOffset());
+                                       if (currentAttr != null) {
+                                               // try to find link for current attribute
+                                               // resolve attribute value
+                                               uriString = getURIString(currentAttr, document);
+                                               // verify validity of uri string
+                                               if (uriString == null || !isValidURI(uriString)) {
+                                                       // reset current attribute
+                                                       currentAttr = null;
+                                               }
+                                       }
+                                       if (currentAttr == null) {
+                                               // try to find a linkable attribute within element
+                                               currentAttr = getLinkableAttr((Element) currentNode);
+                                               if (currentAttr != null) {
+                                                       uriString = getURIString(currentAttr, document);
+                                               }
+                                       }
+                                       currentNode = currentAttr;
+                               }
+                               // try to create hyperlink from information gathered
+                               if (uriString != null && currentNode != null && isValidURI(uriString)) {
+                                       IRegion hyperlinkRegion = getHyperlinkRegion(currentNode);
+                                       IHyperlink hyperlink = createHyperlink(uriString, hyperlinkRegion, document, currentNode);
+                                       if (hyperlink != null) {
+                                               hyperlinks.add(hyperlink);
+                                       }
+                               }
+                       }
+               }
+               if (hyperlinks.size() == 0) {
+                       return null;
+               }
+               return (IHyperlink[]) hyperlinks.toArray(new IHyperlink[0]);
+       }
+       
+       /**
+        * Get the base location from the current model (local file system)
+        */
+       private String getBaseLocation(IDocument document) {
+               String baseLoc = null;
+               // get the base location from the current model
+               IStructuredModel sModel = null;
+               try {
+                       sModel = StructuredModelManager.getModelManager().getExistingModelForRead(document);
+                       if (sModel != null) {
+                               IPath location = new Path(sModel.getBaseLocation());
+                               if (location.toFile().exists()) {
+                                       baseLoc = location.toString();
+                               } else {
+                                       if (location.segmentCount() > 1) {
+                                               baseLoc = ResourcesPlugin.getWorkspace().getRoot().getFile(location).getLocation().toString();
+                                       } else {
+                                               baseLoc = ResourcesPlugin.getWorkspace().getRoot().getLocation().append(location).toString();
+                                       }
+                               }
+                       }
+               } finally {
+                       if (sModel != null) {
+                               sModel.releaseFromRead();
+                       }
+               }
+               return baseLoc;
+       }
+       
+       /**
+        * Get the CMElementDeclaration for an element
+        * 
+        * @param element
+        * @return CMElementDeclaration
+        */
+       private CMElementDeclaration getCMElementDeclaration(Element element) {
+               CMElementDeclaration ed = null;
+               ModelQuery mq = ModelQueryUtil.getModelQuery(element.getOwnerDocument());
+               if (mq != null) {
+                       ed = mq.getCMElementDeclaration(element);
+               }
+               return ed;
+       }
+       
+       /**
+        * Returns the attribute node within node at offset
+        * 
+        * @param node
+        * @param offset
+        * @return Attr
+        */
+       private Attr getCurrentAttrNode(Node node, int offset) {
+               if ((node instanceof IndexedRegion) && ((IndexedRegion) node).contains(offset) && (node.hasAttributes())) {
+                       NamedNodeMap attrs = node.getAttributes();
+                       // go through each attribute in node and if attribute contains
+                       // offset, return that attribute
+                       for (int i = 0; i < attrs.getLength(); ++i) {
+                               // assumption that if parent node is of type IndexedRegion,
+                               // then its attributes will also be of type IndexedRegion
+                               IndexedRegion attRegion = (IndexedRegion) attrs.item(i);
+                               if (attRegion.contains(offset)) {
+                                       return (Attr) attrs.item(i);
+                               }
+                       }
+               }
+               return null;
+       }
+       
+       /**
+        * Returns the node the cursor is currently on in the document. null if no
+        * node is selected
+        * 
+        * @param offset
+        * @return Node either element, doctype, text, or null
+        */
+       private Node getCurrentNode(IDocument document, int offset) {
+               // get the current node at the offset (returns either: element,
+               // doctype, text)
+               IndexedRegion inode = null;
+               IStructuredModel sModel = null;
+               try {
+                       sModel = StructuredModelManager.getModelManager().getExistingModelForRead(document);
+                       inode = sModel.getIndexedRegion(offset);
+                       if (inode == null) {
+                               inode = sModel.getIndexedRegion(offset - 1);
+                       }
+               } finally {
+                       if (sModel != null) {
+                               sModel.releaseFromRead();
+                       }
+               }
+               if (inode instanceof Node) {
+                       return (Node) inode;
+               }
+               return null;
+       }
+       
+       /**
+        * Returns an IFile from the given uri if possible, null if cannot find file
+        * from uri.
+        * 
+        * @param fileString
+        *            file system path
+        * @return returns IFile if fileString exists in the workspace
+        */
+       private IFile getFile(String fileString) {
+               IFile file = null;
+               if (fileString != null) {
+                       IFile[] files = ResourcesPlugin.getWorkspace().getRoot().findFilesForLocation(new Path(fileString));
+                       for (int i = 0; i < files.length && file == null; i++) {
+                               if (files[i].exists()) {
+                                       file = files[i];
+                               }
+                       }
+               }
+               return file;
+       }
+       
+       /**
+        * Create a file from the given uri string
+        * 
+        * @param uriString -
+        *            assumes uriString is not http://
+        * @return File created from uriString if possible, null otherwise
+        */
+       private File getFileFromUriString(String uriString) {
+               File file = null;
+               try {
+                       // first just try to create a file directly from uriString as
+                       // default in case create file from uri does not work
+                       file = new File(uriString);
+                       // try to create file from uri
+                       URI uri = new URI(uriString);
+                       file = new File(uri);
+               } catch (Exception e) {
+                       // if exception is thrown while trying to create File just ignore
+                       // and file will be null
+               }
+               return file;
+       }
+       
+       private IRegion getHyperlinkRegion(Node node) {
+               IRegion hyperRegion = null;
+               if (node != null) {
+                       short nodeType = node.getNodeType();
+                       if (nodeType == Node.DOCUMENT_TYPE_NODE) {
+                               // handle doc type node
+                               IDOMNode docNode = (IDOMNode) node;
+                               hyperRegion = new Region(docNode.getStartOffset(), docNode.getEndOffset() - docNode.getStartOffset());
+                       } else if (nodeType == Node.ATTRIBUTE_NODE) {
+                               // handle attribute nodes
+                               IDOMAttr att = (IDOMAttr) node;
+                               // do not include quotes in attribute value region
+                               int regOffset = att.getValueRegionStartOffset();
+                               ITextRegion valueRegion = att.getValueRegion();
+                               if (valueRegion != null) {
+                                       int regLength = valueRegion.getTextLength();
+                                       String attValue = att.getValueRegionText();
+                                       if (StringUtils.isQuoted(attValue)) {
+                                               ++regOffset;
+                                               regLength = regLength - 2;
+                                       }
+                                       hyperRegion = new Region(regOffset, regLength);
+                               }
+                       }
+               }
+               return hyperRegion;
+       }
+       
+       /**
+        * Attempts to find an attribute within element that is openable.
+        * 
+        * @param element -
+        *            cannot be null
+        * @return Attr attribute that can be used for open on, null if no attribute
+        *         could be found
+        */
+       private Attr getLinkableAttr(Element element) {
+               CMElementDeclaration ed = getCMElementDeclaration(element);
+               // get the list of attributes for this node
+               NamedNodeMap attrs = element.getAttributes();
+               for (int i = 0; i < attrs.getLength(); ++i) {
+                       // check if this attribute is "openOn-able"
+                       Attr att = (Attr) attrs.item(i);
+                       if (isLinkableAttr(att, ed)) {
+                               return att;
+                       }
+               }
+               return null;
+       }
+       
+       /**
+        * Find the location hint for the given namespaceURI if it exists
+        * 
+        * @param elementNode -
+        *            cannot be null
+        * @param namespaceURI -
+        *            cannot be null
+        * @return location hint (systemId) if it was found, null otherwise
+        */
+       private String getLocationHint(Element elementNode, String namespaceURI) {
+               Attr schemaLocNode = elementNode.getAttributeNodeNS(XSI_NAMESPACE_URI, SCHEMA_LOCATION);
+               if (schemaLocNode != null) {
+                       StringTokenizer st = new StringTokenizer(schemaLocNode.getValue());
+                       while (st.hasMoreTokens()) {
+                               String publicId = st.hasMoreTokens() ? st.nextToken() : null;
+                               String systemId = st.hasMoreTokens() ? st.nextToken() : null;
+                               // found location hint
+                               if (namespaceURI.equalsIgnoreCase(publicId)) {
+                                       return systemId;
+                               }
+                       }
+               }
+               return null;
+       }
+       
+       /**
+        * Returns the URI string
+        * 
+        * @param node -
+        *            assumes not null
+        */
+       private String getURIString(Node node, IDocument document) {
+               String resolvedURI = null;
+               // need the base location, publicId, and systemId for URIResolver
+               String baseLoc = null;
+               String publicId = null;
+               String systemId = null;
+               short nodeType = node.getNodeType();
+               // handle doc type node
+               if (nodeType == Node.DOCUMENT_TYPE_NODE) {
+                       baseLoc = getBaseLocation(document);
+                       publicId = ((DocumentType) node).getPublicId();
+                       systemId = ((DocumentType) node).getSystemId();
+               } else if (nodeType == Node.ATTRIBUTE_NODE) {
+                       // handle attribute node
+                       Attr attrNode = (Attr) node;
+                       String attrName = attrNode.getName();
+                       String attrValue = attrNode.getValue();
+                       attrValue = StringUtils.strip(attrValue);
+                       if (attrValue != null && attrValue.length() > 0) {
+                               baseLoc = getBaseLocation(document);
+                               // handle schemaLocation attribute
+                               String prefix = DOMNamespaceHelper.getPrefix(attrName);
+                               String unprefixedName = DOMNamespaceHelper.getUnprefixedName(attrName);
+                               if ((XMLNS.equals(prefix)) || (XMLNS.equals(unprefixedName))) {
+                                       publicId = attrValue;
+                                       systemId = getLocationHint(attrNode.getOwnerElement(), publicId);
+                                       if (systemId == null) {
+                                               systemId = attrValue;
+                                       }
+                               } else if ((XSI_NAMESPACE_URI.equals(DOMNamespaceHelper.getNamespaceURI(attrNode))) && (SCHEMA_LOCATION.equals(unprefixedName))) {
+                                       // for now just use the first pair
+                                       // need to look into being more precise
+                                       StringTokenizer st = new StringTokenizer(attrValue);
+                                       publicId = st.hasMoreTokens() ? st.nextToken() : null;
+                                       systemId = st.hasMoreTokens() ? st.nextToken() : null;
+                                       // else check if xmlns publicId = value
+                               } else {
+                                       systemId = attrValue;
+                               }
+                       }
+               }
+               resolvedURI = resolveURI(baseLoc, publicId, systemId);
+               return resolvedURI;
+       }
+       
+       /**
+        * Returns true if this uriString is an http string
+        * 
+        * @param uriString
+        * @return true if uriString is http string, false otherwise
+        */
+       private boolean isHttp(String uriString) {
+               boolean isHttp = false;
+               if (uriString != null) {
+                       String tempString = uriString.toLowerCase();
+                       if (tempString.startsWith(HTTP_PROTOCOL)) {
+                               isHttp = true;
+                       }
+               }
+               return isHttp;
+       }
+       
+       /**
+        * Checks to see if the given attribute is openable. Attribute is openable
+        * if it is a namespace declaration attribute or if the attribute value is
+        * of type URI.
+        * 
+        * @param attr
+        *            cannot be null
+        * @param cmElement
+        *            CMElementDeclaration associated with the attribute (can be
+        *            null)
+        * @return true if this attribute is "openOn-able" false otherwise
+        */
+       private boolean isLinkableAttr(Attr attr, CMElementDeclaration cmElement) {
+               String attrName = attr.getName();
+               String prefix = DOMNamespaceHelper.getPrefix(attrName);
+               String unprefixedName = DOMNamespaceHelper.getUnprefixedName(attrName);
+               // determine if attribute is namespace declaration
+               if ((XMLNS.equals(prefix)) || (XMLNS.equals(unprefixedName))) {
+                       return true;
+               }
+               // determine if attribute contains schema location
+               if ((XSI_NAMESPACE_URI.equals(DOMNamespaceHelper.getNamespaceURI(attr))) && ((SCHEMA_LOCATION.equals(unprefixedName)) || (NO_NAMESPACE_SCHEMA_LOCATION.equals(unprefixedName)))) {
+                       return true;
+               }
+               // determine if attribute value is of type URI
+               if (cmElement != null) {
+                       CMAttributeDeclaration attrDecl = (CMAttributeDeclaration) cmElement.getAttributes().getNamedItem(attrName);
+                       if ((attrDecl != null) && (attrDecl.getAttrType() != null) && (CMDataType.URI.equals(attrDecl.getAttrType().getDataTypeName()))) {
+                               return true;
+                       }
+               }
+               return false;
+       }
+       
+       /**
+        * Checks whether the given uriString is really pointing to a file
+        * 
+        * @param uriString
+        * @return boolean
+        */
+       private boolean isValidURI(String uriString) {
+               boolean isValid = false;
+               if (isHttp(uriString)) {
+                       isValid = true;
+               } else {
+                       File file = getFileFromUriString(uriString);
+                       if (file != null) {
+                               isValid = file.isFile();
+                       }
+               }
+               return isValid;
+       }
+       
+       /**
+        * Resolves the given URI information
+        * 
+        * @param baseLocation
+        * @param publicId
+        * @param systemId
+        * @return String resolved uri.
+        */
+       private String resolveURI(String baseLocation, String publicId, String systemId) {
+               // dont resolve if there's nothing to resolve
+               if ((baseLocation == null) && (publicId == null) && (systemId == null)) {
+                       return null;
+               }
+               return URIResolverPlugin.createResolver().resolve(baseLocation, publicId, systemId);
+       }
+}
diff --git a/org.eclipse.wst.jsdt.web.ui/.classpath b/org.eclipse.wst.jsdt.web.ui/.classpath
new file mode 100644 (file)
index 0000000..52165ec
--- /dev/null
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+       <classpathentry kind="src" path="src/"/>
+       <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.4"/>
+       <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+       <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/org.eclipse.wst.jsdt.web.ui/.project b/org.eclipse.wst.jsdt.web.ui/.project
new file mode 100644 (file)
index 0000000..4917858
--- /dev/null
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+       <name>org.eclipse.wst.jsdt.web.ui</name>
+       <comment></comment>
+       <projects>
+       </projects>
+       <buildSpec>
+               <buildCommand>
+                       <name>org.eclipse.jdt.core.javabuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+               <buildCommand>
+                       <name>org.eclipse.pde.ManifestBuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+               <buildCommand>
+                       <name>org.eclipse.pde.SchemaBuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+       </buildSpec>
+       <natures>
+               <nature>org.eclipse.jdt.core.javanature</nature>
+               <nature>org.eclipse.pde.PluginNature</nature>
+       </natures>
+</projectDescription>
diff --git a/org.eclipse.wst.jsdt.web.ui/.settings/org.eclipse.core.resources.prefs b/org.eclipse.wst.jsdt.web.ui/.settings/org.eclipse.core.resources.prefs
new file mode 100644 (file)
index 0000000..afa5c91
--- /dev/null
@@ -0,0 +1,3 @@
+#Tue Apr 04 03:36:32 EDT 2006
+eclipse.preferences.version=1
+encoding/<project>=ISO-8859-1
diff --git a/org.eclipse.wst.jsdt.web.ui/.settings/org.eclipse.core.runtime.prefs b/org.eclipse.wst.jsdt.web.ui/.settings/org.eclipse.core.runtime.prefs
new file mode 100644 (file)
index 0000000..7ec5750
--- /dev/null
@@ -0,0 +1,3 @@
+#Mon Apr 17 01:48:39 EDT 2006
+eclipse.preferences.version=1
+line.separator=\r\n
diff --git a/org.eclipse.wst.jsdt.web.ui/.settings/org.eclipse.jdt.core.prefs b/org.eclipse.wst.jsdt.web.ui/.settings/org.eclipse.jdt.core.prefs
new file mode 100644 (file)
index 0000000..6e07215
--- /dev/null
@@ -0,0 +1,96 @@
+#Wed Oct 24 19:49:45 EDT 2007
+eclipse.preferences.version=1
+org.eclipse.jdt.core.builder.cleanOutputFolder=clean
+org.eclipse.jdt.core.builder.duplicateResourceTask=warning
+org.eclipse.jdt.core.builder.invalidClasspath=ignore
+org.eclipse.jdt.core.builder.resourceCopyExclusionFilter=*.launch
+org.eclipse.jdt.core.circularClasspath=error
+org.eclipse.jdt.core.classpath.exclusionPatterns=enabled
+org.eclipse.jdt.core.classpath.multipleOutputLocations=enabled
+org.eclipse.jdt.core.codeComplete.argumentPrefixes=
+org.eclipse.jdt.core.codeComplete.argumentSuffixes=
+org.eclipse.jdt.core.codeComplete.fieldPrefixes=
+org.eclipse.jdt.core.codeComplete.fieldSuffixes=
+org.eclipse.jdt.core.codeComplete.localPrefixes=
+org.eclipse.jdt.core.codeComplete.localSuffixes=
+org.eclipse.jdt.core.codeComplete.staticFieldPrefixes=
+org.eclipse.jdt.core.codeComplete.staticFieldSuffixes=
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=disabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.2
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.4
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.doc.comment.support=enabled
+org.eclipse.jdt.core.compiler.maxProblemPerUnit=100
+org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=warning
+org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
+org.eclipse.jdt.core.compiler.problem.deprecation=ignore
+org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
+org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=enabled
+org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
+org.eclipse.jdt.core.compiler.problem.emptyStatement=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=warning
+org.eclipse.jdt.core.compiler.problem.fallthroughCase=warning
+org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled
+org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore
+org.eclipse.jdt.core.compiler.problem.finalParameterBound=ignore
+org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=error
+org.eclipse.jdt.core.compiler.problem.forbiddenReference=error
+org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning
+org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
+org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore
+org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=error
+org.eclipse.jdt.core.compiler.problem.invalidJavadoc=ignore
+org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsDeprecatedRef=enabled
+org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsNotVisibleRef=enabled
+org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility=private
+org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore
+org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=error
+org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore
+org.eclipse.jdt.core.compiler.problem.missingJavadocComments=ignore
+org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsOverriding=enabled
+org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsVisibility=public
+org.eclipse.jdt.core.compiler.problem.missingJavadocTags=ignore
+org.eclipse.jdt.core.compiler.problem.missingJavadocTagsOverriding=enabled
+org.eclipse.jdt.core.compiler.problem.missingJavadocTagsVisibility=private
+org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore
+org.eclipse.jdt.core.compiler.problem.missingSerialVersion=error
+org.eclipse.jdt.core.compiler.problem.noEffectAssignment=error
+org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
+org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore
+org.eclipse.jdt.core.compiler.problem.nullReference=ignore
+org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning
+org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore
+org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=error
+org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore
+org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning
+org.eclipse.jdt.core.compiler.problem.redundantNullCheck=warning
+org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=enabled
+org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=error
+org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
+org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore
+org.eclipse.jdt.core.compiler.problem.typeParameterHiding=ignore
+org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
+org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
+org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
+org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
+org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning
+org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled
+org.eclipse.jdt.core.compiler.problem.unusedImport=error
+org.eclipse.jdt.core.compiler.problem.unusedLabel=error
+org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
+org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore
+org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled
+org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
+org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
+org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
+org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
+org.eclipse.jdt.core.compiler.source=1.3
+org.eclipse.jdt.core.incompatibleJDKLevel=ignore
+org.eclipse.jdt.core.incompleteClasspath=error
diff --git a/org.eclipse.wst.jsdt.web.ui/.settings/org.eclipse.jdt.ui.prefs b/org.eclipse.wst.jsdt.web.ui/.settings/org.eclipse.jdt.ui.prefs
new file mode 100644 (file)
index 0000000..c91d09d
--- /dev/null
@@ -0,0 +1,51 @@
+#Wed Oct 24 19:41:31 EDT 2007
+cleanup.add_default_serial_version_id=true
+cleanup.add_generated_serial_version_id=false
+cleanup.add_missing_annotations=false
+cleanup.add_missing_deprecated_annotations=true
+cleanup.add_missing_nls_tags=false
+cleanup.add_missing_override_annotations=true
+cleanup.add_serial_version_id=true
+cleanup.always_use_blocks=true
+cleanup.always_use_parentheses_in_expressions=true
+cleanup.always_use_this_for_non_static_field_access=false
+cleanup.always_use_this_for_non_static_method_access=false
+cleanup.convert_to_enhanced_for_loop=false
+cleanup.format_source_code=false
+cleanup.make_local_variable_final=true
+cleanup.make_parameters_final=false
+cleanup.make_private_fields_final=true
+cleanup.make_variable_declarations_final=false
+cleanup.never_use_blocks=false
+cleanup.never_use_parentheses_in_expressions=false
+cleanup.organize_imports=true
+cleanup.qualify_static_field_accesses_with_declaring_class=false
+cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true
+cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true
+cleanup.qualify_static_member_accesses_with_declaring_class=true
+cleanup.qualify_static_method_accesses_with_declaring_class=false
+cleanup.remove_private_constructors=true
+cleanup.remove_unnecessary_casts=true
+cleanup.remove_unnecessary_nls_tags=true
+cleanup.remove_unused_imports=true
+cleanup.remove_unused_local_variables=false
+cleanup.remove_unused_private_fields=true
+cleanup.remove_unused_private_members=true
+cleanup.remove_unused_private_methods=true
+cleanup.remove_unused_private_types=true
+cleanup.use_blocks=true
+cleanup.use_blocks_only_for_return_and_throw=false
+cleanup.use_parentheses_in_expressions=true
+cleanup.use_this_for_non_static_field_access=false
+cleanup.use_this_for_non_static_field_access_only_if_necessary=true
+cleanup.use_this_for_non_static_method_access=false
+cleanup.use_this_for_non_static_method_access_only_if_necessary=true
+cleanup_profile=_SSE Team Styles
+cleanup_settings_version=2
+eclipse.preferences.version=1
+internal.default.compliance=default
+org.eclipse.jdt.ui.exception.name=e
+org.eclipse.jdt.ui.gettersetter.use.is=true
+org.eclipse.jdt.ui.keywordthis=false
+org.eclipse.jdt.ui.overrideannotation=false
+org.eclipse.jdt.ui.text.custom_code_templates=<?xml version\="1.0" encoding\="UTF-8"?><templates/>
diff --git a/org.eclipse.wst.jsdt.web.ui/.settings/org.eclipse.ltk.core.refactoring.prefs b/org.eclipse.wst.jsdt.web.ui/.settings/org.eclipse.ltk.core.refactoring.prefs
new file mode 100644 (file)
index 0000000..c59368c
--- /dev/null
@@ -0,0 +1,3 @@
+#Tue Apr 04 03:36:32 EDT 2006
+eclipse.preferences.version=1
+org.eclipse.ltk.core.refactoring.enable.project.refactoring.history=false
diff --git a/org.eclipse.wst.jsdt.web.ui/.settings/org.eclipse.pde.prefs b/org.eclipse.wst.jsdt.web.ui/.settings/org.eclipse.pde.prefs
new file mode 100644 (file)
index 0000000..262b0ab
--- /dev/null
@@ -0,0 +1,28 @@
+#Fri Feb 27 12:45:35 EST 2009
+compilers.f.unresolved-features=1
+compilers.f.unresolved-plugins=1
+compilers.incompatible-environment=0
+compilers.p.build=0
+compilers.p.deprecated=1
+compilers.p.discouraged-class=1
+compilers.p.illegal-att-value=0
+compilers.p.internal=1
+compilers.p.missing-packages=2
+compilers.p.missing-version-export-package=2
+compilers.p.missing-version-import-package=2
+compilers.p.missing-version-require-bundle=2
+compilers.p.no-required-att=0
+compilers.p.not-externalized-att=0
+compilers.p.unknown-attribute=0
+compilers.p.unknown-class=0
+compilers.p.unknown-element=0
+compilers.p.unknown-identifier=1
+compilers.p.unknown-resource=0
+compilers.p.unresolved-ex-points=0
+compilers.p.unresolved-import=0
+compilers.p.unused-element-or-attribute=0
+compilers.s.create-docs=false
+compilers.s.doc-folder=doc
+compilers.s.open-tags=1
+compilers.use-project=true
+eclipse.preferences.version=1
diff --git a/org.eclipse.wst.jsdt.web.ui/META-INF/MANIFEST.MF b/org.eclipse.wst.jsdt.web.ui/META-INF/MANIFEST.MF
new file mode 100644 (file)
index 0000000..962e393
--- /dev/null
@@ -0,0 +1,57 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: %Bundle-Name.0
+Bundle-SymbolicName: org.eclipse.wst.jsdt.web.ui; singleton:=true
+Bundle-Version: 1.0.401.v201108152113_patch
+Bundle-Activator: org.eclipse.wst.jsdt.web.ui.internal.JsUIPlugin
+Bundle-Vendor: %Bundle-Vendor.0
+Bundle-Localization: plugin
+Export-Package: org.eclipse.wst.jsdt.web.ui;x-internal:=true,
+ org.eclipse.wst.jsdt.web.ui.contentassist,
+ org.eclipse.wst.jsdt.web.ui.internal;x-internal:=true,
+ org.eclipse.wst.jsdt.web.ui.internal.autoedit;x-internal:=true,
+ org.eclipse.wst.jsdt.web.ui.internal.contentassist;x-internal:=true,
+ org.eclipse.wst.jsdt.web.ui.internal.derived;x-internal:=true,
+ org.eclipse.wst.jsdt.web.ui.internal.editor;x-internal:=true,
+ org.eclipse.wst.jsdt.web.ui.internal.format;x-internal:=true,
+ org.eclipse.wst.jsdt.web.ui.internal.hyperlink;x-internal:=true,
+ org.eclipse.wst.jsdt.web.ui.internal.java.refactoring;x-internal:=true,
+ org.eclipse.wst.jsdt.web.ui.internal.java.search;x-internal:=true,
+ org.eclipse.wst.jsdt.web.ui.internal.java.search.ui;x-internal:=true,
+ org.eclipse.wst.jsdt.web.ui.internal.registry;x-internal:=true,
+ org.eclipse.wst.jsdt.web.ui.internal.style;x-internal:=true,
+ org.eclipse.wst.jsdt.web.ui.internal.style.java;x-internal:=true,
+ org.eclipse.wst.jsdt.web.ui.internal.taginfo;x-internal:=true,
+ org.eclipse.wst.jsdt.web.ui.internal.text;x-internal:=true,
+ org.eclipse.wst.jsdt.web.ui.views.contentoutline
+Import-Package: com.ibm.icu.util; version="3.8",
+ com.ibm.icu.text; version="3.8",
+ org.eclipse.core.filesystem,
+ org.eclipse.ui.views.contentoutline
+Require-Bundle: org.eclipse.ui.ide;bundle-version="[3.5.0,4.0.0)",
+ org.eclipse.jface.text;bundle-version="[3.5.0,4.0.0)",
+ org.eclipse.ui.workbench;bundle-version="[3.5.0,4.0.0)",
+ org.eclipse.ui.workbench.texteditor;bundle-version="[3.5.0,4.0.0)",
+ org.eclipse.ui;bundle-version="[3.5.0,4.0.0)",
+ org.eclipse.wst.sse.ui;bundle-version="[1.3.0,1.4.0)",
+ org.eclipse.wst.xml.ui;bundle-version="[1.1.100,1.2.0)",
+ org.eclipse.wst.jsdt.web.core;bundle-version="[1.0.300,2.0.0)",
+ org.eclipse.wst.css.core;bundle-version="[1.1.400,1.2.0)",
+ org.eclipse.wst.xml.core;bundle-version="[1.1.500,1.2.0)",
+ org.eclipse.wst.sse.core;bundle-version="[1.1.500,1.2.0)",
+ org.eclipse.debug.core;bundle-version="[3.5.0,4.0.0)",
+ org.eclipse.core.runtime;bundle-version="[3.5.0,4.0.0)",
+ org.eclipse.search;bundle-version="[3.5.0,4.0.0)",
+ org.eclipse.ltk.core.refactoring;bundle-version="[3.5.0,4.0.0)",
+ org.eclipse.wst.common.uriresolver;bundle-version="[1.1.300,1.2.0)",
+ org.eclipse.ui.ide;bundle-version="[3.5.0,4.0.0)",
+ org.eclipse.wst.jsdt.core;bundle-version="[1.1.0,2.0.0)",
+ org.eclipse.wst.jsdt.ui;bundle-version="[1.1.0,2.0.0)",
+ org.eclipse.wst.html.ui;bundle-version="[1.0.500,1.1.0)",
+ org.eclipse.wst.html.core;bundle-version="[1.1.400,1.2.0)",
+ org.eclipse.wst.jsdt.manipulation;bundle-version="[1.0.200,2.0.0)"
+Bundle-RequiredExecutionEnvironment: J2SE-1.4
+Bundle-ActivationPolicy: lazy
+Eclipse-ExtensibleAPI: true
+Bundle-ClassPath: library.jar,
+ .
diff --git a/org.eclipse.wst.jsdt.web.ui/about.html b/org.eclipse.wst.jsdt.web.ui/about.html
new file mode 100644 (file)
index 0000000..4602330
--- /dev/null
@@ -0,0 +1,28 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
+<title>About</title>
+</head>
+<body lang="EN-US">
+<h2>About This Content</h2>
+<p>June 2, 2006</p>    
+<h3>License</h3>
+
+<p>The Eclipse Foundation makes available all content in this plug-in (&quot;Content&quot;).  Unless otherwise 
+indicated below, the Content is provided to you under the terms and conditions of the
+Eclipse Public License Version 1.0 (&quot;EPL&quot;).  A copy of the EPL is available 
+at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
+For purposes of the EPL, &quot;Program&quot; will mean the Content.</p>
+
+<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is 
+being redistributed by another party (&quot;Redistributor&quot;) and different terms and conditions may
+apply to your use of any object code in the Content.  Check the Redistributor's license that was 
+provided with the Content.  If no such license exists, contact the Redistributor.  Unless otherwise
+indicated below, the terms and conditions of the EPL still apply to any source code in the Content
+and such source code may be obtained at <a href="http://www.eclipse.org">http://www.eclipse.org</a>.</p>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/org.eclipse.wst.jsdt.web.ui/build.properties b/org.eclipse.wst.jsdt.web.ui/build.properties
new file mode 100644 (file)
index 0000000..3cb50b0
--- /dev/null
@@ -0,0 +1,19 @@
+###############################################################################
+# Copyright (c) 2007, 2009 IBM Corporation and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+# 
+# Contributors:
+#     IBM Corporation - initial API and implementation
+###############################################################################
+source.. = src/
+bin.includes = META-INF/,\
+               .,\
+               icons/,\
+               plugin.properties,\
+               plugin.xml,\
+               about.html
+jars.compile.order = .
+
diff --git a/org.eclipse.wst.jsdt.web.ui/icons/eye_icon.gif b/org.eclipse.wst.jsdt.web.ui/icons/eye_icon.gif
new file mode 100644 (file)
index 0000000..078398e
Binary files /dev/null and b/org.eclipse.wst.jsdt.web.ui/icons/eye_icon.gif differ
diff --git a/org.eclipse.wst.jsdt.web.ui/icons/full/elcl16/javaassist_co.gif b/org.eclipse.wst.jsdt.web.ui/icons/full/elcl16/javaassist_co.gif
new file mode 100644 (file)
index 0000000..e9a6bd9
Binary files /dev/null and b/org.eclipse.wst.jsdt.web.ui/icons/full/elcl16/javaassist_co.gif differ
diff --git a/org.eclipse.wst.jsdt.web.ui/plugin.properties b/org.eclipse.wst.jsdt.web.ui/plugin.properties
new file mode 100644 (file)
index 0000000..88766f0
--- /dev/null
@@ -0,0 +1,73 @@
+###############################################################################
+# Copyright (c) 2000, 2010 IBM Corporation and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+#     IBM Corporation - initial API and implementation
+###############################################################################
+
+Bundle-Vendor.0 = Eclipse Web Tools Platform
+Bundle-Name.0 = JSDT Web Support UI
+hyperlinkDetector.name.0 = JavaScript Element
+menu.label.0 = Declarations
+action.tooltip.0 = Working Set
+action.label.0 = Working Set
+action.label.1 = Hierarchy
+action.tooltip.1 = Hierarchy
+action.label.2 = Project
+action.tooltip.2 = Project
+action.label.3 = Workspace
+action.tooltip.3 = Declarations
+menu.label.1 = References
+action.label.4 = Working Set
+action.tooltip.4 = Working Set
+action.label.5 = Hierarchy
+action.tooltip.5 = Hierarchy
+action.label.6 = Project
+action.tooltip.6 = Project
+action.label.7 = Workspace
+action.tooltip.7 = 
+menu.label.2 = Refactor
+menu.label.3 = Source
+action.label.8 = Generate Element Comment
+action.tooltip.8 = Generate Element Comment
+action.label.9 = Change Function Signature
+action.tooltip.9 = Change Function Signature
+action.label.10 = Move
+action.tooltip.10 = Move
+action.label.11 = Rename
+action.tooltip.11 = Rename
+action.label.12 = Delete
+action.tooltip.12 = Delete
+action.label.13 = Paste After
+action.tooltip.13 = Paste
+action.label.14 = Paste Before
+action.tooltip.14 = Paste
+action.label.15 = Copy
+action.tooltip.15 = Copy
+action.label.16 = Cut
+action.tooltip.16 = Cut
+menu.label.4 = Show In
+action.label.17 = Navigator
+action.tooltip.17 = Show In Navigator
+action.label.18 = Script Explorer
+action.tooltip.18 = Show In Script Explorer
+action.label.19 = Open Call Hierarchy
+action.tooltip.19 = Open Call Hierarchy
+action.label.20 = Open Type Hierarchy
+action.tooltip.20 = Open Type Hierarchy
+renameParticipant.name.0 = JSDT Web Rename Participant
+renameParticipant.name.1 = JSDT Web Rename Participant
+renameParticipant.name.2 = JSDT Web Rename Participant
+renameParticipant.name.3 = JSDT Web Rename Participant
+queryParticipant.name.0 = JavaScript Query Participant
+javaScriptProposals = JavaScript Proposals
+
+
+##########################################################################
+# Marker Support
+##########################################################################
+markerCategory.problem = JavaScript Problems
diff --git a/org.eclipse.wst.jsdt.web.ui/plugin.xml b/org.eclipse.wst.jsdt.web.ui/plugin.xml
new file mode 100644 (file)
index 0000000..9088bd7
--- /dev/null
@@ -0,0 +1,791 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.0"?>
+<plugin>
+
+       <extension point="org.eclipse.wst.sse.ui.editorConfiguration">
+               <contentOutlineConfiguration
+                       class="org.eclipse.wst.jsdt.web.ui.views.provisional.contentoutline.JsContentOutlineConfig"
+                       target="org.eclipse.wst.html.core.htmlsource.source" /> 
+               <sourceViewerConfiguration
+                       class="org.eclipse.wst.jsdt.web.ui.StructuredTextViewerConfigurationJSDT"
+                       target="org.eclipse.wst.html.core.htmlsource.source" /> 
+               <provisionalConfiguration
+                       type="linestyleprovider"
+                       class="org.eclipse.wst.jsdt.web.ui.internal.style.java.LineStyleProviderForJSDT"
+                       target="org.eclipse.wst.html.SCRIPT,org.eclipse.wst.html.SCRIPT.EVENTHANDLER" />
+               <documentationTextHover
+                       class="org.eclipse.wst.jsdt.web.ui.internal.taginfo.JSDTHoverProcessor"
+                       target="org.eclipse.wst.html.SCRIPT,org.eclipse.wst.html.SCRIPT.EVENTHANDLER" />
+               <provisionalConfiguration
+                       type="characterpairmatcher"
+                       class="org.eclipse.wst.jsdt.web.ui.internal.text.JsDocumentRegionEdgeMatcher"
+                       target="org.eclipse.wst.html.SCRIPT,org.eclipse.wst.html.SCRIPT.EVENTHANDLER" />
+               <provisionalConfiguration
+                       type="autoeditstrategy"
+                       class="org.eclipse.wst.jsdt.web.ui.internal.autoedit.AutoEditStrategyForJs"
+                       target="org.eclipse.wst.html.SCRIPT,org.eclipse.wst.html.SCRIPT.EVENTHANDLER" />
+               <provisionalConfiguration
+                       type="org.eclipse.wst.sse.ui.internal.search.FindOccurrencesProcessor"
+                       class="org.eclipse.wst.jsdt.web.ui.internal.java.search.JsFindOccurrencesProcessor"
+                       target="org.eclipse.wst.html.SCRIPT,org.eclipse.wst.html.SCRIPT.EVENTHANDLER" />
+               <provisionalConfiguration
+                       type="slaveformattingstrategy"
+                       class="org.eclipse.wst.jsdt.web.ui.internal.format.FormattingStrategyJSDT"
+                       target="org.eclipse.wst.html.SCRIPT" />
+       </extension>            
+       
+        <extension
+         point="org.eclipse.ui.workbench.texteditor.hyperlinkDetectors">
+      <hyperlinkDetector 
+            class="org.eclipse.wst.jsdt.web.ui.internal.hyperlink.JSDTHyperlinkDetector"
+            id="org.eclipse.wst.jsdt.web.ui.JSDTHyperlinkDetector.SCRIPT"
+            name="%hyperlinkDetector.name.0"
+            targetId="org.eclipse.wst.html.SCRIPT"/>
+      <hyperlinkDetector
+            class="org.eclipse.wst.jsdt.web.ui.internal.hyperlink.JSDTHyperlinkDetector"
+            id="org.eclipse.wst.jsdt.web.ui.JSDTHyperlinkDetector.SCRIPT.events"
+            name="%hyperlinkDetector.name.0"
+            targetId="org.eclipse.wst.html.SCRIPT.EVENTHANDLER"/>  
+      <hyperlinkDetector
+                       class="org.eclipse.wst.jsdt.web.ui.internal.hyperlink.JSDTHyperlinkDetector"
+                       id="org.eclipse.wst.jsdt.web.ui.JSDTHyperlinkDetector.HTML"
+                       name="%hyperlinkDetector.name.0"
+                       targetId="org.eclipse.wst.html.core.htmlsource"/>
+   </extension>
+  
+  
+    <extension
+         point="org.eclipse.ui.popupMenus">
+       <!-- content outline contributions for Open Type and Open Hierarchy menu.  Menus show up in reverse order of decliration (google it). -->
+      <objectContribution
+            objectClass="org.eclipse.wst.jsdt.web.ui.views.contentoutline.IJavaWebNode"
+            id="org.eclipse.wst.jsdt.web.ui.JavaActions">
+            <!-- Declarations Search Menu -->
+            <menu
+                id="org.eclipse.wst.jsdt.web.declerations"
+                       label="%menu.label.0"
+                       path="group.search">
+                       <separator name="declerations"/>
+         </menu>
+         <action
+               label="%action.label.0"          
+               tooltip="%action.tooltip.0"
+               menubarPath="org.eclipse.wst.jsdt.web.declerations/declerations"
+               class="org.eclipse.wst.jsdt.web.ui.actions.FindReferencesInWorkingSetAction"
+               enablesFor="1"
+               id="org.eclipse.wst.jsdt.ui.actions.FindDeclarationsInWorkingSetAction">
+         </action>  
+         <action
+               label="%action.label.1"          
+               tooltip="%action.tooltip.1"
+               menubarPath="org.eclipse.wst.jsdt.web.declerations/declerations"
+               class="org.eclipse.wst.jsdt.web.ui.actions.FindReferencesAction"
+               enablesFor="1"
+               id="org.eclipse.wst.jsdt.ui.actions.FindDeclarationsInHierarchyAction">
+         </action> 
+          <action
+               label="%action.label.2"          
+               tooltip="%action.tooltip.2"
+               menubarPath="org.eclipse.wst.jsdt.web.declerations/declerations"
+               class="org.eclipse.wst.jsdt.web.ui.actions.FindReferencesAction"
+               enablesFor="1"
+               id="org.eclipse.wst.jsdt.ui.actions.FindDeclarationsInProjectAction">
+         </action>
+         
+         <action
+               label="%action.label.3"
+               tooltip="%action.tooltip.3"
+               menubarPath="org.eclipse.wst.jsdt.web.declerations/declerations"
+               class="org.eclipse.wst.jsdt.web.ui.actions.FindReferencesAction"
+               enablesFor="1"
+               id="org.eclipse.wst.jsdt.ui.actions.FindDeclarationsAction">
+         </action>   
+            
+            <!-- Refrences Search menu -->
+          <menu
+                id="org.eclipse.wst.jsdt.web.references"
+                       label="%menu.label.1"
+                       path="group.search">
+                       <separator name="references"/>
+         </menu>
+         <action
+               label="%action.label.4"          
+               tooltip="%action.tooltip.4"
+               menubarPath="org.eclipse.wst.jsdt.web.references/references"
+               class="org.eclipse.wst.jsdt.web.ui.actions.FindReferencesInWorkingSetAction"
+               enablesFor="1"
+               id="org.eclipse.wst.jsdt.ui.actions.FindReferencesInWorkingSetAction">
+         </action>  
+         <action
+               label="%action.label.5"          
+               tooltip="%action.tooltip.5"
+               menubarPath="org.eclipse.wst.jsdt.web.references/references"
+               class="org.eclipse.wst.jsdt.web.ui.actions.FindReferencesAction"
+               enablesFor="1"
+               id="org.eclipse.wst.jsdt.ui.actions.FindReferencesInHierarchyAction">
+         </action> 
+          <action
+               label="%action.label.6"          
+               tooltip="%action.tooltip.6"
+               menubarPath="org.eclipse.wst.jsdt.web.references/references"
+               class="org.eclipse.wst.jsdt.web.ui.actions.FindReferencesAction"
+               enablesFor="1"
+               id="org.eclipse.wst.jsdt.ui.actions.FindReferencesInProjectAction">
+         </action>
+         
+         <action
+               label="%action.label.7"
+               tooltip="%action.tooltip.7"
+               menubarPath="org.eclipse.wst.jsdt.web.references/references"
+               class="org.eclipse.wst.jsdt.web.ui.actions.FindReferencesAction"
+               enablesFor="1"
+               id="org.eclipse.wst.jsdt.ui.actions.FindReferencesAction">
+         </action>   
+         <!-- Source and Refactoring Menu's -->
+          <menu
+                id="org.eclipse.wst.jsdt.web.refactor"
+                       label="%menu.label.2"
+                       path="group.generate">
+                       <separator name="refactor"/>
+         </menu>
+
+         <menu
+                id="org.eclipse.wst.jsdt.web.source"
+                       label="%menu.label.3"
+                       path="group.generate">
+                       <separator name="source"/>
+         </menu>
+         <!-- Source Actions -->
+                <action
+               label="%action.label.8"          
+               tooltip="%action.tooltip.8"
+               menubarPath="org.eclipse.wst.jsdt.web.source/source"
+               style="push"
+               class="org.eclipse.wst.jsdt.web.ui.actions.AddJavaDocStubAction"
+               enablesFor="*"
+               id="org.eclipse.wst.jsdt.web.ui.generate.element.comment">
+         </action>
+         <!-- Refactor Actions -->
+         <action
+               label="%action.label.9"          
+               tooltip="%action.tooltip.9"
+               menubarPath="org.eclipse.wst.jsdt.web.refactor/refactor"
+               style="push"
+               class="org.eclipse.wst.jsdt.web.ui.actions.SourceActionsAction"
+               enablesFor="*"
+               id="org.eclipse.wst.jsdt.web.ui.change.function.signature">
+         </action>
+         <action
+               label="%action.label.10"          
+               tooltip="%action.tooltip.10"
+               menubarPath="org.eclipse.wst.jsdt.web.refactor/refactor"
+               style="push"
+               class="org.eclipse.wst.jsdt.web.ui.actions.SourceActionsAction"
+               enablesFor="*"
+               id="org.eclipse.wst.jsdt.web.ui.Move">
+         </action>
+         <action
+               label="%action.label.11"          
+               tooltip="%action.tooltip.11"
+               menubarPath="org.eclipse.wst.jsdt.web.refactor/refactor"
+               style="push"
+               class="org.eclipse.wst.jsdt.web.ui.actions.SourceActionsAction"
+               enablesFor="*"
+               id="org.eclipse.wst.jsdt.web.ui.rename">
+         </action>
+         
+         
+         <!-- Edit  (cut copy paste etc.. -->
+          <action
+               label="%action.label.12"          
+               tooltip="%action.tooltip.12"
+               menubarPath="group.edit"
+               style="push"
+               class="org.eclipse.wst.jsdt.web.ui.actions.StandardEditorActionsAction"
+               enablesFor="*"
+               id="org.eclipse.wst.jsdt.web.ui.delete">
+         </action>
+        
+         <action
+               label="%action.label.13"          
+               tooltip="%action.tooltip.13"
+                     menubarPath="group.edit"
+               style="push"
+               class="org.eclipse.wst.jsdt.web.ui.actions.StandardEditorActionsAction"
+               enablesFor="1"
+               id="org.eclipse.wst.jsdt.web.ui.paste.after">
+         </action>
+          <action
+               label="%action.label.14"          
+               tooltip="%action.tooltip.14"
+                     menubarPath="group.edit"
+               style="push"
+               class="org.eclipse.wst.jsdt.web.ui.actions.StandardEditorActionsAction"
+               enablesFor="1"
+               id="org.eclipse.wst.jsdt.web.ui.paste.before">
+         </action>
+         <action
+               label="%action.label.15"          
+               tooltip="%action.tooltip.15"
+                     menubarPath="group.edit"
+               style="push"
+               class="org.eclipse.wst.jsdt.web.ui.actions.StandardEditorActionsAction"
+               enablesFor="*"
+               id="org.eclipse.wst.jsdt.web.ui.copy">
+         </action>
+
+         <action
+               label="%action.label.16"          
+               tooltip="%action.tooltip.16"
+               menubarPath="group.edit"
+               style="push"
+               class="org.eclipse.wst.jsdt.web.ui.actions.StandardEditorActionsAction"
+               enablesFor="*"
+               id="org.eclipse.wst.jsdt.web.ui.cut">
+         </action>         
+         
+         <!-- Show in Script Explorer, History and Navigator -->       
+         <menu
+                id="org.eclipse.wst.jsdt.web.showin"
+                       label="%menu.label.4"
+                       path="group.show">
+                       <separator name="showin"/>
+         </menu>  
+         <action
+               label="%action.label.17"          
+               tooltip="%action.tooltip.17"
+               menubarPath="org.eclipse.wst.jsdt.web.showin/showin"
+               style="push"
+               class="org.eclipse.wst.jsdt.web.ui.actions.ShowInNavigatorAction"
+               enablesFor="1"
+               id="org.eclipse.wst.jsdt.ui.actions.ShowInNavigatorViewAction">
+         </action>
+         <!-- History not working well -->
+         <!--
+         <action
+               label="History"          
+               tooltip="Show In History"
+               menubarPath="org.eclipse.wst.jsdt.web.showin/showin"
+               style="push"
+               class="org.eclipse.wst.jsdt.web.ui.actions.ShowHistoryAction"
+               enablesFor="1"
+               id="org.eclipse.wst.jsdt.internal.ui.callhierarchy.OpenCallHierarchyAction">
+         </action> 
+         -->
+          <action
+               label="%action.label.18"          
+               tooltip="%action.tooltip.18"
+               menubarPath="org.eclipse.wst.jsdt.web.showin/showin"
+               style="push"
+               class="org.eclipse.wst.jsdt.web.ui.actions.ShowInScriptExplorerAction"
+               enablesFor="1"
+               id="org.eclipse.wst.jsdt.ui.actions.ShowInScriptExplorer">
+         </action>
+         
+         <!-- Open Call and Type Hierarchies -->
+          <action
+               label="%action.label.19"          
+               tooltip="%action.tooltip.19"
+             menubarPath="group.show"
+             style="push"
+               class="org.eclipse.wst.jsdt.web.ui.actions.OpenCallHierarchyAction"
+               enablesFor="1"
+               id="org.eclipse.wst.jsdt.internal.ui.callhierarchy.OpenCallHierarchyAction">
+         </action>
+         <action
+               label="%action.label.20"
+               tooltip="%action.tooltip.20"
+                       menubarPath="group.show"
+                       style="push"
+               class="org.eclipse.wst.jsdt.web.ui.actions.OpenTypeHierarchy"
+               enablesFor="1"
+               id="org.eclipse.wst.jsdt.ui.actions.OpenTypeHierarchyAction">
+         </action>
+       </objectContribution> 
+               
+       </extension>
+       
+  
+       <!-- ====================================================================================== -->
+       <!-- source validation for JSP                                                                                                                    -->
+       <!--======================================================================================-->
+       
+       <extension point="org.eclipse.wst.sse.ui.sourcevalidation">
+               <validator
+                       scope="total"
+                       class="org.eclipse.wst.jsdt.web.core.internal.validation.JsValidator"
+                       id="org.eclipse.wst.jsdt.web.jssourcevalidator">
+                       <contentTypeIdentifier id="org.eclipse.wst.html.core.htmlsource">
+                               <partitionType id="org.eclipse.wst.html.SCRIPT"/>
+                               <partitionType id="org.eclipse.wst.html.SCRIPT.EVENTHANDLER"/>
+                       </contentTypeIdentifier>
+                       <contentTypeIdentifier id="org.eclipse.jst.jsp.core.jspsource">
+                               <partitionType id="org.eclipse.wst.html.SCRIPT"/>
+                               <partitionType id="org.eclipse.wst.html.SCRIPT.EVENTHANDLER"/>
+                       </contentTypeIdentifier>
+               </validator>
+       </extension>
+       
+       <!--======================================================================================-->
+       <!-- JSP UI Adapter factories                                                                                                                     -->
+       <!--======================================================================================-->
+       <extension
+               point="org.eclipse.wst.sse.ui.adapterFactoryDescription">
+               <adapterFactoryDescription
+                       class="org.eclipse.wst.jsdt.web.ui.internal.registry.AdapterFactoryProviderForJSDT">
+                       <contentType id="org.eclipse.wst.html.core.htmlsource" />
+               </adapterFactoryDescription>
+       </extension>
+
+       
+
+
+       <!--======================================================================================-->
+       <!-- for breakpoint                                                                       -->
+       <!--======================================================================================-->
+       <!-- removed for now -->
+       <!--
+       <extension point="org.eclipse.wst.sse.ui.breakpoint">
+               <breakpointContribution id="org.eclipse.wst.jsdt.web.ui.providers">
+                       <provider
+                               contentTypes="org.eclipse.wst.html.core.htmlsource"
+                               class="org.eclipse.wst.jsdt.web.ui.internal.breakpointproviders.JavaStratumBreakpointProvider:*html,js,htm*"
+                               id="org.eclipse.wst.jsdt.web.ui.internal.breakpointproviders.JavaStratumBreakpointProvider" />
+               </breakpointContribution>
+       </extension>
+       -->
+       
+       
+       <!-- Editor actionsets -->
+       <!--
+       <extension point="org.eclipse.ui.actionSetPartAssociations">
+               <actionSetPartAssociation
+                       targetID="org.eclipse.ui.edit.text.actionSet.annotationNavigation">
+                       <part id="org.eclipse.wst.jsdt.web.core.jspsource.source" />
+               </actionSetPartAssociation>
+               <actionSetPartAssociation
+                       targetID="org.eclipse.ui.NavigateActionSet">
+                       <part id="org.eclipse.wst.jsdt.web.core.jspsource.source" />
+               </actionSetPartAssociation>
+       </extension>
+       -->
+
+       
+       
+       
+       <!-- Keybindings for jsp source editor -->
+       <!--
+       <extension point="org.eclipse.ui.bindings"> -->
+           <!--  win32:  M1=CTRL, M2=SHIFT, M3=ALT -->
+               <!-- rename refactor -->
+               <!--
+               <key
+                       sequence="M2+M3+R"
+                       contextId="org.eclipse.wst.jsdt.web.ui.structured.text.editor.jsp.scope"
+                       commandId="org.eclipse.wst.jsdt.ui.edit.text.java.rename.element"
+                       schemeId="org.eclipse.ui.defaultAcceleratorConfiguration">
+               </key>
+               -->
+               <!-- move refactor -->
+               <!--
+               <key
+                       sequence="M2+M3+V"
+                       contextId="org.eclipse.wst.jsdt.web.ui.structured.text.editor.jsp.scope"
+                       commandId="org.eclipse.wst.jsdt.web.ui.refactor.move"
+                       schemeId="org.eclipse.ui.defaultAcceleratorConfiguration">
+               </key>
+       </extension>
+       -->
+       
+       
+       <!--======================================================================================-->
+       <!-- queryParticipant to participate in java seraches                                     -->
+       <!--======================================================================================-->
+       <extension point="org.eclipse.wst.jsdt.ui.queryParticipants">
+               <queryParticipant
+                       name="%queryParticipant.name.0"
+                       nature="org.eclipse.wst.jsdt.core.jsNature"
+                       class="org.eclipse.wst.jsdt.web.ui.internal.java.search.ui.JsQueryParticipant"
+                       id="org.eclipse.wst.jsdt.web.ui.java.search.ui.JsQueryParticipant" />
+
+       </extension>
+       
+       
+       <!--======================================================================================-->
+       <!-- Document provider for ExternalFileEditorInput                                        -->
+       <!--======================================================================================-->
+       <!--
+       <extension point="org.eclipse.ui.editors.documentProviders">
+               <provider
+                       inputTypes="org.eclipse.wst.jsdt.web.ui.internal.hyperlink.ExternalFileEditorInput"
+                       class="org.eclipse.ui.editors.text.TextFileDocumentProvider"
+                       id="org.eclipse.wst.jsdt.web.ui.internal.ExternalFileDocumentProvider" />
+
+       </extension>
+       -->
+       <!--
+       <extension point="org.eclipse.ui.popupMenus">
+               <viewerContribution
+                       targetID="org.eclipse.wst.jsdt.web.core.jspsource.source.RulerContext"
+                       id="org.eclipse.ui.texteditor.ruler.context.actions">
+                       <action
+                               label="%AddTask.label"
+                               helpContextId="org.eclipse.ui.AddTask_action_context"
+                               class="org.eclipse.ui.texteditor.TaskRulerAction"
+                               tooltip="%AddTask.tooltip"
+                               menubarPath="additions"
+                               id="org.eclipse.ui.texteditor.TaskRulerAction" />
+
+                       <action
+                               label="%AddBookmark.label"
+                               helpContextId="org.eclipse.ui.bookmark_action_context"
+                               class="org.eclipse.ui.texteditor.BookmarkRulerAction"
+                               tooltip="%AddBookmark.tooltip"
+                               menubarPath="additions"
+                               id="org.eclipse.ui.texteditor.BookmarkRulerAction" />
+
+               </viewerContribution>
+       </extension>
+-->
+
+
+<!--
+       <extension point="org.eclipse.ui.editorActions">
+               <editorContribution
+                       id="org.eclipse.wst.jsdt.web.core.jspsource.source.editorActions"
+                       contributorClass="org.eclipse.wst.jsdt.internal.ui.javaeditor.CompilationUnitEditorActionContributor"
+                       targetID="org.eclipse.wst.html.core.htmlsource">
+                       <action
+                               id="CleanupDocument"
+                               label="%CleanupDocument_label"
+                               definitionId="org.eclipse.wst.sse.ui.cleanup.document"
+                               tooltip="%CleanupDocument_tooltip"
+                               class="org.eclipse.wst.html.ui.internal.edit.ui.CleanupActionHTMLDelegate"
+                               actionID="CleanupDocument">
+                       </action>
+                       <action
+                               id="ToggleComment"
+                               label="%ToggleComment_label"
+                               definitionId="org.eclipse.wst.sse.ui.toggle.comment"
+                               tooltip="%ToggleComment_tooltip"
+                               class="org.eclipse.wst.xml.ui.internal.actions.ToggleCommentActionXMLDelegate"
+                               actionID="ToggleComment">
+                       </action>
+                       <action
+                               id="AddBlockComment"
+                               label="%AddBlockComment_label"
+                               definitionId="org.eclipse.wst.sse.ui.add.block.comment"
+                               tooltip="%AddBlockComment_tooltip"
+                               class="org.eclipse.wst.xml.ui.internal.actions.AddBlockCommentActionXMLDelegate"
+                               actionID="AddBlockComment">
+                       </action>
+                       <action
+                               id="RemoveBlockComment"
+                               label="%RemoveBlockComment_label"
+                               definitionId="org.eclipse.wst.sse.ui.remove.block.comment"
+                               tooltip="%RemoveBlockComment_tooltip"
+                               class="org.eclipse.wst.xml.ui.internal.actions.RemoveBlockCommentActionXMLDelegate"
+                               actionID="RemoveBlockComment">
+                       </action>
+                       <action
+                               id="RenameElement"
+                               label="%RenameElement_label"
+                               definitionId="org.eclipse.wst.jsdt.web.ui.refactor.rename"
+                               class="org.eclipse.wst.jsdt.web.ui.internal.java.refactoring.JSPRenameElementActionDelegate"
+                               actionID="RenameElement">
+                       </action>
+                       <action
+                               id="MoveElement"
+                               label="%MoveElement_label"
+                               definitionId="org.eclipse.wst.jsdt.web.ui.refactor.move"
+                               class="org.eclipse.wst.jsdt.web.ui.internal.java.refactoring.JSPMoveElementActionDelegate"
+                               actionID="MoveElement">
+                       </action>
+                       <action
+                               id="FindOccurrences"
+                               label="%FindOccurrences_label"
+                               definitionId="org.eclipse.wst.sse.ui.search.find.occurrences"
+                               class="org.eclipse.wst.jsdt.web.ui.internal.java.search.JsFindOccurrencesActionDelegate"
+                               actionID="FindOccurrences">
+                       </action>
+                       <action
+                               id="StructureSelectEnclosing"
+                               label="%StructureSelectEnclosing_label"
+                               definitionId="org.eclipse.wst.sse.ui.structure.select.enclosing"
+                               tooltip="%StructureSelectEnclosing_tooltip"
+                               class="org.eclipse.wst.xml.ui.internal.selection.StructuredSelectEnclosingXMLActionDelegate"
+                               actionID="StructureSelectEnclosing">
+                       </action>
+                       <action
+                               id="StructureSelectNext"
+                               label="%StructureSelectNext_label"
+                               definitionId="org.eclipse.wst.sse.ui.structure.select.next"
+                               tooltip="%StructureSelectNext_tooltip"
+                               class="org.eclipse.wst.xml.ui.internal.selection.StructuredSelectNextXMLActionDelegate"
+                               actionID="StructureSelectNext">
+                       </action>
+                       <action
+                               id="StructureSelectPrevious"
+                               label="%StructureSelectPrevious_label"
+                               definitionId="org.eclipse.wst.sse.ui.structure.select.previous"
+                               tooltip="%StructureSelectPrevious_tooltip"
+                               class="org.eclipse.wst.xml.ui.internal.selection.StructuredSelectPreviousXMLActionDelegate"
+                               actionID="StructureSelectPrevious">
+                       </action>
+                       <action
+                               id="StructureSelectHistory"
+                               label="%StructureSelectHistory_label"
+                               definitionId="org.eclipse.wst.sse.ui.structure.select.last"
+                               tooltip="%StructureSelectHistory_tooltip"
+                               class="org.eclipse.wst.sse.ui.internal.selection.StructuredSelectHistoryActionDelegate"
+                               actionID="StructureSelectHistory">
+                       </action>
+               </editorContribution>
+        <editorContribution
+            targetID="org.eclipse.wst.html.core.htmlsource"
+            id="org.eclipse.wst.jsdt.web.core.jspsource.ruler.actions">
+         <action
+               label="%AddBookmark.label"
+               helpContextId="org.eclipse.ui.bookmark_action_context"
+               class="org.eclipse.ui.texteditor.BookmarkRulerAction"
+               actionID="RulerDoubleClick"
+               id="org.eclipse.ui.texteditor.BookmarkRulerAction"/>
+         <action
+               label="%SelectRuler.label"
+               class="org.eclipse.ui.texteditor.SelectRulerAction"
+               actionID="RulerClick"
+               id="org.eclipse.ui.texteditor.SelectRulerAction"/>
+        </editorContribution>
+       </extension>
+       -->
+               <!--======================================================================================-->
+       <!-- FOR JSP/JAVA RENAME PARTICIPATION                                                    -->
+       <!--======================================================================================-->
+       <extension
+               point="org.eclipse.ltk.core.refactoring.renameParticipants">
+               <renameParticipant
+                       name="%renameParticipant.name.0"
+                       class="org.eclipse.wst.jsdt.web.ui.internal.java.refactoring.JSPTypeRenameParticipant"
+                       id="org.eclipse.wst.jsdt.web.ui.internal.java.refactoring.JSPTypeRenameParticipant">
+                       <enablement>
+                               <with variable="affectedNatures">
+                                       <iterate operator="or">
+                                               <equals value="org.eclipse.wst.jsdt.core.jsNature" />
+                                       </iterate>
+                               </with>
+                               <with variable="element">
+                                       <instanceof value="org.eclipse.wst.jsdt.core.IType" />
+
+                               </with>
+                       </enablement>
+               </renameParticipant>
+               <renameParticipant
+                       name="%renameParticipant.name.1"
+                       class="org.eclipse.wst.jsdt.web.ui.internal.java.refactoring.JSPTypeRenameParticipant"
+                       id="org.eclipse.wst.jsdt.web.ui.internal.java.refactoring.JSPTypeRenameParticipant">
+                       <enablement>
+                               <with variable="affectedNatures">
+                                       <iterate operator="or">
+                                               <equals value="org.eclipse.wst.jsdt.core.jsNature" />
+                                       </iterate>
+                               </with>
+                               <with variable="element">
+                                       <instanceof value="org.eclipse.wst.jsdt.web.ui.views.contentoutline.IJavaWebNode" />
+
+                               </with>
+                       </enablement>
+               </renameParticipant>
+               <renameParticipant
+                       name="%renameParticipant.name.2"
+                       class="org.eclipse.wst.jsdt.web.ui.internal.java.refactoring.JSPMethodRenameParticipant"
+                       id="org.eclipse.wst.jsdt.web.ui.internal.java.refactoring.JSPMethodRenameParticipant">
+                       <enablement>
+                               <with variable="affectedNatures">
+                                       <iterate operator="or">
+                                               <equals value="org.eclipse.wst.jsdt.core.jsNature" />
+
+                                       </iterate>
+                               </with>
+                               <with variable="element">
+                                       <instanceof value="org.eclipse.wst.jsdt.core.IFunction" />
+
+                               </with>
+                       </enablement>
+               </renameParticipant>
+               <renameParticipant
+                       name="%renameParticipant.name.3"
+                       class="org.eclipse.wst.jsdt.web.ui.internal.java.refactoring.JSPMethodRenameParticipant"
+                       id="org.eclipse.wst.jsdt.web.ui.internal.java.refactoring.JSPMethodRenameParticipant">
+                       <enablement>
+                               <with variable="affectedNatures">
+                                       <iterate operator="or">
+                                               <equals value="org.eclipse.wst.jsdt.core.jsNature" />
+
+                                       </iterate>
+                               </with>
+                               <with variable="element">
+                                       <instanceof value="org.eclipse.wst.jsdt.web.ui.views.contentoutline.IJavaWebNode" />
+
+                               </with>
+                       </enablement>
+               </renameParticipant>
+
+         </extension>
+
+         <!--
+  <extension point="org.eclipse.wst.jsdt.ui.JsGlobalScopeUIInitializer">
+     <JsGlobalScopeUIInitializer
+       id="org.eclipse.wst.jsdt.launching.WebProject"
+       class="org.eclipse.wst.jsdt.web.ui.WebProjectJsGlobalScopeUIInitializer">
+     </JsGlobalScopeUIInitializer>
+   </extension>
+-->
+
+        <!--
+        <extension
+         point="org.eclipse.ui.popupMenus">
+               <objectContribution
+            objectClass="org.eclipse.core.resources.IProject"
+            adaptable="true"
+            id="org.eclipse.wst.jsdt.web.ui.jsdtSetup">
+                <visibility>
+               <not>
+                       <or>
+                           <objectState 
+                                   name="projectNature" 
+                                   value="org.eclipse.wst.jsdt.core.jsNature"/>
+                               <objectState
+                                       name="open"
+                                       value="false"/>
+                   </or>
+            </not>
+                </visibility>
+         <action
+            class="org.eclipse.wst.jsdt.web.ui.SetupProjectsWizzard"
+            label="%action.label.21"
+            menubarPath="org.eclipse.ui.projectConfigure/additions"
+            enablesFor="+"
+            id="org.eclipse.wst.jsdt.internal.web.ui.convertProjects">
+       </action>
+               </objectContribution>
+   </extension> 
+-->
+    <extension
+          point="org.eclipse.wst.sse.ui.commentingStrategy">
+       <blockCommentingStrategy
+             prefix="/*"
+             suffix="*/">
+          <contentType
+                id="org.eclipse.wst.html.core.htmlsource">
+             <requiredPartitionTypes>
+                <partitionType
+                      id="org.eclipse.wst.html.SCRIPT">
+                </partitionType>
+             </requiredPartitionTypes>
+             <allowablePartitionTypes
+                   anyPartitionType="false">
+             </allowablePartitionTypes>
+          </contentType>
+          <contentType
+                id="org.eclipse.jst.jsp.core.jspsource">
+             <requiredPartitionTypes>
+                <partitionType
+                      id="org.eclipse.wst.html.SCRIPT">
+                </partitionType>
+                <partitionType
+                      id="org.eclipse.jst.jsp.SCRIPT.JAVASCRIPT">
+                </partitionType>
+             </requiredPartitionTypes>
+             <allowablePartitionTypes
+                   anyPartitionType="false">
+             </allowablePartitionTypes>
+          </contentType>
+       </blockCommentingStrategy>
+       <lineCommentingStrategy
+             prefix="//">
+          <contentType
+                id="org.eclipse.wst.html.core.htmlsource">
+             <requiredPartitionTypes>
+                <partitionType
+                      id="org.eclipse.wst.html.SCRIPT">
+                </partitionType>
+             </requiredPartitionTypes>
+             <allowablePartitionTypes
+                   anyPartitionType="false">
+             </allowablePartitionTypes>
+          </contentType>
+          <contentType
+                id="org.eclipse.jst.jsp.core.jspsource">
+             <requiredPartitionTypes>
+                <partitionType
+                      id="org.eclipse.wst.html.SCRIPT">
+                </partitionType>
+                <partitionType
+                      id="org.eclipse.jst.jsp.SCRIPT.JAVASCRIPT">
+                </partitionType>
+             </requiredPartitionTypes>
+             <allowablePartitionTypes
+                   anyPartitionType="false">
+             </allowablePartitionTypes>
+          </contentType>
+       </lineCommentingStrategy>
+    </extension> 
+
+        <!-- Uncomment for Standalone + HTML as seperate options -->
+        <!--
+        <extension
+         point="org.eclipse.ui.popupMenus">
+               <objectContribution
+            objectClass="org.eclipse.core.resources.IProject"
+            adaptable="true"
+            id="org.eclipse.wst.jsdt.web.ui.jsdtSetup">
+         <action
+            label="Add Support for JavaScript in HTML"
+            class="org.eclipse.wst.jsdt.web.ui.SetupProjectsWizzard"
+            menubarPath="org.eclipse.wst.jsdt.ui.project.tools/group0"
+            enablesFor="+"
+            id="org.eclipse.wst.jsdt.web.internal.ui.convertProjects">
+       </action>
+               </objectContribution>
+   </extension>  
+   -->
+ <extension point="org.eclipse.wst.sse.ui.completionProposal">
+  <proposalCategory
+      id="org.eclipse.wst.jsdt.web.ui.ContentAssistProposals"
+      name="%javaScriptProposals"
+      icon="icons/full/elcl16/javaassist_co.gif">
+  </proposalCategory>
+  <proposalComputer
+      activate="true"
+      categoryId="org.eclipse.wst.jsdt.web.ui.ContentAssistProposals"
+      class="org.eclipse.wst.jsdt.web.ui.internal.contentassist.JSDTContentAssistant"
+      id="org.eclipse.wst.jsdt.web.ui.ContentAssistProposals">
+     <contentType
+        id="org.eclipse.wst.html.core.htmlsource">
+      <partitionType
+            autoActivationDelegate="org.eclipse.wst.jsdt.web.ui.contentassist.JSDTAutoActivationDelegate"
+            id="org.eclipse.wst.html.SCRIPT">
+      </partitionType>
+            <partitionType
+                  autoActivationDelegate="org.eclipse.wst.jsdt.web.ui.contentassist.JSDTAutoActivationDelegate"
+                  id="org.eclipse.wst.html.SCRIPT.EVENTHANDLER">
+      </partitionType>
+    </contentType>
+  </proposalComputer>
+</extension>
+<extension point="org.eclipse.wst.sse.ui.characterPairing">
+       <inserter class="org.eclipse.wst.jsdt.web.ui.internal.text.JsCharacterPairInserter" id="org.eclipse.wst.jsdt.web.ui.inserter">
+         <contentTypeIdentifier
+               id="org.eclipse.wst.html.core.htmlsource"
+               partitions="org.eclipse.wst.html.SCRIPT, org.eclipse.wst.html.SCRIPT.EVENTHANDLER">
+         </contentTypeIdentifier>
+       </inserter>
+</extension>
+
+   <extension point="org.eclipse.ui.ide.markerSupport">
+      <markerTypeCategory name="%markerCategory.problem">
+         <markerTypeReference id="org.eclipse.wst.jsdt.web.core.problem"/>
+      </markerTypeCategory>
+   </extension>
+
+</plugin>
diff --git a/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/Messages.java b/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/Messages.java
new file mode 100644 (file)
index 0000000..3c7655f
--- /dev/null
@@ -0,0 +1,46 @@
+/*******************************************************************************
+ * 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.web.ui;
+
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+/**
+*
+
+* Provisional API: This class/interface is part of an interim API that is still under development and expected to
+* change significantly before reaching stability. It is being made available at this early stage to solicit feedback
+* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
+* (repeatedly) as the API evolves.
+*
+ * @author childsb
+ *
+ */
+public class Messages {
+       private static final String BUNDLE_NAME = "org.eclipse.wst.jsdt.web.ui.messages"; //$NON-NLS-1$
+
+       private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME);
+
+       private Messages() {
+       }
+
+       public static String getString(String key) {
+               try {
+                       return RESOURCE_BUNDLE.getString(key);
+               }
+               catch (MissingResourceException e) {
+                       return '!' + key + '!';
+               }
+       }
+}
diff --git a/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/SetupProjectsWizzard.java b/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/SetupProjectsWizzard.java
new file mode 100644 (file)
index 0000000..298210c
--- /dev/null
@@ -0,0 +1,219 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.wst.jsdt.web.ui;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtension;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.preference.PreferenceDialog;
+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.IActionDelegate;
+import org.eclipse.ui.IObjectActionDelegate;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.dialogs.PreferencesUtil;
+import org.eclipse.ui.progress.IProgressService;
+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.web.core.internal.Logger;
+import org.eclipse.wst.jsdt.web.core.internal.project.JsWebNature;
+import org.eclipse.wst.jsdt.web.ui.internal.JsUIPlugin;
+
+/**
+ * Not API
+ */
+public class SetupProjectsWizzard implements IObjectActionDelegate, IActionDelegate {
+       IWorkbenchPart fPart;
+       Object[] fTarget;
+
+       private void doInstall(IProject project, final boolean openProperties, IProgressMonitor monitor) {
+               boolean configured = false;
+               JsWebNature nature = new JsWebNature(project, monitor);
+               try {
+                       boolean hadBasicNature = JsWebNature.hasNature(project);
+
+                       nature.configure();
+
+                       if (!hadBasicNature) {
+                               /*
+                                * No nature before, so no existing build path. Define the
+                                * project itself as an include folder.
+                                */
+                               IJavaScriptProject jp = JavaScriptCore.create(project);
+                               IIncludePathEntry[] oldEntries = null;
+                               try {
+                                       oldEntries = jp.getRawIncludepath();
+                               }
+                               catch (JavaScriptModelException ex1) {
+                                       Logger.log(Logger.ERROR_DEBUG, null, ex1);
+                               }
+                               
+                               IPath projectPath = project.getFullPath();
+                               IIncludePathEntry projectPathEntry = JavaScriptCore.newSourceEntry(projectPath);
+                               
+                               if (! Arrays.asList(oldEntries).contains(projectPathEntry)) {
+                                       IIncludePathEntry[] newEntries = new IIncludePathEntry[oldEntries.length + 1];
+                                       System.arraycopy(oldEntries, 0, newEntries, 0, oldEntries.length);
+                                       
+                                       newEntries[oldEntries.length] = projectPathEntry;
+                                       jp.setRawIncludepath(newEntries, monitor);
+                               }
+                       }
+                       configured = true;
+               }
+               catch (CoreException ex) {
+                       Logger.logException(ex);
+               }
+
+               if (configured && openProperties) {
+                       showPropertiesOn(project, monitor);
+               }
+       }
+       
+       private void doUninstall(IProject project, IProgressMonitor monitor) {
+               JsWebNature nature = new JsWebNature(project, monitor);
+               try {
+                       nature.deconfigure();
+               } catch (CoreException ex) {
+                       Logger.logException(ex);
+               }
+       }
+
+       private void install(final IProject project, final boolean openProperties) {
+               IProgressService service = null;
+               if (fPart != null) {
+                       service = (IProgressService) fPart.getSite().getService(IProgressService.class);
+               }
+               if (service == null) {
+                       doInstall(project, openProperties, null);
+               }
+               else {
+                       IRunnableWithProgress runnable = new IRunnableWithProgress() {
+                               public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
+                                       doInstall(project, openProperties, monitor);
+                               }
+                       };
+                       try {
+                               service.run(false, false, runnable);
+                       }
+                       catch (InvocationTargetException e) {
+                               Logger.logException(e);
+                       }
+                       catch (InterruptedException e) {
+                               Logger.logException(e);
+                       }
+               }
+       }
+
+       public void run(IAction action) {
+               if (fTarget == null)
+                       return;
+
+               for (int i = 0; i < fTarget.length; i++) {
+                       if (fTarget[i] instanceof IResource) {
+                               final IProject project = ((IResource) fTarget[i]).getProject();
+
+                               if (!JsWebNature.hasNature(project)) {
+                                       /* Doesn't have nature, do a full install. */
+                                       install(project, i == fTarget.length - 1);
+                               }
+                               else {
+                                       /*
+                                        * Has nature, check for browser library on include path
+                                        * and setup if not found.
+                                        */
+                                       IJavaScriptProject jp = JavaScriptCore.create(project);
+                                       IIncludePathEntry[] rawClasspath = null;
+                                       try {
+                                               rawClasspath = jp.getRawIncludepath();
+                                       }
+                                       catch (JavaScriptModelException ex1) {
+                                               Logger.log(Logger.ERROR_DEBUG, null, ex1);
+                                       }
+
+                                       boolean browserFound = false;
+                                       for (int k = 0; rawClasspath != null && !browserFound && k < rawClasspath.length; k++) {
+                                               if (rawClasspath[k].getPath().equals(JsWebNature.VIRTUAL_BROWSER_CLASSPATH)) {
+                                                       browserFound = true;
+                                               }
+                                       }
+                                       if (!browserFound) {
+                                               install(project, false);
+                                       }
+                               }
+                       }
+               }
+
+       }
+
+       public void selectionChanged(IAction action, ISelection selection) {
+               if (selection instanceof IStructuredSelection) {
+                       fTarget = ((IStructuredSelection) selection).toArray();
+               }
+               else {
+                       fTarget = null;
+               }
+       }
+
+       public void setActivePart(IAction action, IWorkbenchPart targetPart) {
+               fPart = targetPart;
+       }
+
+       private void showPropertiesOn(final IProject project, final IProgressMonitor monitor) {
+               IExtension[] extensions = Platform.getExtensionRegistry().getExtensionPoint("org.eclipse.ui.propertyPages").getExtensions(); //$NON-NLS-1$
+               final List pageIds = new ArrayList(8);
+               for (int i = 0; i < extensions.length; i++) {
+                       if (extensions[i].getNamespaceIdentifier().startsWith("org.eclipse.wst.jsdt.")) { //$NON-NLS-1$
+                               IConfigurationElement[] configurationElements = extensions[i].getConfigurationElements();
+                               for (int j = 0; j < configurationElements.length; j++) {
+                                       if ("page".equals(configurationElements[j].getName())) {
+                                               pageIds.add(configurationElements[j].getAttribute("id")); //$NON-NLS-1$
+                                       }
+                               }
+                       }
+               }
+               Shell shell = (Shell) fPart.getAdapter(Shell.class);
+               if (shell == null) {
+                       IWorkbenchWindow activeWorkbenchWindow = JsUIPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow();
+                       if (activeWorkbenchWindow != null)
+                               shell = activeWorkbenchWindow.getShell();
+               }
+               final Shell finalShell = shell;
+               if (finalShell != null) {
+                       finalShell.getDisplay().asyncExec(new Runnable() {
+                               public void run() {
+                                       PreferenceDialog dialog = PreferencesUtil.createPropertyDialogOn(finalShell, project, "org.eclipse.wst.jsdt.ui.propertyPages.BuildPathsPropertyPage", (String[]) pageIds.toArray(new String[pageIds.size()]), null); //$NON-NLS-1$
+                                       if (dialog.open() == Window.CANCEL) {
+                                               doUninstall(project, monitor);
+                                       }
+                               }
+                       });
+               }
+       }
+}
\ No newline at end of file
diff --git a/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/StructuredTextViewerConfigurationJSDT.java b/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/StructuredTextViewerConfigurationJSDT.java
new file mode 100644 (file)
index 0000000..a1d8070
--- /dev/null
@@ -0,0 +1,57 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.web.ui;
+
+import org.eclipse.jface.text.IAutoEditStrategy;
+import org.eclipse.jface.text.source.ISourceViewer;
+import org.eclipse.wst.html.core.text.IHTMLPartitions;
+import org.eclipse.wst.html.ui.StructuredTextViewerConfigurationHTML;
+import org.eclipse.wst.jsdt.web.ui.internal.autoedit.AutoEditStrategyForJs;
+
+/**
+*
+
+* Provisional API: This class/interface is part of an interim API that is still under development and expected to
+* change significantly before reaching stability. It is being made available at this early stage to solicit feedback
+* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
+* (repeatedly) as the API evolves.
+* 
+ * Configuration for a source viewer which shows Html and supports JSDT.
+ * <p>
+ * Clients can subclass and override just those methods which must be specific
+ * to their needs.
+ * </p>
+ * 
+ * @see org.eclipse.wst.sse.ui.StructuredTextViewerConfiguration
+ * @since 1.0
+ */
+public class StructuredTextViewerConfigurationJSDT extends StructuredTextViewerConfigurationHTML {
+       /**
+        * Create new instance of StructuredTextViewerConfigurationHTML
+        */
+       public StructuredTextViewerConfigurationJSDT() {
+               // Must have empty constructor to createExecutableExtension
+               super();
+       }
+       
+       /**
+        * @see org.eclipse.wst.html.ui.StructuredTextViewerConfigurationHTML#getAutoEditStrategies(org.eclipse.jface.text.source.ISourceViewer, java.lang.String)
+        */
+       public IAutoEditStrategy[] getAutoEditStrategies(ISourceViewer sourceViewer, String contentType) {
+               if(contentType.equals(IHTMLPartitions.SCRIPT) || contentType.equals(IHTMLPartitions.SCRIPT_EVENTHANDLER)) {
+                       IAutoEditStrategy[] strategies = new IAutoEditStrategy[1];
+                       strategies[0] = new AutoEditStrategyForJs();
+                       return strategies;
+               } else {
+                       return super.getAutoEditStrategies(sourceViewer, contentType);
+               }
+       }
+}
diff --git a/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/WebProjectJsGlobalScopeUIInitializer.java b/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/WebProjectJsGlobalScopeUIInitializer.java
new file mode 100644 (file)
index 0000000..03aecce
--- /dev/null
@@ -0,0 +1,38 @@
+/*******************************************************************************
+ * 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.web.ui;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.wst.jsdt.core.IJavaScriptProject;
+import org.eclipse.wst.jsdt.internal.ui.IJsGlobalScopeContainerInitializerExtension;
+/**
+*
+
+* Provisional API: This class/interface is part of an interim API that is still under development and expected to
+* change significantly before reaching stability. It is being made available at this early stage to solicit feedback
+* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
+* (repeatedly) as the API evolves.
+*
+ * @author childsb
+ *
+ */
+public class WebProjectJsGlobalScopeUIInitializer implements IJsGlobalScopeContainerInitializerExtension{
+       /* (non-Javadoc)
+        * @see org.eclipse.wst.jsdt.internal.ui.IJsGlobalScopeContainerInitialzerExtension#getImage(org.eclipse.core.runtime.IPath, java.lang.String, org.eclipse.wst.jsdt.core.IJavaScriptProject)
+        */
+       public ImageDescriptor getImage(IPath containerPath, String element, IJavaScriptProject project) {
+               return ImageDescriptor.createFromFile(this.getClass(),"web1.JPG"); //$NON-NLS-1$
+       }
+}
diff --git a/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/actions/AddJavaDocStubAction.java b/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/actions/AddJavaDocStubAction.java
new file mode 100644 (file)
index 0000000..560444c
--- /dev/null
@@ -0,0 +1,100 @@
+/*******************************************************************************
+ * 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.web.ui.actions;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IObjectActionDelegate;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.IWorkbenchPartSite;
+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.IMember;
+import org.eclipse.wst.jsdt.internal.ui.actions.WorkbenchRunnableAdapter;
+import org.eclipse.wst.jsdt.internal.ui.util.ExceptionHandler;
+import org.eclipse.wst.jsdt.web.ui.views.contentoutline.JsJfaceNode;
+/**
+*
+
+* Provisional API: This class/interface is part of an interim API that is still under development and expected to
+* change significantly before reaching stability. It is being made available at this early stage to solicit feedback
+* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
+* (repeatedly) as the API evolves.
+*
+ * @author childsb
+ * 
+ */
+public class AddJavaDocStubAction implements IObjectActionDelegate {
+       private ISelection selection;
+       private IWorkbenchPart targetPart;
+       
+       public String getDialogTitle() {
+               return Messages.getString("AddJavaDocStubAction.0"); //$NON-NLS-1$
+       }
+       
+       public Shell getShell() {
+               return getSite().getShell();
+       }
+       
+       public IWorkbenchPartSite getSite() {
+               return targetPart.getSite();
+       }
+       
+       public void run(IAction action) {
+               IJavaScriptElement[] elements = JsElementActionProxy.getJsElementsFromSelection(selection);
+               if (elements == null || elements.length < 1) {
+                       return;
+               }
+               IJavaScriptElement parent = elements[0].getParent();
+               /* find the cu */
+               while (parent != null && !(parent instanceof IJavaScriptUnit)) {
+                       
+               }
+               if (parent != null) {
+                       ArrayList members = new ArrayList();
+                       for (int i = 0; i < elements.length; i++) {
+                               if (elements[i] instanceof IMember) {
+                                       members.add(elements[i]);
+                               }
+                       }
+                       JsJfaceNode node[] = SimpleJSDTActionProxy.getJsJfaceNodesFromSelection(selection);
+                       /* only should be one node */
+                       run((IJavaScriptUnit) parent, (IMember[]) members.toArray(new IMember[members.size()]), node[0]);
+               }
+       }
+       
+       public void run(IJavaScriptUnit cu, IMember[] members, JsJfaceNode node) {
+               try {
+                       AddJavaDocStubOperation op = new AddJavaDocStubOperation(members, node);
+                       PlatformUI.getWorkbench().getProgressService().runInUI(PlatformUI.getWorkbench().getProgressService(), new WorkbenchRunnableAdapter(op, op.getScheduleRule()), op.getScheduleRule());
+               } catch (InvocationTargetException e) {
+                       ExceptionHandler.handle(e, getShell(), getDialogTitle(), Messages.getString("AddJavaDocStubAction.1")); //$NON-NLS-1$
+               } catch (InterruptedException e) {
+                       // operation canceled
+               }
+       }
+       
+       public void selectionChanged(IAction action, ISelection selection) {
+               this.selection = selection;
+       }
+       
+       public void setActivePart(IAction action, IWorkbenchPart targetPart) {
+               this.targetPart = targetPart;
+       }
+}
diff --git a/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/actions/AddJavaDocStubOperation.java b/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/actions/AddJavaDocStubOperation.java
new file mode 100644 (file)
index 0000000..edde605
--- /dev/null
@@ -0,0 +1,110 @@
+/*******************************************************************************
+ * 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.web.ui.actions;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.Document;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.text.edits.MalformedTreeException;
+import org.eclipse.text.edits.MultiTextEdit;
+import org.eclipse.wst.jsdt.core.IJavaScriptUnit;
+import org.eclipse.wst.jsdt.core.IMember;
+import org.eclipse.wst.jsdt.web.core.javascript.DocumentChangeListenerToTextEdit;
+import org.eclipse.wst.jsdt.web.core.javascript.IJsTranslation;
+
+import org.eclipse.wst.jsdt.web.ui.views.contentoutline.JsJfaceNode;
+import org.eclipse.wst.sse.core.StructuredModelManager;
+import org.eclipse.wst.sse.core.internal.provisional.IModelManager;
+import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
+import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument;
+/**
+*
+
+* Provisional API: This class/interface is part of an interim API that is still under development and expected to
+* change significantly before reaching stability. It is being made available at this early stage to solicit feedback
+* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
+* (repeatedly) as the API evolves.
+*
+ * @author childsb
+ * 
+ */
+public class AddJavaDocStubOperation extends org.eclipse.wst.jsdt.internal.corext.codemanipulation.AddJavaDocStubOperation {
+       private IDocument copy;
+       /**
+        * @param members
+        */
+       private JsJfaceNode node;
+       private DocumentChangeListenerToTextEdit textEditListener;
+       
+       public AddJavaDocStubOperation(IMember[] members, JsJfaceNode node) {
+               super(members);
+               this.node = node;
+       }
+       
+       protected void applyChanges() {
+               IModelManager modelManager = StructuredModelManager.getModelManager();
+               IStructuredModel model = null;
+               IStructuredDocument doc = node.getStructuredDocument();
+               try {
+                       MultiTextEdit edits = textEditListener.getTextEdits();
+                       model = modelManager.getExistingModelForEdit(doc);
+                       model.aboutToChangeModel();
+                       model.beginRecording(this, Messages.getString("AddJavaDocStubOperation.0"), Messages.getString("AddJavaDocStubOperation.1")); //$NON-NLS-1$ //$NON-NLS-2$
+                       edits.apply(doc);
+               } catch (MalformedTreeException ex) {
+                       // TODO Auto-generated catch block
+                       ex.printStackTrace();
+               } catch (BadLocationException ex) {
+                       // TODO Auto-generated catch block
+                       ex.printStackTrace();
+               } finally {
+                       if (model != null) {
+                               model.endRecording(this);
+                               model.changedModel();
+                               model.releaseFromEdit();
+                       }
+               }
+       }
+       
+       /*
+        * (non-Javadoc)
+        * 
+        * @see org.eclipse.wst.jsdt.internal.corext.codemanipulation.AddJavaDocStubOperation#getDocument(org.eclipse.wst.jsdt.core.IJavaScriptUnit,
+        *      org.eclipse.core.runtime.IProgressMonitor)
+        */
+       
+       protected IDocument getDocument(IJavaScriptUnit cu, IProgressMonitor monitor) throws CoreException {
+               return getJavaDocumentFromNode();
+       }
+       
+       protected IDocument getJavaDocumentFromNode() {
+               if (copy == null) {
+                       IJsTranslation tran = node.getTranslation();
+                       copy = new Document(tran.getJsText());
+                       textEditListener = new DocumentChangeListenerToTextEdit();
+                       copy.addDocumentListener(textEditListener);
+               }
+               return copy;
+       }
+       
+       
+       public void run(IProgressMonitor monitor) throws CoreException, OperationCanceledException {
+               super.run(monitor);
+               applyChanges();
+               /* need to apply the text edits back to the original doc */
+       }
+}
diff --git a/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/actions/FindReferencesAction.java b/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/actions/FindReferencesAction.java
new file mode 100644 (file)
index 0000000..28a4c70
--- /dev/null
@@ -0,0 +1,60 @@
+/*******************************************************************************
+ * 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.web.ui.actions;
+
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.wst.jsdt.core.IJavaScriptElement;
+
+/**
+*
+
+* Provisional API: This class/interface is part of an interim API that is still under development and expected to
+* change significantly before reaching stability. It is being made available at this early stage to solicit feedback
+* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
+* (repeatedly) as the API evolves.
+*
+ * @author childsb
+ * 
+ */
+public class FindReferencesAction extends JsElementActionProxy {
+       /*
+        * (non-Javadoc)
+        * 
+        * @see org.eclipse.wst.jsdt.web.ui.actions.JsElementActionProxy#getRunArgs(org.eclipse.jface.action.IAction)
+        */
+       
+       public Object[] getRunArgs(IAction action) {
+               IJavaScriptElement elements[] = JsElementActionProxy.getJsElementsFromSelection(getCurrentSelection());
+               if (elements != null && elements.length > 0) {
+                       return new Object[] { elements[0] };
+               }
+               return new Object[0];
+       }
+       
+       /*
+        * (non-Javadoc)
+        * 
+        * @see org.eclipse.wst.jsdt.web.ui.actions.JsElementActionProxy#getRunArgTypes()
+        */
+       
+       public Class[] getRunArgTypes() {
+               return new Class[] { IJavaScriptElement.class };
+       }
+       
+       
+       public void selectionChanged(IAction action, ISelection selection) {
+               setSelection(selection);
+       }
+}
diff --git a/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/actions/FindReferencesInWorkingSetAction.java b/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/actions/FindReferencesInWorkingSetAction.java
new file mode 100644 (file)
index 0000000..0c8f424
--- /dev/null
@@ -0,0 +1,61 @@
+/*******************************************************************************
+ * 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.web.ui.actions;
+
+import java.lang.reflect.InvocationTargetException;
+
+import org.eclipse.jface.action.IAction;
+import org.eclipse.wst.jsdt.core.IJavaScriptElement;
+/**
+*
+
+* Provisional API: This class/interface is part of an interim API that is still under development and expected to
+* change significantly before reaching stability. It is being made available at this early stage to solicit feedback
+* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
+* (repeatedly) as the API evolves.
+*
+ * @author childsb
+ * 
+ */
+public class FindReferencesInWorkingSetAction extends FindReferencesAction {
+       
+       public void run(IAction action) {
+               try {
+                       Object handler = getActionHandler(action);
+                       IJavaScriptElement elements[] = JsElementActionProxy.getJsElementsFromSelection(getCurrentSelection());
+                       if (elements == null || elements.length == 0) {
+                               return;
+                       }
+                       SimpleJSDTActionProxy.executeMethod(handler, "run", new Class[] { IJavaScriptElement.class }, new Object[] { elements[0] }); //$NON-NLS-1$
+               } catch (IllegalArgumentException ex) {
+                       // TODO Auto-generated catch block
+                       ex.printStackTrace();
+               } catch (SecurityException ex) {
+                       // TODO Auto-generated catch block
+                       ex.printStackTrace();
+               } catch (IllegalAccessException ex) {
+                       // TODO Auto-generated catch block
+                       ex.printStackTrace();
+               } catch (NoSuchMethodException ex) {
+                       // TODO Auto-generated catch block
+                       ex.printStackTrace();
+               } catch (InstantiationException ex) {
+                       // TODO Auto-generated catch block
+                       ex.printStackTrace();
+               } catch (InvocationTargetException ex) {
+                       // If user doesn't select a working set an exception is thrown so we
+                       // wont print stack trace here
+               }
+       }
+}
diff --git a/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/actions/JsElementActionProxy.java b/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/actions/JsElementActionProxy.java
new file mode 100644 (file)
index 0000000..00771fa
--- /dev/null
@@ -0,0 +1,77 @@
+/*******************************************************************************
+ * 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.web.ui.actions;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.wst.jsdt.core.IJavaScriptElement;
+import org.eclipse.wst.jsdt.web.ui.views.contentoutline.IJavaWebNode;
+
+/**
+*
+
+* Provisional API: This class/interface is part of an interim API that is still under development and expected to
+* change significantly before reaching stability. It is being made available at this early stage to solicit feedback
+* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
+* (repeatedly) as the API evolves.
+*
+ * @author childsb
+ * 
+ */
+public class JsElementActionProxy extends SimpleJSDTActionProxy {
+       /* Util method to get all the java elements in a selection */
+       public static IJavaScriptElement[] getJsElementsFromSelection(ISelection selection) {
+               if (selection == null) {
+                       return new IJavaScriptElement[0];
+               }
+               ArrayList elements = new ArrayList();
+               if (selection instanceof IStructuredSelection) {
+                       Iterator itt = ((IStructuredSelection) selection).iterator();
+                       while (itt.hasNext()) {
+                               Object element = itt.next();
+                               if (element instanceof IJavaScriptElement) {
+                                       elements.add(element);
+                               }
+                               if (element instanceof IJavaWebNode) {
+                                       elements.add(((IJavaWebNode) element).getJavaElement());
+                               }
+                       }
+                       return (IJavaScriptElement[]) elements.toArray(new IJavaScriptElement[elements.size()]);
+               }
+               return new IJavaScriptElement[0];
+       }
+       
+       
+       public Object[] getRunArgs(IAction action) {
+               /*
+                * Needs to return an array of IJavaElements. Since its one arg of type
+                * IJavaScriptElement[] need to put into an object array
+                */
+               return new Object[] { JsElementActionProxy.getJsElementsFromSelection(getCurrentSelection()) };
+       }
+       
+       /*
+        * (non-Javadoc)
+        * 
+        * @see org.eclipse.wst.jsdt.web.ui.actions.SimpleJSDTActionProxy#getRunArgTypes()
+        */
+       
+       public Class[] getRunArgTypes() {
+               return new Class[] { (new IJavaScriptElement[0]).getClass() };
+       }
+}
diff --git a/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/actions/Messages.java b/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/actions/Messages.java
new file mode 100644 (file)
index 0000000..0bfa17b
--- /dev/null
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * 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.web.ui.actions;
+
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+/**
+*
+
+* Provisional API: This class/interface is part of an interim API that is still under development and expected to
+* change significantly before reaching stability. It is being made available at this early stage to solicit feedback
+* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
+* (repeatedly) as the API evolves.
+*
+ * @author childsb
+ *
+ */
+public class Messages {
+       private static final String BUNDLE_NAME = "org.eclipse.wst.jsdt.web.ui.actions.messages"; //$NON-NLS-1$
+
+       private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME);
+
+       private Messages() {
+       }
+
+       public static String getString(String key) {
+               try {
+                       return RESOURCE_BUNDLE.getString(key);
+               }
+               catch (MissingResourceException e) {
+                       return '!' + key + '!';
+               }
+       }
+}
diff --git a/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/actions/OpenCallHierarchyAction.java b/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/actions/OpenCallHierarchyAction.java
new file mode 100644 (file)
index 0000000..06083a3
--- /dev/null
@@ -0,0 +1,50 @@
+/*******************************************************************************
+ * 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.web.ui.actions;
+
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.wst.jsdt.core.IJavaScriptElement;
+
+/**
+*
+
+* Provisional API: This class/interface is part of an interim API that is still under development and expected to
+* change significantly before reaching stability. It is being made available at this early stage to solicit feedback
+* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
+* (repeatedly) as the API evolves.
+*
+ * @author childsb
+ * 
+ */
+public class OpenCallHierarchyAction extends JsElementActionProxy {
+       /*
+        * (non-Javadoc)
+        * 
+        * @see org.eclipse.wst.jsdt.web.ui.actions.SimpleJSDTActionProxy#selectionChanged(org.eclipse.jface.action.IAction,
+        *      org.eclipse.jface.viewers.ISelection)
+        */
+       
+       public void selectionChanged(IAction action, ISelection selection) {
+               IJavaScriptElement[] elements = JsElementActionProxy.getJsElementsFromSelection(selection);
+               /* Open call hierarchy needs to be disabled for TYPEs */
+               for (int i = 0; i < elements.length; i++) {
+                       if (elements[i].getElementType() == IJavaScriptElement.TYPE) {
+                               action.setEnabled(false);
+                               return;
+                       }
+               }
+               super.selectionChanged(action, selection);
+       }
+}
diff --git a/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/actions/OpenTypeHierarchy.java b/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/actions/OpenTypeHierarchy.java
new file mode 100644 (file)
index 0000000..405a4c6
--- /dev/null
@@ -0,0 +1,43 @@
+/*******************************************************************************
+ * 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.web.ui.actions;
+
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.wst.jsdt.core.IJavaScriptElement;
+/**
+*
+
+* Provisional API: This class/interface is part of an interim API that is still under development and expected to
+* change significantly before reaching stability. It is being made available at this early stage to solicit feedback
+* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
+* (repeatedly) as the API evolves.
+*
+ * @author childsb
+ * 
+ */
+public class OpenTypeHierarchy extends JsElementActionProxy {
+       
+       public void selectionChanged(IAction action, ISelection selection) {
+               IJavaScriptElement[] elements = JsElementActionProxy.getJsElementsFromSelection(selection);
+               /* Open call hierarchy needs to be disabled for TYPEs */
+               for (int i = 0; i < elements.length; i++) {
+                       if (elements[i].getElementType() != IJavaScriptElement.TYPE) {
+                               action.setEnabled(false);
+                               return;
+                       }
+               }
+               super.selectionChanged(action, selection);
+       }
+}
diff --git a/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/actions/ShowHistoryAction.java b/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/actions/ShowHistoryAction.java
new file mode 100644 (file)
index 0000000..678c02f
--- /dev/null
@@ -0,0 +1,94 @@
+/*******************************************************************************
+ * 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.web.ui.actions;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.ui.IPageLayout;
+import org.eclipse.ui.IViewPart;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.part.ISetSelectionTarget;
+import org.eclipse.wst.jsdt.core.IJavaScriptElement;
+import org.eclipse.wst.jsdt.internal.ui.util.ExceptionHandler;
+/**
+*
+
+* Provisional API: This class/interface is part of an interim API that is still under development and expected to
+* change significantly before reaching stability. It is being made available at this early stage to solicit feedback
+* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
+* (repeatedly) as the API evolves.
+*
+ * @author childsb
+ * 
+ */
+public class ShowHistoryAction extends JsElementActionProxy {
+       /*
+        * (non-Javadoc)
+        * 
+        * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
+        */
+       private IResource getHostResource(IJavaScriptElement virtualElement) {
+               IProject project = virtualElement.getJavaScriptProject().getProject();
+               IPath path = new Path(virtualElement.getHostPath().getPath());
+               IResource host = project.getWorkspace().getRoot().findMember(path);
+               return host;
+       }
+       
+       
+       public void run(IAction action) {
+               IJavaScriptElement elements[] = JsElementActionProxy.getJsElementsFromSelection(getCurrentSelection());
+               if (elements == null || elements.length == 0) {
+                       return;
+               }
+               IResource resource = null;
+               if (elements[0].isVirtual()) {
+                       resource = getHostResource(elements[0]);
+               } else {
+                       resource = elements[0].getResource();
+               }
+               if (resource == null) {
+                       return;
+               }
+               try {
+                       IWorkbenchPage page = targetWorkbenchPart.getSite().getPage();
+                       IViewPart view = page.showView(IPageLayout.ID_RES_NAV);
+                       if (view instanceof ISetSelectionTarget) {
+                               ISelection selection = new StructuredSelection(resource);
+                               ((ISetSelectionTarget) view).selectReveal(selection);
+                       }
+               } catch (PartInitException e) {
+                       ExceptionHandler.handle(e, targetWorkbenchPart.getSite().getShell(), Messages.getString("ShowHistoryAction.0"), Messages.getString("ShowHistoryAction.1") + e); //$NON-NLS-1$ //$NON-NLS-2$
+               }
+       }
+       
+       
+       public void selectionChanged(IAction action, ISelection selection) {
+               setSelection(selection);
+               IJavaScriptElement elements[] = JsElementActionProxy.getJsElementsFromSelection(getCurrentSelection());
+               for (int i = 0; i < elements.length; i++) {
+                       if (elements[i].isVirtual()) {
+                               IResource resource = getHostResource(elements[i]);
+                               if (resource == null || !resource.exists()) {
+                                       action.setEnabled(false);
+                               }
+                       }
+               }
+       }
+}
diff --git a/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/actions/ShowInNavigatorAction.java b/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/actions/ShowInNavigatorAction.java
new file mode 100644 (file)
index 0000000..628b942
--- /dev/null
@@ -0,0 +1,94 @@
+/*******************************************************************************
+ * 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.web.ui.actions;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.ui.IPageLayout;
+import org.eclipse.ui.IViewPart;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.part.ISetSelectionTarget;
+import org.eclipse.wst.jsdt.core.IJavaScriptElement;
+import org.eclipse.wst.jsdt.internal.ui.util.ExceptionHandler;
+/**
+*
+
+* Provisional API: This class/interface is part of an interim API that is still under development and expected to
+* change significantly before reaching stability. It is being made available at this early stage to solicit feedback
+* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
+* (repeatedly) as the API evolves.
+*
+ * @author childsb
+ * 
+ */
+public class ShowInNavigatorAction extends JsElementActionProxy {
+       /*
+        * (non-Javadoc)
+        * 
+        * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
+        */
+       private IResource getHostResource(IJavaScriptElement virtualElement) {
+               IProject project = virtualElement.getJavaScriptProject().getProject();
+               IPath path = new Path(virtualElement.getHostPath().getPath());
+               IResource host = project.getWorkspace().getRoot().findMember(path);
+               return host;
+       }
+       
+       
+       public void run(IAction action) {
+               IJavaScriptElement elements[] = JsElementActionProxy.getJsElementsFromSelection(getCurrentSelection());
+               if (elements == null || elements.length == 0) {
+                       return;
+               }
+               IResource resource = null;
+               if (elements[0].isVirtual()) {
+                       resource = getHostResource(elements[0]);
+               } else {
+                       resource = elements[0].getResource();
+               }
+               if (resource == null) {
+                       return;
+               }
+               try {
+                       IWorkbenchPage page = targetWorkbenchPart.getSite().getPage();
+                       IViewPart view = page.showView(IPageLayout.ID_RES_NAV);
+                       if (view instanceof ISetSelectionTarget) {
+                               ISelection selection = new StructuredSelection(resource);
+                               ((ISetSelectionTarget) view).selectReveal(selection);
+                       }
+               } catch (PartInitException e) {
+                       ExceptionHandler.handle(e, targetWorkbenchPart.getSite().getShell(), Messages.getString("ShowInNavigatorAction.0"), Messages.getString("ShowInNavigatorAction.1") + e); //$NON-NLS-1$ //$NON-NLS-2$
+               }
+       }
+       
+       
+       public void selectionChanged(IAction action, ISelection selection) {
+               setSelection(selection);
+               IJavaScriptElement elements[] = JsElementActionProxy.getJsElementsFromSelection(getCurrentSelection());
+               for (int i = 0; i < elements.length; i++) {
+                       if (elements[i].isVirtual()) {
+                               IResource resource = getHostResource(elements[i]);
+                               if (resource == null || !resource.exists()) {
+                                       action.setEnabled(false);
+                               }
+                       }
+               }
+       }
+}
diff --git a/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/actions/ShowInScriptExplorerAction.java b/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/actions/ShowInScriptExplorerAction.java
new file mode 100644 (file)
index 0000000..799ea1f
--- /dev/null
@@ -0,0 +1,120 @@
+/*******************************************************************************
+ * 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.web.ui.actions;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.ui.part.ISetSelectionTarget;
+import org.eclipse.wst.jsdt.core.IJavaScriptElement;
+import org.eclipse.wst.jsdt.internal.ui.packageview.PackageExplorerPart;
+
+/**
+*
+
+* Provisional API: This class/interface is part of an interim API that is still under development and expected to
+* change significantly before reaching stability. It is being made available at this early stage to solicit feedback
+* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
+* (repeatedly) as the API evolves.
+*
+ * @author childsb
+ * 
+ */
+public class ShowInScriptExplorerAction extends JsElementActionProxy {
+       /*
+        * (non-Javadoc)
+        * 
+        * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
+        */
+       private IResource getHostResource(IJavaScriptElement virtualElement) {
+               IProject project = virtualElement.getJavaScriptProject().getProject();
+               IPath path = new Path(virtualElement.getHostPath().getPath());
+               IResource host = project.getWorkspace().getRoot().findMember(path);
+               return host;
+       }
+       
+       /*
+        * (non-Javadoc)
+        * 
+        * @see org.eclipse.wst.jsdt.web.ui.actions.JsElementActionProxy#getRunArgs(org.eclipse.jface.action.IAction)
+        */
+       
+       public Object[] getRunArgs(IAction action) {
+               IJavaScriptElement elements[] = JsElementActionProxy.getJsElementsFromSelection(getCurrentSelection());
+               if (elements != null && elements.length > 0) {
+                       return new Object[] { elements[0] };
+               }
+               return new Object[0];
+       }
+       
+       /*
+        * (non-Javadoc)
+        * 
+        * @see org.eclipse.wst.jsdt.web.ui.actions.JsElementActionProxy#getRunArgTypes()
+        */
+       
+       public Class[] getRunArgTypes() {
+               return new Class[] { IJavaScriptElement.class };
+       }
+       
+       
+       public void run(IAction action) {
+               IJavaScriptElement elements[] = JsElementActionProxy.getJsElementsFromSelection(getCurrentSelection());
+               if (elements == null || elements.length == 0) {
+                       return;
+               }
+               IResource resource = null;
+               if (elements[0].isVirtual()) {
+                       resource = getHostResource(elements[0]);
+               } else {
+                       resource = elements[0].getResource();
+               }
+               if (resource == null) {
+                       return;
+               }
+               try {
+                       PackageExplorerPart view = PackageExplorerPart.openInActivePerspective();
+                       view.tryToReveal(resource);
+// IWorkbenchPage page= targetWorkbenchPart.getSite().getPage();
+// IViewPart view= page.showView(IPageLayout.ID_RES_NAV);
+                       if (view instanceof ISetSelectionTarget) {
+                               ISelection selection = new StructuredSelection(resource);
+                               ((ISetSelectionTarget) view).selectReveal(selection);
+                       }
+               } catch (Exception e) {
+                       // ExceptionHandler.handle(e,
+                       // targetWorkbenchPart.getSite().getShell(), "Error Opening in
+                       // Script View", "Error while displaying element in Script View:\n"
+                       // + e);
+               }
+       }
+       
+       
+       public void selectionChanged(IAction action, ISelection selection) {
+               setSelection(selection);
+               IJavaScriptElement elements[] = JsElementActionProxy.getJsElementsFromSelection(getCurrentSelection());
+               for (int i = 0; i < elements.length; i++) {
+                       if (elements[i].isVirtual()) {
+                               IResource resource = getHostResource(elements[i]);
+                               if (resource == null || !resource.exists()) {
+                                       action.setEnabled(false);
+                               }
+                       }
+               }
+       }
+}
diff --git a/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/actions/SimpleJSDTActionProxy.java b/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/actions/SimpleJSDTActionProxy.java
new file mode 100644 (file)
index 0000000..3d24b70
--- /dev/null
@@ -0,0 +1,199 @@
+/*******************************************************************************
+ * 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.web.ui.actions;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Iterator;
+
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.ui.IObjectActionDelegate;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.IWorkbenchSite;
+import org.eclipse.wst.jsdt.web.ui.views.contentoutline.JsJfaceNode;
+
+/**
+*
+
+* Provisional API: This class/interface is part of an interim API that is still under development and expected to
+* change significantly before reaching stability. It is being made available at this early stage to solicit feedback
+* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
+* (repeatedly) as the API evolves.
+*
+ * @author childsb
+ * 
+ */
+public class SimpleJSDTActionProxy implements IObjectActionDelegate {
+       public static Object executeMethod(Object handler, String methodName, Class[] paramaterTypes, Object[] paramaterValues) throws SecurityException,
+                       NoSuchMethodException, IllegalArgumentException, IllegalAccessException, InvocationTargetException {
+               Class target = handler.getClass();
+               Method m = target.getMethod(methodName, paramaterTypes);
+               return m.invoke(handler, paramaterValues);
+       }
+       
+       public static JsJfaceNode[] getJsJfaceNodesFromSelection(ISelection selection) {
+               if (selection == null) {
+                       return new JsJfaceNode[0];
+               }
+               ArrayList elements = new ArrayList();
+               if (selection instanceof IStructuredSelection) {
+                       Iterator itt = ((IStructuredSelection) selection).iterator();
+                       while (itt.hasNext()) {
+                               Object element = itt.next();
+                               if (element instanceof JsJfaceNode) {
+                                       elements.add(element);
+                               }
+                       }
+                       return (JsJfaceNode[]) elements.toArray(new JsJfaceNode[elements.size()]);
+               }
+               return new JsJfaceNode[0];
+       }
+       protected Object actionHandlerTarget;
+       private ISelection currentSelection;
+       protected IAction handlerTargetAction;
+       protected IWorkbenchPart targetWorkbenchPart;
+       
+       public SimpleJSDTActionProxy() {}
+       
+       /*
+        * Most handlers look for WorkBenchSite, so we convert the WorkBenchPart to
+        * WorkBenchSite for init
+        */
+       protected Object getActionHandler(IAction action) throws IllegalAccessException, NoSuchMethodException, IllegalArgumentException, InstantiationException,
+                       InvocationTargetException {
+               /* Target class is cached */
+               if (handlerTargetAction == action && actionHandlerTarget != null) {
+                       return actionHandlerTarget;
+               }
+               Class target = null;
+               String className = getActionHandlerClassName(action);
+               try {
+                       target = Class.forName(className);
+               } catch (ClassNotFoundException ex) {
+                       System.out.println("Error.. Class target of action handler not found: " + action);
+                       System.out.println(Messages.getString("SimpleJSDTActionProxy.0") + ex); //$NON-NLS-1$
+               }
+               // use the loaded class
+               Class[] types = new Class[] { IWorkbenchSite.class };
+               Constructor cons = target.getConstructor(types);
+               Object[] args = new Object[] { targetWorkbenchPart.getSite() };
+               
+               actionHandlerTarget = cons.newInstance(args);
+               handlerTargetAction = action;
+               return actionHandlerTarget;
+       }
+       
+       /*
+        * Default way of determining the action handlers class name.. may be
+        * subclassed/overridden
+        */
+       protected String getActionHandlerClassName(IAction action) {
+               return action.getId();
+       }
+       
+       public ISelection getCurrentSelection() {
+               return currentSelection;
+       }
+       
+       public Object[] getRunArgs(IAction action) {
+               return new Object[] { getCurrentSelection() };
+       }
+       
+       public Class[] getRunArgTypes() {
+               return new Class[] { IStructuredSelection.class };
+       }
+       
+       public Object[] getSelectionChangeArgs(IAction action, ISelection selection) {
+               return new Object[] { getCurrentSelection() };
+       }
+       
+       public Class[] getSelectionChangeArgTypes() {
+               return new Class[] { IStructuredSelection.class };
+       }
+       
+       /*
+        * Generic reflection util method to execute a named method with unknown
+        * paramaters on an object
+        */
+       /*
+        * (non-Javadoc)
+        * 
+        * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
+        */
+       public void run(IAction action) {
+               try {
+                       Object handler = getActionHandler(action);
+                       SimpleJSDTActionProxy.executeMethod(handler, "run", getRunArgTypes(), getRunArgs(action)); //$NON-NLS-1$
+               } catch (IllegalArgumentException ex) {
+                       // TODO Auto-generated catch block
+                       ex.printStackTrace();
+               } catch (SecurityException ex) {
+                       // TODO Auto-generated catch block
+                       ex.printStackTrace();
+               } catch (IllegalAccessException ex) {
+                       // TODO Auto-generated catch block
+                       ex.printStackTrace();
+               } catch (NoSuchMethodException ex) {
+                       // TODO Auto-generated catch block
+                       ex.printStackTrace();
+               } catch (InstantiationException ex) {
+                       // TODO Auto-generated catch block
+                       ex.printStackTrace();
+               } catch (InvocationTargetException ex) {
+                       // TODO Auto-generated catch block
+                       ex.printStackTrace();
+               }
+       }
+       
+       public void selectionChanged(IAction action, ISelection selection) {
+               currentSelection = selection;
+               if(targetWorkbenchPart==null) return;
+               
+               try {
+                       Object handler = getActionHandler(action);
+                       SimpleJSDTActionProxy.executeMethod(handler, "selectionChanged", getSelectionChangeArgTypes(), getSelectionChangeArgs(action, selection)); //$NON-NLS-1$
+               } catch (IllegalArgumentException ex) {
+                       // TODO Auto-generated catch block
+                       ex.printStackTrace();
+               } catch (SecurityException ex) {
+                       // TODO Auto-generated catch block
+                       ex.printStackTrace();
+               } catch (IllegalAccessException ex) {
+                       // TODO Auto-generated catch block
+                       ex.printStackTrace();
+               } catch (NoSuchMethodException ex) {
+                       // TODO Auto-generated catch block
+                       ex.printStackTrace();
+               } catch (InstantiationException ex) {
+                       // TODO Auto-generated catch block
+                       ex.printStackTrace();
+               } catch (InvocationTargetException ex) {
+                       // TODO Auto-generated catch block
+                       ex.printStackTrace();
+               }
+               
+       }
+       
+       public void setActivePart(IAction action, IWorkbenchPart targetPart) {
+               this.targetWorkbenchPart = targetPart;
+       }
+       
+       protected void setSelection(ISelection selection) {
+               this.currentSelection = selection;
+       }
+}
diff --git a/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/actions/SourceActionsAction.java b/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/actions/SourceActionsAction.java
new file mode 100644 (file)
index 0000000..75815ea
--- /dev/null
@@ -0,0 +1,61 @@
+/*******************************************************************************
+ * 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.web.ui.actions;
+
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.ui.IObjectActionDelegate;
+import org.eclipse.ui.IWorkbenchPart;
+
+/**
+*
+
+* Provisional API: This class/interface is part of an interim API that is still under development and expected to
+* change significantly before reaching stability. It is being made available at this early stage to solicit feedback
+* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
+* (repeatedly) as the API evolves.
+*
+ * @author childsb
+ * 
+ */
+public class SourceActionsAction implements IObjectActionDelegate {
+       /*
+        * (non-Javadoc)
+        * 
+        * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
+        */
+       public void run(IAction action) {
+       
+       }
+       
+       /*
+        * (non-Javadoc)
+        * 
+        * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction,
+        *      org.eclipse.jface.viewers.ISelection)
+        */
+       public void selectionChanged(IAction action, ISelection selection) {
+               action.setEnabled(false);
+       }
+       
+       /*
+        * (non-Javadoc)
+        * 
+        * @see org.eclipse.ui.IObjectActionDelegate#setActivePart(org.eclipse.jface.action.IAction,
+        *      org.eclipse.ui.IWorkbenchPart)
+        */
+       public void setActivePart(IAction action, IWorkbenchPart targetPart) {
+               
+       }
+}
diff --git a/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/actions/StandardEditorActionsAction.java b/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/actions/StandardEditorActionsAction.java
new file mode 100644 (file)
index 0000000..8677ee4
--- /dev/null
@@ -0,0 +1,233 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2009 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+/**
+ * 
+ */
+package org.eclipse.wst.jsdt.web.ui.actions;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.swt.dnd.Clipboard;
+import org.eclipse.swt.dnd.TextTransfer;
+import org.eclipse.swt.dnd.Transfer;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.IObjectActionDelegate;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.wst.jsdt.core.IJavaScriptElement;
+import org.eclipse.wst.jsdt.web.ui.views.contentoutline.IJavaWebNode;
+import org.eclipse.wst.jsdt.web.ui.views.contentoutline.JsJfaceNode;
+import org.eclipse.wst.sse.core.StructuredModelManager;
+import org.eclipse.wst.sse.core.internal.provisional.IModelManager;
+import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
+import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument;
+
+/**
+*
+
+* Provisional API: This class/interface is part of an interim API that is still under development and expected to
+* change significantly before reaching stability. It is being made available at this early stage to solicit feedback
+* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
+* (repeatedly) as the API evolves.
+*
+ * @author childsb
+ * 
+ */
+public class StandardEditorActionsAction implements IObjectActionDelegate {
+       private static final boolean APPEND_NEW_LINES_TO_COPY = true;
+       protected static final String COPY = "org.eclipse.wst.jsdt.web.ui.copy"; //$NON-NLS-1$
+       protected static final String CUT = "org.eclipse.wst.jsdt.web.ui.cut"; //$NON-NLS-1$
+       protected static final String DELETE = "org.eclipse.wst.jsdt.web.ui.delete"; //$NON-NLS-1$
+       private static final char NEW_LINE = '\n';
+       protected static final String PASTE_AFTER = "org.eclipse.wst.jsdt.web.ui.paste.after"; //$NON-NLS-1$
+       protected static final String PASTE_BEFORE = "org.eclipse.wst.jsdt.web.ui.paste.before"; //$NON-NLS-1$
+       protected ISelection selection;
+       
+       /*
+        * (non-Javadoc)
+        * 
+        * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction,
+        *      org.eclipse.jface.viewers.ISelection)
+        */
+       private void copy(IAction action) {
+               JsJfaceNode[] nodes = parseSelection();
+               if (nodes == null || nodes.length == 0) {
+                       return;
+               }
+               Clipboard clipboard = null;
+               StringBuffer text = new StringBuffer();
+               if (StandardEditorActionsAction.APPEND_NEW_LINES_TO_COPY) {
+                       text.append(StandardEditorActionsAction.NEW_LINE);
+               }
+               try {
+                       for (int i = 0; i < nodes.length; i++) {
+                               JsJfaceNode currentNode = nodes[i];
+                               int start = currentNode.getStartOffset();
+                               int length = currentNode.getLength();
+                               IStructuredDocument doc = currentNode.getStructuredDocument();
+                               try {
+                                       String elementText = doc.get(start, length);
+                                       text.append(elementText);
+                               } catch (BadLocationException ex) {
+                                       // TODO Auto-generated catch block
+                                       ex.printStackTrace();
+                               }
+                               if (StandardEditorActionsAction.APPEND_NEW_LINES_TO_COPY) {
+                                       text.append(StandardEditorActionsAction.NEW_LINE);
+                               }
+                               clipboard = new Clipboard(Display.getCurrent());
+                               clipboard.setContents(new Object[] { text.toString() }, new Transfer[] { TextTransfer.getInstance() });
+                       }
+               } finally {
+                       if (clipboard != null) {
+                               clipboard.dispose();
+                       }
+               }
+       }
+       
+       private void delete(IAction action) {
+               JsJfaceNode[] nodes = parseSelection();
+               if (nodes == null || nodes.length == 0) {
+                       return;
+               }
+               IStructuredDocument lastDoc = null;
+               IModelManager modelManager = StructuredModelManager.getModelManager();
+               IStructuredModel model = null;
+               try {
+                       int start;
+                       int length;
+                       for (int i = 0; i < nodes.length; i++) {
+                               JsJfaceNode currentNode = nodes[i];
+                               start = currentNode.getStartOffset();
+                               length = currentNode.getLength();
+                               IStructuredDocument doc = currentNode.getStructuredDocument();
+                               if (doc != lastDoc) {
+                                       lastDoc = doc;
+                                       if (model != null) {
+                                               model.endRecording(action);
+                                               model.changedModel();
+                                               model.releaseFromEdit();
+                                       }
+                                       if (modelManager != null) {
+                                               model = modelManager.getExistingModelForEdit(doc);
+                                               model.aboutToChangeModel();
+                                               model.beginRecording(action, "Delete JavaScript Element", "Delete JavaScript Element");
+                                       }
+                               }
+                               doc.replaceText(action, start, length, ""); //$NON-NLS-1$
+                       }
+                       model.endRecording(action);
+               } catch (Exception e) {
+                       System.out.println(Messages.getString("StandardEditorActionsAction.8") + e); //$NON-NLS-1$
+               } finally {
+                       if (model != null) {
+                               model.changedModel();
+                               model.releaseFromEdit();
+                       }
+               }
+       }
+       
+       private JsJfaceNode[] parseSelection() {
+               if (selection == null) {
+                       return new JsJfaceNode[0];
+               }
+               ArrayList elements = new ArrayList();
+               if (selection instanceof IStructuredSelection) {
+                       Iterator itt = ((IStructuredSelection) selection).iterator();
+                       while (itt.hasNext()) {
+                               Object element = itt.next();
+                               if (element instanceof IJavaScriptElement) {
+                                       elements.add(element);
+                               }
+                               if (element instanceof IJavaWebNode) {
+                                       elements.add(element);
+                               }
+                       }
+                       return (JsJfaceNode[]) elements.toArray(new JsJfaceNode[elements.size()]);
+               }
+               return new JsJfaceNode[0];
+       }
+       
+       private void paste(IAction action, boolean atEnd) {
+               JsJfaceNode[] nodes = parseSelection();
+               if (nodes == null || nodes.length == 0) {
+                       return;
+               }
+               int startOfPaste = -1;
+               IStructuredDocument doc = null;
+               /* Figure out where to paste the content */
+               if (atEnd) {
+                       for (int i = 0; i < nodes.length; i++) {
+                               if ((nodes[i].getStartOffset() + nodes[i].getLength()) > startOfPaste) {
+                                       startOfPaste = (nodes[i].getStartOffset() + nodes[i].getLength());
+                                       doc = nodes[i].getStructuredDocument();
+                               }
+                       }
+               } else {
+                       for (int i = 0; i < nodes.length; i++) {
+                               if ((nodes[i].getStartOffset() < startOfPaste || startOfPaste < 0)) {
+                                       startOfPaste = nodes[i].getStartOffset();
+                                       doc = nodes[i].getStructuredDocument();
+                               }
+                       }
+               }
+               Clipboard clipboard = null;
+               IModelManager modelManager = StructuredModelManager.getModelManager();
+               IStructuredModel model = null;
+               try {
+                       clipboard = new Clipboard(Display.getCurrent());
+                       String pasteString = (String) clipboard.getContents(TextTransfer.getInstance());
+                       model = modelManager.getExistingModelForEdit(doc);
+                       model.aboutToChangeModel();
+                       model.beginRecording(action, Messages.getString("StandardEditorActionsAction.9") + (atEnd ? Messages.getString("StandardEditorActionsAction.10") : Messages.getString("StandardEditorActionsAction.11")) + Messages.getString("StandardEditorActionsAction.12"), Messages.getString("StandardEditorActionsAction.13") + (atEnd ? Messages.getString("StandardEditorActionsAction.14") : Messages.getString("StandardEditorActionsAction.15")) + Messages.getString("StandardEditorActionsAction.16")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$
+                       doc.replaceText(action, startOfPaste, 0, pasteString);
+               } finally {
+                       if (clipboard != null) {
+                               clipboard.dispose();
+                       }
+                       if (model != null) {
+                               model.endRecording(action);
+                               model.changedModel();
+                               model.releaseFromEdit();
+                       }
+               }
+       }
+       
+       /*
+        * (non-Javadoc)
+        * 
+        * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
+        */
+       public void run(IAction action) {
+               if (action.getId().equals(StandardEditorActionsAction.CUT)) {
+                       copy(action);
+                       delete(action);
+               } else if (action.getId().equals(StandardEditorActionsAction.COPY)) {
+                       copy(action);
+               } else if (action.getId().equals(StandardEditorActionsAction.PASTE_BEFORE)) {
+                       paste(action, false);
+               } else if (action.getId().equals(StandardEditorActionsAction.PASTE_AFTER)) {
+                       paste(action, true);
+               } else if (action.getId().equals(StandardEditorActionsAction.DELETE)) {
+                       delete(action);
+               }
+       }
+       
+       public void selectionChanged(IAction action, ISelection selection) {
+               this.selection = selection;
+       }
+       
+       public void setActivePart(IAction action, IWorkbenchPart targetPart) {}
+}
diff --git a/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/actions/messages.properties b/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/actions/messages.properties
new file mode 100644 (file)
index 0000000..c89b761
--- /dev/null
@@ -0,0 +1,28 @@
+###############################################################################
+# 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
+###############################################################################
+StandardEditorActionsAction.8=Error in Standard Editor Action : 
+StandardEditorActionsAction.9=Insert Text 
+StandardEditorActionsAction.10=before
+StandardEditorActionsAction.11=after
+StandardEditorActionsAction.12=\ a JavaScript Element.
+StandardEditorActionsAction.13=Insert Text 
+StandardEditorActionsAction.14=before
+StandardEditorActionsAction.15=after
+StandardEditorActionsAction.16=\ a JavaScript Element.
+SimpleJSDTActionProxy.0=Exception : 
+ShowHistoryAction.0=Error Opening in Script View
+ShowHistoryAction.1=Error while displaying element in Script View:\n
+ShowInNavigatorAction.0=Error Opening in Script View
+ShowInNavigatorAction.1=Error while displaying element in Script View:\n
+AddJavaDocStubAction.0=JavaScript Doc
+AddJavaDocStubAction.1=Error while adding comment
+AddJavaDocStubOperation.0=Generate JsDoc
+AddJavaDocStubOperation.1=Generate JsDoc
diff --git a/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/contentassist/JSDTAutoActivationDelegate.java b/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/contentassist/JSDTAutoActivationDelegate.java
new file mode 100644 (file)
index 0000000..695a374
--- /dev/null
@@ -0,0 +1,88 @@
+/*******************************************************************************
+ * Copyright (c) 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.web.ui.contentassist;
+
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.wst.jsdt.ui.PreferenceConstants;
+import org.eclipse.wst.sse.ui.contentassist.AutoActivationDelegate;
+
+/**
+ * <p>Used to provide auto activation characters to the content assist framework for JS regions in web pages
+ * based on the JS auto activation character preferences.</p>
+ *
+ */
+public class JSDTAutoActivationDelegate extends AutoActivationDelegate implements IPropertyChangeListener {
+
+       /** auto activation characters */
+       private char[] fCompletionPropoaslAutoActivationCharacters;
+       
+       /**
+        * <p>Default constructor needed because this class is instantiated by extension point.</p>
+        */
+       public JSDTAutoActivationDelegate() {
+               getPreferenceStore().addPropertyChangeListener(this);
+               
+               //get the current user preference
+               getAutoActivationCharacterPreferences();
+       }
+       
+       /**
+        * @see org.eclipse.wst.sse.ui.contentassist.AutoActivationDelegate#getCompletionProposalAutoActivationCharacters()
+        */
+       public char[] getCompletionProposalAutoActivationCharacters() {
+               return this.fCompletionPropoaslAutoActivationCharacters;
+       }
+       
+       /**
+        * @see org.eclipse.wst.sse.ui.contentassist.AutoActivationDelegate#dispose()
+        */
+       public void dispose() {
+               getPreferenceStore().removePropertyChangeListener(this);
+       }
+       
+       /**
+        * @see org.eclipse.wst.sse.ui.contentassist.StructuredContentAssistProcessor#propertyChange(
+        *      org.eclipse.jface.util.PropertyChangeEvent)
+        */
+       public void propertyChange(PropertyChangeEvent event) {
+               String property = event.getProperty();
+               if(property.equals(PreferenceConstants.CODEASSIST_AUTOACTIVATION) ||
+                               property.equals(PreferenceConstants.CODEASSIST_AUTOACTIVATION_TRIGGERS_JAVA)) {
+                       
+                       getAutoActivationCharacterPreferences();
+               }
+       }
+       
+       /**
+        * @return the associated preference store
+        */
+       private IPreferenceStore getPreferenceStore() {
+               return PreferenceConstants.getPreferenceStore();
+       }
+       
+       /**
+        * <p>Gets the auto activation character user preferences for Javascript and stores them for later use</p>
+        */
+       private void getAutoActivationCharacterPreferences() {
+               IPreferenceStore store = getPreferenceStore();
+               
+               boolean doAuto = store.getBoolean(PreferenceConstants.CODEASSIST_AUTOACTIVATION);
+               if (doAuto) {
+                       fCompletionPropoaslAutoActivationCharacters =
+                               store.getString(PreferenceConstants.CODEASSIST_AUTOACTIVATION_TRIGGERS_JAVA).toCharArray();
+               } else {
+                       fCompletionPropoaslAutoActivationCharacters = null;
+               }
+       }
+
+}
diff --git a/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/IActionConstantsJs.java b/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/IActionConstantsJs.java
new file mode 100644 (file)
index 0000000..7d1af51
--- /dev/null
@@ -0,0 +1,25 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.web.ui.internal;
+/**
+*
+
+* Provisional API: This class/interface is part of an interim API that is still under development and expected to
+* change significantly before reaching stability. It is being made available at this early stage to solicit feedback
+* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
+* (repeatedly) as the API evolves.
+*
+ * @author pavery
+ */
+public interface IActionConstantsJs {
+       public final static String ACTION_NAME_MOVE_ELEMENT = "MoveElement"; //$NON-NLS-1$
+       public final static String ACTION_NAME_RENAME_ELEMENT = "RenameElement"; //$NON-NLS-1$
+}
diff --git a/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/IActionDefinitionIdsJs.java b/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/IActionDefinitionIdsJs.java
new file mode 100644 (file)
index 0000000..9161681
--- /dev/null
@@ -0,0 +1,28 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.web.ui.internal;
+
+import org.eclipse.wst.jsdt.ui.actions.IJavaEditorActionDefinitionIds;
+
+/**
+*
+
+* Provisional API: This class/interface is part of an interim API that is still under development and expected to
+* change significantly before reaching stability. It is being made available at this early stage to solicit feedback
+* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
+* (repeatedly) as the API evolves.
+*
+ * @author pavery
+ */
+public interface IActionDefinitionIdsJs {
+       public final static String MOVE_ELEMENT = IJavaEditorActionDefinitionIds.MOVE_ELEMENT;
+       public final static String RENAME_ELEMENT = IJavaEditorActionDefinitionIds.RENAME_ELEMENT;
+}
diff --git a/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/JSPUIPluginResources.properties b/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/JSPUIPluginResources.properties
new file mode 100644 (file)
index 0000000..2cb5d27
--- /dev/null
@@ -0,0 +1,87 @@
+###############################################################################
+# Copyright (c) 2004, 2007 IBM Corporation and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+#     IBM Corporation - initial API and implementation
+###############################################################################
+## The following line is a sample JSP document.  Please translate only the following parts:
+## Use below tags ONLY for JSP 1.1
+## Welcome!
+## Use below tags ONLY for JSP 1.2
+## Welcome!
+Sample_JSP_doc=<%@ page \n\tlanguage=\"java\" \n\tcontentType=\"text/html; charset=ISO-8859-1\"\n%>\n<jsp:include flush=\"true\" page=\"titleBar.jsp\"/>\n\n<%-- Use below tags ONLY for JSP 1.1 --%>\n<%\n\tSystem.out.println(\"Welcome!\");\n%>\n<%-- Use below tags ONLY for JSP 1.2 --%>\n<jsp:scriptlet>\n\tSystem.out.println(\"Welcome!\");\n</jsp:scriptlet>
+JSP_Delimiters_UI_=JSP Delimiters
+Refactor_label=Refactor
+RenameElement_label=Rename
+MoveElement_label=Move
+MoveElementWizard=Move the selected elements
+#
+OK=OK
+JSP_changes=JSP changes
+ActionContributorJSP_0=Refa&ctor
+JSPRenameElementAction_0=Editor selection does not resolve to a renamable Java element
+JSPMoveElementAction_0=Editor selection does not resolve to movable Java elements
+BasicRefactorSearchRequestor_0=JSP Rename
+BasicRefactorSearchRequestor_1=in file: {0} line: {1}
+BasicRefactorSearchRequestor_2=Move Type ''{0}'' to package ''{1}''
+BasicRefactorSearchRequestor_3=Rename Method ''{0}'' to ''{1}''
+BasicRefactorSearchRequestor_4=Rename Type ''{0}'' to ''{1}''
+BasicRefactorSearchRequestor_5=Rename Package ''{0}'' to ''{1}''
+BasicRefactorSearchRequestor_6=JSP Rename Change
+#
+_UI_WIZARD_NEW_TITLE = New JavaServer Page
+_UI_WIZARD_NEW_HEADING = JavaServer Page
+_UI_WIZARD_NEW_DESCRIPTION = Create a new JavaServer Page.
+_ERROR_FILENAME_MUST_END_JSP = The file name must end in one of the following extensions {0}. 
+_WARNING_FILE_MUST_BE_INSIDE_JAVA_PROJECT = JavaServer Pages created in projects that do not support Java might not work as expected. 
+_WARNING_FOLDER_MUST_BE_INSIDE_WEB_CONTENT = Files created outside of the Web Content folder will not be included in your deployed Web application. 
+ResourceGroup_nameExists = The same name already exists.
+NewJSPTemplatesWizardPage_0=Select JSP Template
+NewJSPTemplatesWizardPage_1=Select a template as initial content in the JSP page.
+NewJSPTemplatesWizardPage_2=Name
+NewJSPTemplatesWizardPage_3=Description
+NewJSPTemplatesWizardPage_4=Use JSP Template
+NewJSPTemplatesWizardPage_5=Preview
+NewJSPTemplatesWizardPage_6=Templates are 'New JSP' templates found in the <a>JSP Templates</a> preference page.
+# Copied from sse.ui
+CleanupDocument_label=Cleanup Document...
+CleanupDocument_tooltip=Cleanup Document
+CleanupDocument_description=Cleanup Document
+ToggleComment_label=Toggle Comment
+ToggleComment_tooltip=Toggle Comment
+ToggleComment_description=Toggle Comment
+AddBlockComment_label=Add Block Comment
+AddBlockComment_tooltip=Add Block Comment
+AddBlockComment_description=Add Block Comment
+RemoveBlockComment_label=Remove Block Comment
+RemoveBlockComment_tooltip=Remove Block Comment
+RemoveBlockComment_description=Remove Block Comment
+FindOccurrences_label=Occurrences in File
+OccurrencesSearchQuery_0={0} - {1} Occurrences in {2}
+OccurrencesSearchQuery_2=file
+Content_Assist_not_availab_UI_=Content Assist not available at the current location
+Java_Content_Assist_is_not_UI_=Java Content Assist is not available for the current cursor location
+#
+Override_method_in=Override method in '
+Creating_files_encoding=Creating files encoding preference
+#
+JSPSourcePreferencePage_0=JSP Source preferences are based on the content within the JSP.
+JSPSourcePreferencePage_1=See <a>''{0}''</a> for JSP with HTML content.
+JSPSourcePreferencePage_2=See <a>''{0}''</a> for JSP with XML content.
+JSPColorPage_jsp_content=JSP Content
+JSPFilesPreferencePage_0=Validating files
+JSPFilesPreferencePage_1=Validate JSP fragments
+# JSP Fragments
+JSPFContentSettingsPropertyPage_0=none
+JSPFContentSettingsPropertyPage_1=The properties used instead of the page directive that cannot be specified in JSP fragment files.  The project setting is used if you specify "none."
+JSPFContentSettingsPropertyPage_2=Language:
+JSPFContentSettingsPropertyPage_3=Content Type:
+JSPFContentSettingsPropertyPage_4=Enable specific setting:
+ProjectJSPFContentSettingsPropertyPage_0=The properties for J2EE Web projects act as "project" default to be looked up when no properties are specified for a particular JSP fragment file.
+# CSS JSP
+Title_InvalidValue=Invalid Value
+Message_InvalidValue=Invalid property value.
diff --git a/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/JsUIMessages.java b/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/JsUIMessages.java
new file mode 100644 (file)
index 0000000..fbd9cf8
--- /dev/null
@@ -0,0 +1,110 @@
+/**********************************************************************
+ * 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 - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.wst.jsdt.web.ui.internal;
+
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+import org.eclipse.osgi.util.NLS;
+
+/**
+*
+
+* Provisional API: This class/interface is part of an interim API that is still under development and expected to
+* change significantly before reaching stability. It is being made available at this early stage to solicit feedback
+* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
+* (repeatedly) as the API evolves.
+*
+ */
+public class JsUIMessages extends NLS {
+       public static String _ERROR_FILENAME_MUST_END_JSP;
+       public static String _UI_WIZARD_NEW_DESCRIPTION;
+       public static String _UI_WIZARD_NEW_HEADING;
+       public static String _UI_WIZARD_NEW_TITLE;
+       public static String _WARNING_FILE_MUST_BE_INSIDE_JAVA_PROJECT;
+       public static String _WARNING_FOLDER_MUST_BE_INSIDE_WEB_CONTENT;
+       public static String ActionContributorJSP_0;
+       public static String AddBlockComment_description; // resource bundle
+       public static String AddBlockComment_label; // resource bundle
+       public static String AddBlockComment_tooltip; // resource bundle
+       public static String BasicRefactorSearchRequestor_0;
+       public static String BasicRefactorSearchRequestor_1;
+       public static String BasicRefactorSearchRequestor_2;
+       public static String BasicRefactorSearchRequestor_3;
+       public static String BasicRefactorSearchRequestor_4;
+       public static String BasicRefactorSearchRequestor_5;
+       public static String BasicRefactorSearchRequestor_6;
+       private static final String BUNDLE_NAME = "org.eclipse.wst.jsdt.web.ui.internal.JSPUIPluginResources";//$NON-NLS-1$
+       public static String CleanupDocument_description; // resource bundle
+       public static String CleanupDocument_label; // resource bundle
+       public static String CleanupDocument_tooltip; // resource bundle
+       public static String Content_Assist_not_availab_UI_;
+       public static String Creating_files_encoding;
+       public static String FindOccurrences_label; // resource bundle
+       private static ResourceBundle fResourceBundle;
+       public static String Java_Content_Assist_is_not_UI_;
+       public static String JSP_changes;
+       public static String JSP_Delimiters_UI_;
+       public static String JSPColorPage_jsp_content;
+       public static String JSPFContentSettingsPropertyPage_0;
+       public static String JSPFContentSettingsPropertyPage_1;
+       public static String JSPFContentSettingsPropertyPage_2;
+       public static String JSPFContentSettingsPropertyPage_3;
+       public static String JSPFContentSettingsPropertyPage_4;
+       public static String JSPFilesPreferencePage_0;
+       public static String JSPFilesPreferencePage_1;
+       public static String JSPMoveElementAction_0;
+       public static String JSPRenameElementAction_0;
+       public static String JSPSourcePreferencePage_0;
+       public static String JSPSourcePreferencePage_1;
+       public static String JSPSourcePreferencePage_2;
+       public static String Message_InvalidValue;
+       public static String MoveElement_label; // resource bundle
+       public static String MoveElementWizard;
+       public static String NewJSPTemplatesWizardPage_0;
+       public static String NewJSPTemplatesWizardPage_1;
+       public static String NewJSPTemplatesWizardPage_2;
+       public static String NewJSPTemplatesWizardPage_3;
+       public static String NewJSPTemplatesWizardPage_4;
+       public static String NewJSPTemplatesWizardPage_5;
+       public static String NewJSPTemplatesWizardPage_6;
+       public static String OccurrencesSearchQuery_0;
+       public static String OccurrencesSearchQuery_2;
+       public static String OK;
+       public static String Override_method_in;
+       public static String ProjectJSPFContentSettingsPropertyPage_0;
+       public static String Refactor_label;
+       public static String RemoveBlockComment_description; // resource bundle
+       public static String RemoveBlockComment_label; // resource bundle
+       public static String RemoveBlockComment_tooltip; // resource bundle
+       public static String RenameElement_label; // resource bundle
+       public static String ResourceGroup_nameExists;
+       public static String Sample_JSP_doc;
+       public static String Title_InvalidValue;
+       public static String ToggleComment_description; // resource bundle
+       public static String ToggleComment_label; // resource bundle
+       public static String ToggleComment_tooltip; // resource bundle
+       static {
+               // load message values from bundle file
+               NLS.initializeMessages(JsUIMessages.BUNDLE_NAME, JsUIMessages.class);
+       }
+       
+       public static ResourceBundle getResourceBundle() {
+               try {
+                       if (JsUIMessages.fResourceBundle == null) {
+                               JsUIMessages.fResourceBundle = ResourceBundle.getBundle(JsUIMessages.BUNDLE_NAME);
+                       }
+               } catch (MissingResourceException x) {
+                       JsUIMessages.fResourceBundle = null;
+               }
+               return JsUIMessages.fResourceBundle;
+       }
+}
diff --git a/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/JsUIPlugin.java b/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/JsUIPlugin.java
new file mode 100644 (file)
index 0000000..70b836d
--- /dev/null
@@ -0,0 +1,115 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.web.ui.internal;
+
+import java.io.IOException;
+
+import org.eclipse.jface.text.templates.ContextTypeRegistry;
+import org.eclipse.jface.text.templates.persistence.TemplateStore;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
+import org.eclipse.wst.sse.ui.internal.provisional.registry.AdapterFactoryRegistry;
+import org.eclipse.wst.sse.ui.internal.provisional.registry.AdapterFactoryRegistryImpl;
+import org.osgi.framework.BundleContext;
+
+/**
+*
+
+* Provisional API: This class/interface is part of an interim API that is still under development and expected to
+* change significantly before reaching stability. It is being made available at this early stage to solicit feedback
+* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
+* (repeatedly) as the API evolves.
+*/
+public class JsUIPlugin extends AbstractUIPlugin {
+       public final static String ID = "org.eclipse.wst.jsdt.web.ui"; //$NON-NLS-1$
+       protected static JsUIPlugin instance = null;
+       
+       public static JsUIPlugin getDefault() {
+               return JsUIPlugin.instance;
+       }
+       
+       public synchronized static JsUIPlugin getInstance() {
+               return JsUIPlugin.instance;
+       }
+       /**
+        * The template context type registry for the jsp editor.
+        */
+       private ContextTypeRegistry fContextTypeRegistry;
+       /**
+        * The template store for the jsp editor.
+        */
+       private TemplateStore fTemplateStore;
+       
+       public JsUIPlugin() {
+               super();
+               JsUIPlugin.instance = this;
+       }
+       
+       public AdapterFactoryRegistry getAdapterFactoryRegistry() {
+               return AdapterFactoryRegistryImpl.getInstance();
+       }
+       
+       /**
+        * Returns the template context type registry for the jsp plugin.
+        * 
+        * @return the template context type registry for the jsp plugin
+        */
+       public ContextTypeRegistry getTemplateContextRegistry() {
+               if (fContextTypeRegistry == null) {
+// ContributionContextTypeRegistry registry = new
+// ContributionContextTypeRegistry();
+// registry.addContextType(TemplateContextTypeIdsJSP.ALL);
+// registry.addContextType(TemplateContextTypeIdsJSP.NEW);
+// registry.addContextType(TemplateContextTypeIdsJSP.TAG);
+// registry.addContextType(TemplateContextTypeIdsJSP.ATTRIBUTE);
+// registry.addContextType(TemplateContextTypeIdsJSP.ATTRIBUTE_VALUE);
+                       fContextTypeRegistry = JavaScriptPlugin.getDefault().getCodeTemplateContextRegistry();
+               }
+               return fContextTypeRegistry;
+       }
+       
+       /**
+        * Returns the template store for the jsp editor templates.
+        * 
+        * @return the template store for the jsp editor templates
+        */
+       public TemplateStore getTemplateStore() {
+               if (fTemplateStore == null) {
+// fTemplateStore = new ContributionTemplateStore(
+// getTemplateContextRegistry(), getPreferenceStore(),
+// JSPUIPreferenceNames.TEMPLATES_KEY);
+                       JavaScriptPlugin jp = JavaScriptPlugin.getDefault();
+                       fTemplateStore = jp.getTemplateStore();
+                       try {
+                               fTemplateStore.load();
+                       } catch (IOException e) {
+                               Logger.logException(e);
+                       }
+               }
+               return fTemplateStore;
+       }
+       
+       /* (non-Javadoc)
+        * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+        */
+       public void start(BundleContext context) throws Exception {
+               super.start(context);
+               instance = this;
+       }
+       
+       /* (non-Javadoc)
+        * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+        */
+       public void stop(BundleContext context) throws Exception {
+               super.stop(context);
+               instance = null;
+       }
+}
diff --git a/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/Logger.java b/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/Logger.java
new file mode 100644 (file)
index 0000000..f79c751
--- /dev/null
@@ -0,0 +1,156 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.web.ui.internal;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Status;
+import org.osgi.framework.Bundle;
+
+import com.ibm.icu.util.StringTokenizer;
+
+/**
+*
+
+* Provisional API: This class/interface is part of an interim API that is still under development and expected to
+* change significantly before reaching stability. It is being made available at this early stage to solicit feedback
+* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
+* (repeatedly) as the API evolves.
+*/
+public class Logger {
+       public static final int ERROR = IStatus.ERROR; // 4
+       public static final int ERROR_DEBUG = 200 + Logger.ERROR;
+       public static final int INFO = IStatus.INFO; // 1
+       public static final int INFO_DEBUG = 200 + Logger.INFO;
+       public static final int OK = IStatus.OK; // 0
+       public static final int OK_DEBUG = 200 + Logger.OK;
+       private static final String PLUGIN_ID = "org.eclipse.wst.jsdt.web.ui"; //$NON-NLS-1$
+       private static final String TRACEFILTER_LOCATION = "/debug/tracefilter"; //$NON-NLS-1$
+       public static final int WARNING = IStatus.WARNING; // 2
+       public static final int WARNING_DEBUG = 200 + Logger.WARNING;
+       
+       /**
+        * Adds message to log.
+        * 
+        * @param level
+        *            severity level of the message (OK, INFO, WARNING, ERROR,
+        *            OK_DEBUG, INFO_DEBUG, WARNING_DEBUG, ERROR_DEBUG)
+        * @param message
+        *            text to add to the log
+        * @param exception
+        *            exception thrown
+        */
+       protected static void _log(int level, String message, Throwable exception) {
+               if (level == Logger.OK_DEBUG || level == Logger.INFO_DEBUG || level == Logger.WARNING_DEBUG || level == Logger.ERROR_DEBUG) {
+                       if (!Logger.isDebugging()) {
+                               return;
+                       }
+               }
+               int severity = IStatus.OK;
+               switch (level) {
+                       case INFO_DEBUG:
+                       case INFO:
+                               severity = IStatus.INFO;
+                       break;
+                       case WARNING_DEBUG:
+                       case WARNING:
+                               severity = IStatus.WARNING;
+                       break;
+                       case ERROR_DEBUG:
+                       case ERROR:
+                               severity = IStatus.ERROR;
+               }
+               message = (message != null) ? message : "null"; //$NON-NLS-1$
+               Status statusObj = new Status(severity, Logger.PLUGIN_ID, severity, message, exception);
+               Bundle bundle = Platform.getBundle(Logger.PLUGIN_ID);
+               if (bundle != null) {
+                       Platform.getLog(bundle).log(statusObj);
+               }
+       }
+       
+       /**
+        * Prints message to log if category matches /debug/tracefilter option.
+        * 
+        * @param message
+        *            text to print
+        * @param category
+        *            category of the message, to be compared with
+        *            /debug/tracefilter
+        */
+       protected static void _trace(String category, String message, Throwable exception) {
+               if (Logger.isTracing(category)) {
+                       message = (message != null) ? message : "null"; //$NON-NLS-1$
+                       Status statusObj = new Status(IStatus.OK, Logger.PLUGIN_ID, IStatus.OK, message, exception);
+                       Bundle bundle = Platform.getBundle(Logger.PLUGIN_ID);
+                       if (bundle != null) {
+                               Platform.getLog(bundle).log(statusObj);
+                       }
+               }
+       }
+       
+       /**
+        * @return true if the platform is debugging
+        */
+       public static boolean isDebugging() {
+               return Platform.inDebugMode();
+       }
+       
+       /**
+        * Determines if currently tracing a category
+        * 
+        * @param category
+        * @return true if tracing category, false otherwise
+        */
+       public static boolean isTracing(String category) {
+               if (!Logger.isDebugging()) {
+                       return false;
+               }
+               String traceFilter = Platform.getDebugOption(Logger.PLUGIN_ID + Logger.TRACEFILTER_LOCATION);
+               if (traceFilter != null) {
+                       StringTokenizer tokenizer = new StringTokenizer(traceFilter, ","); //$NON-NLS-1$
+                       while (tokenizer.hasMoreTokens()) {
+                               String cat = tokenizer.nextToken().trim();
+                               if (category.equals(cat)) {
+                                       return true;
+                               }
+                       }
+               }
+               return false;
+       }
+       
+       public static void log(int level, String message) {
+               Logger._log(level, message, null);
+       }
+       
+       public static void log(int level, String message, Throwable exception) {
+               Logger._log(level, message, exception);
+       }
+       
+       public static void logException(String message, Throwable exception) {
+               Logger._log(Logger.ERROR, message, exception);
+       }
+       
+       public static void logException(Throwable exception) {
+               Logger._log(Logger.ERROR, exception.getMessage(), exception);
+       }
+       
+       public static void trace(String category, String message) {
+               Logger._trace(category, message, null);
+       }
+       
+       public static void traceException(String category, String message, Throwable exception) {
+               Logger._trace(category, message, exception);
+       }
+       
+       public static void traceException(String category, Throwable exception) {
+               Logger._trace(category, exception.getMessage(), exception);
+       }
+}
diff --git a/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/autoedit/AutoEditStrategyForJs.java b/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/autoedit/AutoEditStrategyForJs.java
new file mode 100644 (file)
index 0000000..9c1f97c
--- /dev/null
@@ -0,0 +1,84 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.web.ui.internal.autoedit;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jface.text.DocumentCommand;
+import org.eclipse.jface.text.IAutoEditStrategy;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.wst.html.core.text.IHTMLPartitions;
+import org.eclipse.wst.jsdt.core.IJavaScriptProject;
+import org.eclipse.wst.jsdt.core.JavaScriptCore;
+import org.eclipse.wst.jsdt.internal.ui.text.java.JavaAutoIndentStrategy;
+import org.eclipse.wst.jsdt.internal.ui.text.java.SmartSemicolonAutoEditStrategy;
+import org.eclipse.wst.jsdt.internal.ui.text.javadoc.JavaDocAutoIndentStrategy;
+import org.eclipse.wst.sse.core.StructuredModelManager;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
+/**
+*
+
+* Provisional API: This class/interface is part of an interim API that is still under development and expected to
+* change significantly before reaching stability. It is being made available at this early stage to solicit feedback
+* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
+* (repeatedly) as the API evolves.
+*/
+public class AutoEditStrategyForJs implements IAutoEditStrategy {
+       private IAutoEditStrategy[] fStrategies;
+       
+       public AutoEditStrategyForJs() {
+               super();
+       }
+       
+       public void customizeDocumentCommand(IDocument document, DocumentCommand command) {
+               IAutoEditStrategy[] strats = getAutoEditStrategies(document);
+               for (int i = 0; i < strats.length; i++) {
+                       strats[i].customizeDocumentCommand(document, command);
+               }
+       }
+       
+       public IAutoEditStrategy[] getAutoEditStrategies(IDocument document) {
+               if (fStrategies != null) {
+                       return fStrategies;
+               }
+               String partitioning = IHTMLPartitions.SCRIPT;
+               fStrategies = new IAutoEditStrategy[] { new SmartSemicolonAutoEditStrategy(partitioning),
+                               new JavaAutoIndentStrategy(partitioning, getJavaProject(document), null), new JavaDocAutoIndentStrategy(partitioning) };
+               /* new AutoEditStrategyForTabs() */
+               return fStrategies;
+       }
+       
+       private IJavaScriptProject getJavaProject(IDocument document) {
+               IDOMModel model = null;
+               IJavaScriptProject javaProject = null;
+               try {
+                       model = (IDOMModel) StructuredModelManager.getModelManager().getExistingModelForRead(document);
+                       String baseLocation = model.getBaseLocation();
+                       IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
+                       IPath filePath = new Path(baseLocation);
+                       IProject project = null;
+                       if (filePath.segmentCount() > 0) {
+                               project = root.getProject(filePath.segment(0));
+                       }
+                       if (project != null) {
+                               javaProject = JavaScriptCore.create(project);
+                       }
+               } finally {
+                       if (model != null) {
+                               model.releaseFromRead();
+                       }
+               }
+               return javaProject;
+       }
+}
diff --git a/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/autoedit/AutoEditStrategyForTabs.java b/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/autoedit/AutoEditStrategyForTabs.java
new file mode 100644 (file)
index 0000000..50ab442
--- /dev/null
@@ -0,0 +1,187 @@
+/*******************************************************************************
+ * 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
+ *     Jens Lukowski/Innoopract - initial renaming/restructuring
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.web.ui.internal.autoedit;
+
+import org.eclipse.core.runtime.Preferences;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.ConfigurableLineTracker;
+import org.eclipse.jface.text.DocumentCommand;
+import org.eclipse.jface.text.IAutoEditStrategy;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.ILineTracker;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.TextUtilities;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.texteditor.ITextEditor;
+import org.eclipse.ui.texteditor.ITextEditorExtension3;
+import org.eclipse.wst.html.core.internal.HTMLCorePlugin;
+import org.eclipse.wst.html.core.internal.preferences.HTMLCorePreferenceNames;
+import org.eclipse.wst.jsdt.web.ui.internal.Logger;
+
+/**
+*
+
+* Provisional API: This class/interface is part of an interim API that is still under development and expected to
+* change significantly before reaching stability. It is being made available at this early stage to solicit feedback
+* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
+* (repeatedly) as the API evolves.
+*/
+public class AutoEditStrategyForTabs implements IAutoEditStrategy {
+       private final String TAB_CHARACTER = "\t"; //$NON-NLS-1$
+       
+       public void customizeDocumentCommand(IDocument document, DocumentCommand command) {
+               // if not in smart insert mode just ignore
+               if (!isSmartInsertMode()) {
+                       return;
+               }
+               // spaces for tab character
+               if (command.length == 0 && command.text != null && command.text.length() > 0 && command.text.indexOf(TAB_CHARACTER) != -1) {
+                       smartInsertForTab(command, document);
+               }
+       }
+       
+       /**
+        * Returns indentation width if using spaces for indentation, -1 otherwise
+        * 
+        * @return
+        */
+       private int getIndentationWidth() {
+               int width = -1;
+               Preferences preferences = HTMLCorePlugin.getDefault().getPluginPreferences();
+               if (HTMLCorePreferenceNames.SPACE.equals(preferences.getString(HTMLCorePreferenceNames.INDENTATION_CHAR))) {
+                       width = preferences.getInt(HTMLCorePreferenceNames.INDENTATION_SIZE);
+               }
+               return width;
+       }
+       
+       /**
+        * Calculate number of spaces for next tab stop
+        */
+       private String getIndentString(int indentationWidth, int lineOffset, ILineTracker lineTracker, int index) {
+               int indentSize = indentationWidth;
+               int offsetInLine = -1;
+               if (lineTracker != null) {
+                       try {
+                               IRegion lineInfo = lineTracker.getLineInformationOfOffset(index);
+                               if (lineInfo.getOffset() == 0 && lineOffset > -1) {
+                                       offsetInLine = lineOffset + index;
+                               } else {
+                                       offsetInLine = index - lineInfo.getOffset();
+                               }
+                       } catch (BadLocationException e) {
+                               Logger.log(Logger.WARNING_DEBUG, e.getMessage(), e);
+                       }
+               } else {
+                       if (lineOffset > -1) {
+                               offsetInLine = lineOffset + index;
+                       }
+               }
+               if (offsetInLine > -1 && indentationWidth > 0) {
+                       int remainder = offsetInLine % indentationWidth;
+                       indentSize = indentationWidth - remainder;
+               }
+               StringBuffer indent = new StringBuffer();
+               for (int i = 0; i < indentSize; i++) {
+                       indent.append(' ');
+               }
+               return indent.toString();
+       }
+       
+       /**
+        * Set up a line tracker for text within command if text is multi-line
+        */
+       private ILineTracker getLineTracker(IDocument document, String originalText) {
+               ConfigurableLineTracker lineTracker = null;
+               int[] delims = TextUtilities.indexOf(document.getLegalLineDelimiters(), originalText, 0);
+               if (delims[0] != -1 || delims[1] != -1) {
+                       lineTracker = new ConfigurableLineTracker(document.getLegalLineDelimiters());
+                       lineTracker.set(originalText);
+               }
+               return lineTracker;
+       }
+       
+       /**
+        * Return true if active editor is in smart insert mode, false otherwise
+        * 
+        * @return
+        */
+       private boolean isSmartInsertMode() {
+               boolean isSmartInsertMode = false;
+               ITextEditor textEditor = null;
+               IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+               if (window != null) {
+                       IWorkbenchPage page = window.getActivePage();
+                       if (page != null) {
+                               IEditorPart editor = page.getActiveEditor();
+                               if (editor != null) {
+                                       if (editor instanceof ITextEditor) {
+                                               textEditor = (ITextEditor) editor;
+                                       } else {
+                                               textEditor = (ITextEditor) editor.getAdapter(ITextEditor.class);
+                                       }
+                               }
+                       }
+               }
+               // check if smart insert mode
+               if (textEditor instanceof ITextEditorExtension3 && ((ITextEditorExtension3) textEditor).getInsertMode() == ITextEditorExtension3.SMART_INSERT) {
+                       isSmartInsertMode = true;
+               }
+               return isSmartInsertMode;
+       }
+       
+       /**
+        * Insert spaces for tabs
+        * 
+        * @param command
+        */
+       private void smartInsertForTab(DocumentCommand command, IDocument document) {
+               // tab key was pressed. now check preferences to see if need to insert
+               // spaces instead of tab
+               int indentationWidth = getIndentationWidth();
+               if (indentationWidth > -1) {
+                       String originalText = command.text;
+                       StringBuffer newText = new StringBuffer(originalText);
+                       // determine where in line this command begins
+                       int lineOffset = -1;
+                       try {
+                               IRegion lineInfo = document.getLineInformationOfOffset(command.offset);
+                               lineOffset = command.offset - lineInfo.getOffset();
+                       } catch (BadLocationException e) {
+                               Logger.log(Logger.WARNING_DEBUG, e.getMessage(), e);
+                       }
+                       ILineTracker lineTracker = getLineTracker(document, originalText);
+                       int startIndex = 0;
+                       int index = newText.indexOf(TAB_CHARACTER);
+                       while (index != -1) {
+                               String indent = getIndentString(indentationWidth, lineOffset, lineTracker, index);
+                               // replace \t character with spaces
+                               newText.replace(index, index + 1, indent);
+                               if (lineTracker != null) {
+                                       try {
+                                               lineTracker.replace(index, 1, indent);
+                                       } catch (BadLocationException e) {
+                                               // if something goes wrong with replacing text, just
+                                               // reset to current string
+                                               lineTracker.set(newText.toString());
+                                               Logger.log(Logger.WARNING_DEBUG, e.getMessage(), e);
+                                       }
+                               }
+                               startIndex = index + indent.length();
+                               index = newText.indexOf(TAB_CHARACTER, startIndex);
+                       }
+                       command.text = newText.toString();
+               }
+       }
+}
diff --git a/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/contentassist/JSDTCompletionProposal.java b/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/contentassist/JSDTCompletionProposal.java
new file mode 100644 (file)
index 0000000..c32f660
--- /dev/null
@@ -0,0 +1,116 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.web.ui.internal.contentassist;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.ITextViewer;
+import org.eclipse.jface.text.contentassist.ICompletionProposal;
+import org.eclipse.jface.text.contentassist.ICompletionProposalExtension5;
+import org.eclipse.jface.text.contentassist.IContextInformation;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.wst.jsdt.internal.ui.text.java.JavaCompletionProposal;
+import org.eclipse.wst.jsdt.internal.ui.text.java.LazyJavaCompletionProposal;
+import org.eclipse.wst.jsdt.internal.ui.text.java.LazyJavaTypeCompletionProposal;
+import org.eclipse.wst.jsdt.ui.text.java.IJavaCompletionProposal;
+
+/**
+*
+
+* Provisional API: This class/interface is part of an interim API that is still under development and expected to
+* change significantly before reaching stability. It is being made available at this early stage to solicit feedback
+* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
+* (repeatedly) as the API evolves.
+*/
+public class JSDTCompletionProposal extends JavaCompletionProposal implements IJavaCompletionProposal {
+       /*
+        * https://bugs.eclipse.org/bugs/show_bug.cgi?id=124483
+        * 
+        * This is a wrapped proposal so we don't need to make "slow" calls to the
+        * java proposal up front, only when needed for example, getAdditionalInfo()
+        * reads external javadoc, and it makes no sense
+        */
+       ICompletionProposal fJavaCompletionProposal = null;
+       
+       public JSDTCompletionProposal(String replacementString, int replacementOffset, int replacementLength, int cursorPosition, Image image,
+                       String displayString, IContextInformation contextInformation, String additionalProposalInfo, int relevance,
+                       boolean updateReplacementLengthOnValidate) {
+               super(replacementString, replacementOffset, replacementLength, image, displayString, relevance);
+               super.setCursorPosition(cursorPosition);
+               super.setContextInformation(contextInformation);
+// super(replacementString, replacementOffset, replacementLength,
+// cursorPosition, image, displayString, contextInformation,
+// additionalProposalInfo, relevance,
+// updateReplacementLengthOnValidate);
+       }
+       
+       /**
+        * <p>Uses the wrapped proposal if its lazy</p>
+        */
+       public void apply(ITextViewer viewer, char trigger, int stateMask, int offset) {
+               if (this.fJavaCompletionProposal instanceof LazyJavaCompletionProposal) {
+                       ((LazyJavaCompletionProposal) this.fJavaCompletionProposal).apply(viewer, trigger, stateMask, offset);
+               }
+               else {
+                       super.apply(viewer, trigger, stateMask, offset);
+               }
+       }
+       
+       /**
+        * <p>Uses the wrapped proposal if its lazy</p>
+        *
+        * @return the selection after the proposal has been applied
+        */
+       public Point getSelection(IDocument document) {
+               Point selection;
+               if (this.fJavaCompletionProposal instanceof LazyJavaCompletionProposal) {
+                       selection = this.fJavaCompletionProposal.getSelection(document);
+               }
+               else {
+                       selection = super.getSelection(document);
+               }
+               return selection;
+       }
+       
+       public Object getAdditionalProposalInfo(IProgressMonitor monitor) {
+               Object additionalInfo = super.getAdditionalProposalInfo(monitor);
+               ICompletionProposal javaProposal = getJavaCompletionProposal();
+               if ((javaProposal != null) && (javaProposal instanceof ICompletionProposalExtension5)) {
+                       additionalInfo = ((ICompletionProposalExtension5) javaProposal).getAdditionalProposalInfo(monitor);
+               }
+               return additionalInfo;
+       }
+       
+       public String getAdditionalProposalInfo() {
+               String additionalInfo = super.getAdditionalProposalInfo();
+               ICompletionProposal javaProposal = getJavaCompletionProposal();
+               if (javaProposal != null) {
+                       additionalInfo = javaProposal.getAdditionalProposalInfo();
+               }
+               return additionalInfo;
+       }
+       
+       final public ICompletionProposal getJavaCompletionProposal() {
+               return fJavaCompletionProposal;
+       }
+       
+       final public void setJavaCompletionProposal(ICompletionProposal javaCompletionProposal) {
+               fJavaCompletionProposal = javaCompletionProposal;
+       }
+       
+       protected boolean isValidPrefix(String prefix) {
+               if (this.fJavaCompletionProposal instanceof LazyJavaTypeCompletionProposal) {
+                       return ((LazyJavaTypeCompletionProposal) this.fJavaCompletionProposal).isValidTypePrefix(prefix);
+               }
+               return super.isValidPrefix(prefix);
+       }
+}
diff --git a/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/contentassist/JSDTContentAssistant.java b/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/contentassist/JSDTContentAssistant.java
new file mode 100644 (file)
index 0000000..ee92dd9
--- /dev/null
@@ -0,0 +1,165 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2011 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.web.ui.internal.contentassist;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Vector;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.text.ITextViewer;
+import org.eclipse.jface.text.contentassist.ICompletionProposal;
+import org.eclipse.wst.jsdt.core.CompletionProposal;
+import org.eclipse.wst.jsdt.web.core.javascript.IJsTranslation;
+import org.eclipse.wst.jsdt.web.core.javascript.JsTranslationAdapter;
+import org.eclipse.wst.sse.core.StructuredModelManager;
+import org.eclipse.wst.sse.ui.contentassist.CompletionProposalInvocationContext;
+import org.eclipse.wst.sse.ui.contentassist.ICompletionProposalComputer;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
+import org.eclipse.wst.xml.ui.internal.contentassist.AbstractContentAssistProcessor;
+/**
+*
+
+* Provisional API: This class/interface is part of an interim API that is still under development and expected to
+* change significantly before reaching stability. It is being made available at this early stage to solicit feedback
+* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
+* (repeatedly) as the API evolves.
+*/
+public class JSDTContentAssistant extends AbstractContentAssistProcessor implements ICompletionProposalComputer {
+       private JSDTContentAssistantProcessor fContentAssistProcessor;
+       private JSDTTemplateAssistProcessor fTemplateAssistProcessor;
+       private JSDTHtmlCompletionProcessor fHhtmlcomp;
+       
+       public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int documentPosition) {
+               Vector proposals = new Vector();
+               ICompletionProposal[] completionProposals;
+               ICompletionProposal endScript = getHtmlContentAssistProcessor().getEndScriptProposal(viewer, documentPosition);
+               if(endScript!=null) {
+                       return new ICompletionProposal[] {endScript};
+                       //proposals.add(endScript);
+               }
+               JSDTProposalCollector theCollector = getProposalCollector(viewer, documentPosition);
+               /* add end script tag if needed */
+
+               /* --------- Content Assistant --------- */
+               if(theCollector==null) return new ICompletionProposal[0];
+               
+               getContentAssistProcessor().setProposalCollector(theCollector);
+               completionProposals = getContentAssistProcessor().computeCompletionProposals(viewer, documentPosition);
+               proposals.addAll(Arrays.asList(completionProposals));
+               /* HTML Proposals */
+               completionProposals = getHtmlContentAssistProcessor().computeCompletionProposals(viewer, documentPosition);
+               proposals.addAll(Arrays.asList(completionProposals));
+               /* --------- template completions --------- */
+               getTemplateCompletionProcessor().setProposalCollector(theCollector);
+               completionProposals = getTemplateCompletionProcessor().computeCompletionProposals(viewer, documentPosition);
+               proposals.addAll(Arrays.asList(completionProposals));
+               return (ICompletionProposal[]) proposals.toArray(new ICompletionProposal[0]);
+       }
+       
+       private JSDTHtmlCompletionProcessor getHtmlContentAssistProcessor() {
+               if (fHhtmlcomp == null) {
+                       fHhtmlcomp = new JSDTHtmlCompletionProcessor();
+               }
+               return fHhtmlcomp;
+       }
+       
+       private JSDTContentAssistantProcessor getContentAssistProcessor() {
+               if (fContentAssistProcessor == null) {
+                       fContentAssistProcessor = new JSDTContentAssistantProcessor();
+               }
+               return fContentAssistProcessor;
+       }
+       private IJsTranslation getJSPTranslation(ITextViewer viewer, int offset) {
+               IDOMModel xmlModel = null;
+               try {
+                       xmlModel = (IDOMModel) StructuredModelManager.getModelManager().getExistingModelForRead(viewer.getDocument());
+                       IDOMDocument xmlDoc = xmlModel.getDocument();
+
+                       JsTranslationAdapter translationAdapter = (JsTranslationAdapter) xmlDoc.getAdapterFor(IJsTranslation.class);
+                       
+                       if (translationAdapter != null) {
+                               return translationAdapter.getJsTranslation(true);
+                       }
+               } catch (Exception e) {
+                       // TODO Auto-generated catch block
+                       e.printStackTrace();
+               } finally {
+                       if (xmlModel != null) {
+                               xmlModel.releaseFromRead();
+                       }
+               }
+               return null;
+       }
+       
+       protected JSDTProposalCollector getProposalCollector(ITextViewer viewer, int offset) {
+               IJsTranslation tran = getJSPTranslation(viewer, offset);
+               if(tran==null) return null;
+               return new JSDTProposalCollector(tran);
+       }
+       
+       private JSDTTemplateAssistProcessor getTemplateCompletionProcessor() {
+               if (fTemplateAssistProcessor == null) {
+                       fTemplateAssistProcessor = new JSDTTemplateAssistProcessor();
+               }
+               return fTemplateAssistProcessor;
+       }
+
+       public void sessionStarted() {
+               // TODO Auto-generated method stub
+               
+       }
+
+       public List computeCompletionProposals(
+                       CompletionProposalInvocationContext context,
+                       IProgressMonitor monitor) {
+               Vector proposals = new Vector();
+               ICompletionProposal[] completionProposals;
+               ICompletionProposal endScript = getHtmlContentAssistProcessor().getEndScriptProposal(context.getViewer(), context.getInvocationOffset());
+               if(endScript!=null) {
+                       return new ArrayList(0);
+                       //proposals.add(endScript);
+               }
+               JSDTProposalCollector theCollector = getProposalCollector(context.getViewer(), context.getInvocationOffset());
+               /* add end script tag if needed */
+               
+               theCollector.setAllowsRequiredProposals(CompletionProposal.CONSTRUCTOR_INVOCATION, CompletionProposal.TYPE_REF, true);
+
+               /* --------- Content Assistant --------- */
+               if(theCollector==null) return new ArrayList(0);
+               
+               getContentAssistProcessor().setProposalCollector(theCollector);
+               completionProposals = getContentAssistProcessor().computeCompletionProposals(context.getViewer(), context.getInvocationOffset());
+               proposals.addAll(Arrays.asList(completionProposals));
+               /* HTML Proposals */
+               completionProposals = getHtmlContentAssistProcessor().computeCompletionProposals(context.getViewer(), context.getInvocationOffset());
+               proposals.addAll(Arrays.asList(completionProposals));
+               /* --------- template completions --------- */
+               getTemplateCompletionProcessor().setProposalCollector(theCollector);
+               completionProposals = getTemplateCompletionProcessor().computeCompletionProposals(context.getViewer(), context.getInvocationOffset());
+               proposals.addAll(Arrays.asList(completionProposals));
+               return proposals;
+       }
+
+       public List computeContextInformation(
+                       CompletionProposalInvocationContext context,
+                       IProgressMonitor monitor) {
+               return Arrays.asList(computeContextInformation(context.getViewer(), context.getInvocationOffset()));
+       }
+
+       public void sessionEnded() {
+               fContentAssistProcessor = null;
+               fTemplateAssistProcessor = null;
+               fHhtmlcomp = null;
+       }
+}
diff --git a/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/contentassist/JSDTContentAssistantProcessor.java b/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/contentassist/JSDTContentAssistantProcessor.java
new file mode 100644 (file)
index 0000000..29b5e26
--- /dev/null
@@ -0,0 +1,244 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.web.ui.internal.contentassist;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.jface.text.ITextViewer;
+import org.eclipse.jface.text.contentassist.ICompletionProposal;
+import org.eclipse.wst.jsdt.core.IJavaScriptUnit;
+import org.eclipse.wst.jsdt.web.core.javascript.IJsTranslation;
+import org.eclipse.wst.jsdt.web.core.javascript.JsTranslationAdapter;
+import org.eclipse.wst.jsdt.web.ui.internal.JsUIMessages;
+import org.eclipse.wst.sse.core.StructuredModelManager;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
+import org.eclipse.wst.xml.ui.internal.contentassist.AbstractContentAssistProcessor;
+import org.osgi.framework.Bundle;
+
+/**
+ * Provisional API: This class/interface is part of an interim API that is
+ * still under development and expected to change significantly before
+ * reaching stability. It is being made available at this early stage to
+ * solicit feedback from pioneering adopters on the understanding that any
+ * code that uses this API will almost certainly be broken (repeatedly) as the
+ * API evolves.
+ * 
+ * This class is not intended to be subclassed.
+ */
+public class JSDTContentAssistantProcessor extends AbstractContentAssistProcessor {
+       private static final String JSDT_CORE_PLUGIN_ID = "org.eclipse.wst.jsdt.core"; //$NON-NLS-1$
+//     static {
+//             String value = Platform.getDebugOption("org.eclipse.wst.jsdt.web.core/debug/jsptranslation"); //$NON-NLS-1$
+//             //DEBUG = value != null && value.equalsIgnoreCase("true"); //$NON-NLS-1$
+//     }
+       protected String fErrorMessage = null;
+       protected int fJspSourcePosition, fJavaPosition;
+       private JSDTProposalCollector fProposalCollector;
+       protected ITextViewer fViewer = null;
+       
+       public JSDTContentAssistantProcessor() {
+               super();
+       }
+       
+       /**
+        * Returns a list of completion proposals based on the specified location
+        * within the document that corresponds to the current cursor position
+        * within the text viewer.
+        * 
+        * @param viewer
+        *            the viewer whose document is used to compute the proposals
+        * @param documentPosition
+        *            an offset within the document for which completions should be
+        *            computed
+        * @return an array of completion proposals or <code>null</code> if no
+        *         proposals are possible
+        */
+       
+       public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int pos) {
+               initialize(pos);
+               JSDTProposalCollector collector = null;
+               IDOMModel xmlModel = null;
+               try {
+                       fViewer = viewer;
+                       xmlModel = (IDOMModel) StructuredModelManager.getModelManager().getExistingModelForRead(fViewer.getDocument());
+                       IDOMDocument xmlDoc = xmlModel.getDocument();
+                       JsTranslationAdapter translationAdapter = (JsTranslationAdapter) xmlDoc.getAdapterFor(IJsTranslation.class);
+                       
+                       if (translationAdapter != null) {
+                               IJsTranslation translation = translationAdapter.getJsTranslation(true);
+                               fJavaPosition = getDocumentPosition();
+                               try {
+                                       IJavaScriptUnit cu = translation.getCompilationUnit();
+                                       // can't get java proposals w/out a compilation unit
+                                       // or without a valid position
+                                       if (cu == null || -1 == fJavaPosition) {
+                                               return new ICompletionProposal[0];
+                                       }
+                                       collector = getProposalCollector();
+                                       synchronized (cu) {
+                                               cu.codeComplete(fJavaPosition, collector, null);
+                                       }
+                               } catch (CoreException coreEx) {
+                                       // a possible Java Model Exception due to not being a Web
+                                       // (Java) Project
+                                       coreEx.printStackTrace();
+                               }
+                       }
+               } catch (Exception exc) {
+                       exc.printStackTrace();
+                       // throw out exceptions on code assist.
+               } finally {
+                       if (xmlModel != null) {
+                               xmlModel.releaseFromRead();
+                       }
+               }
+               ICompletionProposal[] results = new ICompletionProposal[0];
+               if (collector != null) {
+                       results = collector.getJSPCompletionProposals();
+                       if (results == null || results.length < 1) {
+                               fErrorMessage = JsUIMessages.Java_Content_Assist_is_not_UI_;
+                       }
+               }
+               return results;
+       }
+       
+       /**
+        * Returns information about possible contexts based on the specified
+        * location within the document that corresponds to the current cursor
+        * position within the text viewer.
+        * 
+        * @param viewer
+        *            the viewer whose document is used to compute the possible
+        *            contexts
+        * @param documentPosition
+        *            an offset within the document for which context information
+        *            should be computed
+        * @return an array of context information objects or <code>null</code> if
+        *         no context could be found
+        */
+       
+       public org.eclipse.jface.text.contentassist.IContextInformation[] computeContextInformation(org.eclipse.jface.text.ITextViewer viewer, int documentOffset) {
+               return null;
+       }
+       
+       /**
+        * Returns a string of characters which when pressed should automatically
+        * display content-assist proposals.
+        * 
+        * @return string of characters
+        */
+       public java.lang.String getAutoProposalInvocationCharacters() {
+               return null;
+       }
+       
+       /**
+        * Returns a string of characters which when pressed should automatically
+        * display a content-assist tip.
+        * 
+        * @return string of characters
+        */
+       public java.lang.String getAutoTipInvocationCharacters() {
+               return null;
+       }
+       
+       /**
+        * Returns the characters which when entered by the user should
+        * automatically trigger the presentation of possible completions.
+        * 
+        * @return the auto activation characters for completion proposal or
+        *         <code>null</code> if no auto activation is desired
+        */
+       
+       public char[] getCompletionProposalAutoActivationCharacters() {
+               return null;
+       }
+       
+       /**
+        * Returns the characters which when entered by the user should
+        * automatically trigger the presentation of context information.
+        * 
+        * @return the auto activation characters for presenting context information
+        *         or <code>null</code> if no auto activation is desired
+        */
+       
+       public char[] getContextInformationAutoActivationCharacters() {
+               return null;
+       }
+       
+       /**
+        * Returns a validator used to determine when displayed context information
+        * should be dismissed. May only return <code>null</code> if the processor
+        * is incapable of computing context information.
+        * 
+        * @return a context information validator, or <code>null</code> if the
+        *         processor is incapable of computing context information
+        */
+       
+       public org.eclipse.jface.text.contentassist.IContextInformationValidator getContextInformationValidator() {
+               return null;
+       }
+       
+       protected int getDocumentPosition() {
+               return fJspSourcePosition;
+       }
+       
+       
+       public String getErrorMessage() {
+               // TODO: get appropriate error message
+               // if (fCollector.getErrorMessage() != null &&
+               // fCollector.getErrorMessage().length() > 0)
+               // return fCollector.getErrorMessage();
+               return fErrorMessage;
+       }
+       
+       protected JSDTProposalCollector getProposalCollector() {
+               return fProposalCollector;
+               // return new JSPProposalCollector(translation);
+       }
+       
+       /**
+        * Initialize the code assist processor.
+        */
+       protected void initialize(int pos) {
+               initializeJavaPlugins();
+               fJspSourcePosition = pos;
+               fErrorMessage = null;
+       }
+       
+       /**
+        * Initialize the Java Plugins that the JSP processor requires. See
+        * https://bugs.eclipse.org/bugs/show_bug.cgi?id=143765 We should not call
+        * "start", because that will cause that state to be remembered, and
+        * re-started automatically during the next boot up sequence.
+        * 
+        * ISSUE: we may be able to get rid of this all together, in future, since
+        * 99% we probably have already used some JDT class by the time we need JDT
+        * to be active ... but ... this is the safest fix for this point in 1.5
+        * stream. Next release, let's just remove this, re-discover what ever bug
+        * this was fixing (if any) and if there is one, then we'll either put back
+        * in, as is, or come up with a more appropriate fix.
+        * 
+        */
+       protected void initializeJavaPlugins() {
+               try {
+                       Bundle bundle = Platform.getBundle(JSDTContentAssistantProcessor.JSDT_CORE_PLUGIN_ID);
+                       bundle.loadClass("dummyClassNameThatShouldNeverExist"); //$NON-NLS-1$
+               } catch (ClassNotFoundException e) {
+                       // this is the expected result, we just want to
+                       // nudge the bundle to be sure its activated.
+               }
+       }
+       
+       public void setProposalCollector(JSDTProposalCollector translation) {
+               this.fProposalCollector = translation;
+       }
+}
diff --git a/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/contentassist/JSDTContetAssistInvocationContext.java b/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/contentassist/JSDTContetAssistInvocationContext.java
new file mode 100644 (file)
index 0000000..dcd07a8
--- /dev/null
@@ -0,0 +1,83 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2009 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.web.ui.internal.contentassist;
+
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.ITextViewer;
+import org.eclipse.wst.jsdt.ui.text.java.JavaContentAssistInvocationContext;
+import org.eclipse.wst.jsdt.web.core.javascript.IJsTranslation;
+import org.eclipse.wst.jsdt.web.core.javascript.JsTranslationAdapter;
+import org.eclipse.wst.sse.core.StructuredModelManager;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
+/**
+*
+
+* Provisional API: This class/interface is part of an interim API that is still under development and expected to
+* change significantly before reaching stability. It is being made available at this early stage to solicit feedback
+* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
+* (repeatedly) as the API evolves.
+*/
+public class JSDTContetAssistInvocationContext extends JavaContentAssistInvocationContext {
+       public static JSDTContetAssistInvocationContext getInstance(ITextViewer viewer, int offset, JSDTProposalCollector theCollector) {
+               JSDTContetAssistInvocationContext.getJSPTranslation(viewer);
+               return new JSDTContetAssistInvocationContext(viewer, offset, theCollector);
+       }
+       
+       private static IJsTranslation getJSPTranslation(ITextViewer viewer) {
+               IJsTranslation fTranslation = null;
+               
+               IDOMModel xmlModel = null;
+               try {
+                       xmlModel = (IDOMModel) StructuredModelManager.getModelManager().getExistingModelForRead(viewer.getDocument());
+                       IDOMDocument xmlDoc = xmlModel.getDocument();
+                       JsTranslationAdapter fTranslationAdapter = (JsTranslationAdapter) xmlDoc.getAdapterFor(IJsTranslation.class);
+                       if (fTranslationAdapter != null) {
+                               fTranslation = fTranslationAdapter.getJsTranslation(true);
+                       }
+               } catch (Exception e) {
+                       // TODO Auto-generated catch block
+                       e.printStackTrace();
+               } finally {
+                       if (xmlModel != null) {
+                               xmlModel.releaseFromRead();
+                       }
+               }
+               return fTranslation;
+       }
+       ITextViewer viewer;
+       
+       private JSDTContetAssistInvocationContext(ITextViewer viewer, int offset, JSDTProposalCollector theCollector) {
+               super(viewer, offset, null);
+               this.viewer = viewer;
+               // this.offset=getJSPTranslation().getJavaOffset(offset);
+               // CompletionProposalCollector theCollector = getProposalCollector();
+               super.setCollector(theCollector);
+       }
+       
+// public IDocument getDocument() {
+// return
+// ((JSPTranslationExtension)getJSPTranslation(viewer)).getJavaDocument();
+//      
+// }
+// protected CompletionProposalCollector getProposalCollector() {
+//       
+// return ((CompletionProposalCollector) ( new JSPProposalCollector(
+// getJSPTranslation()) ));
+// }
+       
+       public IDocument getDocument() {
+               return viewer.getDocument();
+       }
+// public IJavaScriptUnit getCompilationUnit() {
+// return getJSPTranslation(viewer).getCompilationUnit();
+// }
+}
diff --git a/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/contentassist/JSDTHtmlCompletionProcessor.java b/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/contentassist/JSDTHtmlCompletionProcessor.java
new file mode 100644 (file)
index 0000000..21727a6
--- /dev/null
@@ -0,0 +1,105 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2009 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.web.ui.internal.contentassist;
+import java.util.ArrayList;
+
+import org.eclipse.jface.text.ITextViewer;
+import org.eclipse.jface.text.contentassist.ICompletionProposal;
+import org.eclipse.wst.jsdt.web.core.javascript.IJsTranslation;
+import org.eclipse.wst.jsdt.web.core.javascript.JsTranslationAdapter;
+import org.eclipse.wst.sse.core.StructuredModelManager;
+import org.eclipse.wst.sse.ui.internal.contentassist.CustomCompletionProposal;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
+
+/**
+*
+
+* Provisional API: This class/interface is part of an interim API that is still under development and expected to
+* change significantly before reaching stability. It is being made available at this early stage to solicit feedback
+* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
+* (repeatedly) as the API evolves.
+*/
+public class JSDTHtmlCompletionProcessor {
+       
+       public JSDTHtmlCompletionProcessor() {}
+       
+       
+       
+       public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int offset) {
+               /* add </script if necisary */
+               ArrayList allProposals = new ArrayList();
+               getJSPTranslation(viewer);
+               
+               return (ICompletionProposal[])allProposals.toArray(new ICompletionProposal[allProposals.size()]);
+       }
+       
+       public ICompletionProposal getEndScriptProposal(ITextViewer viewer, int offset) {
+               /* add </script if necisary */
+       
+               IJsTranslation tran = getJSPTranslation(viewer);
+               if(tran==null) return null;
+               
+               int missingAtOffset = tran.getMissingTagStart();
+               
+               if(offset>=missingAtOffset&& missingAtOffset>-1) {
+                       
+                       String allText = viewer.getDocument().get();
+                       String text = "</script>"; //$NON-NLS-1$
+                       
+                       int startInTag = -1;
+                       
+                       for(int i=0;i<text.length() && allText.length()>offset-1;i++) {
+                               if(allText.charAt(offset-1)==text.charAt(i)) {
+                                       startInTag = i;
+                                       break;
+                               }
+                       }
+                       
+                       if(startInTag==-1 ) {
+                               String displayText = Messages.getString("JSDTHtmlCompletionProcessor.1"); //$NON-NLS-1$
+                               return new CustomCompletionProposal("\n" + text + "\n" ,offset,0,offset,null,displayText,null,Messages.getString("JSDTHtmlCompletionProcessor.4"),100); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+                       }
+                       
+                       String text1 = allText.substring(offset - startInTag - 1, offset).toLowerCase();
+                       String text2 = text.substring(0, startInTag+1).toLowerCase();
+                       if(startInTag>-1  && text2.compareTo(text1)==0 ) {
+                               String displayText = Messages.getString("JSDTHtmlCompletionProcessor.5"); //$NON-NLS-1$
+                               return new CustomCompletionProposal(text  ,offset-startInTag-1,0,text.length(),null,displayText,null,Messages.getString("JSDTHtmlCompletionProcessor.6"),100); //$NON-NLS-1$
+                       }
+                       
+               }
+               
+               return null;
+       }
+       private IJsTranslation getJSPTranslation(ITextViewer viewer) {
+               IDOMModel xmlModel = null;
+               try {
+                       xmlModel = (IDOMModel) StructuredModelManager.getModelManager().getExistingModelForRead(viewer.getDocument());
+                       IDOMDocument xmlDoc = xmlModel.getDocument();
+                       
+                       JsTranslationAdapter fTranslationAdapter = (JsTranslationAdapter) xmlDoc.getAdapterFor(IJsTranslation.class);
+                       
+                       if (fTranslationAdapter != null) {
+                               return fTranslationAdapter.getJsTranslation(true);
+                       }
+               } catch (Exception e) {
+                       // TODO Auto-generated catch block
+                       e.printStackTrace();
+               } finally {
+                       if (xmlModel != null) {
+                               xmlModel.releaseFromRead();
+                       }
+               }
+               return null;
+       }
+       
+}
diff --git a/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/contentassist/JSDTProposalCollector.java b/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/contentassist/JSDTProposalCollector.java
new file mode 100644 (file)
index 0000000..9f873f5
--- /dev/null
@@ -0,0 +1,148 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2011 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.web.ui.internal.contentassist;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+
+import org.eclipse.jface.text.contentassist.IContextInformation;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.wst.jsdt.core.CompletionProposal;
+import org.eclipse.wst.jsdt.core.Signature;
+import org.eclipse.wst.jsdt.ui.text.java.CompletionProposalCollector;
+import org.eclipse.wst.jsdt.ui.text.java.CompletionProposalComparator;
+import org.eclipse.wst.jsdt.ui.text.java.IJavaCompletionProposal;
+import org.eclipse.wst.jsdt.web.core.javascript.IJsTranslation;
+
+
+/**
+*
+
+* Provisional API: This class/interface is part of an interim API that is still under development and expected to
+* change significantly before reaching stability. It is being made available at this early stage to solicit feedback
+* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
+* (repeatedly) as the API evolves.
+*/
+public class JSDTProposalCollector extends CompletionProposalCollector {
+       static char[] getTypeTriggers() {
+               return CompletionProposalCollector.TYPE_TRIGGERS;
+       }
+       private Comparator fComparator;
+       private IJsTranslation fTranslation;
+       
+// public List getGeneratedFunctionNames(){
+// if(fGeneratedFunctionNames==null){
+// fGeneratedFunctionNames = fTranslation.getGeneratedFunctionNames();
+// }
+// return fGeneratedFunctionNames;
+// }
+       public JSDTProposalCollector(IJsTranslation translation) {
+               super(translation!=null?translation.getCompilationUnit():null);
+               if (translation == null) {
+                       throw new IllegalArgumentException("JSPTranslation cannot be null"); //$NON-NLS-1$
+               }
+               fTranslation = translation;
+       }
+       
+       /**
+        * Cacluates the where the cursor should be after applying this proposal.
+        * eg. method(|) if the method proposal chosen had params.
+        * 
+        * @param proposal
+        * @param completion
+        * @return
+        */
+       private int calculatePositionAfter(CompletionProposal proposal, String completion) {
+               int positionAfter = completion.length();
+               int kind = proposal.getKind();
+               // may need better logic here...
+               // put cursor inside parenthesis if there's params
+               // only checking for any kind of declaration
+               if (kind == CompletionProposal.ANONYMOUS_CLASS_DECLARATION || kind == CompletionProposal.METHOD_DECLARATION || kind == CompletionProposal.POTENTIAL_METHOD_DECLARATION || kind == CompletionProposal.METHOD_REF) {
+                       int paramCount = Signature.getParameterCount(proposal.getSignature());
+                       if (completion.length() > 0 && paramCount > 0) {
+                               positionAfter--;
+                       }
+               }
+               return positionAfter;
+       }
+       
+       /**
+        * Overridden to: - translate Java -> JSP offsets - fix
+        * cursor-position-after - fix mangled servlet name in display string -
+        * remove unwanted proposals (servlet constructor)
+        */
+       
+       protected IJavaCompletionProposal createJavaCompletionProposal(CompletionProposal proposal) {
+               return createJSDTProposal(proposal);
+       }
+       
+       private JSDTCompletionProposal createJSDTProposal(CompletionProposal proposal) {
+               JSDTCompletionProposal jspProposal;
+               String completion = String.valueOf(proposal.getCompletion());
+               // java offset
+               int offset = proposal.getReplaceStart();
+               // replacement length
+               int length = proposal.getReplaceEnd() - offset;
+               // translate offset from Java > JSP
+               // cursor position after must be calculated
+               int positionAfter = calculatePositionAfter(proposal, completion);
+               // from java proposal
+               IJavaCompletionProposal javaProposal = super.createJavaCompletionProposal(proposal);
+               proposal.getDeclarationSignature();
+               Image image = javaProposal.getImage();
+               String displayString = javaProposal.getDisplayString();
+               displayString = getTranslation().fixupMangledName(displayString);
+
+               IContextInformation contextInformation = javaProposal.getContextInformation();
+               // String additionalInfo = javaProposal.getAdditionalProposalInfo();
+               int relevance = javaProposal.getRelevance();
+               boolean updateLengthOnValidate = true;
+               jspProposal = new JSDTCompletionProposal(completion, offset, length, positionAfter, image, displayString, contextInformation, null, relevance, updateLengthOnValidate);
+               // https://bugs.eclipse.org/bugs/show_bug.cgi?id=124483
+               // set wrapped java proposal so additional info can be calculated on
+               // demand
+               jspProposal.setJavaCompletionProposal(javaProposal);
+               return jspProposal;
+       }
+       
+       private Comparator getComparator() {
+               if (fComparator == null) {
+                       fComparator = new CompletionProposalComparator();
+               }
+               return fComparator;
+       }
+       
+       /**
+        * Ensures that we only return JSPCompletionProposals.
+        * 
+        * @return an array of JSPCompletionProposals
+        */
+       public JSDTCompletionProposal[] getJSPCompletionProposals() {
+               List results = new ArrayList();
+               IJavaCompletionProposal[] javaProposals = getJavaCompletionProposals();
+               // need to filter out non JSPCompletionProposals
+               // because their offsets haven't been translated
+               for (int i = 0; i < javaProposals.length; i++) {
+                       if (javaProposals[i] instanceof JSDTCompletionProposal) {
+                               results.add(javaProposals[i]);
+                       }
+               }
+               Collections.sort(results, getComparator());
+               return (JSDTCompletionProposal[]) results.toArray(new JSDTCompletionProposal[results.size()]);
+       }
+       
+       public IJsTranslation getTranslation() {
+               return fTranslation;
+       }
+}
\ No newline at end of file
diff --git a/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/contentassist/JSDTTemplateAssistProcessor.java b/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/contentassist/JSDTTemplateAssistProcessor.java
new file mode 100644 (file)
index 0000000..1f98178
--- /dev/null
@@ -0,0 +1,65 @@
+/*******************************************************************************
+ * 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.web.ui.internal.contentassist;
+
+import java.util.List;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.jface.text.ITextViewer;
+import org.eclipse.jface.text.contentassist.ICompletionProposal;
+import org.eclipse.wst.jsdt.internal.ui.text.java.TemplateCompletionProposalComputer;
+import org.eclipse.wst.jsdt.ui.text.java.JavaContentAssistInvocationContext;
+import org.eclipse.wst.jsdt.web.core.javascript.JsTranslationAdapter;
+/**
+*
+
+* Provisional API: This class/interface is part of an interim API that is still under development and expected to
+* change significantly before reaching stability. It is being made available at this early stage to solicit feedback
+* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
+* (repeatedly) as the API evolves.
+*/
+public class JSDTTemplateAssistProcessor {
+       TemplateCompletionProposalComputer fJavaTemplateCompletion;
+       JSDTProposalCollector fProposalCollector;
+       JsTranslationAdapter fTranslationAdapter;
+       IProgressMonitor monitor;
+       
+       public JSDTTemplateAssistProcessor() {
+               monitor = new NullProgressMonitor();
+       }
+       
+       public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int offset) {
+               JavaContentAssistInvocationContext context = getInvocationContext(viewer, offset);
+               List props = getTemplateCompletionProposalComputer().computeCompletionProposals(context, monitor);
+               return (ICompletionProposal[]) props.toArray(new ICompletionProposal[] {});
+       }
+       
+       private JavaContentAssistInvocationContext getInvocationContext(ITextViewer viewer, int offset) {
+               return JSDTContetAssistInvocationContext.getInstance(viewer, offset, getProposalCollector());
+       }
+       
+       protected JSDTProposalCollector getProposalCollector() {
+               return fProposalCollector;
+               // return new JSPProposalCollector(translation);
+       }
+       
+       private TemplateCompletionProposalComputer getTemplateCompletionProposalComputer() {
+               if (fJavaTemplateCompletion == null) {
+                       fJavaTemplateCompletion = new TemplateCompletionProposalComputer();
+               }
+               return fJavaTemplateCompletion;
+       }
+       
+       public void setProposalCollector(JSDTProposalCollector translation) {
+               this.fProposalCollector = translation;
+       }
+}
diff --git a/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/contentassist/Messages.java b/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/contentassist/Messages.java
new file mode 100644 (file)
index 0000000..d59e216
--- /dev/null
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ * 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.web.ui.internal.contentassist;
+
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+/**
+*
+
+* Provisional API: This class/interface is part of an interim API that is still under development and expected to
+* change significantly before reaching stability. It is being made available at this early stage to solicit feedback
+* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
+* (repeatedly) as the API evolves.
+*/
+public class Messages {
+       private static final String BUNDLE_NAME = "org.eclipse.wst.jsdt.web.ui.internal.contentassist.messages"; //$NON-NLS-1$
+
+       private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME);
+
+       private Messages() {
+       }
+
+       public static String getString(String key) {
+               try {
+                       return RESOURCE_BUNDLE.getString(key);
+               }
+               catch (MissingResourceException e) {
+                       return '!' + key + '!';
+               }
+       }
+}
diff --git a/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/contentassist/messages.properties b/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/contentassist/messages.properties
new file mode 100644 (file)
index 0000000..fbdf808
--- /dev/null
@@ -0,0 +1,14 @@
+###############################################################################
+# 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
+###############################################################################
+JSDTHtmlCompletionProcessor.1=<> end with </script>
+JSDTHtmlCompletionProcessor.4=Close the script tag.
+JSDTHtmlCompletionProcessor.5=<> end with </script>
+JSDTHtmlCompletionProcessor.6=Close the script tag.
diff --git a/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/derived/SingleCharReader.java b/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/derived/SingleCharReader.java
new file mode 100644 (file)
index 0000000..e893d44
--- /dev/null
@@ -0,0 +1,70 @@
+/*******************************************************************************
+ * 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
+ *     Jens Lukowski/Innoopract - initial renaming/restructuring
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.web.ui.internal.derived;
+
+import java.io.IOException;
+import java.io.Reader;
+
+/**
+*
+
+* Provisional API: This class/interface is part of an interim API that is still under development and expected to
+* change significantly before reaching stability. It is being made available at this early stage to solicit feedback
+* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
+* (repeatedly) as the API evolves.
+*/
+public abstract class SingleCharReader extends Reader {
+       /**
+        * Gets the content as a String
+        */
+       public String getString() throws IOException {
+               StringBuffer buf = new StringBuffer();
+               int ch;
+               while ((ch = read()) != -1) {
+                       buf.append((char) ch);
+               }
+               return buf.toString();
+       }
+       
+       /**
+        * @see Reader#read()
+        */
+       
+       public abstract int read() throws IOException;
+       
+       /**
+        * @see Reader#read(char[],int,int)
+        */
+       
+       public int read(char cbuf[], int off, int len) throws IOException {
+               int end = off + len;
+               for (int i = off; i < end; i++) {
+                       int ch = read();
+                       if (ch == -1) {
+                               if (i == off) {
+                                       return -1;
+                               }
+                               return i - off;
+                       }
+                       cbuf[i] = (char) ch;
+               }
+               return len;
+       }
+       
+       /**
+        * @see Reader#ready()
+        */
+       
+       public boolean ready() throws IOException {
+               return true;
+       }
+}
diff --git a/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/editor/ActionContributorJSP.java b/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/editor/ActionContributorJSP.java
new file mode 100644 (file)
index 0000000..7a9f5d9
--- /dev/null
@@ -0,0 +1,81 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.web.ui.internal.editor;
+
+import java.util.ResourceBundle;
+
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IWorkbenchActionConstants;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.texteditor.RetargetTextEditorAction;
+import org.eclipse.wst.html.ui.internal.edit.ui.ActionContributorHTML;
+import org.eclipse.wst.jsdt.ui.actions.RefactorActionGroup;
+import org.eclipse.wst.jsdt.web.ui.internal.IActionConstantsJs;
+import org.eclipse.wst.jsdt.web.ui.internal.IActionDefinitionIdsJs;
+import org.eclipse.wst.jsdt.web.ui.internal.JsUIMessages;
+import org.eclipse.wst.sse.ui.internal.actions.StructuredTextEditorActionConstants;
+
+/**
+*
+
+* Provisional API: This class/interface is part of an interim API that is still under development and expected to
+* change significantly before reaching stability. It is being made available at this early stage to solicit feedback
+* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
+* (repeatedly) as the API evolves.
+*/
+public class ActionContributorJSP extends ActionContributorHTML {
+       private static final String[] EDITOR_IDS = { "org.eclipse.wst.html.core.htmlsource.source", "org.eclipse.wst.sse.ui.StructuredTextEditor" }; //$NON-NLS-1$ //$NON-NLS-2$
+       private RetargetTextEditorAction moveElementAction = null;
+       private IMenuManager refactorMenu = null;
+       private RetargetTextEditorAction renameElementAction = null;
+       
+       public ActionContributorJSP() {
+               super();
+               ResourceBundle bundle = JsUIMessages.getResourceBundle();
+               this.renameElementAction = new RetargetTextEditorAction(bundle, IActionConstantsJs.ACTION_NAME_RENAME_ELEMENT + StructuredTextEditorActionConstants.UNDERSCORE);
+               this.renameElementAction.setActionDefinitionId(IActionDefinitionIdsJs.RENAME_ELEMENT);
+               PlatformUI.getWorkbench().getHelpSystem().setHelp(this.renameElementAction, IHelpContextIds.JSP_REFACTORRENAME_HELPID);
+               this.moveElementAction = new RetargetTextEditorAction(bundle, IActionConstantsJs.ACTION_NAME_MOVE_ELEMENT + StructuredTextEditorActionConstants.UNDERSCORE);
+               this.moveElementAction.setActionDefinitionId(IActionDefinitionIdsJs.MOVE_ELEMENT);
+               PlatformUI.getWorkbench().getHelpSystem().setHelp(this.moveElementAction, IHelpContextIds.JSP_REFACTORMOVE_HELPID);
+               // the refactor menu, add the menu itself to add all refactor actions
+               this.refactorMenu = new MenuManager(JsUIMessages.ActionContributorJSP_0, RefactorActionGroup.MENU_ID);
+               refactorMenu.add(this.renameElementAction);
+               refactorMenu.add(this.moveElementAction);
+       }
+       
+       
+       protected void addToMenu(IMenuManager menu) {
+               super.addToMenu(menu);
+               menu.insertAfter(IWorkbenchActionConstants.M_EDIT, this.refactorMenu);
+       }
+       
+       
+       protected String[] getExtensionIDs() {
+               return ActionContributorJSP.EDITOR_IDS;
+       }
+       
+       
+       public void setActiveEditor(IEditorPart activeEditor) {
+               super.setActiveEditor(activeEditor);
+               this.renameElementAction.setAction(getAction(getTextEditor(getActiveEditorPart()), IActionConstantsJs.ACTION_NAME_RENAME_ELEMENT));
+               this.moveElementAction.setAction(getAction(getTextEditor(getActiveEditorPart()), IActionConstantsJs.ACTION_NAME_MOVE_ELEMENT));
+       }
+       
+       
+       public void setViewerSpecificContributionsEnabled(boolean enabled) {
+               super.setViewerSpecificContributionsEnabled(enabled);
+               this.renameElementAction.setEnabled(enabled);
+               this.moveElementAction.setEnabled(enabled);
+       }
+}
diff --git a/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/editor/IHelpContextIds.java b/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/editor/IHelpContextIds.java
new file mode 100644 (file)
index 0000000..c4418fb
--- /dev/null
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.web.ui.internal.editor;
+
+import org.eclipse.wst.jsdt.web.ui.internal.JsUIPlugin;
+
+/**
+*
+
+* Provisional API: This class/interface is part of an interim API that is still under development and expected to
+* change significantly before reaching stability. It is being made available at this early stage to solicit feedback
+* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
+* (repeatedly) as the API evolves.
+*/
+public interface IHelpContextIds {
+       // JSP Fragment Property Page
+       public static final String JSP_FRAGMENT_HELPID = IHelpContextIds.PREFIX + "jspf1000"; //$NON-NLS-1$
+       // // figured out on the fly
+       // // JSP Source page editor
+       // public static final String JSP_SOURCEVIEW_HELPID =
+       // ContentTypeIdForJSP.ContentTypeID_JSP +"_source_HelpId"; //$NON-NLS-1$
+       // JSP New File Wizard - Template Page
+       public static final String JSP_NEWWIZARD_TEMPLATE_HELPID = IHelpContextIds.PREFIX + "jspw0010"; //$NON-NLS-1$
+       // JSP Files Preference page
+       public static final String JSP_PREFWEBX_FILES_HELPID = IHelpContextIds.PREFIX + "webx0050"; //$NON-NLS-1$
+       // JSP Styles Preference page
+       public static final String JSP_PREFWEBX_STYLES_HELPID = IHelpContextIds.PREFIX + "webx0051"; //$NON-NLS-1$
+       // JSP Templates Preference page
+       public static final String JSP_PREFWEBX_TEMPLATES_HELPID = IHelpContextIds.PREFIX + "webx0052"; //$NON-NLS-1$
+       // Refactor Move
+       public static final String JSP_REFACTORMOVE_HELPID = IHelpContextIds.PREFIX + "jspr0020"; //$NON-NLS-1$
+       // JSP Source Editor Context Menu
+       // Refactor Rename
+       public static final String JSP_REFACTORRENAME_HELPID = IHelpContextIds.PREFIX + "jspr0010"; //$NON-NLS-1$
+       // org.eclipse.wst.jsdt.web.ui.
+       public static final String PREFIX = JsUIPlugin.ID + "."; //$NON-NLS-1$
+}
diff --git a/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/format/FormattingStrategyJSDT.java b/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/format/FormattingStrategyJSDT.java
new file mode 100644 (file)
index 0000000..b295d82
--- /dev/null
@@ -0,0 +1,302 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.web.ui.internal.format;
+
+import java.util.LinkedList;
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.eclipse.core.filebuffers.FileBuffers;
+import org.eclipse.core.filebuffers.ITextFileBuffer;
+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.text.BadLocationException;
+import org.eclipse.jface.text.Document;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IDocumentPartitioningListener;
+import org.eclipse.jface.text.Region;
+import org.eclipse.jface.text.TextUtilities;
+import org.eclipse.jface.text.TypedPosition;
+import org.eclipse.jface.text.formatter.ContextBasedFormattingStrategy;
+import org.eclipse.jface.text.formatter.FormattingContextProperties;
+import org.eclipse.jface.text.formatter.IFormattingContext;
+import org.eclipse.text.edits.ReplaceEdit;
+import org.eclipse.text.edits.TextEdit;
+import org.eclipse.wst.jsdt.core.IJavaScriptProject;
+import org.eclipse.wst.jsdt.core.JavaScriptCore;
+import org.eclipse.wst.jsdt.core.formatter.CodeFormatter;
+import org.eclipse.wst.jsdt.internal.corext.util.CodeFormatterUtil;
+import org.eclipse.wst.jsdt.internal.formatter.DefaultCodeFormatter;
+import org.eclipse.wst.jsdt.web.core.internal.Logger;
+import org.eclipse.wst.jsdt.web.core.javascript.IJsTranslation;
+import org.eclipse.wst.jsdt.web.core.javascript.IJsTranslator;
+import org.eclipse.wst.jsdt.web.core.javascript.JsTranslation;
+import org.eclipse.wst.jsdt.web.core.javascript.JsTranslationAdapter;
+import org.eclipse.wst.jsdt.web.core.javascript.JsTranslator;
+import org.eclipse.wst.sse.core.StructuredModelManager;
+import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument;
+import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
+import org.eclipse.wst.sse.core.internal.text.BasicStructuredDocument;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
+/**
+*
+
+* Provisional API: This class/interface is part of an interim API that is still under development and expected to
+* change significantly before reaching stability. It is being made available at this early stage to solicit feedback
+* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
+* (repeatedly) as the API evolves.
+*/
+public class FormattingStrategyJSDT extends ContextBasedFormattingStrategy {
+       /** matches on //--> at end of script region */
+       private static final Pattern END_PATTERN = Pattern.compile("((//.*-->\\s*)\\z)"); //$NON-NLS-1$
+       
+       private static final int regionStartIndentLevel = 1;
+       /** Documents to be formatted by this strategy */
+       private final LinkedList fDocuments = new LinkedList();
+       /** Partitions to be formatted by this strategy */
+       private final LinkedList fPartitions = new LinkedList();
+       private int startIndentLevel;
+       
+       /**
+        * Creates a new java formatting strategy.
+        */
+       public FormattingStrategyJSDT() {
+               super();
+       }
+       
+       class ModelIrritant implements IDocumentPartitioningListener {
+               public ModelIrritant(IDocument attachedDoc) {}
+               
+               public void documentPartitioningChanged(IDocument document) {
+                       document.removeDocumentPartitioningListener(this);
+                       if (document instanceof BasicStructuredDocument) {
+                               try {
+                                       ((BasicStructuredDocument) document).replace(0, document.getLength(), document.get());
+                               } catch (BadLocationException ex) {
+                                       // TODO Auto-generated catch block
+                                       ex.printStackTrace();
+                               }
+                       }
+               }
+       }
+       
+       /*
+        * @see org.eclipse.jface.text.formatter.ContextBasedFormattingStrategy#format()
+        */
+       
+       public void format() {
+               super.format();
+               final IStructuredDocument document = (IStructuredDocument) fDocuments.removeFirst();
+               final TypedPosition partition = (TypedPosition) fPartitions.removeFirst();
+               
+               if (document != null) {
+                       //calculate the indent of the leading <script> tag because we need to add that indent level to the JS indent level
+                       IStructuredDocumentRegion scriptTagStartRegion = document.getRegionAtCharacterOffset(partition.offset-1);
+                       String scriptRegionIndent = ""; //$NON-NLS-1$
+                       if(scriptTagStartRegion != null) {
+                               try {
+                                       int scriptRegionIndentLevel = getIndentOfLine(document,document.getLineOfOffset(scriptTagStartRegion.getStartOffset())).length();
+                                       scriptRegionIndent = getIndentationString(getPreferences(), scriptRegionIndentLevel);
+                                       this.startIndentLevel += scriptRegionIndentLevel;
+                               } catch (BadLocationException e) {
+                                       Logger.logException("Could not calculate starting indent of the script region, using 0", e);//$NON-NLS-1$
+                               }
+                       }
+               
+                       String lineDelim = TextUtilities.getDefaultLineDelimiter(document);
+                       try {
+                               //get the JS text from the document (not translated)
+                               String jsTextNotTranslated = document.get(partition.getOffset(), partition.getLength());
+                               
+                               //deal with getting the JS text and unwrapping it from any <!-- //--> statements
+                               String preText = "";
+                               String postText = lineDelim + scriptRegionIndent;
+
+                               //find start comment tag
+                               Pattern startPattern = Pattern.compile("(\\A(\\s*<!--.*(" + lineDelim + ")?))"); //$NON-NLS-1$
+                               Matcher matcher = startPattern.matcher(jsTextNotTranslated);
+                               if(matcher.find()) {
+                                       jsTextNotTranslated = matcher.replaceFirst(""); //$NON-NLS-1$
+                                       preText = lineDelim + scriptRegionIndent + matcher.group().trim();
+                               }
+                               
+                               //find end tag
+                               matcher = END_PATTERN.matcher(jsTextNotTranslated);
+                               if(matcher.find()) {
+                                       jsTextNotTranslated = matcher.replaceFirst(""); //$NON-NLS-1$
+                                       postText = lineDelim + scriptRegionIndent + matcher.group().trim() + postText;
+                               }
+                               
+                               //replace the text in the document with the none-translated JS text but without HTML leading and trailing comments
+                               TextEdit replaceEdit = new ReplaceEdit(partition.getOffset(), partition.getLength(), jsTextNotTranslated);
+                               replaceEdit.apply(document);
+                               int jsRegionLength = jsTextNotTranslated.length();
+                               
+                               //translate the updated document
+                               IJsTranslation translation = getTranslation(document);
+                               String jsTextTranslated = translation.getJsText();
+                               
+                               //format the text translated text
+                               TextEdit edit = CodeFormatterUtil.format2(CodeFormatter.K_JAVASCRIPT_UNIT, jsTextTranslated, partition.getOffset(), jsRegionLength, startIndentLevel, lineDelim, getPreferences());
+                               IDocument jsDoc = new Document(jsTextTranslated);
+                               
+                               //Undo the text replacements done by the translator so that it could build a CU for the JS region
+                               if(translation instanceof JsTranslation) {
+                                       IJsTranslator translator = ((JsTranslation)translation).getTranslator();
+                                       
+                                       if(translator instanceof JsTranslator) {
+                                               Region[] regions = ((JsTranslator)translator).getGeneratedRanges();
+                                               //for each generated range, replace it with the original text
+                                               for(int r = 0; r < regions.length; ++r) {
+                                                       jsDoc.replace(regions[r].getOffset(), regions[r].getLength(),
+                                                                       document.get(regions[r].getOffset(), regions[r].getLength()));
+                                               }
+                                       }
+                               }
+                               
+                               /* error formating the code so abort */
+                               if(edit==null) return;
+                               edit.apply(jsDoc);
+                               String replaceText = lineDelim + getIndentationString(getPreferences(), startIndentLevel) + (jsDoc.get(edit.getOffset(), edit.getLength())).trim();
+                               
+                               //apply edit to html doc using the formated translated text and the possible leading and trailing html comments
+                               replaceText = preText + replaceText + postText;
+                               replaceEdit = new ReplaceEdit(partition.getOffset(), jsRegionLength, replaceText);
+                               replaceEdit.apply(document);
+                       } catch (BadLocationException e) {
+                       }
+               }
+       }
+       
+       /*
+        * @see org.eclipse.jface.text.formatter.ContextBasedFormattingStrategy#formatterStarts(org.eclipse.jface.text.formatter.IFormattingContext)
+        */
+       
+       public void formatterStarts(final IFormattingContext context) {
+               fPartitions.addLast(context.getProperty(FormattingContextProperties.CONTEXT_PARTITION));
+               fDocuments.addLast(context.getProperty(FormattingContextProperties.CONTEXT_MEDIUM));
+               startIndentLevel = FormattingStrategyJSDT.regionStartIndentLevel + 0;
+               Map projectOptions = (Map) context.getProperty(FormattingContextProperties.CONTEXT_PREFERENCES);
+               if (projectOptions == null) {
+                       IDocument doc = (IDocument) context.getProperty(FormattingContextProperties.CONTEXT_MEDIUM);
+                       context.setProperty(FormattingContextProperties.CONTEXT_PREFERENCES, getProjectOptions(doc));
+               }
+               super.formatterStarts(context);
+       }
+       
+       /*
+        * @see org.eclipse.jface.text.formatter.ContextBasedFormattingStrategy#formatterStops()
+        */
+       
+       public void formatterStops() {
+               super.formatterStops();
+               fPartitions.clear();
+               fDocuments.clear();
+               startIndentLevel = 0;
+       }
+       
+       public String getIndentationString(Map options, int indentationLevel) {
+               DefaultCodeFormatter formatter = new DefaultCodeFormatter(options);
+               return formatter.createIndentationString(indentationLevel);
+       }
+       
+       private Map getProjectOptions(IDocument baseDocument) {
+               IJavaScriptProject javaProject = null;
+               Map options = null;
+               ITextFileBuffer buffer = FileBuffers.getTextFileBufferManager().getTextFileBuffer(baseDocument);
+               if (buffer != null) {
+                       IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
+                       IPath filePath = buffer.getLocation();
+                       IProject project = null;
+                       if (filePath.segmentCount() > 0) {
+                               project = root.getProject(filePath.segment(0));
+                       }
+                       if (project != null) {
+                               javaProject = JavaScriptCore.create(project);
+                       }
+               }
+               if (javaProject != null) {
+                       options = javaProject.getOptions(true);
+               }
+               if (options == null) {
+                       options = JavaScriptCore.getOptions();
+               }
+               return options;
+       }
+       
+       public IJsTranslation getTranslation(IStructuredDocument document) {
+               IJsTranslation tran = null;
+               IDOMModel xmlModel = null;
+               try {
+                       xmlModel = (IDOMModel) StructuredModelManager.getModelManager().getExistingModelForRead(document);
+                       IDOMDocument xmlDoc = xmlModel.getDocument();
+                       JsTranslationAdapter translationAdapter = (JsTranslationAdapter) xmlDoc.getAdapterFor(IJsTranslation.class);
+                       if (translationAdapter != null) {
+                               tran = translationAdapter.getJsTranslation(true);
+                       }
+               } finally {
+                       if (xmlModel != null) {
+                               xmlModel.releaseFromRead();
+                       }
+               }
+               return tran;
+       }
+       
+       /**
+        * 
+        * @param d
+        * @param line
+        * @return
+        * @throws BadLocationException
+        * 
+        * @see org.eclipse.wst.jsdt.internal.ui.text.java.JavaAutoIndentStrategy#getIndentOfLine
+        */
+       private String getIndentOfLine(IDocument d, int line) throws BadLocationException {
+               if (line > -1) {
+                       int start= d.getLineOffset(line);
+                       int end= start + d.getLineLength(line) - 1;
+                       int whiteEnd= findEndOfWhiteSpace(d, start, end);
+                       return d.get(start, whiteEnd - start);
+               } else {
+                       return ""; //$NON-NLS-1$
+               }
+       }
+       
+       /**
+        * Returns the first offset greater than <code>offset</code> and smaller than
+        * <code>end</code> whose character is not a space or tab character. If no such
+        * offset is found, <code>end</code> is returned.
+        *
+        * @param document the document to search in
+        * @param offset the offset at which searching start
+        * @param end the offset at which searching stops
+        * @return the offset in the specified range whose character is not a space or tab
+        * @exception BadLocationException if position is an invalid range in the given document
+        * 
+        * @see org.eclipse.jface.text.DefaultIndentLineAutoEditStrategy#findEndOfWhiteSpace
+        */
+       private int findEndOfWhiteSpace(IDocument document, int offset, int end) throws BadLocationException {
+               while (offset < end) {
+                       char c= document.getChar(offset);
+                       if (c != ' ' && c != '\t') {
+                               return offset;
+                       }
+                       offset++;
+               }
+               return end;
+       }
+       
+
+}
diff --git a/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/hyperlink/ExternalFileEditorInput.java b/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/hyperlink/ExternalFileEditorInput.java
new file mode 100644 (file)
index 0000000..018c424
--- /dev/null
@@ -0,0 +1,174 @@
+/*******************************************************************************
+ * 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.web.ui.internal.hyperlink;
+
+import java.io.File;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IPathEditorInput;
+import org.eclipse.ui.IPersistableElement;
+import org.eclipse.ui.editors.text.ILocationProvider;
+import org.eclipse.ui.model.IWorkbenchAdapter;
+
+/**
+*
+
+* Provisional API: This class/interface is part of an interim API that is still under development and expected to
+* change significantly before reaching stability. It is being made available at this early stage to solicit feedback
+* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
+* (repeatedly) as the API evolves.
+*/
+class ExternalFileEditorInput implements IEditorInput, ILocationProvider {
+       // copies of this class exist in:
+       // org.eclipse.wst.xml.ui.internal.hyperlink
+       // org.eclipse.wst.html.ui.internal.hyperlink
+       // org.eclipse.wst.jsdt.web.ui.internal.hyperlink
+       /**
+        * The workbench adapter which simply provides the label.
+        * 
+        * @see Eclipse 3.1
+        */
+       private class WorkbenchAdapter implements IWorkbenchAdapter {
+               /*
+                * @see org.eclipse.ui.model.IWorkbenchAdapter#getChildren(java.lang.Object)
+                */
+               public Object[] getChildren(Object o) {
+                       return null;
+               }
+               
+               /*
+                * @see org.eclipse.ui.model.IWorkbenchAdapter#getImageDescriptor(java.lang.Object)
+                */
+               public ImageDescriptor getImageDescriptor(Object object) {
+                       return null;
+               }
+               
+               /*
+                * @see org.eclipse.ui.model.IWorkbenchAdapter#getLabel(java.lang.Object)
+                */
+               public String getLabel(Object o) {
+                       return ((ExternalFileEditorInput) o).getName();
+               }
+               
+               /*
+                * @see org.eclipse.ui.model.IWorkbenchAdapter#getParent(java.lang.Object)
+                */
+               public Object getParent(Object o) {
+                       return null;
+               }
+       }
+       private File fFile;
+       private WorkbenchAdapter fWorkbenchAdapter = new WorkbenchAdapter();
+       
+       public ExternalFileEditorInput(File file) {
+               super();
+               fFile = file;
+               fWorkbenchAdapter = new WorkbenchAdapter();
+       }
+       
+       /*
+        * @see java.lang.Object#equals(java.lang.Object)
+        */
+       
+       public boolean equals(Object o) {
+               if (o == this) {
+                       return true;
+               }
+               if (o instanceof ExternalFileEditorInput) {
+                       ExternalFileEditorInput input = (ExternalFileEditorInput) o;
+                       return fFile.equals(input.fFile);
+               }
+               if (o instanceof IPathEditorInput) {
+                       IPathEditorInput input = (IPathEditorInput) o;
+                       return getPath().equals(input.getPath());
+               }
+               return false;
+       }
+       
+       /*
+        * @see org.eclipse.ui.IEditorInput#exists()
+        */
+       public boolean exists() {
+               return fFile.exists();
+       }
+       
+       /*
+        * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
+        */
+       public Object getAdapter(Class adapter) {
+               if (ILocationProvider.class.equals(adapter)) {
+                       return this;
+               }
+               if (IWorkbenchAdapter.class.equals(adapter)) {
+                       return fWorkbenchAdapter;
+               }
+               return Platform.getAdapterManager().getAdapter(this, adapter);
+       }
+       
+       /*
+        * @see org.eclipse.ui.IEditorInput#getImageDescriptor()
+        */
+       public ImageDescriptor getImageDescriptor() {
+               return null;
+       }
+       
+       /*
+        * @see org.eclipse.ui.IEditorInput#getName()
+        */
+       public String getName() {
+               return fFile.getName();
+       }
+       
+       /*
+        * @see org.eclipse.ui.IPathEditorInput#getPath()
+        * @since 3.1
+        */
+       public IPath getPath() {
+               return Path.fromOSString(fFile.getAbsolutePath());
+       }
+       
+       /*
+        * @see org.eclipse.ui.editors.text.ILocationProvider#getPath(java.lang.Object)
+        */
+       public IPath getPath(Object element) {
+               if (element instanceof ExternalFileEditorInput) {
+                       ExternalFileEditorInput input = (ExternalFileEditorInput) element;
+                       return Path.fromOSString(input.fFile.getAbsolutePath());
+               }
+               return null;
+       }
+       
+       /*
+        * @see org.eclipse.ui.IEditorInput#getPersistable()
+        */
+       public IPersistableElement getPersistable() {
+               return null;
+       }
+       
+       /*
+        * @see org.eclipse.ui.IEditorInput#getToolTipText()
+        */
+       public String getToolTipText() {
+               return fFile.getAbsolutePath();
+       }
+       
+       /*
+        * @see java.lang.Object#hashCode()
+        */
+       
+       public int hashCode() {
+               return fFile.hashCode();
+       }
+}
diff --git a/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/hyperlink/ExternalFileHyperlink.java b/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/hyperlink/ExternalFileHyperlink.java
new file mode 100644 (file)
index 0000000..d8905ef
--- /dev/null
@@ -0,0 +1,79 @@
+/*******************************************************************************
+ * 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.web.ui.internal.hyperlink;
+
+import java.io.File;
+
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.hyperlink.IHyperlink;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.ui.IEditorDescriptor;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.ide.IDE;
+import org.eclipse.wst.html.ui.internal.HTMLUIMessages;
+import org.eclipse.wst.jsdt.web.ui.internal.Logger;
+
+/**
+*
+
+* Provisional API: This class/interface is part of an interim API that is still under development and expected to
+* change significantly before reaching stability. It is being made available at this early stage to solicit feedback
+* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
+* (repeatedly) as the API evolves.
+*/
+class ExternalFileHyperlink implements IHyperlink {
+       // copies of this class exist in:
+       // org.eclipse.wst.xml.ui.internal.hyperlink
+       // org.eclipse.wst.html.ui.internal.hyperlink
+       // org.eclipse.wst.jsdt.web.ui.internal.hyperlink
+       private File fHyperlinkFile;
+       private IRegion fHyperlinkRegion;
+       
+       public ExternalFileHyperlink(IRegion region, File file) {
+               fHyperlinkFile = file;
+               fHyperlinkRegion = region;
+       }
+       
+       public IRegion getHyperlinkRegion() {
+               return fHyperlinkRegion;
+       }
+       
+       public String getHyperlinkText() {
+               String path = fHyperlinkFile.getPath();
+               if (path.length() > 60) {
+                       path = path.substring(0, 25) + "..." + path.substring(path.length() - 25, path.length());
+               }
+               return NLS.bind(HTMLUIMessages.Open, path);
+       }
+       
+       public String getTypeLabel() {
+               return null;
+       }
+       
+       public void open() {
+               if (fHyperlinkFile != null) {
+                       IEditorInput input = new ExternalFileEditorInput(fHyperlinkFile);
+                       IEditorDescriptor descriptor;
+                       try {
+                               descriptor = IDE.getEditorDescriptor(input.getName(), true);
+                               if (descriptor != null) {
+                                       IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
+                                       IDE.openEditor(page, input, descriptor.getId(), true);
+                               }
+                       } catch (PartInitException e) {
+                               Logger.log(Logger.WARNING_DEBUG, e.getMessage(), e);
+                       }
+               }
+       }
+}
diff --git a/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/hyperlink/JSDTHyperlink.java b/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/hyperlink/JSDTHyperlink.java
new file mode 100644 (file)
index 0000000..2dbb3fd
--- /dev/null
@@ -0,0 +1,81 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2011 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.web.ui.internal.hyperlink;
+
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.hyperlink.IHyperlink;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.wst.html.ui.internal.HTMLUIMessages;
+import org.eclipse.wst.jsdt.core.IJavaScriptElement;
+import org.eclipse.wst.jsdt.internal.ui.actions.ActionMessages;
+import org.eclipse.wst.jsdt.ui.JavaScriptUI;
+import org.eclipse.wst.jsdt.web.ui.internal.Logger;
+/**
+*
+
+* Provisional API: This class/interface is part of an interim API that is still under development and expected to
+* change significantly before reaching stability. It is being made available at this early stage to solicit feedback
+* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
+* (repeatedly) as the API evolves.
+*/
+class JSDTHyperlink implements IHyperlink {
+       private IJavaScriptElement fElement;
+       private IRegion fRegion;
+       
+       public JSDTHyperlink(IRegion region, IJavaScriptElement element) {
+               fRegion = region;
+               fElement = element;
+       }
+       
+       /*
+        * (non-Javadoc)
+        * 
+        * @see org.eclipse.jface.text.hyperlink.IHyperlink#getHyperlinkRegion()
+        */
+       public IRegion getHyperlinkRegion() {
+               return fRegion;
+       }
+       
+       /*
+        * (non-Javadoc)
+        * 
+        * @see org.eclipse.jface.text.hyperlink.IHyperlink#getHyperlinkText()
+        */
+       public String getHyperlinkText() {
+               return fElement != null ? NLS.bind(HTMLUIMessages.Open, fElement.getDisplayName()) : ActionMessages.OpenAction_declaration_label;
+       }
+       
+       /*
+        * (non-Javadoc)
+        * 
+        * @see org.eclipse.jface.text.hyperlink.IHyperlink#getTypeLabel()
+        */
+       public String getTypeLabel() {
+               return null;
+       }
+       
+       /*
+        * (non-Javadoc)
+        * 
+        * @see org.eclipse.jface.text.hyperlink.IHyperlink#open()
+        */
+       public void open() {
+               try {
+                       IEditorPart editor = JavaScriptUI.openInEditor(fElement);
+                       if (editor != null) {
+                               JavaScriptUI.revealInEditor(editor, fElement);
+                       }
+               } catch (Exception e) {
+                       Logger.log(Logger.WARNING_DEBUG, e.getMessage(), e);
+               }
+       }
+}
diff --git a/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/hyperlink/JSDTHyperlinkDetector.java b/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/hyperlink/JSDTHyperlinkDetector.java
new file mode 100644 (file)
index 0000000..2193098
--- /dev/null
@@ -0,0 +1,263 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2009 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.web.ui.internal.hyperlink;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.ITextViewer;
+import org.eclipse.jface.text.Region;
+import org.eclipse.jface.text.hyperlink.AbstractHyperlinkDetector;
+import org.eclipse.jface.text.hyperlink.IHyperlink;
+import org.eclipse.wst.jsdt.core.IClassFile;
+import org.eclipse.wst.jsdt.core.IField;
+import org.eclipse.wst.jsdt.core.IFunction;
+import org.eclipse.wst.jsdt.core.IJavaScriptElement;
+import org.eclipse.wst.jsdt.core.IJavaScriptUnit;
+import org.eclipse.wst.jsdt.core.ILocalVariable;
+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.core.JavaElement;
+import org.eclipse.wst.jsdt.web.core.javascript.IJsTranslation;
+import org.eclipse.wst.jsdt.web.core.javascript.JsTranslationAdapter;
+import org.eclipse.wst.jsdt.web.ui.internal.Logger;
+import org.eclipse.wst.sse.core.StructuredModelManager;
+import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
+
+/**
+*
+
+* Provisional API: This class/interface is part of an interim API that is still under development and expected to
+* change significantly before reaching stability. It is being made available at this early stage to solicit feedback
+* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
+* (repeatedly) as the API evolves.
+*/
+public class JSDTHyperlinkDetector extends AbstractHyperlinkDetector {
+       private IHyperlink createHyperlink(IJavaScriptElement element, IRegion region, IDocument document) {
+               IHyperlink link = null;
+               if (region != null) {
+                       // open local variable in the JSP file...
+                       if (element instanceof ISourceReference) {
+                               IFile file = null;
+                               IPath outsidePath = null;
+                               int jspOffset = 0;
+                               IStructuredModel sModel = null;
+                               // try to locate the file in the workspace
+                               try {
+                                       sModel = StructuredModelManager.getModelManager().getExistingModelForRead(document);
+                                       if (sModel != null) {
+                                               //URIResolver resolver = sModel.getResolver();
+                                               //if (resolver != null) {
+                                               //      String uriString = resolver.getFileBaseLocation();
+                                               String uriString = sModel.getBaseLocation();
+                                                       file = getFile(uriString);
+                                       //      }
+                                       }
+                               } finally {
+                                       if (sModel != null) {
+                                               sModel.releaseFromRead();
+                                       }
+                               }
+                               // get Java range, translate coordinate to JSP
+                               try {
+                                       ISourceRange range = null;
+                                       IJsTranslation jspTranslation = getJsTranslation(document);
+                                       if (jspTranslation != null) {
+                                               // link to local variable definitions
+                                               if (element instanceof ILocalVariable) {
+                                                       range = ((ILocalVariable) element).getNameRange();
+                                                       IJavaScriptElement unit=((ILocalVariable) element).getParent();
+                                                       IJavaScriptUnit myUnit = jspTranslation.getCompilationUnit();
+                                                       
+                                                       while(!(unit instanceof IJavaScriptUnit || unit instanceof IClassFile || unit==null)) {
+                                                               unit = ((JavaElement) unit).getParent();
+                                                       }
+                                                       if(unit instanceof IJavaScriptUnit) {
+                                                               IJavaScriptUnit cu = (IJavaScriptUnit)unit;
+                                                               if(cu!=myUnit) {
+                                                                       file = getFile(cu.getPath().toString());
+                                                                       if(file==null) {
+                                                                               outsidePath = cu.getPath();
+                                                                       }
+                                                               }
+                                                       }else if(unit instanceof IClassFile) {
+                                                               IClassFile cu = (IClassFile)unit;
+                                                               if(cu!=myUnit) {
+                                                                       file = getFile(cu.getPath().toString());
+                                                                       if(file==null) {
+                                                                               outsidePath = cu.getPath();
+                                                                       }
+                                                               }
+                                                       }
+                                                       
+                                               }
+                                               // linking to fields of the same compilation unit
+                                               else if (element.getElementType() == IJavaScriptElement.FIELD) {
+                                                       Object cu = ((IField) element).getJavaScriptUnit();
+                                                       if (cu != null && cu.equals(jspTranslation.getCompilationUnit())) {
+                                                               range = ((ISourceReference) element).getSourceRange();
+                                                       }
+                                               }
+                                               // linking to methods of the same compilation unit
+                                               else if (element.getElementType() == IJavaScriptElement.METHOD) {
+                                                       Object cu = ((IFunction) element).getJavaScriptUnit();
+                                                       if (cu != null && cu.equals(jspTranslation.getCompilationUnit())) {
+                                                               range = ((ISourceReference) element).getSourceRange();
+                                                       }
+                                               }
+                                       }
+                                       if (range != null && file != null) {
+                                               jspOffset = range.getOffset();
+                                               if (jspOffset >= 0) {
+                                                       link = new WorkspaceFileHyperlink(region, file, new Region(jspOffset, range.getLength()));
+                                               }
+                                       }else if (range!=null && outsidePath!=null) {
+                                               jspOffset = range.getOffset();
+                                               if (jspOffset >= 0) {
+                                                       link = new ExternalFileHyperlink(region,outsidePath.toFile());
+                                               }
+                                       }
+                               } catch (JavaScriptModelException jme) {
+                                       Logger.log(Logger.WARNING_DEBUG, jme.getMessage(), jme);
+                               }
+                       }
+                       if (link == null) {
+                               link = new JSDTHyperlink(region, element);
+                       }
+               }
+               return link;
+       }
+       
+       /*
+        * (non-Javadoc)
+        * 
+        * @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) {
+               List hyperlinks = new ArrayList(0);
+               if (region != null && textViewer != null) {
+                       IDocument document = textViewer.getDocument();
+                       IJsTranslation jsTranslation = getJsTranslation(document);
+                       if (jsTranslation != null) {
+                               IJavaScriptElement[] elements = jsTranslation.getElementsFromJsRange(region.getOffset(), region.getOffset() + region.getLength());
+                               if (elements != null && elements.length > 0) {
+                                       // create a hyperlink for each JavaScript element
+                                       for (int i = 0; i < elements.length; ++i) {
+                                               IJavaScriptElement element = elements[i];
+                                               // find hyperlink range for Java element
+                                               IRegion hyperlinkRegion = selectWord(document, region.getOffset());
+                                               IHyperlink link = createHyperlink(element, hyperlinkRegion, document);
+                                               if (link != null) {
+                                                       hyperlinks.add(link);
+                                               }
+                                       }
+                               }
+                       }
+               }
+               if (hyperlinks.size() == 0) {
+                       return null;
+               }
+               return (IHyperlink[]) hyperlinks.toArray(new IHyperlink[0]);
+       }
+       
+       /**
+        * Returns an IFile from the given uri if possible, null if cannot find file
+        * from uri.
+        * 
+        * @param fileString
+        *            file system path
+        * @return returns IFile if fileString exists in the workspace
+        */
+       private IFile getFile(String fileString) {
+               IFile file = null;
+               if (fileString != null) {
+                       IResource resource  = ResourcesPlugin.getWorkspace().getRoot().findMember(fileString);
+                       if(resource!=null && resource instanceof IFile) {
+                               file = (IFile)resource;
+                       }
+               }
+               return file;
+       }
+       
+       /**
+        * Get JSP translation object
+        * 
+        * @return JSPTranslation if one exists, null otherwise
+        */
+       private IJsTranslation getJsTranslation(IDocument document) {
+               IJsTranslation translation = null;
+               IDOMModel xmlModel = null;
+               try {
+                       xmlModel = (IDOMModel) StructuredModelManager.getModelManager().getExistingModelForRead(document);
+                       if (xmlModel != null) {
+                               IDOMDocument xmlDoc = xmlModel.getDocument();
+                               JsTranslationAdapter adapter = (JsTranslationAdapter) xmlDoc.getAdapterFor(IJsTranslation.class);
+                               if (adapter != null) {
+                                       translation = adapter.getJsTranslation(true);
+                               }
+                       }
+               } finally {
+                       if (xmlModel != null) {
+                               xmlModel.releaseFromRead();
+                       }
+               }
+               return translation;
+       }
+       
+       /**
+        * Java always selects word when defining region
+        * 
+        * @param document
+        * @param anchor
+        * @return IRegion
+        */
+       private IRegion selectWord(IDocument document, int anchor) {
+               try {
+                       int offset = anchor;
+                       char c;
+                       while (offset >= 0) {
+                               c = document.getChar(offset);
+                               if (!Character.isJavaIdentifierPart(c)) {
+                                       break;
+                               }
+                               --offset;
+                       }
+                       int start = offset;
+                       offset = anchor;
+                       int length = document.getLength();
+                       while (offset < length) {
+                               c = document.getChar(offset);
+                               if (!Character.isJavaIdentifierPart(c)) {
+                                       break;
+                               }
+                               ++offset;
+                       }
+                       int end = offset;
+                       if (start == end) {
+                               return new Region(start, 0);
+                       }
+                       return new Region(start + 1, end - start - 1);
+               } catch (BadLocationException x) {
+                       return null;
+               }
+       }
+}
diff --git a/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/hyperlink/WorkspaceFileHyperlink.java b/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/hyperlink/WorkspaceFileHyperlink.java
new file mode 100644 (file)
index 0000000..ea48fbb
--- /dev/null
@@ -0,0 +1,87 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2009 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.web.ui.internal.hyperlink;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.hyperlink.IHyperlink;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.ide.IDE;
+import org.eclipse.ui.texteditor.ITextEditor;
+import org.eclipse.wst.html.ui.internal.HTMLUIMessages;
+import org.eclipse.wst.jsdt.web.ui.internal.Logger;
+
+class WorkspaceFileHyperlink implements IHyperlink {
+       // copies of this class exist in:
+       // org.eclipse.wst.xml.ui.internal.hyperlink
+       // org.eclipse.wst.html.ui.internal.hyperlink
+       // org.eclipse.wst.jsdt.web.ui.internal.hyperlink
+       private IFile fFile;
+       private IRegion fHighlightRange;
+       private IRegion fRegion;
+       
+       public WorkspaceFileHyperlink(IRegion region, IFile file) {
+               fRegion = region;
+               fFile = file;
+       }
+       
+       public WorkspaceFileHyperlink(IRegion region, IFile file, IRegion range) {
+               fRegion = region;
+               fFile = file;
+               fHighlightRange = range;
+       }
+       
+       public IRegion getHyperlinkRegion() {
+               return fRegion;
+       }
+       
+       /*
+        * (non-Javadoc)
+        * 
+        * @see org.eclipse.jface.text.hyperlink.IHyperlink#getHyperlinkText()
+        */
+       public String getHyperlinkText() {
+               String path = fFile.getFullPath().toString();
+               if (path.length() > 60) {
+                       path = path.substring(0, 25) + "..." + path.substring(path.length() - 25, path.length());
+               }
+               return NLS.bind(HTMLUIMessages.Open, path);
+       }
+       
+       /*
+        * (non-Javadoc)
+        * 
+        * @see org.eclipse.jface.text.hyperlink.IHyperlink#getTypeLabel()
+        */
+       public String getTypeLabel() {
+               // TODO Auto-generated method stub
+               return null;
+       }
+       
+       public void open() {
+               if (fFile != null && fFile.exists()) {
+                       try {
+                               IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
+                               IEditorPart editor = IDE.openEditor(page, fFile, true);
+                               // highlight range in editor if possible
+                               if (fHighlightRange != null && editor instanceof ITextEditor) {
+                                       ((ITextEditor) editor).selectAndReveal(fHighlightRange.getOffset(), fHighlightRange.getLength());
+                               }
+                       } catch (PartInitException pie) {
+                               Logger.log(Logger.WARNING_DEBUG, pie.getMessage(), pie);
+                       }
+               }
+       }
+}
diff --git a/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/hyperlink/XMLHyperlinkDetector.java b/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/hyperlink/XMLHyperlinkDetector.java
new file mode 100644 (file)
index 0000000..bf603d0
--- /dev/null
@@ -0,0 +1,502 @@
+/*******************************************************************************
+ * 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.web.ui.internal.hyperlink;
+
+import java.io.File;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.List;
+
+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.jface.text.IDocument;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.ITextViewer;
+import org.eclipse.jface.text.Region;
+import org.eclipse.jface.text.hyperlink.IHyperlink;
+import org.eclipse.jface.text.hyperlink.IHyperlinkDetector;
+import org.eclipse.jface.text.hyperlink.URLHyperlink;
+import org.eclipse.wst.common.uriresolver.internal.provisional.URIResolverPlugin;
+import org.eclipse.wst.sse.core.StructuredModelManager;
+import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
+import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion;
+import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion;
+import org.eclipse.wst.sse.core.utils.StringUtils;
+import org.eclipse.wst.xml.core.internal.contentmodel.CMAttributeDeclaration;
+import org.eclipse.wst.xml.core.internal.contentmodel.CMDataType;
+import org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration;
+import org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQuery;
+import org.eclipse.wst.xml.core.internal.contentmodel.util.DOMNamespaceHelper;
+import org.eclipse.wst.xml.core.internal.modelquery.ModelQueryUtil;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMAttr;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
+import org.w3c.dom.Attr;
+import org.w3c.dom.DocumentType;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+
+import com.ibm.icu.util.StringTokenizer;
+
+/**
+*
+
+* Provisional API: This class/interface is part of an interim API that is still under development and expected to
+* change significantly before reaching stability. It is being made available at this early stage to solicit feedback
+* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
+* (repeatedly) as the API evolves.
+*/
+public class XMLHyperlinkDetector implements IHyperlinkDetector {
+       // copies of this class exist in:
+       // org.eclipse.wst.xml.ui.internal.hyperlink
+       // org.eclipse.wst.html.ui.internal.hyperlink
+       // org.eclipse.wst.jsdt.web.ui.internal.hyperlink
+       private final String HTTP_PROTOCOL = "http://";//$NON-NLS-1$
+       private final String NO_NAMESPACE_SCHEMA_LOCATION = "noNamespaceSchemaLocation"; //$NON-NLS-1$
+       private final String SCHEMA_LOCATION = "schemaLocation"; //$NON-NLS-1$
+       private final String XMLNS = "xmlns"; //$NON-NLS-1$
+       private final String XSI_NAMESPACE_URI = "http://www.w3.org/2001/XMLSchema-instance"; //$NON-NLS-1$
+       
+       /**
+        * Create the appropriate hyperlink
+        * 
+        * @param uriString
+        * @param hyperlinkRegion
+        * @return IHyperlink
+        */
+       private IHyperlink createHyperlink(String uriString, IRegion hyperlinkRegion, IDocument document, Node node) {
+               IHyperlink link = null;
+               if (isHttp(uriString)) {
+                       link = new URLHyperlink(hyperlinkRegion, uriString);
+               } else {
+                       // try to locate the file in the workspace
+                       File systemFile = getFileFromUriString(uriString);
+                       if (systemFile != null) {
+                               String systemPath = systemFile.getPath();
+                               IFile file = getFile(systemPath);
+                               if (file != null) {
+                                       // this is a WorkspaceFileHyperlink since file exists in
+                                       // workspace
+                                       link = new WorkspaceFileHyperlink(hyperlinkRegion, file);
+                               } else {
+                                       // this is an ExternalFileHyperlink since file does not
+                                       // exist in workspace
+                                       link = new ExternalFileHyperlink(hyperlinkRegion, systemFile);
+                               }
+                       }
+               }
+               return link;
+       }
+       
+       public IHyperlink[] detectHyperlinks(ITextViewer textViewer, IRegion region, boolean canShowMultipleHyperlinks) {
+               // for now, only capable of creating 1 hyperlink
+               List hyperlinks = new ArrayList(0);
+               if (region != null && textViewer != null) {
+                       IDocument document = textViewer.getDocument();
+                       Node currentNode = getCurrentNode(document, region.getOffset());
+                       if (currentNode != null) {
+                               String uriString = null;
+                               if (currentNode.getNodeType() == Node.DOCUMENT_TYPE_NODE) {
+                                       // doctype nodes
+                                       uriString = getURIString(currentNode, document);
+                               } else if (currentNode.getNodeType() == Node.ELEMENT_NODE) {
+                                       // element nodes
+                                       Attr currentAttr = getCurrentAttrNode(currentNode, region.getOffset());
+                                       if (currentAttr != null) {
+                                               // try to find link for current attribute
+                                               // resolve attribute value
+                                               uriString = getURIString(currentAttr, document);
+                                               // verify validity of uri string
+                                               if (uriString == null || !isValidURI(uriString)) {
+                                                       // reset current attribute
+                                                       currentAttr = null;
+                                               }
+                                       }
+                                       if (currentAttr == null) {
+                                               // try to find a linkable attribute within element
+                                               currentAttr = getLinkableAttr((Element) currentNode);
+                                               if (currentAttr != null) {
+                                                       uriString = getURIString(currentAttr, document);
+                                               }
+                                       }
+                                       currentNode = currentAttr;
+                               }
+                               // try to create hyperlink from information gathered
+                               if (uriString != null && currentNode != null && isValidURI(uriString)) {
+                                       IRegion hyperlinkRegion = getHyperlinkRegion(currentNode);
+                                       IHyperlink hyperlink = createHyperlink(uriString, hyperlinkRegion, document, currentNode);
+                                       if (hyperlink != null) {
+                                               hyperlinks.add(hyperlink);
+                                       }
+                               }
+                       }
+               }
+               if (hyperlinks.size() == 0) {
+                       return null;
+               }
+               return (IHyperlink[]) hyperlinks.toArray(new IHyperlink[0]);
+       }
+       
+       /**
+        * Get the base location from the current model (local file system)
+        */
+       private String getBaseLocation(IDocument document) {
+               String baseLoc = null;
+               // get the base location from the current model
+               IStructuredModel sModel = null;
+               try {
+                       sModel = StructuredModelManager.getModelManager().getExistingModelForRead(document);
+                       if (sModel != null) {
+                               IPath location = new Path(sModel.getBaseLocation());
+                               if (location.toFile().exists()) {
+                                       baseLoc = location.toString();
+                               } else {
+                                       if (location.segmentCount() > 1) {
+                                               baseLoc = ResourcesPlugin.getWorkspace().getRoot().getFile(location).getLocation().toString();
+                                       } else {
+                                               baseLoc = ResourcesPlugin.getWorkspace().getRoot().getLocation().append(location).toString();
+                                       }
+                               }
+                       }
+               } finally {
+                       if (sModel != null) {
+                               sModel.releaseFromRead();
+                       }
+               }
+               return baseLoc;
+       }
+       
+       /**
+        * Get the CMElementDeclaration for an element
+        * 
+        * @param element
+        * @return CMElementDeclaration
+        */
+       private CMElementDeclaration getCMElementDeclaration(Element element) {
+               CMElementDeclaration ed = null;
+               ModelQuery mq = ModelQueryUtil.getModelQuery(element.getOwnerDocument());
+               if (mq != null) {
+                       ed = mq.getCMElementDeclaration(element);
+               }
+               return ed;
+       }
+       
+       /**
+        * Returns the attribute node within node at offset
+        * 
+        * @param node
+        * @param offset
+        * @return Attr
+        */
+       private Attr getCurrentAttrNode(Node node, int offset) {
+               if ((node instanceof IndexedRegion) && ((IndexedRegion) node).contains(offset) && (node.hasAttributes())) {
+                       NamedNodeMap attrs = node.getAttributes();
+                       // go through each attribute in node and if attribute contains
+                       // offset, return that attribute
+                       for (int i = 0; i < attrs.getLength(); ++i) {
+                               // assumption that if parent node is of type IndexedRegion,
+                               // then its attributes will also be of type IndexedRegion
+                               IndexedRegion attRegion = (IndexedRegion) attrs.item(i);
+                               if (attRegion.contains(offset)) {
+                                       return (Attr) attrs.item(i);
+                               }
+                       }
+               }
+               return null;
+       }
+       
+       /**
+        * Returns the node the cursor is currently on in the document. null if no
+        * node is selected
+        * 
+        * @param offset
+        * @return Node either element, doctype, text, or null
+        */
+       private Node getCurrentNode(IDocument document, int offset) {
+               // get the current node at the offset (returns either: element,
+               // doctype, text)
+               IndexedRegion inode = null;
+               IStructuredModel sModel = null;
+               try {
+                       sModel = StructuredModelManager.getModelManager().getExistingModelForRead(document);
+                       inode = sModel.getIndexedRegion(offset);
+                       if (inode == null) {
+                               inode = sModel.getIndexedRegion(offset - 1);
+                       }
+               } finally {
+                       if (sModel != null) {
+                               sModel.releaseFromRead();
+                       }
+               }
+               if (inode instanceof Node) {
+                       return (Node) inode;
+               }
+               return null;
+       }
+       
+       /**
+        * Returns an IFile from the given uri if possible, null if cannot find file
+        * from uri.
+        * 
+        * @param fileString
+        *            file system path
+        * @return returns IFile if fileString exists in the workspace
+        */
+       private IFile getFile(String fileString) {
+               IFile file = null;
+               if (fileString != null) {
+                       IFile[] files = ResourcesPlugin.getWorkspace().getRoot().findFilesForLocation(new Path(fileString));
+                       for (int i = 0; i < files.length && file == null; i++) {
+                               if (files[i].exists()) {
+                                       file = files[i];
+                               }
+                       }
+               }
+               return file;
+       }
+       
+       /**
+        * Create a file from the given uri string
+        * 
+        * @param uriString -
+        *            assumes uriString is not http://
+        * @return File created from uriString if possible, null otherwise
+        */
+       private File getFileFromUriString(String uriString) {
+               File file = null;
+               try {
+                       // first just try to create a file directly from uriString as
+                       // default in case create file from uri does not work
+                       file = new File(uriString);
+                       // try to create file from uri
+                       URI uri = new URI(uriString);
+                       file = new File(uri);
+               } catch (Exception e) {
+                       // if exception is thrown while trying to create File just ignore
+                       // and file will be null
+               }
+               return file;
+       }
+       
+       private IRegion getHyperlinkRegion(Node node) {
+               IRegion hyperRegion = null;
+               if (node != null) {
+                       short nodeType = node.getNodeType();
+                       if (nodeType == Node.DOCUMENT_TYPE_NODE) {
+                               // handle doc type node
+                               IDOMNode docNode = (IDOMNode) node;
+                               hyperRegion = new Region(docNode.getStartOffset(), docNode.getEndOffset() - docNode.getStartOffset());
+                       } else if (nodeType == Node.ATTRIBUTE_NODE) {
+                               // handle attribute nodes
+                               IDOMAttr att = (IDOMAttr) node;
+                               // do not include quotes in attribute value region
+                               int regOffset = att.getValueRegionStartOffset();
+                               ITextRegion valueRegion = att.getValueRegion();
+                               if (valueRegion != null) {
+                                       int regLength = valueRegion.getTextLength();
+                                       String attValue = att.getValueRegionText();
+                                       if (StringUtils.isQuoted(attValue)) {
+                                               ++regOffset;
+                                               regLength = regLength - 2;
+                                       }
+                                       hyperRegion = new Region(regOffset, regLength);
+                               }
+                       }
+               }
+               return hyperRegion;
+       }
+       
+       /**
+        * Attempts to find an attribute within element that is openable.
+        * 
+        * @param element -
+        *            cannot be null
+        * @return Attr attribute that can be used for open on, null if no attribute
+        *         could be found
+        */
+       private Attr getLinkableAttr(Element element) {
+               CMElementDeclaration ed = getCMElementDeclaration(element);
+               // get the list of attributes for this node
+               NamedNodeMap attrs = element.getAttributes();
+               for (int i = 0; i < attrs.getLength(); ++i) {
+                       // check if this attribute is "openOn-able"
+                       Attr att = (Attr) attrs.item(i);
+                       if (isLinkableAttr(att, ed)) {
+                               return att;
+                       }
+               }
+               return null;
+       }
+       
+       /**
+        * Find the location hint for the given namespaceURI if it exists
+        * 
+        * @param elementNode -
+        *            cannot be null
+        * @param namespaceURI -
+        *            cannot be null
+        * @return location hint (systemId) if it was found, null otherwise
+        */
+       private String getLocationHint(Element elementNode, String namespaceURI) {
+               Attr schemaLocNode = elementNode.getAttributeNodeNS(XSI_NAMESPACE_URI, SCHEMA_LOCATION);
+               if (schemaLocNode != null) {
+                       StringTokenizer st = new StringTokenizer(schemaLocNode.getValue());
+                       while (st.hasMoreTokens()) {
+                               String publicId = st.hasMoreTokens() ? st.nextToken() : null;
+                               String systemId = st.hasMoreTokens() ? st.nextToken() : null;
+                               // found location hint
+                               if (namespaceURI.equalsIgnoreCase(publicId)) {
+                                       return systemId;
+                               }
+                       }
+               }
+               return null;
+       }
+       
+       /**
+        * Returns the URI string
+        * 
+        * @param node -
+        *            assumes not null
+        */
+       private String getURIString(Node node, IDocument document) {
+               String resolvedURI = null;
+               // need the base location, publicId, and systemId for URIResolver
+               String baseLoc = null;
+               String publicId = null;
+               String systemId = null;
+               short nodeType = node.getNodeType();
+               // handle doc type node
+               if (nodeType == Node.DOCUMENT_TYPE_NODE) {
+                       baseLoc = getBaseLocation(document);
+                       publicId = ((DocumentType) node).getPublicId();
+                       systemId = ((DocumentType) node).getSystemId();
+               } else if (nodeType == Node.ATTRIBUTE_NODE) {
+                       // handle attribute node
+                       Attr attrNode = (Attr) node;
+                       String attrName = attrNode.getName();
+                       String attrValue = attrNode.getValue();
+                       attrValue = StringUtils.strip(attrValue);
+                       if (attrValue != null && attrValue.length() > 0) {
+                               baseLoc = getBaseLocation(document);
+                               // handle schemaLocation attribute
+                               String prefix = DOMNamespaceHelper.getPrefix(attrName);
+                               String unprefixedName = DOMNamespaceHelper.getUnprefixedName(attrName);
+                               if ((XMLNS.equals(prefix)) || (XMLNS.equals(unprefixedName))) {
+                                       publicId = attrValue;
+                                       systemId = getLocationHint(attrNode.getOwnerElement(), publicId);
+                                       if (systemId == null) {
+                                               systemId = attrValue;
+                                       }
+                               } else if ((XSI_NAMESPACE_URI.equals(DOMNamespaceHelper.getNamespaceURI(attrNode))) && (SCHEMA_LOCATION.equals(unprefixedName))) {
+                                       // for now just use the first pair
+                                       // need to look into being more precise
+                                       StringTokenizer st = new StringTokenizer(attrValue);
+                                       publicId = st.hasMoreTokens() ? st.nextToken() : null;
+                                       systemId = st.hasMoreTokens() ? st.nextToken() : null;
+                                       // else check if xmlns publicId = value
+                               } else {
+                                       systemId = attrValue;
+                               }
+                       }
+               }
+               resolvedURI = resolveURI(baseLoc, publicId, systemId);
+               return resolvedURI;
+       }
+       
+       /**
+        * Returns true if this uriString is an http string
+        * 
+        * @param uriString
+        * @return true if uriString is http string, false otherwise
+        */
+       private boolean isHttp(String uriString) {
+               boolean isHttp = false;
+               if (uriString != null) {
+                       String tempString = uriString.toLowerCase();
+                       if (tempString.startsWith(HTTP_PROTOCOL)) {
+                               isHttp = true;
+                       }
+               }
+               return isHttp;
+       }
+       
+       /**
+        * Checks to see if the given attribute is openable. Attribute is openable
+        * if it is a namespace declaration attribute or if the attribute value is
+        * of type URI.
+        * 
+        * @param attr
+        *            cannot be null
+        * @param cmElement
+        *            CMElementDeclaration associated with the attribute (can be
+        *            null)
+        * @return true if this attribute is "openOn-able" false otherwise
+        */
+       private boolean isLinkableAttr(Attr attr, CMElementDeclaration cmElement) {
+               String attrName = attr.getName();
+               String prefix = DOMNamespaceHelper.getPrefix(attrName);
+               String unprefixedName = DOMNamespaceHelper.getUnprefixedName(attrName);
+               // determine if attribute is namespace declaration
+               if ((XMLNS.equals(prefix)) || (XMLNS.equals(unprefixedName))) {
+                       return true;
+               }
+               // determine if attribute contains schema location
+               if ((XSI_NAMESPACE_URI.equals(DOMNamespaceHelper.getNamespaceURI(attr))) && ((SCHEMA_LOCATION.equals(unprefixedName)) || (NO_NAMESPACE_SCHEMA_LOCATION.equals(unprefixedName)))) {
+                       return true;
+               }
+               // determine if attribute value is of type URI
+               if (cmElement != null) {
+                       CMAttributeDeclaration attrDecl = (CMAttributeDeclaration) cmElement.getAttributes().getNamedItem(attrName);
+                       if ((attrDecl != null) && (attrDecl.getAttrType() != null) && (CMDataType.URI.equals(attrDecl.getAttrType().getDataTypeName()))) {
+                               return true;
+                       }
+               }
+               return false;
+       }
+       
+       /**
+        * Checks whether the given uriString is really pointing to a file
+        * 
+        * @param uriString
+        * @return boolean
+        */
+       private boolean isValidURI(String uriString) {
+               boolean isValid = false;
+               if (isHttp(uriString)) {
+                       isValid = true;
+               } else {
+                       File file = getFileFromUriString(uriString);
+                       if (file != null) {
+                               isValid = file.isFile();
+                       }
+               }
+               return isValid;
+       }
+       
+       /**
+        * Resolves the given URI information
+        * 
+        * @param baseLocation
+        * @param publicId
+        * @param systemId
+        * @return String resolved uri.
+        */
+       private String resolveURI(String baseLocation, String publicId, String systemId) {
+               // dont resolve if there's nothing to resolve
+               if ((baseLocation == null) && (publicId == null) && (systemId == null)) {
+                       return null;
+               }
+               return URIResolverPlugin.createResolver().resolve(baseLocation, publicId, systemId);
+       }
+}
diff --git a/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/refactoring/BasicRefactorSearchRequestor.java b/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/refactoring/BasicRefactorSearchRequestor.java
new file mode 100644 (file)
index 0000000..e165f7d
--- /dev/null
@@ -0,0 +1,347 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.web.ui.internal.java.refactoring;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Reader;
+import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+import java.util.HashMap;
+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.IProgressMonitor;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.Document;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.ltk.core.refactoring.Change;
+import org.eclipse.ltk.core.refactoring.DocumentChange;
+import org.eclipse.ltk.core.refactoring.RefactoringStatus;
+import org.eclipse.osgi.util.NLS;
+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.ui.IEditorPart;
+import org.eclipse.ui.IEditorReference;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.actions.WorkspaceModifyOperation;
+import org.eclipse.ui.texteditor.ITextEditor;
+import org.eclipse.wst.jsdt.core.IJavaScriptElement;
+import org.eclipse.wst.jsdt.core.search.SearchDocument;
+import org.eclipse.wst.jsdt.core.search.SearchMatch;
+import org.eclipse.wst.jsdt.core.search.SearchRequestor;
+import org.eclipse.wst.jsdt.web.core.javascript.search.JSDTSearchDocumentDelegate;
+import org.eclipse.wst.jsdt.web.core.javascript.search.JsSearchSupport;
+import org.eclipse.wst.jsdt.web.ui.internal.JsUIMessages;
+import org.eclipse.wst.jsdt.web.ui.internal.Logger;
+import org.eclipse.wst.sse.core.internal.document.DocumentReader;
+import org.eclipse.wst.sse.core.internal.encoding.CodedStreamCreator;
+
+/**
+*
+
+* Provisional API: This class/interface is part of an interim API that is still under development and expected to
+* change significantly before reaching stability. It is being made available at this early stage to solicit feedback
+* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
+* (repeatedly) as the API evolves.
+*
+ * @author pavery
+ */
+public class BasicRefactorSearchRequestor extends SearchRequestor {
+       /**
+        * Change class that wraps a text edit on the jsp document
+        */
+       private class RenameChange extends DocumentChange {
+               private String fDescription = JsUIMessages.BasicRefactorSearchRequestor_0;
+               private TextEdit fEdit = null;
+               private IDocument fJSPDoc = null;
+               private IFile fJSPFile = null;
+               
+               public RenameChange(IFile jspFile, IDocument jspDoc, TextEdit edit, String description) {
+                       super(JsUIMessages.BasicRefactorSearchRequestor_6, jspDoc);
+                       this.fEdit = edit;
+                       this.fJSPFile = jspFile;
+                       this.fJSPDoc = jspDoc;
+                       this.fDescription = description;
+               }
+               
+               
+               public Object getModifiedElement() {
+                       return getElement();
+               }
+               
+               
+               public String getName() {
+                       return this.fDescription;
+               }
+               
+               
+               public IDocument getPreviewDocument(IProgressMonitor pm) throws CoreException {
+                       IDocument copyDoc = new Document(fJSPDoc.get());
+                       try {
+                               fEdit.apply(copyDoc);
+                       } catch (MalformedTreeException e) {
+                               // ignore
+                       } catch (BadLocationException e) {
+                               // ignore
+                       }
+                       return copyDoc;
+               }
+               
+               /**
+                * Checks if a document is open in an editor
+                * 
+                * @param jspDoc
+                * @return
+                */
+               private boolean isOpenInEditor(IDocument jspDoc) {
+                       IWorkbenchWindow[] windows = PlatformUI.getWorkbench().getWorkbenchWindows();
+                       IWorkbenchWindow w = null;
+                       for (int i = 0; i < windows.length; i++) {
+                               w = windows[i];
+                               IWorkbenchPage page = w.getActivePage();
+                               if (page != null) {
+                                       IEditorReference[] references = page.getEditorReferences();
+                                       IEditorPart editor = null;
+                                       Object o = null;
+                                       IDocument doc = null;
+                                       for (int j = 0; j < references.length; j++) {
+                                               editor = references[j].getEditor(true);
+                                               // https://w3.opensource.ibm.com/bugzilla/show_bug.cgi?id=3764
+                                               // use adapter to get ITextEditor (for things like
+                                               // page designer)
+                                               o = editor.getAdapter(ITextEditor.class);
+                                               if (o != null && o instanceof ITextEditor) {
+                                                       doc = ((ITextEditor) o).getDocumentProvider().getDocument(editor.getEditorInput());
+                                                       if (doc != null && doc.equals(jspDoc)) {
+                                                               return true;
+                                                       }
+                                               }
+                                       }
+                               }
+                       }
+                       return false;
+               }
+               
+               
+               public RefactoringStatus isValid(IProgressMonitor pm) throws CoreException {
+                       return new RefactoringStatus();
+               }
+               
+               
+               public Change perform(IProgressMonitor pm) throws CoreException {
+                       RenameChange undoChange = null;
+                       try {
+                               if (!isOpenInEditor(this.fJSPDoc)) {
+                                       // apply edit to JSP doc AND save model
+                                       undoChange = new RenameChange(this.fJSPFile, this.fJSPDoc, this.fEdit.apply(fJSPDoc), this.fDescription);
+                                       saveFile(this.fJSPFile, this.fJSPDoc);
+                               } else {
+                                       // just apply edit to JSP document
+                                       undoChange = new RenameChange(this.fJSPFile, this.fJSPDoc, this.fEdit.apply(fJSPDoc), this.fDescription);
+                               }
+                       } catch (MalformedTreeException e) {
+                               Logger.logException(e);
+                       } catch (BadLocationException e) {
+                               Logger.logException(e);
+                       }
+                       return undoChange;
+               }
+               
+               /**
+                * Performed in an operation since it modifies resources in the
+                * workspace
+                * 
+                * @param jspDoc
+                * @throws CoreException
+                */
+               private void saveFile(IFile jspFile, IDocument jspDoc) {
+                       SaveJspFileOp op = new SaveJspFileOp(jspFile, jspDoc);
+                       try {
+                               op.run(JsSearchSupport.getInstance().getProgressMonitor());
+                       } catch (InvocationTargetException e) {
+                               Logger.logException(e);
+                       } catch (InterruptedException e) {
+                               Logger.logException(e);
+                       }
+               }
+       }
+       // end inner class SaveJspFileOp
+       /**
+        * Workspace operation to perform save on model for updated documents.
+        * Should only be done on models not open in an editor.
+        */
+       private class SaveJspFileOp extends WorkspaceModifyOperation {
+               private IDocument fJSPDoc = null;
+               private IFile fJSPFile = null;
+               
+               public SaveJspFileOp(IFile jspFile, IDocument jspDoc) {
+                       this.fJSPDoc = jspDoc;
+                       this.fJSPFile = jspFile;
+               }
+               
+               
+               protected void execute(IProgressMonitor monitor) throws CoreException, InvocationTargetException, InterruptedException {
+                       // https://w3.opensource.ibm.com/bugzilla/show_bug.cgi?id=3765
+                       // save file w/ no intermediate model creation
+                       CodedStreamCreator codedStreamCreator = new CodedStreamCreator();
+                       Reader reader = new DocumentReader(this.fJSPDoc);
+                       codedStreamCreator.set(this.fJSPFile, reader);
+                       ByteArrayOutputStream codedByteStream = null;
+                       InputStream codedStream = null;
+                       try {
+                               codedByteStream = codedStreamCreator.getCodedByteArrayOutputStream();
+                               codedStream = new ByteArrayInputStream(codedByteStream.toByteArray());
+                               if (this.fJSPFile.exists()) {
+                                       this.fJSPFile.setContents(codedStream, true, true, null);
+                               } else {
+                                       this.fJSPFile.create(codedStream, false, null);
+                               }
+                       } catch (CoreException e) {
+                               Logger.logException(e);
+                       } catch (IOException e) {
+                               Logger.logException(e);
+                       } finally {
+                               try {
+                                       if (codedByteStream != null) {
+                                               codedByteStream.close();
+                                       }
+                                       if (codedStream != null) {
+                                               codedStream.close();
+                                       }
+                               } catch (IOException e) {
+                                       // unlikely
+                               }
+                       }
+               }
+       }
+       // end inner class RenameChange
+       /** The type being renamed (the old type) */
+       IJavaScriptElement fElement = null;
+       /** The new name of the type being renamed */
+       private String fNewName = ""; //$NON-NLS-1$
+       /** maps a JSPSearchDocument path -> MultiTextEdit for the java file */
+       private HashMap fSearchDocPath2JavaEditMap = null;
+       
+       public BasicRefactorSearchRequestor(IJavaScriptElement element, String newName) {
+               this.fNewName = newName;
+               this.fElement = element;
+               this.fSearchDocPath2JavaEditMap = new HashMap();
+       }
+       
+       /**
+        * @see org.eclipse.wst.jsdt.core.search.SearchRequestor#acceptSearchMatch(org.eclipse.wst.jsdt.core.search.SearchMatch)
+        */
+       
+       public void acceptSearchMatch(SearchMatch javaMatch) throws CoreException {
+               String matchDocumentPath = javaMatch.getResource().getFullPath().toString();
+               SearchDocument searchDoc = JsSearchSupport.getInstance().getSearchDocument(matchDocumentPath);
+               if (searchDoc != null && searchDoc instanceof JSDTSearchDocumentDelegate) {
+                       String renameText = getRenameText((JSDTSearchDocumentDelegate) searchDoc, javaMatch);
+                       // add it for the correct document
+                       addJavaEdit(searchDoc.getPath(), new ReplaceEdit(javaMatch.getOffset(), javaMatch.getLength(), renameText));
+               }
+       }
+       
+       /**
+        * Adds to the multi edit for a give java document.
+        * 
+        * @param javaDocument
+        * @param javaEdit
+        */
+       private void addJavaEdit(String searchDocPath, ReplaceEdit javaEdit) {
+               Object o = this.fSearchDocPath2JavaEditMap.get(searchDocPath);
+               if (o != null) {
+                       MultiTextEdit multi = (MultiTextEdit) o;
+                       multi.addChild(javaEdit);
+               } else {
+                       // use a multi edit so doc position offsets get updated
+                       // automatically
+                       // when adding multiple child edits
+                       MultiTextEdit multi = new MultiTextEdit();
+                       multi.addChild(javaEdit);
+                       this.fSearchDocPath2JavaEditMap.put(searchDocPath, multi);
+               }
+       }
+       
+       private Change createChange(JSDTSearchDocumentDelegate searchDoc, TextEdit edit) {
+               IDocument doc = searchDoc.getJspTranslation().getHtmlDocument();
+               String file = searchDoc.getFile().getName();
+               String description = getDescription();
+               try {
+                       // document lines are 0 based
+                       String lineNumber = Integer.toString(doc.getLineOfOffset(edit.getOffset()) + 1);
+                       description += " " + NLS.bind(JsUIMessages.BasicRefactorSearchRequestor_1, new String[] { file, lineNumber }); //$NON-NLS-1$
+               } catch (BadLocationException e) {
+                       Logger.logException(e);
+               }
+               return new RenameChange(searchDoc.getFile(), doc, edit, description);
+       }
+       
+       /**
+        * 
+        * @return all JSP changes for the search matches for the given Type
+        */
+       public Change[] getChanges() {
+               JsSearchSupport support = JsSearchSupport.getInstance();
+               List changes = new ArrayList();
+               Iterator keys = fSearchDocPath2JavaEditMap.keySet().iterator();
+               String searchDocPath = null;
+               SearchDocument delegate = null;
+               while (keys.hasNext()) {
+                       // create on the fly
+                       searchDocPath = (String) keys.next();
+                       MultiTextEdit javaEdit = (MultiTextEdit) fSearchDocPath2JavaEditMap.get(searchDocPath);
+                       delegate = support.getSearchDocument(searchDocPath);
+                       if (delegate != null && delegate instanceof JSDTSearchDocumentDelegate) {
+                               JSDTSearchDocumentDelegate javaDelegate = (JSDTSearchDocumentDelegate) delegate;
+                               changes.add(createChange(javaDelegate, javaEdit));
+                       }
+               }
+               return (Change[]) changes.toArray(new Change[changes.size()]);
+       }
+       
+       /**
+        * Subclasses should override to better describe the change.
+        * 
+        * @return
+        */
+       protected String getDescription() {
+               return ""; //$NON-NLS-1$
+       }
+       
+       public IJavaScriptElement getElement() {
+               return this.fElement;
+       }
+       
+       /**
+        * @return the new name for the Type
+        */
+       public String getNewName() {
+               return this.fNewName;
+       }
+       
+       /**
+        * @param searchDoc
+        * @return
+        */
+       protected String getRenameText(JSDTSearchDocumentDelegate searchDoc, SearchMatch javaMatch) {
+               return getNewName();
+       }
+}
diff --git a/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/refactoring/JSPJavaSelectionProvider.java b/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/refactoring/JSPJavaSelectionProvider.java
new file mode 100644 (file)
index 0000000..d671fcf
--- /dev/null
@@ -0,0 +1,64 @@
+/*******************************************************************************
+ * Copyright (c) 2001, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.web.ui.internal.java.refactoring;
+
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.ITextSelection;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.ui.texteditor.ITextEditor;
+import org.eclipse.wst.jsdt.core.IJavaScriptElement;
+import org.eclipse.wst.jsdt.web.core.javascript.IJsTranslation;
+import org.eclipse.wst.jsdt.web.core.javascript.JsTranslationAdapter;
+import org.eclipse.wst.sse.core.StructuredModelManager;
+import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
+/**
+*
+
+* Provisional API: This class/interface is part of an interim API that is still under development and expected to
+* change significantly before reaching stability. It is being made available at this early stage to solicit feedback
+* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
+* (repeatedly) as the API evolves.
+*/
+class JSPJavaSelectionProvider {
+       static IJavaScriptElement[] getSelection(ITextEditor textEditor) {
+               IJavaScriptElement[] elements = null;
+               IDocument document = textEditor.getDocumentProvider().getDocument(textEditor.getEditorInput());
+               ISelection selection = textEditor.getSelectionProvider().getSelection();
+               if (selection instanceof ITextSelection) {
+                       ITextSelection textSelection = (ITextSelection) selection;
+                       // get the JSP translation object for this editor's document
+                       IStructuredModel model = null;
+                       try {
+                               model = StructuredModelManager.getModelManager().getExistingModelForRead(document);
+                               if (model instanceof IDOMModel) {
+                                       IDOMModel xmlModel = (IDOMModel) model;
+                                       IDOMDocument xmlDoc = xmlModel.getDocument();
+                                       JsTranslationAdapter adapter = (JsTranslationAdapter) xmlDoc.getAdapterFor(IJsTranslation.class);
+                                       if (adapter != null) {
+                                               IJsTranslation translation = adapter.getJsTranslation(true);
+                                               elements = translation.getElementsFromJsRange(textSelection.getOffset(), textSelection.getOffset() + textSelection.getLength());
+                                       }
+                               }
+                       } finally {
+                               if (model != null) {
+                                       model.releaseFromRead();
+                               }
+                       }
+               }
+               if (elements == null) {
+                       elements = new IJavaScriptElement[0];
+               }
+               return elements;
+       }
+}
diff --git a/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/refactoring/JSPMethodRenameChange.java b/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/refactoring/JSPMethodRenameChange.java
new file mode 100644 (file)
index 0000000..447afce
--- /dev/null
@@ -0,0 +1,74 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.web.ui.internal.java.refactoring;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.ltk.core.refactoring.Change;
+import org.eclipse.ltk.core.refactoring.RefactoringStatus;
+import org.eclipse.wst.jsdt.core.IFunction;
+import org.eclipse.wst.jsdt.web.core.javascript.search.JsSearchScope;
+import org.eclipse.wst.jsdt.web.core.javascript.search.JsSearchSupport;
+import org.eclipse.wst.jsdt.web.ui.internal.JsUIMessages;
+/**
+*
+
+* Provisional API: This class/interface is part of an interim API that is still under development and expected to
+* change significantly before reaching stability. It is being made available at this early stage to solicit feedback
+* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
+* (repeatedly) as the API evolves.
+*
+ * @author pavery
+ */
+public class JSPMethodRenameChange extends Change {
+       public static Change[] createChangesFor(IFunction method, String newName) {
+               JsSearchSupport support = JsSearchSupport.getInstance();
+               // should be handled by JSPIndexManager
+               // https://w3.opensource.ibm.com/bugzilla/show_bug.cgi?id=3036
+               // support.indexWorkspaceAndWait();
+               BasicRefactorSearchRequestor requestor = new JSPMethodRenameRequestor(method, newName);
+               support.searchRunnable(method, new JsSearchScope(), requestor);
+               return requestor.getChanges();
+       }
+       
+       
+       public Object getModifiedElement() {
+               // pa_TODO Auto-generated method stub
+               return null;
+       }
+       
+       
+       public String getName() {
+               return JsUIMessages.JSP_changes;
+       }
+       
+       
+       public void initializeValidationData(IProgressMonitor pm) {
+       // pa_TODO implement
+       // must be implemented to decide correct value of isValid
+       }
+       
+       
+       public RefactoringStatus isValid(IProgressMonitor pm) throws CoreException {
+               // pa_TODO implement
+               // This method must ensure that the change object is still valid.
+               // This is in particular interesting when performing an undo change
+               // since the workspace could have changed since the undo change has
+               // been created.
+               return new RefactoringStatus();
+       }
+       
+       
+       public Change perform(IProgressMonitor pm) throws CoreException {
+               // pa_TODO return the "undo" change here
+               return null;
+       }
+}
diff --git a/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/refactoring/JSPMethodRenameParticipant.java b/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/refactoring/JSPMethodRenameParticipant.java
new file mode 100644 (file)
index 0000000..27f7ddb
--- /dev/null
@@ -0,0 +1,104 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.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 May 6, 2004
+ *
+ * TODO To change the template for this generated file go to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+package org.eclipse.wst.jsdt.web.ui.internal.java.refactoring;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.ltk.core.refactoring.Change;
+import org.eclipse.ltk.core.refactoring.CompositeChange;
+import org.eclipse.ltk.core.refactoring.RefactoringStatus;
+import org.eclipse.ltk.core.refactoring.participants.CheckConditionsContext;
+import org.eclipse.ltk.core.refactoring.participants.RenameParticipant;
+import org.eclipse.wst.jsdt.core.IFunction;
+import org.eclipse.wst.jsdt.core.JavaScriptModelException;
+import org.eclipse.wst.jsdt.web.ui.internal.JsUIMessages;
+import org.eclipse.wst.jsdt.web.ui.internal.Logger;
+import org.eclipse.wst.jsdt.web.ui.views.contentoutline.IJavaWebNode;
+
+/**
+*
+
+* Provisional API: This class/interface is part of an interim API that is still under development and expected to
+* change significantly before reaching stability. It is being made available at this early stage to solicit feedback
+* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
+* (repeatedly) as the API evolves.
+*
+ * @author pavery
+ */
+public class JSPMethodRenameParticipant extends RenameParticipant {
+       private IFunction fMethod = null;
+       
+       /*
+        * (non-Javadoc)
+        * 
+        * @see org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant#checkConditions(org.eclipse.core.runtime.IProgressMonitor,
+        *      org.eclipse.ltk.core.refactoring.participants.CheckConditionsContext)
+        */
+       
+       public RefactoringStatus checkConditions(IProgressMonitor pm, CheckConditionsContext context) {
+               // TODO Auto-generated method stub
+               return null;
+       }
+       
+       /*
+        * (non-Javadoc)
+        * 
+        * @see org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant#createChange(org.eclipse.core.runtime.IProgressMonitor)
+        */
+       
+       public Change createChange(IProgressMonitor pm) throws CoreException {
+               Change[] changes = JSPMethodRenameChange.createChangesFor(this.fMethod, getArguments().getNewName());
+               CompositeChange multiChange = null;
+               if (changes.length > 0) {
+                       multiChange = new CompositeChange(JsUIMessages.JSP_changes, changes);
+               }
+               return multiChange;
+       }
+       
+       /**
+        * @see org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant#getName()
+        */
+       
+       public String getName() {
+               String name = ""; //$NON-NLS-1$
+               if (this.fMethod != null) {
+                       try {
+                               name = this.fMethod.getSource();
+                       } catch (JavaScriptModelException e) {
+                               Logger.logException(e);
+                       }
+               }
+               return name;
+       }
+       
+       /**
+        * @see org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant#initialize(java.lang.Object)
+        */
+       
+       protected boolean initialize(Object element) {
+               if (element instanceof IFunction) {
+                       this.fMethod = (IFunction) element;
+                       return true;
+               }else if (element instanceof IJavaWebNode) {
+                       if(((IJavaWebNode)element).getJavaElement() instanceof IFunction) {
+                               this.fMethod = (IFunction) ((IJavaWebNode)element).getJavaElement();
+                               return true;
+                       }
+               }
+               return false;
+       }
+}
diff --git a/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/refactoring/JSPMethodRenameRequestor.java b/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/refactoring/JSPMethodRenameRequestor.java
new file mode 100644 (file)
index 0000000..11e6833
--- /dev/null
@@ -0,0 +1,54 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.web.ui.internal.java.refactoring;
+
+import java.text.MessageFormat;
+
+import org.eclipse.wst.jsdt.core.IJavaScriptElement;
+import org.eclipse.wst.jsdt.core.search.SearchMatch;
+import org.eclipse.wst.jsdt.web.core.javascript.search.JSDTSearchDocumentDelegate;
+import org.eclipse.wst.jsdt.web.ui.internal.JsUIMessages;
+/**
+*
+
+* Provisional API: This class/interface is part of an interim API that is still under development and expected to
+* change significantly before reaching stability. It is being made available at this early stage to solicit feedback
+* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
+* (repeatedly) as the API evolves.
+*
+ * @author pavery
+ */
+public class JSPMethodRenameRequestor extends BasicRefactorSearchRequestor {
+       public JSPMethodRenameRequestor(IJavaScriptElement element, String newName) {
+               super(element, newName);
+       }
+       
+       /*
+        * (non-Javadoc)
+        * 
+        * @see org.eclipse.wst.jsdt.web.ui.internal.java.refactoring.BasicRefactorSearchRequestor#getDescription()
+        */
+       
+       protected String getDescription() {
+               String methodName = getElement().getElementName();
+               String newName = getNewName();
+               String description = MessageFormat.format(JsUIMessages.BasicRefactorSearchRequestor_3, new String[] { methodName, newName });
+               return description;
+       }
+       
+       
+       protected String getRenameText(JSDTSearchDocumentDelegate searchDoc, SearchMatch javaMatch) {
+               String javaText = searchDoc.getJspTranslation().getJsText();
+               String methodText = javaText.substring(javaMatch.getOffset(), javaMatch.getOffset() + javaMatch.getLength());
+               String methodSuffix = methodText.substring(methodText.indexOf("(")); //$NON-NLS-1$
+               return getNewName() + methodSuffix;
+       }
+}
diff --git a/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/refactoring/JSPMoveElementActionDelegate.java b/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/refactoring/JSPMoveElementActionDelegate.java
new file mode 100644 (file)
index 0000000..0679a10
--- /dev/null
@@ -0,0 +1,121 @@
+/*******************************************************************************
+ * 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.web.ui.internal.java.refactoring;
+
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.ui.IActionDelegate2;
+import org.eclipse.ui.IEditorActionDelegate;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IViewActionDelegate;
+import org.eclipse.ui.IViewPart;
+import org.eclipse.wst.jsdt.web.ui.internal.JsUIMessages;
+import org.eclipse.wst.sse.ui.internal.util.PlatformStatusLineUtil;
+
+/**
+*
+
+* Provisional API: This class/interface is part of an interim API that is still under development and expected to
+* change significantly before reaching stability. It is being made available at this early stage to solicit feedback
+* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
+* (repeatedly) as the API evolves.
+*
+ * An action delegate that launches JDT move element wizard
+ * 
+ * Still relies heavily on internal API will change post 3.0 with public move
+ * support https://bugs.eclipse.org/bugs/show_bug.cgi?id=61817
+ */
+public class JSPMoveElementActionDelegate implements IEditorActionDelegate, IActionDelegate2, IViewActionDelegate {
+       // private IEditorPart fEditor;
+       public void dispose() {
+       // nulling out just in case
+       // fEditor = null;
+       }
+       
+       public void init(IAction action) {
+               if (action != null) {
+                       action.setText(JsUIMessages.MoveElement_label);
+                       action.setToolTipText(JsUIMessages.MoveElement_label);
+               }
+       }
+       
+       public void init(IViewPart view) {
+       // do nothing
+       }
+       
+       public void run(IAction action) {
+       // no-op until we know how we're supposed to use this
+       // eclipse 3.2M5
+       // public move support:
+       // https://bugs.eclipse.org/bugs/show_bug.cgi?id=61817
+       // IJavaScriptElement[] elements = getSelectedElements();
+       // if (elements.length > 0) {
+       //
+       // // need to check if it's movable
+       // try {
+       // JavaMoveProcessor processor =
+       // JavaMoveProcessor.create(getResources(elements), elements);
+       //                              
+       // Shell parent =
+       // PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
+       // MoveRefactoring refactoring = new MoveRefactoring(processor);
+       //
+       // RefactoringWizard wizard = createWizard(refactoring);
+       //
+       // /*
+       // * 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.
+       // */
+       //
+       // processor.setCreateTargetQueries(new CreateTargetQueries(wizard));
+       // processor.setReorgQueries(new ReorgQueries(wizard));
+       // // String openRefactoringWizMsg =
+       // //
+       // RefactoringMessages.getString("OpenRefactoringWizardAction.refactoring");
+       // // //$NON-NLS-1$
+       // String openRefactoringWizMsg = JSPUIMessages.MoveElementWizard; //
+       // "Move
+       // // the
+       // // selected
+       // // elements";
+       // // //$NON-NLS-1$
+       // new RefactoringStarter().activate(refactoring, wizard, parent,
+       // openRefactoringWizMsg, true);
+       //
+       // PlatformStatusLineUtil.clearStatusLine();
+       //
+       // }
+       // catch (JavaScriptModelException e) {
+       // Logger.logException(e);
+       // }
+       // }
+       // else {
+       // PlatformStatusLineUtil.displayErrorMessage(JSPUIMessages.JSPMoveElementAction_0);
+       // //$NON-NLS-1$
+       // }
+       }
+       
+       public void runWithEvent(IAction action, Event event) {
+               run(action);
+       }
+       
+       public void selectionChanged(IAction action, ISelection selection) {
+               PlatformStatusLineUtil.clearStatusLine();
+       }
+       
+       public void setActiveEditor(IAction action, IEditorPart targetEditor) {
+       // fEditor = targetEditor;
+       }
+}
diff --git a/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/refactoring/JSPPackageRenameChange.java b/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/refactoring/JSPPackageRenameChange.java
new file mode 100644 (file)
index 0000000..8a8a378
--- /dev/null
@@ -0,0 +1,74 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.web.ui.internal.java.refactoring;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.ltk.core.refactoring.Change;
+import org.eclipse.ltk.core.refactoring.RefactoringStatus;
+import org.eclipse.wst.jsdt.core.IPackageFragment;
+import org.eclipse.wst.jsdt.web.core.javascript.search.JsSearchScope;
+import org.eclipse.wst.jsdt.web.core.javascript.search.JsSearchSupport;
+import org.eclipse.wst.jsdt.web.ui.internal.JsUIMessages;
+/**
+*
+
+* Provisional API: This class/interface is part of an interim API that is still under development and expected to
+* change significantly before reaching stability. It is being made available at this early stage to solicit feedback
+* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
+* (repeatedly) as the API evolves.
+*
+ * @author pavery
+ */
+public class JSPPackageRenameChange extends Change {
+       public static Change[] createChangesFor(IPackageFragment pkg, String newName) {
+               JsSearchSupport support = JsSearchSupport.getInstance();
+               // should be handled by JSPIndexManager
+               // https://w3.opensource.ibm.com/bugzilla/show_bug.cgi?id=3036
+               // support.indexWorkspaceAndWait();
+               BasicRefactorSearchRequestor requestor = new JSPPackageRenameRequestor(pkg, newName);
+               support.searchRunnable(pkg, new JsSearchScope(), requestor);
+               return requestor.getChanges();
+       }
+       
+       
+       public Object getModifiedElement() {
+               // return this.pkg;
+               return null;
+       }
+       
+       
+       public String getName() {
+               return JsUIMessages.JSP_changes;
+       }
+       
+       
+       public void initializeValidationData(IProgressMonitor pm) {
+       // pa_TODO implement
+       // must be implemented to decide correct value of isValid
+       }
+       
+       
+       public RefactoringStatus isValid(IProgressMonitor pm) throws CoreException {
+               // pa_TODO implement
+               // This method must ensure that the change object is still valid.
+               // This is in particular interesting when performing an undo change
+               // since the workspace could have changed since the undo change has
+               // been created.
+               return new RefactoringStatus();
+       }
+       
+       
+       public Change perform(IProgressMonitor pm) throws CoreException {
+               // TODO return the "undo" change here
+               return null;
+       }
+}
diff --git a/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/refactoring/JSPPackageRenameParticipant.java b/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/refactoring/JSPPackageRenameParticipant.java
new file mode 100644 (file)
index 0000000..161f73a
--- /dev/null
@@ -0,0 +1,84 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.web.ui.internal.java.refactoring;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.ltk.core.refactoring.Change;
+import org.eclipse.ltk.core.refactoring.CompositeChange;
+import org.eclipse.ltk.core.refactoring.RefactoringStatus;
+import org.eclipse.ltk.core.refactoring.participants.CheckConditionsContext;
+import org.eclipse.ltk.core.refactoring.participants.RenameParticipant;
+import org.eclipse.wst.jsdt.core.IPackageFragment;
+import org.eclipse.wst.jsdt.web.ui.internal.JsUIMessages;
+
+/**
+*
+
+* Provisional API: This class/interface is part of an interim API that is still under development and expected to
+* change significantly before reaching stability. It is being made available at this early stage to solicit feedback
+* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
+* (repeatedly) as the API evolves.
+*
+ * Remember to change the plugin.xml file if the name of this class changes.
+ * 
+ * @author pavery
+ */
+public class JSPPackageRenameParticipant extends RenameParticipant {
+       private IPackageFragment fPkg = null;
+       
+       /**
+        * @see org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant#checkConditions(org.eclipse.core.runtime.IProgressMonitor,
+        *      org.eclipse.ltk.core.refactoring.participants.CheckConditionsContext)
+        */
+       
+       public RefactoringStatus checkConditions(IProgressMonitor pm, CheckConditionsContext context) {
+               // TODO Auto-generated method stub
+               return null;
+       }
+       
+       /**
+        * @see org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant#createChange(org.eclipse.core.runtime.IProgressMonitor)
+        */
+       
+       public Change createChange(IProgressMonitor pm) throws CoreException {
+               Change[] changes = JSPPackageRenameChange.createChangesFor(this.fPkg, getArguments().getNewName());
+               CompositeChange multiChange = null;
+               if (changes.length > 0) {
+                       multiChange = new CompositeChange(JsUIMessages.JSP_changes, changes);
+               }
+               return multiChange;
+       }
+       
+       /**
+        * @see org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant#getName()
+        */
+       
+       public String getName() {
+               String name = ""; //$NON-NLS-1$
+               if (this.fPkg != null) {
+                       name = this.fPkg.getElementName();
+               }
+               return name;
+       }
+       
+       /**
+        * @see org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant#initialize(java.lang.Object)
+        */
+       
+       protected boolean initialize(Object element) {
+               if (element instanceof IPackageFragment) {
+                       this.fPkg = (IPackageFragment) element;
+                       return true;
+               }
+               return false;
+       }
+}
diff --git a/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/refactoring/JSPPackageRenameRequestor.java b/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/refactoring/JSPPackageRenameRequestor.java
new file mode 100644 (file)
index 0000000..6fa4592
--- /dev/null
@@ -0,0 +1,47 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.web.ui.internal.java.refactoring;
+
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.wst.jsdt.core.IJavaScriptElement;
+import org.eclipse.wst.jsdt.web.ui.internal.JsUIMessages;
+/**
+*
+
+* Provisional API: This class/interface is part of an interim API that is still under development and expected to
+* change significantly before reaching stability. It is being made available at this early stage to solicit feedback
+* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
+* (repeatedly) as the API evolves.
+*
+ * @author pavery
+ */
+public class JSPPackageRenameRequestor extends BasicRefactorSearchRequestor {
+       /**
+        * Element is the old package. newName is the new package name.
+        * 
+        * @param element
+        * @param newName
+        */
+       public JSPPackageRenameRequestor(IJavaScriptElement element, String newName) {
+               super(element, newName);
+       }
+       
+       /*
+        * @see org.eclipse.wst.jsdt.web.ui.internal.java.refactoring.BasicRefactorSearchRequestor#getDescription()
+        */
+       
+       protected String getDescription() {
+               String packageName = getElement().getElementName();
+               String newName = getNewName();
+               String description = NLS.bind(JsUIMessages.BasicRefactorSearchRequestor_5, (new String[] { packageName, newName }));
+               return description;
+       }
+}
diff --git a/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/refactoring/JSPRenameElementActionDelegate.java b/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/refactoring/JSPRenameElementActionDelegate.java
new file mode 100644 (file)
index 0000000..7fd2fb5
--- /dev/null
@@ -0,0 +1,112 @@
+/*******************************************************************************
+ * 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.web.ui.internal.java.refactoring;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.ui.IActionDelegate2;
+import org.eclipse.ui.IEditorActionDelegate;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IViewActionDelegate;
+import org.eclipse.ui.IViewPart;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.texteditor.ITextEditor;
+import org.eclipse.wst.jsdt.core.IJavaScriptElement;
+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.ui.refactoring.RenameSupport;
+import org.eclipse.wst.jsdt.web.ui.internal.JsUIMessages;
+import org.eclipse.wst.jsdt.web.ui.internal.Logger;
+import org.eclipse.wst.sse.ui.internal.util.PlatformStatusLineUtil;
+
+/**
+*
+
+* Provisional API: This class/interface is part of an interim API that is still under development and expected to
+* change significantly before reaching stability. It is being made available at this early stage to solicit feedback
+* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
+* (repeatedly) as the API evolves.
+*/
+public class JSPRenameElementActionDelegate implements IEditorActionDelegate, IActionDelegate2, IViewActionDelegate {
+       private IEditorPart fEditor;
+       
+       public void dispose() {
+               // nulling out just in case
+               fEditor = null;
+       }
+       
+       private IJavaScriptElement getSelectedElement() {
+               IJavaScriptElement element = null;
+               if (fEditor instanceof ITextEditor) {
+                       IJavaScriptElement[] elements = JSPJavaSelectionProvider.getSelection((ITextEditor) fEditor);
+                       if (elements.length == 1) {
+                               element = elements[0];
+                       }
+               }
+               return element;
+       }
+       
+       public void init(IAction action) {
+               if (action != null) {
+                       action.setText(JsUIMessages.RenameElement_label);
+                       action.setToolTipText(JsUIMessages.RenameElement_label);
+               }
+       }
+       
+       public void init(IViewPart view) {
+       // do nothing
+       }
+       
+       public void run(IAction action) {
+               IJavaScriptElement element = getSelectedElement();
+               if (element != null) {
+                       RenameSupport renameSupport = null;
+                       try {
+                               switch (element.getElementType()) {
+                                       case IJavaScriptElement.TYPE:
+                                               renameSupport = RenameSupport.create((IType) element, element.getElementName(), RenameSupport.UPDATE_REFERENCES);
+                                       break;
+                                       case IJavaScriptElement.METHOD:
+                                               renameSupport = RenameSupport.create((IFunction) element, element.getElementName(), RenameSupport.UPDATE_REFERENCES);
+                                       break;
+                                       case IJavaScriptElement.PACKAGE_FRAGMENT:
+                                               renameSupport = RenameSupport.create((IPackageFragment) element, element.getElementName(), RenameSupport.UPDATE_REFERENCES);
+                                       break;
+                               }
+                               if (renameSupport != null) {
+                                       renameSupport.openDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell());
+                                       PlatformStatusLineUtil.clearStatusLine();
+                               }
+                       } catch (CoreException e) {
+                               Logger.logException(e);
+                       }
+               } else {
+                       PlatformStatusLineUtil.displayErrorMessage(JsUIMessages.JSPRenameElementAction_0);
+                       PlatformStatusLineUtil.addOneTimeClearListener();
+               }
+       }
+       
+       public void runWithEvent(IAction action, Event event) {
+               run(action);
+       }
+       
+       public void selectionChanged(IAction action, ISelection selection) {
+               PlatformStatusLineUtil.clearStatusLine();
+       }
+       
+       public void setActiveEditor(IAction action, IEditorPart targetEditor) {
+               fEditor = targetEditor;
+       }
+}
diff --git a/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/refactoring/JSPTypeMoveChange.java b/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/refactoring/JSPTypeMoveChange.java
new file mode 100644 (file)
index 0000000..6eaa39b
--- /dev/null
@@ -0,0 +1,72 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.web.ui.internal.java.refactoring;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.ltk.core.refactoring.Change;
+import org.eclipse.ltk.core.refactoring.RefactoringStatus;
+import org.eclipse.wst.jsdt.core.IType;
+import org.eclipse.wst.jsdt.web.core.javascript.search.JsSearchScope;
+import org.eclipse.wst.jsdt.web.core.javascript.search.JsSearchSupport;
+import org.eclipse.wst.jsdt.web.ui.internal.JsUIMessages;
+
+/**
+*
+
+* Provisional API: This class/interface is part of an interim API that is still under development and expected to
+* change significantly before reaching stability. It is being made available at this early stage to solicit feedback
+* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
+* (repeatedly) as the API evolves.
+*/
+public class JSPTypeMoveChange extends Change {
+       public static Change[] createChangesFor(IType type, String newName) {
+               JsSearchSupport support = JsSearchSupport.getInstance();
+               // should be handled by JSPIndexManager
+               // https://w3.opensource.ibm.com/bugzilla/show_bug.cgi?id=3036
+               // support.indexWorkspaceAndWait();
+               JSPTypeMoveRequestor requestor = new JSPTypeMoveRequestor(type, newName);
+               support.searchRunnable(type, new JsSearchScope(), requestor);
+               return requestor.getChanges();
+       }
+       
+       
+       public Object getModifiedElement() {
+               return null;
+       }
+       
+       
+       public String getName() {
+               return JsUIMessages.JSP_changes;
+       }
+       
+       
+       public void initializeValidationData(IProgressMonitor pm) {
+       // pa_TODO implement
+       // must be implemented to decide correct value of isValid
+       }
+       
+       
+       public RefactoringStatus isValid(IProgressMonitor pm) throws CoreException {
+               // pa_TODO implement
+               // This method must ensure that the change object is still valid.
+               // This is in particular interesting when performing an undo change
+               // since the workspace could have changed since the undo change has
+               // been created.
+               return new RefactoringStatus();
+       }
+       
+       
+       public Change perform(IProgressMonitor pm) throws CoreException {
+               // TODO return the "undo" change here
+               return null;
+       }
+}
diff --git a/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/refactoring/JSPTypeMoveParticipant.java b/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/refactoring/JSPTypeMoveParticipant.java
new file mode 100644 (file)
index 0000000..8088e46
--- /dev/null
@@ -0,0 +1,94 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.web.ui.internal.java.refactoring;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.ltk.core.refactoring.Change;
+import org.eclipse.ltk.core.refactoring.CompositeChange;
+import org.eclipse.ltk.core.refactoring.RefactoringStatus;
+import org.eclipse.ltk.core.refactoring.participants.CheckConditionsContext;
+import org.eclipse.ltk.core.refactoring.participants.MoveParticipant;
+import org.eclipse.wst.jsdt.core.IPackageFragment;
+import org.eclipse.wst.jsdt.core.IType;
+import org.eclipse.wst.jsdt.web.ui.internal.JsUIMessages;
+/**
+*
+
+* Provisional API: This class/interface is part of an interim API that is still under development and expected to
+* change significantly before reaching stability. It is being made available at this early stage to solicit feedback
+* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
+* (repeatedly) as the API evolves.
+*/
+public class JSPTypeMoveParticipant extends MoveParticipant {
+       IType fType = null;
+       
+       /*
+        * (non-Javadoc)
+        * 
+        * @see org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant#checkConditions(org.eclipse.core.runtime.IProgressMonitor,
+        *      org.eclipse.ltk.core.refactoring.participants.CheckConditionsContext)
+        */
+       
+       public RefactoringStatus checkConditions(IProgressMonitor pm, CheckConditionsContext context) {
+               // TODO Auto-generated method stub
+               return null;
+       }
+       
+       /*
+        * (non-Javadoc)
+        * 
+        * @see org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant#createChange(org.eclipse.core.runtime.IProgressMonitor)
+        */
+       
+       public Change createChange(IProgressMonitor pm) throws CoreException {
+               if (pm != null && pm.isCanceled()) {
+                       return null;
+               }
+               CompositeChange multiChange = null;
+               Object dest = getArguments().getDestination();
+               if (dest instanceof IPackageFragment) {
+                       Change[] changes = JSPTypeMoveChange.createChangesFor(fType, ((IPackageFragment) dest).getElementName());
+                       if (changes.length > 0) {
+                               multiChange = new CompositeChange(JsUIMessages.JSP_changes, changes);
+                       }
+               }
+               return multiChange;
+       }
+       
+       /*
+        * (non-Javadoc)
+        * 
+        * @see org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant#getName()
+        */
+       
+       public String getName() {
+               String name = ""; //$NON-NLS-1$
+               if (this.fType != null) {
+                       name = this.fType.getElementName();
+               }
+               return name;
+       }
+       
+       /*
+        * (non-Javadoc)
+        * 
+        * @see org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant#initialize(java.lang.Object)
+        */
+       
+       protected boolean initialize(Object element) {
+               if (element instanceof IType) {
+                       this.fType = (IType) element;
+                       return true;
+               }
+               return false;
+       }
+}
diff --git a/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/refactoring/JSPTypeMoveRequestor.java b/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/refactoring/JSPTypeMoveRequestor.java
new file mode 100644 (file)
index 0000000..e760809
--- /dev/null
@@ -0,0 +1,70 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.web.ui.internal.java.refactoring;
+
+import java.text.MessageFormat;
+
+import org.eclipse.wst.jsdt.core.IJavaScriptElement;
+import org.eclipse.wst.jsdt.core.search.SearchMatch;
+//import org.eclipse.wst.jsdt.web.core.internal.java.JsTranslation;
+import org.eclipse.wst.jsdt.web.core.javascript.search.JSDTSearchDocumentDelegate;
+import org.eclipse.wst.jsdt.web.ui.internal.JsUIMessages;
+
+/**
+*
+
+* Provisional API: This class/interface is part of an interim API that is still under development and expected to
+* change significantly before reaching stability. It is being made available at this early stage to solicit feedback
+* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
+* (repeatedly) as the API evolves.
+*
+ * @author pavery
+ */
+public class JSPTypeMoveRequestor extends BasicRefactorSearchRequestor {
+       /**
+        * @param element
+        * @param newName
+        */
+       public JSPTypeMoveRequestor(IJavaScriptElement element, String newPackage) {
+               super(element, newPackage);
+       }
+       
+       /*
+        * (non-Javadoc)
+        * 
+        * @see org.eclipse.wst.jsdt.web.ui.internal.java.refactoring.BasicRefactorSearchRequestor#getDescription()
+        */
+       
+       protected String getDescription() {
+               String typeName = getElement().getElementName();
+               String newName = getNewName();
+               String description = MessageFormat.format(JsUIMessages.BasicRefactorSearchRequestor_2, new String[] { typeName, newName });
+               return description;
+       }
+       
+       
+       protected String getRenameText(JSDTSearchDocumentDelegate searchDoc, SearchMatch javaMatch) {
+               String renameText = getElement().getElementName();
+       //      JsTranslation trans = searchDoc.getJspTranslation();
+               //String matchText = trans.getJsText().substring(javaMatch.getOffset(), javaMatch.getOffset() + javaMatch.getLength());
+               // if it's an import or jsp:useBean, we need to add the package name as
+               // well
+// if (trans.isImport(javaMatch.getOffset())
+//                     
+// || isFullyQualified(matchText)) {
+// if (!getNewName().equals("")) {
+// // getNewName() is the pkg name
+// renameText = getNewName() + "." + renameText; //$NON-NLS-1$
+// }
+// }
+               return renameText;
+       }
+}
diff --git a/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/refactoring/JSPTypeRenameChange.java b/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/refactoring/JSPTypeRenameChange.java
new file mode 100644 (file)
index 0000000..10ad88a
--- /dev/null
@@ -0,0 +1,74 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.web.ui.internal.java.refactoring;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.ltk.core.refactoring.Change;
+import org.eclipse.ltk.core.refactoring.RefactoringStatus;
+import org.eclipse.wst.jsdt.core.IType;
+import org.eclipse.wst.jsdt.web.core.javascript.search.JsSearchScope;
+import org.eclipse.wst.jsdt.web.core.javascript.search.JsSearchSupport;
+import org.eclipse.wst.jsdt.web.ui.internal.JsUIMessages;
+/**
+*
+
+* Provisional API: This class/interface is part of an interim API that is still under development and expected to
+* change significantly before reaching stability. It is being made available at this early stage to solicit feedback
+* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
+* (repeatedly) as the API evolves.
+*
+ * @author pavery
+ */
+public class JSPTypeRenameChange extends Change {
+       public static Change[] createChangesFor(IType type, String newName) {
+               JsSearchSupport support = JsSearchSupport.getInstance();
+               // should be handled by JSPIndexManager
+               // https://w3.opensource.ibm.com/bugzilla/show_bug.cgi?id=3036
+               // support.indexWorkspaceAndWait();
+               JSPTypeRenameRequestor requestor = new JSPTypeRenameRequestor(type, newName);
+               support.searchRunnable(type, new JsSearchScope(), requestor);
+               return requestor.getChanges();
+       }
+       
+       
+       public Object getModifiedElement() {
+               // TODO Auto-generated method stub
+               return null;
+       }
+       
+       
+       public String getName() {
+               return JsUIMessages.JSP_changes;
+       }
+       
+       
+       public void initializeValidationData(IProgressMonitor pm) {
+       // pa_TODO implement
+       // must be implemented to decide correct value of isValid
+       }
+       
+       
+       public RefactoringStatus isValid(IProgressMonitor pm) throws CoreException {
+               // pa_TODO implement
+               // This method must ensure that the change object is still valid.
+               // This is in particular interesting when performing an undo change
+               // since the workspace could have changed since the undo change has
+               // been created.
+               return new RefactoringStatus();
+       }
+       
+       
+       public Change perform(IProgressMonitor pm) throws CoreException {
+               // TODO return the "undo" change here
+               return null;
+       }
+}
diff --git a/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/refactoring/JSPTypeRenameParticipant.java b/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/refactoring/JSPTypeRenameParticipant.java
new file mode 100644 (file)
index 0000000..56a46dd
--- /dev/null
@@ -0,0 +1,95 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.web.ui.internal.java.refactoring;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.ltk.core.refactoring.Change;
+import org.eclipse.ltk.core.refactoring.CompositeChange;
+import org.eclipse.ltk.core.refactoring.RefactoringStatus;
+import org.eclipse.ltk.core.refactoring.participants.CheckConditionsContext;
+import org.eclipse.ltk.core.refactoring.participants.RenameParticipant;
+import org.eclipse.wst.jsdt.core.IType;
+import org.eclipse.wst.jsdt.core.JavaScriptModelException;
+import org.eclipse.wst.jsdt.web.ui.internal.JsUIMessages;
+import org.eclipse.wst.jsdt.web.ui.internal.Logger;
+import org.eclipse.wst.jsdt.web.ui.views.contentoutline.IJavaWebNode;
+/**
+*
+
+* Provisional API: This class/interface is part of an interim API that is still under development and expected to
+* change significantly before reaching stability. It is being made available at this early stage to solicit feedback
+* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
+* (repeatedly) as the API evolves.
+*
+ * Remember to change the plugin.xml file if the name of this class changes.
+ * 
+ * @author pavery
+ */
+public class JSPTypeRenameParticipant extends RenameParticipant {
+       private IType fType = null;
+       
+       /**
+        * @see org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant#checkConditions(org.eclipse.core.runtime.IProgressMonitor,
+        *      org.eclipse.ltk.core.refactoring.participants.CheckConditionsContext)
+        */
+       
+       public RefactoringStatus checkConditions(IProgressMonitor pm, CheckConditionsContext context) {
+               // TODO Auto-generated method stub
+               return null;
+       }
+       
+       /**
+        * @see org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant#createChange(org.eclipse.core.runtime.IProgressMonitor)
+        */
+       
+       public Change createChange(IProgressMonitor pm) throws CoreException {
+               Change[] changes = JSPTypeRenameChange.createChangesFor(fType, getArguments().getNewName());
+               CompositeChange multiChange = null;
+               if (changes.length > 0) {
+                       multiChange = new CompositeChange(JsUIMessages.JSP_changes, changes);
+               }
+               return multiChange;
+       }
+       
+       /**
+        * @see org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant#getName()
+        */
+       
+       public String getName() {
+               String name = ""; //$NON-NLS-1$
+               if (this.fType != null) {
+                       try {
+                               name = this.fType.getSource();
+                       } catch (JavaScriptModelException e) {
+                               Logger.logException(e);
+                       }
+               }
+               return name;
+       }
+       
+       /**
+        * @see org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant#initialize(java.lang.Object)
+        */
+       
+       protected boolean initialize(Object element) {
+               if (element instanceof IType) {
+                       this.fType = (IType) element;
+                       return true;
+               }else if (element instanceof IJavaWebNode) {
+                       if(((IJavaWebNode)element).getJavaElement() instanceof IType) {
+                               this.fType = (IType) ((IJavaWebNode)element).getJavaElement();
+                               return true;
+                       }
+               }
+               return false;
+       }
+}
diff --git a/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/refactoring/JSPTypeRenameRequestor.java b/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/refactoring/JSPTypeRenameRequestor.java
new file mode 100644 (file)
index 0000000..fbce86e
--- /dev/null
@@ -0,0 +1,73 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2009 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.web.ui.internal.java.refactoring;
+
+import java.text.MessageFormat;
+
+import org.eclipse.wst.jsdt.core.IType;
+import org.eclipse.wst.jsdt.core.search.SearchMatch;
+//import org.eclipse.wst.jsdt.web.core.internal.java.JsTranslation;
+import org.eclipse.wst.jsdt.web.core.javascript.search.JSDTSearchDocumentDelegate;
+import org.eclipse.wst.jsdt.web.ui.internal.JsUIMessages;
+
+/**
+*
+
+* Provisional API: This class/interface is part of an interim API that is still under development and expected to
+* change significantly before reaching stability. It is being made available at this early stage to solicit feedback
+* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
+* (repeatedly) as the API evolves.
+*
+ * Creates document change(s) for a type rename. Changes are created for every
+ * type "match" in the workspace
+ * 
+ * @author pavery
+ */
+public class JSPTypeRenameRequestor extends BasicRefactorSearchRequestor {
+       public JSPTypeRenameRequestor(IType type, String newName) {
+               super(type, newName);
+       }
+       
+       /*
+        * (non-Javadoc)
+        * 
+        * @see org.eclipse.wst.jsdt.web.ui.internal.java.refactoring.BasicRefactorSearchRequestor#getDescription()
+        */
+       
+       protected String getDescription() {
+               String typeName = getElement().getElementName();
+               String newName = getNewName();
+               String description = MessageFormat.format(JsUIMessages.BasicRefactorSearchRequestor_4, new String[] { typeName, newName });
+               return description;
+       }
+       
+       
+       protected String getRenameText(JSDTSearchDocumentDelegate searchDoc, SearchMatch javaMatch) {
+               String renameText = getNewName();
+       //      String pkg = getType().getPackageFragment().getElementName();
+       //      JsTranslation trans = searchDoc.getJspTranslation();
+       //      String matchText = trans.getJsText().substring(javaMatch.getOffset(), javaMatch.getOffset() + javaMatch.getLength());
+               // if it's an import or jsp:useBean or fully qualified type, we need to
+               // add the package name as well
+// if (trans.isImport(javaMatch.getOffset())
+// || /* trans.isUseBean(javaMatch.getOffset()) ||
+// */isFullyQualified(matchText)) {
+// if (!pkg.equals("")) {
+// renameText = pkg + "." + renameText; //$NON-NLS-1$
+// }
+// }
+               return renameText;
+       }
+       
+//     private IType getType() {
+//             return (IType) getElement();
+//     }
+}
diff --git a/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/search/BasicJsSearchRequestor.java b/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/search/BasicJsSearchRequestor.java
new file mode 100644 (file)
index 0000000..31d10ba
--- /dev/null
@@ -0,0 +1,148 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.web.ui.internal.java.search;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.jface.text.Document;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.wst.jsdt.core.search.SearchDocument;
+import org.eclipse.wst.jsdt.core.search.SearchMatch;
+import org.eclipse.wst.jsdt.core.search.SearchParticipant;
+import org.eclipse.wst.jsdt.core.search.SearchRequestor;
+
+import org.eclipse.wst.jsdt.web.core.javascript.IJsTranslation;
+import org.eclipse.wst.jsdt.web.core.javascript.search.JSDTSearchDocumentDelegate;
+import org.eclipse.wst.jsdt.web.core.javascript.search.JsSearchSupport;
+
+/**
+*
+
+* Provisional API: This class/interface is part of an interim API that is still under development and expected to
+* change significantly before reaching stability. It is being made available at this early stage to solicit feedback
+* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
+* (repeatedly) as the API evolves.
+*
+ * @author pavery
+ */
+public class BasicJsSearchRequestor extends SearchRequestor {
+       // for debugging
+       private static final boolean DEBUG;
+       static {
+               String value = Platform.getDebugOption("org.eclipse.wst.jsdt.web.core/debug/jspsearch"); //$NON-NLS-1$
+               DEBUG = value != null && value.equalsIgnoreCase("true"); //$NON-NLS-1$
+       }
+       
+       /**
+        * Maps java search coordinates to corresponding JSP coordinates. Adds the
+        * matches to the Search Results view.
+        * 
+        * @see org.eclipse.wst.jsdt.core.search.SearchRequestor#acceptSearchMatch(org.eclipse.wst.jsdt.core.search.SearchMatch)
+        */
+       
+       public void acceptSearchMatch(SearchMatch match) throws CoreException {
+               if (JsSearchSupport.getInstance().isCanceled()) {
+                       return;
+               }
+               String matchDocumentPath = match.getResource().getFullPath().toString();
+               SearchDocument searchDoc = JsSearchSupport.getInstance().getSearchDocument(matchDocumentPath);
+               if (searchDoc != null && searchDoc instanceof JSDTSearchDocumentDelegate) {
+                       JSDTSearchDocumentDelegate javaSearchDoc = (JSDTSearchDocumentDelegate) searchDoc;
+                       int jspStart = match.getOffset();
+                       int jspEnd = match.getOffset() + match.getLength();
+                       IJsTranslation trans = javaSearchDoc.getJspTranslation();
+                       String jspText = trans.getHtmlText();
+                       String javaText = javaSearchDoc.getJavaText();
+                       if (BasicJsSearchRequestor.DEBUG) {
+                               displayDebugInfo(match, jspStart, jspEnd, jspText, javaText);
+                       }
+                       if (jspStart > -1 && jspEnd > -1) {
+                               addSearchMatch(new Document(trans.getHtmlText()), javaSearchDoc.getFile(), jspStart, jspEnd, jspText);
+                       }
+               }
+       }
+       
+       /**
+        * @param searchDoc
+        * @param jspStart
+        * @param jspEnd
+        * @param jspTranslation
+        * @param jspText
+        * @throws CoreException
+        */
+       protected void addSearchMatch(IDocument jspDocument, IFile jspFile, int jspStart, int jspEnd, String jspText) {
+       // implement in subclass
+       }
+       
+       /*
+        * (non-Javadoc)
+        * 
+        * @see org.eclipse.wst.jsdt.core.search.SearchRequestor#beginReporting()
+        */
+       
+       public void beginReporting() {
+               if (BasicJsSearchRequestor.DEBUG) {
+                       System.out.println("JSP Search requestor: beginReporting()"); //$NON-NLS-1$
+               }
+       }
+       
+       /**
+        * For debug.
+        * 
+        * @param origMatch
+        * @param jspStart
+        * @param jspEnd
+        * @param jspText
+        * @param javaText
+        */
+       private void displayDebugInfo(SearchMatch origMatch, int jspStart, int jspEnd, String jspText, String javaText) {
+               if (origMatch == null || jspStart == -1 || jspEnd == -1 || jspEnd < jspStart || jspText == null || javaText == null) {
+                       return;
+               }
+               System.out.println("+-----------------------------------------+"); //$NON-NLS-1$
+               System.out.println("accept possible match [jspDoc: " + origMatch.getResource().getFullPath().toOSString() + " " + origMatch.getOffset() + ":" + origMatch.getOffset() + origMatch.getLength() + "]?"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+               System.out.println("match info:"); //$NON-NLS-1$
+               System.out.println("the java text is:" + javaText.substring(origMatch.getOffset(), origMatch.getOffset() + origMatch.getLength())); //$NON-NLS-1$
+               System.out.println("java search match translates to jsp coords [start: " + jspStart + " end:" + jspEnd + "]"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+               System.out.println(" the jsp text is:" + jspText.substring(jspStart, jspEnd)); //$NON-NLS-1$
+       }
+       
+       /**
+        * @see org.eclipse.wst.jsdt.core.search.SearchRequestor#endReporting()
+        */
+       
+       public void endReporting() {
+               if (BasicJsSearchRequestor.DEBUG) {
+                       System.out.println("JSP Search requestor: endReporting()"); //$NON-NLS-1$
+               }
+       }
+       
+       /**
+        * @see org.eclipse.wst.jsdt.core.search.SearchRequestor#enterParticipant(org.eclipse.wst.jsdt.core.search.SearchParticipant)
+        */
+       
+       public void enterParticipant(SearchParticipant participant) {
+               if (BasicJsSearchRequestor.DEBUG) {
+                       System.out.println("JSP Search requestor: enterParticipant()"); //$NON-NLS-1$
+               }
+       }
+       
+       /**
+        * @see org.eclipse.wst.jsdt.core.search.SearchRequestor#exitParticipant(org.eclipse.wst.jsdt.core.search.SearchParticipant)
+        */
+       
+       public void exitParticipant(SearchParticipant participant) {
+               if (BasicJsSearchRequestor.DEBUG) {
+                       System.out.println("JSP Search requestor: exitParticipant()"); //$NON-NLS-1$
+               }
+       }
+}
diff --git a/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/search/JsFindOccurrencesActionDelegate.java b/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/search/JsFindOccurrencesActionDelegate.java
new file mode 100644 (file)
index 0000000..bbfc633
--- /dev/null
@@ -0,0 +1,47 @@
+/*******************************************************************************
+ * 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.web.ui.internal.java.search;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.wst.html.ui.internal.search.HTMLFindOccurrencesProcessor;
+import org.eclipse.wst.sse.ui.internal.search.FindOccurrencesActionDelegate;
+
+/**
+*
+
+* Provisional API: This class/interface is part of an interim API that is still under development and expected to
+* change significantly before reaching stability. It is being made available at this early stage to solicit feedback
+* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
+* (repeatedly) as the API evolves.
+*/
+public class JsFindOccurrencesActionDelegate extends FindOccurrencesActionDelegate {
+       private List fProcessors;
+       
+       
+       protected List getProcessors() {
+               if (fProcessors == null) {
+                       fProcessors = new ArrayList();
+                       HTMLFindOccurrencesProcessor htmlProcessor = new HTMLFindOccurrencesProcessor();
+                       fProcessors.add(htmlProcessor);
+                       // temporary, workaround to disable function, since using the
+                       // function
+                       // can easily cause deadlock to occur.
+                       // See https://bugs.eclipse.org/bugs/show_bug.cgi?id=103662
+// JSPFindOccurrencesProcessor jspProcessor = new
+// JSPFindOccurrencesProcessor();
+// fProcessors.add(jspProcessor);
+               }
+               return fProcessors;
+       }
+}
diff --git a/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/search/JsFindOccurrencesProcessor.java b/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/search/JsFindOccurrencesProcessor.java
new file mode 100644 (file)
index 0000000..7a0d93d
--- /dev/null
@@ -0,0 +1,89 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.web.ui.internal.java.search;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.ITextSelection;
+import org.eclipse.search.ui.ISearchQuery;
+import org.eclipse.wst.jsdt.core.IJavaScriptElement;
+import org.eclipse.wst.jsdt.web.core.javascript.IJsTranslation;
+import org.eclipse.wst.jsdt.web.core.javascript.JsTranslationAdapter;
+import org.eclipse.wst.jsdt.web.core.text.IJsPartitions;
+import org.eclipse.wst.sse.core.StructuredModelManager;
+import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
+import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument;
+import org.eclipse.wst.sse.ui.internal.search.FindOccurrencesProcessor;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
+import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext;
+/**
+*
+
+* Provisional API: This class/interface is part of an interim API that is still under development and expected to
+* change significantly before reaching stability. It is being made available at this early stage to solicit feedback
+* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
+* (repeatedly) as the API evolves.
+*/
+public class JsFindOccurrencesProcessor extends FindOccurrencesProcessor {
+       private IJavaScriptElement getJavaElement(IDocument document, ITextSelection textSelection) {
+               IJavaScriptElement[] elements = getJavaElementsForCurrentSelection(document, textSelection);
+               return elements.length > 0 ? elements[0] : null;
+       }
+       
+       /**
+        * uses JSPTranslation to get currently selected Java elements.
+        * 
+        * @return currently selected IJavaElements
+        */
+       private IJavaScriptElement[] getJavaElementsForCurrentSelection(IDocument document, ITextSelection selection) {
+               IJavaScriptElement[] elements = new IJavaScriptElement[0];
+               // get JSP translation object for this viewer's document
+               IStructuredModel model = null;
+               try {
+                       model = StructuredModelManager.getModelManager().getExistingModelForRead(document);
+                       if (model != null && model instanceof IDOMModel) {
+                               IDOMDocument xmlDoc = ((IDOMModel) model).getDocument();
+                               JsTranslationAdapter adapter = (JsTranslationAdapter) xmlDoc.getAdapterFor(IJsTranslation.class);
+                               if (adapter != null) {
+                                       IJsTranslation translation = adapter.getJsTranslation(false);
+                                       // https://bugs.eclipse.org/bugs/show_bug.cgi?id=102211
+                                       elements = translation.getElementsFromJsRange(selection.getOffset(), selection.getOffset() + selection.getLength());
+                               }
+                       }
+               } finally {
+                       if (model != null) {
+                               model.releaseFromRead();
+                       }
+               }
+               return elements;
+       }
+       
+       
+       protected String[] getPartitionTypes() {
+               return new String[] { IJsPartitions.HtmlJsPartition };
+       }
+       
+       
+       protected String[] getRegionTypes() {
+               return new String[] { DOMRegionContext.BLOCK_TEXT };
+       }
+       
+       
+       protected ISearchQuery getSearchQuery(IFile file, IStructuredDocument document, String regionText, String regionType, ITextSelection textSelection) {
+               IJavaScriptElement javaScriptElement = getJavaElement(document, textSelection);
+               if (javaScriptElement != null) {
+                       return new JsSearchQuery(file, javaScriptElement);
+               }
+               return null;
+       }
+}
diff --git a/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/search/JsOccurrencesSearchResult.java b/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/search/JsOccurrencesSearchResult.java
new file mode 100644 (file)
index 0000000..504987e
--- /dev/null
@@ -0,0 +1,35 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.web.ui.internal.java.search;
+
+import org.eclipse.search.ui.ISearchQuery;
+import org.eclipse.search.ui.text.Match;
+import org.eclipse.wst.sse.ui.internal.search.OccurrencesSearchResult;
+/**
+*
+
+* Provisional API: This class/interface is part of an interim API that is still under development and expected to
+* change significantly before reaching stability. It is being made available at this early stage to solicit feedback
+* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
+* (repeatedly) as the API evolves.
+*
+ * @author pavery
+ */
+public class JsOccurrencesSearchResult extends OccurrencesSearchResult {
+       public JsOccurrencesSearchResult(ISearchQuery query) {
+               super(query);
+       }
+       
+       
+       public Match[] getMatches() {
+               return super.getMatches();
+       }
+}
diff --git a/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/search/JsSearchQuery.java b/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/search/JsSearchQuery.java
new file mode 100644 (file)
index 0000000..d3807e0
--- /dev/null
@@ -0,0 +1,121 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.web.ui.internal.java.search;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.search.ui.ISearchResult;
+import org.eclipse.wst.jsdt.core.IJavaScriptElement;
+import org.eclipse.wst.jsdt.core.search.SearchDocument;
+import org.eclipse.wst.jsdt.web.core.javascript.search.JsSearchScope;
+import org.eclipse.wst.jsdt.web.core.javascript.search.JsSearchSupport;
+import org.eclipse.wst.jsdt.web.ui.internal.JsUIMessages;
+import org.eclipse.wst.sse.ui.internal.search.BasicSearchQuery;
+
+/**
+*
+
+* Provisional API: This class/interface is part of an interim API that is still under development and expected to
+* change significantly before reaching stability. It is being made available at this early stage to solicit feedback
+* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
+* (repeatedly) as the API evolves.
+*
+ * @author pavery
+ */
+public class JsSearchQuery extends BasicSearchQuery {
+       /** the IJavaScriptElement we are searching for in the file * */
+       private IJavaScriptElement fElement = null;
+       
+       public JsSearchQuery(IFile file, IJavaScriptElement element) {
+               super(file);
+               this.fElement = element;
+       }
+       
+       
+       public boolean canRerun() {
+               return false;
+       }
+       
+       /**
+        * @see org.eclipse.search.ui.ISearchQuery#canRunInBackground()
+        */
+       
+       public boolean canRunInBackground() {
+               return true;
+       }
+       
+       
+       protected IStatus doQuery() {
+               IStatus status = Status.OK_STATUS;
+               try {
+                       JsSearchSupport support = JsSearchSupport.getInstance();
+                       // index the file
+                       SearchDocument delegate = support.addJspFile(getFile());
+                       String scopePath = delegate.getPath();
+                       JsSearchScope singleFileScope = new JsSearchScope(new String[] { getFile().getFullPath().toString(), scopePath });
+                       // perform a searchs
+                       // by passing in this jsp search query, requstor can add matches
+                       // support.searchRunnable(getJavaElement(), singleFileScope, new
+                       // JSPSingleFileSearchRequestor(getInstance()));
+                       support.searchRunnable(getJavaElement(), singleFileScope, new JsSingleFileSearchRequestor(getInstance()));
+               } catch (Exception e) {
+                       status = new Status(IStatus.ERROR, "org.eclipse.wst.sse.ui", IStatus.OK, "", null); //$NON-NLS-1$       //$NON-NLS-2$
+               }
+               return status;
+       }
+       
+       private String getFilename() {
+               String filename = JsUIMessages.OccurrencesSearchQuery_2;
+               if (getFile() != null) {
+                       filename = getFile().getName();
+               }
+               return filename;
+       }
+       
+       // for access by inner class
+       public JsSearchQuery getInstance() {
+               return this;
+       }
+       
+       public IJavaScriptElement getJavaElement() {
+               return this.fElement;
+       }
+       
+       /**
+        * @see org.eclipse.search.ui.ISearchQuery#getLabel()
+        */
+       
+       public String getLabel() {
+               String[] args = { getSearchText(), getOccurrencesCountText(), getFilename() };
+               return NLS.bind(JsUIMessages.OccurrencesSearchQuery_0, args);
+       }
+       
+       private String getOccurrencesCountText() {
+               String count = ""; //$NON-NLS-1$
+               // pa_TODO make dynamic
+               return count;
+       }
+       
+       /**
+        * @see org.eclipse.search.ui.ISearchQuery#getSearchResult()
+        */
+       
+       public ISearchResult getSearchResult() {
+               return new JsOccurrencesSearchResult(this);
+       }
+       
+       
+       protected String getSearchText() {
+               return fElement.getElementName();
+       }
+}
diff --git a/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/search/JsSearchRequestor.java b/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/search/JsSearchRequestor.java
new file mode 100644 (file)
index 0000000..33feb50
--- /dev/null
@@ -0,0 +1,81 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.web.ui.internal.java.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.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.search.ui.NewSearchUI;
+import org.eclipse.search.ui.text.Match;
+import org.eclipse.wst.jsdt.ui.search.ISearchRequestor;
+import org.eclipse.wst.jsdt.web.ui.internal.Logger;
+/**
+*
+
+* Provisional API: This class/interface is part of an interim API that is still under development and expected to
+* change significantly before reaching stability. It is being made available at this early stage to solicit feedback
+* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
+* (repeatedly) as the API evolves.
+*
+ * @author pavery
+ */
+public class JsSearchRequestor extends BasicJsSearchRequestor {
+       private ISearchRequestor fJavaRequestor = null;
+       
+       public JsSearchRequestor() {
+               super();
+       }
+       
+       public JsSearchRequestor(ISearchRequestor javaRequestor) {
+               // need to report matches to javaRequestor
+               this.fJavaRequestor = javaRequestor;
+       }
+       
+       
+       protected void addSearchMatch(IDocument jspDocument, IFile jspFile, int jspStart, int jspEnd, String jspText) {
+               if (!jspFile.exists()) {
+                       return;
+               }
+               int lineNumber = -1;
+               try {
+                       lineNumber = jspDocument.getLineOfOffset(jspStart);
+               } catch (BadLocationException e) {
+                       Logger.logException("offset: " + Integer.toString(jspStart), e); //$NON-NLS-1$
+               }
+               createSearchMarker(jspFile, jspStart, jspEnd, lineNumber);
+               if (this.fJavaRequestor != null) {
+                       Match match = new Match(jspFile, jspStart, jspEnd - jspStart);
+                       this.fJavaRequestor.reportMatch(match);
+               }
+       }
+       
+       /**
+        * @param jspFile
+        * @param jspStart
+        * @param jspEnd
+        */
+       private void createSearchMarker(IFile jspFile, int jspStart, int jspEnd, int lineNumber) {
+               try {
+                       IMarker marker = jspFile.createMarker(NewSearchUI.SEARCH_MARKER);
+                       HashMap attributes = new HashMap(4);
+                       attributes.put(IMarker.CHAR_START, new Integer(jspStart));
+                       attributes.put(IMarker.CHAR_END, new Integer(jspEnd));
+                       attributes.put(IMarker.LINE_NUMBER, new Integer(lineNumber));
+                       marker.setAttributes(attributes);
+               } catch (CoreException e) {
+                       Logger.logException(e);
+               }
+       }
+}
diff --git a/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/search/JsSingleFileSearchRequestor.java b/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/search/JsSingleFileSearchRequestor.java
new file mode 100644 (file)
index 0000000..9556525
--- /dev/null
@@ -0,0 +1,38 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.web.ui.internal.java.search;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.jface.text.IDocument;
+
+/**
+*
+
+* Provisional API: This class/interface is part of an interim API that is still under development and expected to
+* change significantly before reaching stability. It is being made available at this early stage to solicit feedback
+* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
+* (repeatedly) as the API evolves.
+*
+ * @author pavery
+ */
+public class JsSingleFileSearchRequestor extends BasicJsSearchRequestor {
+       private JsSearchQuery fQuery = null;
+       
+       public JsSingleFileSearchRequestor(JsSearchQuery query) {
+               this.fQuery = query;
+       }
+       
+       
+       protected void addSearchMatch(IDocument jspDocument, IFile jspFile, int jspStart, int jspEnd, String jspText) {
+               // add match to JSP query...
+               this.fQuery.addMatch(jspDocument, jspStart, jspEnd);
+       }
+}
diff --git a/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/search/ui/JsMatchPresentation.java b/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/search/ui/JsMatchPresentation.java
new file mode 100644 (file)
index 0000000..aaa8880
--- /dev/null
@@ -0,0 +1,52 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.web.ui.internal.java.search.ui;
+
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.search.ui.text.Match;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.wst.jsdt.ui.search.IMatchPresentation;
+import org.eclipse.wst.sse.ui.internal.search.BasicSearchLabelProvider;
+/**
+*
+
+* Provisional API: This class/interface is part of an interim API that is still under development and expected to
+* change significantly before reaching stability. It is being made available at this early stage to solicit feedback
+* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
+* (repeatedly) as the API evolves.
+*
+ * @author pavery
+ */
+public class JsMatchPresentation implements IMatchPresentation {
+       /**
+        * @see org.eclipse.wst.jsdt.ui.search.IMatchPresentation#createLabelProvider()
+        */
+       public ILabelProvider createLabelProvider() {
+               return new BasicSearchLabelProvider();
+       }
+       
+       /*
+        * (non-Javadoc)
+        * 
+        * @see org.eclipse.wst.jsdt.ui.search.IMatchPresentation#showMatch(org.eclipse.search.ui.text.Match,
+        *      int, int, boolean)
+        */
+       public void showMatch(Match match, int currentOffset, int currentLength, boolean activate) throws PartInitException {
+               // pa_TODO implement
+               // Object obj = match.getElement();
+               // show match in JSP editor
+               if (activate) {
+                       // use show in target?
+               } else {
+                       // just select
+               }
+       }
+}
diff --git a/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/search/ui/JsQueryParticipant.java b/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/search/ui/JsQueryParticipant.java
new file mode 100644 (file)
index 0000000..faf5291
--- /dev/null
@@ -0,0 +1,90 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.web.ui.internal.java.search.ui;
+
+import org.eclipse.core.runtime.CoreException;
+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.search.SearchPattern;
+import org.eclipse.wst.jsdt.core.search.SearchRequestor;
+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;
+import org.eclipse.wst.jsdt.web.core.javascript.search.JsSearchScope;
+import org.eclipse.wst.jsdt.web.core.javascript.search.JsSearchSupport;
+import org.eclipse.wst.jsdt.web.ui.internal.java.search.JsSearchRequestor;
+/**
+*
+
+* Provisional API: This class/interface is part of an interim API that is still under development and expected to
+* change significantly before reaching stability. It is being made available at this early stage to solicit feedback
+* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
+* (repeatedly) as the API evolves.
+*
+ * @author pavery
+ */
+public class JsQueryParticipant implements IQueryParticipant {
+       // for debugging
+       private static final boolean DEBUG;
+       static {
+               String value = Platform.getDebugOption("org.eclipse.wst.jsdt.web.core/debug/jspsearch"); //$NON-NLS-1$
+               DEBUG = value != null && value.equalsIgnoreCase("true"); //$NON-NLS-1$
+       }
+       
+       /**
+        * @see org.eclipse.wst.jsdt.ui.search.IQueryParticipant#estimateTicks(org.eclipse.wst.jsdt.ui.search.QuerySpecification)
+        */
+       public int estimateTicks(QuerySpecification data) {
+               // pa_TODO use project file counter from JSPSearchSupport...
+               return 0;
+       }
+       
+       /**
+        * @see org.eclipse.wst.jsdt.ui.search.IQueryParticipant#getUIParticipant()
+        */
+       public IMatchPresentation getUIParticipant() {
+               return new JsMatchPresentation();
+       }
+       
+       /**
+        * @see org.eclipse.wst.jsdt.ui.search.IQueryParticipant#search(org.eclipse.wst.jsdt.ui.search.ISearchRequestor,
+        *      org.eclipse.wst.jsdt.ui.search.QuerySpecification,
+        *      org.eclipse.core.runtime.IProgressMonitor)
+        */
+       public void search(ISearchRequestor requestor, QuerySpecification querySpecification, IProgressMonitor monitor) throws CoreException {
+               // indexIfNeeded();
+               // do search based on the particular Java query
+               if (querySpecification instanceof ElementQuerySpecification) {
+                       // element search (eg. from global find references in Java file)
+                       ElementQuerySpecification elementQuery = (ElementQuerySpecification) querySpecification;
+                       IJavaScriptElement element = elementQuery.getElement();
+                       if (JsQueryParticipant.DEBUG) {
+                               System.out.println("JSP Query Participant searching on ELEMENT: " + element); //$NON-NLS-1$
+                       }
+                       SearchRequestor jspRequestor = new JsSearchRequestor(requestor);
+                       // pa_TODO need to adapt JavaSearchScope to a JSPSearchScope
+                       JsSearchSupport.getInstance().search(element, new JsSearchScope(), jspRequestor);
+               } else if (querySpecification instanceof PatternQuerySpecification) {
+                       // pattern search (eg. from Java search page)
+                       PatternQuerySpecification patternQuery = (PatternQuerySpecification) querySpecification;
+                       String pattern = patternQuery.getPattern();
+                       if (JsQueryParticipant.DEBUG) {
+                               System.out.println("JSP Query Participant searching on PATTERN: " + pattern); //$NON-NLS-1$
+                       }
+                       SearchRequestor jspRequestor = new JsSearchRequestor(requestor);
+                       JsSearchSupport.getInstance().search(pattern, new JsSearchScope(), patternQuery.getSearchFor(), patternQuery.getLimitTo(), SearchPattern.R_PATTERN_MATCH, false, jspRequestor);
+               }
+       }
+}
diff --git a/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/registry/AdapterFactoryProviderForJSDT.java b/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/registry/AdapterFactoryProviderForJSDT.java
new file mode 100644 (file)
index 0000000..f4b6a69
--- /dev/null
@@ -0,0 +1,70 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.web.ui.internal.registry;
+
+import org.eclipse.wst.html.core.internal.modelhandler.ModelHandlerForHTML;
+import org.eclipse.wst.jsdt.web.core.javascript.JsTranslationAdapterFactory;
+import org.eclipse.wst.jsdt.web.ui.views.contentoutline.JFaceNodeAdapterFactoryForJSDT;
+import org.eclipse.wst.sse.core.internal.ltk.modelhandler.IDocumentTypeHandler;
+import org.eclipse.wst.sse.core.internal.model.FactoryRegistry;
+import org.eclipse.wst.sse.core.internal.provisional.INodeAdapterFactory;
+import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
+import org.eclipse.wst.sse.ui.internal.contentoutline.IJFaceNodeAdapter;
+import org.eclipse.wst.sse.ui.internal.provisional.registry.AdapterFactoryProvider;
+import org.eclipse.wst.sse.ui.internal.util.Assert;
+/**
+*
+
+* Provisional API: This class/interface is part of an interim API that is still under development and expected to
+* change significantly before reaching stability. It is being made available at this early stage to solicit feedback
+* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
+* (repeatedly) as the API evolves.
+*/
+public class AdapterFactoryProviderForJSDT implements AdapterFactoryProvider {
+       /*
+        * @see AdapterFactoryProvider#addAdapterFactories(IStructuredModel)
+        */
+       public void addAdapterFactories(IStructuredModel structuredModel) {
+               // these are the main factories, on model's factory registry
+               addContentBasedFactories(structuredModel);
+               // -------
+               // Must update/add to propagating adapters here too
+               addPropagatingAdapters(structuredModel);
+       }
+       
+       protected void addContentBasedFactories(IStructuredModel structuredModel) {
+               FactoryRegistry factoryRegistry = structuredModel.getFactoryRegistry();
+               Assert.isNotNull(factoryRegistry, "Program Error: client caller must ensure model has factory registry"); //$NON-NLS-1$
+               INodeAdapterFactory factory = null;
+               factory = factoryRegistry.getFactoryFor(IJFaceNodeAdapter.class);
+               if (!(factory instanceof JFaceNodeAdapterFactoryForJSDT)) {
+                       factoryRegistry.removeFactoriesFor(IJFaceNodeAdapter.class);
+                       factory = new JFaceNodeAdapterFactoryForJSDT(IJFaceNodeAdapter.class, true);
+                       factoryRegistry.addFactory(factory);
+               }
+               
+               JsTranslationAdapterFactory.setupAdapterFactory(structuredModel);
+       }
+       
+       protected void addPropagatingAdapters(IStructuredModel structuredModel) {}
+       
+       /*
+        * @see AdapterFactoryProvider#isFor(ContentTypeDescription)
+        */
+       public boolean isFor(IDocumentTypeHandler contentTypeDescription) {
+               // return (contentTypeDescription instanceof ModelHandlerForJSP);
+               return (contentTypeDescription instanceof ModelHandlerForHTML);
+       }
+       
+       public void reinitializeFactories(IStructuredModel structuredModel) {
+               addAdapterFactories(structuredModel);
+       }
+}
diff --git a/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/style/IStyleConstantsJs.java b/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/style/IStyleConstantsJs.java
new file mode 100644 (file)
index 0000000..4a237d6
--- /dev/null
@@ -0,0 +1,22 @@
+/*******************************************************************************
+ * 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.web.ui.internal.style;
+/**
+*
+
+* Provisional API: This class/interface is part of an interim API that is still under development and expected to
+* change significantly before reaching stability. It is being made available at this early stage to solicit feedback
+* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
+* (repeatedly) as the API evolves.
+*/
+public interface IStyleConstantsJs {
+       public static final String JSP_CONTENT = "jsp_content"; //$NON-NLS-1$
+}
diff --git a/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/style/java/IStyleConstantsJSDT.java b/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/style/java/IStyleConstantsJSDT.java
new file mode 100644 (file)
index 0000000..6ec51cb
--- /dev/null
@@ -0,0 +1,27 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Jens Lukowski/Innoopract - initial renaming/restructuring
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.web.ui.internal.style.java;
+/**
+*
+
+* Provisional API: This class/interface is part of an interim API that is still under development and expected to
+* change significantly before reaching stability. It is being made available at this early stage to solicit feedback
+* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
+* (repeatedly) as the API evolves.
+*/
+public interface IStyleConstantsJSDT {
+       String JAVA_DEFAULT = "default"; //$NON-NLS-1$
+       String JAVA_KEYWORD = "keyword"; //$NON-NLS-1$
+       String JAVA_SINGLE_LINE_COMMENT = "single_line_comment"; //$NON-NLS-1$
+       String JAVA_MULTI_LINE_COMMENT = "multi_line_comment"; //$NON-NLS-1$
+       String JAVA_STRING = "string"; //$NON-NLS-1$
+}
diff --git a/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/style/java/JSDTCodeScanner.java b/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/style/java/JSDTCodeScanner.java
new file mode 100644 (file)
index 0000000..d6d50e3
--- /dev/null
@@ -0,0 +1,216 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.web.ui.internal.style.java;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.jface.text.rules.EndOfLineRule;
+import org.eclipse.jface.text.rules.ICharacterScanner;
+import org.eclipse.jface.text.rules.IRule;
+import org.eclipse.jface.text.rules.IToken;
+import org.eclipse.jface.text.rules.IWordDetector;
+import org.eclipse.jface.text.rules.MultiLineRule;
+import org.eclipse.jface.text.rules.PatternRule;
+import org.eclipse.jface.text.rules.SingleLineRule;
+import org.eclipse.jface.text.rules.Token;
+import org.eclipse.jface.text.rules.WordRule;
+import org.eclipse.wst.jsdt.web.core.javascript.JsDataTypes;
+import org.eclipse.wst.xml.ui.internal.style.IStyleConstantsXML;
+
+/**
+*
+
+* Provisional API: This class/interface is part of an interim API that is still under development and expected to
+* change significantly before reaching stability. It is being made available at this early stage to solicit feedback
+* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
+* (repeatedly) as the API evolves.
+*/
+class JSDTCodeScanner extends org.eclipse.jface.text.rules.RuleBasedScanner {
+       private static String[] fgConstants = JsDataTypes.CONSTANTS;
+       private static String[] fgKeywords = JsDataTypes.KEYWORDS;
+       private static String[] fgTypes = JsDataTypes.TYPES;
+       private IToken fDefaultToken;
+       private IToken fKeywordToken;
+       private IToken fSingleLineCommentToken;
+       private IToken fMultiLineCommentToken;
+       private IToken fStringToken;
+       private IToken fTypeToken;
+       private IToken fHTMLCommentBorderToken;
+       
+       /**
+        * Creates a Java code scanner
+        */
+       public JSDTCodeScanner() {
+               super();
+       }
+       
+       public void initializeRules() {
+               List rules = new ArrayList();
+               // Add rule for multiple line comments.
+               rules.add(new MultiLineRule("/*", "*/", fMultiLineCommentToken));//$NON-NLS-1$ //$NON-NLS-2$
+               // Add rule for single line comments.
+               rules.add(new NoneInclusiveEndSequenceSingleLineRule("//", "-->", fSingleLineCommentToken));//$NON-NLS-1$
+               // Add rule for strings and character constants.
+               rules.add(new SingleLineRule("\"", "\"", fStringToken, '\\'));//$NON-NLS-2$//$NON-NLS-1$
+               rules.add(new SingleLineRule("'", "'", fStringToken, '\\'));//$NON-NLS-2$//$NON-NLS-1$
+               // Add generic whitespace rule.
+               // rules.add(new WhitespaceRule(new JavaWhitespaceDetector()));
+               // Add word rule for keywords, types, and constants.
+               WordRule wordRule = new WordRule(new JavaWordDetector(), fDefaultToken);
+               for (int i = 0; i < JSDTCodeScanner.fgKeywords.length; i++) {
+                       wordRule.addWord(JSDTCodeScanner.fgKeywords[i], fKeywordToken);
+               }
+               for (int i = 0; i < JSDTCodeScanner.fgTypes.length; i++) {
+                       wordRule.addWord(JSDTCodeScanner.fgTypes[i], fTypeToken);
+               }
+               for (int i = 0; i < JSDTCodeScanner.fgConstants.length; i++) {
+                       wordRule.addWord(JSDTCodeScanner.fgConstants[i], fTypeToken);
+               }
+               rules.add(wordRule);
+               
+               //add word rule for HTML style comment delimiters
+               rules.add(new WordRule(new HTMLCommentDetector(), this.fHTMLCommentBorderToken));
+               
+               //add rule for text after leading HTML comment delimiter
+               rules.add(new NoneInclusiveStartSequenceEndOfLineRule("<!--", this.fSingleLineCommentToken));
+               
+               IRule[] result = new IRule[rules.size()];
+               rules.toArray(result);
+               setRules(result);
+       }
+       
+       public void setTokenData(String tokenKey, Object data) {
+               if (tokenKey == IStyleConstantsJSDT.JAVA_KEYWORD) {
+                       fKeywordToken = new Token(data);
+                       fTypeToken = new Token(data);
+               } else if (tokenKey == IStyleConstantsJSDT.JAVA_STRING) {
+                       fStringToken = new Token(data);
+               } else if (tokenKey == IStyleConstantsJSDT.JAVA_SINGLE_LINE_COMMENT) {
+                       fSingleLineCommentToken = new Token(data);
+               } else if (tokenKey == IStyleConstantsJSDT.JAVA_MULTI_LINE_COMMENT) {
+                       fMultiLineCommentToken = new Token(data);
+               } else if (tokenKey == IStyleConstantsJSDT.JAVA_DEFAULT) {
+                       fDefaultToken = new Token(data);
+               } else if(tokenKey == IStyleConstantsXML.COMMENT_BORDER) {
+                       fHTMLCommentBorderToken = new Token(data);
+               }
+       }
+       
+       /**
+        * <p>Detector for HTML comment delimiters.</p>
+        */
+       private static class HTMLCommentDetector implements IWordDetector {
+
+               /**
+                * @see IWordDetector#isWordStart(char)
+                */
+               public boolean isWordStart(char c) {
+                       return (c == '<' || c == '-');
+               }
+
+               /**
+                * @see IWordDetector#isWordPart(char)
+                */
+               public boolean isWordPart(char c) {
+                       return (c == '-' || c == '!' || c == '>');
+               }
+       }
+       
+       /**
+        * <p>Same as a {@link SingleLineRule} except the given end sequence is not counted as part of the match.</p>
+        * 
+        * @see SingleLineRule
+        */
+       private static class NoneInclusiveEndSequenceSingleLineRule extends SingleLineRule {
+
+               /**
+                * @param startSequence start sequence included in rule match
+                * @param endSequence end sequence that will end this rule but will not be counted as part of the match
+                * @param token to return on a match by this rule
+                */
+               public NoneInclusiveEndSequenceSingleLineRule(String startSequence, String endSequence, IToken token) {
+                       super(startSequence, endSequence, token);
+               }
+
+               /**
+                * <p>If the end sequence is detected then scanner is rewind to just before the end sequence,
+                * otherwise acts the same as {@link PatternRule#endSequenceDetected}</p>
+                * 
+                * @see PatternRule#endSequenceDetected
+                */
+               protected boolean endSequenceDetected(ICharacterScanner scanner) {
+                       boolean success = super.endSequenceDetected(scanner);
+                       if(success) {
+                               for (int length = this.fEndSequence.length-1; length > 0; length--) {
+                                       scanner.unread();
+                               }
+                               
+                               if(this.sequenceDetected(scanner, this.fEndSequence, false)) {
+                                       for (int length = this.fEndSequence.length; length > 0; length--) {
+                                               scanner.unread();
+                                       }
+                               }
+                       }
+                       return success;
+               }
+       }
+       
+       /**
+        * <p>Same as an {@link EndOfLineRule} except the given start sequence is not counted as part of the match.</p>
+        * 
+        * @see EndOfLineRule
+        */
+       private static class NoneInclusiveStartSequenceEndOfLineRule extends EndOfLineRule {
+
+               /**
+                * @param startSequence start sequence the identifies the start of this match but is not counted as part of the match
+                * @param token to return on a match by this rule
+                */
+               public NoneInclusiveStartSequenceEndOfLineRule(String startSequence, IToken token) {
+                       super(startSequence, token);
+               }
+               
+               /**
+                * <p>Same as overridden function except unreads the scanner back the length of the start sequence
+                * since the start sequence is not counted as part of the match.</p>
+                * 
+                * @see org.eclipse.jface.text.rules.PatternRule#doEvaluate(org.eclipse.jface.text.rules.ICharacterScanner, boolean)
+                */
+               protected IToken doEvaluate(ICharacterScanner scanner, boolean resume) {
+                       if (resume) {
+                               if (endSequenceDetected(scanner))
+                                       return fToken;
+                       } else {
+                               //unread the length of the start sequence since it is not counted as part of the match
+                               for(int i = 0; i < this.fStartSequence.length && scanner.getColumn() >= 0; ++i) {
+                                       scanner.unread();
+                               }
+
+                               int c= scanner.read();
+                               if (c == fStartSequence[0]) {
+                                       if (sequenceDetected(scanner, fStartSequence, false)) {
+                                               if (endSequenceDetected(scanner))
+                                                       return fToken;
+                                       }
+                               }
+                               
+                               //be sure to re-read the length of the start sequence if we did not match
+                               for(int i = 0; i < this.fStartSequence.length && scanner.getColumn() >= 0; ++i) {
+                                       scanner.read();
+                               }
+                       }
+
+                       scanner.unread();
+                       return Token.UNDEFINED;
+               }
+       }
+}
diff --git a/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/style/java/JavaWordDetector.java b/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/style/java/JavaWordDetector.java
new file mode 100644 (file)
index 0000000..a16268a
--- /dev/null
@@ -0,0 +1,35 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.web.ui.internal.style.java;
+
+/**
+*
+
+* Provisional API: This class/interface is part of an interim API that is still under development and expected to
+* change significantly before reaching stability. It is being made available at this early stage to solicit feedback
+* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
+* (repeatedly) as the API evolves.
+*/
+public class JavaWordDetector implements org.eclipse.jface.text.rules.IWordDetector {
+       /**
+        * @see org.eclipse.jface.text.rules.IWordDetector#isWordIdentifierPart
+        */
+       public boolean isWordPart(char c) {
+               return Character.isJavaIdentifierPart(c);
+       }
+       
+       /**
+        * @see org.eclipse.jface.text.rules.IWordDetector#isWordIdentifierStart
+        */
+       public boolean isWordStart(char c) {
+               return Character.isJavaIdentifierStart(c);
+       }
+}
diff --git a/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/style/java/LineStyleProviderForJSDT.java b/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/style/java/LineStyleProviderForJSDT.java
new file mode 100644 (file)
index 0000000..75357fc
--- /dev/null
@@ -0,0 +1,387 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.web.ui.internal.style.java;
+
+import java.util.Collection;
+
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.preference.PreferenceConverter;
+import org.eclipse.jface.text.ITypedRegion;
+import org.eclipse.jface.text.TextAttribute;
+import org.eclipse.jface.text.rules.IToken;
+import org.eclipse.jface.text.rules.Token;
+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.html.ui.internal.HTMLUIPlugin;
+import org.eclipse.wst.jsdt.ui.PreferenceConstants;
+import org.eclipse.wst.jsdt.web.ui.internal.JsUIPlugin;
+import org.eclipse.wst.jsdt.web.ui.internal.style.IStyleConstantsJs;
+import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion;
+import org.eclipse.wst.sse.ui.internal.preferences.ui.ColorHelper;
+import org.eclipse.wst.sse.ui.internal.provisional.style.AbstractLineStyleProvider;
+import org.eclipse.wst.sse.ui.internal.provisional.style.LineStyleProvider;
+import org.eclipse.wst.xml.ui.internal.style.IStyleConstantsXML;
+/**
+*
+
+* Provisional API: This class/interface is part of an interim API that is still under development and expected to
+* change significantly before reaching stability. It is being made available at this early stage to solicit feedback
+* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
+* (repeatedly) as the API evolves.
+*/
+public class LineStyleProviderForJSDT extends AbstractLineStyleProvider implements LineStyleProvider {
+       /** The scanner it uses */
+       private JSDTCodeScanner fScanner;
+       
+       private IPropertyChangeListener fPreferenceListener = new IPropertyChangeListener() {
+               /*
+                * (non-Javadoc)
+                * 
+                * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent)
+                */
+               public void propertyChange(PropertyChangeEvent event) {
+                       // have to do it this way so others can override the method
+                       handlePropertyChange(event);
+               }
+       };
+       
+       public LineStyleProviderForJSDT() {
+               super();
+               fScanner = new JSDTCodeScanner();
+       }
+       
+       /**
+        * Looks up the colorKey in the preference store and adds the style
+        * information to list of TextAttributes
+        * 
+        * @param colorKey
+        */
+       protected void addTextAttribute(String colorKey) {
+               IPreferenceStore javaStore = getJavaColorPreferences();
+               if (javaStore != null && colorKey != null) {
+                       TextAttribute ta = null;
+                       if (colorKey == IStyleConstantsJSDT.JAVA_KEYWORD) {
+                               // keyword
+                               RGB foreground = PreferenceConverter.getColor(javaStore, PreferenceConstants.EDITOR_JAVA_KEYWORD_COLOR);
+                               boolean bold = javaStore.getBoolean(PreferenceConstants.EDITOR_JAVA_KEYWORD_BOLD);
+                               boolean italics = javaStore.getBoolean(PreferenceConstants.EDITOR_JAVA_KEYWORD_ITALIC);
+                               boolean strikethrough = javaStore.getBoolean(PreferenceConstants.EDITOR_JAVA_KEYWORD_STRIKETHROUGH);
+                               boolean underline = javaStore.getBoolean(PreferenceConstants.EDITOR_JAVA_KEYWORD_UNDERLINE);
+                               int style = SWT.NORMAL;
+                               if (bold) {
+                                       style = style | SWT.BOLD;
+                               }
+                               if (italics) {
+                                       style = style | SWT.ITALIC;
+                               }
+                               if (strikethrough) {
+                                       style = style | TextAttribute.STRIKETHROUGH;
+                               }
+                               if (underline) {
+                                       style = style | TextAttribute.UNDERLINE;
+                               }
+                               ta = createTextAttribute(foreground, null, style);
+                       } else if (colorKey == IStyleConstantsJSDT.JAVA_STRING) {
+                               // string
+                               RGB foreground = PreferenceConverter.getColor(javaStore, PreferenceConstants.EDITOR_STRING_COLOR);
+                               boolean bold = javaStore.getBoolean(PreferenceConstants.EDITOR_STRING_BOLD);
+                               boolean italics = javaStore.getBoolean(PreferenceConstants.EDITOR_STRING_ITALIC);
+                               boolean strikethrough = javaStore.getBoolean(PreferenceConstants.EDITOR_STRING_STRIKETHROUGH);
+                               boolean underline = javaStore.getBoolean(PreferenceConstants.EDITOR_STRING_UNDERLINE);
+                               int style = SWT.NORMAL;
+                               if (bold) {
+                                       style = style | SWT.BOLD;
+                               }
+                               if (italics) {
+                                       style = style | SWT.ITALIC;
+                               }
+                               if (strikethrough) {
+                                       style = style | TextAttribute.STRIKETHROUGH;
+                               }
+                               if (underline) {
+                                       style = style | TextAttribute.UNDERLINE;
+                               }
+                               ta = createTextAttribute(foreground, null, style);
+                       } else if (colorKey == IStyleConstantsJSDT.JAVA_SINGLE_LINE_COMMENT) {
+                               // single line comment
+                               RGB foreground = PreferenceConverter.getColor(javaStore, PreferenceConstants.EDITOR_SINGLE_LINE_COMMENT_COLOR);
+                               boolean bold = javaStore.getBoolean(PreferenceConstants.EDITOR_SINGLE_LINE_COMMENT_BOLD);
+                               boolean italics = javaStore.getBoolean(PreferenceConstants.EDITOR_SINGLE_LINE_COMMENT_ITALIC);
+                               boolean strikethrough = javaStore.getBoolean(PreferenceConstants.EDITOR_SINGLE_LINE_COMMENT_STRIKETHROUGH);
+                               boolean underline = javaStore.getBoolean(PreferenceConstants.EDITOR_SINGLE_LINE_COMMENT_UNDERLINE);
+                               int style = SWT.NORMAL;
+                               if (bold) {
+                                       style = style | SWT.BOLD;
+                               }
+                               if (italics) {
+                                       style = style | SWT.ITALIC;
+                               }
+                               if (strikethrough) {
+                                       style = style | TextAttribute.STRIKETHROUGH;
+                               }
+                               if (underline) {
+                                       style = style | TextAttribute.UNDERLINE;
+                               }
+                               ta = createTextAttribute(foreground, null, style);
+                       } else if (colorKey == IStyleConstantsJSDT.JAVA_MULTI_LINE_COMMENT) {
+                               // multi line comment
+                               RGB foreground = PreferenceConverter.getColor(javaStore, PreferenceConstants.EDITOR_MULTI_LINE_COMMENT_COLOR);
+                               boolean bold = javaStore.getBoolean(PreferenceConstants.EDITOR_MULTI_LINE_COMMENT_BOLD);
+                               boolean italics = javaStore.getBoolean(PreferenceConstants.EDITOR_MULTI_LINE_COMMENT_ITALIC);
+                               boolean strikethrough = javaStore.getBoolean(PreferenceConstants.EDITOR_MULTI_LINE_COMMENT_STRIKETHROUGH);
+                               boolean underline = javaStore.getBoolean(PreferenceConstants.EDITOR_MULTI_LINE_COMMENT_UNDERLINE);
+                               int style = SWT.NORMAL;
+                               if (bold) {
+                                       style = style | SWT.BOLD;
+                               }
+                               if (italics) {
+                                       style = style | SWT.ITALIC;
+                               }
+                               if (strikethrough) {
+                                       style = style | TextAttribute.STRIKETHROUGH;
+                               }
+                               if (underline) {
+                                       style = style | TextAttribute.UNDERLINE;
+                               }
+                               ta = createTextAttribute(foreground, null, style);
+                       } else if (colorKey == IStyleConstantsJSDT.JAVA_DEFAULT) {
+                               // default
+                               RGB foreground = PreferenceConverter.getColor(javaStore, PreferenceConstants.EDITOR_JAVA_DEFAULT_COLOR);
+                               boolean bold = javaStore.getBoolean(PreferenceConstants.EDITOR_JAVA_DEFAULT_BOLD);
+                               boolean italics = javaStore.getBoolean(PreferenceConstants.EDITOR_JAVA_DEFAULT_ITALIC);
+                               boolean strikethrough = javaStore.getBoolean(PreferenceConstants.EDITOR_JAVA_DEFAULT_STRIKETHROUGH);
+                               boolean underline = javaStore.getBoolean(PreferenceConstants.EDITOR_JAVA_DEFAULT_UNDERLINE);
+                               int style = SWT.NORMAL;
+                               if (bold) {
+                                       style = style | SWT.BOLD;
+                               }
+                               if (italics) {
+                                       style = style | SWT.ITALIC;
+                               }
+                               if (strikethrough) {
+                                       style = style | TextAttribute.STRIKETHROUGH;
+                               }
+                               if (underline) {
+                                       style = style | TextAttribute.UNDERLINE;
+                               }
+                               ta = createTextAttribute(foreground, null, style);
+                       } else if(colorKey == IStyleConstantsXML.COMMENT_BORDER ||
+                                       colorKey == IStyleConstantsJs.JSP_CONTENT) {
+                               
+                               /** @see AbstractLineStyleProvider#addTextAttribute */
+                               ta = (TextAttribute)getTextAttributes().get(colorKey);
+                               String prefString = getHTMLColorPreferences().getString(colorKey);
+                               String[] stylePrefs = ColorHelper.unpackStylePreferences(prefString);
+                               if (stylePrefs != null) {
+                                       RGB foreground = ColorHelper.toRGB(stylePrefs[0]);
+                                       RGB background = ColorHelper.toRGB(stylePrefs[1]);
+                                       boolean bold = Boolean.valueOf(stylePrefs[2]).booleanValue();
+                                       boolean italic = Boolean.valueOf(stylePrefs[3]).booleanValue();
+                                       boolean strikethrough = Boolean.valueOf(stylePrefs[4]).booleanValue();
+                                       boolean underline = Boolean.valueOf(stylePrefs[5]).booleanValue();
+                                       int style = SWT.NORMAL;
+                                       if (bold) {
+                                               style = style | SWT.BOLD;
+                                       }
+                                       if (italic) {
+                                               style = style | SWT.ITALIC;
+                                       }
+                                       if (strikethrough) {
+                                               style = style | TextAttribute.STRIKETHROUGH;
+                                       }
+                                       if (underline) {
+                                               style = style | TextAttribute.UNDERLINE;
+                                       }
+
+                                       ta = createTextAttribute(foreground, background, style);
+                               }
+                       }
+                       if (ta != null) {
+                               getTextAttributes().put(colorKey, ta);
+                               fScanner.setTokenData(colorKey, ta);
+                       }
+               }
+       }
+       
+       /**
+        * Adds style information to the given text presentation.
+        * 
+        * @param presentation
+        *            the text presentation to be extended
+        * @param offset
+        *            the offset of the range to be styled
+        * @param length
+        *            the length of the range to be styled
+        * @param attr
+        *            the attribute describing the style of the range to be styled
+        */
+       private void addRange(Collection presentation, int offset, int length, TextAttribute attr) {
+               // support for user defined backgroud for JSP scriptlet regions
+               TextAttribute ta = (TextAttribute) getTextAttributes().get(IStyleConstantsJs.JSP_CONTENT);
+               Color bgColor = ta.getBackground();
+               if (bgColor == null) {
+                       bgColor = attr.getBackground();
+               }
+               StyleRange result = new StyleRange(offset, length, attr.getForeground(), bgColor, attr.getStyle());
+               if ((attr.getStyle() & TextAttribute.STRIKETHROUGH) != 0) {
+                       result.strikeout = true;
+               }
+               if ((attr.getStyle() & TextAttribute.UNDERLINE) != 0) {
+                       result.underline = true;
+               }
+               presentation.add(result);
+       }
+       
+       protected IPreferenceStore getColorPreferences() {
+               return JsUIPlugin.getDefault().getPreferenceStore();
+       }
+       
+       private IPreferenceStore getJavaColorPreferences() {
+               return PreferenceConstants.getPreferenceStore();
+       }
+       
+       private IPreferenceStore getHTMLColorPreferences() {
+               return HTMLUIPlugin.getDefault().getPreferenceStore();
+       }
+       
+       /**
+        * Returns a text attribute encoded in the given token. If the token's data
+        * is not <code>null</code> and a text attribute it is assumed that it is
+        * the encoded text attribute. It returns the default text attribute if
+        * there is no encoded text attribute found.
+        * 
+        * @param token
+        *            the token whose text attribute is to be determined
+        * @return the token's text attribute
+        */
+       private TextAttribute getTokenTextAttribute(IToken token) {
+               TextAttribute ta = null;
+               Object data = token.getData();
+               if (data instanceof TextAttribute) {
+                       ta = (TextAttribute) data;
+               } else {
+                       ta = (TextAttribute) getTextAttributes().get(IStyleConstantsJSDT.JAVA_DEFAULT);
+               }
+               return ta;
+       }
+       
+       protected void handlePropertyChange(PropertyChangeEvent event) {
+               String styleKey = null;
+               if (event != null) {
+                       String prefKey = event.getProperty();
+                       // check if preference changed is a style preference
+                       if(IStyleConstantsXML.COMMENT_BORDER.equals(prefKey)) {
+                               styleKey = IStyleConstantsXML.COMMENT_BORDER;
+                       } else if(IStyleConstantsXML.COMMENT_TEXT.equals(prefKey)) {
+                               styleKey = IStyleConstantsXML.COMMENT_TEXT;
+                       } else if (PreferenceConstants.EDITOR_JAVA_KEYWORD_COLOR.equals(prefKey) || (PreferenceConstants.EDITOR_JAVA_KEYWORD_BOLD.equals(prefKey)) || (PreferenceConstants.EDITOR_JAVA_KEYWORD_ITALIC.equals(prefKey))) {
+                               styleKey = IStyleConstantsJSDT.JAVA_KEYWORD;
+                       } else if (PreferenceConstants.EDITOR_STRING_COLOR.equals(prefKey) || (PreferenceConstants.EDITOR_STRING_BOLD.equals(prefKey)) || (PreferenceConstants.EDITOR_STRING_ITALIC.equals(prefKey))) {
+                               styleKey = IStyleConstantsJSDT.JAVA_STRING;
+                       } else if (PreferenceConstants.EDITOR_SINGLE_LINE_COMMENT_COLOR.equals(prefKey) || (PreferenceConstants.EDITOR_SINGLE_LINE_COMMENT_BOLD.equals(prefKey)) || (PreferenceConstants.EDITOR_SINGLE_LINE_COMMENT_ITALIC.equals(prefKey))) {
+                               styleKey = IStyleConstantsJSDT.JAVA_SINGLE_LINE_COMMENT;
+                       } else if (PreferenceConstants.EDITOR_MULTI_LINE_COMMENT_COLOR.equals(prefKey) || (PreferenceConstants.EDITOR_MULTI_LINE_COMMENT_BOLD.equals(prefKey)) || (PreferenceConstants.EDITOR_MULTI_LINE_COMMENT_ITALIC.equals(prefKey))) {
+                               styleKey = IStyleConstantsJSDT.JAVA_MULTI_LINE_COMMENT;
+                       } else if (PreferenceConstants.EDITOR_JAVA_DEFAULT_COLOR.equals(prefKey) || (PreferenceConstants.EDITOR_JAVA_DEFAULT_BOLD.equals(prefKey)) || (PreferenceConstants.EDITOR_JAVA_DEFAULT_ITALIC.equals(prefKey))) {
+                               styleKey = IStyleConstantsJSDT.JAVA_DEFAULT;
+                       }
+               }
+               if (styleKey != null) {
+                       // overwrite style preference with new value
+                       addTextAttribute(styleKey);
+                       fRecHighlighter.refreshDisplay();
+                       fScanner.initializeRules();
+               }
+       }
+       
+       protected void loadColors() {
+               addTextAttribute(IStyleConstantsXML.COMMENT_BORDER);
+               addTextAttribute(IStyleConstantsXML.COMMENT_TEXT);
+               addTextAttribute(IStyleConstantsJs.JSP_CONTENT);
+               addTextAttribute(IStyleConstantsJSDT.JAVA_KEYWORD);
+               addTextAttribute(IStyleConstantsJSDT.JAVA_STRING);
+               addTextAttribute(IStyleConstantsJSDT.JAVA_SINGLE_LINE_COMMENT);
+               addTextAttribute(IStyleConstantsJSDT.JAVA_MULTI_LINE_COMMENT);
+               addTextAttribute(IStyleConstantsJSDT.JAVA_DEFAULT);
+               fScanner.initializeRules();
+       }
+       
+       public boolean prepareRegions(ITypedRegion typedRegion, int ssssrequestedStart, int ssssrequestedLength, Collection holdResults) {
+               boolean result = true;
+               /* Initialize the text attributes. Also load the colors and initialize the rules of the scanner */
+               getTextAttributes();
+               try {
+                       // ideally, eventually, we'll have a "virtualDocument" we can
+                       // refer to, but for now ... we'll simple rescan the one region.
+                       // use simple adjustment (since "sub-content" starts at 0
+                       int lastStart = typedRegion.getOffset();
+                       int length = 0;
+                       IToken lastToken = Token.UNDEFINED;
+                       fScanner.setRange(getDocument(), lastStart, typedRegion.getLength());
+                       while (true) {
+                               IToken token = fScanner.nextToken();
+                               if (token.isEOF()) {
+                                       if (!lastToken.isUndefined() && length != 0) {
+                                               addRange(holdResults, lastStart, length, getTokenTextAttribute(lastToken));
+                                       }
+                                       break;
+                               }
+                               if (token.isWhitespace()) {
+                                       length += fScanner.getTokenLength();
+                                       continue;
+                               }
+                               if (lastToken.isUndefined()) {
+                                       lastToken = token;
+                                       length += fScanner.getTokenLength();
+                                       continue;
+                               }
+                               if (token != lastToken) {
+                                       addRange(holdResults, lastStart, length, getTokenTextAttribute(lastToken));
+                                       lastToken = token;
+                                       lastStart = fScanner.getTokenOffset();
+                                       length = fScanner.getTokenLength();
+                                       continue;
+                               }
+                               length += fScanner.getTokenLength();
+                       }
+               } catch (Exception e) {
+                       // shouldn't happen, but we don't want it to stop other
+                       // highlighting, if it does.
+                       result = false;
+               }
+               return result;
+       }
+
+       protected TextAttribute getAttributeFor(ITextRegion region) {
+               return null;
+       }
+       
+       protected void registerPreferenceManager() {
+               getColorPreferences().addPropertyChangeListener(fPreferenceListener);
+               getJavaColorPreferences().addPropertyChangeListener(fPreferenceListener);
+               this.getHTMLColorPreferences().addPropertyChangeListener(fPreferenceListener);
+       }
+       
+       public void release() {
+               super.release();
+               fScanner = null;
+       }
+       
+       protected void unRegisterPreferenceManager() {
+               getColorPreferences().removePropertyChangeListener(fPreferenceListener);
+               getJavaColorPreferences().removePropertyChangeListener(fPreferenceListener);
+               this.getHTMLColorPreferences().removePropertyChangeListener(fPreferenceListener);
+       }
+}
\ No newline at end of file
diff --git a/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/taginfo/HTMLPrinter.java b/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/taginfo/HTMLPrinter.java
new file mode 100644 (file)
index 0000000..bd00e78
--- /dev/null
@@ -0,0 +1,203 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.web.ui.internal.taginfo;
+
+import java.io.IOException;
+import java.io.Reader;
+import java.net.URL;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.SWTError;
+import org.eclipse.swt.graphics.RGB;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.wst.jsdt.web.ui.internal.Logger;
+
+/**
+*
+
+* Provisional API: This class/interface is part of an interim API that is still under development and expected to
+* change significantly before reaching stability. It is being made available at this early stage to solicit feedback
+* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
+* (repeatedly) as the API evolves.
+*/
+class HTMLPrinter {
+       static RGB BG_COLOR_RGB = null;
+       static {
+               final Display display = Display.getDefault();
+               if (display != null && !display.isDisposed()) {
+                       try {
+                               display.asyncExec(new Runnable() {
+                                       /*
+                                        * @see java.lang.Runnable#run()
+                                        */
+                                       public void run() {
+                                               HTMLPrinter.BG_COLOR_RGB = display.getSystemColor(SWT.COLOR_INFO_BACKGROUND).getRGB();
+                                       }
+                               });
+                       } catch (SWTError err) {
+                               // see: https://bugs.eclipse.org/bugs/show_bug.cgi?id=45294
+                               if (err.code != SWT.ERROR_DEVICE_DISPOSED) {
+                                       throw err;
+                               }
+                       }
+               }
+       }
+       
+       public static void addBullet(StringBuffer buffer, String bullet) {
+               if (bullet != null) {
+                       buffer.append("<li>"); //$NON-NLS-1$
+                       buffer.append(bullet);
+                       buffer.append("</li>"); //$NON-NLS-1$
+               }
+       }
+       
+       public static void addPageEpilog(StringBuffer buffer) {
+               buffer.append("</font></body></html>"); //$NON-NLS-1$
+       }
+       
+       public static void addPageProlog(StringBuffer buffer) {
+               HTMLPrinter.insertPageProlog(buffer, buffer.length());
+       }
+       
+       public static void addParagraph(StringBuffer buffer, Reader paragraphReader) {
+               if (paragraphReader != null) {
+                       HTMLPrinter.addParagraph(buffer, HTMLPrinter.read(paragraphReader));
+               }
+       }
+       
+       public static void addParagraph(StringBuffer buffer, String paragraph) {
+               if (paragraph != null) {
+                       buffer.append("<p>"); //$NON-NLS-1$
+                       buffer.append(paragraph);
+               }
+       }
+       
+       public static void addSmallHeader(StringBuffer buffer, String header) {
+               if (header != null) {
+                       buffer.append("<h5>"); //$NON-NLS-1$
+                       buffer.append(header);
+                       buffer.append("</h5>"); //$NON-NLS-1$
+               }
+       }
+       
+       private static void appendColor(StringBuffer buffer, RGB rgb) {
+               buffer.append('#');
+               buffer.append(Integer.toHexString(rgb.red));
+               buffer.append(Integer.toHexString(rgb.green));
+               buffer.append(Integer.toHexString(rgb.blue));
+       }
+       
+       private static void appendStyleSheetLink(StringBuffer buffer, URL styleSheetURL) {
+               if (styleSheetURL == null) {
+                       return;
+               }
+               buffer.append("<head>"); //$NON-NLS-1$
+               buffer.append("<LINK REL=\"stylesheet\" HREF= \""); //$NON-NLS-1$
+               buffer.append(styleSheetURL);
+               buffer.append("\" CHARSET=\"ISO-8859-1\" TYPE=\"text/css\">"); //$NON-NLS-1$
+               buffer.append("</head>"); //$NON-NLS-1$
+       }
+       
+       public static String convertToHTMLContent(String content) {
+               content = HTMLPrinter.replace(content, '&', "&amp;"); //$NON-NLS-1$
+               content = HTMLPrinter.replace(content, '"', "&quot;"); //$NON-NLS-1$
+               content = HTMLPrinter.replace(content, '<', "&lt;"); //$NON-NLS-1$
+               return HTMLPrinter.replace(content, '>', "&gt;"); //$NON-NLS-1$
+       }
+       
+       public static void endBulletList(StringBuffer buffer) {
+               buffer.append("</ul>"); //$NON-NLS-1$
+       }
+       
+       private static RGB getBgColor() {
+               if (HTMLPrinter.BG_COLOR_RGB != null) {
+                       return HTMLPrinter.BG_COLOR_RGB;
+               }
+               // RGB value of info bg color on WindowsXP
+               return new RGB(255, 255, 225);
+       }
+       
+       public static void insertPageProlog(StringBuffer buffer, int position) {
+               HTMLPrinter.insertPageProlog(buffer, position, HTMLPrinter.getBgColor());
+       }
+       
+       public static void insertPageProlog(StringBuffer buffer, int position, RGB bgRGB) {
+               if (bgRGB == null) {
+                       HTMLPrinter.insertPageProlog(buffer, position);
+               } else {
+                       StringBuffer pageProlog = new StringBuffer(60);
+                       pageProlog.append("<html><body text=\"#000000\" bgcolor=\""); //$NON-NLS-1$
+                       HTMLPrinter.appendColor(pageProlog, bgRGB);
+                       pageProlog.append("\"><font size=-1>"); //$NON-NLS-1$
+                       buffer.insert(position, pageProlog.toString());
+               }
+       }
+       
+       public static void insertPageProlog(StringBuffer buffer, int position, RGB bgRGB, URL styleSheetURL) {
+               if (bgRGB == null) {
+                       HTMLPrinter.insertPageProlog(buffer, position, styleSheetURL);
+               } else {
+                       StringBuffer pageProlog = new StringBuffer(300);
+                       pageProlog.append("<html>"); //$NON-NLS-1$
+                       HTMLPrinter.appendStyleSheetLink(pageProlog, styleSheetURL);
+                       pageProlog.append("<body text=\"#000000\" bgcolor=\""); //$NON-NLS-1$
+                       HTMLPrinter.appendColor(pageProlog, bgRGB);
+                       pageProlog.append("\"><font size=-1>"); //$NON-NLS-1$
+                       buffer.insert(position, pageProlog.toString());
+               }
+       }
+       
+       public static void insertPageProlog(StringBuffer buffer, int position, URL styleSheetURL) {
+               HTMLPrinter.insertPageProlog(buffer, position, HTMLPrinter.getBgColor(), styleSheetURL);
+       }
+       
+       static String read(Reader rd) {
+               StringBuffer buffer = new StringBuffer();
+               char[] readBuffer = new char[2048];
+               try {
+                       int n = rd.read(readBuffer);
+                       while (n > 0) {
+                               buffer.append(readBuffer, 0, n);
+                               n = rd.read(readBuffer);
+                       }
+                       return buffer.toString();
+               } catch (IOException x) {
+                       // never expected
+                       Logger.log(Logger.WARNING_DEBUG, x.getMessage(), x);
+               }
+               return null;
+       }
+       
+       private static String replace(String text, char c, String s) {
+               int previous = 0;
+               int current = text.indexOf(c, previous);
+               if (current == -1) {
+                       return text;
+               }
+               StringBuffer buffer = new StringBuffer();
+               while (current > -1) {
+                       buffer.append(text.substring(previous, current));
+                       buffer.append(s);
+                       previous = current + 1;
+                       current = text.indexOf(c, previous);
+               }
+               buffer.append(text.substring(previous));
+               return buffer.toString();
+       }
+       
+       public static void startBulletList(StringBuffer buffer) {
+               buffer.append("<ul>"); //$NON-NLS-1$
+       }
+       
+       private HTMLPrinter() {
+       // nothing
+       }
+}
diff --git a/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/taginfo/JSDTHoverProcessor.java b/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/taginfo/JSDTHoverProcessor.java
new file mode 100644 (file)
index 0000000..d5e1669
--- /dev/null
@@ -0,0 +1,167 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2009 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.web.ui.internal.taginfo;
+
+import java.io.Reader;
+
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.ITextViewer;
+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.ui.JSdocContentAccess;
+import org.eclipse.wst.jsdt.ui.JavaScriptElementLabels;
+import org.eclipse.wst.jsdt.web.core.javascript.IJsTranslation;
+import org.eclipse.wst.jsdt.web.core.javascript.JsTranslationAdapter;
+import org.eclipse.wst.sse.core.StructuredModelManager;
+import org.eclipse.wst.sse.ui.internal.taginfo.AbstractHoverProcessor;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
+
+/**
+*
+
+* Provisional API: This class/interface is part of an interim API that is still under development and expected to
+* change significantly before reaching stability. It is being made available at this early stage to solicit feedback
+* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
+* (repeatedly) as the API evolves.
+*/
+public class JSDTHoverProcessor extends AbstractHoverProcessor {
+       /*
+        * Bulk of the work was copied from
+        * org.eclipse.wst.jsdt.internal.ui.text.java.hover.JavadocHover
+        */
+       private 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.M_PRE_TYPE_PARAMETERS | JavaScriptElementLabels.T_TYPE_PARAMETERS | JavaScriptElementLabels.USE_RESOLVED;
+       private final long LOCAL_VARIABLE_FLAGS = LABEL_FLAGS & ~JavaScriptElementLabels.F_FULLY_QUALIFIED | JavaScriptElementLabels.F_POST_QUALIFIED;
+       
+       private String getHoverInfo(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 || curr.getElementType() == IJavaScriptElement.LOCAL_VARIABLE) {
+                                       HTMLPrinter.addBullet(buffer, getInfoText(curr));
+                               }
+                               HTMLPrinter.endBulletList(buffer);
+                       }
+               } else {
+                       IJavaScriptElement curr = result[0];
+                       if (curr == null) {
+                               return null;
+                       }
+                       if (curr instanceof IMember) {
+                               IMember member = (IMember) curr;
+                               HTMLPrinter.addSmallHeader(buffer, getInfoText(member));
+                               Reader reader;
+                               try {
+                                       reader = JSdocContentAccess.getHTMLContentReader(member, true, true);
+                               } catch (JavaScriptModelException ex) {
+                                       return null;
+                               }
+                               if (reader != null) {
+                                       HTMLPrinter.addParagraph(buffer, reader);
+                               }
+                       } else if (curr.getElementType() == IJavaScriptElement.LOCAL_VARIABLE) {
+                               HTMLPrinter.addSmallHeader(buffer, getInfoText(curr));
+                       }
+               }
+               if (buffer.length() > 0) {
+                       HTMLPrinter.insertPageProlog(buffer, 0);
+                       HTMLPrinter.addPageEpilog(buffer);
+                       return buffer.toString();
+               }
+               return null;
+       }
+       
+       /*
+        * (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 hoverRegion) {
+               // get JSP translation object for this viewer's document
+               IDOMModel xmlModel = null;
+               try {
+                       xmlModel = (IDOMModel) StructuredModelManager.getModelManager().getExistingModelForRead(textViewer.getDocument());
+                       if (xmlModel != null) {
+                               IDOMDocument xmlDoc = xmlModel.getDocument();
+                               JsTranslationAdapter adapter = (JsTranslationAdapter) xmlDoc.getAdapterFor(IJsTranslation.class);
+                               if (adapter != null) {
+                                       IJsTranslation translation = adapter.getJsTranslation(true);
+                                       IJavaScriptElement[] result = translation.getElementsFromJsRange(hoverRegion.getOffset(), hoverRegion.getOffset() + hoverRegion.getLength());
+// Vector filteredResults = new Vector();
+// List badFunctions = translation.getGeneratedFunctionNames();
+// boolean bad = false;
+// for(int i = 0;i<result.length;i++){
+// bad=false;
+// if(result[i] instanceof IFunction){
+// for(int j=0;j<badFunctions.size() && ! bad;j++){
+// if(((IFunction)result[i]).getElementName().equalsIgnoreCase((String)badFunctions.get(j))){
+// bad=true;
+// continue;
+// }
+// }
+// if(!bad)filteredResults.add(result[i]);
+// }
+// }
+// if(filteredResults.size()<1) return new String();
+//                                     
+// String filteredResult =
+// translation.fixupMangledName(getHoverInfo((IJavaScriptElement[])filteredResults.toArray(new
+// IJavaScriptElement[]{})));
+// for(int i = 0;i<badFunctions.size();i++){
+// filteredResult.replace((String)badFunctions.get(i), "");
+// }
+// return filteredResult;
+                                       return translation.fixupMangledName(getHoverInfo(result));
+                               }
+                       }
+               } finally {
+                       if (xmlModel != null) {
+                               xmlModel.releaseFromRead();
+                       }
+               }
+               return null;
+       }
+       
+       /*
+        * (non-Javadoc)
+        * 
+        * @see org.eclipse.jface.text.ITextHover#getHoverRegion(org.eclipse.jface.text.ITextViewer,
+        *      int)
+        */
+       public IRegion getHoverRegion(ITextViewer textViewer, int offset) {
+               return JsWordFinder.findWord(textViewer.getDocument(), offset);
+       }
+       
+       private String getInfoText(IJavaScriptElement member) {
+               long flags = member.getElementType() == IJavaScriptElement.LOCAL_VARIABLE ? LOCAL_VARIABLE_FLAGS : LABEL_FLAGS;
+               String label = JavaScriptElementLabels.getElementLabel(member, flags);
+               StringBuffer buf = new StringBuffer();
+               for (int i = 0; i < label.length(); i++) {
+                       char ch = label.charAt(i);
+                       if (ch == '<') {
+                               buf.append("&lt;"); //$NON-NLS-1$
+                       } else if (ch == '>') {
+                               buf.append("&gt;"); //$NON-NLS-1$
+                       } else {
+                               buf.append(ch);
+                       }
+               }
+               return buf.toString();
+       }
+}
diff --git a/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/taginfo/JsWordFinder.java b/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/taginfo/JsWordFinder.java
new file mode 100644 (file)
index 0000000..b9311af
--- /dev/null
@@ -0,0 +1,71 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.web.ui.internal.taginfo;
+
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.Region;
+
+/**
+*
+
+* Provisional API: This class/interface is part of an interim API that is still under development and expected to
+* change significantly before reaching stability. It is being made available at this early stage to solicit feedback
+* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
+* (repeatedly) as the API evolves.
+*/
+class JsWordFinder {
+       public static IRegion findWord(IDocument document, int offset) {
+               int start = -1;
+               int end = -1;
+               try {
+                       int pos = offset;
+                       char c;
+                       while (pos >= 0) {
+                               c = document.getChar(pos);
+                               // System.out.println("JavaWordFinder.findWord() Test java char
+                               // (--):" + c);
+                               if (!Character.isJavaIdentifierPart(c)) {
+                                       break;
+                               }
+                               --pos;
+                       }
+                       start = pos;
+                       pos = offset;
+                       int length = document.getLength();
+                       while (pos < length) {
+                               c = document.getChar(pos);
+                               // System.out.println("JavaWordFinder.findWord() Test java char
+                               // (++):" + c);
+                               if (!Character.isJavaIdentifierPart(c)) {
+                                       break;
+                               }
+                               ++pos;
+                       }
+                       end = pos;
+                       // System.out.println("Start:" + start + "End:"+end);
+                       // System.out.println("JavaWordFinder.findWord() Retrieved java
+                       // token of:" + document.get(start, end-start) );
+               } catch (BadLocationException x) {
+               }
+               if (start > -1 && end > -1) {
+                       if (start == offset && end == offset) {
+                               return new Region(offset, 0);
+                       } else if (start == offset) {
+                               return new Region(start, end - start);
+                       } else {
+                               return new Region(start + 1, end - start - 1);
+                       }
+               }
+               return null;
+       }
+}
diff --git a/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/text/JsCharacterPairInserter.java b/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/text/JsCharacterPairInserter.java
new file mode 100644 (file)
index 0000000..38d02d7
--- /dev/null
@@ -0,0 +1,293 @@
+/*******************************************************************************
+ * Copyright (c) 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.web.ui.internal.text;
+
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
+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.ExitFlags;
+import org.eclipse.jface.text.link.LinkedModeUI.IExitPolicy;
+import org.eclipse.jface.text.source.ISourceViewer;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.VerifyEvent;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.wst.jsdt.core.JavaScriptCore;
+import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
+import org.eclipse.wst.jsdt.internal.ui.text.JavaHeuristicScanner;
+import org.eclipse.wst.jsdt.internal.ui.text.Symbols;
+import org.eclipse.wst.jsdt.ui.PreferenceConstants;
+import org.eclipse.wst.jsdt.web.ui.internal.Logger;
+import org.eclipse.wst.sse.ui.typing.AbstractCharacterPairInserter;
+
+/**
+ * <p>Inserts character pairs in script regions in HTML and JSP documents based on the Javascript
+ * character pairing preferences.</p>
+ */
+public class JsCharacterPairInserter extends AbstractCharacterPairInserter implements IPropertyChangeListener{
+
+       private boolean fCloseStrings;
+       private boolean fCloseBrackets;
+       private boolean fCloseBraces;
+       private boolean fCloseAngularBrackets;
+       
+       /**
+        * @see org.eclipse.wst.sse.ui.typing.AbstractCharacterPairInserter#hasPair(char)
+        */
+       public boolean hasPair(char c) {
+               switch (c) {
+                       case '(':
+                       case '<':
+                       case '[':
+                       case '\'':
+                       case '\"':
+                       case '{':
+                               return true;
+                       default:
+                               return false;
+               }
+       }
+       
+       /**
+        * @see org.eclipse.wst.sse.ui.typing.AbstractCharacterPairInserter#shouldPair(org.eclipse.jface.text.source.ISourceViewer, char)
+        */
+       protected boolean shouldPair(ISourceViewer viewer, char c) {
+               IDocument document= viewer.getDocument();
+
+               final Point selection= viewer.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 (c) {
+                               case '(':
+                                       if (!fCloseBrackets
+                                                       || nextToken == Symbols.TokenLPAREN
+                                                       || nextToken == Symbols.TokenIDENT
+                                                       || next != null && next.length() > 1)
+                                               return false;
+                                       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 false;
+                                       break;
+
+                               case '{':
+                                       if (!fCloseBraces
+                                                       || nextToken == Symbols.TokenIDENT
+                                                       || next != null && next.length() > 1)
+                                               return false;
+                                       break;
+                               case '[':
+                                       if (!fCloseBrackets
+                                                       || nextToken == Symbols.TokenIDENT
+                                                       || next != null && next.length() > 1)
+                                               return false;
+                                       break;
+
+                               case '\'':
+                               case '"':
+                                       if (!fCloseStrings
+                                                       || nextToken == Symbols.TokenIDENT
+                                                       || prevToken == Symbols.TokenIDENT
+                                                       || next != null && next.length() > 1
+                                                       || previous != null && previous.length() > 1)
+                                               return false;
+                                       break;
+
+                               default:
+                                       return false;
+                       }
+               } catch (BadLocationException e) {
+                       return false;
+               }
+               
+               return true;
+       }
+       
+       /**
+        * @see org.eclipse.wst.sse.ui.typing.AbstractCharacterPairInserter#getPair(char)
+        */
+       protected char getPair(char c) {
+               switch (c) {
+                       case '(':
+                               return ')';
+                       case '<':
+                               return '>';
+                       case '[':
+                               return ']';
+                       case '{':
+                               return '}';
+                       case '\'':
+                               return c;
+                       case '\"':
+                               return c;
+                       default:
+                               throw new IllegalArgumentException();
+               }
+       }
+       
+       /**
+        * <p>Initialize the preference listener</p>
+        * 
+        * @see org.eclipse.wst.sse.ui.typing.AbstractCharacterPairInserter#initialize()
+        */
+       public void initialize() {
+               super.initialize();
+               IPreferenceStore preferenceStore = JavaScriptPlugin.getDefault().getPreferenceStore();
+               this.fCloseStrings = preferenceStore.getBoolean(PreferenceConstants.EDITOR_CLOSE_STRINGS);
+               this.fCloseBrackets = preferenceStore.getBoolean(PreferenceConstants.EDITOR_CLOSE_BRACKETS);
+               this.fCloseBraces = preferenceStore.getBoolean(PreferenceConstants.EDITOR_CLOSE_BRACES);
+               this.fCloseAngularBrackets = JavaScriptCore.VERSION_1_5.compareTo(
+                               preferenceStore.getString(JavaScriptCore.COMPILER_SOURCE)) <= 0;
+               preferenceStore.addPropertyChangeListener(this);
+       }
+       
+       /**
+        * <p>Dispose the preference listener</p>
+        * 
+        * @see org.eclipse.wst.sse.ui.typing.AbstractCharacterPairInserter#dispose()
+        */
+       public void dispose() {
+               JavaScriptPlugin.getDefault().getPreferenceStore().removePropertyChangeListener(this);
+               super.dispose();
+       }
+
+       /**
+        * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent)
+        */
+       public void propertyChange(PropertyChangeEvent event) {
+               if (PreferenceConstants.EDITOR_CLOSE_STRINGS.equals(event.getProperty())){
+                       this.fCloseStrings = ((Boolean) event.getNewValue()).booleanValue();
+               } else if (PreferenceConstants.EDITOR_CLOSE_BRACKETS.equals(event.getProperty())) {
+                       this.fCloseBrackets = ((Boolean) event.getNewValue()).booleanValue();
+               } else if (PreferenceConstants.EDITOR_CLOSE_BRACES.equals(event.getProperty())) {
+                       this.fCloseBraces = ((Boolean) event.getNewValue()).booleanValue();
+               } else if (JavaScriptCore.COMPILER_SOURCE.equals(event.getProperty())) {
+                       IPreferenceStore preferenceStore = JavaScriptPlugin.getDefault().getPreferenceStore();
+                       this.fCloseAngularBrackets = JavaScriptCore.VERSION_1_5.compareTo(preferenceStore.getString(
+                                               JavaScriptCore.COMPILER_SOURCE)) <= 0;
+               }
+       }
+       
+       /**
+        * TODO: IAN: comment me
+        * @param identifier
+        * @return
+        */
+       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.wst.sse.ui.typing.AbstractCharacterPairInserter#getExitPolicy(char, char, org.eclipse.jface.text.IDocument)
+        */
+       protected IExitPolicy getExitPolicy(char exit, char escape, IDocument document) {
+               return new ExitPolicy(exit, escape, document);
+       }
+       
+       /**
+        * <p>An exit policy that deals with a user adding a carriage return between {}.
+        * In that case rather then exiting to the exit position the linked mode is exited
+        * and the carriage return inserted.</p>
+        */
+       private static class ExitPolicy implements IExitPolicy {
+
+               /** exit character */
+               private char fExit;
+               
+               /** escape character for the exit character */
+               private char fEscape;
+               
+               /** document to execute this exit policy on */
+               private IDocument fDocument;
+
+               /**
+                * <p>Default constructor</p>
+                * 
+                * @param exit exit character
+                * @param escape escape character for the exit character
+                * @param document document to execute this exit policy on
+                */
+               public ExitPolicy(char exit, char escape, IDocument document) {
+                       fExit = exit;
+                       fEscape = escape;
+                       fDocument = document;
+               }
+
+               /**
+                * @see org.eclipse.jface.text.link.LinkedModeUI.IExitPolicy#doExit(org.eclipse.jface.text.link.LinkedModeModel, org.eclipse.swt.events.VerifyEvent, int, int)
+                */
+               public ExitFlags doExit(LinkedModeModel model, VerifyEvent event, int offset, int length) {
+                       if(!isMasked(offset)) {
+                               // if exit character then exit to exit location
+                               if (event.character == fExit) {
+                                       return new ExitFlags(ILinkedModeListener.UPDATE_CARET, false);
+                               }
+                               
+                               // if carriage return and previous character is { then exit linked mode and insert return
+                               if (event.character == SWT.CR && offset > 0) {
+                                       try {
+                                               if (this.fDocument.getChar(offset - 1) == '{') {
+                                                       return new ExitFlags(ILinkedModeListener.EXIT_ALL, true);
+                                               }
+                                       } catch (BadLocationException e) {
+                                               Logger.logException("Error while trying to exit linked mode", e); //$NON-NLS-1$
+                                       }
+                               }
+                       }
+                       return null;
+               }
+
+               /**
+                * <p>Determine if the exit character has been escaped.<p>
+                * 
+                * @param offset current offset in the document
+                * @return <code>true</code> if exit character escaped, <code>false</code> otherwise
+                */
+               private boolean isMasked(int offset) {
+                       try {
+                               return fEscape == fDocument.getChar(offset - 1);
+                       } catch (BadLocationException e) {
+                       }
+                       return false;
+               }
+       }
+}
diff --git a/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/text/JsCodeReader.java b/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/text/JsCodeReader.java
new file mode 100644 (file)
index 0000000..29937d0
--- /dev/null
@@ -0,0 +1,225 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.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 Sep 2, 2003
+ *
+ * To change the template for this generated file go to
+ * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
+ */
+package org.eclipse.wst.jsdt.web.ui.internal.text;
+
+import java.io.IOException;
+
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.wst.jsdt.web.ui.internal.derived.SingleCharReader;
+
+/**
+*
+
+* Provisional API: This class/interface is part of an interim API that is still under development and expected to
+* change significantly before reaching stability. It is being made available at this early stage to solicit feedback
+* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
+* (repeatedly) as the API evolves.
+*/
+class JsCodeReader extends SingleCharReader {
+       /** The EOF character */
+       public static final int EOF = -1;
+       private int fCachedLineNumber = -1;
+       private int fCachedLineOffset = -1;
+       private IDocument fDocument;
+       private int fEnd = -1;
+       private boolean fForward = false;
+       private int fOffset;
+       private boolean fSkipComments = false;
+       private boolean fSkipStrings = false;
+       
+       public JsCodeReader() {}
+       
+       /*
+        * @see Reader#close()
+        */
+       
+       public void close() throws IOException {
+               fDocument = null;
+       }
+       
+       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());
+               }
+       }
+       
+       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);
+       }
+       
+       /**
+        * 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;
+       }
+       
+       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 gotoCommentStart() throws BadLocationException {
+               while (0 < fOffset) {
+                       char current = fDocument.getChar(fOffset--);
+                       if (current == '*' && 0 <= fOffset && fDocument.getChar(fOffset) == '/') {
+                               return;
+                       }
+               }
+       }
+       
+       private void gotoLineEnd() throws BadLocationException {
+               int line = fDocument.getLineOfOffset(fOffset);
+               fOffset = fDocument.getLineOffset(line + 1);
+       }
+       
+       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 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 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;
+                               }
+                       }
+               }
+       }
+       
+       /*
+        * @see SingleCharReader#read()
+        */
+       
+       public int read() throws IOException {
+               try {
+                       return fForward ? readForwards() : readBackwards();
+               } catch (BadLocationException x) {
+                       throw new IOException(x.getMessage());
+               }
+       }
+       
+       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 JsCodeReader.EOF;
+       }
+       
+       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 JsCodeReader.EOF;
+       }
+}
diff --git a/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/text/JsDocumentRegionEdgeMatcher.java b/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/text/JsDocumentRegionEdgeMatcher.java
new file mode 100644 (file)
index 0000000..86c10d8
--- /dev/null
@@ -0,0 +1,34 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.web.ui.internal.text;
+
+import org.eclipse.wst.sse.ui.internal.text.DocumentRegionEdgeMatcher;
+import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext;
+/**
+*
+
+* Provisional API: This class/interface is part of an interim API that is still under development and expected to
+* change significantly before reaching stability. It is being made available at this early stage to solicit feedback
+* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
+* (repeatedly) as the API evolves.
+*/
+public class JsDocumentRegionEdgeMatcher extends DocumentRegionEdgeMatcher {
+       protected final static char[] BRACKETS = { '{', '}', '(', ')', '[', ']' };
+       
+       /**
+        * @param validContexts
+        * @param nextMatcher
+        */
+       public JsDocumentRegionEdgeMatcher() {
+               super(new String[] { DOMRegionContext.XML_TAG_NAME, DOMRegionContext.XML_COMMENT_TEXT, DOMRegionContext.XML_CDATA_TEXT, DOMRegionContext.XML_PI_OPEN,
+                               DOMRegionContext.XML_PI_CONTENT }, new JsPairMatcher(JsDocumentRegionEdgeMatcher.BRACKETS));
+       }
+}
diff --git a/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/text/JsPairMatcher.java b/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/text/JsPairMatcher.java
new file mode 100644 (file)
index 0000000..a1965a0
--- /dev/null
@@ -0,0 +1,185 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.web.ui.internal.text;
+
+import java.io.IOException;
+
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.Region;
+import org.eclipse.jface.text.source.ICharacterPairMatcher;
+
+/**
+*
+
+* Provisional API: This class/interface is part of an interim API that is still under development and expected to
+* change significantly before reaching stability. It is being made available at this early stage to solicit feedback
+* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
+* (repeatedly) as the API evolves.
+*/
+class JsPairMatcher implements ICharacterPairMatcher {
+       protected int fAnchor;
+       protected IDocument fDocument;
+       protected int fEndPos;
+       protected int fOffset;
+       protected char[] fPairs;
+       protected JsCodeReader fReader = new JsCodeReader();
+       protected int fStartPos;
+       
+       public JsPairMatcher(char[] pairs) {
+               fPairs = pairs;
+       }
+       
+       /*
+        * @see org.eclipse.jface.text.source.ICharacterPairMatcher#clear()
+        */
+       public void clear() {
+               if (fReader != null) {
+                       try {
+                               fReader.close();
+                       } catch (IOException x) {
+                               // ignore
+                       }
+               }
+       }
+       
+       /*
+        * (non-Javadoc)
+        * 
+        * @see org.eclipse.jface.text.source.ICharacterPairMatcher#dispose()
+        */
+       public void dispose() {
+               clear();
+               fDocument = null;
+               fReader = null;
+       }
+       
+       /*
+        * (non-Javadoc)
+        * 
+        * @see org.eclipse.jface.text.source.ICharacterPairMatcher#getAnchor()
+        */
+       public int getAnchor() {
+               return fAnchor;
+       }
+       
+       /*
+        * (non-Javadoc)
+        * 
+        * @see org.eclipse.jface.text.source.ICharacterPairMatcher#match(org.eclipse.jface.text.IDocument,
+        *      int)
+        */
+       public IRegion match(IDocument document, int offset) {
+               fOffset = offset;
+               if (fOffset < 0) {
+                       return null;
+               }
+               fDocument = document;
+               if (fDocument != null && matchPairsAt() && fStartPos != fEndPos) {
+                       return new Region(fStartPos, fEndPos - fStartPos + 1);
+               }
+               return null;
+       }
+       
+       protected boolean matchPairsAt() {
+               int i;
+               int pairIndex1 = fPairs.length;
+               int pairIndex2 = fPairs.length;
+               fStartPos = -1;
+               fEndPos = -1;
+               // get the chars preceding and following the start position
+               try {
+                       char prevChar = fDocument.getChar(Math.max(fOffset - 1, 0));
+                       // modified behavior for
+                       // http://dev.eclipse.org/bugs/show_bug.cgi?id=16879
+                       // char nextChar= fDocument.getChar(fOffset);
+                       // search for opening peer character next to the activation point
+                       for (i = 0; i < fPairs.length; i = i + 2) {
+                               // if (nextChar == fPairs[i]) {
+                               // fStartPos= fOffset;
+                               // pairIndex1= i;
+                               // } else
+                               if (prevChar == fPairs[i]) {
+                                       fStartPos = fOffset - 1;
+                                       pairIndex1 = i;
+                               }
+                       }
+                       // search for closing peer character next to the activation point
+                       for (i = 1; i < fPairs.length; i = i + 2) {
+                               if (prevChar == fPairs[i]) {
+                                       fEndPos = fOffset - 1;
+                                       pairIndex2 = i;
+                               }
+                               // else if (nextChar == fPairs[i]) {
+                               // fEndPos= fOffset;
+                               // pairIndex2= i;
+                               // }
+                       }
+                       if (fEndPos > -1) {
+                               fAnchor = ICharacterPairMatcher.RIGHT;
+                               fStartPos = searchForOpeningPeer(fEndPos, fPairs[pairIndex2 - 1], fPairs[pairIndex2], fDocument);
+                               if (fStartPos > -1) {
+                                       return true;
+                               } else {
+                                       fEndPos = -1;
+                               }
+                       } else if (fStartPos > -1) {
+                               fAnchor = ICharacterPairMatcher.LEFT;
+                               fEndPos = searchForClosingPeer(fStartPos, fPairs[pairIndex1], fPairs[pairIndex1 + 1], fDocument);
+                               if (fEndPos > -1) {
+                                       return true;
+                               } else {
+                                       fStartPos = -1;
+                               }
+                       }
+               } catch (BadLocationException x) {
+               } catch (IOException x) {
+               }
+               return false;
+       }
+       
+       protected int searchForClosingPeer(int offset, int openingPeer, int closingPeer, IDocument document) throws IOException {
+               fReader.configureForwardReader(document, offset + 1, document.getLength(), true, true);
+               int stack = 1;
+               int c = fReader.read();
+               while (c != JsCodeReader.EOF) {
+                       if (c == openingPeer && c != closingPeer) {
+                               stack++;
+                       } else if (c == closingPeer) {
+                               stack--;
+                       }
+                       if (stack == 0) {
+                               return fReader.getOffset();
+                       }
+                       c = fReader.read();
+               }
+               return -1;
+       }
+       
+       protected int searchForOpeningPeer(int offset, int openingPeer, int closingPeer, IDocument document) throws IOException {
+               fReader.configureBackwardReader(document, offset, true, true);
+               int stack = 1;
+               int c = fReader.read();
+               while (c != JsCodeReader.EOF) {
+                       if (c == closingPeer && c != openingPeer) {
+                               stack++;
+                       } else if (c == openingPeer) {
+                               stack--;
+                       }
+                       if (stack == 0) {
+                               return fReader.getOffset();
+                       }
+                       c = fReader.read();
+               }
+               return -1;
+       }
+}
diff --git a/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/messages.properties b/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/messages.properties
new file mode 100644 (file)
index 0000000..c6061c4
--- /dev/null
@@ -0,0 +1,11 @@
+###############################################################################
+# 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
+###############################################################################
+WebProjectJsGlobalScopeContainerInitializer.0=Web Project support for JSDT
diff --git a/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/rino.jpg b/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/rino.jpg
new file mode 100644 (file)
index 0000000..b5a6af5
Binary files /dev/null and b/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/rino.jpg differ
diff --git a/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/views/contentoutline/IJavaWebNode.java b/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/views/contentoutline/IJavaWebNode.java
new file mode 100644 (file)
index 0000000..b69918f
--- /dev/null
@@ -0,0 +1,34 @@
+/*******************************************************************************
+ * 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.web.ui.views.contentoutline;
+
+import org.eclipse.wst.jsdt.core.IJavaScriptElement;
+import org.w3c.dom.Node;
+/**
+*
+
+* Provisional API: This class/interface is part of an interim API that is still under development and expected to
+* change significantly before reaching stability. It is being made available at this early stage to solicit feedback
+* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
+* (repeatedly) as the API evolves.
+*/
+public interface IJavaWebNode {
+       public IJavaScriptElement getJavaElement();
+       
+       public Node getParentNode();
+               
+       public boolean hasChildren();
+       
+       
+}
diff --git a/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/views/contentoutline/JFaceNodeAdapterFactoryForJSDT.java b/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/views/contentoutline/JFaceNodeAdapterFactoryForJSDT.java
new file mode 100644 (file)
index 0000000..9afa956
--- /dev/null
@@ -0,0 +1,55 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.web.ui.views.contentoutline;
+
+import org.eclipse.wst.jsdt.web.ui.views.provisional.contentoutline.JsContentOutlineConfig;
+import org.eclipse.wst.sse.core.internal.provisional.INodeAdapter;
+import org.eclipse.wst.sse.core.internal.provisional.INodeAdapterFactory;
+import org.eclipse.wst.sse.core.internal.provisional.INodeNotifier;
+import org.eclipse.wst.sse.ui.internal.contentoutline.IJFaceNodeAdapter;
+import org.eclipse.wst.xml.ui.internal.contentoutline.JFaceNodeAdapterFactory;
+/**
+*
+
+* Provisional API: This class/interface is part of an interim API that is still under development and expected to
+* change significantly before reaching stability. It is being made available at this early stage to solicit feedback
+* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
+* (repeatedly) as the API evolves.
+*/
+public class JFaceNodeAdapterFactoryForJSDT extends JFaceNodeAdapterFactory {
+       public JFaceNodeAdapterFactoryForJSDT() {
+               this(IJFaceNodeAdapter.class, true);
+       }
+       
+       public JFaceNodeAdapterFactoryForJSDT(Object adapterKey, boolean registerAdapters) {
+               super(adapterKey, registerAdapters);
+       }
+       
+       
+       public INodeAdapterFactory copy() {
+               return new JFaceNodeAdapterFactoryForJSDT(getAdapterKey(), isShouldRegisterAdapter());
+       }
+       
+       
+       protected INodeAdapter createAdapter(INodeNotifier node) {
+               if (singletonAdapter == null) {
+                       // create the JFaceNodeAdapter
+                       // singletonAdapter = new JFaceNodeAdapterForJSDT(this);
+                       if (JsContentOutlineConfig.USE_ADVANCED) {
+                               singletonAdapter = new org.eclipse.wst.jsdt.web.ui.views.provisional.contentoutline.JFaceNodeAdapterForJs(this);
+                       } else {
+                               singletonAdapter = new org.eclipse.wst.jsdt.web.ui.views.contentoutline.JFaceNodeAdapterForJs(this);
+                       }
+                       initAdapter(singletonAdapter, node);
+               }
+               return singletonAdapter;
+       }
+}
diff --git a/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/views/contentoutline/JFaceNodeAdapterForJs.java b/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/views/contentoutline/JFaceNodeAdapterForJs.java
new file mode 100644 (file)
index 0000000..456ef6f
--- /dev/null
@@ -0,0 +1,398 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2009 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     bug:244839 - eugene@genuitec.com
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.web.ui.views.contentoutline;
+
+import java.util.Vector;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.jface.text.Position;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.wst.html.ui.internal.contentoutline.JFaceNodeAdapterForHTML;
+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.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.internal.core.JavaElement;
+import org.eclipse.wst.jsdt.internal.core.Member;
+import org.eclipse.wst.jsdt.internal.core.SourceRefElement;
+import org.eclipse.wst.jsdt.ui.JavaScriptElementLabelProvider;
+import org.eclipse.wst.jsdt.ui.StandardJavaScriptElementContentProvider;
+import org.eclipse.wst.jsdt.web.core.internal.Logger;
+import org.eclipse.wst.jsdt.web.core.javascript.IJsTranslation;
+import org.eclipse.wst.jsdt.web.core.javascript.JsTranslationAdapter;
+import org.eclipse.wst.sse.core.StructuredModelManager;
+import org.eclipse.wst.sse.core.internal.provisional.IModelManager;
+import org.eclipse.wst.sse.core.internal.provisional.INodeAdapter;
+import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
+import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument;
+import org.eclipse.wst.sse.ui.internal.contentoutline.IJFaceNodeAdapter;
+import org.eclipse.wst.xml.core.internal.document.NodeImpl;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
+import org.eclipse.wst.xml.ui.internal.contentoutline.JFaceNodeAdapterFactory;
+import org.w3c.dom.Node;
+/**
+*
+
+* Provisional API: This class/interface is part of an interim API that is still under development and expected to
+* change significantly before reaching stability. It is being made available at this early stage to solicit feedback
+* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
+* (repeatedly) as the API evolves.
+*/
+public class JFaceNodeAdapterForJs extends JFaceNodeAdapterForHTML {
+       
+       public JFaceNodeAdapterForJs(JFaceNodeAdapterFactory adapterFactory) {
+               super(adapterFactory);
+       }
+       
+       private IJavaScriptUnit lazyCu;
+       private IProgressMonitor monitor;
+       private JavaScriptElementLabelProvider javaElementLabelProvider;
+       
+       public Object[] getChildren(Object object) {
+               if (object instanceof IJavaScriptElement) {
+                       return getJavaElementProvider().getChildren(object);
+               }
+               if (object instanceof IJavaWebNode) {
+                       JavaElement enclosedElement = (JavaElement) ((IJavaWebNode) object).getJavaElement();
+                       if (enclosedElement != null) {
+                               try {
+                                       IJavaScriptElement[] children = enclosedElement.getChildren();
+                                       if (children == null) {
+                                               return new IJavaScriptElement[0];
+                                       }
+                                       Object[] nodes = new Object[children.length];
+                                       Node parent = ((IJavaWebNode) object).getParentNode();
+                                       
+                                       for (int i = 0; i < children.length; i++) {
+                                       //      int htmllength = ((SourceRefElement) (children[i])).getSourceRange().getLength();
+                                       //      int htmloffset = ((SourceRefElement) (children[i])).getSourceRange().getOffset();
+                                               IJavaScriptElement javaElement = children[i];
+                                               ISourceRange range = null;
+                                               if (javaElement instanceof Member) {
+                                                               range = ((IMember) javaElement).getNameRange();
+                                               } else {
+                                                               range = ((ISourceReference) javaElement).getSourceRange();
+                                               }
+                                               int htmllength = range.getLength();
+                                               int htmloffset = range.getOffset();
+
+                                               
+                                               Position position = new Position(htmloffset, htmllength);
+                                               nodes[i] = getJsNode(parent, javaElement, position);
+                                       }
+                                       return nodes;
+                               } catch (JavaScriptModelException ex) {
+                               }
+                       }
+               }
+               Node node = (Node) object;
+               if (isJSElementParent(node)) {
+                       Object[] results = getJSElementsFromNode(node.getFirstChild(), true);
+                       
+                       
+                       return filter( results );
+               }
+               return super.getChildren(object);
+       }
+       
+       /*
+        * @GINO: Anonymous -- matches anonymous types on the top level
+        */
+       protected boolean matches(Object elementObj) {
+               
+               if( elementObj instanceof IJavaWebNode ){
+                       IJavaScriptElement element = ((IJavaWebNode)elementObj).getJavaElement();
+                       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;
+       }
+
+       /*
+        * @GINO: Anonymous Filter from top level
+        *
+        */
+       protected Object[] filter(Object[] 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]);
+               }
+
+               Object[] result= new Object[v.size()];
+               v.copyInto(result);
+               return result;
+       }
+       
+       public Object[] getElements(Object object) {
+               if (object instanceof IJavaScriptElement) {
+                       return getJavaElementProvider().getElements(object);
+               }
+               return super.getElements(object);
+       }
+       
+       private JavaScriptElementLabelProvider getJavaElementLabelProvider() {
+               if(javaElementLabelProvider==null) {
+                       javaElementLabelProvider = new JavaScriptElementLabelProvider();
+               }
+               return javaElementLabelProvider;
+       }
+       
+       private StandardJavaScriptElementContentProvider getJavaElementProvider() {
+               return new StandardJavaScriptElementContentProvider(true);
+       }
+       
+       private Object[] filterChildrenForRange(IJavaScriptElement[] allChildren, Node node) {
+       //      int javaPositionStart = ((NodeImpl) node).getStartOffset();
+       //      int javaPositionEnd   = ((NodeImpl) node).getEndOffset();
+               
+       //      Object[] result =new Object[0];
+               
+               int javaPositionEnd = ((NodeImpl) node).getEndOffset();
+               int javaPositionStart = ((NodeImpl) node).getStartOffset();
+
+               Vector validChildren = new Vector();
+               for (int i = 0; i < allChildren.length; i++) {
+                       if (allChildren[i] instanceof IJavaScriptElement) {
+                               ISourceRange range = null;
+                               if (allChildren[i] instanceof Member) {
+                                       try {
+                                               range = ((Member) allChildren[i]).getNameRange();
+                                       } catch (JavaScriptModelException e) {
+                                                                                       // TODO Auto-generated catch block
+                                               e.printStackTrace();
+                                       }
+                               } else if (allChildren[i]  instanceof SourceRefElement) {
+                                       try {
+                                               range = ((SourceRefElement)allChildren[i] ).getSourceRange();
+                                       } catch (JavaScriptModelException e) {
+                                               // TODO Auto-generated catch block
+                                               e.printStackTrace();
+                                       }
+                               }
+                               if (allChildren[i].getElementType() == IJavaScriptElement.TYPE || (javaPositionStart <= range.getOffset() && range.getLength() + range.getOffset() <= (javaPositionEnd))) {
+                                       
+                                       
+                                                       int htmllength = range == null ? 0 : range.getLength();
+                                                       int htmloffset = range == null ? 0 : range.getOffset();
+                                                       if (htmllength < 0 || htmloffset < 0) {
+                                                               continue;
+                                                       }
+                                                       Position position = new Position(htmloffset, htmllength);
+                                                       validChildren.add(getJsNode(node.getParentNode(), allChildren[i], position));
+                                       
+                               
+                               }
+                       }
+               }
+               Object[] result = new Object[0];
+
+
+               if (validChildren.size() > 0) {
+                       result = validChildren.toArray();
+               }
+               if (result == null || result.length == 0) {
+                       return new IJavaScriptElement[0];
+               }
+               return result;
+       }
+       
+       private synchronized Object[] getJSElementsFromNode(Node node, boolean ensureConsistant) {
+                               
+//             int startOffset = 0;
+//             int endOffset = 0;
+//             int type = node.getNodeType();
+               Object[] result = null;
+               //JsTranslation translation = null;
+               if (node.getNodeType() == Node.TEXT_NODE && (node instanceof NodeImpl)) {
+//                     startOffset = ((NodeImpl) node).getStartOffset();
+//                     endOffset = ((NodeImpl) node).getEndOffset();
+                       IJavaScriptUnit unit = getLazyCu(node);
+               // Genuitec Begin Fix 6149: Exception opening external HTML file
+                       if (unit == null) {
+                           return new Object[0];
+                       }
+               // Genuitec End Fix 6149: Exception opening external HTML file
+                       try {
+                               if(ensureConsistant) unit.makeConsistent(getProgressMonitor());
+                       } catch (JavaScriptModelException ex1) {
+                               // TODO Auto-generated catch block
+                               ex1.printStackTrace();
+                       }
+                       try {
+                               result = filterChildrenForRange(unit.getChildren(),node);
+                       } catch (JavaScriptModelException ex) {
+                               // TODO Auto-generated catch block
+                               ex.printStackTrace();
+                               result = new Object[0];
+                               lazyCu=null;
+                       }
+                       
+                       //translation = getTranslation(node);
+                       //result = translation.getAllElementsInJsRange(startOffset, endOffset);
+               }
+               return result;
+       }
+       
+       private IProgressMonitor getProgressMonitor() {
+               if(monitor==null) {
+                       monitor = new NullProgressMonitor();
+               }
+               
+               return monitor;
+               
+       }
+       
+       private Object getJsNode(Node parent, IJavaScriptElement root, Position position) {
+               JsJfaceNode instance = null;
+               if (root.getElementType() == IJavaScriptElement.TYPE) {
+                       instance = new JsJfaceNode(parent, root, position, ((SourceRefElement) root).getElementName());
+               } else if (root.getElementType() == IJavaScriptElement.FIELD) {
+                       /* Field refrence, possibly to a type may need to implement later */
+                       instance = new JsJfaceNode(parent, root,  position);
+               } else {
+                       instance = new JsJfaceNode(parent, root, position);
+               }
+               String name = getJavaElementLabelProvider().getText(root);
+               instance.setName(name);
+               // ((JsJfaceNode)instance).setAdapterRegistry(registry);
+               INodeAdapter adapter = (instance).getAdapterFor(IJFaceNodeAdapter.class);
+               if (!(adapter instanceof JFaceNodeAdapterForJs)) {
+                       (instance).removeAdapter(adapter);
+                       (instance).addAdapter(this);
+               }
+               return instance;
+       }
+       
+       
+       public Image getLabelImage(Object node) {
+               if (node instanceof JsJfaceNode) {
+                       return ((JsJfaceNode) node).getImage();
+               }
+               if (node instanceof IJavaScriptElement) {
+                       return getJavaElementLabelProvider().getImage(node);
+               }
+               return super.getLabelImage(node);
+       }
+       
+       
+       public String getLabelText(Object node) {
+//             if (node instanceof JsJfaceNode) {
+//                     return ((JsJfaceNode) node).getName();
+//             }
+               if (node instanceof IJavaScriptElement) {
+                       return getJavaElementLabelProvider().getText(node);
+               }
+               return super.getLabelText(node);
+       }
+       
+       
+       public Object getParent(Object element) {
+               if (element instanceof IJavaScriptElement) {
+                       return getJavaElementProvider().getParent(element);
+               }
+               return super.getParent(element);
+       }
+       
+       private IJavaScriptUnit getLazyCu(Node node) {
+               if(lazyCu==null) {
+                       IJsTranslation tran = getTranslation(node);
+                       if(tran== null) return null;
+                       lazyCu = tran.getCompilationUnit();
+                       if(lazyCu==null) return null;
+                       
+                       try {
+                               lazyCu.makeConsistent( new NullProgressMonitor() );
+                       } catch (JavaScriptModelException e) {
+                               // TODO Auto-generated catch block
+                               e.printStackTrace();
+                       }
+               }
+               return lazyCu;
+       }
+       
+       private IJsTranslation getTranslation(Node node) {
+               IStructuredModel model = null;
+               IModelManager modelManager = StructuredModelManager.getModelManager();
+               IDOMDocument xmlDoc = null;
+               try {
+                       if (modelManager != null) {
+                               IStructuredDocument doc = ((NodeImpl) node).getStructuredDocument();
+                               model = modelManager.getExistingModelForRead(doc);
+                               // model = modelManager.getModelForRead(doc);
+                       }
+                       IDOMModel domModel = (IDOMModel) model;
+                       if(domModel == null) return null;
+                       xmlDoc = domModel.getDocument();
+               } catch (Exception e) {
+                       Logger.logException(e);
+               } finally {
+                       if (model != null) {
+                               // model.changedModel();
+                               model.releaseFromRead();
+                       }
+               }
+               if (xmlDoc == null) {
+                       return null;
+               }
+               JsTranslationAdapter translationAdapter = (JsTranslationAdapter) xmlDoc.getAdapterFor(IJsTranslation.class);
+               return translationAdapter.getJsTranslation(true);
+       }
+       
+       
+       public boolean hasChildren(Object object) {
+               if (object instanceof IJavaScriptElement) {
+                       return getJavaElementProvider().hasChildren(object);
+               }
+               Node node = (Node) object;
+               if (node instanceof IJavaWebNode) {
+                       return ((IJavaWebNode) object).hasChildren();
+                       
+               }
+               if (isJSElementParent(node)) {
+                       Object[] nodes = getJSElementsFromNode(node.getFirstChild(),false);
+                       boolean hasElements = (nodes != null && nodes.length > 0);
+                       return hasElements;
+               }
+               return super.hasChildren(object);
+       }
+       
+       private boolean isJSElementParent(Node node) {
+               return (node.hasChildNodes() && node.getNodeName().equalsIgnoreCase("script")); //$NON-NLS-1$
+       }
+}
diff --git a/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/views/contentoutline/JsJfaceNode.java b/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/views/contentoutline/JsJfaceNode.java
new file mode 100644 (file)
index 0000000..0f5b341
--- /dev/null
@@ -0,0 +1,280 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2009 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.web.ui.views.contentoutline;
+
+import java.util.Collection;
+
+import org.eclipse.jface.text.Position;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.wst.jsdt.core.IJavaScriptElement;
+import org.eclipse.wst.jsdt.core.JavaScriptModelException;
+import org.eclipse.wst.jsdt.internal.core.JavaElement;
+import org.eclipse.wst.jsdt.ui.JavaScriptElementLabelProvider;
+import org.eclipse.wst.jsdt.web.core.internal.Logger;
+import org.eclipse.wst.jsdt.web.core.javascript.IJsTranslation;
+import org.eclipse.wst.jsdt.web.core.javascript.JsTranslationAdapter;
+import org.eclipse.wst.sse.core.StructuredModelManager;
+import org.eclipse.wst.sse.core.internal.model.FactoryRegistry;
+import org.eclipse.wst.sse.core.internal.provisional.AbstractNotifier;
+import org.eclipse.wst.sse.core.internal.provisional.IModelManager;
+import org.eclipse.wst.sse.core.internal.provisional.INodeAdapter;
+import org.eclipse.wst.sse.core.internal.provisional.INodeNotifier;
+import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
+import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion;
+import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument;
+import org.eclipse.wst.xml.core.internal.document.ElementImpl;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
+import org.w3c.dom.Node;
+/**
+*
+
+* Provisional API: This class/interface is part of an interim API that is still under development and expected to
+* change significantly before reaching stability. It is being made available at this early stage to solicit feedback
+* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
+* (repeatedly) as the API evolves.
+*/
+public class JsJfaceNode extends ElementImpl implements IndexedRegion, INodeNotifier, Node, IJavaWebNode {
+       private class JsAdaptableNode extends AbstractNotifier {
+               
+               public FactoryRegistry getFactoryRegistry() {
+                       return adapterRegistry;
+               }
+       }
+       private JsAdaptableNode adaptableDomNode = new JsAdaptableNode();
+       private FactoryRegistry adapterRegistry;
+       private Position fDocPosition;
+//     private Node parent;
+       private String typeName;
+       //private IJavaScriptElement dirtyElement;
+       private boolean hasChildren;
+       //private String name;
+       private Image me;
+       
+       public JsJfaceNode(Node parent, IJavaScriptElement originalElement, Position structureDocLocation) {
+               this(parent, originalElement, structureDocLocation, null);
+       }
+       
+       public JsJfaceNode(Node parent, IJavaScriptElement originalElement, Position structureDocLocation, String typeName) {
+               //super();
+               super(((ElementImpl)parent));
+               // super(parentObject, parentObject.getElementName());
+               fDocPosition = structureDocLocation;
+               //this.parent = parent;
+               this.typeName = typeName;
+               try {
+                       hasChildren=((JavaElement)originalElement).hasChildren();
+               } catch (JavaScriptModelException ex) {
+                       hasChildren=false;
+               }
+               removeAttributes();
+               me = (new JavaScriptElementLabelProvider(JavaScriptElementLabelProvider.SHOW_DEFAULT|JavaScriptElementLabelProvider.SHOW_SMALL_ICONS)).getImage(originalElement);
+       }
+       
+       public Image getImage() {
+               return me;
+       }
+
+       public boolean hasChildren() {
+//             try {
+//                     return ((JavaElement)this.dirtyElement).hasChildren();
+//             } catch (JavaScriptModelException ex) {
+//                     // TODO Auto-generated catch block
+//                     ex.printStackTrace();
+//             }
+               return hasChildren;
+       }
+       
+
+       public void setName(String name) {
+               super.setTagName(name);
+       }
+               
+       public void addAdapter(INodeAdapter adapter) {
+               adaptableDomNode.addAdapter(adapter);
+       }
+       
+       
+       public boolean contains(int testPosition) {
+               return false;
+       }
+       
+       
+       public boolean equals(Object o) {
+               return (o != null && o instanceof JsJfaceNode && ((JsJfaceNode) o).fDocPosition == this.fDocPosition);
+       }
+       
+// public static Object getInstance(Object parent, Position structureDocLocation
+// ){
+// //return new JsJfaceNode((JavaElement)parent.getParent(),
+// parent.getElementName(),structureDocLocation);
+// Vector interfaces = new Vector();
+// interfaces.addAll(Arrays.asList(parent.getClass().getInterfaces()));
+// JsJfaceNode me = new JsJfaceNode(parent,structureDocLocation);
+// interfaces.addAll(Arrays.asList(me.getClass().getInterfaces()));
+// Object proxy = null;
+// try {
+// proxy= Proxy.newProxyInstance(
+// parent.getClass().getClassLoader(),
+// (Class[])interfaces.toArray(new Class[]{}),me);
+// } catch (Exception e) {
+// // TODO Auto-generated catch block
+// System.out.println(e);
+// }
+// return proxy;
+// }
+//   
+       
+       public INodeAdapter getAdapterFor(Object type) {
+               return adaptableDomNode.getAdapterFor(type);
+       }
+       
+       
+       public Collection getAdapters() {
+               return adaptableDomNode.getAdapters();
+       }
+       
+       
+       public int getEndOffset() {
+               return fDocPosition.getOffset() + fDocPosition.getLength();
+       }
+       
+       
+       public INodeAdapter getExistingAdapter(Object type) {
+               // TODO Auto-generated method stub
+               return adaptableDomNode.getExistingAdapter(type);
+       }
+       
+       public synchronized IJavaScriptElement getJavaElement() {
+               /*
+                * since this may become 'stale' we need to rediscover our element every
+                * time we're asked
+                */
+               IJsTranslation tran = getTranslation();
+               int startOffset = getStartOffset();
+               int endOffset = getLength();
+               if (typeName != null) {
+                       IJavaScriptElement myType = tran.getCompilationUnit().getType(typeName);
+                       return myType;
+               }
+               IJavaScriptElement elements[] = tran.getAllElementsInJsRange(startOffset, startOffset + endOffset);
+               if (elements != null) {
+                       return elements[0];
+               } else {
+                       System.out.println(Messages.getString("JsJfaceNode.1")); //$NON-NLS-1$
+                       return null;
+               }
+       }
+       
+       
+       public int getLength() {
+               return fDocPosition.getLength();
+       }
+       
+       
+       
+       /*
+        * (non-Javadoc)
+        * 
+        * @see org.eclipse.wst.xml.core.internal.document.NodeImpl#getOwnerDocument()
+        */
+       
+
+       
+       
+
+       
+       
+       public int getStartOffset() {
+               return fDocPosition.getOffset();
+       }
+       
+// private Method[] getMethods(){
+// // returns the methods this class supports (as declared in interfaces)
+// Class[] interfaces = getClass().getInterfaces();
+// Vector vMethods = new Vector();
+// for(int i = 0;i<interfaces.length;i++){
+// Method methods[] = interfaces[i].getDeclaredMethods();
+// vMethods.addAll(Arrays.asList(methods));
+// }
+//        
+// return (Method[])vMethods.toArray();
+// }
+// public Object invoke(Object proxy, Method method, Object[] args) throws
+// Throwable {
+// Object result;
+// Method[] myMethods = getMethods();
+//        
+// try {
+// for(int i = 0;i<myMethods.length;i++){
+// if(myMethods[i]==method){
+// return method.invoke(this, args);
+// }
+// }
+// result = method.invoke(parentType, args);
+// } catch (InvocationTargetException e) {
+// throw e.getTargetException();
+// } catch (Exception e) {
+// throw new RuntimeException("unexpected invocation exception: " +
+// e.getMessage());
+// }
+//
+// return result;
+// }
+       /*
+        * (non-Javadoc)
+        * 
+        * @see org.eclipse.wst.xml.core.internal.document.NodeImpl#getStructuredDocument()
+        */
+       
+
+       
+       public IJsTranslation getTranslation() {
+               IStructuredModel model = null;
+               IModelManager modelManager = StructuredModelManager.getModelManager();
+               IDOMDocument xmlDoc = null;
+               try {
+                       if (modelManager != null) {
+                               IStructuredDocument doc = getStructuredDocument();
+                               model = modelManager.getExistingModelForRead(doc);
+                               // model = modelManager.getModelForRead(doc);
+                       }
+                       IDOMModel domModel = (IDOMModel) model;
+                       xmlDoc = domModel.getDocument();
+               } catch (Exception e) {
+                       Logger.logException(e);
+               } finally {
+                       if (model != null) {
+                               // model.changedModel();
+                               model.releaseFromRead();
+                       }
+               }
+               if (xmlDoc == null) {
+                       return null;
+               }
+               JsTranslationAdapter translationAdapter = (JsTranslationAdapter) xmlDoc.getAdapterFor(IJsTranslation.class);
+               return translationAdapter.getJsTranslation(true);
+       }
+       
+       
+       public void notify(int eventType, Object changedFeature, Object oldValue, Object newValue, int pos) {
+               adaptableDomNode.notify(eventType, changedFeature, oldValue, newValue, pos);
+       }
+       
+       
+       public void removeAdapter(INodeAdapter adapter) {
+               adaptableDomNode.removeAdapter(adapter);
+       }
+       
+       public void setAdapterRegistry(FactoryRegistry registry) {
+               this.adapterRegistry = registry;
+       }
+}
diff --git a/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/views/contentoutline/Messages.java b/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/views/contentoutline/Messages.java
new file mode 100644 (file)
index 0000000..8a44813
--- /dev/null
@@ -0,0 +1,46 @@
+/*******************************************************************************
+ * 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.web.ui.views.contentoutline;
+
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+/**
+*
+
+* Provisional API: This class/interface is part of an interim API that is still under development and expected to
+* change significantly before reaching stability. It is being made available at this early stage to solicit feedback
+* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
+* (repeatedly) as the API evolves.
+*
+ * @author childsb
+ *
+ */
+public class Messages {
+       private static final String BUNDLE_NAME = "org.eclipse.wst.jsdt.web.ui.views.contentoutline.messages"; //$NON-NLS-1$
+
+       private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME);
+
+       private Messages() {
+       }
+
+       public static String getString(String key) {
+               try {
+                       return RESOURCE_BUNDLE.getString(key);
+               }
+               catch (MissingResourceException e) {
+                       return '!' + key + '!';
+               }
+       }
+}
diff --git a/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/views/contentoutline/messages.properties b/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/views/contentoutline/messages.properties
new file mode 100644 (file)
index 0000000..b36e5be
--- /dev/null
@@ -0,0 +1,11 @@
+###############################################################################
+# 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
+###############################################################################
+JsJfaceNode.1=error in JsJfaceNode... I couldn't retrieve my java element from the original page
diff --git a/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/views/provisional/contentoutline/JFaceNodeAdapterForJs.java b/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/views/provisional/contentoutline/JFaceNodeAdapterForJs.java
new file mode 100644 (file)
index 0000000..6e47c34
--- /dev/null
@@ -0,0 +1,181 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2009 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.web.ui.views.provisional.contentoutline;
+
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.wst.html.ui.internal.contentoutline.JFaceNodeAdapterForHTML;
+import org.eclipse.wst.jsdt.core.IJavaScriptElement;
+import org.eclipse.wst.jsdt.ui.JavaScriptElementLabelProvider;
+import org.eclipse.wst.jsdt.ui.StandardJavaScriptElementContentProvider;
+import org.eclipse.wst.jsdt.web.core.internal.Logger;
+import org.eclipse.wst.jsdt.web.core.javascript.IJsTranslation;
+import org.eclipse.wst.jsdt.web.core.javascript.JsTranslationAdapter;
+import org.eclipse.wst.sse.core.StructuredModelManager;
+import org.eclipse.wst.sse.core.internal.provisional.IModelManager;
+import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
+import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument;
+import org.eclipse.wst.xml.core.internal.document.NodeImpl;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
+import org.eclipse.wst.xml.ui.internal.contentoutline.JFaceNodeAdapterFactory;
+import org.w3c.dom.Node;
+/**
+*
+
+* Provisional API: This class/interface is part of an interim API that is still under development and expected to
+* change significantly before reaching stability. It is being made available at this early stage to solicit feedback
+* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
+* (repeatedly) as the API evolves.
+*/
+public class JFaceNodeAdapterForJs extends JFaceNodeAdapterForHTML {
+       public JFaceNodeAdapterForJs(JFaceNodeAdapterFactory adapterFactory) {
+               super(adapterFactory);
+       }
+       
+       
+       public Object[] getChildren(Object object) {
+               if (object instanceof IJavaScriptElement) {
+                       return getJavaElementProvider().getChildren(object);
+               }
+               Node node = (Node) object;
+               if (isJSElementParent(node)) {
+// Object[] results = getJSElementsFromNode(node.getFirstChild());
+// IMember[] allResults = new IMember[results.length];
+// for(int i = 0;i<results.length;i++) {
+// if(results[i]==null) continue;
+// IMember member = ((IMember)results[i]);
+// allResults[i] = member;
+                       // }
+                       return getJSElementsFromNode(node.getFirstChild());
+               }
+               return super.getChildren(object);
+       }
+       
+       
+       public Object[] getElements(Object object) {
+               if (object instanceof IJavaScriptElement) {
+                       return getJavaElementProvider().getElements(object);
+               }
+               return super.getElements(object);
+       }
+       
+       private JavaScriptElementLabelProvider getJavaElementLabelProvider() {
+               return new JavaScriptElementLabelProvider();
+       }
+       
+       private StandardJavaScriptElementContentProvider getJavaElementProvider() {
+               return new StandardJavaScriptElementContentProvider(true);
+       }
+       
+       private synchronized Object[] getJSElementsFromNode(Node node) {
+               if (node == null) {
+                       return new Object[0];
+               }
+               int startOffset = 0;
+               int endOffset = 0;
+               IJavaScriptElement[] result = null;
+               IJsTranslation translation = null;
+               if (node.getNodeType() == Node.TEXT_NODE && (node instanceof NodeImpl)) {
+                       startOffset = ((NodeImpl) node).getStartOffset();
+                       endOffset = ((NodeImpl) node).getEndOffset();
+                       translation = getTranslation(node);
+                       result = translation.getAllElementsInJsRange(startOffset, endOffset);
+               }
+               return result;
+//                     
+// if (result == null) return null;
+// Object[] newResults = new Object[result.length];
+// for (int i = 0; i < result.length; i++) {
+// int htmllength = 0;
+// int htmloffset = 0;
+// Position position = null;
+// try {
+// htmllength = ((SourceRefElement) (result[i])).getSourceRange().getLength();
+// htmloffset = translation.getJspOffset(((SourceRefElement)
+// (result[i])).getSourceRange().getOffset());
+// position = new Position(htmloffset, htmllength);
+// } catch (JavaScriptModelException e) {
+// e.printStackTrace();
+// }
+// newResults[i] = getJsNode(node.getParentNode(), (IJavaScriptElement) result[i],
+// position);
+// }
+// return newResults;
+       }
+       
+       
+       public Image getLabelImage(Object node) {
+               if (node instanceof IJavaScriptElement) {
+                       return getJavaElementLabelProvider().getImage(node);
+               }
+               return super.getLabelImage(node);
+       }
+       
+       
+       public String getLabelText(Object node) {
+               if (node instanceof IJavaScriptElement) {
+                       return getJavaElementLabelProvider().getText(node);
+               }
+               return super.getLabelText(node);
+       }
+       
+       
+       public Object getParent(Object element) {
+               if (element instanceof IJavaScriptElement) {
+                       return getJavaElementProvider().getParent(element);
+               }
+               return super.getParent(element);
+       }
+       
+       private IJsTranslation getTranslation(Node node) {
+               IStructuredModel model = null;
+               IModelManager modelManager = StructuredModelManager.getModelManager();
+               IDOMDocument xmlDoc = null;
+               try {
+                       if (modelManager != null) {
+                               IStructuredDocument doc = ((NodeImpl) node).getStructuredDocument();
+                               model = modelManager.getExistingModelForRead(doc);
+                               // model = modelManager.getModelForRead(doc);
+                       }
+                       IDOMModel domModel = (IDOMModel) model;
+                       xmlDoc = domModel.getDocument();
+               } catch (Exception e) {
+                       Logger.logException(e);
+               } finally {
+                       if (model != null) {
+                               // model.changedModel();
+                               model.releaseFromRead();
+                       }
+               }
+               if (xmlDoc == null) {
+                       return null;
+               }
+               JsTranslationAdapter translationAdapter = (JsTranslationAdapter) xmlDoc.getAdapterFor(IJsTranslation.class);
+               return translationAdapter.getJsTranslation(true);
+       }
+       
+       
+       public boolean hasChildren(Object object) {
+               if (object instanceof IJavaScriptElement) {
+                       return getJavaElementProvider().hasChildren(object);
+               }
+               Node node = (Node) object;
+               if (isJSElementParent(node)) {
+                       Object[] results = getJSElementsFromNode(node.getFirstChild());
+                       return (results != null && results.length > 0);
+               }
+               return super.hasChildren(object);
+       }
+       
+       private boolean isJSElementParent(Node node) {
+               return (node.getNodeName().equalsIgnoreCase("script")); //$NON-NLS-1$
+       }
+}
diff --git a/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/views/provisional/contentoutline/JsContentOutlineConfig.java b/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/views/provisional/contentoutline/JsContentOutlineConfig.java
new file mode 100644 (file)
index 0000000..8889631
--- /dev/null
@@ -0,0 +1,64 @@
+/*******************************************************************************
+ * 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.web.ui.views.provisional.contentoutline;
+
+import org.eclipse.jface.action.IMenuListener;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.wst.html.ui.views.contentoutline.HTMLContentOutlineConfiguration;
+
+/**
+*
+
+* Provisional API: This class/interface is part of an interim API that is still under development and expected to
+* change significantly before reaching stability. It is being made available at this early stage to solicit feedback
+* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
+* (repeatedly) as the API evolves.
+*/
+public class JsContentOutlineConfig extends HTMLContentOutlineConfiguration {
+       public static final boolean USE_ADVANCED = false;
+       ILabelProvider fLabelProvider = null;
+       
+       public JsContentOutlineConfig() {}
+       
+       private ILabelProvider getJavaLabelProvider() {
+               if (fLabelProvider == null) {
+                       fLabelProvider = new JsLabelProvider();
+               }
+               return fLabelProvider;
+       }
+       
+       
+       public ILabelProvider getLabelProvider(TreeViewer viewer) {
+               if (!JsContentOutlineConfig.USE_ADVANCED) {
+                       return super.getLabelProvider(viewer);
+               }
+               return getJavaLabelProvider();
+       }
+       
+       
+       public IMenuListener getMenuListener(TreeViewer treeViewer) {
+               // if(!USE_ADVANCED)
+               // return super.getMenuListener(treeViewer);
+               return new JsMenuListener(treeViewer);
+       }
+       
+       
+       public ILabelProvider getStatusLineLabelProvider(TreeViewer treeViewer) {
+               if (!JsContentOutlineConfig.USE_ADVANCED) {
+                       return super.getStatusLineLabelProvider(treeViewer);
+               }
+               return getJavaLabelProvider();
+       }
+}
diff --git a/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/views/provisional/contentoutline/JsLabelProvider.java b/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/views/provisional/contentoutline/JsLabelProvider.java
new file mode 100644 (file)
index 0000000..9c30f15
--- /dev/null
@@ -0,0 +1,42 @@
+/**
+ * 
+ */
+package org.eclipse.wst.jsdt.web.ui.views.provisional.contentoutline;
+
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.wst.jsdt.core.IJavaScriptElement;
+import org.eclipse.wst.jsdt.ui.JavaScriptElementLabelProvider;
+/**
+*
+
+* Provisional API: This class/interface is part of an interim API that is still under development and expected to
+* change significantly before reaching stability. It is being made available at this early stage to solicit feedback
+* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
+* (repeatedly) as the API evolves.
+*/
+public class JsLabelProvider extends XMLLabelProvider {
+       JavaScriptElementLabelProvider fLabelProvider = null;
+       
+       
+       public Image getImage(Object o) {
+               if (o instanceof IJavaScriptElement) {
+                       return getJavaElementLabelProvider().getImage(o);
+               }
+               return super.getImage(o);
+       }
+       
+       private JavaScriptElementLabelProvider getJavaElementLabelProvider() {
+               if (fLabelProvider == null) {
+                       fLabelProvider = new JavaScriptElementLabelProvider();
+               }
+               return fLabelProvider;
+       }
+       
+       
+       public String getText(Object o) {
+               if (o instanceof IJavaScriptElement) {
+                       return getJavaElementLabelProvider().getText(o);
+               }
+               return super.getText(o);
+       }
+}
diff --git a/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/views/provisional/contentoutline/JsMenuListener.java b/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/views/provisional/contentoutline/JsMenuListener.java
new file mode 100644 (file)
index 0000000..1f3e078
--- /dev/null
@@ -0,0 +1,160 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+/**
+ * 
+ */
+package org.eclipse.wst.jsdt.web.ui.views.provisional.contentoutline;
+
+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.Separator;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionProvider;
+import org.eclipse.jface.viewers.TreeSelection;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.wst.html.ui.internal.contentoutline.HTMLNodeActionManager;
+import org.eclipse.wst.jsdt.internal.ui.javaeditor.CompilationUnitEditorActionContributor;
+import org.eclipse.wst.jsdt.ui.IContextMenuConstants;
+import org.eclipse.wst.jsdt.web.ui.views.contentoutline.IJavaWebNode;
+import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
+import org.eclipse.wst.sse.ui.internal.IReleasable;
+import org.eclipse.wst.xml.ui.internal.contentoutline.XMLNodeActionManager;
+/**
+*
+
+* Provisional API: This class/interface is part of an interim API that is still under development and expected to
+* change significantly before reaching stability. It is being made available at this early stage to solicit feedback
+* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
+* (repeatedly) as the API evolves.
+*/
+public class JsMenuListener extends HTMLNodeActionManager implements IMenuListener, IReleasable {
+       public static final String EDIT_GROUP_ID = "group.edit"; //$NON-NLS-1$
+       CompilationUnitEditorActionContributor contrib;
+       private XMLNodeActionManager fActionManager;
+       private TreeViewer fTreeViewer;
+       ISelectionProvider selectionProvider;
+       
+       public JsMenuListener(TreeViewer viewer) {
+               super((IStructuredModel) viewer.getInput(), viewer);
+               contrib = new CompilationUnitEditorActionContributor();
+               fTreeViewer = viewer;
+//                     
+// fActionGroups= new CompositeActionGroup(new ActionGroup[] {
+// new OpenViewActionGroup(getWorkbenchSite(), getSelectionProvider()),
+// new CCPActionGroup(getWorkbenchSite()),
+// new GenerateActionGroup(getWorkbenchSite()),
+// new RefactorActionGroup(getWorkbenchSite()),
+// new JavaSearchActionGroup(getWorkbenchSite())});
+       }
+       
+       public IAction[] getAllJsActions() {
+               return null;
+       }
+       
+//     private IWorkbenchSite getWorkbenchSite() {
+//             return InternalHandlerUtil.getActiveSite(fTreeViewer);
+//     }
+       
+       public void menuAboutToShow(IMenuManager manager) {
+               ISelection selection = fTreeViewer.getSelection();
+               if (selection instanceof TreeSelection) {
+                       TreeSelection tselect = (TreeSelection) selection;
+                       Object[] elements = tselect.toArray();
+                       int javaCount = 0;
+                       for (int i = 0; i < elements.length; i++) {
+                               if (elements[i] instanceof IJavaWebNode) {
+                                       javaCount++;
+                               }
+                       }
+                       //IContributionItem[] items = manager.getItems();
+// manager.add(new Separator(IContextMenuConstants.GROUP_NEW));
+// menu.add(new GroupMarker(IContextMenuConstants.GROUP_GOTO));
+// menu.add(new Separator(IContextMenuConstants.GROUP_OPEN));
+// manager.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));
+                       if (javaCount == elements.length && javaCount != 0) {
+                               // see plugin.xml for object contributions that populate these
+                               // menus
+                               /*
+                                * Menu for:
+                                * 
+                                * Open Type Hierarchy Open Call Hierarchy Show In--> Script
+                                * Explorer Navigator
+                                */
+                               manager.add(new Separator(IContextMenuConstants.GROUP_SHOW));
+                               manager.add(new GroupMarker(IContextMenuConstants.GROUP_SHOW));
+                               /*
+                                * Menu for: Cut Copy Paste Delete
+                                */
+                               manager.add(new Separator(JsMenuListener.EDIT_GROUP_ID));
+                               manager.add(new GroupMarker(JsMenuListener.EDIT_GROUP_ID));
+                               /*
+                                * Menu for:
+                                * 
+                                * Source--> Generate Element Comment
+                                * 
+                                * 
+                                * Refactor--> Rename Move Change Function Signature Inline
+                                * Introduce Indirection Infer Generic Type Arguments
+                                */
+                               manager.add(new Separator(IContextMenuConstants.GROUP_SOURCE));
+                               manager.add(new GroupMarker(IContextMenuConstants.GROUP_SOURCE));
+                               /*
+                                * Menu for:
+                                * 
+                                * Refrences--> Workspace Project Hierarchy Working Set
+                                * 
+                                * Declerations--> Workspace Project Hierarchy Working Set
+                                * 
+                                */
+                               manager.add(new Separator(IContextMenuConstants.GROUP_SEARCH));
+                               manager.add(new GroupMarker(IContextMenuConstants.GROUP_SEARCH));
+                               /* all Java Elements */
+//                                     
+//                                     
+//                                     
+// JavaScriptPlugin.createStandardGroups(manager);
+// String[] actionSets = JSDTActionSetUtil.getAllActionSets();
+//
+// IAction[] actions = JSDTActionSetUtil.getActionsFromSet(actionSets);
+// for(int i = 0;i<actions.length;i++) {
+// manager.add(actions[i]);
+// }
+// fActionGroups.setContext(new ActionContext(selection));
+// fActionGroups.fillContextMenu(manager);
+//                                     
+                       } else if (javaCount == 0) {
+                               fillContextMenu(manager, selection);
+                       }
+               }
+       }
+       
+       /*
+        * (non-Javadoc)
+        * 
+        * @see org.eclipse.wst.sse.ui.internal.IReleasable#release()
+        */
+       public void release() {
+               fTreeViewer = null;
+               if (fActionManager != null) {
+                       fActionManager.setModel(null);
+               }
+       }
+}
diff --git a/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/views/provisional/contentoutline/JsWebElementProvider.java b/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/views/provisional/contentoutline/JsWebElementProvider.java
new file mode 100644 (file)
index 0000000..1c0db53
--- /dev/null
@@ -0,0 +1,25 @@
+/*******************************************************************************
+ * 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.web.ui.views.provisional.contentoutline;
+
+import org.eclipse.wst.jsdt.ui.StandardJavaScriptElementContentProvider;
+/**
+*
+
+* Provisional API: This class/interface is part of an interim API that is still under development and expected to
+* change significantly before reaching stability. It is being made available at this early stage to solicit feedback
+* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
+* (repeatedly) as the API evolves.
+*/
+public class JsWebElementProvider extends StandardJavaScriptElementContentProvider {}
diff --git a/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/views/provisional/contentoutline/XMLLabelProvider.java b/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/views/provisional/contentoutline/XMLLabelProvider.java
new file mode 100644 (file)
index 0000000..cf5c62c
--- /dev/null
@@ -0,0 +1,115 @@
+/*******************************************************************************
+ * 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.web.ui.views.provisional.contentoutline;
+
+import org.eclipse.wst.sse.core.utils.StringUtils;
+import org.eclipse.wst.xml.core.internal.contentmodel.CMAttributeDeclaration;
+import org.eclipse.wst.xml.core.internal.contentmodel.CMDataType;
+import org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration;
+import org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQuery;
+import org.eclipse.wst.xml.core.internal.modelquery.ModelQueryUtil;
+import org.eclipse.wst.xml.ui.internal.contentoutline.JFaceNodeLabelProvider;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+
+/**
+*
+
+* Provisional API: This class/interface is part of an interim API that is still under development and expected to
+* change significantly before reaching stability. It is being made available at this early stage to solicit feedback
+* from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
+* (repeatedly) as the API evolves.
+*/
+public class XMLLabelProvider extends JFaceNodeLabelProvider {
+       boolean fShowAttributes = false;
+       
+       
+       public String getText(Object o) {
+               StringBuffer text = new StringBuffer(super.getText(o));
+               if (o instanceof Node) {
+                       Node node = (Node) o;
+                       if ((node.getNodeType() == Node.ELEMENT_NODE) && fShowAttributes) {
+                               // https://bugs.eclipse.org/bugs/show_bug.cgi?id=88444
+                               if (node.hasAttributes()) {
+                                       Element element = (Element) node;
+                                       NamedNodeMap attributes = element.getAttributes();
+                                       Node idTypedAttribute = null;
+                                       Node requiredAttribute = null;
+                                       boolean hasId = false;
+                                       boolean hasName = false;
+                                       Node shownAttribute = null;
+                                       // try to get content model element
+                                       // declaration
+                                       CMElementDeclaration elementDecl = null;
+                                       ModelQuery mq = ModelQueryUtil.getModelQuery(element.getOwnerDocument());
+                                       if (mq != null) {
+                                               elementDecl = mq.getCMElementDeclaration(element);
+                                       }
+                                       // find an attribute of type (or just named)
+                                       // ID
+                                       if (elementDecl != null) {
+                                               int i = 0;
+                                               while ((i < attributes.getLength()) && (idTypedAttribute == null)) {
+                                                       Node attr = attributes.item(i);
+                                                       String attrName = attr.getNodeName();
+                                                       CMAttributeDeclaration attrDecl = (CMAttributeDeclaration) elementDecl.getAttributes().getNamedItem(attrName);
+                                                       if (attrDecl != null) {
+                                                               if ((attrDecl.getAttrType() != null) && (CMDataType.ID.equals(attrDecl.getAttrType().getDataTypeName()))) {
+                                                                       idTypedAttribute = attr;
+                                                               } else if ((attrDecl.getUsage() == CMAttributeDeclaration.REQUIRED) && (requiredAttribute == null)) {
+                                                                       // as a backup, keep tabs on
+                                                                       // any required
+                                                                       // attributes
+                                                                       requiredAttribute = attr;
+                                                               } else {
+                                                                       hasId = hasId || attrName.equals("id"); //$NON-NLS-1$
+                                                                       hasName = hasName || attrName.equals("name"); //$NON-NLS-1$
+                                                               }
+                                                       }
+                                                       ++i;
+                                               }
+                                       }
+                                       /*
+                                        * If no suitable attribute was found, try using a
+                                        * required attribute, if none, then prefer "id" or
+                                        * "name", otherwise just use first attribute
+                                        */
+                                       if (idTypedAttribute != null) {
+                                               shownAttribute = idTypedAttribute;
+                                       } else if (requiredAttribute != null) {
+                                               shownAttribute = requiredAttribute;
+                                       } else if (hasId) {
+                                               shownAttribute = attributes.getNamedItem("id"); //$NON-NLS-1$
+                                       } else if (hasName) {
+                                               shownAttribute = attributes.getNamedItem("name"); //$NON-NLS-1$
+                                       }
+                                       if (shownAttribute == null) {
+                                               shownAttribute = attributes.item(0);
+                                       }
+                                       // display the attribute and value (without quotes)
+                                       String attributeName = shownAttribute.getNodeName();
+                                       if ((attributeName != null) && (attributeName.length() > 0)) {
+                                               text.append(" " + attributeName); //$NON-NLS-1$
+                                               String attributeValue = shownAttribute.getNodeValue();
+                                               if ((attributeValue != null) && (attributeValue.length() > 0)) {
+                                                       text.append("=" + StringUtils.strip(attributeValue)); //$NON-NLS-1$
+                                               }
+                                       }
+                               }
+                       }
+               }
+               return text.toString();
+       }
+}
diff --git a/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/web1.GIF b/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/web1.GIF
new file mode 100644 (file)
index 0000000..a9a220d
Binary files /dev/null and b/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/web1.GIF differ
diff --git a/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/web1.JPG b/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/web1.JPG
new file mode 100644 (file)
index 0000000..68bf9c5
Binary files /dev/null and b/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/web1.JPG differ
index 1a3eb51..6099cd0 100644 (file)
    </copyright>
 
    <license url="license.html">
-Tizen SDK
+      Tizen SDK
 
 
-Tizen SDK contains software portions licensed under various open source licenses as well as proprietary components. All open source software portions ("Open Source Software") are licensed under the open source licenses that accompany such Open Source Software.
+Tizen SDK contains software portions licensed under various open source licenses as well as proprietary components. All open source software portions (&quot;Open Source Software&quot;) are licensed under the open source licenses that accompany such Open Source Software.
 
 The licenses governing the Open Source Software are available at:
 https://developer.tizen.org/tizen-sdk-opensource-license
@@ -29,7 +29,7 @@ https://developer.tizen.org/tizen-sdk-license
 The licenses of all proprietary components contributed from companies other than Samsung will be either displayed as part of their respective installers or accessed inside installation package archive of each component. You may access and download Tizen SDK Open Source Software at:
 http://developer.tizen.org/download/tizenopensdk.tar.gz
 
-BY CLICKING THE "I AGREE" BUTTON OR BY USING ANY PART OF TIZEN SDK, YOU AGREE (ON BEHALF OF YOURSELF AND/OR YOUR COMPANY) TO THE OPEN SOURCE SOFTWARE LICENSE TERMS, THE SAMSUNG TIZEN SDK LICENSE AGREEMENT AND THE LICENSES OF ALL PROPRIETARY COMPONENTS CONTRIBUTED FROM COMPANIES OTHER THAN SAMSUNG. If you do not agree with the Open Source Software license terms or the SAMSUNG TIZEN SDK LICENSE AGREEMENT or THE LICENSES OF ALL PROPRIETARY COMPONENTS CONTRIBUTED FROM COMPANIES OTHER THAN SAMSUNG, you may not download or use Tizen SDK.
+BY CLICKING THE &quot;I AGREE&quot; BUTTON OR BY USING ANY PART OF TIZEN SDK, YOU AGREE (ON BEHALF OF YOURSELF AND/OR YOUR COMPANY) TO THE OPEN SOURCE SOFTWARE LICENSE TERMS, THE SAMSUNG TIZEN SDK LICENSE AGREEMENT AND THE LICENSES OF ALL PROPRIETARY COMPONENTS CONTRIBUTED FROM COMPANIES OTHER THAN SAMSUNG. If you do not agree with the Open Source Software license terms or the SAMSUNG TIZEN SDK LICENSE AGREEMENT or THE LICENSES OF ALL PROPRIETARY COMPONENTS CONTRIBUTED FROM COMPANIES OTHER THAN SAMSUNG, you may not download or use Tizen SDK.
    </license>
 
    <includes
@@ -221,10 +221,6 @@ BY CLICKING THE "I AGREE" BUTTON OR BY USING ANY PART OF TIZEN SDK, YOU AGREE (O
          version="0.0.0"/>
 
    <includes
-         id="org.eclipse.wst.web_ui.feature"
-         version="0.0.0"/>
-
-   <includes
          id="org.eclipse.wst.web_userdoc.feature"
          version="0.0.0"/>
 
@@ -241,14 +237,6 @@ BY CLICKING THE "I AGREE" BUTTON OR BY USING ANY PART OF TIZEN SDK, YOU AGREE (O
          version="0.0.0"/>
 
    <includes
-         id="org.eclipse.egit"
-         version="0.0.0"/>
-
-   <includes
-         id="org.eclipse.jgit"
-         version="0.0.0"/>
-
-   <includes
          id="org.eclipse.cdt.platform"
          version="0.0.0"/>
 
@@ -325,10 +313,6 @@ BY CLICKING THE "I AGREE" BUTTON OR BY USING ANY PART OF TIZEN SDK, YOU AGREE (O
          version="0.0.0"/>
 
    <includes
-         id="org.eclipse.mylyn.cvs"
-         version="0.0.0"/>
-
-   <includes
          id="org.eclipse.mylyn.docs.sdk"
          version="0.0.0"/>
 
@@ -357,14 +341,6 @@ BY CLICKING THE "I AGREE" BUTTON OR BY USING ANY PART OF TIZEN SDK, YOU AGREE (O
          version="0.0.0"/>
 
    <includes
-         id="org.eclipse.mylyn.test_feature"
-         version="0.0.0"/>
-
-   <includes
-         id="org.eclipse.mylyn.trac_feature"
-         version="0.0.0"/>
-
-   <includes
          id="org.eclipse.mylyn.wikitext.sdk"
          version="0.0.0"/>
 
@@ -1228,34 +1204,6 @@ BY CLICKING THE "I AGREE" BUTTON OR BY USING ANY PART OF TIZEN SDK, YOU AGREE (O
          unpack="false"/>
 
    <plugin
-         id="org.eclipse.egit"
-         download-size="0"
-         install-size="0"
-         version="0.0.0"
-         unpack="false"/>
-
-   <plugin
-         id="org.eclipse.egit.core"
-         download-size="0"
-         install-size="0"
-         version="0.0.0"
-         unpack="false"/>
-
-   <plugin
-         id="org.eclipse.egit.doc"
-         download-size="0"
-         install-size="0"
-         version="0.0.0"
-         unpack="false"/>
-
-   <plugin
-         id="org.eclipse.egit.ui"
-         download-size="0"
-         install-size="0"
-         version="0.0.0"
-         unpack="false"/>
-
-   <plugin
          id="org.eclipse.emf"
          download-size="0"
          install-size="0"
@@ -2012,13 +1960,6 @@ BY CLICKING THE "I AGREE" BUTTON OR BY USING ANY PART OF TIZEN SDK, YOU AGREE (O
          unpack="false"/>
 
    <plugin
-         id="org.eclipse.jgit"
-         download-size="0"
-         install-size="0"
-         version="0.0.0"
-         unpack="false"/>
-
-   <plugin
          id="org.eclipse.jsch.core"
          download-size="0"
          install-size="0"
@@ -3097,4 +3038,20 @@ BY CLICKING THE "I AGREE" BUTTON OR BY USING ANY PART OF TIZEN SDK, YOU AGREE (O
          version="0.0.0"
          unpack="false"/>
 
+   <plugin
+         id="org.eclipse.wst.jsdt.web.ui.patch"
+         download-size="0"
+         install-size="0"
+         version="0.0.0"
+         fragment="true"
+         unpack="false"/>
+
+   <plugin
+         id="org.eclipse.wst.jsdt.web.core.patch"
+         download-size="0"
+         install-size="0"
+         version="0.0.0"
+         fragment="true"
+         unpack="false"/>
+
 </feature>
index 7796569..77a0fd8 100755 (executable)
@@ -24,11 +24,14 @@ then
     eclipse_options="-clean ${eclipse_options}"
 fi
 
-linux_name=`cat /etc/issue | awk '{print $1}' | tr [A-Z] [a-z]`
-linux_version=`cat /etc/issue | awk '{print $2}'`
-linux_main_version=`expr substr $linux_version 1 5`
+if [ -e /etc/issue ]
+then
+    linux_name=`cat /etc/issue | awk '{print $1}' | tr [A-Z] [a-z]`
+    linux_version=`cat /etc/issue | awk '{print $2}'`
+    linux_main_version=`expr substr $linux_version 1 5`
+fi
 
-if [ ${linux_name} = "ubuntu" ]
+if [ "${linux_name}" = "ubuntu" ]
 then
     case ${linux_main_version} in
         11.04|11.10|12.04|12.10)
@@ -37,7 +40,8 @@ then
         *)
             GDK_NATIVE_WINDOWS=true ./eclipse ${eclipse_options}
     esac
+else
+    GDK_NATIVE_WINDOWS=true ./eclipse ${eclipse_options}
 fi
 
 cd ${start_path}
-
index a2950b9..bbe293f 100644 (file)
@@ -52,10 +52,10 @@ en</programArgs>
    <license>
         <url>https://developer.tizen.org</url>
         <text>
-Tizen SDK
+   Tizen SDK
 
 
-Tizen SDK contains software portions licensed under various open source licenses as well as proprietary components. All open source software portions ("Open Source Software") are licensed under the open source licenses that accompany such Open Source Software.
+Tizen SDK contains software portions licensed under various open source licenses as well as proprietary components. All open source software portions (&quot;Open Source Software&quot;) are licensed under the open source licenses that accompany such Open Source Software.
 
 The licenses governing the Open Source Software are available at:
 https://developer.tizen.org/tizen-sdk-opensource-license
@@ -66,7 +66,7 @@ https://developer.tizen.org/tizen-sdk-license
 The licenses of all proprietary components contributed from companies other than Samsung will be either displayed as part of their respective installers or accessed inside installation package archive of each component. You may access and download Tizen SDK Open Source Software at:
 http://developer.tizen.org/download/tizenopensdk.tar.gz
 
-BY CLICKING THE "I AGREE" BUTTON OR BY USING ANY PART OF TIZEN SDK, YOU AGREE (ON BEHALF OF YOURSELF AND/OR YOUR COMPANY) TO THE OPEN SOURCE SOFTWARE LICENSE TERMS, THE SAMSUNG TIZEN SDK LICENSE AGREEMENT AND THE LICENSES OF ALL PROPRIETARY COMPONENTS CONTRIBUTED FROM COMPANIES OTHER THAN SAMSUNG. If you do not agree with the Open Source Software license terms or the SAMSUNG TIZEN SDK LICENSE AGREEMENT or THE LICENSES OF ALL PROPRIETARY COMPONENTS CONTRIBUTED FROM COMPANIES OTHER THAN SAMSUNG, you may not download or use Tizen SDK.
+BY CLICKING THE &quot;I AGREE&quot; BUTTON OR BY USING ANY PART OF TIZEN SDK, YOU AGREE (ON BEHALF OF YOURSELF AND/OR YOUR COMPANY) TO THE OPEN SOURCE SOFTWARE LICENSE TERMS, THE SAMSUNG TIZEN SDK LICENSE AGREEMENT AND THE LICENSES OF ALL PROPRIETARY COMPONENTS CONTRIBUTED FROM COMPANIES OTHER THAN SAMSUNG. If you do not agree with the Open Source Software license terms or the SAMSUNG TIZEN SDK LICENSE AGREEMENT or THE LICENSES OF ALL PROPRIETARY COMPONENTS CONTRIBUTED FROM COMPANIES OTHER THAN SAMSUNG, you may not download or use Tizen SDK.
          </text>
    </license>
 
index 5196e80..9c34e68 100644 (file)
@@ -53,10 +53,10 @@ en</programArgs>
    <license>
         <url>https://developer.tizen.org</url>
         <text>
-Tizen SDK
+   Tizen SDK
 
 
-Tizen SDK contains software portions licensed under various open source licenses as well as proprietary components. All open source software portions ("Open Source Software") are licensed under the open source licenses that accompany such Open Source Software.
+Tizen SDK contains software portions licensed under various open source licenses as well as proprietary components. All open source software portions (&quot;Open Source Software&quot;) are licensed under the open source licenses that accompany such Open Source Software.
 
 The licenses governing the Open Source Software are available at:
 https://developer.tizen.org/tizen-sdk-opensource-license
@@ -67,7 +67,7 @@ https://developer.tizen.org/tizen-sdk-license
 The licenses of all proprietary components contributed from companies other than Samsung will be either displayed as part of their respective installers or accessed inside installation package archive of each component. You may access and download Tizen SDK Open Source Software at:
 http://developer.tizen.org/download/tizenopensdk.tar.gz
 
-BY CLICKING THE "I AGREE" BUTTON OR BY USING ANY PART OF TIZEN SDK, YOU AGREE (ON BEHALF OF YOURSELF AND/OR YOUR COMPANY) TO THE OPEN SOURCE SOFTWARE LICENSE TERMS, THE SAMSUNG TIZEN SDK LICENSE AGREEMENT AND THE LICENSES OF ALL PROPRIETARY COMPONENTS CONTRIBUTED FROM COMPANIES OTHER THAN SAMSUNG. If you do not agree with the Open Source Software license terms or the SAMSUNG TIZEN SDK LICENSE AGREEMENT or THE LICENSES OF ALL PROPRIETARY COMPONENTS CONTRIBUTED FROM COMPANIES OTHER THAN SAMSUNG, you may not download or use Tizen SDK.
+BY CLICKING THE &quot;I AGREE&quot; BUTTON OR BY USING ANY PART OF TIZEN SDK, YOU AGREE (ON BEHALF OF YOURSELF AND/OR YOUR COMPANY) TO THE OPEN SOURCE SOFTWARE LICENSE TERMS, THE SAMSUNG TIZEN SDK LICENSE AGREEMENT AND THE LICENSES OF ALL PROPRIETARY COMPONENTS CONTRIBUTED FROM COMPANIES OTHER THAN SAMSUNG. If you do not agree with the Open Source Software license terms or the SAMSUNG TIZEN SDK LICENSE AGREEMENT or THE LICENSES OF ALL PROPRIETARY COMPONENTS CONTRIBUTED FROM COMPANIES OTHER THAN SAMSUNG, you may not download or use Tizen SDK.
          </text>
    </license>
 
index a2950b9..bbe293f 100644 (file)
@@ -52,10 +52,10 @@ en</programArgs>
    <license>
         <url>https://developer.tizen.org</url>
         <text>
-Tizen SDK
+   Tizen SDK
 
 
-Tizen SDK contains software portions licensed under various open source licenses as well as proprietary components. All open source software portions ("Open Source Software") are licensed under the open source licenses that accompany such Open Source Software.
+Tizen SDK contains software portions licensed under various open source licenses as well as proprietary components. All open source software portions (&quot;Open Source Software&quot;) are licensed under the open source licenses that accompany such Open Source Software.
 
 The licenses governing the Open Source Software are available at:
 https://developer.tizen.org/tizen-sdk-opensource-license
@@ -66,7 +66,7 @@ https://developer.tizen.org/tizen-sdk-license
 The licenses of all proprietary components contributed from companies other than Samsung will be either displayed as part of their respective installers or accessed inside installation package archive of each component. You may access and download Tizen SDK Open Source Software at:
 http://developer.tizen.org/download/tizenopensdk.tar.gz
 
-BY CLICKING THE "I AGREE" BUTTON OR BY USING ANY PART OF TIZEN SDK, YOU AGREE (ON BEHALF OF YOURSELF AND/OR YOUR COMPANY) TO THE OPEN SOURCE SOFTWARE LICENSE TERMS, THE SAMSUNG TIZEN SDK LICENSE AGREEMENT AND THE LICENSES OF ALL PROPRIETARY COMPONENTS CONTRIBUTED FROM COMPANIES OTHER THAN SAMSUNG. If you do not agree with the Open Source Software license terms or the SAMSUNG TIZEN SDK LICENSE AGREEMENT or THE LICENSES OF ALL PROPRIETARY COMPONENTS CONTRIBUTED FROM COMPANIES OTHER THAN SAMSUNG, you may not download or use Tizen SDK.
+BY CLICKING THE &quot;I AGREE&quot; BUTTON OR BY USING ANY PART OF TIZEN SDK, YOU AGREE (ON BEHALF OF YOURSELF AND/OR YOUR COMPANY) TO THE OPEN SOURCE SOFTWARE LICENSE TERMS, THE SAMSUNG TIZEN SDK LICENSE AGREEMENT AND THE LICENSES OF ALL PROPRIETARY COMPONENTS CONTRIBUTED FROM COMPANIES OTHER THAN SAMSUNG. If you do not agree with the Open Source Software license terms or the SAMSUNG TIZEN SDK LICENSE AGREEMENT or THE LICENSES OF ALL PROPRIETARY COMPONENTS CONTRIBUTED FROM COMPANIES OTHER THAN SAMSUNG, you may not download or use Tizen SDK.
          </text>
    </license>
 
index 5d7865e..a9ec23d 100644 (file)
@@ -27,7 +27,7 @@
                        </a>                            \r
                </div>                                          \r
                <div style=" position:absolute; top:204px; left:347px; ">\r
-                       <a href="http://org.eclipse.ui.intro/showHelpTopic?id=/org.tizen.native.appprogramming/html/cover_page.htm">\r
+                       <a href="http://org.eclipse.ui.intro/showHelpTopic?id=/org.tizen.cpp.appprogramming/html/cover_page.htm">\r
                                <img border="0" src="icon_03_normal.png" alt="Tizen Native Programming" onmouseover="on_03(this)" onmouseout="off_03(this)" />\r
                        </a>                            \r
                </div>                  \r
index 169e789..df1b429 100644 (file)
@@ -5,8 +5,6 @@
 org.eclipse.ui/SHOW_PROGRESS_ON_STARTUP = true
 org.eclipse.ui/SHOW_TRADITIONAL_STYLE_TABS=false
 org.eclipse.ui/DOCK_PERSPECTIVE_BAR=topRight
-#org.eclipse.ui/defaultPerspectiveId=com.samsung.linuxplatform.perspective.SamsungSDKPerspective
-#org.eclipse.ui/defaultPerspectiveId=com.samsung.tizen.nativeapp.perspective
 org.eclipse.ui/defaultPerspectiveId=org.tizen.web.ui.perspective.WebWidget
 
 org.eclipse.ui.workbench/SHOW_BUILDID_ON_STARTUP=true
diff --git a/org.tizen.base.platform/src/org/tizen/base/platform/InitPreferences.java b/org.tizen.base.platform/src/org/tizen/base/platform/InitPreferences.java
deleted file mode 100644 (file)
index 073a300..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Tizen IDE
- * 
- * Copyright (C) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: 
- * Taeyoung Son <taeyoung2.son@samsung.com>
- * Kangho Kim <kh5325.kim@samsung.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * 
- * Contributors:
- * - S-Core Co., Ltd
- * 
- */
-
-package org.tizen.base.platform;
-import org.eclipse.ui.IStartup;
-
-
-public class InitPreferences implements IStartup {
-
-       @Override
-       public void earlyStartup() {
-               // TODO Auto-generated method stub
-
-       }
-
-}
index 8fcfc76..651b290 100755 (executable)
@@ -9,4 +9,6 @@ ${REMOVE_SHORTCUT} ${DESKTOP_FILE_PATH}
 ide_path=ide
 rm -rf ${INSTALLED_PATH}/${ide_path}/p2
 
+rm -f ${INSTALLED_PATH}/${ide_path}/init
+
 ### End ###
index bbc3ec8..a38cbc2 100644 (file)
@@ -9,4 +9,4 @@ rd/s/q "%INSTALLED_PATH%\ide\p2"
 :: Uninstall Tizen font
 :: del %HOMEDRIVE%\Windows\Fonts\unnamed.ttf
 
-
+del /q "%INSTALLED_PATH%\ide\init"
index 6b13f08..71f5668 100644 (file)
@@ -324,7 +324,10 @@ build()
     
         if [ "x${TARGET_OS}" = "x${platform}" ]
         then
+            if [ "x${package_name}" = "xbase-ide-product" ]
+            then
             build_plugins
+            fi
         else
             echo ""
         fi
@@ -344,7 +347,15 @@ install()
 
         if [ "x${TARGET_OS}" = "x${platform}" ]
         then
-            packaging_plugins
+            if [ "x${package_name}" = "xbase-ide-product" ]
+            then
+                packaging_plugins
+            elif [ "x${package_name}" = "xbase-ide-product-add-ons" ]
+            then
+                INSTALL_DIR=${SRCDIR}/package/${package_name}.package.${TARGET_OS}/data/ide
+                mkdir -p ${INSTALL_DIR}
+                cp -rf ${SRCDIR}/add-ons/* ${INSTALL_DIR}/
+            fi
         else
             echo ""
         fi
index ff44e6b..a26449f 100644 (file)
@@ -1,3 +1,21 @@
+* 2.1.9
+- Removed helpData.xml
+== kh5325.kim <kh5325.kim@samsung.com> 2013-06-12
+* 2.1.8
+- Modified startup.sh for supporting linux OS other than Ubuntu
+== kh5325.kim <kh5325.kim@samsung.com> 2013-06-07
+* 2.1.7
+- Removed org.eclipse.mylyn.test_feature and org.eclipse.mylyn.trac_feature features
+== kh5325.kim <kh5325.kim@samsung.com> 2013-05-28
+* 2.1.6
+- Added base-ide-product-add-ons package
+== kh5325.kim <kh5325.kim@samsung.com> 2013-05-24
+* 2.1.5
+- Added base-ide-product-add-ons package
+== kh5325.kim <kh5325.kim@samsung.com> 2013-05-24
+* 2.1.4
+- 2.1.1 version (EGit 2.3.1 upgrade)
+== kh5325.kim <kh5325.kim@samsung.com> 2013-05-24
 *2.1.3
 - add log4j configuration
 == ho.namkoong <ho.namkoong@samsung.com> 2013-04-16
index a70fa44..850390d 100644 (file)
@@ -1,4 +1,4 @@
-Version:2.1.3
+Version:2.1.9
 Source:product
 Maintainer:kangho kim <kh5325.kim@samsung.com>, yoonki park <yoonki.park@samsung.com>, hyunsik non <hyunsik.noh@samsung.com>, taeyoung son <taeyoung2.son@samsung.com>, gune Kim <gune.kim@samsung.com>, ho namkoong <ho.namkoong@samsung.com>, hyeongseok heo <hyeong-seok.heo@samsung.com>, gyeongseok seo <gyeongseok.seo@samsung.com>, jihoon song<jihoon80.song@samsung.com>, changhyun lee <changhyun1.lee@samsung.com>, Woongsik Choi <woongsik76.choi@samsung.com>, Hyukmin Kwon <hyukmin0530.kwon@samsung.com>, Wooyoung Cho <wooyoung1.cho@samsung.com>, Jaeheung Kim <jaeheung.kim@samsung.com>
 
@@ -32,3 +32,32 @@ Build-host-os:ubuntu-64
 Build-dependency:indigo-macpde [macos-64]
 Description:Make base IDE. This also includes patched eclipse plugins.
 
+Package:base-ide-product-add-ons
+OS:ubuntu-32
+Build-host-os:ubuntu-32
+Install-dependency:base-ide-product [ubuntu-32]
+Description:Add-ons for Tizen IDE (like EGit dropins)
+
+Package:base-ide-product-add-ons
+OS:windows-32
+Build-host-os:ubuntu-32
+Install-dependency:base-ide-product [windows-32]
+Description:Add-ons for Tizen IDE (like EGit dropins)
+
+Package:base-ide-product-add-ons
+OS:ubuntu-64
+Build-host-os:ubuntu-64
+Install-dependency:base-ide-product [ubuntu-64]
+Description:Add-ons for Tizen IDE (like EGit dropins)
+
+Package:base-ide-product-add-ons
+OS:windows-64
+Build-host-os:ubuntu-64
+Install-dependency:base-ide-product [windows-64]
+Description:Add-ons for Tizen IDE (like EGit dropins)
+
+Package:base-ide-product-add-ons
+OS:macos-64
+Build-host-os:ubuntu-64
+Install-dependency:base-ide-product [macos-64]
+Description:Add-ons for Tizen IDE (like EGit dropins)