|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.mucommander.ui.theme.ThemeManager
public class ThemeManager
Offers methods for accessing and modifying themes.
| Method Summary | |
|---|---|
static void |
addCurrentThemeListener(ThemeListener listener)
Adds the specified object to the list of registered current theme listeners. |
static java.util.Iterator |
availableThemeNames()
|
static java.util.Iterator |
availableThemes()
|
static void |
deleteCustomTheme(java.lang.String name)
|
static Theme |
duplicateTheme(Theme theme)
|
static void |
exportTheme(int type,
java.lang.String name,
java.io.File file)
Exports the specified theme to the specified output stream. |
static void |
exportTheme(int type,
java.lang.String name,
java.io.OutputStream out)
Exports the specified theme to the specified output stream. |
static void |
exportTheme(Theme theme,
java.io.File file)
Exports the specified theme to the specified output stream. |
static void |
exportTheme(Theme theme,
java.io.OutputStream out)
Exports the specified theme to the specified output stream. |
static java.util.Vector |
getAvailableThemeNames()
|
static java.util.Vector |
getAvailableThemes()
|
static java.awt.Color |
getCurrentColor(int id)
|
static java.awt.Font |
getCurrentFont(int id)
|
static Theme |
getCurrentTheme()
|
static AbstractFile |
getCustomThemesFolder()
Returns the path to the custom themes' folder. |
static AbstractFile |
getUserThemeFile()
Returns the path to the user's theme file. |
static Theme |
importTheme(java.io.File file)
|
static Theme |
importTheme(ThemeData data,
java.lang.String name)
|
static boolean |
isCurrentTheme(Theme theme)
Returns true if the specified theme is the current one. |
static void |
loadCurrentTheme()
Loads the current theme. |
static Theme |
overwriteUserTheme(ThemeData themeData)
|
static Theme |
readTheme(int type,
java.lang.String name)
Returns the requested theme. |
static ThemeData |
readThemeData(java.io.File file)
Reads theme data from the specified file. |
static ThemeData |
readThemeData(java.io.InputStream in)
Reads theme data from the specified input stream. |
static void |
removeCurrentThemeListener(ThemeListener listener)
Removes the specified object from the list of registered theme listeners. |
static boolean |
renameCustomTheme(Theme theme,
java.lang.String name)
|
static void |
saveCurrentTheme()
Saves the current theme if necessary. |
static boolean |
setCurrentColor(int id,
java.awt.Color color)
Updates the current theme with the specified color. |
static boolean |
setCurrentFont(int id,
java.awt.Font font)
Updates the current theme with the specified font. |
static void |
setCurrentTheme(Theme theme)
Changes the current theme. |
static void |
setUserThemeFile(AbstractFile file)
Sets the path to the user theme file. |
static void |
setUserThemeFile(java.io.File file)
Sets the path to the user theme file. |
static void |
setUserThemeFile(java.lang.String path)
Sets the path to the user theme file. |
static boolean |
willOverwriteUserTheme(int colorId,
java.awt.Color color)
Checks whether setting the specified color would require overwriting of the user theme. |
static boolean |
willOverwriteUserTheme(int fontId,
java.awt.Font font)
Checks whether setting the specified font would require overwriting of the user theme. |
static void |
writeTheme(Theme theme)
Writes the content of the specified theme to its description file. |
static void |
writeTheme(ThemeData data,
int type,
java.lang.String name)
Writes the specified theme data over the theme described by type and name. |
static void |
writeThemeData(ThemeData data,
java.io.File file)
Writes the content of the specified theme data to the specified file. |
static void |
writeThemeData(ThemeData data,
java.io.OutputStream out)
Writes the content of the specified theme data to the specified output stream. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static void loadCurrentTheme()
This method goes through the following steps:
public static java.util.Vector getAvailableThemes()
public static java.util.Vector getAvailableThemeNames()
public static java.util.Iterator availableThemeNames()
public static java.util.Iterator availableThemes()
public static AbstractFile getUserThemeFile()
throws java.io.IOException
This method cannot guarantee the file's existence, and it's up to the caller to deal with the fact that the user might not actually have created a user theme.
This method's return value can be modified through setUserThemeFile(String).
If this wasn't called, the default path will be used. This is generated by calling
new java.io.File(.
PlatformManager.getPreferencesFolder(), USER_THEME_FILE_NAME)
java.io.IOException - if an error occured while locating the default user theme file.setUserThemeFile(String)
public static void setUserThemeFile(java.io.File file)
throws java.io.FileNotFoundException
The specified file does not have to exist. If it does, however, it must be accessible.
file - path to the user theme file.
java.io.FileNotFoundException - if file is not accessible.getUserThemeFile()
public static void setUserThemeFile(AbstractFile file)
throws java.io.FileNotFoundException
The specified file does not have to exist. If it does, however, it must be accessible.
file - path to the user theme file.
java.lang.IllegalArgumentException - if file exists but is not accessible.
java.io.FileNotFoundExceptiongetUserThemeFile()
public static void setUserThemeFile(java.lang.String path)
throws java.io.FileNotFoundException
The specified file does not have to exist. If it does, however, it must be accessible.
path - path to the user theme file.
java.io.FileNotFoundException - if path is not accessible.getUserThemeFile()
public static AbstractFile getCustomThemesFolder()
throws java.io.IOException
This method guarantees that the returned file actually exists.
java.io.IOException - if an error occured while locating the default user themes folder.
public static void deleteCustomTheme(java.lang.String name)
throws java.io.IOException
java.io.IOException
public static boolean renameCustomTheme(Theme theme,
java.lang.String name)
throws java.io.IOException
java.io.IOException
public static void writeThemeData(ThemeData data,
java.io.OutputStream out)
throws java.io.IOException
This method differs from exportTheme(Theme,OutputStream) in that it will
write the theme data only, skipping comments and other metadata.
data - theme data to write.out - where to write the theme data.
java.io.IOException - if an I/O related error occurs.exportTheme(Theme,OutputStream),
exportTheme(Theme,File),
writeThemeData(ThemeData,File).
public static void writeThemeData(ThemeData data,
java.io.File file)
throws java.io.IOException
This method differs from exportTheme(Theme,File) in that it will
write the theme data only, skipping comments and other metadata.
data - theme data to write.file - file in which to write the theme data.
java.io.IOException - if an I/O related error occurs.exportTheme(Theme,OutputStream),
exportTheme(Theme,File),
writeThemeData(ThemeData,OutputStream).
public static void writeTheme(Theme theme)
throws java.io.IOException
theme - theme to write.
java.io.IOException - if any I/O related error occurs.
java.lang.IllegalArgumentException - if theme is a predefined theme.writeTheme(ThemeData,int,String)
public static void writeTheme(ThemeData data,
int type,
java.lang.String name)
throws java.io.IOException
type and name.
Note that this method doesn't check whether this will overwrite an existing theme.
If type equals Theme.USER_THEME, name will be ignored.
data - data to write.type - type of the theme that is being written.name - name of the theme that is being written.
java.io.IOException - if any I/O related error occurs.
java.lang.IllegalArgumentException - if theme is a predefined theme.writeTheme(Theme)
public static void exportTheme(int type,
java.lang.String name,
java.io.OutputStream out)
throws java.io.IOException
If type is equal to Theme.USER_THEME, the name argument will be ignored
as there is only one user theme.
This method differs from writeThemeData(ThemeData,OutputStream) in that it doesn't only copy
the theme's data, but the whole content of the theme file, including comments. It also requires the theme
file to exist.
type - type of the theme to export.name - name of the theme to export.out - where to write the theme.
java.io.IOException - if any I/O related error occurs.exportTheme(int,String,File),
writeThemeData(ThemeData,OutputStream)
public static void exportTheme(int type,
java.lang.String name,
java.io.File file)
throws java.io.IOException
If type is equal to Theme.USER_THEME, the name argument will be ignored
as there is only one user theme.
This method differs from writeThemeData(ThemeData,File) in that it doesn't only copy
the theme's data, but the whole content of the theme file, including comments.
type - type of the theme to export.name - name of the theme to export.file - where to write the theme.
java.io.IOException - if any I/O related error occursexportTheme(int,String,OutputStream),
writeThemeData(ThemeData,File).
public static void exportTheme(Theme theme,
java.io.OutputStream out)
throws java.io.IOException
This is a convenience method only and is strictly equivalent to calling
exportTheme(theme.getType(), theme.getName(), out);
theme - theme to export.out - where to write the theme.
java.io.IOException - if any I/O related error occurs.
public static void exportTheme(Theme theme,
java.io.File file)
throws java.io.IOException
This is a convenience method only and is strictly equivalent to calling
exportTheme(theme.getType(), theme.getName(), file);
theme - theme to export.file - where to write the theme.
java.io.IOException - if any I/O related error occurs.
public static Theme duplicateTheme(Theme theme)
throws java.io.IOException,
java.lang.Exception
java.io.IOException
java.lang.Exception
public static Theme importTheme(ThemeData data,
java.lang.String name)
throws java.io.IOException,
java.lang.Exception
java.io.IOException
java.lang.Exception
public static Theme importTheme(java.io.File file)
throws java.io.IOException,
java.lang.Exception
java.io.IOException
java.lang.Exception
public static Theme readTheme(int type,
java.lang.String name)
throws java.lang.Exception
type - type of theme to retrieve.name - name of the theme to retrieve.
java.lang.Exception
public static ThemeData readThemeData(java.io.InputStream in)
throws java.lang.Exception
in - where to read the theme data from.
java.lang.Exception - if an I/O or syntax error occurs.
public static ThemeData readThemeData(java.io.File file)
throws java.lang.Exception
file - where to read the theme data from.
java.lang.Exception - if an I/O or syntax error occurs.
public static void saveCurrentTheme()
throws java.io.IOException
java.io.IOExceptionpublic static Theme getCurrentTheme()
public static void setCurrentTheme(Theme theme)
This method will change the current theme and trigger all the proper events.
theme - theme to use as the current theme.
java.lang.IllegalArgumentException - thrown if the specified theme could not be loaded.public static java.awt.Font getCurrentFont(int id)
public static java.awt.Color getCurrentColor(int id)
public static Theme overwriteUserTheme(ThemeData themeData)
throws java.io.IOException
java.io.IOException
public static boolean willOverwriteUserTheme(int fontId,
java.awt.Font font)
fontId - identifier of the font to set.font - value for the specified font.
true if applying the specified font will overwrite the user theme,
false otherwise.
public static boolean willOverwriteUserTheme(int colorId,
java.awt.Color color)
colorId - identifier of the color to set.color - value for the specified color.
true if applying the specified color will overwrite the user theme,
false otherwise.
public static boolean setCurrentFont(int id,
java.awt.Font font)
This method might require to overwrite the user theme: custom and predefined themes are
read only. In order to modify them, the ThemeManager must overwrite the user theme with
the current theme and then set the font.
If necessary, this can be checked beforehand by a call to willOverwriteUserTheme(int,Font).
id - identifier of the font to set.font - font to set.
public static boolean setCurrentColor(int id,
java.awt.Color color)
This method might require to overwrite the user theme: custom and predefined themes are
read only. In order to modify them, the ThemeManager must overwrite the user theme with
the current theme and then set the color.
If necessary, this can be checked beforehand by a call to willOverwriteUserTheme(int,Color).
id - identifier of the color to set.color - color to set.public static boolean isCurrentTheme(Theme theme)
true if the specified theme is the current one.
theme - theme to check.
true if the specified theme is the current one, false otherwise.public static void addCurrentThemeListener(ThemeListener listener)
Any object registered through this method will received color
and font events whenever the current theme changes.
Note that these events will not necessarily be fired as a result of a direct theme change: if, for example, the current theme is using look&feel dependant values and the current look&feel changes, the corresponding events will be passed to registered listeners.
Listeners are stored as weak references, to make sure that the API doesn't keep ghost copies of objects whose usefulness is long since past. This forces callers to make sure they keep a copy of the listener's instance: if they do not, the instance will be weakly linked and garbage collected out of existence.
listener - new current theme listener.public static void removeCurrentThemeListener(ThemeListener listener)
Note that since listeners are stored as weak references, calling this method is not strictly necessary. As soon as a listener instance is not referenced anymore, it will automatically be caught and destroyed by the garbage collector.
listener - current theme listener to remove.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
This file is part of muCommander - Copyright (C) 2002-2008 Maxence Bernard