else if (f.type == 0 || f.type > 4)
new ErrorWindow(text("edit_enormal"));
else if (is_html_filename(f.path) && !force_text) {
// Open HTML editor
try {
JSObject win = JSObject.getWindow(this);
String params[] = { f.path, "" };
win.call("htmledit", params);
}
catch(Exception e) {
new ErrorWindow(text("html_efailed",
e.getMessage()));
}
}
else {
// Open text editor
new EditorWindow(f, this);
}
}
else if (b == down_b) {
// Force download of the selected file
if (f == null) return;
download_file(f);
}
else if (b == preview_b) {
// Open preview window for selected file
if (f == null) return;
if (f.type == RemoteFile.DIR)
new ErrorWindow(text("preview_eimage"));
else
new PreviewWindow(this, f);
}
else if (b == refresh_b) {
// Refesh the selected directory (and thus any subdirs)
if (d == null) return;
d.refresh();
show_files(d.file);
}
else if (b == props_b) {
// Display the properties window
if (f == null) return;
new PropertiesWindow(f, this);
}
else if (b == acl_b) {
// Display the ACL window (if filesystem supports them)
if (f == null) return;
FileSystem filefs = find_filesys(f);
if (filefs == null) return;
if (filefs.acls)
new ACLWindow(this, f);
else
new ErrorWindow(text("eacl_efs", filefs.mount));
}
else if (b == attr_b) {
// Display the attributes window (if filesystem supports them)
if (f == null) return;
FileSystem filefs = find_filesys(f);
if (filefs == null) return;
if (filefs.attrs)
new AttributesWindow(this, f);
else
new ErrorWindow(text("attr_efs", filefs.mount));
}
else if (b == ext_b) {
// Display EXT attributes window (if filesystem supports them)
if (f == null) return;
FileSystem filefs = find_filesys(f);
if (filefs == null) return;
if (filefs.ext)
new EXTWindow(this, f);
else
new ErrorWindow(text("ext_efs", filefs.mount));
}
else if (b == copy_b) {
// Copy the selected files
if (f == null) return;
cut_buffer = ff;
cut_mode = false;
}
else if (b == cut_b) {
// Cut the selected file
if (f == null) return;
cut_buffer = ff;
cut_mode = true;
}
else if (b == paste_b) {
// Paste the copied file
if (cut_buffer == null) {
new ErrorWindow(text("paste_ecopy"));
return;
}
// Check for existing file clashes
// XXX
// Go through all the files to paste
for(int i=0; i<cut_buffer.length; i++) {
RemoteFile cf = cut_buffer[i];
// Check for an existing file
RemoteFile already = showing_files.find(cf.name);
String sp = showing_files.path;
String dest_path = sp.equals("/") ? sp+cf.name
: sp+"/"+cf.name;
if (already != null) {
// File exists .. offer to rename
new OverwriteWindow(this, already, cf, i);
}
else {
// do the move or copy
RemoteFile nf = paste_file(cf, showing_files,
dest_path, null, cut_mode);
if (cut_mode && nf != null) {
// Paste from the destination path
// from now on
cut_buffer[i] = nf;
}
}
}
cut_mode = false;
}
else if (b == delete_b) {
// Delete the selected files
if (f == null) return;
new DeleteWindow(this, ff);
}
else if (b == new_b) {
// Open a window for creating a text file
new EditorWindow(showing_files.path, this);
}
else if (b == hnew_b) {
// Open a window for creating an HTML file
try {
JSObject win = JSObject.getWindow(this);
String params[] = { "", showing_files.path };
win.call("htmledit", params);
}
catch(Exception e) {
new ErrorWindow(text("html_efailed",
e.getMessage()));
}
}
else if (b == upload_b) {
// Call javascript to open an upload window
try {
JSObject win = JSObject.getWindow(this);
String params[] = { showing_files.path };
win.call("upload", params);
}
catch(Exception e) {
new ErrorWindow(text("upload_efailed", e.getMessage()));
}
}