Skip to content

Commit d68090e

Browse files
committed
v6, 엔티티 업데이트. Simple View버튼으로 다수 엔티티 표시 가능.
1 parent b588570 commit d68090e

File tree

4 files changed

+253
-25
lines changed

4 files changed

+253
-25
lines changed

.idea/artifacts/SpringAutoCodeJPAEntity3_jar.xml

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main/java/org/example/v6/EntityEditorScreen.java

Lines changed: 118 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ public class EntityEditorScreen extends JFrame {
2020

2121
private final JPanel jpFlowLayoutBtnCenter;
2222

23-
private JTextField jtf, jtf2,jtf3,jtf4,jtf5,jtf6,jtf7,jtf8,jtf9;
23+
private JTextField nowEntityTextField, jtf2,jtf3,jtf4,jtf5,jtf6,jtf7,jtf8,jtf9;
2424
private JTextArea jta,jta2,jta3,jta4;
2525
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;
2727
private JPanel jpFlowLayoutBtns;
2828
//Entity Fields
2929
int entityColumnsCount;
@@ -46,7 +46,9 @@ public class EntityEditorScreen extends JFrame {
4646
String thymleafInitUrl;
4747
String rootPackageStr;
4848

49-
static UtilStaticV5 usv; // Save input values
49+
String nowEntityTextFieldStr;
50+
51+
static UtilStaticV6 usv; // Save input values
5052

5153
public EntityEditorScreen() {
5254

@@ -77,44 +79,44 @@ public EntityEditorScreen() {
7779
jpEast.add(jsp2);
7880

7981

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");
8385

84-
btn4 = new JButton("Simple View");
86+
simpleViewBtn = new JButton("Simple View");
8587
jl = new JLabel("Now Entity:");
86-
jtf = new JTextField(10);
88+
nowEntityTextField = new JTextField(10);
8789

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");
9193

9294
jpFlowLayoutBtnCenter = new JPanel();
9395
jpFlowLayoutBtnCenter.setLayout(new FlowLayout(FlowLayout.CENTER));
9496
//jpGridLayoutBtnCenter.add(Box.createHorizontalGlue());
9597
jpFlowLayoutBtnCenter.setSize(50,300);
96-
jpFlowLayoutBtnCenter.add(btn4);
98+
jpFlowLayoutBtnCenter.add(simpleViewBtn);
9799
jpFlowLayoutBtnCenter.add(Box.createRigidArea(new Dimension(0,20))); // add space ref, https://docs.oracle.com/javase/tutorial/uiswing/layout/box.html
98100

99101
jpFlowLayoutBtnCenter.add(Box.createRigidArea(new Dimension(0,10)));
100-
jpFlowLayoutBtnCenter.add(btn5);
102+
jpFlowLayoutBtnCenter.add(saveBtn);
101103
jpFlowLayoutBtnCenter.add(Box.createRigidArea(new Dimension(0,10)));
102-
jpFlowLayoutBtnCenter.add(btn6);
104+
jpFlowLayoutBtnCenter.add(saveFlatBtn);
103105
jpFlowLayoutBtnCenter.add(Box.createRigidArea(new Dimension(0,10)));
104-
jpFlowLayoutBtnCenter.add(btn7);
106+
jpFlowLayoutBtnCenter.add(loadBtn);
105107
jpFlowLayoutBtnCenter.add(Box.createRigidArea(new Dimension(0,10)));
106108
jpFlowLayoutBtnCenter.add(jl);
107-
jpFlowLayoutBtnCenter.add(jtf);
109+
jpFlowLayoutBtnCenter.add(nowEntityTextField);
108110

109111
jpCenter.setLayout(new BoxLayout(jpCenter, BoxLayout.Y_AXIS));
110112

111113
jpCenter.add(jpFlowLayoutBtnCenter);
112114

113115
jpFlowLayoutBtns = new JPanel();
114116
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);
118120
jpSouth.setLayout(new GridLayout(1,2));
119121
jpSouth.add(jpFlowLayoutBtns);
120122

@@ -133,37 +135,129 @@ public EntityEditorScreen() {
133135
setBounds(500, 270, 765, 500);
134136
setTitle("Entity Editor");
135137

136-
btn.addActionListener(new ActionListener(){
138+
longBtn.addActionListener(new ActionListener(){
137139
@Override
138140
public void actionPerformed(ActionEvent e) {
139141
jta.append("Long long\n");
140142
saveColumns();
141143
}});
142144

143-
btn2.addActionListener(new ActionListener(){
145+
stringBtn.addActionListener(new ActionListener(){
144146
@Override
145147
public void actionPerformed(ActionEvent e) {
146148
jta.append("String string\n");
147149
saveColumns();
148150

149151
}});
150152

151-
btn3.addActionListener(new ActionListener(){
153+
dateBtn.addActionListener(new ActionListener(){
152154
@Override
153155
public void actionPerformed(ActionEvent e) {
154156
jta.append("LocalDateTime date\n");
155157
saveColumns();
156158

157159
}});
158160

159-
btn4.addActionListener(new ActionListener(){
161+
simpleViewBtn.addActionListener(new ActionListener(){
160162
@Override
161163
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);
163171

164172
}});
165173
}
166174

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+
167261
private void saveColumns() {
168262
String line;
169263

src/main/java/org/example/v6/EntityScreen.java

Lines changed: 71 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public class EntityScreen extends JFrame {
4444
String thymleafInitUrl;
4545
String rootPackageStr;
4646

47-
static UtilStaticV5 usv; // Save input values
47+
static UtilStaticV6 usv; // Save input values
4848

4949
EntityScreen() {
5050
jp = new JPanel();
@@ -85,6 +85,76 @@ public void actionPerformed(ActionEvent e) {
8585
new EntityEditorScreen();
8686
}
8787
});
88+
}
89+
90+
public EntityScreen(UtilStaticV6 usv) {
91+
jp = new JPanel();
92+
jpEast = new JPanel();
93+
jpWest = new JPanel();
94+
jpSouth = new JPanel();
95+
jpNorth = new JPanel();
96+
jpCenter = new JPanel();
97+
98+
btn = new JButton("Entity");
99+
jtf = new JTextField(28);
100+
//jtf.setText("https://github.com/infott2t/SpringAutoCodeJPAEntity3");
101+
102+
jta = new JTextArea(5,5);
103+
jsp = new JScrollPane(jta);
104+
jsp.setPreferredSize(new Dimension(250,300));
105+
jta.setText("");
106+
jp.add(jsp);
107+
//jp.add(jpNorth,BorderLayout.NORTH);
108+
//jp.add(jpSouth,BorderLayout.SOUTH);
109+
this.usv = usv;
110+
setVisible(true);
111+
setResizable(true);
112+
add(jsp);
113+
setBounds(150,400,250,300);
114+
if(usv.nowEntityTextFieldStr.equals("")) {
115+
setTitle("[Entity]");
116+
}else{
117+
setTitle(usv.nowEntityTextFieldStr);
118+
}
119+
120+
121+
//jp.setLayout(new BorderLayout()); // BorderLayout. add East, West, North, South, Center ex )add([comp],BorderLayout.EAST)
122+
123+
124+
colNames = usv.colNames;
125+
colLongs = usv.colLongs;
126+
colDates = usv.colDates;
127+
colStrs = usv.colStrs;
128+
String result = "";
129+
if(colNames==null){
130+
result = "No Entity";
131+
}else{
132+
for (int i = 0; i < colNames.length; i++) {
133+
for(int j=0; j< colLongs.length; j++){
134+
if(colNames[i].equals(colLongs[j])){
135+
result += "Long "+colNames[i]+"\n";
136+
}
137+
}
138+
for(int j=0; j< colStrs.length; j++){
139+
if(colNames[i].equals(colStrs[j])){
140+
result += "String "+colNames[i]+"\n";
141+
}
142+
}
143+
for(int j=0; j< colDates.length; j++){
144+
if(colNames[i].equals(colDates[j])){
145+
result += "LocalDateTime "+colNames[i]+"\n";
146+
}
147+
}
148+
}
149+
}
150+
151+
jta.setText(result);
152+
153+
154+
155+
156+
157+
88158
}
89159

90160
public static void main(String[] args) {
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
package org.example.v6;
2+
3+
public class UtilStaticV6 {
4+
5+
6+
public static String domainStr; // entity name, small letter.
7+
public static String[] colStrs; // entity column, String array.
8+
public static String[] colLongs; // entity column, Long array.
9+
public static String[] colDates; // entity column, LocalDateTime array.
10+
11+
public static String[] colNames; // entity column, In orders.
12+
13+
public static String[] foreignCols; // entity column, In orders.
14+
15+
16+
public static String thymleafInitUrl; // /administer/instanceurl
17+
18+
public static String rootPackageStr;
19+
20+
public static String projectPath;
21+
22+
public static String nowEntityTextFieldStr;
23+
24+
public UtilStaticV6(String domainStr, String[] colStrs, String[] colLongs, String[] colDates, String[] colNames, String[] foreignColStrs, String thymleafInitUrl, String rootPackageStr, String projectPath) {
25+
this.domainStr = domainStr;
26+
this.colStrs = colStrs;
27+
this.colLongs = colLongs;
28+
this.colDates = colDates;
29+
this.colNames = colNames;
30+
this.foreignCols = foreignColStrs;
31+
this.thymleafInitUrl = thymleafInitUrl;
32+
this.rootPackageStr = rootPackageStr;
33+
this.projectPath = projectPath;
34+
35+
}
36+
37+
public UtilStaticV6(String domainStr, String[] colStrs, String[] colLongs, String[] colDates, String[] colNames, String[] foreignColStrs, String thymleafInitUrl, String rootPackageStr, String projectPath, String nowEntityTextFieldStr) {
38+
this.domainStr = domainStr;
39+
this.colStrs = colStrs;
40+
this.colLongs = colLongs;
41+
this.colDates = colDates;
42+
this.colNames = colNames;
43+
this.foreignCols = foreignColStrs;
44+
this.thymleafInitUrl = thymleafInitUrl;
45+
this.rootPackageStr = rootPackageStr;
46+
this.projectPath = projectPath;
47+
this.nowEntityTextFieldStr = nowEntityTextFieldStr;
48+
49+
}
50+
}

0 commit comments

Comments
 (0)