自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

Eclipse RCP編輯器關(guān)閉按鈕的屏蔽方法

開發(fā) 后端
Eclipse RCP開發(fā)中,屏蔽視圖的關(guān)閉按鈕很容易,在IPerspectiveFactory接口的createInitialLayout方法中,調(diào)用IViewLayout的setCloseable(boolean)方法即可,而屏蔽編輯器的關(guān)閉按鈕則有點(diǎn)麻煩,需要RCP中的WorkbenchPresentationFactory進(jìn)行定制.

通過設(shè)斷點(diǎn)跟蹤Eclipse RCP的代碼, 發(fā)現(xiàn)編輯器上的關(guān)閉按鈕其實(shí)并不屬于Editor控件的一部分,而是editor所屬容器的,具體層次結(jié)構(gòu)沒有深入去研究,總之按鈕是加在AbstractTabFolder這樣一個控件上的。RCP在啟動時,會通過默認(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)

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

 @SuppressWarnings("restriction")

 public AbstractTabItem add(int index, int flags)

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

以上就是需要定制的代碼,另外,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);     } }

 以上就是個人從事RCP幾年來一點(diǎn)小小的心得體會。

責(zé)任編輯:book05 來源: javaeye
相關(guān)推薦

2013-09-10 16:02:59

Elipse編輯器

2010-02-23 15:44:24

Python編輯器

2011-01-10 16:17:49

2010-03-24 09:20:07

CentOS vi編輯

2011-03-22 13:54:57

UbuntuPHP編輯器

2013-07-11 11:13:51

編輯器

2013-06-18 01:22:46

CocoStudio工Cocos2d-x

2009-06-04 20:08:26

Eclipse RCPEclipse

2025-02-05 12:01:35

屬性編輯器Web

2017-03-09 11:45:16

LinuxVim編輯器

2009-05-20 14:48:07

ibmdwEclipse開發(fā)技巧

2018-09-25 09:25:11

Vim編輯器命令

2009-10-26 10:47:57

linux vi編輯器

2020-10-14 14:00:39

VIM編輯器

2009-12-04 17:07:49

SlickEdit

2022-05-31 14:46:02

Ruby編碼線上編輯器

2018-05-11 14:59:21

LinuxVim編輯器

2023-01-18 08:30:40

圖形編輯器元素

2023-02-01 09:21:59

圖形編輯器標(biāo)尺

2020-09-18 06:00:51

開源Markdown編輯器
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號