Project

General

Profile

« Previous | Next » 

Revision f512d3f1

Added by Katja Luther over 8 years ago

add delete configurator dialog for taxa and names bulkeditor

View differences:

eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/handler/DeleteHandler.java
128 128
						INameService service = controller.getNameService();
129 129
						if (object != null){
130 130
							NameDeletionConfigurator config = new NameDeletionConfigurator();
131
							
132
							DeleteConfiguratorDialog dialog = new DeleteConfiguratorDialog(config, HandlerUtil.getActiveShell(event), "Confirm Deletion",  null,  "Do you really want to delete the name", MessageDialog.WARNING, new String[] { "Delete", "Skip" }, 0); 
133
							int result_dialog= dialog.open();
134
							if (result_dialog == 1){
135
								return null;
136
							}
131 137
							result = service.delete(((TaxonNameBase) object).getUuid(), config);
132 138
							errorMessage = "The name ";
133 139
						}
......
146 152
								errorMessage = "The taxon ";
147 153
							}else{
148 154
								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
								}
155
								
154 156
								result = service.deleteSynonym(((Synonym)object).getUuid(), config);
155 157
								errorMessage = "The synonym ";
156 158
							}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/deleteConfigurator/DeleteConfiguratorDialog.java
18 18
import org.eclipse.swt.widgets.Shell;
19 19

  
20 20
import eu.etaxonomy.cdm.api.service.config.DeleteConfiguratorBase;
21
import eu.etaxonomy.cdm.api.service.config.NameDeletionConfigurator;
21 22
import eu.etaxonomy.cdm.api.service.config.SpecimenDeleteConfigurator;
22 23
import eu.etaxonomy.cdm.api.service.config.TaxonBaseDeletionConfigurator;
23 24
import eu.etaxonomy.cdm.api.service.config.TaxonDeletionConfigurator;
......
53 54
            composite.addConfiguratorComposite(new DeleteSpecimenConfiguratorComposite((SpecimenDeleteConfigurator) configurator, composite.getSectionConfigure(), SWT.NONE));
54 55
        } else if(configurator instanceof TaxonNodeDeletionConfigurator){
55 56
            composite.addConfiguratorComposite(new DeleteNodeConfiguratorComposite((TaxonNodeDeletionConfigurator) configurator, composite.getSectionConfigure(), SWT.NONE));
57
        }  else if(configurator instanceof NameDeletionConfigurator){
58
            composite.addConfiguratorComposite(new DeleteNameConfiguratorComposite((NameDeletionConfigurator) configurator, composite.getSectionConfigure(), SWT.NONE));
56 59
        }
57 60
        
58 61
        return composite;
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/deleteConfigurator/DeleteNameConfiguratorComposite.java
1
package eu.etaxonomy.taxeditor.ui.dialog.deleteConfigurator;
2

  
3
import org.eclipse.core.databinding.DataBindingContext;
4
import org.eclipse.core.databinding.beans.PojoProperties;
5
import org.eclipse.core.databinding.observable.value.IObservableValue;
6
import org.eclipse.jface.databinding.swt.WidgetProperties;
7
import org.eclipse.swt.SWT;
8
import org.eclipse.swt.events.DisposeEvent;
9
import org.eclipse.swt.events.DisposeListener;
10
import org.eclipse.swt.layout.RowLayout;
11
import org.eclipse.swt.widgets.Button;
12
import org.eclipse.swt.widgets.Combo;
13
import org.eclipse.swt.widgets.Composite;
14
import org.eclipse.swt.widgets.Display;
15
import org.eclipse.ui.forms.widgets.FormToolkit;
16

  
17
import eu.etaxonomy.cdm.api.service.config.NameDeletionConfigurator;
18
import eu.etaxonomy.cdm.api.service.config.TaxonDeletionConfigurator;
19
/**
20
 * @author kluther
21
 * @date Nov 2, 2015
22
 *
23
 */
24
public class DeleteNameConfiguratorComposite extends Composite {
25
	private final DataBindingContext m_bindingContext;
26

  
27
    private final FormToolkit toolkit = new FormToolkit(Display.getCurrent());
28
    private final NameDeletionConfigurator configurator;
29
    private final Button btnRemoveAllNameRelationships;
30
    private final Button btnIgnoreIsBasionym;
31
    private final Button btnIgnoreIsReplacedSynonymFor;
32
    private final Button btnIgnoreHasBasionym;
33
    private final Button btnIgnoreHasReplacedSynonym;
34
    private final Button btnRemoveAllTypeDesignations;
35
  
36
    /*
37
     * private boolean removeAllNameRelationships = false;
38
	
39
	private boolean ignoreIsBasionymFor = false;
40
	
41
	private boolean ignoreIsReplacedSynonymFor = false;
42

  
43
	private boolean ignoreHasBasionym = true;
44
	
45
	private boolean ignoreHasReplacedSynonym = true;
46
	
47
	private boolean removeAllNameTypeDesignations = true;
48
     */
49
    
50

  
51
    /**
52
     * Create the composite.
53
     * @param parent
54
     * @param style
55
     */
56
    public DeleteNameConfiguratorComposite(NameDeletionConfigurator configurator, Composite parent, int style) {
57
        super(parent, style);
58
        this.configurator = configurator;
59
        addDisposeListener(new DisposeListener() {
60
            @Override
61
            public void widgetDisposed(DisposeEvent e) {
62
                toolkit.dispose();
63
            }
64
        });
65
        toolkit.paintBordersFor(this);
66
        setLayout(new RowLayout(SWT.VERTICAL));
67
        setBackground(getBackground());
68

  
69
        btnRemoveAllNameRelationships = new Button(this, SWT.CHECK);
70
        btnRemoveAllNameRelationships.setText("Remove all Name Relationships");
71
        btnRemoveAllNameRelationships.setSelection(true);
72
        
73
        btnIgnoreIsBasionym = new Button(this, SWT.CHECK);
74
        btnIgnoreIsBasionym.setText("Ignore is Basionym");
75
        btnIgnoreIsBasionym.setSelection(true);
76
        
77
        btnIgnoreIsReplacedSynonymFor = new Button(this, SWT.CHECK);
78
        btnIgnoreIsReplacedSynonymFor.setText("Ignore is Replaced Synonym");
79
        btnIgnoreIsReplacedSynonymFor.setSelection(true);
80
        
81
        btnIgnoreHasBasionym = new Button(this, SWT.CHECK);
82
        btnIgnoreHasBasionym.setText("Ignore has Basionym");
83
        btnIgnoreHasBasionym.setSelection(true);
84
        
85
        btnIgnoreHasReplacedSynonym = new Button(this, SWT.CHECK);
86
        btnIgnoreHasReplacedSynonym.setText("Ignore has Replaced Synonym");
87
        btnIgnoreHasReplacedSynonym.setSelection(true);
88
        
89
        btnRemoveAllTypeDesignations = new Button(this, SWT.CHECK);
90
        btnRemoveAllTypeDesignations.setText("Remove all Type Designations");
91
        btnRemoveAllTypeDesignations.setSelection(true);
92
        
93
        m_bindingContext = initDataBindings();
94

  
95
    }
96

  
97
    protected DataBindingContext initDataBindings() {
98
        DataBindingContext bindingContext = new DataBindingContext();
99
        //
100
        IObservableValue observeSelectionBtnRemoveAllNameRelationshipsWidget = WidgetProperties.selection().observe(btnRemoveAllNameRelationships);
101
        IObservableValue removeAllNameRelationshipsConfiguratorObserveValue = PojoProperties.value("removeAllNameRelationships").observe(configurator);
102
        bindingContext.bindValue(observeSelectionBtnRemoveAllNameRelationshipsWidget, removeAllNameRelationshipsConfiguratorObserveValue, null, null);
103
        
104
        IObservableValue observeSelectionBtnbtnIgnoreIsBasionymObserveWidget = WidgetProperties.selection().observe(btnIgnoreIsBasionym);
105
        IObservableValue ignoreIsBasionymConfiguratorObserveValue = PojoProperties.value("ignoreIsBasionymFor").observe(configurator);
106
        bindingContext.bindValue(observeSelectionBtnbtnIgnoreIsBasionymObserveWidget, ignoreIsBasionymConfiguratorObserveValue, null, null);
107
      
108
        IObservableValue observeSelectionBtnIgnoreIsReplacedSynonymForWidget = WidgetProperties.selection().observe(btnIgnoreIsReplacedSynonymFor);
109
        IObservableValue ignoreIsReplacedSynonymForConfiguratorObserveValue = PojoProperties.value("ignoreIsReplacedSynonymFor").observe(configurator);
110
        bindingContext.bindValue(observeSelectionBtnIgnoreIsReplacedSynonymForWidget, ignoreIsReplacedSynonymForConfiguratorObserveValue, null, null);
111
        
112
        IObservableValue observeSelectionBtnIgnoreHasBasionymWidget = WidgetProperties.selection().observe(btnIgnoreHasBasionym);
113
        IObservableValue ignoreHasBasionymConfiguratorObserveValue = PojoProperties.value("ignoreHasBasionym").observe(configurator);
114
        bindingContext.bindValue(observeSelectionBtnIgnoreHasBasionymWidget, ignoreHasBasionymConfiguratorObserveValue, null, null);
115
        
116
        IObservableValue observeSelectionBtnIgnoreHasReplacedSynonymWidget = WidgetProperties.selection().observe(btnIgnoreHasReplacedSynonym);
117
        IObservableValue ignoreHasReplacedSynonymConfiguratorObserveValue = PojoProperties.value("ignoreHasReplacedSynonym").observe(configurator);
118
        bindingContext.bindValue(observeSelectionBtnIgnoreHasReplacedSynonymWidget, ignoreHasReplacedSynonymConfiguratorObserveValue, null, null);
119

  
120
        IObservableValue observeSelectionBtnRemoveAllTypeDesignationsWidget = WidgetProperties.selection().observe(btnRemoveAllTypeDesignations);
121
        IObservableValue removeAllNameTypeDesignationsConfiguratorObserveValue = PojoProperties.value("removeAllNameTypeDesignations").observe(configurator);
122
        bindingContext.bindValue(observeSelectionBtnRemoveAllTypeDesignationsWidget, removeAllNameTypeDesignationsConfiguratorObserveValue, null, null);
123

  
124
        //
125
        return bindingContext;
126
    }
127
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/deleteConfigurator/DeleteTaxonConfiguratorComposite.java
9 9
*/
10 10
package eu.etaxonomy.taxeditor.ui.dialog.deleteConfigurator;
11 11

  
12
import java.util.List;
13

  
12 14
import org.eclipse.core.databinding.DataBindingContext;
13 15
import org.eclipse.core.databinding.beans.PojoProperties;
14 16
import org.eclipse.core.databinding.observable.value.IObservableValue;
......
16 18
import org.eclipse.swt.SWT;
17 19
import org.eclipse.swt.events.DisposeEvent;
18 20
import org.eclipse.swt.events.DisposeListener;
21
import org.eclipse.swt.events.SelectionEvent;
22
import org.eclipse.swt.events.SelectionListener;
19 23
import org.eclipse.swt.layout.GridData;
20 24
import org.eclipse.swt.layout.GridLayout;
25

  
21 26
import org.eclipse.swt.layout.RowLayout;
22 27
import org.eclipse.swt.widgets.Button;
23 28
import org.eclipse.swt.widgets.Combo;
......
27 32
import org.eclipse.swt.widgets.Label;
28 33
import org.eclipse.ui.forms.widgets.FormToolkit;
29 34

  
35
import eu.etaxonomy.cdm.api.service.IClassificationService;
30 36
import eu.etaxonomy.cdm.api.service.config.TaxonDeletionConfigurator;
31
import eu.etaxonomy.cdm.common.CdmUtils;
37

  
32 38
import eu.etaxonomy.cdm.model.taxon.Classification;
39
import eu.etaxonomy.taxeditor.store.CdmStore;
33 40

  
34 41

  
35 42
/**
......
37 44
 * @date Feb 18, 2015
38 45
 *
39 46
 */
40
public class DeleteTaxonConfiguratorComposite extends Composite {
47
public class DeleteTaxonConfiguratorComposite extends Composite implements SelectionListener{
41 48
    private final DataBindingContext m_bindingContext;
42 49

  
43 50
    private final FormToolkit toolkit = new FormToolkit(Display.getCurrent());
......
45 52
    private final Button btnDeleteTaxonName;
46 53
    private final Button btnDeleteInAllClassifications;
47 54
    private Combo classificationSelectionCombo;
48
  
55
    private 
56
    
57
    Classification selectedClassification;
58
    private List<Classification> classifications;
49 59
    
50 60

  
51 61
    /**
......
63 73
            }
64 74
        });
65 75
        toolkit.paintBordersFor(this);
66
        setLayout(new RowLayout(SWT.VERTICAL));
76
        setLayout(new GridLayout());
67 77
        setBackground(getBackground());
68 78

  
69 79
        btnDeleteTaxonName = new Button(this, SWT.CHECK);
......
74 84
        btnDeleteInAllClassifications.setText("Delete taxon in all classifications");
75 85
        btnDeleteInAllClassifications.setSelection(true);
76 86
        
87
       // createClassificationSelectionCombo(this);
88
        
77 89
        m_bindingContext = initDataBindings();
78 90

  
79 91
    }
......
88 100
        IObservableValue deleteInAllClassificationsConfiguratorObserveValue = PojoProperties.value("deleteInAllClassifications").observe(configurator);
89 101
        bindingContext.bindValue(observeSelectionBtnDeleteTaxonNameObserveWidget, deleteNameIfPossibleConfiguratorObserveValue, null, null);
90 102
        bindingContext.bindValue(observeSelectionBtnDeleteInAllClassificationObserveWidget, deleteInAllClassificationsConfiguratorObserveValue, null, null);
103
        
104
        
105
        
91 106
        //
92 107
        return bindingContext;
93 108
    }
94 109
    
95
   /* private Control createClassificationSelectionCombo(Composite parent){
110
  /* private Control createClassificationSelectionCombo(Composite parent){
96 111
//		classifications = CdmStore.getTaxonTreeService().list(null, null, null, null, null);
97 112

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

  
101 116
		GridLayout layout = new GridLayout();
102 117
		classificationSelection.setLayout(layout);
......
106 121
		label.setText("Select Classification");
107 122
		classificationSelectionCombo = new Combo(classificationSelection, SWT.BORDER | SWT.READ_ONLY);
108 123
		classificationSelectionCombo.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, true));
109
		List<Classification> classifications = 
124
		classifications = CdmStore.getService(IClassificationService.class).list(null, null, null, null, null);
110 125

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

  
114 129
		}
115 130

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

  
118
		// TODO remember last selection
131
		classificationSelectionCombo.select(0);
119 132
		classificationSelectionCombo.addSelectionListener(this);
120

  
121

  
122

  
133
		
123 134
		return classificationSelection;
124 135
	}*/
136

  
137
@Override
138
public void widgetSelected(SelectionEvent e) {
139
	selectedClassification = classifications.get(classificationSelectionCombo.getSelectionIndex());
140
}
141

  
142
@Override
143
public void widgetDefaultSelected(SelectionEvent e) {
144
	// TODO Auto-generated method stub
145
	
146
}
125 147
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/selection/ClassificationSelectionElement.java
1
package eu.etaxonomy.taxeditor.ui.selection;
2

  
3
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
4
import eu.etaxonomy.cdm.model.taxon.Classification;
5
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
6
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
7

  
8
public class ClassificationSelectionElement extends EntitySelectionElement<Classification> {
9

  
10
	public ClassificationSelectionElement(CdmFormFactory formFactory,
11
			ConversationHolder conversation, ICdmFormElement parentElement,
12
			Class<Classification> clazz, String labelString,
13
			Classification entity, int mode, int style) {
14
		super(formFactory, conversation, parentElement, clazz, labelString, entity,
15
				mode, style);
16
		
17
	}
18

  
19
}

Also available in: Unified diff