diff options
Diffstat (limited to 'bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui')
69 files changed, 0 insertions, 10611 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 4da55ee5c2..0000000000 --- a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/StructuredTextViewerConfigurationHTML.java +++ /dev/null @@ -1,273 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.html.ui; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.Vector; - -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Preferences; -import org.eclipse.jface.text.IAutoEditStrategy; -import org.eclipse.jface.text.ITextDoubleClickStrategy; -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.source.ISourceViewer; -import org.eclipse.jface.viewers.ILabelProvider; -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.provisional.contenttype.ContentTypeIdForHTML; -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.contentassist.HTMLContentAssistProcessor; -import org.eclipse.wst.html.ui.internal.contentassist.NoRegionContentAssistProcessorForHTML; -import org.eclipse.wst.html.ui.internal.style.LineStyleProviderForHTML; -import org.eclipse.wst.sse.core.text.IStructuredPartitions; -import org.eclipse.wst.sse.ui.StructuredTextViewerConfiguration; -import org.eclipse.wst.sse.ui.internal.format.StructuredFormattingStrategy; -import org.eclipse.wst.sse.ui.internal.provisional.style.LineStyleProvider; -import org.eclipse.wst.xml.core.internal.provisional.contenttype.ContentTypeIdForXML; -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; -import org.eclipse.wst.xml.ui.internal.contentoutline.JFaceNodeLabelProvider; -import org.w3c.dom.Node; - -/** - * 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 StructuredTextViewerConfiguration fXMLSourceViewerConfiguration; - private ILabelProvider fStatusLineLabelProvider; - - /** - * 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]); - } - - // 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 == 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) { - IContentFormatter formatter = super.getContentFormatter(sourceViewer); - // super was unable to create a formatter, probably because - // sourceViewer does not have document set yet, so just create a - // generic one - if (!(formatter instanceof MultiPassContentFormatter)) - formatter = new MultiPassContentFormatter(getConfiguredDocumentPartitioning(sourceViewer), IHTMLPartitions.HTML_DEFAULT); - ((MultiPassContentFormatter) 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 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()]); - } - - 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 == 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; - } - - public ILabelProvider getStatusLineLabelProvider(ISourceViewer sourceViewer) { - if (fStatusLineLabelProvider == null) { - fStatusLineLabelProvider = new JFaceNodeLabelProvider() { - public String getText(Object element) { - - if (element == null) - return null; - - StringBuffer s = new StringBuffer(); - Node node = (Node) element; - while (node != null) { - if (node.getNodeType() != Node.DOCUMENT_NODE) { - s.insert(0, super.getText(node)); - } - node = node.getParentNode(); - if (node != null && node.getNodeType() != Node.DOCUMENT_NODE) { - s.insert(0, IPath.SEPARATOR); - } - } - return s.toString(); - } - - }; - } - return fStatusLineLabelProvider; - } - - private StructuredTextViewerConfiguration getXMLSourceViewerConfiguration() { - if (fXMLSourceViewerConfiguration == null) { - fXMLSourceViewerConfiguration = new StructuredTextViewerConfigurationXML(); - } - return fXMLSourceViewerConfiguration; - } - - protected Map getHyperlinkDetectorTargets(ISourceViewer sourceViewer) { - Map targets = super.getHyperlinkDetectorTargets(sourceViewer); - targets.put(ContentTypeIdForHTML.ContentTypeID_HTML, null); - - // also add xml since there could be xml content in html - // (just hope the hyperlink detectors will do additional checking) - targets.put(ContentTypeIdForXML.ContentTypeID_XML, null); - return targets; - } -}
\ 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 db5e57f8af..0000000000 --- a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/HTMLUIMessages.java +++ /dev/null @@ -1,134 +0,0 @@ -/********************************************************************** - * Copyright (c) 2005, 2007 IBM Corporation and others. All rights reserved. This - * program and the accompanying materials are made available under the terms of - * the Eclipse Public License v1.0 which accompanies this distribution, and is - * available at http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM - 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 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 Content_assist_UI_; - public static String Automatically_make_suggest_UI_; - public static String Prompt_when_these_characte_UI_; - public static String Formatting_UI_; - public static String Line_width__UI_; - public static String Split_multiple_attributes; - public static String Align_final_bracket; - public static String Indent_using_tabs; - public static String Indent_using_spaces; - public static String Indentation_size; - public static String Indentation_size_tip; - public static String Clear_all_blank_lines_UI_; - 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; - public static String SyntaxColoringPage_0; - public static String SyntaxColoringPage_2; - public static String SyntaxColoringPage_3; - public static String SyntaxColoringPage_4; - public static String SyntaxColoringPage_5; - public static String SyntaxColoringPage_6; - - // 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 6d049337ad..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, 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; - -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 5b73362bec..0000000000 --- a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/HTMLUIPluginResources.properties +++ /dev/null @@ -1,107 +0,0 @@ -############################################################################### -# Copyright (c) 2004, 2007 IBM Corporation and others. -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License v1.0 -# which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/epl-v10.html -# -# Contributors: -# IBM Corporation - initial API and implementation -# Benjamin Muskalla, b.muskalla@gmx.net - [158660] character entities should have their own syntax highlighting preference -############################################################################### -## 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\t<p>three spaces</p>\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 -# 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: -## HTML Source preference page -Content_assist_UI_=Content assist -Automatically_make_suggest_UI_=Automatically ma&ke suggestions -Prompt_when_these_characte_UI_=P&rompt when these characters are inserted: -Formatting_UI_=Formatting -Line_width__UI_=Line &width: -Split_multiple_attributes=Split &multiple attributes each on a new line -Align_final_bracket=&Align final bracket in multi-line element tags -Indent_using_tabs=&Indent using tabs -Indent_using_spaces=I&ndent using spaces -Indentation_size=In&dentation size: -Indentation_size_tip=Indentation size -Clear_all_blank_lines_UI_=Clear all &blank lines -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. -SyntaxColoringPage_0=Syntax Element: -SyntaxColoringPage_2=Enable -SyntaxColoringPage_3=B&old -SyntaxColoringPage_4=&Italic -SyntaxColoringPage_5=&Strikethrough -SyntaxColoringPage_6=&Underline -# 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 580f3fe80e..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, 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 - * 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 bc89ee54c6..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, 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 - 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 b4643ac887..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, 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 - * 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 6bb0f2061b..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, 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.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 10517f6b84..0000000000 --- a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/contentassist/HTMLContentAssistProcessor.java +++ /dev/null @@ -1,508 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.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.text.contentassist.IContentAssistProcessor; -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.core.text.IHTMLPartitions; -import org.eclipse.wst.html.ui.StructuredTextViewerConfigurationHTML; -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.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.IReleasable; -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 IContentAssistProcessor fJSContentAssistProcessor = 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$ - IContentAssistProcessor jsProcessor = getJSContentAssistProcessor(); - if (jsProcessor != null) { - return jsProcessor.computeCompletionProposals(textViewer, documentPosition); - } - return new ICompletionProposal[0]; - } - } - } - } - } - - 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 = getHTMLTagProposal((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 getHTMLTagProposal(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 - CMDocument correspondingCMDocument = mq.getCorrespondingCMDocument(doc); - if (correspondingCMDocument != null) { - CMElementDeclaration htmlDecl = (CMElementDeclaration) correspondingCMDocument.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 IContentAssistProcessor getJSContentAssistProcessor() { - if (fJSContentAssistProcessor == null) { - fJSContentAssistProcessor = new StructuredTextViewerConfigurationHTML().getContentAssistant(null).getContentAssistProcessor(IHTMLPartitions.SCRIPT); - } - return fJSContentAssistProcessor; - } - - 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(); - } - if (fJSContentAssistProcessor instanceof IReleasable) { - ((IReleasable)fJSContentAssistProcessor).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 53035f6677..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, 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.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; - } - - -} 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 748a54dd38..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, 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this 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.html.ui.StructuredTextViewerConfigurationHTML; -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 StructuredTextViewerConfigurationHTML().getContentAssistant(null).getContentAssistProcessor(IHTMLPartitions.SCRIPT); - addPartitionProcessor(IHTMLPartitions.SCRIPT, jsContentAssistProcessor); - - IContentAssistProcessor cssContentAssistProcessor = new CSSContentAssistProcessor(); - addPartitionProcessor(ICSSPartitions.STYLE, cssContentAssistProcessor); - } -} 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 2a9607ea48..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, 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.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; - } -} 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 b59c9545fe..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, 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.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(); - } - } -} 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 ea1dddd581..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, 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.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()); - } - -} 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 d38bcf4b72..0000000000 --- a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/contentoutline/JFaceNodeAdapterForHTML.java +++ /dev/null @@ -1,73 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.html.ui.internal.contentoutline; - - - -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) { - return HTMLEditorPluginImageHelper.getInstance().getImage(imageResourceName); - } - - /** - * 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 b123df94ad..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, 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; - -/** - * @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 664084c663..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, 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 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 75b272d25e..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, 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 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]); - } - } - -} 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 c42cb159a3..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, 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; - -/** - * <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 fe607798e5..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, 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 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 3263eaa304..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, 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.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 395fdedfca..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, 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 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 333c615c7f..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, 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 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 1ef88f09a2..0000000000 --- a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/contentproperties/ui/WebContentSettingsPropertyPage.java +++ /dev/null @@ -1,383 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - * 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.core.runtime.IAdaptable; -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; - IAdaptable adaptable = getElement(); - if (adaptable instanceof IResource) { - resource = (IResource) adaptable; - } else if (adaptable != null) { - Object o = adaptable.getAdapter(IResource.class); - if (o instanceof IResource) { - resource = (IResource)o; - } - } - 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 3ddb028abe..0000000000 --- a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/correction/CorrectionAssistantProviderHTML.java +++ /dev/null @@ -1,54 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005, 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM - 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 - * - * @deprecated since 2.0 RC0 Use - * org.eclipse.jface.text.quickassist.IQuickAssistProcessor; - */ -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 3860bbcbcf..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, 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 - 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 c471d0622c..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, 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.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; - } -} 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 6d8fd56fb0..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, 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.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 572fe19dd8..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, 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.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; - } -} 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 206614145a..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, 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.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; - } -} 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 569b7240a3..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, 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.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$ -} 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 50238c2269..0000000000 --- a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/preferences/HTMLUIPreferenceInitializer.java +++ /dev/null @@ -1,107 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - * Benjamin Muskalla, b.muskalla@gmx.net - [158660] character entities should have their own syntax highlighting preference - * - *******************************************************************************/ -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 JUSTITALIC = " | null | false | true"; //$NON-NLS-1$ - String styleValue = ColorHelper.getColorString(127, 0, 127) + NOBACKGROUNDBOLD; - store.setDefault(IStyleConstantsXML.TAG_ATTRIBUTE_NAME, styleValue); - - styleValue = ColorHelper.getColorString(42, 0, 255) + JUSTITALIC; - 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); - - styleValue = ColorHelper.getColorString(42, 0, 255) + NOBACKGROUNDBOLD; - store.setDefault(IStyleConstantsXML.ENTITY_REFERENCE, 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 c299dacce8..0000000000 --- a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/preferences/ui/HTMLColorPage.java +++ /dev/null @@ -1,127 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004,2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.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; - -/** - * @deprecated - */ -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 c25acb2f10..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, 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.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; - } -} 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 4a72b9c977..0000000000 --- a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/preferences/ui/HTMLSourcePreferencePage.java +++ /dev/null @@ -1,324 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.html.ui.internal.preferences.ui; - -import org.eclipse.core.runtime.Preferences; -import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Group; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Spinner; -import org.eclipse.swt.widgets.Text; -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.html.ui.internal.preferences.HTMLUIPreferenceNames; -import org.eclipse.wst.sse.ui.internal.preferences.ui.AbstractPreferencePage; - -public class HTMLSourcePreferencePage extends AbstractPreferencePage { - private Button fTagNameUpper = null; - private Button fTagNameLower = null; - private Button fAttrNameUpper = null; - private Button fAttrNameLower = null; - - private final int MIN_INDENTATION_SIZE = 0; - private final int MAX_INDENTATION_SIZE = 16; - - // Content Assist - private Button fAutoPropose; - private Label fAutoProposeLabel; - private Text fAutoProposeText; - private Button fClearAllBlankLines; - - // Formatting - private Text fLineWidthText; - private Button fSplitMultiAttrs; - private Button fAlignEndBracket; - private Button fIndentUsingTabs; - private Button fIndentUsingSpaces; - private Spinner fIndentationSize; - - private void createContentsForContentAssistGroup(Composite parent) { - Group contentAssistGroup = createGroup(parent, 2); - contentAssistGroup.setText(HTMLUIMessages.Content_assist_UI_); - - fAutoPropose = createCheckBox(contentAssistGroup, HTMLUIMessages.Automatically_make_suggest_UI_); - ((GridData) fAutoPropose.getLayoutData()).horizontalSpan = 2; - fAutoPropose.addSelectionListener(this); - - fAutoProposeLabel = createLabel(contentAssistGroup, HTMLUIMessages.Prompt_when_these_characte_UI_); - fAutoProposeText = createTextField(contentAssistGroup); - - // add one more group of preferences - createContentsForPreferredCaseGroup(parent, 2); - } - - private 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; - - } - - private void createContentsForFormattingGroup(Composite parent) { - Group formattingGroup = createGroup(parent, 2); - formattingGroup.setText(HTMLUIMessages.Formatting_UI_); - - createLabel(formattingGroup, HTMLUIMessages.Line_width__UI_); - fLineWidthText = new Text(formattingGroup, SWT.SINGLE | SWT.BORDER); - GridData gData = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.BEGINNING); - gData.widthHint = 25; - fLineWidthText.setLayoutData(gData); - fLineWidthText.addModifyListener(this); - - fSplitMultiAttrs = createCheckBox(formattingGroup, HTMLUIMessages.Split_multiple_attributes); - ((GridData) fSplitMultiAttrs.getLayoutData()).horizontalSpan = 2; - fAlignEndBracket = createCheckBox(formattingGroup, HTMLUIMessages.Align_final_bracket); - ((GridData) fAlignEndBracket.getLayoutData()).horizontalSpan = 2; - fClearAllBlankLines = createCheckBox(formattingGroup, HTMLUIMessages.Clear_all_blank_lines_UI_); - ((GridData) fClearAllBlankLines.getLayoutData()).horizontalSpan = 2; - - fIndentUsingTabs = createRadioButton(formattingGroup, HTMLUIMessages.Indent_using_tabs); - ((GridData) fIndentUsingTabs.getLayoutData()).horizontalSpan = 2; - - fIndentUsingSpaces = createRadioButton(formattingGroup, HTMLUIMessages.Indent_using_spaces); - ((GridData) fIndentUsingSpaces.getLayoutData()).horizontalSpan = 2; - - createLabel(formattingGroup, HTMLUIMessages.Indentation_size); - fIndentationSize = new Spinner(formattingGroup, SWT.READ_ONLY | SWT.BORDER); - GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING); - fIndentationSize.setLayoutData(gd); - fIndentationSize.setToolTipText(HTMLUIMessages.Indentation_size_tip); - fIndentationSize.setMinimum(MIN_INDENTATION_SIZE); - fIndentationSize.setMaximum(MAX_INDENTATION_SIZE); - fIndentationSize.setIncrement(1); - fIndentationSize.setPageIncrement(4); - fIndentationSize.addModifyListener(this); - } - - 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); - - performDefaultsForFormattingGroup(); - performDefaultsForContentAssistGroup(); - - validateValues(); - enableValues(); - - super.performDefaults(); - } - - private void performDefaultsForContentAssistGroup() { - // Content Assist - fAutoPropose.setSelection(getPreferenceStore().getDefaultBoolean(HTMLUIPreferenceNames.AUTO_PROPOSE)); - fAutoProposeText.setText(getPreferenceStore().getDefaultString(HTMLUIPreferenceNames.AUTO_PROPOSE_CODE)); - } - - private void performDefaultsForFormattingGroup() { - // Formatting - fLineWidthText.setText(getModelPreferences().getDefaultString(HTMLCorePreferenceNames.LINE_WIDTH)); - fSplitMultiAttrs.setSelection(getModelPreferences().getDefaultBoolean(HTMLCorePreferenceNames.SPLIT_MULTI_ATTRS)); - fAlignEndBracket.setSelection(getModelPreferences().getDefaultBoolean(HTMLCorePreferenceNames.ALIGN_END_BRACKET)); - fClearAllBlankLines.setSelection(getModelPreferences().getDefaultBoolean(HTMLCorePreferenceNames.CLEAR_ALL_BLANK_LINES)); - - if (HTMLCorePreferenceNames.TAB.equals(getModelPreferences().getDefaultString(HTMLCorePreferenceNames.INDENTATION_CHAR))) { - fIndentUsingTabs.setSelection(true); - fIndentUsingSpaces.setSelection(false); - } - else { - fIndentUsingSpaces.setSelection(true); - fIndentUsingTabs.setSelection(false); - } - fIndentationSize.setSelection(getModelPreferences().getDefaultInt(HTMLCorePreferenceNames.INDENTATION_SIZE)); - } - - 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); - - initializeValuesForFormattingGroup(); - initializeValuesForContentAssistGroup(); - } - - private void initializeValuesForContentAssistGroup() { - // Content Assist - fAutoPropose.setSelection(getPreferenceStore().getBoolean(HTMLUIPreferenceNames.AUTO_PROPOSE)); - fAutoProposeText.setText(getPreferenceStore().getString(HTMLUIPreferenceNames.AUTO_PROPOSE_CODE)); - } - - private void initializeValuesForFormattingGroup() { - // Formatting - fLineWidthText.setText(getModelPreferences().getString(HTMLCorePreferenceNames.LINE_WIDTH)); - fSplitMultiAttrs.setSelection(getModelPreferences().getBoolean(HTMLCorePreferenceNames.SPLIT_MULTI_ATTRS)); - fAlignEndBracket.setSelection(getModelPreferences().getBoolean(HTMLCorePreferenceNames.ALIGN_END_BRACKET)); - fClearAllBlankLines.setSelection(getModelPreferences().getBoolean(HTMLCorePreferenceNames.CLEAR_ALL_BLANK_LINES)); - - if (HTMLCorePreferenceNames.TAB.equals(getModelPreferences().getString(HTMLCorePreferenceNames.INDENTATION_CHAR))) { - fIndentUsingTabs.setSelection(true); - fIndentUsingSpaces.setSelection(false); - } - else { - fIndentUsingSpaces.setSelection(true); - fIndentUsingTabs.setSelection(false); - } - - fIndentationSize.setSelection(getModelPreferences().getInt(HTMLCorePreferenceNames.INDENTATION_SIZE)); - } - - 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); - - storeValuesForFormattingGroup(); - storeValuesForContentAssistGroup(); - } - - private void storeValuesForContentAssistGroup() { - // Content Assist - getPreferenceStore().setValue(HTMLUIPreferenceNames.AUTO_PROPOSE, fAutoPropose.getSelection()); - getPreferenceStore().setValue(HTMLUIPreferenceNames.AUTO_PROPOSE_CODE, fAutoProposeText.getText()); - } - - private void storeValuesForFormattingGroup() { - // Formatting - getModelPreferences().setValue(HTMLCorePreferenceNames.LINE_WIDTH, fLineWidthText.getText()); - getModelPreferences().setValue(HTMLCorePreferenceNames.SPLIT_MULTI_ATTRS, fSplitMultiAttrs.getSelection()); - getModelPreferences().setValue(HTMLCorePreferenceNames.ALIGN_END_BRACKET, fAlignEndBracket.getSelection()); - getModelPreferences().setValue(HTMLCorePreferenceNames.CLEAR_ALL_BLANK_LINES, fClearAllBlankLines.getSelection()); - - if (fIndentUsingTabs.getSelection()) { - getModelPreferences().setValue(HTMLCorePreferenceNames.INDENTATION_CHAR, HTMLCorePreferenceNames.TAB); - } - else { - getModelPreferences().setValue(HTMLCorePreferenceNames.INDENTATION_CHAR, HTMLCorePreferenceNames.SPACE); - } - getModelPreferences().setValue(HTMLCorePreferenceNames.INDENTATION_SIZE, fIndentationSize.getSelection()); - } - - public boolean performOk() { - boolean result = super.performOk(); - - doSavePreferenceStore(); - - return result; - } - - protected Preferences getModelPreferences() { - return HTMLCorePlugin.getDefault().getPluginPreferences(); - } - - protected IPreferenceStore doGetPreferenceStore() { - return HTMLUIPlugin.getDefault().getPreferenceStore(); - } - - private void doSavePreferenceStore() { - HTMLUIPlugin.getDefault().savePluginPreferences(); // UI - HTMLCorePlugin.getDefault().savePluginPreferences(); // model - } - - protected Control createContents(Composite parent) { - Composite composite = (Composite) super.createContents(parent); - PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, IHelpContextIds.HTML_PREFWEBX_SOURCE_HELPID); - - createContentsForFormattingGroup(composite); - createContentsForContentAssistGroup(composite); - setSize(composite); - loadPreferences(); - - return composite; - } - - protected void enableValues() { - if (fAutoPropose != null) { - if (fAutoPropose.getSelection()) { - fAutoProposeLabel.setEnabled(true); - fAutoProposeText.setEnabled(true); - } - else { - fAutoProposeLabel.setEnabled(false); - fAutoProposeText.setEnabled(false); - } - } - } - - protected void validateValues() { - boolean isError = false; - String widthText = null; - - if (fLineWidthText != null) { - try { - widthText = fLineWidthText.getText(); - int formattingLineWidth = Integer.parseInt(widthText); - if ((formattingLineWidth < WIDTH_VALIDATION_LOWER_LIMIT) || (formattingLineWidth > WIDTH_VALIDATION_UPPER_LIMIT)) { - throw new NumberFormatException(); - } - } - catch (NumberFormatException nfexc) { - setInvalidInputMessage(widthText); - setValid(false); - isError = true; - } - } - - int indentSize = 0; - if (fIndentationSize != null) { - try { - indentSize = fIndentationSize.getSelection(); - if ((indentSize < MIN_INDENTATION_SIZE) || (indentSize > MAX_INDENTATION_SIZE)) { - throw new NumberFormatException(); - } - } - catch (NumberFormatException nfexc) { - setInvalidInputMessage(Integer.toString(indentSize)); - setValid(false); - isError = true; - } - } - - if (!isError) { - setErrorMessage(null); - setValid(true); - } - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/preferences/ui/HTMLSyntaxColoringPage.java b/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/preferences/ui/HTMLSyntaxColoringPage.java deleted file mode 100644 index 0a682c7f9e..0000000000 --- a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/preferences/ui/HTMLSyntaxColoringPage.java +++ /dev/null @@ -1,871 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - * - *******************************************************************************/ -package org.eclipse.wst.html.ui.internal.preferences.ui; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - -import org.eclipse.jface.preference.ColorSelector; -import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.jface.preference.PreferencePage; -import org.eclipse.jface.resource.JFaceResources; -import org.eclipse.jface.text.TextAttribute; -import org.eclipse.jface.text.source.SourceViewer; -import org.eclipse.jface.util.IPropertyChangeListener; -import org.eclipse.jface.util.PropertyChangeEvent; -import org.eclipse.jface.viewers.ISelectionChangedListener; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.ITreeContentProvider; -import org.eclipse.jface.viewers.LabelProvider; -import org.eclipse.jface.viewers.ListViewer; -import org.eclipse.jface.viewers.SelectionChangedEvent; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.jface.viewers.StructuredViewer; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.jface.viewers.ViewerComparator; -import org.eclipse.swt.SWT; -import org.eclipse.swt.accessibility.ACC; -import org.eclipse.swt.accessibility.AccessibleAdapter; -import org.eclipse.swt.accessibility.AccessibleEvent; -import org.eclipse.swt.custom.SashForm; -import org.eclipse.swt.custom.StyleRange; -import org.eclipse.swt.custom.StyledText; -import org.eclipse.swt.events.KeyEvent; -import org.eclipse.swt.events.KeyListener; -import org.eclipse.swt.events.MouseEvent; -import org.eclipse.swt.events.MouseListener; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.SelectionListener; -import org.eclipse.swt.events.TraverseEvent; -import org.eclipse.swt.events.TraverseListener; -import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.graphics.RGB; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Link; -import org.eclipse.ui.IWorkbench; -import org.eclipse.ui.IWorkbenchPreferencePage; -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.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.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.SSEUIMessages; -import org.eclipse.wst.sse.ui.internal.SSEUIPlugin; -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.ColorHelper; -import org.eclipse.wst.sse.ui.internal.util.EditorUtility; -import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext; -import org.eclipse.wst.xml.ui.internal.XMLUIMessages; -import org.eclipse.wst.xml.ui.internal.style.IStyleConstantsXML; - -import com.ibm.icu.text.Collator; - -/** - * A preference page to configure our XML syntax color. It resembles the JDT - * and CDT pages far more than our original color page while retaining the - * extra "click-to-find" functionality. - */ -public final class HTMLSyntaxColoringPage extends PreferencePage implements IWorkbenchPreferencePage { - - private Button fBold; - private Label fForegroundLabel; - private Label fBackgroundLabel; - private Button fClearStyle; - private Map fContextToStyleMap; - private Color fDefaultForeground = null; - private Color fDefaultBackground = null; - private IStructuredDocument fDocument; - private ColorSelector fForegroundColorEditor; - private ColorSelector fBackgroundColorEditor; - private Button fItalic; - private OverlayPreferenceStore fOverlayStore; - private Button fStrike; - private Collection fStylePreferenceKeys; - private StructuredViewer fStylesViewer = null; - private Map fStyleToDescriptionMap; - private StyledText fText; - private Button fUnderline; - - // activate controls based on the given local color type - private void activate(String namedStyle) { - Color foreground = fDefaultForeground; - Color background = fDefaultBackground; - if (namedStyle == null) { - fClearStyle.setEnabled(false); - fBold.setEnabled(false); - fItalic.setEnabled(false); - fStrike.setEnabled(false); - fUnderline.setEnabled(false); - fForegroundLabel.setEnabled(false); - fBackgroundLabel.setEnabled(false); - fForegroundColorEditor.setEnabled(false); - fBackgroundColorEditor.setEnabled(false); - fBold.setSelection(false); - fItalic.setSelection(false); - fStrike.setSelection(false); - fUnderline.setSelection(false); - } - else { - TextAttribute attribute = getAttributeFor(namedStyle); - fClearStyle.setEnabled(true); - fBold.setEnabled(true); - fItalic.setEnabled(true); - fStrike.setEnabled(true); - fUnderline.setEnabled(true); - fForegroundLabel.setEnabled(true); - fBackgroundLabel.setEnabled(true); - fForegroundColorEditor.setEnabled(true); - fBackgroundColorEditor.setEnabled(true); - fBold.setSelection((attribute.getStyle() & SWT.BOLD) != 0); - fItalic.setSelection((attribute.getStyle() & SWT.ITALIC) != 0); - fStrike.setSelection((attribute.getStyle() & TextAttribute.STRIKETHROUGH) != 0); - fUnderline.setSelection((attribute.getStyle() & TextAttribute.UNDERLINE) != 0); - if (attribute.getForeground() != null) { - foreground = attribute.getForeground(); - } - if (attribute.getBackground() != null) { - background = attribute.getBackground(); - } - } - - fForegroundColorEditor.setColorValue(foreground.getRGB()); - fBackgroundColorEditor.setColorValue(background.getRGB()); - } - - /** - * Color the text in the sample area according to the current preferences - */ - void applyStyles() { - if (fText == null || fText.isDisposed()) - return; - IStructuredDocumentRegion documentRegion = fDocument.getFirstStructuredDocumentRegion(); - while (documentRegion != null) { - ITextRegionList regions = documentRegion.getRegions(); - for (int i = 0; i < regions.size(); i++) { - ITextRegion currentRegion = regions.get(i); - // lookup the local coloring type and apply it - String namedStyle = (String) fContextToStyleMap.get(currentRegion.getType()); - if (namedStyle == null) - continue; - TextAttribute attribute = getAttributeFor(namedStyle); - if (attribute == null) - continue; - StyleRange style = new StyleRange(documentRegion.getStartOffset(currentRegion), currentRegion.getTextLength(), attribute.getForeground(), attribute.getBackground(), attribute.getStyle()); - style.strikeout = (attribute.getStyle() & TextAttribute.STRIKETHROUGH) != 0; - style.underline = (attribute.getStyle() & TextAttribute.UNDERLINE) != 0; - fText.setStyleRange(style); - } - documentRegion = documentRegion.getNext(); - } - } - - Button createCheckbox(Composite parent, String label) { - Button button = new Button(parent, SWT.CHECK); - button.setText(label); - button.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); - return button; - } - - /** - * Creates composite control and sets the default layout data. - */ - private Composite createComposite(Composite parent, int numColumns) { - Composite composite = new Composite(parent, SWT.NULL); - - // GridLayout - GridLayout layout = new GridLayout(); - layout.numColumns = numColumns; - layout.makeColumnsEqualWidth = false; - layout.marginHeight = 0; - layout.marginWidth = 0; - composite.setLayout(layout); - - // GridData - GridData data = new GridData(SWT.FILL, SWT.FILL, true, false); - composite.setLayoutData(data); - return composite; - } - - protected Control createContents(final Composite parent) { - initializeDialogUnits(parent); - - fDefaultForeground = parent.getDisplay().getSystemColor(SWT.COLOR_LIST_FOREGROUND); - fDefaultBackground = parent.getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND); - Composite pageComponent = createComposite(parent, 2); - PlatformUI.getWorkbench().getHelpSystem().setHelp(pageComponent, IHelpContextIds.HTML_PREFWEBX_STYLES_HELPID); - - Link link = new Link(pageComponent, SWT.WRAP); - link.setText(SSEUIMessages.SyntaxColoring_Link); - link.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - PreferencesUtil.createPreferenceDialogOn(parent.getShell(), e.text, null, null); - } - }); - - GridData linkData= new GridData(SWT.FILL, SWT.BEGINNING, true, false, 2, 1); - linkData.widthHint= 150; // only expand further if anyone else requires it - link.setLayoutData(linkData); - - new Label(pageComponent, SWT.NONE).setLayoutData(new GridData()); - new Label(pageComponent, SWT.NONE).setLayoutData(new GridData()); - - SashForm editor = new SashForm(pageComponent, SWT.VERTICAL); - GridData gridData2 = new GridData(SWT.FILL, SWT.FILL, true, true); - gridData2.horizontalSpan = 2; - editor.setLayoutData(gridData2); - SashForm top = new SashForm(editor, SWT.HORIZONTAL); - Composite styleEditor = createComposite(top, 1); - ((GridLayout) styleEditor.getLayout()).marginRight = 5; - ((GridLayout) styleEditor.getLayout()).marginLeft = 0; - createLabel(styleEditor, HTMLUIMessages.SyntaxColoringPage_0); - fStylesViewer = createStylesViewer(styleEditor); - GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true); - gridData.horizontalIndent = 0; - Iterator iterator = fStyleToDescriptionMap.values().iterator(); - while (iterator.hasNext()) { - gridData.widthHint = Math.max(gridData.widthHint, convertWidthInCharsToPixels(iterator.next().toString().length())); - } - gridData.heightHint = convertHeightInCharsToPixels(5); - fStylesViewer.getControl().setLayoutData(gridData); - - Composite editingComposite = createComposite(top, 1); - ((GridLayout) styleEditor.getLayout()).marginLeft = 5; - createLabel(editingComposite, ""); //$NON-NLS-1$ - Button enabler = createCheckbox(editingComposite, HTMLUIMessages.SyntaxColoringPage_2); - enabler.setEnabled(false); - enabler.setSelection(true); - Composite editControls = createComposite(editingComposite, 2); - ((GridLayout) editControls.getLayout()).marginLeft = 20; - - fForegroundLabel = createLabel(editControls, SSEUIMessages.Foreground_UI_); - ((GridData) fForegroundLabel.getLayoutData()).verticalAlignment = SWT.CENTER; - fForegroundLabel.setEnabled(false); - - fForegroundColorEditor = new ColorSelector(editControls); - Button fForegroundColor = fForegroundColorEditor.getButton(); - GridData gd = new GridData(SWT.BEGINNING, SWT.FILL, false, false); - fForegroundColor.setLayoutData(gd); - fForegroundColorEditor.setEnabled(false); - - fBackgroundLabel = createLabel(editControls, SSEUIMessages.Background_UI_); - ((GridData) fBackgroundLabel.getLayoutData()).verticalAlignment = SWT.CENTER; - fBackgroundLabel.setEnabled(false); - - fBackgroundColorEditor = new ColorSelector(editControls); - Button fBackgroundColor = fBackgroundColorEditor.getButton(); - gd = new GridData(SWT.BEGINNING, SWT.FILL, false, false); - fBackgroundColor.setLayoutData(gd); - fBackgroundColorEditor.setEnabled(false); - - fBold = createCheckbox(editControls, HTMLUIMessages.SyntaxColoringPage_3); - fBold.setEnabled(false); - ((GridData) fBold.getLayoutData()).horizontalSpan = 2; - fItalic = createCheckbox(editControls, HTMLUIMessages.SyntaxColoringPage_4); - fItalic.setEnabled(false); - ((GridData) fItalic.getLayoutData()).horizontalSpan = 2; - fStrike = createCheckbox(editControls, HTMLUIMessages.SyntaxColoringPage_5); - fStrike.setEnabled(false); - ((GridData) fStrike.getLayoutData()).horizontalSpan = 2; - fUnderline = createCheckbox(editControls, HTMLUIMessages.SyntaxColoringPage_6); - fUnderline.setEnabled(false); - ((GridData) fUnderline.getLayoutData()).horizontalSpan = 2; - fClearStyle = new Button(editingComposite, SWT.PUSH); - fClearStyle.setText(SSEUIMessages.Restore_Default_UI_); //$NON-NLS-1$ = "Restore Default" - fClearStyle.setLayoutData(new GridData(SWT.BEGINNING)); - ((GridData)fClearStyle.getLayoutData()).horizontalIndent = 20; - fClearStyle.setEnabled(false); - - Composite sampleArea = createComposite(editor, 1); - - ((GridLayout) sampleArea.getLayout()).marginLeft = 5; - ((GridLayout) sampleArea.getLayout()).marginTop = 5; - createLabel(sampleArea, SSEUIMessages.Sample_text__UI_); //$NON-NLS-1$ = "&Sample text:" - SourceViewer viewer = new SourceViewer(sampleArea, null, SWT.BORDER | SWT.LEFT_TO_RIGHT | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL | SWT.READ_ONLY); - fText = viewer.getTextWidget(); - GridData gridData3 = new GridData(SWT.FILL, SWT.FILL, true, true); - gridData3.widthHint = convertWidthInCharsToPixels(20); - gridData3.heightHint = convertHeightInCharsToPixels(5); - gridData3.horizontalSpan = 2; - fText.setLayoutData(gridData3); - fText.setEditable(false); - fText.setFont(JFaceResources.getFont("org.eclipse.wst.sse.ui.textfont")); //$NON-NLS-1$ - fText.addKeyListener(getTextKeyListener()); - fText.addSelectionListener(getTextSelectionListener()); - fText.addMouseListener(getTextMouseListener()); - fText.addTraverseListener(getTraverseListener()); - setAccessible(fText, SSEUIMessages.Sample_text__UI_); - fDocument = StructuredModelManager.getModelManager().createStructuredDocumentFor(ContentTypeIdForHTML.ContentTypeID_HTML); - fDocument.set(getExampleText()); - viewer.setDocument(fDocument); - - top.setWeights(new int[]{1, 1}); - editor.setWeights(new int[]{1, 1}); - PlatformUI.getWorkbench().getHelpSystem().setHelp(pageComponent, IHelpContextIds.HTML_PREFWEBX_STYLES_HELPID); - - fStylesViewer.setInput(getStylePreferenceKeys()); - - applyStyles(); - - fStylesViewer.addSelectionChangedListener(new ISelectionChangedListener() { - public void selectionChanged(SelectionChangedEvent event) { - if (!event.getSelection().isEmpty()) { - Object o = ((IStructuredSelection) event.getSelection()).getFirstElement(); - String namedStyle = o.toString(); - activate(namedStyle); - if (namedStyle == null) - return; - } - } - }); - - fForegroundColorEditor.addListener(new IPropertyChangeListener() { - public void propertyChange(PropertyChangeEvent event) { - if (event.getProperty().equals(ColorSelector.PROP_COLORCHANGE)) { - Object o = ((IStructuredSelection) fStylesViewer.getSelection()).getFirstElement(); - String namedStyle = o.toString(); - String prefString = getOverlayStore().getString(namedStyle); - String[] stylePrefs = ColorHelper.unpackStylePreferences(prefString); - if (stylePrefs != null) { - String oldValue = stylePrefs[0]; - // open color dialog to get new color - String newValue = ColorHelper.toRGBString(fForegroundColorEditor.getColorValue()); - - if (!newValue.equals(oldValue)) { - stylePrefs[0] = newValue; - String newPrefString = ColorHelper.packStylePreferences(stylePrefs); - getOverlayStore().setValue(namedStyle, newPrefString); - applyStyles(); - fText.redraw(); - } - } - } - } - }); - - fBackgroundColorEditor.addListener(new IPropertyChangeListener() { - public void propertyChange(PropertyChangeEvent event) { - if (event.getProperty().equals(ColorSelector.PROP_COLORCHANGE)) { - Object o = ((IStructuredSelection) fStylesViewer.getSelection()).getFirstElement(); - String namedStyle = o.toString(); - String prefString = getOverlayStore().getString(namedStyle); - String[] stylePrefs = ColorHelper.unpackStylePreferences(prefString); - if (stylePrefs != null) { - String oldValue = stylePrefs[1]; - // open color dialog to get new color - String newValue = ColorHelper.toRGBString(fBackgroundColorEditor.getColorValue()); - - if (!newValue.equals(oldValue)) { - stylePrefs[1] = newValue; - String newPrefString = ColorHelper.packStylePreferences(stylePrefs); - getOverlayStore().setValue(namedStyle, newPrefString); - applyStyles(); - fText.redraw(); - activate(namedStyle); - } - } - } - } - }); - - fBold.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - super.widgetSelected(e); - // get current (newly old) style - Object o = ((IStructuredSelection) fStylesViewer.getSelection()).getFirstElement(); - String namedStyle = o.toString(); - String prefString = getOverlayStore().getString(namedStyle); - String[] stylePrefs = ColorHelper.unpackStylePreferences(prefString); - if (stylePrefs != null) { - String oldValue = stylePrefs[2]; - String newValue = String.valueOf(fBold.getSelection()); - if (!newValue.equals(oldValue)) { - stylePrefs[2] = newValue; - String newPrefString = ColorHelper.packStylePreferences(stylePrefs); - getOverlayStore().setValue(namedStyle, newPrefString); - applyStyles(); - fText.redraw(); - } - } - } - }); - - fItalic.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - super.widgetSelected(e); - // get current (newly old) style - Object o = ((IStructuredSelection) fStylesViewer.getSelection()).getFirstElement(); - String namedStyle = o.toString(); - String prefString = getOverlayStore().getString(namedStyle); - String[] stylePrefs = ColorHelper.unpackStylePreferences(prefString); - if (stylePrefs != null) { - String oldValue = stylePrefs[3]; - String newValue = String.valueOf(fItalic.getSelection()); - if (!newValue.equals(oldValue)) { - stylePrefs[3] = newValue; - String newPrefString = ColorHelper.packStylePreferences(stylePrefs); - getOverlayStore().setValue(namedStyle, newPrefString); - applyStyles(); - fText.redraw(); - } - } - } - }); - - fStrike.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - super.widgetSelected(e); - // get current (newly old) style - Object o = ((IStructuredSelection) fStylesViewer.getSelection()).getFirstElement(); - String namedStyle = o.toString(); - String prefString = getOverlayStore().getString(namedStyle); - String[] stylePrefs = ColorHelper.unpackStylePreferences(prefString); - if (stylePrefs != null) { - String oldValue = stylePrefs[4]; - String newValue = String.valueOf(fStrike.getSelection()); - if (!newValue.equals(oldValue)) { - stylePrefs[4] = newValue; - String newPrefString = ColorHelper.packStylePreferences(stylePrefs); - getOverlayStore().setValue(namedStyle, newPrefString); - applyStyles(); - fText.redraw(); - } - } - } - }); - - fUnderline.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - super.widgetSelected(e); - // get current (newly old) style - Object o = ((IStructuredSelection) fStylesViewer.getSelection()).getFirstElement(); - String namedStyle = o.toString(); - String prefString = getOverlayStore().getString(namedStyle); - String[] stylePrefs = ColorHelper.unpackStylePreferences(prefString); - if (stylePrefs != null) { - String oldValue = stylePrefs[5]; - String newValue = String.valueOf(fUnderline.getSelection()); - if (!newValue.equals(oldValue)) { - stylePrefs[5] = newValue; - String newPrefString = ColorHelper.packStylePreferences(stylePrefs); - getOverlayStore().setValue(namedStyle, newPrefString); - applyStyles(); - fText.redraw(); - } - } - } - }); - - fClearStyle.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - if (fStylesViewer.getSelection().isEmpty()) - return; - String namedStyle = ((IStructuredSelection) fStylesViewer.getSelection()).getFirstElement().toString(); - getOverlayStore().setToDefault(namedStyle); - applyStyles(); - fText.redraw(); - activate(namedStyle); - } - }); - - return pageComponent; - } - - private Label createLabel(Composite parent, String text) { - Label label = new Label(parent, SWT.WRAP); - label.setText(text); - GridData data = new GridData(SWT.FILL, SWT.FILL, false, false); - label.setLayoutData(data); - label.setBackground(parent.getBackground()); - return label; - } - - // protected Label createDescriptionLabel(Composite parent) { - // return null; - // } - - /** - * Set up all the style preference keys in the overlay store - */ - private OverlayKey[] createOverlayStoreKeys() { - List overlayKeys = new ArrayList(); - - Iterator i = getStylePreferenceKeys().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; - } - - /** - * Creates the List viewer where we see the various syntax element display - * names--would it ever be a Tree like JDT's? - * - * @param parent - * @return - */ - private StructuredViewer createStylesViewer(Composite parent) { - StructuredViewer stylesViewer = new ListViewer(parent, SWT.SINGLE | SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER); - stylesViewer.setComparator(new ViewerComparator(Collator.getInstance())); - stylesViewer.setLabelProvider(new LabelProvider() { - public String getText(Object element) { - Object description = fStyleToDescriptionMap.get(element); - if (description != null) - return description.toString(); - return super.getText(element); - } - }); - stylesViewer.setContentProvider(new ITreeContentProvider() { - public void dispose() { - } - - public Object[] getChildren(Object parentElement) { - return getStylePreferenceKeys().toArray(); - } - - public Object[] getElements(Object inputElement) { - return getChildren(inputElement); - } - - public Object getParent(Object element) { - return getStylePreferenceKeys(); - } - - public boolean hasChildren(Object element) { - return false; - } - - public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { - } - }); - return stylesViewer; - } - - public void dispose() { - if (fOverlayStore != null) { - fOverlayStore.stop(); - } - super.dispose(); - } - - protected IPreferenceStore doGetPreferenceStore() { - return HTMLUIPlugin.getDefault().getPreferenceStore(); - } - - private TextAttribute getAttributeFor(String namedStyle) { - TextAttribute ta = new TextAttribute(fDefaultForeground, fDefaultBackground, SWT.NORMAL); - - if (namedStyle != null && fOverlayStore != null) { - // note: "namedStyle" *is* the preference key - String prefString = getOverlayStore().getString(namedStyle); - String[] stylePrefs = ColorHelper.unpackStylePreferences(prefString); - if (stylePrefs != null) { - RGB foreground = ColorHelper.toRGB(stylePrefs[0]); - RGB background = ColorHelper.toRGB(stylePrefs[1]); - - int fontModifier = SWT.NORMAL; - - if (stylePrefs.length > 2) { - boolean on = Boolean.valueOf(stylePrefs[2]).booleanValue(); - if (on) - fontModifier = fontModifier | SWT.BOLD; - } - if (stylePrefs.length > 3) { - boolean on = Boolean.valueOf(stylePrefs[3]).booleanValue(); - if (on) - fontModifier = fontModifier | SWT.ITALIC; - } - if (stylePrefs.length > 4) { - boolean on = Boolean.valueOf(stylePrefs[4]).booleanValue(); - if (on) - fontModifier = fontModifier | TextAttribute.STRIKETHROUGH; - } - if (stylePrefs.length > 5) { - boolean on = Boolean.valueOf(stylePrefs[5]).booleanValue(); - if (on) - fontModifier = fontModifier | TextAttribute.UNDERLINE; - } - - ta = new TextAttribute((foreground != null) ? EditorUtility.getColor(foreground) : null, (background != null) ? EditorUtility.getColor(background) : null, fontModifier); - } - } - return ta; - } - - private String getExampleText() { - return HTMLUIMessages.Sample_HTML_doc; - } - - private String getNamedStyleAtOffset(int offset) { - // ensure the offset is clean - if (offset >= fDocument.getLength()) - return getNamedStyleAtOffset(fDocument.getLength() - 1); - else if (offset < 0) - return getNamedStyleAtOffset(0); - IStructuredDocumentRegion documentRegion = fDocument.getFirstStructuredDocumentRegion(); - while (documentRegion != null && !documentRegion.containsOffset(offset)) { - documentRegion = documentRegion.getNext(); - } - if (documentRegion != null) { - // find the ITextRegion's Context at this offset - ITextRegion interest = documentRegion.getRegionAtCharacterOffset(offset); - if (interest == null) - return null; - if (offset > documentRegion.getTextEndOffset(interest)) - return null; - String regionContext = interest.getType(); - if (regionContext == null) - return null; - // find the named style (internal/selectable name) for that - // context - String namedStyle = (String) fContextToStyleMap.get(regionContext); - if (namedStyle != null) { - return namedStyle; - } - } - return null; - } - - private OverlayPreferenceStore getOverlayStore() { - return fOverlayStore; - } - - private Collection getStylePreferenceKeys() { - if (fStylePreferenceKeys == null) { - List styles = new ArrayList(); - styles.add(IStyleConstantsXML.ENTITY_REFERENCE); - styles.add(IStyleConstantsXML.TAG_BORDER); - styles.add(IStyleConstantsXML.TAG_NAME); - styles.add(IStyleConstantsXML.TAG_ATTRIBUTE_NAME); - styles.add(IStyleConstantsXML.TAG_ATTRIBUTE_VALUE); - styles.add(IStyleConstantsXML.COMMENT_BORDER); - styles.add(IStyleConstantsXML.COMMENT_TEXT); - styles.add(IStyleConstantsXML.DECL_BORDER); - styles.add(IStyleConstantsXML.XML_CONTENT); - styles.add(IStyleConstantsXML.DOCTYPE_NAME); - styles.add(IStyleConstantsXML.DOCTYPE_EXTERNAL_ID); - styles.add(IStyleConstantsXML.DOCTYPE_EXTERNAL_ID_PUBREF); - styles.add(IStyleConstantsXML.DOCTYPE_EXTERNAL_ID_SYSREF); -// styles.add(IStyleConstantsXML.CDATA_BORDER); -// styles.add(IStyleConstantsXML.CDATA_TEXT); -// styles.add(IStyleConstantsXML.PI_BORDER); -// styles.add(IStyleConstantsXML.PI_CONTENT); - fStylePreferenceKeys = styles; - } - return fStylePreferenceKeys; - } - - private KeyListener getTextKeyListener() { - return new KeyListener() { - public void keyPressed(KeyEvent e) { - if (e.widget instanceof StyledText) { - int x = ((StyledText) e.widget).getCaretOffset(); - selectColorAtOffset(x); - } - } - - public void keyReleased(KeyEvent e) { - if (e.widget instanceof StyledText) { - int x = ((StyledText) e.widget).getCaretOffset(); - selectColorAtOffset(x); - } - } - }; - } - - private MouseListener getTextMouseListener() { - return new MouseListener() { - public void mouseDoubleClick(MouseEvent e) { - } - - public void mouseDown(MouseEvent e) { - } - - public void mouseUp(MouseEvent e) { - if (e.widget instanceof StyledText) { - int x = ((StyledText) e.widget).getCaretOffset(); - selectColorAtOffset(x); - } - } - }; - } - - private SelectionListener getTextSelectionListener() { - return new SelectionListener() { - public void widgetDefaultSelected(SelectionEvent e) { - selectColorAtOffset(e.x); - if (e.widget instanceof StyledText) { - ((StyledText) e.widget).setSelection(e.x); - } - } - - public void widgetSelected(SelectionEvent e) { - selectColorAtOffset(e.x); - if (e.widget instanceof StyledText) { - ((StyledText) e.widget).setSelection(e.x); - } - } - }; - } - - private TraverseListener getTraverseListener() { - return new TraverseListener() { - /** - * @see org.eclipse.swt.events.TraverseListener#keyTraversed(TraverseEvent) - */ - public void keyTraversed(TraverseEvent e) { - if (e.widget instanceof StyledText) { - if ((e.detail == SWT.TRAVERSE_TAB_NEXT) || (e.detail == SWT.TRAVERSE_TAB_PREVIOUS)) - e.doit = true; - } - } - }; - } - - public void init(IWorkbench workbench) { - setDescription(SSEUIMessages.SyntaxColoring_Description); - - fStyleToDescriptionMap = new HashMap(); - fContextToStyleMap = new HashMap(); - - initStyleToDescriptionMap(); - initRegionContextToStyleMap(); - - fOverlayStore = new OverlayPreferenceStore(getPreferenceStore(), createOverlayStoreKeys()); - fOverlayStore.load(); - fOverlayStore.start(); - } - - private void initRegionContextToStyleMap() { - fContextToStyleMap.put(DOMRegionContext.XML_COMMENT_OPEN, IStyleConstantsXML.COMMENT_BORDER); - fContextToStyleMap.put(DOMRegionContext.XML_COMMENT_TEXT, IStyleConstantsXML.COMMENT_TEXT); - fContextToStyleMap.put(DOMRegionContext.XML_COMMENT_CLOSE, IStyleConstantsXML.COMMENT_BORDER); - - fContextToStyleMap.put(DOMRegionContext.XML_TAG_OPEN, IStyleConstantsXML.TAG_BORDER); - fContextToStyleMap.put(DOMRegionContext.XML_END_TAG_OPEN, IStyleConstantsXML.TAG_BORDER); - fContextToStyleMap.put(DOMRegionContext.XML_TAG_NAME, IStyleConstantsXML.TAG_NAME); - fContextToStyleMap.put(DOMRegionContext.XML_TAG_ATTRIBUTE_NAME, IStyleConstantsXML.TAG_ATTRIBUTE_NAME); - fContextToStyleMap.put(DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE, IStyleConstantsXML.TAG_ATTRIBUTE_VALUE); - fContextToStyleMap.put(DOMRegionContext.XML_TAG_CLOSE, IStyleConstantsXML.TAG_BORDER); - fContextToStyleMap.put(DOMRegionContext.XML_EMPTY_TAG_CLOSE, IStyleConstantsXML.TAG_BORDER); - - fContextToStyleMap.put(DOMRegionContext.XML_DECLARATION_OPEN, IStyleConstantsXML.DECL_BORDER); - fContextToStyleMap.put(DOMRegionContext.XML_DECLARATION_CLOSE, IStyleConstantsXML.DECL_BORDER); - fContextToStyleMap.put(DOMRegionContext.XML_ELEMENT_DECLARATION, IStyleConstantsXML.DECL_BORDER); - fContextToStyleMap.put(DOMRegionContext.XML_ELEMENT_DECL_CLOSE, IStyleConstantsXML.DECL_BORDER); - - fContextToStyleMap.put(DOMRegionContext.XML_CHAR_REFERENCE, IStyleConstantsXML.ENTITY_REFERENCE); - fContextToStyleMap.put(DOMRegionContext.XML_ENTITY_REFERENCE, IStyleConstantsXML.ENTITY_REFERENCE); - fContextToStyleMap.put(DOMRegionContext.XML_PE_REFERENCE, IStyleConstantsXML.ENTITY_REFERENCE); - - fContextToStyleMap.put(DOMRegionContext.XML_CONTENT, IStyleConstantsXML.XML_CONTENT); - - fContextToStyleMap.put(DOMRegionContext.XML_ELEMENT_DECL_NAME, IStyleConstantsXML.DOCTYPE_NAME); - fContextToStyleMap.put(DOMRegionContext.XML_DOCTYPE_DECLARATION, IStyleConstantsXML.TAG_NAME); - fContextToStyleMap.put(DOMRegionContext.XML_DOCTYPE_DECLARATION_CLOSE, IStyleConstantsXML.DECL_BORDER); - - fContextToStyleMap.put(DOMRegionContext.XML_DOCTYPE_NAME, IStyleConstantsXML.DOCTYPE_NAME); - fContextToStyleMap.put(DOMRegionContext.XML_DOCTYPE_EXTERNAL_ID_PUBLIC, IStyleConstantsXML.DOCTYPE_EXTERNAL_ID); - fContextToStyleMap.put(DOMRegionContext.XML_DOCTYPE_EXTERNAL_ID_PUBREF, IStyleConstantsXML.DOCTYPE_EXTERNAL_ID_PUBREF); - fContextToStyleMap.put(DOMRegionContext.XML_DOCTYPE_EXTERNAL_ID_SYSTEM, IStyleConstantsXML.DOCTYPE_EXTERNAL_ID); - fContextToStyleMap.put(DOMRegionContext.XML_DOCTYPE_EXTERNAL_ID_SYSREF, IStyleConstantsXML.DOCTYPE_EXTERNAL_ID_SYSREF); - -// fContextToStyleMap.put(DOMRegionContext.XML_PI_OPEN, IStyleConstantsXML.PI_BORDER); -// fContextToStyleMap.put(DOMRegionContext.XML_PI_CONTENT, IStyleConstantsXML.PI_CONTENT); -// fContextToStyleMap.put(DOMRegionContext.XML_CDATA_OPEN, IStyleConstantsXML.CDATA_BORDER); -// fContextToStyleMap.put(DOMRegionContext.XML_CDATA_TEXT, IStyleConstantsXML.CDATA_TEXT); -// fContextToStyleMap.put(DOMRegionContext.XML_CDATA_CLOSE, IStyleConstantsXML.CDATA_BORDER); - } - - private void initStyleToDescriptionMap() { - fStyleToDescriptionMap.put(IStyleConstantsXML.COMMENT_BORDER, XMLUIMessages.Comment_Delimiters_UI_); // = - fStyleToDescriptionMap.put(IStyleConstantsXML.COMMENT_TEXT, XMLUIMessages.Comment_Content_UI_); // = - fStyleToDescriptionMap.put(IStyleConstantsXML.TAG_BORDER, XMLUIMessages.Tag_Delimiters_UI_); // = - fStyleToDescriptionMap.put(IStyleConstantsXML.TAG_NAME, XMLUIMessages.Tag_Names_UI_); // = - fStyleToDescriptionMap.put(IStyleConstantsXML.TAG_ATTRIBUTE_NAME, XMLUIMessages.Attribute_Names_UI_); // = - fStyleToDescriptionMap.put(IStyleConstantsXML.TAG_ATTRIBUTE_VALUE, XMLUIMessages.Attribute_Values_UI_); // = - fStyleToDescriptionMap.put(IStyleConstantsXML.DECL_BORDER, XMLUIMessages.Declaration_Delimiters_UI_); // = - fStyleToDescriptionMap.put(IStyleConstantsXML.XML_CONTENT, XMLUIMessages.Content_UI_); // = - fStyleToDescriptionMap.put(IStyleConstantsXML.ENTITY_REFERENCE, XMLUIMessages.Entity_Reference_UI_); //$NON-NLS-1$ = "Entity References" - fStyleToDescriptionMap.put(IStyleConstantsXML.DOCTYPE_NAME, XMLUIMessages.DOCTYPE_Name_UI_); // = - fStyleToDescriptionMap.put(IStyleConstantsXML.DOCTYPE_EXTERNAL_ID, XMLUIMessages.DOCTYPE_SYSTEM_PUBLIC_Keyw_UI_); // = - fStyleToDescriptionMap.put(IStyleConstantsXML.DOCTYPE_EXTERNAL_ID_PUBREF, XMLUIMessages.DOCTYPE_Public_Reference_UI_); // = - fStyleToDescriptionMap.put(IStyleConstantsXML.DOCTYPE_EXTERNAL_ID_SYSREF, XMLUIMessages.DOCTYPE_System_Reference_UI_); // = -// fStyleToDescriptionMap.put(IStyleConstantsXML.PI_BORDER, XMLUIMessages.Processing_Instruction_Del_UI_); -// fStyleToDescriptionMap.put(IStyleConstantsXML.PI_CONTENT, XMLUIMessages.Processing_Instruction_Con_UI__UI_); -// fStyleToDescriptionMap.put(IStyleConstantsXML.CDATA_BORDER, XMLUIMessages.CDATA_Delimiters_UI_); -// fStyleToDescriptionMap.put(IStyleConstantsXML.CDATA_TEXT, XMLUIMessages.CDATA_Content_UI_); -} - - protected void performDefaults() { - super.performDefaults(); - getOverlayStore().loadDefaults(); - applyStyles(); - fStylesViewer.setSelection(StructuredSelection.EMPTY); - activate(null); - fText.redraw(); - } - - public boolean performOk() { - getOverlayStore().propagate(); - - HTMLUIPlugin.getDefault().savePluginPreferences(); - SSEUIPlugin.getDefault().savePluginPreferences(); - return true; - } - - private void selectColorAtOffset(int offset) { - String namedStyle = getNamedStyleAtOffset(offset); - if (namedStyle != null) { - fStylesViewer.setSelection(new StructuredSelection(namedStyle)); - fStylesViewer.reveal(namedStyle); - } - else { - fStylesViewer.setSelection(StructuredSelection.EMPTY); - } - activate(namedStyle); - } - - /** - * Specifically set the reporting name of a control for accessibility - */ - private void setAccessible(Control control, String name) { - if (control == null) - return; - final String n = name; - control.getAccessible().addAccessibleListener(new AccessibleAdapter() { - public void getName(AccessibleEvent e) { - if (e.childID == ACC.CHILDID_SELF) - e.result = n; - } - }); - } -} 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 60d0c85e16..0000000000 --- a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/preferences/ui/HTMLTemplatePreferencePage.java +++ /dev/null @@ -1,157 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.html.ui.internal.preferences.ui; - -import org.eclipse.jface.resource.JFaceResources; -import org.eclipse.jface.text.IDocument; -import org.eclipse.jface.text.contentassist.ContentAssistant; -import org.eclipse.jface.text.contentassist.IContentAssistant; -import org.eclipse.jface.text.source.ISourceViewer; -import org.eclipse.jface.text.source.SourceViewer; -import org.eclipse.jface.text.source.SourceViewerConfiguration; -import org.eclipse.jface.text.templates.ContextTypeRegistry; -import org.eclipse.jface.text.templates.Template; -import org.eclipse.jface.window.Window; -import org.eclipse.swt.SWT; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.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 { - class HTMLEditTemplateDialog extends EditTemplateDialog { - public HTMLEditTemplateDialog(Shell parent, Template template, boolean edit, boolean isNameModifiable, ContextTypeRegistry registry) { - super(parent, template, edit, isNameModifiable, registry); - } - - protected 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); - } - - public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) { - ContentAssistant assistant = new ContentAssistant(); - assistant.enableAutoActivation(true); - assistant.enableAutoInsert(true); - assistant.setContentAssistProcessor(getTemplateProcessor(), IDocument.DEFAULT_CONTENT_TYPE); - return assistant; - } - }; - return doCreateViewer(parent, sourceViewerConfiguration); - } - } - - 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) { - 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); - } - }; - return doCreateViewer(parent, sourceViewerConfiguration); - } - - SourceViewer doCreateViewer(Composite parent, SourceViewerConfiguration viewerConfiguration) { - SourceViewer viewer = null; - String contentTypeID = ContentTypeIdForHTML.ContentTypeID_HTML; - 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(viewerConfiguration); - viewer.setDocument(document); - return viewer; - } - - /** - * Creates the edit dialog. Subclasses may override this method to provide - * a custom dialog. - * - * @param template - * the template being edited - * @param edit - * whether the dialog should be editable - * @param isNameModifiable - * whether the template name may be modified - * @return the created or modified template, or <code>null</code> if the - * edition failed - * @since 3.1 - */ - protected Template editTemplate(Template template, boolean edit, boolean isNameModifiable) { - EditTemplateDialog dialog = new HTMLEditTemplateDialog(getShell(), template, edit, isNameModifiable, getContextTypeRegistry()); - if (dialog.open() == Window.OK) { - return dialog.getTemplate(); - } - return null; - } -} 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 86752b0c6e..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, 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - * Tom Turrell-Croft, left@ultrasis.com - [174307] Enable folding for div tags in JSP and HTML files - *******************************************************************************/ -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, and div 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) || HTML40Namespace.ElementName.DIV.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 c1ccd2c371..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, 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.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 0018554d31..0000000000 --- a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/projection/StructuredTextFoldingProviderHTML.java +++ /dev/null @@ -1,350 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005, 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.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; - } - - long start = System.currentTimeMillis(); - // 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); - } - try { - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=198304 - // disable redraw while adding all adapters - fViewer.setRedraw(false); - addAllAdapters(); - } - finally { - fViewer.setRedraw(true); - } - } - fProjectionNeedsToBeEnabled = false; - - if (debugProjectionPerf) { - long end = System.currentTimeMillis(); - System.out.println("StructuredTextFoldingProviderHTML.initialize: " + (end - start)); //$NON-NLS-1$ - } - } - - /** - * 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 145ab9afef..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, 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.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 - } - -} 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 c20efa168c..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, 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.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 81f765c1a4..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, 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.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 943eec5a25..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, 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.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(); - } -} 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 5f859c7c56..0000000000 --- a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/taginfo/HTMLInformationProvider.java +++ /dev/null @@ -1,65 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.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) - * - * @deprecated StructuredTextViewerConfiguration creates the appropriate - * information provider - */ -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); - } -} 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 a99186ab1a..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, 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.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(); - } - -} 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 2a18055243..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, 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.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 d738264604..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, 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; - -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)); - } -} 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 1b203e3ac9..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, 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; - -/** - * 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/FacetModuleCoreSupport.java b/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/wizard/FacetModuleCoreSupport.java deleted file mode 100644 index 8d11c7bfe5..0000000000 --- a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/wizard/FacetModuleCoreSupport.java +++ /dev/null @@ -1,61 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.html.ui.internal.wizard; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.IPath; - -/** - * This class encapsulates any used Module Core and Facets APIs along with - * fallbacks for use on non-compliant projects and when those services are not - * available at runtime. - * - * Because ModuleCore API calls can result in locks needing to be acquired, - * none of these methods should be called while other thread locks have - * already been acquired. - */ -final class FacetModuleCoreSupport { - static final boolean _dump_NCDFE = false; - - /** - * @param project - * @return the IPath to the "root" of the web contents - */ - public static IPath getWebContentRootPath(IProject project) { - IPath path = null; - try { - path = FacetModuleCoreSupportDelegate.getWebContentRootPath(project); - } - catch (NoClassDefFoundError e) { - if (_dump_NCDFE) - e.printStackTrace(); - } - return path; - } - - /** - * @param project - * @return - * @throws org.eclipse.core.runtime.CoreException - */ - public static boolean isWebProject(IProject project) { - try { - return FacetModuleCoreSupportDelegate.isWebProject(project); - } - catch (NoClassDefFoundError e) { - if (_dump_NCDFE) - e.printStackTrace(); - } - return true; - } - - -} diff --git a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/wizard/FacetModuleCoreSupportDelegate.java b/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/wizard/FacetModuleCoreSupportDelegate.java deleted file mode 100644 index ab5484edbb..0000000000 --- a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/wizard/FacetModuleCoreSupportDelegate.java +++ /dev/null @@ -1,84 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse License v1.0 - * which accompanies this 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 org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; -import org.eclipse.wst.common.componentcore.ComponentCore; -import org.eclipse.wst.common.componentcore.ModuleCoreNature; -import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; -import org.eclipse.wst.common.project.facet.core.IFacetedProject; -import org.eclipse.wst.common.project.facet.core.IProjectFacet; -import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager; -import org.eclipse.wst.html.ui.internal.Logger; - -/** - * Wrapper class for all Facet-related calls. If the Facet or ModuleCore - * bundles are not available, this class will not load, or if it does, its - * methods will cause NoClassDefFoundErrors. This allows us to - * compartmentalize the dependencies. - * - */ -final class FacetModuleCoreSupportDelegate { - /** - * Copied to avoid unneeded extra dependency (plus it's unclear why the - * value is in that plug-in). - * - * @see org.eclipse.wst.common.componentcore.internal.util.IModuleConstants.JST_WEB_MODULE - */ - private final static String JST_WEB_MODULE = "jst.web"; //$NON-NLS-1$ - - private final static String WST_WEB_MODULE = "wst.web"; //$NON-NLS-1$ - - /** - * @param project - * @return the IPath to the "root" of the web contents - */ - static IPath getWebContentRootPath(IProject project) { - if (!ModuleCoreNature.isFlexibleProject(project)) - return project.getFullPath(); - - IPath path = null; - IVirtualComponent component = ComponentCore.createComponent(project); - if (component != null && component.exists()) { - path = component.getRootFolder().getWorkspaceRelativePath(); - } - else { - path = project.getFullPath(); - } - return path; - } - - /** - * @param project - * @return - * @throws CoreException - */ - static boolean isWebProject(IProject project) { - boolean is = false; - try { - IFacetedProject faceted = ProjectFacetsManager.create(project); - if (ProjectFacetsManager.isProjectFacetDefined(JST_WEB_MODULE)) { - IProjectFacet facet = ProjectFacetsManager.getProjectFacet(JST_WEB_MODULE); - is = is || (faceted != null && faceted.hasProjectFacet(facet)); - } - if (ProjectFacetsManager.isProjectFacetDefined(WST_WEB_MODULE)) { - IProjectFacet facet = ProjectFacetsManager.getProjectFacet(WST_WEB_MODULE); - is = is || (faceted != null && faceted.hasProjectFacet(facet)); - } - } - catch (CoreException e) { - Logger.logException(e); - } - return is; - } -} 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 110d80015a..0000000000 --- a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/wizard/NewHTMLFileWizardPage.java +++ /dev/null @@ -1,224 +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.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.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; - -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) { - return FacetModuleCoreSupport.isWebProject(project); - } - - /** - * 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) { - return FacetModuleCoreSupport.getWebContentRootPath(project); - } -} 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 f55aaa4768..0000000000 --- a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/wizard/NewHTMLTemplatesWizardPage.java +++ /dev/null @@ -1,505 +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 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 |