本文整理汇总了Java中org.eclipse.wst.xml.core.text.IXMLPartitions类的典型用法代码示例。如果您正苦于以下问题:Java IXMLPartitions类的具体用法?Java IXMLPartitions怎么用?Java IXMLPartitions使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IXMLPartitions类属于org.eclipse.wst.xml.core.text包,在下文中一共展示了IXMLPartitions类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createFormatter
import org.eclipse.wst.xml.core.text.IXMLPartitions; //导入依赖的package包/类
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: getLineStyleProviders
import org.eclipse.wst.xml.core.text.IXMLPartitions; //导入依赖的package包/类
public LineStyleProvider[] getLineStyleProviders(ISourceViewer sourceViewer, String partitionType) {
LineStyleProvider[] providers = null;
// workaround IXMLPartitions.XML_PI
if (partitionType == IHTMLPartitions.HTML_DEFAULT || partitionType == IHTMLPartitions.HTML_COMMENT || partitionType == IHTMLPartitions.HTML_DECLARATION || partitionType == IXMLPartitions.XML_PI) {
providers = new LineStyleProvider[]{getLineStyleProviderForSS()};
}else if (partitionType == ICSSPartitions.STYLE || partitionType == ICSSPartitions.COMMENT) {
providers = new LineStyleProvider[]{getLineStyleProviderForEmbeddedCSS()};
}
return providers;
}
开发者ID:UndefinedOffset,项目名称:eclipse-silverstripedt,代码行数:13,代码来源:StructuredTextViewerConfigurationSS.java
示例3: create
import org.eclipse.wst.xml.core.text.IXMLPartitions; //导入依赖的package包/类
/**
* 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);
}