zoukankan      html  css  js  c++  java
  • Eclipse插件开发中各种路径的获取


    得到某PLUGIN的路径:

    Platform.getBundle(“mypluginid”).getLocation() ;

    eclipse采用osgi后好像还可以: (前提是这个插件有Activator这个类.这个类继承了ECLIPSE的Plugin类)

    Activator.getDefault().getBundle().getLocation();

    eclipse采用osgi前好像好像是: (前提是这个插件有MyPlugin这个类.这个类继承了ECLIPSE的Plugin类)

    MyPlugin.getDefault().getBundle().getLocation()

    得到工作区路径:

    Platform.getlocation();
    ResourcesPlugin.getWorkspace();
    Platform.getInstanceLocation();

    5.得到ECLIPSE安装路径

    Platform.getInstallLocation();

    6.从插件中获得绝对路径:
    AaaaPlugin.getDefault().getStateLocation().makeAbsolute().toFile().getAbsolutePath();
    7.通过文件得到工程Project:
    IProject project = ((IFile)o).getProject();
    8.通过文件得到全路径:
    String path=((IFile)o).getLocation().makeAbsolute().toFile().getAbsolutePath();
    9.获得工作空间workspace:
    (1)得到Appliaction workspace:
    Platform.asLocalURL(PRODUCT_BUNDLE.getEntry(“”)).getPath()).getAbsolutePath();
    (2)得到runtime workspace:
    Platform.getInstanceLocation().getURL().getPath();
    10.得到整个Workspace的根:
    IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
    11.从根来查找资源:
    IResource resource = root.findMember(new Path(containerName));
    12.从Bundle来查找资源:
    Bundle bundle = Platform.getBundle(pluginId);
    URL fullPathString = BundleUtility.find(bundle, filePath);
    13.从编辑器来获得编辑文件:
    IEditorPart editor = ((DefaultEditDomain)(parent.getViewer().getEditDomain())).getEditorPart();
    IEditorInput input = editor.getEditorInput();
    if(input instanceof IFileEditorInput){
    IFile file = ((IFileEditorInput)input).getFile();
    }
    14.获取插件的绝对路径:
    FileLocator.resolve(BuildUIPlugin.getDefault().getBundle().getEntry(“/”)).getFile();
    15.得到插件所在的路径:
    Platform.asLocalURL(Platform.getBundle(“your plugin ID”).getEntry(“”)).getFile();
    16.得到当前工作空间的路径:
    Platform.getInstanceLocation().getURL().getFile();
    17.得到当前工作空间下的所有工程:
    ResourcesPlugin.getWorkspace().getRoot().getProjects();
    18.得到某 PLUGIN 的路径:
    Platform.getBundle(“mypluginid”).getLocation() ;
    19.eclipse采用osgi后好像还可以:(前提是这个插件有Activator这个类.这个类继承了ECLIPSE的Plugin类):
    Activator.getDefault().getBundle().getLocation();
    20.eclipse采用osgi前好像好像是:(前提是这个插件有MyPlugin这个类.这个类继承了ECLIPSE的Plugin类):
    MyPlugin.getDefault().getBundle().getLocation();
    Platform类获取路径汇总:
    假定Eclipse的安装路径为:D:Javaeclipse
    创建的Workspace路径为:D:Javaeclipseworkspace
    Platform.getNL():zh_CN
    Platform.getWS():win32
    Platform.getOS():win32
    Platform.getOSArch():x86
    Platform.getStateStamp():155
    Platform.getUserLocation().getURL():file:/D:/Profiles/windowsloginname/user/
    Platform.getInstallLocation().getURL():file:/d:/Java/eclipse/
    Platform.getConfigurationLocation().getURL():file:/d:/Java/eclipse/configuration/
    Platform.getInstanceLocation().getURL():file:/D:/Java/eclipse/workspace/
    Platform.getLocation():D:/Java/eclipse/workspace
    Platform.getLocation().toOSString():D:Javaeclipseworkspace
    Platform.getLogFileLocation():D:/Java/eclipse/workspace/.metadata/.log
    Platform.getLogFileLocation().toOSString():D:Javaeclipseworkspace.metadata.log
    Platform.getPluginStateLocation(Platform.getPlugin(“NamedPlugin”)):D:/Java/eclipse/workspace/.metadata/.plugins/NamedPlugin
    Platform.getPlugin(“NamedPlugin”).getStateLocation():D:/Java/eclipse/workspace/.metadata/.plugins/NamedPlugin
    Platform.getPlugin(“NamedPlugin”).getDescriptor():NamedPlugin_1.0.0
    Platform.getPlugin(“NamedPlugin”).getDescriptor().getLabel():Plug-in Name
    Platform.getPlugin(“NamedPlugin”).getDescriptor().getProviderName():ProviderName
    Platform.getPlugin(“NamedPlugin”).getDescriptor().getUniqueIdentifier():NamedPlugin
    Platform.getPlugin(“NamedPlugin”).getDescriptor().getInstallURL():platform:/plugin/NamedPlugin_1.0.0/
    Platform.getPlugin(“NamedPlugin”).getDescriptor().getInstallURL().getPath():/plugin/NamedPlugin_1.0.0/
    ————————————————
    版权声明:本文为CSDN博主「guobinhui」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
    原文链接:https://blog.csdn.net/guobinhui/article/details/51115463

  • 相关阅读:
    今天更新Chrome到1.0版本
    升级安装Windows7后需要处理的兼容性程序(不断更新中)
    解决IE8下无法播放rm的视频网站内容
    升级到NVelocity1.1版本
    安装VS2010中文版初体验
    【iPhone开发】说说Xcode4中xib绑定的原理
    第一个iPhone版本应用发布
    xcode4.2开发最新的ios5应用,分享snow版本下载地址
    xCode 4.X 免证书真机发布及调试
    [转]IT程序员之间薪水差距之大及对职业培训的看法
  • 原文地址:https://www.cnblogs.com/yaolei0422/p/14548195.html
Copyright © 2011-2022 走看看