Permalink
Browse files

may not be running in the GUI thread

  • Loading branch information...
1 parent be4c21b commit 7fb414177f48dd225b9c52bae529ac650caef476 @JPMoresmau committed Mar 28, 2012
@@ -164,7 +164,7 @@ public IPresentationReconciler getPresentationReconciler(final ISourceViewer sv)
PresentationReconciler reconciler = colorInThread?new HaskellPresentationReconciler():new PresentationReconciler();
IFile file = (editor != null ? editor.findFile() : null);
- ScionTokenScanner codeScanner=new ScionTokenScanner(getScannerManager(), file);
+ ScionTokenScanner codeScanner=new ScionTokenScanner(getScannerManager(), file,sv.getTextWidget().getDisplay());
if (editor!=null){
editor.setTokenScanner( codeScanner );
}
@@ -70,9 +70,15 @@
private Set<TaskTag> tags;
private boolean caseS;
- public ScionTokenScanner(final ScannerManager man,final IFile file){
+ /**
+ * since we may run in a job for big files, we need a handle to the GUI display
+ */
+ private final Display display;
+
+ public ScionTokenScanner(final ScannerManager man,final IFile file,final Display display){
this.man=man;
this.file=file;
+ this.display=display;
this.tokenByTypes = new HashMap<String, IToken>() {
// Eclipse insists on a serial version identifier, not that this hash map will ever
// get serialized...
@@ -222,22 +228,28 @@ public void setRange( final IDocument document, final int offset, final int leng
if (!checkedTabs){
checkedTabs=true;
if (contents.contains( "\t" )){
+ // we may be in a job
+ display.syncExec( new Runnable(){
+ @Override
+ public void run() {
+ if (MessageDialog.openConfirm( display.getActiveShell() , UITexts.error_tabs , UITexts.error_tabs_message )){
+ /*IDocumentProvider prov=new TextFileDocumentProvider();
+ prov.connect(file);
+ IDocument doc2=prov.getDocument( file );*/
+ int tw=HaskellUIPlugin.getDefault().getPreferenceStore().getInt( EDITOR_TAB_WIDTH );
+ StringBuilder sb=new StringBuilder();
+ for (int a=0;a<tw;a++){
+ sb.append(" ");
+ }
+ contents=contents.replace( "\t",sb.toString() );
+ // doc2.set(contents);
+ document.set(contents);
+ // prov.saveDocument( new NullProgressMonitor(), file, doc2, true );
+ }
+ }
+ } );
- if (MessageDialog.openConfirm( Display.getCurrent().getActiveShell() , UITexts.error_tabs , UITexts.error_tabs_message )){
- /*IDocumentProvider prov=new TextFileDocumentProvider();
- prov.connect(file);
- IDocument doc2=prov.getDocument( file );*/
- int tw=HaskellUIPlugin.getDefault().getPreferenceStore().getInt( EDITOR_TAB_WIDTH );
- StringBuilder sb=new StringBuilder();
- for (int a=0;a<tw;a++){
- sb.append(" ");
- }
- contents=contents.replace( "\t",sb.toString() );
- // doc2.set(contents);
- document.set(contents);
- // prov.saveDocument( new NullProgressMonitor(), file, doc2, true );
}
- }
}
BWFacade f=BuildWrapperPlugin.getFacade( file.getProject() );
if (f==null){

0 comments on commit 7fb4141

Please sign in to comment.