Revision 11247507
Added by Andreas Kohlbecker over 5 years ago
src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/RegistrationWorksetViewBean.java | ||
---|---|---|
39 | 39 |
import com.vaadin.ui.GridLayout; |
40 | 40 |
import com.vaadin.ui.HorizontalLayout; |
41 | 41 |
import com.vaadin.ui.Label; |
42 |
import com.vaadin.ui.ListSelect; |
|
43 | 42 |
import com.vaadin.ui.Notification; |
44 | 43 |
import com.vaadin.ui.Panel; |
45 | 44 |
import com.vaadin.ui.UI; |
... | ... | |
88 | 87 |
public class RegistrationWorksetViewBean extends AbstractPageView<RegistrationWorkingsetPresenter> |
89 | 88 |
implements RegistrationWorkingsetView, View, AccessRestrictedView { |
90 | 89 |
|
91 |
/** |
|
92 |
* |
|
93 |
*/ |
|
90 |
|
|
94 | 91 |
private static final int COL_INDEX_STATE_LABEL = 0; |
95 | 92 |
|
96 |
/** |
|
97 |
* |
|
98 |
*/ |
|
99 | 93 |
private static final int COL_INDEX_REG_ITEM = 1; |
100 | 94 |
|
101 |
/** |
|
102 |
* |
|
103 |
*/ |
|
104 | 95 |
private static final int COL_INDEX_BUTTON_GROUP = 2; |
105 | 96 |
|
106 | 97 |
public static final String DOM_ID_WORKINGSET = "workingset"; |
107 | 98 |
|
99 |
public static final String TEXT_NAME_TYPIFICATION = "covering the name and typifications"; |
|
100 |
public static final String TEXT_TYPIFICATION_ONLY = "covering typifications only"; |
|
101 |
|
|
108 | 102 |
private static final long serialVersionUID = -213040114015958970L; |
109 | 103 |
|
110 | 104 |
public static final String NAME = "workingset"; |
... | ... | |
126 | 120 |
|
127 | 121 |
private Button addExistingNameButton; |
128 | 122 |
|
129 |
private ListSelect existingNameRegistrationTypeSelect;
|
|
123 |
private Label existingNameRegistrationTypeLabel;
|
|
130 | 124 |
|
131 | 125 |
private RegistrationItem workingsetHeader; |
132 | 126 |
|
... | ... | |
253 | 247 |
addNewNameRegistrationButton.addClickListener( |
254 | 248 |
e -> getViewEventBus().publish(this, new TaxonNameEditorAction(EditorActionType.ADD, null, addNewNameRegistrationButton, null, this))); |
255 | 249 |
|
256 |
existingNameRegistrationTypeSelect = new ListSelect(null, EnumSet.allOf(ExistingNameRegistrationType.class)); |
|
257 |
existingNameRegistrationTypeSelect.setRows(1); |
|
258 |
existingNameRegistrationTypeSelect.setNullSelectionAllowed(true); |
|
259 |
existingNameRegistrationTypeSelect.setEnabled(false); |
|
250 |
existingNameRegistrationTypeLabel = new Label(); |
|
260 | 251 |
addExistingNameButton = new Button("existing name:"); |
261 | 252 |
addExistingNameButton.setEnabled(false); |
262 | 253 |
addExistingNameButton.addClickListener( |
263 | 254 |
e -> getViewEventBus().publish(this, new RegistrationWorkingsetAction( |
264 | 255 |
citationUuid, |
265 |
RegistrationWorkingsetAction.Action.start, |
|
266 |
(ExistingNameRegistrationType)existingNameRegistrationTypeSelect.getValue()) |
|
256 |
RegistrationWorkingsetAction.Action.start |
|
267 | 257 |
) |
268 |
); |
|
258 |
) |
|
259 |
); |
|
269 | 260 |
|
270 | 261 |
existingNameCombobox = new LazyComboBox<TaxonName>(TaxonName.class); |
271 | 262 |
existingNameCombobox.addValueChangeListener( |
272 | 263 |
e -> { |
273 | 264 |
boolean selectionNotEmpty = e.getProperty().getValue() != null; |
274 |
addExistingNameButton.setEnabled(selectionNotEmpty);
|
|
275 |
existingNameRegistrationTypeSelect.setEnabled(selectionNotEmpty);
|
|
265 |
addExistingNameButton.setEnabled(false);
|
|
266 |
existingNameRegistrationTypeLabel.setValue(null);
|
|
276 | 267 |
if(selectionNotEmpty){ |
277 | 268 |
TaxonName name = (TaxonName)e.getProperty().getValue(); |
278 |
if(getPresenter().canCreateRegistrationForName(name)){ |
|
279 |
existingNameRegistrationTypeSelect.setValue(ExistingNameRegistrationType.NAME_TYPIFICATION); |
|
280 |
existingNameRegistrationTypeSelect.setEnabled(true); |
|
281 |
existingNameRegistrationTypeSelect.setNullSelectionAllowed(false); |
|
269 |
if(getPresenter().canCreateNameRegistrationFor(name)){ |
|
270 |
existingNameRegistrationTypeLabel.setValue(TEXT_NAME_TYPIFICATION); |
|
271 |
addExistingNameButton.setEnabled(true); |
|
282 | 272 |
} else { |
283 |
existingNameRegistrationTypeSelect.setValue(ExistingNameRegistrationType.TYPIFICATION_ONLY); |
|
284 |
existingNameRegistrationTypeSelect.setEnabled(false); |
|
273 |
if(!getPresenter().checkWokingsetContainsProtologe(name)){ |
|
274 |
existingNameRegistrationTypeLabel.setValue(TEXT_TYPIFICATION_ONLY); |
|
275 |
addExistingNameButton.setEnabled(true); |
|
276 |
} |
|
285 | 277 |
} |
286 | 278 |
} else { |
287 |
existingNameRegistrationTypeSelect.setNullSelectionAllowed(true); |
|
288 |
existingNameRegistrationTypeSelect.clear(); |
|
289 |
existingNameRegistrationTypeSelect.setEnabled(false); |
|
290 |
|
|
279 |
existingNameRegistrationTypeLabel.setValue(null); |
|
291 | 280 |
} |
292 | 281 |
} |
293 | 282 |
); |
... | ... | |
298 | 287 |
addRegistrationLabel_2, |
299 | 288 |
addExistingNameButton, |
300 | 289 |
existingNameCombobox, |
301 |
existingNameRegistrationTypeSelect
|
|
290 |
existingNameRegistrationTypeLabel
|
|
302 | 291 |
); |
303 | 292 |
buttonContainer.setSpacing(true); |
304 | 293 |
// buttonContainer.setWidth(100, Unit.PERCENTAGE); |
Also available in: Unified diff
fix #7629 restricting new registrations to those which make sense in the current workingset