Search in sources :

Example 16 with IContentFormatter

use of org.eclipse.jface.text.formatter.IContentFormatter in project linuxtools by eclipse.

the class GNUEditorConfiguration method getContentFormatter.

/**
 * Set content formatter. For ChangeLog, it just wraps lines.
 */
@Override
public IContentFormatter getContentFormatter(ISourceViewer sourceViewer) {
    ContentFormatter cf = new ContentFormatter();
    // no partitions
    cf.enablePartitionAwareFormatting(false);
    ChangeLogFormattingStrategy cfs = new ChangeLogFormattingStrategy();
    cf.setFormattingStrategy(cfs, IDocument.DEFAULT_CONTENT_TYPE);
    return cf;
}
Also used : IContentFormatter(org.eclipse.jface.text.formatter.IContentFormatter) ContentFormatter(org.eclipse.jface.text.formatter.ContentFormatter)

Example 17 with IContentFormatter

use of org.eclipse.jface.text.formatter.IContentFormatter in project webtools.sourceediting by eclipse.

the class StructuredTextViewerConfigurationXML method getContentFormatter.

public IContentFormatter getContentFormatter(ISourceViewer sourceViewer) {
    IContentFormatter formatter = super.getContentFormatter(sourceViewer);
    // generic one
    if (!(formatter instanceof MultiPassContentFormatter))
        formatter = new MultiPassContentFormatter(getConfiguredDocumentPartitioning(sourceViewer), IXMLPartitions.XML_DEFAULT);
    ((MultiPassContentFormatter) formatter).setMasterStrategy(new XMLFormattingStrategy());
    return formatter;
}
Also used : IContentFormatter(org.eclipse.jface.text.formatter.IContentFormatter) XMLFormattingStrategy(org.eclipse.wst.xml.ui.internal.XMLFormattingStrategy) MultiPassContentFormatter(org.eclipse.jface.text.formatter.MultiPassContentFormatter)

Example 18 with IContentFormatter

use of org.eclipse.jface.text.formatter.IContentFormatter in project webtools.sourceediting by eclipse.

the class StructuredTextViewerConfiguration method getContentFormatter.

/**
 * Returns the content formatter ready to be used with the given source
 * viewer.
 * <p>
 * It is not recommended that clients override this method as it may
 * become <code>final</code> in the future and replaced by an extensible
 * framework.
 * </p>
 *
 * @param sourceViewer
 *            the source viewer to be configured by this configuration
 * @return a content formatter or <code>null</code> if formatting should
 *         not be supported
 */
public IContentFormatter getContentFormatter(ISourceViewer sourceViewer) {
    // try to use the StructuredTextMultiPassContentFormatter so that it
    // picks up any additional formatting strategies contributed via the
    // editorConfiguration extension point
    IContentFormatter formatter = null;
    if (sourceViewer != null) {
        IDocument document = sourceViewer.getDocument();
        if (document instanceof IDocumentExtension3) {
            String partitioning = getConfiguredDocumentPartitioning(sourceViewer);
            IDocumentPartitioner partitioner = ((IDocumentExtension3) document).getDocumentPartitioner(partitioning);
            if (partitioner instanceof StructuredTextPartitioner) {
                String defaultPartitionType = ((StructuredTextPartitioner) partitioner).getDefaultPartitionType();
                formatter = new StructuredTextMultiPassContentFormatter(partitioning, defaultPartitionType);
            }
        }
    }
    return formatter;
}
Also used : IContentFormatter(org.eclipse.jface.text.formatter.IContentFormatter) IDocumentExtension3(org.eclipse.jface.text.IDocumentExtension3) IDocumentPartitioner(org.eclipse.jface.text.IDocumentPartitioner) IDocument(org.eclipse.jface.text.IDocument) StructuredTextPartitioner(org.eclipse.wst.sse.core.internal.text.rules.StructuredTextPartitioner)

Example 19 with IContentFormatter

use of org.eclipse.jface.text.formatter.IContentFormatter in project dbeaver by serge-rider.

the class XMLSourceViewerConfiguration method getContentFormatter.

@Override
public IContentFormatter getContentFormatter(ISourceViewer sourceViewer) {
    ContentFormatter formatter = new ContentFormatter();
    formatter.setDocumentPartitioning(IDocument.DEFAULT_CONTENT_TYPE);
    IFormattingStrategy formattingStrategy = new XMLFormattingStrategy();
    formatter.setFormattingStrategy(formattingStrategy, IDocument.DEFAULT_CONTENT_TYPE);
    formatter.enablePartitionAwareFormatting(false);
    return formatter;
}
Also used : IFormattingStrategy(org.eclipse.jface.text.formatter.IFormattingStrategy) IContentFormatter(org.eclipse.jface.text.formatter.IContentFormatter) ContentFormatter(org.eclipse.jface.text.formatter.ContentFormatter)

Example 20 with IContentFormatter

use of org.eclipse.jface.text.formatter.IContentFormatter in project dbeaver by serge-rider.

the class JSONSourceViewerConfiguration method getContentFormatter.

@Override
public IContentFormatter getContentFormatter(ISourceViewer sourceViewer) {
    ContentFormatter formatter = new ContentFormatter();
    formatter.setDocumentPartitioning(IDocument.DEFAULT_CONTENT_TYPE);
    IFormattingStrategy formattingStrategy = new JSONFormattingStrategy(sourceViewer, this);
    formatter.setFormattingStrategy(formattingStrategy, IDocument.DEFAULT_CONTENT_TYPE);
    formatter.enablePartitionAwareFormatting(false);
    return formatter;
}
Also used : IFormattingStrategy(org.eclipse.jface.text.formatter.IFormattingStrategy) IContentFormatter(org.eclipse.jface.text.formatter.IContentFormatter) ContentFormatter(org.eclipse.jface.text.formatter.ContentFormatter)

Aggregations

IContentFormatter (org.eclipse.jface.text.formatter.IContentFormatter)20 ContentFormatter (org.eclipse.jface.text.formatter.ContentFormatter)9 IFormattingStrategy (org.eclipse.jface.text.formatter.IFormattingStrategy)5 MultiPassContentFormatter (org.eclipse.jface.text.formatter.MultiPassContentFormatter)5 StructuredFormattingStrategy (org.eclipse.wst.sse.ui.internal.format.StructuredFormattingStrategy)3 XMLFormattingStrategy (com.amalto.workbench.widgets.xmlviewer.format.XMLFormattingStrategy)1 SqlFormattingStrategy (com.cubrid.common.ui.query.format.SqlFormattingStrategy)1 IDocument (org.eclipse.jface.text.IDocument)1 IDocumentExtension3 (org.eclipse.jface.text.IDocumentExtension3)1 IDocumentPartitioner (org.eclipse.jface.text.IDocumentPartitioner)1 FormattingStrategyJSPJava (org.eclipse.jst.jsp.ui.internal.format.FormattingStrategyJSPJava)1 StructuredFormattingStrategyJSP (org.eclipse.jst.jsp.ui.internal.format.StructuredFormattingStrategyJSP)1 FormatProcessorCSS (org.eclipse.wst.css.core.internal.format.FormatProcessorCSS)1 HTMLFormatProcessorImpl (org.eclipse.wst.html.core.internal.format.HTMLFormatProcessorImpl)1 FormatProcessorJSON (org.eclipse.wst.json.core.format.FormatProcessorJSON)1 StructuredTextPartitioner (org.eclipse.wst.sse.core.internal.text.rules.StructuredTextPartitioner)1 XMLFormattingStrategy (org.eclipse.wst.xml.ui.internal.XMLFormattingStrategy)1