Revision: 18312 http://sourceforge.net/p/gate/code/18312 Author: markagreenwood Date: 2014-09-11 11:01:15 +0000 (Thu, 11 Sep 2014) Log Message: ----------- make sure opening a result doc is done from the EDT
Modified Paths: -------------- gate/trunk/src/main/gate/gui/LuceneDataStoreSearchGUI.java Modified: gate/trunk/src/main/gate/gui/LuceneDataStoreSearchGUI.java =================================================================== --- gate/trunk/src/main/gate/gui/LuceneDataStoreSearchGUI.java 2014-09-11 10:56:52 UTC (rev 18311) +++ gate/trunk/src/main/gate/gui/LuceneDataStoreSearchGUI.java 2014-09-11 11:01:15 UTC (rev 18312) @@ -1070,72 +1070,82 @@ } - private void showResultInDocument(Document doc, Pattern result) { - try { - // find the document view associated with the document - TextualDocumentView t = null; - for(Resource r : Gate.getCreoleRegister().getAllInstances( - "gate.gui.docview.TextualDocumentView")) { - if(((TextualDocumentView)r).getDocument().getName() - .equals(doc.getName())) { - t = (TextualDocumentView)r; - break; - } - } + private void showResultInDocument(final Document doc, final Pattern result) { + SwingUtilities.invokeLater(new Runnable() { - if(t != null && t.getOwner() != null) { - // display the annotation sets view - t.getOwner().setRightView(0); + @Override + public void run() { try { - // scroll to the expression that matches the query result - t.getTextView().scrollRectToVisible( - t.getTextView() - .modelToView(result.getRightContextEndOffset())); - } catch(BadLocationException e) { - e.printStackTrace(); - return; - } - // select the expression that matches the query result - t.getTextView().select(result.getLeftContextStartOffset(), - result.getRightContextEndOffset()); - t.getTextView().requestFocus(); - } + // find the document view associated with the document + TextualDocumentView t = null; + for(Resource r : Gate.getCreoleRegister().getAllInstances( + "gate.gui.docview.TextualDocumentView")) { + if(((TextualDocumentView)r).getDocument().getName() + .equals(doc.getName())) { + t = (TextualDocumentView)r; + break; + } + } - // find the annotation sets view associated with the document - for(Resource r : Gate.getCreoleRegister().getAllInstances( - "gate.gui.docview.AnnotationSetsView")) { - AnnotationSetsView asv = (AnnotationSetsView)r; - if(asv == null) { - continue; - } - if(asv.isActive() && asv.getDocument().getName().equals(doc.getName())) { - // display the same annotation types as in Annic - for(int row = 0; row < numStackRows; row++) { - if(stackRows[row][DISPLAY].equals("false")) { - continue; + if(t != null && t.getOwner() != null) { + // display the annotation sets view + t.getOwner().setRightView(0); + try { + // scroll to the expression that matches the query result + t.getTextView().scrollRectToVisible( + t.getTextView() + .modelToView(result.getRightContextEndOffset())); + } catch(BadLocationException e) { + e.printStackTrace(); + return; } - String type = stackRows[row][ANNOTATION_TYPE]; - if(type.equals(Constants.ANNIC_TOKEN)) { - // not interesting to display them + // select the expression that matches the query result + t.getTextView().select(result.getLeftContextStartOffset(), + result.getRightContextEndOffset()); + t.getTextView().requestFocus(); + } + + // find the annotation sets view associated with the document + for(Resource r : Gate.getCreoleRegister().getAllInstances( + "gate.gui.docview.AnnotationSetsView")) { + AnnotationSetsView asv = (AnnotationSetsView)r; + if(asv == null) { continue; } - // look if there is the type displayed in Annic - String asn = result.getAnnotationSetName(); - if(asn.equals(Constants.DEFAULT_ANNOTATION_SET_NAME) - && doc.getAnnotations().getAllTypes().contains(type)) { - asv.setTypeSelected(null, type, true); - } else if(doc.getAnnotationSetNames().contains(asn) - && doc.getAnnotations(asn).getAllTypes().contains(type)) { - asv.setTypeSelected(asn, type, true); + if(asv.isActive() && asv.getDocument().getName().equals(doc.getName())) { + // display the same annotation types as in Annic + for(int row = 0; row < numStackRows; row++) { + if(stackRows[row][DISPLAY].equals("false")) { + continue; + } + String type = stackRows[row][ANNOTATION_TYPE]; + if(type.equals(Constants.ANNIC_TOKEN)) { + // not interesting to display them + continue; + } + // look if there is the type displayed in Annic + String asn = result.getAnnotationSetName(); + if(asn.equals(Constants.DEFAULT_ANNOTATION_SET_NAME) + && doc.getAnnotations().getAllTypes().contains(type)) { + asv.setTypeSelected(null, type, true); + } else if(doc.getAnnotationSetNames().contains(asn) + && doc.getAnnotations(asn).getAllTypes().contains(type)) { + asv.setTypeSelected(asn, type, true); + } + } + break; } } - break; + + } catch(gate.util.GateException e) { + e.printStackTrace(); } + } - - } catch(gate.util.GateException e) { - e.printStackTrace(); - } + + }); + + } // private void showExpressionInDocument /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------------ Want excitement? Manually upgrade your production database. When you want reliability, choose Perforce Perforce version control. Predictably reliable. http://pubads.g.doubleclick.net/gampad/clk?id=157508191&iu=/4140/ostg.clktrk _______________________________________________ GATE-cvs mailing list GATE-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gate-cvs