1 |
3be6ef3e
|
n.hoffmann
|
/**
|
2 |
|
|
* Copyright (C) 2007 EDIT
|
3 |
fdc57cb7
|
Cherian Mathew
|
* European Distributed Institute of Taxonomy
|
4 |
3be6ef3e
|
n.hoffmann
|
* http://www.e-taxonomy.eu
|
5 |
fdc57cb7
|
Cherian Mathew
|
*
|
6 |
3be6ef3e
|
n.hoffmann
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
7 |
|
|
* See LICENSE.TXT at the top of this package for the full license terms.
|
8 |
|
|
*/
|
9 |
|
|
|
10 |
|
|
package eu.etaxonomy.taxeditor.navigation.navigator;
|
11 |
|
|
|
12 |
5fd24c47
|
Katja Luther
|
import java.util.ArrayList;
|
13 |
84e0905d
|
n.hoffmann
|
import java.util.Arrays;
|
14 |
3be6ef3e
|
n.hoffmann
|
import java.util.List;
|
15 |
|
|
|
16 |
|
|
import org.eclipse.core.runtime.IAdaptable;
|
17 |
|
|
import org.eclipse.core.runtime.PlatformObject;
|
18 |
|
|
import org.eclipse.ui.IElementFactory;
|
19 |
|
|
import org.eclipse.ui.IMemento;
|
20 |
|
|
import org.eclipse.ui.IPersistableElement;
|
21 |
|
|
|
22 |
|
|
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
|
23 |
d6c1b4c2
|
n.hoffmann
|
import eu.etaxonomy.cdm.api.conversation.IConversationEnabled;
|
24 |
db5e366d
|
n.hoffmann
|
import eu.etaxonomy.cdm.api.service.IClassificationService;
|
25 |
5fd24c47
|
Katja Luther
|
import eu.etaxonomy.cdm.model.common.ITreeNode;
|
26 |
d31115e0
|
n.hoffmann
|
import eu.etaxonomy.cdm.model.taxon.Classification;
|
27 |
d6c1b4c2
|
n.hoffmann
|
import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap;
|
28 |
3be6ef3e
|
n.hoffmann
|
import eu.etaxonomy.taxeditor.store.CdmStore;
|
29 |
|
|
|
30 |
|
|
/**
|
31 |
|
|
* <p>Root class.</p>
|
32 |
|
|
*
|
33 |
|
|
* @author p.ciardelli
|
34 |
|
|
* @created 02.06.2009
|
35 |
|
|
* @version 1.0
|
36 |
|
|
*/
|
37 |
d6c1b4c2
|
n.hoffmann
|
public class Root extends PlatformObject implements IAdaptable, IPersistableElement, IElementFactory, IConversationEnabled {
|
38 |
3be6ef3e
|
n.hoffmann
|
|
39 |
fdc57cb7
|
Cherian Mathew
|
private final ConversationHolder conversation;
|
40 |
|
|
|
41 |
3be6ef3e
|
n.hoffmann
|
/**
|
42 |
|
|
* <p>Constructor for Root.</p>
|
43 |
|
|
*
|
44 |
|
|
* @param conversation a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
|
45 |
|
|
*/
|
46 |
|
|
public Root (ConversationHolder conversation){
|
47 |
|
|
this.conversation = conversation;
|
48 |
|
|
}
|
49 |
fdc57cb7
|
Cherian Mathew
|
|
50 |
3be6ef3e
|
n.hoffmann
|
/**
|
51 |
|
|
* <p>getParentBeans</p>
|
52 |
|
|
*
|
53 |
|
|
* @return a {@link java.util.List} object.
|
54 |
|
|
*/
|
55 |
5fd24c47
|
Katja Luther
|
public List<ITreeNode> getParentBeans() {
|
56 |
7a9c921d
|
Cherian Mathew
|
List<String> propertyPaths = Arrays.asList(new String[]{
|
57 |
939829bc
|
Patrick Plitzner
|
"name", //$NON-NLS-1$
|
58 |
|
|
"rootNode.childNodes"}); //$NON-NLS-1$
|
59 |
fdc57cb7
|
Cherian Mathew
|
|
60 |
db5e366d
|
n.hoffmann
|
List<Classification> classifications = CdmStore.getService(IClassificationService.class).list(null, null, null, null, propertyPaths);
|
61 |
5fd24c47
|
Katja Luther
|
List<ITreeNode> rootNodes = new ArrayList<>();
|
62 |
fdc57cb7
|
Cherian Mathew
|
|
63 |
22f2d1a4
|
Patrick Plitzner
|
if(classifications.size() == 0){
|
64 |
|
|
//FIXME E4 migrate or delete; when does this happen and SHOULD this happen?
|
65 |
|
|
// Classification classification = Classification.NewInstance(Messages.Root_MY_CLASSIFICATION);
|
66 |
|
|
// AbstractPostOperation operation = new CreateClassification(Messages.Root_CREATE_CLASSIFICATION, NavigationUtil.getUndoContext(), classification, NavigationUtil.getNavigator(false), NavigationUtil.getNavigator(false), NavigationUtil.getNavigator(false));
|
67 |
|
|
// NavigationUtil.executeOperation(operation);
|
68 |
|
|
//
|
69 |
|
|
// classifications = CdmStore.getService(IClassificationService.class).list(null, null, null, null, propertyPaths);
|
70 |
3be6ef3e
|
n.hoffmann
|
}
|
71 |
5fd24c47
|
Katja Luther
|
for (Classification classification: classifications){
|
72 |
|
|
rootNodes.add(classification.getRootNode());
|
73 |
|
|
}
|
74 |
|
|
return rootNodes;
|
75 |
3be6ef3e
|
n.hoffmann
|
}
|
76 |
|
|
|
77 |
|
|
/* (non-Javadoc)
|
78 |
|
|
* @see org.eclipse.ui.IPersistableElement#getFactoryId()
|
79 |
|
|
*/
|
80 |
|
|
/**
|
81 |
|
|
* <p>getFactoryId</p>
|
82 |
|
|
*
|
83 |
|
|
* @return a {@link java.lang.String} object.
|
84 |
|
|
*/
|
85 |
fdc57cb7
|
Cherian Mathew
|
@Override
|
86 |
|
|
public String getFactoryId() {
|
87 |
3be6ef3e
|
n.hoffmann
|
return null;
|
88 |
|
|
}
|
89 |
|
|
|
90 |
|
|
/* (non-Javadoc)
|
91 |
|
|
* @see org.eclipse.ui.IPersistable#saveState(org.eclipse.ui.IMemento)
|
92 |
|
|
*/
|
93 |
|
|
/** {@inheritDoc} */
|
94 |
fdc57cb7
|
Cherian Mathew
|
@Override
|
95 |
|
|
public void saveState(IMemento memento) {
|
96 |
3be6ef3e
|
n.hoffmann
|
}
|
97 |
|
|
|
98 |
|
|
/* (non-Javadoc)
|
99 |
|
|
* @see org.eclipse.ui.IElementFactory#createElement(org.eclipse.ui.IMemento)
|
100 |
|
|
*/
|
101 |
|
|
/** {@inheritDoc} */
|
102 |
fdc57cb7
|
Cherian Mathew
|
@Override
|
103 |
|
|
public IAdaptable createElement(IMemento memento) {
|
104 |
3be6ef3e
|
n.hoffmann
|
return null;
|
105 |
|
|
}
|
106 |
d6c1b4c2
|
n.hoffmann
|
|
107 |
|
|
/* (non-Javadoc)
|
108 |
|
|
* @see eu.etaxonomy.cdm.persistence.hibernate.ICdmPostDataChangeObserver#update(eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap)
|
109 |
|
|
*/
|
110 |
|
|
@Override
|
111 |
|
|
public void update(CdmDataChangeMap changeEvents) {}
|
112 |
|
|
|
113 |
|
|
/* (non-Javadoc)
|
114 |
|
|
* @see eu.etaxonomy.cdm.api.conversation.IConversationEnabled#getConversationHolder()
|
115 |
|
|
*/
|
116 |
|
|
@Override
|
117 |
|
|
public ConversationHolder getConversationHolder() {
|
118 |
|
|
return conversation;
|
119 |
|
|
}
|
120 |
3be6ef3e
|
n.hoffmann
|
}
|