return TaxeditorStorePlugin.getDefault().getPreferenceStore();
}
- static String prefKey(String name) {
+ private static String prefKey(String name) {
return name + "_"+ ((CdmRemoteSource)CdmStore.getActiveCdmSource()).toString();
}
}
}
+ /**
+ * Returns whether the named preference is known.
+ * @param prefKey the key of the preference
+ * @return <code>true</code> if the preference is known, <code>false</code> otherwise
+ */
+ public static boolean contains(String prefKey){
+ return getPreferenceStore().contains(prefKey(prefKey));
+ }
+
}
public class CdmSectionPart<T> extends SectionPart implements
IPropertyChangeListener {
+ public static String EXPANDED = "expanded";
+ public static String COLLAPSED = "collapsed";
+
private final AbstractFormSection<T> formSection;
/**
@Override
protected void expansionStateChanged(boolean expanded) {
super.expansionStateChanged(expanded);
- PreferencesUtil.setBooleanValue(StoreUtil.getPrefKey(formSection.getClass(), rootInput), expanded);
+ PreferencesUtil.setStringValue(StoreUtil.getPrefKey(formSection.getClass(), rootInput), expanded?EXPANDED:COLLAPSED);
}
}
protected int getSectionStyle(Class<? extends AbstractFormSection> clazz, boolean initiallyExpanded){
int style = ExpandableComposite.TWISTIE;
- if(PreferencesUtil.getBooleanValue(StoreUtil.getPrefKey(clazz, getInput()))
- || initiallyExpanded){
- style |= ExpandableComposite.EXPANDED;
+ String prefKey = StoreUtil.getPrefKey(clazz, getInput());
+ if(PreferencesUtil.contains(prefKey)){
+ style = PreferencesUtil.getStringValue(prefKey)==CdmSectionPart.EXPANDED?style |= ExpandableComposite.EXPANDED:style;
+ }
+ else{
+ style = initiallyExpanded?style |= ExpandableComposite.EXPANDED:style;
}
return style;
}