@@ -220,6 +220,39 @@ public UserInput userInput() {
220220 return steps ;
221221 }
222222
223+ private static Div dialogWithOneButton (AppDialog dialog , String dialogType ) {
224+ Div content = new Div ();
225+ Button showDialog = new Button ("Show Dialog" );
226+ // Dialog set-up
227+ DialogHeader .withIcon (dialog , dialogType , IconFactory .warningIcon ());
228+ DialogFooter .withConfirmOnly (dialog , "Close" );
229+ ExampleUserInput userInput = new ExampleUserInput ("Expelliarmus" );
230+ DialogBody .with (dialog , userInput , userInput );
231+
232+ Div confirmBox = new Div ("Click the button and press 'Cancel' or 'Save'" );
233+ showDialog .addClickListener (e -> {
234+ dialog .open ();
235+ confirmBox .setText ("Cancelled the dialog." );
236+ });
237+
238+ dialog .registerCancelAction (() -> {
239+ dialog .close ();
240+ if (dialog .hasChanges ()) {
241+ confirmBox .setText ("Cancelled the dialog although there where changes made!" );
242+ } else {
243+ confirmBox .setText ("Cancelled the dialog. No changes." );
244+ }
245+ });
246+ dialog .registerConfirmAction (() -> {
247+ dialog .close ();
248+ confirmBox .setText ("Confirmed the dialog." );
249+ });
250+
251+ content .add (showDialog , confirmBox );
252+ content .addClassNames (FLEX_VERTICAL , GAP_04 );
253+ return content ;
254+ }
255+
223256 private static Div dialogShowCase (AppDialog dialog , String dialogType ) {
224257 Div content = new Div ();
225258 Button showDialog = new Button ("Show Dialog" );
@@ -368,6 +401,8 @@ private static Div dialogShowCase() {
368401 container .add (dialogSectionShowCase ());
369402 container .add (createHeading3 ("Three steps example" ));
370403 container .add (stepperDialogShowCase (threeSteps (), "Three steps example" ));
404+ container .add (createHeading3 ("Dialog with one button" ));
405+ container .add (dialogWithOneButton (AppDialog .small (), "Dialog with one button" ));
371406
372407 return container ;
373408 }
0 commit comments