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


Java ResourceUtil类代码示例

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


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

示例1: getSeverity

import org.eclipse.ui.ide.ResourceUtil; //导入依赖的package包/类
private int getSeverity() {
	IEditorInput editorInput = getEditorInput();
	if (editorInput == null) {
		return IMarker.SEVERITY_INFO;
	}
	try {
		final IResource resource = ResourceUtil.getResource(editorInput);
		if (resource == null) {
			return IMarker.SEVERITY_INFO;
		}
		int severity = resource.findMaxProblemSeverity(IMarker.PROBLEM, true, IResource.DEPTH_INFINITE);
		return severity;
	} catch (CoreException e) {
		// Might be a project that is not open
	}
	return IMarker.SEVERITY_INFO;
}
 
开发者ID:de-jcup,项目名称:eclipse-batch-editor,代码行数:18,代码来源:BatchEditor.java

示例2: isMarkerChangeForThisEditor

import org.eclipse.ui.ide.ResourceUtil; //导入依赖的package包/类
private boolean isMarkerChangeForThisEditor(IResourceChangeEvent event) {
	IResource resource = ResourceUtil.getResource(getEditorInput());
	if (resource == null) {
		return false;
	}
	IPath path = resource.getFullPath();
	if (path == null) {
		return false;
	}
	IResourceDelta eventDelta = event.getDelta();
	if (eventDelta == null) {
		return false;
	}
	IResourceDelta delta = eventDelta.findMember(path);
	if (delta == null) {
		return false;
	}
	boolean isMarkerChangeForThisResource = (delta.getFlags() & IResourceDelta.MARKERS) != 0;
	return isMarkerChangeForThisResource;
}
 
开发者ID:de-jcup,项目名称:eclipse-batch-editor,代码行数:21,代码来源:BatchEditor.java

示例3: getPathFromInput

import org.eclipse.ui.ide.ResourceUtil; //导入依赖的package包/类
public static String getPathFromInput(IEditorInput in) {
    IResource res = ResourceUtil.getResource(in);
    if (res != null) {
        try {
            if (res.getProject().hasNature(NATURE.ID)) {
                return res.getLocation().toOSString();
            }
        } catch (CoreException ex) {
            Log.log(Log.LOG_WARNING, "Nature error", ex); //$NON-NLS-1$
        }
    }
    if (in instanceof IURIEditorInput) {
        return Paths.get(((IURIEditorInput) in).getURI()).toString();
    } else {
        return null;
    }
}
 
开发者ID:pgcodekeeper,项目名称:pgcodekeeper,代码行数:18,代码来源:PgDbParser.java

示例4: getCurrentDb

import org.eclipse.ui.ide.ResourceUtil; //导入依赖的package包/类
public DbInfo getCurrentDb() {
    if (currentDB != null) {
        return currentDB;
    }

    IResource res = ResourceUtil.getResource(getEditorInput());
    if (res != null) {
        IEclipsePreferences prefs = PgDbProject.getPrefs(res.getProject());
        if (prefs != null) {
            List<DbInfo> lastStore = DbInfo.preferenceToStore(
                    prefs.get(PROJ_PREF.LAST_DB_STORE_EDITOR, "")); //$NON-NLS-1$
            if (!lastStore.isEmpty()) {
                return lastStore.get(0);
            }
        }
    }
    return null;
}
 
开发者ID:pgcodekeeper,项目名称:pgcodekeeper,代码行数:19,代码来源:SQLEditor.java

示例5: getTitleImage

import org.eclipse.ui.ide.ResourceUtil; //导入依赖的package包/类
@Override
public Image getTitleImage() {
    Image image = super.getTitleImage();
    try {
        IEditorInput input = getEditorInput();
        IResource file = ResourceUtil.getResource(input);
        if (input.exists() && file != null
                && file.findMarkers(MARKER.ERROR, false, IResource.DEPTH_ZERO).length > 0) {
            if (errorTitleImage == null) {
                errorTitleImage = new DecorationOverlayIcon(image,
                        PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(
                                ISharedImages.IMG_DEC_FIELD_ERROR), IDecoration.BOTTOM_LEFT)
                        .createImage();
            }
            return errorTitleImage;
        }
    } catch (CoreException e) {
        Log.log(e);
    }
    return image;
}
 
开发者ID:pgcodekeeper,项目名称:pgcodekeeper,代码行数:22,代码来源:SQLEditor.java

示例6: getCurrentDocument

import org.eclipse.ui.ide.ResourceUtil; //导入依赖的package包/类
/**
 * Returns {@link IDocument} in the open editor, or null if the editor
 * is not open.
 */
static IDocument getCurrentDocument(IFile file) {
  try {
    IWorkbench workbench = PlatformUI.getWorkbench();
    IWorkbenchWindow activeWorkbenchWindow = workbench.getActiveWorkbenchWindow();
    IWorkbenchPage activePage = activeWorkbenchWindow.getActivePage();
    IEditorPart editorPart = ResourceUtil.findEditor(activePage, file);
    if (editorPart != null) {
      IDocument document = editorPart.getAdapter(IDocument.class);
      return document;
    }
    return null;
  } catch (IllegalStateException ex) {
    //If workbench does not exist
    return null;
  }
}
 
开发者ID:GoogleCloudPlatform,项目名称:google-cloud-eclipse,代码行数:21,代码来源:XsltQuickFix.java

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

示例8: 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

示例9: decorate

import org.eclipse.ui.ide.ResourceUtil; //导入依赖的package包/类
@Override
public void decorate(Object element, IDecoration decoration) {
    final IResource resource = ResourceUtil.getResource(element);

    if (resource != null && resource.getType() != ROOT) {
        final CodenvyProvider provider = (CodenvyProvider)getProvider(resource.getProject(), CodenvyProvider.PROVIDER_ID);

        if (provider != null) {
            final CodenvyMetaResource metaResource = (CodenvyMetaResource)getAdapter(resource, CodenvyMetaResource.class, true);

            if (metaResource != null && metaResource.isTracked()) {
                decoration.addOverlay(trackedImageDescriptor);

                if (resource.getType() == PROJECT) {
                    decoration.addSuffix(" [codenvy: " + provider.getProjectMetadata().url + "]");
                }
            }
        }
    }
}
 
开发者ID:codenvy-legacy,项目名称:eclipse-plugin,代码行数:21,代码来源:CodenvyLightweightLabelDecorator.java

示例10: 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

示例11: getContextResource

import org.eclipse.ui.ide.ResourceUtil; //导入依赖的package包/类
/**
 * Attempts to guess the most relevant resource for the current workbench state
 */
public static IResource getContextResource() {
	IWorkbenchPage page = getActivePage();
	if (page == null) {
		return null;
	}
	
	final ISelection selection = page.getSelection();
	if (selection instanceof IStructuredSelection) {
		final IStructuredSelection ss = (IStructuredSelection) selection;
		if (!ss.isEmpty()) {
			final Object obj = ss.getFirstElement();
			if (obj instanceof IResource) {
				return (IResource) obj;
			}
		}
	}
	IEditorPart editor = page.getActiveEditor();
	if (editor == null) {
		return null;
	}
	
	IEditorInput editorInput = editor.getEditorInput();
	return ResourceUtil.getResource(editorInput);
}
 
开发者ID:GoClipse,项目名称:goclipse,代码行数:28,代码来源:WorkbenchUtils.java

示例12: 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

示例13: 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

示例14: saveLastDb

import org.eclipse.ui.ide.ResourceUtil; //导入依赖的package包/类
public static void saveLastDb(DbInfo lastDb, IEditorInput inputForProject) {
    IResource res = ResourceUtil.getResource(inputForProject);
    if (res != null) {
        IEclipsePreferences prefs = PgDbProject.getPrefs(res.getProject());
        if (prefs != null) {
            prefs.put(PROJ_PREF.LAST_DB_STORE_EDITOR, lastDb.toString());
            try {
                prefs.flush();
            } catch (BackingStoreException ex) {
                Log.log(ex);
            }
        }
    }
}
 
开发者ID:pgcodekeeper,项目名称:pgcodekeeper,代码行数:15,代码来源:SQLEditor.java

示例15: doSave

import org.eclipse.ui.ide.ResourceUtil; //导入依赖的package包/类
@Override
public void doSave(IProgressMonitor progressMonitor) {
    super.doSave(progressMonitor);
    IResource res = ResourceUtil.getResource(getEditorInput());
    try {
        if (res == null || !PgUIDumpLoader.isInProject(res)) {
            refreshParser(getParser(), res, progressMonitor);
        }
    } catch (Exception ex) {
        Log.log(ex);
    }
}
 
开发者ID:pgcodekeeper,项目名称:pgcodekeeper,代码行数:13,代码来源:SQLEditor.java


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