-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathView1.java
More file actions
134 lines (117 loc) · 4.4 KB
/
Copy pathView1.java
File metadata and controls
134 lines (117 loc) · 4.4 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
package Test;
import Controller.Controller;
import Frames.MyFrame;
import Frames.StartUpWindow;
import Utilz.BaseConstants;
import Utilz.Printer;
import Utilz.SqlProperties;
import net.lingala.zip4j.exception.ZipException;
import net.lingala.zip4j.model.FileHeader;
import net.lingala.zip4j.core.ZipFile;
import org.apache.commons.codec.DecoderException;
import org.apache.commons.codec.binary.Hex;
import javax.swing.*;
import javax.swing.event.*;
import java.awt.*;
import java.io.*;
import java.nio.charset.Charset;
import java.nio.file.*;
import java.nio.file.attribute.BasicFileAttributes;
import java.sql.SQLOutput;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.GregorianCalendar;
import java.util.HashMap;
import java.util.List;
import static Utilz.Printer.printRowToMonitor;
public class View1 {
private static HashMap<SqlProperties,Boolean> statusmap = new HashMap<>();
private static MyFrame frame;
private static int counter;
public static void main(String[] args){
JFrame frame0= new StartUpWindow("");
frame0.setVisible(true);
/* JFrame frame= new JFrame ("FRAME");
frame.setSize(new Dimension(600,400));
frame.setDefaultCloseOperation(frame.EXIT_ON_CLOSE);
frame.setLocationRelativeTo(null);
frame.setLayout(new GridBagLayout());
ProccessesPanelTab ppt = new ProccessesPanelTab();
frame.add(ppt,new GridBagConstraints(0,0,1,1,1,1,
GridBagConstraints.NORTH,GridBagConstraints.BOTH,
new Insets(1,1,1,1),0,0));
initWorkingPool(false);
// ppt.init(statusmap);
frame.setVisible(true);
frame.pack();*/
}
private void test1 (){
try {
readZipFile();
} catch (ZipException e) {
e.printStackTrace(); Printer.saveLogFile(e); ;
}
printMap();
initWorkingPool(false);
Printer.printLog("--------------------");
printMap();
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
frame = new MyFrame("Hello world of SWING!",statusmap);
frame.setSize(1500,500);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
});
/*ожидание генерации формы*/
try {
Thread.sleep (1000);
} catch (InterruptedException e) {
e.printStackTrace(); Printer.saveLogFile(e); ;
}
//frame.getProccessesPanel().updateProccessList();
}
private static void initWorkingPool(boolean isEncrypted){
Controller.init(isEncrypted);
}
private static void readFolderSql() throws IOException {
SimpleFileVisitor<Path> visitor = new SimpleFileVisitor<Path>(){
@Override
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
if (file.toString().endsWith(".rep")) {
SqlProperties prop = new SqlProperties(false);
prop.loadFromFile(file.toFile());
statusmap.put(prop,false);
}
return FileVisitResult.CONTINUE;
}
};
Files.walkFileTree(Paths.get(BaseConstants.getInstance().getPathSQL()), visitor );
}
private static void readZipFile () throws ZipException {
String zipFilePath = BaseConstants.getInstance().getZipFileSQL();
// zipFilePath="C:\\Java\\18.3.2018.zip";
ZipFile zipFile = new ZipFile(zipFilePath);
if (zipFile.isEncrypted()){
zipFile.setPassword(BaseConstants.getInstance().getZipPsw());
}
List<FileHeader> headers =zipFile.getFileHeaders();
for (FileHeader fh:headers) {
printRowToMonitor("Entry: " + fh.getFileName());
if (!fh.isDirectory() && fh.getFileName().endsWith(".rep")) {
SqlProperties prop = new SqlProperties(true);
prop.loadFromFile(new InputStreamReader(zipFile.getInputStream(fh), Charset.forName("UTF-8")),fh.getFileName());
statusmap.put(prop,false);
}
}
}
private static void printMap(){
for (HashMap.Entry<SqlProperties,Boolean> pair:
statusmap.entrySet()) {
printRowToMonitor( "-------------------->>>>");
printRowToMonitor( pair.getKey().getProperty("description"));
printRowToMonitor( pair.getKey().getProperty("sql"));
}
}
}