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


Java IMarker.exists方法代码示例

本文整理汇总了Java中org.eclipse.core.resources.IMarker.exists方法的典型用法代码示例。如果您正苦于以下问题:Java IMarker.exists方法的具体用法?Java IMarker.exists怎么用?Java IMarker.exists使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.core.resources.IMarker的用法示例。


在下文中一共展示了IMarker.exists方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: removeAllRegisteredMarkers

import org.eclipse.core.resources.IMarker; //导入方法依赖的package包/类
/**
 * Removes all created error markers
 * 
 * @throws CoreException
 */
public void removeAllRegisteredMarkers() throws CoreException {
	List<IMarker> workingCopy = new ArrayList<>(markerRegistry);
	for (IMarker marker : workingCopy) {
		String type = null;
		boolean markerExists = marker.exists();
				
		if (markerExists){
			try {
				type = marker.getType();
			} catch (CoreException e) {
				markerExists=false;
			}
			
			if (IMarker.TASK.equals(type)) {
				/* tasks are not deleted */
				continue;
			}
		}
		markerRegistry.remove(marker);
		if (!markerExists) {
			/*
			 * means marker.getType() failed, because marker does not exist
			 * any more. This can happen when a marker is removed manually on ui.
			 */
			continue;
		}
		marker.delete();

	}
}
 
开发者ID:de-jcup,项目名称:eclipse-batch-editor,代码行数:36,代码来源:UnpersistedMarkerHelper.java

示例2: createMarker

import org.eclipse.core.resources.IMarker; //导入方法依赖的package包/类
private void createMarker() {
  editor =
      PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
  file = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage()
      .getActiveEditor().getEditorInput().getAdapter(IFile.class);
  selection =
      PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService().getSelection();

  final IMarker beAdded = getMarker();
  @SuppressWarnings("unused")
  String text = "";
  if (selection instanceof ITextSelection) {
    if (beAdded != null && beAdded.exists()) {
      text = ((ITextSelection) selection).getText();
      AnnotationFactory.addAnnotation(beAdded, AnnotationFactory.ANNOTATION_MARKING);
    }
  } else if (selection instanceof ITreeSelection) {
    if (editor instanceof EcoreEditor) {
      final ITreeSelection treeSelection = (ITreeSelection) selection;
      if (beAdded != null && beAdded.exists()) {
        if (treeSelection.getFirstElement() instanceof EModelElement) {
          text = ((ENamedElement) treeSelection.getFirstElement()).getName();
        } else {
          text = MarkUtilities.getText(beAdded);
        }
      }
    }
  }

  addToAlloyXML(beAdded);

  // MessageDialog dialog = new MessageDialog(MarkerActivator.getShell(), "Mark Information",
  // null,
  // "\"" + text + "\" has been selected to be marked", MessageDialog.INFORMATION,
  // new String[] {"OK"}, 0);
  // dialog.open();
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:38,代码来源:MarkHandler.java

示例3: updateSources

import org.eclipse.core.resources.IMarker; //导入方法依赖的package包/类
public static void updateSources(final IMarker marker) {
  if (MarkUtilities.getSourceList(marker).size() != 0) {
    final ArrayList<MarkElement> sourceElements = MarkUtilities.getSourceList(marker);

    for (final MarkElement sourceElement : sourceElements) {

      final IMarker sourceMarker = sourceElement.getiMarker();

      if (sourceMarker != null && sourceMarker.exists()
          && MarkUtilities.getTargetList(sourceMarker).size() != 0) {
        final ArrayList<MarkElement> targetElementsofSource =
            MarkUtilities.getTargetList(sourceMarker);

        for (final MarkElement targetElementofSource : targetElementsofSource) {
          if (targetElementofSource.getiMarker() != null
              && MarkUtilities.compare(targetElementofSource.getiMarker(), marker)) {
            MarkUtilities.setText(targetElementofSource.getiMarker(),
                MarkUtilities.getText(marker));
            MarkUtilities.setLinenumber(targetElementofSource.getiMarker(),
                MarkUtilities.getLinenumber(marker));
            MarkUtilities.setStart(targetElementofSource.getiMarker(),
                MarkUtilities.getStart(marker));
            MarkUtilities.setEnd(targetElementofSource.getiMarker(),
                MarkUtilities.getEnd(marker));
          }
        }
        MarkUtilities.setTargetList(sourceMarker, targetElementsofSource);
      }
    }
  }
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:32,代码来源:MarkerUpdater.java

示例4: updateTargets

import org.eclipse.core.resources.IMarker; //导入方法依赖的package包/类
public static void updateTargets(final IMarker marker) {
  if (MarkUtilities.getTargetList(marker).size() != 0) {
    final ArrayList<MarkElement> targetElements = MarkUtilities.getTargetList(marker);

    for (final MarkElement targetElement : targetElements) {

      final IMarker targetMarker = targetElement.getiMarker();

      if (targetMarker != null && targetMarker.exists()
          && MarkUtilities.getSourceList(targetMarker).size() != 0) {
        final ArrayList<MarkElement> sourceElementsofTarget =
            MarkUtilities.getSourceList(targetMarker);

        for (final MarkElement sourceElementofTarget : sourceElementsofTarget) {
          if (sourceElementofTarget.getiMarker() != null
              && MarkUtilities.compare(sourceElementofTarget.getiMarker(), marker)) {
            MarkUtilities.setText(sourceElementofTarget.getiMarker(),
                MarkUtilities.getText(marker));
            MarkUtilities.setLinenumber(sourceElementofTarget.getiMarker(),
                MarkUtilities.getLinenumber(marker));
            MarkUtilities.setStart(sourceElementofTarget.getiMarker(),
                MarkUtilities.getStart(marker));
            MarkUtilities.setEnd(sourceElementofTarget.getiMarker(),
                MarkUtilities.getEnd(marker));
          }
        }
        MarkUtilities.setSourceList(targetMarker, sourceElementsofTarget);
      }
    }
  }
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:32,代码来源:MarkerUpdater.java

示例5: 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

示例6: deleteMarkers

import org.eclipse.core.resources.IMarker; //导入方法依赖的package包/类
private void deleteMarkers() {
  this.editor =
      PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
  this.file = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage()
      .getActiveEditor().getEditorInput().getAdapter(IFile.class);
  this.selection =
      PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService().getSelection();

  try {
    final IMarker beDeleted = this.getMarker();
    if (beDeleted != null && beDeleted.exists()) {
      final MessageDialog warningDialog =
          new MessageDialog(MarkerActivator.getShell(), "Warning!", null,
              "If you delete markers, all relations of these markers has been removed! Do you want to continue to delete markers?",
              MessageDialog.WARNING, new String[] {"YES", "NO"}, 0);
      if (warningDialog.open() != 0) {
        return;
      }

      this.findCandidateToTypeChangingMarkers(beDeleted);
      final String sourceIdOfSelectedMarker = MarkUtilities.getSourceId(beDeleted);

      for (final IMarker iMarker : this.candidateToTypeChanging) {
        AnnotationFactory.convertAnnotationType(iMarker, true,
            MarkUtilities.compare(MarkUtilities.getSourceId(iMarker), sourceIdOfSelectedMarker),
            AlloyUtilities.getTotalTargetCount(iMarker));
      }
      final String markerText = MarkUtilities.getText(beDeleted);

      if (MarkUtilities.getGroupId(beDeleted) != null) {
        final String markerGroupId = MarkUtilities.getGroupId(beDeleted);
        final List<IMarker> markers =
            MarkerFactory.findMarkersByGroupId(this.file, markerGroupId);

        for (int i = markers.size() - 1; i >= 0; i--) {
          this.deleteFromAlloyXML(markers.get(i));
          AnnotationFactory.removeAnnotation(markers.get(i));
          markers.get(i).delete();
        }
      } else {
        this.deleteFromAlloyXML(beDeleted);
        AnnotationFactory.removeAnnotation(beDeleted);
        beDeleted.delete();
      }
      final MessageDialog dialog =
          new MessageDialog(MarkerActivator.getShell(), "Mark will be deleted by this wizard",
              null, "\"" + markerText + "\" has been selected to be unmarked",
              MessageDialog.INFORMATION, new String[] {"OK"}, 0);
      dialog.open();
    }

  } catch (final CoreException e) {
    e.printStackTrace();
  }
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:56,代码来源:DeleteAllHandler.java

示例7: addRemoveType

import org.eclipse.core.resources.IMarker; //导入方法依赖的package包/类
private void addRemoveType() {
  if (!MarkerPage.isParsed()) {
    final MessageDialog parseCtrlDialog =
        new MessageDialog(Activator.getShell(), "Type Information", null,
            "You dont have any marker type registered to system! \n"
                + "Please parse an alloy file first",
            MessageDialog.INFORMATION, new String[] {"OK"}, 0);
    parseCtrlDialog.open();
    return;
  }

  final ActionSelectionDialog actionSelectionDialog =
      new ActionSelectionDialog(Activator.getShell());
  actionSelectionDialog.open();
  if (actionSelectionDialog.getReturnCode() == IDialogConstants.CANCEL_ID) {
    return;
  }

  IMarker selectedMarker = this.marker;
  selectedMarker = MarkUtilities.getLeaderOfMarker(selectedMarker);

  if (selectedMarker != null && selectedMarker.exists()) {
    this.findCandidateToTypeChangingMarkers(selectedMarker);
    if (actionSelectionDialog.getReturnCode() == IDialogConstants.YES_ID) {
      AddRemoveTypeCommand.addType(selectedMarker);
    } else if (actionSelectionDialog.getReturnCode() == IDialogConstants.NO_ID) {
      final MessageDialog warningDialog =
          new MessageDialog(Activator.getShell(), "Warning!", null,
              "If you remove marker's type, all relations of this marker has been removed! Do you want to continue to remove marker's type?",
              MessageDialog.WARNING, new String[] {"YES", "NO"}, 0);
      final int returnCode = warningDialog.open();
      if (returnCode != 0) {
        return;
      }
      this.removeType(selectedMarker);
    }
  } else {
    final MessageDialog dialog =
        new MessageDialog(Activator.getShell(), "There is no marker in this position", null,
            "Please select valid marker", MessageDialog.INFORMATION, new String[] {"OK"}, 0);
    dialog.open();
    return;
  }
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:45,代码来源:AddRemoveTypeCommand.java

示例8: deleteMarker

import org.eclipse.core.resources.IMarker; //导入方法依赖的package包/类
private void deleteMarker() {
  try {
    final IMarker beDeleted = marker;
    if (beDeleted != null && beDeleted.exists()) {
      final MessageDialog warningDialog =
          new MessageDialog(Activator.getShell(), "Warning!", null,
              "If you delete marker, all relations of this marker has been removed! Do you want to continue to delete marker?",
              MessageDialog.WARNING, new String[] {"YES", "NO"}, 0);
      if (warningDialog.open() != 0) {
        return;
      }

      findCandidateToTypeChangingMarkers(beDeleted);
      final String sourceIdOfSelectedMarker = MarkUtilities.getSourceId(beDeleted);

      for (final IMarker iMarker : candidateToTypeChanging) {
        AnnotationFactory.convertAnnotationType(iMarker, true,
            MarkUtilities.compare(MarkUtilities.getSourceId(iMarker), sourceIdOfSelectedMarker),
            AlloyUtilities.getTotalTargetCount(iMarker));
      }
      final String markerText = MarkUtilities.getText(beDeleted);

      if (MarkUtilities.getLeaderId(beDeleted) != null) {
        final String markerGroupId = MarkUtilities.getGroupId(beDeleted);
        final List<IMarker> markers =
            MarkerFactory.findMarkersByGroupId(beDeleted.getResource(), markerGroupId);

        for (int i = markers.size() - 1; i >= 0; i--) {
          deleteFromAlloyXML(markers.get(i));
          AnnotationFactory.removeAnnotation(markers.get(i));
          markers.get(i).delete();
        }
      } else {
        deleteFromAlloyXML(beDeleted);
        AnnotationFactory.removeAnnotation(beDeleted);
        beDeleted.delete();
      }
      final MessageDialog dialog =
          new MessageDialog(Activator.getShell(), "Mark will be deleted by this wizard", null,
              "\"" + markerText + "\" has been selected to be unmarked",
              MessageDialog.INFORMATION, new String[] {"OK"}, 0);
      dialog.open();
    }
  } catch (final CoreException e) {
    e.printStackTrace();
  }
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:48,代码来源:DeleteAtomCommand.java


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