当前位置: 首页>>代码示例>>Java>>正文


Java XtextEditor.getEditorInput方法代码示例

本文整理汇总了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);
}
 
开发者ID:dsldevkit,项目名称:dsl-devkit,代码行数:9,代码来源:CheckValidateActionHandler.java

示例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;
}
 
开发者ID:cplutte,项目名称:bts,代码行数:13,代码来源:OccurrenceMarker.java

示例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;
}
 
开发者ID:cplutte,项目名称:bts,代码行数:12,代码来源:OpenDocumentTracker.java

示例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;
}
 
开发者ID:agacek,项目名称:jkind-xtext,代码行数:41,代码来源:RunJLustre2ExcelHandler.java

示例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;
}
 
开发者ID:agacek,项目名称:jkind-xtext,代码行数:40,代码来源:RunJKindHandler.java

示例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");
}
 
开发者ID:crapo,项目名称:sadlos2,代码行数:43,代码来源:SadlActionHandler.java

示例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;
}
 
开发者ID:agacek,项目名称:jkind-xtext,代码行数:44,代码来源:RunJRealizabilityHandler.java


注:本文中的org.eclipse.xtext.ui.editor.XtextEditor.getEditorInput方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。