Skip to content

compatibility #112

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
package com.shuzijun.leetcode.plugin.listener;

import com.intellij.ide.plugins.IdeaPluginDescriptor;
import com.intellij.ide.plugins.PluginInstaller;
import com.intellij.ide.plugins.PluginStateListener;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.startup.StartupActivity;
import org.jetbrains.annotations.NotNull;
Expand All @@ -13,7 +10,7 @@
public class RegisterPluginInstallerStateListener implements StartupActivity {
@Override
public void runActivity(@NotNull Project project) {
PluginInstaller.addStateListener(new PluginStateListener() {
/* PluginInstaller.addStateListener(new PluginStateListener() {
@Override
public void install(@NotNull IdeaPluginDescriptor ideaPluginDescriptor) {
}
Expand All @@ -22,6 +19,6 @@ public void install(@NotNull IdeaPluginDescriptor ideaPluginDescriptor) {
public void uninstall(@NotNull IdeaPluginDescriptor ideaPluginDescriptor) {
System.out.println("uninstall");
}
});
});*/
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.shuzijun.leetcode.plugin.setting;

import com.intellij.ide.passwordSafe.PasswordSafe;
import com.intellij.ide.passwordSafe.PasswordSafeException;
import com.intellij.openapi.components.*;
import com.intellij.util.xmlb.XmlSerializerUtil;
import com.shuzijun.leetcode.plugin.model.Config;
Expand Down Expand Up @@ -66,12 +67,23 @@ public String getTempFilePath() {
}

public void savePassword(String password) {
PasswordSafe.getInstance().storePassword(null, this.getClass(), "leetcode-editor", password != null ? password : "");
try {
PasswordSafe.getInstance().storePassword
(null, this.getClass(), "leetcode-editor", password != null ? password : "");
} catch (PasswordSafeException exception) {
MessageUtils.showAllWarnMsg("warning", "Failed to save password");
}
}

public String getPassword() {
if (getConfig().getVersion() != null) {
return PasswordSafe.getInstance().getPassword(null, this.getClass(), "leetcode-editor");
try {
return PasswordSafe.getInstance().getPassword(null, this.getClass(), "leetcode-editor");
} catch (PasswordSafeException exception) {
MessageUtils.showAllWarnMsg("warning", "Password acquisition failed");
return null;
}

} else {
return getInitConfig().getPassword();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,20 @@ public static class InnerState {
projectConfig = new HashMap<>();
}
}

public String getComponentName() {
return this.getClass().getName();
}

public void initComponent() {
}

public void disposeComponent() {
}

public void projectOpened() {
}

public void projectClosed() {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ public void mouseClicked(MouseEvent e) {
LevelColourField.setText(config.getLevelColour());
englishContentBox.setSelected(config.getEnglishContent());
} else {
LevelColourField.setText(config.getLevelColour());
LevelColourField.setText(new Config().getLevelColour());
ApplicationManager.getApplication().runWriteAction(() -> {
fileNameEditor.getDocument().setText(Constant.CUSTOM_FILE_NAME);
templateEditor.getDocument().setText(Constant.CUSTOM_TEMPLATE);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
package com.shuzijun.leetcode.plugin.timer;

import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.SystemInfo;
import com.intellij.openapi.wm.CustomStatusBarWidget;
import com.intellij.openapi.wm.StatusBar;
import com.intellij.openapi.wm.StatusBarWidget;
import com.shuzijun.leetcode.plugin.model.Config;
import com.shuzijun.leetcode.plugin.setting.PersistentConfig;
import org.apache.commons.lang.StringUtils;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import javax.swing.*;
import java.awt.*;
Expand Down Expand Up @@ -133,5 +136,15 @@ public void reset() {
label.setVisible(false);
}

@Nullable
public StatusBarWidget.WidgetPresentation getPresentation() {
return this.getPresentation(SystemInfo.isMac ? StatusBarWidget.PlatformType.MAC : StatusBarWidget.PlatformType.DEFAULT);
}

@Nullable
public StatusBarWidget.WidgetPresentation getPresentation(@NotNull StatusBarWidget.PlatformType type) {
return null;
}


}
16 changes: 16 additions & 0 deletions src/main/java/com/shuzijun/leetcode/plugin/utils/MessageUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,20 @@ public void showErrorMsg(String title, String body) {
public static void showAllWarnMsg(String title, String body) {
Notifications.Bus.notify(new Notification(Constant.NOTIFICATION_GROUP, title, body, NotificationType.WARNING));
}

public String getComponentName() {
return this.getClass().getName();
}

public void initComponent() {
}

public void disposeComponent() {
}

public void projectOpened() {
}

public void projectClosed() {
}
}