@Execute
- public void execute(@Named(IServiceConstants.ACTIVE_SELECTION)CdmBase selection,
+ public void execute(@Named(IServiceConstants.ACTIVE_SELECTION)Object selection,
@Named(IServiceConstants.ACTIVE_PART)MPart activePart) {
BulkEditorE4 editor = (BulkEditorE4) activePart.getObject();
- editor.getEditorInput().removeMergeCandidate(selection);
- editor.refresh();
+ if (selection instanceof Object[]){
+ for(Object object: (Object[])selection){
+ if (object instanceof CdmBase){
+ editor.getEditorInput().removeMergeCandidate((CdmBase)object);
+ editor.refresh();
+ }
+ }
+ }else if (selection instanceof CdmBase){
+ editor.getEditorInput().removeMergeCandidate((CdmBase)selection);
+ editor.refresh();
+ }
+
+
}
@CanExecute
- public boolean canExecute(@Named(IServiceConstants.ACTIVE_SELECTION)CdmBase selection,
+ public boolean canExecute(@Named(IServiceConstants.ACTIVE_SELECTION)Object selection,
@Named(IServiceConstants.ACTIVE_PART)MPart activePart,
MHandledMenuItem menuItem) {
boolean canExecute = false;
BulkEditorE4 editor = (BulkEditorE4) activePart.getObject();
- canExecute = editor.getEditorInput().isMergingEnabled()
- && editor.getEditorInput().getMergeCandidates().contains(selection);
+ boolean selectedMergeCandidate = false;
+ if (selection instanceof Object[]){
+ for(Object object: (Object[])selection){
+ if (object instanceof CdmBase){
+ editor.getEditorInput().getMergeCandidates().contains((CdmBase)object);
+ selectedMergeCandidate = true;
+ }
+ }
+ }
+
+ canExecute = editor.getEditorInput().isMergingEnabled() && selectedMergeCandidate;
+// && editor.getEditorInput().getMergeCandidates().contains(selection);
menuItem.setVisible(canExecute);
return canExecute;
}
package eu.etaxonomy.taxeditor.navigation.navigator.e4.handler;
import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.Iterator;
import java.util.List;
+import java.util.Set;
import java.util.UUID;
import javax.inject.Named;
import org.eclipse.jface.viewers.TreeSelection;
import org.eclipse.swt.widgets.Shell;
+import eu.etaxonomy.cdm.model.taxon.Classification;
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
import eu.etaxonomy.taxeditor.editor.EditorUtil;
import eu.etaxonomy.taxeditor.navigation.l10n.Messages;
public class RemotingChangeAcceptedTaxonToSynonymHandlerE4 extends RemotingCdmHandlerE4 {
- private TaxonNode oldTaxonNode;
+ private Set<TaxonNode> oldTaxonNodes = new HashSet();
+ private Classification classification;
public RemotingChangeAcceptedTaxonToSynonymHandlerE4() {
super(TaxonNavigatorLabels.CHANGE_ACCEPTED_TAXON_TO_SYNONYM_LABEL);
MPart activePart,
MHandledMenuItem menuItem) {
// check that only a single taxon tree node has been selected
- if(selection.size() > 1) {
- return new Status(IStatus.ERROR,
- "unknown", //$NON-NLS-1$
- TaxonNavigatorLabels.SINGLE_TAXON_SELECTION_MESSAGE);
- }
+// if(selection.size() > 1) {
+// return new Status(IStatus.ERROR,
+// "unknown", //$NON-NLS-1$
+// TaxonNavigatorLabels.SINGLE_TAXON_SELECTION_MESSAGE);
+// }
// check for no taxon tree node selected
if(selection.size() == 0) {
}
// check that selected object is a taxon node
- Object obj = selection.iterator().next();
- if(obj instanceof TaxonNode && ((TaxonNode)obj).hasTaxon()) {
- oldTaxonNode = (TaxonNode)obj;
- } else {
- if (obj instanceof TaxonNode && !((TaxonNode)obj).hasTaxon()){
- return new Status(IStatus.ERROR,
- "Operation not available for Classifications", //$NON-NLS-1$
- TaxonNavigatorLabels.SELECTED_OBJECT_NOT_TREE_NODE_MESSAGE);
- }
- return new Status(IStatus.ERROR,
- "unknown", //$NON-NLS-1$
- TaxonNavigatorLabels.SELECTED_OBJECT_NOT_TREE_NODE_MESSAGE);
- }
- // check that the source taxon node does not have children
- if(oldTaxonNode.getCountChildren() > 0) {
- return new Status(IStatus.ERROR,
- "unknown", //$NON-NLS-1$
- TaxonNavigatorLabels.SOURCE_TAXON_HAS_CHILDREN_MESSAGE);
-
+ Iterator it = selection.iterator();
+ while(it.hasNext()){
+ Object obj = it.next();
+ if(obj instanceof TaxonNode && ((TaxonNode)obj).hasTaxon()) {
+ oldTaxonNodes.add((TaxonNode)obj);
+ if (classification == null){
+ classification = ((TaxonNode)obj).getClassification();
+ }else if (classification != ((TaxonNode)obj).getClassification()){
+ return new Status(IStatus.ERROR,
+ "unknown", //$NON-NLS-1$
+ TaxonNavigatorLabels.ACCEPTED_TAXA_NEED_TO_BE_FROM_SAME_CLASSIFICATION);
+ }
+ } else {
+ if (obj instanceof TaxonNode && !((TaxonNode)obj).hasTaxon()){
+ return new Status(IStatus.ERROR,
+ "Operation not available for Classifications", //$NON-NLS-1$
+ TaxonNavigatorLabels.SELECTED_OBJECT_NOT_TREE_NODE_MESSAGE);
+ }
+ return new Status(IStatus.ERROR,
+ "unknown", //$NON-NLS-1$
+ TaxonNavigatorLabels.SELECTED_OBJECT_NOT_TREE_NODE_MESSAGE);
+ }
+ // check that the source taxon node does not have children
+ if(((TaxonNode)obj).getCountChildren() > 0) {
+ return new Status(IStatus.ERROR,
+ "unknown", //$NON-NLS-1$
+ TaxonNavigatorLabels.SOURCE_TAXON_HAS_CHILDREN_MESSAGE);
+
+ }
+
+ // check if corresponding name editor is closed
+ EditorUtil.closeObsoleteEditor((TaxonNode)obj, partService);
}
-
- // check if corresponding name editor is closed
- EditorUtil.closeObsoleteEditor(oldTaxonNode, partService);
-
return Status.OK_STATUS;
}
MPart activePart,
MHandledMenuItem menuItem) {
List<UUID> excludeTaxa = new ArrayList<UUID>();
- excludeTaxa.add(oldTaxonNode.getTaxon().getUuid());
+ for (TaxonNode oldNode:oldTaxonNodes){
+ excludeTaxa.add(oldNode.getTaxon().getUuid());
+ }
TaxonNode newAcceptedTaxonNode = TaxonNodeSelectionDialog.select(shell,
// new ConversationHolderMock(),
Messages.RemotingChangeAcceptedTaxonToSynonymHandler_CHOOSE_TAXON,
excludeTaxa,
- oldTaxonNode,
- oldTaxonNode.getClassification());
+ null,
+ classification);
if (newAcceptedTaxonNode == null) {
return null;
}
-
+ Set<UUID> nodeUuids = new HashSet();
+ for (TaxonNode node: oldTaxonNodes){
+ nodeUuids.add(node.getUuid());
+ }
RemotingChangeAcceptedTaxonToSynonymOperation rcattso =
new RemotingChangeAcceptedTaxonToSynonymOperation(getTrigger(),
false,
- oldTaxonNode.getUuid(),
+ nodeUuids,
newAcceptedTaxonNode.getUuid());
return rcattso;
*/
package eu.etaxonomy.taxeditor.navigation.navigator.operation;
+import java.util.HashSet;
+import java.util.Set;
import java.util.UUID;
import org.eclipse.core.runtime.IAdaptable;
*/
public class RemotingChangeAcceptedTaxonToSynonymOperation extends RemotingCdmUpdateOperation {
- private final UUID oldTaxonNodeUuid;
+ private Set<UUID> oldTaxonNodeUuids = new HashSet();
private final UUID newAcceptedTaxonNodeUuid;
private final static String LABEL = Messages.RemotingChangeAcceptedTaxonToSynonymOperation_CHANGE_OP;
+ /**
+ * @param label
+ */
+ public RemotingChangeAcceptedTaxonToSynonymOperation(Object source,
+ boolean async,
+ Set<UUID> oldTaxonNodeUuids,
+ UUID newAcceptedTaxonNodeUuid) {
+ super(LABEL, Action.Update, source, async);
+ this.oldTaxonNodeUuids.addAll(oldTaxonNodeUuids);
+ this.newAcceptedTaxonNodeUuid = newAcceptedTaxonNodeUuid;
+ }
+
/**
* @param label
*/
UUID oldTaxonNodeUuid,
UUID newAcceptedTaxonNodeUuid) {
super(LABEL, Action.Update, source, async);
- this.oldTaxonNodeUuid = oldTaxonNodeUuid;
+ this.oldTaxonNodeUuids.add(oldTaxonNodeUuid);
this.newAcceptedTaxonNodeUuid = newAcceptedTaxonNodeUuid;
}
*/
@Override
protected UpdateResult doUpdateExecute(IProgressMonitor monitor, IAdaptable info) throws Exception {
- return CdmApplicationState.getService(ITaxonNodeService.class).makeTaxonNodeASynonymOfAnotherTaxonNode(oldTaxonNodeUuid,
- newAcceptedTaxonNodeUuid,
- null,
- null,
- null);
+ if (this.oldTaxonNodeUuids.size() == 1){
+ return CdmApplicationState.getService(ITaxonNodeService.class).makeTaxonNodeASynonymOfAnotherTaxonNode(oldTaxonNodeUuids.iterator().next(),
+ newAcceptedTaxonNodeUuid,
+ null,
+ null,
+ null);
+ }else{
+ return CdmApplicationState.getService(ITaxonNodeService.class).makeTaxonNodeSynonymsOfAnotherTaxonNode(oldTaxonNodeUuids,
+ newAcceptedTaxonNodeUuid,
+ null,
+ null,
+ null);
+ }
+
}
}