org.netbeans.modules.editor.indent/2 1.28

org.netbeans.modules.editor.indent.spi
Class CodeStylePreferences

java.lang.Object
  extended by org.netbeans.modules.editor.indent.spi.CodeStylePreferences

public final class CodeStylePreferences
extends Object

Provides access to formatting settings for a document or file. The formatting settings can either be stored globally in the IDE or they can be stored in a project owning the document. The settings are provided in form of a java.util.prefs.Prefernces instance.

Typical usecase: This class is typically called from an implementation of IndentTask or ReformatTask, which needs to know formatting setting in order to do its job. The implementation is given a context object with a javax.swing.text.Document instance where the formatting is taking place. The implementation should call get(javax.swing.text.Document) and getPreferences() in order to get Preferences with formatting settings.

The infrastructure will take care of providing the right Preferences instance from either MimeLookup or a project depending on the formatted document and user's choice. It is important not to cache the Preferences instance, because a different instance may be provided in the future if a user changes his mind in using global or per-project formatting settings.

Since:
1.9

Nested Class Summary
static interface CodeStylePreferences.Provider
          Code style preferences provider.
 
Method Summary
static CodeStylePreferences get(Document doc)
          Gets CodeStylePreferences for a document.
static CodeStylePreferences get(Document doc, String mimeType)
          Gets CodeStylePreferences for a document and an embedding mimeType.
static CodeStylePreferences get(FileObject file)
          Gets CodeStylePreferences for a file.
static CodeStylePreferences get(FileObject file, String mimeType)
          Gets CodeStylePreferences for a file.
 Preferences getPreferences()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

get

public static CodeStylePreferences get(Document doc)
Gets CodeStylePreferences for a document. This is the prefered method to use. Whenever you have both Document and its FileObject always use this method and provide the Document instance.

Parameters:
doc - The document to get CodeStylePreferences for, can be null. If null, the method will return global preferences for 'all languages'.
Returns:
The CodeStylePreferences, never null.

get

public static CodeStylePreferences get(Document doc,
                                       String mimeType)
Gets CodeStylePreferences for a document and an embedding mimeType. This is the prefered method to use. Whenever you have both Document and its FileObject always use this method and provide the Document instance.

Parameters:
doc - The document to get CodeStylePreferences for, can be null. If null, the method will return global preferences for 'all languages'.
Returns:
The CodeStylePreferences, never null.

get

public static CodeStylePreferences get(FileObject file)
Gets CodeStylePreferences for a file. If you also have a Document instance you should use the get(javax.swing.text.Document) method.

Parameters:
file - The file to get CodeStylePreferences for, can be null. If null, the method will return global preferences for 'all languages'.
Returns:
The CodeStylePreferences, never null.

get

public static CodeStylePreferences get(FileObject file,
                                       String mimeType)
Gets CodeStylePreferences for a file. If you also have a Document instance you should use the get(javax.swing.text.Document) method.

Parameters:
file - The file to get CodeStylePreferences for, can be null. If null, the method will return global preferences for 'all languages'.
Returns:
The CodeStylePreferences, never null.

getPreferences

public Preferences getPreferences()

org.netbeans.modules.editor.indent/2 1.28

Built on May 22 2012.  |  Portions Copyright 1997-2012 Oracle. All rights reserved.