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