本文整理汇总了Java中org.eclipse.core.resources.IMarker.getResource方法的典型用法代码示例。如果您正苦于以下问题:Java IMarker.getResource方法的具体用法?Java IMarker.getResource怎么用?Java IMarker.getResource使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.core.resources.IMarker
的用法示例。
在下文中一共展示了IMarker.getResource方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: fix
import org.eclipse.core.resources.IMarker; //导入方法依赖的package包/类
private void fix(IMarker marker,IWorkbenchWindow ww,IProgressMonitor monitor) {
IResource resource = marker.getResource();
if (resource instanceof IFile) {
try {
IFile file = (IFile) resource;
buildFile = BuildPolicyManager.createBuildPoliciesFile(file,monitor);
marker.delete();
// remove all markers with this problem. The above
// resolution fixes also all others of the same type
IProject project = file.getProject();
IMarker[] markers = project.findMarkers(GW4EBuilder.MARKER_TYPE, true, IResource.DEPTH_INFINITE);
IContainer container = file.getParent();
for (int i = 0; i < markers.length; i++) {
IMarker m = markers[i];
IResource r = m.getResource();
if (r instanceof IFile) {
IFile f = (IFile) resource;
IContainer c = f.getParent();
if (c.equals(container) && m.exists()) {
Object attr = m.getAttribute(IJavaModelMarker.ID);
Integer pbid = (Integer) attr;
if (pbid == null)
continue;
if (pbid.equals(GW4EParser.MISSING_BUILD_POLICIES_FILE)) {
m.delete();
}
}
}
}
Display.getDefault().syncExec(new Runnable () {
@Override
public void run() {
JDTManager.openEditor(buildFile, ww);
ResourceManager.touchFolderResources(file);
}
});
} catch (Exception e) {
ResourceManager.logException(e);
}
}
}
示例2: updateSourcesToDelete
import org.eclipse.core.resources.IMarker; //导入方法依赖的package包/类
public static void updateSourcesToDelete(final IMarker beDeleted) {
try {
if (MarkUtilities.getSourceList(beDeleted).size() != 0) {
final ArrayList<MarkElement> sourceElements = MarkUtilities.getSourceList(beDeleted);
for (final MarkElement sourceElement : sourceElements) {
final IMarker sourceMarker = sourceElement.getiMarker();
List<IMarker> groupSourceMarkers = new ArrayList<IMarker>();
if (MarkUtilities.getGroupId(sourceMarker) != null) {
groupSourceMarkers = MarkerFactory.findMarkersByGroupId(sourceMarker.getResource(),
MarkUtilities.getGroupId(sourceMarker));
}
if (groupSourceMarkers.isEmpty()) {
groupSourceMarkers.add(sourceMarker);
}
for (final IMarker groupSourceMarker : groupSourceMarkers) {
if (MarkUtilities.getTargetList(groupSourceMarker).size() != 0) {
final ArrayList<MarkElement> targetElementsofSource =
MarkUtilities.getTargetList(groupSourceMarker);
for (int i = targetElementsofSource.size() - 1; i >= 0; i--) {
if (MarkUtilities.compare(targetElementsofSource.get(i).getiMarker(), beDeleted)) {
targetElementsofSource.remove(i);
}
}
MarkUtilities.setTargetList(groupSourceMarker, targetElementsofSource);
if (groupSourceMarker.getType().equals(MarkerFactory.MARKER_MAPPING)
&& targetElementsofSource.size() == 0) {
// final IEditorPart part =
IDE.openEditor(MarkerActivator.getActiveWorkbenchWindow().getActivePage(),
groupSourceMarker, false);
final Map<String, Object> attributes = groupSourceMarker.getAttributes();
final IResource res = groupSourceMarker.getResource();
AnnotationFactory.removeAnnotation(groupSourceMarker);
groupSourceMarker.delete();
MarkerUtilities.createMarker(res, attributes, MarkerFactory.MARKER_MARKING);
final IMarker newMarker = MarkerFactory.findMarkerBySourceId(res,
(String) attributes.get(IMarker.SOURCE_ID));
AnnotationFactory.addAnnotation(newMarker, AnnotationFactory.ANNOTATION_MARKING);
}
}
}
}
}
} catch (final CoreException e) {
e.printStackTrace();
}
}