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


Java IEditorPart.getEditorInput方法代码示例

本文整理汇总了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;
	}

}
 
开发者ID:eclipse,项目名称:n4js,代码行数:23,代码来源:CreateNewN4JSElementInModuleHandler.java

示例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);
	}

}
 
开发者ID:de-jcup,项目名称:eclipse-jenkins-editor,代码行数:24,代码来源:JenkinsEditorUtil.java

示例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;

    }
 
开发者ID:baloise,项目名称:eZooKeeper,代码行数:27,代码来源:BaseAction.java

示例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);
	}

}
 
开发者ID:de-jcup,项目名称:eclipse-bash-editor,代码行数:25,代码来源:BashEditorUtil.java

示例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;
}
 
开发者ID:gw4e,项目名称:gw4e.project,代码行数:24,代码来源:EditorHelper.java

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

示例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());
	}
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:11,代码来源:GenerateXpectReportShortcut.java

示例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;
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:39,代码来源:OpenGeneratedSourceInEditorHandler.java

示例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;
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:10,代码来源:TestDiscoveryUIUtils.java

示例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();
}
 
开发者ID:sebez,项目名称:vertigo-chroma-kspplugin,代码行数:14,代码来源:UiUtils.java

示例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;
}
 
开发者ID:liaoziyang,项目名称:ContentAssist,代码行数:14,代码来源:EditorUtilities.java

示例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;
}
 
开发者ID:gluonhq,项目名称:ide-plugins,代码行数:29,代码来源:InsertGluonFunctionHandler.java

示例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;
}
 
开发者ID:gluonhq,项目名称:ide-plugins,代码行数:34,代码来源:InsertFunctionTester.java

示例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);
}
 
开发者ID:de-jcup,项目名称:eclipse-jenkins-editor,代码行数:15,代码来源:JenkinsEditorUtil.java

示例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;
	}

}
 
开发者ID:de-jcup,项目名称:eclipse-batch-editor,代码行数:11,代码来源:BatchEditorUtil.java


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