Eclipse RCP中编辑器右键菜单与默认可拖动属性的屏蔽方法

// 实现屏蔽功能
		WorkbenchPage wp = (WorkbenchPage) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
		Composite client = wp.getClientComposite();
		Control[] children = client.getChildren();
		for (int iIndex = 0; iIndex < children.length; iIndex++) {
			Composite child = (Composite) children[iIndex];
			Control[] controls = child.getChildren();
			for (final Control control : controls) {
				if (control instanceof CTabFolder) {
					CTabFolder tabfolder = (CTabFolder) control;
					Listener[] menuDetectListeners = tabfolder.getListeners(SWT.MenuDetect);
					if (menuDetectListeners != null) {
						for (int i = 0; i < menuDetectListeners.length; i++) {
							// 屏蔽编辑器右键菜单
							tabfolder.removeListener(SWT.MenuDetect, menuDetectListeners[i]);
						}
					}
					Listener[] dragDetectListeners = tabfolder.getListeners(SWT.DragDetect);
					if (dragDetectListeners != null) {
						for (int i = 0; i < dragDetectListeners.length; i++) {
							// 屏蔽编辑器默认的可拖动属性
							tabfolder.removeListener(SWT.DragDetect, dragDetectListeners[i]);
						}
					}
				}
			}
		}

你可能感兴趣的:(RCP,编辑器)