本文整理汇总了Java中org.eclipse.ui.IFileEditorInput.getFile方法的典型用法代码示例。如果您正苦于以下问题:Java IFileEditorInput.getFile方法的具体用法?Java IFileEditorInput.getFile怎么用?Java IFileEditorInput.getFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.ui.IFileEditorInput
的用法示例。
在下文中一共展示了IFileEditorInput.getFile方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createJavaProjectThroughActiveEditor
import org.eclipse.ui.IFileEditorInput; //导入方法依赖的package包/类
private IJavaProject createJavaProjectThroughActiveEditor() {
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
if(page.getActiveEditor().getEditorInput() instanceof IFileEditorInput)
{
IFileEditorInput input = (IFileEditorInput) page.getActiveEditor().getEditorInput();
IFile file = input.getFile();
IProject activeProject = file.getProject();
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(activeProject.getName());
return JavaCore.create(project);
}
else if(page.getActiveEditor().getEditorInput() instanceof IClassFileEditorInput)
{
IClassFileEditorInput classFileEditorInput=(InternalClassFileEditorInput)page.getActiveEditor().getEditorInput() ;
IClassFile classFile=classFileEditorInput.getClassFile();
return classFile.getJavaProject();
}
return null;
}
示例2: loadProperties
import org.eclipse.ui.IFileEditorInput; //导入方法依赖的package包/类
/**
*
* loading the properties files
*/
public void loadProperties() {
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
if (page.getActiveEditor().getEditorInput() instanceof IFileEditorInput) {
IFileEditorInput input = (IFileEditorInput) page.getActiveEditor().getEditorInput();
List<File> paramNameList = null;
IFile file = input.getFile();
IProject activeProject = file.getProject();
final File globalparamFilesPath = new File(activeProject.getLocation().toString() + "/" + "globalparam");
final File localParamFilePath = new File(activeProject.getLocation().toString() + "/" + Constants.PARAM_FOLDER);
File[] files = (File[]) ArrayUtils.addAll(listFilesForFolder(globalparamFilesPath),
getJobsPropertyFile(localParamFilePath,file));
if (files != null) {
paramNameList = Arrays.asList(files);
getParamMap(paramNameList, null);
}
}
}
示例3: getParameterFileIPath
import org.eclipse.ui.IFileEditorInput; //导入方法依赖的package包/类
private IPath getParameterFileIPath(){
if(getEditorInput() instanceof IFileEditorInput){
IFileEditorInput input = (IFileEditorInput)getEditorInput() ;
IFile file = input.getFile();
IProject activeProject = file.getProject();
String activeProjectName = activeProject.getName();
IPath parameterFileIPath =new Path("/"+activeProjectName+"/param/"+ getPartName().replace(".job", ".properties"));
activeProjectName.concat("_").concat(getPartName().replace(".job", "_"));
return parameterFileIPath;
}else{
return null;
}
}
示例4: disableRunningGraphResource
import org.eclipse.ui.IFileEditorInput; //导入方法依赖的package包/类
private void disableRunningGraphResource(IEditorInput editorInput,String partName){
if(editorInput instanceof IFileEditorInput){
IFileEditorInput input = (IFileEditorInput)editorInput ;
IFile fileJob = input.getFile();
IPath xmlFileIPath =new Path(input.getFile().getFullPath().toOSString().replace(".job", ".xml"));
IFile fileXml = ResourcesPlugin.getWorkspace().getRoot().getFile(xmlFileIPath);
ResourceAttributes attributes = new ResourceAttributes();
attributes.setReadOnly(true);
attributes.setExecutable(true);
try {
fileJob.setResourceAttributes(attributes);
fileXml.setResourceAttributes(attributes);
} catch (CoreException e) {
logger.error("Unable to disable running job resources", e);
}
}
}
示例5: enableRunningGraphResource
import org.eclipse.ui.IFileEditorInput; //导入方法依赖的package包/类
private void enableRunningGraphResource(IEditorInput editorInput,
String partName) {
IFileEditorInput input = (IFileEditorInput)editorInput ;
IFile fileJob = input.getFile();
IPath xmlFileIPath =new Path(input.getFile().getFullPath().toOSString().replace(".job", ".xml"));
IFile fileXml = ResourcesPlugin.getWorkspace().getRoot().getFile(xmlFileIPath);
ResourceAttributes attributes = new ResourceAttributes();
attributes.setReadOnly(false);
attributes.setExecutable(true);
try {
if(fileJob.exists()){
fileJob.setResourceAttributes(attributes);
}
if(fileXml.exists()){
fileXml.setResourceAttributes(attributes);
}
} catch (CoreException e) {
logger.error("Unable to enable locked job resources",e);
}
}
示例6: getOpenEditorOfMarker
import org.eclipse.ui.IFileEditorInput; //导入方法依赖的package包/类
/**
* Note: it compares marker's resource file name and open editors' file name.
*
* @param marker
* @return if marker's editor is open, return editor, else return null
*/
public static IEditorPart getOpenEditorOfMarker(final IMarker marker) {
final IWorkbenchWindow[] windows = PlatformUI.getWorkbench().getWorkbenchWindows();
for (final IWorkbenchWindow iWorkbenchWindow : windows) {
final IWorkbenchPage[] pages = iWorkbenchWindow.getPages();
for (final IWorkbenchPage iWorkbenchPage : pages) {
final IEditorReference[] editors = iWorkbenchPage.getEditorReferences();
for (final IEditorReference iEditorReference : editors) {
try {
if (iEditorReference instanceof IFileEditorInput) {
final IFileEditorInput input = (IFileEditorInput) iEditorReference.getEditorInput();
final IFile file = input.getFile();
// TODO Caused by: java.lang.NullPointerException when delete marker on ecore editor.
if (file.getFullPath().equals(marker.getResource().getFullPath())) {
return iEditorReference.getEditor(false);
}
}
} catch (final PartInitException e) {
e.printStackTrace();
}
}
}
}
return null;
}
示例7: launch
import org.eclipse.ui.IFileEditorInput; //导入方法依赖的package包/类
@Override
public void launch(IEditorPart editor, String mode)
{
// Extract resource from editor
if (editor != null) {
IFileEditorInput input = (IFileEditorInput) editor.getEditorInput();
IFile file = input.getFile();
IProject activeProject = file.getProject();
// If editor existed, run config using extracted resource in
// indicated mode
runConfig(activeProject, mode, editor.getSite().getWorkbenchWindow().getShell());
} else {
WPILibCPPPlugin.logError("Editor was null.", null);
}
}
示例8: getFirstSelectedElement
import org.eclipse.ui.IFileEditorInput; //导入方法依赖的package包/类
/**
* @param selection
* @return first element of the selection
*/
public static Object getFirstSelectedElement(ISelection selection) {
if (selection instanceof TreeSelection) {
TreeSelection treeSelection = (TreeSelection) selection;
return treeSelection.getFirstElement();
} else if (selection instanceof StructuredSelection) {
StructuredSelection structuredSelection = (StructuredSelection) selection;
return structuredSelection.getFirstElement();
} else if (selection instanceof IFileEditorInput) {
IFileEditorInput editorInput = (FileEditorInput) selection;
return editorInput.getFile();
} else if (selection instanceof TextSelection) {
return null;
} else {
throw new RuntimeException(
Messages.GeneratorUtils_SelectionNotSupported);
}
}
示例9: compileUmpleFile
import org.eclipse.ui.IFileEditorInput; //导入方法依赖的package包/类
protected void compileUmpleFile(ExecutionEvent event,boolean generate,String... language){
setDefualtConsole();
IEditorInput editorInput = HandlerUtil.getActiveEditorInput(event);
IFileEditorInput fileEditorInput =(IFileEditorInput)editorInput.getAdapter(IFileEditorInput.class);
IFile iFile = fileEditorInput.getFile();
if (iFile.getFileExtension().toLowerCase().equals("ump")){
String fileName = iFile.getName();
String absolutePath = iFile.getLocation().toString();
String filePath = absolutePath.substring(0, absolutePath.lastIndexOf(fileName, absolutePath.length() - 1));
try {
UmpleModel uModel = getUmpleModel(filePath,fileName,event);
runUmpleModel(uModel,event,generate,language);
refreshProjectFoler(editorInput);
} catch (Exception e) {
showErrorMessage(e.getMessage());
}
} else{
showErrorMessage("Please select an Umple file. The file must have .ump extension.");
}
}
示例10: initFromInput
import org.eclipse.ui.IFileEditorInput; //导入方法依赖的package包/类
private void initFromInput(IEditorInput input) throws PartInitException {
if (input instanceof NodeListEditorInput) {
NodeListEditorInput docInput = (NodeListEditorInput) input;
file = null;
nodeListInfo = docInput.getNodeListDocument();
baseName = docInput.getBaseName();
setPartName(docInput.getName());
needsSave = true;
} else if (input instanceof IFileEditorInput) {
IFileEditorInput fileInput = (IFileEditorInput) input;
file = fileInput.getFile();
NodeListDocXmlPersist persist = NodeListDocXmlPersist.buildForLoad(file);
nodeListInfo = persist.load(file.getRawLocationURI());
baseName = buildFileInputBaseName(file);
setPartName(fileInput.getName());
needsSave = false;
} else {
// Something unexpected
throw new PartInitException(
"Input is not suitable for the NodeList editor.");
}
}
示例11: init
import org.eclipse.ui.IFileEditorInput; //导入方法依赖的package包/类
@Override
public void init(IEditorSite site, IEditorInput input)
throws PartInitException {
setSite(site);
setInput(input);
// only accept a file as input.
if (input instanceof IFileEditorInput) {
// get the URI
IFileEditorInput fileInput = (IFileEditorInput) input;
file = fileInput.getFile();
EdgeMatcherDocXmlPersist persist = EdgeMatcherDocXmlPersist.build(true);
matcherInfo = persist.load(file.getRawLocationURI());
setPartName(buildPartName());
setDirtyState(false);
return;
}
// Something unexpected
throw new PartInitException(
"Input for editor is not suitable for the RelationSetDescriptorEditor");
}
示例12: isBPM2FileType
import org.eclipse.ui.IFileEditorInput; //导入方法依赖的package包/类
private boolean isBPM2FileType(final IFileEditorInput editorInput) {
boolean isBPMN2File = false;
IFile file = editorInput.getFile();
try {
IContentDescription desc = file.getContentDescription();
if (desc != null) {
IContentType type = desc.getContentType();
if (ActivitiBPMNDiagramConstants.BPMN2_CONTENTTYPE_ID.equals(type.getId())) {
isBPMN2File = true;
}
}
} catch (CoreException e) {
e.printStackTrace();
return isBPMN2File;
}
return isBPMN2File;
}
示例13: getFile
import org.eclipse.ui.IFileEditorInput; //导入方法依赖的package包/类
protected IFile getFile()
{
AbstractThemeableEditor editor = fEditor;
if (editor != null)
{
IEditorInput editorInput = editor.getEditorInput();
if (editorInput instanceof IFileEditorInput)
{
IFileEditorInput fileEditorInput = (IFileEditorInput) editorInput;
return fileEditorInput.getFile();
}
}
return null;
}
示例14: getEditorFile
import org.eclipse.ui.IFileEditorInput; //导入方法依赖的package包/类
/**
* Returns the resource file that the editor belongs to.
*
* @param editor
* @return
*/
public static IFile getEditorFile(AbstractThemeableEditor editor)
{
IEditorInput editorInput = editor.getEditorInput();
if (editorInput instanceof IFileEditorInput)
{
IFileEditorInput fileEditorInput = (IFileEditorInput) editorInput;
return fileEditorInput.getFile();
}
else if (editorInput instanceof FileStoreEditorInput)
{
FileStoreEditorInput input = (FileStoreEditorInput) editorInput;
IFile[] files = ResourcesPlugin.getWorkspace().getRoot().findFilesForLocationURI(input.getURI());
if (files != null && files.length > 0)
{
return files[0];
}
}
return null;
}
示例15: getAdapter
import org.eclipse.ui.IFileEditorInput; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public <T> T getAdapter(Class<T> adapter) {
if (BatchEditor.class.equals(adapter)) {
return (T) this;
}
if (IContentOutlinePage.class.equals(adapter)) {
return (T) getOutlinePage();
}
if (ColorManager.class.equals(adapter)) {
return (T) getColorManager();
}
if (IFile.class.equals(adapter)) {
IEditorInput input = getEditorInput();
if (input instanceof IFileEditorInput) {
IFileEditorInput feditorInput = (IFileEditorInput) input;
return (T) feditorInput.getFile();
}
return null;
}
if (ISourceViewer.class.equals(adapter)) {
return (T) getSourceViewer();
}
if (StatusMessageSupport.class.equals(adapter)) {
return (T) this;
}
if (ITreeContentProvider.class.equals(adapter) || BatchEditorTreeContentProvider.class.equals(adapter)) {
if (outlinePage==null){
return null;
}
return (T) outlinePage.getContentProvider();
}
return super.getAdapter(adapter);
}