[Go to]eclipse plug-in development to get the current path

Source: Internet
Author: User

  Normal 0 7.8 lbs 0 2 false false MicrosoftInternetExplorer4

<!--/* Font definitions */@font-face {font-family: Arial; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-alt:simsun; mso-font-ch arset:134; Mso-generic-font-family:auto; mso-font-pitch:variable; Mso-font-signature:3 135135232 16 0 262145 0;} @font-face {font-family: "/@"; Panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-charset:134; mso-generic-font-family:auto; mso-font -pitch:variable; Mso-font-signature:3 135135232 16 0 262145 0;} /* Style Definitions */P.msonormal, Li. MsoNormal, Div. MsoNormal {mso-style-parent: ""; margin:0cm; margin-bottom:.0001pt; text-align:justify; Text-justify:inter-ideograph; Mso-pagination:none; font-size:10.5pt; mso-bidi-font-size:12.0pt; Font-family: "Times New Roman"; Mso-fareast-font-family: Song body; mso-font-kerning:1.0pt;} /* Page Definitions */@page {mso-page-border-surround-header:no; mso-page-border-surround-footer:no;} @page Section1 { Size:595.3pt 841.9pt; margin:72.0pt 90.0pt 72.0pt 90.0pt; mso-header-margin:42.55pt; mso-footer-margin:49.6pt; mso-paper-source:0; layout-grid:15.6pt;} Div. Section1 {page:section1;}-/* Style definitions */table. msonormaltable {mso-style-name: general form; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; Mso-style-parent: ""; mso-padding-alt:0cm 5.4pt 0cm 5.4pt; mso-para-margin:0cm; mso-para-margin-bottom:.0001pt; Mso-pagination:widow-orphan; font-size:10.0pt; Font-family: "Times New Roman"; Mso-fareast-font-family: "Times New Roman"; Mso-ansi-language: #0400; Mso-fareast-language: #0400; Mso-bidi-language: #0400;}

Here are the ways to get the relevant path from the Internet (not all tried, for reference only):

1. Get the path to a PLUGIN:

Platform.getbundle ("Mypluginid"). GetLocation ().

After Eclipse uses OSGi, it seems to be able to:

Activator.getdefault (). Getbundle (). GetLocation (). (provided that the plugin has Activator this class. This class inherits the ECLIPSE's Plugin Class)

Eclipse seems to be using OSGi before it looks like this:

Myplugin.getdefault (). Getbundle (). GetLocation (). (provided that the plugin has myplugin this class. This class inherits the ECLIPSE's Plugin Class)

2. Get Workspace path:P latform.getlocation (); Or

Resourcesplugin.getworkspace (); It seems like

Platform.getinstancelocation () is also possible

3. Get the ECLIPSE installation path

Platform.getinstalllocation ();

4. Obtain the absolute path from the plugin:

Aaaaplugin.getdefault (). Getstatelocation (). Makeabsolute (). ToFile (). GetAbsolutePath ()

Get Project from a file:

Iprojectproject= ((IFile) O). Getproject ();

Get the full path through the file:

Stringpath= ((IFile) O). GetLocation (). Makeabsolute (). ToFile (). GetAbsolutePath ();

Get the root of the whole Workspace:

Iworkspacerootroot=resourcesplugin.getworkspace (). Getroot ();

To find a resource from the root:

Iresourceresource=root.findmember (NewPath (containername));

To find resources from bundles:

Bundlebundle=platform.getbundle (pluginID);

Urlfullpathstring=bundleutility.find (Bundle,filepath);

Get Appliactionworkspace:

Platform.aslocalurl (Product_bundle.getentry (")). GetPath ()). GetAbsolutePath ();

Get Runtimeworkspace:

Platform.getinstancelocation (). GetURL (). GetPath ();

To get an edit file from the editor

Ieditorparteditor= ((Defaulteditdomain) (Parent.getviewer (). Geteditdomain ())). Geteditorpart ();

Ieditorinputinput=editor.geteditorinput ();

if (inputinstanceofifileeditorinput) {

Ifilefile= ((ifileeditorinput) input). GetFile ();

}

Get the absolute path to the plugin:

Filelocator.resolve (Builduiplugin.getdefault (). Getbundle (). Getentry ("/")). GetFile ();

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.