String ( final String className, final boolean generateOK, final boolean generateCancel, final boolean generateMain ) { @NonNls final StringBuilder result = new StringBuilder(1024); result.append("public class ").append(className).append(" extends javax.swing.JDialog {\n"); result.append("private javax.swing.JPanel contentPane;\n"); result.append("private javax.swing.JButton buttonOK;\n"); result.append("private javax.swing.JButton buttonCancel;\n"); result.append("\n"); result.append("public ").append(className).append("(){\n"); result.append("setContentPane(contentPane);\n"); result.append("setModal(true);\n"); result.append("getRootPane().setDefaultButton(buttonOK);\n"); if (generateOK) { result.append("\n"); result.append("buttonOK.addActionListener("); result.append("new java.awt.event.ActionListener(){"); result.append("public void actionPerformed(java.awt.event.ActionEvent e){"); result.append("onOK();"); result.append("}});\n"); } if (generateCancel) { result.append("\n"); result.append("buttonCancel.addActionListener("); result.append("new java.awt.event.ActionListener(){"); result.append("public void actionPerformed(java.awt.event.ActionEvent e){"); result.append("onCancel();"); result.append("}});\n"); result.append("\n "); result.append(UIDesignerBundle.message("comment.call.onCancel.cross")).append("\n"); result.append("setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);\n"); result.append("addWindowListener(new java.awt.event.WindowAdapter() {\n"); result.append(" public void windowClosing(java.awt.event.WindowEvent e) {\n"); result.append(" onCancel();\n"); result.append(" }\n"); result.append("});\n"); result.append("\n "); result.append(UIDesignerBundle.message("comment.call.onCancel.escape")).append("\n"); result.append("contentPane.registerKeyboardAction("); result.append(" new java.awt.event.ActionListener() {"); result.append(" public void actionPerformed(java.awt.event.ActionEvent e) {"); result.append(" onCancel();\n"); result.append(" }"); result.append(" },"); result.append(" javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_ESCAPE, 0),"); result.append(" javax.swing.JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT"); result.append(");"); } result.append("}\n"); if (generateOK) { result.append("\n"); result.append("private void onOK(){\n "); result.append(UIDesignerBundle.message("comment.onok")).append("\n"); result.append("dispose();\n"); result.append("}\n"); } if (generateCancel) { result.append("\n"); result.append("private void onCancel(){\n "); result.append(UIDesignerBundle.message("comment.oncancel")).append("\n"); result.append("dispose();\n"); result.append("}\n"); } if (generateMain) { result.append("\n"); result.append("public static void main(String[] args){\n"); result.append(className).append(" dialog = new ").append(className).append("();\n"); result.append("dialog.pack();\n"); result.append("dialog.setVisible(true);\n"); result.append("System.exit(0);\n"); result.append("}\n"); } result.append("}\n"); return result.toString(); }