超越自我

          一切皆有可能

           

          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

          搜索

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 长宁区| 封开县| 铁岭县| 阳信县| 通榆县| 深水埗区| 秭归县| 满城县| 洛隆县| 洛浦县| 平原县| 鹤峰县| 木里| 睢宁县| 绥棱县| 泌阳县| 津市市| 桃江县| 苍梧县| 吴川市| 无棣县| 公安县| 和顺县| 溧阳市| 稻城县| 富顺县| 安仁县| 阿城市| 巍山| 驻马店市| 苏尼特左旗| 彭山县| 河津市| 威远县| 曲周县| 宝兴县| 达日县| 通道| 新建县| 崇文区| 清河县|