從插件/RCP中取得文件路徑的方法

          作者:hopeshared 引用地址:http://www.aygfsteel.com/hopeshared/archive/2005/12/20/24798.html 最近社區(qū)里問這個(gè)問題的人特別多,所以在這里將自己用到的幾個(gè)方法寫出來。假如以后還有其他的方法,會(huì)進(jìn)行更新。 從插件中獲得絕對(duì)路徑: AaaaPlugin.getDefault().getStateLocation().makeAbsolute().toFile().getAbsolutePath()); 通過文件得到Project: IProject project = ((IFile)o).getProject(); 通過文件得到全路徑: String path = ((IFile)o).getLocation().makeAbsolute().toFile().getAbsolutePath(); 得到整個(gè)Workspace的根: IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); 從根來查找資源: IResource resource = root.findMember(new Path(containerName)); 從Bundle來查找資源: Bundle bundle = Platform.getBundle(pluginId); URL fullPathString = BundleUtility.find(bundle, filePath); 得到Appliaction workspace: Platform.asLocalURL(PRODUCT_BUNDLE.getEntry("")).getPath()).getAbsolutePath(); 得到runtimeworkspace: 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-12-28 13:37 小牛小蝦 閱讀(275) 評(píng)論(0)  編輯  收藏


          只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。


          網(wǎng)站導(dǎo)航:
           
          <2006年12月>
          262728293012
          3456789
          10111213141516
          17181920212223
          24252627282930
          31123456

          導(dǎo)航

          統(tǒng)計(jì)

          常用鏈接

          留言簿(6)

          隨筆檔案

          文章檔案

          eclipse

          搜索

          最新評(píng)論

          閱讀排行榜

          評(píng)論排行榜

          主站蜘蛛池模板: 廊坊市| 木兰县| 穆棱市| 壤塘县| 灵山县| 深州市| 武义县| 武功县| 武邑县| 睢宁县| 南召县| 巴中市| 崇州市| 茂名市| 福海县| 林芝县| 舟曲县| 巴中市| 青州市| 徐水县| 二连浩特市| 大埔县| 龙川县| 长海县| 通海县| 宝应县| 长顺县| 土默特左旗| 隆尧县| 曲松县| 锡林郭勒盟| 曲靖市| 耿马| 手游| 登封市| 兴宁市| 河源市| 平乐县| 永顺县| 洪雅县| 天峨县|