本文整理汇总了Java中org.eclipse.jface.text.formatter.IContentFormatter类的典型用法代码示例。如果您正苦于以下问题:Java IContentFormatter类的具体用法?Java IContentFormatter怎么用?Java IContentFormatter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IContentFormatter类属于org.eclipse.jface.text.formatter包,在下文中一共展示了IContentFormatter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getContentFormatter
import org.eclipse.jface.text.formatter.IContentFormatter; //导入依赖的package包/类
public IContentFormatter getContentFormatter( ISourceViewer sourceViewer){
ContentFormatter formatter = new ContentFormatter();
XMLFormattingStrategy formattingStrategy = new XMLFormattingStrategy();
DefaultFormattingStrategy defaultStrategy = new DefaultFormattingStrategy();
TextFormattingStrategy textStrategy = new TextFormattingStrategy();
DocTypeFormattingStrategy doctypeStrategy = new DocTypeFormattingStrategy();
PIFormattingStrategy piStrategy = new PIFormattingStrategy();
formatter.setFormattingStrategy(defaultStrategy,
IDocument.DEFAULT_CONTENT_TYPE);
formatter.setFormattingStrategy(textStrategy,
XMLPartitionScanner.XML_TEXT);
formatter.setFormattingStrategy(doctypeStrategy,
XMLPartitionScanner.XML_DOCTYPE);
formatter.setFormattingStrategy(piStrategy, XMLPartitionScanner.XML_PI);
formatter.setFormattingStrategy(textStrategy,
XMLPartitionScanner.XML_CDATA);
formatter.setFormattingStrategy(formattingStrategy,
XMLPartitionScanner.XML_START_TAG);
formatter.setFormattingStrategy(formattingStrategy,
XMLPartitionScanner.XML_END_TAG);
return formatter;
}
示例2: getContentFormatter
import org.eclipse.jface.text.formatter.IContentFormatter; //导入依赖的package包/类
public IContentFormatter getContentFormatter(ISourceViewer sourceViewer) {
ContentFormatter formatter = new ContentFormatter();
XMLFormattingStrategy formattingStrategy = new XMLFormattingStrategy();
DefaultFormattingStrategy defaultStrategy = new DefaultFormattingStrategy();
TextFormattingStrategy textStrategy = new TextFormattingStrategy();
DocTypeFormattingStrategy doctypeStrategy = new DocTypeFormattingStrategy();
PIFormattingStrategy piStrategy = new PIFormattingStrategy();
formatter.setFormattingStrategy(defaultStrategy, IDocument.DEFAULT_CONTENT_TYPE);
formatter.setFormattingStrategy(textStrategy, XMLPartitionScanner.XML_TEXT);
formatter.setFormattingStrategy(doctypeStrategy, XMLPartitionScanner.XML_DOCTYPE);
formatter.setFormattingStrategy(piStrategy, XMLPartitionScanner.XML_PI);
formatter.setFormattingStrategy(textStrategy, XMLPartitionScanner.XML_CDATA);
formatter.setFormattingStrategy(formattingStrategy, XMLPartitionScanner.XML_START_TAG);
formatter.setFormattingStrategy(formattingStrategy, XMLPartitionScanner.XML_END_TAG);
return formatter;
}
示例3: getContentFormatter
import org.eclipse.jface.text.formatter.IContentFormatter; //导入依赖的package包/类
public IContentFormatter getContentFormatter(ISourceViewer sourceViewer) {
MultiPassContentFormatter formatter = new MultiPassContentFormatter(
getConfiguredDocumentPartitioning(sourceViewer),
IDocument.DEFAULT_CONTENT_TYPE);
formatter.setMasterStrategy(new NCLDocumentFormattingStrategy());
return formatter;
}
示例4: getContentFormatter
import org.eclipse.jface.text.formatter.IContentFormatter; //导入依赖的package包/类
@Override
public IContentFormatter getContentFormatter(ISourceViewer sourceViewer) {
if (fConfigureFormatter)
return super.getContentFormatter(sourceViewer);
else
return null;
}
示例5: createFormatter
import org.eclipse.jface.text.formatter.IContentFormatter; //导入依赖的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;
}
示例6: getContentFormatter
import org.eclipse.jface.text.formatter.IContentFormatter; //导入依赖的package包/类
@Override
public IContentFormatter getContentFormatter(ISourceViewer sourceViewer) {
IndependentMultiPassContentFormatter formatter = new IndependentMultiPassContentFormatter(
getConfiguredDocumentPartitioning(sourceViewer),
IDocument.DEFAULT_CONTENT_TYPE, JAVA_DOCUMENT_CLONER);
formatter.setMasterStrategy(new JavaFormattingStrategy());
formatter.setSlaveStrategy2(new JsniFormattingStrategy(),
GWTPartitions.JSNI_METHOD);
return formatter;
}
示例7: doFormatPreview
import org.eclipse.jface.text.formatter.IContentFormatter; //导入依赖的package包/类
@Override
protected void doFormatPreview() {
if (fPreviewText == null) {
fPreviewDocument.set(""); //$NON-NLS-1$
return;
}
fPreviewDocument.set(fPreviewText);
fSourceViewer.setRedraw(false);
final IFormattingContext context = new JavaFormattingContext();
try {
final IContentFormatter formatter = fViewerConfiguration.getContentFormatter(fSourceViewer);
if (formatter instanceof IContentFormatterExtension) {
final IContentFormatterExtension extension = (IContentFormatterExtension) formatter;
context.setProperty(FormattingContextProperties.CONTEXT_PREFERENCES, fWorkingValues);
context.setProperty(FormattingContextProperties.CONTEXT_DOCUMENT, Boolean.valueOf(true));
extension.format(fPreviewDocument, context);
} else
formatter.format(fPreviewDocument, new Region(0, fPreviewDocument.getLength()));
} catch (Exception e) {
final IStatus status= new Status(IStatus.ERROR, JavaPlugin.getPluginId(), IJavaStatusConstants.INTERNAL_ERROR,
FormatterMessages.JavaPreview_formatter_exception, e);
JavaPlugin.log(status);
} finally {
context.dispose();
fSourceViewer.setRedraw(true);
}
}
示例8: getContentFormatter
import org.eclipse.jface.text.formatter.IContentFormatter; //导入依赖的package包/类
public IContentFormatter getContentFormatter(ISourceViewer sourceViewer) {
ContentFormatter formatter = new ContentFormatter();
ExampleFormattingStrategy formattingStrategy = new ExampleFormattingStrategy(editor);
formatter.setFormattingStrategy(formattingStrategy, IDocument.DEFAULT_CONTENT_TYPE);
return formatter;
}
示例9: getContentFormatter
import org.eclipse.jface.text.formatter.IContentFormatter; //导入依赖的package包/类
@Override
public IContentFormatter getContentFormatter(ISourceViewer sourceViewer) {
if (configureFormatter)
return super.getContentFormatter(sourceViewer);
else
return null;
}
示例10: getContentFormatter
import org.eclipse.jface.text.formatter.IContentFormatter; //导入依赖的package包/类
@Override
public IContentFormatter getContentFormatter(ISourceViewer sourceViewer) {
IEditorInput input = getEditor().getEditorInput();
return input != null ? new TypeScriptContentFormatter(EditorUtils.getResource(input)) : null;
}
示例11: getContentFormatter
import org.eclipse.jface.text.formatter.IContentFormatter; //导入依赖的package包/类
@Override
public IContentFormatter getContentFormatter(ISourceViewer sourceViewer) {
return null;
}
示例12: getContentFormatter
import org.eclipse.jface.text.formatter.IContentFormatter; //导入依赖的package包/类
@Override
public IContentFormatter getContentFormatter(ISourceViewer sourceViewer) {
if (contentFormatterFactory != null)
return contentFormatterFactory.createConfiguredFormatter(this, sourceViewer);
return super.getContentFormatter(sourceViewer);
}
示例13: createConfiguredFormatter
import org.eclipse.jface.text.formatter.IContentFormatter; //导入依赖的package包/类
public IContentFormatter createConfiguredFormatter(
SourceViewerConfiguration configuration, ISourceViewer sourceViewer) {
return new ContentFormatter();
}
示例14: getContentFormatter
import org.eclipse.jface.text.formatter.IContentFormatter; //导入依赖的package包/类
public IContentFormatter getContentFormatter(ISourceViewer sourceViewer) {
return null;
}
示例15: getContentFormatter
import org.eclipse.jface.text.formatter.IContentFormatter; //导入依赖的package包/类
@Override
public IContentFormatter getContentFormatter(ISourceViewer sourceViewer) {
return UiBinderFormatter.createFormatter(getConfiguredDocumentPartitioning(sourceViewer));
}