Revision 148679e6
Added by Patrick Plitzner over 8 years ago
- added option to toggle the delete configurator parameters in taxon deletion dialog (#4656)
.gitattributes | ||
---|---|---|
1410 | 1410 |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/combo/EnumComboElement.java -text |
1411 | 1411 |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/combo/TermComboElement.java -text |
1412 | 1412 |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/DefaultLanguageDialog.java -text |
1413 |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/DeleteConfiguratorComposite.java -text |
|
1413 | 1414 |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/DeleteConfiguratorDialog.java -text |
1414 | 1415 |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/DeleteTaxonConfiguratorDialog.java -text |
1415 | 1416 |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/LoginDialog.java -text |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/DeleteConfiguratorComposite.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; |
|
11 |
|
|
12 |
import org.eclipse.core.databinding.DataBindingContext; |
|
13 |
import org.eclipse.core.databinding.beans.PojoProperties; |
|
14 |
import org.eclipse.core.databinding.observable.value.IObservableValue; |
|
15 |
import org.eclipse.jface.databinding.swt.WidgetProperties; |
|
16 |
import org.eclipse.swt.SWT; |
|
17 |
import org.eclipse.swt.events.DisposeEvent; |
|
18 |
import org.eclipse.swt.events.DisposeListener; |
|
19 |
import org.eclipse.swt.layout.FillLayout; |
|
20 |
import org.eclipse.swt.widgets.Button; |
|
21 |
import org.eclipse.swt.widgets.Composite; |
|
22 |
import org.eclipse.swt.widgets.Display; |
|
23 |
import org.eclipse.ui.forms.events.ExpansionEvent; |
|
24 |
import org.eclipse.ui.forms.events.IExpansionListener; |
|
25 |
import org.eclipse.ui.forms.widgets.FormToolkit; |
|
26 |
import org.eclipse.ui.forms.widgets.Section; |
|
27 |
|
|
28 |
import eu.etaxonomy.cdm.api.service.config.TaxonBaseDeletionConfigurator; |
|
29 |
|
|
30 |
/** |
|
31 |
* @author pplitzner |
|
32 |
* @date Feb 16, 2015 |
|
33 |
* |
|
34 |
*/ |
|
35 |
public class DeleteConfiguratorComposite extends Composite implements IExpansionListener{ |
|
36 |
private final DataBindingContext m_bindingContext; |
|
37 |
|
|
38 |
private final FormToolkit toolkit = new FormToolkit(Display.getCurrent()); |
|
39 |
private TaxonBaseDeletionConfigurator configurator = null; |
|
40 |
private final Button btnDeleteTaxonName; |
|
41 |
|
|
42 |
/** |
|
43 |
* Create the composite. |
|
44 |
* @param parent |
|
45 |
* @param style |
|
46 |
*/ |
|
47 |
public DeleteConfiguratorComposite(TaxonBaseDeletionConfigurator configurator, final Composite parent, int style) { |
|
48 |
super(parent, SWT.NONE); |
|
49 |
this.configurator = configurator; |
|
50 |
|
|
51 |
addDisposeListener(new DisposeListener() { |
|
52 |
@Override |
|
53 |
public void widgetDisposed(DisposeEvent e) { |
|
54 |
toolkit.dispose(); |
|
55 |
} |
|
56 |
}); |
|
57 |
toolkit.paintBordersFor(this); |
|
58 |
setLayout(new FillLayout(SWT.HORIZONTAL)); |
|
59 |
|
|
60 |
Section sctnConfigure = toolkit.createSection(this, Section.CLIENT_INDENT | Section.TWISTIE); |
|
61 |
sctnConfigure.addExpansionListener(this); |
|
62 |
sctnConfigure.setBackground(getBackground()); |
|
63 |
toolkit.paintBordersFor(sctnConfigure); |
|
64 |
sctnConfigure.setText("Configure"); |
|
65 |
|
|
66 |
btnDeleteTaxonName = new Button(sctnConfigure, SWT.CHECK); |
|
67 |
sctnConfigure.setClient(btnDeleteTaxonName); |
|
68 |
btnDeleteTaxonName.setText("Delete Taxon Name"); |
|
69 |
m_bindingContext = initDataBindings(); |
|
70 |
|
|
71 |
} |
|
72 |
protected DataBindingContext initDataBindings() { |
|
73 |
DataBindingContext bindingContext = new DataBindingContext(); |
|
74 |
// |
|
75 |
IObservableValue observeSelectionBtnDeleteTaxonNameObserveWidget = WidgetProperties.selection().observe(btnDeleteTaxonName); |
|
76 |
IObservableValue deleteNameIfPossibleConfiguratorObserveValue = PojoProperties.value("deleteNameIfPossible").observe(configurator); |
|
77 |
bindingContext.bindValue(observeSelectionBtnDeleteTaxonNameObserveWidget, deleteNameIfPossibleConfiguratorObserveValue, null, null); |
|
78 |
// |
|
79 |
return bindingContext; |
|
80 |
} |
|
81 |
|
|
82 |
public Button getBtnDeleteTaxonName() { |
|
83 |
return btnDeleteTaxonName; |
|
84 |
} |
|
85 |
|
|
86 |
@Override |
|
87 |
public void expansionStateChanged(ExpansionEvent e) { |
|
88 |
getShell().setSize(getShell().computeSize(SWT.DEFAULT, SWT.DEFAULT)); |
|
89 |
} |
|
90 |
@Override |
|
91 |
public void expansionStateChanging(ExpansionEvent e) { |
|
92 |
} |
|
93 |
} |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/DeleteConfiguratorDialog.java | ||
---|---|---|
14 | 14 |
import org.eclipse.swt.graphics.Image; |
15 | 15 |
import org.eclipse.swt.widgets.Composite; |
16 | 16 |
import org.eclipse.swt.widgets.Control; |
17 |
import org.eclipse.swt.widgets.Listener; |
|
18 | 17 |
import org.eclipse.swt.widgets.Shell; |
19 | 18 |
|
20 | 19 |
import eu.etaxonomy.cdm.api.service.config.DeleteConfiguratorBase; |
... | ... | |
26 | 25 |
* @date Jan 28, 2015 |
27 | 26 |
* |
28 | 27 |
*/ |
29 |
public abstract class DeleteConfiguratorDialog extends MessageDialog implements Listener{
|
|
28 |
public abstract class DeleteConfiguratorDialog extends MessageDialog{ |
|
30 | 29 |
|
31 | 30 |
public DeleteConfiguratorDialog(Shell parentShell, String dialogTitle, |
32 | 31 |
Image dialogTitleImage, String dialogMessage, int dialogImageType, String[] dialogButtonLabels, int defaultIndex) { |
... | ... | |
40 | 39 |
protected Control createDialogArea(Composite parent) { |
41 | 40 |
Composite composite = (Composite) super.createDialogArea(parent); |
42 | 41 |
|
43 |
createCheckBoxes(composite); |
|
44 |
|
|
45 | 42 |
return composite; |
46 | 43 |
} |
47 | 44 |
|
48 |
protected abstract void createCheckBoxes(Composite parent); |
|
49 |
|
|
50 | 45 |
/** |
51 | 46 |
* @param kind |
52 | 47 |
* @return |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/DeleteTaxonConfiguratorDialog.java | ||
---|---|---|
10 | 10 |
package eu.etaxonomy.taxeditor.ui.dialog; |
11 | 11 |
|
12 | 12 |
import org.apache.log4j.Logger; |
13 |
import org.eclipse.swt.SWT; |
|
14 | 13 |
import org.eclipse.swt.graphics.Image; |
15 |
import org.eclipse.swt.widgets.Button; |
|
16 | 14 |
import org.eclipse.swt.widgets.Composite; |
17 |
import org.eclipse.swt.widgets.Event;
|
|
15 |
import org.eclipse.swt.widgets.Control;
|
|
18 | 16 |
import org.eclipse.swt.widgets.Shell; |
19 | 17 |
|
20 | 18 |
import eu.etaxonomy.cdm.api.service.config.TaxonDeletionConfigurator; |
... | ... | |
30 | 28 |
private final Logger logger = Logger.getLogger(DeleteTaxonConfiguratorDialog.class); |
31 | 29 |
|
32 | 30 |
private final TaxonDeletionConfigurator configurator; |
33 |
private Button btnDeleteName; |
|
34 | 31 |
|
35 | 32 |
/** |
36 | 33 |
* @param configurator |
... | ... | |
49 | 46 |
} |
50 | 47 |
|
51 | 48 |
/* (non-Javadoc) |
52 |
* @see org.eclipse.swt.widgets.Listener#handleEvent(org.eclipse.swt.widgets.Event)
|
|
49 |
* @see org.eclipse.jface.dialogs.MessageDialog#createCustomArea(org.eclipse.swt.widgets.Composite)
|
|
53 | 50 |
*/ |
54 | 51 |
@Override |
55 |
public void handleEvent(Event event) { |
|
56 |
if(event.widget==btnDeleteName){ |
|
57 |
configurator.setDeleteNameIfPossible(btnDeleteName.getSelection()); |
|
58 |
} |
|
59 |
} |
|
60 |
|
|
61 |
/* (non-Javadoc) |
|
62 |
* @see eu.etaxonomy.taxeditor.ui.dialog.DeleteConfiguratorDialog#createCheckBoxes() |
|
63 |
*/ |
|
64 |
@Override |
|
65 |
protected void createCheckBoxes(Composite parent) { |
|
66 |
btnDeleteName = new Button(parent, SWT.CHECK); |
|
67 |
btnDeleteName.setText("Delete taxon name if possible"); |
|
68 |
btnDeleteName.addListener(SWT.Selection, this); |
|
69 |
btnDeleteName.setSelection(configurator.isDeleteNameIfPossible()); |
|
52 |
protected Control createCustomArea(Composite parent) { |
|
53 |
DeleteConfiguratorComposite composite = new DeleteConfiguratorComposite(configurator, parent, NONE); |
|
54 |
return composite; |
|
70 | 55 |
} |
71 | 56 |
|
72 | 57 |
public static boolean openConfirmWithConfigurator(TaxonDeletionConfigurator configurator, Shell parent, String title, String message) { |
... | ... | |
74 | 59 |
return dialog.open() == 0; |
75 | 60 |
} |
76 | 61 |
|
62 |
/* (non-Javadoc) |
|
63 |
* @see org.eclipse.jface.dialogs.Dialog#isResizable() |
|
64 |
*/ |
|
65 |
@Override |
|
66 |
protected boolean isResizable() { |
|
67 |
return true; |
|
68 |
} |
|
69 |
|
|
77 | 70 |
} |
Also available in: Unified diff