diff options
Diffstat (limited to 'bundles/org.eclipse.wst.html.ui/src')
70 files changed, 0 insertions, 10114 deletions
diff --git a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/StructuredTextViewerConfigurationHTML.java b/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/StructuredTextViewerConfigurationHTML.java deleted file mode 100644 index 80cbe16ead..0000000000 --- a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/StructuredTextViewerConfigurationHTML.java +++ /dev/null @@ -1,328 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.html.ui; - -import java.util.ArrayList; -import java.util.List; -import java.util.Vector; - -import org.eclipse.core.runtime.Preferences; -import org.eclipse.jface.text.IAutoEditStrategy; -import org.eclipse.jface.text.ITextDoubleClickStrategy; -import org.eclipse.jface.text.ITextHover; -import org.eclipse.jface.text.contentassist.IContentAssistProcessor; -import org.eclipse.jface.text.formatter.IContentFormatter; -import org.eclipse.jface.text.formatter.MultiPassContentFormatter; -import org.eclipse.jface.text.hyperlink.IHyperlinkDetector; -import org.eclipse.jface.text.information.IInformationProvider; -import org.eclipse.jface.text.source.ISourceViewer; -import org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants; -import org.eclipse.wst.css.core.text.ICSSPartitions; -import org.eclipse.wst.css.ui.internal.contentassist.CSSContentAssistProcessor; -import org.eclipse.wst.css.ui.internal.style.LineStyleProviderForEmbeddedCSS; -import org.eclipse.wst.html.core.internal.HTMLCorePlugin; -import org.eclipse.wst.html.core.internal.format.HTMLFormatProcessorImpl; -import org.eclipse.wst.html.core.internal.preferences.HTMLCorePreferenceNames; -import org.eclipse.wst.html.core.internal.text.StructuredTextPartitionerForHTML; -import org.eclipse.wst.html.core.text.IHTMLPartitions; -import org.eclipse.wst.html.ui.internal.autoedit.AutoEditStrategyForTabs; -import org.eclipse.wst.html.ui.internal.autoedit.StructuredAutoEditStrategyHTML; -import org.eclipse.wst.html.ui.internal.contentassist.HTMLContentAssistProcessor; -import org.eclipse.wst.html.ui.internal.contentassist.NoRegionContentAssistProcessorForHTML; -import org.eclipse.wst.html.ui.internal.hyperlink.XMLHyperlinkDetector; -import org.eclipse.wst.html.ui.internal.style.LineStyleProviderForHTML; -import org.eclipse.wst.html.ui.internal.taginfo.HTMLInformationProvider; -import org.eclipse.wst.html.ui.internal.taginfo.HTMLTagInfoHoverProcessor; -import org.eclipse.wst.javascript.ui.internal.common.contentassist.JavaScriptContentAssistProcessor; -import org.eclipse.wst.javascript.ui.internal.common.style.LineStyleProviderForJavaScript; -import org.eclipse.wst.javascript.ui.internal.common.taginfo.JavaScriptInformationProvider; -import org.eclipse.wst.javascript.ui.internal.common.taginfo.JavaScriptTagInfoHoverProcessor; -import org.eclipse.wst.sse.core.text.IStructuredPartitions; -import org.eclipse.wst.sse.ui.StructuredTextViewerConfiguration; -import org.eclipse.wst.sse.ui.internal.SSEUIPlugin; -import org.eclipse.wst.sse.ui.internal.format.StructuredFormattingStrategy; -import org.eclipse.wst.sse.ui.internal.provisional.style.LineStyleProvider; -import org.eclipse.wst.sse.ui.internal.taginfo.TextHoverManager; -import org.eclipse.wst.sse.ui.internal.util.EditorUtility; -import org.eclipse.wst.xml.core.internal.text.rules.StructuredTextPartitionerForXML; -import org.eclipse.wst.xml.core.text.IXMLPartitions; -import org.eclipse.wst.xml.ui.StructuredTextViewerConfigurationXML; - -/** - * Configuration for a source viewer which shows HTML content. - * <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 StructuredTextViewerConfigurationHTML extends StructuredTextViewerConfiguration { - /* - * One instance per configuration because not sourceviewer-specific and - * it's a String array - */ - private String[] fConfiguredContentTypes; - /* - * One instance per configuration - */ - private LineStyleProvider fLineStyleProviderForEmbeddedCSS; - /* - * One instance per configuration - */ - private LineStyleProvider fLineStyleProviderForHTML; - /* - * One instance per configuration - */ - private LineStyleProvider fLineStyleProviderForJavascript; - /* - * One instance per configuration - */ - private StructuredTextViewerConfiguration fXMLSourceViewerConfiguration; - - /** - * Create new instance of StructuredTextViewerConfigurationHTML - */ - public StructuredTextViewerConfigurationHTML() { - // Must have empty constructor to createExecutableExtension - super(); - } - - public IAutoEditStrategy[] getAutoEditStrategies(ISourceViewer sourceViewer, String contentType) { - List allStrategies = new ArrayList(0); - - IAutoEditStrategy[] superStrategies = super.getAutoEditStrategies(sourceViewer, contentType); - for (int i = 0; i < superStrategies.length; i++) { - allStrategies.add(superStrategies[i]); - } - - if (contentType == IHTMLPartitions.HTML_DEFAULT || contentType == IHTMLPartitions.HTML_DECLARATION) { - allStrategies.add(new StructuredAutoEditStrategyHTML()); - } - - // be sure this is added last in list, so it has a change to modify - // previous results. - // add auto edit strategy that handles when tab key is pressed - allStrategies.add(new AutoEditStrategyForTabs()); - - return (IAutoEditStrategy[]) allStrategies.toArray(new IAutoEditStrategy[allStrategies.size()]); - } - - public String[] getConfiguredContentTypes(ISourceViewer sourceViewer) { - if (fConfiguredContentTypes == null) { - String[] xmlTypes = StructuredTextPartitionerForXML.getConfiguredContentTypes(); - String[] htmlTypes = StructuredTextPartitionerForHTML.getConfiguredContentTypes(); - fConfiguredContentTypes = new String[2 + xmlTypes.length + htmlTypes.length]; - - fConfiguredContentTypes[0] = IStructuredPartitions.DEFAULT_PARTITION; - fConfiguredContentTypes[1] = IStructuredPartitions.UNKNOWN_PARTITION; - - int index = 0; - System.arraycopy(xmlTypes, 0, fConfiguredContentTypes, index += 2, xmlTypes.length); - System.arraycopy(htmlTypes, 0, fConfiguredContentTypes, index += xmlTypes.length, htmlTypes.length); - } - - return fConfiguredContentTypes; - } - - protected IContentAssistProcessor[] getContentAssistProcessors(ISourceViewer sourceViewer, String partitionType) { - IContentAssistProcessor[] processors = null; - - if ((partitionType == IHTMLPartitions.HTML_DEFAULT) || (partitionType == IHTMLPartitions.HTML_COMMENT)) { - processors = new IContentAssistProcessor[]{new HTMLContentAssistProcessor()}; - } - else if (partitionType == IHTMLPartitions.SCRIPT) { - processors = new IContentAssistProcessor[]{new JavaScriptContentAssistProcessor()}; - } - else if (partitionType == ICSSPartitions.STYLE) { - processors = new IContentAssistProcessor[]{new CSSContentAssistProcessor()}; - } - else if (partitionType == IStructuredPartitions.UNKNOWN_PARTITION) { - processors = new IContentAssistProcessor[]{new NoRegionContentAssistProcessorForHTML()}; - } - - return processors; - } - - public IContentFormatter getContentFormatter(ISourceViewer sourceViewer) { - final MultiPassContentFormatter formatter = new MultiPassContentFormatter(getConfiguredDocumentPartitioning(sourceViewer), IHTMLPartitions.HTML_DEFAULT); - - formatter.setMasterStrategy(new StructuredFormattingStrategy(new HTMLFormatProcessorImpl())); - - return formatter; - } - - public ITextDoubleClickStrategy getDoubleClickStrategy(ISourceViewer sourceViewer, String contentType) { - if (contentType == IHTMLPartitions.HTML_DEFAULT) { - // use xml's doubleclick strategy - return getXMLSourceViewerConfiguration().getDoubleClickStrategy(sourceViewer, IXMLPartitions.XML_DEFAULT); - } - else - return super.getDoubleClickStrategy(sourceViewer, contentType); - } - - public IHyperlinkDetector[] getHyperlinkDetectors(ISourceViewer sourceViewer) { - if (sourceViewer == null || !fPreferenceStore.getBoolean(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_HYPERLINKS_ENABLED)) - return null; - - List allDetectors = new ArrayList(0); - allDetectors.add(new XMLHyperlinkDetector()); - - IHyperlinkDetector[] superDetectors = super.getHyperlinkDetectors(sourceViewer); - for (int m = 0; m < superDetectors.length; m++) { - IHyperlinkDetector detector = superDetectors[m]; - if (!allDetectors.contains(detector)) { - allDetectors.add(detector); - } - } - return (IHyperlinkDetector[]) allDetectors.toArray(new IHyperlinkDetector[0]); - } - - public String[] getIndentPrefixes(ISourceViewer sourceViewer, String contentType) { - Vector vector = new Vector(); - - // prefix[0] is either '\t' or ' ' x tabWidth, depending on preference - Preferences preferences = HTMLCorePlugin.getDefault().getPluginPreferences(); - int indentationWidth = preferences.getInt(HTMLCorePreferenceNames.INDENTATION_SIZE); - String indentCharPref = preferences.getString(HTMLCorePreferenceNames.INDENTATION_CHAR); - boolean useSpaces = HTMLCorePreferenceNames.SPACE.equals(indentCharPref); - - for (int i = 0; i <= indentationWidth; i++) { - StringBuffer prefix = new StringBuffer(); - boolean appendTab = false; - - if (useSpaces) { - for (int j = 0; j + i < indentationWidth; j++) - prefix.append(' '); - - if (i != 0) - appendTab = true; - } - else { - for (int j = 0; j < i; j++) - prefix.append(' '); - - if (i != indentationWidth) - appendTab = true; - } - - if (appendTab) { - prefix.append('\t'); - vector.add(prefix.toString()); - // remove the tab so that indentation - tab is also an indent - // prefix - prefix.deleteCharAt(prefix.length() - 1); - } - vector.add(prefix.toString()); - } - - vector.add(""); //$NON-NLS-1$ - - return (String[]) vector.toArray(new String[vector.size()]); - } - - protected IInformationProvider getInformationProvider(ISourceViewer sourceViewer, String partitionType) { - IInformationProvider provider = null; - if (partitionType == IHTMLPartitions.HTML_DEFAULT) { - // HTML - provider = new HTMLInformationProvider(); - } - else if (partitionType == IHTMLPartitions.SCRIPT) { - // HTML JavaScript - provider = new JavaScriptInformationProvider(); - } - return provider; - } - - public LineStyleProvider[] getLineStyleProviders(ISourceViewer sourceViewer, String partitionType) { - LineStyleProvider[] providers = null; - - if (partitionType == IHTMLPartitions.HTML_DEFAULT || partitionType == IHTMLPartitions.HTML_COMMENT || partitionType == IHTMLPartitions.HTML_DECLARATION) { - providers = new LineStyleProvider[]{getLineStyleProviderForHTML()}; - } - else if (partitionType == IHTMLPartitions.SCRIPT) { - providers = new LineStyleProvider[]{getLineStyleProviderForJavascript()}; - } - else if (partitionType == ICSSPartitions.STYLE) { - providers = new LineStyleProvider[]{getLineStyleProviderForEmbeddedCSS()}; - } - - return providers; - } - - private LineStyleProvider getLineStyleProviderForEmbeddedCSS() { - if (fLineStyleProviderForEmbeddedCSS == null) { - fLineStyleProviderForEmbeddedCSS = new LineStyleProviderForEmbeddedCSS(); - } - return fLineStyleProviderForEmbeddedCSS; - } - - private LineStyleProvider getLineStyleProviderForHTML() { - if (fLineStyleProviderForHTML == null) { - fLineStyleProviderForHTML = new LineStyleProviderForHTML(); - } - return fLineStyleProviderForHTML; - } - - private LineStyleProvider getLineStyleProviderForJavascript() { - if (fLineStyleProviderForJavascript == null) { - fLineStyleProviderForJavascript = new LineStyleProviderForJavaScript(); - } - return fLineStyleProviderForJavascript; - } - - public ITextHover getTextHover(ISourceViewer sourceViewer, String contentType, int stateMask) { - ITextHover textHover = null; - - // look for appropriate text hover processor to return based on - // content type and state mask - TextHoverManager manager = SSEUIPlugin.getDefault().getTextHoverManager(); - TextHoverManager.TextHoverDescriptor[] hoverDescs = manager.getTextHovers(); - int i = 0; - while (i < hoverDescs.length && textHover == null) { - if (hoverDescs[i].isEnabled() && EditorUtility.computeStateMask(hoverDescs[i].getModifierString()) == stateMask) { - String hoverType = hoverDescs[i].getId(); - if (TextHoverManager.COMBINATION_HOVER.equalsIgnoreCase(hoverType)) { - // check if script or html is needed - if (contentType == IHTMLPartitions.SCRIPT) { - textHover = manager.createBestMatchHover(new JavaScriptTagInfoHoverProcessor()); - } - else if (contentType == IHTMLPartitions.HTML_DEFAULT) { - textHover = manager.createBestMatchHover(new HTMLTagInfoHoverProcessor()); - } - } - else if (TextHoverManager.DOCUMENTATION_HOVER.equalsIgnoreCase(hoverType)) - // check if script or html is needed - if (contentType == IHTMLPartitions.SCRIPT) { - textHover = new JavaScriptTagInfoHoverProcessor(); - } - else if (contentType == IHTMLPartitions.HTML_DEFAULT) { - textHover = new HTMLTagInfoHoverProcessor(); - } - } - i++; - } - - // no appropriate text hovers found, try super - if (textHover == null) { - textHover = super.getTextHover(sourceViewer, contentType, stateMask); - } - return textHover; - } - - private StructuredTextViewerConfiguration getXMLSourceViewerConfiguration() { - if (fXMLSourceViewerConfiguration == null) { - fXMLSourceViewerConfiguration = new StructuredTextViewerConfigurationXML(); - } - return fXMLSourceViewerConfiguration; - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/HTMLUIMessages.java b/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/HTMLUIMessages.java deleted file mode 100644 index 5b5b537e44..0000000000 --- a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/HTMLUIMessages.java +++ /dev/null @@ -1,117 +0,0 @@ -/********************************************************************** - * Copyright (c) 2005 IBM Corporation and others. All rights reserved. This - * program and the accompanying materials are made available under the terms of - * 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.html.ui.internal; - -import java.util.MissingResourceException; -import java.util.ResourceBundle; - -import org.eclipse.osgi.util.NLS; - -/** - * Strings used by HTML UI - * - * @plannedfor 1.0 - */ -public class HTMLUIMessages extends NLS { - private static final String BUNDLE_NAME = "org.eclipse.wst.html.ui.internal.HTMLUIPluginResources";//$NON-NLS-1$ - private static ResourceBundle fResourceBundle; - - static { - // load message values from bundle file - NLS.initializeMessages(BUNDLE_NAME, HTMLUIMessages.class); - } - - private HTMLUIMessages() { - // cannot create new instance of this class - } - - public static ResourceBundle getResourceBundle() { - try { - if (fResourceBundle == null) - fResourceBundle = ResourceBundle.getBundle(BUNDLE_NAME); - } - catch (MissingResourceException x) { - fResourceBundle = null; - } - return fResourceBundle; - } - - public static String Sample_HTML_doc; - public static String HTMLFilesPreferencePage_0; - public static String _UI_WIZARD_NEW_TITLE; - public static String _UI_WIZARD_NEW_HEADING; - public static String _UI_WIZARD_NEW_DESCRIPTION; - public static String _ERROR_FILENAME_MUST_END_HTML; - public static String _WARNING_FOLDER_MUST_BE_INSIDE_WEB_CONTENT; - public static String ResourceGroup_nameExists; - public static String NewHTMLTemplatesWizardPage_0; - public static String NewHTMLTemplatesWizardPage_1; - public static String NewHTMLTemplatesWizardPage_2; - public static String NewHTMLTemplatesWizardPage_3; - public static String NewHTMLTemplatesWizardPage_4; - public static String NewHTMLTemplatesWizardPage_5; - public static String NewHTMLTemplatesWizardPage_6; - public static String Creating_files_encoding; - public static String MESSAGE_HTML_VALIDATION_MESSAGE_UI_; - public static String CleanupDocument_label; // resource bundle - public static String CleanupDocument_tooltip; // resource bundle - public static String CleanupDocument_description; // resource bundle - public static String ToggleComment_label; // resource bundle - public static String ToggleComment_tooltip; // resource bundle - public static String ToggleComment_description; // resource bundle - public static String AddBlockComment_label; // resource bundle - public static String AddBlockComment_tooltip; // resource bundle - public static String AddBlockComment_description; // resource bundle - public static String RemoveBlockComment_label; // resource bundle - public static String RemoveBlockComment_tooltip; // resource bundle - public static String RemoveBlockComment_description; // resource bundle - public static String FindOccurrences_label; // resource bundle - public static String Creating_files; - public static String Encoding_desc; - public static String UI_Description_of_role_of_following_DOCTYPE; - public static String UI_Default_HTML_DOCTYPE_ID___1; - public static String UI_Public_ID; - public static String UI_System_ID; - public static String UI_none; - public static String UI_CSS_profile___2; - public static String WebContentSettingsPropertyPage_0; - public static String ProjectWebContentSettingsPropertyPage_0; - - public static String Preferred_markup_case_UI_; - public static String Tag_names__UI_; - public static String Tag_names_Upper_case_UI_; - public static String Tag_names_Lower_case_UI_; - public static String Attribute_names__UI_; - public static String Attribute_names_Upper_case_UI_; - public static String Attribute_names_Lower_case_UI_; - public static String Cleanup_UI_; - public static String Tag_name_case_for_HTML_UI_; - public static String Tag_name_case_As_is_UI_; - public static String Tag_name_case_Lower_UI_; - public static String Tag_name_case_Upper_UI_; - public static String Attribute_name_case_for_HTML_UI_; - public static String Attribute_name_case_As_is_UI_; - public static String Attribute_name_case_Lower_UI_; - public static String Attribute_name_case_Upper_UI_; - public static String Insert_required_attributes_UI_; - public static String Insert_missing_tags_UI_; - public static String Quote_attribute_values_UI_; - public static String Format_source_UI_; - public static String Convert_EOL_codes_UI_; - public static String EOL_Windows_UI; - public static String EOL_Unix_UI; - public static String EOL_Mac_UI; - - // below are possibly unused strings that may be deleted - public static String HTMLFilesPreferencePage_1; - public static String HTMLFilesPreferencePage_2; - public static String HTMLFilesPreferencePage_3; - // above are possibly unused strings that may be deleted -} diff --git a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/HTMLUIPlugin.java b/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/HTMLUIPlugin.java deleted file mode 100644 index e77314f6e1..0000000000 --- a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/HTMLUIPlugin.java +++ /dev/null @@ -1,98 +0,0 @@ -/******************************************************************************* - * 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.html.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.editors.text.templates.ContributionContextTypeRegistry; -import org.eclipse.ui.editors.text.templates.ContributionTemplateStore; -import org.eclipse.ui.plugin.AbstractUIPlugin; -import org.eclipse.wst.html.ui.internal.preferences.HTMLUIPreferenceNames; -import org.eclipse.wst.html.ui.internal.templates.TemplateContextTypeIdsHTML; -import org.eclipse.wst.sse.ui.internal.provisional.registry.AdapterFactoryRegistry; -import org.eclipse.wst.sse.ui.internal.provisional.registry.AdapterFactoryRegistryImpl; - -/** - * The main plugin class to be used in the desktop. - */ -public class HTMLUIPlugin extends AbstractUIPlugin { - public final static String ID = "org.eclipse.wst.html.ui"; //$NON-NLS-1$ - - protected static HTMLUIPlugin instance = null; - - /** - * The template store for the html editor. - */ - private TemplateStore fTemplateStore; - - /** - * The template context type registry for the html editor. - */ - private ContextTypeRegistry fContextTypeRegistry; - - public HTMLUIPlugin() { - super(); - instance = this; - } - - public static HTMLUIPlugin getDefault() { - return instance; - } - - public synchronized static HTMLUIPlugin getInstance() { - return instance; - } - - public AdapterFactoryRegistry getAdapterFactoryRegistry() { - return AdapterFactoryRegistryImpl.getInstance(); - - } - - /** - * Returns the template store for the html editor templates. - * - * @return the template store for the html editor templates - */ - public TemplateStore getTemplateStore() { - if (fTemplateStore == null) { - fTemplateStore = new ContributionTemplateStore(getTemplateContextRegistry(), getPreferenceStore(), HTMLUIPreferenceNames.TEMPLATES_KEY); - - try { - fTemplateStore.load(); - } catch (IOException e) { - Logger.logException(e); - } - } - return fTemplateStore; - } - - /** - * Returns the template context type registry for the html plugin. - * - * @return the template context type registry for the html plugin - */ - public ContextTypeRegistry getTemplateContextRegistry() { - if (fContextTypeRegistry == null) { - ContributionContextTypeRegistry registry = new ContributionContextTypeRegistry(); - registry.addContextType(TemplateContextTypeIdsHTML.ALL); - registry.addContextType(TemplateContextTypeIdsHTML.NEW); - registry.addContextType(TemplateContextTypeIdsHTML.TAG); - registry.addContextType(TemplateContextTypeIdsHTML.ATTRIBUTE); - registry.addContextType(TemplateContextTypeIdsHTML.ATTRIBUTE_VALUE); - - fContextTypeRegistry = registry; - } - - return fContextTypeRegistry; - } -} diff --git a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/HTMLUIPluginResources.properties b/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/HTMLUIPluginResources.properties deleted file mode 100644 index c7be050dfb..0000000000 --- a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/HTMLUIPluginResources.properties +++ /dev/null @@ -1,89 +0,0 @@ -############################################################################### -# 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 -############################################################################### -## The following line is a sample HTML document. Please translate only the following parts: -## HTML Highlighting Preferences -## we need a flaming logo -Sample_HTML_doc=<!DOCTYPE HTML\n\tPUBLIC \"-//W3C/DTD/ HTML 4.01 Transitional//EN\"\n\t\"http://www.w3.org/TR/html4/loose.dtd\">\n<HTML>\n\t<HEAD>\n\t\t<META content=\"text/html\">\n\t\t<TITLE>HTML Highlighting Preferences</TITLE>\n\t</HEAD>\n<BODY>\n\t<!--\n\t\twe need a flaming logo!\n\t-->\n</BODY>\n</HTML> - -HTMLFilesPreferencePage_0=Loading files... -# -_UI_WIZARD_NEW_TITLE = New HTML Page -_UI_WIZARD_NEW_HEADING = HTML Page -_UI_WIZARD_NEW_DESCRIPTION = Create a new HTML Page. -_ERROR_FILENAME_MUST_END_HTML = The file name must end in one of the following extensions {0}. -_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. -NewHTMLTemplatesWizardPage_0=Select HTML Template -NewHTMLTemplatesWizardPage_1=Select a template as initial content in the HTML page. -NewHTMLTemplatesWizardPage_2=Name -NewHTMLTemplatesWizardPage_3=Description -NewHTMLTemplatesWizardPage_4=Use HTML Template -NewHTMLTemplatesWizardPage_5=Preview -NewHTMLTemplatesWizardPage_6=Templates are 'New HTML' templates found in the <a>HTML Templates</a> preference page. -# -Creating_files_encoding=Creating files encoding preference -MESSAGE_HTML_VALIDATION_MESSAGE_UI_=HTML Syntax : {0} -# 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 -Creating_files=Creating files -Encoding_desc=The following encoding will apply: -Preferred_markup_case_UI_=Preferred markup case for content assist, and code generation -Tag_names__UI_=Tag names: -Tag_names_Upper_case_UI_=&Uppercase -Tag_names_Lower_case_UI_=&Lowercase -Attribute_names__UI_=Attribute names: -Attribute_names_Upper_case_UI_=U&ppercase -Attribute_names_Lower_case_UI_=L&owercase -Cleanup_UI_=Cleanup -Tag_name_case_for_HTML_UI_=Tag name case for HTML: -Tag_name_case_As_is_UI_=&As-is -Tag_name_case_Lower_UI_=&Lower -Tag_name_case_Upper_UI_=&Upper -Attribute_name_case_for_HTML_UI_=Attribute name case for HTML: -Attribute_name_case_As_is_UI_=A&s-is -Attribute_name_case_Lower_UI_=L&ower -Attribute_name_case_Upper_UI_=U&pper -Insert_required_attributes_UI_=Insert &required attributes -Insert_missing_tags_UI_=&Insert missing tags -Quote_attribute_values_UI_=&Quote attribute values -Format_source_UI_=&Format source -Convert_EOL_codes_UI_=Convert line &delimiters to -EOL_Windows_UI=&Windows -EOL_Unix_UI=U&NIX -EOL_Mac_UI=&Mac - -# web content settings -UI_Description_of_role_of_following_DOCTYPE=Use the following default document type when no DOCTYPE is declared in a file: -UI_Default_HTML_DOCTYPE_ID___1=Document type: -UI_Public_ID=Public ID: -UI_System_ID=System ID: -UI_none=none -UI_CSS_profile___2=CSS profile: -WebContentSettingsPropertyPage_0=The properties used that cannot or are not specified in web files. The project setting is used if you specify "none." -ProjectWebContentSettingsPropertyPage_0=The properties for J2EE Web projects act as "project" default to be looked up when no properties are specified for a particular web file. - -# below are possibly unused strings that may be deleted -HTMLFilesPreferencePage_1=Add this suffix (if not specified): -HTMLFilesPreferencePage_2=Insert DOCTYPE declaration -HTMLFilesPreferencePage_3=Insert GENERATOR with META tag -# above are possibly unused strings that may be deleted
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/Logger.java b/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/Logger.java deleted file mode 100644 index 926001320e..0000000000 --- a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/Logger.java +++ /dev/null @@ -1,160 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 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 - * Jens Lukowski/Innoopract - initial renaming/restructuring - * - *******************************************************************************/ -package org.eclipse.wst.html.ui.internal; - - - -import com.ibm.icu.util.StringTokenizer; - -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Platform; -import org.eclipse.core.runtime.Status; -import org.osgi.framework.Bundle; - - -/** - * Small convenience class to log messages to plugin's log file and also, if - * desired, the console. This class should only be used by classes in this - * plugin. Other plugins should make their own copy, with appropriate ID. - */ -public class Logger { - private static final String PLUGIN_ID = "org.eclipse.wst.html.ui"; //$NON-NLS-1$ - - public static final int ERROR = IStatus.ERROR; // 4 - public static final int ERROR_DEBUG = 200 + ERROR; - public static final int INFO = IStatus.INFO; // 1 - public static final int INFO_DEBUG = 200 + INFO; - - public static final int OK = IStatus.OK; // 0 - - public static final int OK_DEBUG = 200 + OK; - - 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 + 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 == OK_DEBUG || level == INFO_DEBUG || level == WARNING_DEBUG || level == ERROR_DEBUG) { - if (!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, PLUGIN_ID, severity, message, exception); - Bundle bundle = Platform.getBundle(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 (isTracing(category)) { - message = (message != null) ? message : "null"; //$NON-NLS-1$ - Status statusObj = new Status(IStatus.OK, PLUGIN_ID, IStatus.OK, message, exception); - Bundle bundle = Platform.getBundle(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 (!isDebugging()) - return false; - - String traceFilter = Platform.getDebugOption(PLUGIN_ID + 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) { - _log(level, message, null); - } - - public static void log(int level, String message, Throwable exception) { - _log(level, message, exception); - } - - public static void logException(String message, Throwable exception) { - _log(ERROR, message, exception); - } - - public static void logException(Throwable exception) { - _log(ERROR, exception.getMessage(), exception); - } - - public static void trace(String category, String message) { - _trace(category, message, null); - } - - public static void traceException(String category, String message, Throwable exception) { - _trace(category, message, exception); - } - - public static void traceException(String category, Throwable exception) { - _trace(category, exception.getMessage(), exception); - } -} diff --git a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/autoedit/AutoEditStrategyForTabs.java b/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/autoedit/AutoEditStrategyForTabs.java deleted file mode 100644 index 0eb394ccf9..0000000000 --- a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/autoedit/AutoEditStrategyForTabs.java +++ /dev/null @@ -1,188 +0,0 @@ -/********************************************************************************* - * Copyright (c) 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of 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 - * Jens Lukowski/Innoopract - initial renaming/restructuring - * - *******************************************************************************/ - -package org.eclipse.wst.html.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.html.ui.internal.Logger; - -/** - * AutoEditStrategy to handle characters inserted when Tab key is pressed - */ -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); - } - - /** - * 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(); - } - } - - /** - * 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; - } - - /** - * 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; - } -} diff --git a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/autoedit/StructuredAutoEditStrategyHTML.java b/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/autoedit/StructuredAutoEditStrategyHTML.java deleted file mode 100644 index d17d678141..0000000000 --- a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/autoedit/StructuredAutoEditStrategyHTML.java +++ /dev/null @@ -1,143 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.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.html.ui.internal.autoedit; - -import org.eclipse.jface.text.BadLocationException; -import org.eclipse.jface.text.DocumentCommand; -import org.eclipse.jface.text.IAutoEditStrategy; -import org.eclipse.jface.text.IDocument; -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.sse.core.StructuredModelManager; -import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel; -import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion; -import org.eclipse.wst.xml.core.internal.provisional.document.IDOMElement; -import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode; -import org.eclipse.wst.xml.ui.internal.Logger; -import org.w3c.dom.Node; - -/** - * Automatically inserts closing comment tag or end tag when appropriate. - */ -public class StructuredAutoEditStrategyHTML implements IAutoEditStrategy { - /* - * NOTE: copies of this class exists in - * org.eclipse.wst.xml.ui.internal.autoedit - * org.eclipse.wst.html.ui.internal.autoedit - */ - public void customizeDocumentCommand(IDocument document, DocumentCommand command) { - Object textEditor = getActiveTextEditor(); - if (!(textEditor instanceof ITextEditorExtension3 && ((ITextEditorExtension3) textEditor).getInsertMode() == ITextEditorExtension3.SMART_INSERT)) - return; - - IStructuredModel model = null; - try { - model = StructuredModelManager.getModelManager().getExistingModelForRead(document); - if (model != null) { - if (command.text != null) { - smartInsertForComment(command, document, model); - smartInsertForEndTag(command, document, model); - } - } - } - finally { - if (model != null) - model.releaseFromRead(); - } - } - - private boolean isCommentNode(IDOMNode node) { - return (node != null && node instanceof IDOMElement && ((IDOMElement) node).isCommentTag()); - } - - private boolean isDocumentNode(IDOMNode node) { - return (node != null && node.getNodeType() == Node.DOCUMENT_NODE); - } - - private void smartInsertForComment(DocumentCommand command, IDocument document, IStructuredModel model) { - try { - if (command.text.equals("-") && document.getLength() >= 3 && document.get(command.offset - 3, 3).equals("<!-")) { //$NON-NLS-1$ //$NON-NLS-2$ - command.text += " -->"; //$NON-NLS-1$ - command.shiftsCaret = false; - command.caretOffset = command.offset + 2; - command.doit = false; - } - } - catch (BadLocationException e) { - Logger.logException(e); - } - - } - - private void smartInsertForEndTag(DocumentCommand command, IDocument document, IStructuredModel model) { - try { - if (command.text.equals("/") && document.getLength() >= 1 && document.get(command.offset - 1, 1).equals("<")) { //$NON-NLS-1$ //$NON-NLS-2$ - IDOMNode parentNode = (IDOMNode) ((IDOMNode) model.getIndexedRegion(command.offset - 1)).getParentNode(); - if (isCommentNode(parentNode)) { - // loop and find non comment node parent - while (parentNode != null && isCommentNode(parentNode)) { - parentNode = (IDOMNode) parentNode.getParentNode(); - } - } - - if (!isDocumentNode(parentNode)) { - // only add end tag if one does not already exist or if - // add '/' does not create one already - IStructuredDocumentRegion endTagStructuredDocumentRegion = parentNode.getEndStructuredDocumentRegion(); - if (endTagStructuredDocumentRegion == null) { - StringBuffer toAdd = new StringBuffer(parentNode.getNodeName()); - if (toAdd.length() > 0) { - toAdd.append(">"); //$NON-NLS-1$ - String suffix = toAdd.toString(); - if ((document.getLength() < command.offset + suffix.length()) || (!suffix.equals(document.get(command.offset, suffix.length())))) { - command.text += suffix; - } - } - } - } - } - } - catch (BadLocationException e) { - Logger.logException(e); - } - } - - /** - * Return the active text editor if possible, otherwise the active editor - * part. - * - * @return Object - */ - private Object getActiveTextEditor() { - 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) - return editor; - ITextEditor textEditor = (ITextEditor) editor.getAdapter(ITextEditor.class); - if (textEditor != null) - return textEditor; - return editor; - } - } - } - return null; - } -} diff --git a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/contentassist/CustomTemplateProposal.java b/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/contentassist/CustomTemplateProposal.java deleted file mode 100644 index 3d08fde914..0000000000 --- a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/contentassist/CustomTemplateProposal.java +++ /dev/null @@ -1,40 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - * - *******************************************************************************/ -package org.eclipse.wst.html.ui.internal.contentassist; - -import org.eclipse.jface.text.IRegion; -import org.eclipse.jface.text.templates.Template; -import org.eclipse.jface.text.templates.TemplateContext; -import org.eclipse.jface.text.templates.TemplateProposal; -import org.eclipse.swt.graphics.Image; -import org.eclipse.wst.sse.core.utils.StringUtils; -import org.eclipse.wst.sse.ui.internal.contentassist.IRelevanceCompletionProposal; - -/** - * Purpose of this class is to make the additional proposal info into content - * fit for an HTML viewer (by escaping characters) - */ -class CustomTemplateProposal extends TemplateProposal implements IRelevanceCompletionProposal { - // copies of this class exist in: - // org.eclipse.jst.jsp.ui.internal.contentassist - // org.eclipse.wst.html.ui.internal.contentassist - // org.eclipse.wst.xml.ui.internal.contentassist - - public CustomTemplateProposal(Template template, TemplateContext context, IRegion region, Image image, int relevance) { - super(template, context, region, image, relevance); - } - - public String getAdditionalProposalInfo() { - String additionalInfo = super.getAdditionalProposalInfo(); - return StringUtils.convertToHTMLContent(additionalInfo); - } -} diff --git a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/contentassist/HTMLContentAssistProcessor.java b/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/contentassist/HTMLContentAssistProcessor.java deleted file mode 100644 index a1ad32dc43..0000000000 --- a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/contentassist/HTMLContentAssistProcessor.java +++ /dev/null @@ -1,488 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2006 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.html.ui.internal.contentassist; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.jface.text.ITextViewer; -import org.eclipse.jface.text.contentassist.ICompletionProposal; -import org.eclipse.jface.util.IPropertyChangeListener; -import org.eclipse.jface.util.PropertyChangeEvent; -import org.eclipse.wst.css.ui.internal.contentassist.CSSContentAssistProcessor; -import org.eclipse.wst.html.core.internal.contentmodel.HTMLCMDocument; -import org.eclipse.wst.html.core.internal.provisional.HTML40Namespace; -import org.eclipse.wst.html.core.internal.provisional.HTMLCMProperties; -import org.eclipse.wst.html.ui.internal.HTMLUIPlugin; -import org.eclipse.wst.html.ui.internal.editor.HTMLEditorPluginImageHelper; -import org.eclipse.wst.html.ui.internal.editor.HTMLEditorPluginImages; -import org.eclipse.wst.html.ui.internal.preferences.HTMLUIPreferenceNames; -import org.eclipse.wst.html.ui.internal.templates.TemplateContextTypeIdsHTML; -import org.eclipse.wst.javascript.ui.internal.common.contentassist.JavaScriptContentAssistProcessor; -import org.eclipse.wst.sse.core.StructuredModelManager; -import org.eclipse.wst.sse.core.internal.provisional.IModelManager; -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.sse.core.internal.provisional.IndexedRegion; -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.ITextRegionList; -import org.eclipse.wst.sse.ui.internal.StructuredTextViewer; -import org.eclipse.wst.sse.ui.internal.contentassist.ContentAssistUtils; -import org.eclipse.wst.sse.ui.internal.contentassist.CustomCompletionProposal; -import org.eclipse.wst.xml.core.internal.contentmodel.CMDocument; -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.core.internal.provisional.document.IDOMDocument; -import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel; -import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode; -import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext; -import org.eclipse.wst.xml.core.internal.ssemodelquery.ModelQueryAdapter; -import org.eclipse.wst.xml.ui.internal.contentassist.AbstractContentAssistProcessor; -import org.eclipse.wst.xml.ui.internal.contentassist.ContentAssistRequest; -import org.eclipse.wst.xml.ui.internal.contentassist.XMLContentModelGenerator; -import org.eclipse.wst.xml.ui.internal.contentassist.XMLRelevanceConstants; -import org.w3c.dom.Document; -import org.w3c.dom.DocumentType; -import org.w3c.dom.Element; -import org.w3c.dom.Node; - -public class HTMLContentAssistProcessor extends AbstractContentAssistProcessor implements IPropertyChangeListener { - private INodeAdapterFactory factoryForCSS = null; - protected IPreferenceStore fPreferenceStore = null; - protected boolean isXHTML = false; - private HTMLTemplateCompletionProcessor fTemplateProcessor = null; - private List fTemplateContexts = new ArrayList(); - - public HTMLContentAssistProcessor() { - - super(); - } - - protected void addAttributeNameProposals(ContentAssistRequest contentAssistRequest) { - addTemplates(contentAssistRequest, TemplateContextTypeIdsHTML.ATTRIBUTE); - super.addAttributeNameProposals(contentAssistRequest); - } - - protected void addAttributeValueProposals(ContentAssistRequest contentAssistRequest) { - addTemplates(contentAssistRequest, TemplateContextTypeIdsHTML.ATTRIBUTE_VALUE); - super.addAttributeValueProposals(contentAssistRequest); - } - - /** - * Add the proposals for a completely empty document - */ - protected void addEmptyDocumentProposals(ContentAssistRequest contentAssistRequest) { - addTemplates(contentAssistRequest, TemplateContextTypeIdsHTML.NEW); - } - - protected void addPCDATAProposal(String nodeName, ContentAssistRequest contentAssistRequest) { - if (isXHTML) - super.addPCDATAProposal(nodeName, contentAssistRequest); - } - - protected void addStartDocumentProposals(ContentAssistRequest contentAssistRequest) { - if (isXHTML) - addEmptyDocumentProposals(contentAssistRequest); - } - - protected void addTagInsertionProposals(ContentAssistRequest contentAssistRequest, int childPosition) { - addTemplates(contentAssistRequest, TemplateContextTypeIdsHTML.TAG); - super.addTagInsertionProposals(contentAssistRequest, childPosition); - } - - /** - * Adds templates to the list of proposals - * - * @param contentAssistRequest - * @param context - */ - private void addTemplates(ContentAssistRequest contentAssistRequest, String context) { - addTemplates(contentAssistRequest, context, contentAssistRequest.getReplacementBeginPosition()); - } - - /** - * Adds templates to the list of proposals - * - * @param contentAssistRequest - * @param context - * @param startOffset - */ - private void addTemplates(ContentAssistRequest contentAssistRequest, String context, int startOffset) { - if (contentAssistRequest == null) - return; - - // if already adding template proposals for a certain context type, do - // not add again - if (!fTemplateContexts.contains(context)) { - fTemplateContexts.add(context); - boolean useProposalList = !contentAssistRequest.shouldSeparate(); - - if (getTemplateCompletionProcessor() != null) { - getTemplateCompletionProcessor().setContextType(context); - ICompletionProposal[] proposals = getTemplateCompletionProcessor().computeCompletionProposals(fTextViewer, startOffset); - for (int i = 0; i < proposals.length; ++i) { - if (useProposalList) - contentAssistRequest.addProposal(proposals[i]); - else - contentAssistRequest.addMacro(proposals[i]); - } - } - } - } - - protected boolean beginsWith(String aString, String prefix) { - if (aString == null || prefix == null || prefix.length() == 0) - return true; - int minimumLength = Math.min(prefix.length(), aString.length()); - String beginning = aString.substring(0, minimumLength); - return beginning.equalsIgnoreCase(prefix); - } - - protected ContentAssistRequest computeCompletionProposals(int documentPosition, String matchString, ITextRegion completionRegion, IDOMNode treeNode, IDOMNode xmlnode) { - ContentAssistRequest request = super.computeCompletionProposals(documentPosition, matchString, completionRegion, treeNode, xmlnode); - // bug115927 use original document position for all/any region templates - addTemplates(request, TemplateContextTypeIdsHTML.ALL, documentPosition); - return request; - } - - /** - * Return a list of proposed code completions based on the specified - * location within the document that corresponds to the current cursor - * position within the text-editor control. - * - * @param documentPosition - * a location within the document - * @return an array of code-assist items - */ - public ICompletionProposal[] computeCompletionProposals(ITextViewer textViewer, int documentPosition) { - fTemplateContexts.clear(); - - IndexedRegion treeNode = ContentAssistUtils.getNodeAt(textViewer, documentPosition); - IDOMNode node = (IDOMNode) treeNode; - setErrorMessage(null); - - // check if it's in a comment node - IStructuredDocument structuredDocument = (IStructuredDocument) textViewer.getDocument(); - IStructuredDocumentRegion fn = structuredDocument.getRegionAtCharacterOffset(documentPosition); - if (fn != null && fn.getType() == DOMRegionContext.XML_COMMENT_TEXT && documentPosition != fn.getStartOffset()) { - return new ICompletionProposal[0]; - } - - // CMVC 242695 - // if it's a </script> tag, bounce back to JS ca processor... - if (fn != null && fn.getType() == DOMRegionContext.XML_TAG_NAME && documentPosition == fn.getStartOffset()) { - ITextRegionList v = fn.getRegions(); - if (v.size() > 1) { - // determine that it's a close tag - if ((v.get(0)).getType() == DOMRegionContext.XML_END_TAG_OPEN) { - Iterator it = v.iterator(); - ITextRegion region = null; - // search for script tag name - while (it.hasNext()) { - region = (ITextRegion) it.next(); - if (fn.getText(region).equalsIgnoreCase("script")) { //$NON-NLS-1$ - // return JS content assist... - JavaScriptContentAssistProcessor jsProcessor = new JavaScriptContentAssistProcessor(); - return jsProcessor.computeCompletionProposals(textViewer, documentPosition); - } - } - } - } - } - - isXHTML = getXHTML(node); - - fGenerator = null; // force reload of content generator - - // handle blank HTML document case - if (treeNode == null || isViewerEmpty(textViewer)) { - // cursor is at the EOF - ICompletionProposal htmlTagProposal = getHTMLTagPropsosal((StructuredTextViewer) textViewer, documentPosition); - ICompletionProposal[] superResults = super.computeCompletionProposals(textViewer, documentPosition); - if (superResults != null && superResults.length > 0 && htmlTagProposal != null) { - ICompletionProposal[] blankHTMLDocResults = new ICompletionProposal[superResults.length + 1]; - blankHTMLDocResults[0] = htmlTagProposal; - System.arraycopy(superResults, 0, blankHTMLDocResults, 1, superResults.length); - return blankHTMLDocResults; - } - } - - if (node != null && node.getNodeType() == Node.ELEMENT_NODE) { - - // check embedded CSS proposals at the beginning of the STYLE end - // tag - Element element = (Element) node; - String tagName = element.getTagName(); - if (tagName != null && tagName.equalsIgnoreCase(HTML40Namespace.ATTR_NAME_STYLE)) {//$NON-NLS-1$ - IStructuredDocumentRegion endStructuredDocumentRegion = node.getEndStructuredDocumentRegion(); - if (endStructuredDocumentRegion != null && endStructuredDocumentRegion.getStartOffset() == documentPosition) { - IStructuredDocumentRegion startStructuredDocumentRegion = node.getStartStructuredDocumentRegion(); - if (startStructuredDocumentRegion != null) { - int offset = startStructuredDocumentRegion.getEndOffset(); - int pos = documentPosition - offset; - ICompletionProposal[] proposals = getCSSProposals(textViewer, pos, node, offset, (char) 0); - if (proposals != null) - return proposals; - } - } - } - - // check inline CSS proposals - // need to find attr region from sd region - IStructuredDocumentRegion sdRegion = ContentAssistUtils.getStructuredDocumentRegion(textViewer, documentPosition); - Iterator regions = sdRegion.getRegions().iterator(); - ITextRegion styleNameRegion = null; - ITextRegion styleValueRegion = null; - while (regions.hasNext()) { - styleNameRegion = (ITextRegion) regions.next(); - if (styleNameRegion.getType().equals(DOMRegionContext.XML_TAG_ATTRIBUTE_NAME) && sdRegion.getText(styleNameRegion).equalsIgnoreCase(HTML40Namespace.ATTR_NAME_STYLE)) { //$NON-NLS-1$ - // the next region should be "=" - if (regions.hasNext()) { - regions.next(); // skip the "=" - // next region should be attr value region - if (regions.hasNext()) { - styleValueRegion = (ITextRegion) regions.next(); - break; - } - } - } - } - - if (styleValueRegion != null) { - int offset = sdRegion.getStartOffset(styleValueRegion); - int end = sdRegion.getTextEndOffset(styleValueRegion); - if (documentPosition >= offset && documentPosition <= end) { - boolean askCSS = true; - char quote = (char) 0; - String text = sdRegion.getText(styleValueRegion); - int length = (text != null ? text.length() : 0); - if (length > 0) { - char firstChar = text.charAt(0); - if (firstChar == '"' || firstChar == '\'') { - if (documentPosition == offset) { - // before quote - askCSS = false; - } - else { - offset++; - quote = firstChar; - } - } - if (documentPosition == end) { - if (length > 1 && text.charAt(length - 1) == quote) { - // after quote - askCSS = false; - } - } - } - if (askCSS) { - int pos = documentPosition - offset; - ICompletionProposal[] proposals = getCSSProposals(textViewer, pos, node, offset, quote); - if (proposals != null) - return proposals; - } - } - } - } - - return super.computeCompletionProposals(textViewer, documentPosition); - } - - /** - * Returns true if there is no text or it's all white space, otherwise - * returns false - * - * @param treeNode - * @param textViewer - * @return boolean - */ - private boolean isViewerEmpty(ITextViewer textViewer) { - boolean isEmpty = false; - String text = textViewer.getTextWidget().getText(); - if (text == null || (text != null && text.trim().equals(""))) //$NON-NLS-1$ - isEmpty = true; - return isEmpty; - } - - /** - * @return ICompletionProposal - */ - private ICompletionProposal getHTMLTagPropsosal(StructuredTextViewer viewer, int documentPosition) { - IModelManager mm = StructuredModelManager.getModelManager(); - IStructuredModel model = null; - ICompletionProposal result = null; - try { - if (mm != null) { - model = mm.getExistingModelForRead(viewer.getDocument()); - - if (model != null) { - IDOMDocument doc = ((IDOMModel) model).getDocument(); - - ModelQuery mq = ModelQueryUtil.getModelQuery(doc); - if (mq != null) { - - // XHTML requires lowercase tagname for lookup - CMElementDeclaration htmlDecl = (CMElementDeclaration) mq.getCorrespondingCMDocument(doc).getElements().getNamedItem(HTML40Namespace.ElementName.HTML.toLowerCase()); - if (htmlDecl != null) { - StringBuffer proposedTextBuffer = new StringBuffer(); - getContentGenerator().generateTag(doc, htmlDecl, proposedTextBuffer); - - String proposedText = proposedTextBuffer.toString(); - String requiredName = getContentGenerator().getRequiredName(doc, htmlDecl); - - CustomCompletionProposal proposal = new CustomCompletionProposal(proposedText, documentPosition, - /* start pos */ - 0, /* replace length */ - requiredName.length() + 2, /* - * cursor position - * after (relavtive to - * start) - */ - HTMLEditorPluginImageHelper.getInstance().getImage(HTMLEditorPluginImages.IMG_OBJ_TAG_GENERIC), requiredName, null, null, XMLRelevanceConstants.R_TAG_NAME); - result = proposal; - } - } - } - } - } - finally { - if (model != null) - model.releaseFromRead(); - } - return result; - } - - /** - * @see AbstractContentAssistProcessor#getContentGenerator() - */ - public XMLContentModelGenerator getContentGenerator() { - if (fGenerator == null) { - if (isXHTML) - fGenerator = XHTMLMinimalContentModelGenerator.getInstance(); - else - fGenerator = HTMLMinimalContentModelGenerator.getInstance(); - } - return fGenerator; - } - - protected ICompletionProposal[] getCSSProposals(ITextViewer viewer, int pos, IDOMNode element, int offset, char quote) { - - CSSContentAssistProcessor cssProcessor = new CSSContentAssistProcessor(); - cssProcessor.setDocumentOffset(offset); - cssProcessor.setQuoteCharOfStyleAttribute(quote); - - return cssProcessor.computeCompletionProposals(viewer, pos); - } - - protected String getEmptyTagCloseString() { - if (isXHTML) - return " />"; //$NON-NLS-1$ - return ">"; //$NON-NLS-1$ - } - - private HTMLTemplateCompletionProcessor getTemplateCompletionProcessor() { - if (fTemplateProcessor == null) { - fTemplateProcessor = new HTMLTemplateCompletionProcessor(); - } - return fTemplateProcessor; - } - - /** - * Determine if this Document is an XHTML Document. Oprates solely off of - * the Document Type declaration - */ - protected boolean getXHTML(Node node) { - if (node == null) - return false; - - Document doc = null; - if (node.getNodeType() != Node.DOCUMENT_NODE) - doc = node.getOwnerDocument(); - else - doc = ((Document) node); - - if (doc instanceof IDOMDocument) - return ((IDOMDocument) doc).isXMLType(); - - - if (doc instanceof INodeNotifier) { - ModelQueryAdapter adapter = (ModelQueryAdapter) ((INodeNotifier) doc).getAdapterFor(ModelQueryAdapter.class); - CMDocument cmdoc = null; - if (adapter != null && adapter.getModelQuery() != null) - cmdoc = adapter.getModelQuery().getCorrespondingCMDocument(doc); - if (cmdoc != null) { - // treat as XHTML unless we've got the in-code HTML content - // model - if (cmdoc instanceof HTMLCMDocument) - return false; - if (cmdoc.supports(HTMLCMProperties.IS_XHTML)) - return Boolean.TRUE.equals(cmdoc.getProperty(HTMLCMProperties.IS_XHTML)); - } - } - // this should never be reached - DocumentType docType = doc.getDoctype(); - return docType != null && docType.getPublicId() != null && docType.getPublicId().indexOf("-//W3C//DTD XHTML ") == 0; //$NON-NLS-1$ - } - - protected void init() { - getPreferenceStore().addPropertyChangeListener(this); - reinit(); - } - - protected void reinit() { - String key = HTMLUIPreferenceNames.AUTO_PROPOSE; - boolean doAuto = getPreferenceStore().getBoolean(key); - if (doAuto) { - key = HTMLUIPreferenceNames.AUTO_PROPOSE_CODE; - completionProposalAutoActivationCharacters = getPreferenceStore().getString(key).toCharArray(); - } - else { - completionProposalAutoActivationCharacters = null; - } - } - - public void release() { - if (factoryForCSS != null) { - factoryForCSS.release(); - } - getPreferenceStore().removePropertyChangeListener(this); - super.release(); - } - - protected boolean stringsEqual(String a, String b) { - return a.equalsIgnoreCase(b); - } - - public void propertyChange(PropertyChangeEvent event) { - String property = event.getProperty(); - - if (property.compareTo(HTMLUIPreferenceNames.AUTO_PROPOSE) == 0 || property.compareTo(HTMLUIPreferenceNames.AUTO_PROPOSE_CODE) == 0) { - reinit(); - } - } - - protected IPreferenceStore getPreferenceStore() { - if (fPreferenceStore == null) - fPreferenceStore = HTMLUIPlugin.getDefault().getPreferenceStore(); - - return fPreferenceStore; - } - - public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int documentPosition, IndexedRegion indexedNode, ITextRegion region) { - return computeCompletionProposals(viewer, documentPosition); - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/contentassist/HTMLMinimalContentModelGenerator.java b/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/contentassist/HTMLMinimalContentModelGenerator.java deleted file mode 100644 index f3daa1ae65..0000000000 --- a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/contentassist/HTMLMinimalContentModelGenerator.java +++ /dev/null @@ -1,130 +0,0 @@ -/******************************************************************************* - * 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.html.ui.internal.contentassist; - -import org.eclipse.core.runtime.Preferences; -import org.eclipse.wst.html.core.internal.HTMLCorePlugin; -import org.eclipse.wst.html.core.internal.contentmodel.HTMLElementDeclaration; -import org.eclipse.wst.html.core.internal.preferences.HTMLCorePreferenceNames; -import org.eclipse.wst.html.core.internal.provisional.HTMLCMProperties; -import org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration; -import org.eclipse.wst.xml.core.internal.contentmodel.CMNode; -import org.eclipse.wst.xml.ui.internal.contentassist.XMLContentModelGenerator; -import org.w3c.dom.Node; - -public class HTMLMinimalContentModelGenerator extends XMLContentModelGenerator { - - private static HTMLMinimalContentModelGenerator instance = null; - protected int fTagCase; - protected int fAttrCase; - - /** - * HTMLMinimalContentModelGenerator constructor comment. - */ - private HTMLMinimalContentModelGenerator() { - super(); - } - - private void init() { - //IPreferenceStore prefs = CommonPreferencesPlugin.getDefault().getPreferenceStore(ContentType.ContentTypeID_HTML); - Preferences prefs = HTMLCorePlugin.getDefault().getPluginPreferences(); - fTagCase = prefs.getInt(HTMLCorePreferenceNames.TAG_NAME_CASE); - fAttrCase = prefs.getInt(HTMLCorePreferenceNames.ATTR_NAME_CASE); - } - - protected void generateEndTag(String tagName, Node parentNode, CMElementDeclaration elementDecl, StringBuffer buffer) { - if (elementDecl == null) - return; - if (elementDecl instanceof HTMLElementDeclaration) { - if (((Boolean) elementDecl.getProperty(HTMLCMProperties.IS_JSP)).booleanValue()) { - if (elementDecl.getContentType() == CMElementDeclaration.EMPTY) - return; - } - else { - String ommission = (String) elementDecl.getProperty(HTMLCMProperties.OMIT_TYPE); - if (ommission.equals(HTMLCMProperties.Values.OMIT_END) || ommission.equals(HTMLCMProperties.Values.OMIT_END_DEFAULT) || ommission.equals(HTMLCMProperties.Values.OMIT_END_MUST)) { - return; - } - } - } - - if (elementDecl.getContentType() == CMElementDeclaration.EMPTY) - return; - buffer.append("</" + tagName + ">"); //$NON-NLS-2$//$NON-NLS-1$ - return; - } - - private boolean shouldIgnoreCase(CMNode cmnode) { - if (!cmnode.supports(HTMLCMProperties.SHOULD_IGNORE_CASE)) - return false; - return ((Boolean) cmnode.getProperty(HTMLCMProperties.SHOULD_IGNORE_CASE)).booleanValue(); - } - - public String getRequiredName(Node ownerNode, CMNode cmnode) { - String name = super.getRequiredName(ownerNode, cmnode); - // don't change the case unless we're certain it is meaningless - if (shouldIgnoreCase(cmnode)) { - int caseVal = -1; - if (cmnode.getNodeType() == CMNode.ELEMENT_DECLARATION) - caseVal = fTagCase; - else if (cmnode.getNodeType() == CMNode.ATTRIBUTE_DECLARATION) - caseVal = fAttrCase; - switch (caseVal) { - case HTMLCorePreferenceNames.LOWER : - { - name = name.toLowerCase(); - } - break; - case HTMLCorePreferenceNames.UPPER : - { - name = name.toUpperCase(); - } - break; - } - } - return name; - } - - public String getStartTagClose(Node parentNode, CMElementDeclaration elementDecl) { - String other = getOtherClose(parentNode); - if (other != null) - return other; - if (elementDecl == null) - return ">"; //$NON-NLS-1$ - if (elementDecl instanceof HTMLElementDeclaration) { - if (((Boolean) elementDecl.getProperty(HTMLCMProperties.IS_JSP)).booleanValue()) { - if (elementDecl.getContentType() == CMElementDeclaration.EMPTY) - return "/>"; //$NON-NLS-1$ - } - else { - String ommission = (String) elementDecl.getProperty(HTMLCMProperties.OMIT_TYPE); - if (ommission.equals(HTMLCMProperties.Values.OMIT_END) || ommission.equals(HTMLCMProperties.Values.OMIT_END_DEFAULT) || ommission.equals(HTMLCMProperties.Values.OMIT_END_MUST)) { - return ">"; //$NON-NLS-1$ - } - } - } - - return ">"; //$NON-NLS-1$ - } - - /** - * Gets the instance. - * @return Returns a HTMLMinimalContentModelGenerator - */ - public synchronized static HTMLMinimalContentModelGenerator getInstance() { - if (instance == null) - instance = new HTMLMinimalContentModelGenerator(); - instance.init(); - return instance; - } - - -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/contentassist/HTMLTemplateCompletionProcessor.java b/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/contentassist/HTMLTemplateCompletionProcessor.java deleted file mode 100644 index 6d9d6fa485..0000000000 --- a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/contentassist/HTMLTemplateCompletionProcessor.java +++ /dev/null @@ -1,164 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2006 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.html.ui.internal.contentassist; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.List; - -import org.eclipse.jface.text.IDocument; -import org.eclipse.jface.text.IRegion; -import org.eclipse.jface.text.ITextSelection; -import org.eclipse.jface.text.ITextViewer; -import org.eclipse.jface.text.Region; -import org.eclipse.jface.text.contentassist.ICompletionProposal; -import org.eclipse.jface.text.templates.ContextTypeRegistry; -import org.eclipse.jface.text.templates.Template; -import org.eclipse.jface.text.templates.TemplateCompletionProcessor; -import org.eclipse.jface.text.templates.TemplateContext; -import org.eclipse.jface.text.templates.TemplateContextType; -import org.eclipse.jface.text.templates.TemplateException; -import org.eclipse.jface.text.templates.TemplateProposal; -import org.eclipse.jface.text.templates.persistence.TemplateStore; -import org.eclipse.swt.graphics.Image; -import org.eclipse.wst.html.ui.internal.HTMLUIPlugin; -import org.eclipse.wst.html.ui.internal.editor.HTMLEditorPluginImageHelper; -import org.eclipse.wst.html.ui.internal.editor.HTMLEditorPluginImages; - - -/** - * Completion processor for HTML Templates. Most of the work is already done - * by the HTML Content Assist processor, so by the time the - * HTMLTemplateCompletionProcessor is asked for content assist proposals, the - * HTML content assist processor has already set the context type for - * templates. - */ -class HTMLTemplateCompletionProcessor extends TemplateCompletionProcessor { - private static final class ProposalComparator implements Comparator { - public int compare(Object o1, Object o2) { - return ((TemplateProposal) o2).getRelevance() - ((TemplateProposal) o1).getRelevance(); - } - } - - private static final Comparator fgProposalComparator = new ProposalComparator(); - private String fContextTypeId = null; - - /* - * Copied from super class except instead of calling createContext(viewer, - * region) call createContext(viewer, region, offset) instead - */ - public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int offset) { - - ITextSelection selection = (ITextSelection) viewer.getSelectionProvider().getSelection(); - - // adjust offset to end of normalized selection - if (selection.getOffset() == offset) - offset = selection.getOffset() + selection.getLength(); - - String prefix = extractPrefix(viewer, offset); - Region region = new Region(offset - prefix.length(), prefix.length()); - TemplateContext context = createContext(viewer, region, offset); - if (context == null) - return new ICompletionProposal[0]; - // name of the selection variables {line, word}_selection - context.setVariable("selection", selection.getText()); //$NON-NLS-1$ - - Template[] templates = getTemplates(context.getContextType().getId()); - - List matches = new ArrayList(); - for (int i = 0; i < templates.length; i++) { - Template template = templates[i]; - try { - context.getContextType().validate(template.getPattern()); - } - catch (TemplateException e) { - continue; - } - if (template.matches(prefix, context.getContextType().getId())) - matches.add(createProposal(template, context, (IRegion) region, getRelevance(template, prefix))); - } - - Collections.sort(matches, fgProposalComparator); - - return (ICompletionProposal[]) matches.toArray(new ICompletionProposal[matches.size()]); - } - - /** - * Creates a concrete template context for the given region in the - * document. This involves finding out which context type is valid at the - * given location, and then creating a context of this type. The default - * implementation returns a <code>SmartReplaceTemplateContext</code> for - * the context type at the given location. This takes the offset at which - * content assist was invoked into consideration. - * - * @param viewer - * the viewer for which the context is created - * @param region - * the region into <code>document</code> for which the - * context is created - * @param offset - * the original offset where content assist was invoked - * @return a template context that can handle template insertion at the - * given location, or <code>null</code> - */ - private TemplateContext createContext(ITextViewer viewer, IRegion region, int offset) { - // pretty much same code as super.createContext except create - // SmartReplaceTemplateContext - TemplateContextType contextType = getContextType(viewer, region); - if (contextType != null) { - IDocument document = viewer.getDocument(); - return new ReplaceNameTemplateContext(contextType, document, region.getOffset(), region.getLength(), offset); - } - return null; - } - - protected ICompletionProposal createProposal(Template template, TemplateContext context, IRegion region, int relevance) { - return new CustomTemplateProposal(template, context, region, getImage(template), relevance); - } - - protected TemplateContextType getContextType(ITextViewer viewer, IRegion region) { - TemplateContextType type = null; - - ContextTypeRegistry registry = getTemplateContextRegistry(); - if (registry != null) - type = registry.getContextType(fContextTypeId); - - return type; - } - - protected Image getImage(Template template) { - // just return the same image for now - return HTMLEditorPluginImageHelper.getInstance().getImage(HTMLEditorPluginImages.IMG_OBJ_TAG_TEMPLATE); - } - - private ContextTypeRegistry getTemplateContextRegistry() { - return HTMLUIPlugin.getDefault().getTemplateContextRegistry(); - } - - protected Template[] getTemplates(String contextTypeId) { - Template templates[] = null; - - TemplateStore store = getTemplateStore(); - if (store != null) - templates = store.getTemplates(contextTypeId); - - return templates; - } - - private TemplateStore getTemplateStore() { - return HTMLUIPlugin.getDefault().getTemplateStore(); - } - - void setContextType(String contextTypeId) { - fContextTypeId = contextTypeId; - } -} diff --git a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/contentassist/NoRegionContentAssistProcessorForHTML.java b/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/contentassist/NoRegionContentAssistProcessorForHTML.java deleted file mode 100644 index d4512f2734..0000000000 --- a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/contentassist/NoRegionContentAssistProcessorForHTML.java +++ /dev/null @@ -1,38 +0,0 @@ -/******************************************************************************* - * 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.html.ui.internal.contentassist; - -import org.eclipse.jface.text.contentassist.IContentAssistProcessor; -import org.eclipse.wst.css.core.text.ICSSPartitions; -import org.eclipse.wst.css.ui.internal.contentassist.CSSContentAssistProcessor; -import org.eclipse.wst.html.core.text.IHTMLPartitions; -import org.eclipse.wst.javascript.ui.internal.common.contentassist.JavaScriptContentAssistProcessor; -import org.eclipse.wst.xml.ui.internal.contentassist.NoRegionContentAssistProcessor; - -/** - * - * @author pavery - */ -public class NoRegionContentAssistProcessorForHTML extends NoRegionContentAssistProcessor { - protected void initPartitionToProcessorMap() { - - super.initPartitionToProcessorMap(); - IContentAssistProcessor htmlProcessor = new HTMLContentAssistProcessor(); - addPartitionProcessor(IHTMLPartitions.HTML_DEFAULT, htmlProcessor); - addPartitionProcessor(IHTMLPartitions.HTML_COMMENT, htmlProcessor); - - IContentAssistProcessor jsContentAssistProcessor = new JavaScriptContentAssistProcessor(); - addPartitionProcessor(IHTMLPartitions.SCRIPT, jsContentAssistProcessor); - - IContentAssistProcessor cssContentAssistProcessor = new CSSContentAssistProcessor(); - addPartitionProcessor(ICSSPartitions.STYLE, cssContentAssistProcessor); - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/contentassist/ReplaceNameTemplateContext.java b/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/contentassist/ReplaceNameTemplateContext.java deleted file mode 100644 index eef89629b9..0000000000 --- a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/contentassist/ReplaceNameTemplateContext.java +++ /dev/null @@ -1,104 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.html.ui.internal.contentassist; - -import org.eclipse.jface.text.BadLocationException; -import org.eclipse.jface.text.IDocument; -import org.eclipse.jface.text.Position; -import org.eclipse.jface.text.templates.DocumentTemplateContext; -import org.eclipse.jface.text.templates.Template; -import org.eclipse.jface.text.templates.TemplateBuffer; -import org.eclipse.jface.text.templates.TemplateContextType; -import org.eclipse.jface.text.templates.TemplateException; - -/** - * Just like DocumentTemplateContext except if an insert offset is passed in, - * during evaluation, the "prefix" before the template will be checked to see - * if it matches the template name. If so, overwrite the template name. - * Otherwise, just insert the template at the insert offset location (by not - * overwriting the prefix text) - */ -public class ReplaceNameTemplateContext extends DocumentTemplateContext { - private int fInsertOffset = -1; - - /** - * Creates a document template context. - * - * @param type - * the context type - * @param document - * the document this context applies to - * @param offset - * the offset of the document region - * @param length - * the length of the document region - */ - public ReplaceNameTemplateContext(TemplateContextType type, IDocument document, int offset, int length) { - this(type, document, new Position(offset, length)); - } - - /** - * Creates a document template context. The supplied <code>Position</code> - * will be queried to compute the <code>getStart</code> and - * <code>getEnd</code> methods, which will therefore answer updated - * position data if it is registered with the document. - * - * @param type - * the context type - * @param document - * the document this context applies to - * @param position - * the position describing the area of the document which forms - * the template context - * @since 3.1 - */ - public ReplaceNameTemplateContext(TemplateContextType type, IDocument document, Position position) { - super(type, document, position); - } - - /** - * Creates a document template context. - * - * @param type - * the context type - * @param document - * the document this context applies to - * @param offset - * the offset of the document region - * @param length - * the length of the document region - * @param insertOffset - * the offset of the document region where insert was - * originally requested - */ - public ReplaceNameTemplateContext(TemplateContextType type, IDocument document, int offset, int length, int insertOffset) { - this(type, document, new Position(offset, length)); - fInsertOffset = insertOffset; - } - - /* - * @see org.eclipse.jface.text.templates.TemplateContext#evaluate(org.eclipse.jface.text.templates.Template) - */ - public TemplateBuffer evaluate(Template template) throws BadLocationException, TemplateException { - TemplateBuffer buffer = super.evaluate(template); - if (buffer != null) { - if (fInsertOffset > -1 && fInsertOffset > getStart()) { - String prefix = getDocument().get(getStart(), fInsertOffset - getStart()); - if (!template.getName().startsWith(prefix)) { - // generate a new buffer that actually contains the - // text that was going to be overwritten - buffer = new TemplateBuffer(prefix + buffer.getString(), buffer.getVariables()); - } - } - } - return buffer; - } -} diff --git a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/contentassist/XHTMLMinimalContentModelGenerator.java b/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/contentassist/XHTMLMinimalContentModelGenerator.java deleted file mode 100644 index b6f9af7a02..0000000000 --- a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/contentassist/XHTMLMinimalContentModelGenerator.java +++ /dev/null @@ -1,83 +0,0 @@ -/******************************************************************************* - * 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.html.ui.internal.contentassist; - - - -import org.eclipse.wst.html.core.internal.contentmodel.HTMLElementDeclaration; -import org.eclipse.wst.html.core.internal.provisional.HTMLCMProperties; -import org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration; -import org.eclipse.wst.xml.ui.internal.contentassist.XMLContentModelGenerator; -import org.w3c.dom.Node; - -public class XHTMLMinimalContentModelGenerator extends XMLContentModelGenerator { - - private static XHTMLMinimalContentModelGenerator instance = null; - - private XHTMLMinimalContentModelGenerator() { - super(); - } - - protected void generateEndTag(String tagName, Node parentNode, CMElementDeclaration elementDecl, StringBuffer buffer) { - if (elementDecl == null) - return; - if (elementDecl instanceof HTMLElementDeclaration) { - if (((Boolean) elementDecl.getProperty(HTMLCMProperties.IS_JSP)).booleanValue()) { - if (elementDecl.getContentType() == CMElementDeclaration.EMPTY) - return; - } - else { - String ommission = (String) elementDecl.getProperty(HTMLCMProperties.OMIT_TYPE); - if (ommission.equals(HTMLCMProperties.Values.OMIT_END) || ommission.equals(HTMLCMProperties.Values.OMIT_END_DEFAULT) || ommission.equals(HTMLCMProperties.Values.OMIT_END_MUST)) { - return; - } - } - } - - if (elementDecl.getContentType() == CMElementDeclaration.EMPTY) - return; - buffer.append("</" + tagName + ">"); //$NON-NLS-2$//$NON-NLS-1$ - return; - } - - - public String getStartTagClose(Node parentNode, CMElementDeclaration elementDecl) { - String other = getOtherClose(parentNode); - if (other != null) - return other; - if (elementDecl == null) - return ">"; //$NON-NLS-1$ - // EMPTY tag, do a self-close - if (elementDecl.getContentType() == CMElementDeclaration.EMPTY) { - // if it's a JSP element, don't add the space since the JSP container doesn't/shouldn't care - if (elementDecl instanceof HTMLElementDeclaration && (((Boolean) elementDecl.getProperty(HTMLCMProperties.IS_JSP)).booleanValue())) - // if it's not JSP, conform to XHTML guidelines and add the space - return "/>"; //$NON-NLS-1$ - else - return " />"; //$NON-NLS-1$ - } - // not defined as EMPTY, but should be treated as such anyway - else if (elementDecl instanceof HTMLElementDeclaration) { - String ommission = (String) elementDecl.getProperty(HTMLCMProperties.OMIT_TYPE); - if (ommission.equals(HTMLCMProperties.Values.OMIT_END) || ommission.equals(HTMLCMProperties.Values.OMIT_END_DEFAULT) || ommission.equals(HTMLCMProperties.Values.OMIT_END_MUST)) { - return " />"; //$NON-NLS-1$ - } - } - - return ">"; //$NON-NLS-1$ - } - - public synchronized static XHTMLMinimalContentModelGenerator getInstance() { - if (instance == null) - instance = new XHTMLMinimalContentModelGenerator(); - return instance; - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/contentoutline/HTMLNodeActionManager.java b/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/contentoutline/HTMLNodeActionManager.java deleted file mode 100644 index 6da4ce2451..0000000000 --- a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/contentoutline/HTMLNodeActionManager.java +++ /dev/null @@ -1,129 +0,0 @@ -/******************************************************************************* - * 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.html.ui.internal.contentoutline; - -import org.eclipse.core.runtime.Preferences; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.wst.html.core.internal.HTMLContentBuilder; -import org.eclipse.wst.html.core.internal.HTMLCorePlugin; -import org.eclipse.wst.html.core.internal.format.HTMLFormatProcessorImpl; -import org.eclipse.wst.html.core.internal.preferences.HTMLCorePreferenceNames; -import org.eclipse.wst.html.core.internal.provisional.HTMLCMProperties; -import org.eclipse.wst.html.core.internal.provisional.contenttype.ContentTypeIdForHTML; -import org.eclipse.wst.sse.core.internal.format.IStructuredFormatProcessor; -import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel; -import org.eclipse.wst.xml.core.internal.contentmodel.CMNode; -import org.eclipse.wst.xml.core.internal.contentmodel.util.DOMContentBuilder; -import org.eclipse.wst.xml.ui.internal.contentoutline.XMLNodeActionManager; -import org.w3c.dom.Document; -import org.w3c.dom.Node; - -/** - * - */ -public class HTMLNodeActionManager extends XMLNodeActionManager { - protected int fTagCase; - protected int fAttrCase; - - public HTMLNodeActionManager(IStructuredModel model, Viewer viewer) { - super(model, viewer); - updateCase(); - } - - /** - * If neccessary, employ a DOMContentBuilder that understands how to - * change the case of HTML tags (but NOT taglib derived tags). - */ - public DOMContentBuilder createDOMContentBuilder(Document document) { - DOMContentBuilder builder = null; - String one = fModel.getModelHandler().getAssociatedContentTypeId(); - String modelContentTypeId = fModel.getContentTypeIdentifier(); - if (one != modelContentTypeId) { - System.out.println("not equal"); //$NON-NLS-1$ - } - if (modelContentTypeId.equals(ContentTypeIdForHTML.ContentTypeID_HTML)) - builder = new HTMLContentBuilder(document); - else - builder = super.createDOMContentBuilder(document); - - return builder; - } - - private boolean shouldIgnoreCase(CMNode cmnode) { - if (!cmnode.supports(HTMLCMProperties.SHOULD_IGNORE_CASE)) - return false; - return ((Boolean) cmnode.getProperty(HTMLCMProperties.SHOULD_IGNORE_CASE)).booleanValue(); - } - - /** - * Modify the displayed menuitem label to change the case of HTML children - * but neither XML nor taglib-derived children. - */ - public String getLabel(Node parent, CMNode cmnode) { - String result = null; - // CMNode cmnode = action.getCMNode(); - // don't change the case unless we're certain it is meaningless - if (shouldIgnoreCase(cmnode)) { - String name = cmnode.getNodeName(); - if (cmnode.getNodeType() == CMNode.ELEMENT_DECLARATION) { - if (fTagCase == HTMLCorePreferenceNames.LOWER) - name = name.toLowerCase(); - else if (fTagCase == HTMLCorePreferenceNames.UPPER) - name = name.toUpperCase(); - // else do nothing - } - else if (cmnode.getNodeType() == CMNode.ATTRIBUTE_DECLARATION) { - if (fAttrCase == HTMLCorePreferenceNames.LOWER) - name = name.toLowerCase(); - else if (fAttrCase == HTMLCorePreferenceNames.UPPER) - name = name.toUpperCase(); - // else do nothing - } - result = name; - } - else { - result = super.getLabel(parent, cmnode); - } - - return result; - } - - /** - * Another HTML specific detail. - */ - protected void updateCase() { - if (fModel != null) { - String modelContentTypeId = fModel.getContentTypeIdentifier(); - if (modelContentTypeId != null) { - if (modelContentTypeId.equals(ContentTypeIdForHTML.ContentTypeID_HTML)) { - Preferences prefs = HTMLCorePlugin.getDefault().getPluginPreferences(); //$NON-NLS-1$ - fTagCase = prefs.getInt(HTMLCorePreferenceNames.TAG_NAME_CASE); - fAttrCase = prefs.getInt(HTMLCorePreferenceNames.ATTR_NAME_CASE); - } - } - } - } - - public void reformat(Node newElement, boolean deep) { - try { - // tell the model that we are about to make a big model change - fModel.aboutToChangeModel(); - - // format selected node - IStructuredFormatProcessor formatProcessor = new HTMLFormatProcessorImpl(); - formatProcessor.formatNode(newElement); - } - finally { - // tell the model that we are done with the big model change - fModel.changedModel(); - } - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/contentoutline/JFaceNodeAdapterFactoryForHTML.java b/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/contentoutline/JFaceNodeAdapterFactoryForHTML.java deleted file mode 100644 index 0881b05d14..0000000000 --- a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/contentoutline/JFaceNodeAdapterFactoryForHTML.java +++ /dev/null @@ -1,50 +0,0 @@ -/******************************************************************************* - * 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.html.ui.internal.contentoutline; - - - -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; - -/** - * An adapter factory to create JFaceNodeAdapters. Use this - * adapter factory with a JFaceAdapterContentProvider to display - * DOM nodes in a tree. - */ -public class JFaceNodeAdapterFactoryForHTML extends JFaceNodeAdapterFactory { - - - public JFaceNodeAdapterFactoryForHTML() { - this(IJFaceNodeAdapter.class, true); - } - - public JFaceNodeAdapterFactoryForHTML(Object adapterKey, boolean registerAdapters) { - super(adapterKey, registerAdapters); - } - - protected INodeAdapter createAdapter(INodeNotifier node) { - if (singletonAdapter == null) { - // create the JFaceNodeAdapter - singletonAdapter = new JFaceNodeAdapterForHTML(this); - initAdapter(singletonAdapter, node); - } - return singletonAdapter; - } - - public INodeAdapterFactory copy() { - return new JFaceNodeAdapterFactoryForHTML(getAdapterKey(), isShouldRegisterAdapter()); - } - -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/contentoutline/JFaceNodeAdapterForHTML.java b/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/contentoutline/JFaceNodeAdapterForHTML.java deleted file mode 100644 index 3a18a7d96b..0000000000 --- a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/contentoutline/JFaceNodeAdapterForHTML.java +++ /dev/null @@ -1,77 +0,0 @@ -/******************************************************************************* - * 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.html.ui.internal.contentoutline; - - - -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.swt.graphics.Image; -import org.eclipse.wst.html.ui.internal.editor.HTMLEditorPluginImageHelper; -import org.eclipse.wst.html.ui.internal.editor.HTMLEditorPluginImages; -import org.eclipse.wst.xml.ui.internal.contentoutline.JFaceNodeAdapter; -import org.eclipse.wst.xml.ui.internal.contentoutline.JFaceNodeAdapterFactory; -import org.w3c.dom.Node; - -/** - * Adapts a DOM node to a JFace viewer. - */ -public class JFaceNodeAdapterForHTML extends JFaceNodeAdapter { - - private Image createHTMLImage(String imageResourceName) { - ImageDescriptor imageDescriptor = HTMLEditorPluginImageHelper.getInstance().getImageDescriptor(imageResourceName); - if (imageDescriptor != null) - return imageDescriptor.createImage(); - return null; - } - - /** - * Constructor for JFaceNodeAdapterForHTML. - * - * @param adapterFactory - */ - public JFaceNodeAdapterForHTML(JFaceNodeAdapterFactory adapterFactory) { - super(adapterFactory); - } - - protected Image createImage(Object object) { - Image image = null; - - Node node = (Node) object; - if (node.getNodeType() == Node.ELEMENT_NODE) { - if (node.getNodeName().equalsIgnoreCase("table")) //$NON-NLS-1$ - image = createHTMLImage(HTMLEditorPluginImages.IMG_OBJ_TABLE); - else if (node.getNodeName().equalsIgnoreCase("a")) //$NON-NLS-1$ - image = createHTMLImage(HTMLEditorPluginImages.IMG_OBJ_TAG_ANCHOR); - else if (node.getNodeName().equalsIgnoreCase("body")) //$NON-NLS-1$ - image = createHTMLImage(HTMLEditorPluginImages.IMG_OBJ_TAG_BODY); - else if (node.getNodeName().equalsIgnoreCase("button")) //$NON-NLS-1$ - image = createHTMLImage(HTMLEditorPluginImages.IMG_OBJ_TAG_BUTTON); - else if (node.getNodeName().equalsIgnoreCase("font")) //$NON-NLS-1$ - image = createHTMLImage(HTMLEditorPluginImages.IMG_OBJ_TAG_FONT); - else if (node.getNodeName().equalsIgnoreCase("form")) //$NON-NLS-1$ - image = createHTMLImage(HTMLEditorPluginImages.IMG_OBJ_TAG_FORM); - else if (node.getNodeName().equalsIgnoreCase("html")) //$NON-NLS-1$ - image = createHTMLImage(HTMLEditorPluginImages.IMG_OBJ_TAG_HTML); - else if (node.getNodeName().equalsIgnoreCase("img")) //$NON-NLS-1$ - image = createHTMLImage(HTMLEditorPluginImages.IMG_OBJ_TAG_IMAGE); - else if (node.getNodeName().equalsIgnoreCase("map")) //$NON-NLS-1$ - image = createHTMLImage(HTMLEditorPluginImages.IMG_OBJ_TAG_IMAGE_MAP); - else if (node.getNodeName().equalsIgnoreCase("title")) //$NON-NLS-1$ - image = createHTMLImage(HTMLEditorPluginImages.IMG_OBJ_TAG_TITLE); - else - image = createHTMLImage(HTMLEditorPluginImages.IMG_OBJ_TAG); - } - if (image == null) { - image = super.createImage(node); - } - return image; - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/contentproperties/ui/AbstractDeviceProfileEntry.java b/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/contentproperties/ui/AbstractDeviceProfileEntry.java deleted file mode 100644 index b5d028d59e..0000000000 --- a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/contentproperties/ui/AbstractDeviceProfileEntry.java +++ /dev/null @@ -1,33 +0,0 @@ -/******************************************************************************* - * 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.html.ui.internal.contentproperties.ui; - -/** - * @deprecated Not needed. See BUG118359 - */ -public class AbstractDeviceProfileEntry implements DeviceProfileEntry { - - public AbstractDeviceProfileEntry() { - super(); - } - - public String getEntryId() { - return null; - } - - public String getEntryName() { - return null; - } - - public void release() { - } - -} diff --git a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/contentproperties/ui/AbstractDeviceProfileEntryProvider.java b/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/contentproperties/ui/AbstractDeviceProfileEntryProvider.java deleted file mode 100644 index 44f0bc560b..0000000000 --- a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/contentproperties/ui/AbstractDeviceProfileEntryProvider.java +++ /dev/null @@ -1,32 +0,0 @@ -/******************************************************************************* - * 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.html.ui.internal.contentproperties.ui; - -import java.util.Iterator; - -/** - * @deprecated Not needed. See BUG118359 - */ -public class AbstractDeviceProfileEntryProvider implements - DeviceProfileEntryProvider { - - public AbstractDeviceProfileEntryProvider() { - super(); - } - - public Iterator getDeviceProfileEntries() { - return null; - } - - public void release() { - } - -} diff --git a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/contentproperties/ui/ContentSettingsRegistry.java b/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/contentproperties/ui/ContentSettingsRegistry.java deleted file mode 100644 index 375ad6b95e..0000000000 --- a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/contentproperties/ui/ContentSettingsRegistry.java +++ /dev/null @@ -1,173 +0,0 @@ -/******************************************************************************* - * 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.html.ui.internal.contentproperties.ui; - -import java.util.Enumeration; -import java.util.Iterator; - -import org.eclipse.wst.css.core.internal.metamodel.CSSProfile; -import org.eclipse.wst.css.core.internal.metamodel.CSSProfileRegistry; -import org.eclipse.wst.html.core.internal.document.HTMLDocumentTypeEntry; -import org.eclipse.wst.html.core.internal.document.HTMLDocumentTypeRegistry; -import org.eclipse.wst.html.ui.internal.HTMLUIMessages; -import org.eclipse.wst.sse.core.internal.encoding.CommonCharsetNames; -import org.eclipse.wst.sse.ui.internal.contentproperties.ui.ComboList; - -/** - * @deprecated This class only contains helper methods that you should - * actually implement yourself. - */ -public final class ContentSettingsRegistry { - - private static final String NONE = HTMLUIMessages.UI_none; - - public static String maxLengthStringInHTMLDocumentTypeRegistry = ""; //$NON-NLS-1$ - public static String maxLengthStringInCharacterCodeRegistry = ""; //$NON-NLS-1$ - - private ContentSettingsRegistry() { - } - - public static void setHTMLDocumentTypeRegistryInto(ComboList combo) { - combo.add(NONE, ""); //$NON-NLS-1$ - HTMLDocumentTypeRegistry reg = HTMLDocumentTypeRegistry.getInstance(); - Enumeration e = reg.getEntries(); - while (e.hasMoreElements()) { - HTMLDocumentTypeEntry entry = (HTMLDocumentTypeEntry) e.nextElement(); - String publicId = entry.getPublicId(); - String displayName = entry.getDisplayName(); - if (displayName != null) { - combo.add(displayName, publicId); - if (displayName.length() > maxLengthStringInHTMLDocumentTypeRegistry.length()) - maxLengthStringInHTMLDocumentTypeRegistry = displayName; - } - else - combo.add(publicId, publicId); - if (publicId.length() > maxLengthStringInHTMLDocumentTypeRegistry.length()) - maxLengthStringInHTMLDocumentTypeRegistry = publicId; - if (entry.getSystemId() == null) - continue; // if HTML entry - if (entry.getSystemId().length() > maxLengthStringInHTMLDocumentTypeRegistry.length()) - maxLengthStringInHTMLDocumentTypeRegistry = entry.getSystemId(); - } - - combo.sortByKey(1); - } - - public static void setCSSMetaModelRegistryInto(ComboList combo) { - combo.add(NONE, ""); //$NON-NLS-1$ - CSSProfileRegistry reg = CSSProfileRegistry.getInstance(); - Iterator i = reg.getProfiles(); - while (i.hasNext()) { - CSSProfile profile = (CSSProfile) i.next(); - String id = profile.getProfileID(); - String name = profile.getProfileName(); - combo.add(name, id); - } - combo.sortByKey(1); - } - - public static void setDeviceProfileRegistryInto(ComboList combo) { - combo.add(NONE, ""); //$NON-NLS-1$ - DeviceProfileEntryProvider reg = DeviceProfileEntryProviderBuilder.getEntryProvider(); - if (reg == null) { - return; - } - Iterator profiles = reg.getDeviceProfileEntries(); - if (profiles == null) { - reg.release(); - return; - } - DeviceProfileEntry entry; - while (profiles.hasNext()) { - entry = (DeviceProfileEntry) profiles.next(); - combo.add(entry.getEntryName(), entry.getEntryId()); - entry.release(); - } - reg.release(); - combo.sortByKey(1); - } - - public static String getSystemIdFrom(String publicId) { - if (publicId == null || publicId.length() == 0) - return null; - HTMLDocumentTypeRegistry reg = HTMLDocumentTypeRegistry.getInstance(); - Enumeration e = reg.getEntries(); - while (e.hasMoreElements()) { - HTMLDocumentTypeEntry entry = (HTMLDocumentTypeEntry) e.nextElement(); - if (entry.getPublicId().equals(publicId)) - return entry.getSystemId(); - } - return null; - } - - public static void setContentTypeInto(ComboList combo) { - String[] type = {"", //$NON-NLS-1$ - "application/xhtml+xml", //$NON-NLS-1$ - "application/xml", //$NON-NLS-1$ - "text/html", //$NON-NLS-1$ - "text/xml",}; //$NON-NLS-1$ - String[] displayName = {NONE, "application/xhtml+xml", //$NON-NLS-1$ - //$NON-NLS-1$ - "application/xml", //$NON-NLS-1$ - "text/html", //$NON-NLS-1$ - "text/xml",}; //$NON-NLS-1$ - for (int i = 0; i < type.length; i++) { - if (displayName[i] != null && displayName[i].length() != 0) - combo.add(displayName[i], type[i]); - else - combo.add(type[i], type[i]); - } - - } - - public static void setCharacterCodeInto(ComboList combo) { - combo.add(NONE, ""); //$NON-NLS-1$ - String max = ""; //$NON-NLS-1$ - // CommonCharsetNames encoding = new CommonCharsetNames(); - String[] charCode = CommonCharsetNames.getCommonCharsetNames(); - for (int i = 0; i < charCode.length; i++) { - String displayName = CommonCharsetNames.getDisplayString(charCode[i]); - if (displayName != null && displayName.length() != 0) { - combo.add(displayName, charCode[i]); - int n_byte = displayName.getBytes().length; - if (max.getBytes().length < n_byte) - max = displayName; - } - else - combo.add(charCode[i], charCode[i]); - } - /* - * charCode = encoding.getSupportedJavaEncodings(); for(int i=0;i<charCode.length;i++){ - * String displayName = encoding.getDisplayString(charCode[i]); if - * (displayName!=null && displayName.length()!=0) - * combo.add(displayName,charCode[i]); else - * combo.add(charCode[i],charCode[i]); } - */ - // combo.sortByKey(1); - maxLengthStringInCharacterCodeRegistry = max; - } - - public static void setLanguageInto(ComboList combo) { - String[] lang = {"", //$NON-NLS-1$ - "java", //$NON-NLS-1$ - "javascript",}; //$NON-NLS-1$ - String[] displayName = {NONE, "java", //$NON-NLS-1$ - //$NON-NLS-1$ - "javascript",}; //$NON-NLS-1$ - for (int i = 0; i < lang.length; i++) { - if (displayName[i] != null && displayName[i].length() != 0) - combo.add(displayName[i], lang[i]); - else - combo.add(lang[i], lang[i]); - } - } - -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/contentproperties/ui/DeviceProfileEntry.java b/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/contentproperties/ui/DeviceProfileEntry.java deleted file mode 100644 index 0be791b4e0..0000000000 --- a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/contentproperties/ui/DeviceProfileEntry.java +++ /dev/null @@ -1,27 +0,0 @@ -/******************************************************************************* - * 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.html.ui.internal.contentproperties.ui; - -/** - * <p> - * This interface is not intended to be implemented by clients directly. - * Instead, please use abstract class(AbstractDeviceProfileEntry) instead. - * </p> - * - * @deprecated Not needed. See BUG118359 - */ -public interface DeviceProfileEntry { - public String getEntryId(); - - public String getEntryName(); - - public void release(); -} diff --git a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/contentproperties/ui/DeviceProfileEntryProvider.java b/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/contentproperties/ui/DeviceProfileEntryProvider.java deleted file mode 100644 index 8e7260b1cf..0000000000 --- a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/contentproperties/ui/DeviceProfileEntryProvider.java +++ /dev/null @@ -1,28 +0,0 @@ -/******************************************************************************* - * 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.html.ui.internal.contentproperties.ui; - -import java.util.Iterator; - -/** - * <p> - * This interface is not intended to be implemented by clients directly. - * Instead, please use abstract class(AbstractDeviceProfileEntryProvider) - * instead. - * </p> - * - * @deprecated Not needed. See BUG118359 - */ -public interface DeviceProfileEntryProvider { - public Iterator getDeviceProfileEntries(); - - public void release(); -} diff --git a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/contentproperties/ui/DeviceProfileEntryProviderBuilder.java b/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/contentproperties/ui/DeviceProfileEntryProviderBuilder.java deleted file mode 100644 index 6e5ad050f2..0000000000 --- a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/contentproperties/ui/DeviceProfileEntryProviderBuilder.java +++ /dev/null @@ -1,59 +0,0 @@ -/******************************************************************************* - * 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.html.ui.internal.contentproperties.ui; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.core.runtime.IExtension; -import org.eclipse.core.runtime.IExtensionPoint; -import org.eclipse.core.runtime.Platform; - -/** - * @deprecated Not needed. See BUG118359 - */ -public class DeviceProfileEntryProviderBuilder { - private static final String EXTENSION_POINT_PLUGINID = "org.eclipse.wst.html.ui"; //$NON-NLS-1$ - private static final String EXTENSION_POINT_NAME = "deviceProfileEntryProvider"; //$NON-NLS-1$ - private static final String ATTR_CLASS = "class"; //$NON-NLS-1$ - - public DeviceProfileEntryProviderBuilder() { - super(); - } - static public DeviceProfileEntryProvider getEntryProvider() { - IExtensionPoint point = Platform.getExtensionRegistry().getExtensionPoint(EXTENSION_POINT_PLUGINID, EXTENSION_POINT_NAME); - if (point != null) { - IExtension extensions[] = point.getExtensions(); - if ((extensions != null) && (extensions.length > 0)) { - for (int i = 0; i < extensions.length; i++) { - IConfigurationElement elements[] = extensions[i].getConfigurationElements(); - if ((elements != null) && (elements.length > 0)) { - for (int j = 0; j < elements.length; j++) { - IConfigurationElement config = elements[j]; - if ((config != null) && (config.getName().equals(EXTENSION_POINT_NAME) == true)) { - String className = config.getAttribute(ATTR_CLASS); - if (className != null) { - try { - DeviceProfileEntryProvider provider = (DeviceProfileEntryProvider)config.createExecutableExtension(ATTR_CLASS); - if (provider != null) { - return provider; - } - } catch (CoreException ignored) { - } - } - } - } - } - } - } - } - return null; - } -} diff --git a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/contentproperties/ui/HTMLContentSettingsPropertyPage.java b/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/contentproperties/ui/HTMLContentSettingsPropertyPage.java deleted file mode 100644 index ec1fb0097a..0000000000 --- a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/contentproperties/ui/HTMLContentSettingsPropertyPage.java +++ /dev/null @@ -1,280 +0,0 @@ -/******************************************************************************* - * 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.html.ui.internal.contentproperties.ui; - -import java.util.Map; - -import org.eclipse.core.resources.IResource; -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Text; -import org.eclipse.swt.widgets.Widget; -import org.eclipse.ui.PlatformUI; -import org.eclipse.wst.html.ui.internal.HTMLUIMessages; -import org.eclipse.wst.html.ui.internal.Logger; -import org.eclipse.wst.html.ui.internal.editor.IHelpContextIds; -import org.eclipse.wst.sse.internal.contentproperties.IContentSettings; -import org.eclipse.wst.sse.ui.internal.contentproperties.ui.ComboListOnPropertyPage; -import org.eclipse.wst.sse.ui.internal.contentproperties.ui.ContentSettingsPropertyPage; - -/** - * @deprecated Use WebContentSettingsPropertyPage instead - */ -public final class HTMLContentSettingsPropertyPage extends ContentSettingsPropertyPage implements org.eclipse.swt.events.SelectionListener { - - - private final int N_DOCUMENT_TYPE = 0; - private final int N_CSS_PROFILE = 1; - private final int N_TARGET_DEVICE = 2; - - private Text publicIdText; - private Text systemIdText; - - public HTMLContentSettingsPropertyPage() { - super(); - numberOfCombo = 3; - numCols = 2; - numRows = 8; - combo = new ComboListOnPropertyPage[super.numberOfCombo]; - - } - - - - protected void createDocumentTypeComboBox() { - - // create description of implecit DOCTYPE - Label label = new Label(propertyPage, SWT.LEFT); - label.setText(HTMLUIMessages.UI_Description_of_role_of_following_DOCTYPE); - GridData data = new GridData(); - data.horizontalAlignment = GridData.FILL; - data.horizontalSpan = numCols; - label.setLayoutData(data); - - // create combobox - super.combo[N_DOCUMENT_TYPE] = super.createComboBoxOf(DOCUMENT_LABEL); - super.combo[this.N_DOCUMENT_TYPE].addSelectionListener(this); - // set entry list into Combo - ContentSettingsRegistry.setHTMLDocumentTypeRegistryInto(combo[N_DOCUMENT_TYPE]); - // create TextField - createIDTextField(); - if (combo[N_DOCUMENT_TYPE].getItemCount() <= 0) - return; - - String initValue = contentSettings.getProperty((IResource) super.getElement(), IContentSettings.HTML_DOCUMENT_TYPE); - // when either .contentsettings or element doesn't exist - // when attribute doesn't exists,getProperty returns empty string. - if (initValue == null) - initValue = ""; //$NON-NLS-1$ - // set init selectionItem in Combo - super.setSelectionItem(combo[N_DOCUMENT_TYPE], initValue); - this.publicIdText.setText(initValue); - if (!initValue.equals("")) {//$NON-NLS-1$ - // toro D210260 - if (ContentSettingsRegistry.getSystemIdFrom(initValue) != null) - this.systemIdText.setText(ContentSettingsRegistry.getSystemIdFrom(initValue)); - else - this.systemIdText.setText("");//$NON-NLS-1$ - } - else - this.systemIdText.setText("");//$NON-NLS-1$ - - // create separator - label = new Label(propertyPage, SWT.SEPARATOR | SWT.HORIZONTAL); - data = new GridData(); - data.horizontalAlignment = GridData.FILL; - data.horizontalSpan = numCols; - data.verticalSpan = 8; - label.setLayoutData(data); - - } - - - - protected void createCSSComboBox() { - super.combo[N_CSS_PROFILE] = super.createComboBoxOf(CSS_LABEL); - - ContentSettingsRegistry.setCSSMetaModelRegistryInto(combo[N_CSS_PROFILE]); - if (combo[N_CSS_PROFILE].getItemCount() <= 0) - return; - String initValue = contentSettings.getProperty((IResource) super.getElement(), IContentSettings.CSS_PROFILE); - // when either .contentsettings or element doesn't exist - // when attribute doesn't exists,getProperty returns empty string. - if (initValue == null) - initValue = ""; //$NON-NLS-1$ - // set init selectionItem in Combo - super.setSelectionItem(combo[N_CSS_PROFILE], initValue); - } - - - - protected void createDeviceComboBox() { - super.combo[N_TARGET_DEVICE] = super.createComboBoxOf(DEVICE_LABEL); - - ContentSettingsRegistry.setDeviceProfileRegistryInto(combo[N_TARGET_DEVICE]); - if (combo[N_TARGET_DEVICE].getItemCount() <= 0) - return; - String initValue = contentSettings.getProperty((IResource) super.getElement(), IContentSettings.DEVICE_PROFILE); - // when either .contentsettings or element doesn't exist - // when attribute doesn't exists,getProperty returns empty string. - if (initValue == null) - initValue = ""; //$NON-NLS-1$ - // set init selectionItem in Combo - super.setSelectionItem(combo[N_TARGET_DEVICE], initValue); - } - - - protected void createSettingsPageGUI() { - int type = ((IResource) getElement()).getType(); - switch (type) { - case IResource.FILE : - // composite = createComposite(propertyPage,numCols,numRows); - createDocumentTypeComboBox(); - createCSSComboBox(); - createDeviceComboBox(); - computeMaxWidthHint(); - PlatformUI.getWorkbench().getHelpSystem().setHelp(propertyPage, IHelpContextIds.WEB_CONTENT_SETTINGS_HELPID); - break; - - default : - Logger.log(Logger.WARNING, "HTMLContentSettingsPropertyPage is instantiated by resource except FILE");//$NON-NLS-1$ - break; - } - - } - - - - protected void putSelectedPropertyInto(Map properties, String valueInCombo, int index) { - - switch (index) { - case N_DOCUMENT_TYPE : - // doc type - properties.put(IContentSettings.HTML_DOCUMENT_TYPE, valueInCombo); - break; - case N_CSS_PROFILE : - // css - properties.put(IContentSettings.CSS_PROFILE, valueInCombo); - break; - case N_TARGET_DEVICE : - // device - properties.put(IContentSettings.DEVICE_PROFILE, valueInCombo); - break; - default : - Logger.log(Logger.ERROR, "Index is out of range in putSelectedPropertyInto() in class HTMLContentSettingsPropertyPage");//$NON-NLS-1$ - break; - } - - } - - protected void deleteNoneProperty(int index) { - switch (index) { - case N_DOCUMENT_TYPE : - // doc type - contentSettings.deleteProperty((IResource) super.getElement(), IContentSettings.HTML_DOCUMENT_TYPE); - break; - case N_CSS_PROFILE : - // css - contentSettings.deleteProperty((IResource) super.getElement(), IContentSettings.CSS_PROFILE); - break; - case N_TARGET_DEVICE : - // device - contentSettings.deleteProperty((IResource) super.getElement(), IContentSettings.DEVICE_PROFILE); - break; - default : - Logger.log(Logger.ERROR, "Index is out of range in deleteNoneProperty() in class HTMLContentSettingsPropertyPage");//$NON-NLS-1$ - break; - } - } - - private void createIDTextField() { - // public ID & System ID - Label publicLabel = new Label(super.propertyPage, SWT.NONE); - GridData data = new GridData(GridData.GRAB_HORIZONTAL | GridData.FILL_HORIZONTAL); - data.horizontalIndent = 10; - publicLabel.setLayoutData(data); - publicLabel.setText(HTMLUIMessages.UI_Public_ID); - publicIdText = new Text(super.propertyPage, SWT.BORDER | SWT.READ_ONLY); - data = new GridData(); - - publicIdText.setLayoutData(data); - - Label systemLabel = new Label(super.propertyPage, SWT.NONE); - data = new GridData(GridData.GRAB_HORIZONTAL | GridData.FILL_HORIZONTAL); - data.horizontalIndent = 10; - systemLabel.setLayoutData(data); - systemLabel.setText(HTMLUIMessages.UI_System_ID); - systemIdText = new Text(super.propertyPage, SWT.BORDER | SWT.READ_ONLY); - data = new GridData(); - - systemIdText.setLayoutData(data); - } - - - - private void computeMaxWidthHint() { - // maxLengthString was set when HTMLDocumentTypeEntry was set in class ContentSettingsRegistry. - String maxLengthString = ContentSettingsRegistry.maxLengthStringInHTMLDocumentTypeRegistry; - String backup = this.systemIdText.getText(); - this.systemIdText.setText(maxLengthString); - int maxWidthHint = this.systemIdText.computeSize(SWT.DEFAULT, SWT.DEFAULT).x; - this.systemIdText.setText(backup); - - if (this.combo[this.N_DOCUMENT_TYPE].getLayoutData() != null) - ((GridData) this.combo[this.N_DOCUMENT_TYPE].getLayoutData()).widthHint = maxWidthHint; - if (this.publicIdText.getLayoutData() != null) - ((GridData) this.publicIdText.getLayoutData()).widthHint = maxWidthHint; - if (this.systemIdText.getLayoutData() != null) - ((GridData) this.systemIdText.getLayoutData()).widthHint = maxWidthHint; - if (this.combo[this.N_CSS_PROFILE].getLayoutData() != null) - ((GridData) this.combo[this.N_CSS_PROFILE].getLayoutData()).widthHint = maxWidthHint; - if (this.combo[this.N_TARGET_DEVICE].getLayoutData() != null) - ((GridData) this.combo[this.N_TARGET_DEVICE].getLayoutData()).widthHint = maxWidthHint; - - } - - - public void widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent e) { - } - - public void widgetSelected(org.eclipse.swt.events.SelectionEvent event) { - Widget source = event.widget; - - if (this.combo[this.N_DOCUMENT_TYPE].equals(source)) { - ComboListOnPropertyPage combo = this.combo[this.N_DOCUMENT_TYPE]; - if (combo.getSelectionIndex() < 0) - return; - if (!combo.getSelectedValue().equals("")) {//$NON-NLS-1$ - this.publicIdText.setText(combo.getSelectedValue()); - if (ContentSettingsRegistry.getSystemIdFrom(combo.getSelectedValue()) != null) - this.systemIdText.setText(ContentSettingsRegistry.getSystemIdFrom(combo.getSelectedValue())); - else - this.systemIdText.setText("");//$NON-NLS-1$ - } - else { - this.publicIdText.setText("");//$NON-NLS-1$ - this.systemIdText.setText(""); //$NON-NLS-1$ - } - - } - } - - protected void performDefaults() { - super.performDefaults(); - this.publicIdText.setText("");//$NON-NLS-1$ - this.systemIdText.setText(""); //$NON-NLS-1$ - - } - - -} - diff --git a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/contentproperties/ui/ProjectContentSettingsPropertyPage.java b/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/contentproperties/ui/ProjectContentSettingsPropertyPage.java deleted file mode 100644 index 5188e0572d..0000000000 --- a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/contentproperties/ui/ProjectContentSettingsPropertyPage.java +++ /dev/null @@ -1,282 +0,0 @@ -/******************************************************************************* - * 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.html.ui.internal.contentproperties.ui; - -import java.util.Map; - -import org.eclipse.core.resources.IResource; -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Text; -import org.eclipse.swt.widgets.Widget; -import org.eclipse.ui.PlatformUI; -import org.eclipse.wst.html.ui.internal.HTMLUIMessages; -import org.eclipse.wst.html.ui.internal.Logger; -import org.eclipse.wst.html.ui.internal.editor.IHelpContextIds; -import org.eclipse.wst.sse.internal.contentproperties.IContentSettings; -import org.eclipse.wst.sse.ui.internal.contentproperties.ui.ComboListOnPropertyPage; -import org.eclipse.wst.sse.ui.internal.contentproperties.ui.ContentSettingsPropertyPage; - -/** - * @deprecated Use ProjectHTMLContentSettingsPropertyPage instead - */ -public final class ProjectContentSettingsPropertyPage extends ContentSettingsPropertyPage implements org.eclipse.swt.events.SelectionListener { - - - private final int N_DOCUMENT_TYPE = 0; - private final int N_CSS_PROFILE = 1; - private final int N_TARGET_DEVICE = 2; - - private Text publicIdText; - private Text systemIdText; - - public ProjectContentSettingsPropertyPage() { - super(); - numberOfCombo = 3; - numCols = 2; - numRows = 8; - combo = new ComboListOnPropertyPage[super.numberOfCombo]; - - } - - - - protected void createDocumentTypeComboBox() { - - // create description of implecit DOCTYPE - Label label = new Label(propertyPage, SWT.LEFT); - label.setText(HTMLUIMessages.UI_Description_of_role_of_following_DOCTYPE); - GridData data = new GridData(); - data.horizontalAlignment = GridData.FILL; - data.horizontalSpan = numCols; - label.setLayoutData(data); - - // create combobox - super.combo[N_DOCUMENT_TYPE] = super.createComboBoxOf(DOCUMENT_LABEL); - super.combo[this.N_DOCUMENT_TYPE].addSelectionListener(this); - // set entry list into Combo - ContentSettingsRegistry.setHTMLDocumentTypeRegistryInto(combo[N_DOCUMENT_TYPE]); - // create TextField - createIDTextField(); - if (combo[N_DOCUMENT_TYPE].getItemCount() <= 0) - return; - - String initValue = contentSettings.getProperty((IResource) super.getElement(), IContentSettings.HTML_DOCUMENT_TYPE); - // when either .contentsettings or element doesn't exist - // when attribute doesn't exists,getProperty returns empty string. - if (initValue == null) - initValue = ""; //$NON-NLS-1$ - // set init selectionItem in Combo - super.setSelectionItem(combo[N_DOCUMENT_TYPE], initValue); - this.publicIdText.setText(initValue); - if (!initValue.equals("")) {//$NON-NLS-1$ - // toro D210260 - if (ContentSettingsRegistry.getSystemIdFrom(initValue) != null) - this.systemIdText.setText(ContentSettingsRegistry.getSystemIdFrom(initValue)); - else - this.systemIdText.setText("");//$NON-NLS-1$ - } - else - this.systemIdText.setText("");//$NON-NLS-1$ - - // create separator - label = new Label(propertyPage, SWT.SEPARATOR | SWT.HORIZONTAL); - data = new GridData(); - data.horizontalAlignment = GridData.FILL; - data.horizontalSpan = numCols; - data.verticalSpan = 8; - label.setLayoutData(data); - - } - - - - protected void createCSSComboBox() { - super.combo[N_CSS_PROFILE] = super.createComboBoxOf(CSS_LABEL); - - ContentSettingsRegistry.setCSSMetaModelRegistryInto(combo[N_CSS_PROFILE]); - if (combo[N_CSS_PROFILE].getItemCount() <= 0) - return; - String initValue = contentSettings.getProperty((IResource) super.getElement(), IContentSettings.CSS_PROFILE); - // when either .contentsettings or element doesn't exist - // when attribute doesn't exists,getProperty returns empty string. - if (initValue == null) - initValue = ""; //$NON-NLS-1$ - // set init selectionItem in Combo - super.setSelectionItem(combo[N_CSS_PROFILE], initValue); - } - - - - protected void createDeviceComboBox() { - super.combo[N_TARGET_DEVICE] = super.createComboBoxOf(DEVICE_LABEL); - - ContentSettingsRegistry.setDeviceProfileRegistryInto(combo[N_TARGET_DEVICE]); - if (combo[N_TARGET_DEVICE].getItemCount() <= 0) - return; - String initValue = contentSettings.getProperty((IResource) super.getElement(), IContentSettings.DEVICE_PROFILE); - // when either .contentsettings or element doesn't exist - // when attribute doesn't exists,getProperty returns empty string. - if (initValue == null) - initValue = ""; //$NON-NLS-1$ - // set init selectionItem in Combo - super.setSelectionItem(combo[N_TARGET_DEVICE], initValue); - } - - - protected void createSettingsPageGUI() { - int type = ((IResource) getElement()).getType(); - switch (type) { - case IResource.PROJECT : - // composite = createComposite(propertyPage,numCols,numRows); - createDocumentTypeComboBox(); - createCSSComboBox(); - createDeviceComboBox(); - computeMaxWidthHint(); - PlatformUI.getWorkbench().getHelpSystem().setHelp(propertyPage, IHelpContextIds.WEB_CONTENT_SETTINGS_HELPID); - break; - - default : - Logger.log(Logger.WARNING, "ProjectContentSettingsPropertyPage is instantiated by resource except PROJECT");//$NON-NLS-1$ - break; - } - - } - - - - protected void putSelectedPropertyInto(Map properties, String valueInCombo, int index) { - - switch (index) { - case N_DOCUMENT_TYPE : - // doc type - properties.put(IContentSettings.HTML_DOCUMENT_TYPE, valueInCombo); - break; - case N_CSS_PROFILE : - // css - properties.put(IContentSettings.CSS_PROFILE, valueInCombo); - break; - case N_TARGET_DEVICE : - // device - properties.put(IContentSettings.DEVICE_PROFILE, valueInCombo); - break; - default : - Logger.log(Logger.ERROR, "Index is out of range in putSelectedPropertyInto() in class ProjectContentSettingsPropertyPage");//$NON-NLS-1$ - break; - } - - } - - protected void deleteNoneProperty(int index) { - switch (index) { - case N_DOCUMENT_TYPE : - // doc type - contentSettings.deleteProperty((IResource) super.getElement(), IContentSettings.HTML_DOCUMENT_TYPE); - break; - - case N_CSS_PROFILE : - // css - contentSettings.deleteProperty((IResource) super.getElement(), IContentSettings.CSS_PROFILE); - break; - - case N_TARGET_DEVICE : - // device - contentSettings.deleteProperty((IResource) super.getElement(), IContentSettings.DEVICE_PROFILE); - break; - - default : - Logger.log(Logger.ERROR, "Index is out of range in deleteNoneProperty() in class ProjectContentSettingsPropertyPage");//$NON-NLS-1$ - break; - } - } - - private void createIDTextField() { - // public ID & System ID - Label publicLabel = new Label(super.propertyPage, SWT.NONE); - GridData data = new GridData(GridData.GRAB_HORIZONTAL | GridData.FILL_HORIZONTAL); - data.horizontalIndent = 10; - publicLabel.setLayoutData(data); - publicLabel.setText(HTMLUIMessages.UI_Public_ID); - publicIdText = new Text(super.propertyPage, SWT.BORDER | SWT.READ_ONLY); - data = new GridData(); - - publicIdText.setLayoutData(data); - - Label systemLabel = new Label(super.propertyPage, SWT.NONE); - data = new GridData(GridData.GRAB_HORIZONTAL | GridData.FILL_HORIZONTAL); - data.horizontalIndent = 10; - systemLabel.setLayoutData(data); - systemLabel.setText(HTMLUIMessages.UI_System_ID); - systemIdText = new Text(super.propertyPage, SWT.BORDER | SWT.READ_ONLY); - data = new GridData(); - - systemIdText.setLayoutData(data); - } - - - - private void computeMaxWidthHint() { - // maxLengthString was set when HTMLDocumentTypeEntry was set in class - // ContentSettingsRegistry. - String maxLengthString = ContentSettingsRegistry.maxLengthStringInHTMLDocumentTypeRegistry; - String backup = this.systemIdText.getText(); - this.systemIdText.setText(maxLengthString); - int maxWidthHint = this.systemIdText.computeSize(SWT.DEFAULT, SWT.DEFAULT).x; - this.systemIdText.setText(backup); - - if (this.combo[this.N_DOCUMENT_TYPE].getLayoutData() != null) - ((GridData) this.combo[this.N_DOCUMENT_TYPE].getLayoutData()).widthHint = maxWidthHint; - if (this.publicIdText.getLayoutData() != null) - ((GridData) this.publicIdText.getLayoutData()).widthHint = maxWidthHint; - if (this.systemIdText.getLayoutData() != null) - ((GridData) this.systemIdText.getLayoutData()).widthHint = maxWidthHint; - if (this.combo[this.N_CSS_PROFILE].getLayoutData() != null) - ((GridData) this.combo[this.N_CSS_PROFILE].getLayoutData()).widthHint = maxWidthHint; - if (this.combo[this.N_TARGET_DEVICE].getLayoutData() != null) - ((GridData) this.combo[this.N_TARGET_DEVICE].getLayoutData()).widthHint = maxWidthHint; - - } - - - public void widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent e) { - } - - public void widgetSelected(org.eclipse.swt.events.SelectionEvent event) { - Widget source = event.widget; - - if (this.combo[this.N_DOCUMENT_TYPE].equals(source)) { - ComboListOnPropertyPage combo = this.combo[this.N_DOCUMENT_TYPE]; - if (combo.getSelectionIndex() < 0) - return; - if (!combo.getSelectedValue().equals("")) {//$NON-NLS-1$ - this.publicIdText.setText(combo.getSelectedValue()); - if (ContentSettingsRegistry.getSystemIdFrom(combo.getSelectedValue()) != null) - this.systemIdText.setText(ContentSettingsRegistry.getSystemIdFrom(combo.getSelectedValue())); - else - this.systemIdText.setText("");//$NON-NLS-1$ - } - else { - this.publicIdText.setText("");//$NON-NLS-1$ - this.systemIdText.setText(""); //$NON-NLS-1$ - } - - } - } - - protected void performDefaults() { - super.performDefaults(); - this.publicIdText.setText("");//$NON-NLS-1$ - this.systemIdText.setText(""); //$NON-NLS-1$ - - } - -} diff --git a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/contentproperties/ui/ProjectWebContentSettingsPropertyPage.java b/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/contentproperties/ui/ProjectWebContentSettingsPropertyPage.java deleted file mode 100644 index 6ccbe4cec4..0000000000 --- a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/contentproperties/ui/ProjectWebContentSettingsPropertyPage.java +++ /dev/null @@ -1,19 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.html.ui.internal.contentproperties.ui; - -import org.eclipse.wst.html.ui.internal.HTMLUIMessages; - -public class ProjectWebContentSettingsPropertyPage extends WebContentSettingsPropertyPage { - public ProjectWebContentSettingsPropertyPage() { - setDescription(HTMLUIMessages.ProjectWebContentSettingsPropertyPage_0); - } -} diff --git a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/contentproperties/ui/WebContentSettingsPropertyPage.java b/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/contentproperties/ui/WebContentSettingsPropertyPage.java deleted file mode 100644 index 1c07baa1eb..0000000000 --- a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/contentproperties/ui/WebContentSettingsPropertyPage.java +++ /dev/null @@ -1,376 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2006 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - * David Schneider, david.schneider@unisys.com - [142500] WTP properties pages fonts don't follow Eclipse preferences - *******************************************************************************/ -package org.eclipse.wst.html.ui.internal.contentproperties.ui; - -import java.util.ArrayList; -import java.util.Enumeration; -import java.util.Iterator; -import java.util.List; - -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.SelectionListener; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Combo; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Text; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.dialogs.PropertyPage; -import org.eclipse.wst.css.core.internal.contentproperties.CSSContentProperties; -import org.eclipse.wst.css.core.internal.metamodel.CSSProfile; -import org.eclipse.wst.css.core.internal.metamodel.CSSProfileRegistry; -import org.eclipse.wst.html.core.internal.contentproperties.HTMLContentProperties; -import org.eclipse.wst.html.core.internal.document.HTMLDocumentTypeEntry; -import org.eclipse.wst.html.core.internal.document.HTMLDocumentTypeRegistry; -import org.eclipse.wst.html.ui.internal.HTMLUIMessages; -import org.eclipse.wst.html.ui.internal.Logger; -import org.eclipse.wst.html.ui.internal.editor.IHelpContextIds; - -public class WebContentSettingsPropertyPage extends PropertyPage { - private static final String SELECT_NONE = HTMLUIMessages.UI_none; - private String maxLengthStringInHTMLDocumentTypeRegistry = ""; //$NON-NLS-1$ - - private class ComboSelectionListener implements SelectionListener { - public void widgetDefaultSelected(SelectionEvent e) { - // do nothing - } - - public void widgetSelected(SelectionEvent e) { - int index = fDocumentTypeCombo.getSelectionIndex(); - String doctype = (String) fDocumentTypeIds.get(index); - updateDoctypeText(index, doctype); - } - } - - Combo fDocumentTypeCombo; - List fDocumentTypeIds; - private Text fPublicIdText; - private Text fSystemIdText; - private Combo fProfileCombo; - private List fProfileIds; - private SelectionListener fListener; - - public WebContentSettingsPropertyPage() { - super(); - setDescription(HTMLUIMessages.WebContentSettingsPropertyPage_0); - } - - private Composite createComposite(Composite parent, int numColumns) { - Composite composite = new Composite(parent, SWT.NULL); - - // GridLayout - GridLayout layout = new GridLayout(); - layout.numColumns = numColumns; - composite.setLayout(layout); - - // GridData - GridData data = new GridData(GridData.FILL, GridData.FILL, true, false); - data.horizontalIndent = 0; - composite.setLayoutData(data); - - return composite; - } - - protected Control createContents(Composite parent) { - Composite propertyPage = createComposite(parent, 2); - - createDoctypeContents(propertyPage); - createCSSProfileContents(propertyPage); - - populateValues(); - initializeValues(); - computeMaxWidthHint(); - - fListener = new ComboSelectionListener(); - fDocumentTypeCombo.addSelectionListener(fListener); - - PlatformUI.getWorkbench().getHelpSystem().setHelp(propertyPage, IHelpContextIds.WEB_CONTENT_SETTINGS_HELPID); - Dialog.applyDialogFont(parent); - return propertyPage; - } - - private void createCSSProfileContents(Composite parent) { - // CSS Profile - Text languageLabel = new Text(parent, SWT.READ_ONLY); - languageLabel.setText(HTMLUIMessages.UI_CSS_profile___2); - fProfileCombo = new Combo(parent, SWT.READ_ONLY); - GridData data = new GridData(GridData.FILL, GridData.FILL, true, false); - data.horizontalIndent = 0; - fProfileCombo.setLayoutData(data); - } - - private void createDoctypeContents(Composite parent) { - // create description of implicit DOCTYPE - Text doctypeLabel = new Text(parent, SWT.READ_ONLY); - doctypeLabel.setText(HTMLUIMessages.UI_Description_of_role_of_following_DOCTYPE); - GridData data = new GridData(GridData.FILL, GridData.FILL, true, false); - data.horizontalIndent = 0; - data.horizontalSpan = 2; - doctypeLabel.setLayoutData(data); - - // document type - Text languageLabel = new Text(parent, SWT.READ_ONLY); - languageLabel.setText(HTMLUIMessages.UI_Default_HTML_DOCTYPE_ID___1); - fDocumentTypeCombo = new Combo(parent, SWT.READ_ONLY); - data = new GridData(GridData.FILL, GridData.FILL, true, false); - data.horizontalIndent = 0; - fDocumentTypeCombo.setLayoutData(data); - - // public ID - Text publicIdLabel = new Text(parent, SWT.READ_ONLY); - publicIdLabel.setText(HTMLUIMessages.UI_Public_ID); - fPublicIdText = new Text(parent, SWT.READ_ONLY | SWT.BORDER); - data = new GridData(GridData.FILL, GridData.FILL, true, false); - data.horizontalIndent = 0; - fPublicIdText.setLayoutData(data); - - // system ID - Text systemIdLabel = new Text(parent, SWT.READ_ONLY); - systemIdLabel.setText(HTMLUIMessages.UI_System_ID); - fSystemIdText = new Text(parent, SWT.READ_ONLY | SWT.BORDER); - data = new GridData(GridData.FILL, GridData.FILL, true, false); - data.horizontalIndent = 0; - fSystemIdText.setLayoutData(data); - - // create separator - Label label = new Label(parent, SWT.SEPARATOR | SWT.HORIZONTAL); - data = new GridData(); - data.horizontalAlignment = GridData.FILL; - data.horizontalSpan = 2; - data.verticalSpan = 8; - label.setLayoutData(data); - } - - /** - * Get the resource this properties page is for - * - * @return IResource for this properties page or null if there is no - * IResource - */ - private IResource getResource() { - IResource resource = null; - if (getElement() instanceof IResource) { - resource = (IResource) getElement(); - } - return resource; - } - - private String getSystemIdFrom(String publicId) { - if (publicId == null || publicId.length() == 0) - return null; - HTMLDocumentTypeRegistry reg = HTMLDocumentTypeRegistry.getInstance(); - Enumeration e = reg.getEntries(); - while (e.hasMoreElements()) { - HTMLDocumentTypeEntry entry = (HTMLDocumentTypeEntry) e.nextElement(); - if (entry.getPublicId().equals(publicId)) - return entry.getSystemId(); - } - return null; - } - - private void initializeValues() { - initializeDoctypeValues(); - initializeCSSProfileValues(); - } - - private void initializeCSSProfileValues() { - int index = 0; - String profile = CSSContentProperties.getProperty(CSSContentProperties.CSS_PROFILE, getResource(), false); - if (profile != null && profile.length() > 0) { - /* - * If item is already part of combo, select it. Otherwise, select - * none. - */ - index = fProfileIds.indexOf(profile); - } - index = index >= 0 ? index : 0; - fProfileCombo.select(index); - } - - private void initializeDoctypeValues() { - int index = 0; - String doctype = HTMLContentProperties.getProperty(HTMLContentProperties.DOCUMENT_TYPE, getResource(), false); - if (doctype != null && doctype.length() > 0) { - /* - * If item is already part of combo, select it. Otherwise, select - * none. - */ - index = fDocumentTypeIds.indexOf(doctype); - } - - // set combobox - index = index >= 0 ? index : 0; - fDocumentTypeCombo.select(index); - - updateDoctypeText(index, doctype); - } - - void updateDoctypeText(int index, String doctype) { - if (index > 0) { - // set public/system id text - fPublicIdText.setText(doctype); - String systemId = getSystemIdFrom(doctype); - if (systemId != null) - fSystemIdText.setText(systemId); - else - fSystemIdText.setText(""); //$NON-NLS-1$ - } - else { - // set public/system id text - fPublicIdText.setText(""); //$NON-NLS-1$ - fSystemIdText.setText(""); //$NON-NLS-1$ - } - } - - private void populateValues() { - populateDoctypeValues(); - populateCSSProfileValues(); - } - - private void populateCSSProfileValues() { - fProfileIds = new ArrayList(); - // add none first - fProfileCombo.add(SELECT_NONE); - fProfileIds.add(null); - - CSSProfileRegistry reg = CSSProfileRegistry.getInstance(); - Iterator i = reg.getProfiles(); - while (i.hasNext()) { - CSSProfile profile = (CSSProfile) i.next(); - String id = profile.getProfileID(); - String name = profile.getProfileName(); - fProfileCombo.add(name); - fProfileIds.add(id); - } - } - - private void populateDoctypeValues() { - fDocumentTypeIds = new ArrayList(); - // add none first - fDocumentTypeCombo.add(SELECT_NONE); - fDocumentTypeIds.add(null); - - HTMLDocumentTypeRegistry reg = HTMLDocumentTypeRegistry.getInstance(); - Enumeration e = reg.getEntries(); - while (e.hasMoreElements()) { - HTMLDocumentTypeEntry entry = (HTMLDocumentTypeEntry) e.nextElement(); - String publicId = entry.getPublicId(); - String displayName = entry.getDisplayName(); - displayName = displayName != null ? displayName : publicId; - - fDocumentTypeCombo.add(displayName); - fDocumentTypeIds.add(publicId); - - if (displayName.length() > maxLengthStringInHTMLDocumentTypeRegistry.length()) { - maxLengthStringInHTMLDocumentTypeRegistry = displayName; - } - - if (entry.getSystemId() == null) - continue; // if HTML entry - - - if (entry.getSystemId().length() > maxLengthStringInHTMLDocumentTypeRegistry.length()) - maxLengthStringInHTMLDocumentTypeRegistry = entry.getSystemId(); - } - } - - private void computeMaxWidthHint() { - // maxLengthString was set populateDoctypeValues was called - String maxLengthString = maxLengthStringInHTMLDocumentTypeRegistry; - String backup = fSystemIdText.getText(); - fSystemIdText.setText(maxLengthString); - int maxWidthHint = fSystemIdText.computeSize(SWT.DEFAULT, SWT.DEFAULT).x; - fSystemIdText.setText(backup); - - if (fDocumentTypeCombo.getLayoutData() != null) - ((GridData) fDocumentTypeCombo.getLayoutData()).widthHint = maxWidthHint; - if (fPublicIdText.getLayoutData() != null) - ((GridData) fPublicIdText.getLayoutData()).widthHint = maxWidthHint; - if (fSystemIdText.getLayoutData() != null) - ((GridData) fSystemIdText.getLayoutData()).widthHint = maxWidthHint; - if (fProfileCombo.getLayoutData() != null) - ((GridData) fProfileCombo.getLayoutData()).widthHint = maxWidthHint; - } - - private void performCSSProfileDefaults() { - int index = fProfileCombo.indexOf(SELECT_NONE); - if (index > -1) - fProfileCombo.select(index); - - super.performDefaults(); - } - - private boolean performCSSProfileOk() { - int index = fProfileCombo.getSelectionIndex(); - if (index > -1) { - String id = (String) fProfileIds.get(index); - if (id == null || id.length() == 0 || id.equalsIgnoreCase(SELECT_NONE)) { - // if none, use null - id = null; - } - try { - CSSContentProperties.setProperty(CSSContentProperties.CSS_PROFILE, getResource(), id); - } - catch (CoreException e) { - // maybe in future, let user know there was a problem saving - // file - Logger.log(Logger.WARNING_DEBUG, e.getMessage(), e); - } - } - return true; - } - - protected void performDefaults() { - super.performDefaults(); - - performDoctypeDefaults(); - performCSSProfileDefaults(); - } - - private void performDoctypeDefaults() { - fPublicIdText.setText("");//$NON-NLS-1$ - fSystemIdText.setText(""); //$NON-NLS-1$ - } - - private boolean performDoctypeOk() { - int index = fDocumentTypeCombo.getSelectionIndex(); - if (index > -1) { - String id = (String) fDocumentTypeIds.get(index); - if (id == null || id.length() == 0 || id.equalsIgnoreCase(SELECT_NONE)) { - // if none, use null - id = null; - } - try { - HTMLContentProperties.setProperty(HTMLContentProperties.DOCUMENT_TYPE, getResource(), id); - } - catch (CoreException e) { - // maybe in future, let user know there was a problem saving - // file - Logger.log(Logger.WARNING_DEBUG, e.getMessage(), e); - } - } - return true; - } - - public boolean performOk() { - performDoctypeOk(); - performCSSProfileOk(); - - return super.performOk(); - } -} diff --git a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/correction/CorrectionAssistantProviderHTML.java b/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/correction/CorrectionAssistantProviderHTML.java deleted file mode 100644 index acc458abba..0000000000 --- a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/correction/CorrectionAssistantProviderHTML.java +++ /dev/null @@ -1,51 +0,0 @@ -/********************************************************************************* - * Copyright (c) 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of 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 - * Jens Lukowski/Innoopract - initial renaming/restructuring - * - *******************************************************************************/ - -package org.eclipse.wst.html.ui.internal.correction; - -import org.eclipse.jface.text.contentassist.ContentAssistant; -import org.eclipse.jface.text.contentassist.IContentAssistProcessor; -import org.eclipse.jface.text.contentassist.IContentAssistant; -import org.eclipse.jface.text.source.ISourceViewer; -import org.eclipse.wst.html.core.text.IHTMLPartitions; -import org.eclipse.wst.sse.ui.internal.correction.CorrectionAssistantProvider; -import org.eclipse.wst.xml.core.text.IXMLPartitions; -import org.eclipse.wst.xml.ui.internal.correction.CorrectionProcessorXML; - -/** - * Correction assistant for HTML - */ -public class CorrectionAssistantProviderHTML extends CorrectionAssistantProvider { - - public IContentAssistant getCorrectionAssistant(ISourceViewer sourceViewer) { - IContentAssistant ca = null; - - if (sourceViewer != null) { - ContentAssistant assistant = new ContentAssistant(); - - if (sourceViewer != null) { - IContentAssistProcessor correctionProcessor = new CorrectionProcessorXML(sourceViewer); - assistant.setContentAssistProcessor(correctionProcessor, IHTMLPartitions.HTML_DEFAULT); - assistant.setContentAssistProcessor(correctionProcessor, IXMLPartitions.XML_CDATA); - assistant.setContentAssistProcessor(correctionProcessor, IXMLPartitions.XML_COMMENT); - assistant.setContentAssistProcessor(correctionProcessor, IXMLPartitions.XML_DECLARATION); - assistant.setContentAssistProcessor(correctionProcessor, IXMLPartitions.XML_PI); - assistant.setContentAssistProcessor(correctionProcessor, IXMLPartitions.DTD_SUBSET); - } - ca = assistant; - } - - return ca; - } - -} diff --git a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/derived/SingleCharReader.java b/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/derived/SingleCharReader.java deleted file mode 100644 index c638fb1c5a..0000000000 --- a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/derived/SingleCharReader.java +++ /dev/null @@ -1,67 +0,0 @@ -/********************************************************************************* - * Copyright (c) 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of 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 - * Jens Lukowski/Innoopract - initial renaming/restructuring - * - *******************************************************************************/ - -package org.eclipse.wst.html.ui.internal.derived; - -import java.io.IOException; -import java.io.Reader; - -/* - * Copied from org.eclipse.jdt.internal.corext.javadoc.SingleCharReader. - * Modification was made to fix statement unnecessarily nested within else - * clause warning in read(..). - */ -public abstract class SingleCharReader extends Reader { - - /** - * @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; - } - - /** - * Gets the content as a String - */ - public String getString() throws IOException { - StringBuffer buf = new StringBuffer(); - int ch; - while ((ch = read()) != -1) { - buf.append((char) ch); - } - return buf.toString(); - } -} diff --git a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/edit/ui/ActionContributorHTML.java b/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/edit/ui/ActionContributorHTML.java deleted file mode 100644 index 3e5870b8ef..0000000000 --- a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/edit/ui/ActionContributorHTML.java +++ /dev/null @@ -1,29 +0,0 @@ -/******************************************************************************* - * 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.html.ui.internal.edit.ui; - -import org.eclipse.wst.xml.ui.internal.actions.ActionContributorXML; - -/** - * - * Instead, use SourcePageActionContributor for source page contributor - * of multi page editor. - * - * Note that this class is still valid for single page editor. - */ -public class ActionContributorHTML extends ActionContributorXML { - 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$ - - - protected String[] getExtensionIDs() { - return EDITOR_IDS; - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/edit/ui/CleanupActionHTMLDelegate.java b/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/edit/ui/CleanupActionHTMLDelegate.java deleted file mode 100644 index 4d553f8959..0000000000 --- a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/edit/ui/CleanupActionHTMLDelegate.java +++ /dev/null @@ -1,162 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - * - *******************************************************************************/ - -package org.eclipse.wst.html.ui.internal.edit.ui; - -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.text.IDocument; -import org.eclipse.jface.text.ITextSelection; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.window.Window; -import org.eclipse.swt.custom.BusyIndicator; -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.texteditor.ITextEditor; -import org.eclipse.wst.html.core.internal.cleanup.HTMLCleanupProcessorImpl; -import org.eclipse.wst.html.ui.internal.HTMLUIMessages; -import org.eclipse.wst.sse.core.StructuredModelManager; -import org.eclipse.wst.sse.core.internal.cleanup.IStructuredCleanupProcessor; -import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel; -import org.eclipse.wst.sse.ui.internal.SSEUIMessages; -import org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument; -import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel; - -/** - * Cleanup action delegate for HTML editor - */ -public class CleanupActionHTMLDelegate implements IEditorActionDelegate, IActionDelegate2, IViewActionDelegate { - private IEditorPart fEditor; - private IStructuredCleanupProcessor fCleanupProcessor; - - public void setActiveEditor(IAction action, IEditorPart targetEditor) { - fEditor = targetEditor; - } - - public void dispose() { - // nulling out just in case - fEditor = null; - fCleanupProcessor = null; - } - - public void init(IAction action) { - if (action != null) { - action.setText(HTMLUIMessages.CleanupDocument_label); - action.setToolTipText(HTMLUIMessages.CleanupDocument_tooltip); - action.setDescription(HTMLUIMessages.CleanupDocument_description); - } - } - - public void runWithEvent(IAction action, Event event) { - run(action); - } - - public void init(IViewPart view) { - // do nothing - } - - public void run(IAction action) { - if (fEditor instanceof ITextEditor) { - final ITextEditor editor = (ITextEditor) fEditor; - CleanupDialogHTML cleanupDialog = new CleanupDialogHTML(editor.getSite().getShell()); - cleanupDialog.setisXHTMLType(isXHTML()); - if (cleanupDialog.open() == Window.OK) { - // setup runnable - Runnable runnable = new Runnable() { - public void run() { - IStructuredCleanupProcessor cleanupProcessor = getCleanupProcessor(); - if (cleanupProcessor != null) { - IStructuredModel model = null; - try { - model = StructuredModelManager.getModelManager().getExistingModelForEdit(editor.getDocumentProvider().getDocument(editor.getEditorInput())); - if (model != null) - cleanupProcessor.cleanupModel(model); - } - finally { - if (model != null) - model.releaseFromEdit(); - } - } - } - }; - - // TODO: make independent of 'model'. - IStructuredModel model = null; - try { - model = StructuredModelManager.getModelManager().getExistingModelForEdit(editor.getDocumentProvider().getDocument(editor.getEditorInput())); - if (model != null) { - // begin recording - ITextSelection selection = (ITextSelection) editor.getSelectionProvider().getSelection(); - model.beginRecording(this, SSEUIMessages.Cleanup_Document_UI_, SSEUIMessages.Cleanup_Document_UI_, selection.getOffset(), selection.getLength()); //$NON-NLS-1$ //$NON-NLS-2$ - - // tell the model that we are about to make a big - // model change - model.aboutToChangeModel(); - - // run - BusyIndicator.showWhile(fEditor.getEditorSite().getWorkbenchWindow().getShell().getDisplay(), runnable); - } - } - finally { - if (model != null) { - // tell the model that we are done with the big - // model - // change - model.changedModel(); - - // end recording - ITextSelection selection = (ITextSelection) editor.getSelectionProvider().getSelection(); - model.endRecording(this, selection.getOffset(), selection.getLength()); - model.releaseFromEdit(); - } - } - } - } - } - - public void selectionChanged(IAction action, ISelection selection) { - // do nothing - } - - IStructuredCleanupProcessor getCleanupProcessor() { - if (fCleanupProcessor == null) - fCleanupProcessor = new HTMLCleanupProcessorImpl(); - - return fCleanupProcessor; - } - - private boolean isXHTML() { - boolean isxhtml = false; - if (fEditor instanceof ITextEditor) { - ITextEditor textEditor = (ITextEditor) fEditor; - IDocument document = textEditor.getDocumentProvider().getDocument(textEditor.getEditorInput()); - IStructuredModel model = null; - try { - model = StructuredModelManager.getModelManager().getExistingModelForRead(document); - if (model instanceof IDOMModel) { - IDOMDocument domDocument = ((IDOMModel) model).getDocument(); - if (domDocument != null) - isxhtml = domDocument.isXMLType(); - } - } - finally { - if (model != null) { - model.releaseFromRead(); - } - } - } - return isxhtml; - } -} diff --git a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/edit/ui/CleanupDialogHTML.java b/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/edit/ui/CleanupDialogHTML.java deleted file mode 100644 index af2526043c..0000000000 --- a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/edit/ui/CleanupDialogHTML.java +++ /dev/null @@ -1,318 +0,0 @@ -/******************************************************************************* - * 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.html.ui.internal.edit.ui; - -import org.eclipse.core.runtime.Preferences; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.SelectionListener; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Group; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.PlatformUI; -import org.eclipse.wst.html.core.internal.HTMLCorePlugin; -import org.eclipse.wst.html.core.internal.preferences.HTMLCorePreferenceNames; -import org.eclipse.wst.html.ui.internal.HTMLUIMessages; -import org.eclipse.wst.html.ui.internal.editor.IHelpContextIds; -import org.eclipse.wst.sse.core.internal.encoding.CommonEncodingPreferenceNames; - -public class CleanupDialogHTML extends Dialog implements SelectionListener { - - protected Button fRadioButtonTagNameCaseAsis; - protected Button fRadioButtonTagNameCaseLower; - protected Button fRadioButtonTagNameCaseUpper; - protected Button fRadioButtonAttrNameCaseAsis; - protected Button fRadioButtonAttrNameCaseLower; - protected Button fRadioButtonAttrNameCaseUpper; - protected Button fCheckBoxInsertRequiredAttrs; - protected Button fCheckBoxInsertMissingTags; - protected Button fCheckBoxQuoteAttrValues; - protected Button fCheckBoxFormatSource; - protected Button fCheckBoxConvertEOLCodes; - protected Button fRadioButtonConvertEOLWindows; - protected Button fRadioButtonConvertEOLUnix; - protected Button fRadioButtonConvertEOLMac; - protected Preferences fPreferences = null; - private boolean fIsXHTML = false; - private Group fTagNameCase; - private Group fAttrNameCase; - - public CleanupDialogHTML(Shell shell) { - super(shell); - } - - protected Control createDialogArea(Composite parent) { - getShell().setText(HTMLUIMessages.Cleanup_UI_); - Composite composite = new Composite(parent, SWT.NULL); - - createDialogAreaInComposite(composite); - initializeOptions(); - - return composite; - } - - protected Control createButtonBar(Composite parent) { - Control c = super.createButtonBar(parent); - okButtonEnablement(); - return c; - } - - protected void createDialogAreaInCompositeForHTML(Composite composite) { - // Convert tag name case - // d257064 need to associate group w/ radio buttons so radio buttons - // header can be read - fTagNameCase = new Group(composite, SWT.NONE); - fTagNameCase.setText(HTMLUIMessages.Tag_name_case_for_HTML_UI_); - GridLayout hLayout = new GridLayout(); - hLayout.numColumns = 3; - fTagNameCase.setLayout(hLayout); - fRadioButtonTagNameCaseAsis = new Button(fTagNameCase, SWT.RADIO); - fRadioButtonTagNameCaseAsis.setText(HTMLUIMessages.Tag_name_case_As_is_UI_); - fRadioButtonTagNameCaseAsis.addSelectionListener(this); - fRadioButtonTagNameCaseLower = new Button(fTagNameCase, SWT.RADIO); - fRadioButtonTagNameCaseLower.setText(HTMLUIMessages.Tag_name_case_Lower_UI_); - fRadioButtonTagNameCaseLower.addSelectionListener(this); - fRadioButtonTagNameCaseUpper = new Button(fTagNameCase, SWT.RADIO); - fRadioButtonTagNameCaseUpper.setText(HTMLUIMessages.Tag_name_case_Upper_UI_); - fRadioButtonTagNameCaseUpper.addSelectionListener(this); - - // Convert attr name case - // d257064 need to associate group w/ radio buttons so radio buttons - // header can be read - fAttrNameCase = new Group(composite, SWT.NONE); - fAttrNameCase.setText(HTMLUIMessages.Attribute_name_case_for_HTML_UI_); - fAttrNameCase.setLayout(hLayout); - fRadioButtonAttrNameCaseAsis = new Button(fAttrNameCase, SWT.RADIO); - fRadioButtonAttrNameCaseAsis.setText(HTMLUIMessages.Attribute_name_case_As_is_UI_); - fRadioButtonAttrNameCaseAsis.addSelectionListener(this); - fRadioButtonAttrNameCaseLower = new Button(fAttrNameCase, SWT.RADIO); - fRadioButtonAttrNameCaseLower.setText(HTMLUIMessages.Attribute_name_case_Lower_UI_); - fRadioButtonAttrNameCaseLower.addSelectionListener(this); - fRadioButtonAttrNameCaseUpper = new Button(fAttrNameCase, SWT.RADIO); - fRadioButtonAttrNameCaseUpper.setText(HTMLUIMessages.Attribute_name_case_Upper_UI_); - fRadioButtonAttrNameCaseUpper.addSelectionListener(this); - } - - protected void createDialogAreaInComposite(Composite composite) { - createDialogAreaInCompositeForHTML(composite); - PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, IHelpContextIds.CLEANUP_HTML_HELPID); // use - // HTML - // specific - // help - - GridLayout layout = new GridLayout(); - layout.numColumns = 1; - layout.makeColumnsEqualWidth = true; - composite.setLayout(layout); - - // Insert missing required attrs - fCheckBoxInsertRequiredAttrs = new Button(composite, SWT.CHECK); - fCheckBoxInsertRequiredAttrs.setText(HTMLUIMessages.Insert_required_attributes_UI_); - fCheckBoxInsertRequiredAttrs.addSelectionListener(this); - - // Insert missing begin/end tags - fCheckBoxInsertMissingTags = new Button(composite, SWT.CHECK); - fCheckBoxInsertMissingTags.setText(HTMLUIMessages.Insert_missing_tags_UI_); - fCheckBoxInsertMissingTags.addSelectionListener(this); - - // Quote attribute values - fCheckBoxQuoteAttrValues = new Button(composite, SWT.CHECK); - fCheckBoxQuoteAttrValues.setText(HTMLUIMessages.Quote_attribute_values_UI_); - fCheckBoxQuoteAttrValues.addSelectionListener(this); - - // Format source - fCheckBoxFormatSource = new Button(composite, SWT.CHECK); - fCheckBoxFormatSource.setText(HTMLUIMessages.Format_source_UI_); - fCheckBoxFormatSource.addSelectionListener(this); - - // Convert EOL code - fCheckBoxConvertEOLCodes = new Button(composite, SWT.CHECK); - fCheckBoxConvertEOLCodes.setText(HTMLUIMessages.Convert_EOL_codes_UI_); - fCheckBoxConvertEOLCodes.addSelectionListener(this); - Composite EOLCodes = new Composite(composite, SWT.NULL); - GridLayout hLayout = new GridLayout(); - hLayout.numColumns = 3; - EOLCodes.setLayout(hLayout); - fRadioButtonConvertEOLWindows = new Button(EOLCodes, SWT.RADIO); - fRadioButtonConvertEOLWindows.setText(HTMLUIMessages.EOL_Windows_UI); - fRadioButtonConvertEOLWindows.addSelectionListener(this); - fRadioButtonConvertEOLUnix = new Button(EOLCodes, SWT.RADIO); - fRadioButtonConvertEOLUnix.setText(HTMLUIMessages.EOL_Unix_UI); - fRadioButtonConvertEOLUnix.addSelectionListener(this); - fRadioButtonConvertEOLMac = new Button(EOLCodes, SWT.RADIO); - fRadioButtonConvertEOLMac.setText(HTMLUIMessages.EOL_Mac_UI); - fRadioButtonConvertEOLMac.addSelectionListener(this); - } - - protected void okPressed() { - storeOptions(); - - super.okPressed(); - } - - protected void initializeOptionsForHTML() { - boolean caseSensitive = isXHTMLType(); - - if (caseSensitive) { - fRadioButtonTagNameCaseLower.setSelection(true); - } else { - int tagNameCase = getModelPreferences().getInt(HTMLCorePreferenceNames.CLEANUP_TAG_NAME_CASE); - if (tagNameCase == HTMLCorePreferenceNames.UPPER) { - fRadioButtonTagNameCaseUpper.setSelection(true); - } else if (tagNameCase == HTMLCorePreferenceNames.LOWER) - fRadioButtonTagNameCaseLower.setSelection(true); - else - fRadioButtonTagNameCaseAsis.setSelection(true); - } - - if (caseSensitive) { - fRadioButtonAttrNameCaseLower.setSelection(true); - } else { - int attrNameCase = getModelPreferences().getInt(HTMLCorePreferenceNames.CLEANUP_ATTR_NAME_CASE); - if (attrNameCase == HTMLCorePreferenceNames.UPPER) { - fRadioButtonAttrNameCaseUpper.setSelection(true); - } else if (attrNameCase == HTMLCorePreferenceNames.LOWER) - fRadioButtonAttrNameCaseLower.setSelection(true); - else - fRadioButtonAttrNameCaseAsis.setSelection(true); - } - - enableCaseControls(!caseSensitive); - } - - protected void initializeOptions() { - initializeOptionsForHTML(); - - fCheckBoxInsertRequiredAttrs.setSelection(getModelPreferences().getBoolean(HTMLCorePreferenceNames.INSERT_REQUIRED_ATTRS)); - fCheckBoxInsertMissingTags.setSelection(getModelPreferences().getBoolean(HTMLCorePreferenceNames.INSERT_MISSING_TAGS)); - fCheckBoxQuoteAttrValues.setSelection(getModelPreferences().getBoolean(HTMLCorePreferenceNames.QUOTE_ATTR_VALUES)); - fCheckBoxFormatSource.setSelection(getModelPreferences().getBoolean(HTMLCorePreferenceNames.FORMAT_SOURCE)); - fCheckBoxConvertEOLCodes.setSelection(getModelPreferences().getBoolean(HTMLCorePreferenceNames.CONVERT_EOL_CODES)); - if (fCheckBoxConvertEOLCodes.getSelection()) { - String EOLCode = getModelPreferences().getString(HTMLCorePreferenceNames.CLEANUP_EOL_CODE); - if (EOLCode == CommonEncodingPreferenceNames.LF) - fRadioButtonConvertEOLUnix.setSelection(true); - else if (EOLCode == CommonEncodingPreferenceNames.CR) - fRadioButtonConvertEOLMac.setSelection(true); - else - fRadioButtonConvertEOLWindows.setSelection(true); - } - enableEOLCodeRadios(fCheckBoxConvertEOLCodes.getSelection()); - } - - protected void storeOptionsForHTML() { - if (!isXHTMLType() && fRadioButtonTagNameCaseUpper.getSelection()) - getModelPreferences().setValue(HTMLCorePreferenceNames.CLEANUP_TAG_NAME_CASE, HTMLCorePreferenceNames.UPPER); - else if (fRadioButtonTagNameCaseLower.getSelection()) - getModelPreferences().setValue(HTMLCorePreferenceNames.CLEANUP_TAG_NAME_CASE, HTMLCorePreferenceNames.LOWER); - else - getModelPreferences().setValue(HTMLCorePreferenceNames.CLEANUP_TAG_NAME_CASE, HTMLCorePreferenceNames.ASIS); - - if (!isXHTMLType() && fRadioButtonAttrNameCaseUpper.getSelection()) - getModelPreferences().setValue(HTMLCorePreferenceNames.CLEANUP_ATTR_NAME_CASE, HTMLCorePreferenceNames.UPPER); - else if (fRadioButtonAttrNameCaseLower.getSelection()) - getModelPreferences().setValue(HTMLCorePreferenceNames.CLEANUP_ATTR_NAME_CASE, HTMLCorePreferenceNames.LOWER); - else - getModelPreferences().setValue(HTMLCorePreferenceNames.CLEANUP_ATTR_NAME_CASE, HTMLCorePreferenceNames.ASIS); - - // explicitly save plugin preferences so values are stored - HTMLCorePlugin.getDefault().savePluginPreferences(); - } - - protected void storeOptions() { - storeOptionsForHTML(); - - getModelPreferences().setValue(HTMLCorePreferenceNames.INSERT_REQUIRED_ATTRS, fCheckBoxInsertRequiredAttrs.getSelection()); - getModelPreferences().setValue(HTMLCorePreferenceNames.INSERT_MISSING_TAGS, fCheckBoxInsertMissingTags.getSelection()); - getModelPreferences().setValue(HTMLCorePreferenceNames.QUOTE_ATTR_VALUES, fCheckBoxQuoteAttrValues.getSelection()); - getModelPreferences().setValue(HTMLCorePreferenceNames.FORMAT_SOURCE, fCheckBoxFormatSource.getSelection()); - getModelPreferences().setValue(HTMLCorePreferenceNames.CONVERT_EOL_CODES, fCheckBoxConvertEOLCodes.getSelection()); - - if (fCheckBoxConvertEOLCodes.getSelection()) { - if (fRadioButtonConvertEOLUnix.getSelection()) { - getModelPreferences().setValue(HTMLCorePreferenceNames.CLEANUP_EOL_CODE, CommonEncodingPreferenceNames.LF); - } else if (fRadioButtonConvertEOLMac.getSelection()) { - getModelPreferences().setValue(HTMLCorePreferenceNames.CLEANUP_EOL_CODE, CommonEncodingPreferenceNames.CR); - } else { - getModelPreferences().setValue(HTMLCorePreferenceNames.CLEANUP_EOL_CODE, CommonEncodingPreferenceNames.CRLF); - } - } - - // explicitly save plugin preferences so values are stored - HTMLCorePlugin.getDefault().savePluginPreferences(); - } - - public void widgetDefaultSelected(SelectionEvent e) { - widgetSelected(e); - } - - public void widgetSelected(SelectionEvent e) { - if (e.widget == fCheckBoxConvertEOLCodes) - enableEOLCodeRadios(fCheckBoxConvertEOLCodes.getSelection()); - - okButtonEnablement(); - } - - protected Preferences getModelPreferences() { - return HTMLCorePlugin.getDefault().getPluginPreferences(); - } - - private boolean isXHTMLType() { - return fIsXHTML; - } - - protected void enableEOLCodeRadios(boolean enable) { - if ((fRadioButtonConvertEOLWindows != null) && (fRadioButtonConvertEOLUnix != null) && (fRadioButtonConvertEOLMac != null)) { - fRadioButtonConvertEOLWindows.setEnabled(enable); - fRadioButtonConvertEOLUnix.setEnabled(enable); - fRadioButtonConvertEOLMac.setEnabled(enable); - - if (!fRadioButtonConvertEOLWindows.getSelection() && !fRadioButtonConvertEOLUnix.getSelection() && !fRadioButtonConvertEOLMac.getSelection()) - fRadioButtonConvertEOLWindows.setSelection(true); - } - } - - /** - * Enables/disables the tag/attr case radio buttons - */ - private void enableCaseControls(boolean enable) { - fTagNameCase.setEnabled(enable); - fRadioButtonTagNameCaseAsis.setEnabled(enable); - fRadioButtonTagNameCaseLower.setEnabled(enable); - fRadioButtonTagNameCaseUpper.setEnabled(enable); - - fAttrNameCase.setEnabled(enable); - fRadioButtonAttrNameCaseAsis.setEnabled(enable); - fRadioButtonAttrNameCaseLower.setEnabled(enable); - fRadioButtonAttrNameCaseUpper.setEnabled(enable); - } - - /** - * Enables/disables OK button - * - */ - private void okButtonEnablement() { - boolean tagNameCaseCheck = ((fRadioButtonTagNameCaseUpper != null && fRadioButtonTagNameCaseUpper.getSelection()) || fRadioButtonTagNameCaseLower.getSelection()); - boolean attrNameCaseCheck = ((fRadioButtonAttrNameCaseUpper != null && fRadioButtonAttrNameCaseUpper.getSelection()) || fRadioButtonAttrNameCaseLower.getSelection()); - boolean eolCheck = fCheckBoxConvertEOLCodes.getSelection() && (fRadioButtonConvertEOLUnix.getSelection() || fRadioButtonConvertEOLMac.getSelection() || fRadioButtonConvertEOLWindows.getSelection()); - boolean buttonEnabled = tagNameCaseCheck || attrNameCaseCheck || fCheckBoxInsertMissingTags.getSelection() || fCheckBoxQuoteAttrValues.getSelection() || fCheckBoxFormatSource.getSelection() || eolCheck; - getButton(IDialogConstants.OK_ID).setEnabled(buttonEnabled); - } - - void setisXHTMLType(boolean isXHTML) { - fIsXHTML = isXHTML; - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/editor/HTMLEditorPluginImageHelper.java b/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/editor/HTMLEditorPluginImageHelper.java deleted file mode 100644 index 3e4863d336..0000000000 --- a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/editor/HTMLEditorPluginImageHelper.java +++ /dev/null @@ -1,149 +0,0 @@ -/******************************************************************************* - * 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.html.ui.internal.editor; - -import java.util.HashMap; - -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.resource.ImageRegistry; -import org.eclipse.jface.resource.JFaceResources; -import org.eclipse.swt.graphics.Image; -import org.eclipse.ui.plugin.AbstractUIPlugin; -import org.eclipse.wst.html.ui.internal.HTMLUIPlugin; - - -/** - * Helper class to handle images provided by this plug-in. - */ -public class HTMLEditorPluginImageHelper { - private final String PLUGINID = HTMLUIPlugin.ID; - private static HTMLEditorPluginImageHelper instance = null; - - // save a descriptor for each image - private HashMap fImageDescRegistry = null; - - /** - * Gets the instance. - * - * @return Returns a HTMLEditorPluginImageHelper - */ - public synchronized static HTMLEditorPluginImageHelper getInstance() { - if (instance == null) - instance = new HTMLEditorPluginImageHelper(); - return instance; - } - - /** - * Retrieves the image associated with resource from the image registry. - * If the image cannot be retrieved, attempt to find and load the image at - * the location specified in resource. - * - * @param resource - * the image to retrieve - * @return Image the image associated with resource or null if one could - * not be found - */ - public Image getImage(String resource) { - Image image = getImageRegistry().get(resource); - if (image == null) { - // create an image - image = createImage(resource); - } - return image; - } - - /** - * Retrieves the image descriptor associated with resource from the image - * descriptor registry. If the image descriptor cannot be retrieved, - * attempt to find and load the image descriptor at the location specified - * in resource. - * - * @param resource - * the image descriptor to retrieve - * @return ImageDescriptor the image descriptor assocated with resource or - * the default "missing" image descriptor if one could not be - * found - */ - public ImageDescriptor getImageDescriptor(String resource) { - ImageDescriptor imageDescriptor = null; - Object o = getImageDescriptorRegistry().get(resource); - if (o == null) { - //create a descriptor - imageDescriptor = createImageDescriptor(resource); - } - else { - imageDescriptor = (ImageDescriptor) o; - } - return imageDescriptor; - } - - /** - * Returns the image descriptor registry for this plugin. - * - * @return HashMap - image descriptor registry for this plugin - */ - private HashMap getImageDescriptorRegistry() { - if (fImageDescRegistry == null) - fImageDescRegistry = new HashMap(); - return fImageDescRegistry; - } - - /** - * Returns the image registry for this plugin. - * - * @return ImageRegistry - image registry for this plugin - */ - private ImageRegistry getImageRegistry() { - return JFaceResources.getImageRegistry(); - } - - /** - * Creates an image from the given resource and adds the image to the - * image registry. - * - * @param resource - * @return Image - */ - private Image createImage(String resource) { - ImageDescriptor desc = getImageDescriptor(resource); - Image image = null; - - if (desc != null) { - image = desc.createImage(); - // dont add the missing image descriptor image to the image registry - if (!desc.equals(ImageDescriptor.getMissingImageDescriptor())) - getImageRegistry().put(resource, image); - } - return image; - } - - /** - * Creates an image descriptor from the given imageFilePath and adds the - * image descriptor to the image descriptor registry. If an image - * descriptor could not be created, the default "missing" image descriptor - * is returned but not added to the image descriptor registry. - * - * @param imageFilePath - * @return ImageDescriptor image descriptor for imageFilePath or default - * "missing" image descriptor if resource could not be found - */ - private ImageDescriptor createImageDescriptor(String imageFilePath) { - ImageDescriptor imageDescriptor = AbstractUIPlugin.imageDescriptorFromPlugin(PLUGINID, imageFilePath); - if (imageDescriptor != null) { - getImageDescriptorRegistry().put(imageFilePath, imageDescriptor); - } - else { - imageDescriptor = ImageDescriptor.getMissingImageDescriptor(); - } - - return imageDescriptor; - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/editor/HTMLEditorPluginImages.java b/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/editor/HTMLEditorPluginImages.java deleted file mode 100644 index 1fa0f242e7..0000000000 --- a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/editor/HTMLEditorPluginImages.java +++ /dev/null @@ -1,32 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2006 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.html.ui.internal.editor; - -/** - * Bundle of most images used by the HTML Editor plug-in. - */ -public class HTMLEditorPluginImages { - public static final String IMG_OBJ_TABLE = "icons/full/obj16/table.gif"; //$NON-NLS-1$ - public static final String IMG_OBJ_TAG_ANCHOR = "icons/full/obj16/tag-anchor.gif"; //$NON-NLS-1$ - public static final String IMG_OBJ_TAG_BODY = "icons/full/obj16/tag-body.gif"; //$NON-NLS-1$ - public static final String IMG_OBJ_TAG_BUTTON = "icons/full/obj16/tag-button.gif"; //$NON-NLS-1$ - public static final String IMG_OBJ_TAG_FONT = "icons/full/obj16/tag-font.gif"; //$NON-NLS-1$ - public static final String IMG_OBJ_TAG_FORM = "icons/full/obj16/tag-form.gif"; //$NON-NLS-1$ - public static final String IMG_OBJ_TAG_GENERIC = "icons/full/obj16/tag-generic.gif"; //$NON-NLS-1$ - public static final String IMG_OBJ_TAG_HTML = "icons/full/obj16/tag-html.gif"; //$NON-NLS-1$ - public static final String IMG_OBJ_TAG_IMAGE_MAP = "icons/full/obj16/tag-image-map.gif"; //$NON-NLS-1$ - public static final String IMG_OBJ_TAG_IMAGE = "icons/full/obj16/tag-image.gif"; //$NON-NLS-1$ - public static final String IMG_OBJ_TAG_JSP = "icons/full/obj16/tag-jsp.gif"; //$NON-NLS-1$ - public static final String IMG_OBJ_TAG_TEMPLATE = "icons/full/obj16/tag-template.gif"; //$NON-NLS-1$ - public static final String IMG_OBJ_TAG_TITLE = "icons/full/obj16/tag-title.gif"; //$NON-NLS-1$ - public static final String IMG_OBJ_TAG = "icons/full/obj16/tag.gif"; //$NON-NLS-1$ - public static final String IMG_WIZBAN_NEWHTMLFILE = "icons/full/wizban/newhfile_wiz.png"; //$NON-NLS-1$ -} diff --git a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/editor/IHelpContextIds.java b/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/editor/IHelpContextIds.java deleted file mode 100644 index 0afe5048b3..0000000000 --- a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/editor/IHelpContextIds.java +++ /dev/null @@ -1,49 +0,0 @@ -/******************************************************************************* - * 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.html.ui.internal.editor; - -import org.eclipse.wst.html.ui.internal.HTMLUIPlugin; - -/** - * Help context ids for the HTML Source Editor. - * <p> - * This interface contains constants only; it is not intended to be implemented. - * </p> - * - */ -public interface IHelpContextIds { - // org.eclipse.wst.html.ui. - public static final String PREFIX = HTMLUIPlugin.ID + "."; //$NON-NLS-1$ - - // // figured out on the fly - // // HTML Source page editor - // public static final String HTML_SOURCEVIEW_HELPID = - // ContentTypeIdForHTML.ContentTypeID_HTML +"_source_HelpId"; - // //$NON-NLS-1$ - - // HTML Files Preference page - public static final String HTML_PREFWEBX_FILES_HELPID = PREFIX + "webx0030"; //$NON-NLS-1$ - // HTML Source Preference page - public static final String HTML_PREFWEBX_SOURCE_HELPID = PREFIX + "webx0031"; //$NON-NLS-1$ - // HTML Styles Preference page - public static final String HTML_PREFWEBX_STYLES_HELPID = PREFIX + "webx0032"; //$NON-NLS-1$ - // HTML Templates Preference page - public static final String HTML_PREFWEBX_TEMPLATES_HELPID = PREFIX + "webx0033"; //$NON-NLS-1$ - - // HTML Cleanup dialog - public static final String CLEANUP_HTML_HELPID = PREFIX + "xmlm1100"; //$NON-NLS-1$ - - // HTML Content Settings - public static final String WEB_CONTENT_SETTINGS_HELPID = PREFIX + "misc0170"; //$NON-NLS-1$ - - // HTML New File Wizard - Template Page - public static final String HTML_NEWWIZARD_TEMPLATE_HELPID = PREFIX + "htmlw0010"; //$NON-NLS-1$ -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/hyperlink/ExternalFileEditorInput.java b/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/hyperlink/ExternalFileEditorInput.java deleted file mode 100644 index 4bc2468d79..0000000000 --- a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/hyperlink/ExternalFileEditorInput.java +++ /dev/null @@ -1,159 +0,0 @@ -package org.eclipse.wst.html.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.IPathEditorInput; -import org.eclipse.ui.IPersistableElement; -import org.eclipse.ui.editors.text.ILocationProvider; -import org.eclipse.ui.model.IWorkbenchAdapter; - -/** - * EditorInput for external files. Copied from - * org.eclipse.ui.internal.editors.text.JavaFileEditorInput - */ -class ExternalFileEditorInput implements IPathEditorInput, ILocationProvider { - // copies of this class exist in: - // org.eclipse.wst.xml.ui.internal.hyperlink - // org.eclipse.wst.html.ui.internal.hyperlink - // org.eclipse.jst.jsp.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 org.eclipse.ui.IEditorInput#exists() - */ - public boolean exists() { - return fFile.exists(); - } - - /* - * @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.IEditorInput#getPersistable() - */ - public IPersistableElement getPersistable() { - return null; - } - - /* - * @see org.eclipse.ui.IEditorInput#getToolTipText() - */ - public String getToolTipText() { - return fFile.getAbsolutePath(); - } - - /* - * @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.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.IPathEditorInput#getPath() - * @since 3.1 - */ - public IPath getPath() { - return Path.fromOSString(fFile.getAbsolutePath()); - } - - /* - * @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 java.lang.Object#hashCode() - */ - public int hashCode() { - return fFile.hashCode(); - } -} diff --git a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/hyperlink/ExternalFileHyperlink.java b/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/hyperlink/ExternalFileHyperlink.java deleted file mode 100644 index 07b14ed0e1..0000000000 --- a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/hyperlink/ExternalFileHyperlink.java +++ /dev/null @@ -1,60 +0,0 @@ -package org.eclipse.wst.html.ui.internal.hyperlink; - -import java.io.File; - -import org.eclipse.jface.text.IRegion; -import org.eclipse.jface.text.hyperlink.IHyperlink; -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.Logger; - -/** - * Hyperlink for external files. - */ -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.jst.jsp.ui.internal.hyperlink - - private IRegion fHyperlinkRegion; - private File fHyperlinkFile; - - public ExternalFileHyperlink(IRegion region, File file) { - fHyperlinkFile = file; - fHyperlinkRegion = region; - } - - public IRegion getHyperlinkRegion() { - return fHyperlinkRegion; - } - - public String getTypeLabel() { - return null; - } - - public String getHyperlinkText() { - 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/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/hyperlink/WorkspaceFileHyperlink.java b/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/hyperlink/WorkspaceFileHyperlink.java deleted file mode 100644 index 8ee3ac1db0..0000000000 --- a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/hyperlink/WorkspaceFileHyperlink.java +++ /dev/null @@ -1,79 +0,0 @@ -package org.eclipse.wst.html.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.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.Logger; - -/** - * Hyperlink for files within the workspace. (As long as there is an IFile, - * this can be used) Opens the default editor for the file. - */ -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.jst.jsp.ui.internal.hyperlink - - private IRegion fRegion; - private IFile fFile; - private IRegion fHighlightRange; - - 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#getTypeLabel() - */ - public String getTypeLabel() { - // TODO Auto-generated method stub - return null; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.text.hyperlink.IHyperlink#getHyperlinkText() - */ - public String getHyperlinkText() { - // 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).setHighlightRange(fHighlightRange.getOffset(), fHighlightRange.getLength(), true); - } - } - catch (PartInitException pie) { - Logger.log(Logger.WARNING_DEBUG, pie.getMessage(), pie); - } - } - } - -} diff --git a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/hyperlink/XMLHyperlinkDetector.java b/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/hyperlink/XMLHyperlinkDetector.java deleted file mode 100644 index c4be166338..0000000000 --- a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/hyperlink/XMLHyperlinkDetector.java +++ /dev/null @@ -1,503 +0,0 @@ -package org.eclipse.wst.html.ui.internal.hyperlink; - -import java.io.File; -import java.net.URI; -import java.util.ArrayList; -import java.util.List; -import com.ibm.icu.util.StringTokenizer; - -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; - -/** - * Detects hyperlinks in XML tags. Includes detection in DOCTYPE and attribute - * values. Resolves references to schemas, dtds, etc using the Common URI - * Resolver. - * - */ -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.jst.jsp.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/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/preferences/HTMLUIPreferenceInitializer.java b/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/preferences/HTMLUIPreferenceInitializer.java deleted file mode 100644 index 36fee03b09..0000000000 --- a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/preferences/HTMLUIPreferenceInitializer.java +++ /dev/null @@ -1,89 +0,0 @@ -package org.eclipse.wst.html.ui.internal.preferences; - -import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer; -import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.jface.text.templates.Template; -import org.eclipse.wst.html.ui.internal.HTMLUIPlugin; -import org.eclipse.wst.html.ui.internal.style.IStyleConstantsHTML; -import org.eclipse.wst.sse.ui.internal.preferences.ui.ColorHelper; -import org.eclipse.wst.xml.ui.internal.style.IStyleConstantsXML; - -/** - * Sets default values for HTML UI preferences - */ -public class HTMLUIPreferenceInitializer extends AbstractPreferenceInitializer { - - /* (non-Javadoc) - * @see org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer#initializeDefaultPreferences() - */ - public void initializeDefaultPreferences() { - IPreferenceStore store = HTMLUIPlugin.getDefault().getPreferenceStore(); - - store.setDefault(HTMLUIPreferenceNames.AUTO_PROPOSE, true); - store.setDefault(HTMLUIPreferenceNames.AUTO_PROPOSE_CODE, "<");//$NON-NLS-1$ - - // HTML Style Preferences - String NOBACKGROUNDBOLD = " | null | false"; //$NON-NLS-1$ - String styleValue = ColorHelper.getColorString(127, 0, 127) + NOBACKGROUNDBOLD; - store.setDefault(IStyleConstantsXML.TAG_ATTRIBUTE_NAME, styleValue); - - styleValue = ColorHelper.getColorString(42, 0, 255) + NOBACKGROUNDBOLD; - store.setDefault(IStyleConstantsXML.TAG_ATTRIBUTE_VALUE, styleValue); - - styleValue = "null" + NOBACKGROUNDBOLD; //$NON-NLS-1$ - store.setDefault(IStyleConstantsXML.TAG_ATTRIBUTE_EQUALS, styleValue); // specified value is black; leaving as widget default - - styleValue = ColorHelper.getColorString(63, 95, 191) + NOBACKGROUNDBOLD; - store.setDefault(IStyleConstantsXML.COMMENT_BORDER, styleValue); - store.setDefault(IStyleConstantsXML.COMMENT_TEXT, styleValue); - - styleValue = ColorHelper.getColorString(0, 128, 128) + NOBACKGROUNDBOLD; - store.setDefault(IStyleConstantsXML.DECL_BORDER, styleValue); - - styleValue = ColorHelper.getColorString(0, 0, 128) + NOBACKGROUNDBOLD; - store.setDefault(IStyleConstantsXML.DOCTYPE_NAME, styleValue); - store.setDefault(IStyleConstantsXML.DOCTYPE_EXTERNAL_ID_PUBREF, styleValue); - - styleValue = ColorHelper.getColorString(128, 128, 128) + NOBACKGROUNDBOLD; - store.setDefault(IStyleConstantsXML.DOCTYPE_EXTERNAL_ID, styleValue); - - styleValue = ColorHelper.getColorString(63, 127, 95) + NOBACKGROUNDBOLD; - store.setDefault(IStyleConstantsXML.DOCTYPE_EXTERNAL_ID_SYSREF, styleValue); - - styleValue = "null" + NOBACKGROUNDBOLD; //$NON-NLS-1$ - store.setDefault(IStyleConstantsXML.XML_CONTENT, styleValue); // specified value is black; leaving as widget default - - styleValue = ColorHelper.getColorString(0, 128, 128) + NOBACKGROUNDBOLD; - store.setDefault(IStyleConstantsXML.TAG_BORDER, styleValue); - - styleValue = ColorHelper.getColorString(63, 127, 127) + NOBACKGROUNDBOLD; - store.setDefault(IStyleConstantsXML.TAG_NAME, styleValue); - - styleValue = ColorHelper.getColorString(0, 128, 128) + NOBACKGROUNDBOLD; - store.setDefault(IStyleConstantsXML.PI_BORDER, styleValue); - - styleValue = "null" + NOBACKGROUNDBOLD; //$NON-NLS-1$ - store.setDefault(IStyleConstantsXML.PI_CONTENT, styleValue); // specified value is black; leaving as widget default - - styleValue = ColorHelper.getColorString(0, 128, 128) + NOBACKGROUNDBOLD; - store.setDefault(IStyleConstantsXML.CDATA_BORDER, styleValue); - - styleValue = ColorHelper.getColorString(0, 0, 0) + NOBACKGROUNDBOLD; - store.setDefault(IStyleConstantsXML.CDATA_TEXT, styleValue); - - styleValue = ColorHelper.getColorString(191, 95, 63) + NOBACKGROUNDBOLD; - store.setDefault(IStyleConstantsHTML.SCRIPT_AREA_BORDER, styleValue); - - // set default new html file template to use in new file wizard - /* - * Need to find template name that goes with default template id (name - * may change for differnt language) - */ - String templateName = ""; //$NON-NLS-1$ - Template template = HTMLUIPlugin.getDefault().getTemplateStore().findTemplateById("org.eclipse.wst.html.ui.templates.html"); //$NON-NLS-1$ - if (template != null) - templateName = template.getName(); - store.setDefault(HTMLUIPreferenceNames.NEW_FILE_TEMPLATE_NAME, templateName); - } - -} diff --git a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/preferences/HTMLUIPreferenceNames.java b/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/preferences/HTMLUIPreferenceNames.java deleted file mode 100644 index b4fc96894d..0000000000 --- a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/preferences/HTMLUIPreferenceNames.java +++ /dev/null @@ -1,65 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - * - *******************************************************************************/ -package org.eclipse.wst.html.ui.internal.preferences; - -/** - * Preference keys for HTML UI - */ -public class HTMLUIPreferenceNames { - /** - * A named preference that controls if code assist gets auto activated. - * <p> - * Value is of type <code>Boolean</code>. - * </p> - */ - public static final String AUTO_PROPOSE = getAutoProposeKey(); - - private static String getAutoProposeKey() { - return "autoPropose";//$NON-NLS-1$ - } - - /** - * A named preference that holds the characters that auto activate code - * assist. - * <p> - * Value is of type <code>String</code>. All characters that trigger - * auto code assist. - * </p> - */ - public static final String AUTO_PROPOSE_CODE = getAutoProposeCodeKey(); - - private static String getAutoProposeCodeKey() { - return "autoProposeCode";//$NON-NLS-1$ - } - - /** - * The key to store customized templates. - * <p> - * Value is of type <code>String</code>. - * </p> - */ - public static final String TEMPLATES_KEY = getTemplatesKey(); - - private static String getTemplatesKey() { - return "org.eclipse.wst.sse.ui.custom_templates"; //$NON-NLS-1$ - } - - /** - * The key to store the last template name used in new HTML file wizard. - * Template name is stored instead of template id because user-created - * templates do not have template ids. - * <p> - * Value is of type <code>String</code>. - * </p> - */ - public static final String NEW_FILE_TEMPLATE_NAME = "newFileTemplateName"; //$NON-NLS-1$ -} diff --git a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/preferences/ui/HTMLColorPage.java b/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/preferences/ui/HTMLColorPage.java deleted file mode 100644 index e3b463157e..0000000000 --- a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/preferences/ui/HTMLColorPage.java +++ /dev/null @@ -1,124 +0,0 @@ -/******************************************************************************* - * 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.html.ui.internal.preferences.ui; - -import java.util.ArrayList; -import java.util.Dictionary; -import java.util.Hashtable; -import java.util.Iterator; - -import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.ui.PlatformUI; -import org.eclipse.wst.html.core.internal.provisional.contenttype.ContentTypeIdForHTML; -import org.eclipse.wst.html.ui.internal.HTMLUIMessages; -import org.eclipse.wst.html.ui.internal.HTMLUIPlugin; -import org.eclipse.wst.html.ui.internal.editor.IHelpContextIds; -import org.eclipse.wst.sse.core.StructuredModelManager; -import org.eclipse.wst.sse.core.internal.provisional.IModelManager; -import org.eclipse.wst.sse.ui.internal.preferences.OverlayPreferenceStore; -import org.eclipse.wst.sse.ui.internal.preferences.OverlayPreferenceStore.OverlayKey; -import org.eclipse.wst.sse.ui.internal.preferences.ui.StyledTextColorPicker; -import org.eclipse.wst.xml.ui.internal.preferences.XMLColorPage; - -public class HTMLColorPage extends XMLColorPage { - - /** - * Set up all the style preference keys in the overlay store - */ - protected OverlayKey[] createOverlayStoreKeys() { - ArrayList overlayKeys = new ArrayList(); - - ArrayList styleList = new ArrayList(); - initStyleList(styleList); - Iterator i = styleList.iterator(); - while (i.hasNext()) { - overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, (String)i.next())); - } - - OverlayPreferenceStore.OverlayKey[] keys = new OverlayPreferenceStore.OverlayKey[overlayKeys.size()]; - overlayKeys.toArray(keys); - return keys; - } - - public String getSampleText() { - return HTMLUIMessages.Sample_HTML_doc; - - } - - protected void initContextStyleMap(Dictionary contextStyleMap) { - - initCommonContextStyleMap(contextStyleMap); - initDocTypeContextStyleMap(contextStyleMap); - // FIXME: these were "brute forced" commented out when moving XMLJSPRegionContexts - // effect is unknown, but thought just to effect preference page - //contextStyleMap.put(XMLJSPRegionContexts.JSP_DIRECTIVE_NAME, IStyleConstantsXML.TAG_NAME); - //contextStyleMap.put(XMLJSPRegionContexts.JSP_COMMENT_OPEN, IStyleConstantsXML.COMMENT_BORDER); - //contextStyleMap.put(XMLJSPRegionContexts.JSP_COMMENT_TEXT, IStyleConstantsXML.COMMENT_TEXT); - //contextStyleMap.put(XMLJSPRegionContexts.JSP_COMMENT_CLOSE, IStyleConstantsXML.COMMENT_BORDER); - } - - protected void initDescriptions(Dictionary descriptions) { - - initCommonDescriptions(descriptions); - initDocTypeDescriptions(descriptions); - } - - protected void initStyleList(ArrayList list) { - initCommonStyleList(list); - initDocTypeStyleList(list); - // list.add(HTMLColorManager.SCRIPT_AREA_BORDER); - - } - - protected void setupPicker(StyledTextColorPicker picker) { - IModelManager mmanager = StructuredModelManager.getModelManager(); - picker.setParser(mmanager.createStructuredDocumentFor(ContentTypeIdForHTML.ContentTypeID_HTML).getParser()); - - // create descriptions for hilighting types - Dictionary descriptions = new Hashtable(); - initDescriptions(descriptions); - - // map region types to hilighting types - Dictionary contextStyleMap = new Hashtable(); - initContextStyleMap(contextStyleMap); - - ArrayList styleList = new ArrayList(); - initStyleList(styleList); - - picker.setContextStyleMap(contextStyleMap); - picker.setDescriptions(descriptions); - picker.setStyleList(styleList); - - // updatePickerFont(picker); - } - /* (non-Javadoc) - * @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite) - */ - protected Control createContents(Composite parent) { - Control c = super.createContents(parent); - PlatformUI.getWorkbench().getHelpSystem().setHelp(c, IHelpContextIds.HTML_PREFWEBX_STYLES_HELPID); - return c; - } - /* (non-Javadoc) - * @see org.eclipse.jface.preference.PreferencePage#doGetPreferenceStore() - */ - protected IPreferenceStore doGetPreferenceStore() { - return HTMLUIPlugin.getDefault().getPreferenceStore(); - } - /* (non-Javadoc) - * @see org.eclipse.wst.sse.ui.preferences.ui.AbstractColorPage#savePreferences() - */ - protected void savePreferences() { - HTMLUIPlugin.getDefault().savePluginPreferences(); - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/preferences/ui/HTMLFilesPreferencePage.java b/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/preferences/ui/HTMLFilesPreferencePage.java deleted file mode 100644 index 165153b2e5..0000000000 --- a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/preferences/ui/HTMLFilesPreferencePage.java +++ /dev/null @@ -1,128 +0,0 @@ -/******************************************************************************* - * 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.html.ui.internal.preferences.ui; - -import org.eclipse.core.runtime.Platform; -import org.eclipse.core.runtime.Preferences; -import org.eclipse.core.runtime.content.IContentType; -import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Group; -import org.eclipse.ui.PlatformUI; -import org.eclipse.wst.html.core.internal.HTMLCorePlugin; -import org.eclipse.wst.html.core.internal.provisional.contenttype.ContentTypeIdForHTML; -import org.eclipse.wst.html.ui.internal.HTMLUIMessages; -import org.eclipse.wst.html.ui.internal.HTMLUIPlugin; -import org.eclipse.wst.html.ui.internal.editor.IHelpContextIds; -import org.eclipse.wst.sse.core.internal.encoding.CommonEncodingPreferenceNames; -import org.eclipse.wst.xml.ui.internal.preferences.WorkbenchDefaultEncodingSettings; -import org.eclipse.wst.xml.ui.internal.preferences.XMLFilesPreferencePage; - -public class HTMLFilesPreferencePage extends XMLFilesPreferencePage { - private WorkbenchDefaultEncodingSettings fInputEncodingSettings = null; - - protected Preferences getModelPreferences() { - return HTMLCorePlugin.getDefault().getPluginPreferences(); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.preference.PreferencePage#doGetPreferenceStore() - */ - protected IPreferenceStore doGetPreferenceStore() { - return HTMLUIPlugin.getDefault().getPreferenceStore(); - } - - protected void doSavePreferenceStore() { - HTMLCorePlugin.getDefault().savePluginPreferences(); // model - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite) - */ - protected Control createContents(Composite parent) { - Composite scrolledComposite = createScrolledComposite(parent); - createContentsForCreatingOrSavingGroup(scrolledComposite); - createContentsForCreatingGroup(scrolledComposite); - createContentsForLoadingGroup(scrolledComposite); - - PlatformUI.getWorkbench().getHelpSystem().setHelp(scrolledComposite, IHelpContextIds.HTML_PREFWEBX_FILES_HELPID); - - setSize(scrolledComposite); - loadPreferences(); - - return scrolledComposite; - } - - protected void createContentsForLoadingGroup(Composite parent) { - Group group = createGroup(parent, 1); - group.setText(HTMLUIMessages.HTMLFilesPreferencePage_0); - - fInputEncodingSettings = new WorkbenchDefaultEncodingSettings(group); - } - - protected IContentType getContentType() { - return Platform.getContentTypeManager().getContentType(ContentTypeIdForHTML.ContentTypeID_HTML); - } - - protected void initializeValues() { - super.initializeValues(); - initializeValuesForLoadingGroup(); - } - - protected void initializeValuesForLoadingGroup() { - String encoding = getModelPreferences().getString(CommonEncodingPreferenceNames.INPUT_CODESET); - - fInputEncodingSettings.setIANATag(encoding); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.preference.PreferencePage#performDefaults() - */ - protected void performDefaults() { - super.performDefaults(); - performDefaultsForLoadingGroup(); - } - - protected void performDefaultsForLoadingGroup() { - String encoding = getModelPreferences().getDefaultString(CommonEncodingPreferenceNames.INPUT_CODESET); - - fInputEncodingSettings.setIANATag(encoding); - } - - protected void storeValues() { - super.storeValues(); - storeValuesForLoadingGroup(); - } - - protected void storeValuesForLoadingGroup() { - getModelPreferences().setValue(CommonEncodingPreferenceNames.INPUT_CODESET, fInputEncodingSettings.getIANATag()); - } - - protected void createContentsForCreatingGroup(Composite parent) { - super.createContentsForCreatingGroup(parent); - // Group creatingGroup = createGroup(parent, 2); - // creatingGroup.setText(HTMLUIMessages.Creating_files); - // - // // Encoding.. - // Label label = createLabel(creatingGroup, - // HTMLUIMessages.Encoding_desc); - // ((GridData)label.getLayoutData()).horizontalSpan = 2; - // fEncodingSettings = new EncodingSettings(creatingGroup); - // ((GridData)fEncodingSettings.getLayoutData()).horizontalSpan = 2; - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/preferences/ui/HTMLSourcePreferencePage.java b/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/preferences/ui/HTMLSourcePreferencePage.java deleted file mode 100644 index b055458787..0000000000 --- a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/preferences/ui/HTMLSourcePreferencePage.java +++ /dev/null @@ -1,139 +0,0 @@ -/******************************************************************************* - * 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.html.ui.internal.preferences.ui; - -import org.eclipse.core.runtime.Preferences; -import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Group; -import org.eclipse.ui.PlatformUI; -import org.eclipse.wst.html.core.internal.HTMLCorePlugin; -import org.eclipse.wst.html.core.internal.preferences.HTMLCorePreferenceNames; -import org.eclipse.wst.html.ui.internal.HTMLUIMessages; -import org.eclipse.wst.html.ui.internal.HTMLUIPlugin; -import org.eclipse.wst.html.ui.internal.editor.IHelpContextIds; -import org.eclipse.wst.xml.ui.internal.preferences.XMLSourcePreferencePage; - -public class HTMLSourcePreferencePage extends XMLSourcePreferencePage { - - protected Button fTagNameAsIs = null; - protected Button fTagNameUpper = null; - protected Button fTagNameLower = null; - protected Button fAttrNameAsIs = null; - protected Button fAttrNameUpper = null; - protected Button fAttrNameLower = null; - - protected void createContentsForGrammarConstraintsGroup(Composite parent) { - // do nothing - } - - protected void performDefaultsForGrammarConstraintsGroup() { - // do nothing - } - - protected void initializeValuesForGrammarConstraintsGroup() { - // do nothing - } - - protected void storeValuesForGrammarConstraintsGroup() { - // do nothing - } - - protected void createContentsForContentAssistGroup(Composite parent) { - super.createContentsForContentAssistGroup(parent); - - // add one more group of preferences - createContentsForPreferredCaseGroup(parent, 2); - } - - protected Composite createContentsForPreferredCaseGroup(Composite parent, int columnSpan) { - Group caseGroup = createGroup(parent, columnSpan); - caseGroup.setText(HTMLUIMessages.Preferred_markup_case_UI_); - - // d257064 need to associate group w/ radio buttons so radio buttons header can be read - Group tagNameGroup = createGroup(caseGroup, 1); - tagNameGroup.setText(HTMLUIMessages.Tag_names__UI_); - fTagNameUpper = createRadioButton(tagNameGroup, HTMLUIMessages.Tag_names_Upper_case_UI_); - fTagNameLower = createRadioButton(tagNameGroup, HTMLUIMessages.Tag_names_Lower_case_UI_); - - // d257064 need to associate group w/ radio buttons so radio buttons header can be read - Group attrNameGroup = createGroup(caseGroup, 1); - attrNameGroup.setText(HTMLUIMessages.Attribute_names__UI_); - fAttrNameUpper = createRadioButton(attrNameGroup, HTMLUIMessages.Attribute_names_Upper_case_UI_); - fAttrNameLower = createRadioButton(attrNameGroup, HTMLUIMessages.Attribute_names_Lower_case_UI_); - - return parent; - - } - - protected void performDefaults() { - fTagNameUpper.setSelection(getModelPreferences().getDefaultInt(HTMLCorePreferenceNames.TAG_NAME_CASE) == HTMLCorePreferenceNames.UPPER); - fTagNameLower.setSelection(getModelPreferences().getDefaultInt(HTMLCorePreferenceNames.TAG_NAME_CASE) == HTMLCorePreferenceNames.LOWER); - fAttrNameUpper.setSelection(getModelPreferences().getDefaultInt(HTMLCorePreferenceNames.ATTR_NAME_CASE) == HTMLCorePreferenceNames.UPPER); - fAttrNameLower.setSelection(getModelPreferences().getDefaultInt(HTMLCorePreferenceNames.ATTR_NAME_CASE) == HTMLCorePreferenceNames.LOWER); - - super.performDefaults(); - } - - protected void initializeValues() { - fTagNameUpper.setSelection(getModelPreferences().getInt(HTMLCorePreferenceNames.TAG_NAME_CASE) == HTMLCorePreferenceNames.UPPER); - fTagNameLower.setSelection(getModelPreferences().getInt(HTMLCorePreferenceNames.TAG_NAME_CASE) == HTMLCorePreferenceNames.LOWER); - fAttrNameUpper.setSelection(getModelPreferences().getInt(HTMLCorePreferenceNames.ATTR_NAME_CASE) == HTMLCorePreferenceNames.UPPER); - fAttrNameLower.setSelection(getModelPreferences().getInt(HTMLCorePreferenceNames.ATTR_NAME_CASE) == HTMLCorePreferenceNames.LOWER); - - super.initializeValues(); - } - - protected void storeValues() { - if (fTagNameUpper.getSelection()) - getModelPreferences().setValue(HTMLCorePreferenceNames.TAG_NAME_CASE, HTMLCorePreferenceNames.UPPER); - else - getModelPreferences().setValue(HTMLCorePreferenceNames.TAG_NAME_CASE, HTMLCorePreferenceNames.LOWER); - if (fAttrNameUpper.getSelection()) - getModelPreferences().setValue(HTMLCorePreferenceNames.ATTR_NAME_CASE, HTMLCorePreferenceNames.UPPER); - else - getModelPreferences().setValue(HTMLCorePreferenceNames.ATTR_NAME_CASE, HTMLCorePreferenceNames.LOWER); - - super.storeValues(); - } - - public boolean performOk() { - boolean result = super.performOk(); - - doSavePreferenceStore(); - - return result; - } - - protected Preferences getModelPreferences() { - return HTMLCorePlugin.getDefault().getPluginPreferences(); - } - - protected IPreferenceStore doGetPreferenceStore() { - return HTMLUIPlugin.getDefault().getPreferenceStore(); - } - - protected void doSavePreferenceStore() { - HTMLUIPlugin.getDefault().savePluginPreferences(); // UI - HTMLCorePlugin.getDefault().savePluginPreferences(); // model - } - - /* (non-Javadoc) - * @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite) - */ - protected Control createContents(Composite parent) { - Control c = super.createContents(parent); - PlatformUI.getWorkbench().getHelpSystem().setHelp(c, IHelpContextIds.HTML_PREFWEBX_SOURCE_HELPID); - return c; - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/preferences/ui/HTMLTemplatePreferencePage.java b/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/preferences/ui/HTMLTemplatePreferencePage.java deleted file mode 100644 index ce844e0983..0000000000 --- a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/preferences/ui/HTMLTemplatePreferencePage.java +++ /dev/null @@ -1,97 +0,0 @@ -/******************************************************************************* - * 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.html.ui.internal.preferences.ui; - -import org.eclipse.jface.resource.JFaceResources; -import org.eclipse.jface.text.IDocument; -import org.eclipse.jface.text.source.ISourceViewer; -import org.eclipse.jface.text.source.SourceViewer; -import org.eclipse.jface.text.source.SourceViewerConfiguration; -import org.eclipse.swt.SWT; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.texteditor.templates.TemplatePreferencePage; -import org.eclipse.wst.html.core.internal.provisional.contenttype.ContentTypeIdForHTML; -import org.eclipse.wst.html.ui.StructuredTextViewerConfigurationHTML; -import org.eclipse.wst.html.ui.internal.HTMLUIPlugin; -import org.eclipse.wst.html.ui.internal.editor.IHelpContextIds; -import org.eclipse.wst.sse.core.StructuredModelManager; -import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel; -import org.eclipse.wst.sse.ui.StructuredTextViewerConfiguration; -import org.eclipse.wst.sse.ui.internal.StructuredTextViewer; -import org.eclipse.wst.sse.ui.internal.provisional.style.LineStyleProvider; - - -/** - * Preference page for HTML templates - */ -public class HTMLTemplatePreferencePage extends TemplatePreferencePage { - - public HTMLTemplatePreferencePage() { - HTMLUIPlugin htmlEditorPlugin = HTMLUIPlugin.getDefault(); - - setPreferenceStore(htmlEditorPlugin.getPreferenceStore()); - setTemplateStore(htmlEditorPlugin.getTemplateStore()); - setContextTypeRegistry(htmlEditorPlugin.getTemplateContextRegistry()); - } - - /* (non-Javadoc) - * @see org.eclipse.jface.preference.IPreferencePage#performOk() - */ - public boolean performOk() { - boolean ok = super.performOk(); - HTMLUIPlugin.getDefault().savePluginPreferences(); - return ok; - } - - /* (non-Javadoc) - * @see org.eclipse.ui.texteditor.templates.TemplatePreferencePage#isShowFormatterSetting() - */ - protected boolean isShowFormatterSetting() { - // template formatting has not been implemented - return false; - } - /* (non-Javadoc) - * @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite) - */ - protected Control createContents(Composite ancestor) { - Control c = super.createContents(ancestor); - PlatformUI.getWorkbench().getHelpSystem().setHelp(c, IHelpContextIds.HTML_PREFWEBX_TEMPLATES_HELPID); - return c; - } - /* - * (non-Javadoc) - * @see org.eclipse.ui.texteditor.templates.TemplatePreferencePage#createViewer(org.eclipse.swt.widgets.Composite) - */ - protected SourceViewer createViewer(Composite parent) { - SourceViewer viewer = null; - String contentTypeID = ContentTypeIdForHTML.ContentTypeID_HTML; - SourceViewerConfiguration sourceViewerConfiguration = new StructuredTextViewerConfiguration() { - StructuredTextViewerConfiguration baseConfiguration = new StructuredTextViewerConfigurationHTML(); - - public String[] getConfiguredContentTypes(ISourceViewer sourceViewer) { - return baseConfiguration.getConfiguredContentTypes(sourceViewer); - } - - public LineStyleProvider[] getLineStyleProviders(ISourceViewer sourceViewer, String partitionType) { - return baseConfiguration.getLineStyleProviders(sourceViewer, partitionType); - } - }; - viewer = new StructuredTextViewer(parent, null, null, false, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL); - ((StructuredTextViewer) viewer).getTextWidget().setFont(JFaceResources.getFont("org.eclipse.wst.sse.ui.textfont")); //$NON-NLS-1$ - IStructuredModel scratchModel = StructuredModelManager.getModelManager().createUnManagedStructuredModelFor(contentTypeID); - IDocument document = scratchModel.getStructuredDocument(); - viewer.configure(sourceViewerConfiguration); - viewer.setDocument(document); - return viewer; - } -} diff --git a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/projection/ProjectionAnnotationModelChanges.java b/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/projection/ProjectionAnnotationModelChanges.java deleted file mode 100644 index 2273bb7462..0000000000 --- a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/projection/ProjectionAnnotationModelChanges.java +++ /dev/null @@ -1,54 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.html.ui.internal.projection; - -import java.util.Map; - -import org.eclipse.jface.text.source.Annotation; -import org.w3c.dom.Node; - -/** - * Contains a set of projection model additions/deletions/modifications - */ -class ProjectionAnnotationModelChanges { - // copies of this class located in: - // org.eclipse.wst.xml.ui.internal.projection - // org.eclipse.wst.css.ui.internal.projection - // org.eclipse.wst.html.ui.internal.projection - // org.eclipse.jst.jsp.ui.internal.projection - private Node fNode; - private Annotation[] fDeletions; - private Map fAdditions; - private Annotation[] fModifications; - - public ProjectionAnnotationModelChanges(Node node, Annotation[] deletions, Map additions, Annotation[] modifications) { - fNode = node; - fDeletions = deletions; - fAdditions = additions; - fModifications = modifications; - } - - public Map getAdditions() { - return fAdditions; - } - - public Annotation[] getDeletions() { - return fDeletions; - } - - public Annotation[] getModifications() { - return fModifications; - } - - public Node getNode() { - return fNode; - } -} diff --git a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/projection/ProjectionModelNodeAdapterFactoryHTML.java b/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/projection/ProjectionModelNodeAdapterFactoryHTML.java deleted file mode 100644 index 32c7a35c5a..0000000000 --- a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/projection/ProjectionModelNodeAdapterFactoryHTML.java +++ /dev/null @@ -1,205 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - * - *******************************************************************************/ -package org.eclipse.wst.html.ui.internal.projection; - -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; - -import org.eclipse.jface.text.source.Annotation; -import org.eclipse.jface.text.source.projection.ProjectionViewer; -import org.eclipse.wst.html.core.internal.provisional.HTML40Namespace; -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.INodeNotifier; -import org.w3c.dom.Node; - -public class ProjectionModelNodeAdapterFactoryHTML extends AbstractAdapterFactory { - // copies of this class located in: - // org.eclipse.wst.html.ui.internal.projection - // org.eclipse.jst.jsp.ui.internal.projection - - /** - * List of projection viewers currently associated with this projection - * model node adapter factory. - */ - private HashMap fProjectionViewers; - - public ProjectionModelNodeAdapterFactoryHTML(Object adapterKey, boolean registerAdapters) { - super(adapterKey, registerAdapters); - } - - public ProjectionModelNodeAdapterFactoryHTML(Object adapterKey) { - super(adapterKey); - } - - public ProjectionModelNodeAdapterFactoryHTML() { - this(ProjectionModelNodeAdapterHTML.class); - } - - /** - * Actually creates an adapter for the parent of target if target is the - * "adapt-able" node - */ - protected INodeAdapter createAdapter(INodeNotifier target) { - if ((isActive()) && (target instanceof Node) && ((Node) target).getNodeType() == Node.ELEMENT_NODE) { - Node node = (Node) target; - if (isNodeProjectable(node)) { - - // actually work with the parent node to listen for add, - // delete events - Node parent = node.getParentNode(); - if (parent instanceof INodeNotifier) { - INodeNotifier parentNotifier = (INodeNotifier) parent; - ProjectionModelNodeAdapterHTML parentAdapter = (ProjectionModelNodeAdapterHTML) parentNotifier.getExistingAdapter(ProjectionModelNodeAdapterHTML.class); - if (parentAdapter == null) { - // create a new adapter for parent - parentAdapter = new ProjectionModelNodeAdapterHTML(this); - parentNotifier.addAdapter(parentAdapter); - } - // call update on parent because a new node has just been - // added - parentAdapter.updateAdapter(parent); - } - } - } - - return null; - } - - /** - * Returns true if node is a node type able to fold - * - * @param node - * @return boolean true if node is projectable, false otherwise - */ - boolean isNodeProjectable(Node node) { - if (node.getNodeType() == Node.ELEMENT_NODE) { - String tagName = node.getNodeName(); - // node is only projectable if it is head, body, script, style, - // table, ul, ol tags - if (HTML40Namespace.ElementName.HEAD.equalsIgnoreCase(tagName) || HTML40Namespace.ElementName.BODY.equalsIgnoreCase(tagName) || HTML40Namespace.ElementName.SCRIPT.equalsIgnoreCase(tagName) || HTML40Namespace.ElementName.STYLE.equalsIgnoreCase(tagName) || HTML40Namespace.ElementName.TABLE.equalsIgnoreCase(tagName) || HTML40Namespace.ElementName.UL.equalsIgnoreCase(tagName) || HTML40Namespace.ElementName.OL.equalsIgnoreCase(tagName)) - return true; - } - return false; - } - - /** - * Return true if this factory is currently actively managing projection - * - * @return - */ - boolean isActive() { - return (fProjectionViewers != null && !fProjectionViewers.isEmpty()); - } - - /** - * Updates projection annotation model if document is not in flux. - * Otherwise, queues up the changes to be applied when document is ready. - * - * @param node - * @param deletions - * @param additions - * @param modifications - */ - void queueAnnotationModelChanges(Node node, Annotation[] deletions, Map additions, Annotation[] modifications) { - queueAnnotationModelChanges(node, deletions, additions, modifications, null); - } - - /** - * Updates projection annotation model for a specific projection viewer if - * document is not in flux. Otherwise, queues up the changes to be applied - * when document is ready. - * - * @param node - * @param deletions - * @param additions - * @param modifications - * @param viewer - */ - void queueAnnotationModelChanges(Node node, Annotation[] deletions, Map additions, Annotation[] modifications, ProjectionViewer viewer) { - // create a change object for latest change and add to queue - ProjectionAnnotationModelChanges newChange = new ProjectionAnnotationModelChanges(node, deletions, additions, modifications); - if (fProjectionViewers != null) { - if (viewer != null) { - ProjectionViewerInformation info = (ProjectionViewerInformation) fProjectionViewers.get(viewer); - if (info != null) { - info.queueAnnotationModelChanges(newChange); - } - } - else { - Iterator infos = fProjectionViewers.values().iterator(); - while (infos.hasNext()) { - ProjectionViewerInformation info = (ProjectionViewerInformation) infos.next(); - info.queueAnnotationModelChanges(newChange); - } - } - } - } - - public void release() { - // go through every projectionviewer and call - // removeProjectionViewer(viewer); - if (fProjectionViewers != null) { - Iterator infos = fProjectionViewers.values().iterator(); - while (infos.hasNext()) { - ProjectionViewerInformation info = (ProjectionViewerInformation) infos.next(); - info.dispose(); - infos.remove(); - } - fProjectionViewers = null; - } - super.release(); - } - - /** - * Adds viewer to list of projection viewers this factory is associated - * with - * - * @param viewer - - * assumes viewer's document and projection annotation model - * are not null - */ - void addProjectionViewer(ProjectionViewer viewer) { - // remove old entry if it exists - removeProjectionViewer(viewer); - - if (fProjectionViewers == null) { - fProjectionViewers = new HashMap(); - } - - // create new object containing projection viewer and its info - ProjectionViewerInformation info = new ProjectionViewerInformation(viewer); - fProjectionViewers.put(viewer, info); - info.initialize(); - } - - /** - * Removes the given viewer from the list of projection viewers this - * factor is associated with - * - * @param viewer - */ - void removeProjectionViewer(ProjectionViewer viewer) { - if (fProjectionViewers != null) { - // remove entry from list of viewers - ProjectionViewerInformation info = (ProjectionViewerInformation) fProjectionViewers.remove(viewer); - if (info != null) { - info.dispose(); - } - // if removing last projection viewer, clear out everything - if (fProjectionViewers.isEmpty()) { - fProjectionViewers = null; - } - } - } -} diff --git a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/projection/ProjectionModelNodeAdapterHTML.java b/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/projection/ProjectionModelNodeAdapterHTML.java deleted file mode 100644 index 6544f7aeed..0000000000 --- a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/projection/ProjectionModelNodeAdapterHTML.java +++ /dev/null @@ -1,291 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - * - *******************************************************************************/ -package org.eclipse.wst.html.ui.internal.projection; - -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; - -import org.eclipse.core.runtime.Platform; -import org.eclipse.jface.text.Position; -import org.eclipse.jface.text.source.projection.ProjectionAnnotation; -import org.eclipse.jface.text.source.projection.ProjectionViewer; -import org.eclipse.swt.graphics.FontMetrics; -import org.eclipse.swt.graphics.GC; -import org.eclipse.swt.graphics.Rectangle; -import org.eclipse.swt.widgets.Canvas; -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.IndexedRegion; -import org.w3c.dom.Node; - -/** - * Updates projection annotation model with projection annotations for this - * adapter node's children - */ -public class ProjectionModelNodeAdapterHTML implements INodeAdapter { - // copies of this class located in: - // org.eclipse.wst.html.ui.internal.projection - // org.eclipse.jst.jsp.ui.internal.projection - private final static boolean debugProjectionPerf = "true".equalsIgnoreCase(Platform.getDebugOption("org.eclipse.wst.html.ui/projectionperf")); //$NON-NLS-1$ //$NON-NLS-2$ - - private class TagProjectionAnnotation extends ProjectionAnnotation { - private boolean fIsVisible = false; /* workaround for BUG85874 */ - private Node fNode; - - public TagProjectionAnnotation(Node node, boolean isCollapsed) { - super(isCollapsed); - fNode = node; - } - - public Node getNode() { - return fNode; - } - - public void setNode(Node node) { - fNode = node; - } - - /** - * Does not paint hidden annotations. Annotations are hidden when they - * only span one line. - * - * @see ProjectionAnnotation#paint(org.eclipse.swt.graphics.GC, - * org.eclipse.swt.widgets.Canvas, - * org.eclipse.swt.graphics.Rectangle) - */ - public void paint(GC gc, Canvas canvas, Rectangle rectangle) { - /* workaround for BUG85874 */ - /* - * only need to check annotations that are expanded because hidden - * annotations should never have been given the chance to - * collapse. - */ - if (!isCollapsed()) { - // working with rectangle, so line height - FontMetrics metrics = gc.getFontMetrics(); - if (metrics != null) { - // do not draw annotations that only span one line and - // mark them as not visible - if ((rectangle.height / metrics.getHeight()) <= 1) { - fIsVisible = false; - return; - } - } - } - fIsVisible = true; - super.paint(gc, canvas, rectangle); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.text.source.projection.ProjectionAnnotation#markCollapsed() - */ - public void markCollapsed() { - /* workaround for BUG85874 */ - // do not mark collapsed if annotation is not visible - if (fIsVisible) - super.markCollapsed(); - } - } - - // copies of this class located in: - // org.eclipse.wst.html.ui.internal.projection - // org.eclipse.jst.jsp.ui.internal.projection - - ProjectionModelNodeAdapterFactoryHTML fAdapterFactory; - private Map fTagAnnotations = new HashMap(); - - public ProjectionModelNodeAdapterHTML(ProjectionModelNodeAdapterFactoryHTML factory) { - fAdapterFactory = factory; - } - - /** - * Create a projection position from the given node. Able to get - * projection position if node isNodeProjectable. - * - * @param node - * @return null if no projection position possible, a Position otherwise - */ - private Position createProjectionPosition(Node node) { - Position pos = null; - if (fAdapterFactory.isNodeProjectable(node) && node instanceof IndexedRegion) { - // IDocument document = - // fAdapterFactory.getProjectionViewer().getDocument(); - // if (document != null) { - IndexedRegion inode = (IndexedRegion) node; - int start = inode.getStartOffset(); - int end = inode.getEndOffset(); - if (start >= 0 && start < end) { - // region-based - // extra line when collapsed, but no region - // increase when add newline - pos = new Position(start, end - start); - // try { - // // line-based - // // extra line when collapsed, but no region - // // increase when add newline - // IRegion startLineRegion = - // document.getLineInformationOfOffset(start); - // IRegion endLineRegion = - // document.getLineInformationOfOffset(end); - // int startOffset = startLineRegion.getOffset(); - // int endOffset = endLineRegion.getOffset() + - // endLineRegion.getLength(); - // if (endOffset > startOffset) { - // pos = new Position(startOffset, endOffset - - // startOffset); - // } - // - // // line-based - // // no extra line when collapsed, but region increase - // // when add newline - // int startLine = document.getLineOfOffset(start); - // int endLine = document.getLineOfOffset(end); - // if (endLine + 1 < document.getNumberOfLines()) { - // int offset = document.getLineOffset(startLine); - // int endOffset = document.getLineOffset(endLine + 1); - // pos = new Position(offset, endOffset - offset); - // } - // } - // catch (BadLocationException x) { - // Logger.log(Logger.WARNING_DEBUG, null, x); - // } - } - } - // } - return pos; - } - - /** - * Find TagProjectionAnnotation for node in the current list of projection - * annotations for this adapter - * - * @param node - * @return TagProjectionAnnotation - */ - private TagProjectionAnnotation getExistingAnnotation(Node node) { - TagProjectionAnnotation anno = null; - - if ((node != null) && (!fTagAnnotations.isEmpty())) { - Iterator it = fTagAnnotations.keySet().iterator(); - while (it.hasNext() && anno == null) { - TagProjectionAnnotation a = (TagProjectionAnnotation) it.next(); - Node n = a.getNode(); - if (node.equals(n)) { - anno = a; - } - } - } - return anno; - } - - public boolean isAdapterForType(Object type) { - return type == ProjectionModelNodeAdapterHTML.class; - } - - public void notifyChanged(INodeNotifier notifier, int eventType, Object changedFeature, Object oldValue, Object newValue, int pos) { - // check if folding is even enabled, if not, just ignore notifyChanged - // events - if (!fAdapterFactory.isActive()) { - return; - } - - if ((eventType == INodeNotifier.STRUCTURE_CHANGED) && (notifier instanceof Node)) { - updateAdapter((Node) notifier); - } - } - - /** - * Update the projection annotation of all the nodes that are children of - * node - * - * @param node - */ - void updateAdapter(Node node) { - updateAdapter(node, null); - } - - /** - * Update the projection annotation of all the nodes that are children of - * node and adds all projection annotations to viewer (for newly added - * viewers) - * - * @param node - * @param viewer - */ - void updateAdapter(Node node, ProjectionViewer viewer) { - long start = System.currentTimeMillis(); - - Map additions = new HashMap(); - Map projectionAnnotations = new HashMap(); - - // go through immediate child nodes and figure out projection - // model annotations - if (node != null) { - Node childNode = node.getFirstChild(); - while (childNode != null) { - Position newPos = createProjectionPosition(childNode); - if (newPos != null) { - TagProjectionAnnotation newAnnotation = new TagProjectionAnnotation(childNode, false); - TagProjectionAnnotation existing = getExistingAnnotation(childNode); - if (existing == null) { - // add to map containing all annotations for this - // adapter - projectionAnnotations.put(newAnnotation, newPos); - // add to map containing annotations to add - additions.put(newAnnotation, newPos); - } - else { - // add to map containing all annotations for this - // adapter - projectionAnnotations.put(existing, newPos); - // remove from map containing annotations to delete - fTagAnnotations.remove(existing); - } - } - childNode = childNode.getNextSibling(); - } - - // in the end, want to delete anything leftover in old list, add - // everything in additions, and update everything in - // projectionAnnotations - ProjectionAnnotation[] oldList = null; - if (!fTagAnnotations.isEmpty()) { - oldList = (ProjectionAnnotation[]) fTagAnnotations.keySet().toArray(new ProjectionAnnotation[0]); - } - ProjectionAnnotation[] modifyList = null; - if (!projectionAnnotations.isEmpty()) { - modifyList = (ProjectionAnnotation[]) projectionAnnotations.keySet().toArray(new ProjectionAnnotation[0]); - } - - // specifically add all annotations to viewer - if (viewer != null && !projectionAnnotations.isEmpty()) { - fAdapterFactory.queueAnnotationModelChanges(node, null, projectionAnnotations, null, viewer); - } - - // only update when there is something to update - if ((oldList != null && oldList.length > 0) || (!additions.isEmpty()) || (modifyList != null && modifyList.length > 0)) - fAdapterFactory.queueAnnotationModelChanges(node, oldList, additions, modifyList); - } - - // save new list of annotations - fTagAnnotations = projectionAnnotations; - - if (debugProjectionPerf) { - long end = System.currentTimeMillis(); - String nodeName = node != null ? node.getNodeName() : "null"; //$NON-NLS-1$ - System.out.println("ProjectionModelNodeAdapterHTML.updateAdapter (" + nodeName + "):" + (end - start)); //$NON-NLS-1$ //$NON-NLS-2$ - } - } -} diff --git a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/projection/ProjectionViewerInformation.java b/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/projection/ProjectionViewerInformation.java deleted file mode 100644 index 675efa57da..0000000000 --- a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/projection/ProjectionViewerInformation.java +++ /dev/null @@ -1,196 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.html.ui.internal.projection; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.jface.text.DocumentEvent; -import org.eclipse.jface.text.IDocument; -import org.eclipse.jface.text.IDocumentExtension; -import org.eclipse.jface.text.IDocumentListener; -import org.eclipse.jface.text.source.projection.ProjectionAnnotationModel; -import org.eclipse.jface.text.source.projection.ProjectionViewer; -import org.eclipse.wst.html.ui.internal.Logger; - -/** - * Contains information about a projection viewer and also manages updating - * the viewer's projection annotation model - */ -class ProjectionViewerInformation { - // copies of this class located in: - // org.eclipse.wst.xml.ui.internal.projection - // org.eclipse.wst.css.ui.internal.projection - // org.eclipse.wst.html.ui.internal.projection - // org.eclipse.jst.jsp.ui.internal.projection - - /** - * Listens to document to be aware of when to update the projection - * annotation model. - */ - private class DocumentListener implements IDocumentListener { - private ProjectionViewerInformation fInfo; - - public DocumentListener(ProjectionViewerInformation info) { - fInfo = info; - } - - public void documentAboutToBeChanged(DocumentEvent event) { - IDocument document = event.getDocument(); - if (fInfo.getDocument() == document) { - fInfo.setIsDocumentChanging(true); - } - } - - public void documentChanged(DocumentEvent event) { - // register a post notification replace so that projection - // annotation model will be updated after all documentChanged - // listeners have been notified - IDocument document = event.getDocument(); - if (document instanceof IDocumentExtension && fInfo.getDocument() == document) { - if (fInfo.hasChangesQueued()) - ((IDocumentExtension) document).registerPostNotificationReplace(this, new PostDocumentChangedListener(fInfo)); - } - } - } - - /** - * Essentially a post document changed listener because it is called after - * documentchanged has been fired. - */ - private class PostDocumentChangedListener implements IDocumentExtension.IReplace { - private ProjectionViewerInformation fInfo; - - public PostDocumentChangedListener(ProjectionViewerInformation info) { - fInfo = info; - } - - public void perform(IDocument document, IDocumentListener owner) { - fInfo.applyAnnotationModelChanges(); - fInfo.setIsDocumentChanging(false); - } - } - - /** - * Projection annotation model current associated with this projection - * viewer - */ - private ProjectionAnnotationModel fProjectionAnnotationModel; - /** - * Document currently associated with this projection viewer - */ - private IDocument fDocument; - /** - * Listener to fProjectionViewer's document - */ - private IDocumentListener fDocumentListener; - /** - * Indicates whether or not document is in the middle of changing - */ - private boolean fIsDocumentChanging = false; - /** - * List of projection annotation model changes that need to be applied - */ - private List fQueuedAnnotationChanges; - - public ProjectionViewerInformation(ProjectionViewer viewer) { - fDocument = viewer.getDocument(); - fProjectionAnnotationModel = viewer.getProjectionAnnotationModel(); - } - - IDocument getDocument() { - return fDocument; - } - - private List getQueuedAnnotationChanges() { - if (fQueuedAnnotationChanges == null) { - fQueuedAnnotationChanges = new ArrayList(); - } - return fQueuedAnnotationChanges; - } - - void setIsDocumentChanging(boolean changing) { - fIsDocumentChanging = changing; - } - - private boolean isDocumentChanging() { - return fIsDocumentChanging; - } - - /** - * Applies the pending projection annotation model changes to the - * projection annotation model. - */ - void applyAnnotationModelChanges() { - List queuedChanges = getQueuedAnnotationChanges(); - // go through all the pending annotation changes and apply - // them to - // the projection annotation model - while (!queuedChanges.isEmpty()) { - ProjectionAnnotationModelChanges changes = (ProjectionAnnotationModelChanges) queuedChanges.remove(0); - try { - fProjectionAnnotationModel.modifyAnnotations(changes.getDeletions(), changes.getAdditions(), changes.getModifications()); - } - catch (Exception e) { - // if anything goes wrong, log it and continue - Logger.log(Logger.WARNING_DEBUG, e.getMessage(), e); - } - } - } - - /** - * Returns true if there are annotation changes queued up, false otherwise - * - * @return boolean - */ - boolean hasChangesQueued() { - return !getQueuedAnnotationChanges().isEmpty(); - } - - /** - * Updates projection annotation model if document is not in flux. - * Otherwise, queues up the changes to be applied when document is ready. - */ - public void queueAnnotationModelChanges(ProjectionAnnotationModelChanges newChange) { - /* - * future_TODO: maybe improve by checking if annotation projection - * model change already exists for node. if so, throw out old change. - */ - getQueuedAnnotationChanges().add(newChange); - - // if document isn't changing, go ahead and apply it - if (!isDocumentChanging()) { - applyAnnotationModelChanges(); - } - } - - public void initialize() { - // add document listener - if (fDocumentListener == null) { - fDocumentListener = new DocumentListener(this); - } - getDocument().addDocumentListener(fDocumentListener); - } - - public void dispose() { - // remove document listener - if (fDocumentListener != null) { - getDocument().removeDocumentListener(fDocumentListener); - } - - // clear out list of queued changes since it may no longer - // be accurate - if (fQueuedAnnotationChanges != null) { - fQueuedAnnotationChanges.clear(); - fQueuedAnnotationChanges = null; - } - } -} diff --git a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/projection/StructuredTextFoldingProviderHTML.java b/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/projection/StructuredTextFoldingProviderHTML.java deleted file mode 100644 index a117ccab8c..0000000000 --- a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/projection/StructuredTextFoldingProviderHTML.java +++ /dev/null @@ -1,326 +0,0 @@ -package org.eclipse.wst.html.ui.internal.projection; - -import org.eclipse.core.runtime.Platform; -import org.eclipse.jface.text.IDocument; -import org.eclipse.jface.text.ITextInputListener; -import org.eclipse.jface.text.source.projection.IProjectionListener; -import org.eclipse.jface.text.source.projection.ProjectionViewer; -import org.eclipse.wst.sse.core.StructuredModelManager; -import org.eclipse.wst.sse.core.internal.PropagatingAdapter; -import org.eclipse.wst.sse.core.internal.model.FactoryRegistry; -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.ui.internal.projection.IStructuredTextFoldingProvider; -import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel; -import org.w3c.dom.Document; -import org.w3c.dom.Node; - -/** - * Updates the projection model of a structured model for HTML. - */ -public class StructuredTextFoldingProviderHTML implements IStructuredTextFoldingProvider, IProjectionListener, ITextInputListener { - private final static boolean debugProjectionPerf = "true".equalsIgnoreCase(Platform.getDebugOption("org.eclipse.wst.html.ui/projectionperf")); //$NON-NLS-1$ //$NON-NLS-2$ - - private IDocument fDocument; - private ProjectionViewer fViewer; - private boolean fProjectionNeedsToBeEnabled = false; - /** - * Maximum number of child nodes to add adapters to (limit for performance - * sake) - */ - private final int MAX_CHILDREN = 10; - /** - * Maximum number of sibling nodes to add adapters to (limit for - * performance sake) - */ - private final int MAX_SIBLINGS = 1000; - - /** - * Adds an adapter to node and its children - * - * @param node - * @param childLevel - */ - private void addAdapterToNodeAndChildren(Node node, int childLevel) { - // stop adding initial adapters MAX_CHILDREN levels deep for - // performance sake - if (node instanceof INodeNotifier && childLevel < MAX_CHILDREN) { - INodeNotifier notifier = (INodeNotifier) node; - - // try and get the adapter for the current node and update the - // adapter with projection information - ProjectionModelNodeAdapterHTML adapter = (ProjectionModelNodeAdapterHTML) notifier.getExistingAdapter(ProjectionModelNodeAdapterHTML.class); - if (adapter != null) { - adapter.updateAdapter(node, fViewer); - } - else { - // just call getadapter so the adapter is created and - // automatically initialized - notifier.getAdapterFor(ProjectionModelNodeAdapterHTML.class); - } - int siblingLevel = 0; - Node nextChild = node.getFirstChild(); - while (nextChild != null && siblingLevel < MAX_SIBLINGS) { - Node childNode = nextChild; - nextChild = childNode.getNextSibling(); - - addAdapterToNodeAndChildren(childNode, childLevel + 1); - ++siblingLevel; - } - } - } - - /** - * Goes through every node and adds an adapter onto each for tracking - * purposes - */ - private void addAllAdapters() { - long start = System.currentTimeMillis(); - - if (fDocument != null) { - IStructuredModel sModel = null; - try { - sModel = StructuredModelManager.getModelManager().getExistingModelForRead(fDocument); - if (sModel != null) { - int startOffset = 0; - IndexedRegion startNode = sModel.getIndexedRegion(startOffset); - if (startNode instanceof Node) { - int siblingLevel = 0; - Node nextSibling = (Node) startNode; - while (nextSibling != null && siblingLevel < MAX_SIBLINGS) { - Node currentNode = nextSibling; - nextSibling = currentNode.getNextSibling(); - - addAdapterToNodeAndChildren(currentNode, 0); - ++siblingLevel; - } - } - } - } - finally { - if (sModel != null) { - sModel.releaseFromRead(); - } - } - } - if (debugProjectionPerf) { - long end = System.currentTimeMillis(); - System.out.println("StructuredTextFoldingProviderHTML.addAllAdapters: " + (end - start)); //$NON-NLS-1$ - } - } - - /** - * Get the ProjectionModelNodeAdapterFactoryHTML to use with this - * provider. - * - * @return ProjectionModelNodeAdapterFactoryHTML - */ - private ProjectionModelNodeAdapterFactoryHTML getAdapterFactory(boolean createIfNeeded) { - long start = System.currentTimeMillis(); - - ProjectionModelNodeAdapterFactoryHTML factory = null; - if (fDocument != null) { - IStructuredModel sModel = null; - try { - sModel = StructuredModelManager.getModelManager().getExistingModelForRead(fDocument); - if (sModel != null) { - FactoryRegistry factoryRegistry = sModel.getFactoryRegistry(); - - // getting the projectionmodelnodeadapter for the first - // time - // so do some initializing - if (!factoryRegistry.contains(ProjectionModelNodeAdapterHTML.class) && createIfNeeded) { - ProjectionModelNodeAdapterFactoryHTML newFactory = new ProjectionModelNodeAdapterFactoryHTML(); - - // add factory to factory registry - factoryRegistry.addFactory(newFactory); - - // add factory to propogating adapter - IDOMModel domModel = (IDOMModel) sModel; - Document document = domModel.getDocument(); - PropagatingAdapter propagatingAdapter = (PropagatingAdapter) ((INodeNotifier) document).getAdapterFor(PropagatingAdapter.class); - if (propagatingAdapter != null) { - propagatingAdapter.addAdaptOnCreateFactory(newFactory); - } - } - - // try and get the factory - factory = (ProjectionModelNodeAdapterFactoryHTML) factoryRegistry.getFactoryFor(ProjectionModelNodeAdapterHTML.class); - } - } - finally { - if (sModel != null) - sModel.releaseFromRead(); - } - } - - if (debugProjectionPerf) { - long end = System.currentTimeMillis(); - System.out.println("StructuredTextFoldingProviderHTML.getAdapterFactory: " + (end - start)); //$NON-NLS-1$ - } - return factory; - } - - /** - * Initialize this provider with the correct document. Assumes projection - * is enabled. (otherwise, only install would have been called) - */ - public void initialize() { - if (!isInstalled()) - return; - - // clear out old info - projectionDisabled(); - - fDocument = fViewer.getDocument(); - - // set projection viewer on new document's adapter factory - if (fViewer.getProjectionAnnotationModel() != null) { - ProjectionModelNodeAdapterFactoryHTML factory = getAdapterFactory(true); - if (factory != null) { - factory.addProjectionViewer(fViewer); - } - - addAllAdapters(); - } - fProjectionNeedsToBeEnabled = false; - } - - /** - * Associate a ProjectionViewer with this IStructuredTextFoldingProvider - * - * @param viewer - - * assumes not null - */ - public void install(ProjectionViewer viewer) { - // uninstall before trying to install new viewer - if (isInstalled()) { - uninstall(); - } - fViewer = viewer; - fViewer.addProjectionListener(this); - fViewer.addTextInputListener(this); - } - - private boolean isInstalled() { - return fViewer != null; - } - - public void projectionDisabled() { - ProjectionModelNodeAdapterFactoryHTML factory = getAdapterFactory(false); - if (factory != null) { - factory.removeProjectionViewer(fViewer); - } - - // clear out all annotations - if (fViewer.getProjectionAnnotationModel() != null) - fViewer.getProjectionAnnotationModel().removeAllAnnotations(); - - removeAllAdapters(); - - fDocument = null; - fProjectionNeedsToBeEnabled = false; - } - - public void projectionEnabled() { - initialize(); - } - - /** - * Removes an adapter from node and its children - * - * @param node - * @param level - */ - private void removeAdapterFromNodeAndChildren(Node node, int level) { - if (node instanceof INodeNotifier) { - INodeNotifier notifier = (INodeNotifier) node; - - // try and get the adapter for the current node and remove it - INodeAdapter adapter = notifier.getExistingAdapter(ProjectionModelNodeAdapterHTML.class); - if (adapter != null) { - notifier.removeAdapter(adapter); - } - - Node nextChild = node.getFirstChild(); - while (nextChild != null) { - Node childNode = nextChild; - nextChild = childNode.getNextSibling(); - - removeAdapterFromNodeAndChildren(childNode, level + 1); - } - } - } - - /** - * Goes through every node and removes adapter from each for cleanup - * purposes - */ - private void removeAllAdapters() { - long start = System.currentTimeMillis(); - - if (fDocument != null) { - IStructuredModel sModel = null; - try { - sModel = StructuredModelManager.getModelManager().getExistingModelForRead(fDocument); - if (sModel != null) { - int startOffset = 0; - IndexedRegion startNode = sModel.getIndexedRegion(startOffset); - if (startNode instanceof Node) { - Node nextSibling = (Node) startNode; - while (nextSibling != null) { - Node currentNode = nextSibling; - nextSibling = currentNode.getNextSibling(); - - removeAdapterFromNodeAndChildren(currentNode, 0); - } - } - } - } - finally { - if (sModel != null) { - sModel.releaseFromRead(); - } - } - } - - if (debugProjectionPerf) { - long end = System.currentTimeMillis(); - System.out.println("StructuredTextFoldingProviderHTML.removeAllAdapters: " + (end - start)); //$NON-NLS-1$ - } - } - - public void inputDocumentAboutToBeChanged(IDocument oldInput, IDocument newInput) { - // if folding is enabled and new document is going to be a totally - // different document, disable projection - if (fDocument != null && fDocument != newInput) { - // disable projection and disconnect everything - projectionDisabled(); - fProjectionNeedsToBeEnabled = true; - } - } - - public void inputDocumentChanged(IDocument oldInput, IDocument newInput) { - // if projection was previously enabled before input document changed - // and new document is different than old document - if (fProjectionNeedsToBeEnabled && fDocument == null && newInput != null) { - projectionEnabled(); - fProjectionNeedsToBeEnabled = false; - } - } - - /** - * Disconnect this IStructuredTextFoldingProvider from projection viewer - */ - public void uninstall() { - if (isInstalled()) { - projectionDisabled(); - - fViewer.removeProjectionListener(this); - fViewer.removeTextInputListener(this); - fViewer = null; - } - } -} diff --git a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/registry/AdapterFactoryProviderForHTML.java b/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/registry/AdapterFactoryProviderForHTML.java deleted file mode 100644 index 58bb496896..0000000000 --- a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/registry/AdapterFactoryProviderForHTML.java +++ /dev/null @@ -1,66 +0,0 @@ -/******************************************************************************* - * 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.html.ui.internal.registry; - -import org.eclipse.wst.html.core.internal.modelhandler.ModelHandlerForHTML; -import org.eclipse.wst.html.ui.internal.contentoutline.JFaceNodeAdapterFactoryForHTML; -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; -import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel; - - -public class AdapterFactoryProviderForHTML implements AdapterFactoryProvider { - - - public void addAdapterFactories(IStructuredModel structuredModel) { - - // these are the normal edit side content based factories - addContentBasedFactories(structuredModel); - // Must update/add to propagating adapter here too - if (structuredModel instanceof IDOMModel) { - 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 == null) { - factory = new JFaceNodeAdapterFactoryForHTML(); - factoryRegistry.addFactory(factory); - } - } - - protected void addPropagatingAdapters(IStructuredModel structuredModel) { - // no propagating to add - } - - /* - * @see AdapterFactoryProvider#isFor(ContentTypeDescription) - */ - public boolean isFor(IDocumentTypeHandler contentTypeDescription) { - return (contentTypeDescription instanceof ModelHandlerForHTML); - } - - public void reinitializeFactories(IStructuredModel structuredModel) { - // nothing to do, since no embedded type - } - -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/search/HTMLFindOccurrencesActionDelegate.java b/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/search/HTMLFindOccurrencesActionDelegate.java deleted file mode 100644 index 23c2c49085..0000000000 --- a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/search/HTMLFindOccurrencesActionDelegate.java +++ /dev/null @@ -1,34 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - * - *******************************************************************************/ - -package org.eclipse.wst.html.ui.internal.search; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.wst.sse.ui.internal.search.FindOccurrencesActionDelegate; - -/** - * Sets up FindOccurrencesActionDelegate for html find occurrences processors - */ -public class HTMLFindOccurrencesActionDelegate extends FindOccurrencesActionDelegate { - private List fProcessors; - - protected List getProcessors() { - if (fProcessors == null) { - fProcessors = new ArrayList(); - HTMLFindOccurrencesProcessor htmlProcessor = new HTMLFindOccurrencesProcessor(); - fProcessors.add(htmlProcessor); - } - return fProcessors; - } -} diff --git a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/search/HTMLFindOccurrencesProcessor.java b/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/search/HTMLFindOccurrencesProcessor.java deleted file mode 100644 index 2e2a696a58..0000000000 --- a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/search/HTMLFindOccurrencesProcessor.java +++ /dev/null @@ -1,32 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - * - *******************************************************************************/ - -package org.eclipse.wst.html.ui.internal.search; - -import org.eclipse.wst.html.core.text.IHTMLPartitions; -import org.eclipse.wst.sse.ui.internal.search.FindOccurrencesProcessor; -import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext; -import org.eclipse.wst.xml.core.text.IXMLPartitions; - -/** - * Configures a FindOccurrencesProcessor with HTML partitions and regions - */ -public class HTMLFindOccurrencesProcessor extends FindOccurrencesProcessor { - - protected String[] getPartitionTypes() { - return new String[]{IHTMLPartitions.HTML_DEFAULT, IXMLPartitions.XML_DEFAULT}; - } - - protected String[] getRegionTypes() { - return new String[]{DOMRegionContext.XML_TAG_NAME, DOMRegionContext.XML_TAG_ATTRIBUTE_NAME, DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE}; - } -} diff --git a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/style/IStyleConstantsHTML.java b/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/style/IStyleConstantsHTML.java deleted file mode 100644 index 5c7c88decc..0000000000 --- a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/style/IStyleConstantsHTML.java +++ /dev/null @@ -1,22 +0,0 @@ -/******************************************************************************* - * 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.html.ui.internal.style; - -import org.eclipse.wst.xml.ui.internal.style.IStyleConstantsXML; - -/** - * Contains the symbolic name of styles used by LineStyleProvider, ColorManager, and - * any others who may be interested - */ -public interface IStyleConstantsHTML extends IStyleConstantsXML { - public static final String SCRIPT_AREA_BORDER = "SCRIPT_AREA_BORDER";//$NON-NLS-1$ - public static final String SCRIPT_AREA = "SCRIPT_AREA";//$NON-NLS-1$ -} diff --git a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/style/LineStyleProviderForHTML.java b/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/style/LineStyleProviderForHTML.java deleted file mode 100644 index a2b5e7aa49..0000000000 --- a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/style/LineStyleProviderForHTML.java +++ /dev/null @@ -1,75 +0,0 @@ -/******************************************************************************* - * 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.html.ui.internal.style; - -import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.jface.text.TextAttribute; -import org.eclipse.jface.util.PropertyChangeEvent; -import org.eclipse.wst.html.ui.internal.HTMLUIPlugin; -import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion; -import org.eclipse.wst.sse.ui.internal.provisional.style.LineStyleProvider; -import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext; -import org.eclipse.wst.xml.ui.internal.style.IStyleConstantsXML; -import org.eclipse.wst.xml.ui.internal.style.LineStyleProviderForXML; - -public class LineStyleProviderForHTML extends LineStyleProviderForXML implements LineStyleProvider { - - public LineStyleProviderForHTML() { - super(); - } - - /** - * a method to centralize all the "format rules" for regions - * specifically associated for how to "open" the region. - */ - // NOTE: this method was just copied down form LineStyleProviderForXML - public TextAttribute getAttributeFor(ITextRegion region) { - // not sure why this is coming through null, but just to catch it - if (region == null) { - return (TextAttribute)getTextAttributes().get(IStyleConstantsXML.XML_CONTENT); - } - if (region.getType() == DOMRegionContext.BLOCK_TEXT) { - return (TextAttribute)getTextAttributes().get(IStyleConstantsXML.XML_CONTENT); - } - // first try "standard" tag attributes from super class - return super.getAttributeFor(region); - } - - protected void loadColors() { - super.loadColors(); - - addTextAttribute(IStyleConstantsHTML.SCRIPT_AREA_BORDER); - } - - - protected void handlePropertyChange(PropertyChangeEvent event) { - if (event != null) { - String prefKey = event.getProperty(); - // check if preference changed is a style preference - if (IStyleConstantsHTML.SCRIPT_AREA_BORDER.equals(prefKey)) { - addTextAttribute(IStyleConstantsHTML.SCRIPT_AREA_BORDER); - - // this is what AbstractLineStyleProvider.propertyChange() does - getHighlighter().refreshDisplay(); - } else { - super.handlePropertyChange(event); - } - } else { - super.handlePropertyChange(event); - } - } - /* (non-Javadoc) - * @see org.eclipse.wst.sse.ui.style.AbstractLineStyleProvider#getColorPreferences() - */ - protected IPreferenceStore getColorPreferences() { - return HTMLUIPlugin.getDefault().getPreferenceStore(); - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/taginfo/HTMLInformationProvider.java b/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/taginfo/HTMLInformationProvider.java deleted file mode 100644 index 4e9cb00a1d..0000000000 --- a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/taginfo/HTMLInformationProvider.java +++ /dev/null @@ -1,62 +0,0 @@ -/******************************************************************************* - * 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.html.ui.internal.taginfo; - - - -import org.eclipse.jface.text.IRegion; -import org.eclipse.jface.text.ITextHover; -import org.eclipse.jface.text.ITextViewer; -import org.eclipse.jface.text.information.IInformationProvider; -import org.eclipse.jface.text.information.IInformationProviderExtension; -import org.eclipse.wst.sse.ui.internal.SSEUIPlugin; - -/** - * Provides context information for HTML tags (Shows tooltip description) - */ -public class HTMLInformationProvider implements IInformationProvider, IInformationProviderExtension { - - private ITextHover fTextHover = null; - - public HTMLInformationProvider() { - fTextHover = SSEUIPlugin.getDefault().getTextHoverManager().createBestMatchHover(new HTMLTagInfoHoverProcessor()); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.text.information.IInformationProvider#getSubject(org.eclipse.jface.text.ITextViewer, - * int) - */ - public IRegion getSubject(ITextViewer textViewer, int offset) { - return fTextHover.getHoverRegion(textViewer, offset); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.text.information.IInformationProvider#getInformation(org.eclipse.jface.text.ITextViewer, - * org.eclipse.jface.text.IRegion) - */ - public String getInformation(ITextViewer textViewer, IRegion subject) { - return (String) getInformation2(textViewer, subject); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.text.information.IInformationProviderExtension#getInformation2(org.eclipse.jface.text.ITextViewer, - * org.eclipse.jface.text.IRegion) - */ - public Object getInformation2(ITextViewer textViewer, IRegion subject) { - return fTextHover.getHoverInfo(textViewer, subject); - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/taginfo/HTMLTagInfoHoverProcessor.java b/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/taginfo/HTMLTagInfoHoverProcessor.java deleted file mode 100644 index b8f7103d94..0000000000 --- a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/taginfo/HTMLTagInfoHoverProcessor.java +++ /dev/null @@ -1,28 +0,0 @@ -/******************************************************************************* - * 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.html.ui.internal.taginfo; - - - -import org.eclipse.wst.xml.ui.internal.taginfo.XMLTagInfoHoverProcessor; - -/** - * Provides hover help documentation for HTML tags - * - * @author amywu - */ -public class HTMLTagInfoHoverProcessor extends XMLTagInfoHoverProcessor { - // currently empty because XMLTagInfoHoverProcessor handles all cases relevant to HTML - public HTMLTagInfoHoverProcessor() { - super(); - } - -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/templates/EncodingTemplateVariableResolverHTML.java b/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/templates/EncodingTemplateVariableResolverHTML.java deleted file mode 100644 index aca7d175e7..0000000000 --- a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/templates/EncodingTemplateVariableResolverHTML.java +++ /dev/null @@ -1,38 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - * - *******************************************************************************/ -package org.eclipse.wst.html.ui.internal.templates; - -import org.eclipse.jface.text.templates.SimpleTemplateVariableResolver; -import org.eclipse.jface.text.templates.TemplateContext; -import org.eclipse.wst.html.core.internal.HTMLCorePlugin; -import org.eclipse.wst.html.ui.internal.HTMLUIMessages; -import org.eclipse.wst.sse.core.internal.encoding.CommonEncodingPreferenceNames; - - -public class EncodingTemplateVariableResolverHTML extends SimpleTemplateVariableResolver { - private static final String ENCODING_TYPE = getEncodingType(); - - private static String getEncodingType() { - return "encoding"; //$NON-NLS-1$ - } - - /** - * Creates a new encoding variable - */ - public EncodingTemplateVariableResolverHTML() { - super(ENCODING_TYPE, HTMLUIMessages.Creating_files_encoding); - } - - protected String resolve(TemplateContext context) { - return HTMLCorePlugin.getDefault().getPluginPreferences().getString(CommonEncodingPreferenceNames.OUTPUT_CODESET); - } -} diff --git a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/templates/TemplateContextTypeHTML.java b/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/templates/TemplateContextTypeHTML.java deleted file mode 100644 index bf775f4ce4..0000000000 --- a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/templates/TemplateContextTypeHTML.java +++ /dev/null @@ -1,34 +0,0 @@ -/******************************************************************************* - * 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.html.ui.internal.templates; - -import org.eclipse.jface.text.templates.GlobalTemplateVariables; -import org.eclipse.jface.text.templates.TemplateContextType; - -/** - * Base class for HTML template context types. Templates of this context type - * apply to any place within HTML content type. - */ -public class TemplateContextTypeHTML extends TemplateContextType { - - public TemplateContextTypeHTML() { - super(); - addResolver(new GlobalTemplateVariables.Cursor()); - addResolver(new GlobalTemplateVariables.Date()); - addResolver(new GlobalTemplateVariables.Dollar()); - addResolver(new GlobalTemplateVariables.LineSelection()); - addResolver(new GlobalTemplateVariables.Time()); - addResolver(new GlobalTemplateVariables.User()); - addResolver(new GlobalTemplateVariables.WordSelection()); - addResolver(new GlobalTemplateVariables.Year()); - addResolver(new EncodingTemplateVariableResolverHTML()); - } -} diff --git a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/templates/TemplateContextTypeIdsHTML.java b/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/templates/TemplateContextTypeIdsHTML.java deleted file mode 100644 index 794b13db36..0000000000 --- a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/templates/TemplateContextTypeIdsHTML.java +++ /dev/null @@ -1,50 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - * - *******************************************************************************/ -package org.eclipse.wst.html.ui.internal.templates; - - -public class TemplateContextTypeIdsHTML { - - public static final String ALL = getAll(); - - public static final String ATTRIBUTE = getAttribute(); - - public static final String ATTRIBUTE_VALUE = getAttributeValue(); - - public static final String NEW = getNew(); - - public static final String TAG = getTag(); - - private static String getAll() { - return getPrefix() + "_all"; //$NON-NLS-1$ - } - - private static String getAttribute() { - return getPrefix() + "_attribute"; //$NON-NLS-1$ - } - - private static String getAttributeValue() { - return getPrefix() + "_attribute_value"; //$NON-NLS-1$ - } - - private static String getNew() { - return getPrefix() + "_new"; //$NON-NLS-1$ - } - - private static String getTag() { - return getPrefix() + "_tag"; //$NON-NLS-1$ - } - - private static String getPrefix() { - return "html"; //$NON-NLS-1$ - } -} diff --git a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/text/HTMLDocumentRegionEdgeMatcher.java b/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/text/HTMLDocumentRegionEdgeMatcher.java deleted file mode 100644 index 7cbce425fb..0000000000 --- a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/text/HTMLDocumentRegionEdgeMatcher.java +++ /dev/null @@ -1,27 +0,0 @@ -/******************************************************************************* - * 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.html.ui.internal.text; - -import org.eclipse.wst.sse.ui.internal.text.DocumentRegionEdgeMatcher; -import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext; - -public class HTMLDocumentRegionEdgeMatcher extends DocumentRegionEdgeMatcher { - - protected final static char[] BRACKETS = {'{', '}', '(', ')', '[', ']'}; - - /** - * @param validContexts - * @param nextMatcher - */ - public HTMLDocumentRegionEdgeMatcher() { - super(new String[]{DOMRegionContext.XML_TAG_NAME, DOMRegionContext.XML_COMMENT_TEXT, DOMRegionContext.XML_CDATA_TEXT, DOMRegionContext.XML_PI_OPEN, DOMRegionContext.XML_PI_CONTENT}, new JavaPairMatcher(BRACKETS)); - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/text/IJavaPartitions.java b/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/text/IJavaPartitions.java deleted file mode 100644 index b9d8561a47..0000000000 --- a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/text/IJavaPartitions.java +++ /dev/null @@ -1,54 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.html.ui.internal.text; - -// taken from package org.eclipse.jdt.ui.text; - -/** - * Definition of Java partitioning and its partitions. - * - * @see Eclipse 3.1 - */ -interface IJavaPartitions { - - /** - * The identifier of the Java partitioning. - */ - String JAVA_PARTITIONING = "___java_partitioning"; //$NON-NLS-1$ - - /** - * The identifier of the single-line (JLS2: EndOfLineComment) end comment - * partition content type. - */ - String JAVA_SINGLE_LINE_COMMENT = "__java_singleline_comment"; //$NON-NLS-1$ - - /** - * The identifier multi-line (JLS2: TraditionalComment) comment partition - * content type. - */ - String JAVA_MULTI_LINE_COMMENT = "__java_multiline_comment"; //$NON-NLS-1$ - - /** - * The identifier of the Javadoc (JLS2: DocumentationComment) partition - * content type. - */ - String JAVA_DOC = "__java_javadoc"; //$NON-NLS-1$ - - /** - * The identifier of the Java string partition content type. - */ - String JAVA_STRING = "__java_string"; //$NON-NLS-1$ - - /** - * The identifier of the Java character partition content type. - */ - String JAVA_CHARACTER = "__java_character"; //$NON-NLS-1$ -} diff --git a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/text/JavaCodeReader.java b/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/text/JavaCodeReader.java deleted file mode 100644 index e3cace3005..0000000000 --- a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/text/JavaCodeReader.java +++ /dev/null @@ -1,244 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - * - *******************************************************************************/ -package org.eclipse.wst.html.ui.internal.text; - -// taken from package org.eclipse.jdt.ui.text; - -import java.io.IOException; - -import org.eclipse.jface.text.BadLocationException; -import org.eclipse.jface.text.IDocument; -import org.eclipse.wst.html.ui.internal.derived.SingleCharReader; - -/** - * Reads from a document either forwards or backwards. May be configured to - * skip comments and strings. - */ -class JavaCodeReader extends SingleCharReader { - - /** The EOF character */ - public static final int EOF = -1; - - private boolean fSkipComments = false; - private boolean fSkipStrings = false; - private boolean fForward = false; - - private IDocument fDocument; - private int fOffset; - - private int fEnd = -1; - private int fCachedLineNumber = -1; - private int fCachedLineOffset = -1; - - - public JavaCodeReader() { - } - - /** - * Returns the offset of the last read character. Should only be called - * after read has been called. - */ - public int getOffset() { - return fForward ? fOffset - 1 : fOffset; - } - - public void configureForwardReader(IDocument document, int offset, int length, boolean skipComments, boolean skipStrings) throws IOException { - fDocument = document; - fOffset = offset; - fSkipComments = skipComments; - fSkipStrings = skipStrings; - - fForward = true; - fEnd = Math.min(fDocument.getLength(), fOffset + length); - } - - public void configureBackwardReader(IDocument document, int offset, boolean skipComments, boolean skipStrings) throws IOException { - fDocument = document; - fOffset = offset; - fSkipComments = skipComments; - fSkipStrings = skipStrings; - - fForward = false; - try { - fCachedLineNumber = fDocument.getLineOfOffset(fOffset); - } - catch (BadLocationException x) { - throw new IOException(x.getMessage()); - } - } - - /* - * @see Reader#close() - */ - public void close() throws IOException { - fDocument = null; - } - - /* - * @see SingleCharReader#read() - */ - public int read() throws IOException { - try { - return fForward ? readForwards() : readBackwards(); - } - catch (BadLocationException x) { - throw new IOException(x.getMessage()); - } - } - - private void gotoCommentEnd() throws BadLocationException { - while (fOffset < fEnd) { - char current = fDocument.getChar(fOffset++); - if (current == '*') { - if (fOffset < fEnd && fDocument.getChar(fOffset) == '/') { - ++fOffset; - return; - } - } - } - } - - private void gotoStringEnd(char delimiter) throws BadLocationException { - while (fOffset < fEnd) { - char current = fDocument.getChar(fOffset++); - if (current == '\\') { - // ignore escaped characters - ++fOffset; - } - else if (current == delimiter) { - return; - } - } - } - - private void gotoLineEnd() throws BadLocationException { - int line = fDocument.getLineOfOffset(fOffset); - fOffset = fDocument.getLineOffset(line + 1); - } - - private int readForwards() throws BadLocationException { - while (fOffset < fEnd) { - char current = fDocument.getChar(fOffset++); - - switch (current) { - case '/' : - - if (fSkipComments && fOffset < fEnd) { - char next = fDocument.getChar(fOffset); - if (next == '*') { - // a comment starts, advance to the comment end - ++fOffset; - gotoCommentEnd(); - continue; - } - else if (next == '/') { - // '//'-comment starts, advance to the line end - gotoLineEnd(); - continue; - } - } - - return current; - - case '"' : - case '\'' : - - if (fSkipStrings) { - gotoStringEnd(current); - continue; - } - - return current; - } - - return current; - } - - return EOF; - } - - private void handleSingleLineComment() throws BadLocationException { - int line = fDocument.getLineOfOffset(fOffset); - if (line < fCachedLineNumber) { - fCachedLineNumber = line; - fCachedLineOffset = fDocument.getLineOffset(line); - int offset = fOffset; - while (fCachedLineOffset < offset) { - char current = fDocument.getChar(offset--); - if (current == '/' && fCachedLineOffset <= offset && fDocument.getChar(offset) == '/') { - fOffset = offset; - return; - } - } - } - } - - private void gotoCommentStart() throws BadLocationException { - while (0 < fOffset) { - char current = fDocument.getChar(fOffset--); - if (current == '*' && 0 <= fOffset && fDocument.getChar(fOffset) == '/') - return; - } - } - - private void gotoStringStart(char delimiter) throws BadLocationException { - while (0 < fOffset) { - char current = fDocument.getChar(fOffset); - if (current == delimiter) { - if (!(0 <= fOffset && fDocument.getChar(fOffset - 1) == '\\')) - return; - } - --fOffset; - } - } - - private int readBackwards() throws BadLocationException { - - while (0 < fOffset) { - --fOffset; - - handleSingleLineComment(); - - char current = fDocument.getChar(fOffset); - switch (current) { - case '/' : - - if (fSkipComments && fOffset > 1) { - char next = fDocument.getChar(fOffset - 1); - if (next == '*') { - // a comment ends, advance to the comment start - fOffset -= 2; - gotoCommentStart(); - continue; - } - } - - return current; - - case '"' : - case '\'' : - - if (fSkipStrings) { - --fOffset; - gotoStringStart(current); - continue; - } - - return current; - } - - return current; - } - - return EOF; - } -} diff --git a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/text/JavaHeuristicScanner.java b/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/text/JavaHeuristicScanner.java deleted file mode 100644 index 01602a291e..0000000000 --- a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/text/JavaHeuristicScanner.java +++ /dev/null @@ -1,986 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.html.ui.internal.text; - -// taken from package org.eclipse.jdt.internal.ui.text; - -import java.util.Arrays; - -import org.eclipse.jface.text.Assert; -import org.eclipse.jface.text.BadLocationException; -import org.eclipse.jface.text.IDocument; -import org.eclipse.jface.text.IRegion; -import org.eclipse.jface.text.ITypedRegion; -import org.eclipse.jface.text.Region; -import org.eclipse.jface.text.TextUtilities; -import org.eclipse.jface.text.TypedRegion; - -/** - * Utility methods for heuristic based Java manipulations in an incomplete - * Java source file. - * - * <p> - * An instance holds some internal position in the document and is therefore - * not threadsafe. - * </p> - * - * @see Eclipse 3.0 - */ -final class JavaHeuristicScanner implements Symbols { - /** - * Returned by all methods when the requested position could not be found, - * or if a {@link BadLocationException} was thrown while scanning. - */ - public static final int NOT_FOUND = -1; - - /** - * Special bound parameter that means either -1 (backward scanning) or - * <code>fDocument.getLength()</code> (forward scanning). - */ - public static final int UNBOUND = -2; - - - /* character constants */ - private static final char LBRACE = '{'; - private static final char RBRACE = '}'; - private static final char LPAREN = '('; - private static final char RPAREN = ')'; - private static final char SEMICOLON = ';'; - private static final char COLON = ':'; - private static final char COMMA = ','; - private static final char LBRACKET = '['; - private static final char RBRACKET = ']'; - private static final char QUESTIONMARK = '?'; - private static final char EQUAL = '='; - private static final char LANGLE = '<'; - private static final char RANGLE = '>'; - - /** - * Specifies the stop condition, upon which the <code>scanXXX</code> - * methods will decide whether to keep scanning or not. This interface may - * implemented by clients. - */ - private static abstract class StopCondition { - /** - * Instructs the scanner to return the current position. - * - * @param ch - * the char at the current position - * @param position - * the current position - * @param forward - * the iteration direction - * @return <code>true</code> if the stop condition is met. - */ - public abstract boolean stop(char ch, int position, boolean forward); - - /** - * Asks the condition to return the next position to query. The - * default is to return the next/previous position. - * - * @return the next position to scan - */ - public int nextPosition(int position, boolean forward) { - return forward ? position + 1 : position - 1; - } - } - - /** - * Stops upon a non-whitespace (as defined by - * {@link Character#isWhitespace(char)}) character. - */ - private static class NonWhitespace extends StopCondition { - /* - * @see org.eclipse.jdt.internal.ui.text.JavaHeuristicScanner.StopCondition#stop(char) - */ - public boolean stop(char ch, int position, boolean forward) { - return !Character.isWhitespace(ch); - } - } - - /** - * Stops upon a non-whitespace character in the default partition. - * - * @see NonWhitespace - */ - private final class NonWhitespaceDefaultPartition extends NonWhitespace { - /* - * @see org.eclipse.jdt.internal.ui.text.JavaHeuristicScanner.StopCondition#stop(char) - */ - public boolean stop(char ch, int position, boolean forward) { - return super.stop(ch, position, true) && isDefaultPartition(position); - } - - /* - * @see org.eclipse.jdt.internal.ui.text.JavaHeuristicScanner.StopCondition#nextPosition(int, - * boolean) - */ - public int nextPosition(int position, boolean forward) { - ITypedRegion partition = getPartition(position); - if (fPartition.equals(partition.getType())) - return super.nextPosition(position, forward); - - if (forward) { - int end = partition.getOffset() + partition.getLength(); - if (position < end) - return end; - } - else { - int offset = partition.getOffset(); - if (position > offset) - return offset - 1; - } - return super.nextPosition(position, forward); - } - } - - /** - * Stops upon a non-java identifier (as defined by - * {@link Character#isJavaIdentifierPart(char)}) character. - */ - private static class NonJavaIdentifierPart extends StopCondition { - /* - * @see org.eclipse.jdt.internal.ui.text.JavaHeuristicScanner.StopCondition#stop(char) - */ - public boolean stop(char ch, int position, boolean forward) { - return !Character.isJavaIdentifierPart(ch); - } - } - - /** - * Stops upon a non-java identifier character in the default partition. - * - * @see NonJavaIdentifierPart - */ - private final class NonJavaIdentifierPartDefaultPartition extends NonJavaIdentifierPart { - /* - * @see org.eclipse.jdt.internal.ui.text.JavaHeuristicScanner.StopCondition#stop(char) - */ - public boolean stop(char ch, int position, boolean forward) { - return super.stop(ch, position, true) || !isDefaultPartition(position); - } - - /* - * @see org.eclipse.jdt.internal.ui.text.JavaHeuristicScanner.StopCondition#nextPosition(int, - * boolean) - */ - public int nextPosition(int position, boolean forward) { - ITypedRegion partition = getPartition(position); - if (fPartition.equals(partition.getType())) - return super.nextPosition(position, forward); - - if (forward) { - int end = partition.getOffset() + partition.getLength(); - if (position < end) - return end; - } - else { - int offset = partition.getOffset(); - if (position > offset) - return offset - 1; - } - return super.nextPosition(position, forward); - } - } - - /** - * Stops upon a character in the default partition that matches the given - * character list. - */ - private final class CharacterMatch extends StopCondition { - private final char[] fChars; - - /** - * Creates a new instance. - * - * @param ch - * the single character to match - */ - public CharacterMatch(char ch) { - this(new char[]{ch}); - } - - /** - * Creates a new instance. - * - * @param chars - * the chars to match. - */ - public CharacterMatch(char[] chars) { - Assert.isNotNull(chars); - Assert.isTrue(chars.length > 0); - fChars = chars; - Arrays.sort(chars); - } - - /* - * @see org.eclipse.jdt.internal.ui.text.JavaHeuristicScanner.StopCondition#stop(char, - * int) - */ - public boolean stop(char ch, int position, boolean forward) { - return Arrays.binarySearch(fChars, ch) >= 0 && isDefaultPartition(position); - } - - /* - * @see org.eclipse.jdt.internal.ui.text.JavaHeuristicScanner.StopCondition#nextPosition(int, - * boolean) - */ - public int nextPosition(int position, boolean forward) { - ITypedRegion partition = getPartition(position); - if (fPartition.equals(partition.getType())) - return super.nextPosition(position, forward); - - if (forward) { - int end = partition.getOffset() + partition.getLength(); - if (position < end) - return end; - } - else { - int offset = partition.getOffset(); - if (position > offset) - return offset - 1; - } - return super.nextPosition(position, forward); - } - } - - /** The document being scanned. */ - private IDocument fDocument; - /** The partitioning being used for scanning. */ - private String fPartitioning; - /** The partition to scan in. */ - private String fPartition; - - /* internal scan state */ - - /** the most recently read character. */ - private char fChar; - /** the most recently read position. */ - private int fPos; - - /* preset stop conditions */ - private final StopCondition fNonWSDefaultPart = new NonWhitespaceDefaultPartition(); - private final static StopCondition fNonWS = new NonWhitespace(); - private final StopCondition fNonIdent = new NonJavaIdentifierPartDefaultPartition(); - - /** - * Creates a new instance. - * - * @param document - * the document to scan - * @param partitioning - * the partitioning to use for scanning - * @param partition - * the partition to scan in - */ - public JavaHeuristicScanner(IDocument document, String partitioning, String partition) { - Assert.isNotNull(document); - Assert.isNotNull(partitioning); - Assert.isNotNull(partition); - fDocument = document; - fPartitioning = partitioning; - fPartition = partition; - } - - /** - * Calls - * <code>this(document, IJavaPartitions.JAVA_PARTITIONING, IDocument.DEFAULT_CONTENT_TYPE)</code>. - * - * @param document - * the document to scan. - */ - public JavaHeuristicScanner(IDocument document) { - this(document, IJavaPartitions.JAVA_PARTITIONING, IDocument.DEFAULT_CONTENT_TYPE); - } - - /** - * Returns the most recent internal scan position. - * - * @return the most recent internal scan position. - */ - public int getPosition() { - return fPos; - } - - /** - * Returns the next token in forward direction, starting at - * <code>start</code>, and not extending further than - * <code>bound</code>. The return value is one of the constants defined - * in {@link Symbols}. After a call, {@link #getPosition()} will return - * the position just after the scanned token (i.e. the next position that - * will be scanned). - * - * @param start - * the first character position in the document to consider - * @param bound - * the first position not to consider any more - * @return a constant from {@link Symbols} describing the next token - */ - public int nextToken(int start, int bound) { - int pos = scanForward(start, bound, fNonWSDefaultPart); - if (pos == NOT_FOUND) - return TokenEOF; - - fPos++; - - switch (fChar) { - case LBRACE : - return TokenLBRACE; - case RBRACE : - return TokenRBRACE; - case LBRACKET : - return TokenLBRACKET; - case RBRACKET : - return TokenRBRACKET; - case LPAREN : - return TokenLPAREN; - case RPAREN : - return TokenRPAREN; - case SEMICOLON : - return TokenSEMICOLON; - case COMMA : - return TokenCOMMA; - case QUESTIONMARK : - return TokenQUESTIONMARK; - case EQUAL : - return TokenEQUAL; - case LANGLE : - return TokenLESSTHAN; - case RANGLE : - return TokenGREATERTHAN; - } - - // else - if (Character.isJavaIdentifierPart(fChar)) { - // assume an ident or keyword - int from = pos, to; - pos = scanForward(pos + 1, bound, fNonIdent); - if (pos == NOT_FOUND) - to = bound == UNBOUND ? fDocument.getLength() : bound; - else - to = pos; - - String identOrKeyword; - try { - identOrKeyword = fDocument.get(from, to - from); - } - catch (BadLocationException e) { - return TokenEOF; - } - - return getToken(identOrKeyword); - - - } - else { - // operators, number literals etc - return TokenOTHER; - } - } - - /** - * Returns the next token in backward direction, starting at - * <code>start</code>, and not extending further than - * <code>bound</code>. The return value is one of the constants defined - * in {@link Symbols}. After a call, {@link #getPosition()} will return - * the position just before the scanned token starts (i.e. the next - * position that will be scanned). - * - * @param start - * the first character position in the document to consider - * @param bound - * the first position not to consider any more - * @return a constant from {@link Symbols} describing the previous token - */ - public int previousToken(int start, int bound) { - int pos = scanBackward(start, bound, fNonWSDefaultPart); - if (pos == NOT_FOUND) - return TokenEOF; - - fPos--; - - switch (fChar) { - case LBRACE : - return TokenLBRACE; - case RBRACE : - return TokenRBRACE; - case LBRACKET : - return TokenLBRACKET; - case RBRACKET : - return TokenRBRACKET; - case LPAREN : - return TokenLPAREN; - case RPAREN : - return TokenRPAREN; - case SEMICOLON : - return TokenSEMICOLON; - case COLON : - return TokenCOLON; - case COMMA : - return TokenCOMMA; - case QUESTIONMARK : - return TokenQUESTIONMARK; - case EQUAL : - return TokenEQUAL; - case LANGLE : - return TokenLESSTHAN; - case RANGLE : - return TokenGREATERTHAN; - } - - // else - if (Character.isJavaIdentifierPart(fChar)) { - // assume an ident or keyword - int from, to = pos + 1; - pos = scanBackward(pos - 1, bound, fNonIdent); - if (pos == NOT_FOUND) - from = bound == UNBOUND ? 0 : bound + 1; - else - from = pos + 1; - - String identOrKeyword; - try { - identOrKeyword = fDocument.get(from, to - from); - } - catch (BadLocationException e) { - return TokenEOF; - } - - return getToken(identOrKeyword); - - - } - else { - // operators, number literals etc - return TokenOTHER; - } - - } - - /** - * Returns one of the keyword constants or <code>TokenIDENT</code> for a - * scanned identifier. - * - * @param s - * a scanned identifier - * @return one of the constants defined in {@link Symbols} - */ - private int getToken(String s) { - Assert.isNotNull(s); - - switch (s.length()) { - case 2 : - if ("if".equals(s)) //$NON-NLS-1$ - return TokenIF; - if ("do".equals(s)) //$NON-NLS-1$ - return TokenDO; - break; - case 3 : - if ("for".equals(s)) //$NON-NLS-1$ - return TokenFOR; - if ("try".equals(s)) //$NON-NLS-1$ - return TokenTRY; - if ("new".equals(s)) //$NON-NLS-1$ - return TokenNEW; - break; - case 4 : - if ("case".equals(s)) //$NON-NLS-1$ - return TokenCASE; - if ("else".equals(s)) //$NON-NLS-1$ - return TokenELSE; - if ("enum".equals(s)) //$NON-NLS-1$ - return TokenENUM; - if ("goto".equals(s)) //$NON-NLS-1$ - return TokenGOTO; - break; - case 5 : - if ("break".equals(s)) //$NON-NLS-1$ - return TokenBREAK; - if ("catch".equals(s)) //$NON-NLS-1$ - return TokenCATCH; - if ("class".equals(s)) //$NON-NLS-1$ - return TokenCLASS; - if ("while".equals(s)) //$NON-NLS-1$ - return TokenWHILE; - break; - case 6 : - if ("return".equals(s)) //$NON-NLS-1$ - return TokenRETURN; - if ("static".equals(s)) //$NON-NLS-1$ - return TokenSTATIC; - if ("switch".equals(s)) //$NON-NLS-1$ - return TokenSWITCH; - break; - case 7 : - if ("default".equals(s)) //$NON-NLS-1$ - return TokenDEFAULT; - if ("finally".equals(s)) //$NON-NLS-1$ - return TokenFINALLY; - break; - case 9 : - if ("interface".equals(s)) //$NON-NLS-1$ - return TokenINTERFACE; - break; - case 12 : - if ("synchronized".equals(s)) //$NON-NLS-1$ - return TokenSYNCHRONIZED; - break; - } - return TokenIDENT; - } - - /** - * Returns the position of the closing peer character (forward search). - * Any scopes introduced by opening peers are skipped. All peers accounted - * for must reside in the default partition. - * - * <p> - * Note that <code>start</code> must not point to the opening peer, but - * to the first character being searched. - * </p> - * - * @param start - * the start position - * @param openingPeer - * the opening peer character (e.g. '{') - * @param closingPeer - * the closing peer character (e.g. '}') - * @return the matching peer character position, or <code>NOT_FOUND</code> - */ - public int findClosingPeer(int start, final char openingPeer, final char closingPeer) { - Assert.isNotNull(fDocument); - Assert.isTrue(start >= 0); - - try { - int depth = 1; - start -= 1; - while (true) { - start = scanForward(start + 1, UNBOUND, new CharacterMatch(new char[]{openingPeer, closingPeer})); - if (start == NOT_FOUND) - return NOT_FOUND; - - if (fDocument.getChar(start) == openingPeer) - depth++; - else - depth--; - - if (depth == 0) - return start; - } - - } - catch (BadLocationException e) { - return NOT_FOUND; - } - } - - /** - * Returns the position of the opening peer character (backward search). - * Any scopes introduced by closing peers are skipped. All peers accounted - * for must reside in the default partition. - * - * <p> - * Note that <code>start</code> must not point to the closing peer, but - * to the first character being searched. - * </p> - * - * @param start - * the start position - * @param openingPeer - * the opening peer character (e.g. '{') - * @param closingPeer - * the closing peer character (e.g. '}') - * @return the matching peer character position, or <code>NOT_FOUND</code> - */ - public int findOpeningPeer(int start, char openingPeer, char closingPeer) { - Assert.isTrue(start < fDocument.getLength()); - - try { - int depth = 1; - start += 1; - while (true) { - start = scanBackward(start - 1, UNBOUND, new CharacterMatch(new char[]{openingPeer, closingPeer})); - if (start == NOT_FOUND) - return NOT_FOUND; - - if (fDocument.getChar(start) == closingPeer) - depth++; - else - depth--; - - if (depth == 0) - return start; - } - - } - catch (BadLocationException e) { - return NOT_FOUND; - } - } - - /** - * Computes the surrounding block around <code>offset</code>. The - * search is started at the beginning of <code>offset</code>, i.e. an - * opening brace at <code>offset</code> will not be part of the - * surrounding block, but a closing brace will. - * - * @param offset - * the offset for which the surrounding block is computed - * @return a region describing the surrounding block, or <code>null</code> - * if none can be found - */ - public IRegion findSurroundingBlock(int offset) { - if (offset < 1 || offset >= fDocument.getLength()) - return null; - - int begin = findOpeningPeer(offset - 1, LBRACE, RBRACE); - int end = findClosingPeer(offset, LBRACE, RBRACE); - if (begin == NOT_FOUND || end == NOT_FOUND) - return null; - return new Region(begin, end + 1 - begin); - } - - /** - * Finds the smallest position in <code>fDocument</code> such that the - * position is >= <code>position</code> and < <code>bound</code> - * and <code>Character.isWhitespace(fDocument.getChar(pos))</code> - * evaluates to <code>false</code> and the position is in the default - * partition. - * - * @param position - * the first character position in <code>fDocument</code> to - * be considered - * @param bound - * the first position in <code>fDocument</code> to not - * consider any more, with <code>bound</code> > - * <code>position</code>, or <code>UNBOUND</code> - * @return the smallest position of a non-whitespace character in [<code>position</code>, - * <code>bound</code>) that resides in a Java partition, or - * <code>NOT_FOUND</code> if none can be found - */ - public int findNonWhitespaceForward(int position, int bound) { - return scanForward(position, bound, fNonWSDefaultPart); - } - - /** - * Finds the smallest position in <code>fDocument</code> such that the - * position is >= <code>position</code> and < <code>bound</code> - * and <code>Character.isWhitespace(fDocument.getChar(pos))</code> - * evaluates to <code>false</code>. - * - * @param position - * the first character position in <code>fDocument</code> to - * be considered - * @param bound - * the first position in <code>fDocument</code> to not - * consider any more, with <code>bound</code> > - * <code>position</code>, or <code>UNBOUND</code> - * @return the smallest position of a non-whitespace character in [<code>position</code>, - * <code>bound</code>), or <code>NOT_FOUND</code> if none can - * be found - */ - public int findNonWhitespaceForwardInAnyPartition(int position, int bound) { - return scanForward(position, bound, fNonWS); - } - - /** - * Finds the highest position in <code>fDocument</code> such that the - * position is <= <code>position</code> and > <code>bound</code> - * and <code>Character.isWhitespace(fDocument.getChar(pos))</code> - * evaluates to <code>false</code> and the position is in the default - * partition. - * - * @param position - * the first character position in <code>fDocument</code> to - * be considered - * @param bound - * the first position in <code>fDocument</code> to not - * consider any more, with <code>bound</code> < - * <code>position</code>, or <code>UNBOUND</code> - * @return the highest position of a non-whitespace character in (<code>bound</code>, - * <code>position</code>] that resides in a Java partition, or - * <code>NOT_FOUND</code> if none can be found - */ - public int findNonWhitespaceBackward(int position, int bound) { - return scanBackward(position, bound, fNonWSDefaultPart); - } - - /** - * Finds the lowest position <code>p</code> in <code>fDocument</code> - * such that <code>start</code> <= p < <code>bound</code> and - * <code>condition.stop(fDocument.getChar(p), p)</code> evaluates to - * <code>true</code>. - * - * @param start - * the first character position in <code>fDocument</code> to - * be considered - * @param bound - * the first position in <code>fDocument</code> to not - * consider any more, with <code>bound</code> > - * <code>start</code>, or <code>UNBOUND</code> - * @param condition - * the <code>StopCondition</code> to check - * @return the lowest position in [<code>start</code>, - * <code>bound</code>) for which <code>condition</code> - * holds, or <code>NOT_FOUND</code> if none can be found - */ - public int scanForward(int start, int bound, StopCondition condition) { - Assert.isTrue(start >= 0); - - if (bound == UNBOUND) - bound = fDocument.getLength(); - - Assert.isTrue(bound <= fDocument.getLength()); - - try { - fPos = start; - while (fPos < bound) { - - fChar = fDocument.getChar(fPos); - if (condition.stop(fChar, fPos, true)) - return fPos; - - fPos = condition.nextPosition(fPos, true); - } - } - catch (BadLocationException e) { - } - return NOT_FOUND; - } - - - /** - * Finds the lowest position in <code>fDocument</code> such that the - * position is >= <code>position</code> and < <code>bound</code> - * and <code>fDocument.getChar(position) == ch</code> evaluates to - * <code>true</code> and the position is in the default partition. - * - * @param position - * the first character position in <code>fDocument</code> to - * be considered - * @param bound - * the first position in <code>fDocument</code> to not - * consider any more, with <code>bound</code> > - * <code>position</code>, or <code>UNBOUND</code> - * @param ch - * the <code>char</code> to search for - * @return the lowest position of <code>ch</code> in (<code>bound</code>, - * <code>position</code>] that resides in a Java partition, or - * <code>NOT_FOUND</code> if none can be found - */ - public int scanForward(int position, int bound, char ch) { - return scanForward(position, bound, new CharacterMatch(ch)); - } - - /** - * Finds the lowest position in <code>fDocument</code> such that the - * position is >= <code>position</code> and < <code>bound</code> - * and <code>fDocument.getChar(position) == ch</code> evaluates to - * <code>true</code> for at least one ch in <code>chars</code> and the - * position is in the default partition. - * - * @param position - * the first character position in <code>fDocument</code> to - * be considered - * @param bound - * the first position in <code>fDocument</code> to not - * consider any more, with <code>bound</code> > - * <code>position</code>, or <code>UNBOUND</code> - * @param chars - * an array of <code>char</code> to search for - * @return the lowest position of a non-whitespace character in [<code>position</code>, - * <code>bound</code>) that resides in a Java partition, or - * <code>NOT_FOUND</code> if none can be found - */ - public int scanForward(int position, int bound, char[] chars) { - return scanForward(position, bound, new CharacterMatch(chars)); - } - - /** - * Finds the highest position <code>p</code> in <code>fDocument</code> - * such that <code>bound</code> < <code>p</code> <= - * <code>start</code> and - * <code>condition.stop(fDocument.getChar(p), p)</code> evaluates to - * <code>true</code>. - * - * @param start - * the first character position in <code>fDocument</code> to - * be considered - * @param bound - * the first position in <code>fDocument</code> to not - * consider any more, with <code>bound</code> < - * <code>start</code>, or <code>UNBOUND</code> - * @param condition - * the <code>StopCondition</code> to check - * @return the highest position in (<code>bound</code>, - * <code>start</code> for which <code>condition</code> holds, - * or <code>NOT_FOUND</code> if none can be found - */ - public int scanBackward(int start, int bound, StopCondition condition) { - if (bound == UNBOUND) - bound = -1; - - Assert.isTrue(bound >= -1); - Assert.isTrue(start < fDocument.getLength()); - - try { - fPos = start; - while (fPos > bound) { - - fChar = fDocument.getChar(fPos); - if (condition.stop(fChar, fPos, false)) - return fPos; - - fPos = condition.nextPosition(fPos, false); - } - } - catch (BadLocationException e) { - } - return NOT_FOUND; - } - - /** - * Finds the highest position in <code>fDocument</code> such that the - * position is <= <code>position</code> and > <code>bound</code> - * and <code>fDocument.getChar(position) == ch</code> evaluates to - * <code>true</code> for at least one ch in <code>chars</code> and the - * position is in the default partition. - * - * @param position - * the first character position in <code>fDocument</code> to - * be considered - * @param bound - * the first position in <code>fDocument</code> to not - * consider any more, with <code>bound</code> < - * <code>position</code>, or <code>UNBOUND</code> - * @param ch - * the <code>char</code> to search for - * @return the highest position of one element in <code>chars</code> in (<code>bound</code>, - * <code>position</code>] that resides in a Java partition, or - * <code>NOT_FOUND</code> if none can be found - */ - public int scanBackward(int position, int bound, char ch) { - return scanBackward(position, bound, new CharacterMatch(ch)); - } - - /** - * Finds the highest position in <code>fDocument</code> such that the - * position is <= <code>position</code> and > <code>bound</code> - * and <code>fDocument.getChar(position) == ch</code> evaluates to - * <code>true</code> for at least one ch in <code>chars</code> and the - * position is in the default partition. - * - * @param position - * the first character position in <code>fDocument</code> to - * be considered - * @param bound - * the first position in <code>fDocument</code> to not - * consider any more, with <code>bound</code> < - * <code>position</code>, or <code>UNBOUND</code> - * @param chars - * an array of <code>char</code> to search for - * @return the highest position of one element in <code>chars</code> in (<code>bound</code>, - * <code>position</code>] that resides in a Java partition, or - * <code>NOT_FOUND</code> if none can be found - */ - public int scanBackward(int position, int bound, char[] chars) { - return scanBackward(position, bound, new CharacterMatch(chars)); - } - - /** - * Checks whether <code>position</code> resides in a default (Java) - * partition of <code>fDocument</code>. - * - * @param position - * the position to be checked - * @return <code>true</code> if <code>position</code> is in the - * default partition of <code>fDocument</code>, - * <code>false</code> otherwise - */ - public boolean isDefaultPartition(int position) { - Assert.isTrue(position >= 0); - Assert.isTrue(position <= fDocument.getLength()); - - try { - return fPartition.equals(TextUtilities.getContentType(fDocument, fPartitioning, position, false)); - } - catch (BadLocationException e) { - return false; - } - } - - /** - * Returns the partition at <code>position</code>. - * - * @param position - * the position to get the partition for - * @return the partition at <code>position</code> or a dummy zero-length - * partition if accessing the document fails - */ - private ITypedRegion getPartition(int position) { - Assert.isTrue(position >= 0); - Assert.isTrue(position <= fDocument.getLength()); - - try { - return TextUtilities.getPartition(fDocument, fPartitioning, position, false); - } - catch (BadLocationException e) { - return new TypedRegion(position, 0, "__no_partition_at_all"); //$NON-NLS-1$ - } - - } - - /** - * Checks if the line seems to be an open condition not followed by a - * block (i.e. an if, while, or for statement with just one following - * statement, see example below). - * - * <pre> - * if (condition) - * doStuff(); - * </pre> - * - * <p> - * Algorithm: if the last non-WS, non-Comment code on the line is an if - * (condition), while (condition), for( expression), do, else, and there - * is no statement after that - * </p> - * - * @param position - * the insert position of the new character - * @param bound - * the lowest position to consider - * @return <code>true</code> if the code is a conditional statement or - * loop without a block, <code>false</code> otherwise - */ - public boolean isBracelessBlockStart(int position, int bound) { - if (position < 1) - return false; - - switch (previousToken(position, bound)) { - case TokenDO : - case TokenELSE : - return true; - case TokenRPAREN : - position = findOpeningPeer(fPos, LPAREN, RPAREN); - if (position > 0) { - switch (previousToken(position - 1, bound)) { - case TokenIF : - case TokenFOR : - case TokenWHILE : - return true; - } - } - } - - return false; - } -} diff --git a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/text/JavaPairMatcher.java b/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/text/JavaPairMatcher.java deleted file mode 100644 index 020769fb6b..0000000000 --- a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/text/JavaPairMatcher.java +++ /dev/null @@ -1,277 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - * - *******************************************************************************/ -package org.eclipse.wst.html.ui.internal.text; - -// taken from package org.eclipse.jdt.ui.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; - -class JavaPairMatcher implements ICharacterPairMatcher { - - protected char[] fPairs; - protected IDocument fDocument; - protected int fOffset; - - protected int fStartPos; - protected int fEndPos; - protected int fAnchor; - - protected JavaCodeReader fReader = new JavaCodeReader(); - /** - * Stores the source version state. - * - * @see Eclipse 3.1 - */ - private boolean fHighlightAngularBrackets = false; - - - public JavaPairMatcher(char[] pairs) { - fPairs = pairs; - } - - /* - * (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(offset < 0 || offset >= document.getLength()) - return null; - - fDocument = document; - - if (fDocument != null && matchPairsAt() && fStartPos != fEndPos) - return new Region(fStartPos, fEndPos - fStartPos + 1); - - return 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#dispose() - */ - public void dispose() { - clear(); - fDocument = null; - fReader = null; - } - - /* - * @see org.eclipse.jface.text.source.ICharacterPairMatcher#clear() - */ - public void clear() { - if (fReader != null) { - try { - fReader.close(); - } - catch (IOException x) { - // ignore - } - } - } - - protected boolean matchPairsAt() { - - int i; - int pairIndex1 = fPairs.length; - int pairIndex2 = fPairs.length; - - fStartPos = -1; - fEndPos = -1; - - // get the chars preceding and following the start position - try { - - char prevChar = fDocument.getChar(Math.max(fOffset - 1, 0)); - // modified behavior for - // http://dev.eclipse.org/bugs/show_bug.cgi?id=16879 - // char nextChar= fDocument.getChar(fOffset); - - // search for opening peer character next to the activation point - for (i = 0; i < fPairs.length; i = i + 2) { - // if (nextChar == fPairs[i]) { - // fStartPos= fOffset; - // pairIndex1= i; - // } else - if (prevChar == fPairs[i]) { - fStartPos = fOffset - 1; - pairIndex1 = i; - } - } - - // search for closing peer character next to the activation point - for (i = 1; i < fPairs.length; i = i + 2) { - if (prevChar == fPairs[i]) { - fEndPos = fOffset - 1; - pairIndex2 = i; - } - // else if (nextChar == fPairs[i]) { - // fEndPos= fOffset; - // pairIndex2= i; - // } - } - - if (fEndPos > -1) { - fAnchor = RIGHT; - fStartPos = searchForOpeningPeer(fEndPos, fPairs[pairIndex2 - 1], fPairs[pairIndex2], fDocument); - if (fStartPos > -1) - return true; - else - fEndPos = -1; - } - else if (fStartPos > -1) { - fAnchor = LEFT; - fEndPos = searchForClosingPeer(fStartPos, fPairs[pairIndex1], fPairs[pairIndex1 + 1], fDocument); - if (fEndPos > -1) - return true; - else - fStartPos = -1; - } - - } - catch (BadLocationException x) { - } - catch (IOException x) { - } - - return false; - } - - protected int searchForClosingPeer(int offset, int openingPeer, int closingPeer, IDocument document) throws IOException { - if (openingPeer == '<' && !(fHighlightAngularBrackets && isTypeParameterBracket(offset, document))) - return -1; - - fReader.configureForwardReader(document, offset + 1, document.getLength(), true, true); - - int stack = 1; - int c = fReader.read(); - while (c != JavaCodeReader.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 { - if (openingPeer == '<' && !fHighlightAngularBrackets) - return -1; - - fReader.configureBackwardReader(document, offset, true, true); - - int stack = 1; - int c = fReader.read(); - while (c != JavaCodeReader.EOF) { - if (c == closingPeer && c != openingPeer) - stack++; - else if (c == openingPeer) - stack--; - - if (stack == 0) { - if (closingPeer == '>' && !isTypeParameterBracket(fReader.getOffset(), document)) - return -1; - return fReader.getOffset(); - } - - c = fReader.read(); - } - - return -1; - } - - /** - * Checks if the angular bracket at <code>offset</code> is a type - * parameter bracket. - * - * @param offset - * the offset of the opening bracket - * @param document - * the document - * @return <code>true</code> if the bracket is part of a type parameter, - * <code>false</code> otherwise - * @see Eclipse 3.1 - */ - private boolean isTypeParameterBracket(int offset, IDocument document) { - /* - * type parameter come after braces (closing or opening), semicolons, - * or after a Type name (heuristic: starts with capital character, or - * after a modifier keyword in a method declaration (visibility, - * static, synchronized, final) - */ - - try { - IRegion line = document.getLineInformationOfOffset(offset); - - JavaHeuristicScanner scanner = new JavaHeuristicScanner(document); - int prevToken = scanner.previousToken(offset - 1, line.getOffset()); - int prevTokenOffset = scanner.getPosition() + 1; - String previous = prevToken == Symbols.TokenEOF ? null : document.get(prevTokenOffset, offset - prevTokenOffset).trim(); - - if (prevToken == Symbols.TokenLBRACE || prevToken == Symbols.TokenRBRACE || prevToken == Symbols.TokenSEMICOLON || prevToken == Symbols.TokenSYNCHRONIZED || prevToken == Symbols.TokenSTATIC || (prevToken == Symbols.TokenIDENT && isTypeParameterIntroducer(previous)) || prevToken == Symbols.TokenEOF) - return true; - } - catch (BadLocationException e) { - return false; - } - - return false; - } - - /** - * Returns <code>true</code> if <code>identifier</code> is an - * identifier that could come right before a type parameter list. It uses - * a heuristic: if the identifier starts with an upper case, it is assumed - * a type name. Also, if <code>identifier</code> is a method modifier, - * it is assumed that the angular bracket is part of the generic type - * parameter of a method. - * - * @param identifier - * the identifier to check - * @return <code>true</code> if the identifier could introduce a type - * parameter list - * @see Eclipse 3.1 - */ - private boolean isTypeParameterIntroducer(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$ - } -} diff --git a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/text/Symbols.java b/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/text/Symbols.java deleted file mode 100644 index d88615ed60..0000000000 --- a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/text/Symbols.java +++ /dev/null @@ -1,57 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 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.html.ui.internal.text; - -// taken from package org.eclipse.jdt.ui.text; - -/** - * Symbols for the heuristic java scanner. - * - * @see Eclipse 3.0 - */ -interface Symbols { - int TokenEOF = -1; - int TokenLBRACE = 1; - int TokenRBRACE = 2; - int TokenLBRACKET = 3; - int TokenRBRACKET = 4; - int TokenLPAREN = 5; - int TokenRPAREN = 6; - int TokenSEMICOLON = 7; - int TokenOTHER = 8; - int TokenCOLON = 9; - int TokenQUESTIONMARK = 10; - int TokenCOMMA = 11; - int TokenEQUAL = 12; - int TokenLESSTHAN = 13; - int TokenGREATERTHAN = 14; - int TokenIF = 109; - int TokenDO = 1010; - int TokenFOR = 1011; - int TokenTRY = 1012; - int TokenCASE = 1013; - int TokenELSE = 1014; - int TokenBREAK = 1015; - int TokenCATCH = 1016; - int TokenWHILE = 1017; - int TokenRETURN = 1018; - int TokenSTATIC = 1019; - int TokenSWITCH = 1020; - int TokenFINALLY = 1021; - int TokenSYNCHRONIZED = 1022; - int TokenGOTO = 1023; - int TokenDEFAULT = 1024; - int TokenNEW = 1025; - int TokenCLASS = 1026; - int TokenINTERFACE = 1027; - int TokenENUM = 1028; - int TokenIDENT = 2000; -} diff --git a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/wizard/NewHTMLFileWizardPage.java b/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/wizard/NewHTMLFileWizardPage.java deleted file mode 100644 index e541788044..0000000000 --- a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/wizard/NewHTMLFileWizardPage.java +++ /dev/null @@ -1,251 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - * - *******************************************************************************/ -package org.eclipse.wst.html.ui.internal.wizard; - -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.resources.IWorkspace; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Platform; -import org.eclipse.core.runtime.Preferences; -import org.eclipse.core.runtime.content.IContentType; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.osgi.util.NLS; -import org.eclipse.ui.dialogs.WizardNewFileCreationPage; -import org.eclipse.wst.common.componentcore.ComponentCore; -import org.eclipse.wst.common.componentcore.internal.util.IModuleConstants; -import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; -import org.eclipse.wst.common.project.facet.core.IFacetedProject; -import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager; -import org.eclipse.wst.html.core.internal.HTMLCorePlugin; -import org.eclipse.wst.html.core.internal.preferences.HTMLCorePreferenceNames; -import org.eclipse.wst.html.core.internal.provisional.contenttype.ContentTypeIdForHTML; -import org.eclipse.wst.html.ui.internal.HTMLUIMessages; -import org.eclipse.wst.html.ui.internal.Logger; - -class NewHTMLFileWizardPage extends WizardNewFileCreationPage { - - private IContentType fContentType; - private List fValidExtensions = null; - - public NewHTMLFileWizardPage(String pageName, IStructuredSelection selection) { - super(pageName, selection); - } - - /** - * This method is overriden to set the selected folder to web contents - * folder if the current selection is outside the web contents folder. - */ - protected void initialPopulateContainerNameField() { - super.initialPopulateContainerNameField(); - - IPath fullPath = getContainerFullPath(); - IProject project = getProjectFromPath(fullPath); - IPath webContentPath = getWebContentPath(project); - - if (webContentPath != null && !webContentPath.isPrefixOf(fullPath)) { - setContainerFullPath(webContentPath); - } - } - - /** - * This method is overriden to set additional validation specific to - * html files. - */ - protected boolean validatePage() { - setMessage(null); - setErrorMessage(null); - - if (!super.validatePage()) { - return false; - } - - String fileName = getFileName(); - IPath fullPath = getContainerFullPath(); - if ((fullPath != null) && (fullPath.isEmpty() == false) && (fileName != null)) { - // check that filename does not contain invalid extension - if (!extensionValidForContentType(fileName)) { - setErrorMessage(NLS.bind(HTMLUIMessages._ERROR_FILENAME_MUST_END_HTML, getValidExtensions().toString())); - return false; - } - // no file extension specified so check adding default - // extension doesn't equal a file that already exists - if (fileName.lastIndexOf('.') == -1) { - String newFileName = addDefaultExtension(fileName); - IPath resourcePath = fullPath.append(newFileName); - - IWorkspace workspace = ResourcesPlugin.getWorkspace(); - IStatus result = workspace.validatePath(resourcePath.toString(), IResource.FOLDER); - if (!result.isOK()) { - // path invalid - setErrorMessage(result.getMessage()); - return false; - } - - if ((workspace.getRoot().getFolder(resourcePath).exists() || workspace.getRoot().getFile(resourcePath).exists())) { - setErrorMessage(HTMLUIMessages.ResourceGroup_nameExists); - return false; - } - } - - // get the IProject for the selection path - IProject project = getProjectFromPath(fullPath); - // if inside web project, check if inside webContent folder - if (project != null && isWebProject(project)) { - // check that the path is inside the webContent folder - IPath webContentPath = getWebContentPath(project); - if (!webContentPath.isPrefixOf(fullPath)) { - setMessage(HTMLUIMessages._WARNING_FOLDER_MUST_BE_INSIDE_WEB_CONTENT, WARNING); - } - } - } - - return true; - } - - /** - * Get content type associated with this new file wizard - * - * @return IContentType - */ - private IContentType getContentType() { - if (fContentType == null) - fContentType = Platform.getContentTypeManager().getContentType(ContentTypeIdForHTML.ContentTypeID_HTML); - return fContentType; - } - - /** - * Get list of valid extensions for HTML Content type - * - * @return - */ - private List getValidExtensions() { - if (fValidExtensions == null) { - IContentType type = getContentType(); - fValidExtensions = new ArrayList(Arrays.asList(type.getFileSpecs(IContentType.FILE_EXTENSION_SPEC))); - } - return fValidExtensions; - } - - /** - * Verifies if fileName is valid name for content type. Takes base content - * type into consideration. - * - * @param fileName - * @return true if extension is valid for this content type - */ - private boolean extensionValidForContentType(String fileName) { - boolean valid = false; - - IContentType type = getContentType(); - // there is currently an extension - if (fileName.lastIndexOf('.') != -1) { - // check what content types are associated with current extension - IContentType[] types = Platform.getContentTypeManager().findContentTypesFor(fileName); - int i = 0; - while (i < types.length && !valid) { - valid = types[i].isKindOf(type); - ++i; - } - } - else - valid = true; // no extension so valid - return valid; - } - - /** - * Adds default extension to the filename - * - * @param filename - * @return - */ - String addDefaultExtension(String filename) { - StringBuffer newFileName = new StringBuffer(filename); - - Preferences preference = HTMLCorePlugin.getDefault().getPluginPreferences(); - String ext = preference.getString(HTMLCorePreferenceNames.DEFAULT_EXTENSION); - - newFileName.append("."); //$NON-NLS-1$ - newFileName.append(ext); - - return newFileName.toString(); - } - - /** - * Returns the project that contains the specified path - * - * @param path the path which project is needed - * @return IProject object. If path is <code>null</code> the return value - * is also <code>null</code>. - */ - private IProject getProjectFromPath(IPath path) { - IWorkspace workspace = ResourcesPlugin.getWorkspace(); - IProject project = null; - - if (path != null) { - if (workspace.validatePath(path.toString(), IResource.PROJECT).isOK()) { - project = workspace.getRoot().getProject(path.toString()); - } else { - project = workspace.getRoot().getFile(path).getProject(); - } - } - - return project; - } - - /** - * Checks if the specified project is a web project. - * - * @param project project to be checked - * @return true if the project is web project, otherwise false - */ - private boolean isWebProject(IProject project) { - IFacetedProject faceted = null; - try { - faceted = ProjectFacetsManager.create(project); - } catch (CoreException e) { - Logger.log(Logger.WARNING_DEBUG, e.getMessage(), e); - } - - if (faceted != null && - (faceted.hasProjectFacet(ProjectFacetsManager.getProjectFacet(IModuleConstants.WST_WEB_MODULE)) || - faceted.hasProjectFacet(ProjectFacetsManager.getProjectFacet(IModuleConstants.JST_WEB_MODULE)))) { - return true; - } - - return false; - } - - /** - * Returns the web contents folder of the specified project - * - * @param project the project which web contents path is needed - * @return IPath of the web contents folder - */ - private IPath getWebContentPath(IProject project) { - IPath path = null; - - if (project != null && isWebProject(project)) { - IVirtualComponent component = ComponentCore.createComponent(project); - path = component.getRootFolder().getWorkspaceRelativePath(); - } - - return path; - } -} diff --git a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/wizard/NewHTMLTemplatesWizardPage.java b/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/wizard/NewHTMLTemplatesWizardPage.java deleted file mode 100644 index f065b52882..0000000000 --- a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/wizard/NewHTMLTemplatesWizardPage.java +++ /dev/null @@ -1,495 +0,0 @@ -package org.eclipse.wst.html.ui.internal.wizard; - -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.preference.PreferenceDialog; -import org.eclipse.jface.resource.JFaceResources; -import org.eclipse.jface.text.Document; -import org.eclipse.jface.text.IDocument; -import org.eclipse.jface.text.source.ISourceViewer; -import org.eclipse.jface.text.source.SourceViewer; -import org.eclipse.jface.text.source.SourceViewerConfiguration; -import org.eclipse.jface.text.templates.DocumentTemplateContext; -import org.eclipse.jface.text.templates.Template; -import org.eclipse.jface.text.templates.TemplateBuffer; -import org.eclipse.jface.text.templates.TemplateContext; -import org.eclipse.jface.text.templates.TemplateContextType; -import org.eclipse.jface.text.templates.persistence.TemplateStore; -import org.eclipse.jface.viewers.ISelectionChangedListener; -import org.eclipse.jface.viewers.IStructuredContentProvider; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.ITableLabelProvider; -import org.eclipse.jface.viewers.LabelProvider; -import org.eclipse.jface.viewers.SelectionChangedEvent; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.jface.viewers.TableLayout; -import org.eclipse.jface.viewers.TableViewer; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.jface.viewers.ViewerSorter; -import org.eclipse.jface.wizard.WizardPage; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.ControlAdapter; -import org.eclipse.swt.events.ControlEvent; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.graphics.Rectangle; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Link; -import org.eclipse.swt.widgets.Table; -import org.eclipse.swt.widgets.TableColumn; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.dialogs.PreferencesUtil; -import org.eclipse.wst.html.core.internal.provisional.contenttype.ContentTypeIdForHTML; -import org.eclipse.wst.html.ui.StructuredTextViewerConfigurationHTML; -import org.eclipse.wst.html.ui.internal.HTMLUIMessages; -import org.eclipse.wst.html.ui.internal.HTMLUIPlugin; -import org.eclipse.wst.html.ui.internal.Logger; -import org.eclipse.wst.html.ui.internal.editor.IHelpContextIds; -import org.eclipse.wst.html.ui.internal.preferences.HTMLUIPreferenceNames; -import org.eclipse.wst.html.ui.internal.templates.TemplateContextTypeIdsHTML; -import org.eclipse.wst.sse.core.StructuredModelManager; -import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel; -import org.eclipse.wst.sse.ui.StructuredTextViewerConfiguration; -import org.eclipse.wst.sse.ui.internal.StructuredTextViewer; -import org.eclipse.wst.sse.ui.internal.provisional.style.LineStyleProvider; - -/** - * Templates page in new file wizard. Allows users to select a new file - * template to be applied in new file. - * - */ -public class NewHTMLTemplatesWizardPage extends WizardPage { - - /** - * Content provider for templates - */ - private class TemplateContentProvider implements IStructuredContentProvider { - /** The template store. */ - private TemplateStore fStore; - - /* - * @see IContentProvider#dispose() - */ - public void dispose() { - fStore = null; - } - - /* - * @see IStructuredContentProvider#getElements(Object) - */ - public Object[] getElements(Object input) { - return fStore.getTemplates(TemplateContextTypeIdsHTML.NEW); - } - - /* - * @see IContentProvider#inputChanged(Viewer, Object, Object) - */ - public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { - fStore = (TemplateStore) newInput; - } - } - - /** - * Label provider for templates. - */ - private class TemplateLabelProvider extends LabelProvider implements ITableLabelProvider { - - /* - * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnImage(java.lang.Object, - * int) - */ - public Image getColumnImage(Object element, int columnIndex) { - return null; - } - - /* - * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object, - * int) - */ - public String getColumnText(Object element, int columnIndex) { - Template template = (Template) element; - - switch (columnIndex) { - case 0 : - return template.getName(); - case 1 : - return template.getDescription(); - default : - return ""; //$NON-NLS-1$ - } - } - } - - /** Last selected template name */ - private String fLastSelectedTemplateName; - /** The viewer displays the pattern of selected template. */ - private SourceViewer fPatternViewer; - /** The table presenting the templates. */ - private TableViewer fTableViewer; - /** Template store used by this wizard page */ - private TemplateStore fTemplateStore; - /** Checkbox for using templates. */ - private Button fUseTemplateButton; - - public NewHTMLTemplatesWizardPage() { - super("NewHTMLTemplatesWizardPage", HTMLUIMessages.NewHTMLTemplatesWizardPage_0, null); //$NON-NLS-1$ - setDescription(HTMLUIMessages.NewHTMLTemplatesWizardPage_1); - } - - /** - * Correctly resizes the table so no phantom columns appear - * - * @param parent - * the parent control - * @param buttons - * the buttons - * @param table - * the table - * @param column1 - * the first column - * @param column2 - * the second column - * @param column3 - * the third column - */ - private void configureTableResizing(final Composite parent, final Table table, final TableColumn column1, final TableColumn column2) { - parent.addControlListener(new ControlAdapter() { - public void controlResized(ControlEvent e) { - Rectangle area = parent.getClientArea(); - Point preferredSize = table.computeSize(SWT.DEFAULT, SWT.DEFAULT); - int width = area.width - 2 * table.getBorderWidth(); - if (preferredSize.y > area.height) { - // Subtract the scrollbar width from the total column - // width - // if a vertical scrollbar will be required - Point vBarSize = table.getVerticalBar().getSize(); - width -= vBarSize.x; - } - - Point oldSize = table.getSize(); - if (oldSize.x > width) { - // table is getting smaller so make the columns - // smaller first and then resize the table to - // match the client area width - column1.setWidth(width / 2); - column2.setWidth(width / 2); - table.setSize(width, area.height); - } - else { - // table is getting bigger so make the table - // bigger first and then make the columns wider - // to match the client area width - table.setSize(width, area.height); - column1.setWidth(width / 2); - column2.setWidth(width / 2); - } - } - }); - } - - public void createControl(Composite ancestor) { - Composite parent = new Composite(ancestor, SWT.NONE); - GridLayout layout = new GridLayout(); - layout.numColumns = 2; - parent.setLayout(layout); - - // create checkbox for user to use HTML Template - fUseTemplateButton = new Button(parent, SWT.CHECK); - fUseTemplateButton.setText(HTMLUIMessages.NewHTMLTemplatesWizardPage_4); - GridData data = new GridData(SWT.FILL, SWT.FILL, true, false, 2, 1); - fUseTemplateButton.setLayoutData(data); - fUseTemplateButton.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - enableTemplates(); - } - }); - - // create composite for Templates table - Composite innerParent = new Composite(parent, SWT.NONE); - GridLayout innerLayout = new GridLayout(); - innerLayout.numColumns = 2; - innerLayout.marginHeight = 0; - innerLayout.marginWidth = 0; - innerParent.setLayout(innerLayout); - GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1); - innerParent.setLayoutData(gd); - - // Create linked text to just to templates preference page - Link link = new Link(innerParent, SWT.NONE); - link.setText(HTMLUIMessages.NewHTMLTemplatesWizardPage_6); - data = new GridData(SWT.FILL, SWT.FILL, true, false, 2, 1); - link.setLayoutData(data); - link.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - linkClicked(); - } - }); - - // create table that displays templates - Table table = new Table(innerParent, SWT.BORDER | SWT.FULL_SELECTION); - - data = new GridData(GridData.FILL_BOTH); - data.widthHint = convertWidthInCharsToPixels(2); - data.heightHint = convertHeightInCharsToPixels(10); - data.horizontalSpan = 2; - table.setLayoutData(data); - table.setHeaderVisible(true); - table.setLinesVisible(true); - TableLayout tableLayout = new TableLayout(); - table.setLayout(tableLayout); - - TableColumn column1 = new TableColumn(table, SWT.NONE); - column1.setText(HTMLUIMessages.NewHTMLTemplatesWizardPage_2); - - TableColumn column2 = new TableColumn(table, SWT.NONE); - column2.setText(HTMLUIMessages.NewHTMLTemplatesWizardPage_3); - - fTableViewer = new TableViewer(table); - fTableViewer.setLabelProvider(new TemplateLabelProvider()); - fTableViewer.setContentProvider(new TemplateContentProvider()); - - fTableViewer.setSorter(new ViewerSorter() { - public int compare(Viewer viewer, Object object1, Object object2) { - if ((object1 instanceof Template) && (object2 instanceof Template)) { - Template left = (Template) object1; - Template right = (Template) object2; - int result = left.getName().compareToIgnoreCase(right.getName()); - if (result != 0) - return result; - return left.getDescription().compareToIgnoreCase(right.getDescription()); - } - return super.compare(viewer, object1, object2); - } - - public boolean isSorterProperty(Object element, String property) { - return true; - } - }); - - fTableViewer.addSelectionChangedListener(new ISelectionChangedListener() { - public void selectionChanged(SelectionChangedEvent e) { - updateViewerInput(); - } - }); - - // create viewer that displays currently selected template's contents - fPatternViewer = doCreateViewer(parent); - - fTemplateStore = HTMLUIPlugin.getDefault().getTemplateStore(); - fTableViewer.setInput(fTemplateStore); - - configureTableResizing(innerParent, table, column1, column2); - loadLastSavedPreferences(); - - PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, IHelpContextIds.HTML_NEWWIZARD_TEMPLATE_HELPID); - Dialog.applyDialogFont(parent); - setControl(parent); - } - - /** - * Creates, configures and returns a source viewer to present the template - * pattern on the preference page. Clients may override to provide a - * custom source viewer featuring e.g. syntax coloring. - * - * @param parent - * the parent control - * @return a configured source viewer - */ - private SourceViewer createViewer(Composite parent) { - SourceViewerConfiguration sourceViewerConfiguration = new StructuredTextViewerConfiguration() { - StructuredTextViewerConfiguration baseConfiguration = new StructuredTextViewerConfigurationHTML(); - - public String[] getConfiguredContentTypes(ISourceViewer sourceViewer) { - return baseConfiguration.getConfiguredContentTypes(sourceViewer); - } - - public LineStyleProvider[] getLineStyleProviders(ISourceViewer sourceViewer, String partitionType) { - return baseConfiguration.getLineStyleProviders(sourceViewer, partitionType); - } - }; - SourceViewer viewer = new StructuredTextViewer(parent, null, null, false, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL); - ((StructuredTextViewer) viewer).getTextWidget().setFont(JFaceResources.getFont("org.eclipse.wst.sse.ui.textfont")); //$NON-NLS-1$ - IStructuredModel scratchModel = StructuredModelManager.getModelManager().createUnManagedStructuredModelFor(ContentTypeIdForHTML.ContentTypeID_HTML); - IDocument document = scratchModel.getStructuredDocument(); - viewer.configure(sourceViewerConfiguration); - viewer.setDocument(document); - return viewer; - } - - private SourceViewer doCreateViewer(Composite parent) { - Label label = new Label(parent, SWT.NONE); - label.setText(HTMLUIMessages.NewHTMLTemplatesWizardPage_5); - GridData data = new GridData(); - data.horizontalSpan = 2; - label.setLayoutData(data); - - SourceViewer viewer = createViewer(parent); - viewer.setEditable(false); - - Control control = viewer.getControl(); - data = new GridData(GridData.FILL_BOTH); - data.horizontalSpan = 2; - data.heightHint = convertHeightInCharsToPixels(5); - control.setLayoutData(data); - - return viewer; - } - - /** - * Enable/disable controls in page based on fUseTemplateButton's current - * state. - */ - void enableTemplates() { - boolean enabled = fUseTemplateButton.getSelection(); - - if (!enabled) { - // save last selected template - Template template = getSelectedTemplate(); - if (template != null) - fLastSelectedTemplateName = template.getName(); - else - fLastSelectedTemplateName = ""; //$NON-NLS-1$ - - fTableViewer.setSelection(null); - } - else { - setSelectedTemplate(fLastSelectedTemplateName); - } - - fTableViewer.getControl().setEnabled(enabled); - fPatternViewer.getControl().setEnabled(enabled); - } - - /** - * Return the template preference page id - * - * @return - */ - private String getPreferencePageId() { - return "org.eclipse.wst.html.ui.preferences.templates"; //$NON-NLS-1$ - } - - /** - * Get the currently selected template. - * - * @return - */ - private Template getSelectedTemplate() { - Template template = null; - IStructuredSelection selection = (IStructuredSelection) fTableViewer.getSelection(); - - if (selection.size() == 1) { - template = (Template) selection.getFirstElement(); - } - return template; - } - - /** - * Returns template string to insert. - * - * @return String to insert or null if none is to be inserted - */ - String getTemplateString() { - String templateString = null; - - Template template = getSelectedTemplate(); - if (template != null) { - TemplateContextType contextType = HTMLUIPlugin.getDefault().getTemplateContextRegistry().getContextType(TemplateContextTypeIdsHTML.NEW); - IDocument document = new Document(); - TemplateContext context = new DocumentTemplateContext(contextType, document, 0, 0); - try { - TemplateBuffer buffer = context.evaluate(template); - templateString = buffer.getString(); - } - catch (Exception e) { - Logger.log(Logger.WARNING_DEBUG, "Could not create template for new html", e); //$NON-NLS-1$ - } - } - - return templateString; - } - - void linkClicked() { - String pageId = getPreferencePageId(); - PreferenceDialog dialog = PreferencesUtil.createPreferenceDialogOn(getShell(), pageId, new String[]{pageId}, null); - dialog.open(); - fTableViewer.refresh(); - } - - /** - * Load the last template name used in New HTML File wizard. - */ - private void loadLastSavedPreferences() { - String templateName = HTMLUIPlugin.getDefault().getPreferenceStore().getString(HTMLUIPreferenceNames.NEW_FILE_TEMPLATE_NAME); - if (templateName == null || templateName.length() == 0) { - fLastSelectedTemplateName = ""; //$NON-NLS-1$ - fUseTemplateButton.setSelection(false); - } - else { - fLastSelectedTemplateName = templateName; - fUseTemplateButton.setSelection(true); - } - enableTemplates(); - } - - /** - * Save template name used for next call to New HTML File wizard. - */ - void saveLastSavedPreferences() { - String templateName = ""; //$NON-NLS-1$ - - Template template = getSelectedTemplate(); - if (template != null) { - templateName = template.getName(); - } - - HTMLUIPlugin.getDefault().getPreferenceStore().setValue(HTMLUIPreferenceNames.NEW_FILE_TEMPLATE_NAME, templateName); - HTMLUIPlugin.getDefault().savePluginPreferences(); - } - - /** - * Select a template in the table viewer given the template name. If - * template name cannot be found or templateName is null, just select - * first item in table. If no items in table select nothing. - * - * @param templateName - */ - private void setSelectedTemplate(String templateName) { - Object template = null; - - if (templateName != null && templateName.length() > 0) { - // pick the last used template - template = fTemplateStore.findTemplate(templateName, TemplateContextTypeIdsHTML.NEW); - } - - // no record of last used template so just pick first element - if (template == null) { - // just pick first element - template = fTableViewer.getElementAt(0); - } - - if (template != null) { - IStructuredSelection selection = new StructuredSelection(template); - fTableViewer.setSelection(selection, true); - } - } - - /** - * Updates the pattern viewer. - */ - void updateViewerInput() { - Template template = getSelectedTemplate(); - if (template != null) { - fPatternViewer.getDocument().set(template.getPattern()); - } - else { - fPatternViewer.getDocument().set(""); //$NON-NLS-1$ - } - } -} diff --git a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/wizard/NewHTMLWizard.java b/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/wizard/NewHTMLWizard.java deleted file mode 100644 index 7c5741eb14..0000000000 --- a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/wizard/NewHTMLWizard.java +++ /dev/null @@ -1,131 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005, 2006 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.html.ui.internal.wizard; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.OutputStreamWriter; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.runtime.Preferences; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.jface.wizard.Wizard; -import org.eclipse.ui.INewWizard; -import org.eclipse.ui.IWorkbench; -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.core.internal.HTMLCorePlugin; -import org.eclipse.wst.html.ui.internal.HTMLUIMessages; -import org.eclipse.wst.html.ui.internal.Logger; -import org.eclipse.wst.html.ui.internal.editor.HTMLEditorPluginImageHelper; -import org.eclipse.wst.html.ui.internal.editor.HTMLEditorPluginImages; -import org.eclipse.wst.sse.core.internal.encoding.CommonEncodingPreferenceNames; - -public class NewHTMLWizard extends Wizard implements INewWizard { - - private NewHTMLFileWizardPage fNewFilePage; - private NewHTMLTemplatesWizardPage fNewFileTemplatesPage; - private IStructuredSelection fSelection; - - public void addPages() { - fNewFilePage = new NewHTMLFileWizardPage("HTMLWizardNewFileCreationPage", new StructuredSelection(IDE.computeSelectedResources(fSelection))); //$NON-NLS-1$ - fNewFilePage.setTitle(HTMLUIMessages._UI_WIZARD_NEW_HEADING); - fNewFilePage.setDescription(HTMLUIMessages._UI_WIZARD_NEW_DESCRIPTION); - addPage(fNewFilePage); - - fNewFileTemplatesPage = new NewHTMLTemplatesWizardPage(); - addPage(fNewFileTemplatesPage); - } - - public void init(IWorkbench aWorkbench, IStructuredSelection aSelection) { - fSelection = aSelection; - setWindowTitle(HTMLUIMessages._UI_WIZARD_NEW_TITLE); - - ImageDescriptor descriptor = HTMLEditorPluginImageHelper.getInstance().getImageDescriptor(HTMLEditorPluginImages.IMG_WIZBAN_NEWHTMLFILE); - setDefaultPageImageDescriptor(descriptor); - } - - private void openEditor(final IFile file) { - if (file != null) { - getShell().getDisplay().asyncExec(new Runnable() { - public void run() { - try { - IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); - IDE.openEditor(page, file, true); - } - catch (PartInitException e) { - Logger.log(Logger.WARNING_DEBUG, e.getMessage(), e); - } - } - }); - } - } - - public boolean performFinish() { - boolean performedOK = false; - // save user options for next use - fNewFileTemplatesPage.saveLastSavedPreferences(); - - // no file extension specified so add default extension - String fileName = fNewFilePage.getFileName(); - if (fileName.lastIndexOf('.') == -1) { - String newFileName = fNewFilePage.addDefaultExtension(fileName); - fNewFilePage.setFileName(newFileName); - } - - // create a new empty file - IFile file = fNewFilePage.createNewFile(); - - // if there was problem with creating file, it will be null, so make - // sure to check - if (file != null) { - // put template contents into file - String templateString = fNewFileTemplatesPage.getTemplateString(); - if (templateString != null) { - // determine the encoding for the new file - Preferences preference = HTMLCorePlugin.getDefault().getPluginPreferences(); - String charSet = preference.getString(CommonEncodingPreferenceNames.OUTPUT_CODESET); - - try { - ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); - OutputStreamWriter outputStreamWriter = null; - if (charSet == null || charSet.trim().equals("")) { //$NON-NLS-1$ - // just use default encoding - outputStreamWriter = new OutputStreamWriter(outputStream); - } - else { - outputStreamWriter = new OutputStreamWriter(outputStream, charSet); - } - outputStreamWriter.write(templateString); - outputStreamWriter.flush(); - outputStreamWriter.close(); - ByteArrayInputStream inputStream = new ByteArrayInputStream(outputStream.toByteArray()); - file.setContents(inputStream, true, false, null); - inputStream.close(); - } - catch (Exception e) { - Logger.log(Logger.WARNING_DEBUG, "Could not create contents for new HTML file", e); //$NON-NLS-1$ - } - } - - // open the file in editor - openEditor(file); - - // everything's fine - performedOK = true; - } - return performedOK; - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/views/contentoutline/HTMLContentOutlineConfiguration.java b/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/views/contentoutline/HTMLContentOutlineConfiguration.java deleted file mode 100644 index 421420430d..0000000000 --- a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/views/contentoutline/HTMLContentOutlineConfiguration.java +++ /dev/null @@ -1,44 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.html.ui.views.contentoutline; - -import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.jface.viewers.TreeViewer; -import org.eclipse.wst.html.ui.internal.HTMLUIPlugin; -import org.eclipse.wst.html.ui.internal.contentoutline.HTMLNodeActionManager; -import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel; -import org.eclipse.wst.xml.ui.internal.contentoutline.XMLNodeActionManager; -import org.eclipse.wst.xml.ui.views.contentoutline.XMLContentOutlineConfiguration; - -/** - * Configuration for outline view page which shows HTML content. - * - * @see org.eclipse.wst.sse.ui.views.contentoutline.ContentOutlineConfiguration - * @since 1.0 - */ -public class HTMLContentOutlineConfiguration extends XMLContentOutlineConfiguration { - - /** - * Create new instance of HTMLContentOutlineConfiguration - */ - public HTMLContentOutlineConfiguration() { - // Must have empty constructor to createExecutableExtension - super(); - } - - protected XMLNodeActionManager createNodeActionManager(TreeViewer treeViewer) { - return new HTMLNodeActionManager((IStructuredModel) treeViewer.getInput(), treeViewer); - } - - protected IPreferenceStore getPreferenceStore() { - return HTMLUIPlugin.getDefault().getPreferenceStore(); - } -}
\ No newline at end of file |