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


Java ResourceUtil.getFile方法代码示例

本文整理汇总了Java中org.eclipse.ui.ide.ResourceUtil.getFile方法的典型用法代码示例。如果您正苦于以下问题:Java ResourceUtil.getFile方法的具体用法?Java ResourceUtil.getFile怎么用?Java ResourceUtil.getFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.ui.ide.ResourceUtil的用法示例。


在下文中一共展示了ResourceUtil.getFile方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getFilePath

import org.eclipse.ui.ide.ResourceUtil; //导入方法依赖的package包/类
private IPath getFilePath(ITextEditor textEditor) {
	IEditorInput editorInput = textEditor.getEditorInput();
	IFile file = ResourceUtil.getFile(editorInput);
	File localFile = null;
	if (file != null) {
		localFile = file.getLocation().toFile();
	} else if (editorInput instanceof FileStoreEditorInput) {
		FileStoreEditorInput fileStoreEditorInput = (FileStoreEditorInput) editorInput;
		URI uri = fileStoreEditorInput.getURI();
		IFileStore location = EFS.getLocalFileSystem().getStore(uri);
		try {
			localFile = location.toLocalFile(EFS.NONE, null);
		} catch (CoreException e) {
			// ignore
		}
	}
	if (localFile == null) {
		return null;
	} else {
		return Path.fromOSString(localFile.toString());
	}
}
 
开发者ID:cchabanois,项目名称:mesfavoris,代码行数:23,代码来源:TextEditorBookmarkPropertiesProvider.java

示例2: execute

import org.eclipse.ui.ide.ResourceUtil; //导入方法依赖的package包/类
@Override
public Object execute( ExecutionEvent event ) {
  IEditorInput editorInput = HandlerUtil.getActiveEditorInput( event );
  IFile resource = ResourceUtil.getFile( editorInput );
  if( resource != null ) {
    if( resource.isAccessible() ) {
      deleteResource( HandlerUtil.getActiveWorkbenchWindow( event ), resource );
    }
  } else {
    File file = getFile( editorInput );
    IWorkbenchWindow workbenchWindow = HandlerUtil.getActiveWorkbenchWindow( event );
    if( file != null && prompter.confirmDelete( workbenchWindow, file )) {
      deleteFile( workbenchWindow, file );
    }
  }
  return null;
}
 
开发者ID:rherrmann,项目名称:eclipse-extras,代码行数:18,代码来源:DeleteEditorFileHandler.java

示例3: getCurrentCompilationUnit

import org.eclipse.ui.ide.ResourceUtil; //导入方法依赖的package包/类
public static ICompilationUnit getCurrentCompilationUnit() {
	IEditorPart activeEditor = PlatformUI.getWorkbench().getActiveWorkbenchWindow()
			.getActivePage().getActiveEditor();
	if (activeEditor == null) {
		return null;
	}

	IFile file = (IFile) ResourceUtil.getFile(activeEditor.getEditorInput());
	if (file == null) {
		return null;
	}
	IJavaElement element = JavaCore.create(file);
	if (!(element instanceof ICompilationUnit) || !element.exists()) {
		return null;
	}
	return (ICompilationUnit) element;
}
 
开发者ID:cntoplolicon,项目名称:seasar2-assistant,代码行数:18,代码来源:JavaModelUtil.java

示例4: findSelection

import org.eclipse.ui.ide.ResourceUtil; //导入方法依赖的package包/类
@Override
public IStructuredSelection findSelection(IEditorInput input) {
  IFile file = ResourceUtil.getFile(input);

  if (file != null) {
    return new StructuredSelection(file);
  }

  IFileStore fileStore = (IFileStore) input.getAdapter(IFileStore.class);

  if (fileStore == null && input instanceof FileStoreEditorInput) {
    URI uri = ((FileStoreEditorInput)input).getURI();
    
    try {
      fileStore = EFS.getStore(uri);
    } catch (CoreException e) {

    }
  }
  
  if (fileStore != null) {
    return new StructuredSelection(fileStore);
  }

  return StructuredSelection.EMPTY;
}
 
开发者ID:GoClipse,项目名称:goclipse,代码行数:27,代码来源:NavigatorLinkHelper.java

示例5: execute

import org.eclipse.ui.ide.ResourceUtil; //导入方法依赖的package包/类
@Override
public Object execute(ExecutionEvent event) {
    SQLEditor editor = (SQLEditor) HandlerUtil.getActiveEditor(event);
    DbInfo dbInfo = editor.getCurrentDb();
    if (dbInfo == null){
        ExceptionNotifier.notifyDefault(Messages.sqlScriptDialog_script_select_storage, null);
        return null;
    }
    String text = editor.getEditorText();
    if (text.trim().isEmpty()) {
        ExceptionNotifier.notifyDefault(Messages.QuickUpdate_empty_script, null);
        return null;
    }

    IFile file = ResourceUtil.getFile(editor.getEditorInput());
    editor.doSave(new NullProgressMonitor());
    byte[] textSnapshot;
    try {
        textSnapshot = text.getBytes(file.getCharset());
    } catch (UnsupportedEncodingException | CoreException e) {
        ExceptionNotifier.notifyDefault(Messages.QuickUpdate_error_charset, e);
        return null;
    }

    QuickUpdateJob quickUpdateJob = new QuickUpdateJob(file, dbInfo, textSnapshot, editor);
    quickUpdateJob.setUser(true);
    quickUpdateJob.schedule();
    editor.saveLastDb(dbInfo);

    return null;
}
 
开发者ID:pgcodekeeper,项目名称:pgcodekeeper,代码行数:32,代码来源:QuickUpdate.java

示例6: getFilePath

import org.eclipse.ui.ide.ResourceUtil; //导入方法依赖的package包/类
@Override
protected String getFilePath() {
  IEditorPart editor;
  editor = Activator.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage()
      .getActiveEditor();
  String result = null;
  final IFile file = ResourceUtil.getFile(editor.getEditorInput());
  result = file.getLocation().makeAbsolute().toOSString();
  return result;
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:11,代码来源:UpdateSpecificationFromEditorHandler.java

示例7: getFilePath

import org.eclipse.ui.ide.ResourceUtil; //导入方法依赖的package包/类
@Override
public String getFilePath() {
  IEditorPart editor;
  editor = Activator.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage()
      .getActiveEditor();
  String result = null;
  final IFile file = ResourceUtil.getFile(editor.getEditorInput());
  result = file.getLocation().makeAbsolute().toOSString();
  return result;
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:11,代码来源:LoadSpecificationFromEditorHandler.java

示例8: getWorkspaceResource

import org.eclipse.ui.ide.ResourceUtil; //导入方法依赖的package包/类
private static IResource getWorkspaceResource(IWorkbenchPart part) {
	ITextEditor textEditor = getTextEditor(part);
	if (textEditor == null) {
		return null;
	}
	IEditorInput editorInput = textEditor.getEditorInput();
	IFile file = ResourceUtil.getFile(editorInput);
	return file;
}
 
开发者ID:cchabanois,项目名称:mesfavoris,代码行数:10,代码来源:PathBookmarkPropertiesProviderHelper.java

示例9: addWorkspacePath

import org.eclipse.ui.ide.ResourceUtil; //导入方法依赖的package包/类
private void addWorkspacePath(Map<String, String> properties, ITextEditor textEditor) {
	IEditorInput editorInput = textEditor.getEditorInput();
	IFile file = ResourceUtil.getFile(editorInput);
	if (file == null) {
		return;
	}
	putIfAbsent(properties, PROP_WORKSPACE_PATH, file.getFullPath().toPortableString());
	putIfAbsent(properties, PROP_PROJECT_NAME, file.getProject().getName());
}
 
开发者ID:cchabanois,项目名称:mesfavoris,代码行数:10,代码来源:TextEditorBookmarkPropertiesProvider.java

示例10: getXtextDocument

import org.eclipse.ui.ide.ResourceUtil; //导入方法依赖的package包/类
public IXtextDocument getXtextDocument(IResource resource) {
	IXtextDocument result = XtextDocumentUtil.get(resource);
	if(result == null) {
		IWorkbenchPage page = workbench.getActiveWorkbenchWindow().getActivePage();
		try {
			IFile file = ResourceUtil.getFile(resource);
			IEditorInput input = new FileEditorInput(file);
			page.openEditor(input, getEditorId());
		} catch (PartInitException e) {
			return null;
		}
	}
	return XtextDocumentUtil.get(resource);
}
 
开发者ID:cplutte,项目名称:bts,代码行数:15,代码来源:MarkerResolutionGenerator.java

示例11: extractFileFromSelection

import org.eclipse.ui.ide.ResourceUtil; //导入方法依赖的package包/类
private static IFile extractFileFromSelection( IStructuredSelection selection ) {
  IFile result = null;
  if( selection.size() == 1 ) {
    result = ResourceUtil.getFile( selection.getFirstElement() );
  }
  return result;
}
 
开发者ID:rherrmann,项目名称:eclipse-extras,代码行数:8,代码来源:OpenWithQuickMenuHandler.java

示例12: isEnabled

import org.eclipse.ui.ide.ResourceUtil; //导入方法依赖的package包/类
private static boolean isEnabled( IEvaluationContext evaluationContext ) {
  Object variable = evaluationContext.getVariable( ISources.ACTIVE_EDITOR_INPUT_NAME );
  boolean result = false;
  if( variable instanceof IEditorInput ) {
    IEditorInput editorInput = ( IEditorInput )variable;
    result = ResourceUtil.getFile( editorInput ) != null || getFile( editorInput ) != null;
  }
  return result;
}
 
开发者ID:rherrmann,项目名称:eclipse-extras,代码行数:10,代码来源:DeleteEditorFileHandler.java

示例13: querySaveAsFilePath

import org.eclipse.ui.ide.ResourceUtil; //导入方法依赖的package包/类
private IPath querySaveAsFilePath() {
  SaveAsDialog dialog = new SaveAsDialog( getSite().getShell() );
  IEditorInput editorInput = getEditorInput();
  IFile originalFile = ResourceUtil.getFile( editorInput );
  if( originalFile != null ) {
    dialog.setOriginalFile( originalFile );
  } else {
    dialog.setOriginalName( editorInput.getName() );
  }
  int dialogResult = dialog.open();
  return dialogResult == Window.OK ? dialog.getResult() : null;
}
 
开发者ID:rherrmann,项目名称:eclipse-extras,代码行数:13,代码来源:ImageViewerEditor.java

示例14: findSelection

import org.eclipse.ui.ide.ResourceUtil; //导入方法依赖的package包/类
public IStructuredSelection findSelection(IEditorInput input) {
	IJavaElement element= JavaUI.getEditorInputJavaElement(input);
	if (element == null) {
		IFile file = ResourceUtil.getFile(input);
		if (file != null) {
			element= JavaCore.create(file);
		}
	}
	return (element != null) ? new StructuredSelection(element) : StructuredSelection.EMPTY;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:11,代码来源:JavaFileLinkHelper.java

示例15: findSelection

import org.eclipse.ui.ide.ResourceUtil; //导入方法依赖的package包/类
public IStructuredSelection findSelection(IEditorInput anInput) {
	IFile file = ResourceUtil.getFile(anInput);
	if (file != null) {
		return new StructuredSelection(file);
	}
	return StructuredSelection.EMPTY;
}
 
开发者ID:heartsome,项目名称:translationstudio8,代码行数:8,代码来源:ResourceLinkHelper.java


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