Eclipse GEF 3.2

## org.eclipse.gef.ui.palette
Class DefaultPaletteViewerPreferences

    java.lang.Object
      org.eclipse.gef.ui.palette.DefaultPaletteViewerPreferences

All Implemented Interfaces:
  PaletteViewerPreferences

public class DefaultPaletteViewerPreferences
extends Object
implements PaletteViewerPreferences

This is the default implementation for PaletteViewerPreferences. It uses a single IPreferenceStore to load and save the palette viewer settings.

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
`DefaultPaletteViewerPreferences()` Default Constructor Uses the GEF Plugin's IPreferenceStore to store the preferences.
`DefaultPaletteViewerPreferences(IPreferenceStore store)` Constructor

Method Summary
`void` `addPropertyChangeListener(PropertyChangeListener listener)` NOTE: The `oldValue` field of the `PropertyChangeEvent` used to notify listeners will always be `null`.
`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 be `null`.
`int` `getAutoCollapseSetting()` Returns the current auto-collapse setting.
`FontData` `getFontData()`
`int` `getLayoutSetting()` Returns the current layout setting.
`protected IPreferenceStore` `getPreferenceStore()`
`int[]` `getSupportedLayoutModes()` 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` `removePropertyChangeListener(PropertyChangeListener listener)`
`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` `useLargeIcons()`
`boolean` `useLargeIcons(int layout)` Indicated whether large icons should be used with the given layout mode.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### DefaultPaletteViewerPreferences

    public DefaultPaletteViewerPreferences()

  Default Constructor

  Uses the GEF Plugin's IPreferenceStore to store the preferences.

### DefaultPaletteViewerPreferences

    public DefaultPaletteViewerPreferences(IPreferenceStore store)

  Constructor

Parameters:
  `store` - The IPreferenceStore where the settings are to be saved.

Method Detail

### addPropertyChangeListener

    public void addPropertyChangeListener(PropertyChangeListener listener)

  NOTE: The `oldValue` field of the `PropertyChangeEvent` used to notify listeners will always be `null`.

  Specified by:
    `addPropertyChangeListener` in interface `PaletteViewerPreferences`
  Parameters:
    `listener` - the PropertyChangeListener to be notified of changes
  See Also:
    `PaletteViewerPreferences.addPropertyChangeListener( PropertyChangeListener)`

### convertLayoutToPreferenceName

    public static String convertLayoutToPreferenceName(int layout)

  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

    public static int convertPreferenceNameToLayout(String preference)

  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

    protected void firePropertyChanged(String property,
                                       Object newVal)

  The oldValue of the PropertyChangeEvent that is fired will always be `null`.

  Parameters:
    `property` - The programmatic name of the property that was changed
    `newVal` - The new value of the property
  See Also:
    `PropertyChangeSupport.firePropertyChange(java.lang.String, java.lang.Object, java.lang.Object)`

### 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 interface `PaletteViewerPreferences`
  Returns:
    One of the above-mentioned constants
  See Also:
    `PaletteViewerPreferences.getAutoCollapseSetting()`

### getFontData

    public FontData getFontData()

  Specified by:
    `getFontData` in interface `PaletteViewerPreferences`
  Returns:
    The FontData for the font to be used in the palette.
  See Also:
    `PaletteViewerPreferences.getFontData()`

### 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 interface `PaletteViewerPreferences`
  Returns:
    One of the above-mentioned constants
  See Also:
    `PaletteViewerPreferences.getLayoutSetting()`

### 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 interface `PaletteViewerPreferences`
  Returns:
    The layout modes that are supported
  See Also:
    `PaletteViewerPreferences.getSupportedLayoutModes()`

### handlePreferenceStorePropertyChanged

    protected void handlePreferenceStorePropertyChanged(String property)

  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

    protected IPreferenceStore 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 interface `PaletteViewerPreferences`
  Parameters:
    `layout` - LAYOUT_COLUMNS, LAYOUT_LIST, LAYOUT_ICONS, or LAYOUT_DETAILS
  Returns:
    `true` if the given layout is a supported mode
  See Also:
    `PaletteViewerPreferences.isSupportedLayoutMode(int)`

### removePropertyChangeListener

    public void removePropertyChangeListener(PropertyChangeListener listener)

  Specified by:
    `removePropertyChangeListener` in interface `PaletteViewerPreferences`
  Parameters:
    `listener` - the PropertyChangeListener that should not be notified hereafter
  See Also:
    `PaletteViewerPreferences.removePropertyChangeListener( PropertyChangeListener)`

### 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 interface `PaletteViewerPreferences`
  Parameters:
    `newVal` - One of the above-mentioned constants
  See Also:
    `PaletteViewerPreferences.setAutoCollapseSetting(int)`

### setFontData

    public void setFontData(FontData data)

  Description copied from interface: `PaletteViewerPreferences`
  Sets the FontData for the palette.

  Specified by:
    `setFontData` in interface `PaletteViewerPreferences`
  Parameters:
    `data` - The FontData for the font to be used in the palette
  See Also:
    `PaletteViewerPreferences.setFontData(FontData)`

### 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 interface `PaletteViewerPreferences`
  Parameters:
    `newVal` - One of the above-mentioned constants
  See Also:
    `PaletteViewerPreferences.setLayoutSetting(int)`

### 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 interface `PaletteViewerPreferences`
  Parameters:
    `newVal` - `true` if large icons are to be used with the current layout setting
  See Also:
    `PaletteViewerPreferences.setCurrentUseLargeIcons( boolean)`

### 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 interface `PaletteViewerPreferences`
  Parameters:
    `modes` - an array of layout modes desired
  See Also:
    `PaletteViewerPreferences.setSupportedLayoutModes(int[])`

### 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 interface `PaletteViewerPreferences`
  Parameters:
    `layout` - any of the above-mentioned constants
    `newVal` - `true` if large icons are to be used with the given layout
  See Also:
    `PaletteViewerPreferences.setUseLargeIcons(int, boolean)`

### 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 interface `PaletteViewerPreferences`
  Parameters:
    `layout` - any of the above-mentioned constants
  Returns:
    `true` if large icons are to be used with the given layout
  See Also:
    `PaletteViewerPreferences.useLargeIcons(int)`

### useLargeIcons

    public boolean useLargeIcons()

  Specified by:
    `useLargeIcons` in interface `PaletteViewerPreferences`
  Returns:
    `true` if large icons are to be used with the currently active layout
  See Also:
    `PaletteViewerPreferences.useLargeIcons()`

Eclipse GEF 3.2

Copyright (c) IBM Corp. and others 2000, 2006. All Rights Reserved.