Skip to main content

This CGIT instance is deprecated, and repositories have been moved to Gitlab or Github. See the repository descriptions for specific locations.

summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'bundles/org.eclipse.wst.css.ui/src/org')
-rw-r--r--bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/ActionContributorCSS.java118
-rw-r--r--bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/CSSEditorPlugin.java134
-rw-r--r--bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/StructuredTextEditorCSS.java60
-rw-r--r--bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/StructuredTextViewerConfigurationCSS.java125
-rw-r--r--bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/autoedit/StructuredAutoEditStrategyCSS.java501
-rw-r--r--bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/contentassist/CSSCACandidate.java102
-rw-r--r--bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/contentassist/CSSContentAssistContext.java454
-rw-r--r--bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/contentassist/CSSContentAssistProcessor.java273
-rw-r--r--bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/contentassist/CSSProposalArranger.java169
-rw-r--r--bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/contentassist/CSSProposalGenerator.java209
-rw-r--r--bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/contentassist/CSSProposalGeneratorForAtmarkRule.java293
-rw-r--r--bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/contentassist/CSSProposalGeneratorForDeclarationName.java171
-rw-r--r--bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/contentassist/CSSProposalGeneratorForDeclarationValue.java370
-rw-r--r--bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/contentassist/CSSProposalGeneratorForHTMLTag.java157
-rw-r--r--bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/contentassist/CSSProposalGeneratorForPseudoSelector.java157
-rw-r--r--bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/contentassist/HTML40Namespace.java889
-rw-r--r--bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/contentproperties/ContentSettingsRegistry.java34
-rw-r--r--bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/contentproperties/ui/CSSContentSettingsPropertyPage.java101
-rw-r--r--bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/edit/ui/CleanupActionCSS.java40
-rw-r--r--bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/edit/ui/CleanupDialogCSS.java292
-rw-r--r--bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/image/CSSImageHelper.java124
-rw-r--r--bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/image/CSSImageType.java235
-rw-r--r--bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/internal/Logger.java154
-rw-r--r--bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/internal/editor/CSSEditorPluginImages.java51
-rw-r--r--bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/internal/editor/IHelpContextIds.java42
-rw-r--r--bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/internal/nls/ResourceHandler.java66
-rw-r--r--bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/internal/selection/StructureSelectCSSAction.java53
-rw-r--r--bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/internal/selection/StructureSelectEnclosingCSSAction.java47
-rw-r--r--bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/internal/selection/StructureSelectNextCSSAction.java60
-rw-r--r--bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/internal/selection/StructureSelectPreviousCSSAction.java55
-rw-r--r--bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/preferences/CSSPreferenceManager.java185
-rw-r--r--bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/preferences/ui/CSSColorManager.java228
-rw-r--r--bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/preferences/ui/CSSColorPage.java236
-rw-r--r--bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/preferences/ui/CSSFilesPreferencePage.java59
-rw-r--r--bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/preferences/ui/CSSSourcePreferencePage.java247
-rw-r--r--bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/registry/AdapterFactoryProviderCSS.java55
-rw-r--r--bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/style/CSSTextColors.java143
-rw-r--r--bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/style/IStyleConstantsCSS.java31
-rw-r--r--bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/style/LineStyleProviderForCSS.java202
-rw-r--r--bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/style/LineStyleProviderForEmbeddedCSS.java104
-rw-r--r--bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/taginfo/CSSBestMatchHoverProcessor.java33
-rw-r--r--bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/text/CSSDocumentRegionEdgeMatcher.java89
-rw-r--r--bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/views/contentoutline/CSSContentOutlineConfiguration.java118
-rw-r--r--bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/views/contentoutline/CSSNodeAdapter.java319
-rw-r--r--bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/views/contentoutline/JFaceNodeAdapterFactoryCSS.java42
-rw-r--r--bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/views/contentoutline/JFaceNodeContentProviderCSS.java263
-rw-r--r--bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/views/contentoutline/JFaceNodeLabelProviderCSS.java231
-rw-r--r--bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/views/contentoutline/SortAction.java66
-rw-r--r--bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/views/properties/CSSPropertySheetConfiguration.java53
-rw-r--r--bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/views/properties/CSSPropertySource.java350
-rw-r--r--bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/views/properties/CSSPropertySourceAdapterFactory.java45
-rw-r--r--bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/views/properties/CSSTextPropertyDescriptor.java114
52 files changed, 8749 insertions, 0 deletions
diff --git a/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/ActionContributorCSS.java b/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/ActionContributorCSS.java
new file mode 100644
index 0000000000..3f6861c093
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/ActionContributorCSS.java
@@ -0,0 +1,118 @@
+/*******************************************************************************
+ * Copyright (c) 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.ui;
+
+import java.util.ResourceBundle;
+
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IWorkbenchActionConstants;
+import org.eclipse.ui.texteditor.ITextEditor;
+import org.eclipse.ui.texteditor.ITextEditorActionDefinitionIds;
+import org.eclipse.ui.texteditor.RetargetTextEditorAction;
+import org.eclipse.wst.sse.ui.edit.util.ActionContributor;
+import org.eclipse.wst.sse.ui.edit.util.ActionDefinitionIds;
+import org.eclipse.wst.sse.ui.edit.util.StructuredTextEditorActionConstants;
+import org.eclipse.wst.sse.ui.nls.ResourceHandler;
+
+/**
+ * ActionContributorCSS
+ *
+ * This class should not be used inside multi page editor's
+ * ActionBarContributor, since cascaded init() call from the
+ * ActionBarContributor will causes exception and it leads to lose whole
+ * toolbars.
+ *
+ * Instead, use SourcePageActionContributor for source page contributor of
+ * multi page editor.
+ *
+ * Note that this class is still valid for single page editor.
+ */
+public class ActionContributorCSS extends ActionContributor {
+ private static final String[] EDITOR_IDS = {"org.eclipse.wst.css.ui.StructuredTextEditorCSS", "org.eclipse.wst.sse.ui.StructuredTextEditor"}; //$NON-NLS-1$ //$NON-NLS-2$
+
+ protected RetargetTextEditorAction fContentAssist = null;
+ protected RetargetTextEditorAction fCleanupDocument = null;
+ protected MenuManager fFormatMenu = null;
+ protected RetargetTextEditorAction fFormatDocument = null;
+ protected RetargetTextEditorAction fFormatActiveElements = null;
+
+ public ActionContributorCSS() {
+ super();
+
+ ResourceBundle resourceBundle = ResourceHandler.getResourceBundle();
+
+ // edit commands
+ fContentAssist = new RetargetTextEditorAction(resourceBundle, ""); //$NON-NLS-1$
+ fContentAssist.setActionDefinitionId(ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS);
+
+ // source commands
+ fCleanupDocument = new RetargetTextEditorAction(resourceBundle, ""); //$NON-NLS-1$
+ fCleanupDocument.setActionDefinitionId(ActionDefinitionIds.CLEANUP_DOCUMENT);
+
+ fFormatDocument = new RetargetTextEditorAction(resourceBundle, ""); //$NON-NLS-1$
+ fFormatDocument.setActionDefinitionId(ActionDefinitionIds.FORMAT_DOCUMENT);
+
+ fFormatActiveElements = new RetargetTextEditorAction(resourceBundle, ""); //$NON-NLS-1$
+ fFormatActiveElements.setActionDefinitionId(ActionDefinitionIds.FORMAT_ACTIVE_ELEMENTS);
+
+ fFormatMenu = new MenuManager(ResourceHandler.getString("FormatMenu.label")); //$NON-NLS-1$
+ fFormatMenu.add(fFormatDocument);
+ fFormatMenu.add(fFormatActiveElements);
+ }
+
+ protected String[] getExtensionIDs() {
+ return EDITOR_IDS;
+ }
+
+ protected void addToMenu(IMenuManager menu) {
+ // edit commands
+ IMenuManager editMenu = menu.findMenuUsingPath(IWorkbenchActionConstants.M_EDIT);
+ if (editMenu != null) {
+ editMenu.add(fCommandsSeparator);
+ editMenu.add(fToggleInsertModeAction);
+ editMenu.add(fCommandsSeparator);
+ editMenu.add(fExpandSelectionToMenu);
+ editMenu.add(fCommandsSeparator);
+ editMenu.add(fContentAssist);
+ editMenu.add(fMenuAdditionsGroupMarker);
+ }
+
+ // source commands
+ String sourceMenuLabel = ResourceHandler.getString("SourceMenu.label"); //$NON-NLS-1$
+ String sourceMenuId = "sourceMenuId"; // This is just a menu id. No
+ // need to translate.
+ // //$NON-NLS-1$
+ IMenuManager sourceMenu = new MenuManager(sourceMenuLabel, sourceMenuId);
+ menu.insertAfter(IWorkbenchActionConstants.M_EDIT, sourceMenu);
+ if (sourceMenu != null) {
+ sourceMenu.add(fCommandsSeparator);
+ sourceMenu.add(fShiftRight);
+ sourceMenu.add(fShiftLeft);
+ sourceMenu.add(fCleanupDocument);
+ sourceMenu.add(fFormatMenu);
+ sourceMenu.add(fCommandsSeparator);
+ }
+ }
+
+ public void setActiveEditor(IEditorPart activeEditor) {
+ super.setActiveEditor(activeEditor);
+
+ ITextEditor textEditor = getTextEditor(activeEditor);
+
+ fContentAssist.setAction(getAction(textEditor, StructuredTextEditorActionConstants.ACTION_NAME_CONTENTASSIST_PROPOSALS));
+
+ fCleanupDocument.setAction(getAction(textEditor, StructuredTextEditorActionConstants.ACTION_NAME_CLEANUP_DOCUMENT));
+ fFormatDocument.setAction(getAction(textEditor, StructuredTextEditorActionConstants.ACTION_NAME_FORMAT_DOCUMENT));
+ fFormatActiveElements.setAction(getAction(textEditor, StructuredTextEditorActionConstants.ACTION_NAME_FORMAT_ACTIVE_ELEMENTS));
+ }
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/CSSEditorPlugin.java b/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/CSSEditorPlugin.java
new file mode 100644
index 0000000000..fba4083373
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/CSSEditorPlugin.java
@@ -0,0 +1,134 @@
+/*******************************************************************************
+ * Copyright (c) 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.ui;
+
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IPluginDescriptor;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.eclipse.wst.common.encoding.content.IContentTypeIdentifier;
+import org.eclipse.wst.css.ui.style.IStyleConstantsCSS;
+import org.eclipse.wst.sse.ui.EditorPlugin;
+import org.eclipse.wst.sse.ui.preferences.PreferenceKeyGenerator;
+import org.eclipse.wst.sse.ui.preferences.ui.ColorHelper;
+
+
+/**
+ * The main plugin class to be used in the desktop.
+ */
+public class CSSEditorPlugin extends AbstractUIPlugin {
+ public final static String ID = "org.eclipse.wst.css.ui"; //$NON-NLS-1$
+ //The shared instance.
+ private static CSSEditorPlugin plugin;
+ //Resource bundle.
+ private ResourceBundle resourceBundle;
+
+ /**
+ * The constructor.
+ */
+ public CSSEditorPlugin(IPluginDescriptor descriptor) {
+ super(descriptor);
+ plugin = this;
+ try {
+ resourceBundle = ResourceBundle.getBundle("org.eclipse.wst.css.ui.CSSEditorPluginResources"); //$NON-NLS-1$
+ } catch (MissingResourceException x) {
+ resourceBundle = null;
+ }
+ // reference the preference store so
+ // initializeDefaultPreferences(IPreferenceStore preferenceStore) is
+ // called
+ getPreferenceStore();
+ }
+
+ /**
+ * Returns the shared instance.
+ */
+ public static CSSEditorPlugin getDefault() {
+ return plugin;
+ }
+
+ /**
+ * Returns the workspace instance.
+ */
+ public static IWorkspace getWorkspace() {
+ return ResourcesPlugin.getWorkspace();
+ }
+
+ /**
+ * Returns the string from the plugin's resource bundle, or 'key' if not
+ * found.
+ */
+ public static String getResourceString(String key) {
+ ResourceBundle bundle = CSSEditorPlugin.getDefault().getResourceBundle();
+ try {
+ return bundle.getString(key);
+ } catch (MissingResourceException e) {
+ return key;
+ }
+ }
+
+ /**
+ * Returns the plugin's resource bundle,
+ */
+ public ResourceBundle getResourceBundle() {
+ return resourceBundle;
+ }
+
+ protected void initializeDefaultPreferences(IPreferenceStore store) {
+
+ // ignore this preference store
+ // use EditorPlugin preference store
+ IPreferenceStore editorStore = ((AbstractUIPlugin) Platform.getPlugin(EditorPlugin.ID)).getPreferenceStore();
+ EditorPlugin.initializeDefaultEditorPreferences(editorStore);
+
+ initializeDefaultCSSPreferences(editorStore);
+ }
+
+ private void initializeDefaultCSSPreferences(IPreferenceStore store) {
+ String ctId = IContentTypeIdentifier.ContentTypeID_CSS;
+
+ // CSS Style Preferences
+ String NOBACKGROUNDBOLD = " | null | false"; //$NON-NLS-1$
+ String styleValue = "null" + NOBACKGROUNDBOLD; //$NON-NLS-1$
+ store.setDefault(PreferenceKeyGenerator.generateKey(IStyleConstantsCSS.NORMAL, ctId), styleValue);
+
+ styleValue = ColorHelper.getColorString(63, 127, 127) + NOBACKGROUNDBOLD;
+ store.setDefault(PreferenceKeyGenerator.generateKey(IStyleConstantsCSS.ATMARK_RULE, ctId), styleValue);
+ store.setDefault(PreferenceKeyGenerator.generateKey(IStyleConstantsCSS.SELECTOR, ctId), styleValue);
+
+ styleValue = ColorHelper.getColorString(42, 0, 225) + NOBACKGROUNDBOLD;
+ store.setDefault(PreferenceKeyGenerator.generateKey(IStyleConstantsCSS.MEDIA, ctId), styleValue);
+
+ styleValue = ColorHelper.getColorString(63, 95, 191) + NOBACKGROUNDBOLD;
+ store.setDefault(PreferenceKeyGenerator.generateKey(IStyleConstantsCSS.COMMENT, ctId), styleValue);
+
+ styleValue = ColorHelper.getColorString(127, 0, 127) + NOBACKGROUNDBOLD;
+ store.setDefault(PreferenceKeyGenerator.generateKey(IStyleConstantsCSS.PROPERTY_NAME, ctId), styleValue);
+
+ styleValue = ColorHelper.getColorString(42, 0, 225) + NOBACKGROUNDBOLD;
+ store.setDefault(PreferenceKeyGenerator.generateKey(IStyleConstantsCSS.PROPERTY_VALUE, ctId), styleValue);
+ store.setDefault(PreferenceKeyGenerator.generateKey(IStyleConstantsCSS.URI, ctId), styleValue);
+ store.setDefault(PreferenceKeyGenerator.generateKey(IStyleConstantsCSS.STRING, ctId), styleValue);
+
+ styleValue = "null" + NOBACKGROUNDBOLD; //$NON-NLS-1$
+ store.setDefault(PreferenceKeyGenerator.generateKey(IStyleConstantsCSS.COLON, ctId), styleValue);
+ store.setDefault(PreferenceKeyGenerator.generateKey(IStyleConstantsCSS.SEMI_COLON, ctId), styleValue);
+ store.setDefault(PreferenceKeyGenerator.generateKey(IStyleConstantsCSS.CURLY_BRACE, ctId), styleValue);
+
+ styleValue = ColorHelper.getColorString(191, 63, 63) + NOBACKGROUNDBOLD;
+ store.setDefault(PreferenceKeyGenerator.generateKey(IStyleConstantsCSS.ERROR, ctId), styleValue);
+ }
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/StructuredTextEditorCSS.java b/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/StructuredTextEditorCSS.java
new file mode 100644
index 0000000000..a929d5376d
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/StructuredTextEditorCSS.java
@@ -0,0 +1,60 @@
+/*****************************************************************************
+ * Copyright (c) 2001, 2004 IBM Corporation and others. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this
+ * distribution, and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors: IBM Corporation - initial API and implementation
+ ****************************************************************************/
+package org.eclipse.wst.css.ui;
+
+import java.util.ResourceBundle;
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.wst.css.ui.edit.ui.CleanupActionCSS;
+import org.eclipse.wst.css.ui.internal.editor.IHelpContextIds;
+import org.eclipse.wst.css.ui.internal.nls.ResourceHandler;
+import org.eclipse.wst.css.ui.internal.selection.StructureSelectEnclosingCSSAction;
+import org.eclipse.wst.css.ui.internal.selection.StructureSelectNextCSSAction;
+import org.eclipse.wst.css.ui.internal.selection.StructureSelectPreviousCSSAction;
+import org.eclipse.wst.sse.ui.StructuredTextEditor;
+import org.eclipse.wst.sse.ui.edit.util.ActionDefinitionIds;
+import org.eclipse.wst.sse.ui.edit.util.StructuredTextEditorActionConstants;
+import org.eclipse.wst.sse.ui.internal.selection.SelectionHistory;
+import org.eclipse.wst.sse.ui.internal.selection.StructureSelectHistoryAction;
+
+
+public class StructuredTextEditorCSS extends StructuredTextEditor {
+ protected void createActions() {
+ super.createActions();
+
+ ResourceBundle resourceBundle = ResourceHandler.getResourceBundle();
+
+ Action action = new CleanupActionCSS(resourceBundle, StructuredTextEditorActionConstants.ACTION_NAME_CLEANUP_DOCUMENT + DOT, this);
+ action.setActionDefinitionId(ActionDefinitionIds.CLEANUP_DOCUMENT);
+ setAction(StructuredTextEditorActionConstants.ACTION_NAME_CLEANUP_DOCUMENT, action);
+
+ SelectionHistory selectionHistory = new SelectionHistory(this);
+ action = new StructureSelectEnclosingCSSAction(this, selectionHistory);
+ action.setActionDefinitionId(ActionDefinitionIds.STRUCTURE_SELECT_ENCLOSING);
+ setAction(StructuredTextEditorActionConstants.ACTION_NAME_STRUCTURE_SELECT_ENCLOSING, action);
+
+ action = new StructureSelectNextCSSAction(this, selectionHistory);
+ action.setActionDefinitionId(ActionDefinitionIds.STRUCTURE_SELECT_NEXT);
+ setAction(StructuredTextEditorActionConstants.ACTION_NAME_STRUCTURE_SELECT_NEXT, action);
+
+ action = new StructureSelectPreviousCSSAction(this, selectionHistory);
+ action.setActionDefinitionId(ActionDefinitionIds.STRUCTURE_SELECT_PREVIOUS);
+ setAction(StructuredTextEditorActionConstants.ACTION_NAME_STRUCTURE_SELECT_PREVIOUS, action);
+
+ action = new StructureSelectHistoryAction(this, selectionHistory);
+ action.setActionDefinitionId(ActionDefinitionIds.STRUCTURE_SELECT_HISTORY);
+ setAction(StructuredTextEditorActionConstants.ACTION_NAME_STRUCTURE_SELECT_HISTORY, action);
+ selectionHistory.setHistoryAction((StructureSelectHistoryAction) action);
+ }
+
+ protected void initializeEditor() {
+ super.initializeEditor();
+ setHelpContextId(IHelpContextIds.CSS_SOURCEVIEW_HELPID);
+ }
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/StructuredTextViewerConfigurationCSS.java b/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/StructuredTextViewerConfigurationCSS.java
new file mode 100644
index 0000000000..dbc1089cc4
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/StructuredTextViewerConfigurationCSS.java
@@ -0,0 +1,125 @@
+/*****************************************************************************
+ * Copyright (c) 2004 IBM Corporation and others. All rights reserved. This
+ * program and the accompanying materials are made available under the terms
+ * of the Eclipse Public License v1.0 which accompanies this distribution, and
+ * is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors: IBM Corporation - initial API and implementation
+ ****************************************************************************/
+package org.eclipse.wst.css.ui;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.jface.text.IAutoEditStrategy;
+import org.eclipse.jface.text.ITextHover;
+import org.eclipse.jface.text.contentassist.ContentAssistant;
+import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
+import org.eclipse.jface.text.contentassist.IContentAssistant;
+import org.eclipse.jface.text.formatter.IContentFormatter;
+import org.eclipse.jface.text.formatter.MultiPassContentFormatter;
+import org.eclipse.jface.text.source.ISourceViewer;
+import org.eclipse.wst.css.core.format.FormatProcessorCSS;
+import org.eclipse.wst.css.core.internal.text.rules.StructuredTextPartitionerForCSS;
+import org.eclipse.wst.css.ui.autoedit.StructuredAutoEditStrategyCSS;
+import org.eclipse.wst.css.ui.contentassist.CSSContentAssistProcessor;
+import org.eclipse.wst.css.ui.style.LineStyleProviderForCSS;
+import org.eclipse.wst.css.ui.taginfo.CSSBestMatchHoverProcessor;
+import org.eclipse.wst.sse.core.format.StructuredFormattingStrategy;
+import org.eclipse.wst.sse.core.text.rules.StructuredTextPartitioner;
+import org.eclipse.wst.sse.ui.EditorPlugin;
+import org.eclipse.wst.sse.ui.StructuredTextViewerConfiguration;
+import org.eclipse.wst.sse.ui.style.IHighlighter;
+import org.eclipse.wst.sse.ui.taginfo.AnnotationHoverProcessor;
+import org.eclipse.wst.sse.ui.taginfo.ProblemAnnotationHoverProcessor;
+import org.eclipse.wst.sse.ui.taginfo.TextHoverManager;
+import org.eclipse.wst.sse.ui.util.EditorUtility;
+
+public class StructuredTextViewerConfigurationCSS extends StructuredTextViewerConfiguration {
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.ibm.sse.editor.StructuredTextViewerConfiguration#getAutoEditStrategies(org.eclipse.jface.text.source.ISourceViewer)
+ */
+ public Map getAutoEditStrategies(ISourceViewer sourceViewer) {
+ Map result = super.getAutoEditStrategies(sourceViewer);
+
+ if (result.get(StructuredTextPartitionerForCSS.ST_STYLE) == null)
+ result.put(StructuredTextPartitionerForCSS.ST_STYLE, new ArrayList(1));
+
+ IAutoEditStrategy autoEditStrategy = new StructuredAutoEditStrategyCSS();
+ List strategies = (List) result.get(StructuredTextPartitionerForCSS.ST_STYLE);
+ strategies.add(autoEditStrategy);
+
+ return result;
+ }
+
+ public String[] getConfiguredContentTypes(ISourceViewer sourceViewer) {
+ if (configuredContentTypes == null) {
+ configuredContentTypes = new String[]{StructuredTextPartitionerForCSS.ST_STYLE, StructuredTextPartitioner.ST_DEFAULT_PARTITION, StructuredTextPartitioner.ST_UNKNOWN_PARTITION};
+ }
+ return configuredContentTypes;
+ }
+
+ public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) {
+ IContentAssistant contentAssistant = super.getContentAssistant(sourceViewer);
+
+ if (contentAssistant != null && contentAssistant instanceof ContentAssistant) {
+ //((ContentAssistant)
+ // contentAssistant).setContentAssistProcessor(new
+ // CSSContentAssistProcessor(),
+ // StructuredTextPartitionerForCSS.ST_STYLE);
+ IContentAssistProcessor cssProcessor = new CSSContentAssistProcessor();
+ addContentAssistProcessor((ContentAssistant) contentAssistant, cssProcessor, StructuredTextPartitionerForCSS.ST_STYLE);
+ addContentAssistProcessor((ContentAssistant) contentAssistant, cssProcessor, StructuredTextPartitioner.ST_UNKNOWN_PARTITION);
+ }
+
+ return contentAssistant;
+ }
+
+ public IContentFormatter getContentFormatter(ISourceViewer sourceViewer) {
+ final MultiPassContentFormatter formatter = new MultiPassContentFormatter(getConfiguredDocumentPartitioning(sourceViewer), StructuredTextPartitionerForCSS.ST_STYLE);
+
+ formatter.setMasterStrategy(new StructuredFormattingStrategy(new FormatProcessorCSS()));
+
+ return formatter;
+ }
+
+ public IHighlighter getHighlighter(ISourceViewer sourceViewer) {
+ IHighlighter highlighter = super.getHighlighter(sourceViewer);
+
+ if (highlighter != null) {
+ highlighter.addProvider(StructuredTextPartitionerForCSS.ST_STYLE, new LineStyleProviderForCSS());
+ }
+
+ return highlighter;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.text.source.SourceViewerConfiguration#getTextHover(org.eclipse.jface.text.source.ISourceViewer,
+ * java.lang.String, int)
+ */
+ public ITextHover getTextHover(ISourceViewer sourceViewer, String contentType, int stateMask) {
+ // content type does not really matter since only combo, problem,
+ // annotation hover is available
+ TextHoverManager.TextHoverDescriptor[] hoverDescs = EditorPlugin.getDefault().getTextHoverManager().getTextHovers();
+ int i = 0;
+ while (i < hoverDescs.length) {
+ if (hoverDescs[i].isEnabled() && EditorUtility.computeStateMask(hoverDescs[i].getModifierString()) == stateMask) {
+ String hoverType = hoverDescs[i].getId();
+ if (TextHoverManager.COMBINATION_HOVER.equalsIgnoreCase(hoverType))
+ return new CSSBestMatchHoverProcessor();
+ else if (TextHoverManager.PROBLEM_HOVER.equalsIgnoreCase(hoverType))
+ return new ProblemAnnotationHoverProcessor();
+ else if (TextHoverManager.ANNOTATION_HOVER.equalsIgnoreCase(hoverType))
+ return new AnnotationHoverProcessor();
+ }
+ i++;
+ }
+ return super.getTextHover(sourceViewer, contentType, stateMask);
+ }
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/autoedit/StructuredAutoEditStrategyCSS.java b/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/autoedit/StructuredAutoEditStrategyCSS.java
new file mode 100644
index 0000000000..de3b80885d
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/autoedit/StructuredAutoEditStrategyCSS.java
@@ -0,0 +1,501 @@
+/*****************************************************************************
+ * Copyright (c) 2004 IBM Corporation and others. All rights reserved. This
+ * program and the accompanying materials are made available under the terms
+ * of the Eclipse Public License v1.0 which accompanies this distribution, and
+ * is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors: IBM Corporation - initial API and implementation
+ ****************************************************************************/
+package org.eclipse.wst.css.ui.autoedit;
+
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.DocumentCommand;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.ui.texteditor.ITextEditorExtension3;
+import org.eclipse.wst.css.core.parser.CSSRegionContexts;
+import org.eclipse.wst.css.core.preferences.CSSPreferenceHelper;
+import org.eclipse.wst.css.core.util.RegionIterator;
+import org.eclipse.wst.css.ui.internal.Logger;
+import org.eclipse.wst.sse.core.text.IStructuredDocument;
+import org.eclipse.wst.sse.core.text.IStructuredDocumentRegion;
+import org.eclipse.wst.sse.core.text.ITextRegion;
+import org.eclipse.wst.sse.ui.edit.util.BasicAutoEditStrategy;
+
+public class StructuredAutoEditStrategyCSS extends BasicAutoEditStrategy {
+ protected IStructuredDocument structuredDocument = null;
+
+ class CompoundRegion {
+
+ CompoundRegion(IStructuredDocumentRegion documentRegion, ITextRegion textRegion) {
+ super();
+ this.documentRegion = documentRegion;
+ this.textRegion = textRegion;
+ }
+
+ IStructuredDocumentRegion getDocumentRegion() {
+ return documentRegion;
+ }
+
+ ITextRegion getTextRegion() {
+ return textRegion;
+ }
+
+ int getStart() {
+ return textRegion.getStart();
+ }
+
+ int getEnd() {
+ return textRegion.getEnd();
+ }
+
+ String getType() {
+ return textRegion.getType();
+ }
+
+ String getText() {
+ return documentRegion.getText(textRegion);
+ }
+
+ int getStartOffset() {
+ return documentRegion.getStartOffset(textRegion);
+ }
+
+ int getEndOffset() {
+ return documentRegion.getEndOffset(textRegion);
+ }
+
+ private IStructuredDocumentRegion documentRegion;
+ private ITextRegion textRegion;
+
+ }
+
+ /**
+ */
+ protected void autoIndentAfterClose(DocumentCommand command, String regionType) {
+ if (!setRangeForClose(command))
+ return;
+
+ int position = command.offset + command.length;
+
+ if (position == -1 || structuredDocument.getLength() == 0) {
+ return;
+ }
+
+ // get open brace region
+ CompoundRegion region = prevCorrespondence(position, regionType);
+
+ // get indentation
+ String str = getIndentFor(region, false);
+
+ // append to input
+ if (str != null)
+ command.text = str + command.text;
+ }
+
+ /**
+ * Copies the indentation of the previous line.
+ */
+ protected void autoIndentAfterNewLine(DocumentCommand command) {
+ // select nearest white spaces to replace with new-line
+ setRangeForNewLine(command);
+
+ // get position
+ int position = command.offset;
+
+ if (position == -1 || structuredDocument.getLength() == 0) {
+ return;
+ }
+
+ // get current region
+ CompoundRegion currentRegion = getRegion(command.offset + command.length);
+
+ // get key region
+ CompoundRegion keyRegion = getPrevKeyRegion(position, currentRegion);
+
+ // get indent string
+ String str = getIndentFor(keyRegion, true);
+
+ // check another indentation
+ int shift = needShift(keyRegion, command.offset + command.length);
+
+ // create text to replace
+ StringBuffer buf = new StringBuffer(command.text);
+ if (str != null)
+ buf.append(str);
+ while (shift-- != 0)
+ buf.append(CSSPreferenceHelper.getInstance().getIndentString());
+ command.text = buf.toString();
+
+ }
+
+ /**
+ */
+ public void customizeDocumentCommand(IDocument document, DocumentCommand command) {
+ Object textEditor = getActiveTextEditor();
+ if (!(textEditor instanceof ITextEditorExtension3 && ((ITextEditorExtension3) textEditor).getInsertMode() == ITextEditorExtension3.SMART_INSERT))
+ return;
+
+ //return;
+ ///*
+ structuredDocument = (IStructuredDocument) document;
+
+ if (command.length == 0 && command.text != null) {
+ if (endsWith(document.getLegalLineDelimiters(), command.text) != -1) {
+ autoIndentAfterNewLine(command);
+ } else if (command.text.equals("}")) {//$NON-NLS-1$
+ autoIndentAfterClose(command, CSSRegionContexts.CSS_RBRACE);
+ } else if (command.text.equals("]")) {//$NON-NLS-1$
+ autoIndentAfterClose(command, CSSRegionContexts.CSS_SELECTOR_ATTRIBUTE_END);
+ } else if (command.text.equals(")")) {//$NON-NLS-1$
+ autoIndentAfterClose(command, CSSRegionContexts.CSS_DECLARATION_VALUE_PARENTHESIS_CLOSE);
+ }
+ }
+ //*/
+ }
+
+ /**
+ */
+ protected String getIndentFor(CompoundRegion region, boolean indentForNextRegion) {
+ if (region == null)
+ return null;
+ IStructuredDocumentRegion flatNode = region.getDocumentRegion();
+ if (flatNode == null)
+ return null;
+
+ try {
+ if (region.getType() == CSSRegionContexts.CSS_LBRACE || region.getType() == CSSRegionContexts.CSS_DELIMITER || region.getType() == CSSRegionContexts.CSS_DECLARATION_DELIMITER) {
+ // get meanful flat node
+ RegionIterator it = new RegionIterator(flatNode, region.getTextRegion());
+ it.prev();
+ while (it.hasPrev()) {
+ ITextRegion r = it.prev();
+ region = new CompoundRegion(it.getStructuredDocumentRegion(), r);
+ if (region.getType() != CSSRegionContexts.CSS_S)
+ break;
+ }
+ flatNode = region.getDocumentRegion();
+ // get indent string
+ int position = flatNode.getStart();
+ int line = structuredDocument.getLineOfOffset(position);
+ int start = structuredDocument.getLineOffset(line);
+ int end = findEndOfWhiteSpace(structuredDocument, start, position);
+ return structuredDocument.get(start, end - start);
+ } else if (region.getType() == CSSRegionContexts.CSS_SELECTOR_ATTRIBUTE_START ||
+ //region.getType() == CSSRegionContexts.CSS_PARENTHESIS_OPEN ||
+ region.getType() == CSSRegionContexts.CSS_DECLARATION_VALUE_FUNCTION || region.getType() == CSSRegionContexts.CSS_DECLARATION_SEPARATOR) {
+ int position = flatNode.getStart() + region.getStart();
+ int line = structuredDocument.getLineOfOffset(position);
+ int start = structuredDocument.getLineOffset(line);
+ int end = findEndOfWhiteSpace(structuredDocument, start, position);
+ StringBuffer buf = new StringBuffer(structuredDocument.get(start, end - start));
+ position += region.getText().length();
+ if (indentForNextRegion) {
+ int tokenStart = findEndOfWhiteSpace(structuredDocument, position, structuredDocument.getLineOffset(line) + structuredDocument.getLineLength(line) - 1);
+ if (tokenStart < structuredDocument.getLineOffset(line) + structuredDocument.getLineLength(line) - 1) {
+ position = tokenStart;
+ }
+ }
+ while (position - end > 0) {
+ buf.append(" ");//$NON-NLS-1$
+ end++;
+ }
+ return buf.toString();
+ } else
+ return "";//$NON-NLS-1$
+ } catch (BadLocationException excp) {
+ Logger.logException(excp);
+ }
+ return null;
+ }
+
+ /**
+ */
+ protected CompoundRegion getPrevKeyRegion(int position, CompoundRegion currentRegion) {
+ if (currentRegion == null) {
+ if (structuredDocument.getLastStructuredDocumentRegion() == null)
+ return null;
+ }
+
+ if (currentRegion != null && (currentRegion.getType() == CSSRegionContexts.CSS_RBRACE || currentRegion.getType() == CSSRegionContexts.CSS_SELECTOR_ATTRIBUTE_END || currentRegion.getType() == CSSRegionContexts.CSS_DECLARATION_VALUE_PARENTHESIS_CLOSE)) {
+ return prevCorrespondence(currentRegion);
+ }
+
+ RegionIterator it = new RegionIterator(structuredDocument, position - 1);
+ while (it.hasPrev()) {
+ ITextRegion r = it.prev();
+ CompoundRegion region = new CompoundRegion(it.getStructuredDocumentRegion(), r);
+ if (region.getType() == CSSRegionContexts.CSS_LBRACE ||
+ // region.getType() == CSSRegionContexts.CSS_RBRACE ||
+ region.getType() == CSSRegionContexts.CSS_SELECTOR_ATTRIBUTE_START ||
+ // region.getType() ==
+ // CSSRegionContexts.CSS_BRACKET_CLOSE ||
+ //// region.getType() ==
+ // CSSRegionContexts.CSS_PARENTHESIS_OPEN ||
+ // region.getType() ==
+ // CSSRegionContexts.CSS_PARENTHESIS_CLOSE ||
+ region.getType() == CSSRegionContexts.CSS_DELIMITER || region.getType() == CSSRegionContexts.CSS_DECLARATION_DELIMITER ||
+ // region.getType() == CSSRegionContexts.CSS_COLON ||
+ // region.getType() == CSSRegionContexts.CSS_COMMENT
+ // ||
+ region.getType() == CSSRegionContexts.CSS_DECLARATION_VALUE_FUNCTION) {
+ return region;
+ } else if (region.getType() == CSSRegionContexts.CSS_RBRACE || region.getType() == CSSRegionContexts.CSS_SELECTOR_ATTRIBUTE_END || region.getType() == CSSRegionContexts.CSS_DECLARATION_VALUE_PARENTHESIS_CLOSE) {
+ // skip to LBRACE
+ CompoundRegion pc = prevCorrespondence(region);
+ it.reset(pc.getDocumentRegion(), pc.getTextRegion());
+ it.prev();
+ } else if (region.getType() == CSSRegionContexts.CSS_STRING) {
+ RegionIterator itTmp = new RegionIterator(structuredDocument, position);
+ if (region == itTmp.prev())
+ return region; // position is inside of string
+ } else if (region.getType() == CSSRegionContexts.CSS_COMMENT) {
+ RegionIterator itTmp = new RegionIterator(structuredDocument, position);
+ if (region == itTmp.prev())
+ return region; // position is inside of comment
+ } else if (region.getType() == CSSRegionContexts.CSS_UNKNOWN) {
+ String str = region.getText();
+ if (str.charAt(str.length() - 1) == '\\')
+ return region;
+ } else if (region.getType() == CSSRegionContexts.CSS_DECLARATION_SEPARATOR) {
+ RegionIterator itPrev = new RegionIterator(region.getDocumentRegion(), region.getTextRegion());
+ while (itPrev.hasPrev()) {
+ ITextRegion regionPrev = itPrev.prev();
+ if (regionPrev.getType() == CSSRegionContexts.CSS_RBRACE) {
+ break;
+ } else if (regionPrev.getType() == CSSRegionContexts.CSS_DELIMITER || regionPrev.getType() == CSSRegionContexts.CSS_DECLARATION_DELIMITER) {
+ return region;
+ } else if (regionPrev.getType() == CSSRegionContexts.CSS_LBRACE) {
+ while (itPrev.hasPrev()) {
+ regionPrev = itPrev.prev();
+ if (regionPrev.getType() == CSSRegionContexts.CSS_MEDIA)
+ break;
+ if (regionPrev.getType() == CSSRegionContexts.CSS_LBRACE || regionPrev.getType() == CSSRegionContexts.CSS_RBRACE || regionPrev.getType() == CSSRegionContexts.CSS_DELIMITER || regionPrev.getType() == CSSRegionContexts.CSS_DECLARATION_DELIMITER)
+ return region;
+ }
+ if (regionPrev.getType() == CSSRegionContexts.CSS_MEDIA)
+ break;
+ else
+ return region;
+ }
+ }
+ }
+ }
+ return null;
+ }
+
+ /**
+ */
+ protected CompoundRegion getRegion(int position) {
+ IStructuredDocumentRegion flatNode = structuredDocument.getRegionAtCharacterOffset(position);
+ if (flatNode != null)
+ return new CompoundRegion(flatNode, flatNode.getRegionAtCharacterOffset(position));
+ return null;
+ }
+
+ /**
+ */
+ protected int needShift(CompoundRegion region, int position) {
+ int shift = 0;
+ if (region == null || region.getType() == CSSRegionContexts.CSS_DELIMITER || region.getType() == CSSRegionContexts.CSS_DECLARATION_DELIMITER || region.getType() == CSSRegionContexts.CSS_LBRACE) {
+ // get non space region
+ CompoundRegion cr = getRegion(position - 1);
+ RegionIterator it = new RegionIterator(cr.getDocumentRegion(), cr.getTextRegion());
+ ITextRegion nearestRegion = null;
+ while (it.hasPrev()) {
+ nearestRegion = it.prev();
+ if (nearestRegion.getType() != CSSRegionContexts.CSS_S && nearestRegion.getType() != CSSRegionContexts.CSS_COMMENT)
+ break;
+ }
+ if (nearestRegion != null && (nearestRegion.getType() == CSSRegionContexts.CSS_LBRACE || nearestRegion.getType() == CSSRegionContexts.CSS_RBRACE || nearestRegion.getType() == CSSRegionContexts.CSS_DELIMITER || nearestRegion.getType() == CSSRegionContexts.CSS_DECLARATION_DELIMITER))
+ shift--;
+ else if (region == null)
+ shift--;
+ shift++;
+ }
+ if (region != null && region.getType() == CSSRegionContexts.CSS_LBRACE) {
+ RegionIterator it = new RegionIterator(structuredDocument, position);
+ if (!it.hasPrev() || it.prev().getType() != CSSRegionContexts.CSS_RBRACE)
+ shift++;
+ else
+ shift = 0;
+ }
+ return shift;
+ }
+
+ /**
+ */
+ protected CompoundRegion prevCorrespondence(int position, String regionType) {
+ RegionIterator it = new RegionIterator(structuredDocument, position - 1);
+ ITextRegion region = null;
+ int nest = 1;
+ if (regionType == CSSRegionContexts.CSS_RBRACE) {
+ // skip to LBRACE
+ while (it.hasPrev()) {
+ region = it.prev();
+ if (region.getType() == CSSRegionContexts.CSS_LBRACE)
+ nest--;
+ else if (region.getType() == CSSRegionContexts.CSS_RBRACE)
+ nest++;
+ if (nest <= 0)
+ break;
+ }
+ if (nest == 0)
+ return new CompoundRegion(it.getStructuredDocumentRegion(), region);
+ }
+ if (regionType == CSSRegionContexts.CSS_SELECTOR_ATTRIBUTE_END) {
+ // skip to BRACKET_OPEN
+ while (it.hasPrev()) {
+ region = it.prev();
+ if (region.getType() == CSSRegionContexts.CSS_SELECTOR_ATTRIBUTE_START)
+ nest--;
+ else if (region.getType() == CSSRegionContexts.CSS_SELECTOR_ATTRIBUTE_END)
+ nest++;
+ if (nest <= 0)
+ break;
+ }
+ if (nest == 0)
+ return new CompoundRegion(it.getStructuredDocumentRegion(), region);
+ }
+ if (regionType == CSSRegionContexts.CSS_DECLARATION_VALUE_PARENTHESIS_CLOSE) {
+ // skip to PARENTHESIS_OPEN
+ while (it.hasPrev()) {
+ region = it.prev();
+ if (//region.getType() ==
+ // CSSRegionContexts.CSS_PARENTHESIS_OPEN ||
+ region.getType() == CSSRegionContexts.CSS_DECLARATION_VALUE_FUNCTION)
+ nest--;
+ else if (region.getType() == CSSRegionContexts.CSS_DECLARATION_VALUE_PARENTHESIS_CLOSE)
+ nest++;
+ if (nest <= 0)
+ break;
+ }
+ if (nest == 0)
+ return new CompoundRegion(it.getStructuredDocumentRegion(), region);
+ }
+ return null;
+ }
+
+ /**
+ */
+ protected CompoundRegion prevCorrespondence(CompoundRegion region) {
+ if (region == null)
+ return null;
+
+ IStructuredDocumentRegion flatNode = region.getDocumentRegion();
+ int position = flatNode.getStart() + region.getStart();
+ return prevCorrespondence(position, region.getType());
+ }
+
+ /**
+ * Insert the method's description here.
+ *
+ * @return boolean
+ * @param command
+ * org.eclipse.jface.text.DocumentCommand
+ */
+ protected boolean setRangeForClose(DocumentCommand command) {
+ int position = command.offset;
+
+ if (position == -1 || structuredDocument.getLength() == 0) {
+ return false;
+ }
+
+ try {
+ // find start of line
+ int p = (position == structuredDocument.getLength() ? position - 1 : position);
+
+ int line = structuredDocument.getLineOfOffset(p);
+ int start = structuredDocument.getLineOffset(line);
+ RegionIterator it = new RegionIterator(structuredDocument, start);
+ boolean allWhiteSpace = false;
+ // check whether the text from lStart to position is white space
+ // or not
+ while (it.hasNext()) {
+ ITextRegion region = it.next();
+ if (region.getType() != CSSRegionContexts.CSS_S)
+ break;
+ if (it.getStructuredDocumentRegion().getEndOffset(region) > p) {
+ allWhiteSpace = true;
+ break;
+ }
+ }
+ if (allWhiteSpace) {
+ command.length = command.length - (start - command.offset);
+ command.offset = start;
+ return true;
+ }
+ } catch (BadLocationException excp) {
+ Logger.logException(excp);
+ }
+ return false;
+ }
+
+ /**
+ */
+ protected void setRangeForNewLine(DocumentCommand command) {
+ int position = command.offset;
+
+ if (position == -1 || structuredDocument.getLength() == 0) {
+ return;
+ }
+
+ try {
+ // add pre-nearest white spaces to replace target
+ if (position > 0) {
+ IStructuredDocumentRegion flatNode = structuredDocument.getRegionAtCharacterOffset(position - 1);
+ if (flatNode != null) {
+ ITextRegion region = flatNode.getRegionAtCharacterOffset(position - 1);
+ if (region.getType() == CSSRegionContexts.CSS_S) {
+ int end = command.offset + command.length;
+ int nLine = structuredDocument.getLineOfOffset(position);
+ int nStartPos = structuredDocument.getLineOffset(nLine);
+ if (nStartPos < flatNode.getStartOffset(region))
+ nStartPos = flatNode.getStartOffset(region);
+ command.offset = nStartPos;
+ command.length = end - command.offset;
+ }
+ }
+ }
+
+ // add post-nearest white spaces to replace target
+ if (position < structuredDocument.getLength()) {
+ IStructuredDocumentRegion flatNode = structuredDocument.getRegionAtCharacterOffset(position);
+ if (flatNode != null) {
+ ITextRegion region = flatNode.getRegionAtCharacterOffset(position);
+ if (region.getType() == CSSRegionContexts.CSS_S) {
+ int nLine = structuredDocument.getLineOfOffset(position);
+ String currentLineDelim = structuredDocument.getLineDelimiter(nLine);
+ int nEndPos = structuredDocument.getLineOffset(nLine) + structuredDocument.getLineLength(nLine) - ((currentLineDelim != null) ? currentLineDelim.length() : 0);
+ if (nEndPos > flatNode.getEndOffset(region))
+ nEndPos = flatNode.getEndOffset(region);
+ command.length = nEndPos - command.offset;
+ }
+ }
+ }
+ } catch (BadLocationException e) {
+ // do not customize command
+ }
+
+ }
+
+ private static int endsWith(String[] searchStrings, String text) {
+ for (int i = 0; i < searchStrings.length; i++) {
+ if (text.endsWith(searchStrings[i]))
+ return i;
+ }
+ return -1;
+ }
+
+ private static int findEndOfWhiteSpace(IDocument document, int offset, int end) throws BadLocationException {
+ while (offset < end) {
+ char c = document.getChar(offset);
+ if (c != ' ' && c != '\t') {
+ return offset;
+ }
+ offset++;
+ }
+ return end;
+ }
+
+}
+
diff --git a/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/contentassist/CSSCACandidate.java b/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/contentassist/CSSCACandidate.java
new file mode 100644
index 0000000000..2987933e44
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/contentassist/CSSCACandidate.java
@@ -0,0 +1,102 @@
+/*****************************************************************************
+ * Copyright (c) 2004 IBM Corporation and others. All rights reserved. This
+ * program and the accompanying materials are made available under the terms
+ * of the Eclipse Public License v1.0 which accompanies this distribution, and
+ * is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors: IBM Corporation - initial API and implementation
+ ****************************************************************************/
+package org.eclipse.wst.css.ui.contentassist;
+
+
+
+import org.eclipse.wst.css.ui.image.CSSImageType;
+
+class CSSCACandidate {
+
+ private String fReplacementString = null;
+ private int fCursorPosition = 0;
+ private String fDisplayString = null;
+ private CSSImageType fImageType = null;
+
+ /**
+ * CSSCACandidate constructor comment.
+ */
+ CSSCACandidate() {
+ super();
+ }
+
+ /**
+ *
+ */
+ int getCursorPosition() {
+ return fCursorPosition;
+ }
+
+ /**
+ *
+ */
+ String getDisplayString() {
+ return fDisplayString;
+ }
+
+ /**
+ *
+ */
+ CSSImageType getImageType() {
+ return fImageType;
+ }
+
+ /**
+ *
+ */
+ String getReplacementString() {
+ return fReplacementString;
+ }
+
+ /**
+ *
+ */
+ void setCursorPosition(int cursorPosition) {
+ fCursorPosition = cursorPosition;
+ }
+
+ /**
+ *
+ */
+ void setDisplayString(String displayString) {
+ fDisplayString = displayString;
+ }
+
+ /**
+ *
+ */
+ void setImageType(CSSImageType imageType) {
+ fImageType = imageType;
+ }
+
+ /**
+ *
+ */
+ void setReplacementString(String replacementString) {
+ fReplacementString = replacementString;
+ }
+
+ /**
+ * Returns a String that represents the value of this object.
+ *
+ * @return a string representation of the receiver
+ */
+ public String toString() {
+ StringBuffer buf = new StringBuffer();
+ buf.append(getReplacementString());
+ buf.append("\"");//$NON-NLS-1$
+ buf.append(getDisplayString());
+ buf.append("\"");//$NON-NLS-1$
+ buf.append("(");//$NON-NLS-1$
+ buf.append(getCursorPosition());
+ buf.append(")");//$NON-NLS-1$
+
+ return buf.toString();
+ }
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/contentassist/CSSContentAssistContext.java b/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/contentassist/CSSContentAssistContext.java
new file mode 100644
index 0000000000..3d1baeda6e
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/contentassist/CSSContentAssistContext.java
@@ -0,0 +1,454 @@
+/*****************************************************************************
+ * Copyright (c) 2004 IBM Corporation and others. All rights reserved. This
+ * program and the accompanying materials are made available under the terms
+ * of the Eclipse Public License v1.0 which accompanies this distribution, and
+ * is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors: IBM Corporation - initial API and implementation
+ ****************************************************************************/
+
+
+package org.eclipse.wst.css.ui.contentassist;
+
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.wst.css.core.document.ICSSDocument;
+import org.eclipse.wst.css.core.document.ICSSModel;
+import org.eclipse.wst.css.core.document.ICSSNode;
+import org.eclipse.wst.css.core.metamodel.CSSMetaModel;
+import org.eclipse.wst.css.core.metamodel.util.CSSMetaModelFinder;
+import org.eclipse.wst.css.core.parser.CSSRegionContexts;
+import org.eclipse.wst.css.core.util.CSSUtil;
+import org.eclipse.wst.css.core.util.RegionIterator;
+import org.eclipse.wst.sse.core.IndexedRegion;
+import org.eclipse.wst.sse.core.text.IStructuredDocument;
+import org.eclipse.wst.sse.core.text.IStructuredDocumentRegion;
+import org.eclipse.wst.sse.core.text.ITextRegion;
+
+class CSSContentAssistContext {
+
+ private int fReplaceBegin = -1;
+ private String fTextToReplace = null;
+ private String fTextToCompare = null;
+ private int fTargetPos = -1;
+ private ICSSNode fTargetNode = null;
+ private int fCursorPos = -1;
+ private IStructuredDocument fStructuredDocument = null;
+ private int fDocumentOffset = 0;
+ private char fQuote = 0;
+ private ICSSModel fModel = null;
+
+ /**
+ *
+ */
+ private CSSContentAssistContext() {
+ super();
+ }
+
+ /**
+ *
+ */
+ CSSContentAssistContext(int documentPosition, ICSSNode node, int documentOffset, char quote) {
+ super();
+ fCursorPos = documentPosition;
+ fDocumentOffset = documentOffset;
+ fQuote = quote;
+ initialize(node.getOwnerDocument());
+ }
+
+ /**
+ * @return int
+ */
+ int getCursorPos() {
+ return fCursorPos;
+ }
+
+ /**
+ * @return int
+ */
+ int getDocumentOffset() {
+ return fDocumentOffset;
+ }
+
+ /**
+ * @return com.ibm.sed.structuredDocument.IStructuredDocument
+ */
+ IStructuredDocument getStructuredDocument() {
+ return fStructuredDocument;
+ }
+
+ /**
+ * @return com.ibm.sse.model.css.model.ICSSModel
+ */
+ ICSSModel getModel() {
+ return fModel;
+ }
+
+ private ICSSNode getNodeAt(int offset) {
+ return (ICSSNode) ((fModel != null) ? fModel.getIndexedRegion(offset) : null);
+ }
+
+ /**
+ *
+ * @return char
+ */
+ char getQuoteOfStyleAttribute() {
+ return fQuote;
+ }
+
+ /**
+ *
+ */
+ ITextRegion getRegionByOffset(int offset) {
+ ITextRegion region = null;
+ if (fStructuredDocument != null) {
+ IStructuredDocumentRegion flatNode = fStructuredDocument.getRegionAtCharacterOffset(offset);
+ if (flatNode != null) {
+ region = flatNode.getRegionAtCharacterOffset(offset);
+ }
+ }
+ return region;
+ }
+
+ /**
+ *
+ */
+ // String getRegionText() {
+ // ITextRegion targetRegion = getTargetRegion();
+ // if (targetRegion != null) {
+ // return targetRegion.getText();
+ // } else {
+ // return ""; //$NON-NLS-1$
+ // }
+ // }
+ /**
+ *
+ */
+ int getReplaceBegin() {
+ return fReplaceBegin;
+ }
+
+ /**
+ *
+ * @return com.ibm.sed.structuredDocument.ITextRegion
+ */
+ // ITextRegion getSignificantTargetRegion() {
+ // ITextRegion targetRegion = getTargetRegion();
+ // RegionIterator iterator = null;
+ // if (targetRegion == null) {
+ // if (0 < fCursorPos) {
+ // iterator = new RegionIterator(fStructuredDocument, fCursorPos - 1);
+ // }
+ // } else {
+ // iterator = getRegionIterator();
+ // }
+ // if (iterator != null) {
+ // while (iterator.hasPrev()) {
+ // ITextRegion region = iterator.prev();
+ // String type = region.getType();
+ // if (type != CSSRegionContexts.CSS_S && type !=
+ // CSSRegionContexts.CSS_COMMENT &&
+ // type != CSSRegionContexts.CSS_CDO && type != CSSRegionContexts.CSS_CDC)
+ // {
+ // targetRegion = region;
+ // break;
+ // }
+ // }
+ // }
+ //
+ // return targetRegion;
+ // }
+ /**
+ *
+ */
+ ICSSNode getTargetNode() {
+ return fTargetNode;
+ }
+
+ /**
+ *
+ */
+ private int getTargetPos() {
+ return fTargetPos;
+ }
+
+ /**
+ * @return com.ibm.sed.structuredDocument.ITextRegion
+ */
+ ITextRegion getTargetRegion() {
+ return getRegionByOffset(getTargetPos());
+ }
+
+ private IStructuredDocumentRegion getTargetDocumentRegion() {
+ return getDocumentRegionByOffset(getTargetPos());
+ }
+
+ private IStructuredDocumentRegion getDocumentRegionByOffset(int offset) {
+ return (fStructuredDocument != null) ? fStructuredDocument.getRegionAtCharacterOffset(offset) : null;
+ }
+
+ /**
+ *
+ * @return com.ibm.sed.structuredDocument.ITextRegion
+ */
+ ITextRegion getTargetRegionPrevious() {
+ ITextRegion previousRegion = null;
+ ITextRegion targetRegion = getTargetRegion();
+ RegionIterator iterator = null;
+ if (targetRegion == null) {
+ if (0 < fCursorPos) {
+ iterator = new RegionIterator(fStructuredDocument, fCursorPos - 1);
+ }
+ } else {
+ iterator = getRegionIterator();
+ if (iterator.hasPrev()) {
+ iterator.prev();
+ } else {
+ iterator = null;
+ }
+ }
+ if (iterator != null) {
+ while (iterator.hasPrev()) {
+ ITextRegion region = iterator.prev();
+ String type = region.getType();
+ if (type != CSSRegionContexts.CSS_S && type != CSSRegionContexts.CSS_COMMENT && type != CSSRegionContexts.CSS_CDO && type != CSSRegionContexts.CSS_CDC) {
+ previousRegion = region;
+ break;
+ }
+ }
+ }
+
+ return previousRegion;
+ }
+
+ /**
+ * @return java.lang.String
+ */
+ String getTextToCompare() {
+ return fTextToCompare;
+ }
+
+ /**
+ *
+ */
+ String getTextToReplace() {
+ return fTextToReplace;
+ }
+
+ /**
+ *
+ */
+ private void initialize(ICSSDocument doc) {
+ if (doc == null) {
+ return;
+ }
+ ICSSModel model = doc.getModel();
+ fModel = model;
+ fStructuredDocument = model.getStructuredDocument();
+
+ initializeTargetPos();
+ initializeTargetText();
+ initializeTargetNode();
+ }
+
+ /**
+ *
+ */
+ private void initializeTargetNode() {
+ if (fCursorPos == 0) {
+ fTargetNode = fModel.getDocument();
+ return;
+ }
+
+ // find edge of tree node
+ ICSSNode cursorNode = getNodeAt(fCursorPos);
+ if (cursorNode == null) { // end of document
+ cursorNode = fModel.getDocument();
+ }
+ ICSSNode node = null;
+ IStructuredDocumentRegion flatNode = fStructuredDocument.getRegionAtCharacterOffset(fCursorPos - 1);
+ while (flatNode != null && (node = getNodeAt(flatNode.getStartOffset())) == cursorNode && ((IndexedRegion) node).getStartOffset() != flatNode.getStartOffset()) {
+ flatNode = flatNode.getPrevious();
+ }
+ if (flatNode == null) { // top of document
+ fTargetNode = (node == null) ? fModel.getDocument() : node;
+ return;
+ }
+ // v<--|
+ // AAAAAA
+ // BBBBBBBBBB cursorNode:A , node:B -> target is A
+ if (cursorNode != null) {
+ for (ICSSNode parent = cursorNode.getParentNode(); parent != null; parent = parent.getParentNode()) {
+ if (parent == cursorNode) {
+ fTargetNode = cursorNode;
+ return;
+ }
+ }
+ }
+ // v<--|
+ // AAA
+ // BBBBBBBBBB cursorNode:B , node:A -> depend on A's node type
+ short nodeType = node.getNodeType();
+ if (nodeType == ICSSNode.STYLEDECLITEM_NODE || nodeType == ICSSNode.CHARSETRULE_NODE || nodeType == ICSSNode.IMPORTRULE_NODE) {
+ String type = CSSUtil.getStructuredDocumentRegionType(flatNode);
+ if (type == CSSRegionContexts.CSS_DELIMITER || type == CSSRegionContexts.CSS_DECLARATION_DELIMITER) {
+ fTargetNode = node.getParentNode();
+ } else {
+ fTargetNode = node;
+ }
+ // fTargetNode = (bOverSemiColon) ? node.getParentNode() : node;
+ } else if (CSSUtil.getStructuredDocumentRegionType(flatNode) == CSSRegionContexts.CSS_RBRACE) {
+ fTargetNode = node.getParentNode();
+ } else {
+ fTargetNode = node;
+ }
+
+ return;
+ }
+
+ /**
+ *
+ */
+ private void initializeTargetPos() {
+ if (fCursorPos == 0 || isSpecialDelimiterRegion(fCursorPos - 1)) {
+ fTargetPos = fCursorPos;
+ } else {
+ fTargetPos = fCursorPos - 1;
+ }
+ }
+
+ /**
+ *
+ */
+ private void initializeTargetText() {
+ ITextRegion targetRegion = getTargetRegion();
+ IStructuredDocumentRegion documentRegion = getTargetDocumentRegion();
+ if (targetRegion == null) {
+ fReplaceBegin = fCursorPos;
+ fTextToReplace = ""; //$NON-NLS-1$
+ fTextToCompare = ""; //$NON-NLS-1$
+ } else {
+ String regionText = documentRegion.getText(targetRegion);
+ int regionStart = documentRegion.getStartOffset(targetRegion);
+ if (regionStart == fCursorPos || regionText.trim().length() == 0 || regionStart + regionText.length() - 1 < fTargetPos) {
+ // to insertion
+ fReplaceBegin = fCursorPos;
+ fTextToReplace = ""; //$NON-NLS-1$
+ fTextToCompare = ""; //$NON-NLS-1$
+ } else {
+ // to replace
+ fReplaceBegin = regionStart;
+ fTextToReplace = regionText;
+ fTextToCompare = regionText.substring(0, fCursorPos - fReplaceBegin);
+ }
+ }
+ }
+
+ /**
+ *
+ */
+ private boolean isSpecialDelimiterRegion(int pos) {
+ ITextRegion region = getRegionByOffset(pos);
+ String type = region.getType();
+ return (type == CSSRegionContexts.CSS_LBRACE || type == CSSRegionContexts.CSS_RBRACE || type == CSSRegionContexts.CSS_DELIMITER || type == CSSRegionContexts.CSS_DECLARATION_SEPARATOR || type == CSSRegionContexts.CSS_DECLARATION_DELIMITER || type == CSSRegionContexts.CSS_DECLARATION_VALUE_OPERATOR);
+ }
+
+ /**
+ *
+ */
+ boolean isTargetPosAfterOf(String regionType) {
+ int start = ((IndexedRegion) fTargetNode).getStartOffset();
+ if (start < 0 || ((IndexedRegion) fTargetNode).getEndOffset() <= 0) {
+ return false;
+ }
+
+ RegionIterator iRegion = new RegionIterator(fStructuredDocument, start);
+ while (iRegion.hasNext()) {
+ ITextRegion region = iRegion.next();
+ if (fTargetPos < iRegion.getStructuredDocumentRegion().getTextEndOffset(region)) {
+ break;
+ }
+ if (region.getType() == regionType) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ *
+ */
+ boolean isTargetPosBeforeOf(String regionType) {
+ return !isTargetPosAfterOf(regionType);
+ }
+
+ /**
+ * @return boolean
+ * @param regionType
+ * java.lang.String
+ */
+ boolean targetFollows(String regionType) {
+ RegionIterator iRegion;
+ ITextRegion region = null;
+ if (fStructuredDocument.getLength() <= fTargetPos) {
+ iRegion = new RegionIterator(fStructuredDocument, fStructuredDocument.getLength() - 1);
+ } else {
+ iRegion = new RegionIterator(fStructuredDocument, fTargetPos);
+ try {
+ if (!Character.isWhitespace(fStructuredDocument.getChar(fTargetPos)) && iRegion.hasPrev()) {
+ region = iRegion.prev();
+ }
+ } catch (BadLocationException e) {
+ iRegion = new RegionIterator(fStructuredDocument, fStructuredDocument.getLength() - 1);
+ }
+ }
+ while (iRegion.hasPrev()) {
+ region = iRegion.prev();
+ String type = region.getType();
+ if (type == CSSRegionContexts.CSS_S || type == CSSRegionContexts.CSS_COMMENT) {
+ continue;
+ } else {
+ break;
+ }
+ }
+ if (region != null && region.getType() == regionType) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ /**
+ *
+ */
+ boolean targetHas(String regionType) {
+ int start = ((IndexedRegion) fTargetNode).getStartOffset();
+ int end = ((IndexedRegion) fTargetNode).getEndOffset();
+ if (start < 0 || end <= 0) {
+ return false;
+ }
+ RegionIterator iRegion = new RegionIterator(fStructuredDocument, start);
+ while (iRegion.hasNext()) {
+ ITextRegion region = iRegion.next();
+ if (end <= iRegion.getStructuredDocumentRegion().getStartOffset(region)) {
+ break;
+ }
+ if (region.getType() == regionType) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ RegionIterator getRegionIterator() {
+ return new RegionIterator(getStructuredDocument(), getTargetPos());
+ }
+
+ /**
+ *
+ */
+ CSSMetaModel getMetaModel() {
+ CSSMetaModelFinder finder = CSSMetaModelFinder.getInstance();
+ return finder.findMetaModelFor(getModel());
+ }
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/contentassist/CSSContentAssistProcessor.java b/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/contentassist/CSSContentAssistProcessor.java
new file mode 100644
index 0000000000..50f1d6ddec
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/contentassist/CSSContentAssistProcessor.java
@@ -0,0 +1,273 @@
+/*****************************************************************************
+ * Copyright (c) 2004 IBM Corporation and others. All rights reserved. This
+ * program and the accompanying materials are made available under the terms
+ * of the Eclipse Public License v1.0 which accompanies this distribution, and
+ * is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors: IBM Corporation - initial API and implementation
+ ****************************************************************************/
+package org.eclipse.wst.css.ui.contentassist;
+
+
+
+import org.eclipse.jface.text.ITextViewer;
+import org.eclipse.jface.text.contentassist.ICompletionProposal;
+import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
+import org.eclipse.wst.css.core.adapters.ICSSModelAdapter;
+import org.eclipse.wst.css.core.document.ICSSDocument;
+import org.eclipse.wst.css.core.document.ICSSModel;
+import org.eclipse.wst.css.core.document.ICSSNode;
+import org.eclipse.wst.html.core.htmlcss.StyleAdapterFactory;
+import org.eclipse.wst.sse.core.INodeAdapter;
+import org.eclipse.wst.sse.core.IStructuredModel;
+import org.eclipse.wst.sse.core.IndexedRegion;
+import org.eclipse.wst.sse.ui.StructuredTextViewer;
+import org.eclipse.wst.sse.ui.internal.contentassist.ContentAssistUtils;
+import org.eclipse.wst.xml.core.document.XMLNode;
+import org.eclipse.wst.xml.ui.contentassist.XMLContentAssistUtilities;
+import org.eclipse.wst.xml.ui.util.SharedXMLEditorPluginImageHelper;
+
+public class CSSContentAssistProcessor implements IContentAssistProcessor {
+
+ private int fDocumentOffset = 0;
+ private char fQuote = 0;
+
+ /**
+ * 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 viewer, int documentPosition) {
+
+ IndexedRegion indexedNode = ContentAssistUtils.getNodeAt((StructuredTextViewer) viewer, documentPosition + fDocumentOffset);
+ IndexedRegion keyIndexedNode = null;
+ XMLNode xNode = null;
+ XMLNode parent = null;
+ IStructuredModel cssModel = null;
+ CSSProposalArranger arranger = null;
+
+ // bail if we couldn't get an indexed node
+ //if(indexedNode == null) return new ICompletionProposal[0];
+ if (indexedNode instanceof XMLNode) {
+ xNode = (XMLNode) indexedNode;
+ parent = (XMLNode) xNode.getParentNode();
+ }
+ // need to get in here if there in the no 0 region <style>|</style>
+ // case
+ if (xNode != null && xNode.getNodeName().equalsIgnoreCase(HTML40Namespace.ElementName.STYLE)) {
+ // now we know the cursor is in a <style> tag w/out region
+ cssModel = getCSSModel(xNode);
+ if (cssModel == null)
+ return new ICompletionProposal[0];
+
+ // adjust offsets for embedded style
+ int offset = documentPosition;
+ int pos = 0;
+ keyIndexedNode = cssModel.getIndexedRegion(pos);
+ if (keyIndexedNode == null) {
+ keyIndexedNode = (IndexedRegion) ((ICSSModel) cssModel).getDocument();
+ }
+ arranger = new CSSProposalArranger(pos, (ICSSNode) keyIndexedNode, offset, (char) 0);
+
+ } else if (parent != null && parent.getNodeName().equalsIgnoreCase(HTML40Namespace.ElementName.STYLE)) {
+ // now we know the cursor is in a <style> tag with a region
+ // use the parent because that will be the <style> tag
+ cssModel = getCSSModel(parent);
+ if (cssModel == null)
+ return new ICompletionProposal[0];
+
+ // adjust offsets for embedded style
+ int offset = indexedNode.getStartOffset();
+ int pos = documentPosition - offset;
+ keyIndexedNode = cssModel.getIndexedRegion(pos);
+ if (keyIndexedNode == null) {
+ keyIndexedNode = (IndexedRegion) ((ICSSModel) cssModel).getDocument();
+ }
+ arranger = new CSSProposalArranger(pos, (ICSSNode) keyIndexedNode, offset, (char) 0);
+ } else if (indexedNode instanceof XMLNode) {
+ // get model for node w/ style attribute
+ cssModel = getCSSModel((XMLNode) indexedNode);
+ } else if (indexedNode instanceof ICSSNode) {
+ // when editing external CSS using CSS Designer, ICSSNode is
+ // passed.
+ ICSSDocument cssdoc = ((ICSSNode) indexedNode).getOwnerDocument();
+ if (cssdoc != null) {
+ cssModel = cssdoc.getModel();
+ }
+ } else if (indexedNode == null && isViewerEmpty(viewer) && viewer instanceof StructuredTextViewer) {
+ // the top of empty CSS Document
+ IStructuredModel model = ((StructuredTextViewer) viewer).getModel();
+ if (model instanceof ICSSModel) {
+ cssModel = (ICSSModel) model;
+ }
+ }
+
+ if (cssModel == null)
+ return new ICompletionProposal[0];
+
+ keyIndexedNode = cssModel.getIndexedRegion(documentPosition - fDocumentOffset);
+ if (keyIndexedNode == null) {
+ keyIndexedNode = (IndexedRegion) ((ICSSModel) cssModel).getDocument();
+ }
+
+ if (!(keyIndexedNode instanceof ICSSNode)) {
+ return new ICompletionProposal[0];
+ }
+
+ if (arranger == null) {
+ // if it's null at this point, it must be inline style for a tag,
+ // not embedded
+ arranger = new CSSProposalArranger(documentPosition, (ICSSNode) keyIndexedNode, fDocumentOffset, fQuote);
+ }
+ fDocumentOffset = 0;
+ ICompletionProposal[] temp = arranger.getProposals();
+
+ // add end tag if parent is not closed
+ ICompletionProposal endTag = XMLContentAssistUtilities.computeXMLEndTagProposal(viewer, documentPosition, indexedNode, HTML40Namespace.ElementName.STYLE, SharedXMLEditorPluginImageHelper.IMG_OBJ_TAG_GENERIC); //$NON-NLS-1$
+ if (endTag == null)
+ return temp;
+ else {
+ ICompletionProposal[] plusOne = new ICompletionProposal[temp.length + 1];
+ System.arraycopy(temp, 0, plusOne, 1, temp.length);
+ plusOne[0] = endTag;
+ return plusOne;
+ }
+ }
+
+ /**
+ * 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;
+ }
+
+ /**
+ * Get CSSModel for an indexed node
+ *
+ * @param indexedNode
+ * @return IStructuredModel
+ */
+ // private IStructuredModel getCSSModel(IndexedRegion indexedNode) {
+ // if (indexedNode == null) return null;
+ // Node node = (Node)indexedNode;
+ // INodeNotifier notifier = (INodeNotifier)node.getParentNode();
+ // if (notifier == null) return null;
+ // INodeAdapter adapter =
+ // StyleAdapterFactory.getInstance().adapt(notifier);
+ // if (adapter == null || !(adapter instanceof CSSModelAdapter)) return
+ // null;
+ // CSSModelAdapter modelAdapter = (CSSModelAdapter)adapter;
+ // return modelAdapter.getModel();
+ // }
+ /**
+ * Returns the CSSmodel for a given XML node.
+ *
+ * @param element
+ * @return IStructuredModel
+ */
+ private IStructuredModel getCSSModel(XMLNode element) {
+ if (element == null)
+ return null;
+ INodeAdapter adapter = StyleAdapterFactory.getInstance().adapt(element);
+ if (adapter == null || !(adapter instanceof ICSSModelAdapter))
+ return null;
+ ICSSModelAdapter modelAdapter = (ICSSModelAdapter) adapter;
+ return modelAdapter.getModel();
+ }
+
+ /**
+ * Returns information about possible contexts based on the specified
+ * location within the document that corresponds to the current cursor
+ * position within the text viewer.
+ *
+ * @param viewer
+ * the viewer whose document is used to compute the possible
+ * contexts
+ * @param documentPosition
+ * an offset within the document for which context information
+ * should be computed
+ * @return an array of context information objects or <code>null</code>
+ * if no context could be found
+ */
+ public org.eclipse.jface.text.contentassist.IContextInformation[] computeContextInformation(org.eclipse.jface.text.ITextViewer viewer, int documentOffset) {
+ return null;
+ }
+
+ /**
+ * Returns the characters which when entered by the user should
+ * automatically trigger the presentation of possible completions.
+ *
+ * @return the auto activation characters for completion proposal or
+ * <code>null</code> if no auto activation is desired
+ */
+ public char[] getCompletionProposalAutoActivationCharacters() {
+ return null;
+ }
+
+ /**
+ * Returns the characters which when entered by the user should
+ * automatically trigger the presentation of context information.
+ *
+ * @return the auto activation characters for presenting context
+ * information or <code>null</code> if no auto activation is
+ * desired
+ */
+ public char[] getContextInformationAutoActivationCharacters() {
+ return null;
+ }
+
+ /**
+ * Returns a validator used to determine when displayed context
+ * information should be dismissed. May only return <code>null</code> if
+ * the processor is incapable of computing context information.
+ *
+ * @return a context information validator, or <code>null</code> if the
+ * processor is incapable of computing context information
+ */
+ public org.eclipse.jface.text.contentassist.IContextInformationValidator getContextInformationValidator() {
+ return null;
+ }
+
+ /**
+ * Return the reason why computeProposals was not able to find any
+ * completions.
+ *
+ * @return an error message or null if no error occurred
+ */
+ public String getErrorMessage() {
+ return null;
+ }
+
+ /**
+ * Insert the method's description here. Creation date: (2001/05/22
+ * 10:37:05)
+ *
+ * @param offset
+ * int
+ */
+ public void setDocumentOffset(int offset) {
+ fDocumentOffset = offset;
+ }
+
+ /**
+ *
+ * @param quote
+ * char
+ */
+ public void setQuoteCharOfStyleAttribute(char quote) {
+ fQuote = quote;
+ }
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/contentassist/CSSProposalArranger.java b/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/contentassist/CSSProposalArranger.java
new file mode 100644
index 0000000000..854e87d1ca
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/contentassist/CSSProposalArranger.java
@@ -0,0 +1,169 @@
+/*****************************************************************************
+ * Copyright (c) 2004 IBM Corporation and others. All rights reserved. This
+ * program and the accompanying materials are made available under the terms
+ * of the Eclipse Public License v1.0 which accompanies this distribution, and
+ * is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors: IBM Corporation - initial API and implementation
+ ****************************************************************************/
+package org.eclipse.wst.css.ui.contentassist;
+
+
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.jface.text.contentassist.CompletionProposal;
+import org.eclipse.jface.text.contentassist.ICompletionProposal;
+import org.eclipse.wst.css.core.document.ICSSMediaRule;
+import org.eclipse.wst.css.core.document.ICSSNode;
+import org.eclipse.wst.css.core.document.ICSSPageRule;
+import org.eclipse.wst.css.core.document.ICSSPrimitiveValue;
+import org.eclipse.wst.css.core.document.ICSSStyleDeclItem;
+import org.eclipse.wst.css.core.document.ICSSStyleDeclaration;
+import org.eclipse.wst.css.core.document.ICSSStyleRule;
+import org.eclipse.wst.css.core.document.ICSSStyleSheet;
+import org.eclipse.wst.css.core.parser.CSSRegionContexts;
+import org.w3c.dom.css.CSSFontFaceRule;
+
+class CSSProposalArranger {
+
+ private List fProposals = new ArrayList();
+ private CSSContentAssistContext fContext = null;
+
+ /**
+ * CSSProposalArranger constructor comment.
+ */
+ private CSSProposalArranger() {
+ super();
+ }
+
+ /**
+ * CSSProposalArranger constructor comment.
+ */
+ CSSProposalArranger(int documentPosition, ICSSNode node, int documentOffset, char quote) {
+ super();
+ fContext = new CSSContentAssistContext(documentPosition, node, documentOffset, quote);
+ }
+
+ /**
+ *
+ */
+ void buildProposals() {
+ fProposals.clear();
+
+ /*
+ * String text; ICompletionProposal item; text = "---- Test
+ * Information ----"; item = new CompletionProposal("",
+ * fContext.getReplaceBegin(), 0, 0, null, text, null, null);
+ * fProposals.add(item);
+ *
+ * text = "Target: \"" + fContext.getRegionText() + "\"";
+ *
+ * item = new CompletionProposal("", fContext.getReplaceBegin(), 0, 0,
+ * null, text, null, null); fProposals.add(item);
+ *
+ * text = fContext.getTargetNode().getClass().toString(); int
+ * lastPeriodPos = text.lastIndexOf('.'); text = "Node: " +
+ * text.substring(lastPeriodPos + 1); item = new
+ * CompletionProposal("", fContext.getReplaceBegin(), 0, 0, null,
+ * text, null, null); fProposals.add(item);
+ */
+
+ ICSSNode targetNode = fContext.getTargetNode();
+ //int targetPos = fContext.getTargetPos();
+ if (targetNode instanceof ICSSStyleSheet) {
+ buildProposalsForAnyRule();
+ } else if ((targetNode instanceof ICSSMediaRule && fContext.isTargetPosAfterOf(CSSRegionContexts.CSS_LBRACE)) || (targetNode instanceof ICSSStyleRule && fContext.isTargetPosBeforeOf(CSSRegionContexts.CSS_LBRACE))) {
+ buildProposalsForAnyRule();
+ // buildProposalsForStyleRule();
+ } else if ((targetNode instanceof ICSSPageRule && fContext.isTargetPosBeforeOf(CSSRegionContexts.CSS_LBRACE))) {
+ buildProposalsForPageRulePseudoClass();
+ } else if ((targetNode instanceof ICSSStyleRule || targetNode instanceof CSSFontFaceRule || targetNode instanceof ICSSPageRule || targetNode instanceof ICSSStyleDeclaration) && (targetNode.getOwnerDocument() instanceof ICSSStyleDeclaration || fContext.targetFollows(CSSRegionContexts.CSS_DECLARATION_DELIMITER) || fContext.targetFollows(CSSRegionContexts.CSS_LBRACE))) {
+ buildProposalsForDeclarationName();
+ } else if (targetNode instanceof ICSSStyleDeclItem) {
+ if (fContext.isTargetPosAfterOf(CSSRegionContexts.CSS_DECLARATION_SEPARATOR)) {
+ buildProposalsForDeclarationValue();
+ } else {
+ buildProposalsForDeclarationName();
+ }
+ } else if (targetNode instanceof ICSSPrimitiveValue) {
+ buildProposalsForDeclarationValue();
+ }
+ /*
+ * else if (targetNode instanceof ICSSPrimitiveValue || ((targetNode
+ * instanceof ICSSStyleRule || targetNode instanceof CSSFontFaceRule ||
+ * targetNode instanceof ICSSStyleDeclaration || targetNode instanceof
+ * ICSSStyleDeclItem) &&
+ * fContext.isTargetPosAfterOf(CSSRegionContexts.COLON))) {
+ * buildProposalsForDeclarationValue(); }
+ */
+
+ // for Test
+ }
+
+ /**
+ *
+ */
+ void buildProposalsForAnyRule() {
+ CSSProposalGenerator generator;
+ generator = new CSSProposalGeneratorForAtmarkRule(fContext);
+ fProposals.addAll(generator.getProposals());
+ generator = new CSSProposalGeneratorForHTMLTag(fContext);
+ fProposals.addAll(generator.getProposals());
+ generator = new CSSProposalGeneratorForPseudoSelector(fContext);
+ fProposals.addAll(generator.getProposals());
+ }
+
+ /**
+ *
+ */
+ void buildProposalsForDeclarationName() {
+ CSSProposalGenerator generator;
+ generator = new CSSProposalGeneratorForDeclarationName(fContext);
+ fProposals.addAll(generator.getProposals());
+ }
+
+ /**
+ *
+ */
+ void buildProposalsForDeclarationValue() {
+ CSSProposalGenerator generator;
+ generator = new CSSProposalGeneratorForDeclarationValue(fContext);
+ fProposals.addAll(generator.getProposals());
+ }
+
+ /**
+ *
+ */
+ void buildProposalsForPageRulePseudoClass() {
+ CSSProposalGenerator generator;
+ generator = new CSSProposalGeneratorForPseudoSelector(fContext);
+ fProposals.addAll(generator.getProposals());
+ }
+
+ /**
+ *
+ */
+ void buildProposalsForStyleRule() {
+ CSSProposalGenerator generator;
+ generator = new CSSProposalGeneratorForHTMLTag(fContext);
+ fProposals.addAll(generator.getProposals());
+ generator = new CSSProposalGeneratorForPseudoSelector(fContext);
+ fProposals.addAll(generator.getProposals());
+ }
+
+ /**
+ *
+ */
+ ICompletionProposal[] getProposals() {
+ buildProposals();
+ ICompletionProposal[] proposalArray = new CompletionProposal[fProposals.size()];
+ Iterator iItem = fProposals.iterator();
+ for (int i = 0; iItem.hasNext(); i++) {
+ proposalArray[i] = (ICompletionProposal) iItem.next();
+ }
+ return proposalArray;
+ }
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/contentassist/CSSProposalGenerator.java b/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/contentassist/CSSProposalGenerator.java
new file mode 100644
index 0000000000..483645adfe
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/contentassist/CSSProposalGenerator.java
@@ -0,0 +1,209 @@
+/*****************************************************************************
+ * Copyright (c) 2004 IBM Corporation and others. All rights reserved. This
+ * program and the accompanying materials are made available under the terms
+ * of the Eclipse Public License v1.0 which accompanies this distribution, and
+ * is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors: IBM Corporation - initial API and implementation
+ ****************************************************************************/
+package org.eclipse.wst.css.ui.contentassist;
+
+
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.jface.text.contentassist.CompletionProposal;
+import org.eclipse.jface.text.contentassist.ICompletionProposal;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.wst.css.core.parser.CSSRegionContexts;
+import org.eclipse.wst.css.core.preferences.CSSPreferenceHelper;
+import org.eclipse.wst.css.core.util.RegionIterator;
+import org.eclipse.wst.css.ui.image.CSSImageHelper;
+import org.eclipse.wst.sse.core.text.ITextRegion;
+
+abstract class CSSProposalGenerator {
+
+
+ protected class StringAndOffset {
+ StringAndOffset(String string, int offset) {
+ this.fString = string;
+ this.fOffset = offset;
+ }
+
+ String fString;
+ int fOffset;
+ }
+
+ protected CSSContentAssistContext fContext = null;
+
+ /**
+ * CSSProposalGenerator constructor comment.
+ */
+ private CSSProposalGenerator() {
+ super();
+ }
+
+ CSSProposalGenerator(CSSContentAssistContext context) {
+ super();
+ fContext = context;
+ }
+
+ /**
+ *
+ */
+ protected boolean checkLeadingColon() {
+ boolean hasLeadingColon = false;
+ ITextRegion targetRegion = fContext.getTargetRegion();
+ if (targetRegion == null && 0 < fContext.getCursorPos()) {
+ targetRegion = fContext.getRegionByOffset(fContext.getCursorPos() - 1);
+ if (targetRegion != null && targetRegion.getType() == CSSRegionContexts.CSS_SELECTOR_PSEUDO) {
+ hasLeadingColon = true;
+ }
+ } else if (targetRegion != null) {
+ RegionIterator iterator = fContext.getRegionIterator();
+ if (iterator.hasPrev()) {
+ iterator.prev();
+ if (iterator.hasPrev() && iterator.prev().getType() == CSSRegionContexts.CSS_SELECTOR_PSEUDO) {
+ hasLeadingColon = true;
+ }
+ }
+ }
+ return hasLeadingColon;
+ }
+
+ /**
+ *
+ */
+ protected StringAndOffset generateBraces() {
+ StringBuffer buf = new StringBuffer();
+ String lineDelimiter = fContext.getStructuredDocument().getLineDelimiter();
+ CSSPreferenceHelper prefs = CSSPreferenceHelper.getInstance();
+ String indentStr = prefs.getIndentString();
+ if (prefs.isNewLineOnOpenBrace()) {
+ buf.append(lineDelimiter);
+ }
+ buf.append("{");//$NON-NLS-1$
+ if (prefs.isOnePropertyPerLine()) {
+ buf.append(lineDelimiter);
+ buf.append(indentStr);
+ } else {
+ buf.append(" ");//$NON-NLS-1$
+ }
+ int offset = buf.length();
+ if (prefs.isOnePropertyPerLine()) {
+ buf.append(lineDelimiter);
+ } else {
+ buf.append(" ");//$NON-NLS-1$
+ }
+ buf.append("}");//$NON-NLS-1$
+ return new StringAndOffset(buf.toString(), offset);
+ }
+
+ /**
+ *
+ */
+ protected StringAndOffset generateParenthesis() {
+ StringBuffer buf = new StringBuffer();
+ int offset;
+ buf.append("(");//$NON-NLS-1$
+ offset = 1;
+ buf.append(")");//$NON-NLS-1$
+ return new StringAndOffset(buf.toString(), offset);
+ }
+
+ /**
+ *
+ */
+ protected StringAndOffset generateQuotes() {
+ StringBuffer buf = new StringBuffer();
+ char quoteChar = getQuoteChar();
+ buf.append(quoteChar);
+ buf.append(quoteChar);
+ return new StringAndOffset(buf.toString(), 1);
+ }
+
+ /**
+ *
+ */
+ protected StringAndOffset generateSemicolon() {
+ StringBuffer buf = new StringBuffer();
+ int offset;
+ buf.append(";");//$NON-NLS-1$
+ offset = 0;
+ return new StringAndOffset(buf.toString(), offset);
+ }
+
+ /**
+ *
+ */
+ protected StringAndOffset generateURI() {
+ StringBuffer buf = new StringBuffer();
+ CSSPreferenceHelper prefs = CSSPreferenceHelper.getInstance();
+ char quoteChar = getQuoteChar();
+ buf.append("url(");//$NON-NLS-1$
+ if (prefs.isQuoteInURI()) {
+ buf.append(quoteChar);
+ }
+ int offset = buf.length();
+ if (prefs.isQuoteInURI()) {
+ buf.append(quoteChar);
+ }
+ buf.append(")");//$NON-NLS-1$
+ return new StringAndOffset(buf.toString(), offset);
+ }
+
+ abstract protected Iterator getCandidates();
+
+ List getProposals() {
+ List proposals = new ArrayList();
+
+ CSSImageHelper imageHelper = CSSImageHelper.getInstance();
+ Iterator i = getCandidates();
+ while (i.hasNext()) {
+ CSSCACandidate candidate = (CSSCACandidate) i.next();
+ Image image = imageHelper.getImage(candidate.getImageType());
+ ICompletionProposal item = new CompletionProposal(candidate.getReplacementString(), fContext.getReplaceBegin() + fContext.getDocumentOffset(), fContext.getTextToReplace().length(), candidate.getCursorPosition(), image, candidate.getDisplayString(), null, null);
+ proposals.add(item);
+ }
+
+ return proposals;
+ }
+
+ /**
+ *
+ * @return char
+ */
+ private char getQuoteChar() {
+ CSSPreferenceHelper prefs = CSSPreferenceHelper.getInstance();
+ String quoteStr = prefs.getQuoteString(fContext.getModel());
+ char quoteChar = (quoteStr != null && 0 < quoteStr.length()) ? quoteStr.charAt(0) : '"';
+ char attrQuote = fContext.getQuoteOfStyleAttribute();
+ if (attrQuote != 0) {
+ if (attrQuote == '"' && quoteChar == '"') {
+ quoteChar = '\'';
+ } else if (attrQuote == '\'' && quoteChar == '\'') {
+ quoteChar = '"';
+ }
+ }
+ return quoteChar;
+ }
+
+ /**
+ *
+ */
+ protected boolean isMatch(String text) {
+ String textToCompare = fContext.getTextToCompare();
+ if (textToCompare.length() == 0) {
+ return true;
+ } else {
+ return (text.toUpperCase().indexOf(textToCompare.toUpperCase()) == 0);
+ }
+ /*
+ * String textToReplace = fContext.getTextToReplace(); if
+ * (textToReplace.length() == 0) { return true; } else { return
+ * (text.toUpperCase().indexOf(textToReplace.toUpperCase()) == 0); }
+ */
+ }
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/contentassist/CSSProposalGeneratorForAtmarkRule.java b/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/contentassist/CSSProposalGeneratorForAtmarkRule.java
new file mode 100644
index 0000000000..1539037d77
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/contentassist/CSSProposalGeneratorForAtmarkRule.java
@@ -0,0 +1,293 @@
+/*****************************************************************************
+ * Copyright (c) 2004 IBM Corporation and others. All rights reserved. This
+ * program and the accompanying materials are made available under the terms
+ * of the Eclipse Public License v1.0 which accompanies this distribution, and
+ * is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors: IBM Corporation - initial API and implementation
+ ****************************************************************************/
+package org.eclipse.wst.css.ui.contentassist;
+
+
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.wst.css.core.document.ICSSCharsetRule;
+import org.eclipse.wst.css.core.document.ICSSDocument;
+import org.eclipse.wst.css.core.document.ICSSImportRule;
+import org.eclipse.wst.css.core.document.ICSSModel;
+import org.eclipse.wst.css.core.document.ICSSNode;
+import org.eclipse.wst.css.core.metamodel.CSSMMNode;
+import org.eclipse.wst.css.core.metamodel.util.CSSMetaModelUtil;
+import org.eclipse.wst.css.core.parser.CSSRegionContexts;
+import org.eclipse.wst.css.core.preferences.CSSPreferenceHelper;
+import org.eclipse.wst.css.core.util.SelectionCollector;
+import org.eclipse.wst.css.ui.image.CSSImageType;
+import org.eclipse.wst.sse.core.text.ITextRegion;
+
+class CSSProposalGeneratorForAtmarkRule extends CSSProposalGenerator {
+
+ private boolean fUseUpperCase = false;
+ private static final String CHARSET = "@charset";//$NON-NLS-1$
+ private static final String FONT_FACE = "@font-face";//$NON-NLS-1$
+ private static final String IMPORT = "@import";//$NON-NLS-1$
+ private static final String MEDIA = "@media";//$NON-NLS-1$
+ private static final String PAGE = "@page";//$NON-NLS-1$
+
+ /**
+ * CSSAtmarkRuleProposalGenerator constructor comment.
+ *
+ * @param context
+ * com.ibm.sed.contentassist.old.css.CSSContentAssistContext
+ */
+ CSSProposalGeneratorForAtmarkRule(CSSContentAssistContext context) {
+ super(context);
+ fUseUpperCase = CSSPreferenceHelper.getInstance().isIdentUpperCase();
+ }
+
+ /**
+ *
+ */
+ private CSSCACandidate getCandidateCharsetRule() {
+ // check content model
+ CSSMetaModelUtil util = new CSSMetaModelUtil(fContext.getMetaModel());
+ if (!util.collectNodesByType(CSSMMNode.TYPE_CHARSET_RULE).hasNext()) {
+ return null;
+ }
+
+ // check if embedded or not
+ if (fContext.getModel().getStyleSheetType() == ICSSModel.EMBEDDED) {
+ return null;
+ }
+
+ // check if caret precede all other rules.
+ int offset = fContext.getCursorPos();
+ if (0 < offset) {
+ SelectionCollector trav = new SelectionCollector();
+ trav.setRegion(0, offset - 1);
+ trav.apply(fContext.getModel().getDocument());
+ Iterator i = trav.getSelectedNodes().iterator();
+ while (i.hasNext()) {
+ Object obj = i.next();
+ if (obj instanceof ICSSNode && !(obj instanceof ICSSDocument)) {
+ return null;
+ }
+ }
+ }
+
+ int cursorPos = 0;
+ String ident = (fUseUpperCase) ? CHARSET.toUpperCase() : CHARSET.toLowerCase();
+ StringBuffer buf = new StringBuffer();
+ buf.append(ident);
+ buf.append(" ");//$NON-NLS-1$
+ cursorPos = buf.length();
+ StringAndOffset sao;
+ sao = generateQuotes();
+ buf.append(sao.fString);
+ cursorPos += sao.fOffset;
+ sao = generateSemicolon();
+ buf.append(sao.fString);
+
+ String text = buf.toString();
+
+ if (isMatch(text)) {
+ CSSCACandidate item = new CSSCACandidate();
+ item.setReplacementString(text);
+ item.setCursorPosition(cursorPos);
+ item.setDisplayString(ident);
+ item.setImageType(CSSImageType.RULE_CHARSET);
+ return item;
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ *
+ */
+ private CSSCACandidate getCandidateFontFaceRule() {
+ CSSMetaModelUtil util = new CSSMetaModelUtil(fContext.getMetaModel());
+ if (!util.collectNodesByType(CSSMMNode.TYPE_FONT_FACE_RULE).hasNext()) {
+ return null;
+ }
+
+ int cursorPos = 0;
+ String ident = (fUseUpperCase) ? FONT_FACE.toUpperCase() : FONT_FACE.toLowerCase();
+ StringBuffer buf = new StringBuffer();
+ buf.append(ident);
+ buf.append(" ");//$NON-NLS-1$
+ cursorPos = buf.length();
+ StringAndOffset sao;
+ sao = generateBraces();
+ buf.append(sao.fString);
+ cursorPos += sao.fOffset;
+
+ String text = buf.toString();
+
+ if (isMatch(text)) {
+ CSSCACandidate item = new CSSCACandidate();
+ item.setReplacementString(buf.toString());
+ item.setCursorPosition(cursorPos);
+ item.setDisplayString(ident);
+ item.setImageType(CSSImageType.RULE_FONTFACE);
+ return item;
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ *
+ */
+ private CSSCACandidate getCandidateImportRule() {
+ // check content model
+ CSSMetaModelUtil util = new CSSMetaModelUtil(fContext.getMetaModel());
+ if (!util.collectNodesByType(CSSMMNode.TYPE_IMPORT_RULE).hasNext()) {
+ return null;
+ }
+
+ // charset and import can precede import rule.
+ int offset = fContext.getCursorPos();
+ if (0 < offset) {
+ SelectionCollector trav = new SelectionCollector();
+ trav.setRegion(0, offset - 1);
+ trav.apply(fContext.getModel().getDocument());
+ Iterator i = trav.getSelectedNodes().iterator();
+ while (i.hasNext()) {
+ Object obj = i.next();
+ if (obj instanceof ICSSNode && !(obj instanceof ICSSDocument || obj instanceof ICSSCharsetRule || obj instanceof ICSSImportRule)) {
+ return null;
+ }
+ }
+ }
+
+ int cursorPos = 0;
+ String ident = (fUseUpperCase) ? IMPORT.toUpperCase() : IMPORT.toLowerCase();
+ StringBuffer buf = new StringBuffer();
+ buf.append(ident);
+ buf.append(" ");//$NON-NLS-1$
+ cursorPos = buf.length();
+ StringAndOffset sao;
+ sao = generateURI();
+ buf.append(sao.fString);
+ cursorPos += sao.fOffset;
+ sao = generateSemicolon();
+ buf.append(sao.fString);
+
+ String text = buf.toString();
+
+ if (isMatch(text)) {
+ CSSCACandidate item = new CSSCACandidate();
+ item.setReplacementString(buf.toString());
+ item.setCursorPosition(cursorPos);
+ item.setDisplayString(ident);
+ item.setImageType(CSSImageType.RULE_IMPORT);
+ return item;
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ *
+ */
+ private CSSCACandidate getCandidateMediaRule() {
+ CSSMetaModelUtil util = new CSSMetaModelUtil(fContext.getMetaModel());
+ if (!util.collectNodesByType(CSSMMNode.TYPE_MEDIA_RULE).hasNext()) {
+ return null;
+ }
+
+ int cursorPos = 0;
+ String ident = (fUseUpperCase) ? MEDIA.toUpperCase() : MEDIA.toLowerCase();
+ StringBuffer buf = new StringBuffer();
+ buf.append(ident);
+ buf.append(" ");//$NON-NLS-1$
+ cursorPos = buf.length() - 1;
+ StringAndOffset sao;
+ sao = generateBraces();
+ buf.append(sao.fString);
+
+ String text = buf.toString();
+
+ if (isMatch(text)) {
+ CSSCACandidate item = new CSSCACandidate();
+ item.setReplacementString(buf.toString());
+ item.setCursorPosition(cursorPos);
+ item.setDisplayString(ident);
+ item.setImageType(CSSImageType.RULE_MEDIA);
+ return item;
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ *
+ */
+ private CSSCACandidate getCandidatePageRule() {
+ CSSMetaModelUtil util = new CSSMetaModelUtil(fContext.getMetaModel());
+ if (!util.collectNodesByType(CSSMMNode.TYPE_PAGE_RULE).hasNext()) {
+ return null;
+ }
+
+ int cursorPos = 0;
+ String ident = (fUseUpperCase) ? PAGE.toUpperCase() : PAGE.toLowerCase();
+ StringBuffer buf = new StringBuffer();
+ buf.append(ident);
+ buf.append(" ");//$NON-NLS-1$
+ cursorPos = buf.length();
+ StringAndOffset sao;
+ sao = generateBraces();
+ buf.append(sao.fString);
+ cursorPos += sao.fOffset;
+
+ String text = buf.toString();
+
+ if (isMatch(text)) {
+ CSSCACandidate item = new CSSCACandidate();
+ item.setReplacementString(buf.toString());
+ item.setCursorPosition(cursorPos);
+ item.setDisplayString(ident);
+ item.setImageType(CSSImageType.RULE_PAGE);
+ return item;
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ * getCandidates method comment.
+ */
+ protected Iterator getCandidates() {
+ List candidates = new ArrayList();
+
+ ITextRegion region = fContext.getTargetRegionPrevious();
+ // ITextRegion region = fContext.getSignificantTargetRegion();
+ if (region != null) {
+ String type = region.getType();
+ if (type != CSSRegionContexts.CSS_RBRACE && type != CSSRegionContexts.CSS_DELIMITER) {
+ return candidates.iterator();
+ }
+ }
+
+ CSSCACandidate item;
+ if ((item = getCandidateImportRule()) != null) {
+ candidates.add(item);
+ }
+ if ((item = getCandidateCharsetRule()) != null) {
+ candidates.add(item);
+ }
+ if ((item = getCandidateMediaRule()) != null) {
+ candidates.add(item);
+ }
+ if ((item = getCandidatePageRule()) != null) {
+ candidates.add(item);
+ }
+ if ((item = getCandidateFontFaceRule()) != null) {
+ candidates.add(item);
+ }
+ return candidates.iterator();
+ }
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/contentassist/CSSProposalGeneratorForDeclarationName.java b/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/contentassist/CSSProposalGeneratorForDeclarationName.java
new file mode 100644
index 0000000000..6bf20406c4
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/contentassist/CSSProposalGeneratorForDeclarationName.java
@@ -0,0 +1,171 @@
+/*****************************************************************************
+ * Copyright (c) 2004 IBM Corporation and others. All rights reserved. This
+ * program and the accompanying materials are made available under the terms
+ * of the Eclipse Public License v1.0 which accompanies this distribution, and
+ * is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors: IBM Corporation - initial API and implementation
+ ****************************************************************************/
+package org.eclipse.wst.css.ui.contentassist;
+
+
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.wst.css.core.document.ICSSNode;
+import org.eclipse.wst.css.core.document.ICSSStyleDeclItem;
+import org.eclipse.wst.css.core.metamodel.CSSMMNode;
+import org.eclipse.wst.css.core.metamodel.util.CSSMetaModelUtil;
+import org.eclipse.wst.css.core.parser.CSSRegionContexts;
+import org.eclipse.wst.css.core.preferences.CSSPreferenceHelper;
+import org.eclipse.wst.css.ui.image.CSSImageType;
+import org.eclipse.wst.css.ui.preferences.CSSPreferenceManager;
+
+class CSSProposalGeneratorForDeclarationName extends CSSProposalGenerator {
+
+ /**
+ * CSSProposalGeneratorForDeclaration constructor comment.
+ *
+ * @param context
+ * com.ibm.sed.contentassist.old.css.CSSContentAssistContext
+ */
+ CSSProposalGeneratorForDeclarationName(CSSContentAssistContext context) {
+ super(context);
+ }
+
+ /**
+ * getCandidates method comment.
+ */
+ protected Iterator getCandidates() {
+ List candidates = new ArrayList();
+
+ CSSPreferenceHelper prefs = CSSPreferenceHelper.getInstance();
+ String preDelim = "";//$NON-NLS-1$
+ for (int i = 0; i < prefs.getSpacesPreDelimiter(); i++) {
+ preDelim += ' ';//$NON-NLS-1$
+ }
+ String postDelim = "";//$NON-NLS-1$
+ for (int i = 0; i < prefs.getSpacesPostDelimiter(); i++) {
+ postDelim += ' ';//$NON-NLS-1$
+ }
+
+ ICSSNode targetNode = fContext.getTargetNode();
+ boolean bFontRule = false;
+ for (ICSSNode node = targetNode; node != null; node = node.getParentNode()) {
+ if (node instanceof org.w3c.dom.css.CSSFontFaceRule) {
+ bFontRule = true;
+ break;
+ }
+ }
+
+ List names = new ArrayList();
+ CSSMetaModelUtil util = new CSSMetaModelUtil(fContext.getMetaModel());
+ Iterator iNames = util.collectNodesByType((bFontRule) ? CSSMMNode.TYPE_DESCRIPTOR : CSSMMNode.TYPE_PROPERTY);
+ while (iNames.hasNext()) {
+ CSSMMNode node = (CSSMMNode) iNames.next();
+ names.add(node);
+ }
+ sortNames(names);
+ //Collections.sort(names);
+
+ boolean bAddColon = true;
+ if (targetNode instanceof ICSSStyleDeclItem && fContext.targetHas(CSSRegionContexts.CSS_DECLARATION_SEPARATOR)) {
+ bAddColon = false;
+ }
+
+ Iterator i = names.iterator();
+ while (i.hasNext()) {
+ CSSMMNode node = (CSSMMNode) i.next();
+ String text = node.getName();
+ text = (prefs.isPropNameUpperCase()) ? text.toUpperCase() : text.toLowerCase();
+ if (!isMatch(text)) {
+ continue;
+ }
+
+ int cursorPos = 0;
+ StringBuffer buf = new StringBuffer();
+ buf.append(text);
+ buf.append(preDelim);
+ cursorPos = buf.length();
+ if (bAddColon) {
+ buf.append(':');//$NON-NLS-1$
+ buf.append(postDelim);
+ cursorPos += 1 + postDelim.length();
+ }
+ // if (! (targetNode instanceof ICSSStyleDeclItem)) {
+ // buf.append(';');//$NON-NLS-1$
+ // }
+
+ CSSCACandidate item = new CSSCACandidate();
+ item.setReplacementString(buf.toString());
+ item.setCursorPosition(cursorPos);
+ item.setDisplayString(text);
+ item.setImageType(getCategoryImageType(node));
+ candidates.add(item);
+ }
+
+ return candidates.iterator();
+ }
+
+ void sortNames(List names) {
+ CSSPreferenceManager prefMan = CSSPreferenceManager.getInstance();
+ final boolean categorize = prefMan.getContentAssistCategorize();
+
+ Collections.sort(names, new Comparator() {
+ public int compare(Object o1, Object o2) {
+ CSSMMNode node1 = (CSSMMNode) o1;
+ CSSMMNode node2 = (CSSMMNode) o2;
+ if (node1 == null) {
+ return 1;
+ } else if (node2 == null) {
+ return -1;
+ }
+ int diff = 0;
+ if (categorize) {
+ String category1 = node1.getAttribute("category"); //$NON-NLS-1$
+ String category2 = node2.getAttribute("category"); //$NON-NLS-1$
+ if (category1 == null) {
+ if (category2 == null) {
+ diff = 0;
+ } else {
+ return 1;
+ }
+ } else if (category2 == null) {
+ return -1;
+ } else {
+ diff = category1.compareTo(category2);
+ }
+ }
+ if (diff == 0) {
+ String name = node1.getName();
+ if (name == null) {
+ return 1;
+ } else {
+ return name.compareTo(node2.getName());
+ }
+ } else {
+ return diff;
+ }
+ }
+ });
+ }
+
+ /*
+ * retrieve default category icon name TODO: if node has "icon"(?), use
+ * it.
+ */
+ CSSImageType getCategoryImageType(CSSMMNode node) {
+ CSSImageType imageType = null;
+ if (node != null) {
+ String category = node.getAttribute("category"); //$NON-NLS-1$
+ if (category != null) {
+ imageType = CSSImageType.getImageType(category);
+ }
+ }
+ return (imageType == null) ? CSSImageType.CATEGORY_DEFAULT : imageType;
+ }
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/contentassist/CSSProposalGeneratorForDeclarationValue.java b/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/contentassist/CSSProposalGeneratorForDeclarationValue.java
new file mode 100644
index 0000000000..f80c0f9575
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/contentassist/CSSProposalGeneratorForDeclarationValue.java
@@ -0,0 +1,370 @@
+/*****************************************************************************
+ * Copyright (c) 2004 IBM Corporation and others. All rights reserved. This
+ * program and the accompanying materials are made available under the terms
+ * of the Eclipse Public License v1.0 which accompanies this distribution, and
+ * is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors: IBM Corporation - initial API and implementation
+ ****************************************************************************/
+package org.eclipse.wst.css.ui.contentassist;
+
+
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.wst.css.core.document.ICSSNode;
+import org.eclipse.wst.css.core.document.ICSSPrimitiveValue;
+import org.eclipse.wst.css.core.document.ICSSStyleDeclItem;
+import org.eclipse.wst.css.core.metamodel.CSSMMDescriptor;
+import org.eclipse.wst.css.core.metamodel.CSSMMFunction;
+import org.eclipse.wst.css.core.metamodel.CSSMMNode;
+import org.eclipse.wst.css.core.metamodel.CSSMMNumber;
+import org.eclipse.wst.css.core.metamodel.CSSMMProperty;
+import org.eclipse.wst.css.core.metamodel.CSSMMUnit;
+import org.eclipse.wst.css.core.metamodel.util.CSSFunctionID;
+import org.eclipse.wst.css.core.metamodel.util.CSSMetaModelUtil;
+import org.eclipse.wst.css.core.parser.CSSRegionContexts;
+import org.eclipse.wst.css.core.preferences.CSSPreferenceHelper;
+import org.eclipse.wst.css.core.util.CSSUtil;
+import org.eclipse.wst.css.core.util.RegionIterator;
+import org.eclipse.wst.css.ui.image.CSSImageType;
+import org.eclipse.wst.sse.core.IndexedRegion;
+import org.eclipse.wst.sse.core.text.IStructuredDocumentRegion;
+import org.eclipse.wst.sse.core.text.ITextRegion;
+import org.w3c.dom.css.CSSFontFaceRule;
+
+class CSSProposalGeneratorForDeclarationValue extends CSSProposalGenerator {
+
+ private static final String IMPORTANT = "!important"; //$NON-NLS-1$
+ private boolean fUseUpperCase;
+ private boolean fAppendSemiColon;
+
+ /**
+ * CSSProposalGeneratorForDeclarationValue constructor comment.
+ *
+ * @param context
+ * com.ibm.sed.contentassist.old.css.CSSContentAssistContext
+ */
+ CSSProposalGeneratorForDeclarationValue(CSSContentAssistContext context) {
+ super(context);
+ fUseUpperCase = CSSPreferenceHelper.getInstance().isPropValueUpperCase();
+ }
+
+ /**
+ *
+ */
+ private void addFunction(List candidates, CSSMMFunction prop) {
+ String text = prop.toString();
+ if (!isMatch(text)) {
+ return;
+ }
+
+ int cursorPos = 0;
+ StringBuffer buf = new StringBuffer();
+ if (prop.getName().equals(CSSFunctionID.F_URI)) {
+ StringAndOffset sao = generateURI();
+ buf.append(sao.fString);
+ cursorPos = sao.fOffset;
+ } else {
+ buf.append(prop.toString());
+ cursorPos = buf.length();
+ StringAndOffset sao = generateParenthesis();
+ buf.append(sao.fString);
+ cursorPos += sao.fOffset;
+ }
+
+ text = buf.toString();
+ text = (fUseUpperCase) ? text.toUpperCase() : text.toLowerCase();
+
+ CSSCACandidate item = new CSSCACandidate();
+ item.setReplacementString(text);
+ item.setCursorPosition(cursorPos);
+ item.setDisplayString(text);
+ item.setImageType(CSSImageType.VALUE_FUNCTION);
+ appendSemiColon(item);
+ candidates.add(item);
+ }
+
+ /**
+ *
+ */
+ private void addNumber(List candidates, CSSMMNumber prop) {
+ String fullText = fContext.getTextToReplace();
+ // skip number
+ int unitIndex = -1;
+ for (int i = 0; i < fullText.length(); i++) {
+ if (Character.isDigit(fullText.charAt(i))) {
+ unitIndex = i + 1;
+ } else {
+ break;
+ }
+ }
+
+ String unitSubText = ""; //$NON-NLS-1$
+ String numSubText = ""; //$NON-NLS-1$
+ if (0 <= unitIndex) {
+ numSubText = fullText.substring(0, unitIndex);
+ if (unitIndex < fullText.length()) {
+ unitSubText = fullText.substring(unitIndex);
+ }
+ } else {
+ unitSubText = fullText;
+ }
+
+ Iterator i = prop.getDescendants();
+ while (i.hasNext()) {
+ CSSMMUnit unit = (CSSMMUnit) i.next();
+ String unitString = unit.getUnitString();
+ if ((0 < unitSubText.length() && unitString.indexOf(unitSubText) != 0) || (0 < numSubText.length() && unitString.equals("#"))) { //$NON-NLS-1$
+ continue;
+ }
+
+ String text = numSubText + unitString;
+ text = (fUseUpperCase) ? text.toUpperCase() : text.toLowerCase();
+ CSSCACandidate item = new CSSCACandidate();
+ item.setReplacementString(text);
+ if (0 < numSubText.length() || text.equals("#")) { //$NON-NLS-1$
+ item.setCursorPosition(text.length());
+ } else {
+ item.setCursorPosition(0);
+ }
+ item.setDisplayString(text);
+ item.setImageType(CSSImageType.VALUE_NUMBER);
+ appendSemiColon(item);
+ candidates.add(item);
+ }
+ }
+
+ /**
+ *
+ */
+ private void checkSemiColon() {
+ fAppendSemiColon = false;
+
+ ITextRegion targetRegion = fContext.getTargetRegion();
+ if (targetRegion != null && targetRegion.getType() != CSSRegionContexts.CSS_DECLARATION_DELIMITER) {
+ // find trailing ":" or ";"
+ // if ":" before ";" is found, add ";"
+ RegionIterator iterator = fContext.getRegionIterator();
+ IStructuredDocumentRegion container = iterator.getStructuredDocumentRegion();
+ while (iterator.hasNext()) {
+ ITextRegion region = iterator.next();
+ if (iterator.getStructuredDocumentRegion() != container) {
+ break;
+ }
+ if (region.getType() == CSSRegionContexts.CSS_DECLARATION_SEPARATOR) {
+ fAppendSemiColon = true;
+ break;
+ }
+ }
+ if (!fAppendSemiColon) {
+ // second chance:
+ // leading IStructuredDocumentRegion is not ";"
+ IStructuredDocumentRegion nextStructuredDocumentRegion = CSSUtil.findNextSignificantNode(container);
+ if (CSSUtil.getStructuredDocumentRegionType(nextStructuredDocumentRegion) != CSSRegionContexts.CSS_DECLARATION_DELIMITER) {
+ fAppendSemiColon = true;
+ }
+ }
+ }
+ }
+
+ /**
+ *
+ */
+ private void appendSemiColon(CSSCACandidate item) {
+ if (fAppendSemiColon) {
+ String replacementString = item.getReplacementString();
+ item.setReplacementString(replacementString + ";"); //$NON-NLS-1$
+ int cursorPosition = item.getCursorPosition();
+ if (replacementString.length() <= cursorPosition) {
+ // cursorpos is tail of string
+ cursorPosition++;
+ item.setCursorPosition(cursorPosition);
+ }
+ }
+ }
+
+ /**
+ *
+ */
+ private void addSemiColon(List candidates) {
+ ICSSNode targetNode = fContext.getTargetNode();
+ if (targetNode instanceof ICSSStyleDeclItem) {
+ ICSSNode firstChild = targetNode.getFirstChild();
+ if (firstChild == null) {
+ return;
+ }
+ if (firstChild instanceof IndexedRegion) {
+ int startOffset = ((IndexedRegion) firstChild).getStartOffset();
+ if (fContext.getCursorPos() <= startOffset) {
+ return;
+ }
+ }
+ }
+
+ boolean bAddCloser = false;
+
+ ITextRegion targetRegion = fContext.getTargetRegion();
+ if (targetRegion != null && targetRegion.getType() != CSSRegionContexts.CSS_DECLARATION_DELIMITER) {
+ // find trailing ":" or ";"
+ // if ":" before ";" is found, add ";"
+ RegionIterator iterator = fContext.getRegionIterator();
+ IStructuredDocumentRegion container = iterator.getStructuredDocumentRegion();
+ while (iterator.hasNext()) {
+ ITextRegion region = iterator.next();
+ if (iterator.getStructuredDocumentRegion() != container) {
+ break;
+ }
+ if (region.getType() == CSSRegionContexts.CSS_DECLARATION_SEPARATOR) {
+ bAddCloser = true;
+ break;
+ }
+ }
+ if (!bAddCloser) {
+ // second chance:
+ // leading IStructuredDocumentRegion is not ";"
+ IStructuredDocumentRegion nextStructuredDocumentRegion = CSSUtil.findNextSignificantNode(container);
+ if (CSSUtil.getStructuredDocumentRegionType(nextStructuredDocumentRegion) != CSSRegionContexts.CSS_DECLARATION_DELIMITER) {
+ bAddCloser = true;
+ }
+ }
+ }
+
+ if (bAddCloser) {
+ CSSCACandidate item = new CSSCACandidate();
+ String text = fContext.getTextToReplace() + ";";//$NON-NLS-1$
+ item.setReplacementString(text);
+ item.setCursorPosition(text.length());
+ item.setDisplayString(";");//$NON-NLS-1$
+ item.setImageType(null);
+ candidates.add(item);
+ }
+ }
+
+ /**
+ *
+ */
+ private void addString(List candidates, String text) {
+ if (!isMatch(text)) {
+ return;
+ }
+
+ text = (fUseUpperCase) ? text.toUpperCase() : text.toLowerCase();
+
+ CSSCACandidate item = new CSSCACandidate();
+ item.setReplacementString(text);
+ item.setCursorPosition(text.length());
+ item.setDisplayString(text);
+ item.setImageType(CSSImageType.VALUE_STRING);
+ appendSemiColon(item);
+ candidates.add(item);
+ }
+
+ private void addImportant(List candidates) {
+ ICSSNode targetNode = fContext.getTargetNode();
+ while (targetNode instanceof ICSSPrimitiveValue) {
+ targetNode = targetNode.getParentNode();
+ }
+ if (!(targetNode instanceof ICSSStyleDeclItem)) {
+ return;
+ }
+ // 1. has no priority region
+ // 2. cursor position is after of last child
+ // 3. normal isMatch method
+ String priority = ((ICSSStyleDeclItem) targetNode).getPriority();
+ if (priority == null || priority.length() == 0) {
+ ICSSNode lastChild = targetNode.getLastChild();
+ if (lastChild instanceof IndexedRegion) {
+ int startOffset = ((IndexedRegion) lastChild).getStartOffset();
+ // int endOffset = ((IndexedRegion)lastChild).getEndOffset();
+ if (startOffset < fContext.getCursorPos() && isMatch(IMPORTANT)) {
+ CSSCACandidate item = new CSSCACandidate();
+ item.setReplacementString(IMPORTANT);
+ item.setCursorPosition(IMPORTANT.length());
+ item.setDisplayString(IMPORTANT);
+ item.setImageType(CSSImageType.VALUE_STRING);
+ appendSemiColon(item);
+ candidates.add(item);
+ }
+ }
+ }
+ }
+
+ /**
+ * getCandidates method comment.
+ */
+ protected Iterator getCandidates() {
+ List candidates = new ArrayList();
+
+ checkSemiColon(); // check should add semi-colon or not
+
+ String name = getPropertyName();
+ if (name != null) {
+ CSSMetaModelUtil util = new CSSMetaModelUtil(fContext.getMetaModel());
+ Iterator i = Collections.EMPTY_LIST.iterator();
+ if (isFontFaceRule()) {
+ CSSMMDescriptor desc = util.getDescriptor(name);
+ if (desc != null) {
+ i = desc.getValues();
+ }
+ } else {
+ CSSMMProperty prop = util.getProperty(name);
+ if (prop != null) {
+ i = prop.getValues();
+ }
+ }
+ while (i.hasNext()) {
+ CSSMMNode val = (CSSMMNode) i.next();
+ String valueType = val.getType();
+ if (valueType == CSSMMNode.TYPE_KEYWORD) {
+ addString(candidates, val.toString());
+ } else if (valueType == CSSMMNode.TYPE_NUMBER) {
+ addNumber(candidates, (CSSMMNumber) val);
+ } else if (valueType == CSSMMNode.TYPE_FUNCTION) {
+ addFunction(candidates, (CSSMMFunction) val);
+ }
+ }
+ }
+
+ addImportant(candidates);
+ addSemiColon(candidates);
+
+ return candidates.iterator();
+ }
+
+ /**
+ * @return java.lang.String
+ */
+ private String getPropertyName() {
+ ICSSNode targetNode = fContext.getTargetNode();
+ while (targetNode instanceof ICSSPrimitiveValue) {
+ targetNode = targetNode.getParentNode();
+ }
+ if (targetNode instanceof ICSSStyleDeclItem) {
+ return ((ICSSStyleDeclItem) targetNode).getPropertyName();
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ *
+ */
+ private boolean isFontFaceRule() {
+ ICSSNode targetNode = fContext.getTargetNode();
+ while (targetNode instanceof ICSSPrimitiveValue) {
+ targetNode = targetNode.getParentNode();
+ }
+ if (targetNode instanceof ICSSStyleDeclItem) {
+ targetNode = targetNode.getParentNode(); // get Declaration
+ if (targetNode != null) {
+ // inline style has no rule node
+ targetNode = targetNode.getParentNode(); // get rule
+ }
+ }
+ return (targetNode instanceof CSSFontFaceRule);
+ }
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/contentassist/CSSProposalGeneratorForHTMLTag.java b/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/contentassist/CSSProposalGeneratorForHTMLTag.java
new file mode 100644
index 0000000000..02f250123c
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/contentassist/CSSProposalGeneratorForHTMLTag.java
@@ -0,0 +1,157 @@
+/*****************************************************************************
+ * Copyright (c) 2004 IBM Corporation and others. All rights reserved. This
+ * program and the accompanying materials are made available under the terms
+ * of the Eclipse Public License v1.0 which accompanies this distribution, and
+ * is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors: IBM Corporation - initial API and implementation
+ ****************************************************************************/
+package org.eclipse.wst.css.ui.contentassist;
+
+
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Vector;
+
+import org.eclipse.wst.common.contentmodel.CMAttributeDeclaration;
+import org.eclipse.wst.common.contentmodel.CMDocument;
+import org.eclipse.wst.common.contentmodel.CMElementDeclaration;
+import org.eclipse.wst.common.contentmodel.CMNamedNodeMap;
+import org.eclipse.wst.css.core.document.ICSSModel;
+import org.eclipse.wst.css.core.document.ICSSStyleRule;
+import org.eclipse.wst.css.ui.image.CSSImageType;
+import org.eclipse.wst.html.core.contentmodel.HTMLCMDocumentFactory;
+import org.eclipse.wst.sse.core.contentmodel.CMDocType;
+import org.eclipse.wst.xml.core.document.DocumentTypeAdapter;
+import org.eclipse.wst.xml.core.document.XMLDocument;
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+
+class CSSProposalGeneratorForHTMLTag extends CSSProposalGenerator {
+
+ /**
+ * CSSStyleRuleProposalGenerator constructor comment.
+ *
+ * @param context
+ * com.ibm.sed.contentassist.old.css.CSSContentAssistContext
+ */
+ CSSProposalGeneratorForHTMLTag(CSSContentAssistContext context) {
+ super(context);
+
+ if (fHTMLTags == null) {
+ fHTMLTags = setupHTMLTags();
+ }
+ }
+
+ /**
+ * getCandidates method comment.
+ */
+ protected Iterator getCandidates() {
+ List candidates = new ArrayList();
+
+ if (checkLeadingColon()) {
+ return candidates.iterator();
+ }
+
+ // XHTML requires lower case
+ boolean bLowerCase = false;
+ if (fContext.getModel().getStyleSheetType() == ICSSModel.EMBEDDED) {
+ Node domNode = fContext.getModel().getOwnerDOMNode();
+ if (domNode != null && !(domNode instanceof Document)) {
+ domNode = domNode.getOwnerDocument();
+ if (domNode instanceof XMLDocument) {
+ DocumentTypeAdapter adapter = (DocumentTypeAdapter) ((XMLDocument) domNode).getAdapterFor(DocumentTypeAdapter.class);
+ if (adapter != null)
+ bLowerCase = (adapter.getTagNameCase() == DocumentTypeAdapter.LOWER_CASE);
+ }
+ }
+ }
+
+
+ int length = fHTMLTags.length;
+ for (int i = 0; i < length; i++) {
+ String tagText = fHTMLTags[i];
+ if (bLowerCase) {
+ tagText = tagText.toLowerCase();
+ }
+ if (!isMatch(tagText)) {
+ continue;
+ }
+
+ int cursorPos = 0;
+ StringBuffer buf = new StringBuffer();
+ buf.append(tagText);
+ cursorPos += tagText.length();
+ boolean inRule = (fContext.getTargetNode() instanceof ICSSStyleRule);
+ if (!inRule || fContext.getTextToReplace().length() == 0) {
+ buf.append(" ");//$NON-NLS-1$
+ cursorPos += 1;
+ }
+ if (!inRule) {
+ StringAndOffset sao = generateBraces();
+ buf.append(sao.fString);
+ cursorPos += sao.fOffset;
+ }
+
+ CSSCACandidate item = new CSSCACandidate();
+ item.setReplacementString(buf.toString());
+ item.setCursorPosition(cursorPos);
+ item.setDisplayString(tagText);
+ item.setImageType(CSSImageType.SELECTOR_TAG);
+ candidates.add(item);
+ }
+
+ return candidates.iterator();
+ }
+
+ /**
+ *
+ */
+ private static String[] setupHTMLTags() {
+ CMDocument cmdoc = HTMLCMDocumentFactory.getCMDocument(CMDocType.HTML_DOC_TYPE);
+ CMNamedNodeMap elements = cmdoc.getElements();
+ Vector names = new Vector();
+ int nElements = elements.getLength();
+ for (int i = 0; i < nElements; i++) {
+ CMElementDeclaration edec = (CMElementDeclaration) elements.item(i);
+ if (isAttrDefined(edec, HTML40Namespace.ATTR_NAME_STYLE)) {
+ names.add(edec.getElementName());
+ }
+ }
+ Collections.sort(names);
+ String[] tags = new String[names.size()];
+ Iterator iNames = names.iterator();
+ for (int i = 0; iNames.hasNext(); i++) {
+ tags[i] = (String) iNames.next();
+ }
+ return tags;
+ }
+
+ /**
+ *
+ */
+ private static boolean isAttrDefined(CMElementDeclaration edec, String attrName) {
+ if (edec == null) {
+ return false;
+ }
+ CMNamedNodeMap attrs = edec.getAttributes();
+ if (attrs == null) {
+ return false;
+ }
+ for (int i = 0; i < attrs.getLength(); i++) {
+ CMAttributeDeclaration attr = (CMAttributeDeclaration) attrs.item(i);
+ if (attr == null) {
+ continue;
+ }
+ if (attr.getAttrName().equalsIgnoreCase(attrName)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private static String[] fHTMLTags = null;
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/contentassist/CSSProposalGeneratorForPseudoSelector.java b/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/contentassist/CSSProposalGeneratorForPseudoSelector.java
new file mode 100644
index 0000000000..a9c92a5851
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/contentassist/CSSProposalGeneratorForPseudoSelector.java
@@ -0,0 +1,157 @@
+/*******************************************************************************
+ * Copyright (c) 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.ui.contentassist;
+
+
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.wst.css.core.document.ICSSNode;
+import org.eclipse.wst.css.core.document.ICSSPageRule;
+import org.eclipse.wst.css.core.document.ICSSStyleRule;
+import org.eclipse.wst.css.core.internal.parser.CSSRegionUtil;
+import org.eclipse.wst.css.core.metamodel.CSSMMNode;
+import org.eclipse.wst.css.core.metamodel.CSSMMSelector;
+import org.eclipse.wst.css.core.metamodel.util.CSSMMTypeCollector;
+import org.eclipse.wst.css.core.parser.CSSRegionContexts;
+import org.eclipse.wst.css.core.preferences.CSSPreferenceHelper;
+import org.eclipse.wst.css.ui.image.CSSImageType;
+import org.eclipse.wst.sse.core.text.ITextRegion;
+
+/**
+ *
+ */
+class CSSProposalGeneratorForPseudoSelector extends CSSProposalGenerator {
+
+ /**
+ * CSSProposalGeneratorForPseudoSelector constructor comment.
+ *
+ * @param context
+ * com.ibm.sed.contentassist.old.css.CSSContentAssistContext
+ */
+ CSSProposalGeneratorForPseudoSelector(CSSContentAssistContext context) {
+ super(context);
+ }
+
+ /**
+ * getCandidates method comment.
+ */
+ protected Iterator getCandidates() {
+ List candidates = new ArrayList();
+
+ boolean hasLeadingColon = checkLeadingColon();
+ String textToReplace = fContext.getTextToReplace();
+ if (!hasLeadingColon && 0 < textToReplace.length() && !textToReplace.equals(fContext.getTextToCompare())) {
+ // cursor placed midpoint of the region
+ return candidates.iterator();
+ }
+ ITextRegion region = fContext.getTargetRegion();
+ if (region != null) {
+ String type = region.getType();
+ if (type != CSSRegionContexts.CSS_S && !CSSRegionUtil.isSelectorBegginingType(type)) {
+ return candidates.iterator();
+ }
+ }
+
+ boolean useUpperCase = CSSPreferenceHelper.getInstance().isIdentUpperCase();
+
+ List tags = getSelectorTags();
+ Collections.sort(tags);
+ Iterator i = tags.iterator();
+ while (i.hasNext()) {
+ String text = (String) i.next();
+ if (hasLeadingColon && !isMatch(text)) {
+ continue;
+ }
+ text = (useUpperCase) ? text.toUpperCase() : text.toLowerCase();
+
+ int cursorPos = 0;
+ StringBuffer buf = new StringBuffer();
+ if (hasLeadingColon) {
+ buf.append(text.substring(1));
+ } else {
+ buf.append(textToReplace);
+ buf.append(text);
+ }
+ cursorPos += buf.length();
+
+ if (0 < buf.length()) {
+ boolean inRule = (fContext.getTargetNode() instanceof ICSSStyleRule || fContext.getTargetNode() instanceof ICSSPageRule);
+ if (!inRule || (textToReplace.length() == 0 && !hasLeadingColon)) {
+ buf.append(" ");//$NON-NLS-1$
+ cursorPos += 1;
+ }
+ if (!inRule) {
+ StringAndOffset sao = generateBraces();
+ buf.append(sao.fString);
+ cursorPos += sao.fOffset;
+ }
+ CSSCACandidate item = new CSSCACandidate();
+ item.setReplacementString(buf.toString());
+ item.setCursorPosition(cursorPos);
+ item.setDisplayString(text);
+ item.setImageType(CSSImageType.SELECTOR_PSEUDO);
+ candidates.add(item);
+ }
+ }
+
+ return candidates.iterator();
+ }
+
+ /**
+ *
+ */
+ List getSelectorTags() {
+ List tagList = new ArrayList();
+ ICSSNode targetNode = fContext.getTargetNode();
+ String rootType = (targetNode instanceof ICSSPageRule) ? CSSMMNode.TYPE_PAGE_RULE : CSSMMNode.TYPE_STYLE_RULE;
+
+ CSSMMTypeCollector collector = new CSSMMTypeCollector();
+ collector.collectNestedType(false);
+ collector.apply(fContext.getMetaModel(), rootType);
+ Iterator i;
+ i = collector.getNodes();
+ if (!i.hasNext()) {
+ return tagList;
+ }
+ CSSMMNode node = (CSSMMNode) i.next();
+ i = node.getChildNodes();
+ while (i.hasNext()) {
+ CSSMMNode child = (CSSMMNode) i.next();
+ if (child.getType() == CSSMMNode.TYPE_SELECTOR) {
+ String selType = ((CSSMMSelector) child).getSelectorType();
+ if (selType == CSSMMSelector.TYPE_PSEUDO_CLASS || selType == CSSMMSelector.TYPE_PSEUDO_ELEMENT) {
+ tagList.add(((CSSMMSelector) child).getSelectorString());
+ }
+ }
+ }
+ return tagList;
+ }
+
+ /**
+ *
+ */
+ protected boolean isMatch(String text) {
+ if (!super.isMatch(text)) {
+ ITextRegion region = fContext.getTargetRegion();
+ if (region != null && region.getType() == CSSRegionContexts.CSS_SELECTOR_PSEUDO) {
+ return true;
+ } else {
+ return false;
+ }
+ } else {
+ return true;
+ }
+ }
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/contentassist/HTML40Namespace.java b/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/contentassist/HTML40Namespace.java
new file mode 100644
index 0000000000..2d4ce3253b
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/contentassist/HTML40Namespace.java
@@ -0,0 +1,889 @@
+/*******************************************************************************
+ * Copyright (c) 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.ui.contentassist;
+
+
+
+/**
+ * Provide all names defined in the HTML 4.0? specification.
+ */
+public interface HTML40Namespace {
+
+ // Element names
+ public static interface ElementName {
+ public static final String A = "A"; //$NON-NLS-1$
+ public static final String ABBR = "ABBR"; //$NON-NLS-1$
+ public static final String ACRONYM = "ACRONYM"; //$NON-NLS-1$
+ public static final String ADDRESS = "ADDRESS"; //$NON-NLS-1$
+ public static final String APPLET = "APPLET"; //$NON-NLS-1$
+ public static final String AREA = "AREA"; //$NON-NLS-1$
+ public static final String B = "B"; //$NON-NLS-1$
+ public static final String BASE = "BASE"; //$NON-NLS-1$
+ public static final String BASEFONT = "BASEFONT"; //$NON-NLS-1$
+ public static final String BDO = "BDO"; //$NON-NLS-1$
+ public static final String BGSOUND = "BGSOUND"; // D205513
+ // //$NON-NLS-1$
+ public static final String BIG = "BIG"; //$NON-NLS-1$
+ public static final String BLINK = "BLINK"; //$NON-NLS-1$
+ public static final String BLOCKQUOTE = "BLOCKQUOTE"; //$NON-NLS-1$
+ public static final String BODY = "BODY"; //$NON-NLS-1$
+ public static final String BR = "BR"; //$NON-NLS-1$
+ public static final String BUTTON = "BUTTON"; //$NON-NLS-1$
+ public static final String CAPTION = "CAPTION"; //$NON-NLS-1$
+ public static final String CENTER = "CENTER"; //$NON-NLS-1$
+ public static final String CITE = "CITE"; //$NON-NLS-1$
+ public static final String CODE = "CODE"; //$NON-NLS-1$
+ public static final String COL = "COL"; //$NON-NLS-1$
+ public static final String COLGROUP = "COLGROUP"; //$NON-NLS-1$
+ public static final String DD = "DD"; //$NON-NLS-1$
+ public static final String DEL = "DEL"; //$NON-NLS-1$
+ public static final String DFN = "DFN"; //$NON-NLS-1$
+ public static final String DIR = "DIR"; //$NON-NLS-1$
+ public static final String DIV = "DIV"; //$NON-NLS-1$
+ public static final String DL = "DL"; //$NON-NLS-1$
+ public static final String DT = "DT"; //$NON-NLS-1$
+ public static final String EM = "EM"; //$NON-NLS-1$
+ public static final String EMBED = "EMBED"; //$NON-NLS-1$
+ public static final String FIELDSET = "FIELDSET"; //$NON-NLS-1$
+ public static final String FONT = "FONT"; //$NON-NLS-1$
+ public static final String FORM = "FORM"; //$NON-NLS-1$
+ public static final String FRAME = "FRAME"; //$NON-NLS-1$
+ public static final String FRAMESET = "FRAMESET"; //$NON-NLS-1$
+ public static final String H1 = "H1"; //$NON-NLS-1$
+ public static final String H2 = "H2"; //$NON-NLS-1$
+ public static final String H3 = "H3"; //$NON-NLS-1$
+ public static final String H4 = "H4"; //$NON-NLS-1$
+ public static final String H5 = "H5"; //$NON-NLS-1$
+ public static final String H6 = "H6"; //$NON-NLS-1$
+ public static final String HEAD = "HEAD"; //$NON-NLS-1$
+ public static final String HR = "HR"; //$NON-NLS-1$
+ public static final String HTML = "HTML"; //$NON-NLS-1$
+ public static final String I = "I"; //$NON-NLS-1$
+ public static final String IFRAME = "IFRAME"; //$NON-NLS-1$
+ public static final String IMG = "IMG"; //$NON-NLS-1$
+ public static final String INPUT = "INPUT"; //$NON-NLS-1$
+ public static final String INS = "INS"; //$NON-NLS-1$
+ public static final String ISINDEX = "ISINDEX"; //$NON-NLS-1$
+ public static final String KBD = "KBD"; //$NON-NLS-1$
+ public static final String LABEL = "LABEL"; //$NON-NLS-1$
+ public static final String LEGEND = "LEGEND"; //$NON-NLS-1$
+ public static final String LI = "LI"; //$NON-NLS-1$
+ public static final String LINK = "LINK"; //$NON-NLS-1$
+ public static final String MAP = "MAP"; //$NON-NLS-1$
+ public static final String MENU = "MENU"; //$NON-NLS-1$
+ public static final String META = "META"; //$NON-NLS-1$
+ public static final String NOBR = "NOBR"; // D205513 //$NON-NLS-1$
+ public static final String NOEMBED = "NOEMBED"; //$NON-NLS-1$
+ public static final String NOFRAMES = "NOFRAMES"; //$NON-NLS-1$
+ public static final String NOSCRIPT = "NOSCRIPT"; //$NON-NLS-1$
+ public static final String OBJECT = "OBJECT"; //$NON-NLS-1$
+ public static final String OL = "OL"; //$NON-NLS-1$
+ public static final String OPTGROUP = "OPTGROUP"; //$NON-NLS-1$
+ public static final String OPTION = "OPTION"; //$NON-NLS-1$
+ public static final String P = "P"; //$NON-NLS-1$
+ public static final String PARAM = "PARAM"; //$NON-NLS-1$
+ public static final String PRE = "PRE"; //$NON-NLS-1$
+ public static final String Q = "Q"; //$NON-NLS-1$
+ public static final String S = "S"; //$NON-NLS-1$
+ public static final String SAMP = "SAMP"; //$NON-NLS-1$
+ public static final String SCRIPT = "SCRIPT"; //$NON-NLS-1$
+ public static final String SELECT = "SELECT"; //$NON-NLS-1$
+ public static final String SMALL = "SMALL"; //$NON-NLS-1$
+ public static final String SPAN = "SPAN"; //$NON-NLS-1$
+ public static final String STRIKE = "STRIKE"; //$NON-NLS-1$
+ public static final String STRONG = "STRONG"; //$NON-NLS-1$
+ public static final String STYLE = "STYLE"; //$NON-NLS-1$
+ public static final String SUB = "SUB"; //$NON-NLS-1$
+ public static final String SUP = "SUP"; //$NON-NLS-1$
+ public static final String TABLE = "TABLE"; //$NON-NLS-1$
+ public static final String TBODY = "TBODY"; //$NON-NLS-1$
+ public static final String TD = "TD"; //$NON-NLS-1$
+ public static final String TEXTAREA = "TEXTAREA"; //$NON-NLS-1$
+ public static final String TFOOT = "TFOOT"; //$NON-NLS-1$
+ public static final String TH = "TH"; //$NON-NLS-1$
+ public static final String THEAD = "THEAD"; //$NON-NLS-1$
+ public static final String TITLE = "TITLE"; //$NON-NLS-1$
+ public static final String TR = "TR"; //$NON-NLS-1$
+ public static final String TT = "TT"; //$NON-NLS-1$
+ public static final String U = "U"; //$NON-NLS-1$
+ public static final String UL = "UL"; //$NON-NLS-1$
+ public static final String VAR = "VAR"; //$NON-NLS-1$
+ public static final String WBR = "WBR"; // D205513 //$NON-NLS-1$
+ public static final String MARQUEE = "MARQUEE"; //$NON-NLS-1$
+ public static final String SSI_CONFIG = "SSI:CONFIG"; // D210393
+ // //$NON-NLS-1$
+ public static final String SSI_ECHO = "SSI:ECHO"; //$NON-NLS-1$
+ public static final String SSI_EXEC = "SSI:EXEC"; //$NON-NLS-1$
+ public static final String SSI_FSIZE = "SSI:FSIZE"; //$NON-NLS-1$
+ public static final String SSI_FLASTMOD = "SSI:FLASTMOD"; //$NON-NLS-1$
+ public static final String SSI_INCLUDE = "SSI:INCLUDE"; //$NON-NLS-1$
+ public static final String SSI_PRINTENV = "SSI:PRINTENV"; //$NON-NLS-1$
+ public static final String SSI_SET = "SSI:SET"; //$NON-NLS-1$
+ public static final String WML_WML = "wml"; //$NON-NLS-1$
+ public static final String WML_CARD = "card"; //$NON-NLS-1$
+ public static final String WML_TEMPLATE = "template"; //$NON-NLS-1$
+ public static final String WML_ACCESS = "access"; //$NON-NLS-1$
+ public static final String WML_DO = "do"; //$NON-NLS-1$
+ public static final String WML_ONEVENT = "onevent"; //$NON-NLS-1$
+ public static final String WML_TIMER = "timer"; //$NON-NLS-1$
+ public static final String WML_ANCHOR = "anchor"; //$NON-NLS-1$
+ public static final String WML_PREV = "prev"; //$NON-NLS-1$
+ public static final String WML_REFRESH = "refresh"; //$NON-NLS-1$
+ public static final String WML_GO = "go"; //$NON-NLS-1$
+ public static final String WML_NOOP = "noop"; //$NON-NLS-1$
+ public static final String WML_SETVAR = "setvar"; //$NON-NLS-1$
+ public static final String WML_POSTFIELD = "postfield"; //$NON-NLS-1$
+ }
+
+ // Character Entities
+ public static interface EntityName {
+ public static final String AACUTE_U = "Aacute"; //$NON-NLS-1$
+ public static final String AACUTE_L = "aacute"; //$NON-NLS-1$
+ public static final String ACIRC_U = "Acirc"; //$NON-NLS-1$
+ public static final String ACIRC_L = "acirc"; //$NON-NLS-1$
+ public static final String ACUTE = "acute"; //$NON-NLS-1$
+ public static final String AELIG_U = "AElig"; //$NON-NLS-1$
+ public static final String AELIG_L = "aelig"; //$NON-NLS-1$
+ public static final String AGRAVE_U = "Agrave"; //$NON-NLS-1$
+ public static final String AGRAVE_L = "agrave"; //$NON-NLS-1$
+ public static final String ALEFSYM = "alefsym"; //$NON-NLS-1$
+ public static final String ALPHA_U = "Alpha"; //$NON-NLS-1$
+ public static final String ALPHA_L = "alpha"; //$NON-NLS-1$
+ public static final String AMP = "amp"; //$NON-NLS-1$
+ public static final String AND = "and"; //$NON-NLS-1$
+ public static final String ANG = "ang"; //$NON-NLS-1$
+ public static final String ARING_U = "Aring"; //$NON-NLS-1$
+ public static final String ARING_L = "aring"; //$NON-NLS-1$
+ public static final String ASYMP = "asymp"; //$NON-NLS-1$
+ public static final String ATILDE_U = "Atilde"; //$NON-NLS-1$
+ public static final String ATILDE_L = "atilde"; //$NON-NLS-1$
+ public static final String AUML_U = "Auml"; //$NON-NLS-1$
+ public static final String AUML_L = "auml"; //$NON-NLS-1$
+ public static final String BDQUO = "bdquo"; //$NON-NLS-1$
+ public static final String BETA_U = "Beta"; //$NON-NLS-1$
+ public static final String BETA_L = "beta"; //$NON-NLS-1$
+ public static final String BRVBAR = "brvbar"; //$NON-NLS-1$
+ public static final String BULL = "bull"; //$NON-NLS-1$
+ public static final String CAP = "cap"; //$NON-NLS-1$
+ public static final String CCEDIL_U = "Ccedil"; //$NON-NLS-1$
+ public static final String CCEDIL_L = "ccedil"; //$NON-NLS-1$
+ public static final String CEDIL = "cedil"; //$NON-NLS-1$
+ public static final String CENT = "cent"; //$NON-NLS-1$
+ public static final String CHI_U = "Chi"; //$NON-NLS-1$
+ public static final String CHI_L = "chi"; //$NON-NLS-1$
+ public static final String CIRC = "circ"; //$NON-NLS-1$
+ public static final String CLUBS = "clubs"; //$NON-NLS-1$
+ public static final String CONG = "cong"; //$NON-NLS-1$
+ public static final String COPY = "copy"; //$NON-NLS-1$
+ public static final String CRARR = "crarr"; //$NON-NLS-1$
+ public static final String CUP = "cup"; //$NON-NLS-1$
+ public static final String CURREN = "curren"; //$NON-NLS-1$
+ public static final String DAGGER_U = "Dagger"; //$NON-NLS-1$
+ public static final String DAGGER_L = "dagger"; //$NON-NLS-1$
+ public static final String DARR_U = "dArr"; //$NON-NLS-1$
+ public static final String DARR_L = "darr"; //$NON-NLS-1$
+ public static final String DEG = "deg"; //$NON-NLS-1$
+ public static final String DELTA_U = "Delta"; //$NON-NLS-1$
+ public static final String DELTA_L = "delta"; //$NON-NLS-1$
+ public static final String DIAMS = "diams"; //$NON-NLS-1$
+ public static final String DIVIDE = "divide"; //$NON-NLS-1$
+ public static final String EACUTE_U = "Eacute"; //$NON-NLS-1$
+ public static final String EACUTE_L = "eacute"; //$NON-NLS-1$
+ public static final String ECIRC_U = "Ecirc"; //$NON-NLS-1$
+ public static final String ECIRC_L = "ecirc"; //$NON-NLS-1$
+ public static final String EGRAVE_U = "Egrave"; //$NON-NLS-1$
+ public static final String EGRAVE_L = "egrave"; //$NON-NLS-1$
+ public static final String EMPTY = "empty"; //$NON-NLS-1$
+ public static final String EMSP = "emsp"; //$NON-NLS-1$
+ public static final String ENSP = "ensp"; //$NON-NLS-1$
+ public static final String EPSILON_U = "Epsilon"; //$NON-NLS-1$
+ public static final String EPSILON_L = "epsilon"; //$NON-NLS-1$
+ public static final String EQUIV = "equiv"; //$NON-NLS-1$
+ public static final String ETA_U = "Eta"; //$NON-NLS-1$
+ public static final String ETA_L = "eta"; //$NON-NLS-1$
+ public static final String ETH_U = "ETH"; //$NON-NLS-1$
+ public static final String ETH_L = "eth"; //$NON-NLS-1$
+ public static final String EUML_U = "Euml"; //$NON-NLS-1$
+ public static final String EUML_L = "euml"; //$NON-NLS-1$
+ public static final String EURO = "euro"; //$NON-NLS-1$
+ public static final String EXIST = "exist"; //$NON-NLS-1$
+ public static final String FNOF = "fnof"; //$NON-NLS-1$
+ public static final String FORALL = "forall"; //$NON-NLS-1$
+ public static final String FRAC12 = "frac12"; //$NON-NLS-1$
+ public static final String FRAC14 = "frac14"; //$NON-NLS-1$
+ public static final String FRAC34 = "frac34"; //$NON-NLS-1$
+ public static final String FRASL = "frasl"; //$NON-NLS-1$
+ public static final String GAMMA_U = "Gamma"; //$NON-NLS-1$
+ public static final String GAMMA_L = "gamma"; //$NON-NLS-1$
+ public static final String GE = "ge"; //$NON-NLS-1$
+ public static final String GT = "gt"; //$NON-NLS-1$
+ public static final String HARR_U = "hArr"; //$NON-NLS-1$
+ public static final String HARR_L = "harr"; //$NON-NLS-1$
+ public static final String HEARTS = "hearts"; //$NON-NLS-1$
+ public static final String HELLIP = "hellip"; //$NON-NLS-1$
+ public static final String IACUTE_U = "Iacute"; //$NON-NLS-1$
+ public static final String IACUTE_L = "iacute"; //$NON-NLS-1$
+ public static final String ICIRC_U = "Icirc"; //$NON-NLS-1$
+ public static final String ICIRC_L = "icirc"; //$NON-NLS-1$
+ public static final String IEXCL = "iexcl"; //$NON-NLS-1$
+ public static final String IGRAVE_U = "Igrave"; //$NON-NLS-1$
+ public static final String IGRAVE_L = "igrave"; //$NON-NLS-1$
+ public static final String IMAGE = "image"; //$NON-NLS-1$
+ public static final String INFIN = "infin"; //$NON-NLS-1$
+ public static final String INT = "int"; //$NON-NLS-1$
+ public static final String IOTA_U = "Iota"; //$NON-NLS-1$
+ public static final String IOTA_L = "iota"; //$NON-NLS-1$
+ public static final String IQUEST = "iquest"; //$NON-NLS-1$
+ public static final String ISIN = "isin"; //$NON-NLS-1$
+ public static final String IUML_U = "Iuml"; //$NON-NLS-1$
+ public static final String IUML_L = "iuml"; //$NON-NLS-1$
+ public static final String KAPPA_U = "Kappa"; //$NON-NLS-1$
+ public static final String KAPPA_L = "kappa"; //$NON-NLS-1$
+ public static final String LAMBDA_U = "Lambda"; //$NON-NLS-1$
+ public static final String LAMBDA_L = "lambda"; //$NON-NLS-1$
+ public static final String LANG = "lang"; //$NON-NLS-1$
+ public static final String LAQUO = "laquo"; //$NON-NLS-1$
+ public static final String LARR_U = "lArr"; //$NON-NLS-1$
+ public static final String LARR_L = "larr"; //$NON-NLS-1$
+ public static final String LCEIL = "lceil"; //$NON-NLS-1$
+ public static final String LDQUO = "ldquo"; //$NON-NLS-1$
+ public static final String LE = "le"; //$NON-NLS-1$
+ public static final String LFLOOR = "lfloor"; //$NON-NLS-1$
+ public static final String LOWAST = "lowast"; //$NON-NLS-1$
+ public static final String LOZ = "loz"; //$NON-NLS-1$
+ public static final String LRM = "lrm"; //$NON-NLS-1$
+ public static final String LSAQUO = "lsaquo"; //$NON-NLS-1$
+ public static final String LSQUO = "lsquo"; //$NON-NLS-1$
+ public static final String LT = "lt"; //$NON-NLS-1$
+ public static final String MACR = "macr"; //$NON-NLS-1$
+ public static final String MDASH = "mdash"; //$NON-NLS-1$
+ public static final String MICRO = "micro"; //$NON-NLS-1$
+ public static final String MIDDOT = "middot"; //$NON-NLS-1$
+ public static final String MINUS = "minus"; //$NON-NLS-1$
+ public static final String MU_U = "Mu"; //$NON-NLS-1$
+ public static final String MU_L = "mu"; //$NON-NLS-1$
+ public static final String NABLA = "nabla"; //$NON-NLS-1$
+ public static final String NBSP = "nbsp"; //$NON-NLS-1$
+ public static final String NDASH = "ndash"; //$NON-NLS-1$
+ public static final String NE = "ne"; //$NON-NLS-1$
+ public static final String NI = "ni"; //$NON-NLS-1$
+ public static final String NOT = "not"; //$NON-NLS-1$
+ public static final String NOTIN = "notin"; //$NON-NLS-1$
+ public static final String NSUB = "nsub"; //$NON-NLS-1$
+ public static final String NTILDE_U = "Ntilde"; //$NON-NLS-1$
+ public static final String NTILDE_L = "ntilde"; //$NON-NLS-1$
+ public static final String NU_U = "Nu"; //$NON-NLS-1$
+ public static final String NU_L = "nu"; //$NON-NLS-1$
+ public static final String OACUTE_U = "Oacute"; //$NON-NLS-1$
+ public static final String OACUTE_L = "oacute"; //$NON-NLS-1$
+ public static final String OCIRC_U = "Ocirc"; //$NON-NLS-1$
+ public static final String OCIRC_L = "ocirc"; //$NON-NLS-1$
+ public static final String OELIG_U = "OElig"; //$NON-NLS-1$
+ public static final String OELIG_L = "oelig"; //$NON-NLS-1$
+ public static final String OGRAVE_U = "Ograve"; //$NON-NLS-1$
+ public static final String OGRAVE_L = "ograve"; //$NON-NLS-1$
+ public static final String OLINE = "oline"; //$NON-NLS-1$
+ public static final String OMEGA_U = "Omega"; //$NON-NLS-1$
+ public static final String OMEGA_L = "omega"; //$NON-NLS-1$
+ public static final String OMICRON_U = "Omicron"; //$NON-NLS-1$
+ public static final String OMICRON_L = "omicron"; //$NON-NLS-1$
+ public static final String OPLUS = "oplus"; //$NON-NLS-1$
+ public static final String OR = "or"; //$NON-NLS-1$
+ public static final String ORDF = "ordf"; //$NON-NLS-1$
+ public static final String ORDM = "ordm"; //$NON-NLS-1$
+ public static final String OSLASH_U = "Oslash"; //$NON-NLS-1$
+ public static final String OSLASH_L = "oslash"; //$NON-NLS-1$
+ public static final String OTILDE_U = "Otilde"; //$NON-NLS-1$
+ public static final String OTILDE_L = "otilde"; //$NON-NLS-1$
+ public static final String OTIMES = "otimes"; //$NON-NLS-1$
+ public static final String OUML_U = "Ouml"; //$NON-NLS-1$
+ public static final String OUML_L = "ouml"; //$NON-NLS-1$
+ public static final String PARA = "para"; //$NON-NLS-1$
+ public static final String PART = "part"; //$NON-NLS-1$
+ public static final String PERMIL = "permil"; //$NON-NLS-1$
+ public static final String PERP = "perp"; //$NON-NLS-1$
+ public static final String PHI_U = "Phi"; //$NON-NLS-1$
+ public static final String PHI_L = "phi"; //$NON-NLS-1$
+ public static final String PI_U = "Pi"; //$NON-NLS-1$
+ public static final String PI_L = "pi"; //$NON-NLS-1$
+ public static final String PIV = "piv"; //$NON-NLS-1$
+ public static final String PLUSMN = "plusmn"; //$NON-NLS-1$
+ public static final String POUND = "pound"; //$NON-NLS-1$
+ public static final String PRIME_U = "Prime"; //$NON-NLS-1$
+ public static final String PRIME_L = "prime"; //$NON-NLS-1$
+ public static final String PROD = "prod"; //$NON-NLS-1$
+ public static final String PROP = "prop"; //$NON-NLS-1$
+ public static final String PSI_U = "Psi"; //$NON-NLS-1$
+ public static final String PSI_L = "psi"; //$NON-NLS-1$
+ public static final String QUOT = "quot"; //$NON-NLS-1$
+ public static final String RADIC = "radic"; //$NON-NLS-1$
+ public static final String RANG = "rang"; //$NON-NLS-1$
+ public static final String RAQUO = "raquo"; //$NON-NLS-1$
+ public static final String RARR_U = "rArr"; //$NON-NLS-1$
+ public static final String RARR_L = "rarr"; //$NON-NLS-1$
+ public static final String RCEIL = "rceil"; //$NON-NLS-1$
+ public static final String RDQUO = "rdquo"; //$NON-NLS-1$
+ public static final String REAL = "real"; //$NON-NLS-1$
+ public static final String REG = "reg"; //$NON-NLS-1$
+ public static final String RFLOOR = "rfloor"; //$NON-NLS-1$
+ public static final String RHO_U = "Rho"; //$NON-NLS-1$
+ public static final String RHO_L = "rho"; //$NON-NLS-1$
+ public static final String RLM = "rlm"; //$NON-NLS-1$
+ public static final String RSAQUO = "rsaquo"; //$NON-NLS-1$
+ public static final String RSQUO = "rsquo"; //$NON-NLS-1$
+ public static final String SBQUO = "sbquo"; //$NON-NLS-1$
+ public static final String SCARON_U = "Scaron"; //$NON-NLS-1$
+ public static final String SCARON_L = "scaron"; //$NON-NLS-1$
+ public static final String SDOT = "sdot"; //$NON-NLS-1$
+ public static final String SECT = "sect"; //$NON-NLS-1$
+ public static final String SHY = "shy"; //$NON-NLS-1$
+ public static final String SIGMA_U = "Sigma"; //$NON-NLS-1$
+ public static final String SIGMA_L = "sigma"; //$NON-NLS-1$
+ public static final String SIGMAF = "sigmaf"; //$NON-NLS-1$
+ public static final String SIM = "sim"; //$NON-NLS-1$
+ public static final String SPADES = "spades"; //$NON-NLS-1$
+ public static final String SUB = "sub"; //$NON-NLS-1$
+ public static final String SUBE = "sube"; //$NON-NLS-1$
+ public static final String SUM = "sum"; //$NON-NLS-1$
+ public static final String SUP = "sup"; //$NON-NLS-1$
+ public static final String SUP1 = "sup1"; //$NON-NLS-1$
+ public static final String SUP2 = "sup2"; //$NON-NLS-1$
+ public static final String SUP3 = "sup3"; //$NON-NLS-1$
+ public static final String SUPE = "supe"; //$NON-NLS-1$
+ public static final String SZLIG = "szlig"; //$NON-NLS-1$
+ public static final String TAU_U = "Tau"; //$NON-NLS-1$
+ public static final String TAU_L = "tau"; //$NON-NLS-1$
+ public static final String THERE4 = "there4"; //$NON-NLS-1$
+ public static final String THETA_U = "Theta"; //$NON-NLS-1$
+ public static final String THETA_L = "theta"; //$NON-NLS-1$
+ public static final String THETASYM = "thetasym"; //$NON-NLS-1$
+ public static final String THINSP = "thinsp"; //$NON-NLS-1$
+ public static final String THORN_U = "THORN"; //$NON-NLS-1$
+ public static final String THORN_L = "thorn"; //$NON-NLS-1$
+ public static final String TILDE = "tilde"; //$NON-NLS-1$
+ public static final String TIMES = "times"; //$NON-NLS-1$
+ public static final String TRADE = "trade"; //$NON-NLS-1$
+ public static final String UACUTE_U = "Uacute"; //$NON-NLS-1$
+ public static final String UACUTE_L = "uacute"; //$NON-NLS-1$
+ public static final String UARR_U = "uArr"; //$NON-NLS-1$
+ public static final String UARR_L = "uarr"; //$NON-NLS-1$
+ public static final String UCIRC_U = "Ucirc"; //$NON-NLS-1$
+ public static final String UCIRC_L = "ucirc"; //$NON-NLS-1$
+ public static final String UGRAVE_U = "Ugrave"; //$NON-NLS-1$
+ public static final String UGRAVE_L = "ugrave"; //$NON-NLS-1$
+ public static final String UML = "uml"; //$NON-NLS-1$
+ public static final String UPSIH = "upsih"; //$NON-NLS-1$
+ public static final String UPSILON_U = "Upsilon"; //$NON-NLS-1$
+ public static final String UPSILON_L = "upsilon"; //$NON-NLS-1$
+ public static final String UUML_U = "Uuml"; //$NON-NLS-1$
+ public static final String UUML_L = "uuml"; //$NON-NLS-1$
+ public static final String WEIERP = "weierp"; //$NON-NLS-1$
+ public static final String XI_U = "Xi"; //$NON-NLS-1$
+ public static final String XI_L = "xi"; //$NON-NLS-1$
+ public static final String YACUTE_U = "Yacute"; //$NON-NLS-1$
+ public static final String YACUTE_L = "yacute"; //$NON-NLS-1$
+ public static final String YEN = "yen"; //$NON-NLS-1$
+ public static final String YUML_U = "Yuml"; //$NON-NLS-1$
+ public static final String YUML_L = "yuml"; //$NON-NLS-1$
+ public static final String ZETA_U = "Zeta"; //$NON-NLS-1$
+ public static final String ZETA_L = "zeta"; //$NON-NLS-1$
+ public static final String ZWJ = "zwj"; //$NON-NLS-1$
+ public static final String ZWNJ = "zwnj"; //$NON-NLS-1$
+ }
+
+ public static final String HTML40_URI = "http://www.w3.org/TR/REC-html40/frameset.dtd"; //$NON-NLS-1$
+ public static final String HTML40_TAG_PREFIX = ""; //$NON-NLS-1$
+ // global attribute names
+ public static final String ATTR_NAME_ID = "id"; // %coreattrs;
+ // //$NON-NLS-1$
+ public static final String ATTR_NAME_CLASS = "class"; // %coreattrs;
+ // //$NON-NLS-1$
+ public static final String ATTR_NAME_STYLE = "style"; // %coreattrs;
+ // //$NON-NLS-1$
+ public static final String ATTR_NAME_TITLE = "title"; // %coreattrs;
+ // //$NON-NLS-1$
+ public static final String ATTR_NAME_LANG = "lang"; // %i18n;
+ // //$NON-NLS-1$
+ public static final String ATTR_NAME_DIR = "dir"; // %i18n; //$NON-NLS-1$
+ public static final String ATTR_NAME_ONCLICK = "onclick"; // %events;
+ // //$NON-NLS-1$
+ public static final String ATTR_NAME_ONDBLCLICK = "ondblclick"; // %events;
+ // //$NON-NLS-1$
+ public static final String ATTR_NAME_ONMOUSEDOWN = "onmousedown"; // %events;
+ // //$NON-NLS-1$
+ public static final String ATTR_NAME_ONMOUSEUP = "onmouseup"; // %events;
+ // //$NON-NLS-1$
+ public static final String ATTR_NAME_ONMOUSEOVER = "onmouseover"; // %events;
+ // //$NON-NLS-1$
+ public static final String ATTR_NAME_ONMOUSEMOVE = "onmousemove"; // %events;
+ // //$NON-NLS-1$
+ public static final String ATTR_NAME_ONMOUSEOUT = "onmouseout"; // %events;
+ // //$NON-NLS-1$
+ public static final String ATTR_NAME_ONKEYPRESS = "onkeypress"; // %events;
+ // //$NON-NLS-1$
+ public static final String ATTR_NAME_ONKEYDOWN = "onkeydown"; // %events;
+ // //$NON-NLS-1$
+ public static final String ATTR_NAME_ONKEYUP = "onkeyup"; // %events;
+ // //$NON-NLS-1$
+ public static final String ATTR_NAME_ONHELP = "onhelp"; // %events;
+ // //$NON-NLS-1$
+ public static final String ATTR_NAME_BGCOLOR = "bgcolor"; // %bodycolor;,
+ // TABLE
+ // //$NON-NLS-1$
+ public static final String ATTR_NAME_TEXT = "text"; // %bodycolor;
+ // //$NON-NLS-1$
+ public static final String ATTR_NAME_LINK = "link"; // %bodycolor;
+ // //$NON-NLS-1$
+ public static final String ATTR_NAME_VLINK = "vlink"; // %bodycolor;
+ // //$NON-NLS-1$
+ public static final String ATTR_NAME_ALINK = "alink"; // %bodycolor;
+ // //$NON-NLS-1$
+ public static final String ATTR_NAME_VERSION = "version"; // HTML
+ // //$NON-NLS-1$
+ public static final String ATTR_NAME_PROFILE = "profile"; // HEAD
+ // //$NON-NLS-1$
+ public static final String ATTR_NAME_ONLOAD = "onload"; // BODY
+ // //$NON-NLS-1$
+ public static final String ATTR_NAME_ONUNLOAD = "onunload"; // BODY
+ // //$NON-NLS-1$
+ public static final String ATTR_NAME_BACKGROUND = "background"; // BODY,
+ // TABLE
+ // //$NON-NLS-1$
+ public static final String ATTR_NAME_SRC = "src"; // IMG //$NON-NLS-1$
+ public static final String ATTR_NAME_ALT = "alt"; // IMG,AREA
+ // //$NON-NLS-1$
+ public static final String ATTR_NAME_LONGDESC = "longdesc"; // IMG
+ // //$NON-NLS-1$
+ public static final String ATTR_NAME_NAME = "name"; // IMG //$NON-NLS-1$
+ public static final String ATTR_NAME_HEIGHT = "height"; // IMG, TABLE
+ // //$NON-NLS-1$
+ public static final String ATTR_NAME_WIDTH = "width"; // IMG, TABLE,HR
+ // //$NON-NLS-1$
+ public static final String ATTR_NAME_USEMAP = "usemap"; // IMG
+ // //$NON-NLS-1$
+ public static final String ATTR_NAME_ISMAP = "ismap"; // IMG //$NON-NLS-1$
+ public static final String ATTR_NAME_ALIGN = "align"; // IMG, TABLE,HR
+ // //$NON-NLS-1$
+ public static final String ATTR_NAME_BORDER = "border"; // IMG, TABLE
+ // //$NON-NLS-1$
+ public static final String ATTR_NAME_HSPACE = "hspace"; // IMG
+ // //$NON-NLS-1$
+ public static final String ATTR_NAME_VSPACE = "vspace"; // IMG
+ // //$NON-NLS-1$
+ public static final String ATTR_NAME_MAPFILE = "mapfile"; // IMG
+ // //$NON-NLS-1$
+ public static final String ATTR_NAME_SUMMARY = "summary"; // TABLE
+ // //$NON-NLS-1$
+ public static final String ATTR_NAME_FRAME = "frame"; // TABLE
+ // //$NON-NLS-1$
+ public static final String ATTR_NAME_RULES = "rules"; // TABLE
+ // //$NON-NLS-1$
+ public static final String ATTR_NAME_CELLSPACING = "cellspacing"; // TABLE
+ // //$NON-NLS-1$
+ public static final String ATTR_NAME_CELLPADDING = "cellpadding"; // TABLE
+ // //$NON-NLS-1$
+ public static final String ATTR_NAME_DATAPAGESIZE = "datapagesize"; // TABLE,HR
+ // //$NON-NLS-1$
+ public static final String ATTR_NAME_COLOR = "color"; // BASEFONT,FONT
+ // //$NON-NLS-1$
+ public static final String ATTR_NAME_FACE = "face"; // BASEFONT,FONT
+ // //$NON-NLS-1$
+ public static final String ATTR_NAME_SIZE = "size"; // BASEFONT,FONT
+ // //$NON-NLS-1$
+ public static final String ATTR_NAME_CLEAR = "clear"; // BR //$NON-NLS-1$
+ public static final String ATTR_NAME_SHAPE = "shape"; // AREA
+ // //$NON-NLS-1$
+ public static final String ATTR_NAME_COORDS = "coords"; // AREA
+ // //$NON-NLS-1$
+ public static final String ATTR_NAME_HREF = "href"; // AREA //$NON-NLS-1$
+ public static final String ATTR_NAME_TARGET = "target"; // AREA
+ // //$NON-NLS-1$
+ public static final String ATTR_NAME_NOHREF = "nohref"; // AREA
+ // //$NON-NLS-1$
+ public static final String ATTR_NAME_TABINDEX = "tabindex"; // AREA
+ // //$NON-NLS-1$
+ public static final String ATTR_NAME_ACCESSKEY = "accesskey"; // AREA
+ // //$NON-NLS-1$
+ public static final String ATTR_NAME_ONFOCUS = "onfocus"; // AREA
+ // //$NON-NLS-1$
+ public static final String ATTR_NAME_ONBLUR = "onblur"; // AREA
+ // //$NON-NLS-1$
+ public static final String ATTR_NAME_CHARSET = "charset"; // LINK
+ // //$NON-NLS-1$
+ public static final String ATTR_NAME_HREFLANG = "hreflang"; // LINK
+ // //$NON-NLS-1$
+ public static final String ATTR_NAME_TYPE = "type"; // LINK //$NON-NLS-1$
+ public static final String ATTR_NAME_REL = "rel"; // LINK //$NON-NLS-1$
+ public static final String ATTR_NAME_REV = "rev"; // LINK //$NON-NLS-1$
+ public static final String ATTR_NAME_MEDIA = "media"; // LINK
+ // //$NON-NLS-1$
+ public static final String ATTR_NAME_VALUE = "value"; // PARAM
+ // //$NON-NLS-1$
+ public static final String ATTR_NAME_VALUETYPE = "valuetype"; // PARAM
+ // //$NON-NLS-1$
+ public static final String ATTR_NAME_NOSHADE = "noshade"; // HR
+ // //$NON-NLS-1$
+ public static final String ATTR_NAME_CHECKED = "checked"; // INPUT
+ // //$NON-NLS-1$
+ public static final String ATTR_NAME_DISABLED = "disabled"; // INPUT
+ // //$NON-NLS-1$
+ public static final String ATTR_NAME_READONLY = "readonly"; // INPUT
+ // //$NON-NLS-1$
+ public static final String ATTR_NAME_MAXLENGTH = "maxlength"; // INPUT
+ // //$NON-NLS-1$
+ public static final String ATTR_NAME_ONSELECT = "onselect"; // INPUT
+ // //$NON-NLS-1$
+ public static final String ATTR_NAME_ONCHANGE = "onchange"; // INPUT
+ // //$NON-NLS-1$
+ public static final String ATTR_NAME_ACCEPT = "accept"; // INPUT
+ // //$NON-NLS-1$
+ public static final String ATTR_NAME_ISTYLE = "istyle"; // INPUT
+ // //$NON-NLS-1$
+ public static final String ATTR_NAME_CHAR = "char"; // COL //$NON-NLS-1$
+ public static final String ATTR_NAME_CHAROFF = "charoff"; // COL
+ // //$NON-NLS-1$
+ public static final String ATTR_NAME_VALIGN = "valign"; // COL
+ // //$NON-NLS-1$
+ public static final String ATTR_NAME_SPAN = "span"; // COL //$NON-NLS-1$
+ public static final String ATTR_NAME_FRAMEBORDER = "frameborder"; // FRAME
+ // //$NON-NLS-1$
+ public static final String ATTR_NAME_MARGINWIDTH = "marginwidth"; // FRAME
+ // //$NON-NLS-1$
+ public static final String ATTR_NAME_MARGINHEIGHT = "marginheight"; // FRAME
+ // //$NON-NLS-1$
+ public static final String ATTR_NAME_NORESIZE = "noresize"; // FRAME
+ // //$NON-NLS-1$
+ public static final String ATTR_NAME_SCROLLING = "scrolling"; // FRAME
+ // //$NON-NLS-1$
+ public static final String ATTR_NAME_PROMPT = "prompt"; // ISINDEX
+ // //$NON-NLS-1$
+ public static final String ATTR_NAME_HTTP_EQUIV = "http-equiv"; // META
+ // //$NON-NLS-1$
+ public static final String ATTR_NAME_CONTENT = "content"; // META
+ // //$NON-NLS-1$
+ public static final String ATTR_NAME_SCHEME = "scheme"; // META
+ // //$NON-NLS-1$
+ public static final String ATTR_NAME_ERRMSG = "errmsg"; // ssi:config
+ // //$NON-NLS-1$
+ public static final String ATTR_NAME_SIZEFMT = "sizefmt"; // ssi:config
+ // //$NON-NLS-1$
+ public static final String ATTR_NAME_TIMEFMT = "timefmt"; // ssi:config
+ // //$NON-NLS-1$
+ public static final String ATTR_NAME_VAR = "var"; // ssi:echo
+ // //$NON-NLS-1$
+ public static final String ATTR_NAME_CGI = "cgi"; // ssi:exec
+ // //$NON-NLS-1$
+ public static final String ATTR_NAME_CMD = "cmd"; // ssi:exec
+ // //$NON-NLS-1$
+ public static final String ATTR_NAME_FILE = "file"; // ssi:fsize
+ // //$NON-NLS-1$
+ public static final String ATTR_NAME_VIRTUAL = "virtual"; // ssi:fsize
+ // //$NON-NLS-1$
+ public static final String ATTR_NAME_SELECTED = "selected"; // OPTION
+ // //$NON-NLS-1$
+ public static final String ATTR_NAME_LABEL = "label"; // OPTION
+ // //$NON-NLS-1$
+ public static final String ATTR_NAME_ROWS = "rows"; // TEXTAREA
+ // //$NON-NLS-1$
+ public static final String ATTR_NAME_COLS = "cols"; // TEXTAREA
+ // //$NON-NLS-1$
+ public static final String ATTR_NAME_LANGUAGE = "language"; // SCRIPT
+ // //$NON-NLS-1$
+ public static final String ATTR_NAME_DEFER = "defer"; // SCRIPT
+ // //$NON-NLS-1$
+ public static final String ATTR_NAME_EVENT = "event"; // SCRIPT
+ // //$NON-NLS-1$
+ public static final String ATTR_NAME_FOR = "for"; // SCRIPT //$NON-NLS-1$
+ public static final String ATTR_NAME_COMPACT = "compact"; // OL/UL
+ // //$NON-NLS-1$
+ public static final String ATTR_NAME_START = "start"; // OL/UL
+ // //$NON-NLS-1$
+ public static final String ATTR_NAME_DIRECTKEY = "directkey"; // A
+ // //$NON-NLS-1$
+ public static final String ATTR_NAME_CODEBASE = "codebase"; // APPLET
+ // //$NON-NLS-1$
+ public static final String ATTR_NAME_ARCHIVE = "archive"; // APPLET
+ // //$NON-NLS-1$
+ public static final String ATTR_NAME_CODE = "code"; // APPLET
+ // //$NON-NLS-1$
+ public static final String ATTR_NAME_OBJECT = "object"; // APPLET
+ // //$NON-NLS-1$
+ public static final String ATTR_NAME_MAYSCRIPT = "mayscript"; // APPLET
+ // //$NON-NLS-1$
+ public static final String ATTR_NAME_CITE = "cite"; // BLOCKQUOTE
+ // //$NON-NLS-1$
+ public static final String ATTR_NAME_MACRO = "macro"; // D2W //$NON-NLS-1$
+ public static final String ATTR_NAME_DATETIME = "datetime"; // INS/DEL
+ // //$NON-NLS-1$
+ public static final String ATTR_NAME_LOOP = "loop"; // EMBED //$NON-NLS-1$
+ public static final String ATTR_NAME_HIDDEN = "hidden"; // EMBED
+ // //$NON-NLS-1$
+ public static final String ATTR_NAME_VOLUME = "volume"; // EMBED
+ // //$NON-NLS-1$
+ public static final String ATTR_NAME_AUTOSTART = "autostart"; // EMBED
+ // //$NON-NLS-1$
+ public static final String ATTR_NAME_AUTOPLAY = "autoplay"; // EMBED
+ // //$NON-NLS-1$
+ public static final String ATTR_NAME_AUTOSIZE = "autosize"; // EMBED
+ // //$NON-NLS-1$
+ public static final String ATTR_NAME_CONTROLLER = "controller";// EMBED
+ // //$NON-NLS-1$
+ public static final String ATTR_NAME_SCALE = "scale"; // EMBED
+ // //$NON-NLS-1$
+ public static final String ATTR_NAME_SHOWCONTROLS = "showcontrols";// EMBED
+ // //$NON-NLS-1$
+ public static final String ATTR_NAME_PLAYCOUNT = "playcount"; // EMBED
+ // //$NON-NLS-1$
+ public static final String ATTR_NAME_REPEAT = "repeat"; // EMBED
+ // //$NON-NLS-1$
+ public static final String ATTR_NAME_PANEL = "panel"; // EMBED
+ // //$NON-NLS-1$
+ public static final String ATTR_NAME_PALETTE = "palette"; // EMBED
+ // //$NON-NLS-1$
+ public static final String ATTR_NAME_TEXTFOCUS = "textfocus"; // EMBED
+ // //$NON-NLS-1$
+ public static final String ATTR_NAME_ACTION = "action"; // FORM
+ // //$NON-NLS-1$
+ public static final String ATTR_NAME_METHOD = "method"; // FORM
+ // //$NON-NLS-1$
+ public static final String ATTR_NAME_ENCTYPE = "enctype"; // FORM
+ // //$NON-NLS-1$
+ public static final String ATTR_NAME_ONSUBMIT = "onsubmit"; // FORM
+ // //$NON-NLS-1$
+ public static final String ATTR_NAME_ONRESET = "onreset"; // FORM
+ // //$NON-NLS-1$
+ public static final String ATTR_NAME_ACCEPT_CHARSET = "accept-charset";// FORM
+ // //$NON-NLS-1$
+ public static final String ATTR_NAME_BEHAVIOR = "behavior"; // MARQUEE
+ // //$NON-NLS-1$
+ public static final String ATTR_NAME_DIRECTION = "direction"; // MARQUEE
+ // //$NON-NLS-1$
+ public static final String ATTR_NAME_SCROLLAMOUNT = "scrollamount";// MARQUEE
+ // //$NON-NLS-1$
+ public static final String ATTR_NAME_SCROLLDELAY = "scrolldelay";// MARQUEE
+ // //$NON-NLS-1$
+ public static final String ATTR_NAME_TRUESPEED = "truespeed"; // MARQUEE
+ // //$NON-NLS-1$
+ public static final String ATTR_NAME_DECLARE = "declare"; // OBJECT
+ // //$NON-NLS-1$
+ public static final String ATTR_NAME_CLASSID = "classid"; // OBJECT
+ // //$NON-NLS-1$
+ public static final String ATTR_NAME_DATA = "data"; // OBJECT
+ // //$NON-NLS-1$
+ public static final String ATTR_NAME_CODETYPE = "codetype"; // OBJECT
+ // //$NON-NLS-1$
+ public static final String ATTR_NAME_STANDBY = "standby"; // OBJECT
+ // //$NON-NLS-1$
+ public static final String ATTR_NAME_MULTIPLE = "multiple"; // SELECT
+ // //$NON-NLS-1$
+ public static final String ATTR_NAME_ABBR = "abbr"; // TH/TD //$NON-NLS-1$
+ public static final String ATTR_NAME_AXIS = "axis"; // TH/TD //$NON-NLS-1$
+ public static final String ATTR_NAME_HEADERS = "headers"; // TH/TD
+ // //$NON-NLS-1$
+ public static final String ATTR_NAME_SCOPE = "scope"; // TH/TD
+ // //$NON-NLS-1$
+ public static final String ATTR_NAME_ROWSPAN = "rowspan"; // TH/TD
+ // //$NON-NLS-1$
+ public static final String ATTR_NAME_COLSPAN = "colspan"; // TH/TD
+ // //$NON-NLS-1$
+ public static final String ATTR_NAME_NOWRAP = "nowrap"; // TH/TD
+ // //$NON-NLS-1$
+ // <<D205514
+ public static final String ATTR_NAME_TOPMARGIN = "topmargin"; // BODY
+ // //$NON-NLS-1$
+ public static final String ATTR_NAME_BOTTOMMARGIN = "bottommargin"; // BODY
+ // //$NON-NLS-1$
+ public static final String ATTR_NAME_LEFTMARGIN = "leftmargin"; // BODY
+ // //$NON-NLS-1$
+ public static final String ATTR_NAME_RIGHTMARGIN = "rightmargin"; // BODY
+ // //$NON-NLS-1$
+ public static final String ATTR_NAME_BORDERCOLOR = "bordercolor"; // TABLE/TR/TH/TD/FRAMESET/FRAME
+ // //$NON-NLS-1$
+ // for WML
+ public static final String WML_ATTR_NAME_TITLE = "title"; // card
+ // //$NON-NLS-1$
+ public static final String WML_ATTR_NAME_DOMAIN = "domain"; // access
+ // //$NON-NLS-1$
+ public static final String WML_ATTR_NAME_PATH = "path"; // access
+ // //$NON-NLS-1$
+ public static final String WML_ATTR_NAME_ONENTERFORWARD = "onenterforward"; // template,card
+ // //$NON-NLS-1$
+ public static final String WML_ATTR_NAME_ONENTERBACKWARD = "onenterbackward"; // template,card
+ // //$NON-NLS-1$
+ public static final String WML_ATTR_NAME_ONPICK = "onpick"; // option
+ // //$NON-NLS-1$
+ public static final String WML_ATTR_NAME_ONTIMER = "ontimer"; // template,card
+ // //$NON-NLS-1$
+ public static final String WML_ATTR_NAME_NEWCONTEXT = "newcontext"; // card
+ // //$NON-NLS-1$
+ public static final String WML_ATTR_NAME_ORDERED = "ordered"; // card
+ // //$NON-NLS-1$
+ public static final String WML_ATTR_NAME_OPTIONAL = "optional"; // do
+ // //$NON-NLS-1$
+ public static final String WML_ATTR_NAME_CACHE_CONTROL = "cache-control"; // go
+ // //$NON-NLS-1$
+ public static final String WML_ATTR_NAME_SENDREFERER = "sendreferer"; // go
+ // //$NON-NLS-1$
+ public static final String WML_ATTR_NAME_METHOD = "method"; // go
+ // //$NON-NLS-1$
+ public static final String WML_ATTR_NAME_ENCTYPE = "enctype"; // go
+ // //$NON-NLS-1$
+ public static final String WML_ATTR_NAME_ACCEPT_CHARSET = "accept-charset"; // go
+ // //$NON-NLS-1$
+ public static final String WML_ATTR_NAME_COLUMNS = "columns"; // table
+ // //$NON-NLS-1$
+ // D205514
+ //<<D215684
+ public static final String ATTR_NAME_FRAMESPACING = "framespacing"; // FRAMESET
+ // //$NON-NLS-1$
+ //D215684
+ // global attribute values; mainly used in enumeration.
+ public static final String ATTR_VALUE_VERSION_TRANSITIONAL = "-//W3C//DTD HTML 4.01 Transitional//EN"; //$NON-NLS-1$
+ public static final String ATTR_VALUE_VERSION_FRAMESET = "-//W3C//DTD HTML 4.01 Frameset//EN"; //$NON-NLS-1$
+ public static final String ATTR_VALUE_LTR = "ltr"; // dir //$NON-NLS-1$
+ public static final String ATTR_VALUE_RTL = "rtl"; // dir //$NON-NLS-1$
+ // for align (top|middle|bottom|left|right)
+ public static final String ATTR_VALUE_TOP = "top"; // align //$NON-NLS-1$
+ public static final String ATTR_VALUE_MIDDLE = "middle"; // align
+ // //$NON-NLS-1$
+ public static final String ATTR_VALUE_BOTTOM = "bottom"; // align
+ // //$NON-NLS-1$
+ public static final String ATTR_VALUE_LEFT = "left"; // align
+ // //$NON-NLS-1$
+ public static final String ATTR_VALUE_CENTER = "center"; // align
+ // //$NON-NLS-1$
+ public static final String ATTR_VALUE_RIGHT = "right"; // align
+ // //$NON-NLS-1$
+ public static final String ATTR_VALUE_JUSTIFY = "justify"; // align
+ // //$NON-NLS-1$
+ public static final String ATTR_VALUE_CHAR = "char"; // align
+ // //$NON-NLS-1$
+ // for valign (baseline)
+ public static final String ATTR_VALUE_BASELINE = "baseline"; // valign
+ // //$NON-NLS-1$
+ // for clear (left|all|right|none): left and right are already defined
+ // above.
+ public static final String ATTR_VALUE_ALL = "all"; // clear //$NON-NLS-1$
+ public static final String ATTR_VALUE_NONE = "none"; // clear
+ // //$NON-NLS-1$
+ // for shape (rect|circle|poly|default)
+ public static final String ATTR_VALUE_RECT = "rect"; // shape
+ // //$NON-NLS-1$
+ public static final String ATTR_VALUE_CIRCLE = "circle"; // shape
+ // //$NON-NLS-1$
+ public static final String ATTR_VALUE_POLY = "poly"; // shape
+ // //$NON-NLS-1$
+ public static final String ATTR_VALUE_DEFAULT = "default"; // shape
+ // //$NON-NLS-1$
+ // for valuetype (data|ref|object)
+ public static final String ATTR_VALUE_DATA = "data"; // valuetype
+ // //$NON-NLS-1$
+ public static final String ATTR_VALUE_REF = "ref"; // valuetype
+ // //$NON-NLS-1$
+ public static final String ATTR_VALUE_OBJECT = "object"; // valuetype
+ // //$NON-NLS-1$
+ // for type of INPUT
+ // (text | password | checkbox | radio | submit | reset |
+ // file | hidden | image | button)
+ public static final String ATTR_VALUE_TEXT = "text"; // INPUT:type
+ // //$NON-NLS-1$
+ public static final String ATTR_VALUE_PASSWORD = "password"; // INPUT:type
+ // //$NON-NLS-1$
+ public static final String ATTR_VALUE_CHECKBOX = "checkbox"; // INPUT:type
+ // //$NON-NLS-1$
+ public static final String ATTR_VALUE_RADIO = "radio"; // INPUT:type
+ // //$NON-NLS-1$
+ public static final String ATTR_VALUE_SUBMIT = "submit"; // INPUT:type
+ // //$NON-NLS-1$
+ public static final String ATTR_VALUE_RESET = "reset"; // INPUT:type
+ // //$NON-NLS-1$
+ public static final String ATTR_VALUE_FILE = "file"; // INPUT:type
+ // //$NON-NLS-1$
+ public static final String ATTR_VALUE_HIDDEN = "hidden"; // INPUT:type
+ // //$NON-NLS-1$
+ public static final String ATTR_VALUE_IMAGE = "image"; // INPUT:type
+ // //$NON-NLS-1$
+ public static final String ATTR_VALUE_BUTTON = "button"; // INPUT:type
+ // //$NON-NLS-1$
+ // for span, colspan, rowspan
+ public static final String ATTR_VALUE_1 = "1"; // span //$NON-NLS-1$
+ // for frameborder
+ public static final String ATTR_VALUE_0 = "0"; // FRAME //$NON-NLS-1$
+ // for scrolling
+ public static final String ATTR_VALUE_YES = "yes"; // FRAME //$NON-NLS-1$
+ public static final String ATTR_VALUE_NO = "no"; // FRAME //$NON-NLS-1$
+ public static final String ATTR_VALUE_AUTO = "auto"; // FRAME
+ // //$NON-NLS-1$
+ // for UL
+ public static final String ATTR_VALUE_DISC = "disc"; // UL:type
+ // //$NON-NLS-1$
+ public static final String ATTR_VALUE_SQUARE = "square"; // UL:type
+ // //$NON-NLS-1$
+ // for frame of TABLE
+ public static final String ATTR_VALUE_VOID = "void"; // TABLE:frame
+ // //$NON-NLS-1$
+ public static final String ATTR_VALUE_ABOVE = "above"; // TABLE:frame
+ // //$NON-NLS-1$
+ public static final String ATTR_VALUE_BELOW = "below"; // TABLE:frame
+ // //$NON-NLS-1$
+ public static final String ATTR_VALUE_HSIDES = "hsides"; // TABLE:frame
+ // //$NON-NLS-1$
+ public static final String ATTR_VALUE_LHS = "lhs"; // TABLE:frame
+ // //$NON-NLS-1$
+ public static final String ATTR_VALUE_RHS = "rhs"; // TABLE:frame
+ // //$NON-NLS-1$
+ public static final String ATTR_VALUE_VSIDES = "vsides"; // TABLE:frame
+ // //$NON-NLS-1$
+ public static final String ATTR_VALUE_BOX = "box"; // TABLE:frame
+ // //$NON-NLS-1$
+ public static final String ATTR_VALUE_BORDER = "border"; // TABLE:frame
+ // //$NON-NLS-1$
+ // for rules of TABLE
+ public static final String ATTR_VALUE_GROUPS = "groups"; // TABLE:rules
+ // //$NON-NLS-1$
+ public static final String ATTR_VALUE_ROWS = "rows"; // TEXTAREA
+ // //$NON-NLS-1$
+ public static final String ATTR_VALUE_COLS = "cols"; // TEXTAREA
+ // //$NON-NLS-1$
+ // for method of FORM
+ public static final String ATTR_VALUE_GET = "get"; // FORM //$NON-NLS-1$
+ public static final String ATTR_VALUE_POST = "post"; // FORM //$NON-NLS-1$
+ public static final String ATTR_VALUE_WWW_FORM_URLENCODED = "application/x-www-form-urlencoded"; //$NON-NLS-1$
+ // for scope of (TH | TD)
+ public static final String ATTR_VALUE_ROW = "row"; // (TH|TD):scope
+ // //$NON-NLS-1$
+ public static final String ATTR_VALUE_COL = "col"; // (TH|TD):scope
+ // //$NON-NLS-1$
+ public static final String ATTR_VALUE_ROWGROUP = "rowgroup";// (TH|TD):scope
+ // //$NON-NLS-1$
+ public static final String ATTR_VALUE_COLGROUP = "colgroup";// (TH|TD):scope
+ // //$NON-NLS-1$
+ // for auto?? of EMBED
+ public static final String ATTR_VALUE_TRUE = "true"; // EMBED
+ // //$NON-NLS-1$
+ public static final String ATTR_VALUE_FALSE = "false"; // EMBED
+ // //$NON-NLS-1$
+ // for behaviro of MARQUEE
+ public static final String ATTR_VALUE_SCROLL = "scroll"; // MARQUEE
+ // //$NON-NLS-1$
+ public static final String ATTR_VALUE_SLIDE = "slide"; // MARQUEE
+ // //$NON-NLS-1$
+ public static final String ATTR_VALUE_ALTERNATE = "alternate"; // MARQUEE
+ // //$NON-NLS-1$
+ // for direction of MARQUEE
+ public static final String ATTR_VALUE_UP = "up"; // MARQUEE //$NON-NLS-1$
+ public static final String ATTR_VALUE_DOWN = "down"; // MARQUEE
+ // //$NON-NLS-1$
+ // for type of LI (D19924)
+ public static final String ATTR_VALUE_NUMBER = "1"; // LI //$NON-NLS-1$
+ public static final String ATTR_VALUE_LOWER_ALPHA = "a"; // LI
+ // //$NON-NLS-1$
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/contentproperties/ContentSettingsRegistry.java b/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/contentproperties/ContentSettingsRegistry.java
new file mode 100644
index 0000000000..97638179f1
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/contentproperties/ContentSettingsRegistry.java
@@ -0,0 +1,34 @@
+/*****************************************************************************
+ * Copyright (c) 2004 IBM Corporation and others. All rights reserved. This
+ * program and the accompanying materials are made available under the terms
+ * of the Eclipse Public License v1.0 which accompanies this distribution, and
+ * is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors: IBM Corporation - initial API and implementation
+ ****************************************************************************/
+package org.eclipse.wst.css.ui.contentproperties;
+
+import java.util.Iterator;
+
+import org.eclipse.wst.css.core.metamodel.CSSProfile;
+import org.eclipse.wst.css.core.metamodel.CSSProfileRegistry;
+import org.eclipse.wst.sse.ui.contentproperties.ui.ComboList;
+import org.eclipse.wst.sse.ui.nls.ResourceHandler;
+
+public final class ContentSettingsRegistry {
+ private static final String NONE = ResourceHandler.getString("UI_none"); //$NON-NLS-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);
+ }
+
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/contentproperties/ui/CSSContentSettingsPropertyPage.java b/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/contentproperties/ui/CSSContentSettingsPropertyPage.java
new file mode 100644
index 0000000000..e2c70ca078
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/contentproperties/ui/CSSContentSettingsPropertyPage.java
@@ -0,0 +1,101 @@
+/*****************************************************************************
+ * Copyright (c) 2004 IBM Corporation and others. All rights reserved. This
+ * program and the accompanying materials are made available under the terms
+ * of the Eclipse Public License v1.0 which accompanies this distribution, and
+ * is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors: IBM Corporation - initial API and implementation
+ ****************************************************************************/
+package org.eclipse.wst.css.ui.contentproperties.ui;
+
+
+
+import java.util.Map;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.ui.help.WorkbenchHelp;
+import org.eclipse.wst.css.ui.contentproperties.ContentSettingsRegistry;
+import org.eclipse.wst.css.ui.internal.Logger;
+import org.eclipse.wst.css.ui.internal.editor.IHelpContextIds;
+import org.eclipse.wst.sse.ui.contentproperties.IContentSettings;
+import org.eclipse.wst.sse.ui.contentproperties.ui.ComboListOnPropertyPage;
+import org.eclipse.wst.sse.ui.contentproperties.ui.ContentSettingsPropertyPage;
+
+public final class CSSContentSettingsPropertyPage extends ContentSettingsPropertyPage {
+
+ private final int N_CSS_PROFILE = 0;
+
+
+
+ public CSSContentSettingsPropertyPage() {
+ super();
+ numberOfCombo = 1;
+ numCols = 2;
+ numRows = 1;
+ combo = new ComboListOnPropertyPage[super.numberOfCombo];
+
+ }
+
+ 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 createSettingsPageGUI() {
+
+ int type = ((IResource) getElement()).getType();
+ switch (type) {
+ case IResource.FILE :
+ //composite = createComposite(propertyPage,numCols,numRows);
+ createCSSComboBox();
+ WorkbenchHelp.setHelp(propertyPage, IHelpContextIds.CSS_CONTENT_SETTINGS_HELPID);
+ break;
+
+ default :
+ Logger.log(Logger.WARNING, "CSSContentSettingsPropertyPage is instantiated by resource except FILE");//$NON-NLS-1$
+ break;
+ }
+
+ }
+
+
+ protected void putSelectedPropertyInto(Map properties, String valueInCombo, int index) {
+
+ switch (index) {
+ case N_CSS_PROFILE :
+ // css
+ properties.put(IContentSettings.CSS_PROFILE, valueInCombo);
+ break;
+ default :
+ Logger.log(Logger.ERROR, "Index is out of range in putSelectedPropertyInto() in class CSSContentSettingsPropertyPage");//$NON-NLS-1$
+ break;
+ }
+
+ }
+
+ protected void deleteNoneProperty(int index) {
+ switch (index) {
+ case N_CSS_PROFILE :
+ // css
+ contentSettings.deleteProperty((IResource) super.getElement(), IContentSettings.CSS_PROFILE);
+ break;
+
+ default :
+ Logger.log(Logger.ERROR, "Index is out of range in deleteNoneProperty() in class CSSContentSettingsPropertyPage");//$NON-NLS-1$
+ break;
+ }
+ }
+
+}
+
diff --git a/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/edit/ui/CleanupActionCSS.java b/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/edit/ui/CleanupActionCSS.java
new file mode 100644
index 0000000000..529da96642
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/edit/ui/CleanupActionCSS.java
@@ -0,0 +1,40 @@
+/*****************************************************************************
+ * Copyright (c) 2004 IBM Corporation and others. All rights reserved. This
+ * program and the accompanying materials are made available under the terms
+ * of the Eclipse Public License v1.0 which accompanies this distribution, and
+ * is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors: IBM Corporation - initial API and implementation
+ ****************************************************************************/
+package org.eclipse.wst.css.ui.edit.ui;
+
+import java.util.ResourceBundle;
+
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.texteditor.ITextEditor;
+import org.eclipse.wst.css.core.cleanup.CleanupProcessorCSS;
+import org.eclipse.wst.sse.core.cleanup.IStructuredCleanupProcessor;
+import org.eclipse.wst.sse.ui.edit.util.CleanupAction;
+
+public class CleanupActionCSS extends CleanupAction {
+ protected IStructuredCleanupProcessor fCleanupProcessor;
+
+ public CleanupActionCSS(ResourceBundle bundle, String prefix, ITextEditor editor) {
+ super(bundle, prefix, editor);
+ }
+
+ protected Dialog getCleanupDialog(Shell shell) {
+ if (fCleanupDialog == null)
+ fCleanupDialog = new CleanupDialogCSS(shell);
+
+ return fCleanupDialog;
+ }
+
+ protected IStructuredCleanupProcessor getCleanupProcessor() {
+ if (fCleanupProcessor == null)
+ fCleanupProcessor = new CleanupProcessorCSS();
+
+ return fCleanupProcessor;
+ }
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/edit/ui/CleanupDialogCSS.java b/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/edit/ui/CleanupDialogCSS.java
new file mode 100644
index 0000000000..bb901ea12c
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/edit/ui/CleanupDialogCSS.java
@@ -0,0 +1,292 @@
+/*****************************************************************************
+ * Copyright (c) 2004 IBM Corporation and others. All rights reserved. This
+ * program and the accompanying materials are made available under the terms
+ * of the Eclipse Public License v1.0 which accompanies this distribution, and
+ * is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors: IBM Corporation - initial API and implementation
+ ****************************************************************************/
+package org.eclipse.wst.css.ui.edit.ui;
+
+
+
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.swt.SWT;
+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.help.WorkbenchHelp;
+import org.eclipse.wst.css.core.cleanup.CSSCleanupStrategy;
+import org.eclipse.wst.css.core.cleanup.CSSCleanupStrategyImpl;
+import org.eclipse.wst.css.ui.internal.editor.IHelpContextIds;
+import org.eclipse.wst.sse.ui.nls.ResourceHandler;
+
+public class CleanupDialogCSS extends Dialog {
+
+ private boolean embeddedCSS;
+ protected Button fRadioButtonIdentCaseAsis;
+ protected Button fRadioButtonIdentCaseLower;
+ protected Button fRadioButtonIdentCaseUpper;
+ protected Button fRadioButtonPropNameCaseAsis;
+ protected Button fRadioButtonPropNameCaseLower;
+ protected Button fRadioButtonPropNameCaseUpper;
+ protected Button fRadioButtonPropValueCaseAsis;
+ protected Button fRadioButtonPropValueCaseLower;
+ protected Button fRadioButtonPropValueCaseUpper;
+ protected Button fRadioButtonSelectorTagCaseAsis;
+ protected Button fRadioButtonSelectorTagCaseLower;
+ protected Button fRadioButtonSelectorTagCaseUpper;
+ protected Button fCheckBoxQuoteValues;
+ protected Button fCheckBoxFormatSource;
+
+ /**
+ * CSSCleanupDialog constructor comment.
+ *
+ * @param parentShell
+ * org.eclipse.swt.widgets.Shell
+ */
+ public CleanupDialogCSS(Shell parentShell) {
+ super(parentShell);
+ }
+
+ /**
+ *
+ * @return org.eclipse.swt.widgets.Control
+ * @param parent
+ * org.eclipse.swt.widgets.Composite
+ */
+ public Control createDialogArea(Composite parent) {
+ if (isEmbeddedCSS())
+ getShell().setText(ResourceHandler.getString("CSS_Cleanup_UI_")); //$NON-NLS-1$ = "CSS Cleanup"
+ else
+ getShell().setText(ResourceHandler.getString("Cleanup_UI_")); //$NON-NLS-1$ = "Cleanup"
+
+ Composite panel = new Composite(parent, SWT.NULL);
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 1;
+ layout.makeColumnsEqualWidth = true;
+ panel.setLayout(layout);
+
+ WorkbenchHelp.setHelp(panel, IHelpContextIds.CSS_CLEANUP_HELPID);
+
+ // Convert ident case
+ // ACC: Group radio buttons together so associated label is read
+ // Label identCaseLabel = new Label(panel, SWT.NULL);
+ // identCaseLabel.setText(ResourceHandler.getString("Identifier_case__UI_"));
+ // //$NON-NLS-1$ = "Identifier case:"
+ // Canvas identCase = new Canvas(panel, SWT.NULL);
+ Group identCase = new Group(panel, SWT.NULL);
+ identCase.setText(ResourceHandler.getString("Identifier_case__UI_")); //$NON-NLS-1$ = "Identifier case:"
+ GridLayout hLayout = new GridLayout();
+ hLayout.numColumns = 3;
+ identCase.setLayout(hLayout);
+ fRadioButtonIdentCaseAsis = new Button(identCase, SWT.RADIO);
+ fRadioButtonIdentCaseAsis.setText(ResourceHandler.getString("As-is_UI_")); //$NON-NLS-1$ = "As-is"
+ fRadioButtonIdentCaseLower = new Button(identCase, SWT.RADIO);
+ fRadioButtonIdentCaseLower.setText(ResourceHandler.getString("Lower_UI_")); //$NON-NLS-1$ = "Lower"
+ fRadioButtonIdentCaseUpper = new Button(identCase, SWT.RADIO);
+ fRadioButtonIdentCaseUpper.setText(ResourceHandler.getString("Upper_UI_")); //$NON-NLS-1$ = "Upper"
+
+ // Convert property name case
+ // ACC: Group radio buttons together so associated label is read
+ // Label propNameCaseLabel = new Label(panel, SWT.NULL);
+ // propNameCaseLabel.setText(ResourceHandler.getString("Property_name_case__UI_"));
+ // //$NON-NLS-1$ = "Property name case:"
+ // Canvas propNameCase = new Canvas(panel, SWT.NULL);
+ Group propNameCase = new Group(panel, SWT.NULL);
+ propNameCase.setText(ResourceHandler.getString("Property_name_case__UI_")); //$NON-NLS-1$ = "Property name case:"
+ hLayout = new GridLayout();
+ hLayout.numColumns = 3;
+ propNameCase.setLayout(hLayout);
+ fRadioButtonPropNameCaseAsis = new Button(propNameCase, SWT.RADIO);
+ fRadioButtonPropNameCaseAsis.setText(ResourceHandler.getString("As-is_UI_")); //$NON-NLS-1$ = "As-is"
+ fRadioButtonPropNameCaseLower = new Button(propNameCase, SWT.RADIO);
+ fRadioButtonPropNameCaseLower.setText(ResourceHandler.getString("Lower_UI_")); //$NON-NLS-1$ = "Lower"
+ fRadioButtonPropNameCaseUpper = new Button(propNameCase, SWT.RADIO);
+ fRadioButtonPropNameCaseUpper.setText(ResourceHandler.getString("Upper_UI_")); //$NON-NLS-1$ = "Upper"
+
+ // Convert property Value case
+ // ACC: Group radio buttons together so associated label is read
+ // Label propValueCaseLabel = new Label(panel, SWT.NULL);
+ // propValueCaseLabel.setText(ResourceHandler.getString("Property_value_case__UI_"));
+ // //$NON-NLS-1$ = "Property value case:"
+ // Canvas propValueCase = new Canvas(panel, SWT.NULL);
+ Group propValueCase = new Group(panel, SWT.NULL);
+ propValueCase.setText(ResourceHandler.getString("Property_value_case__UI_")); //$NON-NLS-1$ = "Property value case:"
+ hLayout = new GridLayout();
+ hLayout.numColumns = 3;
+ propValueCase.setLayout(hLayout);
+ fRadioButtonPropValueCaseAsis = new Button(propValueCase, SWT.RADIO);
+ fRadioButtonPropValueCaseAsis.setText(ResourceHandler.getString("As-is_UI_")); //$NON-NLS-1$ = "As-is"
+ fRadioButtonPropValueCaseLower = new Button(propValueCase, SWT.RADIO);
+ fRadioButtonPropValueCaseLower.setText(ResourceHandler.getString("Lower_UI_")); //$NON-NLS-1$ = "Lower"
+ fRadioButtonPropValueCaseUpper = new Button(propValueCase, SWT.RADIO);
+ fRadioButtonPropValueCaseUpper.setText(ResourceHandler.getString("Upper_UI_")); //$NON-NLS-1$ = "Upper"
+
+ if (!isEmbeddedCSS()) {
+ // Convert selector tag case
+ // ACC: Group radio buttons together so associated label is read
+ // Label selectorTagCaseLabel = new Label(panel, SWT.NULL);
+ // selectorTagCaseLabel.setText(ResourceHandler.getString("Selector_tag_name_case__UI_"));
+ // //$NON-NLS-1$ = "Selector tag name case:"
+ // Canvas selectorTagCase = new Canvas(panel, SWT.NULL);
+ Group selectorTagCase = new Group(panel, SWT.NULL);
+ selectorTagCase.setText(ResourceHandler.getString("Selector_tag_name_case__UI_")); //$NON-NLS-1$ = "Selector tag name case:"
+ hLayout = new GridLayout();
+ hLayout.numColumns = 3;
+ selectorTagCase.setLayout(hLayout);
+ fRadioButtonSelectorTagCaseAsis = new Button(selectorTagCase, SWT.RADIO);
+ fRadioButtonSelectorTagCaseAsis.setText(ResourceHandler.getString("As-is_UI_")); //$NON-NLS-1$ = "As-is"
+ fRadioButtonSelectorTagCaseLower = new Button(selectorTagCase, SWT.RADIO);
+ fRadioButtonSelectorTagCaseLower.setText(ResourceHandler.getString("Lower_UI_")); //$NON-NLS-1$ = "Lower"
+ fRadioButtonSelectorTagCaseUpper = new Button(selectorTagCase, SWT.RADIO);
+ fRadioButtonSelectorTagCaseUpper.setText(ResourceHandler.getString("Upper_UI_")); //$NON-NLS-1$ = "Upper"
+ }
+
+ // Quote attribute values
+ fCheckBoxQuoteValues = new Button(panel, SWT.CHECK);
+ fCheckBoxQuoteValues.setText(ResourceHandler.getString("Quote_values_UI_")); //$NON-NLS-1$ = "Quote values"
+
+ if (!isEmbeddedCSS()) {
+ // Format source
+ fCheckBoxFormatSource = new Button(panel, SWT.CHECK);
+ fCheckBoxFormatSource.setText(ResourceHandler.getString("Format_source_UI_")); //$NON-NLS-1$ = "Format source"
+ }
+
+ setCleanupOptions();
+
+ return panel;
+ }
+
+ /**
+ * Insert the method's description here.
+ *
+ * @return boolean
+ */
+ public boolean isEmbeddedCSS() {
+ return embeddedCSS;
+ }
+
+ /**
+ *
+ */
+ protected void okPressed() {
+ updateCleanupOptions();
+ super.okPressed();
+ }
+
+ /**
+ *
+ */
+ protected void setCleanupOptions() {
+ CSSCleanupStrategy stgy = CSSCleanupStrategyImpl.getInstance();
+
+ if (fRadioButtonIdentCaseAsis != null) {
+ if (stgy.getIdentCase() == CSSCleanupStrategy.UPPER)
+ fRadioButtonIdentCaseUpper.setSelection(true);
+ else if (stgy.getIdentCase() == CSSCleanupStrategy.LOWER)
+ fRadioButtonIdentCaseLower.setSelection(true);
+ else
+ fRadioButtonIdentCaseAsis.setSelection(true);
+ }
+
+ if (fRadioButtonPropNameCaseAsis != null) {
+ if (stgy.getPropNameCase() == CSSCleanupStrategy.UPPER)
+ fRadioButtonPropNameCaseUpper.setSelection(true);
+ else if (stgy.getPropNameCase() == CSSCleanupStrategy.LOWER)
+ fRadioButtonPropNameCaseLower.setSelection(true);
+ else
+ fRadioButtonPropNameCaseAsis.setSelection(true);
+ }
+
+ if (fRadioButtonPropValueCaseAsis != null) {
+ if (stgy.getPropValueCase() == CSSCleanupStrategy.UPPER)
+ fRadioButtonPropValueCaseUpper.setSelection(true);
+ else if (stgy.getPropValueCase() == CSSCleanupStrategy.LOWER)
+ fRadioButtonPropValueCaseLower.setSelection(true);
+ else
+ fRadioButtonPropValueCaseAsis.setSelection(true);
+ }
+
+ if (fRadioButtonSelectorTagCaseAsis != null) {
+ if (stgy.getSelectorTagCase() == CSSCleanupStrategy.UPPER)
+ fRadioButtonSelectorTagCaseUpper.setSelection(true);
+ else if (stgy.getSelectorTagCase() == CSSCleanupStrategy.LOWER)
+ fRadioButtonSelectorTagCaseLower.setSelection(true);
+ else
+ fRadioButtonSelectorTagCaseAsis.setSelection(true);
+ }
+
+ if (fCheckBoxQuoteValues != null)
+ fCheckBoxQuoteValues.setSelection(stgy.isQuoteValues());
+
+ if (fCheckBoxFormatSource != null)
+ fCheckBoxFormatSource.setSelection(stgy.isFormatSource());
+
+ }
+
+ /**
+ * Insert the method's description here.
+ *
+ * @param newEmbeddedCSS
+ * boolean
+ */
+ public void setEmbeddedCSS(boolean newEmbeddedCSS) {
+ embeddedCSS = newEmbeddedCSS;
+ }
+
+ /**
+ *
+ */
+ protected void updateCleanupOptions() {
+ CSSCleanupStrategy stgy = CSSCleanupStrategyImpl.getInstance();
+
+ if (fRadioButtonIdentCaseAsis != null) {
+ if (fRadioButtonIdentCaseUpper.getSelection())
+ stgy.setIdentCase(CSSCleanupStrategy.UPPER);
+ else if (fRadioButtonIdentCaseLower.getSelection())
+ stgy.setIdentCase(CSSCleanupStrategy.LOWER);
+ else
+ stgy.setIdentCase(CSSCleanupStrategy.ASIS);
+ }
+
+ if (fRadioButtonPropNameCaseAsis != null) {
+ if (fRadioButtonPropNameCaseUpper.getSelection())
+ stgy.setPropNameCase(CSSCleanupStrategy.UPPER);
+ else if (fRadioButtonPropNameCaseLower.getSelection())
+ stgy.setPropNameCase(CSSCleanupStrategy.LOWER);
+ else
+ stgy.setPropNameCase(CSSCleanupStrategy.ASIS);
+ }
+
+ if (fRadioButtonPropValueCaseAsis != null) {
+ if (fRadioButtonPropValueCaseUpper.getSelection())
+ stgy.setPropValueCase(CSSCleanupStrategy.UPPER);
+ else if (fRadioButtonPropValueCaseLower.getSelection())
+ stgy.setPropValueCase(CSSCleanupStrategy.LOWER);
+ else
+ stgy.setPropValueCase(CSSCleanupStrategy.ASIS);
+ }
+
+ if (fRadioButtonSelectorTagCaseAsis != null) {
+ if (fRadioButtonSelectorTagCaseUpper.getSelection())
+ stgy.setSelectorTagCase(CSSCleanupStrategy.UPPER);
+ else if (fRadioButtonSelectorTagCaseLower.getSelection())
+ stgy.setSelectorTagCase(CSSCleanupStrategy.LOWER);
+ else
+ stgy.setSelectorTagCase(CSSCleanupStrategy.ASIS);
+ }
+
+ if (fCheckBoxQuoteValues != null)
+ stgy.setQuoteValues(fCheckBoxQuoteValues.getSelection());
+
+ if (fCheckBoxFormatSource != null)
+ stgy.setFormatSource(fCheckBoxFormatSource.getSelection());
+
+ // save these values to preferences
+ ((CSSCleanupStrategyImpl) stgy).saveOptions();
+ }
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/image/CSSImageHelper.java b/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/image/CSSImageHelper.java
new file mode 100644
index 0000000000..47c3c888bb
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/image/CSSImageHelper.java
@@ -0,0 +1,124 @@
+/*****************************************************************************
+ * Copyright (c) 2004 IBM Corporation and others. All rights reserved. This
+ * program and the accompanying materials are made available under the terms
+ * of the Eclipse Public License v1.0 which accompanies this distribution, and
+ * is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors: IBM Corporation - initial API and implementation
+ ****************************************************************************/
+package org.eclipse.wst.css.ui.image;
+
+
+
+import java.util.HashMap;
+import java.util.Map;
+
+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.css.ui.CSSEditorPlugin;
+import org.eclipse.wst.css.ui.internal.editor.CSSEditorPluginImages;
+
+
+public class CSSImageHelper {
+ /**
+ * singleton
+ */
+ public synchronized static CSSImageHelper getInstance() {
+ if (fInstance == null) {
+ fInstance = new CSSImageHelper();
+ }
+ return fInstance;
+ }
+
+ /**
+ * by relative path(from here)
+ */
+ public Image getImage(String resource) {
+ if (resource == null) {
+ return null;
+ }
+ Image image = getImageRegistry().get(resource);
+ if (image == null) {
+ image = createImage(resource);
+ }
+ return image;
+ }
+
+ /**
+ * by type
+ */
+ public Image getImage(CSSImageType type) {
+ if (fTypeMap == null) {
+ fTypeMap = new HashMap();
+ fTypeMap.put(CSSImageType.STYLESHEET, CSSEditorPluginImages.IMG_OBJ_STYLESHEET);
+
+ fTypeMap.put(CSSImageType.RULE_CHARSET, CSSEditorPluginImages.IMG_OBJ_RULE_CHARSET);
+ fTypeMap.put(CSSImageType.RULE_FONTFACE, CSSEditorPluginImages.IMG_OBJ_RULE_FONTFACE);
+ fTypeMap.put(CSSImageType.RULE_IMPORT, CSSEditorPluginImages.IMG_OBJ_RULE_IMPORT);
+ fTypeMap.put(CSSImageType.RULE_MEDIA, CSSEditorPluginImages.IMG_OBJ_RULE_MEDIA);
+ fTypeMap.put(CSSImageType.RULE_PAGE, CSSEditorPluginImages.IMG_OBJ_RULE_PAGE);
+ fTypeMap.put(CSSImageType.RULE_STYLE, CSSEditorPluginImages.IMG_OBJ_RULE_STYLE);
+ fTypeMap.put(CSSImageType.RULE_UNKNOWN, CSSEditorPluginImages.IMG_OBJ_RULE_UNKNOWN);
+
+ fTypeMap.put(CSSImageType.SELECTOR_CLASS, CSSEditorPluginImages.IMG_OBJ_SELECTOR_CLASS);
+ fTypeMap.put(CSSImageType.SELECTOR_ID, CSSEditorPluginImages.IMG_OBJ_SELECTOR_ID);
+ fTypeMap.put(CSSImageType.SELECTOR_PSEUDO, CSSEditorPluginImages.IMG_OBJ_SELECTOR_PSEUDO);
+ fTypeMap.put(CSSImageType.SELECTOR_TAG, CSSEditorPluginImages.IMG_OBJ_SELECTOR_TAG);
+ fTypeMap.put(CSSImageType.SELECTOR_LINK, CSSEditorPluginImages.IMG_OBJ_SELECTOR_LINK);
+ fTypeMap.put(CSSImageType.SELECTOR_DEFAULT, CSSEditorPluginImages.IMG_OBJ_SELECTOR_DEFAULT);
+
+ fTypeMap.put(CSSImageType.VALUE_FUNCTION, CSSEditorPluginImages.IMG_OBJ_VALUE_FUNCTION);
+ fTypeMap.put(CSSImageType.VALUE_NUMBER, CSSEditorPluginImages.IMG_OBJ_VALUE_NUMBER);
+ fTypeMap.put(CSSImageType.VALUE_STRING, CSSEditorPluginImages.IMG_OBJ_VALUE_STRING);
+
+ fTypeMap.put(CSSImageType.CATEGORY_AURAL, CSSEditorPluginImages.IMG_OBJ_CATEGORY_AURAL);
+ fTypeMap.put(CSSImageType.CATEGORY_BOX, CSSEditorPluginImages.IMG_OBJ_CATEGORY_BOX);
+ fTypeMap.put(CSSImageType.CATEGORY_COLORANDBACKGROUND, CSSEditorPluginImages.IMG_OBJ_CATEGORY_COLORANDBACKGROUND);
+ fTypeMap.put(CSSImageType.CATEGORY_CONTENT, CSSEditorPluginImages.IMG_OBJ_CATEGORY_CONTENT);
+ fTypeMap.put(CSSImageType.CATEGORY_FONT, CSSEditorPluginImages.IMG_OBJ_CATEGORY_FONT);
+ fTypeMap.put(CSSImageType.CATEGORY_PAGE, CSSEditorPluginImages.IMG_OBJ_CATEGORY_PAGE);
+ fTypeMap.put(CSSImageType.CATEGORY_TABLES, CSSEditorPluginImages.IMG_OBJ_CATEGORY_TABLES);
+ fTypeMap.put(CSSImageType.CATEGORY_TEXT, CSSEditorPluginImages.IMG_OBJ_CATEGORY_TEXT);
+ fTypeMap.put(CSSImageType.CATEGORY_UI, CSSEditorPluginImages.IMG_OBJ_CATEGORY_UI);
+ fTypeMap.put(CSSImageType.CATEGORY_VISUAL, CSSEditorPluginImages.IMG_OBJ_CATEGORY_VISUAL);
+ fTypeMap.put(CSSImageType.CATEGORY_DEFAULT, CSSEditorPluginImages.IMG_OBJ_CATEGORY_DEFAULT);
+ }
+ return getImage((String) fTypeMap.get(type));
+ }
+
+ /**
+ *
+ */
+ private CSSImageHelper() {
+ super();
+ }
+
+ /**
+ *
+ */
+ private Image createImage(String resource) {
+ ImageDescriptor desc = AbstractUIPlugin.imageDescriptorFromPlugin(CSSEditorPlugin.ID, resource);
+ Image image = null;
+
+ if (desc == null) {
+ desc = ImageDescriptor.getMissingImageDescriptor();
+ image = desc.createImage();
+ } else {
+ image = desc.createImage();
+ getImageRegistry().put(resource, image);
+ }
+
+ return image;
+ }
+
+ private ImageRegistry getImageRegistry() {
+ return JFaceResources.getImageRegistry();
+ }
+
+ private Map fTypeMap = null;
+ private static CSSImageHelper fInstance = null;
+
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/image/CSSImageType.java b/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/image/CSSImageType.java
new file mode 100644
index 0000000000..9efa575dcf
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/image/CSSImageType.java
@@ -0,0 +1,235 @@
+/*******************************************************************************
+ * Copyright (c) 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.ui.image;
+
+
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.wst.css.core.document.ICSSDocument;
+import org.eclipse.wst.css.core.document.ICSSModel;
+import org.eclipse.wst.css.core.document.ICSSNode;
+import org.eclipse.wst.css.core.document.ICSSPrimitiveValue;
+import org.eclipse.wst.css.core.document.ICSSSelector;
+import org.eclipse.wst.css.core.document.ICSSSelectorItem;
+import org.eclipse.wst.css.core.document.ICSSSelectorList;
+import org.eclipse.wst.css.core.document.ICSSSimpleSelector;
+import org.eclipse.wst.css.core.document.ICSSStyleDeclItem;
+import org.eclipse.wst.css.core.document.ICSSStyleRule;
+import org.eclipse.wst.css.core.metamodel.CSSMMProperty;
+import org.eclipse.wst.css.core.metamodel.CSSMetaModel;
+import org.eclipse.wst.css.core.metamodel.util.CSSMetaModelFinder;
+import org.eclipse.wst.css.core.metamodel.util.CSSMetaModelUtil;
+import org.w3c.dom.css.CSSCharsetRule;
+import org.w3c.dom.css.CSSFontFaceRule;
+import org.w3c.dom.css.CSSImportRule;
+import org.w3c.dom.css.CSSMediaRule;
+import org.w3c.dom.css.CSSPageRule;
+import org.w3c.dom.css.CSSPrimitiveValue;
+import org.w3c.dom.css.CSSStyleDeclaration;
+import org.w3c.dom.css.CSSStyleRule;
+import org.w3c.dom.css.CSSValue;
+
+/**
+ */
+public class CSSImageType {
+
+ private final String fName;
+
+ private CSSImageType(String name) {
+ this.fName = name;
+ }
+
+ public String toString() {
+ return fName;
+ }
+
+ public static final CSSImageType STYLESHEET = new CSSImageType("STYLESHEET"); //$NON-NLS-1$
+
+ public static final CSSImageType RULE_CHARSET = new CSSImageType("RULE_CHARSET"); //$NON-NLS-1$
+ public static final CSSImageType RULE_FONTFACE = new CSSImageType("RULE_FONTFACE"); //$NON-NLS-1$
+ public static final CSSImageType RULE_IMPORT = new CSSImageType("RULE_IMPORT"); //$NON-NLS-1$
+ public static final CSSImageType RULE_MEDIA = new CSSImageType("RULE_MEDIA"); //$NON-NLS-1$
+ public static final CSSImageType RULE_PAGE = new CSSImageType("RULE_PAGE"); //$NON-NLS-1$
+ public static final CSSImageType RULE_STYLE = new CSSImageType("RULE_STYLE"); //$NON-NLS-1$
+ public static final CSSImageType RULE_UNKNOWN = new CSSImageType("RULE_UNKNOWN"); //$NON-NLS-1$
+
+ public static final CSSImageType SELECTOR_CLASS = new CSSImageType("SELECTOR_CLASS"); //$NON-NLS-1$
+ public static final CSSImageType SELECTOR_ID = new CSSImageType("SELECTOR_ID"); //$NON-NLS-1$
+ public static final CSSImageType SELECTOR_DEFAULT = new CSSImageType("SELECTOR_DEFAULT"); //$NON-NLS-1$
+ public static final CSSImageType SELECTOR_PSEUDO = new CSSImageType("SELECTOR_PSEUDO"); //$NON-NLS-1$
+ public static final CSSImageType SELECTOR_TAG = new CSSImageType("SELECTOR_TAG"); //$NON-NLS-1$
+ public static final CSSImageType SELECTOR_LINK = new CSSImageType("SELECTOR_LINK"); //$NON-NLS-1$
+
+ public static final CSSImageType VALUE_FUNCTION = new CSSImageType("VALUE_FUNCTION"); //$NON-NLS-1$
+ public static final CSSImageType VALUE_NUMBER = new CSSImageType("VALUE_NUMBER"); //$NON-NLS-1$
+ public static final CSSImageType VALUE_STRING = new CSSImageType("VALUE_STRING"); //$NON-NLS-1$
+
+ public static final CSSImageType CATEGORY_AURAL = new CSSImageType("CATEGORY_AURAL"); //$NON-NLS-1$
+ public static final CSSImageType CATEGORY_BOX = new CSSImageType("CATEGORY_BOX"); //$NON-NLS-1$
+ public static final CSSImageType CATEGORY_COLORANDBACKGROUND = new CSSImageType("CATEGORY_COLORANDBACKGROUND"); //$NON-NLS-1$
+ public static final CSSImageType CATEGORY_CONTENT = new CSSImageType("CATEGORY_CONTENT"); //$NON-NLS-1$
+ public static final CSSImageType CATEGORY_FONT = new CSSImageType("CATEGORY_FONT"); //$NON-NLS-1$
+ public static final CSSImageType CATEGORY_PAGE = new CSSImageType("CATEGORY_PAGE"); //$NON-NLS-1$
+ public static final CSSImageType CATEGORY_TABLES = new CSSImageType("CATEGORY_TABLES"); //$NON-NLS-1$
+ public static final CSSImageType CATEGORY_TEXT = new CSSImageType("CATEGORY_TEXT"); //$NON-NLS-1$
+ public static final CSSImageType CATEGORY_UI = new CSSImageType("CATEGORY_UI"); //$NON-NLS-1$
+ public static final CSSImageType CATEGORY_VISUAL = new CSSImageType("CATEGORY_VISUAL"); //$NON-NLS-1$
+ public static final CSSImageType CATEGORY_DEFAULT = new CSSImageType("CATEGORY_DEFAULT"); //$NON-NLS-1$
+
+ /**
+ * by node
+ */
+ public static CSSImageType getImageType(ICSSNode node) {
+ CSSImageType imageType = null;
+ if (node instanceof CSSCharsetRule) {
+ imageType = RULE_CHARSET;
+ } else if (node instanceof CSSFontFaceRule) {
+ imageType = RULE_FONTFACE;
+ } else if (node instanceof CSSImportRule) {
+ imageType = RULE_IMPORT;
+ } else if (node instanceof CSSMediaRule) {
+ imageType = RULE_MEDIA;
+ } else if (node instanceof CSSPageRule) {
+ imageType = RULE_PAGE;
+ } else if (node instanceof CSSStyleRule) {
+ imageType = getImageType(((ICSSStyleRule) node).getSelectors());
+ } else if (node instanceof CSSStyleDeclaration) {
+ ICSSNode parent = node.getParentNode();
+ if (parent != null) {
+ return getImageType(parent);
+ }
+ } else if (node instanceof ICSSStyleDeclItem) {
+ String name = ((ICSSStyleDeclItem) node).getPropertyName();
+ ICSSDocument doc = node.getOwnerDocument();
+ ICSSModel model = (doc != null) ? doc.getModel() : null;
+ CSSMetaModelFinder finder = CSSMetaModelFinder.getInstance();
+ CSSMetaModel metaModel = finder.findMetaModelFor(model);
+ // is font-face rule ?
+ ICSSNode parent = node.getParentNode();
+ if (parent != null) {
+ parent = parent.getParentNode();
+ if (parent instanceof CSSFontFaceRule) {
+ imageType = CSSImageType.CATEGORY_FONT;
+ }
+ }
+ if (imageType == null) {
+ CSSMMProperty prop = new CSSMetaModelUtil(metaModel).getProperty(name);
+ if (prop != null) {
+ String category = prop.getAttribute("category"); //$NON-NLS-1$
+ imageType = getImageType(category);
+ }
+ if (imageType == null) {
+ imageType = CSSImageType.CATEGORY_DEFAULT;
+ }
+ }
+ } else if (node instanceof CSSValue) {
+ switch (((CSSValue) node).getCssValueType()) {
+ case CSSPrimitiveValue.CSS_NUMBER :
+ case CSSPrimitiveValue.CSS_PERCENTAGE :
+ case CSSPrimitiveValue.CSS_EMS :
+ case CSSPrimitiveValue.CSS_EXS :
+ case CSSPrimitiveValue.CSS_PX :
+ case CSSPrimitiveValue.CSS_CM :
+ case CSSPrimitiveValue.CSS_MM :
+ case CSSPrimitiveValue.CSS_IN :
+ case CSSPrimitiveValue.CSS_PT :
+ case CSSPrimitiveValue.CSS_PC :
+ case CSSPrimitiveValue.CSS_DEG :
+ case CSSPrimitiveValue.CSS_RAD :
+ case CSSPrimitiveValue.CSS_GRAD :
+ case CSSPrimitiveValue.CSS_MS :
+ case CSSPrimitiveValue.CSS_S :
+ case CSSPrimitiveValue.CSS_HZ :
+ case CSSPrimitiveValue.CSS_KHZ :
+ case CSSPrimitiveValue.CSS_DIMENSION :
+ case ICSSPrimitiveValue.CSS_INTEGER :
+ case ICSSPrimitiveValue.CSS_HASH :
+ imageType = VALUE_NUMBER;
+ break;
+ case CSSPrimitiveValue.CSS_ATTR :
+ case CSSPrimitiveValue.CSS_COUNTER :
+ case CSSPrimitiveValue.CSS_RECT :
+ case CSSPrimitiveValue.CSS_RGBCOLOR :
+ case CSSPrimitiveValue.CSS_URI :
+ case ICSSPrimitiveValue.CSS_FORMAT :
+ case ICSSPrimitiveValue.CSS_LOCAL :
+ imageType = VALUE_FUNCTION;
+ break;
+ default :
+ imageType = VALUE_STRING;
+ break;
+ }
+ }
+ return imageType;
+ }
+
+ public static CSSImageType getImageType(ICSSSelectorList selectorList) {
+ if (selectorList == null || selectorList.getLength() == 0) {
+ return SELECTOR_DEFAULT;
+ }
+ CSSImageType imageType = null;
+ int nSelectors = selectorList.getLength();
+ for (int i = 0; i < nSelectors; i++) {
+ CSSImageType candidate = getImageType(selectorList.getSelector(i));
+ if (imageType == null) {
+ imageType = candidate;
+ } else if (imageType != candidate) {
+ imageType = null;
+ break;
+ }
+ }
+
+ return (imageType == null) ? SELECTOR_DEFAULT : imageType;
+ }
+
+ public static CSSImageType getImageType(ICSSSelector selector) {
+ CSSImageType imageType = SELECTOR_DEFAULT;
+ if (selector == null || selector.getLength() == 0) {
+ return imageType;
+ }
+ ICSSSelectorItem item = selector.getItem(selector.getLength() - 1);
+ if (item.getItemType() == ICSSSelectorItem.SIMPLE) {
+ ICSSSimpleSelector ss = (ICSSSimpleSelector) item;
+ if (0 < ss.getNumOfIDs()) {
+ imageType = SELECTOR_ID;
+ } else if (0 < ss.getNumOfClasses()) {
+ imageType = SELECTOR_CLASS;
+ } else if (0 < ss.getNumOfPseudoNames()) {
+ imageType = SELECTOR_PSEUDO;
+ } else {
+ imageType = SELECTOR_TAG;
+ }
+ }
+ return imageType;
+ }
+
+ public static CSSImageType getImageType(String category) {
+ if (fCategoryMap == null) {
+ fCategoryMap = new HashMap();
+ fCategoryMap.put("aural", CATEGORY_AURAL); //$NON-NLS-1$
+ fCategoryMap.put("box", CATEGORY_BOX); //$NON-NLS-1$
+ fCategoryMap.put("colorandbackground", CATEGORY_COLORANDBACKGROUND); //$NON-NLS-1$
+ fCategoryMap.put("content", CATEGORY_CONTENT); //$NON-NLS-1$
+ fCategoryMap.put("font", CATEGORY_FONT); //$NON-NLS-1$
+ fCategoryMap.put("page", CATEGORY_PAGE); //$NON-NLS-1$
+ fCategoryMap.put("tables", CATEGORY_TABLES); //$NON-NLS-1$
+ fCategoryMap.put("text", CATEGORY_TEXT); //$NON-NLS-1$
+ fCategoryMap.put("ui", CATEGORY_UI); //$NON-NLS-1$
+ fCategoryMap.put("visual", CATEGORY_VISUAL); //$NON-NLS-1$
+ }
+ CSSImageType imageType = (CSSImageType) fCategoryMap.get(category);
+ return (imageType == null) ? CATEGORY_DEFAULT : imageType;
+ }
+
+ private static Map fCategoryMap = null;
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/internal/Logger.java b/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/internal/Logger.java
new file mode 100644
index 0000000000..480a5a6acc
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/internal/Logger.java
@@ -0,0 +1,154 @@
+/*******************************************************************************
+ * Copyright (c) 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.ui.internal;
+
+
+
+import java.util.StringTokenizer;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Plugin;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.wst.css.ui.CSSEditorPlugin;
+
+/**
+ * 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 Plugin fPlugin = CSSEditorPlugin.getDefault();
+ private static final String fPluginId = fPlugin.getDescriptor().getUniqueIdentifier();
+
+ private static final String TRACEFILTER_LOCATION = "/debug/tracefilter"; //$NON-NLS-1$
+
+ public static final int OK = IStatus.OK; // 0
+ public static final int INFO = IStatus.INFO; // 1
+ public static final int WARNING = IStatus.WARNING; // 2
+ public static final int ERROR = IStatus.ERROR; // 4
+
+ public static final int OK_DEBUG = 200 + OK;
+ public static final int INFO_DEBUG = 200 + INFO;
+ public static final int WARNING_DEBUG = 200 + WARNING;
+ public static final int ERROR_DEBUG = 200 + ERROR;
+
+ /**
+ * 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, fPluginId, severity, message, exception);
+ fPlugin.getLog().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, fPluginId, IStatus.OK, message, exception);
+ fPlugin.getLog().log(statusObj);
+ }
+ }
+
+ /**
+ * @return true if the plugin for this logger is debugging
+ */
+ public static boolean isDebugging() {
+ return fPlugin.isDebugging();
+ }
+
+ /**
+ * 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(fPluginId + 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 traceException(String category, String message, Throwable exception) {
+ _trace(category, message, exception);
+ }
+
+ public static void traceException(String category, Throwable exception) {
+ _trace(category, exception.getMessage(), exception);
+ }
+
+ public static void trace(String category, String message) {
+ _trace(category, message, null);
+ }
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/internal/editor/CSSEditorPluginImages.java b/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/internal/editor/CSSEditorPluginImages.java
new file mode 100644
index 0000000000..c7d179fb39
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/internal/editor/CSSEditorPluginImages.java
@@ -0,0 +1,51 @@
+/*******************************************************************************
+ * Copyright (c) 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.ui.internal.editor;
+
+
+/**
+ * Bundle of most images used by the CSS Source Editor plug-in.
+ */
+public class CSSEditorPluginImages {
+ public static final String IMG_OBJ_SORT = "icons/full/obj16/sort.gif"; //$NON-NLS-1$
+
+ public static final String IMG_OBJ_STYLESHEET = "icons/full/obj16/stylesheet.gif"; //$NON-NLS-1$
+ public static final String IMG_OBJ_RULE_CHARSET = "icons/full/obj16/charset_rule.gif"; //$NON-NLS-1$
+ public static final String IMG_OBJ_RULE_FONTFACE = "icons/full/obj16/fontface_rule.gif"; //$NON-NLS-1$
+ public static final String IMG_OBJ_RULE_IMPORT = "icons/full/obj16/link_rule.gif"; //$NON-NLS-1$
+ public static final String IMG_OBJ_RULE_MEDIA = "icons/full/obj16/media_rule.gif"; //$NON-NLS-1$
+ public static final String IMG_OBJ_RULE_PAGE = "icons/full/obj16/page_rule.gif"; //$NON-NLS-1$
+ public static final String IMG_OBJ_RULE_STYLE = "icons/full/obj16/style_rule.gif"; //$NON-NLS-1$
+ public static final String IMG_OBJ_RULE_UNKNOWN = "icons/full/obj16/unknown_rule.gif"; //$NON-NLS-1$
+
+ public static final String IMG_OBJ_SELECTOR_CLASS = "icons/full/obj16/class_selector.gif"; //$NON-NLS-1$
+ public static final String IMG_OBJ_SELECTOR_ID = "icons/full/obj16/id_selector.gif"; //$NON-NLS-1$
+ public static final String IMG_OBJ_SELECTOR_PSEUDO = "icons/full/obj16/pseudo.gif"; //$NON-NLS-1$
+ public static final String IMG_OBJ_SELECTOR_TAG = "icons/full/obj16/tag_selector.gif"; //$NON-NLS-1$
+ public static final String IMG_OBJ_SELECTOR_LINK = "icons/full/obj16/link_selector.gif"; //$NON-NLS-1$
+ public static final String IMG_OBJ_SELECTOR_DEFAULT = "icons/full/obj16/tag_selector.gif"; //$NON-NLS-1$
+
+ public static final String IMG_OBJ_VALUE_FUNCTION = "icons/full/obj16/css_propertyvalue_function.gif"; //$NON-NLS-1$
+ public static final String IMG_OBJ_VALUE_NUMBER = "icons/full/obj16/css_propertyvalue_unit.gif"; //$NON-NLS-1$
+ public static final String IMG_OBJ_VALUE_STRING = "icons/full/obj16/css_propertyvalue_identifier.gif"; //$NON-NLS-1$
+
+ public static final String IMG_OBJ_CATEGORY_AURAL = "icons/full/obj16/aural_props.gif"; //$NON-NLS-1$
+ public static final String IMG_OBJ_CATEGORY_BOX = "icons/full/obj16/boxmodel_props.gif"; //$NON-NLS-1$
+ public static final String IMG_OBJ_CATEGORY_COLORANDBACKGROUND = "icons/full/obj16/colback_props.gif"; //$NON-NLS-1$
+ public static final String IMG_OBJ_CATEGORY_CONTENT = "icons/full/obj16/content_props.gif"; //$NON-NLS-1$
+ public static final String IMG_OBJ_CATEGORY_FONT = "icons/full/obj16/font_props.gif"; //$NON-NLS-1$
+ public static final String IMG_OBJ_CATEGORY_PAGE = "icons/full/obj16/pagedmedia_props.gif"; //$NON-NLS-1$
+ public static final String IMG_OBJ_CATEGORY_TABLES = "icons/full/obj16/table_props.gif"; //$NON-NLS-1$
+ public static final String IMG_OBJ_CATEGORY_TEXT = "icons/full/obj16/text_props.gif"; //$NON-NLS-1$
+ public static final String IMG_OBJ_CATEGORY_UI = "icons/full/obj16/ui_props.gif"; //$NON-NLS-1$
+ public static final String IMG_OBJ_CATEGORY_VISUAL = "icons/full/obj16/visual_props.gif"; //$NON-NLS-1$
+ public static final String IMG_OBJ_CATEGORY_DEFAULT = "icons/full/obj16/other_props.gif"; //$NON-NLS-1$
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/internal/editor/IHelpContextIds.java b/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/internal/editor/IHelpContextIds.java
new file mode 100644
index 0000000000..598c776ecc
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/internal/editor/IHelpContextIds.java
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ * Copyright (c) 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.ui.internal.editor;
+
+import org.eclipse.wst.css.ui.CSSEditorPlugin;
+
+/**
+ * Help context ids for the CSS Source Editor.
+ * <p>
+ * This interface contains constants only; it is not intended to be
+ * implemented.
+ * </p>
+ *
+ */
+public interface IHelpContextIds {
+ // org.eclipse.wst.css.ui.
+ public static final String PREFIX = CSSEditorPlugin.ID + "."; //$NON-NLS-1$
+
+ // CSS Source page editor
+ public static final String CSS_SOURCEVIEW_HELPID = PREFIX + "ecss0000"; //$NON-NLS-1$
+
+ // CSS Files Preference page
+ public static final String CSS_PREFWEBX_FILES_HELPID = PREFIX + "webx0010"; //$NON-NLS-1$
+ // CSS Source Preference page
+ public static final String CSS_PREFWEBX_SOURCE_HELPID = PREFIX + "webx0011"; //$NON-NLS-1$
+ // CSS Styles Preference page
+ public static final String CSS_PREFWEBX_STYLES_HELPID = PREFIX + "webx0012"; //$NON-NLS-1$
+
+ // CSS Cleanup dialog
+ public static final String CSS_CLEANUP_HELPID = PREFIX + "xmlm1300"; //$NON-NLS-1$
+
+ // CSS Content Settings
+ public static final String CSS_CONTENT_SETTINGS_HELPID = PREFIX + "misc0180"; //$NON-NLS-1$
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/internal/nls/ResourceHandler.java b/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/internal/nls/ResourceHandler.java
new file mode 100644
index 0000000000..a14f3f636b
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/internal/nls/ResourceHandler.java
@@ -0,0 +1,66 @@
+/*****************************************************************************
+ * Copyright (c) 2004 IBM Corporation and others. All rights reserved. This
+ * program and the accompanying materials are made available under the terms
+ * of the Eclipse Public License v1.0 which accompanies this distribution, and
+ * is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors: IBM Corporation - initial API and implementation
+ ****************************************************************************/
+package org.eclipse.wst.css.ui.internal.nls;
+
+
+
+import java.text.MessageFormat;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+public class ResourceHandler {
+
+
+ private static ResourceBundle fgResourceBundle;
+
+ /**
+ * Returns the resource bundle used by all classes in this Project
+ */
+ public static ResourceBundle getResourceBundle() {
+ try {
+ return ResourceBundle.getBundle("EditingCSS");//$NON-NLS-1$
+ } catch (MissingResourceException e) {
+ // does nothing - this method will return null and
+ // getString(String) will return the key
+ // it was called with
+ }
+ return null;
+ }
+
+ public static String getString(String key) {
+ if (fgResourceBundle == null) {
+ fgResourceBundle = getResourceBundle();
+ }
+
+ if (fgResourceBundle != null) {
+ try {
+ return fgResourceBundle.getString(key);
+ } catch (MissingResourceException e) {
+ return "!" + key + "!";//$NON-NLS-2$//$NON-NLS-1$
+ }
+ } else {
+ return "!" + key + "!";//$NON-NLS-2$//$NON-NLS-1$
+ }
+ }
+
+ public static String getString(String key, Object[] args) {
+
+ try {
+ return MessageFormat.format(getString(key), args);
+ } catch (IllegalArgumentException e) {
+ return getString(key);
+ }
+
+ }
+
+ public static String getString(String key, Object[] args, int x) {
+
+ return getString(key);
+ }
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/internal/selection/StructureSelectCSSAction.java b/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/internal/selection/StructureSelectCSSAction.java
new file mode 100644
index 0000000000..cf318d6c58
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/internal/selection/StructureSelectCSSAction.java
@@ -0,0 +1,53 @@
+/*****************************************************************************
+ * Copyright (c) 2004 IBM Corporation and others. All rights reserved. This
+ * program and the accompanying materials are made available under the terms
+ * of the Eclipse Public License v1.0 which accompanies this distribution, and
+ * is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors: IBM Corporation - initial API and implementation
+ ****************************************************************************/
+package org.eclipse.wst.css.ui.internal.selection;
+
+import org.eclipse.jface.text.Region;
+import org.eclipse.wst.css.core.document.ICSSNode;
+import org.eclipse.wst.sse.core.IndexedRegion;
+import org.eclipse.wst.sse.ui.StructuredTextEditor;
+import org.eclipse.wst.sse.ui.internal.selection.SelectionHistory;
+import org.eclipse.wst.sse.ui.internal.selection.StructureSelectAction;
+
+public abstract class StructureSelectCSSAction extends StructureSelectAction {
+ public StructureSelectCSSAction(StructuredTextEditor editor, SelectionHistory history) {
+ super(editor, history);
+ }
+
+ public void run() {
+ Region currentRegion = new Region(fViewer.getSelectedRange().x, fViewer.getSelectedRange().y);
+ if (currentRegion.getLength() == fViewer.getDocument().getLength())
+ return;
+
+ IndexedRegion cursorIndexedRegion = getCursorIndexedRegion();
+ if (cursorIndexedRegion instanceof ICSSNode) {
+ ICSSNode cursorNode = (ICSSNode) cursorIndexedRegion;
+
+ Region cursorNodeRegion = new Region(cursorIndexedRegion.getStartOffset(), cursorIndexedRegion.getEndOffset() - cursorIndexedRegion.getStartOffset());
+
+ Region newRegion = null;
+ if (cursorNodeRegion.getOffset() >= currentRegion.getOffset() && cursorNodeRegion.getOffset() <= currentRegion.getOffset() + currentRegion.getLength() && cursorNodeRegion.getOffset() + cursorNodeRegion.getLength() >= currentRegion.getOffset() && cursorNodeRegion.getOffset() + cursorNodeRegion.getLength() <= currentRegion.getOffset() + currentRegion.getLength())
+ newRegion = getNewSelectionRegion(cursorNode, currentRegion);
+ else
+ newRegion = cursorNodeRegion;
+
+ if (newRegion != null) {
+ fHistory.remember(currentRegion);
+ try {
+ fHistory.ignoreSelectionChanges();
+ fEditor.selectAndReveal(newRegion.getOffset(), newRegion.getLength());
+ } finally {
+ fHistory.listenToSelectionChanges();
+ }
+ }
+ }
+ }
+
+ abstract protected Region getNewSelectionRegion(ICSSNode node, Region region);
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/internal/selection/StructureSelectEnclosingCSSAction.java b/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/internal/selection/StructureSelectEnclosingCSSAction.java
new file mode 100644
index 0000000000..62b67c2583
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/internal/selection/StructureSelectEnclosingCSSAction.java
@@ -0,0 +1,47 @@
+/*****************************************************************************
+ * Copyright (c) 2004 IBM Corporation and others. All rights reserved. This
+ * program and the accompanying materials are made available under the terms
+ * of the Eclipse Public License v1.0 which accompanies this distribution, and
+ * is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors: IBM Corporation - initial API and implementation
+ ****************************************************************************/
+package org.eclipse.wst.css.ui.internal.selection;
+
+import org.eclipse.jface.text.Region;
+import org.eclipse.wst.css.core.document.ICSSNode;
+import org.eclipse.wst.sse.core.IndexedRegion;
+import org.eclipse.wst.sse.ui.StructuredTextEditor;
+import org.eclipse.wst.sse.ui.internal.selection.SelectionHistory;
+import org.eclipse.wst.sse.ui.nls.ResourceHandler;
+import org.w3c.dom.Node;
+
+public class StructureSelectEnclosingCSSAction extends StructureSelectCSSAction {
+ public StructureSelectEnclosingCSSAction(StructuredTextEditor editor, SelectionHistory history) {
+ super(editor, history);
+ setText(ResourceHandler.getString("StructureSelectEnclosing.label")); //$NON-NLS-1$
+ setToolTipText(ResourceHandler.getString("StructureSelectEnclosing.tooltip")); //$NON-NLS-1$
+ setDescription(ResourceHandler.getString("StructureSelectEnclosing.description")); //$NON-NLS-1$
+ }
+
+ protected IndexedRegion getCursorIndexedRegion() {
+ return getIndexedRegion(fViewer.getSelectedRange().x);
+ }
+
+ protected Region getNewSelectionRegion(Node node, Region region) {
+ return null;
+ }
+
+ protected Region getNewSelectionRegion(ICSSNode node, Region region) {
+ Region newRegion = null;
+
+ ICSSNode newNode = node.getParentNode();
+
+ if (newNode instanceof IndexedRegion) {
+ IndexedRegion newIndexedRegion = (IndexedRegion) newNode;
+ newRegion = new Region(newIndexedRegion.getStartOffset(), newIndexedRegion.getEndOffset() - newIndexedRegion.getStartOffset());
+ }
+
+ return newRegion;
+ }
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/internal/selection/StructureSelectNextCSSAction.java b/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/internal/selection/StructureSelectNextCSSAction.java
new file mode 100644
index 0000000000..7e469265ec
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/internal/selection/StructureSelectNextCSSAction.java
@@ -0,0 +1,60 @@
+/*****************************************************************************
+ * Copyright (c) 2004 IBM Corporation and others. All rights reserved. This
+ * program and the accompanying materials are made available under the terms
+ * of the Eclipse Public License v1.0 which accompanies this distribution, and
+ * is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors: IBM Corporation - initial API and implementation
+ ****************************************************************************/
+package org.eclipse.wst.css.ui.internal.selection;
+
+import org.eclipse.jface.text.Region;
+import org.eclipse.wst.css.core.document.ICSSNode;
+import org.eclipse.wst.sse.core.IndexedRegion;
+import org.eclipse.wst.sse.ui.StructuredTextEditor;
+import org.eclipse.wst.sse.ui.internal.selection.SelectionHistory;
+import org.eclipse.wst.sse.ui.nls.ResourceHandler;
+import org.w3c.dom.Node;
+
+public class StructureSelectNextCSSAction extends StructureSelectCSSAction {
+ public StructureSelectNextCSSAction(StructuredTextEditor editor, SelectionHistory history) {
+ super(editor, history);
+ setText(ResourceHandler.getString("StructureSelectNext.label")); //$NON-NLS-1$
+ setToolTipText(ResourceHandler.getString("StructureSelectNext.tooltip")); //$NON-NLS-1$
+ setDescription(ResourceHandler.getString("StructureSelectNext.description")); //$NON-NLS-1$
+ }
+
+ protected IndexedRegion getCursorIndexedRegion() {
+ int offset = fViewer.getSelectedRange().x + fViewer.getSelectedRange().y - 1;
+
+ if (offset < 0)
+ offset = 0;
+
+ return getIndexedRegion(offset);
+ }
+
+ protected Region getNewSelectionRegion(Node node, Region region) {
+ return null;
+ }
+
+ protected Region getNewSelectionRegion(ICSSNode node, Region region) {
+ Region newRegion = null;
+
+ ICSSNode newNode = node.getNextSibling();
+ if (newNode == null) {
+ newNode = node.getParentNode();
+
+ if (newNode instanceof IndexedRegion) {
+ IndexedRegion newIndexedRegion = (IndexedRegion) newNode;
+ newRegion = new Region(newIndexedRegion.getStartOffset(), newIndexedRegion.getEndOffset() - newIndexedRegion.getStartOffset());
+ }
+ } else {
+ if (newNode instanceof IndexedRegion) {
+ IndexedRegion newIndexedRegion = (IndexedRegion) newNode;
+ newRegion = new Region(region.getOffset(), newIndexedRegion.getEndOffset() - region.getOffset());
+ }
+ }
+
+ return newRegion;
+ }
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/internal/selection/StructureSelectPreviousCSSAction.java b/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/internal/selection/StructureSelectPreviousCSSAction.java
new file mode 100644
index 0000000000..762eb0b6a4
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/internal/selection/StructureSelectPreviousCSSAction.java
@@ -0,0 +1,55 @@
+/*****************************************************************************
+ * Copyright (c) 2004 IBM Corporation and others. All rights reserved. This
+ * program and the accompanying materials are made available under the terms
+ * of the Eclipse Public License v1.0 which accompanies this distribution, and
+ * is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors: IBM Corporation - initial API and implementation
+ ****************************************************************************/
+package org.eclipse.wst.css.ui.internal.selection;
+
+import org.eclipse.jface.text.Region;
+import org.eclipse.wst.css.core.document.ICSSNode;
+import org.eclipse.wst.sse.core.IndexedRegion;
+import org.eclipse.wst.sse.ui.StructuredTextEditor;
+import org.eclipse.wst.sse.ui.internal.selection.SelectionHistory;
+import org.eclipse.wst.sse.ui.nls.ResourceHandler;
+import org.w3c.dom.Node;
+
+public class StructureSelectPreviousCSSAction extends StructureSelectCSSAction {
+ public StructureSelectPreviousCSSAction(StructuredTextEditor editor, SelectionHistory history) {
+ super(editor, history);
+ setText(ResourceHandler.getString("StructureSelectPrevious.label")); //$NON-NLS-1$
+ setToolTipText(ResourceHandler.getString("StructureSelectPrevious.tooltip")); //$NON-NLS-1$
+ setDescription(ResourceHandler.getString("StructureSelectPrevious.description")); //$NON-NLS-1$
+ }
+
+ protected IndexedRegion getCursorIndexedRegion() {
+ return getIndexedRegion(fViewer.getSelectedRange().x);
+ }
+
+ protected Region getNewSelectionRegion(Node node, Region region) {
+ return null;
+ }
+
+ protected Region getNewSelectionRegion(ICSSNode node, Region region) {
+ Region newRegion = null;
+
+ ICSSNode newNode = node.getPreviousSibling();
+ if (newNode == null) {
+ newNode = node.getParentNode();
+
+ if (newNode instanceof IndexedRegion) {
+ IndexedRegion newIndexedRegion = (IndexedRegion) newNode;
+ newRegion = new Region(newIndexedRegion.getStartOffset(), newIndexedRegion.getEndOffset() - newIndexedRegion.getStartOffset());
+ }
+ } else {
+ if (newNode instanceof IndexedRegion) {
+ IndexedRegion newIndexedRegion = (IndexedRegion) newNode;
+ newRegion = new Region(newIndexedRegion.getStartOffset(), region.getOffset() + region.getLength() - newIndexedRegion.getStartOffset());
+ }
+ }
+
+ return newRegion;
+ }
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/preferences/CSSPreferenceManager.java b/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/preferences/CSSPreferenceManager.java
new file mode 100644
index 0000000000..433a9bab57
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/preferences/CSSPreferenceManager.java
@@ -0,0 +1,185 @@
+/*******************************************************************************
+ * Copyright (c) 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.ui.preferences;
+
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.wst.sse.core.IModelManagerPlugin;
+import org.eclipse.wst.sse.ui.preferences.PreferenceManager;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+/**
+ * @deprecated preference management has moved to base preferences
+ */
+public class CSSPreferenceManager extends PreferenceManager {
+
+ private static CSSPreferenceManager fInstance = null;
+ //
+ private final static String GROUP_COLOR = "color";//$NON-NLS-1$
+ private final static String COLOR_ENABLED = "useColor";//$NON-NLS-1$
+ //
+ private final static String GROUP_ASSIST = "contentAssist"; //$NON-NLS-1$
+ private final static String ASSIST_CATEGORIZE = "categorize"; //$NON-NLS-1$
+
+ protected Document fallbackDocument = null;
+
+ /**
+ *
+ */
+ protected CSSPreferenceManager() {
+ super();
+ }
+
+ /**
+ *
+ */
+ public Document createDefaultPreferences() {
+ Document doc = super.createDefaultPreferences();
+ if (doc == null) {
+ return doc;
+ }
+
+ Node preference = doc.getFirstChild();
+
+ Element color = doc.createElement(GROUP_COLOR);
+ setBooleanAttribute(color, COLOR_ENABLED, true);
+ preference.appendChild(color);
+
+ Element contentAssist = doc.createElement(GROUP_ASSIST);
+ setBooleanAttribute(contentAssist, ASSIST_CATEGORIZE, true);
+ preference.appendChild(contentAssist);
+
+ return doc;
+ }
+
+ public boolean getContentAssistCategorize() {
+ return getBooleanAttribute(getGroupElement(GROUP_ASSIST), ASSIST_CATEGORIZE);
+ }
+
+ public void setContentAssistCategorize(boolean categorize) {
+ setBooleanAttribute(getGroupElement(GROUP_ASSIST), ASSIST_CATEGORIZE, categorize);
+ }
+
+ /**
+ *
+ */
+ protected boolean getBooleanAttribute(Element element, String name) {
+ String str = element.getAttribute(name);
+ if (str == null || str.length() <= 0) {
+ element = getDefaultGroupElement(element.getTagName());
+ if (element != null)
+ str = element.getAttribute(name);
+ }
+ return (str == null) ? false : str.equals(Boolean.TRUE.toString());
+ }
+
+ /**
+ *
+ */
+ public boolean getColorEnabled() {
+ return getBooleanAttribute(getGroupElement(GROUP_COLOR), COLOR_ENABLED);
+ }
+
+ /**
+ *
+ */
+ protected String getFilename() {
+ if (fileName == null) {
+ fileName = Platform.getPlugin(IModelManagerPlugin.ID).getStateLocation().toString() + "/cssprefs.xml";//$NON-NLS-1$
+ }
+ return fileName;
+ }
+
+ /**
+ *
+ */
+ protected Element getGroupElement(String name) {
+ Node node = getNamedChild(getRootElement(), name);
+ return (node instanceof Element) ? (Element) node : getDefaultGroupElement(name);
+ }
+
+ /**
+ *
+ */
+ protected Element getDefaultGroupElement(String name) {
+ Node node = getNamedChild(getDefaultRootElement(), name);
+ return (node instanceof Element) ? (Element) node : null;
+ }
+
+ /**
+ *
+ */
+ protected Node getDefaultRootElement() {
+ if (fallbackDocument == null)
+ fallbackDocument = createDefaultPreferences();
+ return getRootElement(fallbackDocument);
+ }
+
+ /**
+ *
+ */
+ public synchronized static CSSPreferenceManager getInstance() {
+ if (fInstance == null) {
+ fInstance = new CSSPreferenceManager();
+ }
+ return fInstance;
+ }
+
+ /**
+ *
+ */
+ protected int getIntAttribute(Element element, String name) {
+ int value = 0;
+ try {
+ value = Integer.parseInt(element.getAttribute(name));
+ } catch (NumberFormatException e) {
+ element = getDefaultGroupElement(element.getTagName());
+ try {
+ value = Integer.parseInt(element.getAttribute(name));
+ } catch (NumberFormatException ee) {
+ }
+ }
+ return value;
+ }
+
+ /**
+ *
+ */
+ protected String getStringAttribute(Element element, String name) {
+ if (element.getAttributeNode(name) == null) {
+ element = getDefaultGroupElement(element.getTagName());
+ }
+ return element.getAttribute(name);
+ }
+
+ /**
+ *
+ */
+ protected void setBooleanAttribute(Element element, String name, boolean value) {
+ element.setAttribute(name, new Boolean(value).toString());
+ }
+
+ /**
+ *
+ */
+ public void setColorEnabled(boolean enabled) {
+ setBooleanAttribute(getGroupElement(GROUP_COLOR), COLOR_ENABLED, enabled);
+ }
+
+ /**
+ *
+ */
+ protected void setStringAttribute(Element element, String name, String value) {
+ element.setAttribute(name, value);
+ }
+
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/preferences/ui/CSSColorManager.java b/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/preferences/ui/CSSColorManager.java
new file mode 100644
index 0000000000..e3c1eac472
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/preferences/ui/CSSColorManager.java
@@ -0,0 +1,228 @@
+/*******************************************************************************
+ * Copyright (c) 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.ui.preferences.ui;
+
+
+
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.RGB;
+import org.eclipse.wst.css.ui.internal.Logger;
+import org.eclipse.wst.css.ui.style.IStyleConstantsCSS;
+import org.eclipse.wst.sse.core.IModelManagerPlugin;
+import org.eclipse.wst.sse.ui.preferences.PreferenceManager;
+import org.eclipse.wst.sse.ui.preferences.ui.ColorNames;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+/**
+ * @deprecated color preference management has moved to base preferences
+ */
+public class CSSColorManager extends PreferenceManager {
+
+ private static CSSColorManager fInstance = null;
+ // highlighting types
+ /** @deprecated use IStyleConstantsCSS instead TODO remove in C5 or earlier */
+ public static final String NORMAL = "NORMAL";//$NON-NLS-1$
+ /** @deprecated use IStyleConstantsCSS instead TODO remove in C5 or earlier */
+ public static final String ATMARK_RULE = "ATMARK_RULE";//$NON-NLS-1$
+ /** @deprecated use IStyleConstantsCSS instead TODO remove in C5 or earlier */
+ public static final String SELECTOR = "SELECTOR";//$NON-NLS-1$
+ /** @deprecated use IStyleConstantsCSS instead TODO remove in C5 or earlier */
+ public static final String MEDIA = "MEDIA"; //$NON-NLS-1$
+ /** @deprecated use IStyleConstantsCSS instead TODO remove in C5 or earlier */
+ public static final String COMMENT = "COMMENT";//$NON-NLS-1$
+ /** @deprecated use IStyleConstantsCSS instead TODO remove in C5 or earlier */
+ public static final String PROPERTY_NAME = "PROPERTY_NAME";//$NON-NLS-1$
+ /** @deprecated use IStyleConstantsCSS instead TODO remove in C5 or earlier */
+ public static final String PROPERTY_VALUE = "PROPERTY_VALUE";//$NON-NLS-1$
+ /** @deprecated use IStyleConstantsCSS instead TODO remove in C5 or earlier */
+ public static final String URI = "URI";//$NON-NLS-1$
+ /** @deprecated use IStyleConstantsCSS instead TODO remove in C5 or earlier */
+ public static final String STRING = "STRING";//$NON-NLS-1$
+ /** @deprecated use IStyleConstantsCSS instead TODO remove in C5 or earlier */
+ public static final String COLON = "COLON";//$NON-NLS-1$
+ /** @deprecated use IStyleConstantsCSS instead TODO remove in C5 or earlier */
+ public static final String SEMI_COLON = "SEMI_COLON";//$NON-NLS-1$
+ /** @deprecated use IStyleConstantsCSS instead TODO remove in C5 or earlier */
+ public static final String CURLY_BRACE = "CURLY_BRACE";//$NON-NLS-1$
+ /** @deprecated use IStyleConstantsCSS instead TODO remove in C5 or earlier */
+ public static final String ERROR = "ERROR";//$NON-NLS-1$
+ // names for preference elements ... non-NLS
+ public static final String FOREGROUND = "foreground";//$NON-NLS-1$
+ public static final String BACKGROUND = "background";//$NON-NLS-1$
+ public static final String BOLD = "bold";//$NON-NLS-1$
+ public static final String ITALIC = "italic";//$NON-NLS-1$
+ public static final String NAME = "name";//$NON-NLS-1$
+ public static final String COLOR = "color";//$NON-NLS-1$
+
+ private CSSColorManager() {
+ super();
+ }
+
+ protected Element addColor(Node colors, String name, String foreground, String background) {
+ Element newColor = newColor(colors.getOwnerDocument(), name, foreground, background);
+ colors.appendChild(newColor);
+ return newColor;
+ }
+
+ /**
+ * <!ELEMENT colors (color) > <!ELEMENT color EMPTY > <!ATTLIST color name
+ * CDATA #REQUIRED foreground CDATA #IMPLIED background CDATA #IMPLIED
+ * bold CDATA #REQUIRED >
+ *
+ */
+ public Document createDefaultPreferences() {
+ Document prefDocument = super.createDefaultPreferences();
+ if (prefDocument == null)
+ return prefDocument;
+
+ while (prefDocument.getChildNodes().getLength() > 0)
+ prefDocument.removeChild(prefDocument.getLastChild());
+ Element colors = prefDocument.createElement(getRootElementName());
+ prefDocument.appendChild(colors);
+
+ // current as of 2001-8-13
+ addColor(colors, IStyleConstantsCSS.NORMAL, null, null);
+ addColor(colors, IStyleConstantsCSS.ATMARK_RULE, getColorString(63, 127, 127), null);
+ addColor(colors, IStyleConstantsCSS.SELECTOR, getColorString(63, 127, 127), null);
+ addColor(colors, IStyleConstantsCSS.MEDIA, getColorString(42, 0, 225), null);
+ addColor(colors, IStyleConstantsCSS.COMMENT, getColorString(63, 95, 191), null);
+ addColor(colors, IStyleConstantsCSS.PROPERTY_NAME, getColorString(127, 0, 127), null);
+ addColor(colors, IStyleConstantsCSS.PROPERTY_VALUE, getColorString(42, 0, 225), null);
+ addColor(colors, IStyleConstantsCSS.URI, getColorString(42, 0, 225), null);
+ addColor(colors, IStyleConstantsCSS.STRING, getColorString(42, 0, 225), null);
+ addColor(colors, IStyleConstantsCSS.COLON, null, null);
+ addColor(colors, IStyleConstantsCSS.SEMI_COLON, null, null);
+ addColor(colors, IStyleConstantsCSS.CURLY_BRACE, null, null);
+ addColor(colors, IStyleConstantsCSS.ERROR, getColorString(191, 63, 63), null);
+
+ return prefDocument;
+ }
+
+ public RGB getBackgroundRGB(String name) {
+ Element element = getColorElement(name);
+ if (element != null) {
+ return getRGB(element.getAttribute(BACKGROUND));
+ } else {
+ return new RGB(255, 255, 255);
+ }
+ }
+
+ private Element getColorElement(String name) {
+ Node colorsElement = getRootElement();
+ NodeList colors = colorsElement.getChildNodes();
+ for (int i = 0; i < colors.getLength(); i++) {
+ Node node = colors.item(i);
+ if (node.getNodeType() == Node.ELEMENT_NODE && ((Element) node).getAttribute(NAME).equals(name)) {
+ return (Element) node;
+ }
+ }
+ return null;
+ }
+
+ public static String getColorString(int r, int g, int b) {
+ return "#" + getHexString(r, 2) + getHexString(g, 2) + getHexString(b, 2);//$NON-NLS-1$
+ }
+
+ public String getFilename() {
+ if (fileName == null) {
+ fileName = Platform.getPlugin(IModelManagerPlugin.ID).getStateLocation().toString() + "/csssourcecolors.xml";//$NON-NLS-1$
+ }
+ return fileName;
+ }
+
+ public RGB getForegroundRGB(String name) {
+ Element element = getColorElement(name);
+ if (element != null) {
+ return getRGB(element.getAttribute(FOREGROUND));
+ } else {
+ return new RGB(0, 0, 0);
+ }
+ }
+
+ public static String getHexString(int value, int minWidth) {
+ String hexString = Integer.toHexString(value);
+ for (int i = hexString.length(); i < minWidth; i++) {
+ hexString = "0" + hexString;//$NON-NLS-1$
+ }
+ return hexString;
+ }
+
+ public synchronized static CSSColorManager getInstance() {
+ if (fInstance == null) {
+ fInstance = new CSSColorManager();
+ }
+ return fInstance;
+ }
+
+ private RGB getRGB(String rgbStr) {
+ RGB result = null;
+ if (6 < rgbStr.length() && rgbStr.charAt(0) == '#') {
+ try {
+ int r = Integer.valueOf(rgbStr.substring(1, 3), 16).intValue();
+ int g = Integer.valueOf(rgbStr.substring(3, 5), 16).intValue();
+ int b = Integer.valueOf(rgbStr.substring(5, 7), 16).intValue();
+ result = new RGB(r, g, b);
+ } catch (NumberFormatException e) {
+ Logger.logException("Invalid color string " + rgbStr, e); //$NON-NLS-1$
+ }
+ }
+ return result;
+ }
+
+ /**
+ * The intended name for the root Element of the Document; what is also
+ * listed within the DOCTYPE declaration.
+ *
+ * @return String
+ */
+ public String getRootElementName() {
+ return ColorNames.COLORS;
+ }
+
+ public int getStyle(String name) {
+ int style = SWT.NORMAL;
+ Element element = getColorElement(name);
+ if (element != null) {
+ if (Boolean.valueOf(element.getAttribute(BOLD)).booleanValue()) {
+ style |= SWT.BOLD;
+ }
+ if (Boolean.valueOf(element.getAttribute(ITALIC)).booleanValue()) {
+ style |= SWT.ITALIC;
+ }
+ }
+ return style;
+ }
+
+ protected Element newColor(Document doc, String name, String foreground, String background) {
+ if (doc == null || name == null || name.length() < 1)
+ return null;
+ Element newColor = doc.createElement(ColorNames.COLOR);
+ newColor.setAttribute(ColorNames.NAME, name);
+ if (foreground != null)
+ newColor.setAttribute(ColorNames.FOREGROUND, foreground);
+ if (background != null)
+ newColor.setAttribute(ColorNames.BACKGROUND, background);
+ return newColor;
+ }
+
+ protected Element newColor(Document doc, String name, String foreground, String background, boolean bold, boolean italic) {
+ Element newColor = newColor(doc, name, foreground, background);
+ if (newColor == null)
+ return null;
+ newColor.setAttribute(ColorNames.BOLD, String.valueOf(bold));
+ newColor.setAttribute(ColorNames.ITALIC, String.valueOf(italic));
+ return newColor;
+ }
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/preferences/ui/CSSColorPage.java b/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/preferences/ui/CSSColorPage.java
new file mode 100644
index 0000000000..bbbbad30c3
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/preferences/ui/CSSColorPage.java
@@ -0,0 +1,236 @@
+/*****************************************************************************
+ * Copyright (c) 2004 IBM Corporation and others. All rights reserved. This
+ * program and the accompanying materials are made available under the terms
+ * of the Eclipse Public License v1.0 which accompanies this distribution, and
+ * is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors: IBM Corporation - initial API and implementation
+ ****************************************************************************/
+package org.eclipse.wst.css.ui.preferences.ui;
+
+
+
+import java.util.ArrayList;
+import java.util.Dictionary;
+import java.util.Hashtable;
+import java.util.Iterator;
+
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.ui.help.WorkbenchHelp;
+import org.eclipse.wst.common.encoding.content.IContentTypeIdentifier;
+import org.eclipse.wst.css.core.internal.parser.CSSSourceParser;
+import org.eclipse.wst.css.core.parser.CSSRegionContexts;
+import org.eclipse.wst.css.ui.internal.editor.IHelpContextIds;
+import org.eclipse.wst.css.ui.internal.nls.ResourceHandler;
+import org.eclipse.wst.css.ui.style.IStyleConstantsCSS;
+import org.eclipse.wst.sse.core.IModelManager;
+import org.eclipse.wst.sse.core.IModelManagerPlugin;
+import org.eclipse.wst.sse.ui.EditorPlugin;
+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.preferences.PreferenceKeyGenerator;
+import org.eclipse.wst.sse.ui.preferences.ui.AbstractColorPage;
+import org.eclipse.wst.sse.ui.preferences.ui.StyledTextColorPicker;
+
+public class CSSColorPage extends AbstractColorPage {
+
+ /**
+ * 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, PreferenceKeyGenerator.generateKey((String) i.next(), IContentTypeIdentifier.ContentTypeID_CSS)));
+ }
+
+ OverlayPreferenceStore.OverlayKey[] keys = new OverlayPreferenceStore.OverlayKey[overlayKeys.size()];
+ overlayKeys.toArray(keys);
+ return keys;
+ }
+
+ protected Control createContents(Composite parent) {
+ Composite pageComponent = createComposite(parent, 1);
+ ((GridData) pageComponent.getLayoutData()).horizontalAlignment = GridData.HORIZONTAL_ALIGN_FILL;
+
+ super.createContents(pageComponent);
+
+ // assigning one help for whole group
+ // WorkbenchHelp.setHelp(pageComponent,
+ // "com.ibm.etools.webedit.core.cssp2000"); //$NON-NLS-1$
+ WorkbenchHelp.setHelp(pageComponent, IHelpContextIds.CSS_PREFWEBX_STYLES_HELPID);
+
+ return pageComponent;
+ }
+
+ protected Composite createColoringComposite(Composite parent) {
+ Composite coloringComposite = super.createColoringComposite(parent);
+
+ // assigning one help for whole group
+ // WorkbenchHelp.setHelp(coloringComposite,
+ // "com.ibm.etools.webedit.core.cssp2100"); //$NON-NLS-1$
+
+ return coloringComposite;
+ }
+
+ /**
+ * getSampleText method comment.
+ */
+ public String getSampleText() {
+ return ResourceHandler.getString("PrefsLabel.ColorSample"); //$NON-NLS-1$
+ }
+
+ /**
+ *
+ * @param contextStyleMap
+ * java.util.Dictionary
+ */
+ protected void initContextStyleMap(Dictionary contextStyleMap) {
+ contextStyleMap.put(CSSRegionContexts.CSS_COMMENT, IStyleConstantsCSS.COMMENT);
+ contextStyleMap.put(CSSRegionContexts.CSS_CDO, IStyleConstantsCSS.COMMENT);
+ contextStyleMap.put(CSSRegionContexts.CSS_CDC, IStyleConstantsCSS.COMMENT);
+ contextStyleMap.put(CSSRegionContexts.CSS_S, IStyleConstantsCSS.NORMAL);
+
+ contextStyleMap.put(CSSRegionContexts.CSS_DELIMITER, IStyleConstantsCSS.SEMI_COLON);
+ contextStyleMap.put(CSSRegionContexts.CSS_LBRACE, IStyleConstantsCSS.CURLY_BRACE);
+ contextStyleMap.put(CSSRegionContexts.CSS_RBRACE, IStyleConstantsCSS.CURLY_BRACE);
+
+ contextStyleMap.put(CSSRegionContexts.CSS_IMPORT, IStyleConstantsCSS.ATMARK_RULE);
+ contextStyleMap.put(CSSRegionContexts.CSS_PAGE, IStyleConstantsCSS.ATMARK_RULE);
+ contextStyleMap.put(CSSRegionContexts.CSS_MEDIA, IStyleConstantsCSS.ATMARK_RULE);
+ contextStyleMap.put(CSSRegionContexts.CSS_FONT_FACE, IStyleConstantsCSS.ATMARK_RULE);
+ contextStyleMap.put(CSSRegionContexts.CSS_CHARSET, IStyleConstantsCSS.ATMARK_RULE);
+ contextStyleMap.put(CSSRegionContexts.CSS_ATKEYWORD, IStyleConstantsCSS.ATMARK_RULE);
+
+ contextStyleMap.put(CSSRegionContexts.CSS_STRING, IStyleConstantsCSS.STRING);
+ contextStyleMap.put(CSSRegionContexts.CSS_URI, IStyleConstantsCSS.URI);
+ contextStyleMap.put(CSSRegionContexts.CSS_MEDIUM, IStyleConstantsCSS.MEDIA);
+ contextStyleMap.put(CSSRegionContexts.CSS_MEDIA_SEPARATOR, IStyleConstantsCSS.MEDIA);
+
+ contextStyleMap.put(CSSRegionContexts.CSS_CHARSET_NAME, IStyleConstantsCSS.STRING);
+
+ contextStyleMap.put(CSSRegionContexts.CSS_PAGE_SELECTOR, IStyleConstantsCSS.MEDIA);
+
+ contextStyleMap.put(CSSRegionContexts.CSS_SELECTOR_ELEMENT_NAME, IStyleConstantsCSS.SELECTOR);
+ contextStyleMap.put(CSSRegionContexts.CSS_SELECTOR_UNIVERSAL, IStyleConstantsCSS.SELECTOR);
+ contextStyleMap.put(CSSRegionContexts.CSS_SELECTOR_PSEUDO, IStyleConstantsCSS.SELECTOR);
+ contextStyleMap.put(CSSRegionContexts.CSS_SELECTOR_CLASS, IStyleConstantsCSS.SELECTOR);
+ contextStyleMap.put(CSSRegionContexts.CSS_SELECTOR_ID, IStyleConstantsCSS.SELECTOR);
+
+ contextStyleMap.put(CSSRegionContexts.CSS_SELECTOR_COMBINATOR, IStyleConstantsCSS.SELECTOR);
+ contextStyleMap.put(CSSRegionContexts.CSS_SELECTOR_SEPARATOR, IStyleConstantsCSS.SELECTOR);
+ contextStyleMap.put(CSSRegionContexts.CSS_SELECTOR_ATTRIBUTE_START, IStyleConstantsCSS.SELECTOR);
+ contextStyleMap.put(CSSRegionContexts.CSS_SELECTOR_ATTRIBUTE_END, IStyleConstantsCSS.SELECTOR);
+ contextStyleMap.put(CSSRegionContexts.CSS_SELECTOR_ATTRIBUTE_NAME, IStyleConstantsCSS.SELECTOR);
+ contextStyleMap.put(CSSRegionContexts.CSS_SELECTOR_ATTRIBUTE_VALUE, IStyleConstantsCSS.SELECTOR);
+ contextStyleMap.put(CSSRegionContexts.CSS_SELECTOR_ATTRIBUTE_OPERATOR, IStyleConstantsCSS.SELECTOR);
+
+ contextStyleMap.put(CSSRegionContexts.CSS_DECLARATION_PROPERTY, IStyleConstantsCSS.PROPERTY_NAME);
+ contextStyleMap.put(CSSRegionContexts.CSS_DECLARATION_VALUE_IDENT, IStyleConstantsCSS.PROPERTY_VALUE);
+ contextStyleMap.put(CSSRegionContexts.CSS_DECLARATION_VALUE_DIMENSION, IStyleConstantsCSS.PROPERTY_VALUE);
+ contextStyleMap.put(CSSRegionContexts.CSS_DECLARATION_VALUE_PERCENTAGE, IStyleConstantsCSS.PROPERTY_VALUE);
+ contextStyleMap.put(CSSRegionContexts.CSS_DECLARATION_VALUE_NUMBER, IStyleConstantsCSS.PROPERTY_VALUE);
+ contextStyleMap.put(CSSRegionContexts.CSS_DECLARATION_VALUE_FUNCTION, IStyleConstantsCSS.PROPERTY_VALUE);
+ contextStyleMap.put(CSSRegionContexts.CSS_DECLARATION_VALUE_PARENTHESIS_CLOSE, IStyleConstantsCSS.PROPERTY_VALUE);
+ contextStyleMap.put(CSSRegionContexts.CSS_DECLARATION_VALUE_STRING, IStyleConstantsCSS.PROPERTY_VALUE);
+ contextStyleMap.put(CSSRegionContexts.CSS_DECLARATION_VALUE_URI, IStyleConstantsCSS.PROPERTY_VALUE);
+ contextStyleMap.put(CSSRegionContexts.CSS_DECLARATION_VALUE_HASH, IStyleConstantsCSS.PROPERTY_VALUE);
+ contextStyleMap.put(CSSRegionContexts.CSS_DECLARATION_VALUE_UNICODE_RANGE, IStyleConstantsCSS.PROPERTY_VALUE);
+ contextStyleMap.put(CSSRegionContexts.CSS_DECLARATION_VALUE_IMPORTANT, IStyleConstantsCSS.PROPERTY_VALUE);
+ contextStyleMap.put(CSSRegionContexts.CSS_DECLARATION_VALUE_OPERATOR, IStyleConstantsCSS.PROPERTY_VALUE);
+ contextStyleMap.put(CSSRegionContexts.CSS_DECLARATION_VALUE_S, IStyleConstantsCSS.PROPERTY_VALUE);
+ contextStyleMap.put(CSSRegionContexts.CSS_DECLARATION_SEPARATOR, IStyleConstantsCSS.COLON);
+ contextStyleMap.put(CSSRegionContexts.CSS_DECLARATION_DELIMITER, IStyleConstantsCSS.SEMI_COLON);
+
+ contextStyleMap.put(CSSRegionContexts.CSS_UNKNOWN, IStyleConstantsCSS.ERROR);
+ }
+
+ /**
+ *
+ * @param descriptions
+ * java.util.Dictionary
+ */
+ protected void initDescriptions(Dictionary descriptions) {
+ // create descriptions for hilighting types
+ descriptions.put(IStyleConstantsCSS.NORMAL, ResourceHandler.getString("PrefsLabel.ColorNormal"));//$NON-NLS-1$
+ descriptions.put(IStyleConstantsCSS.ATMARK_RULE, ResourceHandler.getString("PrefsLabel.ColorAtmarkRule"));//$NON-NLS-1$
+ descriptions.put(IStyleConstantsCSS.SELECTOR, ResourceHandler.getString("PrefsLabel.ColorSelector"));//$NON-NLS-1$
+ descriptions.put(IStyleConstantsCSS.MEDIA, ResourceHandler.getString("PrefsLabel.ColorMedia"));//$NON-NLS-1$
+ descriptions.put(IStyleConstantsCSS.COMMENT, ResourceHandler.getString("PrefsLabel.ColorComment"));//$NON-NLS-1$
+ descriptions.put(IStyleConstantsCSS.PROPERTY_NAME, ResourceHandler.getString("PrefsLabel.ColorPropertyName"));//$NON-NLS-1$
+ descriptions.put(IStyleConstantsCSS.PROPERTY_VALUE, ResourceHandler.getString("PrefsLabel.ColorPropertyValue"));//$NON-NLS-1$
+ descriptions.put(IStyleConstantsCSS.URI, ResourceHandler.getString("PrefsLabel.ColorUri"));//$NON-NLS-1$
+ descriptions.put(IStyleConstantsCSS.STRING, ResourceHandler.getString("PrefsLabel.ColorString"));//$NON-NLS-1$
+ descriptions.put(IStyleConstantsCSS.COLON, ResourceHandler.getString("PrefsLabel.ColorColon"));//$NON-NLS-1$
+ descriptions.put(IStyleConstantsCSS.SEMI_COLON, ResourceHandler.getString("PrefsLabel.ColorSemiColon"));//$NON-NLS-1$
+ descriptions.put(IStyleConstantsCSS.CURLY_BRACE, ResourceHandler.getString("PrefsLabel.ColorCurlyBrace"));//$NON-NLS-1$
+ descriptions.put(IStyleConstantsCSS.ERROR, ResourceHandler.getString("PrefsLabel.ColorError"));//$NON-NLS-1$
+ }
+
+ /**
+ *
+ * @param list
+ * java.util.ArrayList
+ */
+ protected void initStyleList(ArrayList list) {
+ list.add(IStyleConstantsCSS.NORMAL);
+ list.add(IStyleConstantsCSS.ATMARK_RULE);
+ list.add(IStyleConstantsCSS.SELECTOR);
+ list.add(IStyleConstantsCSS.MEDIA);
+ list.add(IStyleConstantsCSS.COMMENT);
+ list.add(IStyleConstantsCSS.PROPERTY_NAME);
+ list.add(IStyleConstantsCSS.PROPERTY_VALUE);
+ list.add(IStyleConstantsCSS.URI);
+ list.add(IStyleConstantsCSS.STRING);
+ list.add(IStyleConstantsCSS.COLON);
+ list.add(IStyleConstantsCSS.SEMI_COLON);
+ list.add(IStyleConstantsCSS.CURLY_BRACE);
+ list.add(IStyleConstantsCSS.ERROR);
+ }
+
+ /**
+ * setupPicker method comment.
+ */
+ protected void setupPicker(StyledTextColorPicker picker) {
+ IModelManagerPlugin plugin = (IModelManagerPlugin) Platform.getPlugin(IModelManagerPlugin.ID);
+ if (plugin != null) {
+ IModelManager mmanager = plugin.getModelManager();
+ picker.setParser(mmanager.createStructuredDocumentFor(IContentTypeIdentifier.ContentTypeID_CSS).getParser());
+ } else {
+ picker.setParser(new CSSSourceParser());
+ }
+
+ Dictionary descriptions = new Hashtable();
+ initDescriptions(descriptions);
+
+ Dictionary contextStyleMap = new Hashtable();
+ initContextStyleMap(contextStyleMap);
+
+ ArrayList styleList = new ArrayList();
+ initStyleList(styleList);
+
+ picker.setContextStyleMap(contextStyleMap);
+ picker.setDescriptions(descriptions);
+ picker.setStyleList(styleList);
+
+ picker.setGeneratorKey(IContentTypeIdentifier.ContentTypeID_CSS);
+ }
+
+ protected IPreferenceStore doGetPreferenceStore() {
+ return EditorPlugin.getDefault().getPreferenceStore();
+ }
+
+ public boolean performOk() {
+ super.performOk();
+
+ EditorPlugin.getDefault().savePluginPreferences();
+ return true;
+ }
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/preferences/ui/CSSFilesPreferencePage.java b/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/preferences/ui/CSSFilesPreferencePage.java
new file mode 100644
index 0000000000..681a3834aa
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/preferences/ui/CSSFilesPreferencePage.java
@@ -0,0 +1,59 @@
+/*****************************************************************************
+ * Copyright (c) 2004 IBM Corporation and others. All rights reserved. This
+ * program and the accompanying materials are made available under the terms
+ * of the Eclipse Public License v1.0 which accompanies this distribution, and
+ * is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors: IBM Corporation - initial API and implementation
+ ****************************************************************************/
+package org.eclipse.wst.css.ui.preferences.ui;
+
+import org.eclipse.core.runtime.Preferences;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.ui.help.WorkbenchHelp;
+import org.eclipse.wst.css.core.CSSCorePlugin;
+import org.eclipse.wst.css.ui.CSSEditorPlugin;
+import org.eclipse.wst.css.ui.internal.editor.IHelpContextIds;
+import org.eclipse.wst.xml.ui.preferences.XMLFilesPreferencePage;
+
+public class CSSFilesPreferencePage extends XMLFilesPreferencePage {
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.preference.PreferencePage#doGetPreferenceStore()
+ */
+ protected IPreferenceStore doGetPreferenceStore() {
+ return CSSEditorPlugin.getDefault().getPreferenceStore();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.ibm.sse.editor.xml.preferences.ui.XMLFilesPreferencePage#doSavePreferenceStore()
+ */
+ protected void doSavePreferenceStore() {
+ CSSCorePlugin.getDefault().savePluginPreferences(); // model
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.ibm.sse.editor.preferences.ui.AbstractPreferencePage#getModelPreferences()
+ */
+ protected Preferences getModelPreferences() {
+ return CSSCorePlugin.getDefault().getPluginPreferences();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
+ */
+ protected Control createContents(Composite parent) {
+ Control c = super.createContents(parent);
+ WorkbenchHelp.setHelp(c, IHelpContextIds.CSS_PREFWEBX_FILES_HELPID);
+ return c;
+ }
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/preferences/ui/CSSSourcePreferencePage.java b/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/preferences/ui/CSSSourcePreferencePage.java
new file mode 100644
index 0000000000..ce5f660442
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/preferences/ui/CSSSourcePreferencePage.java
@@ -0,0 +1,247 @@
+/*******************************************************************************
+ * Copyright (c) 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.ui.preferences.ui;
+
+
+import org.eclipse.core.runtime.Preferences;
+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.Text;
+import org.eclipse.ui.help.WorkbenchHelp;
+import org.eclipse.wst.common.encoding.content.IContentTypeIdentifier;
+import org.eclipse.wst.css.core.CSSCorePlugin;
+import org.eclipse.wst.css.core.preferences.CSSModelPreferenceNames;
+import org.eclipse.wst.css.ui.internal.editor.IHelpContextIds;
+import org.eclipse.wst.css.ui.internal.nls.ResourceHandler;
+import org.eclipse.wst.sse.core.preferences.CommonModelPreferenceNames;
+import org.eclipse.wst.sse.ui.EditorPlugin;
+import org.eclipse.wst.sse.ui.preferences.PreferenceKeyGenerator;
+import org.eclipse.wst.xml.ui.preferences.XMLSourcePreferencePage;
+
+/**
+ */
+public class CSSSourcePreferencePage extends XMLSourcePreferencePage {
+ // Formatting
+ private final static String FORMATTING_GROUP = ResourceHandler.getString("Formatting_UI_"); //$NON-NLS-1$
+ // private final static String FORMATTING_SPLIT_LINES = "Split lines";
+ private final static String FORMATTING_LINE_WIDTH = ResourceHandler.getString("Line_width__UI_"); //$NON-NLS-1$;
+ private final static String FORMATTING_INSERT_LINE_BREAK = ResourceHandler.getString("PrefsLabel.WrappingInsertLineBreak"); //$NON-NLS-1$
+ private final static String FORMATTING_WRAPPING_WITHOUT_ATTR = ResourceHandler.getString("PrefsLabel.WrappingWithoutAttr");//$NON-NLS-1$
+ private final static String FORMATTING_INDENT_USING_TABS = ResourceHandler.getString("&Indent_using_tabs_3"); //$NON-NLS-1$
+
+ // Case
+ private final static String CASE_GROUP = ResourceHandler.getString("PrefsLabel.CaseGroup"); //$NON-NLS-1$
+ private final static String CASE_IDENT = ResourceHandler.getString("PrefsLabel.CaseIdent"); //$NON-NLS-1$
+ private final static String CASE_PROP_NAME = ResourceHandler.getString("PrefsLabel.CasePropName"); //$NON-NLS-1$
+ private final static String CASE_PROP_VALUE = ResourceHandler.getString("PrefsLabel.CasePropValue"); //$NON-NLS-1$
+ private final static String CASE_IDENT_UPPER = ResourceHandler.getString("PrefsLabel.CaseIdentUpper"); //$NON-NLS-1$
+ private final static String CASE_IDENT_LOWER = ResourceHandler.getString("PrefsLabel.CaseIdentLower"); //$NON-NLS-1$
+ private final static String CASE_PROP_NAME_UPPER = ResourceHandler.getString("PrefsLabel.CasePropNameUpper"); //$NON-NLS-1$
+ private final static String CASE_PROP_NAME_LOWER = ResourceHandler.getString("PrefsLabel.CasePropNameLower"); //$NON-NLS-1$
+ private final static String CASE_PROP_VALUE_UPPER = ResourceHandler.getString("PrefsLabel.CasePropValueUpper"); //$NON-NLS-1$
+ private final static String CASE_PROP_VALUE_LOWER = ResourceHandler.getString("PrefsLabel.CasePropValueLower"); //$NON-NLS-1$
+
+ // one property per one line
+ protected Button fPropertyPerLine;
+ // prohibit wrapping if style attribute
+ protected Button fNowrapAttr;
+
+ // case of output character
+ // case of identifier
+ protected Button fIdentUpper;
+ protected Button fIdentLower;
+ // case of property name
+ protected Button fPropNameUpper;
+ protected Button fPropNameLower;
+ // case of property value
+ protected Button fPropValueUpper;
+ protected Button fPropValueLower;
+
+ protected void createContentsForFormattingGroup(Composite parent) {
+ Group formattingGroup = createGroup(parent, 2);
+ formattingGroup.setText(FORMATTING_GROUP);
+ // // assigning one help for whole group
+ // WorkbenchHelp.setHelp(formattingGroup,
+ // "com.ibm.etools.webedit.core.cssp1200"); //$NON-NLS-1$
+
+ fLineWidthLabel = createLabel(formattingGroup, FORMATTING_LINE_WIDTH);
+ 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);
+
+ fPropertyPerLine = createCheckBox(formattingGroup, FORMATTING_INSERT_LINE_BREAK);
+ ((GridData) fPropertyPerLine.getLayoutData()).horizontalSpan = 2;
+
+ fIndentUsingTabs = createCheckBox(formattingGroup, FORMATTING_INDENT_USING_TABS);
+ ((GridData) fIndentUsingTabs.getLayoutData()).horizontalSpan = 2;
+
+ fNowrapAttr = createCheckBox(formattingGroup, FORMATTING_WRAPPING_WITHOUT_ATTR);
+ ((GridData) fNowrapAttr.getLayoutData()).horizontalSpan = 2;
+ }
+
+ protected void performDefaultsForFormattingGroup() {
+ // Formatting
+ Preferences prefs = getModelPreferences();
+ fLineWidthText.setText(prefs.getDefaultString(CommonModelPreferenceNames.LINE_WIDTH));
+ fPropertyPerLine.setSelection(prefs.getDefaultBoolean(CSSModelPreferenceNames.WRAPPING_ONE_PER_LINE));
+ fIndentUsingTabs.setSelection(prefs.getDefaultBoolean(CommonModelPreferenceNames.INDENT_USING_TABS));
+ fNowrapAttr.setSelection(prefs.getDefaultBoolean(CSSModelPreferenceNames.WRAPPING_PROHIBIT_WRAP_ON_ATTR));
+ }
+
+ protected void initializeValuesForFormattingGroup() {
+ // Formatting
+ Preferences prefs = getModelPreferences();
+ fLineWidthText.setText(prefs.getString(CommonModelPreferenceNames.LINE_WIDTH));
+ fPropertyPerLine.setSelection(prefs.getBoolean(CSSModelPreferenceNames.WRAPPING_ONE_PER_LINE));
+ fIndentUsingTabs.setSelection(prefs.getBoolean(CommonModelPreferenceNames.INDENT_USING_TABS));
+ fNowrapAttr.setSelection(prefs.getBoolean(CSSModelPreferenceNames.WRAPPING_PROHIBIT_WRAP_ON_ATTR));
+ }
+
+ protected void storeValuesForFormattingGroup() {
+ // Formatting
+ Preferences prefs = getModelPreferences();
+ prefs.setValue(CommonModelPreferenceNames.LINE_WIDTH, fLineWidthText.getText());
+ prefs.setValue(CSSModelPreferenceNames.WRAPPING_ONE_PER_LINE, fPropertyPerLine.getSelection());
+ prefs.setValue(CommonModelPreferenceNames.INDENT_USING_TABS, fIndentUsingTabs.getSelection());
+ prefs.setValue(CSSModelPreferenceNames.WRAPPING_PROHIBIT_WRAP_ON_ATTR, fNowrapAttr.getSelection());
+ }
+
+ protected void createContentsForContentAssistGroup(Composite parent) {
+ // not content assist, but preferred case
+ Group caseGroup = createGroup(parent, 3);
+ caseGroup.setText(CASE_GROUP);
+ // WorkbenchHelp.setHelp(caseGroup,
+ // "com.ibm.etools.webedit.core.cssp1400"); //$NON-NLS-1$
+
+ // createLabel(caseGroup, CASE_IDENT);
+ // createLabel(caseGroup, CASE_PROP_NAME);
+ // createLabel(caseGroup, CASE_PROP_VALUE);
+
+ // use group for radio buttons so that associated label is read
+ // Composite identGroup = createComposite(caseGroup, 1);
+ Group identGroup = createGroup(caseGroup, 1);
+ identGroup.setText(CASE_IDENT);
+ fIdentUpper = createRadioButton(identGroup, CASE_IDENT_UPPER);
+ fIdentLower = createRadioButton(identGroup, CASE_IDENT_LOWER);
+
+ // use group for radio buttons so that associated label is read
+ // Composite propNameGroup = createComposite(caseGroup, 1);
+ Group propNameGroup = createGroup(caseGroup, 1);
+ propNameGroup.setText(CASE_PROP_NAME);
+ fPropNameUpper = createRadioButton(propNameGroup, CASE_PROP_NAME_UPPER);
+ fPropNameLower = createRadioButton(propNameGroup, CASE_PROP_NAME_LOWER);
+
+ // use group for radio buttons so that associated label is read
+ // Composite propValueGroup = createComposite(caseGroup, 1);
+ Group propValueGroup = createGroup(caseGroup, 1);
+ propValueGroup.setText(CASE_PROP_VALUE);
+ fPropValueUpper = createRadioButton(propValueGroup, CASE_PROP_VALUE_UPPER);
+ fPropValueLower = createRadioButton(propValueGroup, CASE_PROP_VALUE_LOWER);
+ }
+
+ protected void performDefaultsForContentAssistGroup() {
+ // not content assist, but preferred case
+ Preferences prefs = getModelPreferences();
+ fIdentUpper.setSelection(prefs.getDefaultInt(CSSModelPreferenceNames.CASE_IDENTIFIER) == CommonModelPreferenceNames.UPPER);
+ fIdentLower.setSelection(prefs.getDefaultInt(CSSModelPreferenceNames.CASE_IDENTIFIER) == CommonModelPreferenceNames.LOWER);
+ fPropNameUpper.setSelection(prefs.getDefaultInt(CSSModelPreferenceNames.CASE_PROPERTY_NAME) == CommonModelPreferenceNames.UPPER);
+ fPropNameLower.setSelection(prefs.getDefaultInt(CSSModelPreferenceNames.CASE_PROPERTY_NAME) == CommonModelPreferenceNames.LOWER);
+ fPropValueUpper.setSelection(prefs.getDefaultInt(CSSModelPreferenceNames.CASE_PROPERTY_VALUE) == CommonModelPreferenceNames.UPPER);
+ fPropValueLower.setSelection(prefs.getDefaultInt(CSSModelPreferenceNames.CASE_PROPERTY_VALUE) == CommonModelPreferenceNames.LOWER);
+ }
+
+ protected void initializeValuesForContentAssistGroup() {
+ // not content assist, but preferred case
+ Preferences prefs = getModelPreferences();
+ fIdentUpper.setSelection(prefs.getInt(CSSModelPreferenceNames.CASE_IDENTIFIER) == CommonModelPreferenceNames.UPPER);
+ fIdentLower.setSelection(prefs.getInt(CSSModelPreferenceNames.CASE_IDENTIFIER) == CommonModelPreferenceNames.LOWER);
+ fPropNameUpper.setSelection(prefs.getInt(CSSModelPreferenceNames.CASE_PROPERTY_NAME) == CommonModelPreferenceNames.UPPER);
+ fPropNameLower.setSelection(prefs.getInt(CSSModelPreferenceNames.CASE_PROPERTY_NAME) == CommonModelPreferenceNames.LOWER);
+ fPropValueUpper.setSelection(prefs.getInt(CSSModelPreferenceNames.CASE_PROPERTY_VALUE) == CommonModelPreferenceNames.UPPER);
+ fPropValueLower.setSelection(prefs.getInt(CSSModelPreferenceNames.CASE_PROPERTY_VALUE) == CommonModelPreferenceNames.LOWER);
+ }
+
+ protected void storeValuesForContentAssistGroup() {
+ // not content assist, but preferred case
+ Preferences prefs = getModelPreferences();
+ prefs.setValue(CSSModelPreferenceNames.CASE_IDENTIFIER, (fIdentUpper.getSelection()) ? CommonModelPreferenceNames.UPPER : CommonModelPreferenceNames.LOWER);
+ prefs.setValue(CSSModelPreferenceNames.CASE_PROPERTY_NAME, (fPropNameUpper.getSelection()) ? CommonModelPreferenceNames.UPPER : CommonModelPreferenceNames.LOWER);
+ prefs.setValue(CSSModelPreferenceNames.CASE_PROPERTY_VALUE, (fPropValueUpper.getSelection()) ? CommonModelPreferenceNames.UPPER : CommonModelPreferenceNames.LOWER);
+ }
+
+ protected void createContentsForGrammarConstraintsGroup(Composite parent) {
+ // do nothing
+ }
+
+ protected void performDefaultsForGrammarConstraintsGroup() {
+ // do nothing
+ }
+
+ protected void initializeValuesForGrammarConstraintsGroup() {
+ // do nothing
+ }
+
+ protected void storeValuesForGrammarConstraintsGroup() {
+ // do nothing
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.preference.PreferencePage#doGetPreferenceStore()
+ */
+ // protected IPreferenceStore doGetPreferenceStore() {
+ // return CSSEditorPlugin.getDefault().getPreferenceStore();
+ // }
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.ibm.sse.editor.xml.preferences.ui.XMLFilesPreferencePage#doSavePreferenceStore()
+ */
+ protected void doSavePreferenceStore() {
+ EditorPlugin.getDefault().savePluginPreferences();
+ CSSCorePlugin.getDefault().savePluginPreferences(); // model
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.ibm.sse.editor.preferences.ui.AbstractPreferencePage#getModelPreferences()
+ */
+ protected Preferences getModelPreferences() {
+ return CSSCorePlugin.getDefault().getPluginPreferences();
+ }
+
+ /*
+ * helper method to generate content type id specific preference keys
+ */
+ protected String getKey(String key) {
+ String contentTypeId = IContentTypeIdentifier.ContentTypeID_CSS;
+ return PreferenceKeyGenerator.generateKey(key, contentTypeId);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
+ */
+ protected Control createContents(Composite parent) {
+ Control c = super.createContents(parent);
+ WorkbenchHelp.setHelp(c, IHelpContextIds.CSS_PREFWEBX_SOURCE_HELPID);
+ return c;
+ }
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/registry/AdapterFactoryProviderCSS.java b/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/registry/AdapterFactoryProviderCSS.java
new file mode 100644
index 0000000000..f5f854f233
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/registry/AdapterFactoryProviderCSS.java
@@ -0,0 +1,55 @@
+/*****************************************************************************
+ * Copyright (c) 2004 IBM Corporation and others. All rights reserved. This
+ * program and the accompanying materials are made available under the terms
+ * of the Eclipse Public License v1.0 which accompanies this distribution, and
+ * is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors: IBM Corporation - initial API and implementation
+ ****************************************************************************/
+package org.eclipse.wst.css.ui.registry;
+
+import org.eclipse.ui.views.properties.IPropertySource;
+import org.eclipse.wst.css.core.modelhandler.ModelHandlerForCSS;
+import org.eclipse.wst.css.ui.views.contentoutline.JFaceNodeAdapterFactoryCSS;
+import org.eclipse.wst.css.ui.views.properties.CSSPropertySourceAdapterFactory;
+import org.eclipse.wst.sse.core.AdapterFactory;
+import org.eclipse.wst.sse.core.IFactoryRegistry;
+import org.eclipse.wst.sse.core.IStructuredModel;
+import org.eclipse.wst.sse.core.modelhandler.IDocumentTypeHandler;
+import org.eclipse.wst.sse.ui.registry.AdapterFactoryProvider;
+import org.eclipse.wst.sse.ui.util.Assert;
+import org.eclipse.wst.sse.ui.views.contentoutline.IJFaceNodeAdapter;
+
+public class AdapterFactoryProviderCSS implements AdapterFactoryProvider {
+ public boolean isFor(IDocumentTypeHandler contentTypeDescription) {
+ return (contentTypeDescription instanceof ModelHandlerForCSS);
+ }
+
+ public void addAdapterFactories(IStructuredModel structuredModel) {
+ // add the normal content based factories to model's registry
+ addContentBasedFactories(structuredModel);
+ }
+
+ protected void addContentBasedFactories(IStructuredModel structuredModel) {
+ IFactoryRegistry factoryRegistry = structuredModel.getFactoryRegistry();
+ Assert.isNotNull(factoryRegistry, "Program Error: client caller must ensure model has factory registry"); //$NON-NLS-1$
+ AdapterFactory factory = null;
+
+ factory = factoryRegistry.getFactoryFor(IPropertySource.class);
+ if (factory == null) {
+ factory = new CSSPropertySourceAdapterFactory(IPropertySource.class, true);
+ factoryRegistry.addFactory(factory);
+ }
+
+ factory = factoryRegistry.getFactoryFor(IJFaceNodeAdapter.class);
+ if (factory == null) {
+ factory = new JFaceNodeAdapterFactoryCSS(IJFaceNodeAdapter.class, true);
+ factoryRegistry.addFactory(factory);
+ }
+ }
+
+ public void reinitializeFactories(IStructuredModel structuredModel) {
+
+ }
+
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/style/CSSTextColors.java b/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/style/CSSTextColors.java
new file mode 100644
index 0000000000..8bf4594aab
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/style/CSSTextColors.java
@@ -0,0 +1,143 @@
+/*******************************************************************************
+ * Copyright (c) 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.ui.style;
+
+
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.eclipse.jface.text.TextAttribute;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.RGB;
+import org.eclipse.wst.css.ui.preferences.CSSPreferenceManager;
+import org.eclipse.wst.css.ui.preferences.ui.CSSColorManager;
+import org.eclipse.wst.sse.ui.util.EditorUtility;
+
+/**
+ * @deprecated Most methods and constants moved to LineStyleProviderForCSS or
+ * IStyleConstantsCSS. TODO remove in C5 or earlier
+ */
+public class CSSTextColors {
+ class TextColors {
+
+ TextColors() {
+ super();
+ }
+
+ void setTextAttribute(Object key, RGB foreground, RGB background, int style) {
+ TextAttribute attribute = new TextAttribute(EditorUtility.getColor(foreground), EditorUtility.getColor(background), style);
+ setTextAttribute(key, attribute);
+ }
+
+ void setTextAttribute(Object key, TextAttribute attribute) {
+ TextAttribute oldAttribute = (TextAttribute) fAttributeTable.get(key);
+ if (oldAttribute != null) {
+ fAttributeTable.remove(key);
+ }
+ fAttributeTable.put(key, attribute);
+ }
+
+ TextAttribute getTextAttribute(Object key) {
+ return (TextAttribute) fAttributeTable.get(key);
+ }
+
+ private Map fAttributeTable = new HashMap();
+ }
+
+ // color types
+ public static final String NORMAL = "NORMAL"; //$NON-NLS-1$
+ public static final String ATMARK_RULE = "ATMARK_RULE"; //$NON-NLS-1$
+ public static final String SELECTOR = "SELECTOR"; //$NON-NLS-1$
+ public static final String MEDIA = "MEDIA"; //$NON-NLS-1$
+ public static final String COMMENT = "COMMENT"; //$NON-NLS-1$
+ public static final String PROPERTY_NAME = "PROPERTY_NAME"; //$NON-NLS-1$
+ public static final String PROPERTY_VALUE = "PROPERTY_VALUE"; //$NON-NLS-1$
+ public static final String URI = "URI"; //$NON-NLS-1$
+ public static final String STRING = "STRING"; //$NON-NLS-1$
+ public static final String COLON = "COLON"; //$NON-NLS-1$
+ public static final String SEMI_COLON = "SEMI_COLON"; //$NON-NLS-1$
+ public static final String CURLY_BRACE = "CURLY_BRACE"; //$NON-NLS-1$
+ public static final String ERROR = "ERROR"; //$NON-NLS-1$
+ private static CSSTextColors fInstance = null;
+ private TextColors fTextColors = null;
+ private Map fPrefToType = null;
+
+ protected CSSTextColors() {
+ super();
+ applyPreference();
+ }
+
+ public synchronized static CSSTextColors getInstance() {
+ if (fInstance == null) {
+ fInstance = new CSSTextColors();
+ }
+ return fInstance;
+ }
+
+ public void applyPreference() {
+ if (fTextColors == null) {
+ fTextColors = new TextColors();
+ }
+
+ if (fPrefToType == null) {
+ fPrefToType = new HashMap();
+ fPrefToType.put(NORMAL, CSSColorManager.NORMAL);
+ fPrefToType.put(ATMARK_RULE, CSSColorManager.ATMARK_RULE);
+ fPrefToType.put(SELECTOR, CSSColorManager.SELECTOR);
+ fPrefToType.put(MEDIA, CSSColorManager.MEDIA);
+ fPrefToType.put(COMMENT, CSSColorManager.COMMENT);
+ fPrefToType.put(PROPERTY_NAME, CSSColorManager.PROPERTY_NAME);
+ fPrefToType.put(PROPERTY_VALUE, CSSColorManager.PROPERTY_VALUE);
+ fPrefToType.put(URI, CSSColorManager.URI);
+ fPrefToType.put(STRING, CSSColorManager.STRING);
+ fPrefToType.put(COLON, CSSColorManager.COLON);
+ fPrefToType.put(SEMI_COLON, CSSColorManager.SEMI_COLON);
+ fPrefToType.put(CURLY_BRACE, CSSColorManager.CURLY_BRACE);
+ fPrefToType.put(ERROR, CSSColorManager.ERROR);
+ }
+ boolean bEnabled = CSSPreferenceManager.getInstance().getColorEnabled();
+ CSSColorManager pref = CSSColorManager.getInstance();
+
+ Iterator i = fPrefToType.keySet().iterator();
+ while (i.hasNext()) {
+ String key = (String) i.next();
+ if (bEnabled) {
+ String type = (String) fPrefToType.get(key);
+ setTextAttribute(key, pref.getForegroundRGB(type), pref.getBackgroundRGB(type), pref.getStyle(type));
+ } else {
+ setTextAttribute(key, null);
+ }
+ }
+ }
+
+ public void dispose() {
+ }
+
+ public TextAttribute getTextAttribute(String type) {
+ if (fTextColors == null) {
+ applyPreference();
+ }
+ return fTextColors.getTextAttribute(type);
+ }
+
+ private void setTextAttribute(String type, RGB foreground) {
+ setTextAttribute(type, foreground, null, SWT.NORMAL);
+ }
+
+ private void setTextAttribute(String type, RGB foreground, RGB background, int style) {
+ if (fTextColors == null) {
+ return;
+ }
+ fTextColors.setTextAttribute(type, foreground, background, style);
+ }
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/style/IStyleConstantsCSS.java b/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/style/IStyleConstantsCSS.java
new file mode 100644
index 0000000000..31eb84e7ed
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/style/IStyleConstantsCSS.java
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ * Copyright (c) 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.ui.style;
+
+/**
+ * Contains the symbolic name of styles used by LineStyleProvider,
+ * ColorManager, and any others who may be interested
+ */
+public interface IStyleConstantsCSS {
+ public static final String NORMAL = "NORMAL"; //$NON-NLS-1$
+ public static final String ATMARK_RULE = "ATMARK_RULE"; //$NON-NLS-1$
+ public static final String SELECTOR = "SELECTOR"; //$NON-NLS-1$
+ public static final String MEDIA = "MEDIA"; //$NON-NLS-1$
+ public static final String COMMENT = "COMMENT"; //$NON-NLS-1$
+ public static final String PROPERTY_NAME = "PROPERTY_NAME"; //$NON-NLS-1$
+ public static final String PROPERTY_VALUE = "PROPERTY_VALUE"; //$NON-NLS-1$
+ public static final String URI = "URI"; //$NON-NLS-1$
+ public static final String STRING = "STRING"; //$NON-NLS-1$
+ public static final String COLON = "COLON"; //$NON-NLS-1$
+ public static final String SEMI_COLON = "SEMI_COLON"; //$NON-NLS-1$
+ public static final String CURLY_BRACE = "CURLY_BRACE"; //$NON-NLS-1$
+ public static final String ERROR = "ERROR"; //$NON-NLS-1$
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/style/LineStyleProviderForCSS.java b/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/style/LineStyleProviderForCSS.java
new file mode 100644
index 0000000000..27bf5378cd
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/style/LineStyleProviderForCSS.java
@@ -0,0 +1,202 @@
+/*******************************************************************************
+ * Copyright (c) 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.ui.style;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.text.TextAttribute;
+import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.wst.common.encoding.content.IContentTypeIdentifier;
+import org.eclipse.wst.css.core.parser.CSSRegionContexts;
+import org.eclipse.wst.sse.core.text.ITextRegion;
+import org.eclipse.wst.sse.ui.EditorPlugin;
+import org.eclipse.wst.sse.ui.preferences.PreferenceKeyGenerator;
+import org.eclipse.wst.sse.ui.style.AbstractLineStyleProvider;
+import org.eclipse.wst.sse.ui.style.LineStyleProvider;
+
+/**
+ */
+public class LineStyleProviderForCSS extends AbstractLineStyleProvider implements LineStyleProvider {
+ /** Contains region to style mapping */
+ private Map fColorTypes;
+
+ /**
+ * LineStyleProviderForEmbeddedCSS constructor comment.
+ */
+ public LineStyleProviderForCSS() {
+ super();
+ initAttributes();
+ loadColors();
+ }
+
+ protected TextAttribute getAttributeFor(ITextRegion region) {
+ if (region != null) {
+ String type = region.getType();
+ if (type != null) {
+ return getAttributeFor(type);
+ }
+ }
+ return (TextAttribute) getTextAttributes().get(IStyleConstantsCSS.NORMAL);
+ }
+
+ protected TextAttribute getAttributeFor(String type) {
+ return (TextAttribute) getTextAttributes().get(fColorTypes.get(type));
+ }
+
+ private void initAttributes() {
+ if (fColorTypes == null) {
+ fColorTypes = new HashMap();
+ }
+ fColorTypes.put(CSSRegionContexts.CSS_COMMENT, IStyleConstantsCSS.COMMENT);
+ fColorTypes.put(CSSRegionContexts.CSS_CDO, IStyleConstantsCSS.COMMENT);
+ fColorTypes.put(CSSRegionContexts.CSS_CDC, IStyleConstantsCSS.COMMENT);
+ fColorTypes.put(CSSRegionContexts.CSS_S, IStyleConstantsCSS.NORMAL);
+
+ fColorTypes.put(CSSRegionContexts.CSS_DELIMITER, IStyleConstantsCSS.SEMI_COLON);
+ fColorTypes.put(CSSRegionContexts.CSS_LBRACE, IStyleConstantsCSS.CURLY_BRACE);
+ fColorTypes.put(CSSRegionContexts.CSS_RBRACE, IStyleConstantsCSS.CURLY_BRACE);
+
+ fColorTypes.put(CSSRegionContexts.CSS_IMPORT, IStyleConstantsCSS.ATMARK_RULE);
+ fColorTypes.put(CSSRegionContexts.CSS_PAGE, IStyleConstantsCSS.ATMARK_RULE);
+ fColorTypes.put(CSSRegionContexts.CSS_MEDIA, IStyleConstantsCSS.ATMARK_RULE);
+ fColorTypes.put(CSSRegionContexts.CSS_FONT_FACE, IStyleConstantsCSS.ATMARK_RULE);
+ fColorTypes.put(CSSRegionContexts.CSS_CHARSET, IStyleConstantsCSS.ATMARK_RULE);
+ fColorTypes.put(CSSRegionContexts.CSS_ATKEYWORD, IStyleConstantsCSS.ATMARK_RULE);
+
+ fColorTypes.put(CSSRegionContexts.CSS_STRING, IStyleConstantsCSS.STRING);
+ fColorTypes.put(CSSRegionContexts.CSS_URI, IStyleConstantsCSS.URI);
+ fColorTypes.put(CSSRegionContexts.CSS_MEDIUM, IStyleConstantsCSS.MEDIA);
+ fColorTypes.put(CSSRegionContexts.CSS_MEDIA_SEPARATOR, IStyleConstantsCSS.MEDIA);
+
+ fColorTypes.put(CSSRegionContexts.CSS_CHARSET_NAME, IStyleConstantsCSS.STRING);
+
+ fColorTypes.put(CSSRegionContexts.CSS_PAGE_SELECTOR, IStyleConstantsCSS.MEDIA);
+
+ fColorTypes.put(CSSRegionContexts.CSS_SELECTOR_ELEMENT_NAME, IStyleConstantsCSS.SELECTOR);
+ fColorTypes.put(CSSRegionContexts.CSS_SELECTOR_UNIVERSAL, IStyleConstantsCSS.SELECTOR);
+ fColorTypes.put(CSSRegionContexts.CSS_SELECTOR_PSEUDO, IStyleConstantsCSS.SELECTOR);
+ fColorTypes.put(CSSRegionContexts.CSS_SELECTOR_CLASS, IStyleConstantsCSS.SELECTOR);
+ fColorTypes.put(CSSRegionContexts.CSS_SELECTOR_ID, IStyleConstantsCSS.SELECTOR);
+
+ fColorTypes.put(CSSRegionContexts.CSS_SELECTOR_COMBINATOR, IStyleConstantsCSS.SELECTOR);
+ fColorTypes.put(CSSRegionContexts.CSS_SELECTOR_SEPARATOR, IStyleConstantsCSS.SELECTOR);
+ fColorTypes.put(CSSRegionContexts.CSS_SELECTOR_ATTRIBUTE_START, IStyleConstantsCSS.SELECTOR);
+ fColorTypes.put(CSSRegionContexts.CSS_SELECTOR_ATTRIBUTE_END, IStyleConstantsCSS.SELECTOR);
+ fColorTypes.put(CSSRegionContexts.CSS_SELECTOR_ATTRIBUTE_NAME, IStyleConstantsCSS.SELECTOR);
+ fColorTypes.put(CSSRegionContexts.CSS_SELECTOR_ATTRIBUTE_VALUE, IStyleConstantsCSS.SELECTOR);
+ fColorTypes.put(CSSRegionContexts.CSS_SELECTOR_ATTRIBUTE_OPERATOR, IStyleConstantsCSS.SELECTOR);
+
+ fColorTypes.put(CSSRegionContexts.CSS_DECLARATION_PROPERTY, IStyleConstantsCSS.PROPERTY_NAME);
+ fColorTypes.put(CSSRegionContexts.CSS_DECLARATION_VALUE_IDENT, IStyleConstantsCSS.PROPERTY_VALUE);
+ fColorTypes.put(CSSRegionContexts.CSS_DECLARATION_VALUE_DIMENSION, IStyleConstantsCSS.PROPERTY_VALUE);
+ fColorTypes.put(CSSRegionContexts.CSS_DECLARATION_VALUE_PERCENTAGE, IStyleConstantsCSS.PROPERTY_VALUE);
+ fColorTypes.put(CSSRegionContexts.CSS_DECLARATION_VALUE_NUMBER, IStyleConstantsCSS.PROPERTY_VALUE);
+ fColorTypes.put(CSSRegionContexts.CSS_DECLARATION_VALUE_FUNCTION, IStyleConstantsCSS.PROPERTY_VALUE);
+ fColorTypes.put(CSSRegionContexts.CSS_DECLARATION_VALUE_PARENTHESIS_CLOSE, IStyleConstantsCSS.PROPERTY_VALUE);
+ fColorTypes.put(CSSRegionContexts.CSS_DECLARATION_VALUE_STRING, IStyleConstantsCSS.PROPERTY_VALUE);
+ fColorTypes.put(CSSRegionContexts.CSS_DECLARATION_VALUE_URI, IStyleConstantsCSS.PROPERTY_VALUE);
+ fColorTypes.put(CSSRegionContexts.CSS_DECLARATION_VALUE_HASH, IStyleConstantsCSS.PROPERTY_VALUE);
+ fColorTypes.put(CSSRegionContexts.CSS_DECLARATION_VALUE_UNICODE_RANGE, IStyleConstantsCSS.PROPERTY_VALUE);
+ fColorTypes.put(CSSRegionContexts.CSS_DECLARATION_VALUE_IMPORTANT, IStyleConstantsCSS.PROPERTY_VALUE);
+ fColorTypes.put(CSSRegionContexts.CSS_DECLARATION_VALUE_OPERATOR, IStyleConstantsCSS.PROPERTY_VALUE);
+ fColorTypes.put(CSSRegionContexts.CSS_DECLARATION_VALUE_S, IStyleConstantsCSS.PROPERTY_VALUE);
+ fColorTypes.put(CSSRegionContexts.CSS_DECLARATION_SEPARATOR, IStyleConstantsCSS.COLON);
+ fColorTypes.put(CSSRegionContexts.CSS_DECLARATION_DELIMITER, IStyleConstantsCSS.SEMI_COLON);
+
+ fColorTypes.put(CSSRegionContexts.CSS_UNKNOWN, IStyleConstantsCSS.NORMAL);
+ }
+
+ protected void handlePropertyChange(PropertyChangeEvent event) {
+ String styleKey = null;
+
+ if (event != null) {
+ String prefKey = event.getProperty();
+ // check if preference changed is a style preference
+ if (getPreferenceKey(IStyleConstantsCSS.ATMARK_RULE).equals(prefKey)) {
+ styleKey = IStyleConstantsCSS.ATMARK_RULE;
+ } else if (getPreferenceKey(IStyleConstantsCSS.COLON).equals(prefKey)) {
+ styleKey = IStyleConstantsCSS.COLON;
+ } else if (getPreferenceKey(IStyleConstantsCSS.COMMENT).equals(prefKey)) {
+ styleKey = IStyleConstantsCSS.COMMENT;
+ } else if (getPreferenceKey(IStyleConstantsCSS.CURLY_BRACE).equals(prefKey)) {
+ styleKey = IStyleConstantsCSS.CURLY_BRACE;
+ } else if (getPreferenceKey(IStyleConstantsCSS.ERROR).equals(prefKey)) {
+ styleKey = IStyleConstantsCSS.ERROR;
+ } else if (getPreferenceKey(IStyleConstantsCSS.MEDIA).equals(prefKey)) {
+ styleKey = IStyleConstantsCSS.MEDIA;
+ } else if (getPreferenceKey(IStyleConstantsCSS.NORMAL).equals(prefKey)) {
+ styleKey = IStyleConstantsCSS.NORMAL;
+ } else if (getPreferenceKey(IStyleConstantsCSS.PROPERTY_NAME).equals(prefKey)) {
+ styleKey = IStyleConstantsCSS.PROPERTY_NAME;
+ } else if (getPreferenceKey(IStyleConstantsCSS.PROPERTY_VALUE).equals(prefKey)) {
+ styleKey = IStyleConstantsCSS.PROPERTY_VALUE;
+ } else if (getPreferenceKey(IStyleConstantsCSS.SELECTOR).equals(prefKey)) {
+ styleKey = IStyleConstantsCSS.SELECTOR;
+ } else if (getPreferenceKey(IStyleConstantsCSS.SEMI_COLON).equals(prefKey)) {
+ styleKey = IStyleConstantsCSS.SEMI_COLON;
+ } else if (getPreferenceKey(IStyleConstantsCSS.STRING).equals(prefKey)) {
+ styleKey = IStyleConstantsCSS.STRING;
+ } else if (getPreferenceKey(IStyleConstantsCSS.URI).equals(prefKey)) {
+ styleKey = IStyleConstantsCSS.URI;
+ }
+ } else {
+ // this is around for old deprecated preferencesChanged() method
+ // TODO remove when preferencesChanged() is removed
+ loadColors();
+ super.handlePropertyChange(event);
+ }
+
+ if (styleKey != null) {
+ // overwrite style preference with new value
+ addTextAttribute(styleKey);
+ super.handlePropertyChange(event);
+ }
+ }
+
+ public void release() {
+ if (fColorTypes != null) {
+ fColorTypes.clear();
+ }
+ super.release();
+ }
+
+ public void loadColors() {
+ clearColors();
+ addTextAttribute(IStyleConstantsCSS.ATMARK_RULE);
+ addTextAttribute(IStyleConstantsCSS.COLON);
+ addTextAttribute(IStyleConstantsCSS.COMMENT);
+ addTextAttribute(IStyleConstantsCSS.CURLY_BRACE);
+ addTextAttribute(IStyleConstantsCSS.ERROR);
+ addTextAttribute(IStyleConstantsCSS.MEDIA);
+ addTextAttribute(IStyleConstantsCSS.NORMAL);
+ addTextAttribute(IStyleConstantsCSS.PROPERTY_NAME);
+ addTextAttribute(IStyleConstantsCSS.PROPERTY_VALUE);
+ addTextAttribute(IStyleConstantsCSS.SELECTOR);
+ addTextAttribute(IStyleConstantsCSS.SEMI_COLON);
+ addTextAttribute(IStyleConstantsCSS.STRING);
+ addTextAttribute(IStyleConstantsCSS.URI);
+ }
+
+ protected void clearColors() {
+ getTextAttributes().clear();
+ }
+
+ protected String getPreferenceKey(String key) {
+ String contentTypeId = IContentTypeIdentifier.ContentTypeID_CSS;
+ return PreferenceKeyGenerator.generateKey(key, contentTypeId);
+ }
+
+ protected IPreferenceStore getColorPreferences() {
+ return EditorPlugin.getDefault().getPreferenceStore();
+ }
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/style/LineStyleProviderForEmbeddedCSS.java b/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/style/LineStyleProviderForEmbeddedCSS.java
new file mode 100644
index 0000000000..71bc4b2a49
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/style/LineStyleProviderForEmbeddedCSS.java
@@ -0,0 +1,104 @@
+/*****************************************************************************
+ * Copyright (c) 2004 IBM Corporation and others. All rights reserved. This
+ * program and the accompanying materials are made available under the terms
+ * of the Eclipse Public License v1.0 which accompanies this distribution, and
+ * is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors: IBM Corporation - initial API and implementation
+ ****************************************************************************/
+package org.eclipse.wst.css.ui.style;
+
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.jface.text.ITypedRegion;
+import org.eclipse.jface.text.TextAttribute;
+import org.eclipse.swt.custom.StyleRange;
+import org.eclipse.wst.css.core.parser.CSSTextParser;
+import org.eclipse.wst.css.core.parser.CSSTextToken;
+import org.eclipse.wst.sse.core.text.IStructuredDocumentRegion;
+import org.eclipse.wst.sse.core.text.ITextRegion;
+
+public class LineStyleProviderForEmbeddedCSS extends LineStyleProviderForCSS {
+
+ public boolean prepareRegions(ITypedRegion typedRegion, int lineRequestStart, int lineRequestLength, Collection holdResults) {
+ int regionStart = typedRegion.getOffset();
+ int regionEnd = regionStart + typedRegion.getLength();
+ IStructuredDocumentRegion wholeRegion = getDocument().getRegionAtCharacterOffset(regionStart);
+
+ List tokens;
+ int offset;
+
+ ParserCache cache = getCachedParsingResult(wholeRegion);
+ if (cache == null) {
+ offset = wholeRegion.getStartOffset();
+ String content;
+ content = wholeRegion.getText();
+
+ CSSTextParser parser = new CSSTextParser(CSSTextParser.MODE_STYLESHEET, content);
+ tokens = parser.getTokenList();
+ cacheParsingResult(wholeRegion, new ParserCache(offset, tokens));
+ } else {
+ tokens = cache.tokens;
+ offset = cache.offset;
+ }
+
+ boolean result = false;
+
+ if (0 < tokens.size()) {
+ int start = offset;
+ Iterator i = tokens.iterator();
+ while (i.hasNext()) {
+ CSSTextToken token = (CSSTextToken) i.next();
+ if (regionStart <= start && start < regionEnd) {
+ TextAttribute attribute = getAttributeFor(token.kind);
+ holdResults.add(new StyleRange(start, token.length, attribute.getForeground(), attribute.getBackground()));
+ }
+ start += token.length;
+ }
+ result = true;
+ }
+
+ return result;
+ }
+
+ protected TextAttribute getAttributeFor(ITextRegion region) {
+ return null;
+ }
+
+ private void cleanupCache() {
+ fCacheKey = -1;
+ fCacheResult = null;
+ }
+
+ private ParserCache getCachedParsingResult(IStructuredDocumentRegion region) {
+ if (fCacheKey == region.getText().hashCode()) {
+ return fCacheResult;
+ }
+ return null;
+ }
+
+ private void cacheParsingResult(IStructuredDocumentRegion region, ParserCache result) {
+ fCacheKey = region.getText().hashCode();
+ fCacheResult = result;
+ }
+
+ public void release() {
+ super.release();
+ cleanupCache();
+ }
+
+ private class ParserCache {
+ ParserCache(int newOffset, List newTokens) {
+ offset = newOffset;
+ tokens = newTokens;
+ }
+
+ int offset;
+ List tokens;
+ }
+
+ int fCacheKey = -1;
+ ParserCache fCacheResult = null;
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/taginfo/CSSBestMatchHoverProcessor.java b/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/taginfo/CSSBestMatchHoverProcessor.java
new file mode 100644
index 0000000000..2c4a0feb23
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/taginfo/CSSBestMatchHoverProcessor.java
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * Copyright (c) 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.ui.taginfo;
+
+import org.eclipse.jface.text.ITextHover;
+import org.eclipse.wst.sse.ui.taginfo.AbstractBestMatchHoverProcessor;
+
+/**
+ * Provides the best css hover help documentation (by using other hover help
+ * processors) Priority of hover help processors is: ProblemHoverProcessor,
+ * AnnotationHoverProcessor
+ */
+public class CSSBestMatchHoverProcessor extends AbstractBestMatchHoverProcessor {
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.ibm.sse.editor.taginfo.AbstractBestMatchHoverProcessor#getTagInfoHover()
+ */
+ protected ITextHover getTagInfoHover() {
+ // CSS has no taginfo hover
+ return null;
+ }
+
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/text/CSSDocumentRegionEdgeMatcher.java b/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/text/CSSDocumentRegionEdgeMatcher.java
new file mode 100644
index 0000000000..ce975a9b81
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/text/CSSDocumentRegionEdgeMatcher.java
@@ -0,0 +1,89 @@
+/*****************************************************************************
+ * Copyright (c) 2004 IBM Corporation and others. All rights reserved. This
+ * program and the accompanying materials are made available under the terms
+ * of the Eclipse Public License v1.0 which accompanies this distribution, and
+ * is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors: IBM Corporation - initial API and implementation
+ ****************************************************************************/
+package org.eclipse.wst.css.ui.text;
+
+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;
+import org.eclipse.wst.css.core.parser.CSSRegionContexts;
+import org.eclipse.wst.sse.core.text.IStructuredDocument;
+import org.eclipse.wst.sse.core.text.IStructuredDocumentRegion;
+
+public class CSSDocumentRegionEdgeMatcher implements ICharacterPairMatcher {
+
+ private int fAnchor = ICharacterPairMatcher.LEFT;
+
+ /**
+ * @param validContexts
+ * @param nextMatcher
+ */
+ public CSSDocumentRegionEdgeMatcher() {
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.text.source.ICharacterPairMatcher#clear()
+ */
+ public void clear() {
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.text.source.ICharacterPairMatcher#dispose()
+ */
+ public void dispose() {
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.text.source.ICharacterPairMatcher#getAnchor()
+ */
+ public int getAnchor() {
+ return fAnchor;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.ibm.sse.editor.ui.text.DocumentRegionEdgeMatcher#match(org.eclipse.jface.text.IDocument,
+ * int)
+ */
+
+
+ public IRegion match(IDocument document, int offset) {
+ if (document instanceof IStructuredDocument) {
+ IStructuredDocumentRegion r = ((IStructuredDocument) document).getRegionAtCharacterOffset(offset);
+ if (r != null) {
+ if (r.getPrevious() != null && r.getStartOffset() == offset && r.getPrevious().getType().equals(CSSRegionContexts.CSS_RBRACE)) {
+ r = r.getPrevious();
+ }
+ if (r.getType().equals(CSSRegionContexts.CSS_RBRACE)) {
+ while (r != null && !r.getType().equals(CSSRegionContexts.CSS_LBRACE)) {
+ r = r.getPrevious();
+ }
+ if (r != null) {
+ return new Region(r.getStartOffset(), 1);
+ }
+ } else if (r.getType().equals(CSSRegionContexts.CSS_LBRACE)) {
+ while (r != null && !r.getType().equals(CSSRegionContexts.CSS_RBRACE)) {
+ r = r.getNext();
+ }
+ if (r != null) {
+ return new Region(r.getEndOffset() - 1, 1);
+ }
+ }
+ }
+ }
+ return null;
+ }
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/views/contentoutline/CSSContentOutlineConfiguration.java b/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/views/contentoutline/CSSContentOutlineConfiguration.java
new file mode 100644
index 0000000000..82f94e504e
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/views/contentoutline/CSSContentOutlineConfiguration.java
@@ -0,0 +1,118 @@
+/*****************************************************************************
+ * Copyright (c) 2004 IBM Corporation and others. All rights reserved. This
+ * program and the accompanying materials are made available under the terms
+ * of the Eclipse Public License v1.0 which accompanies this distribution, and
+ * is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors: IBM Corporation - initial API and implementation
+ ****************************************************************************/
+package org.eclipse.wst.css.ui.views.contentoutline;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.jface.action.IContributionItem;
+import org.eclipse.jface.viewers.IContentProvider;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.wst.css.core.document.ICSSNode;
+import org.eclipse.wst.css.core.document.ICSSStyleDeclItem;
+import org.eclipse.wst.css.core.document.ICSSValue;
+import org.eclipse.wst.css.ui.CSSEditorPlugin;
+import org.eclipse.wst.sse.core.AdapterFactory;
+import org.eclipse.wst.sse.ui.preferences.PreferenceKeyGenerator;
+import org.eclipse.wst.sse.ui.view.events.NodeSelectionChangedEvent;
+import org.eclipse.wst.sse.ui.views.contentoutline.PropertyChangeUpdateActionContributionItem;
+import org.eclipse.wst.sse.ui.views.contentoutline.StructuredContentOutlineConfiguration;
+
+public class CSSContentOutlineConfiguration extends StructuredContentOutlineConfiguration {
+ private final String OUTLINE_SORT_PREF = "outline-sort"; //$NON-NLS-1$
+
+ public CSSContentOutlineConfiguration() {
+ super();
+ }
+
+ public IContributionItem[] createToolbarContributions(TreeViewer viewer) {
+ IContributionItem[] items = super.createToolbarContributions(viewer);
+
+ SortAction sortAction = new SortAction(viewer, CSSEditorPlugin.getDefault().getPreferenceStore(), getSortPreferenceKey());
+ IContributionItem sortItem = new PropertyChangeUpdateActionContributionItem(sortAction);
+
+ if (items == null) {
+ items = new IContributionItem[1];
+ items[0] = sortItem;
+ } else {
+ IContributionItem[] combinedItems = new IContributionItem[items.length + 1];
+ combinedItems[0] = sortItem;
+ System.arraycopy(items, 0, combinedItems, 1, items.length);
+ items = combinedItems;
+ }
+ return items;
+ }
+
+ /**
+ * @see com.ibm.sse.editor.views.contentoutline.ContentOutlineConfiguration#getContentProvider(org.eclipse.jface.viewers.TreeViewer)
+ */
+ public IContentProvider getContentProvider(TreeViewer viewer) {
+ if (fContentProvider == null && getFactory() != null)
+ fContentProvider = new JFaceNodeContentProviderCSS((AdapterFactory) getFactory());
+ return fContentProvider;
+ }
+
+ /**
+ * @see com.ibm.sse.editor.views.contentoutline.ContentOutlineConfiguration#getLabelProvider(org.eclipse.jface.viewers.TreeViewer)
+ */
+ public ILabelProvider getLabelProvider(TreeViewer viewer) {
+ if (fLabelProvider == null && getFactory() != null)
+ fLabelProvider = new JFaceNodeLabelProviderCSS((AdapterFactory) getFactory());
+ return fLabelProvider;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.ibm.sse.editor.views.contentoutline.ContentOutlineConfiguration#getNodes(java.util.List)
+ */
+ public List getNodes(List nodes) {
+ List filteredNodes = new ArrayList(nodes);
+
+ List targetNodes = new ArrayList();
+ Iterator i = filteredNodes.iterator();
+ while (i.hasNext()) {
+ Object obj = i.next();
+ if (obj instanceof ICSSNode) {
+ ICSSNode node = (ICSSNode) obj;
+ short nodeType = node.getNodeType();
+ if (node instanceof ICSSValue) {
+ while (node != null && !(node instanceof ICSSStyleDeclItem)) {
+ node = node.getParentNode();
+ }
+ } else if (nodeType == ICSSNode.STYLEDECLARATION_NODE) {
+ node = node.getParentNode();
+ } else if (nodeType == ICSSNode.MEDIALIST_NODE) {
+ node = node.getParentNode();
+ }
+ if (node != null) {
+ obj = node;
+ }
+ }
+ targetNodes.add(obj);
+ }
+
+ return targetNodes;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.ibm.sse.editor.views.contentoutline.ContentOutlineConfiguration#getSelectedNodes(com.ibm.sse.editor.view.events.NodeSelectionChangedEvent)
+ */
+ public List getSelectedNodes(NodeSelectionChangedEvent event) {
+ return getNodes(event.getSelectedNodes());
+ }
+
+ public String getSortPreferenceKey() {
+ return PreferenceKeyGenerator.generateKey(OUTLINE_SORT_PREF, getDeclaringID());
+ }
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/views/contentoutline/CSSNodeAdapter.java b/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/views/contentoutline/CSSNodeAdapter.java
new file mode 100644
index 0000000000..d012df085d
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/views/contentoutline/CSSNodeAdapter.java
@@ -0,0 +1,319 @@
+/*******************************************************************************
+ * Copyright (c) 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.ui.views.contentoutline;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Vector;
+
+import org.eclipse.jface.viewers.StructuredViewer;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.views.properties.PropertySheetPage;
+import org.eclipse.wst.css.core.document.ICSSNode;
+import org.eclipse.wst.css.core.document.ICSSStyleDeclItem;
+import org.eclipse.wst.css.core.document.ICSSStyleDeclaration;
+import org.eclipse.wst.css.core.document.ICSSStyleRule;
+import org.eclipse.wst.css.core.document.ICSSStyleSheet;
+import org.eclipse.wst.sse.core.AdapterFactory;
+import org.eclipse.wst.sse.core.INodeAdapter;
+import org.eclipse.wst.sse.core.INodeNotifier;
+import org.eclipse.wst.sse.ui.views.contentoutline.IJFaceNodeAdapter;
+import org.eclipse.wst.sse.ui.views.contentoutline.IJFaceNodeAdapterFactory;
+
+/**
+ * Adapts a DOM node to a JFace viewer.
+ */
+//public class CSSNodeAdapter extends JFaceNodeAdapter {
+public class CSSNodeAdapter implements INodeAdapter, Runnable {
+ class NotifyContext {
+ NotifyContext(INodeNotifier notifier, int eventType, Object changedFeature, Object oldValue, Object newValue, int pos) {
+ this.notifier = notifier;
+ this.eventType = eventType;
+ this.changedFeature = changedFeature;
+ this.oldValue = oldValue;
+ this.newValue = newValue;
+ this.pos = pos;
+ }
+
+ void fire() {
+ internalNotifyChanged(notifier, eventType, changedFeature, oldValue, newValue, pos);
+ }
+
+ INodeNotifier notifier;
+ int eventType;
+ Object changedFeature;
+ Object oldValue;
+ Object newValue;
+ int pos;
+ }
+
+ class StyleViewUpdater implements Runnable {
+ public void run() {
+ if (lastUpdater == this) {
+ internalActionPerformed();
+ lastUpdater = null;
+ }
+ }
+ }
+
+ protected AdapterFactory adapterFactory;
+ private Vector notifyQueue;
+ StyleViewUpdater lastUpdater;
+ protected int delayMSecs = 500;
+ final static Class ADAPTER_KEY = IJFaceNodeAdapter.class;
+
+ public CSSNodeAdapter(AdapterFactory adapterFactory) {
+ super();
+ this.adapterFactory = adapterFactory;
+ }
+
+ /**
+ * Insert the method's description here.
+ */
+ protected void internalActionPerformed() {
+ if (notifyQueue == null) {
+ return;
+ }
+ boolean refresh_all = false;
+ boolean refresh_rule = false;
+ int pos_all = 0;
+ List targets = new ArrayList();
+ for (int i = 0; i < notifyQueue.size(); i++) {
+ NotifyContext context = (NotifyContext) notifyQueue.get(i);
+ if (context.notifier instanceof ICSSStyleSheet) {
+ refresh_all = true;
+ pos_all = i;
+ }
+ if (context.notifier instanceof ICSSStyleDeclaration) {
+ refresh_rule = true;
+ targets.add(context);
+ // pos_rule = i;
+ }
+ // ((NotifyContext) notifyQueue.get(i)).fire();
+ }
+ if (refresh_all) {
+ ((NotifyContext) notifyQueue.get(pos_all)).fire();
+ } else if (refresh_rule) {
+ Iterator i = targets.iterator();
+ while (i.hasNext()) {
+ ((NotifyContext) i.next()).fire();
+ }
+ // else if (refresh_rule) internalRefreshAll();
+ } else {
+ for (int i = 0; i < notifyQueue.size(); i++) {
+ ((NotifyContext) notifyQueue.get(i)).fire();
+ }
+ }
+ notifyQueue.clear();
+ }
+
+ /**
+ * Called by the object being adapter (the notifier) when something has
+ * changed.
+ */
+ public void internalNotifyChanged(INodeNotifier notifier, int eventType, Object changedFeature, Object oldValue, Object newValue, int pos) {
+ Iterator iterator = ((IJFaceNodeAdapterFactory) adapterFactory).getListeners().iterator();
+ while (iterator.hasNext()) {
+ Object listener = iterator.next();
+ if (listener instanceof StructuredViewer) {
+ notifyChangedForStructuredViewer((StructuredViewer) listener, notifier, eventType, changedFeature, oldValue, newValue, pos);
+ } else if (listener instanceof PropertySheetPage) {
+ notifyChangedForPropertySheetPage((PropertySheetPage) listener, notifier, eventType, changedFeature, oldValue, newValue, pos);
+ }
+ }
+ }
+
+ private void notifyChangedForPropertySheetPage(PropertySheetPage page, INodeNotifier notifier, int eventType, Object changedFeature, Object oldValue, Object newValue, int pos) {
+ if (page.getControl() == null || page.getControl().isDisposed()) {
+ return;
+ }
+ if (eventType == INodeNotifier.CHANGE || eventType == INodeNotifier.ADD || eventType == INodeNotifier.REMOVE) {
+ page.refresh();
+ }
+ }
+
+ private void notifyChangedForStructuredViewer(StructuredViewer viewer, INodeNotifier notifier, int eventType, Object changedFeature, Object oldValue, Object newValue, int pos) {
+ if (viewer.getControl() == null || viewer.getControl().isDisposed()) {
+ return;
+ }
+ if (eventType == INodeNotifier.CHANGE) {
+ if (notifier instanceof ICSSStyleSheet) {
+ ICSSNode temp = (changedFeature != null) ? (ICSSNode) changedFeature : (ICSSNode) newValue;
+ if (temp instanceof ICSSStyleRule) {
+ viewer.refresh();
+ } else {
+ for (;;) {
+ if (temp instanceof ICSSStyleRule) {
+ break;
+ }
+ temp = temp.getParentNode();
+ if (temp == null) {
+ break;
+ }
+ }
+ if (temp == null || temp instanceof ICSSStyleSheet) {
+ viewer.refresh();
+ } else {
+ viewer.refresh(temp);
+ }
+ }
+ } else {
+ ICSSNode temp = (ICSSNode) notifier;
+ if (temp != null) {
+ temp = temp.getParentNode();
+ }
+ if (temp == null || temp instanceof ICSSStyleSheet) {
+ viewer.refresh();
+ } else {
+ viewer.refresh(temp);
+ }
+ }
+ }
+ if (eventType == INodeNotifier.ADD) {
+ if (notifier instanceof ICSSStyleSheet) {
+ ICSSNode temp = (changedFeature != null) ? (ICSSNode) changedFeature : (ICSSNode) newValue;
+ if (temp instanceof ICSSStyleRule) {
+ viewer.refresh();
+ } else {
+ for (;;) {
+ if (temp instanceof ICSSStyleRule) {
+ break;
+ }
+ temp = temp.getParentNode();
+ if (temp == null) {
+ break;
+ }
+ }
+ }
+ if (temp == null || (temp instanceof ICSSStyleSheet)) {
+ viewer.refresh();
+ } else {
+ viewer.refresh(temp);
+ }
+ } else {
+ if (newValue != null && (newValue instanceof ICSSStyleDeclItem)) {
+ viewer.refresh(((ICSSNode) newValue).getParentNode());
+ } else {
+ ICSSNode temp = (ICSSNode) notifier;
+ if (temp != null) {
+ temp = temp.getParentNode();
+ }
+ if (temp == null || (temp instanceof ICSSStyleSheet)) {
+ viewer.refresh();
+ } else {
+ viewer.refresh(temp);
+ }
+ }
+ }
+ } else if (eventType == INodeNotifier.REMOVE) {
+ if (notifier instanceof ICSSStyleSheet) {
+ ICSSNode temp = (changedFeature != null) ? (ICSSNode) changedFeature : (ICSSNode) newValue;
+ if (temp instanceof ICSSStyleRule) {
+ viewer.refresh();
+ } else {
+ for (;;) {
+ if (temp instanceof ICSSStyleRule) {
+ break;
+ }
+ temp = temp.getParentNode();
+ if (temp == null) {
+ break;
+ }
+ }
+ if (temp == null || (temp instanceof ICSSStyleSheet)) {
+ viewer.refresh();
+ } else {
+ viewer.refresh(temp);
+ }
+ }
+ } else {
+ // viewer.refresh(notifier);
+ ICSSNode temp = (ICSSNode) notifier;
+ if (temp != null) {
+ temp = temp.getParentNode();
+ }
+ if (temp == null || (temp instanceof ICSSStyleSheet)) {
+ viewer.refresh();
+ } else {
+ viewer.refresh(temp);
+ }
+ }
+ }
+ // }
+ }
+
+ /**
+ *
+ */
+ public void internalRefreshAll() {
+ Collection listeners = ((JFaceNodeAdapterFactoryCSS) adapterFactory).getListeners();
+ Iterator iterator = listeners.iterator();
+ while (iterator.hasNext()) {
+ Object listener = iterator.next();
+ if (listener instanceof StructuredViewer) {
+ StructuredViewer viewer = (StructuredViewer) listener;
+ if (viewer.getControl() != null && !viewer.getControl().isDisposed()) {
+ viewer.refresh();
+ }
+ } else if (listener instanceof PropertySheetPage) {
+ PropertySheetPage page = (PropertySheetPage) listener;
+ if (page.getControl() != null && !page.getControl().isDisposed()) {
+ page.refresh();
+ }
+ }
+ }
+ }
+
+ /**
+ * Allowing the INodeAdapter to compare itself against the type allows it
+ * to return true in more than one case.
+ */
+ public boolean isAdapterForType(Object type) {
+ return type.equals(ADAPTER_KEY);
+ }
+
+ /**
+ * Called by the object being adapter (the notifier) when something has
+ * changed.
+ */
+ public void notifyChanged(INodeNotifier notifier, int eventType, Object changedFeature, Object oldValue, Object newValue, int pos) {
+ if (notifyQueue == null)
+ notifyQueue = new Vector();
+ notifyQueue.add(new NotifyContext(notifier, eventType, changedFeature, oldValue, newValue, pos));
+ // TODO-future: there's probably a better way than relying on async
+ // exec
+ if (Thread.currentThread() == getDisplay().getThread())
+ getDisplay().timerExec(delayMSecs, this);
+ else
+ getDisplay().asyncExec(new Runnable() {
+ public void run() {
+ if (getDisplay() != null) {
+ getDisplay().timerExec(delayMSecs, this);
+ }
+ }
+ });
+ }
+
+ Display getDisplay() {
+ return PlatformUI.getWorkbench().getDisplay();
+ }
+
+ /**
+ * this method is intended only for timerExec()
+ */
+ public void run() {
+ lastUpdater = new StyleViewUpdater();
+ getDisplay().asyncExec(lastUpdater);
+ }
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/views/contentoutline/JFaceNodeAdapterFactoryCSS.java b/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/views/contentoutline/JFaceNodeAdapterFactoryCSS.java
new file mode 100644
index 0000000000..df96b82b76
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/views/contentoutline/JFaceNodeAdapterFactoryCSS.java
@@ -0,0 +1,42 @@
+/*****************************************************************************
+ * Copyright (c) 2004 IBM Corporation and others. All rights reserved. This
+ * program and the accompanying materials are made available under the terms
+ * of the Eclipse Public License v1.0 which accompanies this distribution, and
+ * is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors: IBM Corporation - initial API and implementation
+ ****************************************************************************/
+package org.eclipse.wst.css.ui.views.contentoutline;
+
+import org.eclipse.wst.sse.core.INodeAdapter;
+import org.eclipse.wst.sse.core.INodeNotifier;
+import org.eclipse.wst.sse.ui.views.contentoutline.IJFaceNodeAdapter;
+import org.eclipse.wst.xml.ui.views.contentoutline.JFaceNodeAdapterFactory;
+
+public class JFaceNodeAdapterFactoryCSS extends JFaceNodeAdapterFactory {
+ public JFaceNodeAdapterFactoryCSS() {
+ this(IJFaceNodeAdapter.class, true);
+ }
+
+ public JFaceNodeAdapterFactoryCSS(Object adapterKey, boolean registerAdapters) {
+ super(adapterKey, registerAdapters);
+ }
+
+
+ protected void initAdapter(INodeAdapter adapter, INodeNotifier node) {
+ }
+
+ protected INodeAdapter createAdapter(INodeNotifier node) {
+ if (singletonAdapter == null) {
+ // create the JFaceNodeAdapter
+ singletonAdapter = new CSSNodeAdapter(this);
+ initAdapter(singletonAdapter, node);
+ }
+ return singletonAdapter;
+ }
+
+ public void release() {
+ }
+
+
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/views/contentoutline/JFaceNodeContentProviderCSS.java b/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/views/contentoutline/JFaceNodeContentProviderCSS.java
new file mode 100644
index 0000000000..3235b9cae1
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/views/contentoutline/JFaceNodeContentProviderCSS.java
@@ -0,0 +1,263 @@
+/*******************************************************************************
+ * Copyright (c) 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.ui.views.contentoutline;
+
+
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.wst.css.core.document.ICSSDocument;
+import org.eclipse.wst.css.core.document.ICSSModel;
+import org.eclipse.wst.css.core.document.ICSSNode;
+import org.eclipse.wst.css.core.document.ICSSPrimitiveValue;
+import org.eclipse.wst.css.core.document.ICSSStyleDeclItem;
+import org.eclipse.wst.css.core.document.ICSSStyleDeclaration;
+import org.eclipse.wst.sse.core.AdapterFactory;
+import org.eclipse.wst.sse.core.INodeNotifier;
+import org.eclipse.wst.xml.ui.views.contentoutline.JFaceNodeContentProvider;
+import org.w3c.dom.css.CSSRule;
+import org.w3c.dom.stylesheets.MediaList;
+
+
+/**
+ * A Content provider for a JFace viewer used to display DOM nodes. This
+ * content provider takes an adapter factory to create JFace adapters for the
+ * nodes in the tree.
+ */
+public class JFaceNodeContentProviderCSS extends JFaceNodeContentProvider {
+ protected AdapterFactory adapterFactory;
+
+ //protected DomainNotifier domainNotifier;
+ /**
+ */
+ public JFaceNodeContentProviderCSS(AdapterFactory adapterFactory) {
+ super(adapterFactory);
+ this.adapterFactory = adapterFactory;
+ }
+
+ /**
+ */
+ protected void adaptElements(Object element) {
+
+ ICSSNode node;
+
+ if (element instanceof ICSSModel) {
+ ICSSDocument doc = ((ICSSModel) element).getDocument();
+ adapterFactory.adapt((INodeNotifier) doc);
+ node = doc.getFirstChild();
+ } else if (element instanceof ICSSNode) {
+ node = ((ICSSNode) element).getFirstChild();
+ } else {
+ return;
+ }
+
+ while (node != null) {
+ // if (node instanceof CSSRule) {
+ adapterFactory.adapt((INodeNotifier) node);
+ adaptElements(node);
+ // }
+ // else{
+ // adapterFactory.adapt((INodeNotifier) node);
+ // }
+
+ node = node.getNextSibling();
+ }
+ }
+
+ /**
+ */
+ protected void addElements(Object element, ArrayList v) {
+
+ ICSSNode node;
+
+ if (element instanceof ICSSModel) {
+ ICSSModel model = (ICSSModel) element;
+ ICSSDocument doc = model.getDocument();
+ // addAdapter((INodeNotifier) doc);
+ adapterFactory.adapt((INodeNotifier) doc);
+ node = doc.getFirstChild();
+ } else if (element instanceof ICSSNode) {
+ node = ((ICSSNode) element).getFirstChild();
+ } else
+ return;
+
+ while (node != null) {
+ if (node instanceof CSSRule) {
+ v.add(node);
+ }
+
+ node = node.getNextSibling();
+ }
+
+ }
+
+ /**
+ * The visual part that is using this content provider is about to be
+ * disposed. Deallocate all allocated SWT resources.
+ */
+ public void dispose() {
+ }
+
+ /**
+ * Returns an enumeration containing all child nodes of the given element,
+ * which represents a node in a tree. The difference to
+ * <code>IStructuredContentProvider.getElements(Object)</code> is as
+ * follows: <code>getElements</code> is called to obtain the tree
+ * viewer's root elements. Method <code>getChildren</code> is used to
+ * obtain the children of a given node in the tree, which can can be a
+ * root node, too.
+ */
+ public Object[] getChildren(Object object) {
+ if (object instanceof ICSSNode) {
+ ICSSNode node = (ICSSNode) object;
+ short nodeType = node.getNodeType();
+ if (nodeType == ICSSNode.STYLERULE_NODE || nodeType == ICSSNode.PAGERULE_NODE || nodeType == ICSSNode.FONTFACERULE_NODE) {
+ for (node = node.getFirstChild(); node != null && !(node instanceof ICSSStyleDeclaration); node.getNextSibling()) {
+ // nop
+ }
+ }
+ List children = new ArrayList();
+ ICSSNode child = (node != null) ? node.getFirstChild() : null;
+ while (child != null) {
+ if (!(child instanceof ICSSPrimitiveValue) && !(child instanceof MediaList)) {
+ children.add(child);
+ }
+ child = child.getNextSibling();
+ }
+ return children.toArray();
+ }
+ return new Object[0];
+ }
+
+ /**
+ * Returns an enumeration with the elements belonging to the passed
+ * element. These elements can be presented as rows in a table, items in a
+ * list etc.
+ */
+ public Object[] getElements(Object object) {
+ // The root is usually an instance of an XMLStructuredModel in
+ // which case we want to extract the document.
+
+ if (object instanceof ICSSModel) {
+ ArrayList v = new ArrayList();
+ // internalGetElements(object, v);
+ addElements(object, v);
+ adaptElements(object);
+ return v.toArray();
+ }
+ return new Object[0];
+
+ }
+
+ /**
+ * Returns the parent for the given element. This method can return
+ * <code>null</code> indicating that the parent can't be computed. In
+ * this case the tree viewer can't expand a given node correctly if
+ * requested.
+ */
+ public Object getParent(Object object) {
+ // IJFaceNodeAdapter adapter = getAdapter(object);
+ /*
+ * ICSSNodeAdapter adapter = (ICSSNodeAdapter)getAdapter(object); if
+ * (adapter != null) return adapter.getParent((ICSSNode) object); else
+ * return null;
+ */
+ if (object instanceof ICSSNode) {
+ ICSSNode node = ((ICSSNode) object).getParentNode();
+ if (node != null && node.getNodeType() == ICSSNode.STYLEDECLARATION_NODE) {
+ node = node.getParentNode();
+ }
+ return node;
+ }
+ return null;
+ }
+
+ /**
+ * Returns <code>true</code> if the given element has children.
+ * Otherwise <code>false</code> is returned.
+ */
+ public boolean hasChildren(Object object) {
+ // return getAdapter(object).hasChildren((ICSSNode) object);
+ if (object instanceof ICSSNode) {
+ if (object instanceof ICSSStyleDeclItem)
+ return false;
+ else
+ return ((ICSSNode) object).hasChildNodes();
+ }
+ return false;
+ }
+
+ /**
+ * Called when the viewer's input is changing from <code>oldInput</code>
+ * to <code>newInput</code>. Both <code>newInput</code> and
+ * <code>oldInput</code> can be <code>null</code>. If
+ * <code>oldInput</code> is <code>null</code> it is the viewer's first
+ * connection to the content provider. If <code>newInput</code> is
+ * <code>null</code> the visual part is disconnected from any input. A
+ * typical implementation of this methods registers the content provider
+ * as a listener to changes on the new input, and deregisters the viewer
+ * from the old input. The content provider then updates the viewer in
+ * response to change notifications from the input.
+ */
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ //// If there was no old input, then we must be providing content for
+ // this part for the first time...
+ //if (oldInput == null) {
+ //// If the part is an IDomainListener then make the part start
+ // listening to us.
+ //if (viewer instanceof IDomainListener)
+ //domainNotifier.addDomainListener((IDomainListener) viewer);
+ //}
+ //// If there is no new input, we must clean ourselves up as if we'd
+ // never seen the viewer.
+ //else
+ //if (newInput == null) {
+ //// If the part is an IDomainListener, then we make it stop
+ // listening to us.
+ //if (viewer instanceof IDomainListener)
+ //domainNotifier.removeDomainListener((IDomainListener) viewer);
+
+ //}
+ }
+
+ /**
+ */
+ /*
+ * protected void internalGetElements(Object element, ArrayList v) {
+ *
+ * ICSSNode node;
+ *
+ * if (element instanceof ICSSModel) { ICSSModel model =
+ * (ICSSModel)element; ICSSDocument doc = model.getDocument();
+ * adapterFactory.adapt((INodeNotifier)doc); node = doc.getFirstChild(); }
+ * else if (element instanceof ICSSNode) { node =
+ * ((ICSSNode)element).getFirstChild(); } else { return; }
+ *
+ * while (node != null) { switch (node.getNodeType()) { case
+ * ICSSNode.STYLEDECLARATION_NODE: adapterFactory.adapt((INodeNotifier)
+ * node); break; case ICSSNode.STYLERULE_NODE: case
+ * ICSSNode.FONTFACERULE_NODE: case ICSSNode.PAGERULE_NODE: case
+ * ICSSNode.IMPORTRULE_NODE: case ICSSNode.MEDIARULE_NODE: v.add(node);
+ * adapterFactory.adapt((INodeNotifier) node); break; default:
+ * adapterFactory.adapt((INodeNotifier) node); break; }
+ *
+ * node = node.getNextSibling(); }
+ * }
+ */
+ /**
+ * Checks whether the given element is deleted or not.
+ */
+ public boolean isDeleted(Object element) {
+ return false;
+ }
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/views/contentoutline/JFaceNodeLabelProviderCSS.java b/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/views/contentoutline/JFaceNodeLabelProviderCSS.java
new file mode 100644
index 0000000000..5df26448d5
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/views/contentoutline/JFaceNodeLabelProviderCSS.java
@@ -0,0 +1,231 @@
+/*******************************************************************************
+ * Copyright (c) 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.ui.views.contentoutline;
+
+
+
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.ILabelProviderListener;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.wst.css.core.document.ICSSMediaRule;
+import org.eclipse.wst.css.core.document.ICSSNode;
+import org.eclipse.wst.css.core.document.ICSSPageRule;
+import org.eclipse.wst.css.core.document.ICSSPrimitiveValue;
+import org.eclipse.wst.css.core.document.ICSSStyleDeclItem;
+import org.eclipse.wst.css.core.document.ICSSStyleRule;
+import org.eclipse.wst.css.ui.image.CSSImageHelper;
+import org.eclipse.wst.css.ui.image.CSSImageType;
+import org.eclipse.wst.sse.core.AdapterFactory;
+import org.eclipse.wst.sse.core.INodeNotifier;
+import org.eclipse.wst.sse.ui.views.contentoutline.IJFaceNodeAdapter;
+import org.w3c.dom.css.CSSImportRule;
+import org.w3c.dom.css.CSSRule;
+import org.w3c.dom.stylesheets.MediaList;
+
+
+/**
+ * A class that uses a JFaceNodeAdapterFactory to provide adapters to provide
+ * the labels and images for DOM nodes.
+ */
+public class JFaceNodeLabelProviderCSS implements ILabelProvider {
+ protected AdapterFactory fAdapterFactory;
+
+ /**
+ * JFaceNodeLabelProvider constructor comment.
+ */
+ public JFaceNodeLabelProviderCSS(AdapterFactory adapterFactory) {
+ super();
+ this.fAdapterFactory = adapterFactory;
+ }
+
+ /**
+ * Adds a listener to the label provider. A label provider should inform
+ * its listener about state changes that enforces rendering of the visual
+ * part that uses this label provider.
+ */
+ public void addListener(ILabelProviderListener listener) {
+ // The label provider state never changes so we do not have
+ // to implement this method.
+ }
+
+ /**
+ * The visual part that is using this label provider is about to be
+ * disposed. Deallocate all allocated SWT resources.
+ */
+ public void dispose() {
+ // Nothing to dispose
+ }
+
+ /**
+ * Returns the JFace adapter for the specified object.
+ *
+ * @return com.ibm.sed.view.tree.DOMJFaceAdapter The JFace adapter
+ * @param adaptable
+ * java.lang.Object The object to get the adapter for
+ */
+ //protected IJFaceNodeAdapter getAdapter(Object adaptable) {
+ // return (IJFaceNodeAdapter) adapterFactory.adapt((INodeNotifier)
+ // adaptable);
+ protected IJFaceNodeAdapter getAdapter(Object adaptable) {
+ return (IJFaceNodeAdapter) fAdapterFactory.adapt((INodeNotifier) adaptable);
+ }
+
+ /**
+ * Returns the image for the label of the given element, for use in the
+ * given viewer.
+ *
+ * @param viewer
+ * The viewer that displays the element.
+ * @param element
+ * The element for which to provide the label image. Element
+ * can be <code>null</code> indicating no input object is set
+ * to the viewer.
+ */
+ public Image getImage(Object element) {
+ // return getAdapter(element).getLabelImage((Node) element);
+
+
+ if (element instanceof ICSSNode) {
+ CSSImageHelper helper = CSSImageHelper.getInstance();
+ return helper.getImage(CSSImageType.getImageType((ICSSNode) element));
+ // Image image = getCSSNodeImage(element);
+ // return image;
+ // return getAdapter(element).getLabelImage((ICSSNode) element);
+ }
+ return null;
+ }
+
+ /**
+ * Insert the method's description here.
+ */
+ public String getLabelText(Viewer viewer, Object element) {
+ return ""; //$NON-NLS-1$
+ }
+
+ /**
+ * Returns the text for the label of the given element, for use in the
+ * given viewer.
+ *
+ * @param viewer
+ * The viewer that displays the element.
+ * @param element
+ * The element for which to provide the label text. Element can
+ * be <code>null</code> indicating no input object is set to
+ * the viewer.
+ */
+ public String getText(Object element) {
+ // This was returning null, on occasion ... probably should not be,
+ // but
+ // took the quick and easy way out for now. (dmw 3/8/01)
+
+ String result = "";//$NON-NLS-1$
+ String mediaText;
+ if (element instanceof ICSSNode) {
+ switch (((ICSSNode) element).getNodeType()) {
+ case ICSSNode.STYLERULE_NODE :
+ result = ((ICSSStyleRule) element).getSelectors().getString();
+ break;
+ case ICSSNode.FONTFACERULE_NODE :
+ result = "@font-face";//$NON-NLS-1$
+ break;
+ case ICSSNode.IMPORTRULE_NODE :
+ result = ((CSSImportRule) element).getHref();
+ mediaText = getMediaText((CSSImportRule) element);
+ if (mediaText != null && 0 < mediaText.length()) {
+ result += " (" + mediaText + ")"; //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ break;
+ case ICSSNode.PAGERULE_NODE :
+ result = ((ICSSPageRule) element).getSelectors().getString();
+ break;
+ case ICSSNode.STYLEDECLARATION_NODE :
+ result = "properties";//$NON-NLS-1$
+ break;
+ case ICSSNode.STYLEDECLITEM_NODE :
+ result = ((ICSSStyleDeclItem) element).getPropertyName();
+ break;
+ case ICSSNode.PRIMITIVEVALUE_NODE :
+ result = ((ICSSPrimitiveValue) element).getStringValue();
+ break;
+ case ICSSNode.MEDIARULE_NODE :
+ result = "@media";//$NON-NLS-1$
+ mediaText = getMediaText((ICSSMediaRule) element);
+ if (mediaText != null && 0 < mediaText.length()) {
+ result += " (" + mediaText + ")"; //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ break;
+ case ICSSNode.CHARSETRULE_NODE :
+ result = "@charset";//$NON-NLS-1$
+ break;
+ case ICSSNode.MEDIALIST_NODE :
+ result = ((MediaList) element).getMediaText();
+ break;
+ default :
+ break;
+ }
+ }
+
+ // if (element instanceof ICSSNode) {
+ // ICSSNode node = ((ICSSNode)element);
+ // result = getAdapter(element).getLabelText((ICSSNode) element);
+ // }
+ return result;
+ }
+
+ private String getMediaText(CSSRule rule) {
+ String result = ""; //$NON-NLS-1$
+ ICSSNode child = (rule != null) ? ((ICSSNode) rule).getFirstChild() : null;
+ while (child != null) {
+ if (child.getNodeType() == ICSSNode.MEDIALIST_NODE) {
+ result = ((MediaList) child).getMediaText();
+ break;
+ }
+ child = child.getNextSibling();
+ }
+ return result;
+ }
+
+ /**
+ * Checks whether this label provider is affected by the given domain
+ * event.
+ */
+ public boolean isAffected(Object dummy) {//DomainEvent event) {
+ //return event.isModifier(DomainEvent.NON_STRUCTURE_CHANGE);
+ return true;
+
+ }
+
+ /**
+ * Returns whether the label would be affected by a change to the given
+ * property of the given element. This can be used to optimize a
+ * non-structural viewer update. If the property mentioned in the update
+ * does not affect the label, then the viewer need not update the label.
+ *
+ * @param element
+ * the element
+ * @param property
+ * the property
+ * @return <code>true</code> if the label would be affected, and
+ * <code>false</code> if it would be unaffected
+ */
+ public boolean isLabelProperty(Object element, String property) {
+ return false;
+ }
+
+ /**
+ * Removes a listener from the label provider.
+ */
+ public void removeListener(ILabelProviderListener listener) {
+ // The label provider state never changes so we do not have
+ // to implement this method.
+ }
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/views/contentoutline/SortAction.java b/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/views/contentoutline/SortAction.java
new file mode 100644
index 0000000000..3e6b16faa1
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/views/contentoutline/SortAction.java
@@ -0,0 +1,66 @@
+/*******************************************************************************
+ * Copyright (c) 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+/*
+ * Created on Jan 22, 2004
+ *
+ * To change the template for this generated file go to
+ * Window - Preferences - Java - Code Generation - Code and Comments
+ */
+package org.eclipse.wst.css.ui.views.contentoutline;
+
+import java.text.Collator;
+
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.ViewerSorter;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.eclipse.wst.css.ui.CSSEditorPlugin;
+import org.eclipse.wst.css.ui.internal.editor.CSSEditorPluginImages;
+import org.eclipse.wst.css.ui.internal.nls.ResourceHandler;
+import org.eclipse.wst.sse.ui.views.contentoutline.PropertyChangeUpdateAction;
+
+/**
+ * Based on com.ibm.etools.dtd.editor.DTDContentOutlinePage#SortAction
+ */
+class SortAction extends PropertyChangeUpdateAction {
+ private TreeViewer treeViewer;
+
+ public SortAction(TreeViewer viewer, IPreferenceStore store, String preferenceKey) {
+ super(ResourceHandler.getString("SortAction.0"), store, preferenceKey, false); //$NON-NLS-1$
+ ImageDescriptor desc = AbstractUIPlugin.imageDescriptorFromPlugin(CSSEditorPlugin.ID, CSSEditorPluginImages.IMG_OBJ_SORT);
+ setImageDescriptor(desc);
+ setToolTipText(getText());
+ treeViewer = viewer;
+ if (isChecked()) {
+ treeViewer.setSorter(new ViewerSorter(Collator.getInstance()));
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.texteditor.IUpdate#update()
+ */
+ public void update() {
+ super.update();
+ treeViewer.getControl().setVisible(false);
+ Object[] expandedElements = treeViewer.getExpandedElements();
+ if (isChecked()) {
+ treeViewer.setSorter(new ViewerSorter(Collator.getInstance()));
+ } else {
+ treeViewer.setSorter(null);
+ }
+ treeViewer.setInput(treeViewer.getInput());
+ treeViewer.setExpandedElements(expandedElements);
+ treeViewer.getControl().setVisible(true);
+ }
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/views/properties/CSSPropertySheetConfiguration.java b/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/views/properties/CSSPropertySheetConfiguration.java
new file mode 100644
index 0000000000..5972406b2b
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/views/properties/CSSPropertySheetConfiguration.java
@@ -0,0 +1,53 @@
+/*****************************************************************************
+ * Copyright (c) 2004 IBM Corporation and others. All rights reserved. This
+ * program and the accompanying materials are made available under the terms
+ * of the Eclipse Public License v1.0 which accompanies this distribution, and
+ * is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors: IBM Corporation - initial API and implementation
+ ****************************************************************************/
+/*
+ * Created on Jan 23, 2004
+ *
+ * To change the template for this generated file go to Window - Preferences -
+ * Java - Code Generation - Code and Comments
+ */
+package org.eclipse.wst.css.ui.views.properties;
+
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.wst.css.core.document.ICSSNode;
+import org.eclipse.wst.sse.ui.views.properties.StructuredPropertySheetConfiguration;
+
+public class CSSPropertySheetConfiguration extends StructuredPropertySheetConfiguration {
+ public CSSPropertySheetConfiguration() {
+ super();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.ibm.sse.editor.views.properties.StructuredPropertySheetConfiguration#getSelection(org.eclipse.jface.viewers.ISelection,
+ * org.eclipse.ui.IWorkbenchPart)
+ */
+ public ISelection getSelection(IWorkbenchPart selectingPart, ISelection selection) {
+ ISelection preferredSelection = super.getSelection(selectingPart, selection);
+ if (preferredSelection instanceof IStructuredSelection) {
+ Object[] objects = ((IStructuredSelection) preferredSelection).toArray();
+ for (int i = 0; i < objects.length; i++) {
+ if (objects[i] instanceof ICSSNode) {
+ ICSSNode node = (ICSSNode) objects[i];
+ while (node.getNodeType() == ICSSNode.PRIMITIVEVALUE_NODE || node.getNodeType() == ICSSNode.STYLEDECLITEM_NODE) {
+ node = node.getParentNode();
+ objects[i] = node;
+
+ }
+ }
+ }
+ preferredSelection = new StructuredSelection(objects);
+ }
+ return preferredSelection;
+ }
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/views/properties/CSSPropertySource.java b/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/views/properties/CSSPropertySource.java
new file mode 100644
index 0000000000..41b771c5fc
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/views/properties/CSSPropertySource.java
@@ -0,0 +1,350 @@
+/*******************************************************************************
+ * Copyright (c) 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.ui.views.properties;
+
+
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.views.properties.IPropertyDescriptor;
+import org.eclipse.ui.views.properties.IPropertySource;
+import org.eclipse.wst.css.core.document.ICSSNode;
+import org.eclipse.wst.css.core.document.ICSSNodeList;
+import org.eclipse.wst.css.core.document.ICSSStyleDeclItem;
+import org.eclipse.wst.css.core.metamodel.CSSMMCategory;
+import org.eclipse.wst.css.core.metamodel.CSSMMNode;
+import org.eclipse.wst.css.core.metamodel.CSSMetaModel;
+import org.eclipse.wst.css.core.metamodel.util.CSSMetaModelFinder;
+import org.eclipse.wst.css.core.metamodel.util.CSSMetaModelUtil;
+import org.eclipse.wst.css.ui.internal.nls.ResourceHandler;
+import org.eclipse.wst.sse.core.INodeAdapter;
+import org.eclipse.wst.sse.core.INodeNotifier;
+import org.w3c.dom.css.CSSStyleDeclaration;
+
+/**
+ * A IPropertySource implementation for a JFace viewer used to display
+ * propreties of DOM nodes. This takes an adapter factory to create JFace
+ * adapters for the nodes in the tree.
+ */
+public class CSSPropertySource implements INodeAdapter, IPropertySource {
+ protected ICSSNode fNode = null;
+ // for performance...
+ final static Class ADAPTER_KEY = IPropertySource.class;
+
+ /**
+ * DOMPropertySource constructor comment.
+ */
+ public CSSPropertySource(INodeNotifier target) {
+ super();
+ fNode = (ICSSNode) target;
+ }
+
+ protected IPropertyDescriptor createDefaultPropertyDescriptor(String attributeName) {
+ // the displayName MUST be set
+ IPropertyDescriptor descriptor = new CSSTextPropertyDescriptor(attributeName, attributeName, fNode);
+ // IPropertyDescriptor descriptor = new
+ // TextPropertyDescriptor(attributeName, attributeName);
+ return descriptor;
+ }
+
+ protected IPropertyDescriptor createPropertyDescriptor(CSSMMNode node, String category) {
+ return createPropertyDescriptor(node.getName(), category);
+ }
+
+ protected IPropertyDescriptor createPropertyDescriptor(String name, String category) {
+ IPropertyDescriptor descriptor = null;
+ if (name != null && 0 < name.length()) {
+ name = name.toLowerCase();
+ if (category == null) {
+ category = ResourceHandler.getString("INFO_Not_Categorized_1"); //$NON-NLS-1$
+ }
+ descriptor = new CSSTextPropertyDescriptor(name, name, fNode, category);
+ // if (category == null) {
+ // descriptor = new CSSTextPropertyDescriptor(name, name, fNode);
+ // } else {
+ // descriptor = new CSSTextPropertyDescriptor(name, name, fNode,
+ // category);
+ // }
+ }
+ return descriptor;
+ }
+
+ /**
+ * Returns a value for this object that can be editted in a property
+ * sheet.
+ *
+ * @return a value that can be editted
+ */
+ public Object getEditableValue() {
+ return null;
+ }
+
+ /**
+ * Returns the current collection of property descriptors.
+ *
+ * @return a vector containing all descriptors.
+ */
+ public IPropertyDescriptor[] getPropertyDescriptors() {
+ CSSMetaModel metamodel = CSSMetaModelFinder.getInstance().findMetaModelFor(fNode);
+ Iterator iProperties = Collections.EMPTY_LIST.iterator();
+ switch (fNode.getNodeType()) {
+ case ICSSNode.STYLERULE_NODE :
+ case ICSSNode.FONTFACERULE_NODE :
+ case ICSSNode.PAGERULE_NODE :
+ case ICSSNode.STYLEDECLARATION_NODE :
+ CSSMMNode mmParent = new CSSMetaModelUtil(metamodel).getMetaModelNodeFor(fNode);
+ if (mmParent != null) {
+ iProperties = mmParent.getChildNodes();
+ }
+ break;
+ case ICSSNode.STYLEDECLITEM_NODE :
+ CSSMMNode mmNode = new CSSMetaModelUtil(metamodel).getMetaModelNodeFor(fNode);
+ if (mmNode != null) {
+ iProperties = Collections.singletonList(mmNode).iterator();
+ }
+ break;
+ default :
+ break;
+ }
+
+ // setup categories
+ Map categories = new HashMap();
+ Iterator iCategories = metamodel.getCategories();
+ while (iCategories.hasNext()) {
+ CSSMMCategory category = (CSSMMCategory) iCategories.next();
+ categories.put(category.getName(), category.getCaption());
+ }
+
+ // collect property names
+ Set declaredProperties = new HashSet();
+ if (iProperties.hasNext()) {
+ CSSStyleDeclaration declaration = getDeclarationNode();
+ if (declaration != null) {
+ ICSSNodeList nodeList = ((ICSSNode) declaration).getChildNodes();
+ int nProps = (nodeList != null) ? nodeList.getLength() : 0;
+ for (int i = 0; i < nProps; i++) {
+ ICSSNode node = nodeList.item(i);
+ if (node instanceof ICSSStyleDeclItem) {
+ String name = ((ICSSStyleDeclItem) node).getPropertyName();
+ if (name != null && 0 < name.length()) {
+ declaredProperties.add(name.toLowerCase());
+ }
+ }
+ }
+ }
+ }
+
+ List descriptors = new ArrayList();
+
+ // first: properties from content model
+ while (iProperties.hasNext()) {
+ CSSMMNode node = (CSSMMNode) iProperties.next();
+ if (node.getType() == CSSMMNode.TYPE_PROPERTY || node.getType() == CSSMMNode.TYPE_DESCRIPTOR) {
+ String category = (String) categories.get(node.getAttribute("category")); //$NON-NLS-1$
+ String name = node.getName().toLowerCase();
+ if (declaredProperties.contains(name)) {
+ declaredProperties.remove(name);
+ }
+ IPropertyDescriptor descriptor = createPropertyDescriptor(name, category);
+ if (descriptor != null) {
+ descriptors.add(descriptor);
+ }
+ }
+ }
+
+ // second: existing properties but not in content model
+ Iterator iRemains = declaredProperties.iterator();
+ while (iRemains.hasNext()) {
+ IPropertyDescriptor descriptor = createPropertyDescriptor((String) iRemains.next(), null);
+ if (descriptor != null) {
+ descriptors.add(descriptor);
+ }
+ }
+
+ IPropertyDescriptor[] resultArray = new IPropertyDescriptor[descriptors.size()];
+ return (IPropertyDescriptor[]) descriptors.toArray(resultArray);
+ }
+
+ /**
+ * Returns the current value for the named property.
+ *
+ * @param name
+ * the name of the property as named by its property descriptor
+ * @return the current value of the property
+ */
+ public Object getPropertyValue(Object name) {
+ if (name == null) {
+ return ""; //$NON-NLS-1$
+ }
+
+ String valueString = null;
+ String nameString = name.toString();
+
+ CSSStyleDeclaration declaration = null;
+
+ switch (fNode.getNodeType()) {
+ case ICSSNode.STYLEDECLITEM_NODE :
+ valueString = ((ICSSStyleDeclItem) fNode).getCSSValueText();
+ break;
+ case ICSSNode.STYLERULE_NODE :
+ case ICSSNode.FONTFACERULE_NODE :
+ case ICSSNode.PAGERULE_NODE :
+ declaration = (CSSStyleDeclaration) fNode.getFirstChild();
+ if (declaration != null) {
+ valueString = declaration.getPropertyValue(nameString);
+ }
+ break;
+ case ICSSNode.STYLEDECLARATION_NODE :
+ valueString = ((CSSStyleDeclaration) fNode).getPropertyValue(nameString);
+ break;
+ case ICSSNode.PRIMITIVEVALUE_NODE :
+ ICSSNode parent = fNode;
+ while (parent != null && !(parent instanceof ICSSStyleDeclItem)) {
+ parent = parent.getParentNode();
+ }
+ if (parent != null) {
+ valueString = ((ICSSStyleDeclItem) parent).getCSSValueText();
+ }
+ break;
+ default :
+ break;
+ }
+
+ if (valueString == null) {
+ valueString = ""; //$NON-NLS-1$
+ }
+
+ return valueString;
+ }
+
+ /**
+ * Allowing the INodeAdapter to compare itself against the type allows it
+ * to return true in more than one case.
+ */
+ public boolean isAdapterForType(java.lang.Object type) {
+ return type.equals(ADAPTER_KEY);
+ }
+
+ /**
+ * Returns whether the property value has changed from the default.
+ *
+ * @return <code>true</code> if the value of the specified property has
+ * changed from its original default value; <code>false</code>
+ * otherwise.
+ */
+ public boolean isPropertySet(Object property) {
+ if (property == null) {
+ return false;
+ }
+ CSSStyleDeclaration declaration = getDeclarationNode();
+ if (declaration != null) {
+ String value = declaration.getPropertyValue(property.toString());
+ if (value != null && 0 < value.length()) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ */
+ public void notifyChanged(INodeNotifier notifier, int eventType, java.lang.Object changedFeature, java.lang.Object oldValue, java.lang.Object newValue, int pos) {
+ }
+
+ /**
+ * Resets the specified property's value to its default value.
+ *
+ * @param property
+ * the property to reset
+ */
+ public void resetPropertyValue(Object str) {
+ if (str == null) {
+ return;
+ }
+ CSSStyleDeclaration declaration = getDeclarationNode();
+ if (declaration != null) {
+ declaration.removeProperty(str.toString());
+ }
+ }
+
+ /**
+ * Sets the named property to the given value.
+ *
+ * @param name
+ * the name of the property being set
+ * @param value
+ * the new value for the property
+ */
+ public void setPropertyValue(Object name, Object value) {
+ if (name == null) {
+ return;
+ }
+ String valueString = (value != null) ? value.toString() : null;
+ String nameString = name.toString();
+ CSSStyleDeclaration declaration = getDeclarationNode();
+ if (declaration != null) {
+ try {
+ if (valueString == null || valueString.length() <= 0) {
+ declaration.removeProperty(nameString);
+ } else {
+ declaration.setProperty(nameString, valueString, ""); //$NON-NLS-1$
+ }
+ } catch (Exception e) {
+ IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+ String title = ResourceHandler.getString("Title.InvalidValue"); //$NON-NLS-1$
+ String message = ResourceHandler.getString("Message.InvalidValue"); //$NON-NLS-1$
+ MessageDialog.openWarning(window.getShell(), title, message);
+ }
+ }
+ }
+
+ private CSSStyleDeclaration getDeclarationNode() {
+ CSSStyleDeclaration declaration = null;
+
+ switch (fNode.getNodeType()) {
+ case ICSSNode.STYLEDECLITEM_NODE :
+ declaration = (CSSStyleDeclaration) fNode.getParentNode();
+ break;
+ case ICSSNode.STYLERULE_NODE :
+ case ICSSNode.FONTFACERULE_NODE :
+ case ICSSNode.PAGERULE_NODE :
+ declaration = (CSSStyleDeclaration) fNode.getFirstChild();
+ break;
+ case ICSSNode.STYLEDECLARATION_NODE :
+ declaration = (CSSStyleDeclaration) fNode;
+ break;
+ case ICSSNode.PRIMITIVEVALUE_NODE :
+ ICSSNode parent = fNode;
+ while (parent != null && !(parent instanceof CSSStyleDeclaration)) {
+ parent = parent.getParentNode();
+ }
+ if (parent != null) {
+ declaration = (CSSStyleDeclaration) parent;
+ }
+ break;
+ default :
+ break;
+ }
+
+ return declaration;
+ }
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/views/properties/CSSPropertySourceAdapterFactory.java b/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/views/properties/CSSPropertySourceAdapterFactory.java
new file mode 100644
index 0000000000..feed515d31
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/views/properties/CSSPropertySourceAdapterFactory.java
@@ -0,0 +1,45 @@
+/*****************************************************************************
+ * Copyright (c) 2004 IBM Corporation and others. All rights reserved. This
+ * program and the accompanying materials are made available under the terms
+ * of the Eclipse Public License v1.0 which accompanies this distribution, and
+ * is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors: IBM Corporation - initial API and implementation
+ ****************************************************************************/
+package org.eclipse.wst.css.ui.views.properties;
+
+import org.eclipse.wst.sse.core.AbstractAdapterFactory;
+import org.eclipse.wst.sse.core.INodeAdapter;
+import org.eclipse.wst.sse.core.INodeNotifier;
+
+
+
+//import com.ibm.sed.edit.xml.DOMPropertySource;
+public class CSSPropertySourceAdapterFactory extends AbstractAdapterFactory {
+ /**
+ * PropertySourceAdapterFactory constructor comment.
+ */
+ public CSSPropertySourceAdapterFactory() {
+ super();
+ }
+
+ /**
+ * PropertySourceAdapterFactory constructor comment.
+ *
+ * @param adapterKey
+ * java.lang.Object
+ * @param registerAdapters
+ * boolean
+ */
+ public CSSPropertySourceAdapterFactory(Object newAdapterKey, boolean newRegisterAdapters) {
+ super(newAdapterKey, newRegisterAdapters);
+ }
+
+ /**
+ * createAdapter method comment.
+ */
+ protected INodeAdapter createAdapter(INodeNotifier target) {
+ // at the moment, only one implementation exists
+ return new CSSPropertySource(target);
+ }
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/views/properties/CSSTextPropertyDescriptor.java b/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/views/properties/CSSTextPropertyDescriptor.java
new file mode 100644
index 0000000000..4b6d0f2f1b
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/views/properties/CSSTextPropertyDescriptor.java
@@ -0,0 +1,114 @@
+/*******************************************************************************
+ * Copyright (c) 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.ui.views.properties;
+
+
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.jface.viewers.CellEditor;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IEditorReference;
+import org.eclipse.ui.IFileEditorInput;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.views.properties.TextPropertyDescriptor;
+import org.eclipse.wst.css.core.document.ICSSModel;
+import org.eclipse.wst.css.core.document.ICSSNode;
+import org.eclipse.wst.css.core.util.CSSPathService;
+import org.eclipse.wst.sse.core.IModelManagerPlugin;
+import org.eclipse.wst.sse.core.IStructuredModel;
+import org.eclipse.wst.xml.core.document.XMLNode;
+
+/**
+ */
+public class CSSTextPropertyDescriptor extends TextPropertyDescriptor {
+ private final ICSSNode fNode;
+
+ /**
+ * CSSTextPropertyDescriptor constructor comment.
+ *
+ * @param id
+ * java.lang.String
+ * @param displayName
+ * java.lang.String
+ */
+ public CSSTextPropertyDescriptor(String id, String displayName, ICSSNode node) {
+ super(id, displayName);
+ this.fNode = node;
+ }
+
+ public CSSTextPropertyDescriptor(String id, String displayName, ICSSNode node, String category) {
+ super(id, displayName);
+ this.fNode = node;
+ setCategory(category);
+ }
+
+ /**
+ * @return org.eclipse.jface.viewers.CellEditor
+ * @param parent
+ * org.eclipse.swt.widgets.Composite
+ */
+ public CellEditor createPropertyEditor(Composite parent) {
+ ICSSModel model = fNode.getOwnerDocument().getModel();
+ if (model == null)
+ return null;
+ if (model.getStyleSheetType() == ICSSModel.EXTERNAL && findEditor(model) == null)
+ return null;
+ // check whether IFile is readonly to prohibit editing before
+ // validateEdit()
+ IStructuredModel structuredModel = model;
+ if (model.getStyleSheetType() != ICSSModel.EXTERNAL) {
+ structuredModel = ((XMLNode) model.getOwnerDOMNode()).getModel();
+ if (structuredModel == null)
+ return null;
+ }
+ IFile file = CSSPathService.location2File(structuredModel.getBaseLocation());
+ if (file == null || file.isReadOnly())
+ return null;
+
+ return super.createPropertyEditor(parent);
+ }
+
+ private static IEditorPart findEditor(ICSSModel model) {
+ IWorkbench workbench = PlatformUI.getWorkbench();
+ IWorkbenchWindow[] windows = workbench.getWorkbenchWindows();
+ for (int i = 0; i < windows.length; i++) {
+ IWorkbenchPage[] pages = windows[i].getPages();
+ for (int j = 0; j < pages.length; j++) {
+ IEditorReference[] editors = pages[j].getEditorReferences();
+ for (int k = 0; k < editors.length; k++) {
+ IEditorPart editPart = editors[k].getEditor(false);
+ if (editPart != null) {
+ IEditorInput editorInput = editPart.getEditorInput();
+ if (editorInput instanceof IFileEditorInput) {
+ IFile file = ((IFileEditorInput) editorInput).getFile();
+ if (file != null) {
+ //TODO Urgent needs to be fixed
+ // I think we need 'equals' (or 'equivalent'
+ // on model) for cases like this
+ IModelManagerPlugin plugin = (IModelManagerPlugin) Platform.getPlugin(IModelManagerPlugin.ID);
+ if (plugin.getModelManager().calculateId(file).equals(model.getId())) {
+ return editPart;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ return null;
+ }
+} \ No newline at end of file

Back to the top