Skip to content

Commit 971a4ea

Browse files
committed
compatibility
1 parent b1cf09f commit 971a4ea

File tree

6 files changed

+62
-8
lines changed

6 files changed

+62
-8
lines changed
Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
package com.shuzijun.leetcode.plugin.listener;
22

3-
import com.intellij.ide.plugins.IdeaPluginDescriptor;
4-
import com.intellij.ide.plugins.PluginInstaller;
5-
import com.intellij.ide.plugins.PluginStateListener;
63
import com.intellij.openapi.project.Project;
74
import com.intellij.openapi.startup.StartupActivity;
85
import org.jetbrains.annotations.NotNull;
@@ -13,7 +10,7 @@
1310
public class RegisterPluginInstallerStateListener implements StartupActivity {
1411
@Override
1512
public void runActivity(@NotNull Project project) {
16-
PluginInstaller.addStateListener(new PluginStateListener() {
13+
/* PluginInstaller.addStateListener(new PluginStateListener() {
1714
@Override
1815
public void install(@NotNull IdeaPluginDescriptor ideaPluginDescriptor) {
1916
}
@@ -22,6 +19,6 @@ public void install(@NotNull IdeaPluginDescriptor ideaPluginDescriptor) {
2219
public void uninstall(@NotNull IdeaPluginDescriptor ideaPluginDescriptor) {
2320
System.out.println("uninstall");
2421
}
25-
});
22+
});*/
2623
}
2724
}

src/main/java/com/shuzijun/leetcode/plugin/setting/PersistentConfig.java

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.shuzijun.leetcode.plugin.setting;
22

33
import com.intellij.ide.passwordSafe.PasswordSafe;
4+
import com.intellij.ide.passwordSafe.PasswordSafeException;
45
import com.intellij.openapi.components.*;
56
import com.intellij.util.xmlb.XmlSerializerUtil;
67
import com.shuzijun.leetcode.plugin.model.Config;
@@ -66,12 +67,23 @@ public String getTempFilePath() {
6667
}
6768

6869
public void savePassword(String password) {
69-
PasswordSafe.getInstance().storePassword(null, this.getClass(), "leetcode-editor", password != null ? password : "");
70+
try {
71+
PasswordSafe.getInstance().storePassword
72+
(null, this.getClass(), "leetcode-editor", password != null ? password : "");
73+
} catch (PasswordSafeException exception) {
74+
MessageUtils.showAllWarnMsg("warning", "Failed to save password");
75+
}
7076
}
7177

7278
public String getPassword() {
7379
if (getConfig().getVersion() != null) {
74-
return PasswordSafe.getInstance().getPassword(null, this.getClass(), "leetcode-editor");
80+
try {
81+
return PasswordSafe.getInstance().getPassword(null, this.getClass(), "leetcode-editor");
82+
} catch (PasswordSafeException exception) {
83+
MessageUtils.showAllWarnMsg("warning", "Password acquisition failed");
84+
return null;
85+
}
86+
7587
} else {
7688
return getInitConfig().getPassword();
7789
}

src/main/java/com/shuzijun/leetcode/plugin/setting/ProjectConfig.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,20 @@ public static class InnerState {
6262
projectConfig = new HashMap<>();
6363
}
6464
}
65+
66+
public String getComponentName() {
67+
return this.getClass().getName();
68+
}
69+
70+
public void initComponent() {
71+
}
72+
73+
public void disposeComponent() {
74+
}
75+
76+
public void projectOpened() {
77+
}
78+
79+
public void projectClosed() {
80+
}
6581
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ public void mouseClicked(MouseEvent e) {
202202
LevelColourField.setText(config.getLevelColour());
203203
englishContentBox.setSelected(config.getEnglishContent());
204204
} else {
205-
LevelColourField.setText(config.getLevelColour());
205+
LevelColourField.setText(new Config().getLevelColour());
206206
ApplicationManager.getApplication().runWriteAction(() -> {
207207
fileNameEditor.getDocument().setText(Constant.CUSTOM_FILE_NAME);
208208
templateEditor.getDocument().setText(Constant.CUSTOM_TEMPLATE);

src/main/java/com/shuzijun/leetcode/plugin/timer/TimerBarWidget.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
package com.shuzijun.leetcode.plugin.timer;
22

33
import com.intellij.openapi.project.Project;
4+
import com.intellij.openapi.util.SystemInfo;
45
import com.intellij.openapi.wm.CustomStatusBarWidget;
56
import com.intellij.openapi.wm.StatusBar;
7+
import com.intellij.openapi.wm.StatusBarWidget;
68
import com.shuzijun.leetcode.plugin.model.Config;
79
import com.shuzijun.leetcode.plugin.setting.PersistentConfig;
810
import org.apache.commons.lang.StringUtils;
911
import org.jetbrains.annotations.NotNull;
12+
import org.jetbrains.annotations.Nullable;
1013

1114
import javax.swing.*;
1215
import java.awt.*;
@@ -133,5 +136,15 @@ public void reset() {
133136
label.setVisible(false);
134137
}
135138

139+
@Nullable
140+
public StatusBarWidget.WidgetPresentation getPresentation() {
141+
return this.getPresentation(SystemInfo.isMac ? StatusBarWidget.PlatformType.MAC : StatusBarWidget.PlatformType.DEFAULT);
142+
}
143+
144+
@Nullable
145+
public StatusBarWidget.WidgetPresentation getPresentation(@NotNull StatusBarWidget.PlatformType type) {
146+
return null;
147+
}
148+
136149

137150
}

src/main/java/com/shuzijun/leetcode/plugin/utils/MessageUtils.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,20 @@ public void showErrorMsg(String title, String body) {
6161
public static void showAllWarnMsg(String title, String body) {
6262
Notifications.Bus.notify(new Notification(Constant.NOTIFICATION_GROUP, title, body, NotificationType.WARNING));
6363
}
64+
65+
public String getComponentName() {
66+
return this.getClass().getName();
67+
}
68+
69+
public void initComponent() {
70+
}
71+
72+
public void disposeComponent() {
73+
}
74+
75+
public void projectOpened() {
76+
}
77+
78+
public void projectClosed() {
79+
}
6480
}

0 commit comments

Comments
 (0)