@@ -20,10 +20,10 @@ public class EntityEditorScreen extends JFrame {
20
20
21
21
private final JPanel jpFlowLayoutBtnCenter ;
22
22
23
- private JTextField jtf , jtf2 ,jtf3 ,jtf4 ,jtf5 ,jtf6 ,jtf7 ,jtf8 ,jtf9 ;
23
+ private JTextField nowEntityTextField , jtf2 ,jtf3 ,jtf4 ,jtf5 ,jtf6 ,jtf7 ,jtf8 ,jtf9 ;
24
24
private JTextArea jta ,jta2 ,jta3 ,jta4 ;
25
25
private JScrollPane jsp ,jsp2 ,jsp3 ,jsp4 ;
26
- private JButton btn , btn2 , btn3 , btn4 , btn5 , btn6 , btn7 ,btn8 ,btn9 ,btn10 ,btn11 ,btn12 ,btn13 ,btn14 ;
26
+ private JButton longBtn , stringBtn , dateBtn , simpleViewBtn , saveBtn , saveFlatBtn , loadBtn ,btn8 ,btn9 ,btn10 ,btn11 ,btn12 ,btn13 ,btn14 ;
27
27
private JPanel jpFlowLayoutBtns ;
28
28
//Entity Fields
29
29
int entityColumnsCount ;
@@ -46,7 +46,9 @@ public class EntityEditorScreen extends JFrame {
46
46
String thymleafInitUrl ;
47
47
String rootPackageStr ;
48
48
49
- static UtilStaticV5 usv ; // Save input values
49
+ String nowEntityTextFieldStr ;
50
+
51
+ static UtilStaticV6 usv ; // Save input values
50
52
51
53
public EntityEditorScreen () {
52
54
@@ -77,44 +79,44 @@ public EntityEditorScreen() {
77
79
jpEast .add (jsp2 );
78
80
79
81
80
- btn = new JButton ("Long" );
81
- btn2 = new JButton ("String" );
82
- btn3 = new JButton ("LocalDateTime" );
82
+ longBtn = new JButton ("Long" );
83
+ stringBtn = new JButton ("String" );
84
+ dateBtn = new JButton ("LocalDateTime" );
83
85
84
- btn4 = new JButton ("Simple View" );
86
+ simpleViewBtn = new JButton ("Simple View" );
85
87
jl = new JLabel ("Now Entity:" );
86
- jtf = new JTextField (10 );
88
+ nowEntityTextField = new JTextField (10 );
87
89
88
- btn5 = new JButton ("Save" );
89
- btn6 = new JButton ("Save Flat" );
90
- btn7 = new JButton ("Load" );
90
+ saveBtn = new JButton ("Save" );
91
+ saveFlatBtn = new JButton ("Save Flat" );
92
+ loadBtn = new JButton ("Load" );
91
93
92
94
jpFlowLayoutBtnCenter = new JPanel ();
93
95
jpFlowLayoutBtnCenter .setLayout (new FlowLayout (FlowLayout .CENTER ));
94
96
//jpGridLayoutBtnCenter.add(Box.createHorizontalGlue());
95
97
jpFlowLayoutBtnCenter .setSize (50 ,300 );
96
- jpFlowLayoutBtnCenter .add (btn4 );
98
+ jpFlowLayoutBtnCenter .add (simpleViewBtn );
97
99
jpFlowLayoutBtnCenter .add (Box .createRigidArea (new Dimension (0 ,20 ))); // add space ref, https://docs.oracle.com/javase/tutorial/uiswing/layout/box.html
98
100
99
101
jpFlowLayoutBtnCenter .add (Box .createRigidArea (new Dimension (0 ,10 )));
100
- jpFlowLayoutBtnCenter .add (btn5 );
102
+ jpFlowLayoutBtnCenter .add (saveBtn );
101
103
jpFlowLayoutBtnCenter .add (Box .createRigidArea (new Dimension (0 ,10 )));
102
- jpFlowLayoutBtnCenter .add (btn6 );
104
+ jpFlowLayoutBtnCenter .add (saveFlatBtn );
103
105
jpFlowLayoutBtnCenter .add (Box .createRigidArea (new Dimension (0 ,10 )));
104
- jpFlowLayoutBtnCenter .add (btn7 );
106
+ jpFlowLayoutBtnCenter .add (loadBtn );
105
107
jpFlowLayoutBtnCenter .add (Box .createRigidArea (new Dimension (0 ,10 )));
106
108
jpFlowLayoutBtnCenter .add (jl );
107
- jpFlowLayoutBtnCenter .add (jtf );
109
+ jpFlowLayoutBtnCenter .add (nowEntityTextField );
108
110
109
111
jpCenter .setLayout (new BoxLayout (jpCenter , BoxLayout .Y_AXIS ));
110
112
111
113
jpCenter .add (jpFlowLayoutBtnCenter );
112
114
113
115
jpFlowLayoutBtns = new JPanel ();
114
116
jpFlowLayoutBtns .setLayout (new FlowLayout (FlowLayout .LEFT ));
115
- jpFlowLayoutBtns .add (btn );
116
- jpFlowLayoutBtns .add (btn2 );
117
- jpFlowLayoutBtns .add (btn3 );
117
+ jpFlowLayoutBtns .add (longBtn );
118
+ jpFlowLayoutBtns .add (stringBtn );
119
+ jpFlowLayoutBtns .add (dateBtn );
118
120
jpSouth .setLayout (new GridLayout (1 ,2 ));
119
121
jpSouth .add (jpFlowLayoutBtns );
120
122
@@ -133,37 +135,129 @@ public EntityEditorScreen() {
133
135
setBounds (500 , 270 , 765 , 500 );
134
136
setTitle ("Entity Editor" );
135
137
136
- btn .addActionListener (new ActionListener (){
138
+ longBtn .addActionListener (new ActionListener (){
137
139
@ Override
138
140
public void actionPerformed (ActionEvent e ) {
139
141
jta .append ("Long long\n " );
140
142
saveColumns ();
141
143
}});
142
144
143
- btn2 .addActionListener (new ActionListener (){
145
+ stringBtn .addActionListener (new ActionListener (){
144
146
@ Override
145
147
public void actionPerformed (ActionEvent e ) {
146
148
jta .append ("String string\n " );
147
149
saveColumns ();
148
150
149
151
}});
150
152
151
- btn3 .addActionListener (new ActionListener (){
153
+ dateBtn .addActionListener (new ActionListener (){
152
154
@ Override
153
155
public void actionPerformed (ActionEvent e ) {
154
156
jta .append ("LocalDateTime date\n " );
155
157
saveColumns ();
156
158
157
159
}});
158
160
159
- btn4 .addActionListener (new ActionListener (){
161
+ simpleViewBtn .addActionListener (new ActionListener (){
160
162
@ Override
161
163
public void actionPerformed (ActionEvent e ) {
162
- new EntityScreen ();
164
+ String [] foreignColStrs = null ;
165
+ String projectPath = "" ;
166
+ nowEntityTextFieldStr = nowEntityTextField .getText ();
167
+ usv = new UtilStaticV6 (domainStr , colStrs , colLongs , colDates ,colNames , foreignColStrs , thymleafInitUrl , rootPackageStr , projectPath , nowEntityTextFieldStr );
168
+
169
+
170
+ new EntityScreen (usv );
163
171
164
172
}});
165
173
}
166
174
175
+ private void entityTextCalc (){
176
+ String line ;
177
+ BufferedReader reader = new BufferedReader (new StringReader (jta .getText ()));
178
+ columnStrings ="" ;
179
+ columnLongs ="" ;
180
+ columnDates ="" ;
181
+ columnNames ="" ;
182
+ try {
183
+ while ((line = reader .readLine ())!=null ){
184
+ System .out .println (line );
185
+ if (line .indexOf ("Long" )>=0 ) {
186
+ // System.out.println(line.indexOf("Long") );
187
+ String longStr = line .substring (line .indexOf ("Long" ) + 5 );
188
+ longStr = longStr .replace (";" , "" );
189
+ columnLongs = columnLongs + longStr + "," ;
190
+ columnNames = columnNames + longStr + "," ;
191
+ }
192
+ if (line .indexOf ("String" )>=0 ) {
193
+ // System.out.println(line.indexOf("Long") );
194
+ String strings = line .substring (line .indexOf ("String" ) + 7 );
195
+ strings = strings .replace (";" , "" );
196
+ columnStrings = columnStrings + strings + "," ;
197
+ columnNames = columnNames + strings + "," ;
198
+ }
199
+
200
+ if (line .indexOf ("LocalDateTime" )>=0 ){
201
+ String dates = line .substring (line .indexOf ("LocalDateTime" ) + 14 );
202
+ dates = dates .replace (";" , "" );
203
+ columnDates = columnDates + dates + "," ;
204
+ columnNames = columnNames + dates + "," ;
205
+ }
206
+
207
+ }
208
+ }catch (Exception ex ){
209
+ ex .printStackTrace ();
210
+ }
211
+
212
+ if (columnLongs !=null && columnLongs .length ()>0 ) {
213
+ columnLongs = columnLongs .substring (0 , columnLongs .length () - 1 );
214
+ }
215
+
216
+ if (columnStrings !=null && columnStrings .length ()>0 ) {
217
+ columnStrings = columnStrings .substring (0 , columnStrings .length () - 1 );
218
+ }
219
+
220
+ if (columnDates !=null && columnDates .length ()>0 ) {
221
+ columnDates = columnDates .substring (0 , columnDates .length () - 1 );
222
+ }
223
+ //columnDates = columnDates.substring(0,columnDates.length()-1);
224
+
225
+ columnNames = columnNames .substring (0 ,columnNames .length ()-1 );
226
+
227
+ colStrs = columnStrings .split ("," );
228
+ colLongs = columnLongs .split ("," );
229
+ colDates = columnDates .split ("," );
230
+ colNames = columnNames .split ("," );
231
+
232
+ System .out .println (colStrs .toString ());
233
+ System .out .println (colLongs .toString ());
234
+ System .out .println (colNames .toString ());
235
+
236
+ for (int i =0 ; i < colStrs .length ;i ++ ){
237
+ System .out .println (colStrs [i ]);
238
+ }
239
+ for (int i = 0 ; i < colNames .length ; i ++) {
240
+ System .out .println (colNames [i ]);
241
+ }
242
+ //thymleafInitUrl = jtf2.getText();
243
+ String foreignColStrs [] = null ;
244
+
245
+ try {
246
+ if (jta2 .getText ()!=null && jta2 .getText ().length ()>0 ) {
247
+ foreignColStr = jta2 .getText ();
248
+ foreignColStrs = foreignColStr .split ("," );
249
+
250
+ for (int i =0 ; i < foreignColStrs .length ;i ++ ){
251
+ foreignColStrs [i ] = foreignColStrs [i ].trim ();
252
+ }
253
+ }
254
+ }catch (Exception e1 ){
255
+ e1 .printStackTrace ();
256
+ }
257
+
258
+ thymleafInitUrl = jtf2 .getText ();
259
+ }
260
+
167
261
private void saveColumns () {
168
262
String line ;
169
263
0 commit comments