fix for some plugins
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
package io.zhile.research.intellij.ier.common;
|
||||
|
||||
import com.intellij.ide.plugins.IdeaPluginDescriptor;
|
||||
import com.intellij.ide.plugins.PluginManager;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
abstract public class PluginRecord implements EvalRecord {
|
||||
public void test(List<EvalRecord> list) {
|
||||
for (IdeaPluginDescriptor descriptor : PluginManager.getPlugins()) {
|
||||
if (descriptor.getName().equals(getName())) {
|
||||
list.add(this);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
abstract public String getName();
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "PLUGIN: " + getName();
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,7 @@ import io.zhile.research.intellij.ier.helper.AppHelper;
|
||||
import io.zhile.research.intellij.ier.helper.Constants;
|
||||
import io.zhile.research.intellij.ier.helper.NotificationHelper;
|
||||
import io.zhile.research.intellij.ier.helper.ReflectionHelper;
|
||||
import io.zhile.research.intellij.ier.plugins.MyBatisCodeHelper;
|
||||
import org.jdom.Attribute;
|
||||
import org.jdom.Element;
|
||||
|
||||
@@ -155,6 +156,8 @@ public class Resetter {
|
||||
}
|
||||
}
|
||||
|
||||
new MyBatisCodeHelper().test(list);
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
package io.zhile.research.intellij.ier.plugins;
|
||||
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.components.PersistentStateComponent;
|
||||
import io.zhile.research.intellij.ier.common.PluginRecord;
|
||||
import io.zhile.research.intellij.ier.helper.ReflectionHelper;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
public final class MyBatisCodeHelper extends PluginRecord {
|
||||
private static final String PLUGIN_NAME = "MyBatisCodeHelperPro (Marketplace Edition)";
|
||||
|
||||
@Override
|
||||
public void reset() throws Exception {
|
||||
PersistentStateComponent component = (PersistentStateComponent) ApplicationManager.getApplication().getComponent("MyBatisCodeHelper");
|
||||
if (null == component) {
|
||||
return;
|
||||
}
|
||||
|
||||
Object state = component.getState();
|
||||
if (null == state) {
|
||||
return;
|
||||
}
|
||||
|
||||
Method method = ReflectionHelper.getMethod(state.getClass(), "getProfile");
|
||||
if (null == method) {
|
||||
return;
|
||||
}
|
||||
|
||||
Object profile = method.invoke(state);
|
||||
method = ReflectionHelper.getMethod(profile.getClass(), "setValid", boolean.class);
|
||||
if (null != method) {
|
||||
method.invoke(profile, true);
|
||||
}
|
||||
|
||||
method = ReflectionHelper.getMethod(profile.getClass(), "setTheUsageCount", String.class);
|
||||
if (null != method) {
|
||||
method.invoke(profile, "-1");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return PLUGIN_NAME;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user