Revision 69373790
Added by U-BGBM\k.luther over 8 years ago
eu.etaxonomy.taxeditor.editor/plugin.xml | ||
---|---|---|
682 | 682 |
<visibleWhen |
683 | 683 |
checkEnabled="true"> |
684 | 684 |
<or> |
685 |
<reference |
|
686 |
definitionId="isDescriptionElement"> |
|
687 |
</reference> |
|
688 | 685 |
<reference |
689 | 686 |
definitionId="isFeatureNodeContainer"> |
690 | 687 |
</reference> |
... | ... | |
1300 | 1297 |
id="eu.etaxonomy.taxeditor.editor.media.command.delete" |
1301 | 1298 |
name="%command.name.49"> |
1302 | 1299 |
</command> |
1300 |
|
|
1303 | 1301 |
<category |
1304 | 1302 |
id="eu.etaxonomy.taxeditor.editor.new.category" |
1305 | 1303 |
name="%category.name.4"> |
... | ... | |
1442 | 1440 |
<command |
1443 | 1441 |
categoryId="eu.etaxonomy.taxeditor.editor.view.descriptive.command.category" |
1444 | 1442 |
defaultHandler="eu.etaxonomy.taxeditor.editor.view.descriptive.handler.MoveDescriptionToOtherTaxonHandler" |
1445 |
id="eu.etaxonomy.taxeditor.editor.commands.description.moveDescriptionToTaxon"
|
|
1443 |
id="eu.etaxonomy.taxeditor.editor.view.descriptive.command.moveDescriptionToTaxon"
|
|
1446 | 1444 |
name="%command.name.13"> |
1447 | 1445 |
</command> |
1446 |
|
|
1448 | 1447 |
<command |
1449 | 1448 |
categoryId="eu.etaxonomy.taxeditor.editor.view.descriptive.command.category" |
1450 | 1449 |
defaultHandler="eu.etaxonomy.taxeditor.editor.view.descriptive.handler.MoveDescriptionElementsHandler" |
1451 |
id="eu.etaxonomy.taxeditor.description.commands.moveDescriptionElements"
|
|
1450 |
id="eu.etaxonomy.taxeditor.editor.view.descriptive.command.moveDescriptionElements"
|
|
1452 | 1451 |
name="%command.name.12"> |
1453 | 1452 |
</command> |
1454 | 1453 |
|
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/handler/MoveDescriptionElementsHandler.java | ||
---|---|---|
20 | 20 |
import org.eclipse.core.commands.common.NotDefinedException; |
21 | 21 |
import org.eclipse.jface.viewers.ISelection; |
22 | 22 |
import org.eclipse.jface.viewers.IStructuredSelection; |
23 |
import org.eclipse.swt.widgets.Display; |
|
24 |
import org.eclipse.ui.PartInitException; |
|
23 | 25 |
import org.eclipse.ui.handlers.HandlerUtil; |
24 | 26 |
|
25 | 27 |
import eu.etaxonomy.cdm.api.service.IDescriptionService; |
26 | 28 |
import eu.etaxonomy.cdm.api.service.ITaxonService; |
29 |
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper; |
|
27 | 30 |
import eu.etaxonomy.cdm.model.common.Annotation; |
28 | 31 |
import eu.etaxonomy.cdm.model.common.AnnotationType; |
32 |
import eu.etaxonomy.cdm.model.common.CdmBase; |
|
29 | 33 |
import eu.etaxonomy.cdm.model.common.Language; |
34 |
import eu.etaxonomy.cdm.model.description.DescriptionBase; |
|
30 | 35 |
import eu.etaxonomy.cdm.model.description.DescriptionElementBase; |
31 | 36 |
import eu.etaxonomy.cdm.model.description.TaxonDescription; |
32 | 37 |
import eu.etaxonomy.cdm.model.taxon.Taxon; |
38 |
import eu.etaxonomy.cdm.model.taxon.TaxonNode; |
|
33 | 39 |
import eu.etaxonomy.taxeditor.editor.EditorUtil; |
40 |
import eu.etaxonomy.taxeditor.editor.MultiPageTaxonEditor; |
|
41 |
import eu.etaxonomy.taxeditor.editor.Page; |
|
42 |
import eu.etaxonomy.taxeditor.editor.name.TaxonNameEditor; |
|
34 | 43 |
import eu.etaxonomy.taxeditor.editor.view.descriptive.DescriptiveViewPart; |
35 | 44 |
import eu.etaxonomy.taxeditor.editor.view.descriptive.operation.MoveDescriptionElementsOperation; |
45 |
import eu.etaxonomy.taxeditor.model.AbstractUtility; |
|
36 | 46 |
import eu.etaxonomy.taxeditor.model.FeatureNodeContainer; |
37 | 47 |
import eu.etaxonomy.taxeditor.model.MessagingUtils; |
38 | 48 |
import eu.etaxonomy.taxeditor.operation.AbstractPostOperation; |
39 | 49 |
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled; |
40 | 50 |
import eu.etaxonomy.taxeditor.store.CdmStore; |
41 | 51 |
import eu.etaxonomy.taxeditor.ui.dialog.selection.TaxonBaseSelectionDialog; |
52 |
import eu.etaxonomy.taxeditor.ui.dialog.selection.TaxonNodeSelectionDialog; |
|
42 | 53 |
|
43 | 54 |
|
44 | 55 |
/** |
... | ... | |
46 | 57 |
* @created Feb 8, 2011 |
47 | 58 |
* @version 1.0 |
48 | 59 |
*/ |
49 |
public class MoveDescriptionElementsHandler extends AbstractHandler { |
|
50 |
|
|
60 |
public class MoveDescriptionElementsHandler extends AbstractHandler implements IPostOperationEnabled{ |
|
61 |
private UUID newAcceptedTaxonNodeUuid; |
|
62 |
private TaxonNameEditor editor; |
|
51 | 63 |
/* (non-Javadoc) |
52 | 64 |
* @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent) |
53 | 65 |
*/ |
... | ... | |
55 | 67 |
public Object execute(ExecutionEvent event) throws ExecutionException { |
56 | 68 |
|
57 | 69 |
// ConversationHolder conversation = CdmStore.createConversation(); |
58 |
|
|
70 |
editor = (TaxonNameEditor) EditorUtil.getActiveEditorPage(Page.NAME); |
|
59 | 71 |
ISelection selection = HandlerUtil.getCurrentSelection(event); |
60 | 72 |
|
61 | 73 |
if(selection instanceof IStructuredSelection){ |
... | ... | |
81 | 93 |
if(elements.size() == 0){ |
82 | 94 |
return null; |
83 | 95 |
} |
96 |
DescriptionBase description = elements.get(0).getInDescription(); |
|
97 |
List<UUID> excludeTaxa = new ArrayList<UUID>(); |
|
98 |
if (description.isInstanceOf(TaxonDescription.class)){ |
|
99 |
TaxonDescription taxonDescription = HibernateProxyHelper.deproxy(description, TaxonDescription.class); |
|
100 |
Taxon actualTaxon = taxonDescription.getTaxon(); |
|
101 |
excludeTaxa.add(actualTaxon.getUuid()); |
|
102 |
} |
|
84 | 103 |
|
85 |
Taxon targetTaxon = TaxonBaseSelectionDialog.selectTaxon(HandlerUtil.getActiveShell(event), EditorUtil.getActiveMultiPageTaxonEditor().getConversationHolder(), null); |
|
104 |
|
|
105 |
TaxonNode newAcceptedTaxonNode = TaxonNodeSelectionDialog.select(HandlerUtil.getActiveShell(event), |
|
106 |
editor.getConversationHolder(), |
|
107 |
"Choose the accepted taxon", |
|
108 |
excludeTaxa, |
|
109 |
null, |
|
110 |
null); |
|
111 |
Taxon targetTaxon = newAcceptedTaxonNode.getTaxon(); |
|
86 | 112 |
|
87 | 113 |
if(targetTaxon == null){ |
88 | 114 |
// canceled |
89 | 115 |
return null; |
90 | 116 |
} |
91 |
|
|
117 |
newAcceptedTaxonNodeUuid = newAcceptedTaxonNode.getUuid(); |
|
92 | 118 |
TaxonDescription targetDescription = TaxonDescription.NewInstance(targetTaxon); |
93 | 119 |
String moveMessage = String.format("Elements moved from %s", EditorUtil.getActiveMultiPageTaxonEditor().getTaxon()); |
94 | 120 |
targetDescription.setTitleCache(moveMessage, true); |
... | ... | |
99 | 125 |
try { |
100 | 126 |
AbstractPostOperation operation = new MoveDescriptionElementsOperation( |
101 | 127 |
event.getCommand().getName(), EditorUtil.getUndoContext(), |
102 |
targetDescription, elements, false, (IPostOperationEnabled) EditorUtil.getView(DescriptiveViewPart.ID, true)); |
|
128 |
targetDescription, elements, false, this); |
|
129 |
|
|
103 | 130 |
EditorUtil.executeOperation(operation); |
104 |
// conversation.commit(true); |
|
105 |
CdmStore.getService(ITaxonService.class).saveOrUpdate(targetTaxon); |
|
131 |
|
|
132 |
//CdmStore.getService(ITaxonService.class).saveOrUpdate(targetTaxon);
|
|
106 | 133 |
|
107 | 134 |
} catch (NotDefinedException e) { |
108 | 135 |
MessagingUtils.error(getClass(), e); |
... | ... | |
112 | 139 |
return null; |
113 | 140 |
} |
114 | 141 |
|
142 |
/* (non-Javadoc) |
|
143 |
* @see eu.etaxonomy.taxeditor.operations.IPostOperationEnabled#postOperation(eu.etaxonomy.cdm.model.common.CdmBase) |
|
144 |
*/ |
|
145 |
/** {@inheritDoc} */ |
|
146 |
@Override |
|
147 |
public boolean postOperation(CdmBase objectAffectedByOperation) { |
|
148 |
|
|
149 |
editor.getConversationHolder().bind(); |
|
150 |
editor.getConversationHolder().commit(true); |
|
151 |
Display.getDefault().asyncExec(new Runnable(){ |
|
152 |
|
|
153 |
public void run() { |
|
154 |
//AbstractUtility.close(editor.getMultiPageTaxonEditor()); |
|
155 |
|
|
156 |
try { |
|
157 |
MultiPageTaxonEditor possibleOpenEditor = (MultiPageTaxonEditor) EditorUtil.findEditorByTaxonNodeUuid(newAcceptedTaxonNodeUuid); |
|
158 |
if(possibleOpenEditor != null){ |
|
159 |
AbstractUtility.close(possibleOpenEditor); |
|
160 |
} |
|
161 |
EditorUtil.openTaxonNode(newAcceptedTaxonNodeUuid); |
|
162 |
} catch (PartInitException e) { |
|
163 |
MessagingUtils.error(this.getClass(), e); |
|
164 |
throw new RuntimeException(e); |
|
165 |
} catch (Exception e) { |
|
166 |
MessagingUtils.warningDialog("Could not create Taxon", this, e.getMessage()); |
|
167 |
} |
|
168 |
} |
|
169 |
|
|
170 |
}); |
|
171 |
|
|
172 |
|
|
173 |
return true; |
|
174 |
} |
|
175 |
|
|
176 |
@Override |
|
177 |
public boolean onComplete() { |
|
178 |
// TODO Auto-generated method stub |
|
179 |
return false; |
|
180 |
} |
|
181 |
|
|
115 | 182 |
} |
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/handler/MoveDescriptionToOtherTaxonHandler.java | ||
---|---|---|
20 | 20 |
|
21 | 21 |
import eu.etaxonomy.cdm.api.service.IDescriptionService; |
22 | 22 |
import eu.etaxonomy.cdm.model.common.CdmBase; |
23 |
import eu.etaxonomy.cdm.model.description.DescriptionBase; |
|
23 | 24 |
import eu.etaxonomy.cdm.model.description.TaxonDescription; |
24 | 25 |
import eu.etaxonomy.cdm.model.taxon.TaxonNode; |
25 | 26 |
import eu.etaxonomy.taxeditor.editor.EditorUtil; |
... | ... | |
28 | 29 |
import eu.etaxonomy.taxeditor.editor.name.TaxonNameEditor; |
29 | 30 |
import eu.etaxonomy.taxeditor.editor.view.descriptive.operation.MoveDescriptionToOtherTaxonOperation; |
30 | 31 |
import eu.etaxonomy.taxeditor.model.AbstractUtility; |
32 |
import eu.etaxonomy.taxeditor.model.FeatureNodeContainer; |
|
31 | 33 |
import eu.etaxonomy.taxeditor.model.MessagingUtils; |
32 | 34 |
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled; |
33 | 35 |
import eu.etaxonomy.taxeditor.store.CdmStore; |
... | ... | |
66 | 68 |
IStructuredSelection structuredSelection = (IStructuredSelection) selection; |
67 | 69 |
|
68 | 70 |
for(Object element : structuredSelection.toArray()){ |
69 |
if (element instanceof TaxonDescription){ |
|
70 |
UUID uuid = ((TaxonDescription)element).getUuid(); |
|
71 |
UUID uuid = null; |
|
72 |
if (element instanceof FeatureNodeContainer){ |
|
73 |
uuid = ((FeatureNodeContainer)element).getDescription().getUuid(); |
|
74 |
} else if (element instanceof DescriptionBase){ |
|
75 |
uuid = ((DescriptionBase)element).getUuid(); |
|
76 |
} |
|
77 |
|
|
78 |
if (uuid != null){ |
|
71 | 79 |
descriptions.add((TaxonDescription) CdmStore.getService(IDescriptionService.class).load(uuid, null)); |
72 | 80 |
} |
73 | 81 |
} |
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/operation/MoveDescriptionElementsOperation.java | ||
---|---|---|
17 | 17 |
import org.eclipse.core.runtime.IAdaptable; |
18 | 18 |
import org.eclipse.core.runtime.IProgressMonitor; |
19 | 19 |
import org.eclipse.core.runtime.IStatus; |
20 |
import org.eclipse.swt.widgets.Display; |
|
21 |
import org.eclipse.ui.PartInitException; |
|
20 | 22 |
|
21 | 23 |
import eu.etaxonomy.cdm.api.service.IDescriptionService; |
24 |
import eu.etaxonomy.cdm.model.common.CdmBase; |
|
22 | 25 |
import eu.etaxonomy.cdm.model.description.DescriptionBase; |
23 | 26 |
import eu.etaxonomy.cdm.model.description.DescriptionElementBase; |
27 |
import eu.etaxonomy.taxeditor.editor.EditorUtil; |
|
28 |
import eu.etaxonomy.taxeditor.editor.MultiPageTaxonEditor; |
|
29 |
import eu.etaxonomy.taxeditor.model.AbstractUtility; |
|
30 |
import eu.etaxonomy.taxeditor.model.MessagingUtils; |
|
24 | 31 |
import eu.etaxonomy.taxeditor.operation.AbstractPostTaxonOperation; |
25 | 32 |
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled; |
26 | 33 |
import eu.etaxonomy.taxeditor.store.CdmStore; |
... | ... | |
30 | 37 |
* @created Feb 8, 2011 |
31 | 38 |
* @version 1.0 |
32 | 39 |
*/ |
33 |
public class MoveDescriptionElementsOperation extends AbstractPostTaxonOperation {
|
|
40 |
public class MoveDescriptionElementsOperation extends AbstractPostTaxonOperation{ |
|
34 | 41 |
|
35 | 42 |
private Collection<DescriptionElementBase> descriptionElements; |
36 | 43 |
private DescriptionBase targetDescription; |
... | ... | |
68 | 75 |
|
69 | 76 |
service.moveDescriptionElementsToDescription(descriptionElements, targetDescription, isCopy); |
70 | 77 |
|
78 |
|
|
71 | 79 |
return postExecute(targetDescription); |
72 | 80 |
} |
73 | 81 |
|
... | ... | |
90 | 98 |
// TODO Auto-generated method stub |
91 | 99 |
return null; |
92 | 100 |
} |
101 |
|
|
102 |
|
|
93 | 103 |
|
94 | 104 |
} |
Also available in: Unified diff
changes for move descriptions and description elements