Eclipse plug-in development involves a wide range of aspects, and sometimes there are many strange errors. The following are some solutions after some special exceptions I encountered in Eclipse plug-in development, these are some searched from the Internet, some are their own summary. This article will be updated as my accumulation, and I hope to help some coder who encounter the same problem!
1. "org. Eclipse. UI. partinitexception: Unable to open Editor, unknown editor ID: package. Class" SOLUTION
Error cause: the <extension> label in plugin. XML does not contain an icon.
<Extension
Point = "org. Eclipse. UI. Editors">
<Editor
Class = "testrcp. testeditor"
Id = "testrcp. testeditor"
Name = "New editorpart">
</Editor>
</Extension>
Solution: Add <extension> icon in plugin. XML, which can be empty.
<Extension
Point = "org. Eclipse. UI. Editors">
<Editor
Class = "testrcp. testeditor"
Icon = ""
Id = "testrcp. testeditor"
Name = "New editorpart">
</Editor>
</Extension>
2. "org. Eclipse. UI. partinitexception: Editor initialization failed: package. Class. Site is incorrect." Processing Method
Error cause: the init () of the editorpart class is not implemented.
Solution: Implement Init () as follows:
Public void Init (ieditorsite site, ieditorinput input)
Throws partinitexception {
System. Out. println (input. tostring ());
This. setinput (input );
This. setsite (SITE );
}
3. "org. Eclipse. Core. runtime. assertionfailedexception: NULL argument: A part's title tool tip must be non-null" Processing Method
Error cause: the gettooltiptext () returned value of the editorinput class is null.
Solution: override the return value of the gettooltiptext () method to "" or any character type.
Public String gettooltiptext (){
Return "";
}
4. Handling of file resources not synchronized
Many times we are developing eclipseProgramIf ifile is not used for file operations, Java is used. io. file, or through a third-party program to modify file resources, the actual file and ifile will not be synchronized, because of performance problems, ifile information is cached, therefore, to operate files, you should first consider using the methods provided by ifile or some tool classes provided by eclipse. But we don't always ensure that file operations are what we think. How can we determine whether an ifile is synchronized with the file system?
Solution: Compare the timestamp of the ifile object and the java. Io. File object. If they are different, refresh the ifile object.
If (ifile. getlocaltimestamp ()! = File. lastmodified ()){
Ifile. refreshlocal (INT depth, iprogressmonitor Monitor );
}
5. How to deal with "org. Eclipse. SWT. swtexception: subclassing not allowed" in extended SWT Widgets
Cause of error: eclipse has the following sentence: "Custom widgets are created by subclassing in the existing widget class hierarchy", which means that the extended widgets class must be at the same level as the widgets class.
Solution: there are two types. The first is to change the package of your extended class to package org. Eclipse. SWT. widgets, that is, the widgets class is at the same class level;
The second extension class overrides the protected void checksubclass () method in the widgets class for class level check, and the short implementation is enough.