免费视频淫片aa毛片_日韩高清在线亚洲专区vr_日韩大片免费观看视频播放_亚洲欧美国产精品完整版
打開APP
未登錄
開通VIP,暢享免費電子書等14項超值服
開通VIP
首頁
好書
留言交流
下載APP
聯(lián)系客服
從插件/RCP中取得文件路徑的方法 中國Eclipse社區(qū)
jinzq
>《我的圖書館》
2007.01.18
關(guān)注
從插件/RCP中取得文件路徑的方法
作者:hopeshared
引用地址:
http://www.blogjava.net/hopeshared/archive/2005/12/20/24798.html
最近社區(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();
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////
得到項目的絕對路徑:
FileLocator.toFileURL(
Platform.getBundle(Application.PLUGIN_ID).getEntry(""))
.getPath()
///////////////////////////////////////////////////////////////////////////////////////////////////////////
從插件中獲得絕對路徑:
AaaaPlugin.getDefault().getStateLocation().makeAbsolute().toFile().getAbsolutePath());
getStateLocation() 報錯NullPointerException!
///////////////////////////////////////////////////////////////////////////////////////////////////////////
Location installLoc = LocationManager.getInstallLocation();
String path = null;
String installPath = null;
if (installLoc != null)
{
URL installURL = installLoc.getURL();
// assume install URL is file: based
path = installURL.getPath();
}
installPath = path.substring(1, path.length());
這個方法不錯,我花了一個下午看源代碼找到的。
如果你的RCP工程沒有發(fā)布,得到的是eclipse的路徑。如果你的RCP工程已經(jīng)發(fā)布(假如在D:\RCP\下面),得到的路徑就是D:/RCP/。
大家可以試試看 。
///////////////////////////////////////////////////////////////////////////////////////////////////////////
請問IEditorPart editor =((DefaultEditDomain)(parent.getViewer().getEditDomain())).getEditorPart();這一句里面的parent是什么?我直接用下面的代碼取代parent.getViewer().getEditDomain()這一句可不可以?
IWorkbenchPage workbenchPage = VecasCompile.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage();
IEditorPart editor = workbenchPage.getActiveEditor();
本站僅提供存儲服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請
點擊舉報
。
打開APP,閱讀全文并永久保存
查看更多類似文章
猜你喜歡
類似文章
eclipse 路徑的獲取
Java 中 File.getPath() getAbsolutePath()和getCanonicalPath()的不同
Eclipse插件開發(fā) RCP生成jar包后獲取jar包中的Plugin/Bundle文件資源(路徑)——以FreeMarker為例
RCP運行路徑檢測報告
NSBundle
java中File類getPath()、getAbsolutePath()、getCanonicalPath()區(qū)別?
更多類似文章 >>
生活服務(wù)
首頁
萬象
文化
人生
生活
健康
教育
職場
理財
娛樂
藝術(shù)
上網(wǎng)
留言交流
回頂部
聯(lián)系我們
分享
收藏
點擊這里,查看已保存的文章
導(dǎo)長圖
關(guān)注
一鍵復(fù)制
下載文章
綁定賬號成功
后續(xù)可登錄賬號暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點擊這里聯(lián)系客服!
聯(lián)系客服
微信登錄中...
請勿關(guān)閉此頁面
先別劃走!
送你5元優(yōu)惠券,購買VIP限時立減!
5
元
優(yōu)惠券
優(yōu)惠券還有
10:00
過期
馬上使用
×