<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 內(nèi)目錄文件絕對路徑的方法 
    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中取得文件路徑的方法 

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

    從插件中獲得絕對路徑: 
        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 閱讀(1529) 評論(0)  編輯  收藏 所屬分類: Eclipse的相關(guān)
    <2025年5月>
    27282930123
    45678910
    11121314151617
    18192021222324
    25262728293031
    1234567

    常用鏈接

    留言簿(3)

    隨筆檔案

    文章分類

    文章檔案

    相冊

    搜索

    •  

    最新評論

    主站蜘蛛池模板: 亚洲VA中文字幕无码一二三区| 亚洲精品美女视频| 成年轻人网站色免费看| a色毛片免费视频| 国产AV日韩A∨亚洲AV电影| 国产成人精品日本亚洲11| 久久精品国产亚洲AV麻豆王友容| 亚洲一区二区三区乱码A| 免费观看的a级毛片的网站| 91嫩草免费国产永久入口| 久久精品免费电影| 国产免费高清69式视频在线观看| 在线播放亚洲精品| 亚洲精品V天堂中文字幕| 亚洲综合丁香婷婷六月香| 精品亚洲aⅴ在线观看| 亚洲AV无一区二区三区久久| 国产亚洲欧洲Aⅴ综合一区| www.91亚洲| 亚洲va中文字幕无码| 四虎精品亚洲一区二区三区| 在线观看免费大黄网站| 国产免费不卡v片在线观看| 免费在线视频你懂的| 91禁漫免费进入| 蜜桃视频在线观看免费视频网站WWW | 亚洲中文无码线在线观看| 亚洲综合一区二区精品导航| 亚洲AV第一页国产精品| 亚洲成AV人片在WWW色猫咪| 国产精品久久久亚洲| 亚洲国产成人高清在线观看 | 亚洲人成色777777精品| 亚洲精品久久久久无码AV片软件| 亚洲天堂男人影院| 亚洲熟女www一区二区三区| 亚洲精品永久在线观看| 国产成人人综合亚洲欧美丁香花 | 免费女人18毛片a级毛片视频| 亚洲 国产 图片| 国产亚洲精品激情都市|