1. Implementation of plug-in development in multiple languages in eclipse
To use the. properties file, you need to define in the META-INF/manifest. MF file:
Bundle-localization: plugin
This will automatically load the plugin. properties file (plugin_zh_cn.properties for Chinese)
Then replace the string with % key in the plugin. xml file.
We recommend that you first use the external string directory of Eclipse:
Bundle-Localization: OSGI-INF/l10n/plugin
2. Hide a toolbar button during Eclipse plug-in development Initialization
After finding the solution on the Internet for a long time, I finally searched for the eclipse installation directory and found the sample from its own plug-in. Example: org. Eclipse. jdt. UI/plugin. xml
<Extension point = "org. Eclipse. UI. perspectiveextensions"> <perspectiveextension targetid = "*"> <! -- Note that the ID here is the ID of the action or command -->
3. Obtain the eclipse version number in the plug-in.
String sEclipseVersion = System.getProperty("osgi.framework.version");
4. Obtain the path from the plug-in
// Obtain the path platform of the plug-in. aslocalurl (platform. getbundle ("your plugin ID "). getentry ("")). getFile (); // obtain the current workspace path platform. getinstancelocation (). geturl (). getFile (); // obtain resourcesplugin for all projects in the current workspace. getworkspace (). getroot (). getprojects (); // obtain the path of a plug-in: platform. getbundle ("mypluginid "). getlocation (). // after using osgi, eclipse seems to be able to: activator. getdefault (). getbundle (). getlocation (); // The premise is that the plug-in has the activator class. this class inherits the Eclipse plug-in class // before eclipse adopts osgi, it seems like: myplugin. getdefault (). getbundle (). getlocation (); // The premise is that this plug-in has the myplugin class. this class inherits the eclipse plugin class // get the workspace path: platform. getlocation (); // or resourcesplugin. getworkspace (); like platform. getinstancelocation () is also feasible // obtain the eclipse installation path platform. getinstalllocation (); // obtain the absolute path from the plug-in: aaaaplugin. getdefault (). getstatelocation (). makeabsolute (). tofile (). getabsolutepath (); // obtain project: iproject project = (ifile) O) through the file ). getproject (); // obtain the full path through the file: String Path = (ifile) O ). getlocation (). makeabsolute (). tofile (). getabsolutepath (); // get the root of the entire Workspace: iworkspaceroot root = resourcesplugin. getworkspace (). getroot (); // search for resources from the root: iresource resource = root. findmember (New Path (containername); // find resources from bundle: bundle = platform. getbundle (pluginid); Url fullpathstring = bundleutility. find (bundle, filepath); // obtain Appliaction Workspace: platform. aslocalurl (product_bundle.getentry ("")). getpath ()). getabsolutepath (); // get runtimeworkspace: platform. getinstancelocation (). geturl (). getpath (); // obtain the ieditorpart editor = (defaulteditdomain) (parent. getviewer (). geteditdomain ())). geteditorpart (); ieditorinput input = editor. geteditorinput (); If (input instanceof ifileeditorinput) {ifile file = (ifileeditorinput) input ). getFile () ;}// obtain the absolute path of the plug-in: filelocator. resolve (builduiplugin. getdefault (). getbundle (). getentry ("/")). getFile ();
5. Preference page and propertypage
// Open preferencepagedialog: preferencemanager manager = Window. getworkbench (). getpreferencemanager (); preferencedialog dialog = new preferencedialog (window. getshell (), manager); dialog. open (); // open propertypagedialog: propertydialog dialog = propertydialog. createdialogon (shell, null, element); dialog. open (); // open the dialog only on the selected preference page: workbenchpreferencedialog dialog = workbenchpreferencedialog. createdialogon (parent. getshell (), ID); dialog. showonly (New String [] {ID}); dialog. open ();
7. Use eclipse's support for Web Browser
try{ IWorkbenchBrowserSupport support = PlatformUI.getWorkbench().getBrowserSupport(); IWebBrowser browser = support.createBrowser("Some_ID"); browser.openURL(new URL(("http://www.eclipse.org")));}catch (PartInitException e){ e.printStackTrace();}catch (MalformedURLException e){ e.printStackTrace();}
8. osgi package header description
Bundle-activator specifies the name of the class used to start and stop the package. Bundle-classpath specifies the jar files or directories containing classes and resources. Periods ('.'), the default value specifies the jar root directory of the package. Bundle-contactaddress contains the supplier's contact address. Bundle-copyright contains the copyright description of this package. Bundle-docurl specifies a URL pointing to the document about this package. Bundle-localization specifies the location of the package's Localization file, which defaults to OSGI-INF/l10n/bundle. Bundle-manifestversion specifies that the package complies with the rules in osgi specification V3 or osgi specification V4. Bundle-name specifies the readable name (no space) of the package ). Bundle-symbolicname: a mandatory header, used to specify a unique name for this package. Bundle-vendor contains the readable name of a package supplier. Bundle-version specifies the package version. The default value is 0.0.0. Export-Package specifies the exported package ). Fragment-host defines the local package (host bundle) of this fragment ). Import-package declares the import package (Imported package) of this package ). Require-bundle specifies the export from other packages. Export-service is not recommended for import-service.
Note: Reference page:
Http://www.diybl.com/course/3_program/java/javajs/200865/122139.html
Http://allenyoung.iteye.com/blog/59312