mirror of
https://gitlab.kit.edu/uskyk/typicalc.git
synced 2024-11-09 10:50:42 +00:00
Limit scope of close shortcut in type assumptions
This commit is contained in:
parent
002f402691
commit
caeb2fca84
@ -51,7 +51,7 @@ public class TypeAssumptionsArea extends Dialog implements LocaleChangeObserver
|
|||||||
private final Button saveAssumptions;
|
private final Button saveAssumptions;
|
||||||
private final Notification invalidInputNotification;
|
private final Notification invalidInputNotification;
|
||||||
private final Label hintLabel;
|
private final Label hintLabel;
|
||||||
|
|
||||||
private final List<TypeAssumptionField> fields = new ArrayList<>();
|
private final List<TypeAssumptionField> fields = new ArrayList<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -62,19 +62,19 @@ public class TypeAssumptionsArea extends Dialog implements LocaleChangeObserver
|
|||||||
protected TypeAssumptionsArea(Map<String, String> types) {
|
protected TypeAssumptionsArea(Map<String, String> types) {
|
||||||
heading = new H3("");
|
heading = new H3("");
|
||||||
invalidInputNotification = createInvInputNotification();
|
invalidInputNotification = createInvInputNotification();
|
||||||
|
|
||||||
VerticalLayout layout = new VerticalLayout();
|
VerticalLayout layout = new VerticalLayout();
|
||||||
layout.setId(ASS_LAYOUT_ID);
|
layout.setId(ASS_LAYOUT_ID);
|
||||||
|
|
||||||
|
assumptionContainer = new VerticalLayout();
|
||||||
|
assumptionContainer.setId(ASS_CONTAINER_ID);
|
||||||
|
|
||||||
addAssumption = new Button("", new Icon(VaadinIcon.PLUS_CIRCLE));
|
addAssumption = new Button("", new Icon(VaadinIcon.PLUS_CIRCLE));
|
||||||
deleteAll = new Button("", new Icon(VaadinIcon.TRASH));
|
deleteAll = new Button("", new Icon(VaadinIcon.TRASH));
|
||||||
saveAssumptions = new Button(getTranslation("root.save"), event -> closeAction());
|
saveAssumptions = new Button(getTranslation("root.save"), event -> closeAction());
|
||||||
HorizontalLayout buttons = makeButtons();
|
HorizontalLayout buttons = makeButtons();
|
||||||
buttons.setId(ASS_BUTTONS_ID);
|
buttons.setId(ASS_BUTTONS_ID);
|
||||||
|
|
||||||
assumptionContainer = new VerticalLayout();
|
|
||||||
assumptionContainer.setId(ASS_CONTAINER_ID);
|
|
||||||
|
|
||||||
hintLabel = new Label("");
|
hintLabel = new Label("");
|
||||||
hintLabel.setId(HINT_ID);
|
hintLabel.setId(HINT_ID);
|
||||||
|
|
||||||
@ -86,10 +86,10 @@ public class TypeAssumptionsArea extends Dialog implements LocaleChangeObserver
|
|||||||
// attach and trigger javascript event listener after reopening the dialog
|
// attach and trigger javascript event listener after reopening the dialog
|
||||||
addOpenedChangeListener(this::onOpenedChange);
|
addOpenedChangeListener(this::onOpenedChange);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onOpenedChange(OpenedChangeEvent<Dialog> event) {
|
private void onOpenedChange(OpenedChangeEvent<Dialog> event) {
|
||||||
if (event.isOpened()) {
|
if (event.isOpened()) {
|
||||||
fields.forEach(TypeAssumptionField::refresh);
|
fields.forEach(TypeAssumptionField::refresh);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -104,7 +104,7 @@ public class TypeAssumptionsArea extends Dialog implements LocaleChangeObserver
|
|||||||
invalidInputNotification.close();
|
invalidInputNotification.close();
|
||||||
this.close();
|
this.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
private Notification createInvInputNotification() {
|
private Notification createInvInputNotification() {
|
||||||
Notification notification = new Notification();
|
Notification notification = new Notification();
|
||||||
notification.addThemeVariants(NotificationVariant.LUMO_ERROR);
|
notification.addThemeVariants(NotificationVariant.LUMO_ERROR);
|
||||||
@ -112,7 +112,7 @@ public class TypeAssumptionsArea extends Dialog implements LocaleChangeObserver
|
|||||||
notification.setDuration(5000); // set the duration to 5 seconds
|
notification.setDuration(5000); // set the duration to 5 seconds
|
||||||
return notification;
|
return notification;
|
||||||
}
|
}
|
||||||
|
|
||||||
private HorizontalLayout makeHeader() {
|
private HorizontalLayout makeHeader() {
|
||||||
HorizontalLayout headingLayout = new HorizontalLayout();
|
HorizontalLayout headingLayout = new HorizontalLayout();
|
||||||
headingLayout.setId(HEADING_LAYOUT_ID);
|
headingLayout.setId(HEADING_LAYOUT_ID);
|
||||||
@ -134,10 +134,11 @@ public class TypeAssumptionsArea extends Dialog implements LocaleChangeObserver
|
|||||||
deleteAll.setIconAfterText(true);
|
deleteAll.setIconAfterText(true);
|
||||||
deleteAll.addThemeVariants(ButtonVariant.LUMO_ERROR);
|
deleteAll.addThemeVariants(ButtonVariant.LUMO_ERROR);
|
||||||
saveAssumptions.addThemeVariants(ButtonVariant.LUMO_SUCCESS);
|
saveAssumptions.addThemeVariants(ButtonVariant.LUMO_SUCCESS);
|
||||||
saveAssumptions.addClickShortcut(Key.ENTER);
|
saveAssumptions.addClickShortcut(Key.ENTER).listenOn(assumptionContainer);
|
||||||
buttons.add(addAssumption, deleteAll, saveAssumptions);
|
buttons.add(addAssumption, deleteAll, saveAssumptions);
|
||||||
return buttons;
|
return buttons;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new empty TypeAssumptionsArea.
|
* Creates a new empty TypeAssumptionsArea.
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user