1
|
/**
|
2
|
* Copyright (C) 2016 EDIT
|
3
|
* European Distributed Institute of Taxonomy
|
4
|
* http://www.e-taxonomy.eu
|
5
|
*
|
6
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
7
|
* See LICENSE.TXT at the top of this package for the full license terms.
|
8
|
*/
|
9
|
package eu.etaxonomy.taxeditor.ui.dialog.configurator.deleteConfigurator;
|
10
|
|
11
|
import org.eclipse.core.databinding.DataBindingContext;
|
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.events.DisposeEvent;
|
17
|
import org.eclipse.swt.events.DisposeListener;
|
18
|
import org.eclipse.swt.layout.RowLayout;
|
19
|
import org.eclipse.swt.widgets.Button;
|
20
|
import org.eclipse.swt.widgets.Composite;
|
21
|
import org.eclipse.swt.widgets.Display;
|
22
|
import org.eclipse.swt.widgets.Event;
|
23
|
import org.eclipse.ui.forms.widgets.FormToolkit;
|
24
|
|
25
|
import eu.etaxonomy.cdm.api.service.config.MediaDeletionConfigurator;
|
26
|
import eu.etaxonomy.taxeditor.l10n.Messages;
|
27
|
|
28
|
/**
|
29
|
* @author k.luther
|
30
|
* @date 02.11.2016
|
31
|
*
|
32
|
*/
|
33
|
public class DeleteMediaConfiguratorComposite extends Composite {
|
34
|
private final DataBindingContext m_bindingContext;
|
35
|
|
36
|
private final FormToolkit toolkit = new FormToolkit(Display.getCurrent());
|
37
|
private final MediaDeletionConfigurator configurator;
|
38
|
private Button btnDelete;
|
39
|
private Button btnDeleteIfUsedInTaxonDescription;
|
40
|
private Button btnDeleteIfUsedInSpecimenDescription;
|
41
|
private Button btnRemoveFromImageGallery;
|
42
|
|
43
|
private boolean inBulkEditor;
|
44
|
|
45
|
|
46
|
public DeleteMediaConfiguratorComposite(MediaDeletionConfigurator configurator, Composite parent, int style, boolean inBulkEditor) {
|
47
|
super(parent, style);
|
48
|
this.inBulkEditor = inBulkEditor;
|
49
|
this.configurator = configurator;
|
50
|
addDisposeListener(new DisposeListener() {
|
51
|
@Override
|
52
|
public void widgetDisposed(DisposeEvent e) {
|
53
|
toolkit.dispose();
|
54
|
}
|
55
|
});
|
56
|
toolkit.paintBordersFor(this);
|
57
|
setLayout(new RowLayout(SWT.VERTICAL));
|
58
|
setBackground(getBackground());
|
59
|
|
60
|
|
61
|
if (inBulkEditor){
|
62
|
btnDeleteIfUsedInTaxonDescription = new Button(this, SWT.CHECK);
|
63
|
btnDeleteIfUsedInTaxonDescription.setText(Messages.DeleteConfiguration_media_deleteIfUsedInTaxonDescription);
|
64
|
btnDeleteIfUsedInTaxonDescription.setEnabled(true);
|
65
|
btnDeleteIfUsedInTaxonDescription.setSelection(configurator.isDeleteIfUsedInTaxonDescription());
|
66
|
btnDeleteIfUsedInSpecimenDescription = new Button(this, SWT.CHECK);
|
67
|
btnDeleteIfUsedInSpecimenDescription.setText(Messages.DeleteConfiguration_media_deleteIfUsedInSpecimenDescription);
|
68
|
btnDeleteIfUsedInSpecimenDescription.setEnabled(true);
|
69
|
btnDeleteIfUsedInSpecimenDescription.setSelection(configurator.isDeleteIfUsedInSpecimenDescription());
|
70
|
}
|
71
|
else {
|
72
|
|
73
|
btnDelete = new Button(this, SWT.RADIO);
|
74
|
btnDelete.setText(Messages.DeleteConfiguration_media_delete);
|
75
|
|
76
|
// btnDeleteIfUsedInSpecimenDescription = new Button(this, SWT.CHECK);
|
77
|
// btnDeleteIfUsedInSpecimenDescription.setText(Messages.DeleteConfiguration_media_deleteIfUsedInSpecimenDescription);
|
78
|
// btnDeleteIfUsedInTaxonDescription = new Button(this, SWT.CHECK);
|
79
|
// btnDeleteIfUsedInTaxonDescription.setText(Messages.DeleteConfiguration_media_deleteIfUsedInTaxonDescription);
|
80
|
// btnDelete.addListener(SWT.Selection, (Event e) -> {
|
81
|
// Button b = (Button) e.widget;
|
82
|
// btnDeleteIfUsedInSpecimenDescription.setEnabled(b.getSelection());
|
83
|
// btnDeleteIfUsedInTaxonDescription.setEnabled(b.getSelection());
|
84
|
// });
|
85
|
btnRemoveFromImageGallery = new Button(this, SWT.RADIO);
|
86
|
btnRemoveFromImageGallery.setText(Messages.DeleteConfiguration_media_removeFromGallery);
|
87
|
btnDelete.setSelection(true);
|
88
|
btnRemoveFromImageGallery.setSelection(configurator.isOnlyRemoveFromGallery());
|
89
|
}
|
90
|
|
91
|
m_bindingContext = initDataBindings();
|
92
|
|
93
|
}
|
94
|
|
95
|
protected DataBindingContext initDataBindings() {
|
96
|
DataBindingContext bindingContext = new DataBindingContext();
|
97
|
//
|
98
|
if (inBulkEditor){
|
99
|
IObservableValue observeSelectionBtnDeleteIfUsedInTaxonDescription = WidgetProperties.selection().observe(btnDeleteIfUsedInTaxonDescription);
|
100
|
IObservableValue deleteIfUsedInTaxonDescriptionConfiguratorObserveValue = PojoProperties.value("deleteIfUsedInTaxonDescription").observe(configurator);
|
101
|
bindingContext.bindValue(observeSelectionBtnDeleteIfUsedInTaxonDescription, deleteIfUsedInTaxonDescriptionConfiguratorObserveValue, null, null);
|
102
|
|
103
|
IObservableValue observeSelectionBtnDeleteIfUsedInSpecimenDescription = WidgetProperties.selection().observe(btnDeleteIfUsedInSpecimenDescription);
|
104
|
IObservableValue deleteIfUsedInSpecimenDescriptionConfiguratorObserveValue = PojoProperties.value("deleteIfUsedInSpecimenDescription").observe(configurator);
|
105
|
bindingContext.bindValue(observeSelectionBtnDeleteIfUsedInSpecimenDescription, deleteIfUsedInSpecimenDescriptionConfiguratorObserveValue, null, null);
|
106
|
} else{
|
107
|
|
108
|
IObservableValue observeSelectionBtnDelete = WidgetProperties.selection().observe(btnDelete);
|
109
|
IObservableValue deleteConfiguratorObserveValue = PojoProperties.value("deleteIfUsedInTaxonDescription").observe(configurator);
|
110
|
bindingContext.bindValue(observeSelectionBtnDelete, deleteConfiguratorObserveValue, null, null);
|
111
|
|
112
|
IObservableValue observeSelectionBtnRemoveFromImageGallery = WidgetProperties.selection().observe(btnRemoveFromImageGallery);
|
113
|
IObservableValue removeFromImageGalleryConfiguratorObserveValue = PojoProperties.value("onlyRemoveFromGallery").observe(configurator);
|
114
|
bindingContext.bindValue(observeSelectionBtnRemoveFromImageGallery, removeFromImageGalleryConfiguratorObserveValue, null, null);
|
115
|
}
|
116
|
|
117
|
|
118
|
|
119
|
return bindingContext;
|
120
|
}
|
121
|
|
122
|
|
123
|
}
|