ConfigModel.java
4.9 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
189
190
191
192
193
194
195
196
197
package com.zhazhapan.util.visual.model;
import cn.hutool.core.util.ClipboardUtil;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSONArray;
import com.zhazhapan.modules.constant.ValueConsts;
import com.zhazhapan.util.Checker;
import javafx.util.Pair;
import java.util.*;
/**
* 配置参数
*
* @author pantao
* @since 2018/4/2
*/
public class ConfigModel {
private static List<Pair<Date, String>> clipboardHistory = new LinkedList<>();
private static double width = 1000;
private static double height = 700;
private static JSONArray supportTabs;
private static String fileFilterRegex = "^[^.].*$";
private static boolean fileFilterTip = true;
private static int clipboardSize = 20;
private static JSONArray tabs = new JSONArray();
private static boolean fullscreen = false;
private static boolean autoWrap = false;
private static String host = "127.0.0.1:3306";
private static String database = "efo";
private static String condition = "useUnicode=true&characterEncoding=utf-8&useSSL=true";
private static String username = "zhazhapan";
private static String password = "zhazhapan";
private static List<WaverModel> waver = new ArrayList<>();
static {
tabs.add("JsonParser");
tabs.add("FileManager");
tabs.add("RandomGenerator");
tabs.add("ClipboardHistory");
tabs.add("QrCodeGenerator");
tabs.add("CharsetConverter");
tabs.add("NetworkTool");
tabs.add("QiniuTool");
tabs.add("WaveViewer");
supportTabs = ObjectUtil.cloneByStream(tabs);
}
public static String getHost() {
return host;
}
public static void setHost(String host) {
ConfigModel.host = host;
}
public static String getDatabase() {
return database;
}
public static void setDatabase(String database) {
ConfigModel.database = database;
}
public static String getCondition() {
return condition;
}
public static void setCondition(String condition) {
ConfigModel.condition = condition;
}
public static String getUsername() {
return username;
}
public static void setUsername(String username) {
ConfigModel.username = username;
}
public static String getPassword() {
return password;
}
public static void setPassword(String password) {
ConfigModel.password = password;
}
public static List<WaverModel> getWaver() {
return waver;
}
public static JSONArray getSupportTabs() {
return supportTabs;
}
public static boolean isAutoWrap() {
return autoWrap;
}
public static void setAutoWrap(boolean autoWrap) {
ConfigModel.autoWrap = autoWrap;
}
public static boolean isFullscreen() {
return fullscreen;
}
public static void setFullscreen(boolean fullscreen) {
ConfigModel.fullscreen = fullscreen;
}
public static int getClipboardHistorySize() {
return clipboardHistory.size();
}
public static void appendClipboardHistory(Date date, String content) {
if (getClipboardHistorySize() < clipboardSize) {
clipboardHistory.add(new Pair<>(date, Checker.checkNull(content)));
} else {
clipboardHistory.remove(ValueConsts.ZERO_INT);
appendClipboardHistory(date, content);
}
}
public static Pair<Date, String> getLastClipboardHistoryItem() {
Optional<Pair<Date, String>> last = Optional.ofNullable(getClipboardHistoryItem(getClipboardHistorySize() - 1));
return last.orElse(new Pair<>(new Date(), Checker.checkNull(ClipboardUtil.getStr())));
}
public static Pair<Date, String> getClipboardHistoryItem(int index) {
if (index >= 0 && index < clipboardSize) {
return clipboardHistory.get(index);
}
return null;
}
public static void setClipboardSize(int clipboardSize) {
ConfigModel.clipboardSize = clipboardSize;
}
public static double getWidth() {
return width;
}
public static void setWidth(double width) {
ConfigModel.width = width;
}
public static double getHeight() {
return height;
}
public static void setHeight(double height) {
ConfigModel.height = height;
}
public static JSONArray getTabs() {
return tabs;
}
public static void setTabs(JSONArray tabs) {
ConfigModel.tabs = tabs;
}
public static String getFileFilterRegex() {
return fileFilterRegex;
}
public static void setFileFilterRegex(String fileFilterRegex) {
ConfigModel.fileFilterRegex = fileFilterRegex;
}
public static boolean isFileFilterTip() {
return fileFilterTip;
}
public static void setFileFilterTip(boolean fileFilterTip) {
ConfigModel.fileFilterTip = fileFilterTip;
}
}