Open GoogleCodeExporter opened 8 years ago
This can happen when the iDocIt! ConfigurationChange event
(IConfigurationChangeListener) is fired and a listening PreferencePage is
already disposed and can not be updated by the event.
Maybe the following code snippet helps to improve the listener management.
/**
* Useful code snippets: how to hook the preference page change event.
* @author Dirk Meier-Eickhoff
*/
public class GetPreferencePageChangeEvent
{
private IPageChangedListener pageChangedListener;
public void init() {
initAllListener();
addAllListener();
}
private void initAllListener()
{
pageChangedListener = new IPageChangedListener() {
@Override
public void pageChanged(PageChangedEvent event)
{
if (event.getSelectedPage() != null
&& event.getSelectedPage() instanceof ThematicGridPreferencePage)
{
// refresh dialog content on open
setSelection(getSelection());
}
}
};
}
private WorkbenchPreferenceDialog getWorkbenchPreferenceDialog()
{
// there can be only one WorkbenchPreferenceDialog within Eclipse, so I will get
// the existing one
return WorkbenchPreferenceDialog.createDialogOn(null, null);
// alternative if you are within the PreferencePages, but maybe not stable:
// return (WorkbenchPreferenceDialog) getShell().getData();
}
private void addAllListener()
{
getWorkbenchPreferenceDialog().addPageChangedListener(this.pageChangedListener);
}
private void removeAllListener()
{
getWorkbenchPreferenceDialog()
.removePageChangedListener(this.pageChangedListener);
}
}
Original comment by dirk.mei...@gmail.com
on 23 Nov 2012 at 8:33
Original issue reported on code.google.com by
krauseda...@web.de
on 23 Nov 2012 at 8:09Attachments: