fix error notification
Signed-off-by: pengzhile <pengzhile@gmail.com>
This commit is contained in:
parent
f145eac269
commit
2225971c59
|
@ -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.12.zip).
|
1. Download and install plugin from [Download Link](https://plugins.zhile.io/files/ide-eval-resetter-2.1.13.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`
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
plugins {
|
plugins {
|
||||||
id 'java'
|
id 'java'
|
||||||
id 'org.jetbrains.intellij' version '0.5.0'
|
id 'org.jetbrains.intellij' version '0.6.5'
|
||||||
}
|
}
|
||||||
|
|
||||||
group 'io.zhile.research.intellij'
|
group 'io.zhile.research.intellij'
|
||||||
version '2.1.12'
|
version '2.1.13'
|
||||||
|
|
||||||
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.13
|
||||||
|
1. fix error notification
|
||||||
Release v2.1.12
|
Release v2.1.12
|
||||||
1. fix disable plugins
|
1. fix disable plugins
|
||||||
Release v2.1.11
|
Release v2.1.11
|
||||||
|
|
|
@ -22,16 +22,12 @@ import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public class ResetAction extends AnAction implements DumbAware {
|
public class ResetAction extends AnAction implements DumbAware {
|
||||||
static {
|
static {
|
||||||
|
CustomProperties.fix();
|
||||||
BrokenPlugins.fix();
|
BrokenPlugins.fix();
|
||||||
BrokenPluginsListener.getInstance().listen();
|
BrokenPluginsListener.getInstance().listen();
|
||||||
|
|
||||||
AppEventListener.getInstance().listen();
|
AppEventListener.getInstance().listen();
|
||||||
AppActivationListener.getInstance().listen();
|
AppActivationListener.getInstance().listen();
|
||||||
try {
|
|
||||||
CustomProperties.fix();
|
|
||||||
} catch (Exception e) {
|
|
||||||
//
|
|
||||||
}
|
|
||||||
CustomRepository.checkAndAdd(CustomRepository.DEFAULT_HOST);
|
CustomRepository.checkAndAdd(CustomRepository.DEFAULT_HOST);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,15 +1,17 @@
|
||||||
package io.zhile.research.intellij.ier.helper;
|
package io.zhile.research.intellij.ier.helper;
|
||||||
|
|
||||||
import com.intellij.openapi.application.PathManager;
|
import com.intellij.openapi.application.PathManager;
|
||||||
|
import com.intellij.openapi.diagnostic.Logger;
|
||||||
|
import com.intellij.openapi.util.io.FileUtil;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.file.Files;
|
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
import java.nio.file.StandardCopyOption;
|
|
||||||
|
|
||||||
public class BrokenPlugins {
|
public class BrokenPlugins {
|
||||||
|
private static final Logger LOG = Logger.getInstance(BrokenPlugins.class);
|
||||||
|
|
||||||
public static void fix() {
|
public static void fix() {
|
||||||
String content = "[]";
|
String content = "[]";
|
||||||
String fileName = "brokenPlugins.json";
|
String fileName = "brokenPlugins.json";
|
||||||
|
@ -19,12 +21,17 @@ public class BrokenPlugins {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
File tmp = null;
|
||||||
try {
|
try {
|
||||||
Path bak = brokenPluginsPath.getParent().resolve(fileName + ".tmp");
|
tmp = File.createTempFile(fileName, null);
|
||||||
Files.write(bak, content.getBytes());
|
FileUtil.writeToFile(tmp, content);
|
||||||
Files.move(bak, brokenPluginsPath, StandardCopyOption.REPLACE_EXISTING, StandardCopyOption.ATOMIC_MOVE);
|
FileUtil.copy(tmp, brokenPluginsFile);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
NotificationHelper.showError(null, "Set broken plugins failed!");
|
LOG.warn("Set broken plugins failed", e);
|
||||||
|
} finally {
|
||||||
|
if (null != tmp) {
|
||||||
|
FileUtil.delete(tmp);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,51 +1,8 @@
|
||||||
package io.zhile.research.intellij.ier.helper;
|
package io.zhile.research.intellij.ier.helper;
|
||||||
|
|
||||||
import com.intellij.openapi.application.PathManager;
|
|
||||||
import com.intellij.util.SystemProperties;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileInputStream;
|
|
||||||
import java.io.FileOutputStream;
|
|
||||||
import java.nio.file.Path;
|
|
||||||
import java.nio.file.Paths;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Properties;
|
|
||||||
|
|
||||||
public class CustomProperties {
|
public class CustomProperties {
|
||||||
public static void fix() throws Exception {
|
public static void fix() {
|
||||||
String key = "idea.ignore.disabled.plugins";
|
String key = "idea.ignore.disabled.plugins";
|
||||||
System.clearProperty(key);
|
System.clearProperty(key);
|
||||||
|
|
||||||
List<Path> paths = new ArrayList<>();
|
|
||||||
paths.add(Paths.get(SystemProperties.getUserHome(), PathManager.PROPERTIES_FILE_NAME));
|
|
||||||
|
|
||||||
String customOptionsDir = PathManager.getCustomOptionsDirectory();
|
|
||||||
if (null != customOptionsDir) {
|
|
||||||
paths.add(Paths.get(customOptionsDir, PathManager.PROPERTIES_FILE_NAME));
|
|
||||||
}
|
|
||||||
|
|
||||||
for (Path path : paths) {
|
|
||||||
File file = path.toFile();
|
|
||||||
if (!file.exists()) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
Properties props = new Properties();
|
|
||||||
try (FileInputStream fis = new FileInputStream(file)) {
|
|
||||||
props.load(fis);
|
|
||||||
}
|
|
||||||
|
|
||||||
props.remove(key);
|
|
||||||
|
|
||||||
if (props.isEmpty()) {
|
|
||||||
file.delete();
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
try (FileOutputStream fos = new FileOutputStream(file)) {
|
|
||||||
props.store(fos, null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user