Project

General

Profile

« Previous | Next » 

Revision 8f555f2f

Added by Patrick Plitzner almost 5 years ago

Fix expansion state preference for details and suppData view

View differences:

eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/PreferencesUtil.java
93 93
		return TaxeditorStorePlugin.getDefault().getPreferenceStore();
94 94
	}
95 95

  
96
	static String prefKey(String name) {
96
	private static String prefKey(String name) {
97 97
	    return name + "_"+  ((CdmRemoteSource)CdmStore.getActiveCdmSource()).toString();
98 98
	}
99 99

  
......
1616 1616
        }
1617 1617
    }
1618 1618

  
1619
    /**
1620
     * Returns whether the named preference is known.
1621
     * @param prefKey the key of the preference
1622
     * @return <code>true</code> if the preference is known, <code>false</code> otherwise
1623
     */
1624
    public static boolean contains(String prefKey){
1625
        return getPreferenceStore().contains(prefKey(prefKey));
1626
    }
1627

  
1619 1628
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/detail/CdmSectionPart.java
55 55
public class CdmSectionPart<T> extends SectionPart implements
56 56
		IPropertyChangeListener {
57 57

  
58
    public static String EXPANDED = "expanded";
59
    public static String COLLAPSED = "collapsed";
60

  
58 61
	private final AbstractFormSection<T> formSection;
59 62

  
60 63
	/**
......
199 202
	@Override
200 203
	protected void expansionStateChanged(boolean expanded) {
201 204
	    super.expansionStateChanged(expanded);
202
	    PreferencesUtil.setBooleanValue(StoreUtil.getPrefKey(formSection.getClass(), rootInput), expanded);
205
	    PreferencesUtil.setStringValue(StoreUtil.getPrefKey(formSection.getClass(), rootInput), expanded?EXPANDED:COLLAPSED);
203 206
	}
204 207

  
205 208
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/e4/AbstractCdmDataViewerE4.java
179 179

  
180 180
    protected int getSectionStyle(Class<? extends AbstractFormSection> clazz, boolean initiallyExpanded){
181 181
        int style = ExpandableComposite.TWISTIE;
182
        if(PreferencesUtil.getBooleanValue(StoreUtil.getPrefKey(clazz, getInput()))
183
                || initiallyExpanded){
184
            style |= ExpandableComposite.EXPANDED;
182
        String prefKey = StoreUtil.getPrefKey(clazz, getInput());
183
        if(PreferencesUtil.contains(prefKey)){
184
            style = PreferencesUtil.getStringValue(prefKey)==CdmSectionPart.EXPANDED?style |= ExpandableComposite.EXPANDED:style;
185
        }
186
        else{
187
            style = initiallyExpanded?style |= ExpandableComposite.EXPANDED:style;
185 188
        }
186 189
        return style;
187 190
    }

Also available in: Unified diff