Skip to content

Commit 9a35c17

Browse files
committed
Donate
1 parent 01b5155 commit 9a35c17

File tree

4 files changed

+62
-0
lines changed

4 files changed

+62
-0
lines changed

resources/image/WeChat.png

31.2 KB
Loading

resources/image/alipay.png

29.8 KB
Loading
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
package com.shuzijun.leetcode.plugin.listener;
2+
3+
import com.intellij.openapi.project.Project;
4+
import com.intellij.openapi.project.ProjectManager;
5+
import com.intellij.openapi.ui.DialogWrapper;
6+
import com.shuzijun.leetcode.plugin.utils.LogUtils;
7+
import org.jetbrains.annotations.Nullable;
8+
9+
import javax.imageio.ImageIO;
10+
import javax.swing.*;
11+
import java.awt.*;
12+
import java.awt.event.ActionEvent;
13+
import java.awt.event.ActionListener;
14+
import java.io.IOException;
15+
16+
/**
17+
* @author shuzijun
18+
*/
19+
public class DonateListener implements ActionListener {
20+
private JCheckBox jcb;
21+
22+
public DonateListener(JCheckBox jcb) {
23+
this.jcb = jcb;
24+
}
25+
26+
@Override
27+
public void actionPerformed(ActionEvent e) {
28+
if (jcb.isSelected()) {
29+
Project project = ProjectManager.getInstance().getDefaultProject();
30+
DonateListener.DonatePanel dialog = new DonateListener.DonatePanel(project);
31+
dialog.setTitle("Donate");
32+
dialog.showAndGet();
33+
}
34+
}
35+
36+
private class DonatePanel extends DialogWrapper {
37+
38+
private JPanel jpanel;
39+
40+
public DonatePanel(@Nullable Project project) {
41+
super(project, true);
42+
jpanel = new JPanel();
43+
try {
44+
jpanel.add(new JLabel(new ImageIcon(ImageIO.read(this.getClass().getClassLoader().getResourceAsStream("image/WeChat.png")))));
45+
jpanel.add(new JLabel(new ImageIcon(ImageIO.read(this.getClass().getClassLoader().getResourceAsStream("image/AliPay.png")))));
46+
} catch (IOException e) {
47+
LogUtils.LOG.error("加载图片失败",e);
48+
}
49+
jpanel.setMinimumSize(new Dimension(400, 200));
50+
setModal(true);
51+
init();
52+
}
53+
54+
@Nullable
55+
@Override
56+
protected JComponent createCenterPanel() {
57+
return jpanel;
58+
}
59+
}
60+
}

src/com/shuzijun/leetcode/plugin/setting/SettingUI.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import com.intellij.ui.components.JBPasswordField;
1515
import com.intellij.ui.components.JBScrollPane;
1616
import com.intellij.ui.components.JBTextField;
17+
import com.shuzijun.leetcode.plugin.listener.DonateListener;
1718
import com.shuzijun.leetcode.plugin.model.CodeTypeEnum;
1819
import com.shuzijun.leetcode.plugin.model.Config;
1920
import com.shuzijun.leetcode.plugin.model.Constant;
@@ -192,6 +193,7 @@ public void mouseClicked(MouseEvent e) {
192193
templateEditor.getDocument().setText(Constant.CUSTOM_TEMPLATE);
193194
});
194195
}
196+
customCodeBox.addActionListener(new DonateListener(customCodeBox));
195197
}
196198

197199
private void addComponent(Component component, GridBagConstraints constraints, int x, int y, int ex, int ey) {

0 commit comments

Comments
 (0)