fix disable plugins

Signed-off-by: pengzhile <pengzhile@gmail.com>
pull/8/head
pengzhile 4 years ago
parent dee34a27f9
commit f145eac269

@ -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.11.zip). 1. Download and install plugin from [Download Link](https://plugins.zhile.io/files/ide-eval-resetter-2.1.12.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.11' version '2.1.12'
sourceCompatibility = 1.7 sourceCompatibility = 1.7
targetCompatibility = 1.7 targetCompatibility = 1.7
@ -29,6 +29,8 @@ intellij {
patchPluginXml { patchPluginXml {
changeNotes """<pre> changeNotes """<pre>
Release v2.1.12
1. fix disable plugins
Release v2.1.11 Release v2.1.11
1. fix for block list: https://plugins.jetbrains.com/files/brokenPlugins.json 1. fix for block list: https://plugins.jetbrains.com/files/brokenPlugins.json
Release v2.1.10 Release v2.1.10

@ -15,18 +15,22 @@ import com.intellij.openapi.wm.ex.ToolWindowManagerEx;
import io.zhile.research.intellij.ier.helper.*; import io.zhile.research.intellij.ier.helper.*;
import io.zhile.research.intellij.ier.listener.AppActivationListener; import io.zhile.research.intellij.ier.listener.AppActivationListener;
import io.zhile.research.intellij.ier.listener.AppEventListener; import io.zhile.research.intellij.ier.listener.AppEventListener;
import io.zhile.research.intellij.ier.listener.BrokenPluginsListener;
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 { static {
BrokenPlugins.fix();
BrokenPluginsListener.getInstance().listen();
AppEventListener.getInstance().listen(); AppEventListener.getInstance().listen();
AppActivationListener.getInstance().listen(); AppActivationListener.getInstance().listen();
try { try {
CustomProperties.checkAndUpdate(); CustomProperties.fix();
} catch (Exception e) { } catch (Exception e) {
NotificationHelper.showError(null, "Set broken plugins failed!"); //
} }
CustomRepository.checkAndAdd(CustomRepository.DEFAULT_HOST); CustomRepository.checkAndAdd(CustomRepository.DEFAULT_HOST);
} }

@ -4,9 +4,11 @@ import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.util.Disposer; import com.intellij.openapi.util.Disposer;
import io.zhile.research.intellij.ier.listener.AppActivationListener; import io.zhile.research.intellij.ier.listener.AppActivationListener;
import io.zhile.research.intellij.ier.listener.AppEventListener; 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(AppActivationListener.getInstance());
Disposer.dispose(AppEventListener.getInstance()); Disposer.dispose(AppEventListener.getInstance());

@ -0,0 +1,30 @@
package io.zhile.research.intellij.ier.helper;
import com.intellij.openapi.application.PathManager;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardCopyOption;
public class BrokenPlugins {
public static void fix() {
String content = "[]";
String fileName = "brokenPlugins.json";
Path brokenPluginsPath = Paths.get(PathManager.getPluginsPath(), fileName);
File brokenPluginsFile = brokenPluginsPath.toFile();
if (!brokenPluginsFile.exists() || content.length() == brokenPluginsFile.length()) {
return;
}
try {
Path bak = brokenPluginsPath.getParent().resolve(fileName + ".tmp");
Files.write(bak, content.getBytes());
Files.move(bak, brokenPluginsPath, StandardCopyOption.REPLACE_EXISTING, StandardCopyOption.ATOMIC_MOVE);
} catch (IOException e) {
NotificationHelper.showError(null, "Set broken plugins failed!");
}
}
}

@ -13,9 +13,9 @@ import java.util.List;
import java.util.Properties; import java.util.Properties;
public class CustomProperties { public class CustomProperties {
public static void checkAndUpdate() throws Exception { public static void fix() throws Exception {
String key = "idea.ignore.disabled.plugins", value = "true"; String key = "idea.ignore.disabled.plugins";
System.setProperty(key, value); System.clearProperty(key);
List<Path> paths = new ArrayList<>(); List<Path> paths = new ArrayList<>();
paths.add(Paths.get(SystemProperties.getUserHome(), PathManager.PROPERTIES_FILE_NAME)); paths.add(Paths.get(SystemProperties.getUserHome(), PathManager.PROPERTIES_FILE_NAME));
@ -28,7 +28,7 @@ public class CustomProperties {
for (Path path : paths) { for (Path path : paths) {
File file = path.toFile(); File file = path.toFile();
if (!file.exists()) { if (!file.exists()) {
new FileOutputStream(file).close(); continue;
} }
Properties props = new Properties(); Properties props = new Properties();
@ -36,7 +36,12 @@ public class CustomProperties {
props.load(fis); props.load(fis);
} }
props.setProperty(key, value); props.remove(key);
if (props.isEmpty()) {
file.delete();
continue;
}
try (FileOutputStream fos = new FileOutputStream(file)) { try (FileOutputStream fos = new FileOutputStream(file)) {
props.store(fos, null); props.store(fos, null);

@ -7,6 +7,7 @@ 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 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.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;
@ -62,6 +63,8 @@ public class AppEventListener implements AppLifecycleListener, Disposable {
} }
public void appClosing() { public void appClosing() {
BrokenPlugins.fix();
if (!Resetter.isAutoReset()) { if (!Resetter.isAutoReset()) {
return; return;
} }

@ -0,0 +1,58 @@
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.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 BrokenPluginsListener instance = new BrokenPluginsListener();
private static MessageBusConnection connection;
protected BrokenPluginsListener() {
}
public static BrokenPluginsListener getInstance() {
return instance;
}
public synchronized void listen() {
if (connection != null) {
return;
}
connection = ApplicationManager.getApplication().getMessageBus().connect();
connection.subscribe(ApplicationActivationListener.TOPIC, this);
}
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;
}
}

@ -34,6 +34,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());
Disposer.dispose(AppActivationListener.getInstance()); Disposer.dispose(AppActivationListener.getInstance());
Disposer.dispose(AppEventListener.getInstance()); Disposer.dispose(AppEventListener.getInstance());
MainToolWindowFactory.unregisterAll(); MainToolWindowFactory.unregisterAll();

Loading…
Cancel
Save