本文整理汇总了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);
}
}
}
示例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();
}
}
}
}
示例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);
}
}
}
示例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);
}
}
}