Merge branch 'develop' into remoting-4.0
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / preference / menu / CdmPreferencePage.java
1 // $Id$
2 /**
3 * Copyright (C) 2015 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
6 *
7 * The contents of this file are subject to the Mozilla Public License Version 1.1
8 * See LICENSE.TXT at the top of this package for the full license terms.
9 */
10 package eu.etaxonomy.taxeditor.preference.menu;
11
12 import java.util.Collection;
13 import java.util.List;
14 import java.util.Map;
15
16 import org.eclipse.jface.preference.PreferencePage;
17
18 import eu.etaxonomy.cdm.model.common.CdmBase;
19 import eu.etaxonomy.taxeditor.session.ICdmEntitySession;
20 import eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled;
21 import eu.etaxonomy.taxeditor.store.CdmStore;
22
23 /**
24 * @author cmathew
25 * @date 30 Jul 2015
26 *
27 */
28 public abstract class CdmPreferencePage extends PreferencePage implements ICdmEntitySessionEnabled {
29
30 public CdmPreferencePage() {
31 bindNullSession();
32 }
33
34 public CdmPreferencePage(String title) {
35 super(title);
36 bindNullSession();
37 }
38
39 private void bindNullSession() {
40 if(CdmStore.isActive()) {
41 CdmStore.getCurrentSessionManager().bindNullSession(this);
42 }
43 }
44
45 protected void disposeNullSession() {
46 if(CdmStore.isActive()) {
47 CdmStore.getCurrentSessionManager().dispose(this);
48 }
49 }
50
51 @Override
52 public boolean performOk() {
53 disposeNullSession();
54 return super.performOk();
55 }
56
57 @Override
58 public boolean performCancel() {
59 disposeNullSession();
60 return super.performCancel();
61 }
62
63 /* (non-Javadoc)
64 * @see eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled#getCdmEntitySession()
65 */
66 @Override
67 public ICdmEntitySession getCdmEntitySession() {
68 return CdmStore.getCurrentSessionManager().getNullSession();
69 }
70
71 /* (non-Javadoc)
72 * @see eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled#getRootEntities()
73 */
74 @Override
75 public <T extends CdmBase> Collection<T> getRootEntities() {
76 return null;
77 }
78
79 /* (non-Javadoc)
80 * @see eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled#getPropertyPathsMap()
81 */
82 @Override
83 public Map<Object, List<String>> getPropertyPathsMap() {
84 return null;
85 }
86
87 }