[113584] add formatting preference to align final bracket in multi-line tags
diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/format/HTMLElementFormatter.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/format/HTMLElementFormatter.java
index 88d249b..abb85b7 100644
--- a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/format/HTMLElementFormatter.java
+++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/format/HTMLElementFormatter.java
@@ -157,6 +157,8 @@
}
boolean insertBreak = false;
insertBreak = ((StructuredFormatPreferencesXML) getFormatPreferences()).getSplitMultiAttrs();
+ boolean alignEndBracket = ((StructuredFormatPreferencesXML) getFormatPreferences()).isAlignEndBracket();
+ boolean attributesSplitted = false;
if (insertBreak) {
NamedNodeMap attributes = element.getAttributes();
@@ -164,6 +166,7 @@
insertBreak = false;
}
String breakSpaces = getBreakSpaces(element);
+ String originalBreakSpaces = breakSpaces;
String indent = getIndent();
if (indent != null && indent.length() > 0) {
breakSpaces += indent;
@@ -219,6 +222,7 @@
if (insertBreak || !isWidthAvailable(contraints, count + 1)) {
replaceTailingSpaces(startStructuredDocumentRegion, lastBreakRegion, breakSpaces);
setWidth(contraints, breakSpaces);
+ attributesSplitted = true;
}
else {
compressTailingSpaces(startStructuredDocumentRegion, lastBreakRegion);
@@ -243,6 +247,7 @@
if (insertBreak || !isWidthAvailable(contraints, count + 1)) {
replaceTailingSpaces(startStructuredDocumentRegion, lastBreakRegion, breakSpaces);
setWidth(contraints, breakSpaces);
+ attributesSplitted = true;
}
else {
compressTailingSpaces(startStructuredDocumentRegion, lastBreakRegion);
@@ -273,6 +278,12 @@
else {
addWidth(contraints, startStructuredDocumentRegion.getLength());
}
+ // BUG113584 - align last bracket
+ if (alignEndBracket && attributesSplitted) {
+ removeTailingSpaces(startStructuredDocumentRegion, lastBreakRegion);
+ replaceTailingSpaces(startStructuredDocumentRegion, lastBreakRegion, originalBreakSpaces);
+ contraints.setAvailableLineWidth(getLineWidth() - originalBreakSpaces.length() - 1);
+ }
}
/**
diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/format/HTMLFormatProcessorImpl.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/format/HTMLFormatProcessorImpl.java
index 8235e46..0552bc2 100644
--- a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/format/HTMLFormatProcessorImpl.java
+++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/format/HTMLFormatProcessorImpl.java
@@ -38,6 +38,7 @@
if (preferences != null) {
fFormatPreferences.setLineWidth(preferences.getInt(HTMLCorePreferenceNames.LINE_WIDTH));
((StructuredFormatPreferencesXML) fFormatPreferences).setSplitMultiAttrs(preferences.getBoolean(HTMLCorePreferenceNames.SPLIT_MULTI_ATTRS));
+ ((StructuredFormatPreferencesXML) fFormatPreferences).setAlignEndBracket(preferences.getBoolean(HTMLCorePreferenceNames.ALIGN_END_BRACKET));
fFormatPreferences.setClearAllBlankLines(preferences.getBoolean(HTMLCorePreferenceNames.CLEAR_ALL_BLANK_LINES));
char indentChar = ' ';
diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/format/HTMLFormatter.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/format/HTMLFormatter.java
index 37890b5..ba00f0b 100644
--- a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/format/HTMLFormatter.java
+++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/format/HTMLFormatter.java
@@ -623,6 +623,7 @@
if (preferences != null) {
fFormatPreferences.setLineWidth(preferences.getInt(HTMLCorePreferenceNames.LINE_WIDTH));
((StructuredFormatPreferencesXML) fFormatPreferences).setSplitMultiAttrs(preferences.getBoolean(HTMLCorePreferenceNames.SPLIT_MULTI_ATTRS));
+ ((StructuredFormatPreferencesXML) fFormatPreferences).setAlignEndBracket(preferences.getBoolean(HTMLCorePreferenceNames.ALIGN_END_BRACKET));
fFormatPreferences.setClearAllBlankLines(preferences.getBoolean(HTMLCorePreferenceNames.CLEAR_ALL_BLANK_LINES));
char indentChar = ' ';
diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/format/HTMLFormatterFactory.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/format/HTMLFormatterFactory.java
index ba003c8..d34701a 100644
--- a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/format/HTMLFormatterFactory.java
+++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/format/HTMLFormatterFactory.java
@@ -86,6 +86,7 @@
if (preferences != null) {
fFormatPreferences.setLineWidth(preferences.getInt(HTMLCorePreferenceNames.LINE_WIDTH));
fFormatPreferences.setSplitMultiAttrs(preferences.getBoolean(HTMLCorePreferenceNames.SPLIT_MULTI_ATTRS));
+ fFormatPreferences.setAlignEndBracket(preferences.getBoolean(HTMLCorePreferenceNames.ALIGN_END_BRACKET));
fFormatPreferences.setClearAllBlankLines(preferences.getBoolean(HTMLCorePreferenceNames.CLEAR_ALL_BLANK_LINES));
char indentChar = ' ';
diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/preferences/HTMLCorePreferenceInitializer.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/preferences/HTMLCorePreferenceInitializer.java
index 1021cc7..ea59b8a 100644
--- a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/preferences/HTMLCorePreferenceInitializer.java
+++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/preferences/HTMLCorePreferenceInitializer.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2006 IBM Corporation and others.
+ * Copyright (c) 2005, 2007 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -31,6 +31,7 @@
node.put(HTMLCorePreferenceNames.INDENTATION_CHAR, HTMLCorePreferenceNames.TAB);
node.putInt(HTMLCorePreferenceNames.INDENTATION_SIZE, 1);
node.putBoolean(HTMLCorePreferenceNames.SPLIT_MULTI_ATTRS, false);
+ node.putBoolean(HTMLCorePreferenceNames.ALIGN_END_BRACKET, false);
// cleanup preferences
node.putInt(HTMLCorePreferenceNames.CLEANUP_TAG_NAME_CASE, HTMLCorePreferenceNames.ASIS);
diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/preferences/HTMLCorePreferenceNames.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/preferences/HTMLCorePreferenceNames.java
index 606783d..0e2e671 100644
--- a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/preferences/HTMLCorePreferenceNames.java
+++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/preferences/HTMLCorePreferenceNames.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2006 IBM Corporation and others.
+ * Copyright (c) 2005, 2007 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -93,6 +93,15 @@
public static final String SPLIT_MULTI_ATTRS = "splitMultiAttrs";//$NON-NLS-1$
/**
+ * Indicates if end brackets of start tags should be placed on a new line
+ * if the start tag spans more than one line.
+ * <p>
+ * Value is of type <code>Boolean</code>.
+ * </p>
+ */
+ public static final String ALIGN_END_BRACKET = "alignEndBracket";//$NON-NLS-1$
+
+ /**
* Indicates whether or not cleanup processor should format source.
* <p>
* Value is of type <code>Boolean</code>.
diff --git a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/HTMLUIMessages.java b/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/HTMLUIMessages.java
index 3df9ad0..926bb45 100644
--- a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/HTMLUIMessages.java
+++ b/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/HTMLUIMessages.java
@@ -89,6 +89,7 @@
public static String Formatting_UI_;
public static String Line_width__UI_;
public static String Split_multiple_attributes;
+ public static String Align_final_bracket;
public static String Indent_using_tabs;
public static String Indent_using_spaces;
public static String Indentation_size;
diff --git a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/HTMLUIPluginResources.properties b/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/HTMLUIPluginResources.properties
index c219fd5..37092cf 100644
--- a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/HTMLUIPluginResources.properties
+++ b/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/HTMLUIPluginResources.properties
@@ -54,6 +54,7 @@
Formatting_UI_=Formatting
Line_width__UI_=Line &width:
Split_multiple_attributes=Split &multiple attributes each on a new line
+Align_final_bracket=&Align final bracket in multi-line element tags
Indent_using_tabs=&Indent using tabs
Indent_using_spaces=I&ndent using spaces
Indentation_size=In&dentation size:
diff --git a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/preferences/ui/HTMLSourcePreferencePage.java b/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/preferences/ui/HTMLSourcePreferencePage.java
index 576e4f2..4a72b9c 100644
--- a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/preferences/ui/HTMLSourcePreferencePage.java
+++ b/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/preferences/ui/HTMLSourcePreferencePage.java
@@ -48,6 +48,7 @@
// Formatting
private Text fLineWidthText;
private Button fSplitMultiAttrs;
+ private Button fAlignEndBracket;
private Button fIndentUsingTabs;
private Button fIndentUsingSpaces;
private Spinner fIndentationSize;
@@ -102,6 +103,8 @@
fSplitMultiAttrs = createCheckBox(formattingGroup, HTMLUIMessages.Split_multiple_attributes);
((GridData) fSplitMultiAttrs.getLayoutData()).horizontalSpan = 2;
+ fAlignEndBracket = createCheckBox(formattingGroup, HTMLUIMessages.Align_final_bracket);
+ ((GridData) fAlignEndBracket.getLayoutData()).horizontalSpan = 2;
fClearAllBlankLines = createCheckBox(formattingGroup, HTMLUIMessages.Clear_all_blank_lines_UI_);
((GridData) fClearAllBlankLines.getLayoutData()).horizontalSpan = 2;
@@ -148,6 +151,7 @@
// Formatting
fLineWidthText.setText(getModelPreferences().getDefaultString(HTMLCorePreferenceNames.LINE_WIDTH));
fSplitMultiAttrs.setSelection(getModelPreferences().getDefaultBoolean(HTMLCorePreferenceNames.SPLIT_MULTI_ATTRS));
+ fAlignEndBracket.setSelection(getModelPreferences().getDefaultBoolean(HTMLCorePreferenceNames.ALIGN_END_BRACKET));
fClearAllBlankLines.setSelection(getModelPreferences().getDefaultBoolean(HTMLCorePreferenceNames.CLEAR_ALL_BLANK_LINES));
if (HTMLCorePreferenceNames.TAB.equals(getModelPreferences().getDefaultString(HTMLCorePreferenceNames.INDENTATION_CHAR))) {
@@ -181,6 +185,7 @@
// Formatting
fLineWidthText.setText(getModelPreferences().getString(HTMLCorePreferenceNames.LINE_WIDTH));
fSplitMultiAttrs.setSelection(getModelPreferences().getBoolean(HTMLCorePreferenceNames.SPLIT_MULTI_ATTRS));
+ fAlignEndBracket.setSelection(getModelPreferences().getBoolean(HTMLCorePreferenceNames.ALIGN_END_BRACKET));
fClearAllBlankLines.setSelection(getModelPreferences().getBoolean(HTMLCorePreferenceNames.CLEAR_ALL_BLANK_LINES));
if (HTMLCorePreferenceNames.TAB.equals(getModelPreferences().getString(HTMLCorePreferenceNames.INDENTATION_CHAR))) {
@@ -219,6 +224,7 @@
// Formatting
getModelPreferences().setValue(HTMLCorePreferenceNames.LINE_WIDTH, fLineWidthText.getText());
getModelPreferences().setValue(HTMLCorePreferenceNames.SPLIT_MULTI_ATTRS, fSplitMultiAttrs.getSelection());
+ getModelPreferences().setValue(HTMLCorePreferenceNames.ALIGN_END_BRACKET, fAlignEndBracket.getSelection());
getModelPreferences().setValue(HTMLCorePreferenceNames.CLEAR_ALL_BLANK_LINES, fClearAllBlankLines.getSelection());
if (fIndentUsingTabs.getSelection()) {
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
index c2bb9d8..ac150c9 100644
--- 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
@@ -35,6 +35,7 @@
node.put(XMLCorePreferenceNames.INDENTATION_CHAR, XMLCorePreferenceNames.TAB);
node.putInt(XMLCorePreferenceNames.INDENTATION_SIZE, 1);
node.putBoolean(XMLCorePreferenceNames.SPLIT_MULTI_ATTRS, false);
+ node.putBoolean(XMLCorePreferenceNames.ALIGN_END_BRACKET, false);
node.putBoolean(XMLCorePreferenceNames.PRESERVE_CDATACONTENT, false);
// cleanup preferences
@@ -52,7 +53,7 @@
// this could be made smarter by actually looking up the content
// type's valid extensions
node.put(XMLCorePreferenceNames.DEFAULT_EXTENSION, "xml"); //$NON-NLS-1$
-
+
node.putBoolean(XMLCorePreferenceNames.WARN_NO_GRAMMAR, false);
}
}
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
index 3c2c2a8..41d7b30 100644
--- 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
@@ -171,4 +171,13 @@
* </p>
*/
public static final String PRESERVE_CDATACONTENT = "preserveCDATAContent";//$NON-NLS-1$
+
+ /**
+ * Indicates if end brackets of start tags should be placed on a new line
+ * if the start tag spans more than one line.
+ * <p>
+ * Value is of type <code>Boolean</code>.
+ * </p>
+ */
+ public static final String ALIGN_END_BRACKET = "alignEndBracket";//$NON-NLS-1$
}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/provisional/format/ElementNodeFormatter.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/provisional/format/ElementNodeFormatter.java
index 37713ee..00713d1 100644
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/provisional/format/ElementNodeFormatter.java
+++ b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/provisional/format/ElementNodeFormatter.java
@@ -157,6 +157,7 @@
String lineIndent = formatContraints.getCurrentIndent();
String attrIndent = lineIndent + singleIndent;
boolean splitMultiAttrs = preferences.getSplitMultiAttrs();
+ boolean alignEndBracket = preferences.isAlignEndBracket();
boolean sawXmlSpace = false;
IStructuredDocumentRegion flatNode = node.getFirstStructuredDocumentRegion();
@@ -185,6 +186,7 @@
String lineDelimiter = node.getModel().getStructuredDocument().getLineDelimiter();
int attrLength = attributes.getLength();
int lastUndefinedRegionOffset = 0;
+ boolean startTagSpansOver1Line = false;
for (int i = 0; i < attrLength; i++) {
AttrImpl attr = (AttrImpl) attributes.item(i);
@@ -231,6 +233,7 @@
if (splitMultiAttrs && attrLength > 1) {
stringBuffer.append(lineDelimiter + attrIndent);
stringBuffer.append(flatNode.getText(nameRegion));
+ startTagSpansOver1Line = true;
if (valueRegion != null) {
// append undefined regions
undefinedRegion = getUndefinedRegions(node, lastUndefinedRegionOffset, flatNode.getStartOffset(equalRegion) - lastUndefinedRegionOffset);
@@ -272,6 +275,7 @@
}
else {
stringBuffer.append(lineDelimiter + attrIndent);
+ startTagSpansOver1Line = true;
currentAvailableLineWidth = preferences.getLineWidth() - attrIndent.length();
}
@@ -305,6 +309,7 @@
}
else {
stringBuffer.append(lineDelimiter + attrIndent);
+ startTagSpansOver1Line = true;
currentAvailableLineWidth = preferences.getLineWidth() - attrIndent.length();
}
@@ -338,12 +343,18 @@
if (lastRegion.getType() == DOMRegionContext.XML_TAG_CLOSE || lastRegion.getType() == DOMRegionContext.XML_EMPTY_TAG_CLOSE)
length = length - lastRegion.getLength();
- if (lastRegion.getType() == DOMRegionContext.XML_EMPTY_TAG_CLOSE)
+ if (lastRegion.getType() == DOMRegionContext.XML_EMPTY_TAG_CLOSE) {
// leave space before XML_EMPTY_TAG_CLOSE: <tagName />
- stringBuffer.append(SPACE_CHAR);
+ // unless already going to move end bracket
+ if (!startTagSpansOver1Line || !alignEndBracket)
+ stringBuffer.append(SPACE_CHAR);
+ }
}
}
+ if (startTagSpansOver1Line && alignEndBracket) {
+ stringBuffer.append(lineDelimiter).append(lineIndent);
+ }
replace(structuredDocument, offset, length, stringBuffer.toString());
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 d49d827..a798dbd 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
@@ -35,6 +35,7 @@
if (preferences != null) {
fFormatPreferences.setLineWidth(preferences.getInt(XMLCorePreferenceNames.LINE_WIDTH));
((StructuredFormatPreferencesXML) fFormatPreferences).setSplitMultiAttrs(preferences.getBoolean(XMLCorePreferenceNames.SPLIT_MULTI_ATTRS));
+ ((StructuredFormatPreferencesXML) fFormatPreferences).setAlignEndBracket(preferences.getBoolean(XMLCorePreferenceNames.ALIGN_END_BRACKET));
((StructuredFormatPreferencesXML) fFormatPreferences).setPreservePCDATAContent(preferences.getBoolean(XMLCorePreferenceNames.PRESERVE_CDATACONTENT));
fFormatPreferences.setClearAllBlankLines(preferences.getBoolean(XMLCorePreferenceNames.CLEAR_ALL_BLANK_LINES));
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 7964580..f48ed18 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
@@ -361,6 +361,7 @@
if (preferences != null) {
fFormatPreferences.setLineWidth(preferences.getInt(XMLCorePreferenceNames.LINE_WIDTH));
((StructuredFormatPreferencesXML) fFormatPreferences).setSplitMultiAttrs(preferences.getBoolean(XMLCorePreferenceNames.SPLIT_MULTI_ATTRS));
+ ((StructuredFormatPreferencesXML) fFormatPreferences).setAlignEndBracket(preferences.getBoolean(XMLCorePreferenceNames.ALIGN_END_BRACKET));
((StructuredFormatPreferencesXML) fFormatPreferences).setPreservePCDATAContent(preferences.getBoolean(XMLCorePreferenceNames.PRESERVE_CDATACONTENT));
fFormatPreferences.setClearAllBlankLines(preferences.getBoolean(XMLCorePreferenceNames.CLEAR_ALL_BLANK_LINES));
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/provisional/format/StructuredFormatPreferencesXML.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/provisional/format/StructuredFormatPreferencesXML.java
index 930bb5a..07024eb 100644
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/provisional/format/StructuredFormatPreferencesXML.java
+++ b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/provisional/format/StructuredFormatPreferencesXML.java
@@ -15,22 +15,67 @@
import org.eclipse.wst.sse.core.internal.format.StructuredFormatPreferences;
public class StructuredFormatPreferencesXML extends StructuredFormatPreferences {
- private boolean fSplitMultiAttrs;
- private boolean fPreservePCDATAContent;
+ private boolean fSplitMultiAttrs = false;
+ private boolean fPreservePCDATAContent = false;
+ private boolean fAlignEndBracket = false;
+ /**
+ * True if formatter should split elements with multiple attributes onto
+ * new lines.
+ *
+ * @return boolean
+ */
public boolean getSplitMultiAttrs() {
return fSplitMultiAttrs;
}
+ /**
+ * Sets whether or not formatter should split elements with multiple
+ * attributes onto new lines.
+ *
+ * @param splitMultiAttrs
+ */
public void setSplitMultiAttrs(boolean splitMultiAttrs) {
fSplitMultiAttrs = splitMultiAttrs;
}
+ /**
+ * True if tags with PCDATA content should not have their whitespace
+ * messed with when formatting.
+ *
+ * @return boolean
+ */
public boolean isPreservePCDATAContent() {
return fPreservePCDATAContent;
}
+ /**
+ * Sets whether or not formatter should preserve whitespace in tags with
+ * PCDATA content.
+ *
+ * @param preservePCDATAContent
+ */
public void setPreservePCDATAContent(boolean preservePCDATAContent) {
fPreservePCDATAContent = preservePCDATAContent;
}
+
+ /**
+ * True if end brackets of start tags should be placed on a new line if
+ * the start tag spans more than one line.
+ *
+ * @return
+ */
+ public boolean isAlignEndBracket() {
+ return fAlignEndBracket;
+ }
+
+ /**
+ * Sets whether or not formatter should align the end bracket of a start
+ * tag on a new line if the start tag spans more than one line.
+ *
+ * @param alignEndBracket
+ */
+ public void setAlignEndBracket(boolean alignEndBracket) {
+ fAlignEndBracket = alignEndBracket;
+ }
}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/XMLUIMessages.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/XMLUIMessages.java
index aaba4a7..72037cf 100644
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/XMLUIMessages.java
+++ b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/XMLUIMessages.java
@@ -223,6 +223,7 @@
public static String Formatting_UI_;
public static String Line_width__UI_;
public static String Split_multiple_attributes;
+ public static String Align_final_bracket;
public static String Preserve_PCDATA_Content;
public static String Indent_using_tabs;
public static String Indent_using_spaces;
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/XMLUIPluginResources.properties b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/XMLUIPluginResources.properties
index 72b8083..1fb6f99 100644
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/XMLUIPluginResources.properties
+++ b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/XMLUIPluginResources.properties
@@ -253,14 +253,15 @@
Formatting_UI_=Formatting
Line_width__UI_=Line &width:
Split_multiple_attributes=Split &multiple attributes each on a new line
-Preserve_PCDATA_Content=Preserve whitespace in tags with PCDATA content
+Align_final_bracket=&Align final bracket in multi-line element tags
+Preserve_PCDATA_Content=&Preserve whitespace in tags with PCDATA content
Indent_using_tabs=&Indent using tabs
Indent_using_spaces=I&ndent using spaces
Indentation_size=In&dentation size:
Indentation_size_tip=Indentation size
Clear_all_blank_lines_UI_=Clear all &blank lines
Grammar_Constraints=Grammar Constraints
-Use_inferred_grammar_in_absence_of=Use inferred grammar in absence of DTD/Schema
+Use_inferred_grammar_in_absence_of=&Use inferred grammar in absence of DTD/Schema
Suggestion_Strategy=&Suggestion strategy:
Suggestion_Strategy_Lax=Lax
Suggestion_Strategy_Strict=Strict
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/preferences/XMLSourcePreferencePage.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/preferences/XMLSourcePreferencePage.java
index a881916..4d9b7d3 100644
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/preferences/XMLSourcePreferencePage.java
+++ b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/preferences/XMLSourcePreferencePage.java
@@ -57,6 +57,7 @@
private Button fIndentUsingSpaces;
private Spinner fIndentationSize;
private Button fPreservePCDATAContent;
+ private Button fAlignEndBracket;
// grammar constraints
protected Button fUseInferredGrammar;
@@ -108,6 +109,8 @@
fSplitMultiAttrs = createCheckBox(formattingGroup, XMLUIMessages.Split_multiple_attributes);
((GridData) fSplitMultiAttrs.getLayoutData()).horizontalSpan = 2;
+ fAlignEndBracket = createCheckBox(formattingGroup, XMLUIMessages.Align_final_bracket);
+ ((GridData) fAlignEndBracket.getLayoutData()).horizontalSpan = 2;
fPreservePCDATAContent = createCheckBox(formattingGroup, XMLUIMessages.Preserve_PCDATA_Content);
((GridData) fPreservePCDATAContent.getLayoutData()).horizontalSpan = 2;
fClearAllBlankLines = createCheckBox(formattingGroup, XMLUIMessages.Clear_all_blank_lines_UI_);
@@ -201,6 +204,7 @@
// Formatting
fLineWidthText.setText(getModelPreferences().getString(XMLCorePreferenceNames.LINE_WIDTH));
fSplitMultiAttrs.setSelection(getModelPreferences().getBoolean(XMLCorePreferenceNames.SPLIT_MULTI_ATTRS));
+ fAlignEndBracket.setSelection(getModelPreferences().getBoolean(XMLCorePreferenceNames.ALIGN_END_BRACKET));
fClearAllBlankLines.setSelection(getModelPreferences().getBoolean(XMLCorePreferenceNames.CLEAR_ALL_BLANK_LINES));
fPreservePCDATAContent.setSelection(getModelPreferences().getBoolean(XMLCorePreferenceNames.PRESERVE_CDATACONTENT));
@@ -248,6 +252,7 @@
// Formatting
fLineWidthText.setText(getModelPreferences().getDefaultString(XMLCorePreferenceNames.LINE_WIDTH));
fSplitMultiAttrs.setSelection(getModelPreferences().getDefaultBoolean(XMLCorePreferenceNames.SPLIT_MULTI_ATTRS));
+ fAlignEndBracket.setSelection(getModelPreferences().getDefaultBoolean(XMLCorePreferenceNames.ALIGN_END_BRACKET));
fClearAllBlankLines.setSelection(getModelPreferences().getDefaultBoolean(XMLCorePreferenceNames.CLEAR_ALL_BLANK_LINES));
fPreservePCDATAContent.setSelection(getModelPreferences().getDefaultBoolean(XMLCorePreferenceNames.PRESERVE_CDATACONTENT));
@@ -307,6 +312,7 @@
// Formatting
getModelPreferences().setValue(XMLCorePreferenceNames.LINE_WIDTH, fLineWidthText.getText());
getModelPreferences().setValue(XMLCorePreferenceNames.SPLIT_MULTI_ATTRS, fSplitMultiAttrs.getSelection());
+ getModelPreferences().setValue(XMLCorePreferenceNames.ALIGN_END_BRACKET, fAlignEndBracket.getSelection());
getModelPreferences().setValue(XMLCorePreferenceNames.CLEAR_ALL_BLANK_LINES, fClearAllBlankLines.getSelection());
getModelPreferences().setValue(XMLCorePreferenceNames.PRESERVE_CDATACONTENT, fPreservePCDATAContent.getSelection());