11package fabs .component ;
22
3+
4+ import fabs .util .AbstractDialog ;
5+
36import javax .swing .*;
47import java .awt .event .*;
58import java .util .ArrayList ;
69import java .util .HashMap ;
710import java .util .Map ;
811
9- public class ComponentCreatorDialog extends JDialog {
12+ public class ComponentCreatorDialog extends AbstractDialog {
1013 private JPanel contentPane ;
1114 private JButton buttonOK ;
1215 private JButton buttonCancel ;
@@ -22,24 +25,15 @@ public class ComponentCreatorDialog extends JDialog {
2225 private final String storyTemplateFile = "templates/component/component.story.tsx.mustache" ;
2326 private final String markdownTemplateFile = "templates/component/component.md.mustache" ;
2427
25- private boolean hasCanceled = false ;
2628
2729 public ComponentCreatorDialog () {
2830 setContentPane (contentPane );
2931 setModal (true );
3032 getRootPane ().setDefaultButton (buttonOK );
3133
32- buttonOK .addActionListener (new ActionListener () {
33- public void actionPerformed (ActionEvent e ) {
34- onOK ();
35- }
36- });
34+ buttonOK .addActionListener (e -> onOK ());
3735
38- buttonCancel .addActionListener (new ActionListener () {
39- public void actionPerformed (ActionEvent e ) {
40- onCancel ();
41- }
42- });
36+ buttonCancel .addActionListener (e -> onCancel ());
4337
4438 // call onCancel() when cross is clicked
4539 setDefaultCloseOperation (DO_NOTHING_ON_CLOSE );
@@ -50,12 +44,7 @@ public void windowClosing(WindowEvent e) {
5044 });
5145
5246 // call onCancel() on ESCAPE
53- contentPane .registerKeyboardAction (new ActionListener () {
54- public void actionPerformed (ActionEvent e ) {
55- onCancel ();
56- }
57- }, KeyStroke .getKeyStroke (KeyEvent .VK_ESCAPE , 0 ), JComponent .WHEN_ANCESTOR_OF_FOCUSED_COMPONENT );
58-
47+ contentPane .registerKeyboardAction (e -> onCancel (), KeyStroke .getKeyStroke (KeyEvent .VK_ESCAPE , 0 ), JComponent .WHEN_ANCESTOR_OF_FOCUSED_COMPONENT );
5948 }
6049
6150 public Map <String , Object > getTemplateVars () {
@@ -90,19 +79,4 @@ public String[] getFiles() {
9079
9180 return files .toArray (new String [files .size ()]);
9281 }
93-
94- public boolean isCanceled () {
95- return hasCanceled ;
96- }
97-
98- private void onOK () {
99- hasCanceled = false ;
100- dispose ();
101- }
102-
103- private void onCancel () {
104- hasCanceled = true ;
105- dispose ();
106- }
107-
10882}
0 commit comments