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:
authordavid_williams2005-05-25 21:11:11 +0000
committerdavid_williams2005-05-25 21:11:11 +0000
commitd3484c7460a56ed05ad2eff8096d312d1a107b84 (patch)
tree177c0ba11ce26410fedcf7dd9da5792b1fc9e556 /bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml
parent6d01c05d4b484610b30ea98f43c970f4be5fe7d2 (diff)
downloadwebtools.sourceediting-d3484c7460a56ed05ad2eff8096d312d1a107b84.tar.gz
webtools.sourceediting-d3484c7460a56ed05ad2eff8096d312d1a107b84.tar.xz
webtools.sourceediting-d3484c7460a56ed05ad2eff8096d312d1a107b84.zip
[88846] Make indentation customizable
Diffstat (limited to 'bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml')
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/XMLCorePlugin.java37
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/cleanup/CleanupProcessorXML.java18
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/cleanup/NodeCleanupHandler.java18
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/preferences/XMLCorePreferenceInitializer.java51
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/preferences/XMLCorePreferenceNames.java144
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/provisional/format/FormatProcessorXML.java29
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/provisional/format/NodeFormatter.java29
7 files changed, 241 insertions, 85 deletions
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/XMLCorePlugin.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/XMLCorePlugin.java
index 962b707466..5d7fea07cf 100644
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/XMLCorePlugin.java
+++ b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/XMLCorePlugin.java
@@ -15,9 +15,6 @@ package org.eclipse.wst.xml.core.internal;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.Plugin;
-import org.eclipse.core.runtime.Preferences;
-import org.eclipse.wst.sse.core.internal.encoding.CommonEncodingPreferenceNames;
-import org.eclipse.wst.sse.core.internal.preferences.CommonModelPreferenceNames;
/**
@@ -48,38 +45,4 @@ public class XMLCorePlugin extends Plugin {
super();
plugin = this;
}
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.core.runtime.Plugin#initializeDefaultPluginPreferences()
- */
- protected void initializeDefaultPluginPreferences() {
- Preferences prefs = getDefault().getPluginPreferences();
- // set model preference defaults
- prefs.setDefault(CommonModelPreferenceNames.CLEANUP_TAG_NAME_CASE, CommonModelPreferenceNames.ASIS);
- prefs.setDefault(CommonModelPreferenceNames.CLEANUP_ATTR_NAME_CASE, CommonModelPreferenceNames.ASIS);
- prefs.setDefault(CommonModelPreferenceNames.COMPRESS_EMPTY_ELEMENT_TAGS, true);
- prefs.setDefault(CommonModelPreferenceNames.INSERT_REQUIRED_ATTRS, true);
- prefs.setDefault(CommonModelPreferenceNames.INSERT_MISSING_TAGS, true);
- prefs.setDefault(CommonModelPreferenceNames.QUOTE_ATTR_VALUES, true);
- prefs.setDefault(CommonModelPreferenceNames.FORMAT_SOURCE, true);
- prefs.setDefault(CommonModelPreferenceNames.CONVERT_EOL_CODES, false);
-
- prefs.setDefault(CommonEncodingPreferenceNames.INPUT_CODESET, ""); //$NON-NLS-1$
- prefs.setDefault(CommonEncodingPreferenceNames.OUTPUT_CODESET, CommonModelPreferenceNames.UTF_8);
- prefs.setDefault(CommonEncodingPreferenceNames.END_OF_LINE_CODE, ""); //$NON-NLS-1$
-
- prefs.setDefault(CommonModelPreferenceNames.TAB_WIDTH, 4);
-
- prefs.setDefault(CommonModelPreferenceNames.FORMATTING_SUPPORTED, true);
- prefs.setDefault(CommonModelPreferenceNames.LINE_WIDTH, 72);
- prefs.setDefault(CommonModelPreferenceNames.SPLIT_MULTI_ATTRS, false);
- prefs.setDefault(CommonModelPreferenceNames.INDENT_USING_TABS, true);
- prefs.setDefault(CommonModelPreferenceNames.CLEAR_ALL_BLANK_LINES, false);
-
- prefs.setDefault(CommonModelPreferenceNames.PREFERRED_MARKUP_CASE_SUPPORTED, false);
- prefs.setDefault(CommonModelPreferenceNames.TAG_NAME_CASE, CommonModelPreferenceNames.LOWER);
- prefs.setDefault(CommonModelPreferenceNames.ATTR_NAME_CASE, CommonModelPreferenceNames.LOWER);
- }
}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/cleanup/CleanupProcessorXML.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/cleanup/CleanupProcessorXML.java
index 53a3da814a..97bf41cdf8 100644
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/cleanup/CleanupProcessorXML.java
+++ b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/cleanup/CleanupProcessorXML.java
@@ -18,8 +18,8 @@ import org.eclipse.wst.sse.core.internal.cleanup.IStructuredCleanupHandler;
import org.eclipse.wst.sse.core.internal.cleanup.IStructuredCleanupPreferences;
import org.eclipse.wst.sse.core.internal.cleanup.StructuredCleanupPreferences;
import org.eclipse.wst.sse.core.internal.format.IStructuredFormatProcessor;
-import org.eclipse.wst.sse.core.internal.preferences.CommonModelPreferenceNames;
import org.eclipse.wst.xml.core.internal.XMLCorePlugin;
+import org.eclipse.wst.xml.core.internal.preferences.XMLCorePreferenceNames;
import org.eclipse.wst.xml.core.internal.provisional.contenttype.ContentTypeIdForXML;
import org.eclipse.wst.xml.core.internal.provisional.format.FormatProcessorXML;
import org.w3c.dom.Node;
@@ -57,15 +57,13 @@ public class CleanupProcessorXML extends AbstractStructuredCleanupProcessor {
Preferences preferences = getModelPreferences();
if (preferences != null) {
- fCleanupPreferences.setTagNameCase(preferences.getInt(CommonModelPreferenceNames.CLEANUP_TAG_NAME_CASE));
- fCleanupPreferences.setAttrNameCase(preferences.getInt(CommonModelPreferenceNames.CLEANUP_ATTR_NAME_CASE));
- fCleanupPreferences.setCompressEmptyElementTags(preferences.getBoolean(CommonModelPreferenceNames.COMPRESS_EMPTY_ELEMENT_TAGS));
- fCleanupPreferences.setInsertRequiredAttrs(preferences.getBoolean(CommonModelPreferenceNames.INSERT_REQUIRED_ATTRS));
- fCleanupPreferences.setInsertMissingTags(preferences.getBoolean(CommonModelPreferenceNames.INSERT_MISSING_TAGS));
- fCleanupPreferences.setQuoteAttrValues(preferences.getBoolean(CommonModelPreferenceNames.QUOTE_ATTR_VALUES));
- fCleanupPreferences.setFormatSource(preferences.getBoolean(CommonModelPreferenceNames.FORMAT_SOURCE));
- fCleanupPreferences.setConvertEOLCodes(preferences.getBoolean(CommonModelPreferenceNames.CONVERT_EOL_CODES));
- fCleanupPreferences.setEOLCode(preferences.getString(CommonModelPreferenceNames.CLEANUP_EOL_CODE));
+ fCleanupPreferences.setCompressEmptyElementTags(preferences.getBoolean(XMLCorePreferenceNames.COMPRESS_EMPTY_ELEMENT_TAGS));
+ fCleanupPreferences.setInsertRequiredAttrs(preferences.getBoolean(XMLCorePreferenceNames.INSERT_REQUIRED_ATTRS));
+ fCleanupPreferences.setInsertMissingTags(preferences.getBoolean(XMLCorePreferenceNames.INSERT_MISSING_TAGS));
+ fCleanupPreferences.setQuoteAttrValues(preferences.getBoolean(XMLCorePreferenceNames.QUOTE_ATTR_VALUES));
+ fCleanupPreferences.setFormatSource(preferences.getBoolean(XMLCorePreferenceNames.FORMAT_SOURCE));
+ fCleanupPreferences.setConvertEOLCodes(preferences.getBoolean(XMLCorePreferenceNames.CONVERT_EOL_CODES));
+ fCleanupPreferences.setEOLCode(preferences.getString(XMLCorePreferenceNames.CLEANUP_EOL_CODE));
}
}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/cleanup/NodeCleanupHandler.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/cleanup/NodeCleanupHandler.java
index d8775a0f4e..444ff50e31 100644
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/cleanup/NodeCleanupHandler.java
+++ b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/cleanup/NodeCleanupHandler.java
@@ -17,8 +17,8 @@ import org.eclipse.core.runtime.Preferences;
import org.eclipse.wst.sse.core.internal.cleanup.IStructuredCleanupHandler;
import org.eclipse.wst.sse.core.internal.cleanup.IStructuredCleanupPreferences;
import org.eclipse.wst.sse.core.internal.cleanup.StructuredCleanupPreferences;
-import org.eclipse.wst.sse.core.internal.preferences.CommonModelPreferenceNames;
import org.eclipse.wst.xml.core.internal.XMLCorePlugin;
+import org.eclipse.wst.xml.core.internal.preferences.XMLCorePreferenceNames;
import org.w3c.dom.Node;
@@ -44,15 +44,13 @@ public class NodeCleanupHandler implements IStructuredCleanupHandler {
Preferences preferences = getModelPreferences();
if (preferences != null) {
- fCleanupPreferences.setTagNameCase(preferences.getInt(CommonModelPreferenceNames.CLEANUP_TAG_NAME_CASE));
- fCleanupPreferences.setAttrNameCase(preferences.getInt(CommonModelPreferenceNames.CLEANUP_ATTR_NAME_CASE));
- fCleanupPreferences.setCompressEmptyElementTags(preferences.getBoolean(CommonModelPreferenceNames.COMPRESS_EMPTY_ELEMENT_TAGS));
- fCleanupPreferences.setInsertRequiredAttrs(preferences.getBoolean(CommonModelPreferenceNames.INSERT_REQUIRED_ATTRS));
- fCleanupPreferences.setInsertMissingTags(preferences.getBoolean(CommonModelPreferenceNames.INSERT_MISSING_TAGS));
- fCleanupPreferences.setQuoteAttrValues(preferences.getBoolean(CommonModelPreferenceNames.QUOTE_ATTR_VALUES));
- fCleanupPreferences.setFormatSource(preferences.getBoolean(CommonModelPreferenceNames.FORMAT_SOURCE));
- fCleanupPreferences.setConvertEOLCodes(preferences.getBoolean(CommonModelPreferenceNames.CONVERT_EOL_CODES));
- fCleanupPreferences.setEOLCode(preferences.getString(CommonModelPreferenceNames.CLEANUP_EOL_CODE));
+ fCleanupPreferences.setCompressEmptyElementTags(preferences.getBoolean(XMLCorePreferenceNames.COMPRESS_EMPTY_ELEMENT_TAGS));
+ fCleanupPreferences.setInsertRequiredAttrs(preferences.getBoolean(XMLCorePreferenceNames.INSERT_REQUIRED_ATTRS));
+ fCleanupPreferences.setInsertMissingTags(preferences.getBoolean(XMLCorePreferenceNames.INSERT_MISSING_TAGS));
+ fCleanupPreferences.setQuoteAttrValues(preferences.getBoolean(XMLCorePreferenceNames.QUOTE_ATTR_VALUES));
+ fCleanupPreferences.setFormatSource(preferences.getBoolean(XMLCorePreferenceNames.FORMAT_SOURCE));
+ fCleanupPreferences.setConvertEOLCodes(preferences.getBoolean(XMLCorePreferenceNames.CONVERT_EOL_CODES));
+ fCleanupPreferences.setEOLCode(preferences.getString(XMLCorePreferenceNames.CLEANUP_EOL_CODE));
}
}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/preferences/XMLCorePreferenceInitializer.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/preferences/XMLCorePreferenceInitializer.java
new file mode 100644
index 0000000000..7211076f7e
--- /dev/null
+++ b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/preferences/XMLCorePreferenceInitializer.java
@@ -0,0 +1,51 @@
+/*******************************************************************************
+ * Copyright (c) 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.xml.core.internal.preferences;
+
+import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
+import org.eclipse.core.runtime.preferences.DefaultScope;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences;
+import org.eclipse.wst.sse.core.internal.encoding.CommonEncodingPreferenceNames;
+import org.eclipse.wst.xml.core.internal.XMLCorePlugin;
+
+/**
+ * Sets default values for XML Core preferences
+ */
+public class XMLCorePreferenceInitializer extends AbstractPreferenceInitializer {
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer#initializeDefaultPreferences()
+ */
+ public void initializeDefaultPreferences() {
+ IEclipsePreferences node = new DefaultScope().getNode(XMLCorePlugin.getDefault().getBundle().getSymbolicName());
+
+ // formatting preferences
+ node.putInt(XMLCorePreferenceNames.LINE_WIDTH, 72);
+ node.putBoolean(XMLCorePreferenceNames.CLEAR_ALL_BLANK_LINES, false);
+ node.put(XMLCorePreferenceNames.INDENTATION_CHAR, XMLCorePreferenceNames.TAB);
+ node.putInt(XMLCorePreferenceNames.INDENTATION_SIZE, 1);
+ node.putBoolean(XMLCorePreferenceNames.SPLIT_MULTI_ATTRS, false);
+
+ // cleanup preferences
+ node.putBoolean(XMLCorePreferenceNames.COMPRESS_EMPTY_ELEMENT_TAGS, true);
+ node.putBoolean(XMLCorePreferenceNames.INSERT_REQUIRED_ATTRS, true);
+ node.putBoolean(XMLCorePreferenceNames.INSERT_MISSING_TAGS, true);
+ node.putBoolean(XMLCorePreferenceNames.QUOTE_ATTR_VALUES, true);
+ node.putBoolean(XMLCorePreferenceNames.FORMAT_SOURCE, true);
+ node.putBoolean(XMLCorePreferenceNames.CONVERT_EOL_CODES, false);
+
+ node.put(CommonEncodingPreferenceNames.INPUT_CODESET, ""); //$NON-NLS-1$
+ node.put(CommonEncodingPreferenceNames.OUTPUT_CODESET, "UTF-8");//$NON-NLS-1$
+ node.put(CommonEncodingPreferenceNames.END_OF_LINE_CODE, ""); //$NON-NLS-1$
+ }
+}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/preferences/XMLCorePreferenceNames.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/preferences/XMLCorePreferenceNames.java
new file mode 100644
index 0000000000..308b8ae0cc
--- /dev/null
+++ b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/preferences/XMLCorePreferenceNames.java
@@ -0,0 +1,144 @@
+/*******************************************************************************
+ * Copyright (c) 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.wst.xml.core.internal.preferences;
+
+/**
+ * Common preference keys used by XML core
+ *
+ * @since 1.0
+ */
+public class XMLCorePreferenceNames {
+ private XMLCorePreferenceNames() {
+ // empty private constructor so users cannot instantiate class
+ }
+
+ /**
+ * The maximum width of a line before a line split is needed.
+ * <p>
+ * Value is of type <code>Integer</code>.
+ * </p>
+ */
+ public static final String LINE_WIDTH = "lineWidth";//$NON-NLS-1$
+
+ /**
+ * Indicates if all blanks lines should be cleared during formatting.
+ * Blank lines will be kept when false.
+ * <p>
+ * Value is of type <code>Boolean</code>.
+ * </p>
+ */
+ public static final String CLEAR_ALL_BLANK_LINES = "clearAllBlankLines";//$NON-NLS-1$
+
+ /**
+ * The number of #INDENTATION_CHAR for 1 indentation.
+ * <p>
+ * Value is of type <code>Integer</code>.
+ * </p>
+ */
+ public static final String INDENTATION_SIZE = "indentationSize";//$NON-NLS-1$
+
+ /**
+ * The character used for indentation.
+ * <p>
+ * Value is of type <code>String</code>.<br />
+ * Possible values: {TAB, SPACE}
+ * </p>
+ */
+ public static final String INDENTATION_CHAR = "indentationChar";//$NON-NLS-1$
+
+ /**
+ * Possible value for the preference #INDENTATION_CHAR. Indicates to use
+ * tab character when formatting.
+ *
+ * @see #SPACE
+ * @see #INDENTATION_CHAR
+ */
+ public static final String TAB = "tab"; //$NON-NLS-1$
+
+ /**
+ * Possible value for the preference #INDENTATION_CHAR. Indicates to use
+ * space character when formatting.
+ *
+ * @see #TAB
+ * @see #INDENTATION_CHAR
+ */
+ public static final String SPACE = "space"; //$NON-NLS-1$
+
+ /**
+ * Indicates if tags with multiple attributes should be formatted
+ * (splitting each attr on a new line).
+ * <p>
+ * Value is of type <code>Boolean</code>.
+ * </p>
+ */
+ public static final String SPLIT_MULTI_ATTRS = "splitMultiAttrs";//$NON-NLS-1$
+
+ /**
+ * Indicates whether or not cleanup processor should format source.
+ * <p>
+ * Value is of type <code>Boolean</code>.
+ * </p>
+ */
+ public static final String FORMAT_SOURCE = "formatSource";//$NON-NLS-1$
+
+ /**
+ * Indicates whether or not empty elements should be compressed during
+ * cleanup.
+ * <p>
+ * Value is of type <code>Boolean</code>.
+ * </p>
+ */
+ public static final String COMPRESS_EMPTY_ELEMENT_TAGS = "compressEmptyElementTags";//$NON-NLS-1$
+
+ /**
+ * Indicates whether or not to insert required attributes during cleanup.
+ * <p>
+ * Value is of type <code>Boolean</code>.
+ * </p>
+ */
+ public static final String INSERT_REQUIRED_ATTRS = "insertRequiredAttrs";//$NON-NLS-1$
+
+ /**
+ * Indicates whether or not to insert missing tags during cleanup.
+ * <p>
+ * Value is of type <code>Boolean</code>.
+ * </p>
+ */
+ public static final String INSERT_MISSING_TAGS = "insertMissingTags";//$NON-NLS-1$
+
+ /**
+ * Indicates whether or not to quote all attribute values during cleanup.
+ * <p>
+ * Value is of type <code>Boolean</code>.
+ * </p>
+ */
+ public static final String QUOTE_ATTR_VALUES = "quoteAttrValues";//$NON-NLS-1$
+
+ /**
+ * Indicates whether or not to convert all line delimiters during cleanup.
+ * <p>
+ * Value is of type <code>Boolean</code>.
+ * </p>
+ */
+ public static final String CONVERT_EOL_CODES = "convertEOLCodes";//$NON-NLS-1$
+
+ /**
+ * Indicates the line delimiter to use during cleanup if converting line
+ * delimiters.
+ * <p>
+ * Value is of type <code>String</code>.<br />
+ * Possible values: {CR, CRLF, LF, NO_TRANSLATION}
+ * </p>
+ *
+ */
+ public static final String CLEANUP_EOL_CODE = "cleanupEOLCode";//$NON-NLS-1$
+}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/provisional/format/FormatProcessorXML.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/provisional/format/FormatProcessorXML.java
index 54b84b5a2f..c6ab4bae06 100644
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/provisional/format/FormatProcessorXML.java
+++ b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/provisional/format/FormatProcessorXML.java
@@ -13,13 +13,12 @@
package org.eclipse.wst.xml.core.internal.provisional.format;
import org.eclipse.core.runtime.Preferences;
-import org.eclipse.wst.sse.core.internal.SSECorePlugin;
import org.eclipse.wst.sse.core.internal.format.AbstractStructuredFormatProcessor;
import org.eclipse.wst.sse.core.internal.format.IStructuredFormatPreferences;
import org.eclipse.wst.sse.core.internal.format.IStructuredFormatter;
-import org.eclipse.wst.sse.core.internal.preferences.CommonModelPreferenceNames;
import org.eclipse.wst.xml.core.internal.XMLCorePlugin;
import org.eclipse.wst.xml.core.internal.document.CDATASectionImpl;
+import org.eclipse.wst.xml.core.internal.preferences.XMLCorePreferenceNames;
import org.w3c.dom.Node;
public class FormatProcessorXML extends AbstractStructuredFormatProcessor {
@@ -35,20 +34,22 @@ public class FormatProcessorXML extends AbstractStructuredFormatProcessor {
Preferences preferences = getModelPreferences();
if (preferences != null) {
- fFormatPreferences.setLineWidth(preferences.getInt(CommonModelPreferenceNames.LINE_WIDTH));
- ((IStructuredFormatPreferencesXML) fFormatPreferences).setSplitMultiAttrs(preferences.getBoolean(CommonModelPreferenceNames.SPLIT_MULTI_ATTRS));
- fFormatPreferences.setClearAllBlankLines(preferences.getBoolean(CommonModelPreferenceNames.CLEAR_ALL_BLANK_LINES));
+ fFormatPreferences.setLineWidth(preferences.getInt(XMLCorePreferenceNames.LINE_WIDTH));
+ ((IStructuredFormatPreferencesXML) fFormatPreferences).setSplitMultiAttrs(preferences.getBoolean(XMLCorePreferenceNames.SPLIT_MULTI_ATTRS));
+ fFormatPreferences.setClearAllBlankLines(preferences.getBoolean(XMLCorePreferenceNames.CLEAR_ALL_BLANK_LINES));
- if (preferences.getBoolean(CommonModelPreferenceNames.INDENT_USING_TABS))
- fFormatPreferences.setIndent("\t"); //$NON-NLS-1$
- else {
- int tabWidth = SSECorePlugin.getDefault().getPluginPreferences().getInt(CommonModelPreferenceNames.TAB_WIDTH);
- String indent = ""; //$NON-NLS-1$
- for (int i = 0; i < tabWidth; i++) {
- indent += " "; //$NON-NLS-1$
- }
- fFormatPreferences.setIndent(indent);
+ String indentChar = " "; //$NON-NLS-1$
+ String indentCharPref = preferences.getString(XMLCorePreferenceNames.INDENTATION_CHAR);
+ if (XMLCorePreferenceNames.TAB.equals(indentCharPref)) {
+ indentChar = "\t"; //$NON-NLS-1$
}
+ int indentationWidth = preferences.getInt(XMLCorePreferenceNames.INDENTATION_SIZE);
+
+ String indent = ""; //$NON-NLS-1$
+ for (int i = 0; i < indentationWidth; i++) {
+ indent += indentChar;
+ }
+ fFormatPreferences.setIndent(indent);
}
}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/provisional/format/NodeFormatter.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/provisional/format/NodeFormatter.java
index 349e373968..d8832e83bc 100644
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/provisional/format/NodeFormatter.java
+++ b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/provisional/format/NodeFormatter.java
@@ -15,13 +15,11 @@ package org.eclipse.wst.xml.core.internal.provisional.format;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.Preferences;
import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.wst.sse.core.internal.SSECorePlugin;
import org.eclipse.wst.sse.core.internal.format.IStructuredFormatContraints;
import org.eclipse.wst.sse.core.internal.format.IStructuredFormatPreferences;
import org.eclipse.wst.sse.core.internal.format.IStructuredFormatter;
import org.eclipse.wst.sse.core.internal.format.StructuredFormatContraints;
import org.eclipse.wst.sse.core.internal.parser.ContextRegion;
-import org.eclipse.wst.sse.core.internal.preferences.CommonModelPreferenceNames;
import org.eclipse.wst.sse.core.internal.provisional.exceptions.SourceEditingRuntimeException;
import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument;
import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
@@ -33,6 +31,7 @@ import org.eclipse.wst.xml.core.internal.document.CDATASectionImpl;
import org.eclipse.wst.xml.core.internal.document.CharacterDataImpl;
import org.eclipse.wst.xml.core.internal.document.CommentImpl;
import org.eclipse.wst.xml.core.internal.parser.regions.TagNameRegion;
+import org.eclipse.wst.xml.core.internal.preferences.XMLCorePreferenceNames;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext;
@@ -416,20 +415,22 @@ public class NodeFormatter implements IStructuredFormatter {
Preferences preferences = getModelPreferences();
if (preferences != null) {
- fFormatPreferences.setLineWidth(preferences.getInt(CommonModelPreferenceNames.LINE_WIDTH));
- ((IStructuredFormatPreferencesXML) fFormatPreferences).setSplitMultiAttrs(preferences.getBoolean(CommonModelPreferenceNames.SPLIT_MULTI_ATTRS));
- fFormatPreferences.setClearAllBlankLines(preferences.getBoolean(CommonModelPreferenceNames.CLEAR_ALL_BLANK_LINES));
+ fFormatPreferences.setLineWidth(preferences.getInt(XMLCorePreferenceNames.LINE_WIDTH));
+ ((IStructuredFormatPreferencesXML) fFormatPreferences).setSplitMultiAttrs(preferences.getBoolean(XMLCorePreferenceNames.SPLIT_MULTI_ATTRS));
+ fFormatPreferences.setClearAllBlankLines(preferences.getBoolean(XMLCorePreferenceNames.CLEAR_ALL_BLANK_LINES));
+
+ String indentChar = " "; //$NON-NLS-1$
+ String indentCharPref = preferences.getString(XMLCorePreferenceNames.INDENTATION_CHAR);
+ if (XMLCorePreferenceNames.TAB.equals(indentCharPref)) {
+ indentChar = "\t"; //$NON-NLS-1$
+ }
+ int indentationWidth = preferences.getInt(XMLCorePreferenceNames.INDENTATION_SIZE);
- if (preferences.getBoolean(CommonModelPreferenceNames.INDENT_USING_TABS))
- fFormatPreferences.setIndent("\t"); //$NON-NLS-1$
- else {
- int tabWidth = SSECorePlugin.getDefault().getPluginPreferences().getInt(CommonModelPreferenceNames.TAB_WIDTH);
- String indent = ""; //$NON-NLS-1$
- for (int i = 0; i < tabWidth; i++) {
- indent += " "; //$NON-NLS-1$
- }
- fFormatPreferences.setIndent(indent);
+ String indent = ""; //$NON-NLS-1$
+ for (int i = 0; i < indentationWidth; i++) {
+ indent += indentChar;
}
+ fFormatPreferences.setIndent(indent);
}
}

Back to the top