Project

General

Profile

Revision 5a073138

ID5a0731384fe4249373ebcfa5fab58bbbf0bfb472
Parent 871e0d37
Child 38eaa3c8

Added by Patrick Plitzner almost 4 years ago

ref #6059 Save expand state for supplemental data view

View differences:

eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/AbstractCdmDataViewer.java
17 17
import org.eclipse.swt.widgets.Display;
18 18
import org.eclipse.ui.forms.IFormPart;
19 19
import org.eclipse.ui.forms.ManagedForm;
20
import org.eclipse.ui.forms.events.ExpansionEvent;
21
import org.eclipse.ui.forms.events.IExpansionListener;
20 22
import org.eclipse.ui.forms.widgets.ScrolledForm;
23
import org.eclipse.ui.forms.widgets.Section;
21 24

  
22 25
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
23 26
import eu.etaxonomy.cdm.api.conversation.IConversationEnabled;
24 27
import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap;
28
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
25 29
import eu.etaxonomy.taxeditor.ui.element.AbstractFormSection;
26 30
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
27 31
import eu.etaxonomy.taxeditor.ui.element.LayoutConstants;
......
29 33
import eu.etaxonomy.taxeditor.view.detail.CdmSectionPart;
30 34

  
31 35
/**
32
 * <p>Abstract AbstractCdmDataViewer class.</p>
33
 *
34 36
 * @author n.hoffmann
35 37
 * @created Feb 9, 2010
36 38
 * @version 1.0
......
53 55
	private final AbstractCdmViewPart viewPart;
54 56

  
55 57

  
56
	/**
57
	 * <p>Constructor for AbstractCdmDataViewer.</p>
58
	 *
59
	 * @param parent a {@link org.eclipse.swt.widgets.Composite} object.
60
	 * @param viewPart a {@link eu.etaxonomy.taxeditor.view.AbstractCdmViewPart} object.
61
	 */
62 58
	public AbstractCdmDataViewer(Composite parent, AbstractCdmViewPart viewPart) {
63 59
		this.viewPart = viewPart;
64 60

  
65 61
		managedForm = new ManagedForm(parent){
66 62

  
67
			/* (non-Javadoc)
68
			 * @see org.eclipse.ui.forms.ManagedForm#dirtyStateChanged()
69
			 */
70 63
			@Override
71 64
			public void dirtyStateChanged() {
72 65
				markViewPartDirty();
......
84 77
		rootElement = new RootElement(formFactory, body);
85 78
	}
86 79

  
87
	/**
88
	 * <p>createFormFactory</p>
89
	 */
90 80
	protected void createFormFactory() {
91 81
		if(formFactory != null){
92 82
			formFactory.dispose();
......
99 89
		viewPart.changed(input);
100 90
	}
101 91

  
102

  
103
	/**
104
	 * @return
105
	 */
106 92
	protected AbstractCdmViewPart getViewPart() {
107 93
		return viewPart;
108 94
	}
109 95

  
110
	/* (non-Javadoc)
111
	 * @see org.eclipse.jface.viewers.Viewer#getControl()
112
	 */
113 96
	/** {@inheritDoc} */
114 97
	@Override
115 98
	public Control getControl() {
......
123 106
		return body;
124 107
	}
125 108
	
126
	/* (non-Javadoc)
127
	 * @see org.eclipse.jface.viewers.Viewer#setInput(java.lang.Object)
128
	 */
129 109
	/** {@inheritDoc} */
130 110
	@Override
131 111
	public void setInput(Object input) {
......
135 115
		refresh();
136 116
	}
137 117

  
138
	/* (non-Javadoc)
139
	 * @see org.eclipse.jface.viewers.Viewer#getInput()
140
	 */
141 118
	/** {@inheritDoc} */
142 119
	@Override
143 120
	public Object getInput() {
144 121
		return input;
145 122
	}
146 123

  
147
	/* (non-Javadoc)
148
	 * @see org.eclipse.jface.viewers.Viewer#refresh()
149
	 */
150 124
	/** {@inheritDoc} */
151 125
	@Override
152 126
	public void refresh() {
......
159 133
		managedForm.reflow(true);
160 134
	}
161 135

  
162

  
163
	/**
164
	 * <p>layout</p>
165
	 */
166 136
	public void layout(){
167 137
		body.layout();
168 138
	}
169 139

  
170
	/**
171
	 * <p>showParts</p>
172
	 */
173 140
	protected abstract void showParts();
174 141

  
175

  
176
	/**
177
	 * <p>destroySections</p>
178
	 */
179 142
	protected void destroySections() {
180 143
		for (IFormPart formPart : managedForm.getParts()){
181
			removePart((CdmSectionPart) formPart);
144
			removePart((CdmSectionPart<?>) formPart);
182 145
		}
183 146

  
184 147
		managedForm.setInput(null);
......
195 158
		}
196 159
	}
197 160

  
198

  
199
	/**
200
	 * <p>setFocus</p>
201
	 */
202 161
	public void setFocus(){
203 162
		// we have to set focus to a control of this viewer
204 163
		// otherwise, after opening a dialog from the details, the focus will not be
......
209 168
		}
210 169
	}
211 170

  
212
	/**
213
	 * <p>reflow</p>
214
	 */
215 171
	public void reflow(){
216 172
		managedForm.reflow(true);
217 173
	}
218 174

  
219
	/**
220
	 * <p>removePart</p>
221
	 *
222
	 * @param sectionPart a {@link eu.etaxonomy.taxeditor.view.detail.CdmSectionPart} object.
223
	 */
224
	protected void removePart(CdmSectionPart sectionPart){
175
	protected void removePart(CdmSectionPart<?> sectionPart){
225 176
		managedForm.removePart(sectionPart);
226 177
		formFactory.removePropertyChangeListener(sectionPart);
227 178
	}
228 179

  
229
	/**
230
	 * <p>addPart</p>
231
	 *
232
	 * @param section a {@link eu.etaxonomy.taxeditor.ui.element.AbstractFormSection} object.
233
	 */
234
	protected void addPart(AbstractFormSection section){
235
		CdmSectionPart sectionPart = new CdmSectionPart(section);
180
	protected void addPart(AbstractFormSection<?> section, boolean isDefaultExpanded){
181
		CdmSectionPart<?> sectionPart = new CdmSectionPart<>(section);
236 182
		managedForm.addPart(sectionPart);
237 183
		formFactory.addPropertyChangeListener(sectionPart);
184
		PreferencesUtil.getPreferenceStore().setDefault(section.getClass().getCanonicalName()+";"+getInput().getClass().getCanonicalName(), isDefaultExpanded);
185
		section.setExpanded(PreferencesUtil.getPreferenceStore().getBoolean(section.getClass().getCanonicalName()+";"+getInput().getClass().getCanonicalName()));
186
		section.addExpansionListener(new ExpandListener(section));
238 187
	}
239 188

  
240
	/**
241
	 * <p>getConversationHolder</p>
242
	 *
243
	 * @return a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
244
	 */
245 189
	@Override
246 190
    public ConversationHolder getConversationHolder() {
247 191
		return viewPart.getConversationHolder();
......
250 194
	/** {@inheritDoc} */
251 195
	@Override
252 196
    public void update(CdmDataChangeMap changeEvents) {}
197
	
198
    private class ExpandListener implements IExpansionListener{
199
    	
200
    	private Section section;
201
    	
202
		public ExpandListener(Section section) {
203
			super();
204
			this.section = section;
205
		}
206

  
207
		@Override
208
		public void expansionStateChanging(ExpansionEvent e) {
209
		}
210

  
211
		@Override
212
		public void expansionStateChanged(ExpansionEvent e) {
213
			PreferencesUtil.getPreferenceStore().setValue(section.getClass().getCanonicalName()+";"+getInput().getClass().getCanonicalName(), e.getState());
214
		}
215
    	
216
    }
253 217

  
254 218
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/detail/DetailsViewer.java
18 18
import org.eclipse.jface.viewers.TreeNode;
19 19
import org.eclipse.swt.SWT;
20 20
import org.eclipse.swt.widgets.Composite;
21
import org.eclipse.ui.forms.events.ExpansionEvent;
22
import org.eclipse.ui.forms.events.IExpansionListener;
23 21
import org.eclipse.ui.forms.widgets.ExpandableComposite;
24
import org.eclipse.ui.forms.widgets.Section;
25 22

  
26 23
import eu.etaxonomy.cdm.api.facade.DerivedUnitFacade;
27 24
import eu.etaxonomy.cdm.api.facade.DerivedUnitFacadeNotSupportedException;
......
330 327

  
331 328
        EmptySection emptySection = formFactory.createEmptySection(formFactory, parent, SWT.NONE);
332 329

  
333
        addPart(emptySection);
330
        addPart(emptySection, false);
334 331
    }
335 332

  
336 333
    private void createGroupSection(RootElement parent) {
......
782 779
        AbstractFormSection<?> definedTermDetailSection = formFactory.createDefinedTermDetailSection(getInput().getClass(), getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
783 780
        addPart(definedTermDetailSection, true);
784 781
    }
785
    
786
	protected void addPart(AbstractFormSection section, boolean isDefaultExpanded){
787
		super.addPart(section);
788
		PreferencesUtil.getPreferenceStore().setDefault(section.getClass().getCanonicalName()+";"+getInput().getClass().getCanonicalName(), isDefaultExpanded);
789
		section.setExpanded(PreferencesUtil.getPreferenceStore().getBoolean(section.getClass().getCanonicalName()+";"+getInput().getClass().getCanonicalName()));
790
		section.addExpansionListener(new ExpandListener(section));
791
	}
792
    
793
    private class ExpandListener implements IExpansionListener{
794
    	
795
    	private Section section;
796
    	
797
		public ExpandListener(Section section) {
798
			super();
799
			this.section = section;
800
		}
801

  
802
		@Override
803
		public void expansionStateChanging(ExpansionEvent e) {
804
		}
805

  
806
		@Override
807
		public void expansionStateChanged(ExpansionEvent e) {
808
			PreferencesUtil.getPreferenceStore().setValue(section.getClass().getCanonicalName()+";"+getInput().getClass().getCanonicalName(), e.getState());
809
		}
810
    	
811
    }
812 782

  
813 783
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/supplementaldata/SupplementalDataViewer.java
131 131

  
132 132
	private void createHeadlineSection(RootElement parent){
133 133
		HeadlineSection headlineSection = formFactory.createHeadlineSection(parent);
134
		addPart(headlineSection);
134
		addPart(headlineSection, false);
135 135
	}
136 136

  
137 137
    private void createAnnotationSections(RootElement parent) {
......
143 143

  
144 144
        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
145 145

  
146
        addPart(annotationSection);
147
        addPart(markerSection);
146
        addPart(annotationSection, false);
147
        addPart(markerSection, false);
148 148
    }
149 149

  
150 150
    private void createIdentifiableSections(RootElement parent) {
......
166 166

  
167 167
        IdentifierSection identifierSection = formFactory.createIdentifierDetailSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE);
168 168
        
169
        addPart(creditSection);
170
        addPart(extensionSection);
171
        addPart(rightsSection);
172
        addPart(sourceSection);
173
        addPart(identifierSection);
169
        addPart(creditSection, false);
170
        addPart(extensionSection, false);
171
        addPart(rightsSection, false);
172
        addPart(sourceSection, false);
173
        addPart(identifierSection, false);
174 174

  
175 175
	}
176 176

  
......
179 179

  
180 180
        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
181 181

  
182
        addPart(mediaSection);
182
        addPart(mediaSection, false);
183 183
    }
184 184

  
185 185
	private void createVersionSection(RootElement parent){
186 186
		VersionSection versionSection = formFactory.createVersionSection(parent, ExpandableComposite.NO_TITLE | ExpandableComposite.EXPANDED);
187
		addPart(versionSection);
187
		addPart(versionSection, true);
188 188
	}
189 189

  
190 190
	/**
......
193 193
	private void createCdmBaseSection(RootElement parent) {
194 194

  
195 195
		CdmBaseSection cdmBaseSection = formFactory.createCdmBaseSection(parent, ExpandableComposite.NO_TITLE | ExpandableComposite.EXPANDED);
196
		addPart(cdmBaseSection);
196
		addPart(cdmBaseSection, true);
197 197
	}
198 198

  
199 199
	/*

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)