Skip to content

Commit 7aaab5a

Browse files
committed
remove scheduled for removal API and Deprecated API
1 parent 9e7abdd commit 7aaab5a

File tree

13 files changed

+151
-150
lines changed

13 files changed

+151
-150
lines changed

build.gradle

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66
*/
77
plugins {
88
id 'java'
9-
id 'org.jetbrains.intellij' version '0.4.21'
9+
id 'org.jetbrains.intellij' version '1.17.2'
1010
}
1111

1212
group 'cn.ieclipse.smartim'
13-
version '3.0.0'
13+
version '3.0.0.223'
1414

1515
repositories {
1616
mavenCentral()
@@ -38,18 +38,18 @@ dependencies {
3838

3939
// See https://github.com/JetBrains/gradle-intellij-plugin/
4040
intellij {
41-
version = 'IU-2019.1.4'
41+
version = 'IU-2023.3.6'
4242
}
4343
patchPluginXml {
44-
sinceBuild = '141'
44+
sinceBuild = '223'
4545
untilBuild = '241.*'
4646
}
4747
publishPlugin {
48-
token = System.getProperty("intellijPublishToken")
48+
token = project.getProperty "intellijPublishToken"
4949
}
5050
tasks.withType(JavaCompile) {
51-
sourceCompatibility = "8"
52-
targetCompatibility = "8"
51+
sourceCompatibility = "17"
52+
targetCompatibility = "17"
5353
options.encoding = 'UTF-8'
5454
options.compilerArgs += ['-Xlint:unchecked', '-Xlint:deprecation', '-parameters']
5555
}

resources/META-INF/plugin.xml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,17 @@
99
上班聊天的摸鱼神器,直接在IDE中与微信好友沟通,老板以为你是在写代码?No!No!No!其实,你是在聊天,不过,作为程序猿,怎么可能有时间聊天,哈哈,如果此插件帮助了你,是否可以请我喝杯咖啡?<br/>
1010
about more: <a href="https://github.com/Jamling/SmartIM4Intellij/">https://github.com/Jamling/SmartIM4Intellij/</a>
1111
]]></description>
12-
1312
<change-notes><![CDATA[
13+
v3.0.0.223 2024-04-20 <br/>
14+
兼容IDE版本修改为2023.x - 最新,如果IDE版本过旧,请下载历史旧版本 <br/>
15+
修复#93 <br/>
1416
v3.0.0 2024-04-05 <br/>
1517
微信使用PC版协议,解决大部分账号限制登录的问题 <br/>
1618
]]>
1719
</change-notes>
1820

1921
<!-- please see http://www.jetbrains.org/intellij/sdk/docs/basics/getting_started/build_number_ranges.html for description -->
20-
<idea-version since-build="141.0"/>
22+
<idea-version since-build="223.0"/>
2123

2224
<!-- please see http://www.jetbrains.org/intellij/sdk/docs/basics/getting_started/plugin_compatibility.html
2325
on how to contact different products -->
@@ -31,6 +33,8 @@
3133
factoryClass="cn.ieclipse.smartim.IMWindowFactory"
3234
icon="/icons/im.svg">
3335
</toolWindow>
36+
<notificationGroup id="SmartIM"
37+
displayType="BALLOON"/>
3438
<applicationConfigurable instance="cn.ieclipse.smartim.settings.SmartSettingsPanel" displayName="SmartIM"/>
3539
<applicationService serviceImplementation="cn.ieclipse.smartim.settings.SmartIMSettings"/>
3640
</extensions>

src/cn/ieclipse/smartim/IMWindowFactory.java

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
import cn.ieclipse.smartqq.SmartQQPanel;
44
import cn.ieclipse.wechat.WechatPanel;
5+
import com.intellij.ide.plugins.PluginManagerCore;
6+
import com.intellij.openapi.extensions.PluginDescriptor;
7+
import com.intellij.openapi.extensions.PluginId;
58
import com.intellij.openapi.project.Project;
69
import com.intellij.openapi.project.ProjectManager;
710
import com.intellij.openapi.wm.ToolWindow;
@@ -11,6 +14,7 @@
1114
import org.jetbrains.annotations.NotNull;
1215

1316
import java.io.File;
17+
import java.util.Optional;
1418

1519
/**
1620
* Created by Jamling on 2017/7/11.
@@ -21,6 +25,11 @@ public class IMWindowFactory implements ToolWindowFactory {
2125

2226
private Project project;
2327

28+
/**
29+
* 在未找到QQ新协议之前,不展示QQ
30+
*/
31+
private final boolean enableQQ = false;
32+
2433
@Override public void createToolWindowContent(@NotNull Project project, @NotNull ToolWindow toolWindow) {
2534
instance = this;
2635
this.project = project;
@@ -34,13 +43,16 @@ private void createContents(@NotNull Project project, @NotNull ToolWindow toolWi
3443
dir.mkdirs();
3544
}
3645
System.setProperty("log.home", dir.getAbsolutePath());
37-
ContentFactory contentFactory = ContentFactory.SERVICE.getInstance();
46+
ContentFactory contentFactory = ContentFactory.getInstance();
3847
Content content;
3948

4049
WechatPanel wechatPanel = new WechatPanel(project, toolWindow);
4150
content = contentFactory.createContent(wechatPanel, "Wechat", false);
4251
toolWindow.getContentManager().addContent(content, 0);
4352

53+
if (!enableQQ) {
54+
return;
55+
}
4456
SmartQQPanel qqPanel = new SmartQQPanel(project, toolWindow);
4557
content = contentFactory.createContent(qqPanel, "SmartQQ", false);
4658
toolWindow.getContentManager().addContent(content, 1);
@@ -51,13 +63,12 @@ public File getWorkDir() {
5163
if (p == null) {
5264
p = ProjectManager.getInstance().getDefaultProject();
5365
Project[] ps = ProjectManager.getInstance().getOpenProjects();
54-
if (ps != null) {
55-
for (Project t : ps) {
56-
if (!t.isDefault()) {
57-
p = t;
58-
}
66+
for (Project t : ps) {
67+
if (!t.isDefault()) {
68+
p = t;
5969
}
6070
}
71+
6172
}
6273
return new File(p.getBasePath(), Project.DIRECTORY_STORE_FOLDER);
6374
}
@@ -71,4 +82,9 @@ public Project getProject() {
7182
public static IMWindowFactory getDefault() {
7283
return instance;
7384
}
85+
86+
public static Optional<PluginDescriptor> getPlugin() {
87+
PluginId pluginId = PluginId.getId("cn.ieclipse.smartqq.intellij");
88+
return Optional.ofNullable(PluginManagerCore.getPlugin(pluginId));
89+
}
7490
}

src/cn/ieclipse/smartim/actions/HideContactAction.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ public HideContactAction(IMPanel panel) {
2323
return ActionUpdateThread.BGT;
2424
}
2525

26-
@Override public boolean isSelected(AnActionEvent anActionEvent) {
26+
@Override public boolean isSelected(@NotNull AnActionEvent anActionEvent) {
2727
return panel.isLeftHidden();
2828
}
2929

30-
@Override public void setSelected(AnActionEvent anActionEvent, boolean b) {
30+
@Override public void setSelected(@NotNull AnActionEvent anActionEvent, boolean b) {
3131
panel.setLeftHide(b);
3232
}
3333
}

src/cn/ieclipse/smartim/actions/LoginAction.java

Lines changed: 4 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -20,54 +20,19 @@ public LoginAction(IMPanel panel) {
2020
SmartClient client = imPanel.getClient();
2121
boolean ok = true;
2222
if (client.isLogin()) {
23-
ok = MessageDialogBuilder.yesNo("", "您已处于登录状态,确定要重新登录吗?").show() == 0;
23+
ok = MessageDialogBuilder.yesNo("", "您已处于登录状态,确定要重新登录吗?").ask(getEventProject(anActionEvent));
2424
}
2525
if (ok) {
2626
client.setLoginCallback(new MyLoginCallback(client, imPanel));
27-
new Thread() {
28-
@Override public void run() {
29-
client.login();
30-
}
31-
}.start();
27+
new Thread(client::login).start();
3228
} else {
3329
imPanel.initContacts();
3430
}
35-
//
36-
// LoginDialog dialog = new LoginDialog(client);
37-
// dialog.setSize(200, 240);
38-
// dialog.setLocationRelativeTo(null);
39-
// dialog.pack();
40-
// dialog.setVisible(true);
41-
// LOG.info("login : " + client.isLogin());
42-
// if (client.isLogin()) {
43-
// new LoadThread(client).start();
44-
// } else {
45-
// //fillTestData(client);
46-
// }
4731
}
4832

49-
// private void fillTestData(SmartClient client) {
50-
// client.categories = new ArrayList<>();
51-
// for (int i = 0; i < 5; i++) {
52-
// Category c = new Category();
53-
// c.setName("Cate " + i);
54-
// client.categories.add(c);
55-
// for (int j = 0; j < 5; j++) {
56-
// Friend f = new Friend();
57-
// f.setMarkname("friend " + j);
58-
// c.addFriend(f);
59-
// }
60-
// }
61-
// client.groups = new ArrayList<>();
62-
// Group g = new Group();
63-
// g.setName("Group 0");
64-
// client.groups.add(g);
65-
// smartPanel.updateContact();
66-
// }
67-
6833
public static class MyLoginCallback extends DefaultLoginCallback {
69-
private SmartClient client;
70-
private IMPanel panel;
34+
private final SmartClient client;
35+
private final IMPanel panel;
7136

7237
private MyLoginCallback(SmartClient client, IMPanel panel) {
7338
this.client = client;

src/cn/ieclipse/smartim/common/BalloonNotifier.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,28 +4,28 @@
44
import cn.ieclipse.smartim.model.IContact;
55
import cn.ieclipse.smartim.views.IMPanel;
66
import cn.ieclipse.util.StringUtils;
7-
import com.intellij.notification.Notification;
8-
import com.intellij.notification.NotificationDisplayType;
9-
import com.intellij.notification.NotificationGroup;
10-
import com.intellij.notification.NotificationType;
7+
import com.intellij.notification.*;
118
import com.intellij.openapi.project.ProjectManager;
129

1310
/**
1411
* Created by Jamling on 2017/10/31.
1512
*/
1613
public class BalloonNotifier {
1714
private static final NotificationGroup NOTIFICATION_GROUP =
18-
new NotificationGroup("SmartIM",
19-
NotificationDisplayType.BALLOON, true, IMWindowFactory.TOOL_WINDOW_ID);
15+
NotificationGroupManager.getInstance().getNotificationGroup(IMWindowFactory.TOOL_WINDOW_ID);
2016
public static void notify(final String title, final CharSequence text) {
21-
Notification n = NOTIFICATION_GROUP.createNotification();
22-
n.setTitle(title);
23-
n.setContent(StringUtils.isEmpty(text) ? "" : text.toString());
17+
String content = StringUtils.isEmpty(text) ? "" : text.toString();
18+
Notification n = NOTIFICATION_GROUP.createNotification(title, content, NotificationType.INFORMATION);
2419
n.notify(ProjectManager.getInstance().getDefaultProject());
2520
}
2621

2722
public static void notify(final IMPanel contactView, final IContact target, final String title,
2823
final CharSequence text) {
2924
notify(title, text);
3025
}
26+
27+
public static void error(String error) {
28+
Notification n = NOTIFICATION_GROUP.createNotification(IMWindowFactory.TOOL_WINDOW_ID, error, NotificationType.ERROR);
29+
n.notify(ProjectManager.getInstance().getDefaultProject());
30+
}
3131
}

src/cn/ieclipse/smartim/common/RestUtils.java

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
*/
1616
package cn.ieclipse.smartim.common;
1717

18+
import cn.ieclipse.smartim.IMWindowFactory;
1819
import cn.ieclipse.util.XPathUtils;
1920
import com.intellij.ide.plugins.IdeaPluginDescriptor;
2021
import com.intellij.ide.plugins.PluginManager;
@@ -29,7 +30,7 @@
2930
import javax.swing.*;
3031
import javax.swing.text.html.StyleSheet;
3132
import java.net.MalformedURLException;
32-
import java.net.URL;
33+
import java.net.URI;
3334

3435
/**
3536
* 类/接口描述
@@ -46,12 +47,10 @@ public static String getWelcome(String im) {
4647
if (im.equals("qq")) {
4748
return "因腾讯业务调整,SmartQQ于2019年1月1日起停止服务。当前暂无替代的协议,暂无法提供脑出血,敬请谅解!";
4849
}
49-
50-
final IdeaPluginDescriptor descriptor =
51-
PluginManager.getPlugin(PluginId.findId("cn.ieclipse.smartqq.intellij"));
52-
return String.format("欢迎使用SmartIM4IntelliJ (ver:%s),为保障安全,请不要在公开场合讨论本插件以免被封", descriptor.getVersion());
50+
return "欢迎使用SmartIM4IntelliJ,为保障安全,请不要在公开场合讨论本插件以免被封";
5351
}
5452

53+
5554
public static void checkUpdate() {
5655
new Thread(() -> {
5756
try {
@@ -64,16 +63,16 @@ public static void checkUpdate() {
6463
Element node = XPathUtils.findElement(doc, "/plugin-repository/category/idea-plugin[1]");
6564
String latest = XPathUtils.findElement(node, "version").getTextContent();
6665
String desc = XPathUtils.findElement(node, "change-notes").getTextContent();
67-
final IdeaPluginDescriptor descriptor =
68-
PluginManager.getPlugin(PluginId.findId("cn.ieclipse.smartqq.intellij"));
69-
SwingUtilities.invokeLater(() -> {
70-
if (descriptor != null && descriptor.getVersion().equals(latest)) {
71-
JOptionPane.showMessageDialog(null, "已是最新版本");
72-
return;
73-
}
74-
BalloonNotifier.notify(latest, desc);
75-
JOptionPane.showMessageDialog(null,
76-
"发现新版本" + latest + "请在File->Settings->Plugins插件页中更新SmartIM");
66+
IMWindowFactory.getPlugin().ifPresent(descriptor -> {
67+
SwingUtilities.invokeLater(() -> {
68+
if (descriptor.getVersion().equals(latest)) {
69+
JOptionPane.showMessageDialog(null, "已是最新版本");
70+
return;
71+
}
72+
BalloonNotifier.notify(latest, desc);
73+
JOptionPane.showMessageDialog(null,
74+
"发现新版本" + latest + "请在File->Settings->Plugins插件页中更新SmartIM");
75+
});
7776
});
7877
}
7978
} catch (Exception ex) {
@@ -88,9 +87,9 @@ public static void loadStyleAsync(final StyleSheet styleSheet) {
8887

8988
public static void loadStyleSync(final StyleSheet styleSheet) {
9089
try {
91-
styleSheet.importStyleSheet(new URL(CSS_URL));
90+
styleSheet.importStyleSheet(URI.create(CSS_URL).toURL());
9291
} catch (MalformedURLException e1) {
93-
e1.printStackTrace();
92+
BalloonNotifier.error("unable to load " + CSS_URL);
9493
}
9594
}
9695

src/cn/ieclipse/smartim/settings/GeneralPanel.java

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,13 @@
1010
import javax.swing.*;
1111
import java.awt.event.MouseAdapter;
1212
import java.awt.event.MouseEvent;
13+
import java.util.Objects;
1314

1415
/**
1516
* Created by Jamling on 2017/7/11.
1617
*/
1718
public class GeneralPanel implements Configurable {
18-
private JComboBox comboSend;
19+
private JComboBox<String> comboSend;
1920
private JCheckBox chkNotify;
2021
private JCheckBox chkNotifyUnread;
2122
private JCheckBox chkSendBtn;
@@ -26,7 +27,7 @@ public class GeneralPanel implements Configurable {
2627
private JLabel linkUpdate;
2728
private JLabel linkAbout;
2829
private JCheckBox chkHistory;
29-
private SmartIMSettings settings;
30+
private final SmartIMSettings settings;
3031

3132
public GeneralPanel(SmartIMSettings settings) {
3233
this.settings = settings;
@@ -56,7 +57,7 @@ public GeneralPanel(SmartIMSettings settings) {
5657
}
5758

5859
@Override public boolean isModified() {
59-
return chkNotify.isSelected() != settings.getState().NOTIFY_MSG || chkNotifyUnread.isSelected() != settings
60+
return chkNotify.isSelected() != Objects.requireNonNull(settings.getState()).NOTIFY_MSG || chkNotifyUnread.isSelected() != settings
6061
.getState().NOTIFY_UNREAD || chkSendBtn.isSelected() != settings.getState().SHOW_SEND
6162
|| chkNotifyGroupMsg.isSelected() != settings.getState().NOTIFY_GROUP_MSG
6263
|| chkNotifyUnknown.isSelected() != settings.getState().NOTIFY_UNKNOWN
@@ -65,7 +66,7 @@ public GeneralPanel(SmartIMSettings settings) {
6566
}
6667

6768
@Override public void apply() throws ConfigurationException {
68-
settings.getState().NOTIFY_MSG = chkNotify.isSelected();
69+
Objects.requireNonNull(settings.getState()).NOTIFY_MSG = chkNotify.isSelected();
6970
settings.getState().NOTIFY_UNREAD = chkNotifyUnread.isSelected();
7071
settings.getState().SHOW_SEND = chkSendBtn.isSelected();
7172
settings.getState().NOTIFY_GROUP_MSG = chkNotifyGroupMsg.isSelected();
@@ -76,7 +77,7 @@ public GeneralPanel(SmartIMSettings settings) {
7677
}
7778

7879
@Override public void reset() {
79-
chkNotify.setSelected(settings.getState().NOTIFY_MSG);
80+
chkNotify.setSelected(Objects.requireNonNull(settings.getState()).NOTIFY_MSG);
8081
chkNotifyGroupMsg.setSelected(settings.getState().NOTIFY_GROUP_MSG);
8182
chkSendBtn.setSelected(settings.getState().SHOW_SEND);
8283
chkNotifyUnread.setSelected(settings.getState().NOTIFY_UNREAD);
@@ -86,10 +87,6 @@ public GeneralPanel(SmartIMSettings settings) {
8687
comboSend.setSelectedItem(settings.getState().KEY_SEND);
8788
}
8889

89-
@Override public void disposeUIResources() {
90-
91-
}
92-
9390
private void checkUpdate() {
9491
RestUtils.checkUpdate();
9592
}

0 commit comments

Comments
 (0)