Revision 95ee1b51
Added by U-BGBM\k.luther over 8 years ago
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/handler/MoveTaxonHandler.java | ||
---|---|---|
1 | 1 |
/** |
2 | 2 |
* Copyright (C) 2007 EDIT |
3 |
* European Distributed Institute of Taxonomy
|
|
3 |
* European Distributed Institute of Taxonomy |
|
4 | 4 |
* http://www.e-taxonomy.eu |
5 |
*
|
|
5 |
* |
|
6 | 6 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
7 | 7 |
* See LICENSE.TXT at the top of this package for the full license terms. |
8 | 8 |
*/ |
... | ... | |
19 | 19 |
import org.eclipse.core.commands.AbstractHandler; |
20 | 20 |
import org.eclipse.core.commands.ExecutionEvent; |
21 | 21 |
import org.eclipse.core.commands.ExecutionException; |
22 |
import org.eclipse.core.expressions.EvaluationContext; |
|
23 | 22 |
import org.eclipse.jface.dialogs.MessageDialog; |
24 | 23 |
import org.eclipse.jface.viewers.TreeSelection; |
25 |
import org.eclipse.ui.IEditorInput; |
|
26 |
import org.eclipse.ui.IEditorReference; |
|
27 | 24 |
import org.eclipse.ui.IWorkbenchPage; |
28 |
import org.eclipse.ui.PartInitException; |
|
29 | 25 |
import org.eclipse.ui.handlers.HandlerUtil; |
30 | 26 |
|
31 |
import eu.etaxonomy.cdm.api.application.ICdmApplicationConfiguration; |
|
32 |
import eu.etaxonomy.cdm.api.service.ITaxonNodeService; |
|
33 | 27 |
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper; |
34 | 28 |
import eu.etaxonomy.cdm.model.common.CdmBase; |
35 |
import eu.etaxonomy.cdm.model.common.ITreeNode; |
|
36 |
import eu.etaxonomy.cdm.model.taxon.ITaxonTreeNode; |
|
37 | 29 |
import eu.etaxonomy.cdm.model.taxon.TaxonNode; |
38 |
import eu.etaxonomy.taxeditor.editor.TaxonEditorInput; |
|
39 | 30 |
import eu.etaxonomy.taxeditor.navigation.NavigationUtil; |
40 | 31 |
import eu.etaxonomy.taxeditor.navigation.navigator.TaxonNavigator; |
41 | 32 |
import eu.etaxonomy.taxeditor.navigation.navigator.operation.MoveTaxonOperation; |
42 | 33 |
import eu.etaxonomy.taxeditor.operation.AbstractPostOperation; |
43 | 34 |
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled; |
44 | 35 |
import eu.etaxonomy.taxeditor.preference.PreferencesUtil; |
45 |
import eu.etaxonomy.taxeditor.store.CdmStore; |
|
46 | 36 |
import eu.etaxonomy.taxeditor.ui.dialog.selection.TaxonNodeSelectionDialog; |
47 |
import eu.etaxonomy.taxeditor.ui.dialog.selection.TaxonNodeSelectionNaturalOrderDialog; |
|
48 | 37 |
|
49 | 38 |
/** |
50 | 39 |
* <p>MoveTaxonHandler class.</p> |
... | ... | |
61 | 50 |
* @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent) |
62 | 51 |
*/ |
63 | 52 |
/** {@inheritDoc} */ |
64 |
public Object execute(ExecutionEvent event) throws ExecutionException { |
|
53 |
@Override |
|
54 |
public Object execute(ExecutionEvent event) throws ExecutionException { |
|
65 | 55 |
activePage = HandlerUtil.getActiveWorkbenchWindow(event).getActivePage(); |
66 | 56 |
TaxonNavigator taxonNavigator = (TaxonNavigator)NavigationUtil.showView(TaxonNavigator.ID); |
67 |
|
|
57 |
|
|
68 | 58 |
TreeSelection selection = (TreeSelection) HandlerUtil.getCurrentSelection(event); |
69 |
|
|
59 |
|
|
70 | 60 |
Iterator selectionIterator = selection.iterator(); |
71 |
TaxonNode taxonNode = null; |
|
72 |
UUID taxonNodeUUID = null; |
|
61 |
Set<TaxonNode> taxonNodes = new HashSet<TaxonNode>(); |
|
62 |
TaxonNode taxonNode= null; |
|
63 |
Set<UUID> taxonNodeUUIDs = new HashSet<UUID>(); |
|
73 | 64 |
// do not show the current selection |
74 | 65 |
List<UUID> excludeTaxa = new ArrayList<UUID>(); |
75 |
|
|
76 |
if (selection.size() == 1){ |
|
66 |
|
|
67 |
//if (selection.size() == 1){ |
|
68 |
|
|
69 |
while (selectionIterator.hasNext()){ |
|
77 | 70 |
Object object = selectionIterator.next(); |
78 | 71 |
if(object instanceof TaxonNode){ |
79 |
taxonNode = HibernateProxyHelper.deproxy(object,TaxonNode.class); |
|
80 |
taxonNodeUUID = taxonNode.getUuid(); |
|
72 |
taxonNode = HibernateProxyHelper.deproxy(object,TaxonNode.class); |
|
73 |
taxonNodes.add(taxonNode); |
|
74 |
taxonNodeUUIDs.add(taxonNode.getUuid()); |
|
81 | 75 |
excludeTaxa.add(taxonNode.getTaxon().getUuid()); |
82 | 76 |
} |
83 |
} else{ |
|
77 |
} |
|
78 |
/*} else{ |
|
84 | 79 |
if( MessageDialog.openConfirm(HandlerUtil.getActiveShell(event), "Moving taxon", "The operation move accepted taxon to other parent is available only for a single taxon.")){ |
85 | 80 |
return null; |
86 | 81 |
} |
87 |
} |
|
88 |
|
|
89 |
|
|
82 |
}*/
|
|
83 |
|
|
84 |
|
|
90 | 85 |
// TaxonNode taxonNode = (TaxonNode) selection.getFirstElement(); |
91 |
if (taxonNode != null){
|
|
92 |
boolean moveToNewParent = true;
|
|
86 |
if (taxonNodes.size() >= 1){
|
|
87 |
boolean moveToNewParent = true; |
|
93 | 88 |
if (PreferencesUtil.getSortNodesNaturally()){ |
94 | 89 |
if(!MessageDialog.openQuestion(null, "Target node", "The choosen target node should be the parent?")){ |
95 | 90 |
moveToNewParent = false; |
... | ... | |
104 | 99 |
"changes in the parent taxon. Please save first."); |
105 | 100 |
return null; |
106 | 101 |
} |
107 |
|
|
102 |
|
|
108 | 103 |
AbstractPostOperation operation = new MoveTaxonOperation |
109 | 104 |
("Move taxon to new parent", NavigationUtil.getUndoContext(), |
110 |
taxonNode, parentTaxonNode, taxonNavigator, taxonNavigator, moveToNewParent); //$NON-NLS-1$ |
|
105 |
taxonNodeUUIDs, parentTaxonNode, taxonNavigator, taxonNavigator, moveToNewParent); //$NON-NLS-1$
|
|
111 | 106 |
NavigationUtil.executeOperation(operation); |
112 | 107 |
taxonNavigator.refresh(); |
113 |
|
|
108 |
|
|
114 | 109 |
} |
115 | 110 |
} |
116 | 111 |
return null; |
... | ... | |
120 | 115 |
* @see eu.etaxonomy.taxeditor.operations.IPostOperationEnabled#postOperation(eu.etaxonomy.cdm.model.common.CdmBase) |
121 | 116 |
*/ |
122 | 117 |
/** {@inheritDoc} */ |
123 |
public boolean postOperation(CdmBase objectAffectedByOperation) { |
|
118 |
@Override |
|
119 |
public boolean postOperation(CdmBase objectAffectedByOperation) { |
|
124 | 120 |
return true; |
125 | 121 |
} |
126 | 122 |
|
... | ... | |
129 | 125 |
* |
130 | 126 |
* @return a boolean. |
131 | 127 |
*/ |
132 |
public boolean onComplete() { |
|
128 |
@Override |
|
129 |
public boolean onComplete() { |
|
133 | 130 |
return false; |
134 | 131 |
} |
135 |
|
|
136 |
|
|
137 |
|
|
132 |
|
|
133 |
|
|
134 |
|
|
138 | 135 |
} |
Also available in: Unified diff
moving more than one taxon node, merge of team and person, reusing name for new taxon