Revision de9c748c
Added by Andreas Kohlbecker over 5 years ago
src/main/java/eu/etaxonomy/vaadin/mvp/AbstractPopupEditor.java | ||
---|---|---|
54 | 54 |
import com.vaadin.ui.Notification.Type; |
55 | 55 |
import com.vaadin.ui.PopupDateField; |
56 | 56 |
import com.vaadin.ui.TextField; |
57 |
import com.vaadin.ui.UI; |
|
57 | 58 |
import com.vaadin.ui.VerticalLayout; |
59 |
import com.vaadin.ui.Window; |
|
58 | 60 |
import com.vaadin.ui.themes.ValoTheme; |
59 | 61 |
|
60 | 62 |
import eu.etaxonomy.cdm.database.PermissionDeniedException; |
... | ... | |
171 | 173 |
save.addClickListener(e -> save()); |
172 | 174 |
|
173 | 175 |
cancel = new Button("Cancel", FontAwesome.REMOVE); |
174 |
cancel.addClickListener(e -> cancel()); |
|
176 |
cancel.addClickListener(e -> cancelEditorDialog());
|
|
175 | 177 |
|
176 | 178 |
delete = new Button("Delete", FontAwesome.TRASH); |
177 | 179 |
delete.setStyleName(ValoTheme.BUTTON_DANGER); |
... | ... | |
377 | 379 |
fieldGroup.addCommitHandler(commitHandler); |
378 | 380 |
} |
379 | 381 |
|
382 |
protected void cancelEditorDialog(){ |
|
383 |
|
|
384 |
if(fieldGroup.isModified()){ |
|
385 |
String message = "<p>The editor has been modified.<br>Do you want to save your changes or discard them?<p>"; |
|
386 |
Window editorModifiedDialog = new Window("Cancel editor"); |
|
387 |
editorModifiedDialog.setModal(true); |
|
388 |
VerticalLayout subContent = new VerticalLayout(); |
|
389 |
subContent.setMargin(true); |
|
390 |
editorModifiedDialog.setContent(subContent); |
|
391 |
Button save = new Button("Save", FontAwesome.SAVE); |
|
392 |
save.setStyleName(ValoTheme.BUTTON_PRIMARY); |
|
393 |
Button discard = new Button("Discard", FontAwesome.REMOVE); |
|
394 |
discard.setStyleName(ValoTheme.BUTTON_DANGER); |
|
395 |
Button cancel = new Button("Cancel", FontAwesome.ARROW_CIRCLE_LEFT); |
|
396 |
Label messageLabel = new Label(message, com.vaadin.shared.ui.label.ContentMode.HTML); |
|
397 |
subContent.addComponent(messageLabel); |
|
398 |
HorizontalLayout buttonBar = new HorizontalLayout(save, discard, cancel); |
|
399 |
buttonBar.setStyleName(ValoTheme.WINDOW_BOTTOM_TOOLBAR); |
|
400 |
buttonBar.setWidth(100, Unit.PERCENTAGE); |
|
401 |
buttonBar.setSpacing(true); |
|
402 |
buttonBar.setExpandRatio(save, 1); |
|
403 |
buttonBar.setComponentAlignment(discard, Alignment.TOP_RIGHT); |
|
404 |
buttonBar.setComponentAlignment(save, Alignment.TOP_RIGHT); |
|
405 |
buttonBar.setComponentAlignment(cancel, Alignment.TOP_RIGHT); |
|
406 |
subContent.addComponent(buttonBar); |
|
407 |
save.addClickListener(e -> {editorModifiedDialog.close(); save();}); |
|
408 |
discard.addClickListener(e -> {editorModifiedDialog.close(); cancel();}); |
|
409 |
cancel.addClickListener(e -> editorModifiedDialog.close()); |
|
410 |
UI.getCurrent().addWindow(editorModifiedDialog); |
|
411 |
} else { |
|
412 |
cancel(); |
|
413 |
} |
|
414 |
} |
|
415 |
|
|
380 | 416 |
|
381 | 417 |
/** |
382 | 418 |
* Cancel editing and discard all modifications. |
Also available in: Unified diff
fix #7906 editor cancel confirmation dialog implemented