Revision ed60b90e
Added by Patrick Plitzner over 5 years ago
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/element/AbstractFormSection.java | ||
---|---|---|
26 | 26 |
import org.eclipse.swt.widgets.Display; |
27 | 27 |
import org.eclipse.swt.widgets.TypedListener; |
28 | 28 |
import org.eclipse.swt.widgets.Widget; |
29 |
import org.eclipse.ui.forms.events.ExpansionEvent; |
|
30 |
import org.eclipse.ui.forms.events.IExpansionListener; |
|
31 | 29 |
import org.eclipse.ui.forms.widgets.Section; |
32 | 30 |
import org.eclipse.ui.forms.widgets.TableWrapLayout; |
33 | 31 |
import org.eclipse.ui.forms.widgets.ToggleHyperlink; |
... | ... | |
37 | 35 |
import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap; |
38 | 36 |
import eu.etaxonomy.taxeditor.model.AbstractUtility; |
39 | 37 |
import eu.etaxonomy.taxeditor.model.MessagingUtils; |
40 |
import eu.etaxonomy.taxeditor.preference.PreferencesUtil; |
|
41 | 38 |
|
42 | 39 |
/** |
43 | 40 |
* <p> |
... | ... | |
167 | 164 |
*/ |
168 | 165 |
public void setEntity(ENTITY entity) { |
169 | 166 |
this.entity = entity; |
170 |
addExpandListener(); |
|
171 | 167 |
} |
172 | 168 |
|
173 | 169 |
/** |
... | ... | |
590 | 586 |
|
591 | 587 |
} |
592 | 588 |
|
593 |
public class ExpandListener implements IExpansionListener{ |
|
594 |
@Override |
|
595 |
public void expansionStateChanging(ExpansionEvent e) { |
|
596 |
} |
|
597 |
@Override |
|
598 |
public void expansionStateChanged(ExpansionEvent e) { |
|
599 |
PreferencesUtil.getPreferenceStore().setValue(getPrefKey(), e.getState()); |
|
600 |
} |
|
601 |
} |
|
602 |
|
|
603 |
/** |
|
604 |
* Adds a custom implementation of IExpansionListener to this section |
|
605 |
* which stores the expansion state in the preferences |
|
606 |
*/ |
|
607 |
protected void addExpandListener() { |
|
608 |
PreferencesUtil.getPreferenceStore().setDefault(getPrefKey(), isExpanded()); |
|
609 |
setExpanded(PreferencesUtil.getPreferenceStore().getBoolean(getPrefKey())); |
|
610 |
addExpansionListener(new ExpandListener()); |
|
611 |
} |
|
612 |
|
|
613 |
private String getPrefKey() { |
|
614 |
return this.getClass().getCanonicalName()+";"+entity.getClass().getCanonicalName(); |
|
615 |
} |
|
616 |
|
|
617 |
|
|
618 | 589 |
} |
Also available in: Unified diff
ref #6554 Evaluate expansion state at widget creation time