本文整理汇总了Java中org.eclipse.wst.xml.core.text.IXMLPartitions.XML_DEFAULT属性的典型用法代码示例。如果您正苦于以下问题:Java IXMLPartitions.XML_DEFAULT属性的具体用法?Java IXMLPartitions.XML_DEFAULT怎么用?Java IXMLPartitions.XML_DEFAULT使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.eclipse.wst.xml.core.text.IXMLPartitions
的用法示例。
在下文中一共展示了IXMLPartitions.XML_DEFAULT属性的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createFormatter
public static IContentFormatter createFormatter(String partitioning) {
/*
* Ideally, we would have no master strategy and two slave strategies, one
* for XML and one for CSS. The problem is, XMLFormattingStrategy won't work
* properly since some paired opening and closing tags are spread across
* different partitions (for example, the <ui:style> tag since the CSS
* partition will be between the opening and closing tag.)
*/
IndependentMultiPassContentFormatter formatter = new IndependentMultiPassContentFormatter(
partitioning, IXMLPartitions.XML_DEFAULT, new StructuredDocumentCloner(
partitioning, UIBINDER_XML_PARTITIONER_FACTORY));
formatter.setMasterStrategy(new XMLFormattingStrategy());
formatter.setSlaveStrategy2(new InlinedCssFormattingStrategy(),
ICSSPartitions.STYLE);
/*
* If the <ui:style> contains a '%' (for example, in something like
* "width: 50%;"), the XML following the <ui:style> tag will not be
* formatted. For the '%', the region type is UNDEFINED, and there is no
* corresponding DOM node. Before formatting, the
* DefaultXMLPartitionFormatter ensures the current region matches the
* current DOM node's first region, and since there is no DOM node for the
* UNDEFINED region, the formatting abruptly stops. To workaround this
* issue, we replace the CSS with whitespace when the master formatter runs.
*/
formatter.setReplaceSlavePartitionsDuringMasterFormat(true);
formatter.setCheckForNonwhitespaceChanges(true);
return formatter;
}
示例2: create
/**
* Make sure to call {@link #release()} after you are done!
*
* @return a {@link DtdRemover} or null
*/
private static DtdRemover create(ITextViewer textViewer,
int documentPosition) {
IDocumentPartitionerFactory docPartitionerFactory = new IDocumentPartitionerFactory() {
public IDocumentPartitioner createDocumentPartitioner() {
return new StructuredTextPartitionerForUiBinderXml();
}
};
StructuredDocumentCloner structuredDocumentCloner = new StructuredDocumentCloner(
IXMLPartitions.XML_DEFAULT, docPartitionerFactory);
IStructuredDocument clonedDoc = structuredDocumentCloner.clone(textViewer.getDocument());
if (clonedDoc == null) {
return null;
}
IDOMModel model = (IDOMModel) StructuredModelManager.getModelManager().getExistingModelForRead(
clonedDoc);
try {
IDOMNode docType = (IDOMNode) model.getDocument().getDoctype();
if (docType == null) {
return null;
}
IStructuredDocumentRegion firstRegion = docType.getFirstStructuredDocumentRegion();
IStructuredDocumentRegion lastRegion = docType.getLastStructuredDocumentRegion();
int firstPos = firstRegion.getStartOffset();
int lastPos = lastRegion.getEndOffset();
int docTypeLen = lastPos - firstPos;
if (docTypeLen == 0 || documentPosition >= firstPos
&& documentPosition <= lastPos) {
return null;
}
try {
clonedDoc.replace(firstPos, docTypeLen,
StringUtilities.repeatCharacter(' ', docTypeLen));
} catch (BadLocationException e) {
GWTPluginLog.logError(e,
"Unexpected bad location while removing doctype");
return null;
}
} finally {
if (model != null) {
model.releaseFromRead();
}
}
return new DtdRemover(new DocumentChangingTextViewer(textViewer,
clonedDoc), documentPosition, structuredDocumentCloner, clonedDoc);
}