/**
* img.bsh -- BeanShell macro script for the jEdit text editor.
* Insert tag
with attributes of choosen file from dialog window.
*/
caret = textArea.getCaretPosition();
parent = new Frame();
fileDialog = new FileDialog(parent, "Please select image...");
fileDialog.setDirectory(editPane.getBuffer().getPath());
fileDialog.setVisible(true);
if (fileDialog.getFile() != null) {
image = Toolkit.getDefaultToolkit().getImage(fileDialog.getDirectory() + fileDialog.getFile());
width = image.getWidth();
height = image.getHeight();
if (width != -1 || height != -1) {
tag = "
";
textArea.setSelectedText(tag);
textArea.setCaretPosition(caret + tag.length());
} else {
Macros.message(view, "Selected file is not image!");
}
}