import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.ui.IEditorInput;
import eu.etaxonomy.cdm.api.service.ITaxonService;
import eu.etaxonomy.cdm.api.service.IUserService;
import eu.etaxonomy.cdm.api.service.config.NameDeletionConfigurator;
+import eu.etaxonomy.cdm.api.service.config.SynonymDeletionConfigurator;
+import eu.etaxonomy.cdm.api.service.config.TaxonDeletionConfigurator;
import eu.etaxonomy.cdm.model.agent.TeamOrPersonBase;
import eu.etaxonomy.cdm.model.common.Group;
import eu.etaxonomy.cdm.model.common.User;
import eu.etaxonomy.taxeditor.model.DeleteResultMessagingUtils;
import eu.etaxonomy.taxeditor.model.MessagingUtils;
import eu.etaxonomy.taxeditor.store.CdmStore;
+import eu.etaxonomy.taxeditor.ui.dialog.deleteConfigurator.DeleteConfiguratorDialog;
+import eu.etaxonomy.taxeditor.ui.dialog.deleteConfigurator.DeleteTaxonConfiguratorComposite;
/**
ITaxonService service = controller.getTaxonService();
if (object != null){
if (object instanceof Taxon){
- result = service.deleteTaxon(((TaxonBase) object).getUuid(), null, null);
+ TaxonDeletionConfigurator config = new TaxonDeletionConfigurator();
+ config.setDeleteInAllClassifications(true);
+ DeleteConfiguratorDialog dialog = new DeleteConfiguratorDialog(config, HandlerUtil.getActiveShell(event), "Confirm Deletion", null, "Do you really want to delete the taxon", MessageDialog.WARNING, new String[] { "Delete", "Skip" }, 0);
+ int result_dialog= dialog.open();
+ if (result_dialog == 1){
+ return null;
+ }
+ result = service.deleteTaxon(((TaxonBase) object).getUuid(), config, null);
errorMessage = "The taxon ";
}else{
- result = service.deleteSynonym(((Synonym)object).getUuid(), null);
+ SynonymDeletionConfigurator config = new SynonymDeletionConfigurator();
+ DeleteConfiguratorDialog dialog = new DeleteConfiguratorDialog(config, HandlerUtil.getActiveShell(event), "Confirm Deletion", null, "Do you really want to delete the synonym", MessageDialog.WARNING, new String[] { "Delete", "Skip" }, 0);
+ int result_dialog= dialog.open();
+ if (result_dialog == 1){
+ return null;
+ }
+ result = service.deleteSynonym(((Synonym)object).getUuid(), config);
errorMessage = "The synonym ";
}
}
import org.eclipse.swt.dnd.DragSourceAdapter;
import org.eclipse.swt.dnd.DragSourceEvent;
+import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
import eu.etaxonomy.cdm.model.description.DescriptionBase;
import eu.etaxonomy.cdm.model.description.DescriptionElementBase;
import eu.etaxonomy.taxeditor.model.FeatureNodeContainer;
public class DescriptionElementDragListener extends DragSourceAdapter {
private DescriptiveViewPart part;
+ private DescriptionBase description;
public DescriptionElementDragListener(DescriptiveViewPart part){
this.part = part;
return;
// FIXME what to do here?
if (event.detail != DND.DROP_NONE) {
- IStructuredSelection selection = (IStructuredSelection) part.getViewer()
- .getSelection();
- part.changed(null);
+ //IStructuredSelection selection = (IStructuredSelection) part.getViewer().getSelection();
+ part.getViewer().refresh();
+
+ part.changed(null);
}
}
for (Object object : selection.toList()){
if(object instanceof DescriptionBase){
descriptionElements.addAll(((DescriptionBase) object).getElements());
+ description = HibernateProxyHelper.deproxy(object, DescriptionBase.class);
+
}else if(object instanceof FeatureNodeContainer){
descriptionElements.addAll(((FeatureNodeContainer) object).getDescriptionElements());
}else if(object instanceof DescriptionElementBase){
if (DescriptionElementTransfer.getInstance().isSupportedType(
event.dataType)) {
event.data = descriptionElements.toArray(new DescriptionElementBase[descriptionElements.size()]);
+
}
+
}
/**
EditorUtil.executeOperation(operation);
+
return true;
}
for(DescriptionElementBase deBase : descriptionElements) {
descriptionElementsUuid.add(deBase.getUuid());
}
-
+ UpdateResult result;
if(targetDescription == null){
- UpdateResult result = service.moveDescriptionElementsToDescription(descriptionElementsUuid, targetTaxonUuid, moveMessage, isCopy);
+ result = service.moveDescriptionElementsToDescription(descriptionElementsUuid, targetTaxonUuid, moveMessage, isCopy);
} else {
UUID targetDescriptionUuid = targetDescription.getUuid();
- service.moveDescriptionElementsToDescription(descriptionElementsUuid, targetDescriptionUuid, isCopy);
+ result = service.moveDescriptionElementsToDescription(descriptionElementsUuid, targetDescriptionUuid, isCopy);
+
}
return postExecute(targetDescription);
}
import eu.etaxonomy.cdm.api.service.config.DeleteConfiguratorBase;
import eu.etaxonomy.cdm.api.service.config.SpecimenDeleteConfigurator;
import eu.etaxonomy.cdm.api.service.config.TaxonBaseDeletionConfigurator;
+import eu.etaxonomy.cdm.api.service.config.TaxonDeletionConfigurator;
import eu.etaxonomy.cdm.api.service.config.TaxonNodeDeletionConfigurator;
/**
@Override
protected Control createCustomArea(Composite parent) {
DeleteConfiguratorComposite composite = new DeleteConfiguratorComposite(parent, NONE);
- if(configurator instanceof TaxonBaseDeletionConfigurator){
- composite.addConfiguratorComposite(new DeleteTaxonConfiguratorComposite((TaxonBaseDeletionConfigurator) configurator, composite.getSectionConfigure(), SWT.NONE));
+ if(configurator instanceof TaxonDeletionConfigurator){
+ composite.addConfiguratorComposite(new DeleteTaxonConfiguratorComposite((TaxonDeletionConfigurator) configurator, composite.getSectionConfigure(), SWT.NONE));
}
else if(configurator instanceof SpecimenDeleteConfigurator){
composite.addConfiguratorComposite(new DeleteSpecimenConfiguratorComposite((SpecimenDeleteConfigurator) configurator, composite.getSectionConfigure(), SWT.NONE));
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.events.DisposeListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.layout.RowLayout;
import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Label;
import org.eclipse.ui.forms.widgets.FormToolkit;
-import eu.etaxonomy.cdm.api.service.config.TaxonBaseDeletionConfigurator;
+import eu.etaxonomy.cdm.api.service.config.TaxonDeletionConfigurator;
+import eu.etaxonomy.cdm.common.CdmUtils;
+import eu.etaxonomy.cdm.model.taxon.Classification;
+
/**
* @author pplitzner
private final DataBindingContext m_bindingContext;
private final FormToolkit toolkit = new FormToolkit(Display.getCurrent());
- private final TaxonBaseDeletionConfigurator configurator;
+ private final TaxonDeletionConfigurator configurator;
private final Button btnDeleteTaxonName;
+ private final Button btnDeleteInAllClassifications;
+ private Combo classificationSelectionCombo;
+
+
/**
* Create the composite.
* @param parent
* @param style
*/
- public DeleteTaxonConfiguratorComposite(TaxonBaseDeletionConfigurator configurator, Composite parent, int style) {
+ public DeleteTaxonConfiguratorComposite(TaxonDeletionConfigurator configurator, Composite parent, int style) {
super(parent, style);
this.configurator = configurator;
addDisposeListener(new DisposeListener() {
btnDeleteTaxonName = new Button(this, SWT.CHECK);
btnDeleteTaxonName.setText("Delete taxon name if possible");
+ btnDeleteTaxonName.setSelection(true);
+
+ btnDeleteInAllClassifications = new Button(this, SWT.CHECK);
+ btnDeleteInAllClassifications.setText("Delete taxon in all classifications");
+ btnDeleteInAllClassifications.setSelection(true);
+
m_bindingContext = initDataBindings();
}
//
IObservableValue observeSelectionBtnDeleteTaxonNameObserveWidget = WidgetProperties.selection().observe(btnDeleteTaxonName);
IObservableValue deleteNameIfPossibleConfiguratorObserveValue = PojoProperties.value("deleteNameIfPossible").observe(configurator);
+
+ IObservableValue observeSelectionBtnDeleteInAllClassificationObserveWidget = WidgetProperties.selection().observe(btnDeleteInAllClassifications);
+ IObservableValue deleteInAllClassificationsConfiguratorObserveValue = PojoProperties.value("deleteInAllClassifications").observe(configurator);
bindingContext.bindValue(observeSelectionBtnDeleteTaxonNameObserveWidget, deleteNameIfPossibleConfiguratorObserveValue, null, null);
+ bindingContext.bindValue(observeSelectionBtnDeleteInAllClassificationObserveWidget, deleteInAllClassificationsConfiguratorObserveValue, null, null);
//
return bindingContext;
}
+
+ /* private Control createClassificationSelectionCombo(Composite parent){
+// classifications = CdmStore.getTaxonTreeService().list(null, null, null, null, null);
+
+ Composite classificationSelection = new Composite(parent, SWT.NULL);
+ classificationSelection.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
+
+ GridLayout layout = new GridLayout();
+ classificationSelection.setLayout(layout);
+
+ Label label = new Label(classificationSelection, SWT.NULL);
+ // TODO not working is not really true but leave it here to remind everyone that this is under construction
+ label.setText("Select Classification");
+ classificationSelectionCombo = new Combo(classificationSelection, SWT.BORDER | SWT.READ_ONLY);
+ classificationSelectionCombo.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, true));
+ List<Classification> classifications =
+
+ for(Classification tree : classifications){
+ classificationSelectionCombo.add(tree.getName().getText(), classifications.indexOf(tree));
+
+ }
+
+ classificationSelectionCombo.select(classifications.indexOf(selectedClassification));
+
+ // TODO remember last selection
+ classificationSelectionCombo.addSelectionListener(this);
+
+
+
+ return classificationSelection;
+ }*/
}
/** {@inheritDoc} */
@Override
public DescriptionElementSource createNewElement() {
- if(getEntity().getId() == 0) {
+ /* if(getEntity().getId() == 0) {
MessagingUtils.warningDialog("Description not saved", this, "Please save the newly created description before adding source");
return null;
- }
+ }*/
return DescriptionElementSource.NewInstance(OriginalSourceType.PrimaryTaxonomicSource);
}