import org.eclipse.swt.widgets.TypedListener;
import org.eclipse.swt.widgets.Widget;
import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.forms.events.ExpansionEvent;
+import org.eclipse.ui.forms.events.IExpansionListener;
import org.eclipse.ui.forms.widgets.Section;
import org.eclipse.ui.forms.widgets.TableWrapLayout;
import org.eclipse.ui.forms.widgets.ToggleHyperlink;
import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap;
import eu.etaxonomy.taxeditor.model.AbstractUtility;
import eu.etaxonomy.taxeditor.model.MessagingUtils;
+import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
/**
* <p>
*/
public void setEntity(ENTITY entity) {
this.entity = entity;
+ addExpandListener();
}
/*
}
/** {@inheritDoc} */
-
@Override
public void update(CdmDataChangeMap changeEvents) {
}
+
+ private class ExpandListener implements IExpansionListener{
+ @Override
+ public void expansionStateChanging(ExpansionEvent e) {
+ }
+ @Override
+ public void expansionStateChanged(ExpansionEvent e) {
+ PreferencesUtil.getPreferenceStore().setValue(getPrefKey(), e.getState());
+ }
+ }
+
+ /**
+ * Adds a custom implementation of IExpansionListener to this section
+ * which stores the expansion state in the preferences
+ */
+ private void addExpandListener() {
+ PreferencesUtil.getPreferenceStore().setDefault(getPrefKey(), isExpanded());
+ setExpanded(PreferencesUtil.getPreferenceStore().getBoolean(getPrefKey()));
+ addExpansionListener(new ExpandListener());
+ }
+
+ private String getPrefKey() {
+ return this.getClass().getCanonicalName()+";"+entity.getClass().getCanonicalName();
+ }
}