15 |
15 |
import org.eclipse.swt.SWT;
|
16 |
16 |
import org.eclipse.swt.events.DisposeEvent;
|
17 |
17 |
import org.eclipse.swt.events.DisposeListener;
|
18 |
|
import org.eclipse.swt.layout.GridData;
|
19 |
|
import org.eclipse.swt.layout.GridLayout;
|
20 |
18 |
import org.eclipse.swt.layout.RowLayout;
|
21 |
19 |
import org.eclipse.swt.widgets.Button;
|
22 |
20 |
import org.eclipse.swt.widgets.Composite;
|
23 |
21 |
import org.eclipse.swt.widgets.Display;
|
24 |
22 |
import org.eclipse.swt.widgets.Event;
|
25 |
|
import org.eclipse.swt.widgets.Listener;
|
26 |
23 |
import org.eclipse.ui.forms.widgets.FormToolkit;
|
27 |
24 |
|
28 |
25 |
import eu.etaxonomy.cdm.api.service.config.MediaDeletionConfigurator;
|
... | ... | |
40 |
37 |
private final MediaDeletionConfigurator configurator;
|
41 |
38 |
private final Button btnDeleteIfUsedInTaxonDescription;
|
42 |
39 |
private final Button btnDeleteIfUsedInSpecimenDescription;
|
43 |
|
private final Button btnRemoveFromImageGallery;
|
44 |
|
private final boolean isInBulkEditor;
|
|
40 |
private Button btnRemoveFromImageGallery;
|
45 |
41 |
|
46 |
42 |
|
47 |
|
/**
|
48 |
|
* Create the composite.
|
49 |
|
* @param parent
|
50 |
|
* @param style
|
51 |
|
*/
|
52 |
|
public DeleteMediaConfiguratorComposite(MediaDeletionConfigurator configurator, Composite parent, int style) {
|
53 |
|
super(parent, style);
|
54 |
|
this.configurator = configurator;
|
55 |
|
this.isInBulkEditor = false;
|
56 |
|
addDisposeListener(new DisposeListener() {
|
57 |
|
@Override
|
58 |
|
public void widgetDisposed(DisposeEvent e) {
|
59 |
|
toolkit.dispose();
|
60 |
|
}
|
61 |
|
});
|
62 |
|
toolkit.paintBordersFor(this);
|
63 |
|
setLayout(new RowLayout(SWT.VERTICAL));
|
64 |
|
setBackground(getBackground());
|
65 |
|
|
66 |
|
btnRemoveFromImageGallery = null;
|
67 |
|
|
68 |
|
btnDeleteIfUsedInTaxonDescription = new Button(this, SWT.CHECK);
|
69 |
|
btnDeleteIfUsedInTaxonDescription.setText(Messages.DeleteConfiguration_media_deleteIfUsedInTaxonDescription);
|
70 |
|
btnDeleteIfUsedInTaxonDescription.setSelection(false);
|
71 |
|
|
72 |
|
btnDeleteIfUsedInSpecimenDescription = new Button(this, SWT.CHECK);
|
73 |
|
btnDeleteIfUsedInSpecimenDescription.setText(Messages.DeleteConfiguration_media_deleteIfUsedInSpecimenDescription);
|
74 |
|
btnDeleteIfUsedInSpecimenDescription.setSelection(false);
|
75 |
|
|
76 |
|
|
77 |
|
m_bindingContext = initDataBindings();
|
78 |
|
|
79 |
|
}
|
80 |
|
|
81 |
43 |
public DeleteMediaConfiguratorComposite(MediaDeletionConfigurator configurator, Composite parent, int style, boolean inBulkEditor) {
|
82 |
44 |
super(parent, style);
|
83 |
45 |
this.configurator = configurator;
|
84 |
|
this.isInBulkEditor = inBulkEditor;
|
85 |
46 |
addDisposeListener(new DisposeListener() {
|
86 |
47 |
@Override
|
87 |
48 |
public void widgetDisposed(DisposeEvent e) {
|
... | ... | |
89 |
50 |
}
|
90 |
51 |
});
|
91 |
52 |
toolkit.paintBordersFor(this);
|
92 |
|
setLayout(new GridLayout());
|
|
53 |
setLayout(new RowLayout(SWT.VERTICAL));
|
93 |
54 |
setBackground(getBackground());
|
94 |
55 |
|
95 |
|
|
96 |
|
|
97 |
|
|
98 |
|
if (!inBulkEditor){
|
99 |
|
btnRemoveFromImageGallery = new Button(this, SWT.RADIO);
|
100 |
|
btnRemoveFromImageGallery.setText(Messages.DeleteConfiguration_media_removeFromGallery);
|
101 |
|
|
102 |
|
btnRemoveFromImageGallery.setSelection(true);
|
103 |
|
btnRemoveFromImageGallery.setVisible(true);
|
104 |
|
btnDeleteIfUsedInTaxonDescription = new Button(this, SWT.RADIO);
|
105 |
|
btnDeleteIfUsedInTaxonDescription.setSelection(false);
|
106 |
|
btnDeleteIfUsedInTaxonDescription.setVisible(true);
|
107 |
|
btnDeleteIfUsedInTaxonDescription.setText(Messages.DeleteConfiguration_media_delete);
|
108 |
|
btnDeleteIfUsedInSpecimenDescription = new Button(this, SWT.CHECK);
|
109 |
|
btnDeleteIfUsedInSpecimenDescription.setText(Messages.DeleteConfiguration_media_deleteIfUsedInSpecimenDescription);
|
110 |
|
btnDeleteIfUsedInSpecimenDescription.setVisible(false);
|
111 |
|
btnDeleteIfUsedInTaxonDescription.addListener(SWT.Selection, new Listener() {
|
112 |
|
@Override
|
113 |
|
public void handleEvent(Event e) {
|
114 |
|
Button b = (Button) e.widget;
|
115 |
|
GridData data = (GridData) btnDeleteIfUsedInTaxonDescription.getLayoutData();
|
116 |
|
data.exclude = b.getSelection();
|
117 |
|
btnDeleteIfUsedInSpecimenDescription.setVisible(data.exclude);
|
118 |
|
|
119 |
|
}
|
120 |
|
});
|
121 |
|
|
122 |
|
|
123 |
|
|
124 |
|
|
125 |
|
} else{
|
126 |
|
btnRemoveFromImageGallery =null;
|
|
56 |
if (inBulkEditor){
|
127 |
57 |
btnDeleteIfUsedInTaxonDescription = new Button(this, SWT.CHECK);
|
128 |
|
btnDeleteIfUsedInTaxonDescription.setSelection(false);
|
129 |
58 |
btnDeleteIfUsedInTaxonDescription.setText(Messages.DeleteConfiguration_media_deleteIfUsedInTaxonDescription);
|
130 |
|
btnDeleteIfUsedInTaxonDescription.setVisible(true);
|
131 |
|
|
132 |
|
btnDeleteIfUsedInSpecimenDescription = new Button(this, SWT.CHECK);
|
133 |
|
btnDeleteIfUsedInSpecimenDescription.setText(Messages.DeleteConfiguration_media_deleteIfUsedInSpecimenDescription);
|
134 |
|
btnDeleteIfUsedInSpecimenDescription.setVisible(true);
|
135 |
59 |
}
|
|
60 |
else {
|
|
61 |
btnDeleteIfUsedInTaxonDescription = new Button(this, SWT.RADIO);
|
|
62 |
btnDeleteIfUsedInTaxonDescription.setText(Messages.DeleteConfiguration_media_delete);
|
136 |
63 |
|
|
64 |
btnRemoveFromImageGallery = new Button(this, SWT.RADIO);
|
|
65 |
btnRemoveFromImageGallery.setText(Messages.DeleteConfiguration_media_removeFromGallery);
|
|
66 |
}
|
137 |
67 |
|
|
68 |
btnDeleteIfUsedInSpecimenDescription = new Button(this, SWT.CHECK);
|
|
69 |
btnDeleteIfUsedInSpecimenDescription.setText(Messages.DeleteConfiguration_media_deleteIfUsedInSpecimenDescription);
|
138 |
70 |
|
|
71 |
if(inBulkEditor){
|
|
72 |
btnDeleteIfUsedInSpecimenDescription.setEnabled(true);
|
|
73 |
}
|
|
74 |
else{
|
|
75 |
btnDeleteIfUsedInSpecimenDescription.setEnabled(false);
|
139 |
76 |
|
|
77 |
btnDeleteIfUsedInTaxonDescription.addListener(SWT.Selection, (Event e) -> {
|
|
78 |
Button b = (Button) e.widget;
|
|
79 |
btnDeleteIfUsedInSpecimenDescription.setEnabled(b.getSelection());
|
140 |
80 |
|
141 |
|
|
|
81 |
});
|
|
82 |
}
|
|
83 |
btnDeleteIfUsedInTaxonDescription.setSelection(true);
|
142 |
84 |
|
143 |
85 |
m_bindingContext = initDataBindings();
|
144 |
86 |
|
... | ... | |
150 |
92 |
IObservableValue observeSelectionBtnDeleteIfUsedInTaxonDescription = WidgetProperties.selection().observe(btnDeleteIfUsedInTaxonDescription);
|
151 |
93 |
IObservableValue deleteIfUsedInTaxonDescriptionConfiguratorObserveValue = PojoProperties.value("deleteIfUsedInTaxonDescription").observe(configurator);
|
152 |
94 |
bindingContext.bindValue(observeSelectionBtnDeleteIfUsedInTaxonDescription, deleteIfUsedInTaxonDescriptionConfiguratorObserveValue, null, null);
|
153 |
|
if (isInBulkEditor){
|
154 |
|
IObservableValue observeSelectionBtnDeleteIfUsedInSpecimenDescription = WidgetProperties.selection().observe(btnDeleteIfUsedInSpecimenDescription);
|
155 |
|
IObservableValue deleteIfUsedInSpecimenDescriptionConfiguratorObserveValue = PojoProperties.value("deleteIfUsedInSpecimenDescription").observe(configurator);
|
156 |
|
bindingContext.bindValue(observeSelectionBtnDeleteIfUsedInSpecimenDescription, deleteIfUsedInSpecimenDescriptionConfiguratorObserveValue, null, null);
|
157 |
|
}else{
|
|
95 |
|
|
96 |
if(btnRemoveFromImageGallery!=null){
|
158 |
97 |
IObservableValue observeSelectionBtnRemoveFromImageGallery = WidgetProperties.selection().observe(btnRemoveFromImageGallery);
|
159 |
98 |
IObservableValue removeFromImageGalleryConfiguratorObserveValue = PojoProperties.value("onlyRemoveFromGallery").observe(configurator);
|
160 |
99 |
bindingContext.bindValue(observeSelectionBtnRemoveFromImageGallery, removeFromImageGalleryConfiguratorObserveValue, null, null);
|
161 |
|
|
162 |
|
IObservableValue observeSelectionBtnDeleteIfUsedInSpecimenDescription = WidgetProperties.selection().observe(btnDeleteIfUsedInSpecimenDescription);
|
163 |
|
IObservableValue deleteIfUsedInSpecimenDescriptionConfiguratorObserveValue = PojoProperties.value("deleteIfUsedInSpecimenDescription").observe(configurator);
|
164 |
|
bindingContext.bindValue(observeSelectionBtnDeleteIfUsedInSpecimenDescription, deleteIfUsedInSpecimenDescriptionConfiguratorObserveValue, null, null);
|
165 |
100 |
}
|
166 |
101 |
|
|
102 |
IObservableValue observeSelectionBtnDeleteIfUsedInSpecimenDescription = WidgetProperties.selection().observe(btnDeleteIfUsedInSpecimenDescription);
|
|
103 |
IObservableValue deleteIfUsedInSpecimenDescriptionConfiguratorObserveValue = PojoProperties.value("deleteIfUsedInSpecimenDescription").observe(configurator);
|
|
104 |
bindingContext.bindValue(observeSelectionBtnDeleteIfUsedInSpecimenDescription, deleteIfUsedInSpecimenDescriptionConfiguratorObserveValue, null, null);
|
|
105 |
|
167 |
106 |
return bindingContext;
|
168 |
107 |
}
|
169 |
108 |
|
ref #6527 Refactor configurator composite