日本综合一区二区|亚洲中文天堂综合|日韩欧美自拍一区|男女精品天堂一区|欧美自拍第6页亚洲成人精品一区|亚洲黄色天堂一区二区成人|超碰91偷拍第一页|日韩av夜夜嗨中文字幕|久久蜜综合视频官网|精美人妻一区二区三区

RELATEED CONSULTING
相關(guān)咨詢(xún)
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時(shí)間:8:30-17:00
你可能遇到了下面的問(wèn)題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營(yíng)銷(xiāo)解決方案
EclipseRCP編輯器關(guān)閉按鈕的屏蔽方法

通過(guò)設(shè)斷點(diǎn)跟蹤Eclipse RCP的代碼, 發(fā)現(xiàn)編輯器上的關(guān)閉按鈕其實(shí)并不屬于Editor控件的一部分,而是editor所屬容器的,具體層次結(jié)構(gòu)沒(méi)有深入去研究,總之按鈕是加在AbstractTabFolder這樣一個(gè)控件上的。RCP在啟動(dòng)時(shí),會(huì)通過(guò)默認(rèn)的WorkbenchPresentationFactory在生成GUI上的DefaultTabFolder,并且默認(rèn)具有關(guān)閉按鈕。因此屏蔽關(guān)閉按鈕就從此入手。

首先,在ApplicationWorkbenchWindowAdvisor類(lèi)的preWindowOpen()方法中注冊(cè)我們自己定制的PresentationFactory。

Java代碼:

configurer.setPresentationFactory(new UnCloseableEditorPresentationFactory());  

UnCloseableEditorPresentationFactory類(lèi)繼承WorkbenchPresentationFactory類(lèi),為了不影響別的GUI功能,我們只需要重寫(xiě)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)); ...

該方法中其余部分代碼,把父類(lèi)的復(fù)制過(guò)來(lái)即可。

***就是定義我們自己的UnCloseableEditorFolder了

Java代碼:

public UnCloseableEditorFolder(Composite parent, 
int flags,boolean allowMin, boolean allowMax)

 {   super(parent, flags, allowMin, allowMax);  }

 @SuppressWarnings("restriction")

 public AbstractTabItem add(int index, int flags)

{   return super.add(index, flags ^ SWT.CLOSE);  }

以上就是需要定制的代碼,另外,UnCloseableEditorPresentationFactory類(lèi)中,我們還可以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);     } }

 以上就是個(gè)人從事RCP幾年來(lái)一點(diǎn)小小的心得體會(huì)。

責(zé)任編輯:book05
來(lái)源: javaeye Eclipse RCP編輯器 屏蔽視圖


當(dāng)前題目:EclipseRCP編輯器關(guān)閉按鈕的屏蔽方法
網(wǎng)站路徑:http://www.dlmjj.cn/article/djdcjcp.html