15
15
16
16
import javax .swing .*;
17
17
import java .awt .*;
18
+ import java .awt .event .ActionEvent ;
19
+ import java .awt .event .ActionListener ;
18
20
19
21
public class FileChooseDialog extends DialogWrapper {
20
22
private OnClickListener onOkClickListener ;
21
23
private String title ;
24
+ private boolean rpc ;
22
25
private boolean showProtoPath ;
23
26
24
27
public interface OnClickListener {
25
- void onOk (String goctlHome , String output , String protoPath , String style );
28
+ void onOk (String goctlHome , String output , String protoPath , String style , boolean group , boolean client );
26
29
27
30
void onJump ();
28
31
}
29
32
30
33
private TextFieldWithBrowseButton textFieldWithBrowseButton ;
31
34
private TextFieldWithBrowseButton protoPathBrowseButton ;
32
35
private TextFieldWithBrowseButton templateBrowseButton ;
36
+ private Checkbox groupCheckBox , clientBox ;
33
37
private JTextField gozeroTextField ;
34
38
private final String stylePropertyKey = "cn.xiaoheiban.go-zero" + "_style" ;
35
39
36
- public FileChooseDialog (String title , String cancelText , boolean showProtoPath ) {
40
+ public FileChooseDialog (String title , String cancelText , boolean showProtoPath , boolean rpc ) {
37
41
super (true );
38
42
this .title = title ;
39
43
this .showProtoPath = showProtoPath ;
44
+ this .rpc = rpc ;
40
45
init ();
41
46
setTitle (title );
42
47
setOKButtonText ("Confirm" );
@@ -61,7 +66,7 @@ public void setDefaultPath(String path) {
61
66
@ Override
62
67
protected JComponent createCenterPanel () {
63
68
final JPanel contentPane = new JPanel ();
64
- contentPane .setLayout (new GridLayoutManager (4 , 2 , new Insets (10 , 10 , 10 , 10 ), -1 , -1 ));
69
+ contentPane .setLayout (new GridLayoutManager (6 , 2 , new Insets (10 , 10 , 10 , 10 ), -1 , -1 ));
65
70
66
71
Dimension labelDimension = new Dimension (100 , -1 );
67
72
Dimension textFieldDimension = new Dimension (500 , -1 );
@@ -113,6 +118,29 @@ protected JComponent createCenterPanel() {
113
118
contentPane .add (stylePanel , new GridConstraints (0 , 0 , 1 , 2 , 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 ));
114
119
contentPane .add (outputPanel , 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 ));
115
120
contentPane .add (templatePanel , new GridConstraints (2 , 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 ));
121
+ if (rpc ) {
122
+ final JPanel groupPanel = new JPanel ();
123
+ groupPanel .setLayout (new GridLayoutManager (1 , 2 , new Insets (0 , 0 , 0 , 0 ), -1 , -1 ));
124
+ final JLabel groupLabel = new JLabel ();
125
+ groupLabel .setText ("Group" );
126
+ groupPanel .add (groupLabel , new GridConstraints (0 , 0 , 1 , 1 , GridConstraints .ANCHOR_WEST , GridConstraints .FILL_NONE , GridConstraints .SIZEPOLICY_FIXED , GridConstraints .SIZEPOLICY_FIXED , null , labelDimension , null , 0 , false ));
127
+
128
+ groupCheckBox = new Checkbox ();
129
+ groupPanel .add (groupCheckBox , new GridConstraints (0 , 1 , 1 , 1 , GridConstraints .ANCHOR_WEST , GridConstraints .FILL_HORIZONTAL , GridConstraints .SIZEPOLICY_WANT_GROW , GridConstraints .SIZEPOLICY_FIXED , null , textFieldDimension , null , 0 , false ));
130
+ contentPane .add (groupPanel , new GridConstraints (3 , 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 ));
131
+
132
+ final JPanel clientPanel = new JPanel ();
133
+ clientPanel .setLayout (new GridLayoutManager (1 , 2 , new Insets (0 , 0 , 0 , 0 ), -1 , -1 ));
134
+ final JLabel clientLabel = new JLabel ();
135
+ clientLabel .setText ("Client" );
136
+ clientPanel .add (clientLabel , new GridConstraints (0 , 0 , 1 , 1 , GridConstraints .ANCHOR_WEST , GridConstraints .FILL_NONE , GridConstraints .SIZEPOLICY_FIXED , GridConstraints .SIZEPOLICY_FIXED , null , labelDimension , null , 0 , false ));
137
+
138
+ clientBox = new Checkbox ();
139
+ clientBox .setState (true );
140
+ clientPanel .add (clientBox , new GridConstraints (0 , 1 , 1 , 1 , GridConstraints .ANCHOR_WEST , GridConstraints .FILL_HORIZONTAL , GridConstraints .SIZEPOLICY_WANT_GROW , GridConstraints .SIZEPOLICY_FIXED , null , textFieldDimension , null , 0 , false ));
141
+ contentPane .add (clientPanel , new GridConstraints (4 , 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 ));
142
+
143
+ }
116
144
if (showProtoPath ) {
117
145
final JPanel protoPathPanel = new JPanel ();
118
146
protoPathPanel .setLayout (new GridLayoutManager (1 , 2 , new Insets (0 , 0 , 0 , 0 ), -1 , -1 ));
@@ -126,7 +154,7 @@ protected JComponent createCenterPanel() {
126
154
TextBrowseFolderListener protoPathListener = new TextBrowseFolderListener (protoPathChooserDescriptor );
127
155
protoPathBrowseButton .addBrowseFolderListener (protoPathListener );
128
156
protoPathPanel .add (protoPathBrowseButton , new GridConstraints (0 , 1 , 1 , 1 , GridConstraints .ANCHOR_WEST , GridConstraints .FILL_HORIZONTAL , GridConstraints .SIZEPOLICY_WANT_GROW , GridConstraints .SIZEPOLICY_FIXED , null , textFieldDimension , null , 0 , false ));
129
- contentPane .add (protoPathPanel , new GridConstraints (3 , 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 ));
157
+ contentPane .add (protoPathPanel , new GridConstraints (5 , 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 ));
130
158
}
131
159
return contentPane ;
132
160
}
@@ -136,7 +164,8 @@ protected JComponent createCenterPanel() {
136
164
protected ValidationInfo doValidate () {
137
165
String goctlHome = templateBrowseButton .getText ();
138
166
String outputBrowserPath = textFieldWithBrowseButton .getText ();
139
-
167
+ boolean groupCheck = false ;
168
+ boolean clientCheck = true ;
140
169
// store style string
141
170
String style = gozeroTextField .getText ();
142
171
PropertiesComponent .getInstance ().setValue (stylePropertyKey , style );
@@ -154,8 +183,14 @@ protected ValidationInfo doValidate() {
154
183
protoPath = protoFile .getPath ();
155
184
}
156
185
}
186
+ if (groupCheckBox != null ) {
187
+ groupCheck = groupCheckBox .getState ();
188
+ }
189
+ if (clientBox != null ) {
190
+ clientCheck = clientBox .getState ();
191
+ }
157
192
if (this .onOkClickListener != null ) {
158
- this .onOkClickListener .onOk (goctlHome , output , protoPath , style );
193
+ this .onOkClickListener .onOk (goctlHome , output , protoPath , style , groupCheck , clientCheck );
159
194
}
160
195
return null ;
161
196
}
0 commit comments