Revision 9457da34
Added by Katja Luther about 6 years ago
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/menu/CdmPreferencePage.java | ||
---|---|---|
8 | 8 |
*/ |
9 | 9 |
package eu.etaxonomy.taxeditor.preference.menu; |
10 | 10 |
|
11 |
import java.util.Collection; |
|
12 |
import java.util.List; |
|
13 |
import java.util.Map; |
|
14 |
|
|
15 | 11 |
import org.eclipse.jface.preference.PreferencePage; |
16 | 12 |
import org.eclipse.jface.resource.ImageDescriptor; |
17 | 13 |
|
18 |
import eu.etaxonomy.cdm.model.common.CdmBase; |
|
19 | 14 |
import eu.etaxonomy.taxeditor.preference.IE4PreferencePage; |
20 | 15 |
import eu.etaxonomy.taxeditor.preference.PreferencesUtil; |
21 |
import eu.etaxonomy.taxeditor.session.ICdmEntitySession; |
|
22 |
import eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled; |
|
23 |
import eu.etaxonomy.taxeditor.store.CdmStore; |
|
24 | 16 |
|
25 | 17 |
/** |
26 | 18 |
* @author cmathew |
27 | 19 |
* @date 30 Jul 2015 |
28 | 20 |
* |
29 | 21 |
*/ |
30 |
public abstract class CdmPreferencePage extends PreferencePage implements ICdmEntitySessionEnabled, IE4PreferencePage {
|
|
22 |
public abstract class CdmPreferencePage extends PreferencePage implements IE4PreferencePage { |
|
31 | 23 |
|
32 |
private ICdmEntitySession previousCdmEntitySession; |
|
33 | 24 |
private boolean isApply; |
34 | 25 |
|
35 | 26 |
public CdmPreferencePage() { |
... | ... | |
42 | 33 |
|
43 | 34 |
public CdmPreferencePage(String title, ImageDescriptor image) { |
44 | 35 |
super(title, image); |
45 |
initSession(); |
|
36 |
|
|
46 | 37 |
init(); |
47 | 38 |
} |
48 | 39 |
|
... | ... | |
50 | 41 |
setPreferenceStore(PreferencesUtil.getPreferenceStore()); |
51 | 42 |
} |
52 | 43 |
|
53 |
private void initSession() { |
|
54 |
if (CdmStore.isActive()){ |
|
55 |
previousCdmEntitySession = CdmStore.getCurrentSessionManager().getActiveSession(); |
|
56 |
bindNullSession(); |
|
57 |
} |
|
58 |
|
|
59 |
} |
|
60 |
|
|
61 |
private void bindNullSession() { |
|
62 |
if(CdmStore.isActive()) { |
|
63 |
CdmStore.getCurrentSessionManager().bindNullSession(); |
|
64 |
} |
|
65 |
} |
|
66 |
|
|
67 | 44 |
@Override |
68 | 45 |
public boolean performOk() { |
69 |
if(previousCdmEntitySession != null && !isApply) { |
|
70 |
previousCdmEntitySession.bind(); |
|
71 |
} |
|
46 |
|
|
72 | 47 |
return super.performOk(); |
73 | 48 |
} |
74 | 49 |
|
75 | 50 |
@Override |
76 | 51 |
public boolean performCancel() { |
77 |
if(previousCdmEntitySession != null) { |
|
78 |
previousCdmEntitySession.bind(); |
|
79 |
} |
|
52 |
|
|
80 | 53 |
return super.performCancel(); |
81 | 54 |
} |
82 | 55 |
|
... | ... | |
87 | 60 |
isApply = false; |
88 | 61 |
} |
89 | 62 |
|
90 |
/* (non-Javadoc) |
|
91 |
* @see eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled#getCdmEntitySession() |
|
92 |
*/ |
|
93 |
@Override |
|
94 |
public ICdmEntitySession getCdmEntitySession() { |
|
95 |
return CdmStore.getCurrentSessionManager().getNullSession(); |
|
96 |
} |
|
97 | 63 |
|
98 |
/* (non-Javadoc) |
|
99 |
* @see eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled#getRootEntities() |
|
100 |
*/ |
|
101 |
@Override |
|
102 |
public <T extends CdmBase> Collection<T> getRootEntities() { |
|
103 |
return null; |
|
104 |
} |
|
105 | 64 |
|
106 |
/* (non-Javadoc) |
|
107 |
* @see eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled#getPropertyPathsMap() |
|
108 |
*/ |
|
109 |
@Override |
|
110 |
public Map<Object, List<String>> getPropertyPathsMap() { |
|
111 |
return null; |
|
112 |
} |
|
65 |
|
|
113 | 66 |
|
114 | 67 |
} |
Also available in: Unified diff
fix #7312: fix immediately saving of preference changes