-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFXInterface.java
More file actions
188 lines (146 loc) · 6.67 KB
/
FXInterface.java
File metadata and controls
188 lines (146 loc) · 6.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
import javafx.application.*;
import javafx.geometry.*;
import javafx.scene.*;
import javafx.event.*;
import javafx.scene.control.*;
import javafx.scene.layout.*;
import javafx.stage.*;
import javafx.scene.paint.*;
import javax.swing.*;
import javafx.*;
import javafx.scene.image.*;
import java.util.*;
import java.io.*;
public class FXInterface extends Application
{
public void start(Stage stg) throws Exception{
FileChooser fileChooser = new FileChooser();
File file = fileChooser.showOpenDialog(stg);
Classifier.readFile(file);
ArrayList<Classifier.Statement> stmts = Classifier.stmts;
ArrayList<Classifier.Statement> mStmts = new ArrayList<Classifier.Statement>();
VBox screen = new VBox();
{
HBox line = new HBox();
for(int i = 0; i < stmts.size();i++){
String s = stmts.get(i).stmt;
for(;s.indexOf('\n'+"") != -1;){
screen.getChildren().add(line);
line = new HBox();
screen.getChildren().add(new Label(s.substring(0,s.indexOf('\n'+""))));
s = s.substring(s.indexOf('\n'+"")+1);
}
line.getChildren().add(new Label(s+" "));
s = stmts.get(i).stmt;
String toCheck = Classifier.removeComments(s).replaceAll('\n'+"","");
//System.out.println(s);
if(Classifier.isVar(toCheck)){
TextField txt = new TextField();
TitledPane tp = new TitledPane("",txt);
tp.setExpanded(false);
stmts.get(i).var = txt;
line.getChildren().add(tp);
mStmts.add(stmts.get(i));
}
else if(Classifier.isMethod(toCheck)){
String[] param = Classifier.getParams(s.replaceAll('\n'+"",""));
VBox params = new VBox();
HBox subLine;
TextField []txts;
subLine = new HBox();
subLine.getChildren().add(new Label("Function: "));
stmts.get(i).methDef = new TextField();
subLine.getChildren().add(stmts.get(i).methDef);
params.getChildren().add(subLine);
if(param != null){
txts = new TextField[param.length];
params.getChildren().add(new Label("------------------"));
for(int k = 0;param != null && k < param.length;k++){
subLine = new HBox();
subLine.getChildren().add(new Label(param[k]));
txts[k] = new TextField();
subLine.getChildren().add(txts[k]);
params.getChildren().add(subLine);
}
stmts.get(i).txts = txts;
}
params.getChildren().add(new Label("------------------"));
subLine = new HBox();
subLine.getChildren().add(new Label("Returns: "));
stmts.get(i).ret = new TextField();
subLine.getChildren().add(stmts.get(i).ret);
params.getChildren().add(subLine);
TitledPane tp = new TitledPane("Method",params);
tp.setExpanded(false);
line.getChildren().add(tp);
mStmts.add(stmts.get(i));
}
else if(Classifier.isClass(toCheck)){
VBox params = new VBox();
HBox subLine;
TextField []txts;
subLine = new HBox();
subLine.getChildren().add(new Label("Function: "));
stmts.get(i).classDef = new TextField();
subLine.getChildren().add(stmts.get(i).classDef);
params.getChildren().add(subLine);
TitledPane tp = new TitledPane("Class",params);
tp.setExpanded(false);
line.getChildren().add(tp);
mStmts.add(stmts.get(i));
}
else {
mStmts.add(stmts.get(i));
}
}
}
Button save = new Button("SAVE");
save.setMinSize(1000,30);
save.setOnAction(new EventHandler<ActionEvent>(){
public void handle(ActionEvent e){
try{
Classifier.update(Classifier.copy(mStmts));
Classifier.writeFile(Classifier.updated,new File("Doc-"+ file.getName()));
}catch(Exception ex){
System.out.println("Exception at Handle");
}
}
});
ScrollPane scr= new ScrollPane();
scr.setContent(screen);
VBox finalScr = new VBox();
finalScr.getChildren().add(scr);
finalScr.getChildren().add(save);
Scene scene = new Scene(finalScr,600,600);
stg.setScene(scene);
stg.show();
}
public static void main(String[] args){
launch(args);
Classifier.printStmts(Classifier.updated);
System.exit(0);
}
/* // Backup
*
* for(int i = 0; i < stmts.size();i++){
String s = stmts.get(i).stmt;
for(;s.indexOf('\n'+"") != -1;){
screen.getChildren().add(line);
line = new HBox();
screen.getChildren().add(new Label(s.substring(0,s.indexOf('\n'+""))));
s = s.substring(s.indexOf('\n'+"")+1);
}
line.getChildren().add(new Label(s+" "));
s = stmts.get(i).stmt;
if(Classifier.isVar(s.replaceAll('\n'+"",""))){
TextField txt = new TextField();
//txt.setOnAction
stmts.get(i).txt = txt;
line.getChildren().add(txt);
}
else if(Classifier.isMethod(s.replaceAll("~",""))){
}
}
*
*/
}