/* * Insert_File.bsh - Prompts user to select a file * then replaces the current selection with the * contents of the selected file. * * Copyright (C) 2004 Ollie Rutherfurd * * $Id$ */ insertFile(View view){ VFSFileChooserDialog chooser = new VFSFileChooserDialog( view,null,VFSBrowser.OPEN_DIALOG,false); String[] files = chooser.getSelectedFiles(); if(files == null) return; String path = files[0]; // read into temporary buffer Buffer b = jEdit.openTemporary(view,null,path,false); try{ if(b == null) return; while(!b.isLoaded()) VFSManager.waitForRequests(); String text = b.getText(0,b.getLength()); view.getTextArea().setSelectedText(text); }finally{ if(b != null) b.close(); } } if(buffer.isReadOnly()){ getToolkit().beep(); } else{ insertFile(view); } /* Insert_File.bsh Prompts user to select a file then replaces the current selection with the contents of the selected file. */