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
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:
* Add "Custom Plugin Repository": `https://plugins.zhile.io` manually (`Settings/Preferences` -> `Plugins`)
* Search and install plugin: `IDE Eval Reset`

@ -4,7 +4,7 @@ plugins {
}
group 'io.zhile.research.intellij'
version '2.1.11'
version '2.1.12'
sourceCompatibility = 1.7
targetCompatibility = 1.7
@ -29,6 +29,8 @@ intellij {
patchPluginXml {
changeNotes """<pre>
Release v2.1.12
1. fix disable plugins
Release v2.1.11
1. fix for block list: https://plugins.jetbrains.com/files/brokenPlugins.json
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.listener.AppActivationListener;
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.ui.dialog.MainDialog;
import org.jetbrains.annotations.NotNull;
public class ResetAction extends AnAction implements DumbAware {
static {
BrokenPlugins.fix();
BrokenPluginsListener.getInstance().listen();
AppEventListener.getInstance().listen();
AppActivationListener.getInstance().listen();
try {
CustomProperties.checkAndUpdate();
CustomProperties.fix();
} catch (Exception e) {
NotificationHelper.showError(null, "Set broken plugins failed!");
//
}
CustomRepository.checkAndAdd(CustomRepository.DEFAULT_HOST);
}

@ -105,7 +105,7 @@ public class Resetter {
try {
List<String> prefsList = new ArrayList<>();
for (String name:Preferences.userRoot().node(DEFAULT_VENDOR).childrenNames()) {
for (String name : Preferences.userRoot().node(DEFAULT_VENDOR).childrenNames()) {
if (!name.toLowerCase().startsWith(Constants.IDE_NAME_LOWER)) {
continue;
}

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

@ -7,6 +7,7 @@ import com.intellij.openapi.project.Project;
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.helper.BrokenPlugins;
import io.zhile.research.intellij.ier.helper.ResetTimeHelper;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@ -62,6 +63,8 @@ public class AppEventListener implements AppLifecycleListener, Disposable {
}
public void appClosing() {
BrokenPlugins.fix();
if (!Resetter.isAutoReset()) {
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));
}
Disposer.dispose(BrokenPluginsListener.getInstance());
Disposer.dispose(AppActivationListener.getInstance());
Disposer.dispose(AppEventListener.getInstance());
MainToolWindowFactory.unregisterAll();

Loading…
Cancel
Save