1
1
package com .thedeanda .ajaxproxy .ui .rest ;
2
2
3
- import java .awt .BorderLayout ;
3
+ import java .awt .Color ;
4
4
import java .awt .Dimension ;
5
5
import java .awt .event .ActionEvent ;
6
6
import java .awt .event .ActionListener ;
18
18
import javax .swing .JTextArea ;
19
19
import javax .swing .JTextField ;
20
20
import javax .swing .SpringLayout ;
21
+ import javax .swing .UIDefaults ;
21
22
22
23
import org .apache .commons .io .IOUtils ;
23
24
import org .apache .commons .lang3 .StringUtils ;
28
29
import com .thedeanda .ajaxproxy .http .HttpClient .RequestMethod ;
29
30
import com .thedeanda .ajaxproxy .http .RequestListener ;
30
31
import com .thedeanda .ajaxproxy .ui .SwingUtils ;
32
+ import com .thedeanda .ajaxproxy .ui .border .BottomBorder ;
31
33
import com .thedeanda .ajaxproxy .ui .viewer .RequestViewer ;
32
34
33
35
public class RestClientPanel extends JPanel implements ActionListener {
@@ -47,10 +49,15 @@ public class RestClientPanel extends JPanel implements ActionListener {
47
49
48
50
public RestClientPanel () {
49
51
httpClient = new HttpClient ();
52
+ SpringLayout layout = new SpringLayout ();
53
+ setLayout (layout );
54
+
55
+ JPanel urlPanel = initUrlPanel ();
56
+ urlPanel .setBorder (new BottomBorder ());
57
+ add (urlPanel );
50
58
51
59
JSplitPane mainSplit = new JSplitPane (JSplitPane .HORIZONTAL_SPLIT );
52
60
SwingUtils .flattenSplitPane (mainSplit );
53
- setLayout (new BorderLayout ());
54
61
add (mainSplit );
55
62
56
63
JPanel leftPanel = initLeftPanel ();
@@ -60,68 +67,96 @@ public RestClientPanel() {
60
67
mainSplit .setRightComponent (outputPanel );
61
68
mainSplit .setDividerLocation (400 );
62
69
70
+ layout .putConstraint (SpringLayout .NORTH , urlPanel , 0 ,
71
+ SpringLayout .NORTH , this );
72
+ layout .putConstraint (SpringLayout .EAST , urlPanel , 0 , SpringLayout .EAST ,
73
+ this );
74
+ layout .putConstraint (SpringLayout .WEST , urlPanel , 0 , SpringLayout .WEST ,
75
+ this );
76
+ layout .putConstraint (SpringLayout .SOUTH , urlPanel , 50 ,
77
+ SpringLayout .NORTH , this );
78
+
79
+ layout .putConstraint (SpringLayout .EAST , mainSplit , 0 ,
80
+ SpringLayout .EAST , this );
81
+ layout .putConstraint (SpringLayout .WEST , mainSplit , 0 ,
82
+ SpringLayout .WEST , this );
83
+ layout .putConstraint (SpringLayout .SOUTH , mainSplit , 0 ,
84
+ SpringLayout .SOUTH , this );
85
+ layout .putConstraint (SpringLayout .NORTH , mainSplit , 0 ,
86
+ SpringLayout .SOUTH , urlPanel );
63
87
}
64
88
65
- public void setDefaultButton () {
66
- getRootPane ().setDefaultButton (submitButton );
67
- }
68
-
69
- private JPanel initLeftPanel () {
89
+ private JPanel initUrlPanel () {
70
90
JPanel panel = new JPanel ();
71
91
SpringLayout layout = new SpringLayout ();
72
92
panel .setLayout (layout );
73
- panel .setMinimumSize (new Dimension (200 , 350 ));
93
+ panel .setMinimumSize (new Dimension (200 , 50 ));
74
94
75
- JLabel urlLabel = SwingUtils .newJLabel ("Request URL" );
95
+ JLabel urlLabel = SwingUtils .newJLabel ("URL" );
76
96
urlField = SwingUtils .newJTextField ();
97
+ panel .add (urlLabel );
77
98
78
- JComboBox < String > methods = createMethodDropDown ();
79
- panel .add (methods );
99
+ urlField = SwingUtils . newJTextField ();
100
+ panel .add (urlField );
80
101
81
102
submitButton = new JButton ("Submit" );
82
103
submitButton .addActionListener (this );
83
104
panel .add (submitButton );
84
105
85
- panel .add (urlLabel );
86
- panel .add (urlField );
87
-
88
- JSplitPane split = initLeftSplit ();
89
- panel .add (split );
90
-
91
- // methods
92
- layout .putConstraint (SpringLayout .EAST , methods , -10 ,
93
- SpringLayout .EAST , panel );
94
- layout .putConstraint (SpringLayout .NORTH , methods , 20 ,
95
- SpringLayout .NORTH , panel );
106
+ JComboBox <String > methods = createMethodDropDown ();
107
+ methodCombo = methods ;
108
+ panel .add (methods );
96
109
97
110
// url label
98
111
layout .putConstraint (SpringLayout .WEST , urlLabel , 10 ,
99
112
SpringLayout .WEST , panel );
100
113
layout .putConstraint (SpringLayout .VERTICAL_CENTER , urlLabel , 0 ,
101
114
SpringLayout .VERTICAL_CENTER , methods );
102
115
103
- // url field
104
- layout .putConstraint (SpringLayout .NORTH , urlField , 10 ,
105
- SpringLayout .SOUTH , urlLabel );
106
- layout .putConstraint (SpringLayout .EAST , urlField , -10 ,
116
+ // submit button
117
+ layout .putConstraint (SpringLayout .EAST , submitButton , -10 ,
107
118
SpringLayout .EAST , panel );
119
+ layout .putConstraint (SpringLayout .VERTICAL_CENTER , submitButton , 0 ,
120
+ SpringLayout .VERTICAL_CENTER , panel );
121
+
122
+ // method list
123
+ layout .putConstraint (SpringLayout .EAST , methods , -10 ,
124
+ SpringLayout .WEST , submitButton );
125
+ layout .putConstraint (SpringLayout .VERTICAL_CENTER , methods , 0 ,
126
+ SpringLayout .VERTICAL_CENTER , panel );
127
+
128
+ // input field
108
129
layout .putConstraint (SpringLayout .WEST , urlField , 10 ,
109
- SpringLayout .WEST , panel );
130
+ SpringLayout .EAST , urlLabel );
131
+ layout .putConstraint (SpringLayout .VERTICAL_CENTER , urlField , 0 ,
132
+ SpringLayout .VERTICAL_CENTER , methods );
133
+ layout .putConstraint (SpringLayout .EAST , urlField , -10 ,
134
+ SpringLayout .WEST , methods );
135
+
136
+ return panel ;
137
+ }
138
+
139
+ public void setDefaultButton () {
140
+ getRootPane ().setDefaultButton (submitButton );
141
+ }
142
+
143
+ private JPanel initLeftPanel () {
144
+ JPanel panel = new JPanel ();
145
+ SpringLayout layout = new SpringLayout ();
146
+ panel .setLayout (layout );
147
+ panel .setMinimumSize (new Dimension (200 , 350 ));
148
+
149
+ JSplitPane split = initLeftSplit ();
150
+ panel .add (split );
110
151
111
152
// split
112
- layout .putConstraint (SpringLayout .NORTH , split , 10 , SpringLayout .SOUTH ,
113
- urlField );
153
+ layout .putConstraint (SpringLayout .NORTH , split , 24 , SpringLayout .NORTH ,
154
+ panel );
114
155
layout .putConstraint (SpringLayout .EAST , split , 0 , SpringLayout .EAST ,
115
156
panel );
116
157
layout .putConstraint (SpringLayout .WEST , split , 0 , SpringLayout .WEST ,
117
158
panel );
118
159
layout .putConstraint (SpringLayout .SOUTH , split , -10 ,
119
- SpringLayout .NORTH , submitButton );
120
-
121
- // submit button
122
- layout .putConstraint (SpringLayout .EAST , submitButton , -10 ,
123
- SpringLayout .EAST , panel );
124
- layout .putConstraint (SpringLayout .SOUTH , submitButton , -10 ,
125
160
SpringLayout .SOUTH , panel );
126
161
127
162
return panel ;
@@ -176,7 +211,7 @@ private JPanel initHeadersPanel() {
176
211
SpringLayout layout = new SpringLayout ();
177
212
panel .setLayout (layout );
178
213
179
- JLabel headersLabel = SwingUtils .newJLabel ("Headers" );
214
+ JLabel headersLabel = SwingUtils .newJLabel ("Request Headers" );
180
215
headersField = SwingUtils .newJTextArea ();
181
216
182
217
JScrollPane headersScroll = new JScrollPane (headersField );
@@ -230,7 +265,7 @@ private JComboBox<String> createMethodDropDown() {
230
265
}
231
266
String [] stmp = new String [tmp .size ()];
232
267
tmp .toArray (stmp );
233
- methodCombo = new JComboBox <String >(stmp );
268
+ JComboBox methodCombo = new JComboBox <String >(stmp );
234
269
methodCombo .addActionListener (this );
235
270
return methodCombo ;
236
271
}
0 commit comments