package eu.etaxonomy.taxeditor.editor.name.e4.handler;
-import java.util.ArrayList;
-import java.util.List;
+import java.util.HashSet;
+import java.util.Set;
import java.util.UUID;
import javax.inject.Inject;
Synonym synonym = (Synonym) selection.getFirstElement();
Taxon oldParent = input.getTaxon();
- List<UUID> excludeTaxa = new ArrayList<UUID>();
+ Set<UUID> excludeTaxa = new HashSet<>();
excludeTaxa.add(oldParent.getUuid());
package eu.etaxonomy.taxeditor.editor.view.descriptive.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;
}
DescriptionBase description = elements.get(0).getInDescription();
- List<UUID> excludeTaxa = new ArrayList<UUID>();
+ Set<UUID> excludeTaxa = new HashSet<>();
if (description!=null && description.isInstanceOf(TaxonDescription.class)){
TaxonDescription taxonDescription = HibernateProxyHelper.deproxy(description, TaxonDescription.class);
actualTaxon = taxonDescription.getTaxon();
package eu.etaxonomy.taxeditor.editor.view.descriptive.e4.handler;
import java.util.ArrayList;
+import java.util.HashSet;
import java.util.List;
+import java.util.Set;
import java.util.UUID;
import javax.inject.Named;
descriptions.add(description);
// Choose the target taxon
- List<UUID> excludeTaxa = new ArrayList<UUID>();
+ Set<UUID> excludeTaxa = new HashSet<>();
excludeTaxa.add(descriptions.get(0).getTaxon().getUuid());
// targetTreeNode = HibernateProxyHelper.deproxy(targetTreeNode, TaxonNode.class);
// }
if(taxonNodes != null) {
- if (taxonNodes.size() == 1){
+// if (taxonNodes.size() == 1){
boolean success = moveTaxon(taxonNodes, targetTreeNode);
if (success){
taxonNavigator.refresh();
}
return success;
- } else{
- if( MessageDialog.openConfirm(null, Messages.TreeNodeDropAdapter_MOVING, Messages.TreeNodeDropAdapter_MOVING_MESSAGE)){
- return true;
- }
- }
+// } else{
+// if( MessageDialog.openConfirm(null, Messages.TreeNodeDropAdapter_MOVING, Messages.TreeNodeDropAdapter_MOVING_MESSAGE)){
+// return true;
+// }
+// }
}
}
return false;
*/
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;
Shell shell,
MPart activePart,
MHandledMenuItem menuItem) {
- List<UUID> excludeTaxa = new ArrayList<UUID>();
+ Set<UUID> excludeTaxa = new HashSet<>();
for (TaxonNodeDto oldNode:oldTaxonNodes){
excludeTaxa.add(oldNode.getTaxonUuid());
}
*/
package eu.etaxonomy.taxeditor.navigation.navigator.e4.handler;
-import java.util.ArrayList;
-import java.util.List;
+import java.util.HashSet;
+import java.util.Set;
import java.util.UUID;
import javax.inject.Named;
TaxonNavigatorLabels.UNSAVED_CHANGES_MESSAGE);
}
- List<UUID> excludeTaxa = new ArrayList<UUID>();
+ Set<UUID> excludeTaxa = new HashSet<>();
excludeTaxa.add(sourceTaxonNode.getTaxonUuid());
targetTaxonNode = TaxonNodeSelectionDialog.select(shell,
*/
package eu.etaxonomy.taxeditor.navigation.navigator.e4.handler;
-import java.util.ArrayList;
-import java.util.List;
+import java.util.HashSet;
+import java.util.Iterator;
+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.api.service.ITaxonNodeService;
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
import eu.etaxonomy.cdm.persistence.dto.TaxonNodeDto;
import eu.etaxonomy.taxeditor.navigation.NavigationUtil;
import eu.etaxonomy.taxeditor.navigation.navigator.operation.RemotingMoveTaxonOperation;
import eu.etaxonomy.taxeditor.operation.e4.RemotingCdmHandlerE4;
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
-import eu.etaxonomy.taxeditor.store.CdmStore;
import eu.etaxonomy.taxeditor.ui.dialog.selection.TaxonNodeSelectionDialog;
/**
*/
public class RemotingMoveTaxonNodeHandlerE4 extends RemotingCdmHandlerE4 {
- private TaxonNodeDto oldTaxonNode;
+ private Set<UUID> oldTaxonNodeUUIDs = new HashSet<>();
public RemotingMoveTaxonNodeHandlerE4() {
super(TaxonNavigatorLabels.MOVE_TAXON_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) {
TaxonNavigatorLabels.NO_TAXON_SELECTION_MESSAGE);
}
// check that selected object is a taxon node
- Object obj = selection.iterator().next();
- if(obj instanceof TaxonNodeDto) {
- oldTaxonNode = (TaxonNodeDto)obj;
- } else {
- return new Status(IStatus.ERROR,
- "unknown", //$NON-NLS-1$
- TaxonNavigatorLabels.SELECTED_OBJECT_NOT_TREE_NODE_MESSAGE);
+ Object obj ;
+ Iterator iter = selection.iterator();
+ while (iter.hasNext()){
+ obj = iter.next();
+ if(obj instanceof TaxonNodeDto) {
+ oldTaxonNodeUUIDs.add(((TaxonNodeDto)obj).getUuid());
+ } else {
+ return new Status(IStatus.ERROR,
+ "unknown", //$NON-NLS-1$
+ TaxonNavigatorLabels.SELECTED_OBJECT_NOT_TREE_NODE_MESSAGE);
+ }
}
return Status.OK_STATUS;
}
MPart activePart,
MHandledMenuItem menuItem) {
TaxonNode parentTaxonNode;
-
- List<UUID> excludeTaxa = new ArrayList<UUID>();
- excludeTaxa.add(oldTaxonNode.getTaxonUuid());
-
MovingType moveToNewParent = MovingType.CHILD;
if (PreferencesUtil.getSortNodesNaturally()){
parentTaxonNode = TaxonNodeSelectionDialog.select(shell,
// new ConversationHolderMock(),
Messages.RemotingMoveTaxonNodeHandler_CHOOSE_TAXON,
- excludeTaxa,
+ oldTaxonNodeUUIDs,
null,
- oldTaxonNode.getClassificationUUID(), true);
+ null, true);
String[] buttonLables = {Messages.RemotingMoveTaxonNodeHandler_CHILD, Messages.RemotingMoveTaxonNodeHandler_BEHIND,Messages.RemotingMoveTaxonNodeHandler_CANCEL};
MessageDialog dialog = new MessageDialog(null, Messages.RemotingMoveTaxonNodeHandler_TARGET_NODE, null, Messages.RemotingMoveTaxonNodeHandler_TARGET_NODE_MESSAGE, MessageDialog.QUESTION_WITH_CANCEL, buttonLables, 0);
dialog.open();
parentTaxonNode = TaxonNodeSelectionDialog.select(shell,
// new ConversationHolderMock(),
Messages.RemotingMoveTaxonNodeHandler_CHOOSE_PARENT,
- excludeTaxa,
- CdmStore.getService(ITaxonNodeService.class).find(oldTaxonNode.getUuid()),
- oldTaxonNode.getClassificationUUID(), true);
+ oldTaxonNodeUUIDs,
+ null,
+ null, true);
}
return new RemotingMoveTaxonOperation(getTrigger(),
false,
- oldTaxonNode.getUuid(),
+ oldTaxonNodeUUIDs,
parentTaxonNode.getUuid(),
moveToNewParent);
}
*/
package eu.etaxonomy.taxeditor.navigation.navigator.operation;
-import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
import eu.etaxonomy.cdm.api.application.CdmChangeEvent.Action;
import eu.etaxonomy.cdm.api.service.ITaxonNodeService;
import eu.etaxonomy.cdm.api.service.UpdateResult;
-import eu.etaxonomy.cdm.model.taxon.TaxonNode;
import eu.etaxonomy.taxeditor.navigation.l10n.Messages;
import eu.etaxonomy.taxeditor.navigation.navigator.e4.TreeNodeDropAdapterE4.MovingType;
import eu.etaxonomy.taxeditor.operation.RemotingCdmUpdateOperation;
private final static String LABEL = Messages.RemotingMoveTaxonOperation_MOVE_OP;
- private final Set<UUID> taxonNodesToMoveUuid;
+ private Set<UUID> taxonNodesToMoveUuid;
private final UUID newParentTreeNodeUuid;
private final MovingType moveToParentNode;
public RemotingMoveTaxonOperation(Object source,
boolean async,
- UUID taxonNodeToMoveUuid,
+ Set<UUID> taxonNodeToMoveUuid,
UUID newParentTreeNodeUuid,
MovingType moveToParentNode) {
super(LABEL, Action.Update, source,async);
- taxonNodesToMoveUuid = new HashSet<UUID>();
- taxonNodesToMoveUuid.add(taxonNodeToMoveUuid);
+ taxonNodesToMoveUuid = taxonNodeToMoveUuid;
this.newParentTreeNodeUuid = newParentTreeNodeUuid;
this.moveToParentNode = moveToParentNode;
}
- public RemotingMoveTaxonOperation(Object source,
- boolean async,
- TaxonNode taxonNodeToMove,
- TaxonNode newParentTreeNode,
- MovingType moveToParentNode) {
- super(LABEL, Action.Update, source,async);
- taxonNodesToMoveUuid = new HashSet<UUID>();
- taxonNodesToMoveUuid.add(taxonNodeToMove.getUuid());
- this.newParentTreeNodeUuid = newParentTreeNode.getUuid();
- this.moveToParentNode = moveToParentNode;
- }
+// public RemotingMoveTaxonOperation(Object source,
+// boolean async,
+// List<TaxonNode> taxonNodeToMove,
+// TaxonNode newParentTreeNode,
+// MovingType moveToParentNode) {
+// super(LABEL, Action.Update, source,async);
+//
+// taxonNodesToMoveUuid=taxonNodeToMove;
+// this.newParentTreeNodeUuid = newParentTreeNode.getUuid();
+// this.moveToParentNode = moveToParentNode;
+// }
- /**
- * @param source
- * @param async
- * @param uuids
- * @param uuid
- * @param child
- */
- public RemotingMoveTaxonOperation(Object source, boolean async, Set<UUID> uuids, UUID uuid,
- MovingType child) {
- super(LABEL, Action.Update, source,async);
- this.taxonNodesToMoveUuid = uuids;
- this.newParentTreeNodeUuid = uuid;
- this.moveToParentNode = child;
- }
+// /**
+// * @param source
+// * @param async
+// * @param uuids
+// * @param uuid
+// * @param child
+// */
+// public RemotingMoveTaxonOperation(Object source, boolean async, Set<UUID> uuids, UUID uuid,
+// MovingType child) {
+// super(LABEL, Action.Update, source,async);
+// this.taxonNodesToMoveUuid = uuids;
+// this.newParentTreeNodeUuid = uuid;
+// this.moveToParentNode = child;
+// }
/* (non-Javadoc)
* @see eu.etaxonomy.taxeditor.operation.RemotingCdmUpdateOperation#doUpdateExecute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
private T selectedObject;
- protected T cdmBaseToBeFiltered;
+ protected Set<UUID> cdmBaseToBeFiltered;
/**
setShellStyle(SWT.DIALOG_TRIM);
setMessage(Messages.SearchDialog_patternLabel);
this.settings = settings;
-
- this.cdmBaseToBeFiltered = cdmObject;
+ if (cdmObject != null){
+ this.cdmBaseToBeFiltered = new HashSet<>();
+ this.cdmBaseToBeFiltered.add(cdmObject.getUuid());
+ }
Cursor cursor = shell.getCursor();
shell.setCursor(shell.getDisplay().getSystemCursor(SWT.CURSOR_WAIT));
init();
while(iterator.hasNext()){
element = iterator.next();
- if (cdmBaseToBeFiltered == null || !element.getUuid().equals(cdmBaseToBeFiltered.getUuid())){
+ if (cdmBaseToBeFiltered == null || !cdmBaseToBeFiltered.contains(element.getUuid())){
contentProvider.add(element);
}
if (progressMonitor != null){
}
AbstractNewEntityWizard wizard = getNewEntityWizard(text);
if(wizard!=null){
- wizard.init(null, null);
+ if (wizard.getEntity() == null){
+ wizard.init(null, null);
+ }
if(wizard.getEntity() != null) {
WizardDialog dialog = new WizardDialog(getShell(), wizard);
int status = dialog.open();
UuidAndTitleCache uuidAndTitleCacheToRemove = null;
for (UuidAndTitleCache uuidAndTitleCache : model){
- if ((cdmBaseToBeFiltered.getUuid()).equals(uuidAndTitleCache.getUuid())) {
+ if (cdmBaseToBeFiltered != null && cdmBaseToBeFiltered.contains(uuidAndTitleCache.getUuid())) {
uuidAndTitleCacheToRemove = uuidAndTitleCache;
}
}
package eu.etaxonomy.taxeditor.ui.dialog.selection;
import java.util.Collections;
+import java.util.HashSet;
import java.util.UUID;
import org.eclipse.swt.widgets.Shell;
String title, boolean multi, TaxonBase taxon, TaxonBase taxonToBeFiltered) {
super(shell, //conversation,
title, multi, TaxonBaseSelectionDialog.class.getCanonicalName(), taxon);
- this.cdmBaseToBeFiltered = taxonToBeFiltered;
+ if (taxonToBeFiltered != null){
+ this.cdmBaseToBeFiltered = new HashSet<>();
+ this.cdmBaseToBeFiltered.add(taxonToBeFiltered.getUuid());
+ }
this.clazz = clazz;
search();
}
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
+import java.util.Set;
import java.util.UUID;
import org.eclipse.jface.viewers.ILabelProvider;
public class TaxonNodeSelectionDialog extends AbstractFilteredCdmResourceSelectionDialog<TaxonNode> implements SelectionListener{
public static TaxonNode select(Shell shell, //ConversationHolder conversation,
- String title, List<UUID> excludeTaxa, TaxonNode node, UUID classificationUUID, boolean allowSelectClassification) {
+ String title, Set<UUID> excludeTaxa, TaxonNode node, UUID classificationUUID, boolean allowSelectClassification) {
TaxonNodeSelectionDialog dialog = new TaxonNodeSelectionDialog(shell,
//conversation,
title,
return getSelectionFromDialog(dialog);
}
public static TaxonNode select(Shell shell, //ConversationHolder conversation,
- String title, List<UUID> excludeTaxa, TaxonNode node, UUID classificationUUID) {
+ String title, Set<UUID> excludeTaxa, TaxonNode node, UUID classificationUUID) {
TaxonNodeSelectionDialog dialog = new TaxonNodeSelectionDialog(shell,
//conversation,
title,
}
public static UuidAndTitleCache<TaxonNode> selectUuidAndTitleCache(Shell shell, //ConversationHolder conversation,
- String title, List<UUID> excludeTaxa, TaxonNode node, UUID classificationUUID) {
+ String title, Set<UUID> excludeTaxa, TaxonNode node, UUID classificationUUID) {
TaxonNodeSelectionDialog dialog = new TaxonNodeSelectionDialog(shell,
//conversation,
title,
private Classification selectedClassification;
private UUID selectedUuid;
- private final List<UUID> excludeTaxa;
+// private final Set<UUID> excludeTaxa;
private boolean allowClassificationSelection = false;
protected TaxonNodeSelectionDialog(Shell shell, //ConversationHolder conversation,
- String title, List<UUID> excludeTaxa, boolean multi, TaxonNode node, UUID classificationUUID, boolean allowSelectClassification) {
+ String title, Set<UUID> excludeTaxa, boolean multi, TaxonNode node, UUID classificationUUID, boolean allowSelectClassification) {
super(shell, //conversation,
title, multi, TaxonNodeSelectionDialog.class.getCanonicalName(), node);
setListLabelProvider(labelProvider);
// setDetailsLabelProvider(labelProvider);
- this.excludeTaxa = excludeTaxa;
+ this.cdmBaseToBeFiltered = excludeTaxa;
if(classificationUUID != null){
selectedUuid = classificationUUID;
}
createClassificationSelectionCombo(shell);
}
protected TaxonNodeSelectionDialog(Shell shell, //ConversationHolder conversation,
- String title, List<UUID> excludeTaxa, boolean multi, TaxonNode node, UUID classificationUUID) {
+ String title, Set<UUID> excludeTaxa, boolean multi, TaxonNode node, UUID classificationUUID) {
this(shell, title, excludeTaxa, multi, node, classificationUUID, false);
}
}
});
if (selectedClassification == null){
- if (this.cdmBaseToBeFiltered == null){
+// if (this.cdmBaseToBeFiltered.isEmpty()){
selectedClassification = classifications.iterator().next();
- } else {
- selectedClassification = this.cdmBaseToBeFiltered.getClassification();
- }
+
+// } else {
+// selectedClassification = this.cdmBaseToBeFiltered.getClassification();
+// }
}
}
}
package eu.etaxonomy.taxeditor.ui.dialog.selection;\r
\r
-import java.util.List;\r
+import java.util.Set;\r
import java.util.UUID;\r
\r
import org.eclipse.swt.widgets.Shell;\r
\r
protected TaxonNodeSelectionNaturalOrderDialog(Shell shell,//ConversationHolder conversation,\r
String title,\r
- List<UUID> excludeTaxa, boolean multi, TaxonNode node,\r
+ Set<UUID> excludeTaxa, boolean multi, TaxonNode node,\r
Classification classification) {\r
super(shell, //conversation,\r
title, excludeTaxa, multi, node, classification.getUuid());\r