<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 文件路徑問(wèn)題 
    String path =FileLocator.toFileURL(Platform.getBundle("工程名").getEntry("")).getPath 

    得到eclipse rcp plugin 內(nèi)目錄文件絕對(duì)路徑的方法 
    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("請(qǐng)檢查文件的路徑",new NullPointerException()); 
                // get path URL 
                urlentry = bundle.getEntry(entry); 
                if (urlentry==null) 
                    throw new DataException("請(qǐng)檢查文件的路徑",new NullPointerException()); 
                strEntry = FileLocator.toFileURL(urlentry).getPath(); 
            } catch (IOException e1) { 
                throw new DataException("請(qǐng)檢查文件的路徑", e1); 
            } 
            return strEntry; 
        } 
        
        public static String getPluginPath(){        
            return Activator.getDefault().getStateLocation().makeAbsolute().toFile().getAbsolutePath(); 
            
        }   
        
    } 

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


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




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

    最近社區(qū)里問(wèn)這個(gè)問(wèn)題的人特別多,所以在這里將自己用到的幾個(gè)方法寫(xiě)出來(lái)。假如以后還有其他的方法,會(huì)進(jìn)行更新。 

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


    通過(guò)文件得到Project: 

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


    通過(guò)文件得到全路徑: 

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



    得到整個(gè)Workspace的根: 

    IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); 


    從根來(lái)查找資源: 

    IResource resource = root.findMember(new Path(containerName)); 

    從Bundle來(lái)查找資源: 

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

    從編輯器來(lái)獲得編輯文件: 

    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) 評(píng)論(0)  編輯  收藏 所屬分類: Eclipse的相關(guān)
    <2025年5月>
    27282930123
    45678910
    11121314151617
    18192021222324
    25262728293031
    1234567

    常用鏈接

    留言簿(3)

    隨筆檔案

    文章分類

    文章檔案

    相冊(cè)

    搜索

    •  

    最新評(píng)論

    主站蜘蛛池模板: 亚洲国产精品美女| 亚洲动漫精品无码av天堂| 亚洲AV无码一区二区三区国产| 一区国严二区亚洲三区| 国产亚洲av人片在线观看| 亚洲精品国产精品乱码不99 | 国产成人免费高清激情明星| 国产在线观看麻豆91精品免费| 久久受www免费人成_看片中文| 国产精品极品美女免费观看| 亚洲美女高清一区二区三区| 亚洲人成亚洲精品| 中文字幕亚洲情99在线| 国产亚洲Av综合人人澡精品| 亚洲日本精品一区二区| 亚洲国产精品成人AV在线| jizz免费观看| 国产国产人免费视频成69堂| 国产成人精品男人免费| 亚洲爆乳无码专区| 亚洲一区二区影视| 免费无码午夜福利片69| 99精品免费观看| 四虎影视永久免费观看| 久久国产亚洲观看| 亚洲AV无码专区在线电影成人 | 国产精品亚洲小说专区| 中文字幕乱码一区二区免费| 野花高清在线电影观看免费视频| 免费一级肉体全黄毛片| 久久精品国产亚洲av麻豆色欲| 亚洲AV无码专区国产乱码不卡| 国产午夜免费高清久久影院 | 亚洲成人免费在线| 国产91在线免费| 91久久亚洲国产成人精品性色 | 亚洲欧洲无卡二区视頻| 国产区在线免费观看| 成人AV免费网址在线观看| 亚洲欧洲国产成人综合在线观看| 91情国产l精品国产亚洲区|