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


Java IMarker.getResource方法代码示例

本文整理汇总了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);
		}
	}
}
 
开发者ID:gw4e,项目名称:gw4e.project,代码行数:43,代码来源:MissingBuildPoliciesFileMarkerResolution.java

示例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();
  }
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:54,代码来源:MarkerUpdater.java


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