Summary of some exceptions encountered in Eclipse plug-in development

Source: Internet
Author: User

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.