Skip to content

Commit feb0c1a

Browse files
committed
v1.7.1发布
1 parent 2c4f071 commit feb0c1a

11 files changed

+115
-52
lines changed

README.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ double shift,连按两下shift,输入leeks,找到toolWindow,打开以后
3636
- v1.6.2
3737
适配IDEA 2020.3
3838
- v1.6.3
39-
修复颜色错乱问题
39+
修复颜色错乱问题 , 日志调整 merge from [qwn3213](https://github.com/qwn3213)
40+
- v1.7.1
41+
增加日志开关 ,设置界面样式调整 merge from [dengerYang](https://github.com/dengerYang) ,增加新浪股票接口备选 merge from [JulianXG](https://github.com/JulianXG)
42+
4043

4144

build.gradle

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ plugins {
44
}
55

66
group 'com.huage2580'
7-
version '1.6.4'
7+
version '1.7.1'
88

99
sourceCompatibility = 1.8
1010

@@ -32,6 +32,7 @@ patchPluginXml {
3232
v1.4 增加了隐蔽模式(全拼音和无色涨跌幅
3333
v1.5 增加了股票界面的排序~,可按净值和涨跌幅等列排序
3434
v1.6 样式修改,增加精确净值(当日,上一交易日
35+
v1.7 设置界面样式调整,增加新浪股票接口备选
3536
"""
3637
sinceBuild '173.*'
3738
untilBuild '203.*'

gradle/wrapper/gradle-wrapper.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#Wed Jul 15 10:09:28 CST 2020
2-
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip
2+
distributionUrl=https\://services.gradle.org/distributions/gradle-5.2.1-all.zip
33
distributionBase=GRADLE_USER_HOME
44
distributionPath=wrapper/dists
55
zipStorePath=wrapper/dists
145 KB
Binary file not shown.

src/main/java/SettingsWindow.form

+41-16
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@
66
<rowspec value="center:max(d;4px):noGrow"/>
77
<rowspec value="top:4dlu:noGrow"/>
88
<rowspec value="center:max(d;4px):noGrow"/>
9-
<colspec value="left:183px:noGrow"/>
9+
<colspec value="left:119px:noGrow"/>
1010
<colspec value="left:13dlu:noGrow"/>
1111
<colspec value="left:d:grow"/>
12+
<colspec value="left:4dlu:noGrow"/>
13+
<colspec value="fill:max(d;4px):noGrow"/>
1214
<constraints>
1315
<xy x="20" y="20" width="1004" height="400"/>
1416
</constraints>
@@ -27,20 +29,9 @@
2729
<toolTipText value="采取全拼音显示,无色文本"/>
2830
</properties>
2931
</component>
30-
<component id="ed221" class="javax.swing.JCheckBox" binding="checkBoxTableStriped">
31-
<constraints>
32-
<grid row="0" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
33-
<forms defaultalign-horz="false" defaultalign-vert="false"/>
34-
</constraints>
35-
<properties>
36-
<horizontalAlignment value="2"/>
37-
<horizontalTextPosition value="2"/>
38-
<text value="表格条纹(斑马线)"/>
39-
</properties>
40-
</component>
4132
<tabbedpane id="e57b" binding="tabbedPane1" default-binding="true">
4233
<constraints>
43-
<grid row="2" column="0" row-span="1" col-span="3" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false">
34+
<grid row="2" column="0" row-span="1" col-span="5" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false">
4435
<preferred-size width="200" height="200"/>
4536
</grid>
4637
<forms/>
@@ -88,7 +79,7 @@
8879
<properties>
8980
<lineWrap value="true"/>
9081
<minimumSize width="370" height="17"/>
91-
<preferredSize width="370" height="85"/>
82+
<preferredSize width="370" height="95"/>
9283
<rows value="5"/>
9384
<text value=""/>
9485
<toolTipText value="基金编码,英文逗号分隔"/>
@@ -156,7 +147,7 @@
156147
<properties>
157148
<lineWrap value="true"/>
158149
<minimumSize width="370" height="17"/>
159-
<preferredSize width="370" height="85"/>
150+
<preferredSize width="370" height="95"/>
160151
<rows value="5"/>
161152
<toolTipText value="股票编码,英文逗号分隔,例如:【sh000001,sh600519,sz000001,hk00700,usAAPL】"/>
162153
</properties>
@@ -192,9 +183,43 @@
192183
<forms/>
193184
</constraints>
194185
<properties>
195-
<text value="小韭菜 V1.6.4"/>
186+
<text value="小韭菜 V1.7.1"/>
196187
</properties>
197188
</component>
189+
<grid id="b17a5" layout-manager="FlowLayout" hgap="30" vgap="5" flow-align="0">
190+
<constraints>
191+
<grid row="0" column="1" row-span="1" col-span="2" vsize-policy="3" hsize-policy="3" anchor="8" fill="2" indent="0" use-parent-layout="false"/>
192+
<forms defaultalign-horz="false" defaultalign-vert="false"/>
193+
</constraints>
194+
<properties/>
195+
<border type="none"/>
196+
<children>
197+
<component id="ed221" class="javax.swing.JCheckBox" binding="checkBoxTableStriped">
198+
<constraints/>
199+
<properties>
200+
<horizontalAlignment value="2"/>
201+
<horizontalTextPosition value="2"/>
202+
<text value="表格条纹(斑马线)"/>
203+
</properties>
204+
</component>
205+
<component id="8c514" class="javax.swing.JCheckBox" binding="checkboxSina">
206+
<constraints/>
207+
<properties>
208+
<horizontalAlignment value="2"/>
209+
<horizontalTextPosition value="2"/>
210+
<text value="采用新浪股票接口(无港股美股数据)"/>
211+
</properties>
212+
</component>
213+
<component id="3e6da" class="javax.swing.JCheckBox" binding="checkboxLog">
214+
<constraints/>
215+
<properties>
216+
<horizontalAlignment value="2"/>
217+
<horizontalTextPosition value="2"/>
218+
<text value="关闭日志"/>
219+
</properties>
220+
</component>
221+
</children>
222+
</grid>
198223
</children>
199224
</grid>
200225
</form>

src/main/java/SettingsWindow.java

+6
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ public class SettingsWindow implements Configurable {
1818
private JCheckBox checkBoxTableStriped;
1919
private JSpinner spinnerFund;
2020
private JSpinner spinnerStock;
21+
private JCheckBox checkboxSina;
22+
private JCheckBox checkboxLog;
2123

2224
@Override
2325
public @Nls(capitalization = Nls.Capitalization.Title) String getDisplayName() {
@@ -34,6 +36,8 @@ public class SettingsWindow implements Configurable {
3436
textAreaStock.setText(value_stock);
3537
checkbox.setSelected(!value_color);
3638
checkBoxTableStriped.setSelected(instance.getBoolean("key_table_striped"));
39+
checkboxSina.setSelected(instance.getBoolean("key_stocks_sina"));
40+
checkboxLog.setSelected(instance.getBoolean("key_close_log"));
3741
spinnerFund.setModel(new SpinnerNumberModel(instance.getInt("key_funds_thread_time", 60), 1, Integer.MAX_VALUE, 1));
3842
spinnerStock.setModel(new SpinnerNumberModel(instance.getInt("key_stocks_thread_time", 10), 1, Integer.MAX_VALUE, 1));
3943
return panel1;
@@ -53,6 +57,8 @@ public void apply() throws ConfigurationException {
5357
instance.setValue("key_funds_thread_time", spinnerFund.getValue().toString());
5458
instance.setValue("key_stocks_thread_time", spinnerStock.getValue().toString());
5559
instance.setValue("key_table_striped", checkBoxTableStriped.isSelected());
60+
instance.setValue("key_stocks_sina",checkboxSina.isSelected());
61+
instance.setValue("key_close_log",checkboxLog.isSelected());
5662
StockWindow.apply();
5763
FundWindow.apply();
5864
}

src/main/java/StockWindow.java

+33-5
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,26 @@
1818
public class StockWindow {
1919
private JPanel mPanel;
2020

21-
static TencentStockHandler handler;
21+
static StockRefreshHandler handler;
22+
23+
static JBTable table;
24+
static JLabel refreshTimeLabel;
2225

2326
public JPanel getmPanel() {
2427
return mPanel;
2528
}
2629

27-
public StockWindow() {
28-
JLabel refreshTimeLabel = new JLabel();
30+
static {
31+
refreshTimeLabel = new JLabel();
2932
refreshTimeLabel.setToolTipText("最后刷新时间");
3033
refreshTimeLabel.setBorder(new EmptyBorder(0, 0, 0, 5));
34+
table = new JBTable();
35+
}
3136

32-
JBTable table = new JBTable();
33-
handler = new TencentStockHandler(table, refreshTimeLabel);
37+
public StockWindow() {
38+
39+
//切换接口
40+
handler = factoryHandler();
3441

3542
AnActionButton refreshAction = new AnActionButton("停止刷新当前表格数据", AllIcons.Actions.StopRefresh) {
3643
@Override
@@ -57,8 +64,29 @@ public void actionPerformed(@NotNull AnActionEvent e) {
5764
apply();
5865
}
5966

67+
private static StockRefreshHandler factoryHandler(){
68+
boolean useSinaApi = PropertiesComponent.getInstance().getBoolean("key_stocks_sina");
69+
if (useSinaApi){
70+
if (handler instanceof SinaStockHandler){
71+
return handler;
72+
}
73+
if (handler!=null){
74+
handler.stopHandle();
75+
}
76+
return new SinaStockHandler(table, refreshTimeLabel);
77+
}
78+
if (handler instanceof TencentStockHandler){
79+
return handler;
80+
}
81+
if (handler!=null){
82+
handler.stopHandle();
83+
}
84+
return new TencentStockHandler(table, refreshTimeLabel);
85+
}
86+
6087
public static void apply() {
6188
if (handler != null) {
89+
handler = factoryHandler();
6290
PropertiesComponent instance = PropertiesComponent.getInstance();
6391
handler.setStriped(instance.getBoolean("key_table_striped"));
6492
handler.setThreadSleepTime(instance.getInt("key_stocks_thread_time", handler.getThreadSleepTime()));

src/main/java/utils/LogUtil.java

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package utils;
22

3+
import com.intellij.ide.util.PropertiesComponent;
34
import com.intellij.notification.NotificationDisplayType;
45
import com.intellij.notification.NotificationGroup;
56
import com.intellij.openapi.project.Project;
@@ -13,6 +14,9 @@ public static void setProject(Project project) {
1314
}
1415

1516
public static void info(String text){
16-
new NotificationGroup("Gradle sync", NotificationDisplayType.NONE, true).createNotification(text, MessageType.INFO).notify(project);
17+
boolean closeLog = PropertiesComponent.getInstance().getBoolean("key_close_log");
18+
if (!closeLog){
19+
new NotificationGroup("Gradle sync", NotificationDisplayType.NONE, true).createNotification(text, MessageType.INFO).notify(project);
20+
}
1721
}
1822
}

src/main/java/utils/SinaStockHandler.java

+9-17
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,7 @@ public class SinaStockHandler extends StockRefreshHandler {
2222
private static final Pattern DEFAULT_STOCK_PATTERN = Pattern.compile("var hq_str_(\\w+?)=\"(.*?)\";");
2323
private final JLabel refreshTimeLabel;
2424

25-
private static final ScheduledExecutorService mSchedulerExecutor = Executors.newSingleThreadScheduledExecutor();
26-
private volatile boolean working = true;
27-
private volatile boolean started = false;
25+
private static ScheduledExecutorService mSchedulerExecutor = Executors.newSingleThreadScheduledExecutor();
2826

2927
public SinaStockHandler(JTable table, JLabel label) {
3028
super(table);
@@ -41,30 +39,24 @@ public void handle(List<String> code) {
4139
}
4240

4341
public void useScheduleThreadExecutor(List<String> code) {
44-
if (!started) {
45-
mSchedulerExecutor.scheduleAtFixedRate(getWork(code), 0, 1, TimeUnit.SECONDS);
46-
started = true;
47-
LogUtil.info("stock 定时线程池 init success");
42+
if (mSchedulerExecutor.isShutdown()){
43+
mSchedulerExecutor = Executors.newSingleThreadScheduledExecutor();
4844
}
49-
working = true;
50-
System.out.println("working = " + working);
51-
LogUtil.info("stock 定时线程池 start success");
45+
mSchedulerExecutor.scheduleAtFixedRate(getWork(code), 0, threadSleepTime, TimeUnit.SECONDS);
5246
}
5347

5448
private Runnable getWork(List<String> code) {
5549
return () -> {
56-
if (working) {
57-
pollStock(code);
58-
}
50+
pollStock(code);
5951
};
6052
}
6153

6254
private void pollStock(List<String> code) {
6355
String params = Joiner.on(",").join(code);
6456
try {
6557
String res = HttpClientPool.getHttpClient().get(URL + params);
66-
String time = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss,SSS"));
67-
System.out.printf("%s,%s%n", time, res);
58+
// String time = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss,SSS"));
59+
// System.out.printf("%s,%s%n", time, res);
6860
handleResponse(res);
6961
} catch (Exception e) {
7062
LogUtil.info(e.getMessage());
@@ -80,7 +72,7 @@ public void handleResponse(String response) {
8072
}
8173
String code = matcher.group(1);
8274
String[] split = matcher.group(2).split(",");
83-
if (split == null || split.length < 32) {
75+
if (split.length < 32) {
8476
continue;
8577
}
8678
StockBean bean = new StockBean(code);
@@ -109,7 +101,7 @@ public void handleResponse(String response) {
109101

110102
@Override
111103
public void stopHandle() {
112-
working = false;
104+
mSchedulerExecutor.shutdown();
113105
LogUtil.info("leeks stock 自动刷新关闭!");
114106
}
115107
}

src/main/java/utils/StockRefreshHandler.java

+13
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ public abstract class StockRefreshHandler extends DefaultTableModel {
1919
private JTable table;
2020
private boolean colorful = true;
2121

22+
/**
23+
* 更新数据的间隔时间(秒)
24+
*/
25+
protected volatile int threadSleepTime = 10;
26+
2227
public StockRefreshHandler(JTable table) {
2328
this.table = table;
2429
table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
@@ -213,4 +218,12 @@ private Vector<Object> convertData(StockBean fundBean) {
213218
public boolean isCellEditable(int row, int column) {
214219
return false;
215220
}
221+
222+
public int getThreadSleepTime() {
223+
return threadSleepTime;
224+
}
225+
226+
public void setThreadSleepTime(int threadSleepTime) {
227+
this.threadSleepTime = threadSleepTime;
228+
}
216229
}

src/main/java/utils/TencentStockHandler.java

+1-10
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,7 @@ public class TencentStockHandler extends StockRefreshHandler {
1212

1313
private Thread worker;
1414
private JLabel refreshTimeLabel;
15-
/**
16-
* 更新数据的间隔时间(秒)
17-
*/
18-
private volatile int threadSleepTime = 10;
15+
1916

2017
public TencentStockHandler(JTable table1, JLabel refreshTimeLabel) {
2118
super(table1);
@@ -111,11 +108,5 @@ public void run() {
111108
});
112109
}
113110

114-
public int getThreadSleepTime() {
115-
return threadSleepTime;
116-
}
117111

118-
public void setThreadSleepTime(int threadSleepTime) {
119-
this.threadSleepTime = threadSleepTime;
120-
}
121112
}

0 commit comments

Comments
 (0)