<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)

    隨筆檔案

    文章分類

    文章檔案

    相冊

    搜索

    •  

    最新評論

    主站蜘蛛池模板: 亚洲?V无码乱码国产精品 | 老司机午夜在线视频免费| 亚洲宅男永久在线| 亚洲国产美女精品久久久| 美女被免费喷白浆视频| 亚洲专区一路线二| 免费可以在线看A∨网站| 亚洲人成网站在线播放vr| 黄视频在线观看免费| 拍拍拍又黄又爽无挡视频免费| 蜜芽亚洲av无码精品色午夜| 一级特黄aa毛片免费观看| 日本免费一本天堂在线| 国产精品无码亚洲精品2021| 免费va人成视频网站全| 国产成人1024精品免费| 国产V亚洲V天堂无码久久久| 暖暖免费中文在线日本| 女人张腿给男人桶视频免费版| 亚洲色大18成人网站WWW在线播放| 黄网站免费在线观看| 久久亚洲AV成人无码电影| 全免费毛片在线播放| 亚洲AV电影天堂男人的天堂| 亚洲Av无码乱码在线znlu| 中文字幕一区二区免费| 亚洲在成人网在线看| 日韩免费毛片视频| 国产无遮挡无码视频免费软件 | 亚洲欧美成人av在线观看| 99精品国产成人a∨免费看| 亚洲乱码卡一卡二卡三| 国产免费观看网站| 国产成人精品久久亚洲高清不卡| 亚洲国产香蕉人人爽成AV片久久 | 亚洲黄色免费电影| 免费无遮挡无码视频网站| 一级毛片免费播放视频| 亚洲精品美女在线观看| 免费a级毛片大学生免费观看| 久久黄色免费网站|