本文整理汇总了Java中org.eclipse.xtext.ui.editor.utils.EditorUtils.getXtextEditor方法的典型用法代码示例。如果您正苦于以下问题:Java EditorUtils.getXtextEditor方法的具体用法?Java EditorUtils.getXtextEditor怎么用?Java EditorUtils.getXtextEditor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.xtext.ui.editor.utils.EditorUtils
的用法示例。
在下文中一共展示了EditorUtils.getXtextEditor方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: open
import org.eclipse.xtext.ui.editor.utils.EditorUtils; //导入方法依赖的package包/类
/**
* If a platform plugin URI is given, a read-only Xtext editor is opened and returned. {@inheritDoc}
*
* @see {@link org.eclipse.emf.common.util.URI#isPlatformPlugin()}
*/
@Override
public IEditorPart open(final URI uri, final EReference crossReference, final int indexInList, final boolean select) {
IEditorPart result = super.open(uri, crossReference, indexInList, select);
if (result == null && (uri.isPlatformPlugin() || OSGI_RESOURCE_URL_PROTOCOL.equals(uri.scheme()))) {
final IModelLocation modelLocation = getModelLocation(uri.trimFragment());
if (modelLocation != null) {
PlatformPluginStorage storage = new PlatformPluginStorage(modelLocation);
IEditorInput editorInput = new XtextReadonlyEditorInput(storage);
IWorkbenchPage activePage = workbench.getActiveWorkbenchWindow().getActivePage();
try {
IEditorPart editor = IDE.openEditor(activePage, editorInput, editorID);
selectAndReveal(editor, uri, crossReference, indexInList, select);
return EditorUtils.getXtextEditor(editor);
} catch (WrappedException e) {
LOG.error("Error while opening editor part for EMF URI '" + uri + "'", e.getCause()); //$NON-NLS-1$ //$NON-NLS-2$
} catch (PartInitException partInitException) {
LOG.error("Error while opening editor part for EMF URI '" + uri + "'", partInitException); //$NON-NLS-1$ //$NON-NLS-2$
}
}
}
return result;
}
示例2: selectAndReveal
import org.eclipse.xtext.ui.editor.utils.EditorUtils; //导入方法依赖的package包/类
protected void selectAndReveal(IEditorPart openEditor, final URI uri, final EReference crossReference,
final int indexInList, final boolean select) {
final XtextEditor xtextEditor = EditorUtils.getXtextEditor(openEditor);
if (xtextEditor != null) {
if (uri.fragment() != null) {
xtextEditor.getDocument().readOnly(new IUnitOfWork.Void<XtextResource>() {
@Override
public void process(XtextResource resource) throws Exception {
if (resource != null) {
EObject object = resource.getEObject(uri.fragment());
ITextRegion location = (crossReference != null) ? locationProvider.getSignificantTextRegion(object,
crossReference, indexInList) : locationProvider.getSignificantTextRegion(object);
if (select) {
xtextEditor.selectAndReveal(location.getOffset(), location.getLength());
} else {
xtextEditor.reveal(location.getOffset(), location.getLength());
}
}
}
});
}
}
}
示例3: open
import org.eclipse.xtext.ui.editor.utils.EditorUtils; //导入方法依赖的package包/类
public IEditorPart open(URI uri, EReference crossReference, int indexInList, boolean select) {
Iterator<Pair<IStorage, IProject>> storages = mapper.getStorages(uri.trimFragment()).iterator();
if (storages != null && storages.hasNext()) {
try {
IStorage storage = storages.next().getFirst();
// TODO we should create a JarEntryEditorInput if storage is a NonJavaResource from jdt to match the editor input used when double clicking on the same resource in a jar.
IEditorInput editorInput = (storage instanceof IFile) ? new FileEditorInput((IFile) storage)
: new XtextReadonlyEditorInput(storage);
IWorkbenchPage activePage = workbench.getActiveWorkbenchWindow().getActivePage();
IEditorPart editor = IDE.openEditor(activePage, editorInput, editorID);
selectAndReveal(editor, uri, crossReference, indexInList, select);
return EditorUtils.getXtextEditor(editor);
} catch (WrappedException e) {
logger.error("Error while opening editor part for EMF URI '" + uri + "'", e.getCause());
} catch (PartInitException partInitException) {
logger.error("Error while opening editor part for EMF URI '" + uri + "'", partInitException);
}
}
return null;
}
示例4: selectAndReveal
import org.eclipse.xtext.ui.editor.utils.EditorUtils; //导入方法依赖的package包/类
protected void selectAndReveal(IEditorPart openEditor, final URI uri, final EReference crossReference,
final int indexInList, final boolean select) {
final XtextEditor xtextEditor = EditorUtils.getXtextEditor(openEditor);
if (xtextEditor != null) {
xtextEditor.getDocument().readOnly(new IUnitOfWork.Void<XtextResource>() {
@Override
public void process(XtextResource resource) throws Exception {
if (resource != null) {
EObject object = findEObjectByURI(uri, resource);
if (object != null) {
ITextRegion location = (crossReference != null) ? locationProvider
.getSignificantTextRegion(object, crossReference, indexInList)
: locationProvider.getSignificantTextRegion(object);
if (select)
xtextEditor.selectAndReveal(location.getOffset(), location.getLength());
}
}
}
});
}
}
示例5: getXtextEditor
import org.eclipse.xtext.ui.editor.utils.EditorUtils; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override
public XtextEditor getXtextEditor(final IEditorPart openEditor) {
return EditorUtils.getXtextEditor(openEditor);
}