fix for some plugins
This commit is contained in:
		
							parent
							
								
									497ffe9660
								
							
						
					
					
						commit
						d28b716475
					
				| 
						 | 
				
			
			@ -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.3.0-064755.zip).
 | 
			
		||||
1. Download and install plugin from [Download Link](https://plugins.zhile.io/files/ide-eval-resetter-2.3.1-6b4c51.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.3.0'
 | 
			
		||||
version '2.3.1'
 | 
			
		||||
 | 
			
		||||
sourceCompatibility = 1.7
 | 
			
		||||
targetCompatibility = 1.7
 | 
			
		||||
| 
						 | 
				
			
			@ -29,6 +29,8 @@ intellij {
 | 
			
		|||
 | 
			
		||||
patchPluginXml {
 | 
			
		||||
    changeNotes = """<pre>
 | 
			
		||||
Release v2.3.1
 | 
			
		||||
  1. fix for some plugins
 | 
			
		||||
Release v2.3.0
 | 
			
		||||
  1. fix for 2021.2.3
 | 
			
		||||
Release v2.2.4
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user