Package de.sciss.app
Class AbstractApplication
- java.lang.Object
-
- de.sciss.app.AbstractApplication
-
- All Implemented Interfaces:
Application
- Direct Known Subclasses:
BasicApplication
public abstract class AbstractApplication extends java.lang.Object implements Application
A rudimentary implementation of thede.sciss.app.Applicationinterface, which deals with component registration, quitting, preference, clipboard and resource bundle generation.
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractApplication(java.lang.Class mainClass, java.lang.String name)Creates a new instance of this class.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddComponent(java.lang.Object key, java.lang.Object component)synchronization: this method is synchronizedstatic ApplicationgetApplication()Returns the current runtime's application.java.awt.datatransfer.ClipboardgetClipboard()Returns the system's clipboard, or a local clipboard if security permits to retrieve the system clipboard.java.lang.ObjectgetComponent(java.lang.Object key)synchronization: this method is synchronizedjava.lang.StringgetName()Returns the application's name.java.lang.StringgetResourceString(java.lang.String key)Returns a localized string for a given key.java.lang.StringgetResourceString(java.lang.String key, java.lang.String defaultValue)Returns a localized string for a given key.java.util.prefs.PreferencesgetSystemPrefs()Returns the applications system wide preferences.java.util.prefs.PreferencesgetUserPrefs()Returns the applications user specific preferences.voidquit()Flushes preferences and quits.voidremoveComponent(java.lang.Object key)synchronization: this method is synchronizedvoidsetName(java.lang.String name)-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface de.sciss.app.Application
getDocumentHandler, getGraphicsHandler, getVersion, getWindowHandler
-
-
-
-
Constructor Detail
-
AbstractApplication
protected AbstractApplication(java.lang.Class mainClass, java.lang.String name)Creates a new instance of this class. ThemainClasswill be used to determine the application's preference root node. Thisnamewill be used to set the application's name and to load aResourceBundlewith localized text strings. The resource bundle must be stored in a file"<name>Strings.properties", e.g. ifnameequals"FScape", the resources are retrieved from"FScapeStrings.properties"!Only one instance of this class can be created, any further attempt will result in a
RuntimeException. The one and only instance is available through the class methodgetApplication.- Parameters:
mainClass- the main class of the application whose package (e.g.de.sciss.fscape) is used to identify the preferences files.name- application name, should not contain white spaces or special characters.- See Also:
getApplication()
-
-
Method Detail
-
setName
public void setName(java.lang.String name)
-
getName
public java.lang.String getName()
Description copied from interface:ApplicationReturns the application's name.- Specified by:
getNamein interfaceApplication- Returns:
- the application's name
-
getSystemPrefs
public final java.util.prefs.Preferences getSystemPrefs()
Description copied from interface:ApplicationReturns the applications system wide preferences.- Specified by:
getSystemPrefsin interfaceApplication- Returns:
- the root node of the application's global preferences
- See Also:
Preferences.systemNodeForPackage( Class )
-
getUserPrefs
public final java.util.prefs.Preferences getUserPrefs()
Description copied from interface:ApplicationReturns the applications user specific preferences.- Specified by:
getUserPrefsin interfaceApplication- Returns:
- the root node of the application's preferences from the current user's local folder
- See Also:
Preferences.userNodeForPackage( Class )
-
getClipboard
public final java.awt.datatransfer.Clipboard getClipboard()
Returns the system's clipboard, or a local clipboard if security permits to retrieve the system clipboard.- Specified by:
getClipboardin interfaceApplication- Returns:
- the clipboard used by the application
- See Also:
Toolkit.getSystemClipboard()
-
getComponent
public final java.lang.Object getComponent(java.lang.Object key)
synchronization: this method is synchronized- Specified by:
getComponentin interfaceApplication- Parameters:
key- agreed upon idenfier for the component, e.g. a string or class- Returns:
- the requested component or
nullif absent or unknown
-
addComponent
public final void addComponent(java.lang.Object key, java.lang.Object component)synchronization: this method is synchronized- Specified by:
addComponentin interfaceApplication- Parameters:
key- agreed upon idenfier for the component, e.g. a string or classcomponent- the component to be registered
-
removeComponent
public final void removeComponent(java.lang.Object key)
synchronization: this method is synchronized- Specified by:
removeComponentin interfaceApplication- Parameters:
key- agreed upon idenfier for the component to be removed, e.g. a string or class
-
getResourceString
public final java.lang.String getResourceString(java.lang.String key)
Description copied from interface:ApplicationReturns a localized string for a given key. If the key is not found, returns a warning text and the key name.- Specified by:
getResourceStringin interfaceApplication- Parameters:
key- a key into the application's main string recource file- Returns:
- the localized text
- See Also:
ResourceBundle.getString( String )
-
getResourceString
public final java.lang.String getResourceString(java.lang.String key, java.lang.String defaultValue)Description copied from interface:ApplicationReturns a localized string for a given key. If the key is not found, returns the given default string.- Specified by:
getResourceStringin interfaceApplication- Parameters:
key- a key into the application's main string recource filedefaultValue- the text to return if the key is not in the dictionary- Returns:
- the localized text
- See Also:
ResourceBundle.getString( String )
-
quit
public void quit()
Flushes preferences and quits.- Specified by:
quitin interfaceApplication
-
getApplication
public static Application getApplication()
Returns the current runtime's application. Since this is a class method, it can be used by static classes such IO or GUI utilities to retrieve the application and its preferences or resource bundle.- Returns:
- the active
Applicationornullif no application has been created.
-
-