@Override
 public void removeMatch(Match match) {
   synchronized (this) {
     if (getMatchCount(match.getElement()) == 1)
       fElementsToParticipants.remove(match.getElement());
   }
   super.removeMatch(match);
 }
Exemple #2
0
 public void showMatch(Match match, int currentOffset, int currentLength, boolean activate) {
   Object o = match.getElement();
   if (o instanceof IReferenceDescription) {
     IReferenceDescription descr = (IReferenceDescription) o;
     if (activate) {
       uriEditorOpener.open(
           descr.getSourceEObjectUri(), descr.getEReference(), descr.getIndexInList(), true);
     }
   }
 }
 public boolean isShownInEditor(Match match, IEditorPart editor) {
   Object element = match.getElement();
   if (element instanceof IDOMNode) {
     // DOMNode matched
     IDOMNode node = (IDOMNode) element;
     IStructuredModel editorModel = (IStructuredModel) editor.getAdapter(IStructuredModel.class);
     if (editorModel != null) {
       // Returns true if found node belong to the current XML editor
       // which
       // has launched the search and false otherwise.
       return editorModel.equals(node.getModel());
     }
   }
   return false;
 }
 boolean addMatch(Match match, IMatchPresentation participant) {
   Object element = match.getElement();
   if (fElementsToParticipants.get(element) != null) {
     // TODO must access the participant id / label to properly report the error.
     JavaPlugin.log(
         new Status(
             IStatus.WARNING,
             JavaPlugin.getPluginId(),
             0,
             "A second search participant was found for an element",
             null)); //$NON-NLS-1$
     return false;
   }
   fElementsToParticipants.put(element, participant);
   addMatch(match);
   return true;
 }
Exemple #5
0
 public static IEditorPart open(Match match, int offset, int length, boolean activate)
     throws PartInitException, JavaModelException {
   IEditorPart editor = null;
   Object element = match.getElement();
   if (element instanceof IJavaElement) {
     editor = JavaUI.openInEditor((IJavaElement) element);
   }
   if (editor != null && activate) editor.getEditorSite().getPage().activate(editor);
   if (editor instanceof ITextEditor) {
     ITextEditor textEditor = (ITextEditor) editor;
     textEditor.selectAndReveal(offset, length);
   } else if (editor != null) {
     if (element instanceof IFile) {
       IFile file = (IFile) element;
       showWithMarker(editor, file, offset, length);
     }
   }
   return editor;
 }