Project

General

Profile

« Previous | Next » 

Revision 025f3eb9

Added by Cherian Mathew over 8 years ago

Update operation for move taxon nodes

View differences:

eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/handler/MoveTaxonHandler.java
10 10
package eu.etaxonomy.taxeditor.navigation.navigator.handler;
11 11

  
12 12
import java.util.ArrayList;
13
import java.util.HashSet;
13 14
import java.util.Iterator;
14 15
import java.util.List;
16
import java.util.Set;
15 17
import java.util.UUID;
16 18

  
17 19
import org.eclipse.core.commands.AbstractHandler;
......
48 50
	 * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
49 51
	 */
50 52
	/** {@inheritDoc} */
51

  
52 53
	@Override
53 54
    public Object execute(ExecutionEvent event) throws ExecutionException {
54 55
		activePage = HandlerUtil.getActiveWorkbenchWindow(event).getActivePage();
......
57 58
		TreeSelection selection = (TreeSelection) HandlerUtil.getCurrentSelection(event);
58 59

  
59 60
		Iterator selectionIterator = selection.iterator();
60
		TaxonNode taxonNode = null;
61
		UUID taxonNodeUUID = null;
61
		Set<TaxonNode> taxonNodes = new HashSet<TaxonNode>();
62
		TaxonNode taxonNode= null;
63
		Set<UUID> taxonNodeUUIDs = new HashSet<UUID>();
62 64
		// do not show the current selection
63 65
		List<UUID> excludeTaxa = new ArrayList<UUID>();
64 66

  
67
		//if (selection.size() == 1){
65 68

  
66
		if (selection.size() == 1){
69
		while (selectionIterator.hasNext()){
67 70
			Object object = selectionIterator.next();
68 71
			if(object instanceof TaxonNode){
69
				taxonNode = HibernateProxyHelper.deproxy(object,TaxonNode.class);
70
				taxonNodeUUID = taxonNode.getUuid();
72
			    taxonNode = HibernateProxyHelper.deproxy(object,TaxonNode.class);
73
				taxonNodes.add(taxonNode);
74
				taxonNodeUUIDs.add(taxonNode.getUuid());
71 75
				excludeTaxa.add(taxonNode.getTaxon().getUuid());
72 76
			}
73
		} else{
77
		}
78
		/*} else{
74 79
			if( MessageDialog.openConfirm(HandlerUtil.getActiveShell(event), "Moving taxon", "The operation move accepted taxon to other parent is available only for a single taxon.")){
75 80
				return null;
76 81
			}
77
		}
78

  
82
		}*/
79 83

  
80 84

  
81 85
//		TaxonNode taxonNode = (TaxonNode) selection.getFirstElement();
82
		if (taxonNode != null){
86
		if (taxonNodes.size() >= 1){
83 87
			boolean moveToNewParent = true;
84 88
			if (PreferencesUtil.getSortNodesNaturally()){
85 89
				if(!MessageDialog.openQuestion(null, "Target node", "The choosen target node should be the parent?")){
......
98 102

  
99 103
				AbstractPostOperation operation = new MoveTaxonOperation
100 104
						("Move taxon to new parent", NavigationUtil.getUndoContext(),
101
								taxonNode, parentTaxonNode, taxonNavigator, taxonNavigator, moveToNewParent); //$NON-NLS-1$
105
								taxonNodeUUIDs, parentTaxonNode, taxonNavigator, taxonNavigator, moveToNewParent); //$NON-NLS-1$
102 106
				NavigationUtil.executeOperation(operation);
103 107
				taxonNavigator.refresh();
104 108

  
105 109
			}
106 110
		}
107

  
108 111
		return null;
109 112
	}
110 113

  
......
127 130
		return false;
128 131
	}
129 132

  
133

  
134

  
130 135
}

Also available in: Unified diff