Class DefaultPaletteViewerPreferences

  • All Implemented Interfaces:
    PaletteViewerPreferences

    public class DefaultPaletteViewerPreferences
    extends java.lang.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().

    • 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

      • convertLayoutToPreferenceName

        public static java.lang.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​(java.lang.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​(java.lang.String property,
                                           java.lang.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)
      • handlePreferenceStorePropertyChanged

        protected void handlePreferenceStorePropertyChanged​(java.lang.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.
      • 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[])
      • 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)