protected IStructuredFormatProcessor getFormatProcessor() { return new FormatProcessorXML(); }
/** * formats the node (and content). please make sure to only format the node you have created.. * * @param newNode */ public static void format(Node newNode) { Node parentNode = newNode.getParentNode(); if(parentNode != null && newNode.equals(parentNode.getLastChild())) { //add a new line to get the newly generated content correctly formatted. Document ownerDocument; if(parentNode instanceof Document) { ownerDocument = (Document) parentNode; } else { ownerDocument = parentNode.getOwnerDocument(); } parentNode.appendChild(ownerDocument.createTextNode("\n")); //$NON-NLS-1$ } FormatProcessorXML formatProcessor = new FormatProcessorXML(); //ignore any line width settings, causes wrong formatting of <foo>bar</foo> formatProcessor.getFormatPreferences().setLineWidth(2000); formatProcessor.formatNode(newNode); }
formatter.setFormatPreferences(getFormatPreferences()); formatter.setProgressMonitor(fProgressMonitor);
public IStructuredFormatPreferences getFormatPreferences() { if (fFormatPreferences == null) { fFormatPreferences = new StructuredFormatPreferencesXML(); Preferences preferences = getModelPreferences(); 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)); char indentChar = ' '; String indentCharPref = preferences.getString(XMLCorePreferenceNames.INDENTATION_CHAR); if (XMLCorePreferenceNames.TAB.equals(indentCharPref)) { indentChar = '\t'; } int indentationWidth = preferences.getInt(XMLCorePreferenceNames.INDENTATION_SIZE); StringBuffer indent = new StringBuffer(); for (int i = 0; i < indentationWidth; i++) { indent.append(indentChar); } fFormatPreferences.setIndent(indent.toString()); } } return fFormatPreferences; }
public IContentFormatter getContentFormatter(ISourceViewer sourceViewer) { final MultiPassContentFormatter formatter = new MultiPassContentFormatter(getConfiguredDocumentPartitioning(sourceViewer), IXMLPartitions.XML_DEFAULT); formatter.setMasterStrategy(new StructuredFormattingStrategy(new FormatProcessorXML())); return formatter; }
public void reformat(Node newElement, boolean deep) { try { // tell the model that we are about to make a big model change fModel.aboutToChangeModel(); // format selected node IStructuredFormatProcessor formatProcessor = new FormatProcessorXML(); formatProcessor.formatNode(newElement); } finally { // tell the model that we are done with the big model change fModel.changedModel(); } }
public static void formatChild(Node child) { if (child instanceof IDOMNode) { IDOMModel model = ((IDOMNode)child).getModel(); try { // tell the model that we are about to make a big model change model.aboutToChangeModel(); IStructuredFormatProcessor formatProcessor = new FormatProcessorXML(); formatProcessor.formatNode(child); } finally { // tell the model that we are done with the big model change model.changedModel(); } } }
protected void formatChild(Element child) { if (child instanceof IDOMNode) { IDOMModel model = ((IDOMNode)child).getModel(); try { // tell the model that we are about to make a big model change model.aboutToChangeModel(); IStructuredFormatProcessor formatProcessor = new FormatProcessorXML(); formatProcessor.formatNode(child); } finally { // tell the model that we are done with the big model change model.changedModel(); } } } /*
protected void formatChild(Element child) { if (child instanceof IDOMNode) { IDOMModel model = ((IDOMNode)child).getModel(); try { // tell the model that we are about to make a big model change model.aboutToChangeModel(); IStructuredFormatProcessor formatProcessor = new FormatProcessorXML(); formatProcessor.formatNode(child); } finally { // tell the model that we are done with the big model change model.changedModel(); } } }
protected void formatChild(Element child) { if (child instanceof IDOMNode) { IDOMModel model = ((IDOMNode)child).getModel(); try { // tell the model that we are about to make a big model change model.aboutToChangeModel(); IStructuredFormatProcessor formatProcessor = new FormatProcessorXML(); formatProcessor.formatNode(child); } finally { // tell the model that we are done with the big model change model.changedModel(); } } }
public static void formatChild(Node child) { if (child instanceof IDOMNode) { IDOMModel model = ((IDOMNode) child).getModel(); try { // tell the model that we are about to make a big model change model.aboutToChangeModel(); IStructuredFormatProcessor formatProcessor = new FormatProcessorXML(); formatProcessor.formatNode(child); } finally { // tell the model that we are done with the big model change model.changedModel(); } } }
IStructuredFormatProcessor formatProcessor = new FormatProcessorXML(); formatProcessor.formatNode(newElementNode);