<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    posts - 1,  comments - 25,  trackbacks - 0
    終于找到直接可以用的了 
    Java代碼 
    1. path = FileLocator.toFileURL(  
    2.         Platform.getBundle(IAppConstants.APPLICATION_ID)  
    3.                 .getEntry("")).getPath().toString();  



    RCP 文件路徑問題 
    String path =FileLocator.toFileURL(Platform.getBundle("工程名").getEntry("")).getPath 

    得到eclipse rcp plugin 內目錄文件絕對路徑的方法 
    import java.io.IOException; 
    import java.net.URL; 

    import org.eclipse.core.runtime.FileLocator; 
    import org.eclipse.core.runtime.Platform; 
    import org.osgi.framework.Bundle; 

    import com.work.base.exception.DataException; 
    import com.work.view.Activator; 

    public class BundlePathUtil { 

        public static String getRealPath(String bundleID, String entry) 
                throws DataException { 
            URL urlentry; 
            String strEntry; 
            try { 
                Bundle bundle = Platform.getBundle(bundleID); 
                if (bundle==null) 
                    throw new DataException("請檢查文件的路徑",new NullPointerException()); 
                // get path URL 
                urlentry = bundle.getEntry(entry); 
                if (urlentry==null) 
                    throw new DataException("請檢查文件的路徑",new NullPointerException()); 
                strEntry = FileLocator.toFileURL(urlentry).getPath(); 
            } catch (IOException e1) { 
                throw new DataException("請檢查文件的路徑", e1); 
            } 
            return strEntry; 
        } 
        
        public static String getPluginPath(){        
            return Activator.getDefault().getStateLocation().makeAbsolute().toFile().getAbsolutePath(); 
            
        }   
        
    } 

    另外,獲取插件/rcp 的workspace的路徑: 


    Platform.getInstanceLocation().getURL().getPath() 




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

    最近社區里問這個問題的人特別多,所以在這里將自己用到的幾個方法寫出來。假如以后還有其他的方法,會進行更新。 

    從插件中獲得絕對路徑: 
        AaaaPlugin.getDefault().getStateLocation().makeAbsolute().toFile().getAbsolutePath()); 


    通過文件得到Project: 

    IProject project = ((IFile)o).getProject(); 


    通過文件得到全路徑: 

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



    得到整個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 2010-09-24 10:59 Daniel 閱讀(1534) 評論(0)  編輯  收藏 所屬分類: Eclipse的相關
    <2025年7月>
    293012345
    6789101112
    13141516171819
    20212223242526
    272829303112
    3456789

    常用鏈接

    留言簿(3)

    隨筆檔案

    文章分類

    文章檔案

    相冊

    搜索

    •  

    最新評論

    主站蜘蛛池模板: 日韩国产免费一区二区三区| 1000部免费啪啪十八未年禁止观看| 久久综合亚洲色一区二区三区| 国产精品va无码免费麻豆| 麻豆一区二区免费播放网站| 国产自国产自愉自愉免费24区 | 亚洲成aⅴ人片久青草影院| 亚洲成a∧人片在线观看无码| 亚洲成av人片天堂网| 亚洲性日韩精品一区二区三区| 性色午夜视频免费男人的天堂| 一级毛片a女人刺激视频免费| 免费不卡在线观看AV| 国产免费人成在线视频| 国产亚洲一区二区手机在线观看| 亚洲 欧洲 视频 伦小说| 亚洲熟妇无码AV| 亚洲精品色在线网站| 深夜A级毛片视频免费| 高潮毛片无遮挡高清免费| 丁香花在线观看免费观看图片 | 亚洲精品在线不卡| 亚洲精品乱码久久久久久蜜桃 | 一级毛片在线免费观看| 免费观看成人久久网免费观看| 小日子的在线观看免费| 四虎在线视频免费观看| 国产亚洲精品免费视频播放| 亚洲成av人片在线观看天堂无码| 97人妻无码一区二区精品免费| 一区二区三区在线免费 | 青青久在线视频免费观看| 国产亚洲色婷婷久久99精品91| 亚洲aⅴ天堂av天堂无码麻豆| a拍拍男女免费看全片| 亚洲AV无码成人精品区大在线| 国产免费啪嗒啪嗒视频看看| 亚洲精品97久久中文字幕无码| 久久久久亚洲精品影视| 亚洲成a人片在线观看播放| 亚洲日本VA中文字幕久久道具|