Skip to content

Commit becb47c

Browse files
committed
Got UI looking similar for Eclipse plugin.
1 parent 24195bc commit becb47c

File tree

2 files changed

+114
-14
lines changed

2 files changed

+114
-14
lines changed

src/ServiceStackEclipse/src/net/servicestack/eclipse/popup/actions/AddRef.java renamed to src/ServiceStackEclipse/src/net/servicestack/eclipse/popup/actions/AddRefDialog.java

Lines changed: 112 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,130 @@
11
package net.servicestack.eclipse.popup.actions;
22

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;
418
import javax.swing.event.DocumentEvent;
519
import javax.swing.event.DocumentListener;
6-
import javax.swing.*;
720

8-
import java.awt.*;
21+
import java.awt.GridLayout;
922
import java.awt.event.ActionEvent;
1023
import java.awt.event.ActionListener;
1124
import java.awt.event.KeyEvent;
1225
import java.awt.event.WindowAdapter;
1326
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;
1432

15-
public class AddRef extends JDialog {
16-
private JPanel contentPane;
33+
public class AddRefDialog extends JDialog {
34+
35+
private final JPanel contentPanel = new JPanel();
1736
private JButton buttonOK;
1837
private JButton buttonCancel;
1938
private JTextPane errorTextPane;
2039
private JTextField addressUrlTextField;
2140
private JTextField nameTextField;
2241
private JTextPane infoTextPane;
23-
42+
2443
private String errorMessage;
2544
private String selectedDirectory;
2645

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);
30128
getRootPane().setDefaultButton(buttonOK);
31129
ImageIcon imageIcon = createImageIcon("/icons/logo-16.png", "ServiceStack");
32130
if (imageIcon != null) {
@@ -154,14 +252,14 @@ public void windowClosing(WindowEvent e) {
154252
});
155253

156254
// call onCancel() on ESCAPE
157-
contentPane.registerKeyboardAction(new ActionListener() {
255+
contentPanel.registerKeyboardAction(new ActionListener() {
158256
public void actionPerformed(ActionEvent e) {
159257
onCancel();
160258
}
161259
}, 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) {
165263
this.selectedDirectory = selectedDirectory;
166264
}
167265

@@ -226,4 +324,5 @@ private void onOK() {
226324
private void onCancel() {
227325
dispose();
228326
}
327+
229328
}

src/ServiceStackEclipse/src/net/servicestack/eclipse/popup/actions/AddReferenceAction.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,13 @@ public void setActivePart(IAction action, IWorkbenchPart targetPart) {
2929
* @see IActionDelegate#run(IAction)
3030
*/
3131
public void run(IAction action) {
32-
AddRef dialog = new AddRef();
32+
AddRefDialog dialog = new AddRefDialog();
3333
dialog.pack();
3434
dialog.setLocationRelativeTo(null);
3535
dialog.setSize(dialog.getPreferredSize());
3636
dialog.setResizable(true);
3737
dialog.setTitle("Add ServiceStack Reference");
38+
dialog.setVisible(true);
3839
}
3940

4041
/**

0 commit comments

Comments
 (0)