本篇內(nèi)容介紹了“Eclipse RCP編輯器關(guān)閉按鈕的屏蔽方法是什么”的有關(guān)知識,在實(shí)際案例的操作過程中,不少人都會遇到這樣的困境,接下來就讓小編帶領(lǐng)大家學(xué)習(xí)一下如何處理這些情況吧!希望大家仔細(xì)閱讀,能夠?qū)W有所成!
旌德網(wǎng)站建設(shè)公司創(chuàng)新互聯(lián)建站,旌德網(wǎng)站設(shè)計(jì)制作,有大型網(wǎng)站制作公司豐富經(jīng)驗(yàn)。已為旌德上千家提供企業(yè)網(wǎng)站建設(shè)服務(wù)。企業(yè)網(wǎng)站搭建\外貿(mào)網(wǎng)站建設(shè)要多少錢,請找那個(gè)售后服務(wù)好的旌德做網(wǎng)站的公司定做!
通過設(shè)斷點(diǎn)跟蹤Eclipse RCP的代碼, 發(fā)現(xiàn)編輯器上的關(guān)閉按鈕其實(shí)并不屬于Editor控件的一部分,而是editor所屬容器的,具體層次結(jié)構(gòu)沒有深入去研究,總之按鈕是加在AbstractTabFolder這樣一個(gè)控件上的。RCP在啟動時(shí),會通過默認(rèn)的WorkbenchPresentationFactory在生成GUI上的DefaultTabFolder,并且默認(rèn)具有關(guān)閉按鈕。因此屏蔽關(guān)閉按鈕就從此入手。
首先,在ApplicationWorkbenchWindowAdvisor類的preWindowOpen()方法中注冊我們自己定制的PresentationFactory。
Java代碼:
configurer.setPresentationFactory(new UnCloseableEditorPresentationFactory()); |
UnCloseableEditorPresentationFactory類繼承WorkbenchPresentationFactory類,為了不影響別的GUI功能,我們只需要重寫public StackPresentation createEditorPresentation(Composite parent, IStackPresentationSite site)方法中的關(guān)于設(shè)置TableFolder的部分,具體如下:
Java代碼:
DefaultTabFolder folder = new UnCloseableEditorFolder(parent, editorTabPosition | SWT.BORDER, site.supportsState(IStackPresentationSite.STATE_MINIMIZED), site.supportsState(IStackPresentationSite.STATE_MAXIMIZED)); ... |
該方法中其余部分代碼,把父類的復(fù)制過來即可。
***就是定義我們自己的UnCloseableEditorFolder了
Java代碼:
public UnCloseableEditorFolder(Composite parent, int flags,boolean allowMin, boolean allowMax) |
以上就是需要定制的代碼,另外,UnCloseableEditorPresentationFactory類中,我們還可以public StackPresentation createEditorPresentation(Composite parent, IStackPresentationSite site)中定制StandardViewSystemMenu,從而去掉RCP中編輯器folder上的菜單中的close,closeall,new editor等菜單
Java代碼:
class StandardEditorSystemMenu extends StandardViewSystemMenu { /** * @param site */ public StandardEditorSystemMenu(IStackPresentationSite site) { super(site); } String getMoveMenuText() { return WorkbenchMessages.EditorPane_moveEditor; } /* (non-Javadoc) * @see org.eclipse.ui.internal.presentations.util. ISystemMenu#show(org.eclipse.swt.widgets.Control, org.eclipse.swt.graphics.Point, org.eclipse.ui.presentations.IPresentablePart) */ public void show(Control parent, Point displayCoordinates, IPresentablePart currentSelection) { super.show(parent, displayCoordinates, currentSelection); } } |
“Eclipse RCP編輯器關(guān)閉按鈕的屏蔽方法是什么”的內(nèi)容就介紹到這里了,感謝大家的閱讀。如果想了解更多行業(yè)相關(guān)的知識可以關(guān)注創(chuàng)新互聯(lián)網(wǎng)站,小編將為大家輸出更多高質(zhì)量的實(shí)用文章!
新聞名稱:EclipseRCP編輯器關(guān)閉按鈕的屏蔽方法是什么
新聞來源:http://chinadenli.net/article8/ihggop.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站制作、企業(yè)網(wǎng)站制作、外貿(mào)網(wǎng)站建設(shè)、服務(wù)器托管、網(wǎng)站導(dǎo)航、網(wǎng)站收錄
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)