JmolViewer viewer,
String fileName, Object historyFileObject,
String windowName,
boolean allowAppend) {
HistoryFile historyFile = (HistoryFile) historyFileObject;
if (openChooser == null) {
openChooser = new FileChooser();
Object temp = UIManager.get("FileChooser.fileNameLabelText");
UIManager.put("FileChooser.fileNameLabelText", GT._("File or URL:"));
getXPlatformLook(openChooser);
UIManager.put("FileChooser.fileNameLabelText", temp);
}
if (openPreview == null
&& (viewer.isApplet() || Boolean.valueOf(
System.getProperty("openFilePreview", "true")).booleanValue())) {
openPreview = new FilePreview(openChooser, viewer.getModelAdapter(), allowAppend,
appletContext);
}
if (historyFile != null) {
Dimension dim = historyFile.getWindowSize(windowName);
if (dim != null)
openChooser.setDialogSize(dim);
Point loc = historyFile.getWindowPosition(windowName);
if (loc != null)
openChooser.setDialogLocation(loc);
}
openChooser.resetChoosableFileFilters();
if (fileName != null) {
int pt = fileName.lastIndexOf(".");
String sType = fileName.substring(pt + 1);
if (pt >= 0 && sType.length() > 0)
openChooser.addChoosableFileFilter(new TypeFilter(sType));
if (fileName.indexOf(".") == 0)
fileName = "Jmol" + fileName;
if (fileName.length() > 0)
openChooser.setSelectedFile(new File(fileName));
}
//System.out.println("fileName for dialog: " + fileName);
if (fileName == null || fileName.indexOf(":") < 0 && fileName.indexOf("/") != 0) {
File dir = FileManager.getLocalDirectory(viewer, true);
//System.out.println("directory for dialog: " + dir.getAbsolutePath());
openChooser.setCurrentDirectory(dir);
}
File file = null;
if (openChooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION)
file = openChooser.getSelectedFile();
if (file == null)
return closePreview();
if (historyFile != null)
historyFile.addWindowInfo(windowName, openChooser.getDialog(), null);
String url = FileManager.getLocalUrl(file);
if (url != null) {
fileName = url;
} else {