本文整理汇总了Java中org.eclipse.ui.texteditor.AbstractTextEditor.getDocumentProvider方法的典型用法代码示例。如果您正苦于以下问题:Java AbstractTextEditor.getDocumentProvider方法的具体用法?Java AbstractTextEditor.getDocumentProvider怎么用?Java AbstractTextEditor.getDocumentProvider使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.ui.texteditor.AbstractTextEditor
的用法示例。
在下文中一共展示了AbstractTextEditor.getDocumentProvider方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getEditorDocument
import org.eclipse.ui.texteditor.AbstractTextEditor; //导入方法依赖的package包/类
public static IDocument getEditorDocument(AbstractTextEditor editor) {
IEditorInput editorInput = editor.getEditorInput();
IDocumentProvider documentProvider = editor.getDocumentProvider();
return documentProvider.getDocument(editorInput);
}
示例2: openPopup
import org.eclipse.ui.texteditor.AbstractTextEditor; //导入方法依赖的package包/类
private void openPopup() {
IEditorPart part = PlatformUI.getWorkbench().getActiveWorkbenchWindow()
.getActivePage().getActiveEditor();
if (!(part instanceof AbstractTextEditor)) {
return;
}
AbstractTextEditor editor = (AbstractTextEditor) part;
if (!editor.getTitle().endsWith(".java")) {
return;
}
IDocumentProvider dp = editor.getDocumentProvider();
doc = dp.getDocument(editor.getEditorInput());
textUtils = new StringUtils();
textUtils.setDoc(doc.get());
textUtils.setCursorPosition(StringHandler.getCursorPosition());
boolean val = textUtils.proccess();
if (textUtils.getCursorPosition() < 0) {
return;
}
if (!val) {
return;
}
StyledText styledText = (StyledText) editor.getAdapter(Control.class);
Point p = StringHandler.getPoint(styledText.getCaret());
Rectangle r = PlatformUI.getWorkbench().getActiveWorkbenchWindow()
.getShell().getBounds();
Point pos = Display.getCurrent().getCursorLocation();
Point location = new Point(StringHandler.min(p.x, r.x + r.width - 500,
pos.x + 10), StringHandler.min(p.y, r.y + r.height - 160,
pos.y + 10));
final StringPopup textPopUp = new StringPopup(PlatformUI.getWorkbench()
.getActiveWorkbenchWindow().getShell(), textUtils.getText(),
location);
textPopUp.open();
textPopUp.setTextListenerAndFocus(this);
}
示例3: execute
import org.eclipse.ui.texteditor.AbstractTextEditor; //导入方法依赖的package包/类
public Object execute(ExecutionEvent event) throws ExecutionException {
IEditorPart part = PlatformUI.getWorkbench().getActiveWorkbenchWindow()
.getActivePage().getActiveEditor();
if (!(part instanceof AbstractTextEditor)) {
return null;
}
AbstractTextEditor editor = (AbstractTextEditor) part;
if (!editor.getTitle().endsWith(".java")) {
return null;
}
IDocumentProvider dp = editor.getDocumentProvider();
doc = dp.getDocument(editor.getEditorInput());
textUtils = new StringUtils();
textUtils.setDoc(doc.get());
textUtils.setCursorPosition(getCursorPosition());
boolean val = textUtils.proccess();
if (textUtils.getCursorPosition() < 0) {
return null;
}
if (!val) {
return null;
}
StyledText styledText = (StyledText) editor.getAdapter(Control.class);
Point p = getPoint(styledText.getCaret());
Rectangle r = PlatformUI.getWorkbench().getActiveWorkbenchWindow()
.getShell().getBounds();
Point pos = Display.getCurrent().getCursorLocation();
Point location = new Point(min(p.x, r.x + r.width - 500, pos.x + 10),
min(p.y, r.y + r.height - 160, pos.y + 10));
final StringPopup textPopUp = new StringPopup(PlatformUI.getWorkbench()
.getActiveWorkbenchWindow().getShell(), textUtils.getText(),
location);
textPopUp.open();
textPopUp.setTextListenerAndFocus(this);
return null;
}