本文整理汇总了Java中org.eclipse.ui.ide.ResourceUtil.getResource方法的典型用法代码示例。如果您正苦于以下问题:Java ResourceUtil.getResource方法的具体用法?Java ResourceUtil.getResource怎么用?Java ResourceUtil.getResource使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.ui.ide.ResourceUtil
的用法示例。
在下文中一共展示了ResourceUtil.getResource方法的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;
}
示例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;
}
示例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;
}
}
示例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;
}
示例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;
}
示例6: 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 + "]");
}
}
}
}
}
示例7: 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);
}
示例8: 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);
}
}
}
}
示例9: 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);
}
}
示例10: initParser
import org.eclipse.ui.ide.ResourceUtil; //导入方法依赖的package包/类
private PgDbParser initParser() throws InterruptedException, IOException, CoreException {
IEditorInput in = getEditorInput();
IResource res = ResourceUtil.getResource(in);
if (res != null && PgUIDumpLoader.isInProject(res)) {
return PgDbParser.getParser(res.getProject());
}
PgDbParser parser = new PgDbParser();
if (refreshParser(parser, res, null)) {
return parser;
}
throw new PartInitException("Unknown editor input: " + in); //$NON-NLS-1$
}
示例11: resourceChanged
import org.eclipse.ui.ide.ResourceUtil; //导入方法依赖的package包/类
@Override
public void resourceChanged(IResourceChangeEvent event) {
IResource file = ResourceUtil.getResource(getEditorInput());
IResourceDelta delta = event.getDelta();
if (delta != null && file != null) {
IResourceDelta child = delta.findMember(file.getFullPath());
if (child != null && (child.getFlags() & IResourceDelta.MARKERS) != 0) {
UiSync.exec(parentComposite, () -> {
if (!parentComposite.isDisposed()) {
firePropertyChange(IWorkbenchPart.PROP_TITLE);
}
});
}
}
}
示例12: updatePageModel
import org.eclipse.ui.ide.ResourceUtil; //导入方法依赖的package包/类
private void updatePageModel() {
String text = getText();
if (text == null) text = "";
IResource resource = ResourceUtil.getResource(getEditorInput());
pageModel.updateModel(resource, text);
pageDirty = false;
}
示例13: newMarker
import org.eclipse.ui.ide.ResourceUtil; //导入方法依赖的package包/类
public void newMarker() {
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
IResource file = ResourceUtil.getResource(page.getActiveEditor().getEditorInput());
createCoolMarker(file, 3);
createCoolMarker(file, 5);
createCoolMarker(file, 9);
createCoolMarker(file, 13);
createCoolMarker(file, 34);
}
示例14: isInProject
import org.eclipse.ui.ide.ResourceUtil; //导入方法依赖的package包/类
public static boolean isInProject(IEditorInput editorInput) {
IResource res = ResourceUtil.getResource(editorInput);
return res == null ? false : isInProject(res);
}
示例15: getProjectResource
import org.eclipse.ui.ide.ResourceUtil; //导入方法依赖的package包/类
/**
* @param editorInput
* @return param's {@link IResource} or null if not available or not {@link #isInProject(IPath)}
*/
public static IResource getProjectResource(IEditorInput editorInput) {
IResource res = ResourceUtil.getResource(editorInput);
return isInProject(res) ? res : null;
}