Difference: DpHipePreferences (4 vs. 5)

Revision 52009-06-24 - JaimeSaiz

Line: 1 to 1

HIPE Preferences

Line: 240 to 240
  would also be valid.

Change preferences

Preferences are supposed to be changed only by users, within the preferences dialog.
This is the reason why UserPreferences just provides methods for reading preferences, but not for changing them.

Now, it may be the case that you need to update preferences from some user action.
For instance, user presses Ctrl-+, so all font sizes must be increased.

This communication can be performed through events: the requester code triggers an event, which is listened and handled by the corresponding preferences panel.


We have an editor with a split panel, and want to detect any drag in the split separator by the user, so its new position is saved as a preference.

// The event class
class SplitLocationChangeEvent extends SiteEvent {
    private final int _location;

    SplitLocationChangeEvent(Object source, int location) {
        _location = location;

    int getLocation() { return _location; }

// The notifier class
public class SplittedEditor extends AbstractEditorComponent<SomeSelection> {

    // Suppose we detect changes in the split pane here
    private void splitMoved(int newLocation) {
        SiteEvent event = new SplitLocationChangeEvent(this, newLocation);

// The preferences panel
public class SomePreferencesPanel extends PreferencesPanel implements SiteEventListener {

    protected void makeContent() {
        // Fill the panel ...
        // and register to split changes
        SiteEventHandler eventHandler = SiteUtil.getSite().getEventHandler();
        eventHandler.addEventListener(SplitLocationChangeEvent.class, this);

    public void selectionChanged(SiteEvent event) {
	int location = ((SplitLocationChangeEvent)event).getLocation();
        setValue("splitLocation", location);

Listen to changes in preferences

Suppose the user opens an editor component you have developed, then open the preferences dialog, changes some preference related to the presentation of your editor, and press OK.

This site is powered by the TWiki collaboration platform Powered by Perl