当前位置: 首页>>代码示例>>Java>>正文


Java IWorkbenchPart.getAdapter方法代码示例

本文整理汇总了Java中org.eclipse.ui.IWorkbenchPart.getAdapter方法的典型用法代码示例。如果您正苦于以下问题:Java IWorkbenchPart.getAdapter方法的具体用法?Java IWorkbenchPart.getAdapter怎么用?Java IWorkbenchPart.getAdapter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.ui.IWorkbenchPart的用法示例。


在下文中一共展示了IWorkbenchPart.getAdapter方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setupControls

import org.eclipse.ui.IWorkbenchPart; //导入方法依赖的package包/类
/**
 * Find controls within a part, set it up to be used by iTrace,
 * and extract meta-data from it.
 * 
 * @param partRef partRef that just became visible.
 */
private void setupControls(IWorkbenchPartReference partRef) {
	IWorkbenchPart part = partRef.getPart(true);
    Control control = part.getAdapter(Control.class);
    //set up manager for control and managers for each child control if necessary
    if (control != null) {
    	setupControls(part, control);
    } else {
    	//Browser - always set up browser managers, no matter the partRef that
    	//has become visible
    	//not possible to get Browser control from a partRef
    	Shell workbenchShell = partRef.getPage().getWorkbenchWindow().getShell();
    	for (Control ctrl: workbenchShell.getChildren()) {
    		setupBrowsers(ctrl);
    	}
    }
}
 
开发者ID:SERESLab,项目名称:iTrace-Archive,代码行数:23,代码来源:ControlView.java

示例2: partActivated

import org.eclipse.ui.IWorkbenchPart; //导入方法依赖的package包/类
@Override
public void partActivated(IWorkbenchPart part) {
	if (part instanceof ITextEditor) {
		ITextViewer textViewer = (ITextViewer) part.getAdapter(ITextOperationTarget.class);
		if (textViewer != null) {
			ICodeLensController controller = codeLensControllers.get(part);
			if (controller != null) {
				controller.refresh();
			}
		}
	}
}
 
开发者ID:angelozerr,项目名称:codelens-eclipse,代码行数:13,代码来源:EditorTracker.java

示例3: bind

import org.eclipse.ui.IWorkbenchPart; //导入方法依赖的package包/类
/**
 * Binds all controls in an IWorkbenchPartReference that is
 * an instance of IEditorPartReference to their appropriate
 * gaze handlers if the handler exists.
 * Binds the IWorkbenchPartReference that is an instance of
 * IViewPartReference to the appropriate gaze handler if the
 * handler exists.
 * @param partRef Workbench part from which to get controls.
 */
public static void bind(IWorkbenchPartReference partRef) {
    IWorkbenchPart part = partRef.getPart(true);
    Control control = part.getAdapter(Control.class);
    System.out.println(control);
    //is an EditorPart
    if (control != null) {
    	bindControl(partRef, control, false);
    //is a ViewPart
    } else {
    	//must be handled on a case to case basis
    	
    	//Browser - always look through all controls in the shell for browsers and bind them
    	//regardless of the partRef that has become visible
    	//not possible to get a Browser control from a partRef
    	Shell workbenchShell = partRef.getPage().getWorkbenchWindow().getShell();
    	for (Control ctrl : workbenchShell.getChildren()) {
    		bind(ctrl); //call recursive helper function to find all browser controls
    	}
    	
    	//Project Explorer
    	if (part.getAdapter(ProjectExplorer.class) != null) {
    		ProjectExplorer explorer = part.getAdapter(ProjectExplorer.class);
    		//this control is the primary control associated with a ProjectExplorer
    		Control viewControl = explorer.getCommonViewer().getControl();
    		bindControl(partRef, viewControl, false);
    	}
    }
}
 
开发者ID:SERESLab,项目名称:iTrace-Archive,代码行数:38,代码来源:HandlerBindManager.java

示例4: unbind

import org.eclipse.ui.IWorkbenchPart; //导入方法依赖的package包/类
/**
 * Unbinds all controls in an IWorkbenchPartReference that is an instance
 * of IEditorPartReference which are currently bound to a gaze handler.
 * Unbinds an IWorkbenchPartReference that is an instance of IViewPartReference
 * which is currently bound to a gaze handler.
 * @param partRef Workbench part from which to get controls.
 */
public static void unbind(IWorkbenchPartReference partRef) {
	IWorkbenchPart part = partRef.getPart(true);
    Control control = part.getAdapter(Control.class);
    
    //is an EditorPart
    if (control != null) {
    	bindControl(partRef, control, true);
    //is a ViewPart
    } else {
    	//must be handled on a case to case basis
    	
    	//Browser - always look through all controls in the shell for browsers and unbind them
    	//regardless of the partRef that has been hidden
    	//not possible to get Browser control from a partRef
    	Shell workbenchShell = partRef.getPage().getWorkbenchWindow().getShell();
    	for (Control ctrl : workbenchShell.getChildren()) {
    		unbind(ctrl);
    	}
    	
    	//Project Explorer
    	if (part.getAdapter(ProjectExplorer.class) != null) {
    		ProjectExplorer explorer = part.getAdapter(ProjectExplorer.class);
    		//this control is the primary control associated with a ProjectExplorer
    		Control viewControl = explorer.getCommonViewer().getControl();
    		bindControl(partRef, viewControl, true);
    	}
    }
}
 
开发者ID:SERESLab,项目名称:iTrace-Archive,代码行数:36,代码来源:HandlerBindManager.java


注:本文中的org.eclipse.ui.IWorkbenchPart.getAdapter方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。