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