org.eclipse.jface.text.formatter

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » IDE Eclipse » jface » org.eclipse.jface.text.formatter 
org.eclipse.jface.text.formatter
Package-level Javadoc Provides a content formatter add-on for an ITextViewer. A content formatter changes the formatting of a document region while preserving and correctly updating the positions of the document.

Package Specification

IContentFormatter defines the concept of a text formatter. It collaborates with content type specific formatting stratgies (IFormattingStrategy) which for a given document region format the subregion with the matching content type. The package contains a default implementation of IContentFormatter (ContentFormatter).
Additionally, an implementation of IContentFormatterExtension is provided for text edit based formatting strategies. This implementation only accepts formatting strategies implementing the extension interface IFormattingStrategyExtension. These formatting strategies are required to handle the position updating of the document. To facilitate the work with these text edit based formatting strategies, a default implementation called ContextBasedFormattingStrategy is provided. Formatting strategies inheriting from this class are text edit based and behave context dependent. Depending on the formatting context that is passed to the content formatter, different preferences and modes can be used to format different parts of a document.

To set up a proper working text edit based content formatter, the following steps are needed:

  • Create an instance of IFormattingContext. The default implementation FormattingContext already provides support for the conversion of preferences from a preference store to a map and vice versa. The method getPreferenceKeys usually has to be overridden to return the appropriate keys of the preferences used during the formatting process. Then register a map of preferences with the formatting context by calling setProperty(String, Object) with the property identifier FormattingContextProperties.CONTEXT_PREFERENCES.
  • Create an instance of the text edit based content formatter class MultiPassContentFormatter. The document partitioning and its associated default content type have to be passed to the constructor. This information is needed since the content formatter is able to format documents according to arbitrary partitionings and default content types.
  • Register the formatting strategies for the content types that have to be formatted. If a formatting strategy is registered as master strategy, it is automatically associated with the default content type of the specified partitioning. If the formatting strategy is registered as slave strategy, it is associated with the indicated content type during the registration. Note that the master strategy can also be registered as a slave strategy for a content type other than the default content type.
  • Specify the proper formatting mode (see FormattingContextProperties):
    • For whole document formatting set the property CONTEXT_DOCUMENT of the created formatting context to true. This is equivalent to setting CONTEXT_REGION with a region spanning the whole document.
    • For multiple region formatting set the property CONTEXT_REGION of the formatting context. Note that the content formatter automatically aligns the offset of a region to a line start for the master formatting strategy, it also completes eventual partitions covered only partially by the region for the slave formatting strategies.
    • For explicit formatting of a partition with the formatting strategy registered for a certain content type use the property CONTEXT_PARTITION. Note that the region denoted by this property must correspond to a partition relative to the specified partitioning in the document to be formatted. The content type of this property overrides the content type of the partition in the document.
  • Call the method MultiPassContentFormatter#format(IDocument, IFormattingContext) with the created formatting context and the document to be formatted.

Java Source File NameTypeComment
ContentFormatter.javaClass Standard implementation of IContentFormatter. The formatter supports two operation modes: partition aware and partition unaware.
ContextBasedFormattingStrategy.javaClass Formatting strategy for context based content formatting.
FormattingContext.javaClass Default implementation of IFormattingContext.
FormattingContextProperties.javaClass Keys used by IFormattingContext objects to register specific properties needed during the formatting process of a content formatter implementing IContentFormatterExtension.
IContentFormatter.javaInterface The interface of a document content formatter.
IContentFormatterExtension.javaInterface Extension interface for IContentFormatter .

Updates the content formatter to be able to pass IFormattingContext context objects to IFormattingStrategyExtension objects operating in context based mode.

Clients using context based formatting call the method format(IDocument, IFormattingContext) with a properly initialized formatting context.
The formatting context must be set up according to the desired formatting mode:

Depending on the registered formatting strategies, more context information must be passed in the formatting context, like e.g.
IFormattingContext.javaInterface Formatting context used in formatting strategies implementing interface IFormattingStrategyExtension.
IFormattingStrategy.javaInterface A formatting strategy is assumed to be specialized on formatting text of a particular content type.
IFormattingStrategyExtension.javaInterface Extension interface for IFormattingStrategy.

Updates formatting strategies to be able to receive a more general IFormattingContext object from its associated content formatters.

Each formatting process calls the strategy's methods in the following sequence:

  • formatterStarts
  • format
  • formatterStops

Note that multiple calls to formatterStarts can be issued to a strategy before launching the formatting process with format.

This interface must be implemented by clients.

MultiPassContentFormatter.javaClass Content formatter for edit-based formatting strategies.

Two kinds of formatting strategies can be registered with this formatter:

  • one master formatting strategy for the default content type
  • one formatting strategy for each non-default content type
The master formatting strategy always formats the whole region to be formatted in the first pass.
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.