Class DefaultPaletteViewerPreferences
- All Implemented Interfaces:
PaletteViewerPreferences
It is recommended that the default constructor be used (which will use the
preference store in the GEF plugin) as that will cause the preferences to be
shared across different types of editors. If the client does not wish to
share one of the existing preferences for their editor (say the auto-collapse
setting), they will have to sub-class this class and override the necessary
methods (in this case, getAutoCollapseSetting()
and
setAutoCollapseSetting(int)
) and save that preference in some other
preference store. Sub-classes can add newer preferences to the store by using
getPreferenceStore()
.
-
Field Summary
Fields inherited from interface org.eclipse.gef.ui.palette.PaletteViewerPreferences
COLLAPSE_ALWAYS, COLLAPSE_AS_NEEDED, COLLAPSE_NEVER, LAYOUT_COLUMNS, LAYOUT_DETAILS, LAYOUT_FOLDER, LAYOUT_ICONS, LAYOUT_LIST, PREFERENCE_AUTO_COLLAPSE, PREFERENCE_COLUMNS_ICON_SIZE, PREFERENCE_DETAILS_ICON_SIZE, PREFERENCE_FOLDER_ICON_SIZE, PREFERENCE_FONT, PREFERENCE_ICONS_ICON_SIZE, PREFERENCE_LAYOUT, PREFERENCE_LIST_ICON_SIZE
-
Constructor Summary
ConstructorsConstructorDescriptionDefault ConstructorConstructor -
Method Summary
Modifier and TypeMethodDescriptionvoid
NOTE: TheoldValue
field of thePropertyChangeEvent
used to notify listeners will always benull
.static String
convertLayoutToPreferenceName
(int layout) This is a convenience method that converts the given layout mode to the matching preference name.static int
convertPreferenceNameToLayout
(String preference) This convenience method converts the given preference to the matching layout mode.protected void
firePropertyChanged
(String property, Object newVal) The oldValue of the PropertyChangeEvent that is fired will always benull
.int
Returns the current auto-collapse setting.int
Returns the current layout setting.protected IPreferenceStore
int[]
Returns the layout modes that are supported.protected void
handlePreferenceStorePropertyChanged
(String property) This method is invoked when the preference store fires a property change.boolean
isSupportedLayoutMode
(int layout) This is a convenience method.void
void
setAutoCollapseSetting
(int newVal) Sets the auto-collapse setting.void
setCurrentUseLargeIcons
(boolean newVal) Sets the "Use Large Icons" option for the currently active layout.void
setFontData
(FontData data) Sets the FontData for the palette.void
setLayoutSetting
(int newVal) Sets the given setting as the current layout.void
setSupportedLayoutModes
(int[] modes) NOTE: Restricting the layout modes here does not in any way restrict those values from being stored in the preference store.void
setUseLargeIcons
(int layout, boolean newVal) Sets the "Use Large Icons" option for the given layout.boolean
boolean
useLargeIcons
(int layout) Indicated whether large icons should be used with the given layout mode.
-
Constructor Details
-
DefaultPaletteViewerPreferences
public DefaultPaletteViewerPreferences()Default ConstructorUses the GEF Plugin's IPreferenceStore to store the preferences.
-
DefaultPaletteViewerPreferences
Constructor- Parameters:
store
- The IPreferenceStore where the settings are to be saved.
-
-
Method Details
-
addPropertyChangeListener
NOTE: TheoldValue
field of thePropertyChangeEvent
used to notify listeners will always benull
.- Specified by:
addPropertyChangeListener
in interfacePaletteViewerPreferences
- Parameters:
listener
- the PropertyChangeListener to be notified of changes- See Also:
-
convertLayoutToPreferenceName
This is a convenience method that converts the given layout mode to the matching preference name.- int <-> String
- LAYOUT_LIST <-> PREFERENCE_LIST_ICON_SIZE
- LAYOUT_COLUMNS <-> PREFERENCE_COLUMNS_ICON_SIZE
- LAYOUT_ICONS <-> PREFERENCE_ICONS_ICON_SIZE
- LAYOUT_DETAILS <-> PREFERENCE_DETAILS_ICON_SIZE
- Parameters:
layout
- LAYOUT_LIST, LAYOUT_DETAILS, LAYOUT_COLUMNS, or LAYOUT_ICONS- Returns:
- The corresponding preference String
-
convertPreferenceNameToLayout
This convenience method converts the given preference to the matching layout mode.- int <-> String
- LAYOUT_LIST <-> PREFERENCE_LIST_ICON_SIZE
- LAYOUT_COLUMNS <-> PREFERENCE_COLUMNS_ICON_SIZE
- LAYOUT_ICONS <-> PREFERENCE_ICONS_ICON_SIZE
- LAYOUT_DETAILS <-> PREFERENCE_DETAILS_ICON_SIZE
- Parameters:
preference
- PREFERENCE_DETAILS_ICON_SIZE, PREFERENCE_COLUMNS_ICON_SIZE, PREFERENCE_ICONS_ICON_SIZE or PREFERENCE_LIST_ICON_SIZE- Returns:
- The corresponding layout code
-
firePropertyChanged
The oldValue of the PropertyChangeEvent that is fired will always benull
.- Parameters:
property
- The programmatic name of the property that was changednewVal
- The new value of the property- See Also:
-
getAutoCollapseSetting
public int getAutoCollapseSetting()Description copied from interface:PaletteViewerPreferences
Returns the current auto-collapse setting.Possible values returned:
- COLLAPSE_ALWAYS (Always collapse)
- COLLAPSE_AS_NEEDED (Collapse when needed)
- COLLAPSE_NEVER (Never collapse)
- Specified by:
getAutoCollapseSetting
in interfacePaletteViewerPreferences
- Returns:
- One of the above-mentioned constants
- See Also:
-
getFontData
- Specified by:
getFontData
in interfacePaletteViewerPreferences
- Returns:
- The FontData for the font to be used in the palette.
- See Also:
-
getLayoutSetting
public int getLayoutSetting()Description copied from interface:PaletteViewerPreferences
Returns the current layout setting.Possible values returned:
- LAYOUT_COLUMNS (columns View)
- LAYOUT_LIST (List View)
- LAYOUT_ICONS (Icons Only View)
- LAYOUT_DETAILS (Details View)
- Specified by:
getLayoutSetting
in interfacePaletteViewerPreferences
- Returns:
- One of the above-mentioned constants
- See Also:
-
getSupportedLayoutModes
public int[] getSupportedLayoutModes()Description copied from interface:PaletteViewerPreferences
Returns the layout modes that are supported. All four layout modes -- LAYOUT_COLUMNS, LAYOUT_LIST, LAYOUT_ICONS, LAYOUT_DETAILS -- are supported by default.- Specified by:
getSupportedLayoutModes
in interfacePaletteViewerPreferences
- Returns:
- The layout modes that are supported
- See Also:
-
handlePreferenceStorePropertyChanged
This method is invoked when the preference store fires a property change.- Parameters:
property
- The property String used for the change fired by the preference store
-
getPreferenceStore
- Returns:
- The IPreferenceStore used by this class to store the preferences.
-
isSupportedLayoutMode
public boolean isSupportedLayoutMode(int layout) Description copied from interface:PaletteViewerPreferences
This is a convenience method. Instead of getting the supported layout modes and checking to see if a certain layout is supported, you can call this method.- Specified by:
isSupportedLayoutMode
in interfacePaletteViewerPreferences
- Parameters:
layout
- LAYOUT_COLUMNS, LAYOUT_LIST, LAYOUT_ICONS, or LAYOUT_DETAILS- Returns:
true
if the given layout is a supported mode- See Also:
-
removePropertyChangeListener
- Specified by:
removePropertyChangeListener
in interfacePaletteViewerPreferences
- Parameters:
listener
- the PropertyChangeListener that should not be notified hereafter- See Also:
-
setAutoCollapseSetting
public void setAutoCollapseSetting(int newVal) Description copied from interface:PaletteViewerPreferences
Sets the auto-collapse setting.Possible values:
- COLLAPSE_ALWAYS (Always collapse)
- COLLAPSE_AS_NEEDED (Collapse when needed)
- COLLAPSE_NEVER (Never collapse)
- Specified by:
setAutoCollapseSetting
in interfacePaletteViewerPreferences
- Parameters:
newVal
- One of the above-mentioned constants- See Also:
-
setFontData
Description copied from interface:PaletteViewerPreferences
Sets the FontData for the palette.- Specified by:
setFontData
in interfacePaletteViewerPreferences
- Parameters:
data
- The FontData for the font to be used in the palette- See Also:
-
setLayoutSetting
public void setLayoutSetting(int newVal) Description copied from interface:PaletteViewerPreferences
Sets the given setting as the current layout.Possible values:
- LAYOUT_COLUMNS (Columns View)
- LAYOUT_LIST (List View)
- LAYOUT_ICONS (Icons Only View)
- LAYOUT_DETAILS (Details View)
- Specified by:
setLayoutSetting
in interfacePaletteViewerPreferences
- Parameters:
newVal
- One of the above-mentioned constants- See Also:
-
setCurrentUseLargeIcons
public void setCurrentUseLargeIcons(boolean newVal) Description copied from interface:PaletteViewerPreferences
Sets the "Use Large Icons" option for the currently active layout.- Specified by:
setCurrentUseLargeIcons
in interfacePaletteViewerPreferences
- Parameters:
newVal
-true
if large icons are to be used with the current layout setting- See Also:
-
setSupportedLayoutModes
public void setSupportedLayoutModes(int[] modes) NOTE: Restricting the layout modes here does not in any way restrict those values from being stored in the preference store. Instead, it is the responsibility of all clients manipulating the layout settings to check to see if a particular layout mode is supported before manipulating it, or allowing the end user to manipulate it.- Specified by:
setSupportedLayoutModes
in interfacePaletteViewerPreferences
- Parameters:
modes
- an array of layout modes desired- See Also:
-
setUseLargeIcons
public void setUseLargeIcons(int layout, boolean newVal) Description copied from interface:PaletteViewerPreferences
Sets the "Use Large Icons" option for the given layout.
The defaults are as follows:- LAYOUT_COLUMNS -
true
- LAYOUT_LIST -
false
- LAYOUT_ICONS -
true
- LAYOUT_DETAILS -
false
- Specified by:
setUseLargeIcons
in interfacePaletteViewerPreferences
- Parameters:
layout
- any of the above-mentioned constantsnewVal
-true
if large icons are to be used with the given layout- See Also:
- LAYOUT_COLUMNS -
-
useLargeIcons
public boolean useLargeIcons(int layout) Description copied from interface:PaletteViewerPreferences
Indicated whether large icons should be used with the given layout mode.
The defaults are as follows:- LAYOUT_COLUMNS -
true
- LAYOUT_LIST -
false
- LAYOUT_ICONS -
true
- LAYOUT_DETAILS -
false
- Specified by:
useLargeIcons
in interfacePaletteViewerPreferences
- Parameters:
layout
- any of the above-mentioned constants- Returns:
true
if large icons are to be used with the given layout- See Also:
- LAYOUT_COLUMNS -
-
useLargeIcons
public boolean useLargeIcons()- Specified by:
useLargeIcons
in interfacePaletteViewerPreferences
- Returns:
true
if large icons are to be used with the currently active layout- See Also:
-