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

    隨筆檔案

    文章分類

    文章檔案

    相冊

    搜索

    •  

    最新評論

    主站蜘蛛池模板: 免费国产成人午夜私人影视 | 免费在线观看亚洲| 波多野结衣中文字幕免费视频| 久久久久亚洲AV无码专区首| a级毛片在线免费| 亚洲AV无码专区电影在线观看| 97无码人妻福利免费公开在线视频| 亚洲欧洲成人精品香蕉网| 伊人免费在线观看| 亚洲av无码一区二区三区网站 | 3d成人免费动漫在线观看| 亚洲综合无码一区二区三区| 日本片免费观看一区二区| 亚洲一区在线免费观看| 日韩免费视频播播| 国产免费MV大全视频网站| 国产亚洲成AV人片在线观黄桃| 久久这里只精品99re免费| 亚洲人成网站日本片| 永久免费视频v片www| www成人免费视频| 久久亚洲中文字幕精品有坂深雪| 国产电影午夜成年免费视频| 亚洲精品久久无码| 成人亚洲性情网站WWW在线观看| 国产99视频精品免费专区| 亚洲中文字幕在线无码一区二区| 国产成人免费网站在线观看| 久久国产美女免费观看精品| 久久亚洲精品成人无码网站| 性色av免费观看| 精品国产污污免费网站入口在线| 日木av无码专区亚洲av毛片| 暖暖在线日本免费中文| 你好老叔电影观看免费| 亚洲偷自拍另类图片二区| 一本久久a久久精品亚洲| 91成人免费在线视频| 中文在线日本免费永久18近| 亚洲av片不卡无码久久| 久久久久亚洲爆乳少妇无|