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


Java ResourceUtil.getResource方法代码示例

本文整理汇总了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;
}
 
开发者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: 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

示例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);
}
 
开发者ID:GoClipse,项目名称:goclipse,代码行数:28,代码来源:WorkbenchUtils.java

示例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);
            }
        }
    }
}
 
开发者ID:pgcodekeeper,项目名称:pgcodekeeper,代码行数:15,代码来源:SQLEditor.java

示例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);
    }
}
 
开发者ID:pgcodekeeper,项目名称:pgcodekeeper,代码行数:13,代码来源:SQLEditor.java

示例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$
}
 
开发者ID:pgcodekeeper,项目名称:pgcodekeeper,代码行数:16,代码来源:SQLEditor.java

示例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);
                }
            });
        }
    }
}
 
开发者ID:pgcodekeeper,项目名称:pgcodekeeper,代码行数:16,代码来源:SQLEditor.java

示例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;
}
 
开发者ID:grosenberg,项目名称:fluentmark,代码行数:8,代码来源:FluentMkEditor.java

示例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);
}
 
开发者ID:TheRealTier,项目名称:ConSea,代码行数:11,代码来源:Kappamarker.java

示例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);
}
 
开发者ID:pgcodekeeper,项目名称:pgcodekeeper,代码行数:5,代码来源:PgUIDumpLoader.java

示例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;
}
 
开发者ID:pgcodekeeper,项目名称:pgcodekeeper,代码行数:9,代码来源:PgUIDumpLoader.java


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