|
Eclipse Platform Release 3.0 |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.eclipse.jface.text.formatter.MultiPassContentFormatter
Content formatter for edit-based formatting strategies.
Two kinds of formatting strategies can be registered with this formatter:
IFormattingStrategyExtension
.
Regions to be formatted with the master formatting strategy always have an offset aligned to the line start. Regions to be formatted with slave formatting strategies are aligned on partition boundaries.
IFormattingStrategyExtension
Nested Class Summary | |
protected class |
MultiPassContentFormatter.NonDeletingPositionUpdater
Position updater that shifts otherwise deleted positions to the next non-whitespace character. |
Constructor Summary | |
MultiPassContentFormatter(String partitioning,
String type)
Creates a new content formatter. |
Method Summary | |
void |
format(IDocument medium,
IFormattingContext context)
Formats the given region of the specified document. |
void |
format(IDocument medium,
IRegion region)
Formats the given region of the specified document.The formatter may safely assume that it is the only subject that modifies the document at this point in time. |
protected void |
formatMaster(IFormattingContext context,
IDocument document,
int offset,
int length)
Formats the document specified in the formatting context with the master formatting strategy. |
protected void |
formatSlave(IFormattingContext context,
IDocument document,
int offset,
int length,
String type)
Formats the document specified in the formatting context with the formatting strategy registered for the content type. |
protected void |
formatSlaves(IFormattingContext context,
IDocument document,
int offset,
int length)
Formats the document specified in the formatting context with the slave formatting strategies. |
IFormattingStrategy |
getFormattingStrategy(String type)
Returns the formatting strategy registered for the given content type. |
void |
setMasterStrategy(IFormattingStrategy strategy)
Registers a master formatting strategy. |
void |
setSlaveStrategy(IFormattingStrategy strategy,
String type)
Registers a slave formatting strategy for a certain content type. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public MultiPassContentFormatter(String partitioning, String type)
partitioning
- the document partitioning for this formattertype
- the default content typeMethod Detail |
public final void format(IDocument medium, IFormattingContext context)
IContentFormatterExtension
The formatter may safely assume that it is the only subject that modifies the document at this point in time. This method is fully reentrant, but not thread-safe.
The formatting process performed by format(IDocument, IFormattingContext)
happens as follows:
format
in interface IContentFormatterExtension
medium
- The document to be formattedcontext
- The formatting context to pass to the formatting strategies.
This argument must not be null
.public final void format(IDocument medium, IRegion region)
IContentFormatter
format
in interface IContentFormatter
medium
- the document to be formattedregion
- the region within the document to be formattedprotected void formatMaster(IFormattingContext context, IDocument document, int offset, int length)
The master formatting strategy covers all regions of the document. The offset of the region to be formatted is aligned on line start boundaries, whereas the end index of the region remains the same. For this formatting type the document partitioning is not taken into account.
context
- The formatting context to usedocument
- The document to operate onoffset
- The offset of the region to formatlength
- The length of the region to formatprotected void formatSlave(IFormattingContext context, IDocument document, int offset, int length, String type)
For this formatting type only slave strategies are used. The region to be formatted is aligned on partition boundaries of the underlying content type. The exact formatting strategy is determined by the underlying content type of the document partitioning.
context
- The formatting context to usedocument
- The document to operate onoffset
- The offset of the region to formatlength
- The length of the region to formattype
- The content type of the region to formatprotected void formatSlaves(IFormattingContext context, IDocument document, int offset, int length)
For each content type of the region to be formatted in the document partitioning, the registered slave formatting strategy is used to format that particular region. The region to be formatted is aligned on partition boundaries of the underlying content type. If the content type is the document's default content type, nothing happens.
context
- The formatting context to usedocument
- The document to operate onoffset
- The offset of the region to formatlength
- The length of the region to formatpublic final IFormattingStrategy getFormattingStrategy(String type)
IContentFormatter
getFormattingStrategy
in interface IContentFormatter
type
- the content type for which to look up the formatting strategy
null
if there is no such strategypublic final void setMasterStrategy(IFormattingStrategy strategy)
The strategy may already be registered with a certain content type as slave strategy. The master strategy is registered for the default content type of documents. If a master strategy has already been registered, it is overridden by the new one.
strategy
- The master formatting strategy, must implement
IFormattingStrategyExtension
public final void setSlaveStrategy(IFormattingStrategy strategy, String type)
The strategy may already be registered as master strategy. If it is already registered as slave strategy for the specified content type, nothing happens. However, the same strategy may be registered with several content types. Slave strategies cannot be registered for the default content type of documents.
strategy
- The slave formatting strategytype
- The content type to register this strategy with,
must implement IFormattingStrategyExtension
|
Eclipse Platform Release 3.0 |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Guidelines for using Eclipse APIs.
Copyright (c) IBM Corp. and others 2000, 2004. All rights reserved.