Revision 2c4731aa
Added by Katja Luther almost 8 years ago
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/deleteConfigurator/DeleteTaxonConfiguratorComposite.java | ||
---|---|---|
1 |
// $Id$ |
|
2 |
/** |
|
3 |
* Copyright (C) 2015 EDIT |
|
4 |
* European Distributed Institute of Taxonomy |
|
5 |
* http://www.e-taxonomy.eu |
|
6 |
* |
|
7 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
|
8 |
* See LICENSE.TXT at the top of this package for the full license terms. |
|
9 |
*/ |
|
10 |
package eu.etaxonomy.taxeditor.ui.dialog.deleteConfigurator; |
|
11 |
|
|
12 |
import java.util.List; |
|
13 |
|
|
14 |
import org.eclipse.core.databinding.DataBindingContext; |
|
15 |
import org.eclipse.core.databinding.beans.PojoProperties; |
|
16 |
import org.eclipse.core.databinding.observable.value.IObservableValue; |
|
17 |
import org.eclipse.jface.databinding.swt.WidgetProperties; |
|
18 |
import org.eclipse.swt.SWT; |
|
19 |
import org.eclipse.swt.events.DisposeEvent; |
|
20 |
import org.eclipse.swt.events.DisposeListener; |
|
21 |
import org.eclipse.swt.events.SelectionEvent; |
|
22 |
import org.eclipse.swt.events.SelectionListener; |
|
23 |
import org.eclipse.swt.layout.GridData; |
|
24 |
import org.eclipse.swt.layout.GridLayout; |
|
25 |
|
|
26 |
import org.eclipse.swt.layout.RowLayout; |
|
27 |
import org.eclipse.swt.widgets.Button; |
|
28 |
import org.eclipse.swt.widgets.Combo; |
|
29 |
import org.eclipse.swt.widgets.Composite; |
|
30 |
import org.eclipse.swt.widgets.Control; |
|
31 |
import org.eclipse.swt.widgets.Display; |
|
32 |
import org.eclipse.swt.widgets.Label; |
|
33 |
import org.eclipse.ui.forms.widgets.FormToolkit; |
|
34 |
|
|
35 |
import eu.etaxonomy.cdm.api.service.IClassificationService; |
|
36 |
import eu.etaxonomy.cdm.api.service.config.TaxonDeletionConfigurator; |
|
37 |
|
|
38 |
import eu.etaxonomy.cdm.model.taxon.Classification; |
|
39 |
import eu.etaxonomy.taxeditor.store.CdmStore; |
|
40 |
|
|
41 |
|
|
42 |
/** |
|
43 |
* @author pplitzner |
|
44 |
* @date Feb 18, 2015 |
|
45 |
* |
|
46 |
*/ |
|
47 |
public class DeleteTaxonConfiguratorComposite extends Composite implements SelectionListener{ |
|
48 |
private final DataBindingContext m_bindingContext; |
|
49 |
|
|
50 |
private final FormToolkit toolkit = new FormToolkit(Display.getCurrent()); |
|
51 |
private final TaxonDeletionConfigurator configurator; |
|
52 |
private final Button btnDeleteTaxonName; |
|
53 |
private final Button btnDeleteInAllClassifications; |
|
54 |
private Combo classificationSelectionCombo; |
|
55 |
private |
|
56 |
|
|
57 |
Classification selectedClassification; |
|
58 |
private List<Classification> classifications; |
|
59 |
|
|
60 |
|
|
61 |
/** |
|
62 |
* Create the composite. |
|
63 |
* @param parent |
|
64 |
* @param style |
|
65 |
*/ |
|
66 |
public DeleteTaxonConfiguratorComposite(TaxonDeletionConfigurator configurator, Composite parent, int style) { |
|
67 |
super(parent, style); |
|
68 |
this.configurator = configurator; |
|
69 |
addDisposeListener(new DisposeListener() { |
|
70 |
@Override |
|
71 |
public void widgetDisposed(DisposeEvent e) { |
|
72 |
toolkit.dispose(); |
|
73 |
} |
|
74 |
}); |
|
75 |
toolkit.paintBordersFor(this); |
|
76 |
setLayout(new GridLayout()); |
|
77 |
setBackground(getBackground()); |
|
78 |
|
|
79 |
btnDeleteTaxonName = new Button(this, SWT.CHECK); |
|
80 |
btnDeleteTaxonName.setText("Delete taxon name if possible"); |
|
81 |
btnDeleteTaxonName.setSelection(true); |
|
82 |
|
|
83 |
btnDeleteInAllClassifications = new Button(this, SWT.CHECK); |
|
84 |
btnDeleteInAllClassifications.setText("Delete taxon in all classifications"); |
|
85 |
btnDeleteInAllClassifications.setSelection(true); |
|
86 |
|
|
87 |
// createClassificationSelectionCombo(this); |
|
88 |
|
|
89 |
m_bindingContext = initDataBindings(); |
|
90 |
|
|
91 |
} |
|
92 |
|
|
93 |
protected DataBindingContext initDataBindings() { |
|
94 |
DataBindingContext bindingContext = new DataBindingContext(); |
|
95 |
// |
|
96 |
IObservableValue observeSelectionBtnDeleteTaxonNameObserveWidget = WidgetProperties.selection().observe(btnDeleteTaxonName); |
|
97 |
IObservableValue deleteNameIfPossibleConfiguratorObserveValue = PojoProperties.value("deleteNameIfPossible").observe(configurator); |
|
98 |
|
|
99 |
IObservableValue observeSelectionBtnDeleteInAllClassificationObserveWidget = WidgetProperties.selection().observe(btnDeleteInAllClassifications); |
|
100 |
IObservableValue deleteInAllClassificationsConfiguratorObserveValue = PojoProperties.value("deleteInAllClassifications").observe(configurator); |
|
101 |
bindingContext.bindValue(observeSelectionBtnDeleteTaxonNameObserveWidget, deleteNameIfPossibleConfiguratorObserveValue, null, null); |
|
102 |
bindingContext.bindValue(observeSelectionBtnDeleteInAllClassificationObserveWidget, deleteInAllClassificationsConfiguratorObserveValue, null, null); |
|
103 |
|
|
104 |
|
|
105 |
|
|
106 |
// |
|
107 |
return bindingContext; |
|
108 |
} |
|
109 |
|
|
110 |
/* private Control createClassificationSelectionCombo(Composite parent){ |
|
111 |
// classifications = CdmStore.getTaxonTreeService().list(null, null, null, null, null); |
|
112 |
|
|
113 |
Composite classificationSelection = new Composite(parent, SWT.NULL); |
|
114 |
classificationSelection.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, true)); |
|
115 |
|
|
116 |
GridLayout layout = new GridLayout(); |
|
117 |
classificationSelection.setLayout(layout); |
|
118 |
|
|
119 |
Label label = new Label(classificationSelection, SWT.NULL); |
|
120 |
// TODO not working is not really true but leave it here to remind everyone that this is under construction |
|
121 |
label.setText("Select Classification"); |
|
122 |
classificationSelectionCombo = new Combo(classificationSelection, SWT.BORDER | SWT.READ_ONLY); |
|
123 |
classificationSelectionCombo.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, true)); |
|
124 |
classifications = CdmStore.getService(IClassificationService.class).list(null, null, null, null, null); |
|
125 |
|
|
126 |
for(Classification tree : classifications){ |
|
127 |
classificationSelectionCombo.add(tree.getName().getText(), classifications.indexOf(tree)); |
|
128 |
|
|
129 |
} |
|
130 |
|
|
131 |
classificationSelectionCombo.select(0); |
|
132 |
classificationSelectionCombo.addSelectionListener(this); |
|
133 |
|
|
134 |
return classificationSelection; |
|
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 |
} |
|
147 |
} |
|
1 |
// $Id$ |
|
2 |
/** |
|
3 |
* Copyright (C) 2016 EDIT |
|
4 |
* European Distributed Institute of Taxonomy |
|
5 |
* http://www.e-taxonomy.eu |
|
6 |
* |
|
7 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
|
8 |
* See LICENSE.TXT at the top of this package for the full license terms. |
|
9 |
*/ |
|
10 |
package eu.etaxonomy.taxeditor.ui.dialog.deleteConfigurator; |
|
11 |
|
|
12 |
import org.eclipse.core.databinding.beans.PojoProperties; |
|
13 |
import org.eclipse.core.databinding.observable.value.IObservableValue; |
|
14 |
import org.eclipse.jface.databinding.swt.WidgetProperties; |
|
15 |
import org.eclipse.swt.SWT; |
|
16 |
import org.eclipse.swt.widgets.Button; |
|
17 |
import org.eclipse.swt.widgets.Composite; |
|
18 |
|
|
19 |
import eu.etaxonomy.cdm.api.service.config.TaxonBaseDeletionConfigurator; |
|
20 |
|
|
21 |
/** |
|
22 |
* @author k.luther |
|
23 |
* @date 19.04.2016 |
|
24 |
* |
|
25 |
*/ |
|
26 |
public class DeleteTaxonConfiguratorComposite extends DeleteTaxonBaseConfiguratorComposite { |
|
27 |
|
|
28 |
private final Button btnDeleteSynonyms; |
|
29 |
private final Button btnDeleteMisappliedNamesAndInvalidDesignations; |
|
30 |
private final Button btnTaxonRelationships; |
|
31 |
private final Button btnConceptRelationships; |
|
32 |
/** |
|
33 |
* @param configurator |
|
34 |
* @param parent |
|
35 |
* @param style |
|
36 |
*/ |
|
37 |
public DeleteTaxonConfiguratorComposite(TaxonBaseDeletionConfigurator configurator, Composite parent, int style) { |
|
38 |
super(configurator, parent, style); |
|
39 |
btnDeleteSynonyms = new Button(this, SWT.CHECK); |
|
40 |
btnDeleteSynonyms.setText("Delete synonyms if possible"); |
|
41 |
btnDeleteSynonyms.setSelection(true); |
|
42 |
|
|
43 |
btnDeleteMisappliedNamesAndInvalidDesignations = new Button(this, SWT.CHECK); |
|
44 |
btnDeleteMisappliedNamesAndInvalidDesignations.setText("Delete misapplied names and invalid designations if possible"); |
|
45 |
btnDeleteMisappliedNamesAndInvalidDesignations.setSelection(true); |
|
46 |
|
|
47 |
|
|
48 |
btnTaxonRelationships = new Button(this, SWT.CHECK); |
|
49 |
btnTaxonRelationships.setText("Delete taxon relations if possible"); |
|
50 |
btnTaxonRelationships.setSelection(true); |
|
51 |
|
|
52 |
btnConceptRelationships = new Button(this, SWT.CHECK); |
|
53 |
btnConceptRelationships.setText("Delete concept relations if possible"); |
|
54 |
btnConceptRelationships.setSelection(true); |
|
55 |
initDataBindingsTaxon(); |
|
56 |
} |
|
57 |
|
|
58 |
protected void initDataBindingsTaxon() { |
|
59 |
|
|
60 |
IObservableValue observeSelectionBtnDeleteSynonymsObserveWidget = WidgetProperties.selection().observe(btnDeleteSynonyms); |
|
61 |
IObservableValue deleteSynonymsConfiguratorObserveValue = PojoProperties.value("deleteSynonymsIfPossible").observe(configurator); |
|
62 |
m_bindingContext.bindValue(observeSelectionBtnDeleteSynonymsObserveWidget, deleteSynonymsConfiguratorObserveValue, null, null); |
|
63 |
|
|
64 |
IObservableValue observeSelectionbtnDeleteMisappliedNamesAndInvalidDesignationsObserveWidget = WidgetProperties.selection().observe(btnDeleteMisappliedNamesAndInvalidDesignations); |
|
65 |
IObservableValue deleteMisappliedNamesAndInvalidDesignationsConfiguratorObserveValue = PojoProperties.value("deleteMisappliedNamesAndInvalidDesignationsIfPossible").observe(configurator); |
|
66 |
m_bindingContext.bindValue(observeSelectionbtnDeleteMisappliedNamesAndInvalidDesignationsObserveWidget, deleteMisappliedNamesAndInvalidDesignationsConfiguratorObserveValue, null, null); |
|
67 |
|
|
68 |
IObservableValue observeSelectionbtnTaxonRelationshipsObserveWidget = WidgetProperties.selection().observe(btnTaxonRelationships); |
|
69 |
IObservableValue deleteTaxonRelationshipsConfiguratorObserveValue = PojoProperties.value("deleteTaxonRelationships").observe(configurator); |
|
70 |
m_bindingContext.bindValue(observeSelectionbtnTaxonRelationshipsObserveWidget, deleteTaxonRelationshipsConfiguratorObserveValue, null, null); |
|
71 |
|
|
72 |
IObservableValue observeSelectionbtnConceptRelationshipsObserveWidget = WidgetProperties.selection().observe(btnConceptRelationships); |
|
73 |
IObservableValue deleteConceptRelationshipsConfiguratorObserveValue = PojoProperties.value("deleteConceptRelationships").observe(configurator); |
|
74 |
m_bindingContext.bindValue(observeSelectionbtnConceptRelationshipsObserveWidget, deleteConceptRelationshipsConfiguratorObserveValue, null, null); |
|
75 |
|
|
76 |
} |
|
77 |
} |
Also available in: Unified diff
improve the delete configurator dialogs for taxa and synonyms