超越自我

          一切皆有可能

           

          Eclipse 文件資源路徑

          運行環境(runtime-workspace)下面.metadata\.plugins\xxxxxx (plugin ID)
          AaaaPlugin.getDefault().getStateLocation().makeAbsolute().toFile().getAbsolutePath());


          String path = ((IFile)o).getLocation().makeAbsolute().toFile().getAbsolutePath();

          ?

          運行環境(runtime-workspace):

          IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();


          從根來查找資源:

          IResource resource = root.findMember(new Path(containerName));

          IWorkspaceRoot
          ?-IProject
          ?? -IFolder
          ???? -IFile

          IResource
          得到絕對路徑方法:
          getLocation().toOSString()
          得到相對路徑方法:
          getFullPath().toOSString()
          通過相對路徑找到文件:
          比如說:XXXProject下面有 "/webApp/StarflowFormEdit.jsp"
          String path=pjt.getFile("/webApp/StarflowFormEdit.jsp").getLocation().toOSString();

          //Project
          從Bundle來查找資源:

          Bundle bundle = Platform.getBundle(pluginId);
          URL fullPathString = BundleUtility.find(bundle, filePath);
          備注:
          一個OSGI模塊最重要的就是Bundle和Service,我們可以認為Bundle是一種插件管理器,
          主要是通過BundleActivator管理模塊的生命周期,而Service則是這個模塊可暴露對外的服務對象。
          這里體現了OSGI和傳統的Plug-in Framework不同的一個地方,管理和靜態結構分開,
          每個Bundle擁有自己的ClassLoader以及context,通過context可進行服務的注冊、卸載等,
          這些操作都會通過事件機制廣播給相應的其他的Bundle;一般來說都為通過在Bundle中編寫初始需要注冊的服務的方法來
          完成Bundle可供外部使用的服務的暴露功能。


          得到Appliaction workspace:
          Platform.asLocalURL(PRODUCT_BUNDLE.getEntry("")).getPath()).getAbsolutePath();

          運行環境(runtime-workspace):
          Platform.getInstanceLocation().getURL().getPath();

          從編輯器來獲得編輯文件:

          IEditorPart editor = ((DefaultEditDomain)(parent.getViewer().getEditDomain())).getEditorPart();
          IEditorInput input = editor.getEditorInput();
          if(input instanceof IFileEditorInput){
          IFile file = ((IFileEditorInput)input).getFile();

          posted on 2006-08-04 13:57 jame 閱讀(1807) 評論(0)  編輯  收藏 所屬分類: Eclipse接口


          只有注冊用戶登錄后才能發表評論。


          網站導航:
           

          導航

          統計

          常用鏈接

          留言簿(3)

          隨筆檔案

          文章分類

          文章檔案

          相冊

          收藏夾

          UML

          搜索

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 文登市| 溧阳市| 二连浩特市| 宁德市| 南部县| 桦川县| 庆云县| 天津市| 广安市| 贵南县| 平舆县| 小金县| 天镇县| 潮州市| 丰顺县| 剑河县| 永登县| 普安县| 饶平县| 青田县| 北安市| 江达县| 富源县| 洛阳市| 松阳县| 确山县| 杨浦区| 安龙县| 嵊州市| 军事| 玉树县| 万载县| 瑞丽市| 尚义县| 安仁县| 中卫市| 宝丰县| 陆丰市| 增城市| 沾益县| 青河县|