Revision 324d38f7
Added by Alex Theys about 12 years ago
eu.etaxonomy.taxeditor.application/src/main/java/eu/etaxonomy/taxeditor/perspective/PalmUses.java | ||
---|---|---|
12 | 12 |
import eu.etaxonomy.taxeditor.view.userecords.UseRecordsViewPart; |
13 | 13 |
|
14 | 14 |
/** |
15 |
* @author a.theys
|
|
15 |
* The context manager mediates context start/stop and workbench shutdowns to all registered listeners.
|
|
16 | 16 |
* |
17 |
* @author a.theys |
|
18 |
* @created mar 13, 2012 |
|
19 |
* @version 1.0 |
|
17 | 20 |
*/ |
18 | 21 |
public class PalmUses extends Default { |
19 | 22 |
|
... | ... | |
26 | 29 |
layout.addView(UseRecordsViewPart.ID, IPageLayout.RIGHT, 0.25f, layout.getEditorArea()); |
27 | 30 |
layout.addView(UsesViewPart.ID, IPageLayout.BOTTOM, 0.25f, layout.getEditorArea()); |
28 | 31 |
|
29 |
// layout.addView(SupplementalDataViewPart.ID, IPageLayout.BOTTOM, 0.25f, DetailsViewPart.ID); |
|
30 |
|
|
31 | 32 |
createAdditionalFolder(layout, layout.getEditorArea()); |
32 | 33 |
} |
33 | 34 |
|
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/uses/UsesContentProvider.java | ||
---|---|---|
10 | 10 |
import org.eclipse.jface.viewers.ITreeContentProvider; |
11 | 11 |
import org.eclipse.jface.viewers.Viewer; |
12 | 12 |
|
13 |
import eu.etaxonomy.cdm.api.service.IDescriptionService;
|
|
13 |
import eu.etaxonomy.cdm.api.service.ITermService;
|
|
14 | 14 |
import eu.etaxonomy.cdm.model.common.Marker; |
15 | 15 |
import eu.etaxonomy.cdm.model.common.MarkerType; |
16 | 16 |
import eu.etaxonomy.cdm.model.description.DescriptionBase; |
... | ... | |
25 | 25 |
import eu.etaxonomy.taxeditor.store.CdmStore; |
26 | 26 |
import eu.etaxonomy.taxeditor.store.TermStore; |
27 | 27 |
|
28 |
/** |
|
29 |
* The context manager mediates context start/stop and workbench shutdowns to all registered listeners. |
|
30 |
* |
|
31 |
* @author a.theys |
|
32 |
* @created mar 13, 2012 |
|
33 |
* @version 1.0 |
|
34 |
*/ |
|
28 | 35 |
public class UsesContentProvider implements ITreeContentProvider { |
29 | 36 |
|
30 | 37 |
private static final Object[] NO_CHILDREN = new Object[0]; |
... | ... | |
124 | 131 |
* @param parentElement |
125 | 132 |
* @return |
126 | 133 |
*/ |
127 |
//CdmStore.getService(IDescriptionService.class).listTaxonDescriptions(input.getTaxonNode().getTaxon(), null, null, null, null, null, null) |
|
128 | 134 |
private List<DescriptionBase> getDescriptions(TaxonEditorInput parentElement) { |
129 |
//this.markerTypes.addAll(CdmStore.getTermManager().getPreferredMarkerTypes()); |
|
130 | 135 |
this.markerTypes.addAll(CdmStore.getTermManager().getPreferredTerms(MarkerType.class)); |
131 | 136 |
Taxon taxon = parentElement.getTaxon(); |
132 |
Set<MarkerType> typesToDisdplay = new HashSet<MarkerType>(); |
|
133 | 137 |
List<DescriptionBase> descriptions = new ArrayList<DescriptionBase>(); |
134 |
List<TaxonDescription> usesDescriptions = new ArrayList<TaxonDescription>(); |
|
135 | 138 |
|
136 |
/*for (MarkerType markerType : markerTypes) { |
|
137 |
if (markerType.toString().equals("complete")) { |
|
138 |
typesToDisdplay.add(markerType); |
|
139 |
} |
|
140 |
}*/ |
|
141 |
//usesDescriptions = CdmStore.getService(IDescriptionService.class).listTaxonDescriptions(taxon, null, null, typesToDisdplay, null, null, null); |
|
142 |
//for(DescriptionBase description : CdmStore.getService(IDescriptionService.class).listTaxonDescriptions(taxon, null, null, typesToDisdplay, null, null, null)){ |
|
143 |
for(DescriptionBase description : taxon.getDescriptions()){ |
|
139 |
for(DescriptionBase description : taxon.getDescriptions()){ |
|
144 | 140 |
if(! description.isImageGallery()){ |
141 |
MarkerType useMarkertype = (MarkerType) CdmStore.getService(ITermService.class).find(UUID.fromString("2e6e42d9-e92a-41f4-899b-03c0ac64f039")); |
|
145 | 142 |
Set<Marker> descriptionMarkers = description.getMarkers(); |
146 | 143 |
if(descriptionMarkers != null) { |
147 | 144 |
for (Marker marker: descriptionMarkers) { |
148 | 145 |
//TODO Use the GetbyUUID method |
149 |
if(marker.getMarkerType().getTitleCache().equals("use")) {
|
|
146 |
if(marker.getMarkerType().equals(useMarkertype)) {
|
|
150 | 147 |
descriptions.add(description); |
151 | 148 |
} |
152 | 149 |
} |
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/uses/UsesLabelProvider.java | ||
---|---|---|
1 | 1 |
package eu.etaxonomy.taxeditor.editor.view.uses; |
2 | 2 |
|
3 |
import java.util.Arrays; |
|
4 |
import java.util.List; |
|
5 |
import java.util.Map; |
|
6 | 3 |
|
7 |
import javax.swing.text.html.HTMLDocument.HTMLReader.IsindexAction; |
|
8 | 4 |
|
9 | 5 |
import org.eclipse.jface.viewers.ColumnLabelProvider; |
10 | 6 |
import org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider.IStyledLabelProvider; |
... | ... | |
12 | 8 |
|
13 | 9 |
import eu.etaxonomy.cdm.api.service.DefaultCategoricalDescriptionBuilder; |
14 | 10 |
import eu.etaxonomy.cdm.api.service.DescriptionBuilder; |
15 |
import eu.etaxonomy.cdm.model.common.Language; |
|
16 |
import eu.etaxonomy.cdm.model.common.LanguageString; |
|
17 | 11 |
import eu.etaxonomy.cdm.model.description.CategoricalData; |
18 | 12 |
import eu.etaxonomy.cdm.model.description.DescriptionBase; |
19 |
import eu.etaxonomy.cdm.model.description.DescriptionElementBase; |
|
20 | 13 |
import eu.etaxonomy.cdm.model.description.Modifier; |
21 |
import eu.etaxonomy.cdm.model.description.State; |
|
22 | 14 |
import eu.etaxonomy.cdm.model.description.StateData; |
23 |
import eu.etaxonomy.cdm.model.description.TextData; |
|
24 | 15 |
import eu.etaxonomy.taxeditor.store.CdmStore; |
25 | 16 |
|
17 |
/** |
|
18 |
* The context manager mediates context start/stop and workbench shutdowns to all registered listeners. |
|
19 |
* |
|
20 |
* @author a.theys |
|
21 |
* @created mar 13, 2012 |
|
22 |
* @version 1.0 |
|
23 |
*/ |
|
26 | 24 |
public class UsesLabelProvider extends ColumnLabelProvider implements |
27 | 25 |
IStyledLabelProvider { |
28 | 26 |
|
29 |
private static DescriptionBuilder<CategoricalData> categoricalDescriptionBuilder = new DefaultCategoricalDescriptionBuilder(); |
|
30 | 27 |
public String getText(Object element) { |
31 | 28 |
String text = ""; |
32 |
/* |
|
33 |
* return DescriptionHelper.getLabel(element); |
|
34 |
* |
|
35 |
* for (Marker marker : element.getMarkers()) { if |
|
36 |
* (marker.getMarkerType().getTitleCache().equals("use")) { return |
|
37 |
* "Use: " + text; } } |
|
38 |
*/ |
|
29 |
|
|
39 | 30 |
if (element instanceof DescriptionBase) { |
40 | 31 |
text = ((DescriptionBase) element).getTitleCache(); |
41 | 32 |
if (text == null || text.length() == 0) { |
... | ... | |
46 | 37 |
} |
47 | 38 |
} |
48 | 39 |
else if (element instanceof CategoricalData) { |
49 |
//String text = ""; |
|
50 |
//TextData textData = categoricalDescriptionBuilder.build((CategoricalData) element, getLanguageList()); |
|
51 | 40 |
if (!((CategoricalData) element).getStates().isEmpty()) { |
52 | 41 |
for (StateData statedata : ((CategoricalData) element).getStates()) { |
53 | 42 |
if(statedata.getState() != null && statedata.getModifyingText().get(CdmStore.getDefaultLanguage()) !=null && statedata.getModifyingText().get(CdmStore.getDefaultLanguage()).getText().equals("Use Category")) { |
... | ... | |
126 | 115 |
StyledString.QUALIFIER_STYLER); |
127 | 116 |
} |
128 | 117 |
|
129 |
private static List<Language> getLanguageList(){ |
|
130 |
return Arrays.asList(new Language[]{CdmStore.getDefaultLanguage()}); |
|
131 |
} |
|
118 |
|
|
132 | 119 |
|
133 | 120 |
} |
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/uses/UsesViewPart.java | ||
---|---|---|
75 | 75 |
import eu.etaxonomy.taxeditor.view.AbstractCdmEditorViewPart; |
76 | 76 |
|
77 | 77 |
|
78 |
|
|
78 |
/** |
|
79 |
* The context manager mediates context start/stop and workbench shutdowns to all registered listeners. |
|
80 |
* |
|
81 |
* @author a.theys |
|
82 |
* @created mar 13, 2012 |
|
83 |
* @version 1.0 |
|
84 |
*/ |
|
79 | 85 |
public class UsesViewPart extends AbstractCdmEditorViewPart implements IPartContentHasDetails, IPartContentHasSupplementalData { |
80 | 86 |
|
81 | 87 |
|
... | ... | |
110 | 116 |
TermVocabulary<Modifier> humanGroupVocabulary = (TermVocabulary<Modifier>) CdmStore.getService(IVocabularyService.class).find(UUID.fromString("ca46cea5-bdf7-438d-9cd8-e2793d2178dc")); |
111 | 117 |
ConversationHolder conversation = CdmStore.createConversation(); |
112 | 118 |
if (existingMarkertype == null) { |
113 |
//existingMarkertype.set("use") |
|
114 |
//existingMarkertype.setLabel("use"); |
|
115 |
//MarkerType useMarkerType = MarkerType.NewInstance("use", "use", null); |
|
116 |
//ConversationHolder conversation = CdmStore.createConversation(); |
|
117 | 119 |
existingMarkertype = MarkerType.NewInstance("use", "use", null); |
118 | 120 |
existingMarkertype.setUuid( UUID.fromString("2e6e42d9-e92a-41f4-899b-03c0ac64f039")); |
119 |
//CdmStore.getService(ITermService.class).save(existingMarkertype); |
|
120 |
//saveOrUpdate(existingMarkertype); |
|
121 |
//TermVocabulary<MarkerType> markerTypeVocabulary = (TermVocabulary<MarkerType>)CdmStore.getService(IVocabularyService.class).getVocabulary(VocabularyEnum.MarkerType); |
|
122 | 121 |
TermVocabulary<MarkerType> markerTypeVocabulary = (TermVocabulary<MarkerType>)CdmStore.getService(IVocabularyService.class).find((UUID.fromString("19dffff7-e142-429c-a420-5d28e4ebe305"))); |
123 |
//(UUID.fromString("19dffff7-e142-429c-a420-5d28e4ebe305")); |
|
124 |
//CdmStore. |
|
125 |
|
|
126 | 122 |
markerTypeVocabulary.addTerm(existingMarkertype); |
127 | 123 |
CdmStore.getService(IVocabularyService.class).saveOrUpdate(markerTypeVocabulary); |
128 | 124 |
conversation.commit(true); |
129 |
//conversation.close(); |
|
130 | 125 |
} |
131 | 126 |
if (stateVocabulary == null) { |
132 | 127 |
monitor.subTask("stateVocabulary empty"); |
... | ... | |
134 | 129 |
try { |
135 | 130 |
termSourceUri = new URI("eu.etaxonomy.cdm.model.description.State"); |
136 | 131 |
} catch (URISyntaxException e) { |
137 |
// TODO Auto-generated catch block |
|
138 | 132 |
e.printStackTrace(); |
139 | 133 |
} |
140 | 134 |
stateVocabulary = TermVocabulary.NewInstance("Use Category", "Use Category", null, termSourceUri); |
... | ... | |
152 | 146 |
try { |
153 | 147 |
termSourceUri = new URI("eu.etaxonomy.cdm.model.description.Modifier"); |
154 | 148 |
} catch (URISyntaxException e) { |
155 |
// TODO Auto-generated catch block |
|
156 | 149 |
e.printStackTrace(); |
157 | 150 |
} |
158 | 151 |
countryVocabulary = TermVocabulary.NewInstance("Country", "Country", null, termSourceUri); |
... | ... | |
169 | 162 |
try { |
170 | 163 |
termSourceUri = new URI("eu.etaxonomy.cdm.model.description.Modifier"); |
171 | 164 |
} catch (URISyntaxException e) { |
172 |
// TODO Auto-generated catch block |
|
173 | 165 |
e.printStackTrace(); |
174 | 166 |
} |
175 | 167 |
plantPartVocabulary = TermVocabulary.NewInstance("Plant Part", "Plant Part", null, termSourceUri); |
... | ... | |
185 | 177 |
try { |
186 | 178 |
termSourceUri = new URI("eu.etaxonomy.cdm.model.description.Modifier"); |
187 | 179 |
} catch (URISyntaxException e) { |
188 |
// TODO Auto-generated catch block |
|
189 | 180 |
e.printStackTrace(); |
190 | 181 |
} |
191 | 182 |
humanGroupVocabulary = TermVocabulary.NewInstance("Human Group", "Human Group", null, termSourceUri); |
... | ... | |
198 | 189 |
conversation.commit(true); |
199 | 190 |
} |
200 | 191 |
if(featureUseRecord == null) { |
201 |
//Feature usesFeature = (Feature) CdmStore.getService(ITermService.class).find(UUID.fromString("e5374d39-b210-47c7-bec1-bee05b5f1cb6")); |
|
202 | 192 |
featureUseRecord = Feature.NewInstance("Use Record", "Use Record", null); |
203 | 193 |
featureUseRecord.setUuid(UUID.fromString("8125a59d-b4d5-4485-89ea-67306297b599")); |
204 | 194 |
featureUseRecord.setSupportsCategoricalData(true); |
205 |
//featureUseRecord |
|
206 |
//featureUseRecord.setLabel("Use Record"); |
|
207 |
//featureUseRecord. |
|
208 | 195 |
TermVocabulary<Feature> featureVocabulary = (TermVocabulary<Feature>)CdmStore.getService(IVocabularyService.class).find((UUID.fromString("b187d555-f06f-4d65-9e53-da7c93f8eaa8"))); |
209 | 196 |
featureVocabulary.addTerm(featureUseRecord); |
210 | 197 |
CdmStore.getService(IVocabularyService.class).saveOrUpdate(featureVocabulary); |
... | ... | |
215 | 202 |
|
216 | 203 |
conversation.close(); |
217 | 204 |
} |
218 |
/*public void contextStop(IMemento memento, IProgressMonitor monitor) { |
|
219 |
monitor.subTask("Getting rid of search results"); |
|
220 |
NavigationUtil.hideView(SearchResultView.this); |
|
221 |
}*/ |
|
222 | 205 |
} |
223 | 206 |
|
224 | 207 |
public static final String ID = "eu.etaxonomy.taxeditor.editor.view.uses"; |
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/uses/handler/CreateUseHandler.java | ||
---|---|---|
17 | 17 |
import eu.etaxonomy.taxeditor.operation.AbstractPostOperation; |
18 | 18 |
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled; |
19 | 19 |
|
20 |
/** |
|
21 |
* The context manager mediates context start/stop and workbench shutdowns to all registered listeners. |
|
22 |
* |
|
23 |
* @author a.theys |
|
24 |
* @created mar 13, 2012 |
|
25 |
* @version 1.0 |
|
26 |
*/ |
|
20 | 27 |
public class CreateUseHandler extends AbstractHandler { |
21 | 28 |
/* (non-Javadoc) |
22 | 29 |
* @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent) |
... | ... | |
36 | 43 |
Taxon taxon = ((TaxonEditorInput) input).getTaxon(); |
37 | 44 |
AbstractPostOperation operation; |
38 | 45 |
try { |
39 |
// TODO use undo context specific to editor |
|
40 | 46 |
operation = new CreateTaxonUseOperation(event.getCommand().getName(), |
41 | 47 |
EditorUtil.getUndoContext(), taxon, postOperationEnabled); |
42 | 48 |
EditorUtil.executeOperation(operation); |
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/uses/handler/CreateUseRecordHandler.java | ||
---|---|---|
1 | 1 |
package eu.etaxonomy.taxeditor.editor.view.uses.handler; |
2 | 2 |
|
3 |
import java.util.List; |
|
4 |
import java.util.Set; |
|
3 |
|
|
5 | 4 |
import java.util.UUID; |
6 | 5 |
|
7 | 6 |
import org.eclipse.core.commands.AbstractHandler; |
... | ... | |
12 | 11 |
import org.eclipse.jface.viewers.IStructuredSelection; |
13 | 12 |
import org.eclipse.jface.viewers.ITreeSelection; |
14 | 13 |
import org.eclipse.jface.viewers.TreePath; |
15 |
import org.eclipse.swt.widgets.Event; |
|
16 | 14 |
import org.eclipse.ui.IEditorInput; |
17 | 15 |
import org.eclipse.ui.IEditorPart; |
18 | 16 |
import org.eclipse.ui.IWorkbenchPart; |
... | ... | |
20 | 18 |
import org.eclipse.ui.handlers.HandlerUtil; |
21 | 19 |
|
22 | 20 |
import eu.etaxonomy.cdm.api.service.ITermService; |
23 |
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper; |
|
24 |
import eu.etaxonomy.cdm.model.description.CategoricalData; |
|
25 |
import eu.etaxonomy.cdm.model.description.DescriptionElementBase; |
|
26 | 21 |
import eu.etaxonomy.cdm.model.description.Feature; |
27 | 22 |
import eu.etaxonomy.cdm.model.description.TaxonDescription; |
28 |
import eu.etaxonomy.cdm.model.description.TextData; |
|
29 | 23 |
import eu.etaxonomy.cdm.model.taxon.Taxon; |
30 | 24 |
import eu.etaxonomy.taxeditor.editor.EditorUtil; |
31 | 25 |
import eu.etaxonomy.taxeditor.editor.TaxonEditorInput; |
... | ... | |
34 | 28 |
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled; |
35 | 29 |
import eu.etaxonomy.taxeditor.store.CdmStore; |
36 | 30 |
|
31 |
/** |
|
32 |
* The context manager mediates context start/stop and workbench shutdowns to all registered listeners. |
|
33 |
* |
|
34 |
* @author a.theys |
|
35 |
* @created mar 13, 2012 |
|
36 |
* @version 1.0 |
|
37 |
*/ |
|
37 | 38 |
public class CreateUseRecordHandler extends AbstractHandler { |
38 | 39 |
public Object execute(ExecutionEvent event) throws ExecutionException { |
39 | 40 |
IWorkbenchPart part = HandlerUtil.getActivePart(event); |
... | ... | |
69 | 70 |
AbstractPostOperation operation = null; |
70 | 71 |
try { |
71 | 72 |
//Use Record Feature retrieval below |
72 |
//Feature feature = (Feature) CdmStore.getService(ITermService.class).find(UUID.fromString("8125a59d-b4d5-4485-89ea-67306297b599")); |
|
73 |
//Feature feature = (Feature) CdmStore.getService(ITermService.class).find(UUID.fromString("247606f2-5f24-421f-92ca-dad2351b171e")); |
|
73 |
Feature feature = (Feature) CdmStore.getService(ITermService.class).find(UUID.fromString("8125a59d-b4d5-4485-89ea-67306297b599")); |
|
74 | 74 |
//The code below retrieves the feature "Uses" as a work around |
75 |
Feature feature = (Feature) CdmStore.getService(ITermService.class).find(UUID.fromString("e5374d39-b210-47c7-bec1-bee05b5f1cb6")); |
|
75 |
//Feature feature = (Feature) CdmStore.getService(ITermService.class).find(UUID.fromString("e5374d39-b210-47c7-bec1-bee05b5f1cb6"));
|
|
76 | 76 |
feature.setSupportsCategoricalData(true); |
77 | 77 |
operation = new CreateUseRecordOperation(event |
78 | 78 |
.getCommand().getName(), |
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/uses/handler/DeleteUseHandler.java | ||
---|---|---|
9 | 9 |
import org.eclipse.core.commands.common.NotDefinedException; |
10 | 10 |
import org.eclipse.core.commands.operations.IUndoContext; |
11 | 11 |
import org.eclipse.jface.viewers.IStructuredSelection; |
12 |
import org.eclipse.jface.viewers.TreePath; |
|
13 |
import org.eclipse.jface.viewers.TreeSelection; |
|
14 | 12 |
import org.eclipse.ui.IWorkbenchPart; |
15 | 13 |
import org.eclipse.ui.handlers.HandlerUtil; |
16 | 14 |
|
17 | 15 |
import eu.etaxonomy.cdm.model.description.DescriptionElementBase; |
18 | 16 |
import eu.etaxonomy.cdm.model.description.TaxonDescription; |
19 |
import eu.etaxonomy.cdm.model.media.Media; |
|
20 | 17 |
import eu.etaxonomy.taxeditor.editor.EditorUtil; |
21 |
import eu.etaxonomy.taxeditor.editor.view.descriptive.operation.DeleteDescriptionElementOperation; |
|
22 |
import eu.etaxonomy.taxeditor.editor.view.media.operation.DeleteMediaOperation; |
|
23 | 18 |
import eu.etaxonomy.taxeditor.editor.view.uses.operation.DeleteTaxonUseOperation; |
24 | 19 |
import eu.etaxonomy.taxeditor.editor.view.uses.operation.DeleteUseRecordOperation; |
25 | 20 |
import eu.etaxonomy.taxeditor.model.FeatureNodeContainer; |
26 | 21 |
import eu.etaxonomy.taxeditor.operation.AbstractPostOperation; |
27 | 22 |
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled; |
28 | 23 |
|
24 |
/** |
|
25 |
* The context manager mediates context start/stop and workbench shutdowns to all registered listeners. |
|
26 |
* |
|
27 |
* @author a.theys |
|
28 |
* @created mar 13, 2012 |
|
29 |
* @version 1.0 |
|
30 |
*/ |
|
29 | 31 |
public class DeleteUseHandler extends AbstractHandler { |
30 | 32 |
|
31 | 33 |
/* |
... | ... | |
53 | 55 |
|
54 | 56 |
for (Object object : selection.toArray()) { |
55 | 57 |
|
56 |
AbstractPostOperation operation = null; |
|
57 |
|
|
58 | 58 |
// TaxonDescription |
59 | 59 |
if (object instanceof TaxonDescription) { |
60 | 60 |
operations.add(new DeleteTaxonUseOperation(label, |
... | ... | |
76 | 76 |
postOperationEnabled)); |
77 | 77 |
} |
78 | 78 |
} |
79 |
// Media |
|
80 |
else if (object instanceof Media) { |
|
81 |
TreeSelection treeSelection = (TreeSelection) selection; |
|
82 |
|
|
83 |
TreePath[] path = treeSelection.getPathsFor(object); |
|
84 |
|
|
85 |
TaxonDescription imageGallery = (TaxonDescription) path[0] |
|
86 |
.getFirstSegment(); |
|
87 |
|
|
88 |
operations |
|
89 |
.add(new DeleteMediaOperation(label, undoContext, |
|
90 |
imageGallery, (Media) object, |
|
91 |
postOperationEnabled)); |
|
92 |
} else { |
|
79 |
else { |
|
93 | 80 |
EditorUtil.error(getClass(), |
94 | 81 |
"Selection is not valid for this delete handler", |
95 | 82 |
null); |
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/uses/operation/CreateTaxonUseOperation.java | ||
---|---|---|
20 | 20 |
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled; |
21 | 21 |
import eu.etaxonomy.taxeditor.store.CdmStore; |
22 | 22 |
|
23 |
/** |
|
24 |
* The context manager mediates context start/stop and workbench shutdowns to all registered listeners. |
|
25 |
* |
|
26 |
* @author a.theys |
|
27 |
* @created mar 13, 2012 |
|
28 |
* @version 1.0 |
|
29 |
*/ |
|
23 | 30 |
public class CreateTaxonUseOperation extends AbstractPostOperation { |
24 | 31 |
private TaxonDescription description; |
25 | 32 |
private boolean isImageGallery; |
... | ... | |
66 | 73 |
monitor.worked(20); |
67 | 74 |
//this.markerTypes.addAll(CdmStore.getTermManager().getPreferredMarkerTypes()); |
68 | 75 |
this.markerTypes.addAll(CdmStore.getTermManager().getPreferredTerms(MarkerType.class)); |
69 |
Set<MarkerType> typesToDisdplay = new HashSet<MarkerType>(); |
|
70 | 76 |
for (MarkerType markerType : markerTypes) { |
71 | 77 |
if (markerType.getTitleCache().equals("use")) { |
72 | 78 |
marker = Marker.NewInstance(markerType, true); |
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/uses/operation/CreateUseRecordOperation.java | ||
---|---|---|
20 | 20 |
import eu.etaxonomy.taxeditor.operation.AbstractPostOperation; |
21 | 21 |
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled; |
22 | 22 |
|
23 |
|
|
24 |
/** |
|
25 |
* The context manager mediates context start/stop and workbench shutdowns to all registered listeners. |
|
26 |
* |
|
27 |
* @author a.theys |
|
28 |
* @created mar 13, 2012 |
|
29 |
* @version 1.0 |
|
30 |
*/ |
|
23 | 31 |
public class CreateUseRecordOperation extends AbstractPostOperation { |
24 | 32 |
|
25 | 33 |
public static final String ID = "eu.etaxonomy.taxeditor.editor.use.createUseRecord"; |
... | ... | |
29 | 37 |
private DescriptionElementBase element; |
30 | 38 |
|
31 | 39 |
|
32 |
/*public CreateUseRecordOperation(String label, IUndoContext undoContext, |
|
33 |
Taxon taxon, TaxonDescription description, Feature feature, IPostOperationEnabled postOperationEnabled) {*/ |
|
34 | 40 |
public CreateUseRecordOperation(String label, IUndoContext undoContext, |
35 | 41 |
Taxon taxon, TaxonDescription description, Feature feature, IPostOperationEnabled postOperationEnabled) { |
36 | 42 |
super(label, undoContext, taxon, postOperationEnabled); |
... | ... | |
43 | 49 |
IUndoContext undoContext, Taxon taxon, |
44 | 50 |
TaxonDescription description, Feature feature, |
45 | 51 |
DescriptionElementBase element, IPostOperationEnabled postOperationEnabled) { |
46 |
/*public CreateUseRecordOperation(String label, |
|
47 |
IUndoContext undoContext, Taxon taxon, |
|
48 |
TaxonDescription description, Feature feature, |
|
49 |
DescriptionElementBase element, IPostOperationEnabled postOperationEnabled) {*/ |
|
52 |
this(label, undoContext, taxon, description, feature, postOperationEnabled); |
|
50 | 53 |
|
51 |
this(label, undoContext, taxon, description, feature, postOperationEnabled); |
|
52 |
//this(label, undoContext, taxon, description, (CategoricalData) element, postOperationEnabled); |
|
53 |
|
|
54 | 54 |
this.element = element; |
55 | 55 |
} |
56 | 56 |
|
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/uses/operation/DeleteTaxonUseOperation.java | ||
---|---|---|
10 | 10 |
import eu.etaxonomy.taxeditor.operation.AbstractPostOperation; |
11 | 11 |
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled; |
12 | 12 |
|
13 |
|
|
14 |
/** |
|
15 |
* The context manager mediates context start/stop and workbench shutdowns to all registered listeners. |
|
16 |
* |
|
17 |
* @author a.theys |
|
18 |
* @created mar 13, 2012 |
|
19 |
* @version 1.0 |
|
20 |
*/ |
|
13 | 21 |
public class DeleteTaxonUseOperation extends AbstractPostOperation { |
14 | 22 |
|
15 | 23 |
private TaxonDescription description; |
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/uses/operation/DeleteUseRecordOperation.java | ||
---|---|---|
1 | 1 |
package eu.etaxonomy.taxeditor.editor.view.uses.operation; |
2 | 2 |
|
3 |
|
|
3 | 4 |
import org.eclipse.core.commands.ExecutionException; |
4 | 5 |
import org.eclipse.core.commands.operations.IUndoContext; |
5 | 6 |
import org.eclipse.core.runtime.IAdaptable; |
... | ... | |
12 | 13 |
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled; |
13 | 14 |
import eu.etaxonomy.taxeditor.store.StoreUtil; |
14 | 15 |
|
16 |
/** |
|
17 |
* The context manager mediates context start/stop and workbench shutdowns to all registered listeners. |
|
18 |
* |
|
19 |
* @author a.theys |
|
20 |
* @created mar 13, 2012 |
|
21 |
* @version 1.0 |
|
22 |
*/ |
|
15 | 23 |
public class DeleteUseRecordOperation extends AbstractPostOperation { |
16 | 24 |
private DescriptionElementBase element; |
17 | 25 |
private DescriptionBase description = null; |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/userecords/UseRecordDetailElement.java | ||
---|---|---|
22 | 22 |
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory; |
23 | 23 |
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement; |
24 | 24 |
import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement; |
25 |
import eu.etaxonomy.taxeditor.ui.section.description.DescriptionElementDetailElement; |
|
26 | 25 |
|
26 |
|
|
27 |
/** |
|
28 |
* The context manager mediates context start/stop and workbench shutdowns to all registered listeners. |
|
29 |
* |
|
30 |
* @author a.theys |
|
31 |
* @created mar 13, 2012 |
|
32 |
* @version 1.0 |
|
33 |
*/ |
|
27 | 34 |
public class UseRecordDetailElement extends |
28 | 35 |
AbstractCdmDetailElement<CategoricalData> implements SelectionListener { |
29 | 36 |
|
... | ... | |
242 | 249 |
/** {@inheritDoc} */ |
243 | 250 |
@Override |
244 | 251 |
public void handleEvent(Object eventSource) { |
245 |
/* |
|
246 |
* if(eventSource == checkbox_orderRelevant){ |
|
247 |
* getEntity().setOrderRelevant(checkbox_orderRelevant.getSelection()); |
|
248 |
* } |
|
249 |
*/ |
|
250 | 252 |
if (eventSource == combo_UseCategory) { |
251 | 253 |
if (combo_UseCategory.getSelection() != null) { |
252 | 254 |
boolean isChanged = false; |
... | ... | |
512 | 514 |
for (Object object: combo_UseCategory.getControls()) { |
513 | 515 |
if (object == eventSource) { |
514 | 516 |
State selectedUseCategory = combo_UseCategory.getSelection(); |
515 |
//List<State> newSubCategories = setUseCategoryComboTerms(TermStore.getTerms(State.class, null, false),selectedUseCategory); |
|
516 | 517 |
if (selectedUseCategory != null) { |
517 | 518 |
combo_UseSubCategory.setTerms(setUseCategoryComboTerms(TermStore.getTerms(State.class, null, false),selectedUseCategory)); |
518 | 519 |
|
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/userecords/UseRecordDetailSection.java | ||
---|---|---|
10 | 10 |
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement; |
11 | 11 |
import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailSection; |
12 | 12 |
|
13 |
/** |
|
14 |
* The context manager mediates context start/stop and workbench shutdowns to all registered listeners. |
|
15 |
* |
|
16 |
* @author a.theys |
|
17 |
* @created mar 13, 2012 |
|
18 |
* @version 1.0 |
|
19 |
*/ |
|
13 | 20 |
public class UseRecordDetailSection extends AbstractCdmDetailSection<DescriptionElementBase> { |
14 | 21 |
public UseRecordDetailSection(CdmFormFactory cdmFormFactory, ConversationHolder conversation, |
15 | 22 |
ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style) { |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/userecords/UseRecordsViewPart.java | ||
---|---|---|
14 | 14 |
import eu.etaxonomy.taxeditor.view.AbstractCdmEditorViewPart; |
15 | 15 |
import eu.etaxonomy.taxeditor.view.AbstractCdmViewPart; |
16 | 16 |
|
17 |
|
|
18 |
public class UseRecordsViewPart extends AbstractCdmEditorViewPart implements IPartContentHasSupplementalData{ |
|
17 |
/** |
|
18 |
* The context manager mediates context start/stop and workbench shutdowns to all registered listeners. |
|
19 |
* |
|
20 |
* @author a.theys |
|
21 |
* @created mar 13, 2012 |
|
22 |
* @version 1.0 |
|
23 |
*/ |
|
24 |
public class UseRecordsViewPart extends AbstractCdmEditorViewPart implements IPartContentHasSupplementalData{ |
|
19 | 25 |
|
20 |
public static String ID = "eu.etaxonomy.taxeditor.view.userecords"; |
|
21 |
private UseRecordsViewer viewer; |
|
26 |
public static String ID = "eu.etaxonomy.taxeditor.view.userecords"; |
|
27 |
private UseRecordsViewer viewer; |
|
28 |
|
|
29 |
@Override |
|
30 |
public void createViewer(Composite parent) { |
|
31 |
viewer = new UseRecordsViewer(parent, this); |
|
32 |
getSite().setSelectionProvider(viewer); |
|
22 | 33 |
|
23 |
@Override |
|
24 |
public void createViewer(Composite parent) { |
|
25 |
//selectionService.addPostSelectionListener(this); |
|
26 |
|
|
27 |
viewer = new UseRecordsViewer(parent, this); |
|
28 |
getSite().setSelectionProvider(viewer); |
|
29 |
|
|
34 |
} |
|
35 |
|
|
36 |
@Override |
|
37 |
public void selectionChanged(IWorkbenchPart part, ISelection selection) { |
|
38 |
if(StoreUtil.getActiveEditor() == null){ |
|
39 |
showEmptyPage(); |
|
40 |
return; |
|
41 |
} |
|
42 |
|
|
43 |
if(part == this){ |
|
44 |
return; |
|
30 | 45 |
} |
31 | 46 |
|
32 |
@Override |
|
33 |
public void selectionChanged(IWorkbenchPart part, ISelection selection) { |
|
34 |
if(StoreUtil.getActiveEditor() == null){ |
|
47 |
if(!(selection instanceof IStructuredSelection)){ |
|
48 |
return; |
|
49 |
} |
|
50 |
|
|
51 |
IStructuredSelection structuredSelection = (IStructuredSelection) selection; |
|
52 |
|
|
53 |
if((part instanceof IEditorPart) || (part instanceof AbstractCdmViewPart)) { |
|
54 |
if(structuredSelection.size() != 1){ |
|
35 | 55 |
showEmptyPage(); |
36 | 56 |
return; |
37 | 57 |
} |
38 | 58 |
|
39 |
if(part == this){ |
|
40 |
return; |
|
41 |
} |
|
42 |
|
|
43 |
if(!(selection instanceof IStructuredSelection)){ |
|
44 |
return; |
|
45 |
} |
|
46 |
|
|
47 |
IStructuredSelection structuredSelection = (IStructuredSelection) selection; |
|
48 |
|
|
49 |
if((part instanceof IEditorPart) || (part instanceof AbstractCdmViewPart)) { |
|
50 |
if(structuredSelection.size() != 1){ |
|
59 |
// do not show details for feature nodes TODO really? |
|
60 |
if(structuredSelection.getFirstElement() instanceof FeatureNodeContainer){ |
|
61 |
// do show the map for distributions |
|
62 |
Feature feature = ((FeatureNodeContainer) ((IStructuredSelection) selection).getFirstElement()).getFeature(); |
|
63 |
if(!feature.equals(Feature.DISTRIBUTION())){ |
|
51 | 64 |
showEmptyPage(); |
52 | 65 |
return; |
53 | 66 |
} |
54 |
|
|
55 |
// do not show details for feature nodes TODO really? |
|
56 |
if(structuredSelection.getFirstElement() instanceof FeatureNodeContainer){ |
|
57 |
// do show the map for distributions |
|
58 |
Feature feature = ((FeatureNodeContainer) ((IStructuredSelection) selection).getFirstElement()).getFeature(); |
|
59 |
if(!feature.equals(Feature.DISTRIBUTION())){ |
|
60 |
showEmptyPage(); |
|
61 |
return; |
|
62 |
} |
|
63 |
} |
|
64 |
|
|
65 |
showViewer(part, structuredSelection); |
|
66 |
}else{ |
|
67 |
showEmptyPage(); |
|
68 |
} |
|
67 |
} |
|
69 | 68 |
|
70 |
} |
|
69 |
showViewer(part, structuredSelection); |
|
70 |
}else{ |
|
71 |
showEmptyPage(); |
|
72 |
} |
|
71 | 73 |
|
72 |
@Override |
|
73 |
public Viewer getViewer() { |
|
74 |
return viewer; |
|
75 |
} |
|
74 |
} |
|
75 |
|
|
76 |
@Override |
|
77 |
public Viewer getViewer() { |
|
78 |
return viewer; |
|
79 |
} |
|
76 | 80 |
|
77 |
/** {@inheritDoc} */
|
|
78 |
@Override
|
|
79 |
public void dispose() {
|
|
80 |
super.dispose();
|
|
81 |
selectionService.removePostSelectionListener(this);
|
|
82 |
}
|
|
81 |
/** {@inheritDoc} */ |
|
82 |
@Override |
|
83 |
public void dispose() { |
|
84 |
super.dispose(); |
|
85 |
selectionService.removePostSelectionListener(this); |
|
86 |
} |
|
83 | 87 |
|
84 |
/**
|
|
85 |
* <p>onComplete</p>
|
|
86 |
*
|
|
87 |
* @return a boolean.
|
|
88 |
*/
|
|
89 |
public boolean onComplete() {
|
|
90 |
return true;
|
|
91 |
}
|
|
88 |
/** |
|
89 |
* <p>onComplete</p> |
|
90 |
* |
|
91 |
* @return a boolean. |
|
92 |
*/ |
|
93 |
public boolean onComplete() { |
|
94 |
return true; |
|
95 |
} |
|
92 | 96 |
|
93 | 97 |
|
94 | 98 |
|
95 | 99 |
|
96 | 100 |
|
97 | 101 |
|
98 |
} |
|
102 |
} |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/userecords/UseRecordsViewer.java | ||
---|---|---|
12 | 12 |
import eu.etaxonomy.cdm.model.description.DescriptionBase; |
13 | 13 |
import eu.etaxonomy.cdm.model.description.DescriptionElementBase; |
14 | 14 |
import eu.etaxonomy.cdm.model.occurrence.DerivedUnitBase; |
15 |
import eu.etaxonomy.cdm.model.reference.Reference; |
|
16 | 15 |
import eu.etaxonomy.cdm.model.taxon.TaxonBase; |
17 | 16 |
import eu.etaxonomy.taxeditor.preference.PreferencesUtil; |
18 | 17 |
import eu.etaxonomy.taxeditor.store.StoreUtil; |
19 | 18 |
import eu.etaxonomy.taxeditor.ui.element.RootElement; |
20 | 19 |
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory.DetailType; |
21 | 20 |
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory.EntityDetailType; |
22 |
import eu.etaxonomy.taxeditor.ui.section.description.DescribedSpecimenSection; |
|
23 | 21 |
import eu.etaxonomy.taxeditor.ui.section.description.DescriptionDetailSection; |
24 |
import eu.etaxonomy.taxeditor.ui.section.description.DescriptionElementDetailSection; |
|
25 |
import eu.etaxonomy.taxeditor.ui.section.description.DescriptionElementMediaSection; |
|
26 |
import eu.etaxonomy.taxeditor.ui.section.description.DescriptionElementSourceSection; |
|
27 | 22 |
import eu.etaxonomy.taxeditor.ui.section.description.DescriptionSourceSection; |
28 |
import eu.etaxonomy.taxeditor.ui.section.description.NaturalLanguageSection; |
|
29 |
import eu.etaxonomy.taxeditor.ui.section.description.ScopeSection; |
|
30 | 23 |
import eu.etaxonomy.taxeditor.ui.section.name.NameRelationshipDetailSection; |
31 | 24 |
import eu.etaxonomy.taxeditor.ui.section.name.NomenclaturalStatusSection; |
32 | 25 |
import eu.etaxonomy.taxeditor.ui.section.name.NonViralNameDetailSection; |
... | ... | |
42 | 35 |
import eu.etaxonomy.taxeditor.view.AbstractCdmViewPart; |
43 | 36 |
|
44 | 37 |
|
45 |
|
|
46 |
|
|
47 |
|
|
38 |
/** |
|
39 |
* The context manager mediates context start/stop and workbench shutdowns to all registered listeners. |
|
40 |
* |
|
41 |
* @author a.theys |
|
42 |
* @created mar 13, 2012 |
|
43 |
* @version 1.0 |
|
44 |
*/ |
|
48 | 45 |
public class UseRecordsViewer extends AbstractCdmDataViewer { |
49 | 46 |
|
50 | 47 |
private ISelection selection; |
Also available in: Unified diff
AT: committing latest changes to the Tax Editor after a first round of Code review