當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。