本文整理汇总了Java中org.eclipse.ui.IEditorPart.getEditorInput方法的典型用法代码示例。如果您正苦于以下问题:Java IEditorPart.getEditorInput方法的具体用法?Java IEditorPart.getEditorInput怎么用?Java IEditorPart.getEditorInput使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.ui.IEditorPart
的用法示例。
在下文中一共展示了IEditorPart.getEditorInput方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getActiveEditorFile
import org.eclipse.ui.IEditorPart; //导入方法依赖的package包/类
/**
* Returns the opened file of the currently active editor.
*
* Returns null if no editor is open.
*/
private static IFile getActiveEditorFile() {
IEditorPart activeEditor = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage()
.getActiveEditor();
if (null == activeEditor) {
return null;
}
IEditorInput input = activeEditor.getEditorInput();
if (input instanceof FileEditorInput) {
return ((FileEditorInput) input).getFile();
} else {
return null;
}
}
示例2: addLinterError
import org.eclipse.ui.IEditorPart; //导入方法依赖的package包/类
public static void addLinterError(IEditorPart editor, JenkinsLinterError error) {
if (editor == null) {
return;
}
if (error == null) {
return;
}
IEditorInput input = editor.getEditorInput();
if (input == null) {
return;
}
IResource editorResource = input.getAdapter(IResource.class);
if (editorResource == null) {
return;
}
try {
linterMarkerHelper.createErrorMarker(editorResource, error.getMessage(), error.getLine());
} catch (CoreException e) {
logError("Was not able to add error markers", e);
}
}
示例3: canRun
import org.eclipse.ui.IEditorPart; //导入方法依赖的package包/类
public boolean canRun() {
InputType inputType = getInputType();
if (inputType.isStructuredSelection()) {
IStructuredSelection structuredSelection = getCurrentStructuredSelection();
if (canRunWithStructuredSelection(structuredSelection)) {
return true;
}
}
else if (inputType.isEditorInput()) {
IEditorPart editor = getActiveEditor();
IEditorInput editorInput = (editor != null) ? editor.getEditorInput() : null;
if (canRunWithEditorInput(editorInput)) {
return true;
}
}
else if (canRunWithNothing()) {
return true;
}
return false;
}
示例4: addScriptError
import org.eclipse.ui.IEditorPart; //导入方法依赖的package包/类
public static void addScriptError(IEditorPart editor, int line, BashError error, int severity) {
if (editor == null) {
return;
}
if (error == null) {
return;
}
IEditorInput input = editor.getEditorInput();
if (input == null) {
return;
}
IResource editorResource = input.getAdapter(IResource.class);
if (editorResource == null) {
return;
}
try {
scriptProblemMarkerHelper.createScriptMarker(severity, editorResource, error.getMessage(), line, error.getStart(),
+ error.getEnd());
} catch (CoreException e) {
logError("Was not able to add error markers", e);
}
}
示例5: getEditedFileFolder
import org.eclipse.ui.IEditorPart; //导入方法依赖的package包/类
public static File getEditedFileFolder() {
IWorkbenchPage page = null;
IWorkbenchWindow[] windows = PlatformUI.getWorkbench().getWorkbenchWindows();
for (int i = 0; i < windows.length; i++) {
if (windows[i] != null) {
IWorkbenchWindow window = windows[i];
page = windows[i].getActivePage();
if (page != null)
break;
}
}
IEditorPart part = page.getActiveEditor();
FileEditorInput editor = (FileEditorInput) part.getEditorInput();
IFile file = editor.getFile();
IFolder folder = (IFolder) file.getParent();
File f = null;
try {
f = ResourceManager.toFile(folder.getFullPath());
} catch (FileNotFoundException e) {
ResourceManager.logException(e);
}
return f;
}
示例6: launch
import org.eclipse.ui.IEditorPart; //导入方法依赖的package包/类
@Override
public void launch(IEditorPart editor, String mode) {
try {
IEditorInput editorInput = editor.getEditorInput();
if (editorInput instanceof IFileEditorInput) {
IFile selectObj = ((IFileEditorInput) editorInput).getFile();
launchFile(selectObj, mode);
} else {
showDialogNotImplemented(editor.getClass().getName());
}
} catch (CoreException e) {
System.out.println(e.getLocalizedMessage() + "\n");
}
}
示例7: launch
import org.eclipse.ui.IEditorPart; //导入方法依赖的package包/类
@Override
public void launch(IEditorPart editor, String mode) {
IEditorInput editorInput = editor.getEditorInput();
if (editorInput instanceof IFileEditorInput) {
IFile selectObj = ((IFileEditorInput) editorInput).getFile();
generateBug(selectObj);
} else {
showDialogNotImplemented(editor.getClass().getName());
}
}
示例8: execute
import org.eclipse.ui.IEditorPart; //导入方法依赖的package包/类
@Override
public Object execute(final ExecutionEvent event) throws ExecutionException {
final ISelection selection = getCurrentSelection(event);
if (null == selection) {
return null;
}
if (selection.isEmpty()) {
return null;
}
final AtomicReference<IFile> fileRef = new AtomicReference<>();
if (selection instanceof IStructuredSelection) {
final Object element = ((IStructuredSelection) selection).getFirstElement();
if (element instanceof IFile) {
fileRef.set((IFile) element);
}
} else if (selection instanceof ITextSelection) {
final IEditorPart editorPart = getActiveEditor(event);
if (null != editorPart) {
final IEditorInput input = editorPart.getEditorInput();
if (input instanceof IFileEditorInput) {
fileRef.set(((IFileEditorInput) input).getFile());
}
}
}
if (null != fileRef.get()) {
final Optional<IFile> generatedSource = fileLocator.tryGetGeneratedSourceForN4jsFile(fileRef.get());
if (generatedSource.isPresent()) {
tryOpenFileInEditor(fileRef.get(), generatedSource.get());
}
}
return null;
}
示例9: getLocationForEditor
import org.eclipse.ui.IEditorPart; //导入方法依赖的package包/类
/**
* Derives a location URI as expected by {@link TestDiscoveryHelper#collectTests(URI...)} from an editor.
*/
public static final URI getLocationForEditor(IEditorPart editor) {
final IEditorInput input = editor.getEditorInput();
if (input instanceof IFileEditorInput)
return getLocationForEditorInput((IFileEditorInput) input);
return null;
}
示例10: getEditorFile
import org.eclipse.ui.IEditorPart; //导入方法依赖的package包/类
public static IFile getEditorFile(IEditorPart editor) {
if (editor == null) {
return null;
}
IEditorInput editorInput = editor.getEditorInput();
if (!(editorInput instanceof FileEditorInput)) {
return null;
}
FileEditorInput fileInput = (FileEditorInput) editorInput;
return fileInput.getFile();
}
示例11: getInputFile
import org.eclipse.ui.IEditorPart; //导入方法依赖的package包/类
/**
* Obtains a file existing on an editor.
* @param editor the editor
* @return the file existing on the editor, or <code>null</code> if none
*/
public static IFile getInputFile(IEditorPart editor) {
IEditorInput input = editor.getEditorInput();
if (input instanceof IFileEditorInput) {
IFile file = ((IFileEditorInput)input).getFile();
return file;
}
return null;
}
示例12: execute
import org.eclipse.ui.IEditorPart; //导入方法依赖的package包/类
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
IWorkbenchWindow activeWorkbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if (activeWorkbenchWindow == null) {
return null;
}
IWorkbenchPage activePage = activeWorkbenchWindow.getActivePage();
if (activePage == null) {
return null;
}
IEditorPart editor = activePage.getActiveEditor();
if (editor == null) {
return null;
}
IEditorInput input = editor.getEditorInput();
if (input == null || ! (input instanceof FileEditorInput)) {
return null;
}
IFile file = ((FileEditorInput) input).getFile();
if (file != null && file.getType() == IResource.FILE && file.getFileExtension().equals("java")) {
utils = new ProjectUtils(file.getProject());
if (utils.isGluonMobileProject()) {
ISelection selection = HandlerUtil.getCurrentSelection(event);
Display.getDefault().asyncExec(() -> new JCode(utils, selection, (JavaEditor) editor));
}
}
return null;
}
示例13: test
import org.eclipse.ui.IEditorPart; //导入方法依赖的package包/类
@Override
public boolean test(Object receiver, String property, Object[] args, Object expectedValue) {
if ("gluonMobileFound".equals(property)) {
try {
IWorkbenchWindow activeWorkbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if (activeWorkbenchWindow == null) {
return false;
}
IWorkbenchPage activePage = activeWorkbenchWindow.getActivePage();
if (activePage == null) {
return false;
}
IWorkbenchPart activePart = activePage.getActivePart();
if (activePart == null || ! (activePart instanceof CompilationUnitEditor)) {
return false;
}
IEditorPart editor = activePage.getActiveEditor();
if (editor == null) {
return false;
}
IEditorInput input = editor.getEditorInput();
if (input == null || ! (input instanceof FileEditorInput)) {
return false;
}
IFile file = ((FileEditorInput) input).getFile();
if (file != null && file.getType() == IResource.FILE && file.getFileExtension().equals("java")) {
ProjectUtils utils = new ProjectUtils(file.getProject());
return utils.isGluonMobileProject();
}
} catch (Exception e) { }
}
return false;
}
示例14: removeLinterErrors
import org.eclipse.ui.IEditorPart; //导入方法依赖的package包/类
public static void removeLinterErrors(IEditorPart editor) {
if (editor == null) {
return;
}
IEditorInput input = editor.getEditorInput();
if (input == null) {
return;
}
IResource editorResource = input.getAdapter(IResource.class);
if (editorResource == null) {
return;
}
linterMarkerHelper.removeMarkers(editorResource);
}
示例15: removeScriptErrors
import org.eclipse.ui.IEditorPart; //导入方法依赖的package包/类
public static void removeScriptErrors(IEditorPart editor) {
if (editor == null) {
return;
}
IEditorInput input = editor.getEditorInput();
if (input == null) {
return;
}
}