Access to global objects in Eclipse plug-in development

Source: Internet
Author: User

Transferred from: http://blog.csdn.net/liaomin416100569/article/details/7165425

1. Get the system default shell
Shell shell = Platformui.getworkbench (). Getactiveworkbenchwindow (). Getshell ();
2. Get additional plug-in Activetor objects
Plugin p=platform.getplugin ("Org.liaomin.huqun.ftptool");
3. Get preferences for a plugin
String name=platform.getplugin ("plug-in ID"). getpluginpreferences (). getString ("Key value for preferences");
4. Get the root directory of the workspace
resourcesplugin.getworkspace (). Getroot ()
5. Get a ijavaproject
resourcesplugin.getworkspace (). Getroot (). Getproject ("project name")
6. Convert Iproject to Ijavaproject
Ijavaproject Create = Javacore.create (p);
7 Finding the corresponding resource by Path
Iworkspaceroot root = Resourcesplugin.getworkspace (). Getroot ();

Iresource resource = Root.findmember (new Path (Srcpath)),//srcpath similar to Linux/project name/directory/subdirectory

8 Restarting the Working space

Platformui.getworkbench (). restart ();

8 Finding a Perspective

Platformui.getworkbench (). Getperspectiveregistry (). Findperspectivewithid (Perspective image ID);

9 Getting Help information

Platformui.getworkbench (). Gethelpsystem ()

10 Convert JDT objects by ifile

Ijavaelement Create (IFile file): Creates the corresponding Java element from the file.
Ijavaelement Create (IFolder folder): Creates the corresponding Java element from the folder.
Ijavaproject Create (IProject project): Get IProject corresponding ijavaproject.
Ijavaelement Create (Iresource Resource): creates the corresponding Java element from the resource.
Ijavamodel Create (Iworkspaceroot root): Gets the corresponding Ijavamodel from the workspace root directory.
Iclassfile createclassfilefrom (IFile file): Creates the corresponding iclassfile from the file.
Icompilationunit createcompilationunitfrom (IFile file): Creates the corresponding icompilationunit from the file.

Getting global objects from Eclipse plug-in development

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.