byte val[] = var.getFunc().getRessourceValues()[idx];
if (val != null) {
oldFilename = new String(val);
}
}
JFileChooser chooser = new ImageFileChooser(Tools.FILEEXT_PNG);
if (oldFilename != null && oldFilename.length() > 0) {
try {
chooser.setCurrentDirectory(new File(oldFilename).getAbsoluteFile().getParentFile());
chooser.setSelectedFile(new File(oldFilename));
}
catch (Exception ex) {
ex.printStackTrace();
}
}
else {
if (prefs.getInputImagePath() != null) {
try {
chooser.setCurrentDirectory(new File(prefs.getInputImagePath()));
}
catch (Exception ex) {
ex.printStackTrace();
}
}
}
if (chooser.showOpenDialog(centerPanel) == JFileChooser.APPROVE_OPTION) {
File file = chooser.getSelectedFile();
String valStr = file.getAbsolutePath();
byte[] valByteArray = valStr != null ? valStr.getBytes() : null;
var.getFunc().setRessource(rName, valByteArray);
}
}
break;
case IMAGE_FILE: {
JFileChooser chooser = new ImageFileChooser(Tools.FILEEXT_PNG);
if (prefs.getInputImagePath() != null) {
try {
chooser.setCurrentDirectory(new File(prefs.getInputImagePath()));
}
catch (Exception ex) {
ex.printStackTrace();
}
}
if (chooser.showOpenDialog(centerPanel) == JFileChooser.APPROVE_OPTION) {
try {
File file = chooser.getSelectedFile();
byte[] imgData = Tools.readFile(file.getAbsolutePath());
var.getFunc().setRessource(rName, imgData);
}
catch (Exception ex) {
errorHandler.handleError(ex);
}
}
}
break;
case SVG_FILE: {
JFileChooser chooser = new SvgFileChooser(prefs);
if (prefs.getTinaSVGPath() != null) {
try {
chooser.setCurrentDirectory(new File(prefs.getTinaSVGPath()));
}
catch (Exception ex) {
ex.printStackTrace();
}
}
if (chooser.showOpenDialog(centerPanel) == JFileChooser.APPROVE_OPTION) {
try {
File file = chooser.getSelectedFile();
String svg = Tools.readUTF8Textfile(file.getAbsolutePath());
byte[] valByteArray = svg != null ? svg.getBytes() : null;
var.getFunc().setRessource(rName, valByteArray);
}
catch (Exception ex) {