Markus
Markus

Reputation: 1482

Eclipse RCP: Get notified when IWorkbenchPreferencePage is left

I have implemented two custom IWorkbenchPreferencePage's and they are working as expected. Basically Page1 shows different information based on the selections made in Page2. The problem is that I have to close (explicitly save) the preference dialog to see the changes of Page2 reflect in Page1.

Now I was wondering if there is some kind of mechanism that would allow me to do something (In my case save information on the open preference page) once a IWorkbenchPreferencePage gets left.

Upvotes: 0

Views: 40

Answers (1)

greg-449
greg-449

Reputation: 111216

You can override the okToLeave method which is called when a different page is selected.

The default implementation of this in PreferencePage is:

@Override
public boolean okToLeave() {
    return isValid();
}

You can also use the

public void setVisible(boolean visible)

method which is called when the page is made visible and when it is hidden (be sure to call super.setVisible in your override).

Upvotes: 1

Related Questions