|
1 | 1 | package net.servicestack.eclipse.popup.actions; |
2 | 2 |
|
3 | | - |
| 3 | +import java.awt.BorderLayout; |
| 4 | +import java.awt.FlowLayout; |
| 5 | +import java.awt.Font; |
| 6 | + |
| 7 | +import javax.swing.ImageIcon; |
| 8 | +import javax.swing.InputVerifier; |
| 9 | +import javax.swing.JButton; |
| 10 | +import javax.swing.JComponent; |
| 11 | +import javax.swing.JDialog; |
| 12 | +import javax.swing.JLabel; |
| 13 | +import javax.swing.JPanel; |
| 14 | +import javax.swing.JTextField; |
| 15 | +import javax.swing.JTextPane; |
| 16 | +import javax.swing.KeyStroke; |
| 17 | +import javax.swing.border.EmptyBorder; |
4 | 18 | import javax.swing.event.DocumentEvent; |
5 | 19 | import javax.swing.event.DocumentListener; |
6 | | -import javax.swing.*; |
7 | 20 |
|
8 | | -import java.awt.*; |
| 21 | +import java.awt.GridLayout; |
9 | 22 | import java.awt.event.ActionEvent; |
10 | 23 | import java.awt.event.ActionListener; |
11 | 24 | import java.awt.event.KeyEvent; |
12 | 25 | import java.awt.event.WindowAdapter; |
13 | 26 | import java.awt.event.WindowEvent; |
| 27 | +import java.awt.Dimension; |
| 28 | +import javax.swing.SwingConstants; |
| 29 | +import javax.swing.SwingUtilities; |
| 30 | + |
| 31 | +import java.awt.Color; |
14 | 32 |
|
15 | | -public class AddRef extends JDialog { |
16 | | - private JPanel contentPane; |
| 33 | +public class AddRefDialog extends JDialog { |
| 34 | + |
| 35 | + private final JPanel contentPanel = new JPanel(); |
17 | 36 | private JButton buttonOK; |
18 | 37 | private JButton buttonCancel; |
19 | 38 | private JTextPane errorTextPane; |
20 | 39 | private JTextField addressUrlTextField; |
21 | 40 | private JTextField nameTextField; |
22 | 41 | private JTextPane infoTextPane; |
23 | | - |
| 42 | + |
24 | 43 | private String errorMessage; |
25 | 44 | private String selectedDirectory; |
26 | 45 |
|
27 | | - public AddRef() { |
28 | | - setContentPane(contentPane); |
29 | | - setModal(true); |
| 46 | + /** |
| 47 | + * Launch the application. |
| 48 | + */ |
| 49 | + public static void main(String[] args) { |
| 50 | + try { |
| 51 | + AddRefDialog dialog = new AddRefDialog(); |
| 52 | + dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); |
| 53 | + dialog.setVisible(true); |
| 54 | + } catch (Exception e) { |
| 55 | + e.printStackTrace(); |
| 56 | + } |
| 57 | + } |
| 58 | + |
| 59 | + /** |
| 60 | + * Create the dialog. |
| 61 | + */ |
| 62 | + public AddRefDialog() { |
| 63 | + setBounds(100, 100, 450, 300); |
| 64 | + getContentPane().setLayout(new BorderLayout()); |
| 65 | + contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5)); |
| 66 | + final JPanel panel1 = new JPanel(); |
| 67 | + panel1.setLayout(new BorderLayout()); |
| 68 | + getContentPane().add(contentPanel, BorderLayout.CENTER); |
| 69 | + contentPanel.setLayout(new GridLayout(0, 1, 0, 0)); |
| 70 | + |
| 71 | + JPanel panel = new JPanel(); |
| 72 | + contentPanel.add(panel); |
| 73 | + panel.setLayout(new GridLayout(0, 1, 0, 0)); |
| 74 | + infoTextPane = new JTextPane(); |
| 75 | + panel.add(infoTextPane); |
| 76 | + infoTextPane.setEditable(false); |
| 77 | + infoTextPane.setFocusCycleRoot(false); |
| 78 | + infoTextPane.setFocusable(false); |
| 79 | + infoTextPane.setFont(new Font("Arial", infoTextPane.getFont().getStyle(), infoTextPane.getFont().getSize())); |
| 80 | + infoTextPane.setOpaque(false); |
| 81 | + infoTextPane.setRequestFocusEnabled(false); |
| 82 | + infoTextPane.setText("To generate the DTO Service Model types for a specific ServiceStack instance, enter the base URI for the remote ServiceStack server and click OK."); |
| 83 | + errorTextPane = new JTextPane(); |
| 84 | + errorTextPane.setForeground(Color.RED); |
| 85 | + errorTextPane.setVisible(false); |
| 86 | + panel.add(errorTextPane); |
| 87 | + errorTextPane.setEditable(false); |
| 88 | + errorTextPane.setFocusCycleRoot(false); |
| 89 | + errorTextPane.setFocusable(false); |
| 90 | + errorTextPane.setFont(new Font("Arial", errorTextPane.getFont().getStyle(), errorTextPane.getFont().getSize())); |
| 91 | + errorTextPane.setOpaque(false); |
| 92 | + final JPanel panel3 = new JPanel(); |
| 93 | + contentPanel.add(panel3); |
| 94 | + panel3.setFocusable(false); |
| 95 | + panel3.setLayout(new GridLayout(0, 1, 0, 0)); |
| 96 | + final JLabel label3 = new JLabel(); |
| 97 | + label3.setText("Name"); |
| 98 | + panel3.add(label3); |
| 99 | + nameTextField = new JTextField(); |
| 100 | + nameTextField.setText("dto.java"); |
| 101 | + panel3.add(nameTextField); |
| 102 | + label3.setLabelFor(nameTextField); |
| 103 | + final JLabel label1 = new JLabel(); |
| 104 | + panel3.add(label1); |
| 105 | + label1.setText("Address Url"); |
| 106 | + { |
| 107 | + JPanel buttonPane = new JPanel(); |
| 108 | + buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT)); |
| 109 | + getContentPane().add(buttonPane, BorderLayout.SOUTH); |
| 110 | + { |
| 111 | + buttonOK = new JButton("OK"); |
| 112 | + buttonOK.setActionCommand("OK"); |
| 113 | + buttonPane.add(buttonOK); |
| 114 | + getRootPane().setDefaultButton(buttonOK); |
| 115 | + } |
| 116 | + { |
| 117 | + buttonCancel = new JButton("Cancel"); |
| 118 | + buttonCancel.setActionCommand("Cancel"); |
| 119 | + buttonPane.add(buttonCancel); |
| 120 | + } |
| 121 | + } |
| 122 | + addressUrlTextField = new JTextField(); |
| 123 | + panel3.add(addressUrlTextField); |
| 124 | + addressUrlTextField.setToolTipText("eg, http://example.com/"); |
| 125 | + label1.setLabelFor(addressUrlTextField); |
| 126 | + |
| 127 | + setModal(true); |
30 | 128 | getRootPane().setDefaultButton(buttonOK); |
31 | 129 | ImageIcon imageIcon = createImageIcon("/icons/logo-16.png", "ServiceStack"); |
32 | 130 | if (imageIcon != null) { |
@@ -154,14 +252,14 @@ public void windowClosing(WindowEvent e) { |
154 | 252 | }); |
155 | 253 |
|
156 | 254 | // call onCancel() on ESCAPE |
157 | | - contentPane.registerKeyboardAction(new ActionListener() { |
| 255 | + contentPanel.registerKeyboardAction(new ActionListener() { |
158 | 256 | public void actionPerformed(ActionEvent e) { |
159 | 257 | onCancel(); |
160 | 258 | } |
161 | 259 | }, KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); |
162 | | - } |
163 | | - |
164 | | - public void setSelectedDirectory(String selectedDirectory) { |
| 260 | + } |
| 261 | + |
| 262 | + public void setSelectedDirectory(String selectedDirectory) { |
165 | 263 | this.selectedDirectory = selectedDirectory; |
166 | 264 | } |
167 | 265 |
|
@@ -226,4 +324,5 @@ private void onOK() { |
226 | 324 | private void onCancel() { |
227 | 325 | dispose(); |
228 | 326 | } |
| 327 | + |
229 | 328 | } |
0 commit comments