Skip to content

Commit

Permalink
v1.7.1发布
Browse files Browse the repository at this point in the history
  • Loading branch information
huage2580 committed Jan 18, 2021
1 parent 2c4f071 commit feb0c1a
Show file tree
Hide file tree
Showing 11 changed files with 115 additions and 52 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ double shift,连按两下shift,输入leeks,找到toolWindow,打开以后
- v1.6.2
适配IDEA 2020.3
- v1.6.3
修复颜色错乱问题
修复颜色错乱问题 , 日志调整 merge from [qwn3213](https://github.com/qwn3213)
- v1.7.1
增加日志开关 ,设置界面样式调整 merge from [dengerYang](https://github.com/dengerYang) ,增加新浪股票接口备选 merge from [JulianXG](https://github.com/JulianXG)



3 changes: 2 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ plugins {
}

group 'com.huage2580'
version '1.6.4'
version '1.7.1'

sourceCompatibility = 1.8

Expand Down Expand Up @@ -32,6 +32,7 @@ patchPluginXml {
v1.4 增加了隐蔽模式(全拼音和无色涨跌幅
v1.5 增加了股票界面的排序~,可按净值和涨跌幅等列排序
v1.6 样式修改,增加精确净值(当日,上一交易日
v1.7 设置界面样式调整,增加新浪股票接口备选
"""
sinceBuild '173.*'
untilBuild '203.*'
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#Wed Jul 15 10:09:28 CST 2020
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-5.2.1-all.zip
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
Expand Down
Binary file renamed leeks-1.6.3.zip → leeks-1.7.1.zip
Binary file not shown.
57 changes: 41 additions & 16 deletions src/main/java/SettingsWindow.form
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@
<rowspec value="center:max(d;4px):noGrow"/>
<rowspec value="top:4dlu:noGrow"/>
<rowspec value="center:max(d;4px):noGrow"/>
<colspec value="left:183px:noGrow"/>
<colspec value="left:119px:noGrow"/>
<colspec value="left:13dlu:noGrow"/>
<colspec value="left:d:grow"/>
<colspec value="left:4dlu:noGrow"/>
<colspec value="fill:max(d;4px):noGrow"/>
<constraints>
<xy x="20" y="20" width="1004" height="400"/>
</constraints>
Expand All @@ -27,20 +29,9 @@
<toolTipText value="采取全拼音显示,无色文本"/>
</properties>
</component>
<component id="ed221" class="javax.swing.JCheckBox" binding="checkBoxTableStriped">
<constraints>
<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"/>
<forms defaultalign-horz="false" defaultalign-vert="false"/>
</constraints>
<properties>
<horizontalAlignment value="2"/>
<horizontalTextPosition value="2"/>
<text value="表格条纹(斑马线)"/>
</properties>
</component>
<tabbedpane id="e57b" binding="tabbedPane1" default-binding="true">
<constraints>
<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">
<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">
<preferred-size width="200" height="200"/>
</grid>
<forms/>
Expand Down Expand Up @@ -88,7 +79,7 @@
<properties>
<lineWrap value="true"/>
<minimumSize width="370" height="17"/>
<preferredSize width="370" height="85"/>
<preferredSize width="370" height="95"/>
<rows value="5"/>
<text value=""/>
<toolTipText value="基金编码,英文逗号分隔"/>
Expand Down Expand Up @@ -156,7 +147,7 @@
<properties>
<lineWrap value="true"/>
<minimumSize width="370" height="17"/>
<preferredSize width="370" height="85"/>
<preferredSize width="370" height="95"/>
<rows value="5"/>
<toolTipText value="股票编码,英文逗号分隔,例如:【sh000001,sh600519,sz000001,hk00700,usAAPL】"/>
</properties>
Expand Down Expand Up @@ -192,9 +183,43 @@
<forms/>
</constraints>
<properties>
<text value="小韭菜 V1.6.4"/>
<text value="小韭菜 V1.7.1"/>
</properties>
</component>
<grid id="b17a5" layout-manager="FlowLayout" hgap="30" vgap="5" flow-align="0">
<constraints>
<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"/>
<forms defaultalign-horz="false" defaultalign-vert="false"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="ed221" class="javax.swing.JCheckBox" binding="checkBoxTableStriped">
<constraints/>
<properties>
<horizontalAlignment value="2"/>
<horizontalTextPosition value="2"/>
<text value="表格条纹(斑马线)"/>
</properties>
</component>
<component id="8c514" class="javax.swing.JCheckBox" binding="checkboxSina">
<constraints/>
<properties>
<horizontalAlignment value="2"/>
<horizontalTextPosition value="2"/>
<text value="采用新浪股票接口(无港股美股数据)"/>
</properties>
</component>
<component id="3e6da" class="javax.swing.JCheckBox" binding="checkboxLog">
<constraints/>
<properties>
<horizontalAlignment value="2"/>
<horizontalTextPosition value="2"/>
<text value="关闭日志"/>
</properties>
</component>
</children>
</grid>
</children>
</grid>
</form>
6 changes: 6 additions & 0 deletions src/main/java/SettingsWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ public class SettingsWindow implements Configurable {
private JCheckBox checkBoxTableStriped;
private JSpinner spinnerFund;
private JSpinner spinnerStock;
private JCheckBox checkboxSina;
private JCheckBox checkboxLog;

@Override
public @Nls(capitalization = Nls.Capitalization.Title) String getDisplayName() {
Expand All @@ -34,6 +36,8 @@ public class SettingsWindow implements Configurable {
textAreaStock.setText(value_stock);
checkbox.setSelected(!value_color);
checkBoxTableStriped.setSelected(instance.getBoolean("key_table_striped"));
checkboxSina.setSelected(instance.getBoolean("key_stocks_sina"));
checkboxLog.setSelected(instance.getBoolean("key_close_log"));
spinnerFund.setModel(new SpinnerNumberModel(instance.getInt("key_funds_thread_time", 60), 1, Integer.MAX_VALUE, 1));
spinnerStock.setModel(new SpinnerNumberModel(instance.getInt("key_stocks_thread_time", 10), 1, Integer.MAX_VALUE, 1));
return panel1;
Expand All @@ -53,6 +57,8 @@ public void apply() throws ConfigurationException {
instance.setValue("key_funds_thread_time", spinnerFund.getValue().toString());
instance.setValue("key_stocks_thread_time", spinnerStock.getValue().toString());
instance.setValue("key_table_striped", checkBoxTableStriped.isSelected());
instance.setValue("key_stocks_sina",checkboxSina.isSelected());
instance.setValue("key_close_log",checkboxLog.isSelected());
StockWindow.apply();
FundWindow.apply();
}
Expand Down
38 changes: 33 additions & 5 deletions src/main/java/StockWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,26 @@
public class StockWindow {
private JPanel mPanel;

static TencentStockHandler handler;
static StockRefreshHandler handler;

static JBTable table;
static JLabel refreshTimeLabel;

public JPanel getmPanel() {
return mPanel;
}

public StockWindow() {
JLabel refreshTimeLabel = new JLabel();
static {
refreshTimeLabel = new JLabel();
refreshTimeLabel.setToolTipText("最后刷新时间");
refreshTimeLabel.setBorder(new EmptyBorder(0, 0, 0, 5));
table = new JBTable();
}

JBTable table = new JBTable();
handler = new TencentStockHandler(table, refreshTimeLabel);
public StockWindow() {

//切换接口
handler = factoryHandler();

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

private static StockRefreshHandler factoryHandler(){
boolean useSinaApi = PropertiesComponent.getInstance().getBoolean("key_stocks_sina");
if (useSinaApi){
if (handler instanceof SinaStockHandler){
return handler;
}
if (handler!=null){
handler.stopHandle();
}
return new SinaStockHandler(table, refreshTimeLabel);
}
if (handler instanceof TencentStockHandler){
return handler;
}
if (handler!=null){
handler.stopHandle();
}
return new TencentStockHandler(table, refreshTimeLabel);
}

public static void apply() {
if (handler != null) {
handler = factoryHandler();
PropertiesComponent instance = PropertiesComponent.getInstance();
handler.setStriped(instance.getBoolean("key_table_striped"));
handler.setThreadSleepTime(instance.getInt("key_stocks_thread_time", handler.getThreadSleepTime()));
Expand Down
6 changes: 5 additions & 1 deletion src/main/java/utils/LogUtil.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package utils;

import com.intellij.ide.util.PropertiesComponent;
import com.intellij.notification.NotificationDisplayType;
import com.intellij.notification.NotificationGroup;
import com.intellij.openapi.project.Project;
Expand All @@ -13,6 +14,9 @@ public static void setProject(Project project) {
}

public static void info(String text){
new NotificationGroup("Gradle sync", NotificationDisplayType.NONE, true).createNotification(text, MessageType.INFO).notify(project);
boolean closeLog = PropertiesComponent.getInstance().getBoolean("key_close_log");
if (!closeLog){
new NotificationGroup("Gradle sync", NotificationDisplayType.NONE, true).createNotification(text, MessageType.INFO).notify(project);
}
}
}
26 changes: 9 additions & 17 deletions src/main/java/utils/SinaStockHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@ public class SinaStockHandler extends StockRefreshHandler {
private static final Pattern DEFAULT_STOCK_PATTERN = Pattern.compile("var hq_str_(\\w+?)=\"(.*?)\";");
private final JLabel refreshTimeLabel;

private static final ScheduledExecutorService mSchedulerExecutor = Executors.newSingleThreadScheduledExecutor();
private volatile boolean working = true;
private volatile boolean started = false;
private static ScheduledExecutorService mSchedulerExecutor = Executors.newSingleThreadScheduledExecutor();

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

public void useScheduleThreadExecutor(List<String> code) {
if (!started) {
mSchedulerExecutor.scheduleAtFixedRate(getWork(code), 0, 1, TimeUnit.SECONDS);
started = true;
LogUtil.info("stock 定时线程池 init success");
if (mSchedulerExecutor.isShutdown()){
mSchedulerExecutor = Executors.newSingleThreadScheduledExecutor();
}
working = true;
System.out.println("working = " + working);
LogUtil.info("stock 定时线程池 start success");
mSchedulerExecutor.scheduleAtFixedRate(getWork(code), 0, threadSleepTime, TimeUnit.SECONDS);
}

private Runnable getWork(List<String> code) {
return () -> {
if (working) {
pollStock(code);
}
pollStock(code);
};
}

private void pollStock(List<String> code) {
String params = Joiner.on(",").join(code);
try {
String res = HttpClientPool.getHttpClient().get(URL + params);
String time = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss,SSS"));
System.out.printf("%s,%s%n", time, res);
// String time = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss,SSS"));
// System.out.printf("%s,%s%n", time, res);
handleResponse(res);
} catch (Exception e) {
LogUtil.info(e.getMessage());
Expand All @@ -80,7 +72,7 @@ public void handleResponse(String response) {
}
String code = matcher.group(1);
String[] split = matcher.group(2).split(",");
if (split == null || split.length < 32) {
if (split.length < 32) {
continue;
}
StockBean bean = new StockBean(code);
Expand Down Expand Up @@ -109,7 +101,7 @@ public void handleResponse(String response) {

@Override
public void stopHandle() {
working = false;
mSchedulerExecutor.shutdown();
LogUtil.info("leeks stock 自动刷新关闭!");
}
}
13 changes: 13 additions & 0 deletions src/main/java/utils/StockRefreshHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ public abstract class StockRefreshHandler extends DefaultTableModel {
private JTable table;
private boolean colorful = true;

/**
* 更新数据的间隔时间(秒)
*/
protected volatile int threadSleepTime = 10;

public StockRefreshHandler(JTable table) {
this.table = table;
table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
Expand Down Expand Up @@ -213,4 +218,12 @@ private Vector<Object> convertData(StockBean fundBean) {
public boolean isCellEditable(int row, int column) {
return false;
}

public int getThreadSleepTime() {
return threadSleepTime;
}

public void setThreadSleepTime(int threadSleepTime) {
this.threadSleepTime = threadSleepTime;
}
}
11 changes: 1 addition & 10 deletions src/main/java/utils/TencentStockHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@ public class TencentStockHandler extends StockRefreshHandler {

private Thread worker;
private JLabel refreshTimeLabel;
/**
* 更新数据的间隔时间(秒)
*/
private volatile int threadSleepTime = 10;


public TencentStockHandler(JTable table1, JLabel refreshTimeLabel) {
super(table1);
Expand Down Expand Up @@ -111,11 +108,5 @@ public void run() {
});
}

public int getThreadSleepTime() {
return threadSleepTime;
}

public void setThreadSleepTime(int threadSleepTime) {
this.threadSleepTime = threadSleepTime;
}
}

0 comments on commit feb0c1a

Please sign in to comment.