fix issues
Signed-off-by: pengzhile <pengzhile@gmail.com>
This commit is contained in:
parent
8b0fec7281
commit
827c8583ab
|
@ -1,6 +1,6 @@
|
||||||
# Reset Your IDE Eval Information
|
# Reset Your IDE Eval Information
|
||||||
|
|
||||||
1. Download and install plugin from [Download Link](https://plugins.zhile.io/files/ide-eval-resetter-2.1.15-3ef56c82.zip).
|
1. Download and install plugin from [Download Link](https://plugins.zhile.io/files/ide-eval-resetter-2.2.0-16b45f7.zip).
|
||||||
* Alternative installation method:
|
* Alternative installation method:
|
||||||
* Add "Custom Plugin Repository": `https://plugins.zhile.io` manually (`Settings/Preferences` -> `Plugins`)
|
* Add "Custom Plugin Repository": `https://plugins.zhile.io` manually (`Settings/Preferences` -> `Plugins`)
|
||||||
* Search and install plugin: `IDE Eval Reset`
|
* Search and install plugin: `IDE Eval Reset`
|
||||||
|
|
|
@ -4,7 +4,7 @@ plugins {
|
||||||
}
|
}
|
||||||
|
|
||||||
group 'io.zhile.research.intellij'
|
group 'io.zhile.research.intellij'
|
||||||
version '2.1.15'
|
version '2.2.0'
|
||||||
|
|
||||||
sourceCompatibility = 1.7
|
sourceCompatibility = 1.7
|
||||||
targetCompatibility = 1.7
|
targetCompatibility = 1.7
|
||||||
|
@ -29,8 +29,11 @@ intellij {
|
||||||
|
|
||||||
patchPluginXml {
|
patchPluginXml {
|
||||||
changeNotes = """<pre>
|
changeNotes = """<pre>
|
||||||
|
Release v2.2.0
|
||||||
|
1. fix the issue: "Cannot create listener"
|
||||||
|
2. add support for: Android Studio
|
||||||
Release v2.1.15
|
Release v2.1.15
|
||||||
1. fix welcome screen menu for 2021.1
|
1. fix welcome screen menu for 2021.2
|
||||||
Release v2.1.14
|
Release v2.1.14
|
||||||
1. fix minor exceptions
|
1. fix minor exceptions
|
||||||
Release v2.1.13
|
Release v2.1.13
|
||||||
|
|
|
@ -12,25 +12,15 @@ import com.intellij.openapi.wm.ToolWindowAnchor;
|
||||||
import com.intellij.openapi.wm.ToolWindowEP;
|
import com.intellij.openapi.wm.ToolWindowEP;
|
||||||
import com.intellij.openapi.wm.ToolWindowManager;
|
import com.intellij.openapi.wm.ToolWindowManager;
|
||||||
import com.intellij.openapi.wm.ex.ToolWindowManagerEx;
|
import com.intellij.openapi.wm.ex.ToolWindowManagerEx;
|
||||||
import io.zhile.research.intellij.ier.helper.*;
|
import io.zhile.research.intellij.ier.helper.Constants;
|
||||||
import io.zhile.research.intellij.ier.listener.AppActivationListener;
|
import io.zhile.research.intellij.ier.helper.NotificationHelper;
|
||||||
import io.zhile.research.intellij.ier.listener.AppEventListener;
|
import io.zhile.research.intellij.ier.helper.PluginHelper;
|
||||||
import io.zhile.research.intellij.ier.listener.BrokenPluginsListener;
|
import io.zhile.research.intellij.ier.listener.ListenerConnector;
|
||||||
import io.zhile.research.intellij.ier.tw.MainToolWindowFactory;
|
import io.zhile.research.intellij.ier.tw.MainToolWindowFactory;
|
||||||
import io.zhile.research.intellij.ier.ui.dialog.MainDialog;
|
import io.zhile.research.intellij.ier.ui.dialog.MainDialog;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public class ResetAction extends AnAction implements DumbAware {
|
public class ResetAction extends AnAction implements DumbAware {
|
||||||
static {
|
|
||||||
CustomProperties.fix();
|
|
||||||
BrokenPlugins.fix();
|
|
||||||
BrokenPluginsListener.getInstance().listen();
|
|
||||||
|
|
||||||
AppEventListener.getInstance().listen();
|
|
||||||
AppActivationListener.getInstance().listen();
|
|
||||||
CustomRepository.checkAndAdd(CustomRepository.DEFAULT_HOST);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ResetAction() {
|
public ResetAction() {
|
||||||
super(Constants.ACTION_NAME, "Reset my IDE eval information", AllIcons.General.Reset);
|
super(Constants.ACTION_NAME, "Reset my IDE eval information", AllIcons.General.Reset);
|
||||||
|
|
||||||
|
@ -38,6 +28,8 @@ public class ResetAction extends AnAction implements DumbAware {
|
||||||
if ((optionsGroup instanceof DefaultActionGroup)) {
|
if ((optionsGroup instanceof DefaultActionGroup)) {
|
||||||
((DefaultActionGroup) optionsGroup).add(this);
|
((DefaultActionGroup) optionsGroup).add(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ListenerConnector.setup();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -1,17 +1,9 @@
|
||||||
package io.zhile.research.intellij.ier.helper;
|
package io.zhile.research.intellij.ier.helper;
|
||||||
|
|
||||||
import com.intellij.openapi.application.ApplicationManager;
|
import com.intellij.openapi.application.ApplicationManager;
|
||||||
import com.intellij.openapi.util.Disposer;
|
|
||||||
import io.zhile.research.intellij.ier.listener.AppActivationListener;
|
|
||||||
import io.zhile.research.intellij.ier.listener.AppEventListener;
|
|
||||||
import io.zhile.research.intellij.ier.listener.BrokenPluginsListener;
|
|
||||||
|
|
||||||
public class AppHelper {
|
public class AppHelper {
|
||||||
public static void restart() {
|
public static void restart() {
|
||||||
Disposer.dispose(BrokenPluginsListener.getInstance());
|
|
||||||
Disposer.dispose(AppActivationListener.getInstance());
|
|
||||||
Disposer.dispose(AppEventListener.getInstance());
|
|
||||||
|
|
||||||
ApplicationManager.getApplication().invokeLater(new Runnable() {
|
ApplicationManager.getApplication().invokeLater(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
|
|
@ -1,66 +1,28 @@
|
||||||
package io.zhile.research.intellij.ier.listener;
|
package io.zhile.research.intellij.ier.listener;
|
||||||
|
|
||||||
import com.intellij.notification.NotificationType;
|
import com.intellij.notification.NotificationType;
|
||||||
import com.intellij.openapi.Disposable;
|
|
||||||
import com.intellij.openapi.actionSystem.ActionManager;
|
import com.intellij.openapi.actionSystem.ActionManager;
|
||||||
import com.intellij.openapi.actionSystem.AnAction;
|
import com.intellij.openapi.actionSystem.AnAction;
|
||||||
import com.intellij.openapi.application.ApplicationActivationListener;
|
import com.intellij.openapi.application.ApplicationActivationListener;
|
||||||
import com.intellij.openapi.application.ApplicationManager;
|
|
||||||
import com.intellij.openapi.diagnostic.Logger;
|
|
||||||
import com.intellij.openapi.wm.IdeFrame;
|
import com.intellij.openapi.wm.IdeFrame;
|
||||||
import com.intellij.util.messages.MessageBusConnection;
|
|
||||||
import io.zhile.research.intellij.ier.common.Resetter;
|
import io.zhile.research.intellij.ier.common.Resetter;
|
||||||
|
import io.zhile.research.intellij.ier.helper.BrokenPlugins;
|
||||||
import io.zhile.research.intellij.ier.helper.Constants;
|
import io.zhile.research.intellij.ier.helper.Constants;
|
||||||
import io.zhile.research.intellij.ier.helper.NotificationHelper;
|
import io.zhile.research.intellij.ier.helper.NotificationHelper;
|
||||||
import io.zhile.research.intellij.ier.helper.ResetTimeHelper;
|
import io.zhile.research.intellij.ier.helper.ResetTimeHelper;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public class AppActivationListener implements ApplicationActivationListener, Disposable {
|
public class AppActivationListener implements ApplicationActivationListener {
|
||||||
private static final Logger LOG = Logger.getInstance(AppActivationListener.class);
|
private boolean tipped = false;
|
||||||
private static AppActivationListener instance;
|
|
||||||
private static MessageBusConnection connection;
|
|
||||||
|
|
||||||
protected AppActivationListener() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public synchronized static AppActivationListener getInstance() {
|
|
||||||
if (instance == null) {
|
|
||||||
instance = new AppActivationListener();
|
|
||||||
}
|
|
||||||
|
|
||||||
return instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
public synchronized void listen() {
|
|
||||||
if (connection != null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
connection = ApplicationManager.getApplication().getMessageBus().connect();
|
|
||||||
connection.subscribe(ApplicationActivationListener.TOPIC, this);
|
|
||||||
} catch (Exception e) {
|
|
||||||
LOG.warn("sub app activation failed.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public synchronized void stop() {
|
|
||||||
if (connection == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
connection.disconnect();
|
|
||||||
connection = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void applicationActivated(@NotNull IdeFrame ideFrame) {
|
public void applicationActivated(@NotNull IdeFrame ideFrame) {
|
||||||
if (!ResetTimeHelper.overResetPeriod()) {
|
BrokenPlugins.fix();
|
||||||
|
|
||||||
|
if (tipped || !ResetTimeHelper.overResetPeriod()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
stop();
|
tipped = true;
|
||||||
|
|
||||||
AnAction action = ActionManager.getInstance().getAction(Constants.RESET_ACTION_ID);
|
AnAction action = ActionManager.getInstance().getAction(Constants.RESET_ACTION_ID);
|
||||||
NotificationType type = NotificationType.INFORMATION;
|
NotificationType type = NotificationType.INFORMATION;
|
||||||
String message = "It has been a long time since the last reset!\nWould you like to reset it again?";
|
String message = "It has been a long time since the last reset!\nWould you like to reset it again?";
|
||||||
|
@ -79,10 +41,4 @@ public class AppActivationListener implements ApplicationActivationListener, Dis
|
||||||
public void delayedApplicationDeactivated(@NotNull IdeFrame ideFrame) {
|
public void delayedApplicationDeactivated(@NotNull IdeFrame ideFrame) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void dispose() {
|
|
||||||
stop();
|
|
||||||
instance = null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,57 +1,15 @@
|
||||||
package io.zhile.research.intellij.ier.listener;
|
package io.zhile.research.intellij.ier.listener;
|
||||||
|
|
||||||
import com.intellij.ide.AppLifecycleListener;
|
import com.intellij.ide.AppLifecycleListener;
|
||||||
import com.intellij.openapi.Disposable;
|
|
||||||
import com.intellij.openapi.application.ApplicationManager;
|
|
||||||
import com.intellij.openapi.diagnostic.Logger;
|
|
||||||
import com.intellij.openapi.project.Project;
|
import com.intellij.openapi.project.Project;
|
||||||
import com.intellij.openapi.util.Ref;
|
import com.intellij.openapi.util.Ref;
|
||||||
import com.intellij.util.messages.MessageBusConnection;
|
|
||||||
import io.zhile.research.intellij.ier.common.Resetter;
|
import io.zhile.research.intellij.ier.common.Resetter;
|
||||||
import io.zhile.research.intellij.ier.helper.BrokenPlugins;
|
import io.zhile.research.intellij.ier.helper.BrokenPlugins;
|
||||||
import io.zhile.research.intellij.ier.helper.ResetTimeHelper;
|
import io.zhile.research.intellij.ier.helper.ResetTimeHelper;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
public class AppEventListener implements AppLifecycleListener, Disposable {
|
public class AppEventListener implements AppLifecycleListener {
|
||||||
private static final Logger LOG = Logger.getInstance(AppEventListener.class);
|
|
||||||
private static AppEventListener instance;
|
|
||||||
private static MessageBusConnection connection;
|
|
||||||
|
|
||||||
protected AppEventListener() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public synchronized static AppEventListener getInstance() {
|
|
||||||
if (instance == null) {
|
|
||||||
instance = new AppEventListener();
|
|
||||||
}
|
|
||||||
|
|
||||||
return instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
public synchronized void listen() {
|
|
||||||
if (connection != null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
connection = ApplicationManager.getApplication().getMessageBus().connect();
|
|
||||||
connection.subscribe(AppLifecycleListener.TOPIC, this);
|
|
||||||
} catch (Exception e) {
|
|
||||||
LOG.warn("sub app lifecycle failed.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public synchronized void stop() {
|
|
||||||
if (connection == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
connection.disconnect();
|
|
||||||
connection = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void appFrameCreated(String[] commandLineArgs, @NotNull Ref<Boolean> willOpenProject) {
|
public void appFrameCreated(String[] commandLineArgs, @NotNull Ref<Boolean> willOpenProject) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -73,6 +31,7 @@ public class AppEventListener implements AppLifecycleListener, Disposable {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void appClosing() {
|
public void appClosing() {
|
||||||
|
ListenerConnector.dispose();
|
||||||
BrokenPlugins.fix();
|
BrokenPlugins.fix();
|
||||||
|
|
||||||
if (!Resetter.isAutoReset()) {
|
if (!Resetter.isAutoReset()) {
|
||||||
|
@ -82,10 +41,4 @@ public class AppEventListener implements AppLifecycleListener, Disposable {
|
||||||
Resetter.reset(Resetter.getEvalRecords());
|
Resetter.reset(Resetter.getEvalRecords());
|
||||||
ResetTimeHelper.resetLastResetTime();
|
ResetTimeHelper.resetLastResetTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void dispose() {
|
|
||||||
stop();
|
|
||||||
instance = null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,30 +1,20 @@
|
||||||
package io.zhile.research.intellij.ier.listener;
|
package io.zhile.research.intellij.ier.listener;
|
||||||
|
|
||||||
import com.intellij.ide.AppLifecycleListener;
|
import com.intellij.ide.AppLifecycleListener;
|
||||||
import com.intellij.openapi.Disposable;
|
|
||||||
import com.intellij.openapi.actionSystem.ActionManager;
|
import com.intellij.openapi.actionSystem.ActionManager;
|
||||||
import com.intellij.openapi.actionSystem.AnAction;
|
|
||||||
import com.intellij.openapi.project.Project;
|
import com.intellij.openapi.project.Project;
|
||||||
import com.intellij.openapi.util.Ref;
|
import com.intellij.openapi.util.Ref;
|
||||||
import io.zhile.research.intellij.ier.helper.Constants;
|
import io.zhile.research.intellij.ier.helper.Constants;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.lang.ref.WeakReference;
|
public class AppInitListener implements AppLifecycleListener {
|
||||||
|
|
||||||
public class AppInitListener implements AppLifecycleListener, Disposable {
|
|
||||||
private static final WeakReference<AnAction> ACTION = new WeakReference<>(ActionManager.getInstance().getAction(Constants.RESET_ACTION_ID));
|
|
||||||
|
|
||||||
protected AppInitListener() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public void appFrameCreated(String[] commandLineArgs, @NotNull Ref<Boolean> willOpenProject) {
|
public void appFrameCreated(String[] commandLineArgs, @NotNull Ref<Boolean> willOpenProject) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void appStarting(@Nullable Project projectFromCommandLine) {
|
public void appStarting(@Nullable Project projectFromCommandLine) {
|
||||||
|
ActionManager.getInstance().getAction(Constants.RESET_ACTION_ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void projectFrameClosed() {
|
public void projectFrameClosed() {
|
||||||
|
@ -42,9 +32,4 @@ public class AppInitListener implements AppLifecycleListener, Disposable {
|
||||||
public void appClosing() {
|
public void appClosing() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void dispose() {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,68 +0,0 @@
|
||||||
package io.zhile.research.intellij.ier.listener;
|
|
||||||
|
|
||||||
import com.intellij.openapi.Disposable;
|
|
||||||
import com.intellij.openapi.application.ApplicationActivationListener;
|
|
||||||
import com.intellij.openapi.application.ApplicationManager;
|
|
||||||
import com.intellij.openapi.diagnostic.Logger;
|
|
||||||
import com.intellij.openapi.wm.IdeFrame;
|
|
||||||
import com.intellij.util.messages.MessageBusConnection;
|
|
||||||
import io.zhile.research.intellij.ier.helper.BrokenPlugins;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
public class BrokenPluginsListener implements ApplicationActivationListener, Disposable {
|
|
||||||
private static final Logger LOG = Logger.getInstance(BrokenPluginsListener.class);
|
|
||||||
private static BrokenPluginsListener instance;
|
|
||||||
private static MessageBusConnection connection;
|
|
||||||
|
|
||||||
protected BrokenPluginsListener() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public synchronized static BrokenPluginsListener getInstance() {
|
|
||||||
if (instance == null) {
|
|
||||||
instance = new BrokenPluginsListener();
|
|
||||||
}
|
|
||||||
|
|
||||||
return instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
public synchronized void listen() {
|
|
||||||
if (connection != null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
connection = ApplicationManager.getApplication().getMessageBus().connect();
|
|
||||||
connection.subscribe(ApplicationActivationListener.TOPIC, this);
|
|
||||||
} catch (Exception e) {
|
|
||||||
LOG.warn("sub app activation failed.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public synchronized void stop() {
|
|
||||||
if (connection == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
connection.disconnect();
|
|
||||||
connection = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void applicationActivated(@NotNull IdeFrame ideFrame) {
|
|
||||||
BrokenPlugins.fix();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void applicationDeactivated(@NotNull IdeFrame ideFrame) {
|
|
||||||
applicationActivated(ideFrame);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void delayedApplicationDeactivated(@NotNull IdeFrame ideFrame) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void dispose() {
|
|
||||||
stop();
|
|
||||||
instance = null;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,37 @@
|
||||||
|
package io.zhile.research.intellij.ier.listener;
|
||||||
|
|
||||||
|
import com.intellij.ide.AppLifecycleListener;
|
||||||
|
import com.intellij.openapi.Disposable;
|
||||||
|
import com.intellij.openapi.application.ApplicationActivationListener;
|
||||||
|
import com.intellij.openapi.application.ApplicationManager;
|
||||||
|
import com.intellij.openapi.util.Disposer;
|
||||||
|
import com.intellij.util.messages.MessageBusConnection;
|
||||||
|
import io.zhile.research.intellij.ier.helper.BrokenPlugins;
|
||||||
|
import io.zhile.research.intellij.ier.helper.CustomProperties;
|
||||||
|
import io.zhile.research.intellij.ier.helper.CustomRepository;
|
||||||
|
|
||||||
|
public class ListenerConnector {
|
||||||
|
private static Disposable disposable;
|
||||||
|
|
||||||
|
public static void setup() {
|
||||||
|
dispose();
|
||||||
|
|
||||||
|
CustomProperties.fix();
|
||||||
|
BrokenPlugins.fix();
|
||||||
|
CustomRepository.checkAndAdd(CustomRepository.DEFAULT_HOST);
|
||||||
|
|
||||||
|
disposable = Disposer.newDisposable();
|
||||||
|
MessageBusConnection connection = ApplicationManager.getApplication().getMessageBus().connect(disposable);
|
||||||
|
connection.subscribe(AppLifecycleListener.TOPIC, new AppEventListener());
|
||||||
|
connection.subscribe(ApplicationActivationListener.TOPIC, new AppActivationListener());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void dispose() {
|
||||||
|
if (null == disposable || Disposer.isDisposed(disposable)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Disposer.dispose(disposable);
|
||||||
|
disposable = null;
|
||||||
|
}
|
||||||
|
}
|
|
@ -5,7 +5,6 @@ import com.intellij.ide.plugins.IdeaPluginDescriptor;
|
||||||
import com.intellij.openapi.actionSystem.ActionManager;
|
import com.intellij.openapi.actionSystem.ActionManager;
|
||||||
import com.intellij.openapi.actionSystem.AnAction;
|
import com.intellij.openapi.actionSystem.AnAction;
|
||||||
import com.intellij.openapi.actionSystem.DefaultActionGroup;
|
import com.intellij.openapi.actionSystem.DefaultActionGroup;
|
||||||
import com.intellij.openapi.util.Disposer;
|
|
||||||
import io.zhile.research.intellij.ier.helper.Constants;
|
import io.zhile.research.intellij.ier.helper.Constants;
|
||||||
import io.zhile.research.intellij.ier.helper.NotificationHelper;
|
import io.zhile.research.intellij.ier.helper.NotificationHelper;
|
||||||
import io.zhile.research.intellij.ier.helper.PluginHelper;
|
import io.zhile.research.intellij.ier.helper.PluginHelper;
|
||||||
|
@ -34,9 +33,7 @@ public class PluginListener implements DynamicPluginListener {
|
||||||
((DefaultActionGroup) optionsGroup).remove(ActionManager.getInstance().getAction(Constants.RESET_ACTION_ID));
|
((DefaultActionGroup) optionsGroup).remove(ActionManager.getInstance().getAction(Constants.RESET_ACTION_ID));
|
||||||
}
|
}
|
||||||
|
|
||||||
Disposer.dispose(BrokenPluginsListener.getInstance());
|
ListenerConnector.dispose();
|
||||||
Disposer.dispose(AppActivationListener.getInstance());
|
|
||||||
Disposer.dispose(AppEventListener.getInstance());
|
|
||||||
MainToolWindowFactory.unregisterAll();
|
MainToolWindowFactory.unregisterAll();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
package io.zhile.research.intellij.ier.tw;
|
package io.zhile.research.intellij.ier.tw;
|
||||||
|
|
||||||
|
import com.intellij.openapi.Disposable;
|
||||||
import com.intellij.openapi.project.DumbAware;
|
import com.intellij.openapi.project.DumbAware;
|
||||||
import com.intellij.openapi.project.Project;
|
import com.intellij.openapi.project.Project;
|
||||||
import com.intellij.openapi.project.ProjectManager;
|
import com.intellij.openapi.project.ProjectManager;
|
||||||
|
import com.intellij.openapi.util.Disposer;
|
||||||
import com.intellij.openapi.wm.ToolWindow;
|
import com.intellij.openapi.wm.ToolWindow;
|
||||||
import com.intellij.openapi.wm.ToolWindowFactory;
|
import com.intellij.openapi.wm.ToolWindowFactory;
|
||||||
import com.intellij.openapi.wm.ToolWindowManager;
|
import com.intellij.openapi.wm.ToolWindowManager;
|
||||||
|
@ -15,9 +17,11 @@ import org.jetbrains.annotations.NotNull;
|
||||||
public class MainToolWindowFactory implements ToolWindowFactory, DumbAware {
|
public class MainToolWindowFactory implements ToolWindowFactory, DumbAware {
|
||||||
@Override
|
@Override
|
||||||
public void createToolWindowContent(@NotNull Project project, @NotNull ToolWindow toolWindow) {
|
public void createToolWindowContent(@NotNull Project project, @NotNull ToolWindow toolWindow) {
|
||||||
MainForm mainForm = new MainForm(null);
|
Disposable disposable = Disposer.newDisposable();
|
||||||
Content content = ContentFactory.SERVICE.getInstance().createContent(mainForm.getContent(), "", true);
|
|
||||||
content.setDisposer(mainForm);
|
MainForm mainForm = new MainForm(disposable);
|
||||||
|
Content content = ContentFactory.SERVICE.getInstance().createContent(mainForm.getContent(disposable), "", true);
|
||||||
|
content.setDisposer(disposable);
|
||||||
toolWindow.getContentManager().addContent(content);
|
toolWindow.getContentManager().addContent(content);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,8 +14,9 @@ public class MainDialog extends DialogWrapper {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected JComponent createCenterPanel() {
|
protected JComponent createCenterPanel() {
|
||||||
MainForm mainForm = new MainForm(this);
|
MainForm mainForm = new MainForm(getDisposable(), this);
|
||||||
return mainForm.getContent();
|
|
||||||
|
return mainForm.getContent(getDisposable());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -17,10 +17,10 @@ import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class MainForm implements Disposable {
|
public class MainForm {
|
||||||
private JPanel rootPanel;
|
private JPanel rootPanel;
|
||||||
private JButton btnReset;
|
private JButton btnReset;
|
||||||
private JList lstMain;
|
private JList<String> lstMain;
|
||||||
private JLabel lblLastResetTime;
|
private JLabel lblLastResetTime;
|
||||||
private JButton btnReload;
|
private JButton btnReload;
|
||||||
private JLabel lblFound;
|
private JLabel lblFound;
|
||||||
|
@ -28,17 +28,35 @@ public class MainForm implements Disposable {
|
||||||
private JCheckBox chkResetAuto;
|
private JCheckBox chkResetAuto;
|
||||||
private JLabel lblVersion;
|
private JLabel lblVersion;
|
||||||
|
|
||||||
private final DialogWrapper dialogWrapper;
|
private DialogWrapper dialogWrapper;
|
||||||
private final DefaultListModel<String> listModel = new DefaultListModel<>();
|
private DefaultListModel<String> listModel = new DefaultListModel<>();
|
||||||
|
|
||||||
public MainForm(DialogWrapper dialogWrapper) {
|
public MainForm(Disposable disposable) {
|
||||||
this.dialogWrapper = dialogWrapper;
|
this(disposable, null);
|
||||||
if (dialogWrapper != null) {
|
|
||||||
Disposer.register(dialogWrapper.getDisposable(), this);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public JPanel getContent() {
|
public MainForm(Disposable disposable, DialogWrapper wrapper) {
|
||||||
|
this.dialogWrapper = wrapper;
|
||||||
|
|
||||||
|
Disposer.register(disposable, new Disposable() {
|
||||||
|
@Override
|
||||||
|
public void dispose() {
|
||||||
|
rootPanel.removeAll();
|
||||||
|
|
||||||
|
listModel = null;
|
||||||
|
dialogWrapper = null;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public JPanel getContent(Disposable disposable) {
|
||||||
|
Disposer.register(disposable, new Disposable() {
|
||||||
|
@Override
|
||||||
|
public void dispose() {
|
||||||
|
rootPanel.removeAll();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
boldFont(lblFound);
|
boldFont(lblFound);
|
||||||
boldFont(lblLastResetTimeLabel);
|
boldFont(lblLastResetTimeLabel);
|
||||||
reloadLastResetTime();
|
reloadLastResetTime();
|
||||||
|
@ -46,38 +64,38 @@ public class MainForm implements Disposable {
|
||||||
lblVersion.setText("v" + PluginHelper.getPluginVersion());
|
lblVersion.setText("v" + PluginHelper.getPluginVersion());
|
||||||
|
|
||||||
chkResetAuto.setSelected(Resetter.isAutoReset());
|
chkResetAuto.setSelected(Resetter.isAutoReset());
|
||||||
chkResetAuto.addActionListener(new AbstractAction() {
|
addActionEventListener(chkResetAuto, new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
Resetter.setAutoReset(chkResetAuto.isSelected());
|
Resetter.setAutoReset(chkResetAuto.isSelected());
|
||||||
}
|
}
|
||||||
});
|
}, disposable);
|
||||||
|
|
||||||
lstMain.setModel(listModel);
|
lstMain.setModel(listModel);
|
||||||
reloadRecordItems();
|
reloadRecordItems();
|
||||||
|
|
||||||
btnReload.setIcon(AllIcons.Actions.Refresh);
|
btnReload.setIcon(AllIcons.Actions.Refresh);
|
||||||
btnReload.addActionListener(new AbstractAction() {
|
addActionEventListener(btnReload, new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
reloadLastResetTime();
|
reloadLastResetTime();
|
||||||
reloadRecordItems();
|
reloadRecordItems();
|
||||||
}
|
}
|
||||||
});
|
}, disposable);
|
||||||
|
|
||||||
btnReset.setIcon(AllIcons.General.Reset);
|
btnReset.setIcon(AllIcons.General.Reset);
|
||||||
btnReset.addActionListener(new AbstractAction() {
|
addActionEventListener(btnReset, new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
resetEvalItems();
|
resetEvalItems();
|
||||||
}
|
}
|
||||||
});
|
}, disposable);
|
||||||
|
|
||||||
if (null != dialogWrapper) {
|
if (null != dialogWrapper) {
|
||||||
dialogWrapper.getRootPane().setDefaultButton(btnReset);
|
dialogWrapper.getRootPane().setDefaultButton(btnReset);
|
||||||
|
rootPanel.setMinimumSize(new Dimension(600, 240));
|
||||||
}
|
}
|
||||||
|
|
||||||
rootPanel.setMinimumSize(new Dimension(600, 240));
|
|
||||||
return rootPanel;
|
return rootPanel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -115,14 +133,13 @@ public class MainForm implements Disposable {
|
||||||
component.setFont(font.deriveFont(font.getStyle() | Font.BOLD));
|
component.setFont(font.deriveFont(font.getStyle() | Font.BOLD));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void addActionEventListener(final AbstractButton button, final ActionListener listener, Disposable disposable) {
|
||||||
|
button.addActionListener(listener);
|
||||||
|
Disposer.register(disposable, new Disposable() {
|
||||||
@Override
|
@Override
|
||||||
public void dispose() {
|
public void dispose() {
|
||||||
for (AbstractButton button : new AbstractButton[]{chkResetAuto, btnReload, btnReset}) {
|
|
||||||
for (ActionListener listener : button.getActionListeners()) {
|
|
||||||
button.removeActionListener(listener);
|
button.removeActionListener(listener);
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
|
|
||||||
rootPanel.removeAll();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,8 +11,6 @@
|
||||||
</p>
|
</p>
|
||||||
]]></description>
|
]]></description>
|
||||||
|
|
||||||
<depends>com.intellij.modules.ultimate</depends>
|
|
||||||
|
|
||||||
<actions>
|
<actions>
|
||||||
<action class="io.zhile.research.intellij.ier.action.ResetAction"
|
<action class="io.zhile.research.intellij.ier.action.ResetAction"
|
||||||
id="io.zhile.research.intellij.ier.action.ResetAction">
|
id="io.zhile.research.intellij.ier.action.ResetAction">
|
||||||
|
|
Loading…
Reference in New Issue
Block a user