Revision b7b99774
Added by Patrick Plitzner almost 10 years ago
- implemented "Save Specimen" command
- added @Override annotations
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/command/SaveSpecimenCommand.java | ||
---|---|---|
3 | 3 |
import org.eclipse.core.commands.AbstractHandler; |
4 | 4 |
import org.eclipse.core.commands.ExecutionEvent; |
5 | 5 |
import org.eclipse.core.commands.ExecutionException; |
6 |
import org.eclipse.jface.viewers.ISelection; |
|
7 |
import org.eclipse.ui.IWorkbenchWindow; |
|
8 |
import org.eclipse.ui.PlatformUI; |
|
9 |
|
|
10 |
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase; |
|
11 |
import eu.etaxonomy.taxeditor.model.LineSelection; |
|
12 |
import eu.etaxonomy.taxeditor.store.CdmStore; |
|
6 | 13 |
|
7 | 14 |
public class SaveSpecimenCommand extends AbstractHandler { |
8 | 15 |
|
... | ... | |
11 | 18 |
*/ |
12 | 19 |
@Override |
13 | 20 |
public Object execute(ExecutionEvent event) throws ExecutionException { |
14 |
// TODO Auto-generated method stub |
|
21 |
final IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); |
|
22 |
final ISelection selection = window.getActivePage().getSelection(); |
|
23 |
if(selection instanceof LineSelection){ |
|
24 |
LineSelection line = (LineSelection)selection; |
|
25 |
Object firstElement = line.getFirstElement(); |
|
26 |
if(firstElement instanceof SpecimenOrObservationBase){ |
|
27 |
CdmStore.getCurrentApplicationConfiguration().getOccurrenceService().saveOrUpdate((SpecimenOrObservationBase) firstElement); |
|
28 |
} |
|
29 |
} |
|
15 | 30 |
return null; |
16 | 31 |
} |
17 | 32 |
|
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/model/LineSelection.java | ||
---|---|---|
1 | 1 |
// $Id$ |
2 | 2 |
/** |
3 | 3 |
* Copyright (C) 2007 EDIT |
4 |
* European Distributed Institute of Taxonomy
|
|
4 |
* European Distributed Institute of Taxonomy |
|
5 | 5 |
* http://www.e-taxonomy.eu |
6 |
*
|
|
6 |
* |
|
7 | 7 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
8 | 8 |
* See LICENSE.TXT at the top of this package for the full license terms. |
9 | 9 |
*/ |
... | ... | |
31 | 31 |
public class LineSelection extends TextSelection implements IStructuredSelection { |
32 | 32 |
|
33 | 33 |
private StructuredSelection structuredSelection; |
34 |
|
|
34 |
|
|
35 | 35 |
/** |
36 | 36 |
* <p>Constructor for LineSelection.</p> |
37 | 37 |
* |
... | ... | |
56 | 56 |
* |
57 | 57 |
* @return a {@link java.lang.Object} object. |
58 | 58 |
*/ |
59 |
public Object getFirstElement() { |
|
59 |
@Override |
|
60 |
public Object getFirstElement() { |
|
60 | 61 |
return structuredSelection.getFirstElement(); |
61 | 62 |
} |
62 | 63 |
|
... | ... | |
68 | 69 |
* |
69 | 70 |
* @return a {@link java.util.Iterator} object. |
70 | 71 |
*/ |
71 |
public Iterator<?> iterator() { |
|
72 |
@Override |
|
73 |
public Iterator<?> iterator() { |
|
72 | 74 |
return structuredSelection.iterator(); |
73 | 75 |
} |
74 | 76 |
|
... | ... | |
80 | 82 |
* |
81 | 83 |
* @return a int. |
82 | 84 |
*/ |
83 |
public int size() { |
|
85 |
@Override |
|
86 |
public int size() { |
|
84 | 87 |
return structuredSelection.size(); |
85 | 88 |
} |
86 | 89 |
|
... | ... | |
92 | 95 |
* |
93 | 96 |
* @return an array of {@link java.lang.Object} objects. |
94 | 97 |
*/ |
95 |
public Object[] toArray() { |
|
98 |
@Override |
|
99 |
public Object[] toArray() { |
|
96 | 100 |
return structuredSelection.toArray(); |
97 | 101 |
} |
98 | 102 |
|
... | ... | |
104 | 108 |
* |
105 | 109 |
* @return a {@link java.util.List} object. |
106 | 110 |
*/ |
107 |
public List<?> toList() { |
|
111 |
@Override |
|
112 |
public List<?> toList() { |
|
108 | 113 |
return structuredSelection.toList(); |
109 | 114 |
} |
110 | 115 |
} |
Also available in: Unified diff