本文整理汇总了Java中org.eclipse.xtext.ui.editor.XtextEditor.getEditorInput方法的典型用法代码示例。如果您正苦于以下问题:Java XtextEditor.getEditorInput方法的具体用法?Java XtextEditor.getEditorInput怎么用?Java XtextEditor.getEditorInput使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.xtext.ui.editor.XtextEditor
的用法示例。
在下文中一共展示了XtextEditor.getEditorInput方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: execute
import org.eclipse.xtext.ui.editor.XtextEditor; //导入方法依赖的package包/类
@Override
public Object execute(final ExecutionEvent event) throws ExecutionException {
XtextEditor xtextEditor = EditorUtils.getActiveXtextEditor(event);
if (xtextEditor != null && xtextEditor.getEditorInput() instanceof XtextReadonlyEditorInput) {
return null;
}
return super.execute(event);
}
示例2: getAnnotationModel
import org.eclipse.xtext.ui.editor.XtextEditor; //导入方法依赖的package包/类
protected IAnnotationModel getAnnotationModel(XtextEditor editor) {
if(editor != null) {
IEditorInput editorInput = editor.getEditorInput();
if(editorInput != null) {
IDocumentProvider documentProvider = editor.getDocumentProvider();
if(documentProvider != null) {
return documentProvider.getAnnotationModel(editorInput);
}
}
}
return null;
}
示例3: getResourceURI
import org.eclipse.xtext.ui.editor.XtextEditor; //导入方法依赖的package包/类
protected URI getResourceURI(XtextEditor editor) {
IEditorInput editorInput = editor.getEditorInput();
if (editorInput instanceof IStorageEditorInput) {
try {
return storage2UriMapper.getUri(((IStorageEditorInput) editorInput).getStorage());
} catch (CoreException e) {
LOG.error("Error getting URI for storage", e);
}
}
return null;
}
示例4: executeOnEditor
import org.eclipse.xtext.ui.editor.XtextEditor; //导入方法依赖的package包/类
@Override
protected Object executeOnEditor(ExecutionEvent event) {
IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindow(event);
if (window == null) {
return null;
}
final XtextEditor xtextEditor = EditorUtils.getActiveXtextEditor(event);
if (xtextEditor == null) {
return null;
}
FileEditorInput input = (FileEditorInput) xtextEditor.getEditorInput();
final java.io.File fileOnDisk = input.getFile().getLocation().toFile();
if (xtextEditor.isDirty()) {
if (MessageDialog.openConfirm(window.getShell(), "Save and Run JLustre2Excel",
"The file " + input.getName() + " has unsaved changes. Save file and continue?")) {
xtextEditor.doSave(null);
} else {
return null;
}
}
WorkspaceJob job = new WorkspaceJob("JLustre2Excel") {
@Override
public IStatus runInWorkspace(final IProgressMonitor monitor) {
if (hasErrors(xtextEditor)) {
return errorStatus("Lustre file contains errors");
}
if (hasFunctions(xtextEditor)) {
return errorStatus("Functions are not support in JLustre2Excel");
}
return runJob(fileOnDisk);
}
};
job.schedule();
return null;
}
示例5: executeOnEditor
import org.eclipse.xtext.ui.editor.XtextEditor; //导入方法依赖的package包/类
@Override
protected Object executeOnEditor(ExecutionEvent event) {
window = HandlerUtil.getActiveWorkbenchWindow(event);
if (window == null) {
return null;
}
final XtextEditor xtextEditor = EditorUtils.getActiveXtextEditor(event);
if (xtextEditor == null) {
return null;
}
FileEditorInput input = (FileEditorInput) xtextEditor.getEditorInput();
final java.io.File fileOnDisk = input.getFile().getLocation().toFile();
if (xtextEditor.isDirty()) {
if (MessageDialog.openConfirm(window.getShell(), "Save and Run JKind", "The file "
+ input.getName() + " has unsaved changes. Save file and continue?")) {
xtextEditor.doSave(null);
} else {
return null;
}
}
WorkspaceJob job = new WorkspaceJob("JKind Analysis") {
@Override
public IStatus runInWorkspace(final IProgressMonitor monitor) {
activateTerminateHandler(monitor, this);
JKindResult result = initializeJKindResult(xtextEditor);
if (result == null) {
return errorStatus("Lustre file contains errors");
}
return runJob(fileOnDisk, result, monitor);
}
};
job.schedule();
return null;
}
示例6: getTargetFile
import org.eclipse.xtext.ui.editor.XtextEditor; //导入方法依赖的package包/类
protected IFile getTargetFile(String[] validTargetTypes) throws ExecutionException {
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if (window != null) {
ISelection selection = (ISelection) window.getSelectionService().getSelection();
if (selection instanceof TextSelection) {
XtextEditor editor = EditorUtils.getActiveXtextEditor();
if (editor != null) {
IEditorInput editorInput = editor.getEditorInput();
if (editorInput instanceof IFileEditorInput) {
return ((IFileEditorInput) editorInput).getFile();
}
}
}
if (!(selection instanceof IStructuredSelection) || selection.isEmpty()) {
throw new ExecutionException("Nothing is selected for action");
}
Object firstElement = ((IStructuredSelection)selection).getFirstElement();
if (firstElement instanceof IAdaptable)
{
if (firstElement instanceof org.eclipse.core.resources.IFile) {
String ext = ((org.eclipse.core.resources.IFile)firstElement).getFileExtension();
boolean validTarget = false;
for (String s : validTargetTypes) {
if (s.equals(ext)) {
validTarget = true;
break;
}
}
if (validTarget) {
return (IFile) firstElement;
}
else {
throw new ExecutionException("Only files of type .sadl or .test can be targets for this action");
}
}
else {
throw new ExecutionException("A valid target file must be selected");
}
}
}
throw new ExecutionException("No project window selected");
}
示例7: executeOnEditor
import org.eclipse.xtext.ui.editor.XtextEditor; //导入方法依赖的package包/类
@Override
protected Object executeOnEditor(ExecutionEvent event) {
window = HandlerUtil.getActiveWorkbenchWindow(event);
if (window == null) {
return null;
}
final XtextEditor xtextEditor = EditorUtils.getActiveXtextEditor(event);
if (xtextEditor == null) {
return null;
}
FileEditorInput input = (FileEditorInput) xtextEditor.getEditorInput();
final java.io.File fileOnDisk = input.getFile().getLocation().toFile();
if (xtextEditor.isDirty()) {
if (MessageDialog
.openConfirm(window.getShell(), "Save and Run JRealizability", "The file "
+ input.getName() + " has unsaved changes. Save file and continue?")) {
xtextEditor.doSave(null);
} else {
return null;
}
}
WorkspaceJob job = new WorkspaceJob("JKind Analysis") {
@Override
public IStatus runInWorkspace(final IProgressMonitor monitor) {
activateTerminateHandler(monitor, this);
if (!hasQuery(xtextEditor)) {
return errorStatus("Main node does not contain realizability query");
}
JRealizabilityResult result = initializeJRealizabilityResult(xtextEditor);
if (result == null) {
return errorStatus("Lustre file contains errors");
}
return runJob(fileOnDisk, result, monitor);
}
};
job.schedule();
return null;
}