1 22 23 package org.gjt.sp.jedit.bufferio; 24 25 import java.io.*; 27 import org.gjt.sp.jedit.io.*; 28 import org.gjt.sp.jedit.*; 29 import org.gjt.sp.util.*; 30 32 37 public class BufferInsertRequest extends BufferIORequest 38 { 39 48 public BufferInsertRequest(View view, Buffer buffer, 49 Object session, VFS vfs, String path) 50 { 51 super(view,buffer,session,vfs,path); 52 } 54 public void run() 56 { 57 InputStream in = null; 58 try 59 { 60 String [] args = { vfs.getFileName(path) }; 61 setStatus(jEdit.getProperty("vfs.status.load",args)); 62 setAbortable(true); 63 64 path = vfs._canonPath(session,path,view); 65 66 VFSFile entry = vfs._getFile( 67 session,path,view); 68 long length; 69 if(entry != null) 70 length = entry.getLength(); 71 else 72 length = 0L; 73 74 in = vfs._createInputStream(session,path,false,view); 75 if(in == null) 76 return; 77 78 final SegmentBuffer seg = read( 79 autodetect(in),length,true); 80 81 83 VFSManager.runInAWTThread(new Runnable () 84 { 85 public void run() 86 { 87 view.getTextArea().setSelectedText( 88 seg.toString()); 89 } 90 }); 91 } 92 catch(IOException io) 93 { 94 Log.log(Log.ERROR,this,io); 95 String [] pp = { io.toString() }; 96 VFSManager.error(view,path,"ioerror.read-error",pp); 97 98 buffer.setBooleanProperty(ERROR_OCCURRED,true); 99 } 100 catch(WorkThread.Abort a) 101 { 102 buffer.setBooleanProperty(ERROR_OCCURRED,true); 103 } 104 finally 105 { 106 IOUtilities.closeQuietly(in); 107 try 108 { 109 vfs._endVFSSession(session,view); 110 } 111 catch(IOException io) 112 { 113 Log.log(Log.ERROR,this,io); 114 String [] pp = { io.toString() }; 115 VFSManager.error(view,path,"ioerror.read-error",pp); 116 117 buffer.setBooleanProperty(ERROR_OCCURRED,true); 118 } 119 catch(WorkThread.Abort a) 120 { 121 buffer.setBooleanProperty(ERROR_OCCURRED,true); 122 } 123 } 124 } } 126 | Popular Tags |