@@ -22,12 +22,11 @@ public class AddTypeScriptRef extends JDialog {
2222 private JTextField nameTextField ;
2323 private JTextPane errorTextPane ;
2424 private JTextPane infoTextPane ;
25+ private JCheckBox onlyTypeScriptDefinitionsCheckBox ;
2526
2627 private String selectedDirectory ;
27- private StringBuilder errorMessageBuilder = new StringBuilder ();
2828 private String errorMessage ;
2929
30- private String initialDtoName ;
3130 private Module module ;
3231
3332 public AddTypeScriptRef (Module module ) {
@@ -169,14 +168,21 @@ public void actionPerformed(ActionEvent e) {
169168 }
170169
171170 private void onOK () {
171+ StringBuilder errorMessageBuilder = new StringBuilder ();
172172 AddTypeScriptRefHandler .handleOk (
173173 this .module ,
174174 this .addressUrlTextField .getText (),
175175 this .nameTextField .getText (),
176176 this .selectedDirectory ,
177- this .errorMessageBuilder
177+ this .onlyTypeScriptDefinitionsCheckBox .isSelected (),
178+ errorMessageBuilder
178179 );
179- dispose ();
180+ if (errorMessageBuilder .toString ().length () > 0 ) {
181+ errorTextPane .setText (errorMessageBuilder .toString ());
182+ errorTextPane .setVisible (true );
183+ } else {
184+ dispose ();
185+ }
180186 }
181187
182188 private void onCancel () {
@@ -190,6 +196,7 @@ public static void main(String[] args) {
190196 dialog .setVisible (true );
191197 System .exit (0 );
192198 }
199+
193200 private ImageIcon createImageIcon (String path , String description ) {
194201 URL imgURL = getClass ().getResource (path );
195202 if (imgURL != null ) {
@@ -210,11 +217,11 @@ public void setSelectedDirectory(String selectedDirectory) {
210217 }
211218
212219 public String getInitialDtoName () {
213- return initialDtoName ;
220+ return this . nameTextField . getText () ;
214221 }
215222
216223 public void setInitialDtoName (String initialDtoName ) {
217- this .initialDtoName = initialDtoName ;
224+ this .nameTextField . setText ( initialDtoName ) ;
218225 }
219226
220227 {
@@ -239,19 +246,23 @@ public void setInitialDtoName(String initialDtoName) {
239246 contentPane .setPreferredSize (new Dimension (550 , 220 ));
240247 contentPane .setRequestFocusEnabled (false );
241248 final JPanel panel1 = new JPanel ();
242- panel1 .setLayout (new GridLayoutManager (1 , 2 , new Insets (0 , 0 , 0 , 0 ), -1 , -1 ));
249+ panel1 .setLayout (new GridLayoutManager (1 , 3 , new Insets (0 , 0 , 0 , 0 ), -1 , -1 ));
243250 contentPane .add (panel1 , new GridConstraints (2 , 0 , 1 , 1 , GridConstraints .ANCHOR_CENTER , GridConstraints .FILL_BOTH , GridConstraints .SIZEPOLICY_CAN_SHRINK | GridConstraints .SIZEPOLICY_CAN_GROW , 1 , null , null , null , 0 , false ));
244251 final Spacer spacer1 = new Spacer ();
245- panel1 .add (spacer1 , new GridConstraints (0 , 0 , 1 , 1 , GridConstraints .ANCHOR_CENTER , GridConstraints .FILL_HORIZONTAL , GridConstraints .SIZEPOLICY_WANT_GROW , 1 , null , null , null , 0 , false ));
252+ panel1 .add (spacer1 , new GridConstraints (0 , 1 , 1 , 1 , GridConstraints .ANCHOR_CENTER , GridConstraints .FILL_HORIZONTAL , GridConstraints .SIZEPOLICY_WANT_GROW , 1 , null , null , null , 0 , false ));
246253 final JPanel panel2 = new JPanel ();
247254 panel2 .setLayout (new GridLayoutManager (1 , 2 , new Insets (0 , 0 , 0 , 0 ), -1 , -1 , true , false ));
248- panel1 .add (panel2 , new GridConstraints (0 , 1 , 1 , 1 , GridConstraints .ANCHOR_CENTER , GridConstraints .FILL_BOTH , GridConstraints .SIZEPOLICY_CAN_SHRINK | GridConstraints .SIZEPOLICY_CAN_GROW , GridConstraints .SIZEPOLICY_CAN_SHRINK | GridConstraints .SIZEPOLICY_CAN_GROW , null , null , null , 0 , false ));
255+ panel1 .add (panel2 , new GridConstraints (0 , 2 , 1 , 1 , GridConstraints .ANCHOR_CENTER , GridConstraints .FILL_BOTH , GridConstraints .SIZEPOLICY_CAN_SHRINK | GridConstraints .SIZEPOLICY_CAN_GROW , GridConstraints .SIZEPOLICY_CAN_SHRINK | GridConstraints .SIZEPOLICY_CAN_GROW , null , null , null , 0 , false ));
249256 buttonOK = new JButton ();
250257 buttonOK .setText ("OK" );
251258 panel2 .add (buttonOK , new GridConstraints (0 , 0 , 1 , 1 , GridConstraints .ANCHOR_CENTER , GridConstraints .FILL_HORIZONTAL , GridConstraints .SIZEPOLICY_CAN_SHRINK | GridConstraints .SIZEPOLICY_CAN_GROW , GridConstraints .SIZEPOLICY_FIXED , null , null , null , 0 , false ));
252259 buttonCancel = new JButton ();
253260 buttonCancel .setText ("Cancel" );
254261 panel2 .add (buttonCancel , new GridConstraints (0 , 1 , 1 , 1 , GridConstraints .ANCHOR_CENTER , GridConstraints .FILL_HORIZONTAL , GridConstraints .SIZEPOLICY_CAN_SHRINK | GridConstraints .SIZEPOLICY_CAN_GROW , GridConstraints .SIZEPOLICY_FIXED , null , null , null , 0 , false ));
262+ onlyTypeScriptDefinitionsCheckBox = new JCheckBox ();
263+ onlyTypeScriptDefinitionsCheckBox .setSelected (true );
264+ onlyTypeScriptDefinitionsCheckBox .setText ("Only TypeScript definitions" );
265+ panel1 .add (onlyTypeScriptDefinitionsCheckBox , new GridConstraints (0 , 0 , 1 , 1 , GridConstraints .ANCHOR_WEST , GridConstraints .FILL_NONE , GridConstraints .SIZEPOLICY_CAN_SHRINK | GridConstraints .SIZEPOLICY_CAN_GROW , GridConstraints .SIZEPOLICY_FIXED , null , null , null , 0 , false ));
255266 final JPanel panel3 = new JPanel ();
256267 panel3 .setLayout (new GridLayoutManager (2 , 3 , new Insets (0 , 0 , 0 , 0 ), -1 , -1 ));
257268 contentPane .add (panel3 , new GridConstraints (1 , 0 , 1 , 1 , GridConstraints .ANCHOR_CENTER , GridConstraints .FILL_BOTH , GridConstraints .SIZEPOLICY_CAN_SHRINK | GridConstraints .SIZEPOLICY_CAN_GROW , GridConstraints .SIZEPOLICY_CAN_SHRINK | GridConstraints .SIZEPOLICY_CAN_GROW , null , null , null , 0 , false ));
@@ -265,7 +276,7 @@ public void setInitialDtoName(String initialDtoName) {
265276 label2 .setText ("Name" );
266277 panel3 .add (label2 , new GridConstraints (1 , 0 , 1 , 1 , GridConstraints .ANCHOR_WEST , GridConstraints .FILL_NONE , GridConstraints .SIZEPOLICY_FIXED , GridConstraints .SIZEPOLICY_FIXED , null , null , null , 0 , false ));
267278 nameTextField = new JTextField ();
268- nameTextField .setText ("dtos.java " );
279+ nameTextField .setText ("" );
269280 panel3 .add (nameTextField , new GridConstraints (1 , 1 , 1 , 2 , GridConstraints .ANCHOR_WEST , GridConstraints .FILL_HORIZONTAL , GridConstraints .SIZEPOLICY_WANT_GROW , GridConstraints .SIZEPOLICY_FIXED , null , new Dimension (150 , -1 ), null , 0 , false ));
270281 final JPanel panel4 = new JPanel ();
271282 panel4 .setLayout (new GridLayoutManager (2 , 1 , new Insets (0 , 0 , 0 , 0 ), -1 , -1 ));
0 commit comments