Project

General

Profile

« Previous | Next » 

Revision c1c463d7

Added by Katja Luther over 8 years ago

fix move whole description to another description and adding delete configurator to bulk editor

View differences:

eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/handler/DeleteHandler.java
16 16
import org.eclipse.core.commands.AbstractHandler;
17 17
import org.eclipse.core.commands.ExecutionEvent;
18 18
import org.eclipse.core.commands.ExecutionException;
19
import org.eclipse.jface.dialogs.MessageDialog;
19 20
import org.eclipse.jface.viewers.ISelection;
20 21
import org.eclipse.jface.viewers.IStructuredSelection;
21 22
import org.eclipse.ui.IEditorInput;
......
33 34
import eu.etaxonomy.cdm.api.service.ITaxonService;
34 35
import eu.etaxonomy.cdm.api.service.IUserService;
35 36
import eu.etaxonomy.cdm.api.service.config.NameDeletionConfigurator;
37
import eu.etaxonomy.cdm.api.service.config.SynonymDeletionConfigurator;
38
import eu.etaxonomy.cdm.api.service.config.TaxonDeletionConfigurator;
36 39
import eu.etaxonomy.cdm.model.agent.TeamOrPersonBase;
37 40
import eu.etaxonomy.cdm.model.common.Group;
38 41
import eu.etaxonomy.cdm.model.common.User;
......
50 53
import eu.etaxonomy.taxeditor.model.DeleteResultMessagingUtils;
51 54
import eu.etaxonomy.taxeditor.model.MessagingUtils;
52 55
import eu.etaxonomy.taxeditor.store.CdmStore;
56
import eu.etaxonomy.taxeditor.ui.dialog.deleteConfigurator.DeleteConfiguratorDialog;
57
import eu.etaxonomy.taxeditor.ui.dialog.deleteConfigurator.DeleteTaxonConfiguratorComposite;
53 58

  
54 59

  
55 60
/**
......
130 135
						ITaxonService service = controller.getTaxonService();
131 136
						if (object != null){
132 137
							if (object instanceof Taxon){
133
								result = service.deleteTaxon(((TaxonBase) object).getUuid(), null, null);
138
								TaxonDeletionConfigurator config = new TaxonDeletionConfigurator();
139
								config.setDeleteInAllClassifications(true);
140
								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); 
141
								int result_dialog= dialog.open();
142
								if (result_dialog == 1){
143
									return null;
144
								}
145
								result = service.deleteTaxon(((TaxonBase) object).getUuid(), config, null);
134 146
								errorMessage = "The taxon ";
135 147
							}else{
136
								result = service.deleteSynonym(((Synonym)object).getUuid(), null);
148
								SynonymDeletionConfigurator config = new SynonymDeletionConfigurator();
149
								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); 
150
								int result_dialog= dialog.open();
151
								if (result_dialog == 1){
152
									return null;
153
								}
154
								result = service.deleteSynonym(((Synonym)object).getUuid(), config);
137 155
								errorMessage = "The synonym ";
138 156
							}
139 157
						}
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/DescriptionElementDragListener.java
18 18
import org.eclipse.swt.dnd.DragSourceAdapter;
19 19
import org.eclipse.swt.dnd.DragSourceEvent;
20 20

  
21
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
21 22
import eu.etaxonomy.cdm.model.description.DescriptionBase;
22 23
import eu.etaxonomy.cdm.model.description.DescriptionElementBase;
23 24
import eu.etaxonomy.taxeditor.model.FeatureNodeContainer;
......
30 31
public class DescriptionElementDragListener extends DragSourceAdapter {
31 32

  
32 33
	private DescriptiveViewPart part;
34
	private DescriptionBase description;
33 35
	
34 36
	public DescriptionElementDragListener(DescriptiveViewPart part){
35 37
		this.part = part;
......
43 45
			return;
44 46
		// FIXME what to do here?
45 47
		if (event.detail != DND.DROP_NONE) {
46
			IStructuredSelection selection = (IStructuredSelection) part.getViewer()
47
					.getSelection();
48
			part.changed(null);
48
			//IStructuredSelection selection = (IStructuredSelection) part.getViewer().getSelection();
49
			part.getViewer().refresh();
50
			
51
		part.changed(null);
49 52
		}
50 53
	}
51 54
	
......
59 62
		for (Object object : selection.toList()){
60 63
			if(object instanceof DescriptionBase){
61 64
				descriptionElements.addAll(((DescriptionBase) object).getElements());
65
				description = HibernateProxyHelper.deproxy(object, DescriptionBase.class);
66
				
62 67
			}else if(object instanceof FeatureNodeContainer){
63 68
				descriptionElements.addAll(((FeatureNodeContainer) object).getDescriptionElements());
64 69
			}else if(object instanceof DescriptionElementBase){
......
69 74
		if (DescriptionElementTransfer.getInstance().isSupportedType(
70 75
				event.dataType)) {
71 76
			event.data = descriptionElements.toArray(new DescriptionElementBase[descriptionElements.size()]);
77
			
72 78
		}
79
		
73 80
	}
74 81
	
75 82
	/**
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/DescriptionElementDropAdapter.java
74 74
		
75 75
		EditorUtil.executeOperation(operation);
76 76
		
77
		
77 78
		return true;
78 79
	}
79 80

  
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/operation/MoveDescriptionElementsOperation.java
88 88
		for(DescriptionElementBase deBase : descriptionElements) {
89 89
		    descriptionElementsUuid.add(deBase.getUuid());
90 90
		}
91

  
91
		UpdateResult result; 
92 92
		if(targetDescription == null){
93
		    UpdateResult result = service.moveDescriptionElementsToDescription(descriptionElementsUuid, targetTaxonUuid, moveMessage, isCopy);
93
			result = service.moveDescriptionElementsToDescription(descriptionElementsUuid, targetTaxonUuid, moveMessage, isCopy);
94 94

  
95 95
		} else {
96 96
		    UUID targetDescriptionUuid = targetDescription.getUuid();
97
		    service.moveDescriptionElementsToDescription(descriptionElementsUuid, targetDescriptionUuid, isCopy);
97
		    result = service.moveDescriptionElementsToDescription(descriptionElementsUuid, targetDescriptionUuid, isCopy);
98
		    
98 99
		}
99 100
		return postExecute(targetDescription);
100 101
	}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/deleteConfigurator/DeleteConfiguratorDialog.java
20 20
import eu.etaxonomy.cdm.api.service.config.DeleteConfiguratorBase;
21 21
import eu.etaxonomy.cdm.api.service.config.SpecimenDeleteConfigurator;
22 22
import eu.etaxonomy.cdm.api.service.config.TaxonBaseDeletionConfigurator;
23
import eu.etaxonomy.cdm.api.service.config.TaxonDeletionConfigurator;
23 24
import eu.etaxonomy.cdm.api.service.config.TaxonNodeDeletionConfigurator;
24 25

  
25 26
/**
......
45 46
    @Override
46 47
    protected Control createCustomArea(Composite parent) {
47 48
        DeleteConfiguratorComposite composite = new DeleteConfiguratorComposite(parent, NONE);
48
        if(configurator instanceof TaxonBaseDeletionConfigurator){
49
            composite.addConfiguratorComposite(new DeleteTaxonConfiguratorComposite((TaxonBaseDeletionConfigurator) configurator, composite.getSectionConfigure(), SWT.NONE));
49
        if(configurator instanceof TaxonDeletionConfigurator){
50
            composite.addConfiguratorComposite(new DeleteTaxonConfiguratorComposite((TaxonDeletionConfigurator) configurator, composite.getSectionConfigure(), SWT.NONE));
50 51
        }
51 52
        else if(configurator instanceof SpecimenDeleteConfigurator){
52 53
            composite.addConfiguratorComposite(new DeleteSpecimenConfiguratorComposite((SpecimenDeleteConfigurator) configurator, composite.getSectionConfigure(), SWT.NONE));
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/deleteConfigurator/DeleteTaxonConfiguratorComposite.java
16 16
import org.eclipse.swt.SWT;
17 17
import org.eclipse.swt.events.DisposeEvent;
18 18
import org.eclipse.swt.events.DisposeListener;
19
import org.eclipse.swt.layout.GridData;
20
import org.eclipse.swt.layout.GridLayout;
19 21
import org.eclipse.swt.layout.RowLayout;
20 22
import org.eclipse.swt.widgets.Button;
23
import org.eclipse.swt.widgets.Combo;
21 24
import org.eclipse.swt.widgets.Composite;
25
import org.eclipse.swt.widgets.Control;
22 26
import org.eclipse.swt.widgets.Display;
27
import org.eclipse.swt.widgets.Label;
23 28
import org.eclipse.ui.forms.widgets.FormToolkit;
24 29

  
25
import eu.etaxonomy.cdm.api.service.config.TaxonBaseDeletionConfigurator;
30
import eu.etaxonomy.cdm.api.service.config.TaxonDeletionConfigurator;
31
import eu.etaxonomy.cdm.common.CdmUtils;
32
import eu.etaxonomy.cdm.model.taxon.Classification;
33

  
26 34

  
27 35
/**
28 36
 * @author pplitzner
......
33 41
    private final DataBindingContext m_bindingContext;
34 42

  
35 43
    private final FormToolkit toolkit = new FormToolkit(Display.getCurrent());
36
    private final TaxonBaseDeletionConfigurator configurator;
44
    private final TaxonDeletionConfigurator configurator;
37 45
    private final Button btnDeleteTaxonName;
46
    private final Button btnDeleteInAllClassifications;
47
    private Combo classificationSelectionCombo;
48
  
49
    
38 50

  
39 51
    /**
40 52
     * Create the composite.
41 53
     * @param parent
42 54
     * @param style
43 55
     */
44
    public DeleteTaxonConfiguratorComposite(TaxonBaseDeletionConfigurator configurator, Composite parent, int style) {
56
    public DeleteTaxonConfiguratorComposite(TaxonDeletionConfigurator configurator, Composite parent, int style) {
45 57
        super(parent, style);
46 58
        this.configurator = configurator;
47 59
        addDisposeListener(new DisposeListener() {
......
56 68

  
57 69
        btnDeleteTaxonName = new Button(this, SWT.CHECK);
58 70
        btnDeleteTaxonName.setText("Delete taxon name if possible");
71
        btnDeleteTaxonName.setSelection(true);
72
        
73
        btnDeleteInAllClassifications = new Button(this, SWT.CHECK);
74
        btnDeleteInAllClassifications.setText("Delete taxon in all classifications");
75
        btnDeleteInAllClassifications.setSelection(true);
76
        
59 77
        m_bindingContext = initDataBindings();
60 78

  
61 79
    }
......
65 83
        //
66 84
        IObservableValue observeSelectionBtnDeleteTaxonNameObserveWidget = WidgetProperties.selection().observe(btnDeleteTaxonName);
67 85
        IObservableValue deleteNameIfPossibleConfiguratorObserveValue = PojoProperties.value("deleteNameIfPossible").observe(configurator);
86
        
87
        IObservableValue observeSelectionBtnDeleteInAllClassificationObserveWidget = WidgetProperties.selection().observe(btnDeleteInAllClassifications);
88
        IObservableValue deleteInAllClassificationsConfiguratorObserveValue = PojoProperties.value("deleteInAllClassifications").observe(configurator);
68 89
        bindingContext.bindValue(observeSelectionBtnDeleteTaxonNameObserveWidget, deleteNameIfPossibleConfiguratorObserveValue, null, null);
90
        bindingContext.bindValue(observeSelectionBtnDeleteInAllClassificationObserveWidget, deleteInAllClassificationsConfiguratorObserveValue, null, null);
69 91
        //
70 92
        return bindingContext;
71 93
    }
94
    
95
   /* private Control createClassificationSelectionCombo(Composite parent){
96
//		classifications = CdmStore.getTaxonTreeService().list(null, null, null, null, null);
97

  
98
		Composite classificationSelection = new Composite(parent, SWT.NULL);
99
		classificationSelection.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
100

  
101
		GridLayout layout = new GridLayout();
102
		classificationSelection.setLayout(layout);
103

  
104
		Label label = new Label(classificationSelection, SWT.NULL);
105
		// TODO not working is not really true but leave it here to remind everyone that this is under construction
106
		label.setText("Select Classification");
107
		classificationSelectionCombo = new Combo(classificationSelection, SWT.BORDER | SWT.READ_ONLY);
108
		classificationSelectionCombo.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, true));
109
		List<Classification> classifications = 
110

  
111
		for(Classification tree : classifications){
112
			classificationSelectionCombo.add(tree.getName().getText(), classifications.indexOf(tree));
113

  
114
		}
115

  
116
		classificationSelectionCombo.select(classifications.indexOf(selectedClassification));
117

  
118
		// TODO remember last selection
119
		classificationSelectionCombo.addSelectionListener(this);
120

  
121

  
122

  
123
		return classificationSelection;
124
	}*/
72 125
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/description/DescriptionElementSourceSection.java
38 38
	/** {@inheritDoc} */
39 39
	@Override
40 40
	public DescriptionElementSource createNewElement() {
41
	    if(getEntity().getId() == 0) {
41
	   /* if(getEntity().getId() == 0) {
42 42
	        MessagingUtils.warningDialog("Description not saved", this, "Please save the newly created description before adding source");
43 43
	        return null;
44
	    }
44
	    }*/
45 45
		return DescriptionElementSource.NewInstance(OriginalSourceType.PrimaryTaxonomicSource);
46 46
	}
47 47

  

Also available in: Unified diff