本文整理汇总了Java中org.eclipse.ui.IEditorPart.getAdapter方法的典型用法代码示例。如果您正苦于以下问题:Java IEditorPart.getAdapter方法的具体用法?Java IEditorPart.getAdapter怎么用?Java IEditorPart.getAdapter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.ui.IEditorPart
的用法示例。
在下文中一共展示了IEditorPart.getAdapter方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: editorOpened
import org.eclipse.ui.IEditorPart; //导入方法依赖的package包/类
private void editorOpened(IEditorPart part) {
if (part instanceof ITextEditor) {
ITextViewer textViewer = (ITextViewer) part.getAdapter(ITextOperationTarget.class);
if (textViewer != null) {
ICodeLensController controller = codeLensControllers.get(part);
if (controller == null) {
ITextEditor textEditor = (ITextEditor) part;
controller = CodeLensControllerRegistry.getInstance().create(textEditor);
if (controller != null) {
controller.setProgressMonitor(new NullProgressMonitor());
codeLensControllers.put(textEditor, controller);
//controller.install();
}
}
}
}
}
示例2: AstManager
import org.eclipse.ui.IEditorPart; //导入方法依赖的package包/类
/**
* Constructor. Loads the AST and sets up the StyledText to automatically
* reload after certain events.
* @param editor IEditorPart which owns the following StyledText.
* @param styledText StyledText to which this AST pertains.
*/
public AstManager(IEditorPart editor, StyledText styledText) {
try {
editorPath = ((IFileEditorInput) editor.getEditorInput()).getFile()
.getFullPath().toFile().getCanonicalPath();
} catch (IOException e) {
// ignore IOErrors while constructing path
editorPath = "?";
}
this.editor = editor;
this.styledText = styledText;
//This is the only why I know to get the ProjectionViewer. Perhaps there is better way. ~Ben
ITextOperationTarget t = (ITextOperationTarget) editor.getAdapter(ITextOperationTarget.class);
if(t instanceof ProjectionViewer) projectionViewer = (ProjectionViewer)t;
hookupAutoReload();
reload();
}
示例3: getSourceViewer
import org.eclipse.ui.IEditorPart; //导入方法依赖的package包/类
/**
* Obtains the source viewer of an editor.
* @param editor the editor
* @return the source viewer of the editor
*/
public static ISourceViewer getSourceViewer(IEditorPart editor) {
if (editor == null) {
return null;
}
ISourceViewer viewer = (ISourceViewer)editor.getAdapter(ITextOperationTarget.class);
return viewer;
}
示例4: setActiveEditor
import org.eclipse.ui.IEditorPart; //导入方法依赖的package包/类
public void setActiveEditor(IEditorPart editorPart){
activeEditor = editorPart;
if(activeEditor == null) return;
if(!tokenHighlighters.containsKey(editorPart)){
StyledText styledText = (StyledText) editorPart.getAdapter(Control.class);
if(styledText != null){
ITextOperationTarget t = (ITextOperationTarget) activeEditor.getAdapter(ITextOperationTarget.class);
if(t instanceof ProjectionViewer){
ProjectionViewer projectionViewer = (ProjectionViewer)t;
tokenHighlighters.put(activeEditor, new TokenHighlighter(styledText, showTokenHighlights, projectionViewer));
}
}
}
}
示例5: openFileInEditor
import org.eclipse.ui.IEditorPart; //导入方法依赖的package包/类
private ITextEditor openFileInEditor(IFile file) throws PartInitException {
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
IWorkbenchPage page = window.getActivePage();
IEditorPart editor = IDE.openEditor(page, file, true);
ITextEditor textEditor = editor.getAdapter(ITextEditor.class);
return textEditor;
}
示例6: findActionByActionId
import org.eclipse.ui.IEditorPart; //导入方法依赖的package包/类
public IAction findActionByActionId(String actionId) {
IEditorPart editor = getEditorPart();
ActionRegistry actionRegistry = (ActionRegistry) editor.getAdapter(ActionRegistry.class);
IAction action = actionRegistry.getAction(actionId);
return action;
}