From fea20fdc4fb890edbf04bbfaa4d3909cf3ed8b24 Mon Sep 17 00:00:00 2001 From: "(no author)" <(no author)> Date: Sun, 25 Jan 2004 22:24:20 +0000 Subject: [PATCH] This commit was manufactured by cvs2svn to create tag 'release-2-2beta3rev2'. git-svn-id: https://svn.cyberduck.io/tags/release-2-2beta3rev2@341 9e2dff1d-8f06-0410-b5b1-4d70b6340adc --- CDBrowserDelegate.java | 31 - CDBrowserTableDataSource.java | 168 ---- CDConnectedItemView.java | 62 -- CDConnectedListView.java | 38 - CDConnectedScrollView.java | 26 - CDConnectedTableDataSource.java | 48 -- CDConnectionController.java | 386 --------- CDConnectionDialog.java | 101 --- CDFavoriteTableDataSource.java | 39 - CDFavoritesListView.java | 22 - CDInfoWindow.java | 57 -- CDListView.java | 26 - CDMainController.java | 60 -- CDMainWindow.java | 236 ------ CDServerItemView.java | 42 - CDSplitView.java | 69 -- CDStatusLabel.java | 91 --- CDTransferTableDataSource.java | 96 --- ja.lproj/Browser.nib/info.nib | 2 +- ja.lproj/Browser.nib/keyedobjects.nib | Bin 17667 -> 17665 bytes source/ch/cyberduck/Attic/connection/.DS_Store | Bin 6149 -> 0 bytes source/ch/cyberduck/Attic/connection/Check.java | 235 ------ source/ch/cyberduck/Attic/connection/Client.java | 60 -- source/ch/cyberduck/Attic/connection/History.java | 117 --- source/ch/cyberduck/Attic/connection/Log.java | 123 --- source/ch/cyberduck/Attic/connection/Message.java | 66 -- source/ch/cyberduck/Attic/connection/Path.java | 342 -------- .../ch/cyberduck/Attic/connection/Permission.java | 191 ----- source/ch/cyberduck/Attic/connection/Queue.java | 74 -- source/ch/cyberduck/Attic/connection/Session.java | 305 ------- .../Attic/connection/SessionException.java | 71 -- source/ch/cyberduck/Attic/connection/Status.java | 641 --------------- .../ch/cyberduck/Attic/connection/Transcript.java | 57 -- .../cyberduck/Attic/connection/TransferAction.java | 111 --- source/ch/cyberduck/Attic/connection/ftp/.DS_Store | Bin 6149 -> 0 bytes .../cyberduck/Attic/connection/ftp/FTPParser.java | 335 -------- .../cyberduck/Attic/connection/ftp/FTPSession.java | 383 --------- .../ch/cyberduck/Attic/connection/http/.DS_Store | Bin 6149 -> 0 bytes .../Attic/connection/http/HTTPSession.java | 242 ------ .../ch/cyberduck/Attic/connection/sftp/.DS_Store | Bin 6149 -> 0 bytes .../cyberduck/Attic/connection/sftp/Handler.java | 48 -- .../Attic/connection/sftp/SFTPException.java | 37 - .../Attic/connection/sftp/SFTPParser.java | 81 -- .../Attic/connection/sftp/SFTPSession.java | 192 ----- source/ch/cyberduck/Attic/menu/MenuAction.java | 168 ---- source/ch/cyberduck/Attic/menu/MenuItemAction.java | 148 ---- .../ch/cyberduck/Attic/util/BrowserLauncher.java | 584 -------------- source/ch/cyberduck/Attic/util/URLExporter.java | 97 --- source/ch/cyberduck/Attic/util/URLImporter.java | 107 --- source/ch/cyberduck/ui/BookmarkPanel.java | 882 --------------------- source/ch/cyberduck/ui/BookmarkTable.java | 204 ----- source/ch/cyberduck/ui/EditPanel.java | 366 --------- source/ch/cyberduck/ui/ListPanel.java | 596 -------------- source/ch/cyberduck/ui/ListTable.java | 351 -------- source/ch/cyberduck/ui/LogPanel.java | 84 -- source/ch/cyberduck/ui/LoginPanel.java | 145 ---- source/ch/cyberduck/ui/PermissionDialog.java | 181 ----- source/ch/cyberduck/ui/PreferencesPanel.java | 730 ----------------- source/ch/cyberduck/ui/ProgressPanel.java | 311 -------- source/ch/cyberduck/ui/StatusPanel.java | 280 ------- 60 files changed, 1 insertion(+), 10544 deletions(-) delete mode 100644 CDBrowserDelegate.java delete mode 100644 CDBrowserTableDataSource.java delete mode 100644 CDConnectedItemView.java delete mode 100644 CDConnectedListView.java delete mode 100644 CDConnectedScrollView.java delete mode 100644 CDConnectedTableDataSource.java delete mode 100644 CDConnectionController.java delete mode 100644 CDConnectionDialog.java delete mode 100644 CDFavoriteTableDataSource.java delete mode 100644 CDFavoritesListView.java delete mode 100644 CDInfoWindow.java delete mode 100644 CDListView.java delete mode 100644 CDMainController.java delete mode 100644 CDMainWindow.java delete mode 100644 CDServerItemView.java delete mode 100644 CDSplitView.java delete mode 100644 CDStatusLabel.java delete mode 100644 CDTransferTableDataSource.java delete mode 100644 source/ch/cyberduck/Attic/connection/.DS_Store delete mode 100644 source/ch/cyberduck/Attic/connection/Check.java delete mode 100644 source/ch/cyberduck/Attic/connection/Client.java delete mode 100644 source/ch/cyberduck/Attic/connection/History.java delete mode 100644 source/ch/cyberduck/Attic/connection/Log.java delete mode 100644 source/ch/cyberduck/Attic/connection/Message.java delete mode 100644 source/ch/cyberduck/Attic/connection/Path.java delete mode 100644 source/ch/cyberduck/Attic/connection/Permission.java delete mode 100644 source/ch/cyberduck/Attic/connection/Queue.java delete mode 100644 source/ch/cyberduck/Attic/connection/Session.java delete mode 100644 source/ch/cyberduck/Attic/connection/SessionException.java delete mode 100644 source/ch/cyberduck/Attic/connection/Status.java delete mode 100644 source/ch/cyberduck/Attic/connection/Transcript.java delete mode 100644 source/ch/cyberduck/Attic/connection/TransferAction.java delete mode 100644 source/ch/cyberduck/Attic/connection/ftp/.DS_Store delete mode 100644 source/ch/cyberduck/Attic/connection/ftp/FTPParser.java delete mode 100644 source/ch/cyberduck/Attic/connection/ftp/FTPSession.java delete mode 100644 source/ch/cyberduck/Attic/connection/http/.DS_Store delete mode 100644 source/ch/cyberduck/Attic/connection/http/HTTPSession.java delete mode 100644 source/ch/cyberduck/Attic/connection/sftp/.DS_Store delete mode 100644 source/ch/cyberduck/Attic/connection/sftp/Handler.java delete mode 100644 source/ch/cyberduck/Attic/connection/sftp/SFTPException.java delete mode 100644 source/ch/cyberduck/Attic/connection/sftp/SFTPParser.java delete mode 100644 source/ch/cyberduck/Attic/connection/sftp/SFTPSession.java delete mode 100644 source/ch/cyberduck/Attic/menu/MenuAction.java delete mode 100644 source/ch/cyberduck/Attic/menu/MenuItemAction.java delete mode 100644 source/ch/cyberduck/Attic/util/BrowserLauncher.java delete mode 100644 source/ch/cyberduck/Attic/util/URLExporter.java delete mode 100644 source/ch/cyberduck/Attic/util/URLImporter.java delete mode 100644 source/ch/cyberduck/ui/BookmarkPanel.java delete mode 100644 source/ch/cyberduck/ui/BookmarkTable.java delete mode 100644 source/ch/cyberduck/ui/EditPanel.java delete mode 100644 source/ch/cyberduck/ui/ListPanel.java delete mode 100644 source/ch/cyberduck/ui/ListTable.java delete mode 100644 source/ch/cyberduck/ui/LogPanel.java delete mode 100644 source/ch/cyberduck/ui/LoginPanel.java delete mode 100644 source/ch/cyberduck/ui/PermissionDialog.java delete mode 100644 source/ch/cyberduck/ui/PreferencesPanel.java delete mode 100644 source/ch/cyberduck/ui/ProgressPanel.java delete mode 100644 source/ch/cyberduck/ui/StatusPanel.java diff --git a/CDBrowserDelegate.java b/CDBrowserDelegate.java deleted file mode 100644 index a315048605..0000000000 --- a/CDBrowserDelegate.java +++ /dev/null @@ -1,31 +0,0 @@ -/* CDBrowserDelegate */ - -package ch.cyberduck.ui.cocoa; - -import com.apple.cocoa.foundation.*; -import com.apple.cocoa.application.*; - -import org.apache.log4j.Logger; - -public class CDBrowserDelegate extends NSObject { - - private NSMutableArray[] files; - - public CDBrowserDelegate() { - super(); - } - - public int browserNumberOfRowsInColumn(NSBrowser sender, int column) { - return -1; -// return files[column].size(); - } - - public String browserTitleOfColumn( NSBrowser sender, int column) { - return "?? files"; - } - - public void browserWillDisplayCell(NSBrowser sender, Object cell, int row, int column) { - // TODO - } - -} diff --git a/CDBrowserTableDataSource.java b/CDBrowserTableDataSource.java deleted file mode 100644 index ad5d8998de..0000000000 --- a/CDBrowserTableDataSource.java +++ /dev/null @@ -1,168 +0,0 @@ -/* - * ch.cyberduck.ui.cocoa.CDListingTableDataSource.java - * Cyberduck - * - * Copyright (c) 2002 David Kocher. All rights reserved. - * http://icu.unizh.ch/~dkocher/ - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * Bug fixes, suggestions and comments should be sent to: - * dkocher@cyberduck.ch - */ - -package ch.cyberduck.ui.cocoa; - -import com.apple.cocoa.foundation.*; -import com.apple.cocoa.application.*; - -import com.sshtools.j2ssh.sftp.SftpFile; -//import java.util.Observer; -//import java.util.Observable; - -import java.util.List; -import java.util.ArrayList; - -//import ch.cyberduck.core.Bookmark; -//import ch.cyberduck.core.Path; - -import org.apache.log4j.Logger; - -public class CDBrowserTableDataSource extends NSObject {//implements Observer {//implements NSTableView.DataSource { - private static Logger log = Logger.getLogger(CDBrowserTableDataSource.class); - - private List data; - - public CDBrowserTableDataSource() { - super(); - this.setEntries(new ArrayList()); - log.debug("CDBrowserTableDataSource"); - } - - public void mouseUp(NSEvent event) { - if(event.clickCount() == 2) { - // Double click - log.info("I got double click!"); - } - } - - public void awakeFromNib() { - // test -// this.addEntry(new Path("/Users/dkocher/Desktop")); - //ObserverList.instance().registerObserver((Observer)this); - } - - public int numberOfRowsInTableView(NSTableView tableView) { - return data.size(); - } - - //getValue() - public Object tableViewObjectValueForLocation(NSTableView tableView, NSTableColumn tableColumn, int row) { -// log.debug("CDListingTableDataSource.tableViewObjectValueForLocation("+row+")"); - String identifier = (String)tableColumn.identifier(); - //todo generalisieren mit cyberduck.Path - SftpFile p = (SftpFile)data.get(row); - if(identifier.equals("TYPE")) { - if(p.isFile()) - return NSImage.imageNamed("file.tiff"); - if(p.isDirectory()) - return NSImage.imageNamed("folder.tiff"); - } - if(identifier.equals("FILENAME")) - return p.getFilename(); - if(identifier.equals("SIZE")) - return p.getAttributes().getSize()+""; - if(identifier.equals("MODIFIED")) - return p.getAttributes().getModifiedTime()+""; - if(identifier.equals("OWNER")) - return p.getAttributes().getUID()+""; - if(identifier.equals("PERMISSION")) - return p.getAttributes().getPermissions()+""; - throw new IllegalArgumentException("Unknown identifier: "+identifier); - } - - //setValue() - public void tableViewSetObjectValueForLocation(NSTableView tableView, Object object, NSTableColumn tableColumn, int row) { - log.debug("tableViewSetObjectValueForLocation() not implemented."); - } - - // Returns true to permit aTableView to edit the cell at rowIndex in aTableColumn, false to deny permission. The delegate can implemen this method to disallow editing of specific cells. - public boolean tableViewShouldEditLocation( NSTableView view, NSTableColumn tableColumn, int row) { - String identifier = (String)tableColumn.identifier(); - if(identifier.equals("FILENAME")) - return true; - return false; - } - - /* Delegate method of CDConnectedTableDataSource*/ - public void tableViewSelectionDidChange(NSNotification notification) { - NSTableView table = (NSTableView)notification.object(); // Returns the object associated with the receiver. This is often the object that posted this notification - //table.selectedRow(); - } - - public void clear() { - this.data.clear(); - } - - public void addEntry(Object entry, int row) { - this.data.add(row, entry); - } - - public void addEntry(Object entry) { - log.debug("CDListingTableDataSource.addEntry("+entry+")"); - this.data.add(entry); - } - - public Object getEntry(int row) { - log.debug("CDListingTableDataSource.getEntry("+row+")"); - return this.data.get(row); - } - - public List getEntries() { - return this.data; - } - - public void setEntries(List data) { - this.data = data; - } - - /* - public void update(Observable o, Object arg) { - log.debug("CDListingTableDataSource:update"); - if(o instanceof Bookmark) { - if(arg.equals(Bookmark.LIST)) { - Bookmark bookmark = (Bookmark)o; - java.util.Iterator iterator = bookmark.getListing().iterator(); - int i = 0; - Path p = null; - this.files.removeAllObjects(); - while(iterator.hasNext()) { - p = (Path)iterator.next(); - if(p.isVisible()) { - this.files.insertObjectAtIndex(p, i); - i++; - } - } - //update path select combobox - //Path cwd = selected.getCurrentPath(); - //int depth = cwd.getPathDepth(); - //for(int i = 0; i <= depth; i++) { - // this.files.addObject(cwd.getPathFragment(i)); - //} - } - else - throw new IllegalArgumentException("Unknown observable argument: "+arg); - } - else - throw new IllegalArgumentException("Unknown observable: "+o); - } - */ -} diff --git a/CDConnectedItemView.java b/CDConnectedItemView.java deleted file mode 100644 index f3cf6e2d2f..0000000000 --- a/CDConnectedItemView.java +++ /dev/null @@ -1,62 +0,0 @@ -/* CDServerItemView */ -package ch.cyberduck.ui.cocoa; - -import com.apple.cocoa.foundation.*; -import com.apple.cocoa.application.*; - -import ch.cyberduck.core.Host; - -import org.apache.log4j.Logger; - -public class CDConnectedItemView extends NSView { - private static Logger log = Logger.getLogger(CDConnectedItemView.class); - - public NSTextField hostname; /* IBOutlet */ - public NSTextField username; /* IBOutlet */ -// public NSImageView icon; /* IBOutlet */ - - private Host host; - - public CDConnectedItemView(Host host) { - super(); - this.host = host; - log.debug("CDConnectedItemView"); - this.setHostname(host.getName()); - this.setUsername(host.getUsername()); - NSTextField f = new NSTextField(); - f.setStringValue("you are connected to this host."); - this.addSubview(f); - } - - public CDConnectedItemView() { - super(); - log.debug("CDConnectedItemView"); - } - - public CDConnectedItemView(NSRect rect) { - super(rect); - log.debug("CDConnectedItemView(NSRect)"); - } - - public void awakeFromNib() { - log.debug("CDConnectedItemView:awakeFromNib"); - - NSTextField f = new NSTextField(); - f.setStringValue("you are connected to this host."); - this.addSubview(f); - } - - public void setHostname(String hostname) { - log.debug("CDConnectedItemView:setHostname"); -// this.hostname.setStringValue(hostname); - } - - public void setIcon(Object icon) { - log.debug("CDConnectedItemView:setIcon"); - } - - public void setUsername(String username) { - log.debug("CDConnectedItemView:setUsername"); -// this.username.setStringValue(username); - } -} diff --git a/CDConnectedListView.java b/CDConnectedListView.java deleted file mode 100644 index ba1544cedb..0000000000 --- a/CDConnectedListView.java +++ /dev/null @@ -1,38 +0,0 @@ -/* CDConnectedListView */ - -package ch.cyberduck.ui.cocoa; - -import ch.cyberduck.core.Host; -import ch.cyberduck.core.Session; - -import com.apple.cocoa.foundation.*; -import com.apple.cocoa.application.*; - -import org.apache.log4j.Logger; - -public class CDConnectedListView extends CDListView { - - private static Logger log = Logger.getLogger(CDConnectedListView.class); - - public CDConnectedListView() { - super(); - log.debug("CDConnectedListView"); - Host h = new Host(Session.SFTP, "host.domain.tld", 22, "dkocher", "topsecret"); - NSView item = new CDConnectedItemView(h); - this.addSubview(item); - this.setNeedsDisplay(item.frame()); - } - - public CDConnectedListView(NSRect frameRect) { - super(frameRect); - log.debug("CDConnectedListView(NSRect)"); - } - - public void awakeFromNib() { - log.debug("CDConnectedListView:awakeFromNib"); - Host h = new Host(Session.SFTP, "host.domain.tld", 22, "dkocher", "topsecret"); - NSView item = new CDConnectedItemView(h); - this.addSubview(item); - this.setNeedsDisplay(item.frame()); - } -} \ No newline at end of file diff --git a/CDConnectedScrollView.java b/CDConnectedScrollView.java deleted file mode 100644 index 3444c3402e..0000000000 --- a/CDConnectedScrollView.java +++ /dev/null @@ -1,26 +0,0 @@ -/* CDConnectedScrollView */ -package ch.cyberduck.ui.cocoa; - -import com.apple.cocoa.foundation.*; -import com.apple.cocoa.application.*; - -import org.apache.log4j.Logger; - -public class CDConnectedScrollView extends NSScrollView { - private static Logger log = Logger.getLogger(CDConnectedListView.class); - - public CDConnectedScrollView() { - super(); - log.debug("CDConnectedScrollView"); - } - - public CDConnectedScrollView(NSRect frameRect) { - super(frameRect); - log.debug("CDConnectedScrollView(NSRect)"); - } - - public void awakeFromNib() { - log.debug("CDConnectedScrollView:awakeFromNib"); - this.setDocumentView(new CDConnectedListView()); - } -} diff --git a/CDConnectedTableDataSource.java b/CDConnectedTableDataSource.java deleted file mode 100644 index 8de6b0d04d..0000000000 --- a/CDConnectedTableDataSource.java +++ /dev/null @@ -1,48 +0,0 @@ -/* CDConnectedTableDataSource */ - -import com.apple.cocoa.foundation.*; -import com.apple.cocoa.application.*; - -import org.apache.log4j.Logger; - -public class CDConnectedTableDataSource extends NSObject {//implements NSTableView.DataSource { - private static Logger log = Logger.getLogger(CDServerTableDataSource.class); - - private NSMutableArray data; - - public CDConnectedTableDataSource() { - super(); - this.data = new NSMutableArray(); - log.debug("CDConnectedTableDataSource"); - } - - public void awakeFromNib() { - log.debug("CDConnectedTableDataSource:awakeFromNib"); - CDServerItemView item = new CDServerItemView(); - item.setHostname("hostname.domain.tld"); - item.setUsername("anonymous"); - this.data.addObject(item); - } - - public int numberOfRowsInTableView(NSTableView tableView) { -// log.debug("CDServerTableDataSource:numberOfRowsInTableView"); - return data.count(); - } - - public Object tableViewObjectValueForLocation(NSTableView tableView, NSTableColumn tableColumn, int row) { - log.debug("CDConnectedTableDataSource:tableViewObjectValueForLocation"); - - String identifier = (String)tableColumn.identifier(); - if(identifier.equals("SERVER")) { - NSCell cell = new NSCell(); - cell.setObjectValue(new CDServerItemView()); - tableColumn.setDataCell(cell); - return data.objectAtIndex(row); - } - throw new IllegalArgumentException("Unknown identifier: "+identifier); - } - - public void tableViewSetObjectValueForLocation(NSTableView tableView, Object object, NSTableColumn tableColumn, int row) { - log.debug("CDConnectedTableDataSource:tableViewSetObjectValueForLocation() not implemented."); - } -} diff --git a/CDConnectionController.java b/CDConnectionController.java deleted file mode 100644 index 7c8b38361e..0000000000 --- a/CDConnectionController.java +++ /dev/null @@ -1,386 +0,0 @@ -/* - * ch.cyberduck.ui.cocoa.CDConnectionController.java - * Cyberduck - * - * Copyright (c) 2002 David Kocher. All rights reserved. - * http://icu.unizh.ch/~dkocher/ - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * Bug fixes, suggestions and comments should be sent to: - * dkocher@cyberduck.ch - */ - -package ch.cyberduck.ui.cocoa; - -import com.apple.cocoa.foundation.*; -import com.apple.cocoa.application.*; - -import java.io.IOException; - -import ch.cyberduck.core.*; -import ch.cyberduck.core.http.*; -import ch.cyberduck.core.sftp.*; -import ch.cyberduck.core.ftp.*; - -import com.sshtools.j2ssh.session.SessionChannelClient; -import com.sshtools.j2ssh.transport.InvalidHostFileException; -import com.sshtools.j2ssh.transport.HostKeyVerification; -import com.sshtools.j2ssh.authentication.PasswordAuthentication; -import com.sshtools.j2ssh.authentication.AuthenticationProtocolState; -import com.sshtools.j2ssh.sftp.*; -import com.sshtools.j2ssh.*; - -import org.apache.log4j.Appender; -import org.apache.log4j.Logger; - -public class CDConnectionController extends NSObject { - - private static Logger log = Logger.getLogger(CDConnectionController.class); - - public NSWindow mainWindow; /* IBOutlet */ - public NSWindow connectionSheet; /* IBOutlet */ - public NSWindow loginSheet; /* IBOutlet */ - - public NSSecureTextField passwordField; /* IBOutlet */ - public NSTextField pathField; /* IBOutlet */ - public NSTextField portField; /* IBOutlet */ - public NSPopUpButton protocolPopup; /* IBOutlet */ - public NSTextField hostField; /* IBOutlet */ - public NSTextField usernameField; /* IBOutlet */ - public NSTextView logTextView; /* IBOutlet */ - public NSProgressIndicator progressIndicator; /* IBOutlet */ - - public NSTextField statusLabel; /* IBOutlet */ - public NSTableView browserTable; /* IBOutlet */ - public NSView connectedListView; /* IBOutlet */ - - private CDConnectionController controller = this; - - public CDConnectionController() { - super(); - log.debug("CDConnectionController"); - } - - public void awakeFromNib() { -// log.addAppender(statusLabel); - } - - - public void connect(NSObject sender) { - log.debug("connect"); - try { - Host host = null; - String protocol = null; - int tag = protocolPopup.selectedItem().tag(); - switch(tag) { - case(1): - protocol = Session.SFTP; - break; - case(2): - protocol = Session.FTP; - break; -// case(3): -// protocol = Session.HTTP; -// break; - } - - //@todo new connection via menu item recent connection - // if(sender instanceof NSMenu - //NSMenuItem item = menu.getSelectedItem() - //host = item. - - if(sender instanceof NSTextField) { - host = new Host(protocol, ((NSControl)sender).stringValue(), 22, null, null); - } - if(sender instanceof NSButton) { - NSApplication.sharedApplication().endSheet(connectionSheet, NSAlertPanel.AlternateReturn); - host = new Host(protocol, hostField.stringValue(), 22, usernameField.stringValue(), passwordField.stringValue()); - } - - mainWindow.setTitle(host.getName()); - Session session = host.getSession(new TransferAction(TransferAction.LIST)); - -// log.debug(session.toString()); - } - catch(IOException e) { - log.error(e.toString()); - } - // connectedListView.addSubview(new CDConnectedItemView(host)); -// connectedListView.setNeedsDisplay(true); - -// Thread session = new Session(host); -// session.start(); - - // // Now try to write to a file without creating it! - //SftpFile file = sftp.openFile("shinning.txt", - // SftpSubsystemClient.OPEN_CREATE - // | SftpSubsystemClient.OPEN_WRITE); - - - } - - public void disconnect(NSObject sender) { - log.debug("disconnect"); - } - - - /* - private class Session extends Thread { - private Host host; - - public Session(Host host) { - this.host = host; - } - public void run() { - try { - SshClient SSH = new SshClient(); - SSH.connect(hostField.stringValue(), new CDHostKeyVerification()); - PasswordAuthentication auth = new PasswordAuthentication(); - auth.setUsername(usernameField.stringValue()); - auth.setPassword(passwordField.stringValue()); - int result = SSH.authenticate(auth); - if (result == AuthenticationProtocolState.COMPLETE) { - SessionChannelClient session = SSH.openSessionChannel(); - SftpSubsystemClient SFTP = new SftpSubsystemClient(); - session.startSubsystem(SFTP); - SftpFile workingDirectory = SFTP.openDirectory("."); - java.util.List children = new java.util.ArrayList(); - CDBrowserTableDataSource browserTableDataSource = (CDBrowserTableDataSource)browserTable.dataSource(); - int read = 1; - while(read > 0) { - read = SFTP.listChildren(workingDirectory, children); - } - java.util.Iterator i = children.iterator(); - browserTableDataSource.clear(); - while(i.hasNext()) { - browserTableDataSource.addEntry(i.next()); - browserTable.reloadData(); - } - - } - else { - NSApplication.sharedApplication().beginSheet(loginSheet, mainWindow, null, - new NSSelector( - "loginSheetDidEnd", - new Class[] { NSWindow.class, int.class, NSWindow.class } - ),// end selector - null); - log.info("Authentication failed."); - } - } - catch(InvalidHostFileException e) { - e.printStackTrace(); - } - catch(java.io.IOException e) { - e.printStackTrace(); - } - } - - public void loginSheetDidEnd(NSWindow sheet, int returncode, NSWindow main) { - sheet.close(); - } - } - - */ - - public void closeLoginSheet(NSObject sender) { - // Ends a document modal session by specifying the sheet window, sheet. Also passes along a returnCode to the delegate. - NSApplication.sharedApplication().endSheet(loginSheet, NSAlertPanel.AlternateReturn); - } - - private class CDHostKeyVerification extends HostKeyVerification { - private String host; - private String fingerprint; - - private boolean done; - - public boolean isDone() { - return this.done; - } - - public CDHostKeyVerification() throws InvalidHostFileException { - super(); - log.debug("CDHostKeyVerification"); - } - - public CDHostKeyVerification(String hostFile) throws InvalidHostFileException { - super(hostFile); - } - - public void onDeniedHost(String hostname) { - log.debug("onDeniedHost"); - NSAlertPanel.beginInformationalAlertSheet( - "Access denied", //title - "OK",// defaultbutton - null,//alternative button - null,//other button - mainWindow, - this, //delegate - new NSSelector - ( - "deniedHostSheetDidEnd", - new Class[] - { - NSWindow.class, int.class, NSWindow.class - } - ),// end selector - null, // dismiss selector - this, // context - "Access to the host " + hostname + " is denied from this system" // message - ); - while(!this.isDone()) { - try { - Thread.sleep(500); //milliseconds - } - catch(InterruptedException e) { - e.printStackTrace(); - } - } - } - - public void onHostKeyMismatch(String host, String fingerprint, String actualHostKey) { - log.debug("onHostKeyMismatch"); - this.host = host; - this.fingerprint = fingerprint; - NSAlertPanel.beginInformationalAlertSheet( - "Host key mismatch", //title - "Allow",// defaultbutton - "Deny",//alternative button - isHostFileWriteable() ? "Always" : null,//other button - mainWindow, - this, //delegate - new NSSelector - ( - "keyMismatchSheetDidEnd", - new Class[] - { - NSWindow.class, int.class, NSWindow.class - } - ),// end selector - null, // dismiss selector - this, // context - "The host key supplied by " + host + " is: " - + actualHostKey + - "The current allowed key for " + host + " is: " - + fingerprint +"\nDo you want to allow the host access?"); - while(!this.isDone()) { - try { - Thread.sleep(500); //milliseconds - } - catch(InterruptedException e) { - e.printStackTrace(); - } - } - } - - - public void onUnknownHost(String host, String fingerprint) { - log.debug("onUnknownHost"); - this.host = host; - this.fingerprint = fingerprint; - NSAlertPanel.beginInformationalAlertSheet( - "Unknown host", //title - "Allow",// defaultbutton - "Deny",//alternative button - isHostFileWriteable() ? "Always" : null,//other button - mainWindow,//window - this, //delegate - new NSSelector - ( - "unknownHostSheetDidEnd", - new Class[] - { - NSWindow.class, int.class, NSWindow.class - } - ),// end selector - null, // dismiss selector - this, // context - "The host " + host - + " is currently unknown to the system. The host key fingerprint is: " + fingerprint+"."); - while(!this.isDone()) { - try { - Thread.sleep(500); //milliseconds - } - catch(InterruptedException e) { - e.printStackTrace(); - } - } - } - - - public void deniedHostSheetDidEnd(NSWindow sheet, int returncode, NSWindow main) { - log.debug("deniedHostSheetDidEnd"); - sheet.close(); - done = true; - } - - public void keyMismatchSheetDidEnd(NSWindow sheet, int returncode, NSWindow main) { - log.debug("keyMismatchSheetDidEnd"); - try { - if(returncode == NSAlertPanel.DefaultReturn) - allowHost(host, fingerprint, false); - if(returncode == NSAlertPanel.AlternateReturn) { - sheet.close(); - NSAlertPanel.beginInformationalAlertSheet( - "Invalid host key", //title - "OK",// defaultbutton - null,//alternative button - null,//other button - mainWindow, - this, //delegate - null,// end selector - null, // dismiss selector - this, // context - "Cannot continue without a valid host key." // message - ); - log.info("Cannot continue without a valid host key"); - } - if(returncode == NSAlertPanel.OtherReturn) - sheet.close(); - done = true; - } - catch(InvalidHostFileException e) { - e.printStackTrace(); - } - } - - public void unknownHostSheetDidEnd(NSWindow sheet, int returncode, NSWindow main) { - log.debug("unknownHostSheetDidEnd"); - try { - if(returncode == NSAlertPanel.DefaultReturn) - allowHost(host, fingerprint, false); // allow host - if(returncode == NSAlertPanel.AlternateReturn) { - sheet.close(); - NSAlertPanel.beginInformationalAlertSheet( - "Invalid host key", //title - "OK",// defaultbutton - null,//alternative button - null,//other button - mainWindow, - this, //delegate - null,// end selector - null, // dismiss selector - this, // context - "Cannot continue without a valid host key." // message - ); - log.info("Cannot continue without a valid host key"); - } - if(returncode == NSAlertPanel.OtherReturn) - allowHost(host, fingerprint, true); // always allow host - done = true; - } - catch(InvalidHostFileException e) { - e.printStackTrace(); - } - } - } -} diff --git a/CDConnectionDialog.java b/CDConnectionDialog.java deleted file mode 100644 index fb7d6ba36f..0000000000 --- a/CDConnectionDialog.java +++ /dev/null @@ -1,101 +0,0 @@ -/* - * ch.cyberduck.ui.cocoa.CDConnectionDialog.java - * Cyberduck - * - * Copyright (c) 2002 David Kocher. All rights reserved. - * http://icu.unizh.ch/~dkocher/ - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * Bug fixes, suggestions and comments should be sent to: - * dkocher@cyberduck.ch - */ - -package ch.cyberduck.ui.cocoa; - -import com.apple.cocoa.foundation.*; -import com.apple.cocoa.application.*; - -import org.apache.log4j.Logger; - -public class CDConnectionDialog extends NSWindow { - - private static Logger log = Logger.getLogger(CDConnectionDialog.class); - - public NSPopUpButton protocolPopup; - public NSTextField hostNameField; - public NSTextField pathField; - public NSTextField portField; - public NSTextField usernameField; - public NSTextField urlLabel; - - public CDConnectionDialog() { - super(); - log.debug("CDConnectionDialog"); - } - - public CDConnectionDialog(NSRect contentRect, int styleMask, int backingType, boolean defer) { - super(contentRect, styleMask, backingType, defer); - log.debug("CDConnectionDialog"); - } - - public CDConnectionDialog(NSRect contentRect, int styleMask, int bufferingType, boolean defer, NSScreen aScreen) { - super(contentRect, styleMask, bufferingType, defer, aScreen); - log.debug("CDConnectionDialog"); - } - - public void awakeFromNib() { - log.debug("CDConnectionDialog:awakeFromNib"); - this.textInputDidChange(null); -// this.urlLabel.setStringValue(""); - // Notify the textInputDidChange() method if the user types. - (NSNotificationCenter.defaultCenter()).addObserver( - this, - new NSSelector("textInputDidChange", new Class[]{NSNotification.class}), - NSControl.ControlTextDidChangeNotification, - hostNameField); - (NSNotificationCenter.defaultCenter()).addObserver( - this, - new NSSelector("textInputDidChange", new Class[]{NSNotification.class}), - NSControl.ControlTextDidChangeNotification, - pathField); - (NSNotificationCenter.defaultCenter()).addObserver( - this, - new NSSelector("textInputDidChange", new Class[]{NSNotification.class}), - NSControl.ControlTextDidChangeNotification, - portField); - (NSNotificationCenter.defaultCenter()).addObserver( - this, - new NSSelector("textInputDidChange", new Class[]{NSNotification.class}), - NSControl.ControlTextDidChangeNotification, - usernameField); - } - - private static final int SFTP_TAG = 1; - private static final int FTP_TAG = 2; - - public void protocolSelectionChanged(NSObject sender) { - NSMenuItem selectedItem = protocolPopup.selectedItem(); - log.debug("protocol selection changed"); - if(selectedItem.tag() == SFTP_TAG) - portField.setIntValue(22); //todo: use constant - if(selectedItem.tag() == FTP_TAG) - portField.setIntValue(21); - } - - public void textInputDidChange(NSNotification sender) { - urlLabel.setStringValue(usernameField.stringValue()+"@"+hostNameField.stringValue()+":"+portField.stringValue()+"/"+pathField.stringValue()); - } - - public void finalize() { - (NSNotificationCenter.defaultCenter()).removeObserver(this); - } -} diff --git a/CDFavoriteTableDataSource.java b/CDFavoriteTableDataSource.java deleted file mode 100644 index 85b5395cfb..0000000000 --- a/CDFavoriteTableDataSource.java +++ /dev/null @@ -1,39 +0,0 @@ -/* CDFavoriteTableDataSource */ - -package ch.cyberduck.ui.cocoa; - -import com.apple.cocoa.foundation.*; -import com.apple.cocoa.application.*; - -import org.apache.log4j.Logger; - -public class CDFavoriteTableDataSource extends NSObject { - private static Logger log = Logger.getLogger(CDFavoriteTableDataSource.class); - - private NSMutableArray data; - - public CDFavoriteTableDataSource() { - super(); - this.data = new NSMutableArray(); - log.debug("CDFavoriteTableDataSource"); - } - - public void awakeFromNib() { - log.debug("CDFavoriteTableDataSource:awakeFromNib"); - } - - public int numberOfRowsInTableView(NSTableView tableView) { -// log.debug("CDFavoriteTableDataSource:numberOfRowsInTableView"); - return data.count(); - } - - public Object tableViewObjectValueForLocation(NSTableView tableView, NSTableColumn tableColumn, int row) { - log.debug("CDFavoriteTableDataSource:tableViewObjectValueForLocation"); - String identifier = (String)tableColumn.identifier(); - throw new IllegalArgumentException("Unknown identifier: "+identifier); - } - - public void tableViewSetObjectValueForLocation(NSTableView tableView, Object object, NSTableColumn tableColumn, int row) { - log.debug("CDFavoriteTableDataSource:tableViewSetObjectValueForLocation() not implemented."); - } -} diff --git a/CDFavoritesListView.java b/CDFavoritesListView.java deleted file mode 100644 index 40577068aa..0000000000 --- a/CDFavoritesListView.java +++ /dev/null @@ -1,22 +0,0 @@ -/* CDFavoritesListView */ - -package ch.cyberduck.ui.cocoa; - -import com.apple.cocoa.foundation.*; -import com.apple.cocoa.application.*; - -import org.apache.log4j.Logger; - -public class CDFavoritesListView extends CDListView { - private static Logger log = Logger.getLogger(CDFavoritesListView.class); - - public CDFavoritesListView() { - super(); - log.debug("CDFavoritesListView"); - } - - public CDFavoritesListView(NSRect frameRect) { - super(frameRect); - log.debug("CDFavoritesListView"); - } -} diff --git a/CDInfoWindow.java b/CDInfoWindow.java deleted file mode 100644 index 4435fe2237..0000000000 --- a/CDInfoWindow.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * ch.cyberduck.ui.cocoa.CDInfoWindow.java - * Cyberduck - * - * Copyright (c) 2002 David Kocher. All rights reserved. - * http://icu.unizh.ch/~dkocher/ - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * Bug fixes, suggestions and comments should be sent to: - * dkocher@cyberduck.ch - */ -package ch.cyberduck.ui.cocoa; - -import com.apple.cocoa.foundation.*; -import com.apple.cocoa.application.*; - -import org.apache.log4j.Logger; - -public class CDInfoWindow extends NSWindow { - - public Object filenameField; /* IBOutlet */ - public Object groupField; /* IBOutlet */ - public Object kindField; /* IBOutlet */ - public Object modifiedField; /* IBOutlet */ - public Object ownerField; /* IBOutlet */ - public Object sizeField; /* IBOutlet */ - - private static Logger log = Logger.getLogger(CDInfoWindow.class); - - public CDInfoWindow() { - super(); - log.debug("CDInfoWindow"); - } - - public CDInfoWindow(NSRect contentRect, int styleMask, int backingType, boolean defer) { - super(contentRect, styleMask, backingType, defer); - log.debug("CDInfoWindow"); - } - - public CDInfoWindow(NSRect contentRect, int styleMask, int bufferingType, boolean defer, NSScreen aScreen) { - super(contentRect, styleMask, bufferingType, defer, aScreen); - log.debug("CDInfoWindow"); - } - - public void awakeFromNib() { - log.debug("CDInfoWindow:awakeFromNib"); - } -} diff --git a/CDListView.java b/CDListView.java deleted file mode 100644 index 5728fd2387..0000000000 --- a/CDListView.java +++ /dev/null @@ -1,26 +0,0 @@ -/* CDListView */ - -package ch.cyberduck.ui.cocoa; - -import com.apple.cocoa.foundation.*; -import com.apple.cocoa.application.*; - -import org.apache.log4j.Logger; - -public class CDListView extends NSView { - private static Logger log = Logger.getLogger(CDListView.class); - - public CDListView() { - super(); - log.debug("CDListView"); - } - - public CDListView(NSRect frameRect) { - super(frameRect); - log.debug("CDListView(NSRect)"); - } - - public void awakeFromNib() { - log.debug("CDListView:awakeFromNib"); - } -} diff --git a/CDMainController.java b/CDMainController.java deleted file mode 100644 index a8e36d9ccc..0000000000 --- a/CDMainController.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * ch.cyberduck.ui.cocoa.CDMainController.java - * Cyberduck - * - * Copyright (c) 2002 David Kocher. All rights reserved. - * http://icu.unizh.ch/~dkocher/ - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * Bug fixes, suggestions and comments should be sent to: - * dkocher@cyberduck.ch - */ - -package ch.cyberduck.ui.cocoa; - -import com.apple.cocoa.foundation.*; -import com.apple.cocoa.application.*; - -import org.apache.log4j.Logger; - -public class CDMainController extends NSObject { - - private static Logger log = Logger.getLogger(CDMainController.class); - - public CDMainController() { - super(); - org.apache.log4j.BasicConfigurator.configure(); - log.debug("CDMainController"); - } - - public void awakeFromNib() { - - } - -/* - public int applicationShouldTerminate(NSObject sender) { - return NSApplication.TerminateNow; - } -*/ - public boolean applicationShouldTerminateAfterLastWindowClosed(NSApplication app) { - return true; - } - - public void donate(NSObject sender) { - try { - NSWorkspace.sharedWorkspace().openURL(new java.net.URL("http://www.cyberduck.ch/donate/")); - } - catch(java.net.MalformedURLException e) { - e.printStackTrace(); - } - } -} diff --git a/CDMainWindow.java b/CDMainWindow.java deleted file mode 100644 index 203208f6c3..0000000000 --- a/CDMainWindow.java +++ /dev/null @@ -1,236 +0,0 @@ -/* - * ch.cyberduck.ui.cocoa.CDMainWindow.java - * Cyberduck - * - * Copyright (c) 2002 David Kocher. All rights reserved. - * http://icu.unizh.ch/~dkocher/ - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * Bug fixes, suggestions and comments should be sent to: - * dkocher@cyberduck.ch - */ - -package ch.cyberduck.ui.cocoa; - -import com.apple.cocoa.foundation.*; -import com.apple.cocoa.application.*; - -//import java.util.Observer; -//import java.util.Observable; - -//import ch.cyberduck.core.Status; -//import ch.cyberduck.ui.ObserverList; - -import org.apache.log4j.Logger; - -public class CDMainWindow extends NSWindow {//implements Observer { - - private static Logger log = Logger.getLogger(CDMainWindow.class); - - //public NSPopUpButton favoritePopUpButton; - public NSWindow connectionSheet; /* IBOutlet */ - public NSTextField quickConnectField; /* IBOutlet */ - public NSDrawer drawer; /* IBOutlet */ - - private NSMutableDictionary toolbarItems; - - public CDMainWindow() { - super(); - log.debug("CDMainWindow"); -// ObserverList.instance().registerObserver((Observer)this); - } - - public CDMainWindow(NSRect contentRect, int styleMask, int backingType, boolean defer) { - super(contentRect, styleMask, backingType, defer); - log.debug("CDMainWindow"); -// ObserverList.instance().registerObserver((Observer)this); - } - - public CDMainWindow(NSRect contentRect, int styleMask, int bufferingType, boolean defer, NSScreen aScreen) { - super(contentRect, styleMask, bufferingType, defer, aScreen); - log.debug("CDMainWindow"); -// ObserverList.instance().registerObserver((Observer)this); - } - - /** - * @return The string that appears in the title bar of the receiver. - */ - public String title() { - return "Connected to "; - } - - - public void awakeFromNib() { - log.debug("CDMainWindow:awakeFromNib"); -/* - NSArray columns = connectedView.tableColumns(); - NSTableColumn c = columns.objectAtIndex(columns.count()-1); - c.setDataCell(new CDServerItemView()); - */ - this.setDelegate(this); - - - // ---------------------------------------------------------- - // Toolbar - // ---------------------------------------------------------- - - NSToolbar toolbar = new NSToolbar("mainToolbar"); - this.toolbarItems = new NSMutableDictionary(); - - this.addToolbarItem(toolbarItems, "New Connection", "New Connection", "New Connection", "Connect to remote host", this, new NSSelector("openConnectionSheet", new Class[] {null}), NSImage.imageNamed("server.tiff")); - - this.addToolbarItem(toolbarItems, "Back", "Back", "Back", "Show parent directory", this, new NSSelector("back", new Class[] {null}), NSImage.imageNamed("back.tiff")); - - this.addToolbarItem(toolbarItems, "Quick Connect", "Quick Connect", "Quick Connect", null, this, null, null); - NSToolbarItem quickConnectItem = (NSToolbarItem)toolbarItems.objectForKey("Quick Connect"); - quickConnectItem.setView(quickConnectField); - quickConnectItem.setMinSize(quickConnectField.frame().size()); - quickConnectItem.setMaxSize(quickConnectField.frame().size()); - /* - this.addToolbarItem(toolbarItems, "Favorites", "Favorites", "Favorites", null, this, null, null); - - NSToolbarItem favoriteItem = (NSToolbarItem)toolbarItems.objectForKey("Favorites"); - favoriteItem.setView(favoritePopUpButton); - favoriteItem.setMinSize(favoritePopUpButton.frame().size()); - favoriteItem.setMaxSize(favoritePopUpButton.frame().size()); - */ - - this.addToolbarItem(toolbarItems, "Refresh", "Refresh", "Refresh", "Refresh directory listing", this, new NSSelector("refreshListing", new Class[] {null}), NSImage.imageNamed("refresh.tiff")); - - this.addToolbarItem(toolbarItems, "Download", "Download", "Download", "Download file", this, new NSSelector("download", new Class[] {null}), NSImage.imageNamed("download.tiff")); - - this.addToolbarItem(toolbarItems, "Upload", "Upload", "Upload", "Upload file", this, new NSSelector("upload", new Class[] {null}), NSImage.imageNamed("upload.tiff")); - - this.addToolbarItem(toolbarItems, "Get Info", "Get Info", "Get Info", "Show file permissions", this, new NSSelector("showInfo", new Class[] {null}), NSImage.imageNamed("info.tiff")); - - this.addToolbarItem(toolbarItems, "Show Transcript", "Show Transcript", "Show Transcript", "Show connection transcript", this, new NSSelector("showTranscriptDrawer", new Class[] {null}), NSImage.imageNamed("transcript.tiff")); - - this.addToolbarItem(toolbarItems, "Delete", "Delete", "Delete", "Delete file", this, new NSSelector("deleteFile", new Class[] {null}), NSImage.imageNamed("delete.tiff")); - - toolbar.setDelegate(this); - toolbar.setAllowsUserCustomization(true); - toolbar.setAutosavesConfiguration(true); - this.setToolbar(toolbar); - } - - - // ---------------------------------------------------------- - // Toolbar delegate methods - // ---------------------------------------------------------- - - private void addToolbarItem(NSMutableDictionary toolbarItems, String identifier, String label, String paletteLabel, String toolTip, Object target, NSSelector action, NSImage image) { - NSToolbarItem item = new NSToolbarItem(identifier); - item.setLabel(label); - item.setPaletteLabel(paletteLabel); - item.setToolTip(toolTip); - item.setImage(image); - item.setTarget(target); - item.setAction(action); - item.setEnabled(true); - - toolbarItems.setObjectForKey(item, identifier); - } - - public NSArray toolbarDefaultItemIdentifiers(NSToolbar toolbar) { - return new NSArray(new Object[] {"New Connection", NSToolbarItem.SeparatorItemIdentifier, "Quick Connect", NSToolbarItem.SeparatorItemIdentifier, "Back", "Refresh", "Download", "Upload", "Delete", "Get Info", NSToolbarItem.FlexibleSpaceItemIdentifier, "Show Transcript"}); - } - - public NSArray toolbarAllowedItemIdentifiers(NSToolbar toolbar) { - return new NSArray(new Object[] {"New Connection", "Quick Connect", NSToolbarItem.SeparatorItemIdentifier, "Back", "Refresh", "Download", "Upload", "Delete", "Get Info", NSToolbarItem.FlexibleSpaceItemIdentifier, "Show Transcript", NSToolbarItem.CustomizeToolbarItemIdentifier, NSToolbarItem.SpaceItemIdentifier}); - } - - public NSToolbarItem toolbarItemForItemIdentifier(NSToolbar toolbar, String itemIdentifier, boolean flag) { - return (NSToolbarItem)toolbarItems.objectForKey(itemIdentifier); - } - - public boolean validateToolbarItem(NSToolbarItem item) { - return true; - } - - public void showTranscriptDrawer(NSObject sender) { - drawer.toggle(this); - } - - public void openConnectionSheet(NSObject sender) { - NSApplication.sharedApplication().beginSheet(connectionSheet, this, this, - new NSSelector - ( - "connectionSheetDidEnd", - new Class[] - { - NSWindow.class, int.class, NSWindow.class - } - ),// end selector - this); - } - - public void closeConnectionSheet(NSObject sender) { - // Ends a document modal session by specifying the sheet window, sheet. Also passes along a returnCode to the delegate. - NSApplication.sharedApplication().endSheet(connectionSheet, NSAlertPanel.AlternateReturn); - } - - public void connectionSheetDidEnd(NSWindow sheet, int returncode, NSWindow main) { - sheet.close(); - } - - /* - public void update(Observable o, Object arg) { - if(o instanceof Status) { - log.debug("Observable "+o+" sent argument "+ arg); - if(arg.equals(Status.TIME) || arg.equals(Status.PROGRESS) || arg.equals(Status.ERROR)) { - statusLabel.setStringValue(selected.status.getMessage(Status.TIME) + " : " + selected.status.getMessage(Status.PROGRESS) + " : " + selected.status.getMessage(Status.ERROR)); - } - else - throw new IllegalArgumentException("Unknown observable argument: "+arg); - } - else - throw new IllegalArgumentException("Unknown observable: "+o); - } - */ - - // ---------------------------------------------------------- - // Window delegate methods - // ---------------------------------------------------------- - - public boolean windowShouldClose(NSWindow sender) { - NSAlertPanel.beginAlertSheet( - "Really quit Cyberduck now?", //title - "Quit",// defaultbutton - "Cancel",//alternative button - null,//other button - sender,//window - this, //delegate - new NSSelector - ( - "quitSheetDidEnd", - new Class[] - { - NSWindow.class, int.class, NSWindow.class - } - ),// end selector - null, // dismiss selector - sender, // context - "All connections to remote servers will be closed." // message - ); - return false; - } - - // ---------------------------------------------------------- - // IB action methods - // ---------------------------------------------------------- - - public void quitSheetDidEnd(NSWindow sheet, int returncode, NSWindow main) { - // if multi window app only close the one window with main.close() - if(returncode == NSAlertPanel.DefaultReturn) - NSApplication.sharedApplication().terminate(this); - } -} diff --git a/CDServerItemView.java b/CDServerItemView.java deleted file mode 100644 index 2a02ce836c..0000000000 --- a/CDServerItemView.java +++ /dev/null @@ -1,42 +0,0 @@ -/* CDServerItemView */ - -import com.apple.cocoa.foundation.*; -import com.apple.cocoa.application.*; - -import org.apache.log4j.Logger; - -public class CDServerItemView extends NSView { - private static Logger log = Logger.getLogger(CDServerItemView.class); - - public NSTextField hostname = new NSTextField(); /* IBOutlet */ - public NSTextField username = new NSTextField(); /* IBOutlet */ - public NSImageView icon; /* IBOutlet */ - - public CDServerItemView() { - super(); - log.debug("CDServerItemView"); - } - - public CDServerItemView(NSRect rect) { - super(rect); - log.debug("CDServerItemView"); - } - - public void awakeFromNib() { - // - } - - public void setHostname(String hostname) { - log.debug("CDServerItemView:setHostname"); - this.hostname.setStringValue(hostname); - } - - public void setIcon(Object icon) { - log.debug("CDServerItemView:setIcon"); - } - - public void setUsername(String username) { - log.debug("CDServerItemView:setUsername"); - this.username.setStringValue(username); - } -} diff --git a/CDSplitView.java b/CDSplitView.java deleted file mode 100644 index 9db150525b..0000000000 --- a/CDSplitView.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * ch.cyberduck.ui.cocoa.CDSplitView.java - * Cyberduck - * - * Copyright (c) 2002 David Kocher. All rights reserved. - * http://icu.unizh.ch/~dkocher/ - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * Bug fixes, suggestions and comments should be sent to: - * dkocher@cyberduck.ch - */ -package ch.cyberduck.ui.cocoa; - -import com.apple.cocoa.foundation.*; -import com.apple.cocoa.application.*; - -import org.apache.log4j.Logger; - -public class CDSplitView extends NSSplitView { - - private static Logger log = Logger.getLogger(CDSplitView.class); - - public NSView browserView; - public NSView transferView; - - public CDSplitView() { - super(); - log.debug("CDSplitView"); - } - - public CDSplitView(NSRect frameRect) { - super(frameRect); - log.debug("CDSplitView"); - } - - public boolean splitViewCanCollapseSubview( NSSplitView sender, NSView subview) { - log.debug("CDSplitView:splitViewCanCollapseSubview"); - return true; - } - - public boolean canCollapseSubview(NSView subview) { - log.debug("CDSplitView:canCollapseSubview"); - return (subview == transferView); - } - - public void awakeFromNib() { - log.debug("CDSplitView:awakeFromNib"); - this.setDelegate(this); - this.setVertical(false); - this.addSubview(browserView); - this.addSubview(transferView); - //Adjusts the sizes of the receiver's subviews so they (plus the dividers) fill the receiver. The subviews are resized proportionally; the size of a subview relative to the other subviews doesn't change. - this.adjustSubviews(); - } - - // Returns the thickness of the divider. You can subclass NSSplitView and override this method to change the divider's size, if necessary. -// public float dividerThickness() - - -} diff --git a/CDStatusLabel.java b/CDStatusLabel.java deleted file mode 100644 index 3e2bddb1e4..0000000000 --- a/CDStatusLabel.java +++ /dev/null @@ -1,91 +0,0 @@ -/* CDStatusLabel */ -package ch.cyberduck.ui.cocoa; - -import com.apple.cocoa.foundation.*; -import com.apple.cocoa.application.*; - -import org.apache.log4j.Appender; //Implement this interface for your own strategies for outputting log statements. -import org.apache.log4j.spi.LoggingEvent; -import org.apache.log4j.spi.ErrorHandler; -import org.apache.log4j.spi.Filter; -import org.apache.log4j.Level; -import org.apache.log4j.Logger; -import org.apache.log4j.Layout; - -public class CDStatusLabel extends NSTextField implements Appender { - - private static Logger log = Logger.getLogger(CDStatusLabel.class); - private String name; - - public CDStatusLabel() { - super(); - } - - public CDStatusLabel(NSRect frameRect) { - super(frameRect); - } - - public String getName() { - return this.name; - } - - public void setName(String name) { - this.name = name; - } - - public void addFilter(Filter f) { - log.debug("not implemented"); - } - - public Filter getFilter() { - return null; - } - - public void clearFilters() { - log.debug("not implemented"); - } - - public void close() { - //don't have anyhting to close, ie stream - } - - public boolean requiresLayout() { - return true; - } - - public void setLayout(Layout l) { - log.debug("not implemented"); - } - - public Layout getLayout() { - return new LabelLayout(); - } - - public void setErrorHandler(ErrorHandler h) { - log.debug("not implemented"); - } - - public ErrorHandler getErrorHandler() { - log.debug("not implemented"); - return null; - } - - public void doAppend(LoggingEvent event) { - if(event.getLevel().equals(Level.INFO)) - this.setStringValue(event.getRenderedMessage()); - } - - private class LabelLayout extends Layout { - public String format(LoggingEvent event) { - return event.getRenderedMessage(); - } - - public void activateOptions() { - - } - - public boolean ignoresThrowable() { - return false; - } - } -} diff --git a/CDTransferTableDataSource.java b/CDTransferTableDataSource.java deleted file mode 100644 index 9388086fd5..0000000000 --- a/CDTransferTableDataSource.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * ch.cyberduck.ui.cocoa.CDTransferTableDataSource.java - * Cyberduck - * - * Copyright (c) 2002 David Kocher. All rights reserved. - * http://icu.unizh.ch/~dkocher/ - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * Bug fixes, suggestions and comments should be sent to: - * dkocher@cyberduck.ch - */ - -package ch.cyberduck.ui.cocoa; - -import com.apple.cocoa.foundation.*; -import com.apple.cocoa.application.*; - -import org.apache.log4j.Logger; - -public class CDTransferTableDataSource extends NSObject {//implements NSTableView.DataSource { - - private static Logger log = Logger.getLogger(CDTransferTableDataSource.class); - private NSMutableArray files; - - public CDTransferTableDataSource() { - super(); - log.debug("CDTransferTableDataSource"); - } - - public void awakeFromNib() { - this.setEntries(new NSMutableArray()); - } - - public int numberOfRowsInTableView(NSTableView tableView) { - if(null == files) - return 0; - return files.count(); - } - - //getValue() - public Object tableViewObjectValueForLocation(NSTableView tableView, NSTableColumn tableColumn, int row) { - log.debug("CDTransferTableDataSource.tableViewObjectValueForLocation("+row+")"); - String identifier = (String)tableColumn.identifier(); - if(identifier.equals("TYPE")) { - //if.isDownload() return down.tiff - //if.isUpload() return up.tiff - return "Upload/Download"; - } - if(identifier.equals("FILENAME")) - return "Filename"; - if(identifier.equals("PROGRESS")) - return "00% of 124445K"; - throw new IllegalArgumentException("Unknown identifier: "+identifier); - } - - //setValue() - public void tableViewSetObjectValueForLocation(NSTableView tableView, Object object, NSTableColumn tableColumn, int row) { - log.debug("CDTransferTableDataSource.tableViewSetObjectValueForLocation() not implemented."); - } - - - public void addEntry(Object entry, int row) { - this.files.insertObjectAtIndex(entry, row); - } - - - public void addEntry(Object entry) { - log.debug("CDTransferTableDataSource.addEntry("+entry+")"); - this.files.addObject(entry); - } - - - public Object getEntry(int row) { - log.debug("CDTransferTableDataSource.getEntry("+row+")"); - return this.files.objectAtIndex(row); - } - - - public NSArray getEntries() { - return this.files; - } - - - public void setEntries(NSMutableArray files) { - this.files = files; - } -} diff --git a/ja.lproj/Browser.nib/info.nib b/ja.lproj/Browser.nib/info.nib index d939d53c54..7486fd1d07 100644 --- a/ja.lproj/Browser.nib/info.nib +++ b/ja.lproj/Browser.nib/info.nib @@ -7,7 +7,7 @@ IBEditorPositions 202 - 353 536 573 291 0 0 1280 1002 + 225 365 573 291 0 0 1024 746 511 521 630 238 102 0 0 1280 1002 896 diff --git a/ja.lproj/Browser.nib/keyedobjects.nib b/ja.lproj/Browser.nib/keyedobjects.nib index cb3afe82d774b0c399c988db748629323db24cc3..79b4679f8c540adc1b68f275f8c92d8e2ff865d3 100644 GIT binary patch delta 3125 zcwS|Zd3+Q_7RP(KI;$dJYG!(lp6QvMp6)q&X1ZslCsmvhh~RRE%MdXl5RQZ-gam?7 zhG1AUE-~xKrGap4xS}9}B47lKga9ERmk8>L62Kr{upp;9=;yN^_p|j!y{cEgdY|9- zy%(x96;+zImx95IsioBGR4uiVT18w1Z&FQ~Q`9HaKB`%Big=gULG9N(M;)LJYSO7g z#8u)Ku$F424pVK^5$Y)QDY=r`m((1ij#DR+Iep?hh$XDlXf1IsWm-yJN`A`pl!BDP zlpTP4M7d0d_W;Hh>L&+8B`|G2lONI$ugo4^aKK#Lu66aL>@H`v=A36 zG)ohwBSLthd`>4(M zsX)a2e4qPz&bQ>!S~a`>44YI>{}ZbHch>u)|Ht_|W5TFzO?<8P z9)FBTOV({6@RN^C&7b6+$qk)dFsV3e$cXgPl9Iv#C40z-!IKI~A1|3SUCA0&STw5W z{y?((_8U|XAR6xyd5VSzh2*DT#K7?R01S=po4Z&Rqav?YaK@$Y)AXp2*GzgNV zMnZ52f=mc@La-V>3HCs61%i1HEP&u5)TBd@1HnoN;t-sN;3Eh&K~N3BR0v*$U<(9K zK=2&|w;^~X^%w*-5Uhe=4FuO9xRZJWf(8ioLGW=Z4Z%ORoxwkmaY2i<-L*ZnBeYLz zCuqyG&uS~R)!L=nmD=~TjoLHXFSPC2AG9~LcXhljsKdJMx}Lh;x<0zU>PG3t=(2R# zx^cQ3UAeAScT{&tpQ7)or}ezvqwl59)=$vq>1XNZ>gVYf=&SXM^{e%p^zZ6F(qE@3 z+DJQTiAHfcgYHj1P7kC9(?jV@dL%uXeuB=UOXxUVL2shB(;w0;^g+6nZljOV$LW*w zSM)gpXOIloFu?GPq0mres5NXbykpp5*lE~pXf%9m*l##sIA%CuxMH|zxNW#+B#d68 z-xx5e#$Lw$#%yDevDjE*eA)P#afLD7VBBte*Lcv_YHTx}Hntl(j8{#Bsf$T8bu;xa zjWRuDnrtdIB}^+!b*9y(b*2rbk4$Z*&rIK#u9&rEz1eKGnA6OUn){lw%rnf-nqM&2 znAe;4m=BsSntwF^YQD>)GG=BXlgmtDrZM?U0aL^jGbPL{ri>|P=Ej){rjl96R56Q~ z8YaOkVU{zsOdYd^sb@AY4a{a{E3=*1!R%rhnY~OC)69Ivv@=(j>&&mrE#{6zv_vc! zmSL6&mRXhsmSvXLEp?XFmbI38%iETnmQO5)Ehj8rS~@IOEw`-D%2^d_#Hv~|txs8> zwmxH>XpQGur&woLORTf3YpwOx_12Bn2J2ha_pFW9AFMZ6f+bms{R{gb+lke&2DUFd zj2+A7vjuDsTg;ZSv)MUpIa|rT!LDHI*wyS>ww_(jZe$zSx7aQ0R<@bFYD=|AwoF^T zt?V^{3m?0xMy_7eN^_IdV~ z?A7+A_F8+R{e=As`;Xj1oRw3!2p8iJ*NyAX4dq61qq!%zaa;~Jo}0jxanEwgxVN}1 zToc#Iead~sUFLq_u5s77U%B5L8V7KsIH1Gk@HkXQngcuH-5q@$gB-&hPdO$!@*E|O zIgT2~3dcIfHpd=Ev*SxghvR$4HQvk%yqEX$0X~B-;EVW~d>Q{NznEXeZ{*+M_wa}K zFZi$cOZ-j#wv%+~oV3&H?B?v@9N^4yW;-W3OP#ZwFFLE7e|Ii+E_Lp89&nyJzsmi^<40hUd9{o4)Kohj`hy;&hu8qy^Fjx-h{W-yVBd>-R|A#-S0i> z{oH%rd&PUtr}1fhw9n=9`jGE&-yq)@-xOb-uf(^&_oDAr-&)@~-!9)FUz@Mpcinf> zcgJt`yZm0iy zx>O|1k)D&{(tN2(N=Qqj<{e;5EvX7 z8hA1=B`_oKT%acKR^Xk$?!ewaTi{%vBXBd=IYCpGqfdiG;}<4Ds(nxx4(RoGxd{x$;ywUtT2F$SdUc7@)+GL=zEu~Mp(De+g77UhuArhKNHQ7$SS%FoKZuqOOS z*c1+gdxiUi`-R7ci^HYivhd>Yy70#E_VB)NOZZUuLik4bR`_m29}y#-NHmfW84wvA znH-rGnH`xIIUYF``8@JXCvIlanampUbG~-KYCQ9Rhv2?uI8#! z)qJ&3Emlj_GPPWtt5&F$>O!?jU8L5i33Z9OT&-2>)HQ0ox+FK?dlG7m)fZA zRh!gi^`v@U{Uw$X>l(Af#F!H69_t?)8_SKA#a@X0Ew(JSDYhfFH+CR)EUhrD4AIDh zEXal&NI-5B_n`oiQ3S;hMmi}ARiH|=5LKZ?s0Jm_60{uEqB^t&)uRol0c}QG(RQ>0?Lv)cFKR-~=m2U(N6;~J z5}ih8(O2jkI*%^KQ3tw$enMB#b#xQmLBC-Vr{D+i!?-JkSdWdE!B%X?4lH0d_Td1Q zaRkRO#yxOvoQ^Z_06Y*6!Nc)LJO+=&RQ9jce91F96N zl{!eZf%S>L!^Cy!bLt3nl&qol6FaD5#5L+Tb)xD5h>^s-Dux=S?vT?Vx5LB^c|>}L z{0;>j3L9oqZ#~v=SlWb%C0Rucyyn%8w0`<@N#vv%A~!uOqeK~&B)Q=ulbbf@4R~~5 ze`&w8UTT*%OD)n>DSrS_zG43OY2B)B2M1G2XQ`?iGD2Z$Ff|&qP+sDaN(B&=q1px7 z$Q+OcEMP8inK(lsB9F)iy@-n{0yv28K^XKVdsB<3end}@N=&3u$f-mD;6XAakYk8U zB6pT*N!7^+uRTp%Q*}}OQ`MDPqEf3g1Vb&Y5~E?;i_*8!LFuA&=NQo=@%a`}SVv_% zFr>T`qEf0xM;SF}18tN*oJq_KC*FdpcvK%J&JY&~2XO{CKr-Q=goN;*%1jK-Nep%X zlu#W+Pa^Z7^J=PMv)cX;?*ZKZqY-(3V>$l9`U~n$q-4PViIn@$ZEclBsW*-sFgRs$ zNl8I|I2=yY{j>5X_btiF3s>z^di2fwTg)6(P&l;knF+-uW7O(isVM~oxp`xYa#M@O zmSzvCAw^F*mR@KdWeDuheG>vLAL-y%Z~mgH*~(@}z}Y1j3|5jv=EU zjqFYa$RL?RT1g*~OQnEh5+$I_q$`2Yo3w!z6+w+AL#kb*gA`OM(n(^HB^62l7V>f8 z5_k|&KAA*@6Oi`AHhEGe{h${)mGn@E>_&2Aj7+975!S zfsV!LUUYA|58apUNB5@((HZm*dKf){E~019ae5=YmEKM7qg&`!x{W?eAEl4eXX$VB zR=uE4(x>U4*XQZy>zC{6^jq}X^gHy8`d#{u_09VI`Xl;d`XBT+^|$nQ^!E%NgU{eM zL=2A`dK)qg`G!J6k)hmBX;@*1zhl^HXfU)GS`BT6lZNw#%Z6VJ_l%v5P9rjQGY&S6 zGG-YIjf;&djH`^RjkU%)W0SGX_=WMD@duOIq%j#xCX-@%!qn3=+*DwiYMNzQWP01Q z$8^AS$@G)yrs)pTl`%5om@FonnZV>Sc}xK_i793#Go?%!Gb7H-WacpQm~v(zQ^8a+ zOPFQM3Z{lx%hWO(n0n?tW((86Y-bvo-Aog+muY5BG8dS3<_2?nydFI?F~&y=9YSn`O7cuuYzMX@+lke%G@HT>WHZ@Z zHjgb}C$S~$6m}|G#?E1vvn$yeb`86Zt!3-jjch%;iG82l!Zx$ltX-{sYq~YpI>)-q zy2kph^&{(kYn%13^@#PN^?KZT*QT~)Z|QCU?(H*hxEOSKC>;#~!uE?8qMPW>2yAvk$V5wvV&t*o*B`?G^Tw z_P6a@?R)Ia_OtdY_8;um9Y%-K;dKZO(UI!Na}+p=9HowFjyD~v9UC1VIQBSN9cLV0 zJHB`P?)by0a%!A9r`L&{-JN}$Bb?7V$2m)!Q=G3k%bl+~-*hf@HaT0IUpdb>|KmIt z=R5J8c{Q)$b$o!Ac$rst#P{S=`82+iui!WGJNQO^H{ZnX<(v7#{89cmf0@6^|H%Kw z-*>58!1WJTCzsphbqOxf)zekxn(tcRTIgEjs&XxHRl90kb*_5X4p*b=GuI*4Rad*~ zCpYCzcK2}ibf>!0-SNThXWiNE9QRcBEO(82t-IF!q5Hb~H}@^~9Zx4u7Z3DUJ$6sP z6Z2$yay)sSLQk=0il^LD>3Peu*VF82@f`G=@O+c)p%k&lb;=b~@Z=tWkSLs{fTji_wHTZV=_W3^d zo${UcwfpW0ga8Gd;1aw-lJJz!PZ%a-3pqluFjsg@SS+j)-WD2#R^gCvLAW9OF5LDT z{Vu=P@An7&VgCSsx_^j&xc^yyk$;>2kpCrMjR`?B*rI*6U72? zsyJPIMVuv;i6&y`x*s-#yLKN5Wr)&xWsr+r!soLIyIF z895|BDfg1o8z)$&I9U3t5_Uv8BT$(Q9@@*VkpL?7`)gh(vXC-QV;L}Wr_ zVq{umcI1o5smPhgg~*l2^~jy5D=J5yjP{LYM8`zONAsdnq6ebK6obMkS#f2&lB?t^ zlavyrR4G$tC^MBg$~>i9S*TPfmC6!jnX*EuQPwK8$_Axgc~9A*G$`AZMrF6sr0i9i zl@{fMa!&bKxfkmav&DR|NGvTjFg7YSK2{ccH8wxCJhmy;7~2~=7(03gu0_AP*0SK`k<##e>4aUM#E4h8imH77f==&k8)8ynuJPFDJnxV z&`dN3%|qpAA*w)?XbD<|R-hWR7S*B+s2;tCwx9;I9W|oes0r;w&8P((M2FE)bOL>e zPNT2UIdmRfLRaFb9sP{1p&RITbQ|5nDoo*yxD)PzyJ8L2VFP9`i#hDXZtTM%4q+K9 z7~$?X89#}8;WXSAKZ6J23_KK%z$5W)m`{rSNO6)b$p(N8 zkNX+O01~`7VNv2X6S{rlHAF;23LUgNsJ zMmDjTEo^0*mk%xD@L{~OaY8XpAy(K55m~VF 0)) { - this.prepareOverwrite(); - return true; - } - */ - //else { - if(Preferences.instance().getProperty("duplicate.ask").equals("true")) { - Object[] values = {"Resume", "Similar Name", "Overwrite", "Cancel"}; - int option = dialog.showOptionDialog( - null, - "The file '" + transfer.getLocalFilename() + "' already exists\n" + - "in your download directory.", - "File exists", - dialog.DEFAULT_OPTION, - dialog.QUESTION_MESSAGE, - null, - values, - values[0] - ); - switch(option) { - case 0: - this.prepareResume(); - return true; - case 1: - this.prepareSimilarName(); - return true; - case 2: - this.prepareOverwrite(); - return true; - case 3: - return false; - default: - return false; - } - } - if(Preferences.instance().getProperty("duplicate.similar").equals("true")) { - this.prepareSimilarName(); - return true; - } - if(Preferences.instance().getProperty("duplicate.resume").equals("true")) { - this.prepareResume(); - return true; - } - if(Preferences.instance().getProperty("duplicate.overwrite").equals("true")) { - this.prepareOverwrite(); - return true; - } - System.err.println("[Check] Fatal error: dupliate property not set"); - //} - } - return false; - } - - private boolean validateResume() { - if(transfer.getLocalTempPath() != null && transfer.getLocalTempPath().exists()) { - this.prepareResume(); - return true; - } - else { //if(!transfer.getLocalTempPath().exists()) - this.prepareInitial(); - return true; - } - } - - private boolean validateSimilar() { - this.prepareSimilarName(); - return true; - } - - private boolean validateOverwrite() { - this.prepareOverwrite(); - return true; - } - - private void prepareResume() { - Cyberduck.DEBUG("[Check] prepareResume()"); - status.setResume(true); - status.setCurrent(new Long(transfer.getLocalTempPath().length()).intValue()); - } - - private void prepareSimilarName() { - Cyberduck.DEBUG("[Check] prepareSimilarName()"); - status.setResume(false); - status.setCurrent(0); - - String fn = null; - String filename = transfer.getLocalFilename(); - int no = 1; - int index = filename.lastIndexOf("."); - do { - fn = filename.substring(0, index) + "_" + no + filename.substring(index); - transfer.setLocalPath(new File(transfer.getLocalDirectory(), fn)); - no++; - } - while (transfer.getLocalTempPath().exists() || transfer.getLocalPath().exists()); - } - - private void prepareOverwrite() { - Cyberduck.DEBUG("[Check] prepareOverwrite()"); - status.setResume(false); - status.setCurrent(0); - } - - private void prepareInitial() { - Cyberduck.DEBUG("[Check] prepareInitial()"); - status.setResume(false); - status.setCurrent(0); - } -} diff --git a/source/ch/cyberduck/Attic/connection/Client.java b/source/ch/cyberduck/Attic/connection/Client.java deleted file mode 100644 index bc395a30c2..0000000000 --- a/source/ch/cyberduck/Attic/connection/Client.java +++ /dev/null @@ -1,60 +0,0 @@ -package ch.cyberduck.connection; - -/* - * ch.cyberduck.connection.Client.java - * Cyberduck - * - * $Header$ - * $Revision$ - * $Date$ - * - * Copyright (c) 2003 David Kocher. All rights reserved. - * http://icu.unizh.ch/~dkocher/ - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * Bug fixes, suggestions and comments should be sent to: - * dkocher@cyberduck.ch - */ - -import java.io.IOException; - -/* - * This is just a marker interface, the current implementation has no methods. - * @version $Id$ - */ -public interface Client { - - //@todo now obsolete - - /** - * @return true if the connection is open. - */ - public abstract boolean isAlive(); - - /** - * Start session - * @param remoteHost The server - * @param controlPort the port to connect to - */ - public abstract void connect(String remoteHost, int controlPort) throws IOException, SessionException; - /** - * Start session - * @param remoteHost The server - * @param controlPort the port to connect to - * @param secure true if a secure socket should be used - */ - public abstract void connect(String remoteHost, int controlPort, boolean secure) throws IOException, SessionException; - /** - * Close connection to remote host - */ - public abstract void quit() throws IOException, SessionException; -} diff --git a/source/ch/cyberduck/Attic/connection/History.java b/source/ch/cyberduck/Attic/connection/History.java deleted file mode 100644 index 868b842b42..0000000000 --- a/source/ch/cyberduck/Attic/connection/History.java +++ /dev/null @@ -1,117 +0,0 @@ -package ch.cyberduck.connection; - -/* - * ch.cyberduck.connection.History.java - * Cyberduck - * - * $Header$ - * $Revision$ - * $Date$ - * - * Copyright (c) 2003 David Kocher. All rights reserved. - * http://icu.unizh.ch/~dkocher/ - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * Bug fixes, suggestions and comments should be sent to: - * dkocher@cyberduck.ch - */ - - - -/** - * Not yet implemented - * @version $Id$ - */ -public class History extends java.util.ArrayList { - - public History() { - //@todo impl - } - - /* - public void save() { - Cyberduck.DEBUG("[History] save()"); - FileOutputStream st1 = null; - ObjectOutputStream st2 = null; - try { - st1 = new FileOutputStream(new File(Cyberduck.PREFS_DIRECTORY, Cyberduck.HISTORY_FILE)); - st2 = new ObjectOutputStream(st1); - java.util.Iterator iterator = this.iterator(); - while (iterator.hasNext()) { - st2.writeObject(iterator.next()); - } - } - catch(IOException e) { - System.err.println("[History] Problem saving transfer history: " + e.getMessage()); - e.printStackTrace(); - } - finally { - try { - if (st1 != null) - st1.close(); - if (st2 != null) - st2.close(); - } - catch(IOException e) { - System.err.println("[History] Problem closing output stream: " + e.getMessage()); - e.printStackTrace(); - } - } - } - */ - - /* - public static java.util.List restore() { - Cyberduck.DEBUG("[History] restore()"); - java.util.List l = new java.util.ArrayList(); - FileInputStream st1 = null; - ObjectInputStream st2 = null; - File path = new File(Cyberduck.PREFS_DIRECTORY, Cyberduck.HISTORY_FILE); - if (path.exists()) { - try { - st1 = new FileInputStream(path); - st2 = new ObjectInputStream(st1); - while(true) { - try { - Bookmark bookmark = (Bookmark)st2.readObject(); - l.add(bookmark); - } - catch(ClassNotFoundException e) { - System.err.println("[History] " + e.getMessage()); - e.printStackTrace(); - } - } - } - catch(EOFException e) { - //actually no error. Just the end of the file. - } - catch(IOException e) { - System.err.println("[History] Error while reading from '" + Cyberduck.TABLE_FILE + "': " + e.getMessage()); - e.printStackTrace(); - } - finally { - try { - if (st1 != null) - st1.close(); - if (st2 != null) - st2.close(); - } - catch(IOException e) { - System.err.println("[History] Error while closing output stream: " + e.getMessage()); - e.printStackTrace(); - } - } - } - return l; - } - */ -} diff --git a/source/ch/cyberduck/Attic/connection/Log.java b/source/ch/cyberduck/Attic/connection/Log.java deleted file mode 100644 index f82552ec87..0000000000 --- a/source/ch/cyberduck/Attic/connection/Log.java +++ /dev/null @@ -1,123 +0,0 @@ -package ch.cyberduck.connection; - -/* - * ch.cyberduck.connection.Log.java - * Cyberduck - * - * $Header$ - * $Revision$ - * $Date$ - * - * Copyright (c) 2003 David Kocher. All rights reserved. - * http://icu.unizh.ch/~dkocher/ - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * Bug fixes, suggestions and comments should be sent to: - * dkocher@cyberduck.ch - */ - -import java.io.*; - -import ch.cyberduck.Cyberduck; -import ch.cyberduck.Preferences; - -/** - * I am the logger of a connection. - * @version $Id$ - */ -public class Log { - StringBuffer buffer; - - public Log () { - Cyberduck.DEBUG("[Log] new Log()"); - buffer = new StringBuffer(); - } - - public void append(String text) { -// Cyberduck.DEBUG("[Log] append(" + text + ")"); - buffer.append(text + Cyberduck.SEPARATOR); - } - - public void save() { - Cyberduck.DEBUG("[Log] save()"); - FileWriter fw = null; - BufferedWriter bw = null; - try { - File prefFile = new File(Cyberduck.PREFS_DIRECTORY, Preferences.instance().getProperty("connection.log.file")); - bw = new BufferedWriter(fw = new FileWriter(prefFile.toString(), true)); - String logtext = buffer.toString(); - if (logtext != null) { -// bw.write("////////////////////////////////////////////////"); - bw.newLine(); -// bw.write(Cyberduck.SEPARATOR + logtext + Cyberduck.SEPARATOR); - bw.write(logtext); - bw.newLine(); - Cyberduck.DEBUG("[Log] " + logtext); - } - bw.flush(); - } - catch (IOException e) { - System.out.println("Error: " + e.getMessage()); - e.printStackTrace(); - } - finally { - try { - if(fw != null) - fw.close(); - if(bw != null) - bw.close(); - } - catch(IOException close) { - System.err.println("[Log] Error: " + close.getMessage()); - close.printStackTrace(); - } - } - } - - public static String open() { - Cyberduck.DEBUG("[Log] open()"); - StringBuffer logtext = new StringBuffer(); - File path = new File(Cyberduck.PREFS_DIRECTORY, Preferences.instance().getProperty("connection.log.file")); - if(path.exists()) { - try { - FileReader fr = new FileReader(path); - BufferedReader br = new BufferedReader(fr); - boolean eof = false; - while(!eof) { - String line = br.readLine(); - if (line == null) { - eof = true; - } - else { - logtext.append(line + Cyberduck.SEPARATOR); - } - } - } - catch (IOException e) { - System.err.println("[Log] Could not open log file." + e.getMessage()); - } - } - return logtext.toString(); - } - - public static void delete() { - Cyberduck.DEBUG("[Log] delete()"); - try { - File path = new File(Cyberduck.PREFS_DIRECTORY, Preferences.instance().getProperty("connection.log.file")); - if (path.exists()) - path.delete(); - } - catch(SecurityException e) { - System.err.println("[Log] Could not delete log file: " + e.getMessage()); - } - } -} diff --git a/source/ch/cyberduck/Attic/connection/Message.java b/source/ch/cyberduck/Attic/connection/Message.java deleted file mode 100644 index 47a5f885d4..0000000000 --- a/source/ch/cyberduck/Attic/connection/Message.java +++ /dev/null @@ -1,66 +0,0 @@ -package ch.cyberduck.connection; - -/* - * ch.cyberduck.connection.Message.java - * Cyberduck - * - * $Header$ - * $Revision$ - * $Date$ - * - * Copyright (c) 2003 David Kocher. All rights reserved. - * http://icu.unizh.ch/~dkocher/ - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * Bug fixes, suggestions and comments should be sent to: - * dkocher@cyberduck.ch - */ - -/** - * A message is sent to the observers of a Bookmark - * to inform about the current status. There are many different types - * of messages. - * @version $Id$ - */ -public class Message implements java.io.Serializable { - - private String title; - private String description; - - /** - * @param t The title of the mesage - * @param d The description of the mesage - */ - public Message(String t, String d) { - this.title = t; - this.description = d; - } - - /** - * @param d The description of the mesage - */ - public Message(String d) { - this.description = d; - } - - public String getTitle() { - return title; - } - - public String getDesription() { - return description; - } - - public String toString() { - return this.description; - } -} diff --git a/source/ch/cyberduck/Attic/connection/Path.java b/source/ch/cyberduck/Attic/connection/Path.java deleted file mode 100644 index 6bca074f73..0000000000 --- a/source/ch/cyberduck/Attic/connection/Path.java +++ /dev/null @@ -1,342 +0,0 @@ -package ch.cyberduck.connection; - -/* - * ch.cyberduck.connection.Path.java - * Cyberduck - * - * $Header$ - * $Revision$ - * $Date$ - * - * Copyright (c) 2003 David Kocher. All rights reserved. - * http://icu.unizh.ch/~dkocher/ - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * Bug fixes, suggestions and comments should be sent to: - * dkocher@cyberduck.ch - */ - -import java.text.DateFormat; -import java.util.Date; -import java.awt.datatransfer.Transferable; -import java.awt.datatransfer.DataFlavor; -import java.awt.datatransfer.UnsupportedFlavorException; -import java.io.Serializable; - -import ch.cyberduck.Cyberduck; - -/** - * A path is a remote directory or file. - * @version $Id$ - */ -public class Path implements Serializable, Transferable { - - private String name = null; - private String path = null; - private Path parent = null; - - private int size; - private long modified; - - private String owner; - private String group; - private String access; - private Permission permission; - - private boolean visible = true; - - public static final DataFlavor pathFlavor - = new DataFlavor(ch.cyberduck.connection.Path.class, "ch.cyberduck.connection.Path"); - - public DataFlavor[] getTransferDataFlavors() { - return new DataFlavor[]{pathFlavor}; - } - - public boolean isDataFlavorSupported(DataFlavor flavor) { - return flavor.equals(pathFlavor); - } - - public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException { - if(flavor.equals(pathFlavor)) - return this; - throw new UnsupportedFlavorException(flavor); - } - - /** - * @param path the absolute directory - * @param name the file relative to param path - */ - public Path(String path, String name) { - //Cyberduck.DEBUG("[Path] Path(" + path+","+name+")"); - if(path.charAt(path.length() -1) == '/') - this.init(path + name); - else - this.init(path + "/" + name); - } - - /** - * @param path The absolute path of the file - */ - public Path(String path) { - this.init(path); - } - - private void init(String pathname) { - //Cyberduck.DEBUG("[Path] init(" + pathname + ")"); - String p = pathname.trim(); - this.path = p; - if(this.isDirectory()) { - if(!this.isRoot()) { - this.parent = this.getPathFragment(this.getPathDepth() - 1); - } - if(this.getPathDepth() > 1) { - this.name = p.substring(parent.toString().length(), p.lastIndexOf('/')); - } - else if(this.getPathDepth() > 0) {// must always be true if this.isDirectory() - this.name = p.substring(1, p.lastIndexOf('/')); - } - } - else if(this.isFile()) { - this.parent = this.getPathFragment(this.getPathDepth()); - this.name = p.substring(p.lastIndexOf('/') + 1); - } -// Cyberduck.DEBUG("Path:" + this.path + ", Name:" + this.getName() + ", Parent:" + this.getParent()); - } - - /** - * Only use this if you know what you do! Use constructor by default. - * @see #Path(String, String) - */ - public void setPath(String p) { - Cyberduck.DEBUG("[Path] setPath(" + p + ")"); - StringBuffer buffer = new StringBuffer(); - for(int i = 0; i < p.length(); i++) { - if(! Character.isWhitespace(p.charAt(i))) - buffer.append(p.charAt(i)); - } - this.path = buffer.toString(); - } - - /** - * @return true - * even if the file doesn't exist on the local filesystem - * but seems to be a file because there isn't a '/' at - * the end of the path. - */ - public boolean isFile() { - String path = this.toString(); - if(path.lastIndexOf('/') == path.length() - 1) { - return false; - } - return true; - } - - /** - * @return true - * even if the directory doesn't exist on the local filesystem - * but seems to be a directory because it ends with '/' - */ - public boolean isDirectory() { -// Cyberduck.DEBUG("[Path] isDirectory()"); - String path = this.toString(); - if(path.lastIndexOf('/') == path.length() - 1) { - return true; - } - return false; - } - - /** - * @return The filename if the path is a file - * or the full path if it is a directory - */ - public String getName() { - return this.name; - } - - /** - * @return the absolute path name - */ - public String getPath() { - return this.path; - } - - /** - * @return my parent directory - */ - public Path getParent() { - return this.parent; - } - - /** - * @return Returns the number of '/' characters in a path - */ - public int getPathDepth() { - int depth = 0; - int length = 0; - while((length = this.toString().indexOf('/', length + 1)) != -1) { - depth++; - } - return depth; - } - - /* - * Returns a path relative the parameter - * @param relative - */ - public Path getRelativePath(Path relative) { - int index = this.getPath().indexOf(relative.getPath()); - if(index == -1) { - throw new IllegalArgumentException("The argument must be part of this path"); - } - else { - return new Path(this.getPath().substring(index + relative.getPath().length())); - } - } - - /** - * @ param depth the '/' - * @ return a new Path cut to the length of parameter depth - */ - public Path getPathFragment(int depth) throws IllegalArgumentException { -// Cyberduck.DEBUG("[Path] getPathFragment(" + depth + ")"); - if(depth > this.getPathDepth()) - throw new IllegalArgumentException("Path is not that long: " + depth + " > " + this.getPathDepth()); - if(depth > 0) { - int length = 1; //@modification - for (int n = 0; n < depth; n++) { - if((length = this.toString().indexOf('/', length + 1)) < 0) { - break; - } - } - if(length > 0) - return new Path(this.toString().substring(0, length + 1)); - else { - return new Path(this.toString()); - } - } - else { - return new Path("/"); - } - } - - /* - public static String encode(String path) { - return java.net.URLEncoder.encode(path); - } - */ - - /** - * @param size The size of the file - */ - public void setSize(int size) { - this.size = size; - } - - private static final int KILO = 1024; //2^10 - private static final int MEGA = 1048576; // 2^20 - private static final int GIGA = 1073741824; // 2^30 - - /** - * @return The size of the file - */ - public String getSize() { - if(size < KILO) { - return size + " B"; - } - else if(size < MEGA) { - return new Double(size/KILO).intValue() + " KB"; - } - else if(size < GIGA) { - return new Double(size/MEGA).intValue() + " MB"; - } - else { - return new Double(size/GIGA).intValue() + " GB"; - } - } - - /** - * Set the modfication returned by ftp directory listings - */ - public void setModified(long m) { - this.modified = m; - } - - /** - * @return the modification date of this file - */ - public String getModified() { - return (DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT)).format(new Date(this.modified)); - } - - /** - * @param access unix access permitions, i.e. -rwxrwxrwx - */ - public void setMode(String access) { - this.access = access; - } - - /** - * @return The unix access permissions - */ - public String getMode() { - return this.access; - } - - public void setPermission(Permission p) { - this.permission = p; - } - - public Permission getPermission() { - return this.permission; - } - - public void setOwner(String o) { - this.owner = o; - } - - public String getOwner() { - return this.owner; - } - - public void setGroup(String g) { - this.group = g; - } - - public String getGroup() { - return this.group; - } - - /** - * @param visible If this path should be shown in the directory listing - */ - public void setVisible(boolean visible) { - this.visible = visible; - } - - /** - * @return If this path is shown in the directory listing - */ - public boolean isVisible() { - return this.visible; - } - - /** - * @return true if this paths points to '/' - */ - public boolean isRoot() { - return this.toString().equals("/"); - } - - public String toString() { - return this.getPath().toString(); - } -} diff --git a/source/ch/cyberduck/Attic/connection/Permission.java b/source/ch/cyberduck/Attic/connection/Permission.java deleted file mode 100644 index 0f46b63827..0000000000 --- a/source/ch/cyberduck/Attic/connection/Permission.java +++ /dev/null @@ -1,191 +0,0 @@ -package ch.cyberduck.connection; - -/* - * ch.cyberduck.connection.Permission.java - * Cyberduck - * - * $Header$ - * $Revision$ - * $Date$ - * - * Copyright (c) 2003 David Kocher. All rights reserved. - * http://icu.unizh.ch/~dkocher/ - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * Bug fixes, suggestions and comments should be sent to: - * dkocher@cyberduck.ch - */ - -import java.util.Arrays; - -/** - * Encapsulating unix file permissions. - * @version $Id$ - */ -public class Permission implements java.io.Serializable { - - public static final int OWNER = 0; - public static final int GROUP = 1; - public static final int OTHER = 2; - - public static final int READ = 0; - public static final int WRITE = 1; - public static final int EXECUTE = 2; - - // {read, write, execute} - private boolean[] owner = new boolean[3]; - private boolean[] group = new boolean[3]; - private boolean[] other = new boolean[3]; - - /** - * @param s the access string to parse the permissions from. - * Must be someting like -rwxrwxrwx - */ - public Permission(String s) { - this.owner = this.getOwnerPermissions(s); - this.group = this.getGroupPermissions(s); - this.other = this.getOtherPermissions(s); - } - - /** - * @param p A 3*3 boolean array representing read, write and execute permissions - * by owner, group and others. (1,1) is the owner's read permission - */ - public Permission(boolean[][] p) { - this.owner[READ] = p[OWNER][READ]; - this.owner[WRITE] = p[OWNER][WRITE]; - this.owner[EXECUTE] = p[OWNER][EXECUTE]; - - this.group[READ] = p[GROUP][READ]; - this.group[WRITE] = p[GROUP][WRITE]; - this.group[EXECUTE] = p[GROUP][EXECUTE]; - - this.other[READ] = p[OTHER][READ]; - this.other[WRITE] = p[OTHER][WRITE]; - this.other[EXECUTE] = p[OTHER][EXECUTE]; - } - - /** - * @return a thee-dimensional boolean array representing read, write - * and execute permissions (in that order) of the file owner. - */ - public boolean[] getOwnerPermissions() { - return owner; - } - /** - * @return a thee-dimensional boolean array representing read, write - * and execute permissions (in that order) of the group - */ - public boolean[] getGroupPermissions() { - return group; - } - /** - * @return a thee-dimensional boolean array representing read, write - * and execute permissions (in that order) of any user - */ - public boolean[] getOtherPermissions() { - return other; - } - - private boolean[] getOwnerPermissions(String s) { - boolean[] b = {s.charAt(1) == 'r', s.charAt(2) == 'w', s.charAt(3) == 'x'}; - return b; - } - - private boolean[] getGroupPermissions(String s) { - boolean[] b = {s.charAt(4) == 'r', s.charAt(5) == 'w', s.charAt(6) == 'x'}; - return b; - } - - private boolean[] getOtherPermissions(String s) { - boolean[] b = {s.charAt(7) == 'r', s.charAt(8) == 'w', s.charAt(9) == 'x' || s.charAt(9) == 't' || s.charAt(9) == 'T'}; - return b; - } - - /** - * @return i.e. rwxrwxrwx (777) - */ - public String toString() { - return this.getString()+" ("+this.getCode()+")"; - } - - /** - * @return The unix equivalent access string like rwxrwxrwx - */ - public String getString() { - String owner = this.getAccessString(this.getOwnerPermissions()); - String group = this.getAccessString(this.getGroupPermissions()); - String other = this.getAccessString(this.getOtherPermissions()); - return owner+group+other; - } - - /** - * @return The unix equivalent access code like 777 - */ - public String getCode() { - String owner = ""+ this.getAccessNumber(this.getOwnerPermissions()); - String group = ""+ this.getAccessNumber(this.getGroupPermissions()); - String other = ""+ this.getAccessNumber(this.getOtherPermissions()); - return owner+group+other; - } - - /* -* 0 = no permissions whatsoever; this person cannot read, write, or execute the file -* 1 = execute only -* 2 = write only -* 3 = write and execute (1+2) -* 4 = read only -* 5 = read and execute (4+1) -* 6 = read and write (4+2) -* 7 = read and write and execute (4+2+1) - */ - - //-rwxrwxrwx - - private int getAccessNumber(boolean[] permissions) { - if(Arrays.equals(permissions, new boolean[]{false, false, false})) - return 0; - if(Arrays.equals(permissions, new boolean[]{false, false, true})) - return 1; - if(Arrays.equals(permissions, new boolean[]{false, true, false})) - return 2; - if(Arrays.equals(permissions, new boolean[]{false, true, true})) - return 3; - if(Arrays.equals(permissions, new boolean[]{true, false, false})) - return 4; - if(Arrays.equals(permissions, new boolean[]{true, false, true})) - return 5; - if(Arrays.equals(permissions, new boolean[]{true, true, false})) - return 6; - if(Arrays.equals(permissions, new boolean[]{true, true, true})) - return 7; - return -1; - } - - private String getAccessString(boolean[] permissions) { - String read = permissions[READ] ? "r" : "-"; - String write = permissions[WRITE] ? "w" : "-"; - String execute = permissions[EXECUTE] ? "x" : "-"; - return read+write+execute; - } - - /* - public static final int --- = 0; {false, false, false} - public static final int --x = 1; {false, false, true} - public static final int -w- = 2; {false, true, false} - public static final int -wx = 3; {false, true, true} - public static final int r-- = 4; {true, false, false} - public static final int r-x = 5; {true, false, true} - public static final int rw- = 6; {true, true, false} - public static final int rwx = 7; {true, true, true} - */ -} diff --git a/source/ch/cyberduck/Attic/connection/Queue.java b/source/ch/cyberduck/Attic/connection/Queue.java deleted file mode 100644 index 5a5c4d41e1..0000000000 --- a/source/ch/cyberduck/Attic/connection/Queue.java +++ /dev/null @@ -1,74 +0,0 @@ -package ch.cyberduck.connection; - -/* - * ch.cyberduck.connection.TransferAction.java - * Cyberduck - * - * $Header$ - * $Revision$ - * $Date$ - * - * Copyright (c) 2003 David Kocher. All rights reserved. - * http://icu.unizh.ch/~dkocher/ - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * Bug fixes, suggestions and comments should be sent to: - * dkocher@cyberduck.ch - */ - -import ch.cyberduck.Cyberduck; - -/** - * Used to queue multiple connections. queue.start() will - * start the the connections in the order the have been added to me. - * Useful for actions where the reihenfolge of the taken actions - * is important, i.e. deleting directories or uploading directories. - * @version $Id$ - */ -public class Queue extends Thread { - - java.util.Vector connections = new java.util.Vector(); - - /** - * @param thread A connection thread - * @see ch.cyberduck.connection.Session - */ - public void add(Runnable thread) { - Cyberduck.DEBUG("[Queue] add()"); - connections.add(thread); - } - - /** - * Execute pending connections in the order they have been added to the queue - first added gets first - * executed. - */ - public void run() { - java.util.Iterator i = connections.iterator(); - Thread thread = null; - while (i.hasNext()) { - if(thread != null) { - if(thread.isAlive()) { - try { - thread.join(); - } - catch(InterruptedException e) { - Cyberduck.DEBUG("[Queue] ERROR: Failed joining last connection."); - e.printStackTrace(); - } - } - } - thread = (Thread)i.next(); - Cyberduck.DEBUG("[Queue] Starting new thread"); - thread.start(); - } - } -} diff --git a/source/ch/cyberduck/Attic/connection/Session.java b/source/ch/cyberduck/Attic/connection/Session.java deleted file mode 100644 index 0a283cb761..0000000000 --- a/source/ch/cyberduck/Attic/connection/Session.java +++ /dev/null @@ -1,305 +0,0 @@ -package ch.cyberduck.connection; - -/* - * ch.cyberduck.connection.Session.java - * Cyberduck - * - * $Header$ - * $Revision$ - * $Date$ - * - * Copyright (c) 2003 David Kocher. All rights reserved. - * http://icu.unizh.ch/~dkocher/ - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * Bug fixes, suggestions and comments should be sent to: - * dkocher@cyberduck.ch - */ - -import java.io.*; -import java.util.Date; - -import ch.cyberduck.Cyberduck; -import ch.cyberduck.Preferences; - -/** - * @version $Id$ - */ -public abstract class Session extends Thread { - - public static final String HTTP = "http"; - public static final String HTTPS = "https"; - public static final String FTP = "ftp"; - public static final String SFTP = "sftp"; - - public static final int HTTP_PORT = 80; - public static final int HTTPS_PORT = 443; - public static final int FTP_PORT = 21; - public static final int SFTP_PORT = 22; - - private Log log; - - public Bookmark bookmark; - /** - * the action to execute(download, upload, list, ...) - */ - public TransferAction action; - - public boolean secure = false; - - public Session(Bookmark b, TransferAction action) { - this(b, action, false); - } - public Session(Bookmark b, TransferAction action, boolean secure) { - super(b.getHost()); - this.bookmark = b; - this.action = action; - this.secure = secure; - System.getProperties().put("proxySet", Preferences.instance().getProperty("connection.proxy")); - System.getProperties().put("proxyHost", Preferences.instance().getProperty("connection.proxy.host")); - System.getProperties().put("proxyPort", Preferences.instance().getProperty("connection.proxy.port")); - this.log = new Log(); - this.log("-------" + new Date().toString(), Status.LOG); - this.log("-------" + bookmark.getAddressAsString(), Status.LOG); - } - - /** - * Start the session and run the action specified with TransferAction - * in the constructor. - * The protocol specific implementation is be coded in the subclasses. - */ - public abstract void run(); - - /** - * ascii upload - * @param reader The stream to read from - * @param writer The stream to write to - */ - public void upload(java.io.Writer writer, java.io.Reader reader) throws IOException { - Cyberduck.DEBUG("[Session] upload(" + writer.toString() + ", " + reader.toString()); - // this.log("Uploading " + action.getParam() + "... (ASCII)", Status.PROGRESS); - this.transfer(reader, writer); -// this.log("Upload of '" + action.getParam() + "' complete", Status.PROGRESS); - } - - /** - * binary upload - * @param i The stream to read from - * @param o The stream to write to - */ - public void upload(java.io.OutputStream o, java.io.InputStream i) throws IOException { - Cyberduck.DEBUG("[Session] upload(" + o.toString() + ", " + i.toString()); -// this.log("Uploading " + action.getParam() + "... (BINARY)", Status.PROGRESS); - this.transfer(i, o); -// this.log("Upload of '" + action.getParam() + "' complete", Status.PROGRESS); - } - - /** - * ascii download - * @param reader The stream to read from - * @param writer The stream to write to - */ - public void download(java.io.Reader reader, java.io.Writer writer) throws IOException { - Cyberduck.DEBUG("[Session] transfer(" + reader.toString() + ", " + writer.toString()); -// this.log("Downloading " + bookmark.getServerFilename() + "... (ASCII)", Status.PROGRESS); - this.transfer(reader, writer); - } - - /** - * binary download - * @param i The stream to read from - * @param o The stream to write to - */ - public void download(java.io.InputStream i, java.io.OutputStream o) throws IOException { - Cyberduck.DEBUG("[Session] transfer(" + i.toString() + ", " + o.toString()); -// this.log("Downloading " + bookmark.getServerFilename() + "... (BINARY) ", Status.PROGRESS); - this.transfer(i, o); - } - - /** - * @param reader The stream to read from - * @param writer The stream to write to - */ - private void transfer(java.io.Reader reader, java.io.Writer writer) throws IOException { - LineNumberReader in = new LineNumberReader(reader); - BufferedWriter out = new BufferedWriter(writer); - int current = bookmark.status.getCurrent(); - boolean complete = false; - // read/write a line at a time - String line = null; - while (!complete && !bookmark.status.isCancled()) { - line = in.readLine(); - if(line == null) { - complete = true; - } - else { - bookmark.status.setCurrent(current += line.getBytes().length); - out.write(line, 0, line.length()); - out.newLine(); - } - } - this.eof(complete); - // close streams - if(in != null) { - in.close(); - } - if(out != null) { - out.flush(); - out.close(); - } - } - - /** - * @param i The stream to read from - * @param o The stream to write to - */ - private void transfer(java.io.InputStream i, java.io.OutputStream o) throws IOException { - BufferedInputStream in = new BufferedInputStream(new DataInputStream(i)); - BufferedOutputStream out = new BufferedOutputStream(new DataOutputStream(o)); - - // do the retrieving - int chunksize = Integer.parseInt(Preferences.instance().getProperty("connection.buffer")); - byte[] chunk = new byte[chunksize]; - int amount = 0; - int current = bookmark.status.getCurrent(); - boolean complete = false; - - // read from socket (bytes) & write to file in chunks - while (!complete && !bookmark.status.isCancled()) { - amount = in.read(chunk, 0, chunksize); - if(amount == -1) { - complete = true; - } - else { - bookmark.status.setCurrent(current += amount); - out.write(chunk, 0, amount); - } - } - this.eof(complete); - // close streams - if(in != null) { - in.close(); - } - if(out != null) { - out.flush(); - out.close(); - } - } - - /** - * Do some cleanup if transfer has been completed - */ - private void eof(boolean complete) { - if(complete) { - bookmark.status.setCurrent(bookmark.status.getLength()); - if(action.toString().equals(TransferAction.GET)) { - bookmark.getLocalTempPath().renameTo(bookmark.getLocalPath()); - if(Preferences.instance().getProperty("files.postprocess").equals("true")) { - bookmark.open(); - } - } - this.log("Complete" , Status.PROGRESS); - bookmark.status.fireCompleteEvent(); - } - else { - this.log("Incomplete", Status.PROGRESS); - bookmark.status.fireStopEvent(); - } - } - - /** - * Can be called within the run() to check if the thread should die. - */ - public void check() throws SessionException { - if( bookmark.status.isCancled()) { - bookmark.status.ignoreEvents(false); - throw new SessionException("Session canceled."); - } - } - - public void log(String message, Message type) { - Cyberduck.DEBUG("[Session] log("+message+","+type+")"); - bookmark.status.setMessage(message, type); - if(type.equals(Status.TRANSCRIPT)) { - Transcript.instance().transcript(message); - } - if(type.equals(Status.LOG)) { - log.append(message); - } - if(type.equals(Status.PROGRESS)) { - log.append(" [PROGRESS] " + message); - } - if(type.equals(Status.ERROR)) { - log.append(" [ERROR] " + message); - if(Preferences.instance().getProperty("interface.error-dialog").equals("true")) { - StringBuffer error = new StringBuffer(); - //building lines with approx. 50 characters - int begin = 0; - int end = 50; - while(end > 0 && end < message.length()) { - Cyberduck.DEBUG("***substring("+begin+","+end+")"); - String sub = message.substring(begin, end); - int space = sub.lastIndexOf(' '); - Cyberduck.DEBUG("***append("+begin+","+(begin + space)+")"); - error.append(message.substring(begin, (begin + space))+System.getProperty("line.separator")); - begin = (begin + space + 1); - end = (end + 30); - } - error.append(message.substring(begin)); - - javax.swing.JOptionPane.showMessageDialog( - null, - error.toString(), - bookmark.getHost(), - javax.swing.JOptionPane.ERROR_MESSAGE, - null - ); - } - } - } - - public void saveLog() { -// if(Preferences.instance().getProperty("connection.log").equals("true")) { - log.save(); - } - -/* -import java.util.*; - -class SystemProperties -{ - public static void main(String args[]) - { - Properties systemproperties = System.getProperties(); - systemproperties.put("firewallHost", - "web.proxy.nl.com"); // firewall proxy server - systemproperties.put("firewallPort", - "140"); // firewall port # - systemproperties.put("firewallSet","true"); - systemproperties.put("proxyHost", - "http.proxy.nl.com");// http proxy server - systemproperties.put("proxyPort", - "180"); // http port # - systemproperties.put("proxySet","true"); - systemproperties.put("ftpProxyHost", - "ftp.proxy.nl.com"); // ftp proxy server - systemproperties.put("ftpProxyPort", - "110"); // ftp port # - systemproperties.put("ftpProxySet","true"); - systemproperties.put("http.nonProxyHosts", - "apple.com|netscape.com"); - // proxy bypass sites - System.setProperties(systemproperties); - } -} - */ -} diff --git a/source/ch/cyberduck/Attic/connection/SessionException.java b/source/ch/cyberduck/Attic/connection/SessionException.java deleted file mode 100644 index fd7ec6a6cc..0000000000 --- a/source/ch/cyberduck/Attic/connection/SessionException.java +++ /dev/null @@ -1,71 +0,0 @@ -package ch.cyberduck.connection; - -/* - * ch.cyberduck.connection.SessionException.java - * Cyberduck - * - * $Header$ - * $Revision$ - * $Date$ - * - * Copyright (c) 2003 David Kocher. All rights reserved. - * http://icu.unizh.ch/~dkocher/ - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * Bug fixes, suggestions and comments should be sent to: - * dkocher@cyberduck.ch - */ - -/** -* An exception occuring when communicating with a remote host but not IO related. - * @version $Id$ - */ -public class SessionException extends Exception { - - private int code = -1; - - /** - * @param message The description of the exception - */ - public SessionException(String message) { - super(message); - } - - /** - * @param message The description of the exception - * @param reploycode The associated code the server replied with the error message - */ - public SessionException(String message, int replycode) { - super(message); - this.code = replycode; - } - - /** - * @param message The description of the exception - * @param reploycode The associated code the server replied with the error message - */ - public SessionException(String message, String replycode) { - super(message); - try { - this.code = Integer.parseInt(replycode); - } - catch (NumberFormatException ex) { - } - } - - /** - * @return The code the server replied along with the error message - */ - public int getReplyCode() { - return this.code; - } -} diff --git a/source/ch/cyberduck/Attic/connection/Status.java b/source/ch/cyberduck/Attic/connection/Status.java deleted file mode 100644 index 55a0980020..0000000000 --- a/source/ch/cyberduck/Attic/connection/Status.java +++ /dev/null @@ -1,641 +0,0 @@ -package ch.cyberduck.connection; - -/* - * ch.cyberduck.connection.Status.java - * Cyberduck - * - * $Header$ - * $Revision$ - * $Date$ - * - * Copyright (c) 2003 David Kocher. All rights reserved. - * http://icu.unizh.ch/~dkocher/ - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * Bug fixes, suggestions and comments should be sent to: - * dkocher@cyberduck.ch - */ - -import javax.swing.BoundedRangeModel; -import javax.swing.DefaultBoundedRangeModel; -import javax.swing.Timer; -import java.applet.Applet; -import java.applet.AudioClip; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.io.Serializable; -import java.text.DateFormat; -import java.util.Calendar; -import java.util.Iterator; -import java.util.Observable; -import java.util.Vector; - -import ch.cyberduck.Cyberduck; -import ch.cyberduck.Preferences; - -/** - * The Status class is the model of a download's status. The view of this is represented by - * the StatusPanel notified by the methods available from the Observable class. - * To get notifed of my status register via registerObserver() of BookmarkPanel. - * @version $Id$ - */ -public class Status extends Observable implements Serializable { - /** - * Progress trackers. - */ - private transient Timer chronoTimer, currentSpeedTimer, overallSpeedTimer;//, timeLeftTimer; - - private boolean canceled; - /** - * Indicates that the last action has been completed. - */ - private boolean complete = false; - /** - * The last actioin has been stopped, but must not be completed. - */ - private transient boolean stopped = true; - /** - * Download is resumable - */ - private transient boolean resume = false; - - /** - * I am selected in the table view - */ - private boolean selected; - - public void setSelected(boolean s) { - this.selected = s; - } - public boolean isSelected() { - return this.selected; - } - - // Messages sent to observers as argument to update only specific components - // different type of status messages (eg for jlabels in status panel) - // milestones of the transfer - public static final Message ACTIVE = new Message ("ACTIVE"); - public static final Message STOP = new Message ("STOP"); - public static final Message COMPLETE = new Message ("COMPLETE"); - // panel messages - check if the appropriate panel is displayed. - public static final String PROGRESSPANEL = new String("PROGRESSPANEL"); -// public static final String EDITPANEL = new String("EDITPANEL"); - public static final String LOGINPANEL = new String("LOGINPANEL"); - public static final String LISTPANEL = new String("LISTPANEL"); - /** progress noted */ - public static final Message CURRENT = new Message("CURRENT"); - /** - * Indiciating an initial transfer - */ - public static final Message INITIAL = new Message("INITIAL"); - /** - * Indiciating a resumable transfer - */ - public static final Message RESUME = new Message("RESUME"); - /** - * Indicating that the we want to reload the data - */ - public static final Message RELOAD = new Message("RELOAD"); - /** - * An error message - */ - public static final Message ERROR = new Message("ERROR"); - /** - * Time counter message - */ - public static final Message TIME = new Message("TIME"); - /** - * Something like 'Connecting...' - */ - public static final Message PROGRESS = new Message("PROGRESS"); - /** - * A message about the transfered bytes - */ - public static final Message DATA = new Message("DATA"); - /** - * Write this message to the log - */ - public static final Message LOG = new Message("LOG"); - /** - * Write this mesage to the transcript - */ - public static final Message TRANSCRIPT = new Message("TRANSCRIPT"); - - private int current = 0; - /* - * current speed (bytes/second) - */ - private transient double speed = 0; - /* - * overall speed (bytes/second) - */ - private transient double overall = 0; - /* - * the size of the file - */ - private int length = -1; - /* - * timee left in seconds ((length-current)/speed) - */ - - private Calendar calendar = Calendar.getInstance(); - private DateFormat df = DateFormat.getTimeInstance(); - - private int seconds = 0; - private int minutes = 0; - private int hours = 0; - - //@todo -// private final static transient AudioClip startSound = Applet.newAudioClip(Cyberduck.getResource("start.au")); -// private final static transient AudioClip stopSound = Applet.newAudioClip(Cyberduck.getResource("stop.au")); -// private final static transient AudioClip completeSound = Applet.newAudioClip(Cyberduck.getResource("complete.au")); - - /** - * The wrapper for any status informations of a transfer like it's length and transferred - * bytes. - */ - public Status () { - Cyberduck.DEBUG("[Status] new Status()"); - - calendar.set(Calendar.HOUR, 0); - calendar.set(Calendar.MINUTE, 0); - calendar.set(Calendar.SECOND, 0); - - /* - timeLeftTimer = new Timer(1000, - new ActionListener() { - public void actionPerformed(ActionEvent e) { - setTimeLeft((int)((getLength() - getCurrent())/getSpeed())); - } - } - ); - */ - } - - /** - * Notify all observers - * @param arg The message to send to the observers - * @see ch.cyberduck.connection.Message - */ - public void callObservers(Object arg) { -// Cyberduck.DEBUG("[Bookmark] Notifying " + this.countObservers() + " observers."); -// long start = System.currentTimeMillis(); - this.setChanged(); - if(this.isSelected()) { - this.notifyObservers(arg); - } -// long end = System.currentTimeMillis(); -// Cyberduck.DEBUG("Status.callObservers(): " + (end - start) + " ms"); - } - - - // @todo replace this with HashMap messageMap - private String errormessage = ""; - private String progressmessage = "Idle"; - private String transcriptmessage = ""; - private String timemessage = "00:00"; - - // @todo replace this with messageMap.put(type, msg); - public void setMessage(String msg, Message type) { - if (type.equals(Status.TIME)) { - timemessage = msg; - } - else if (type.equals(Status.ERROR)) { - errormessage = msg; - } - /* - else if (type.equals(Message.STATUS)) { - statusmessage = msg; - } - */ - else if (type.equals(Status.PROGRESS)) { - progressmessage = msg; - } - else if (type.equals(Status.TRANSCRIPT)) { - transcriptmessage = msg; - } - this.callObservers(type); - } - - // @todo replace this with messageMap.get(type); - /** - * @return The status string - * @param type The type of message to return - * @see ch.cyberduck.connection.Message - */ - public String getMessage(Message type) { -// Cyberduck.DEBUG("[Status] getMessage(" + type + ")"); - if(type.equals(Status.TIME)) { - return timemessage; - } - if(type.equals(Status.DATA)) { - if(this.getSpeed() <= 0 && this.getOverall() <= 0) { - return this.parseDouble(this.getCurrent()/1024) + " of " + this.parseDouble(this.getLength()/1024) + " kBytes."; - } - else { - if(this.getOverall() <= 0) { - return this.parseDouble(this.getCurrent()/1024) + " of " - + this.parseDouble(this.getLength()/1024) + " kBytes. Current: " + - + this.parseDouble(this.getSpeed()/1024) + "kB/s. ";// + this.getTimeLeftMessage(); - } - else { - return this.parseDouble(this.getCurrent()/1024) + " of " - + this.parseDouble(this.getLength()/1024) + " kBytes. Current: " - + this.parseDouble(this.getSpeed()/1024) + "kB/s, Overall: " - + this.parseDouble(this.getOverall()/1024) + " kB/s. ";// + this.getTimeLeftMessage(); - } - } - } - if(type.equals(Status.ERROR)) { - return errormessage; - } - /* - if(type.equals(Message.STATUS)) { - return statusmessage; - } - */ - if(type.equals(Status.PROGRESS)) { - return progressmessage; - } - if(type.equals(Status.TRANSCRIPT)) { - return transcriptmessage; - } - throw new IllegalArgumentException("Can't find message of type " + type.toString()); - } - - private String parseTime(int t) { - if(t > 9) { - return String.valueOf(t); - } - else { - return "0" + t; - } - } - - private double parseDouble(double d) { - //Cyberduck.DEBUG("[Status] parseDouble(" + d + ")"); - String s = Double.toString(d); - if(s.indexOf(".") != -1) { - int l = s.substring(s.indexOf(".")).length(); - if(l > 3) { - return Double.parseDouble(s.substring(0, s.indexOf('.') + 3)); - } - else { - return Double.parseDouble(s.substring(0, s.indexOf('.') + l)); - } - } - else { - return d; - } - } - - public javax.swing.Icon getIcon() { - if(this.isComplete()) { - return ch.cyberduck.ui.common.GUIFactory.GREEN_ICON; - } - if(!this.isStopped()) { - return ch.cyberduck.ui.common.GUIFactory.BLUE_ICON; - } - if(this.getLength() > this.getCurrent()) { - return ch.cyberduck.ui.common.GUIFactory.RED_ICON; - } - return ch.cyberduck.ui.common.GUIFactory.GRAY_ICON; - } - - // ZUSTAENDE - private void setComplete(boolean b) { - this.complete = b; - } - public boolean isComplete() { - return this.complete; - } - - private void setStopped(boolean b) { - this.stopped = b; - } - public boolean isStopped() { - return this.stopped; - } - - public void setCanceled(boolean b) { - canceled = b; - } - - public boolean isCancled() { - return canceled; - } - - /** - * Notify that the connection has been opened. - */ - public void fireActiveEvent() { - Cyberduck.DEBUG("[Status] fireActiveEvent()"); - this.reset(); - this.setCanceled(false); - this.setComplete(false); - this.setStopped(false); - this.overallSpeedTimer.start(); - this.currentSpeedTimer.start(); - this.chronoTimer.start(); - if(!ignoreEvents) { - if(Preferences.instance().getProperty("status.sound.start").equals("true")) { -//@todo startSound.play(); - } - this.callObservers(Status.ACTIVE); - } - } - - /** - * Notify that the connection has been closed. - */ - public void fireStopEvent() { - Cyberduck.DEBUG("[Status] fireStopEvent()"); - if(this.currentSpeedTimer != null) - this.currentSpeedTimer.stop(); - if(this.overallSpeedTimer != null) - this.overallSpeedTimer.stop(); - if(this.chronoTimer != null) - this.chronoTimer.stop(); - if(!ignoreEvents) { - if(Preferences.instance().getProperty("status.sound.stop").equals("true") && !this.isComplete()) { -//@todo stopSound.play(); - } - this.setStopped(true); - this.setResume(false); - this.callObservers(Status.STOP); - } - } - - /** - * Notify that the transfer has been completed. - */ - public void fireCompleteEvent() { - Cyberduck.DEBUG("[Status] fireCompleteEvent()"); - this.currentSpeedTimer.stop(); - this.overallSpeedTimer.stop(); - this.chronoTimer.stop(); - if(!ignoreEvents) { - if(Preferences.instance().getProperty("status.sound.complete").equals("true")) { -//@todo completeSound.play(); - } - this.setStopped(true); - this.setResume(false); - this.setComplete(true); - this.callObservers(Status.COMPLETE); - } - } - - private transient boolean ignoreEvents = false; - - public void ignoreEvents(boolean ignore) { - this.ignoreEvents = ignore; - } - - public void setResume(boolean value) { - this.resume = value; - } - public boolean isResume() { - return this.resume; - } - - public int getCurrent() { - return current; - } - /** - * @param c The currently transfered bytes - */ - public void setCurrent(int c) { -// Cyberduck.DEBUG("[Status] setCurrent(" + c + ")"); - this.current = c; - this.callObservers(Status.CURRENT); - } - - /** - * @return double current bytes/second - */ - private double getSpeed() { - return this.speed; - } - private void setSpeed(double s) { - this.speed = s; - } - - /** - * @return double bytes per seconds transfered since the connection has been opened - */ - private double getOverall() { - return this.overall; - } - private void setOverall(double s) { - this.overall = s; - } - - /* - private void setTimeLeft(int seconds) { - this.left = seconds; - } - private int getTimeLeft() { - return this.left; - } - */ - /* - private String getTimeLeftMessage() { - int s = this.getTimeLeft(); - String message = ""; - /*@todo: implementation of better 'time left' management. - if(s != -1) { - if(s >= 60) { - message = (int)s/60 + " minutes remaining."; - } - else { - message = s + " seconds remaining."; - } - } - return message; - } - */ - - /** - * @ param length the size of file in bytes. - */ - public void setLength(int length) { - Cyberduck.DEBUG("[Status] setLength("+length+")"); - this.length = length; - } - - /** - * @ return length the size of file in bytes. - */ - public int getLength() { - return length; - } - - public BoundedRangeModel getProgressModel() { - DefaultBoundedRangeModel m = null; - try { - if(this.getLength() < 0) { - m = new DefaultBoundedRangeModel(0, 0, 0, 100); - } - m = new DefaultBoundedRangeModel(this.getCurrent(), 0, 0, this.getLength()); - } - catch(IllegalArgumentException e) { - m = new DefaultBoundedRangeModel(0, 0, 0, 100); - } - return m; - } - - public String getPanelProperty() { - if(this.panelProperty == null) - this.panelProperty = this.getDefaultPanelProperty(); - return this.panelProperty; - } - - public String getLastPanelProperty() { - if(this.lastPanelProperty == null || this.panelProperty.equals(this.lastPanelProperty)) - return this.getDefaultPanelProperty(); - return lastPanelProperty; - } - - public String getDefaultPanelProperty() { - return PROGRESSPANEL; - } - - - // initial panel property - private String panelProperty; - private String lastPanelProperty; - - public void setPanelProperty(String newPanelProperty) { - Cyberduck.DEBUG("[Status] setPanelProperty("+newPanelProperty+")"); - if(lastPanelProperty != newPanelProperty) { - this.lastPanelProperty = this.panelProperty; - } - if(panelProperty != newPanelProperty) { - this.panelProperty = newPanelProperty; - this.callObservers(newPanelProperty); - } - } - - /** - * reset messages and timers - */ - private void reset() { - Cyberduck.DEBUG("[Status] reset()"); - this.speed = 0; - this.overall = 0; - this.errormessage = ""; - //this.infomessage = ""; - this.timemessage = "00:00"; - - if(overallSpeedTimer == null) { - overallSpeedTimer = new Timer(4000, - new ActionListener() { - Vector overall = new Vector(); - double current; - double last; - public void actionPerformed(ActionEvent e) { - // Cyberduck.DEBUG("[Status] overallSpeedTimer:actionPerformed()"); - current = getCurrent(); - if(current <= 0) { - setOverall(0); - } - else { - overall.add(new Double((current - last)/4)); // bytes transferred for the last 4 seconds - Iterator iterator = overall.iterator(); - double sum = 0; - while(iterator.hasNext()) { - Double s = (Double)iterator.next(); - sum = sum + s.doubleValue(); - } - setOverall((sum/overall.size())); - last = current; - // Cyberduck.DEBUG("[Status] overallSpeed " + sum/overall.size()/1024 + " KBytes/sec"); - } - } - } - ); - } - - if(currentSpeedTimer == null) { - currentSpeedTimer = new Timer(500, - new ActionListener() { - int i = 0; - int current; - int last; - int[] speeds = new int[8]; - public void actionPerformed(ActionEvent e) { - // Cyberduck.DEBUG("[Status] currentSpeedTimer:actionPerformed()"); - int diff = 0; - current = getCurrent(); - if(current <= 0) { - setSpeed(0); - } - else { - speeds[i] = (current - last)*(2); i++; last = current; - if(i == 8) { // wir wollen immer den schnitt der letzten vier sekunden - i = 0; - } - - for (int k = 0; k < speeds.length; k++) { - diff = diff + speeds[k]; // summe der differenzen zwischen einer halben sekunde - } - - // Cyberduck.DEBUG("[Status] currentSpeed " + diff/speeds.length/1024 + " KBytes/sec"); - setSpeed((diff/speeds.length)); - } - } - } - ); - } - - if(chronoTimer == null) { - chronoTimer = new Timer(1000, - new ActionListener() { - public void actionPerformed(ActionEvent event) { - // Cyberduck.DEBUG("[Status] chronoTimer:actionPerformed()"); - seconds++; - // calendar.set(year, mont, date, hour, minute, second) - // >= one hour - if(seconds >= 3600) { - hours = (int)(seconds/60/60); - minutes = (int)((seconds - hours*60*60)/60); - calendar.set(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), calendar.get(Calendar.DATE), hours, minutes, seconds - minutes*60); - } - else { - // >= one minute - if(seconds >= 60) { - minutes = (int)(seconds/60); - calendar.set(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), calendar.get(Calendar.DATE), calendar.get(Calendar.HOUR), minutes, seconds - minutes*60); - } - // only seconds - else { - calendar.set(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), calendar.get(Calendar.DATE), calendar.get(Calendar.HOUR), calendar.get(Calendar.MINUTE), seconds); - } - } - - // der variable timemessage den neuen wert zuweisen. - if(calendar.get(Calendar.HOUR) > 0) { - setMessage(parseTime(calendar.get(Calendar.HOUR)) + ":" + parseTime(calendar.get(Calendar.MINUTE)) + ":" + parseTime(calendar.get(Calendar.SECOND)), Status.TIME); - } - else { - setMessage(parseTime(calendar.get(Calendar.MINUTE)) + ":" + parseTime(calendar.get(Calendar.SECOND)), Status.TIME); - } - } - } - ); - } - } - - public String toString() { - return "Status:" + "Stopped=" + isStopped() + ", Complete=" + isComplete() + ", Resume=" + isResume() + ", Current=" + getCurrent() + ", Speed=" + getSpeed() + ", Overall=" + getOverall(); - } -} diff --git a/source/ch/cyberduck/Attic/connection/Transcript.java b/source/ch/cyberduck/Attic/connection/Transcript.java deleted file mode 100644 index f5a95372ed..0000000000 --- a/source/ch/cyberduck/Attic/connection/Transcript.java +++ /dev/null @@ -1,57 +0,0 @@ -package ch.cyberduck.connection; - -/* - * ch.cyberduck.connection.Trasncript.java - * Cyberduck - * - * $Header$ - * $Revision$ - * $Date$ - * - * Copyright (c) 2003 David Kocher. All rights reserved. - * http://icu.unizh.ch/~dkocher/ - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * Bug fixes, suggestions and comments should be sent to: - * dkocher@cyberduck.ch - */ - -import javax.swing.JTextArea; - -import ch.cyberduck.ui.common.GUIFactory; - -/** - * Singleton text area to append logging messages. - * @version $Id$ - */ -public class Transcript extends JTextArea { - - private static Transcript instance; - - public static Transcript instance() { - if(instance == null) - instance = new Transcript(); - return instance; - } - - private Transcript() { - super(); - this.setEditable(true); - this.setFont(GUIFactory.FONT_MONOSPACED_SMALL); - } - - public void transcript(String text) { - //if(Preferences.instance().getProperty("connection.log").equals("true")) { - this.append(text); - this.setSelectionStart(this.getText().length()); - } -} diff --git a/source/ch/cyberduck/Attic/connection/TransferAction.java b/source/ch/cyberduck/Attic/connection/TransferAction.java deleted file mode 100644 index 00fd5d3403..0000000000 --- a/source/ch/cyberduck/Attic/connection/TransferAction.java +++ /dev/null @@ -1,111 +0,0 @@ -package ch.cyberduck.connection; - -/* - * ch.cyberduck.connection.TransferAction.java - * Cyberduck - * - * $Header$ - * $Revision$ - * $Date$ - * - * Copyright (c) 2003 David Kocher. All rights reserved. - * http://icu.unizh.ch/~dkocher/ - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * Bug fixes, suggestions and comments should be sent to: - * dkocher@cyberduck.ch - */ - - - -/** - * The TransferAction is passed to the transfer() method - * of the Bookmark class as a param. - * @see ch.cyberduck.connection.Bookmark#transfer - * @version $Id$ - */ -public class TransferAction implements java.io.Serializable { - - /** download */ - public static final String GET = "GET"; - /** upload */ - public static final String PUT = "PUT"; - - // ftp protocol only - /** delete */ - public static final String LIST = "LIST"; - /** make directory */ - public static final String MKDIR = "MKDIR"; - /** change directory */ - public static final String CHDIR = "CHDIR"; - /** delete */ - public static final String DELE = "DELE"; - /** rename */ - public static final String RNFR = "RNFR"; - /** system command*/ - public static final String SITE = "SITE"; - //public static final String ABORT = "ABORT"; - /** close connection */ - public static final String QUIT = "QUIT"; - - private String action; - //@todo replace this with a map - key value pairs - private Object param1 = null; - private Object param2 = null; - - /** - * @param action The String indicating the action (GET, PUT, ...) to pass to Bookmark.transfer() - */ - public TransferAction(String action, Object param1, Object param2) { - //Cyberduck.DEBUG("[TransferAction] TransferAction(" + action + "," + param2 + ")"); - this.action = action; - this.param1 = param1; - this.param2 = param2; - } - - /** - * @param action The String indicating the action (GET, PUT, ...) to pass to Bookmark.transfer() - */ - public TransferAction(String action, Object param1) { - //Cyberduck.DEBUG("[TransferAction] TransferAction(" + action + "," + param1 + ")"); - this.action = action; - this.param1 = param1; - } - - /** - * @param action The String indicating the action (GET, PUT, ...) to pass to Bookmark.transfer() - */ - public TransferAction(String action) { - this.action = action; - } - - /** - * @return the first parameter of this action or null if not set - */ - public Object getParam() { - return param1; - } - - /** - * @return the second parameter of this action or null if not set - */ - public Object getParam2() { - return param2; - } - - /** - * @return String represantation of this action like "GET" - */ - public String toString() { - return this.action; - } -} diff --git a/source/ch/cyberduck/Attic/connection/ftp/.DS_Store b/source/ch/cyberduck/Attic/connection/ftp/.DS_Store deleted file mode 100644 index 6e5794abda021ffd06ff10b21d8bfaac11683cf2..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcwPel00001 literal 6149 zcwX(;I}XAy5QO1b)m`{rSNO6)b$p(N8 zkNX+O01~`7VNv2X6S{rlHAF;23LUgNsJ zMmDjTEo^0*mk%xD@L{~OaY8XpAy(K55m~VF link" - */ - public static String parseLink(String link) { - if(!isValidLink(link)) { - return null; - } - return link.substring(jumpWhiteSpace(link, link.indexOf("->")) + 3).trim(); - } - - public static boolean isFile(String c) { - return c.charAt(0) == '-'; - } - - public static boolean isLink(String c) { - return c.charAt(0) == 'l'; - } - - public static boolean isDirectory(String c) { -// Cyberduck.DEBUG("[FTPParser] isDirectory(" + c + ")"); - return c.charAt(0) == 'd'; - } - - private static Path parseListLine(String parent, String line) throws FTPException { -// Cyberduck.DEBUG("[FTPParser] parseListLine("+ parent+","+line+")"); - // unix list format never strarts with number - if("0123456789".indexOf(line.charAt(0)) < 0) { - return FTPParser.parseUnixListLine(parent, line); - } - // windows list format always starts with number - else { - return FTPParser.parseWinListLine(parent, line); - } - } - - - private static Path parseWinListLine(String path, String line) throws FTPException { -// Cyberduck.DEBUG("[FTPParser] parseWinListLine("+ path+","+line+")"); - - // 10-16-01 11:35PM 1479 file - // 10-16-01 11:37PM awt * - Path p = null; - try { - StringTokenizer toker = new StringTokenizer(line); - long date = parseWinListDate (toker.nextToken(), toker.nextToken());// time - String size2dir = toker.nextToken(); // size or dir - String access; - int size = 0; - if(size2dir.equals("")) { - access = "d?????????"; - } - else { - access = "-?????????"; - } - String name = toker.nextToken("").trim(); - String owner = ""; - String group = ""; - - if(FTPParser.isDirectory(access) && !(name.charAt(name.length()-1) == '/')) { - name = name + "/"; - } - p = new Path(path, name); - p.setOwner(owner); - p.setModified(date); - p.setMode(access); - p.setPermission(new Permission(access)); - p.setSize(size); - return p; - } - catch(NumberFormatException e) { - throw new FTPException("Invalid server response : "+e.getMessage()); - } - catch(StringIndexOutOfBoundsException e) { - throw new FTPException("Invalid server response : "+e.getMessage()); - } - } - - private static long parseWinListDate(String date, String time) throws NumberFormatException { - //10-16-01 11:35PM - //10-16-2001 11:35PM - Calendar c = Calendar.getInstance(); - StringTokenizer toker = new StringTokenizer(date,"-"); - int m = Integer.parseInt(toker.nextToken()), - d = Integer.parseInt(toker.nextToken()), - y = Integer.parseInt(toker.nextToken()); - if(y >= 70) y += 1900; else y += 2000; - toker = new StringTokenizer(time,":APM"); - c.set(y,m,d,(time.endsWith("PM")?12:0)+ - Integer.parseInt(toker.nextToken()), - Integer.parseInt(toker.nextToken())); - return c.getTime().getTime(); - } - - private static Path parseUnixListLine(String path, String line) throws FTPException{ -// Cyberduck.DEBUG("[FTPParser] parseUnixListLine("+ path+","+line+")"); - - //drwxr-xr-x 33 root wheel 1078 Mar 15 16:18 bin - //lrwxrwxr-t 1 root admin 13 Mar 16 13:38 cores -> private/cores - //dr-xr-xr-x 2 root wheel 512 Mar 16 02:38 dev - //lrwxrwxr-t 1 root admin 11 Mar 16 13:38 etc -> private/etc - //lrwxrwxr-t 1 root admin 9 Mar 16 13:38 mach -> /mach.sym - //-r--r--r-- 1 root admin 563812 Mar 16 02:38 mach.sym - //-rw-r--r-- 1 root wheel 3156580 Jan 25 07:06 mach_kernel - //drwxr-xr-x 7 root wheel 264 Jul 10 2001 private - //drwxr-xr-x 59 root wheel 1962 Mar 15 16:18 sbin - //lrwxrwxr-t 1 root admin 11 Mar 16 13:38 tmp -> private/tmp - //drwxr-xr-x 11 root wheel 330 Jan 31 08:15 usr - //lrwxrwxr-t 1 root admin 11 Mar 16 13:38 var -> private/var - - Path p = null; - try { - String link = null; - if(isLink(line)) { - link = parseLink(line); - line = line.substring(0, line.indexOf("->")).trim(); - } - StringTokenizer toker = new StringTokenizer(line); - String access = toker.nextToken(); // access - toker.nextToken(); // links - String owner = toker.nextToken(); // owner - String group = toker.nextToken(); // group - String size = toker.nextToken(); // size - if(size.endsWith(",")) - size = size.substring(0,size.indexOf(",")); - String uu = size; - if(access.startsWith("c")) - uu = toker.nextToken(); // device - // if uu.charAt(0) is not digit try uu_file format - if("0123456789".indexOf(uu.charAt(0)) < 0) { - size = group; - group = ""; - } - long date = parseUnixListDate(("0123456789".indexOf(uu.charAt(0)) < 0 ?uu - :toker.nextToken()), // month - toker.nextToken(), // day - toker.nextToken()); // time or year - String name = toker.nextToken("").trim(); // name - - /* - //@ verify - if(FTPParser.isDirectory(access) && !(name.charAt(name.length()-1) == '/')) { - name = name + "/"; - } - */ - - p = new Path(path, name); - p.setOwner(owner); - p.setGroup(group); - p.setModified(date); - p.setMode(access); - p.setPermission(new Permission(access)); - p.setSize(Integer.parseInt(size)); - - - // @todo implement this in Path.class - /* - if(isLink(line)) { - // the following lines are the most ugly. I just don't know how I can be sure - // a link is a directory or a file. Now I look if there's a '.' and if we have execute rights. - - //good chance it is a directory if everyone can execute - boolean execute = p.getPermission().getOtherPermissions()[Permission.EXECUTE]; - boolean point = false; - if(link.length() >= 4) { - if(link.charAt(link.length()-3) == '.' || link.charAt(link.length()-4) == '.') - point = true; - } - boolean directory = false; - if(!point && execute) - directory = true; - - if(directory) { - //Cyberduck.DEBUG("***Parsing link as directory:"+link); - if(!(link.charAt(link.length()-1) == '/')) - link = link+"/"; - if(link.charAt(0) == '/') - p.setPath(link); - else - p.setPath(path + link); - } - else { - //Cyberduck.DEBUG("***Parsing link as file:"+link); - if(link.charAt(0) == '/') - p.setPath(link); - else - p.setPath(path + link); - } - } - */ - return p; - } - catch(NoSuchElementException e) { - throw new FTPException("Invalid server response : "+e.getMessage()); - } - catch(StringIndexOutOfBoundsException e) { - throw new FTPException("Invalid server response : "+e.getMessage()); - } - } - - - private static long parseUnixListDate(String month, String day, String year2time) throws NumberFormatException { - - // Nov 9 1998 - // Nov 12 13:51 - Calendar c = Calendar.getInstance(); - month = month.toUpperCase(); - for(int m=0;m<12;m++) { - if(month.equals(months[m])) { - if(year2time.indexOf(':')!= -1) { - // current year - c.setTime(new Date(System.currentTimeMillis())); - StringTokenizer toker = new StringTokenizer(year2time,":"); - // date and time - c.set(c.get(Calendar.YEAR), m, - Integer.parseInt(day), - Integer.parseInt(toker.nextToken()), - Integer.parseInt(toker.nextToken())); - } - else { - // date - c.set(Integer.parseInt(year2time), m, Integer.parseInt(day),0,0); - } - break; - } - } - return c.getTime().getTime(); - } - - // UTILITY METHODS - - private static boolean isValidLink(String link) { - return link.indexOf("->") != -1; - } - - private static boolean isValidLine(String l) { - String line = l.trim(); - if(line.equals("")) { - return false; - } - /* When decoding, it is important to note that many implementations include a line at the start like "total ". Clients should ignore any lines that don't match the described format. - */ - if( line.indexOf("total") != -1 ) { - try { - Integer.parseInt(line.substring(line.lastIndexOf(' ') + 1)); - return false; - } - catch(NumberFormatException e) { - // return true // total must be name of real file - } - } - return true; - } - - private static int jumpWhiteSpace(String line, int index) { - while(line.substring(index, index + 1).equals(" ")) { - index++; - } - return index; - } -} diff --git a/source/ch/cyberduck/Attic/connection/ftp/FTPSession.java b/source/ch/cyberduck/Attic/connection/ftp/FTPSession.java deleted file mode 100644 index e5b95b71b9..0000000000 --- a/source/ch/cyberduck/Attic/connection/ftp/FTPSession.java +++ /dev/null @@ -1,383 +0,0 @@ -package ch.cyberduck.connection.ftp; - -/* - * ch.cyberduck.connection.ftp.FTPSession.java - * Cyberduck - * - * $Header$ - * $Revision$ - * $Date$ - * - * Copyright (c) 2003 David Kocher. All rights reserved. - * http://icu.unizh.ch/~dkocher/ - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * Bug fixes, suggestions and comments should be sent to: - * dkocher@cyberduck.ch - */ - -import java.io.*; - -import com.enterprisedt.net.ftp.*; - -import ch.cyberduck.Cyberduck; -import ch.cyberduck.Preferences; -import ch.cyberduck.connection.*; - -/** - * Opens a connection to the remote server via ftp protocol - * @version $Id$ - */ -public class FTPSession extends Session { - - private FTPClient FTP; - - /** - * @param client The client to use which does implement the ftp protocol - * @param action The TransferAction to execute after the connection has been opened - * @param transfer The Bookmark object - * @param secure If the connection is secure - */ - public FTPSession(Bookmark b, TransferAction action) { - super(b, action); - this.FTP = new FTPClient(); - } - - private void connect() throws IOException, FTPException { - this.log("Connecting to " + bookmark.getHost(), Status.PROGRESS); - this.log("\nConnecting to " + bookmark.getIp()+"\n", Status.TRANSCRIPT); - if(Preferences.instance().getProperty("ftp.active").equals("true")) { - FTP.setConnectMode(FTPConnectMode.ACTIVE); - } - else if(Preferences.instance().getProperty("ftp.passive").equals("true")) { - FTP.setConnectMode(FTPConnectMode.PASV); - } - if(Preferences.instance().getProperty("connection.proxy").equals("true")) { - FTP.initSOCKS(Preferences.instance().getProperty("connection.proxy.port"), Preferences.instance().getProperty("connection.proxy.host")); - } - if(Preferences.instance().getProperty("connection.proxy.authenticate").equals("true")) { - FTP.initSOCKSAuthentication(Preferences.instance().getProperty("connection.proxy.username"), Preferences.instance().getProperty("connection.proxy.password")); - } - FTP.connect(bookmark.getHost(), bookmark.getPort()); - FTP.setTimeout(Integer.parseInt(Preferences.instance().getProperty("connection.timeout"))*60*1000); - this.log("Unsecure connection established.", Status.PROGRESS); - try { - this.log("Authenticating as " + bookmark.getUsername() + "...", Status.PROGRESS); - FTP.login(bookmark.getUsername(), bookmark.getPassword()); - this.log("Login successfull.", Status.PROGRESS); - } - catch(FTPException e) { - bookmark.status.setPanelProperty(Status.LOGINPANEL); - throw e; - } - FTP.system(); - } - - private void list(Path directory) throws FTPException, IOException { - FTP.setType(FTPTransferType.ASCII); - Path currentDirectory; - if(directory.getPath().equals("/") && bookmark.getCurrentPath().getPath().equals("/")) { - String cwd = FTP.pwd(); -// cwd = cwd.substring(cwd.indexOf('"') + 1, cwd.lastIndexOf('"')); - Path current = null; - if(cwd.length() == 1 && cwd.charAt(0) == '/') - current = new Path(cwd); - else - current = new Path(cwd +"/"); - bookmark.setCurrentPath(current); - } - else { - bookmark.setCurrentPath(directory); - FTP.chdir(directory.getPath()); - } - bookmark.setListing(FTPParser.parseList(bookmark.getCurrentPath().getPath(), FTP.dir())); - } - - private void delete(Path path) throws SessionException, IOException { - if(path.isDirectory()) { - FTP.chdir(path.getName()); - java.util.List files = FTPParser.parseList(path.getPath(), FTP.dir()); - java.util.Iterator iterator = files.iterator(); - Path file = null; - while(iterator.hasNext()) { - file = (Path)iterator.next(); - if(file.isDirectory()) { - this.delete(file); - } - if(file.isFile()) { - this.deleteFile(file.getName()); - } - } - FTP.cdup(); - FTP.rmdir(path.getName()); - } - if(path.isFile()) { - this.deleteFile(path.getName()); - } - } - - private void deleteFile(String file) throws SessionException, IOException { - this.check(); - this.log("Deleting '" + file + "'...", Status.PROGRESS); - FTP.delete(file); - } - - private void putDirectory(java.io.File file) throws SessionException, IOException { - FTP.mkdir(file.getName()); - FTP.chdir(file.getName()); - File[] files = file.listFiles(); - for(int i = 0; i < files.length; i++) { - if(files[i].isDirectory()) { - this.putDirectory(files[i]); - } - if(files[i].isFile()) { - this.putFile(files[i]); - } - } - FTP.cdup(); - } - - private void putFile(File file) throws SessionException, IOException { - this.check(); - bookmark.status.fireActiveEvent(); - bookmark.setLocalPath(file); - bookmark.status.setLength((int)file.length()); - bookmark.status.setCurrent(0); - if(bookmark.getTransferType().equals(FTPTransferType.BINARY)) { - //this.log("Setting transfer mode to BINARY.", Message.PROGRESS); - FTP.setType(FTPTransferType.BINARY); - - java.io.InputStream in = new FileInputStream(file); - if(in == null) { - throw new IOException("Unable to buffer data"); - } - - this.log("Opening data stream...", Status.PROGRESS); - - java.io.OutputStream out = FTP.putBinary(file.getName(), bookmark.status.isResume()); - if(out == null) { - throw new IOException("Unable opening data stream"); - } - this.log("Uploading "+file.getName()+"...", Status.PROGRESS); - this.upload(out, in); - FTP.validateTransfer(); - } - else if(bookmark.getTransferType().equals(FTPTransferType.ASCII)) { - //this.log("Setting transfer type to ASCII.", Message.PROGRESS); - FTP.setType(FTPTransferType.ASCII); - - java.io.Reader in = new FileReader(file); - if(in == null) { - throw new IOException("Unable to buffer data"); - } - - this.log("Opening data stream...", Status.PROGRESS); - java.io.Writer out = FTP.putASCII(file.getName(), bookmark.status.isResume()); - if(out == null) { - throw new IOException("Unable opening data stream"); - } - this.log("Uploading "+file.getName()+"...", Status.PROGRESS); - this.upload(out, in); - FTP.validateTransfer(); - } - } - - /** - * @param remote The absolute path of the file on the server - * @param local The name of the file to save locally - */ - private void getDirectory(Path remote, File local) throws SessionException, IOException { - java.util.List files = FTPParser.parseList(remote.getPath(), FTP.dir()); - File dir = new File(local, remote.getName()); - //Cyberduck.DEBUG("making directory: "+dir.toString()); - dir.mkdir(); - java.util.Iterator i = files.iterator(); - while(i.hasNext()) { - Path r = (Path)i.next(); - if(r.isDirectory()) { - //Cyberduck.DEBUG("changing directory: "+r.toString()); - FTP.chdir(r.getPath()); - this.getDirectory(r, dir); - } - if(r.isFile()) { - bookmark.setServerPath(r.getPath()); - bookmark.setLocalPath(new java.io.File(dir, r.getName())); - bookmark.status.setCurrent(0); - //Cyberduck.DEBUG("getting file:"+r.toString()); - this.getFile(r.getName(), bookmark.getLocalTempPath()); - } - } - //Cyberduck.DEBUG("upping directory"); - FTP.cdup(); - } - - /** - * @param file The filename of the remote file - * @param local The absolute path where to store the file locally - */ - private void getFile(String file, File local) throws SessionException, IOException { - this.check(); - bookmark.status.fireActiveEvent(); - if(bookmark.getTransferType().equals(FTPTransferType.BINARY)) { - //this.log("Setting transfer mode to BINARY", Message.PROGRESS); - FTP.setType(FTPTransferType.BINARY); - bookmark.status.setLength((int)(FTP.size(file))); - OutputStream out = new FileOutputStream(local.toString(), bookmark.status.isResume()); - if(out == null) { - throw new IOException("Unable to buffer data"); - } - this.log("Opening data stream...", Status.PROGRESS); -// public void get(OutputStream destStream, String remoteFile) - java.io.InputStream in = FTP.getBinary(file, bookmark.status.isResume() ? bookmark.status.getCurrent() : 0); - if(in == null) { - throw new IOException("Unable opening data stream"); - } - this.log("Downloading "+file+"...", Status.PROGRESS); - this.download(in, out); - FTP.validateTransfer(); - } - else if(bookmark.getTransferType().equals(FTPTransferType.ASCII)) { - //this.log("Setting transfer type to ASCII", Message.PROGRESS); - FTP.setType(FTPTransferType.ASCII); - bookmark.status.setLength((int)(FTP.size(file))); - java.io.Writer out = new FileWriter(local.toString(), bookmark.status.isResume()); - if(out == null) { - throw new IOException("Unable to buffer data"); - } - this.log("Opening data stream...", Status.PROGRESS); - java.io.Reader in = FTP.getASCII(file, bookmark.status.isResume() ? bookmark.status.getCurrent() : 0); - if(in == null) { - throw new IOException("Unable opening data stream"); - } - this.log("Downloading "+file+"...", Status.PROGRESS); - this.download(in, out); - FTP.validateTransfer(); - } - else { - throw new FTPException("Unknown transfer type"); - } - } - - public void run() { - bookmark.status.fireActiveEvent(); - Cyberduck.DEBUG("[FtpSession] run():" + action.toString() + "************************************"); - try { - this.log("Checking status...", Status.PROGRESS); - if(action.toString().equals(TransferAction.QUIT)) { - if(FTP.isAlive()) { - this.log("Disconnecting from '" + bookmark.getHost() + "'...", Status.PROGRESS); - FTP.quit(); - } - this.log("Disconnected", Status.PROGRESS); - return; - } - if(!FTP.isAlive()) { - this.connect(); - } - try { - FTP.noop(); - } - catch(IOException e) { - Cyberduck.DEBUG(e.getMessage()); - this.connect(); - } - catch(SessionException e) { - Cyberduck.DEBUG(e.getMessage()); - this.connect(); - } - this.check(); - if(action.toString().equals(TransferAction.GET)) { - FTP.chdir(bookmark.getServerDirectoryAsString()); - Path p = bookmark.getServerPath(); - if(p.isFile()) { - this.getFile(bookmark.getServerFilename(), bookmark.getLocalTempPath()); - } - if(p.isDirectory()) { - bookmark.status.ignoreEvents(true); - this.getDirectory(p, new java.io.File(Preferences.instance().getProperty("download.path"))); - bookmark.status.ignoreEvents(false); - bookmark.status.fireCompleteEvent(); - } - FTP.quit(); - } - else if(action.toString().equals(TransferAction.PUT)) { - FTP.chdir(bookmark.getCurrentPathAsString()); - File f = (File)action.getParam(); - if(f.isDirectory()) { - bookmark.status.ignoreEvents(true); - this.putDirectory(f); - bookmark.status.ignoreEvents(false); - bookmark.status.fireCompleteEvent(); - } - if(f.isFile()) { - this.putFile(f); - } - this.list(bookmark.getCurrentPath()); - } - else if(action.toString().equals(TransferAction.LIST)) { - Path directory; - if(action.getParam() == null) - directory = bookmark.getCurrentPath(); - else - directory = (Path)action.getParam(); - this.log("Listing directory '" + directory + "'...", Status.PROGRESS); - this.list(directory); - //this.log("Listing of '" + directory + "' complete", Message.PROGRESS); - } - else if(action.toString().equals(TransferAction.MKDIR)) { - FTP.chdir(bookmark.getCurrentPathAsString()); - this.log("Making directory '" + action.getParam() + "'...", Status.PROGRESS); - FTP.mkdir((String)action.getParam()); - this.list(bookmark.getCurrentPath()); - } - else if(action.toString().equals(TransferAction.DELE)) { - FTP.chdir(bookmark.getCurrentPathAsString()); - this.log("Deleting '" + action.getParam() + "'...", Status.PROGRESS); - this.delete((Path)action.getParam()); - //this.log("'" + action.getParam() + "' deleted", Message.PROGRESS); - this.list(bookmark.getCurrentPath()); - } - else if(action.toString().equals(TransferAction.RNFR)) { - FTP.chdir(bookmark.getCurrentPathAsString()); - Path from = (Path)action.getParam(); - Path to = ((Path)action.getParam2()).getRelativePath(bookmark.getCurrentPath()); - this.log("Renaming '" + from + "' to '" + to + "'...", Status.PROGRESS); - FTP.rename(from.getName(), to.getPath()); - this.list(bookmark.getCurrentPath()); - } - else if(action.toString().equals(TransferAction.SITE)) { - String command = (String)action.getParam(); - this.log("Running SITE command...", Status.PROGRESS); - FTP.site(command); - this.list(bookmark.getCurrentPath()); - //this.log("Renaming '" + from.getName() + "' to '" + to.getName() + "'...", Status.PROGRESS); - } - else { - throw new FTPException("Unknown action: " + action.toString()); - } - this.log("Command completed.", Status.PROGRESS); - } - catch (SessionException e) { - this.log("FTP Error: " + e.getReplyCode() + " " + e.getMessage(), Status.ERROR); - this.log("Incomplete", Status.PROGRESS); - } - catch (IOException e) { - this.log("IO Error: " + e.getMessage(), Status.ERROR); - this.log("Incomplete", Status.PROGRESS); - } - finally { - this.saveLog(); - this.bookmark.status.ignoreEvents(false); - this.bookmark.status.fireStopEvent(); - } - } -} diff --git a/source/ch/cyberduck/Attic/connection/http/.DS_Store b/source/ch/cyberduck/Attic/connection/http/.DS_Store deleted file mode 100644 index 6e5794abda021ffd06ff10b21d8bfaac11683cf2..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcwPel00001 literal 6149 zcwX(;I}XAy5QO1b)m`{rSNO6)b$p(N8 zkNX+O01~`7VNv2X6S{rlHAF;23LUgNsJ zMmDjTEo^0*mk%xD@L{~OaY8XpAy(K55m~VFTransferAction to execute after the connection has been opened - * @param b The Bookmark object - * @param secure If the connection is secure - */ -// public HTTPSession(Client client, Bookmark b, TransferAction action, boolean secure) { - public HTTPSession(Bookmark b, TransferAction action, boolean secure) { - super(b, action, secure); - this.HTTP = new HttpClient(); - } - - /** - * Connect to the remote server and execute the action set - * via Session.setAction(TransferAction action) - * Must be ConnectAction.GET - */ - public void run() { - bookmark.status.fireActiveEvent(); - Cyberduck.DEBUG("[HTTPConnection] run():" + action.toString() + "************************************"); - GetMethod GET = null; - try { - this.log("Connecting to " + bookmark.getHost(), Status.PROGRESS); - this.log("\nConnecting to " + bookmark.getIp()+"\n", Status.TRANSCRIPT); - if(this.action.toString().equals(TransferAction.GET)) { - if(Preferences.instance().getProperty("connection.proxy").equals("true")) { - HTTP.connect(bookmark.getHost(), bookmark.getPort(), Preferences.instance().getProperty("connection.proxy.host"), Integer.parseInt(Preferences.instance().getProperty("connection.proxy.port"))); - } - else { - HTTP.connect(bookmark.getHost(), bookmark.getPort(), secure); - } - this.log("Connected.", Status.PROGRESS); - this.check(); - -// GET = new GetMethod(Path.encode(bookmark.getServerPathAsString())); - GET = new GetMethod(bookmark.getServerPathAsString()); - GET.setUseDisk(false); - - if(Preferences.instance().getProperty("connection.proxy.authenticate").equals("true")) { - // enter the username and password for the proxy - String authString = Preferences.instance().getProperty( - "connection.proxy.username") - +":"+ - Preferences.instance().getProperty("connection.proxy.password"); - // base64 encode the password. - String auth = "Basic " + Base64.encode(authString.getBytes()); - // Set up the connection so it knows we are sending proxy user information - GET.addRequestHeader( "Proxy-Authorization", auth ); - } - GET.addRequestHeader("Accept", "*/*"); - GET.addRequestHeader("User-Agent", "Cyberduck/" + Cyberduck.getVersion()); - if(bookmark.status.isResume()) { - GET.addRequestHeader("Range", "bytes=" + bookmark.status.getCurrent() + "-"); - } - - this.log("\n", Status.TRANSCRIPT); - String p = GET.isHttp11() ? "HTTP/1.1" : "HTTP/1.0"; - this.log("GET " + bookmark.getServerPathAsString() + " " + p + "\n", Status.TRANSCRIPT); - Header[] requestHeaders = GET.getRequestHeaders(); - for(int i = 0; i < requestHeaders.length; i++) { - this.log(requestHeaders[i].toExternalForm(), Status.TRANSCRIPT); - } - this.check(); - int response = HTTP.executeMethod(GET); - this.log(response + " " + HttpStatus.getStatusText(response) + "\n", Status.TRANSCRIPT); - Header[] responseHeaders = GET.getResponseHeaders(); - for(int i = 0; i < responseHeaders.length; i++) { - this.log(responseHeaders[i].toExternalForm(), Status.TRANSCRIPT); - } - this.log("\n", Status.TRANSCRIPT); - - if(response == HttpStatus.SC_MOVED_PERMANENTLY || response == HttpStatus.SC_MOVED_TEMPORARILY) { - try { - URL redirect = new URL(GET.getResponseHeader("Location").getValue()); - bookmark.setAddress(redirect); - //bookmark.transfer(new TransferAction(TransferAction.GET)); - return; - } - catch(MalformedURLException e) { - throw new HttpException(HttpStatus.getStatusText(response), response); - } - } - - if(!HttpStatus.isSuccessfulResponse(response)) { - throw new HttpException(HttpStatus.getStatusText(response), response); - } - - if(bookmark.status.isResume()) { - if(GET.getStatusCode() != HttpStatus.SC_PARTIAL_CONTENT) { - this.log("Resumption not possible.", Status.ERROR); - bookmark.status.setCurrent(0); - bookmark.status.setResume(false); - } - else { - this.log("Resume at " + bookmark.status.getCurrent() + ".", Status.PROGRESS); - } - } - - Header rangeHeader = GET.getResponseHeader("Content-Range"); //Content-Range: bytes 21010-47021/47022 - Header lengthHeader = GET.getResponseHeader("Content-Length"); - Header transferEncodingHeader = GET.getResponseHeader("Bookmark-Encoding"); - if(lengthHeader != null) { - try { - bookmark.status.setLength(Integer.parseInt(lengthHeader.getValue())); - } - catch(NumberFormatException e) { - bookmark.status.setLength(-1); - } - } - if(rangeHeader != null) { - try { - String v = rangeHeader.getValue(); - int l = Integer.parseInt(v.substring(v.indexOf('/') + 1)); - bookmark.status.setLength(l); - } - catch(NumberFormatException e) { - bookmark.status.setLength(-1); - } - } - else if(null != transferEncodingHeader) { - if("chunked".equalsIgnoreCase(transferEncodingHeader.getValue())) { - bookmark.status.setLength(-1); - } - } - - if(bookmark.getTransferType().equals(FTPTransferType.BINARY)) { - OutputStream out = new FileOutputStream(bookmark.getLocalTempPath().toString(), bookmark.status.isResume()); - if(out == null) { - throw new IOException("Unable to buffer data"); - } - this.check(); - this.log("Opening data stream...", Status.PROGRESS); - InputStream in = HTTP.getInputStream(GET); - if(in == null) { - throw new IOException("Unable opening data stream"); - } - this.log("Downloading "+bookmark.getServerFilename()+"...", Status.PROGRESS); - this.download(in, out); - } - else if(bookmark.getTransferType().equals(FTPTransferType.ASCII)) { - throw new IOException("ASCII transfers are not currently supported in HTTP mode"); - //@todo: support ASCII http transfers. - /* - java.io.Writer out = new FileWriter(bookmark.getLocalTempPath().toString(), bookmark.bookmark.status.isResume()); - if(out == null) { - throw new IOException("Unable to buffer data"); - } - this.log("Opening data stream...", Message.PROGRESS); - java.io.Reader in = HTTP.getASCII(GET); - if(in == null) { - throw new IOException("Unable opening data stream"); - } - this.transfer(in, out); - */ - } - else { - throw new HttpException("Unknown transfer type"); - } - } - else { - throw new HttpException("Unknown action: " + action.toString()); - } - } - catch(SessionException e) { - this.log("Incomplete." , Status.PROGRESS); - Header[] responseHeaders = GET.getResponseHeaders(); - for(int i = 0; i < responseHeaders.length; i++) { - this.log(responseHeaders[i].toExternalForm(), Status.TRANSCRIPT); - } - this.log("\n", Status.TRANSCRIPT); - this.log("HTTP Error: " + e.getReplyCode() + " " + e.getMessage(), Status.ERROR); - } - catch (IOException e) { - this.log("Incomplete." , Status.PROGRESS); - this.log("IO Error: " + e.getMessage(), Status.ERROR); - } - finally { - try { - HTTP.quit(); - } - catch(IOException e) { - this.log(e.getMessage() , Status.ERROR); - } - this.saveLog(); - bookmark.status.fireStopEvent(); - } - } -} diff --git a/source/ch/cyberduck/Attic/connection/sftp/.DS_Store b/source/ch/cyberduck/Attic/connection/sftp/.DS_Store deleted file mode 100644 index 6e5794abda021ffd06ff10b21d8bfaac11683cf2..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcwPel00001 literal 6149 zcwX(;I}XAy5QO1b)m`{rSNO6)b$p(N8 zkNX+O01~`7VNv2X6S{rlHAF;23LUgNsJ zMmDjTEo^0*mk%xD@L{~OaY8XpAy(K55m~VFTransferAction to execute after the connection has been opened - * @param transfer The Bookmark object - * @param secure If the connection is secure - */ - public SFTPSession(Bookmark b, TransferAction action) { - super(b, action, true); - SSH = new SshClient(); - } - - public void run() { - try { - bookmark.status.fireActiveEvent(); - this.log("Checking status...", Status.PROGRESS); - if(action.toString().equals(TransferAction.QUIT)) { - //if(SFTP.isAlive()) { - this.log("Disconnecting from '" + bookmark.getHost() + "'...", Status.PROGRESS); - this.quit(); - // } - this.log("Disconnected", Status.PROGRESS); - return; - } - /* if(!SFTP.isAlive()) { - this.connect(); - } - try { - SFTP.noop(); - } - catch(IOException e) { - Cyberduck.DEBUG(e.getMessage()); - this.connect(); - } - catch(SessionException e) { - Cyberduck.DEBUG(e.getMessage()); - this.connect(); - } - */ - this.connect(); - this.check(); - - if(action.toString().equals(TransferAction.LIST)) { - Path directory; - if(action.getParam() == null) - directory = bookmark.getCurrentPath(); - else - directory = (Path)action.getParam(); - this.log("Listing directory '" + directory + "'...", Status.PROGRESS); - this.list(directory); - } - else if(action.toString().equals(TransferAction.MKDIR)) { - SFTP.openDirectory(bookmark.getCurrentPathAsString()); - this.log("Making directory '" + action.getParam() + "'...", Status.PROGRESS); - SFTP.makeDirectory((String)action.getParam()); - this.list(bookmark.getCurrentPath()); - } - else { - throw new SFTPException("Unknown action: " + action.toString()); - } - this.log("Command completed.", Status.PROGRESS); - } - catch (SessionException e) { - this.log("SFTP Error: " + e.getReplyCode() + " " + e.getMessage(), Status.ERROR); - this.log("Incomplete", Status.PROGRESS); - } - catch (IOException e) { - this.log("IO Error: " + e.getMessage(), Status.ERROR); - this.log("Incomplete", Status.PROGRESS); - } - finally { - this.saveLog(); - this.bookmark.status.ignoreEvents(false); - this.bookmark.status.fireStopEvent(); - } - } - - private void connect() throws IOException, SessionException { - if(!SSH.isConnected()) { - this.log("\nConnecting to " + bookmark.getIp()+"\n", Status.TRANSCRIPT); - // Make a client connection - this.log("Initializing SSH connection", Status.PROGRESS); - // Connect to the host - SSH.connect(bookmark.getHost()); - - // Create a password authentication instance - this.log("Authenticating as '"+bookmark.getUsername()+"'", Status.PROGRESS); - PasswordAuthentication pwd = new PasswordAuthentication(); - pwd.setUsername(bookmark.getUsername()); - pwd.setPassword(bookmark.getPassword()); - - // Try the authentication - int result = SSH.authenticate(pwd); - // Evaluate the result - if (result == AuthenticationProtocolState.COMPLETE) { - this.log("Login sucessfull", Status.PROGRESS); - this.log("Opening SSH session channel", Status.PROGRESS); - // The connection is authenticated we can now do some real work! - session = SSH.openSessionChannel(); - this.log("Starting SFTP subsystem", Status.PROGRESS); - SFTP = new SftpSubsystemClient(); - session.startSubsystem(SFTP); - this.log("Secure connection established.", Status.PROGRESS); - } - else { - bookmark.status.setPanelProperty(Status.LOGINPANEL); - throw new SFTPException("Authentication failed.", ""+result); - } - } - } - - private void list(Path directory) throws IOException, SessionException { - SftpFile workingDirectory; - // no specific directory has been given. Open the user's default directory on the server. - if(directory.getPath().equals("/") && bookmark.getCurrentPath().getPath().equals("/")) { - workingDirectory = SFTP.openDirectory("."); - java.util.List children = new java.util.ArrayList(); - int read = 1; - while(read > 0) { - read = SFTP.listChildren(workingDirectory, children); - } - java.util.Iterator i = children.iterator(); - } - else { - workingDirectory = SFTP.openDirectory(directory.getPath()); -// bookmark.setCurrentPath(new Path(workingDirectory.getAbsolutePath()+"/")); - } - - bookmark.setCurrentPath(new Path(workingDirectory.getAbsolutePath())); - List children = new ArrayList(); - int read = 1; - while(read > 0) { - read = SFTP.listChildren(workingDirectory, children); - } - bookmark.setListing(SFTPParser.parseList(workingDirectory.getAbsolutePath(), children)); - } - - private void quit() throws IOException { - session.close(); - SSH.disconnect(); - } -} diff --git a/source/ch/cyberduck/Attic/menu/MenuAction.java b/source/ch/cyberduck/Attic/menu/MenuAction.java deleted file mode 100644 index c9a2fc1a6d..0000000000 --- a/source/ch/cyberduck/Attic/menu/MenuAction.java +++ /dev/null @@ -1,168 +0,0 @@ -package ch.cyberduck.menu; - -/* - * ch.cyberduck.menu.MenuAction.java - * Cyberduck - * - * $Header$ - * $Revision$ - * $Date$ - * - * Copyright (c) 2003 David Kocher. All rights reserved. - * http://icu.unizh.ch/~dkocher/ - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * Bug fixes, suggestions and comments should be sent to: - * dkocher@mac.com - * - * - * Sample code. - * Permission is given to use or modify this code in your own code. - * Lee Ann Rucker - */ - -import javax.swing.*; -import javax.swing.event.*; -import java.awt.*; -import java.awt.event.*; -import java.beans.*; - -/** -MenuAction is an AbstractAction designed to be shared amongst several JMenuBars; - it controls JMenus which contain shared MenuItemActions - */ -public class MenuAction extends AbstractAction { - Object[] items; - int count = 0; - - /** - * Constructs a new MenuAction which can be used to create a - * JMenu with the supplied string as its text - * - * - * @param s the text for the menu label - * @param items the contents of the menu - */ - MenuAction(String s, Object[] items) { - super(s); - this.items = items; - } - - /** Convenience method to create a JMenuBar from an array of MenuActions. - Each JFrame needs its own JMenuBar - - * @param menus the MenuActions that will create the JMenuBar - */ - /* - public static JMenuBar makeMenuBar(MenuAction[] menus) { - JMenuBar mb = new JMenuBar(); - for (int i = 0; i < menus.length; i++) - mb.add(menus[i].createMenu()); - return mb; - } - */ - - /** Create a JMenu that contains the provided items - and knows how to handle adding and removing them - */ - public JMenu makeMenu() { - JActionMenu menu = new JActionMenu(this); - addItems(menu); - return menu; - } - - /** - * Add the items to this MenuAction's JMenu - */ - protected void addItems(JMenu menu) { - if (items != null) { - synchronized (menu.getTreeLock()) { - for (int i = 0; i < items.length; i++) { - if (items[i] instanceof MenuItemAction) - menu.add(((MenuItemAction)items[i]).createMenuItem()); - else if (items[i] instanceof JPopupMenu.Separator) - menu.add(new JPopupMenu.Separator()); - else if (items[i] instanceof JSeparator) - menu.add(new JSeparator()); - // if the item is a JSeparator, make a new one, if we reuse - // the one from the array, it'll be removed from the last menu we made - } - } - } - } - - /** Does nothing, since JMenus are usually containers for JMenuItems - */ - public void actionPerformed(ActionEvent e) {} - - /** - Add an item to this MenuAction and all the JMenu instances that use it - */ - public void add(MenuItemAction action) { - int oldLength = items.length; - Object[] newItems = new Object[oldLength + 1]; - System.arraycopy(items, 0, newItems, 0, oldLength); - items = newItems; - items[oldLength] = action; - - firePropertyChange("MenuAction.addAction", null, action); - } - - /** - Remove an item from this MenuAction and all the JMenu instances that use it - */ - public void remove(MenuItemAction action) { - // Find the index of this action - // and remove based on index - int index = -1; - for (int i = 0; i < items.length; i++) { - if (action.equals(items[i])) { - index = i; - break; - } - } - if (index >= 0) { - int oldLength = items.length; - Object[] newItems = new Object[oldLength - 1]; - System.arraycopy(items, 0, newItems, 0, index); - System.arraycopy(items, index + 1, - newItems, index, - oldLength - index - 1); - items = newItems; - firePropertyChange("MenuAction.remove", null, new Integer(index)); - } - } - - /** Subclass of JMenu which handles adding and removing MenuActions - */ - class JActionMenu extends JMenu { - boolean fAddAll = false; - JActionMenu(Action action) { - super(action); - action.addPropertyChangeListener(new ActionItemsChangedListener()); - } - - JMenu getMenu() {return this;} - - private class ActionItemsChangedListener implements PropertyChangeListener { - public void propertyChange(PropertyChangeEvent e) { - String propertyName = e.getPropertyName(); - if (e.getPropertyName().equals("MenuAction.addAction")) { - getMenu().add(((MenuItemAction) e.getNewValue()).createMenuItem()); - } - else if (e.getPropertyName().equals("MenuAction.remove")) { - getMenu().remove(((Integer) e.getNewValue()).intValue()); - } - } - } - } -} diff --git a/source/ch/cyberduck/Attic/menu/MenuItemAction.java b/source/ch/cyberduck/Attic/menu/MenuItemAction.java deleted file mode 100644 index fa25fc17af..0000000000 --- a/source/ch/cyberduck/Attic/menu/MenuItemAction.java +++ /dev/null @@ -1,148 +0,0 @@ -package ch.cyberduck.menu; - -/* - * ch.cyberduck.menu.MenuItemAction.java - * Cyberduck - * - * $Header$ - * $Revision$ - * $Date$ - * - * Copyright (c) 2003 David Kocher. All rights reserved. - * http://icu.unizh.ch/~dkocher/ - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * Bug fixes, suggestions and comments should be sent to: - * dkocher@mac.com - * - * - * Sample code. - * Permission is given to use or modify this code in your own code. - * Lee Ann Rucker - */ - -import javax.swing.*; -import javax.swing.event.EventListenerList; -import java.awt.*; -import java.awt.event.*; - -/** -MenuItemAction is an AbstractAction designed to control JMenuItems which - are shared amongst several JMenuBars. - - For convenience, it uses ActionListeners just like JMenuItems do. - - This implementation uses getMenuShortcutKeyMask to provide the correct - modifiers for the current platform. - - It's recommended you not use mnemonics on Macintoshes, as that is counter to - the Mac User Interface - */ -public class MenuItemAction extends AbstractAction { - - static int sMenuMask = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(); - protected EventListenerList listenerList = new EventListenerList(); - - /** - * Creates a menuItemAction with text. - * - * @param text the text of the MenuItem. - */ - MenuItemAction(String text) { - super(text); - } - - /** - * Creates a menuItemAction with text and an accelerator. - * - * @param text the text of the MenuItem. - * @param accel the key which will be combined with the - * default MenuShortcutKeyMask to create the accelerator - * - * @see #Toolkit.getMenuShortcutKeyMask - */ - MenuItemAction(String text, int accel) { - this(text, accel, 0); - } - - /** - * Creates a menuItemAction with text and an accelerator. - * - * @param text the text of the MenuItem. - * @param accel the key which will be combined with the - * default MenuShortcutKeyMask to create the accelerator - * @param extraMask the modifiers which will be combined with the default - * modifier - * For best results, extraMask should not be ctrl or meta - * because the default might be one of those - * ctrl-meta shortcuts are not common on any platform - * - * @see #Toolkit.getMenuShortcutKeyMask - */ - - MenuItemAction(String text, int accel, int extraMask) { - super(text); - putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(accel, sMenuMask | extraMask)); - } - - /** Create a JMenuItem that uses this Action. - You could just create a new JMenuItem directly, but prior to 1.4, - JMenuItem.configurePropertiesFromAction ignores ACCELERATOR_KEY - - If you set it after creation, remember that JMenuItem's default - PropertyChangeListener isn't looking for it either, so you'll need to add your own - */ - public JMenuItem createMenuItem() { - JMenuItem mi = new JMenuItem(this); - KeyStroke accel = (KeyStroke)getValue(Action.ACCELERATOR_KEY); - if (accel != null) - mi.setAccelerator(accel); - return mi; - } - - /** - * Adds an ActionListener to the Action. - * @param l the ActionListener to be added - */ - public void addActionListener(ActionListener l) { - listenerList.add(ActionListener.class, l); - } - - - /** - * Removes an ActionListener from the Action. - * @param l the listener to be removed - */ - public void removeActionListener(ActionListener l) { - listenerList.remove(ActionListener.class, l); - } - - /** - * Notifies all listeners that have registered interest for - * notification on this event type. - * - * @param e the ActionEvent object - * @see EventListenerList - */ - public void actionPerformed(ActionEvent event) { - // Guaranteed to return a non-null array - Object[] listeners = listenerList.getListenerList(); - // Process the listeners last to first, notifying - // those that are interested in this event - for (int i = listeners.length-2; i>=0; i-=2) { - if (listeners[i]==ActionListener.class) { - ((ActionListener)listeners[i+1]).actionPerformed(event); - } - } - } -} - diff --git a/source/ch/cyberduck/Attic/util/BrowserLauncher.java b/source/ch/cyberduck/Attic/util/BrowserLauncher.java deleted file mode 100644 index eba01b2ee1..0000000000 --- a/source/ch/cyberduck/Attic/util/BrowserLauncher.java +++ /dev/null @@ -1,584 +0,0 @@ -package ch.cyberduck.util; -//package edu.stanford.ejalbert; - -import java.io.File; -import java.io.IOException; -import java.lang.reflect.Constructor; -import java.lang.reflect.Field; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; - -/** - * BrowserLauncher is a class that provides one static method, openURL, which opens the default - * web browser for the current user of the system to the given URL. It may support other - * protocols depending on the system -- mailto, ftp, etc. -- but that has not been rigorously - * tested and is not guaranteed to work. - *

- * Yes, this is platform-specific code, and yes, it may rely on classes on certain platforms - * that are not part of the standard JDK. What we're trying to do, though, is to take something - * that's frequently desirable but inherently platform-specific -- opening a default browser -- - * and allow programmers (you, for example) to do so without worrying about dropping into native - * code or doing anything else similarly evil. - *

- * Anyway, this code is completely in Java and will run on all JDK 1.1-compliant systems without - * modification or a need for additional libraries. All classes that are required on certain - * platforms to allow this to run are dynamically loaded at runtime via reflection and, if not - * found, will not cause this to do anything other than returning an error when opening the - * browser. - *

- * There are certain system requirements for this class, as it's running through Runtime.exec(), - * which is Java's way of making a native system call. Currently, this requires that a Macintosh - * have a Finder which supports the GURL event, which is true for Mac OS 8.0 and 8.1 systems that - * have the Internet Scripting AppleScript dictionary installed in the Scripting Additions folder - * in the Extensions folder (which is installed by default as far as I know under Mac OS 8.0 and - * 8.1), and for all Mac OS 8.5 and later systems. On Windows, it only runs under Win32 systems - * (Windows 95, 98, and NT 4.0, as well as later versions of all). On other systems, this drops - * back from the inherently platform-sensitive concept of a default browser and simply attempts - * to launch Netscape via a shell command. - *

- * This code is Copyright 1999-2001 by Eric Albert (ejalbert@cs.stanford.edu) and may be - * redistributed or modified in any form without restrictions as long as the portion of this - * comment from this paragraph through the end of the comment is not removed. The author - * requests that he be notified of any application, applet, or other binary that makes use of - * this code, but that's more out of curiosity than anything and is not required. This software - * includes no warranty. The author is not repsonsible for any loss of data or functionality - * or any adverse or unexpected effects of using this software. - *

- * Credits: - *
Steven Spencer, JavaWorld magazine (Java Tip 66) - *
Thanks also to Ron B. Yeh, Eric Shapiro, Ben Engber, Paul Teitlebaum, Andrea Cantatore, - * Larry Barowski, Trevor Bedzek, Frank Miedrich, and Ron Rabakukk - * - * @author Eric Albert (ejalbert@cs.stanford.edu) - * @version 1.4b1 (Released June 20, 2001) - */ -public class BrowserLauncher { - - /** - * The Java virtual machine that we are running on. Actually, in most cases we only care - * about the operating system, but some operating systems require us to switch on the VM. */ - private static int jvm; - - /** The browser for the system */ - private static Object browser; - - /** - * Caches whether any classes, methods, and fields that are not part of the JDK and need to - * be dynamically loaded at runtime loaded successfully. - *

- * Note that if this is false, openURL() will always return an - * IOException. - */ - private static boolean loadedWithoutErrors; - - /** The com.apple.mrj.MRJFileUtils class */ - private static Class mrjFileUtilsClass; - - /** The com.apple.mrj.MRJOSType class */ - private static Class mrjOSTypeClass; - - /** The com.apple.MacOS.AEDesc class */ - private static Class aeDescClass; - - /** The (int) method of com.apple.MacOS.AETarget */ - private static Constructor aeTargetConstructor; - - /** The (int, int, int) method of com.apple.MacOS.AppleEvent */ - private static Constructor appleEventConstructor; - - /** The (String) method of com.apple.MacOS.AEDesc */ - private static Constructor aeDescConstructor; - - /** The findFolder method of com.apple.mrj.MRJFileUtils */ - private static Method findFolder; - - /** The getFileCreator method of com.apple.mrj.MRJFileUtils */ - private static Method getFileCreator; - - /** The getFileType method of com.apple.mrj.MRJFileUtils */ - private static Method getFileType; - - /** The openURL method of com.apple.mrj.MRJFileUtils */ - private static Method openURL; - - /** The makeOSType method of com.apple.MacOS.OSUtils */ - private static Method makeOSType; - - /** The putParameter method of com.apple.MacOS.AppleEvent */ - private static Method putParameter; - - /** The sendNoReply method of com.apple.MacOS.AppleEvent */ - private static Method sendNoReply; - - /** Actually an MRJOSType pointing to the System Folder on a Macintosh */ - private static Object kSystemFolderType; - - /** The keyDirectObject AppleEvent parameter type */ - private static Integer keyDirectObject; - - /** The kAutoGenerateReturnID AppleEvent code */ - private static Integer kAutoGenerateReturnID; - - /** The kAnyTransactionID AppleEvent code */ - private static Integer kAnyTransactionID; - - /** The linkage object required for JDirect 3 on Mac OS X. */ - private static Object linkage; - - /** The framework to reference on Mac OS X */ - private static final String JDirect_MacOSX = "/System/Library/Frameworks/Carbon.framework/Frameworks/HIToolbox.framework/HIToolbox"; - - /** JVM constant for MRJ 2.0 */ - private static final int MRJ_2_0 = 0; - - /** JVM constant for MRJ 2.1 or later */ - private static final int MRJ_2_1 = 1; - - /** JVM constant for Java on Mac OS X 10.0 (MRJ 3.0) */ - private static final int MRJ_3_0 = 3; - - /** JVM constant for MRJ 3.1 */ - private static final int MRJ_3_1 = 4; - - /** JVM constant for any Windows NT JVM */ - private static final int WINDOWS_NT = 5; - - /** JVM constant for any Windows 9x JVM */ - private static final int WINDOWS_9x = 6; - - /** JVM constant for any other platform */ - private static final int OTHER = -1; - - /** - * The file type of the Finder on a Macintosh. Hardcoding "Finder" would keep non-U.S. English - * systems from working properly. - */ - private static final String FINDER_TYPE = "FNDR"; - - /** - * The creator code of the Finder on a Macintosh, which is needed to send AppleEvents to the - * application. - */ - private static final String FINDER_CREATOR = "MACS"; - - /** The name for the AppleEvent type corresponding to a GetURL event. */ - private static final String GURL_EVENT = "GURL"; - - /** - * The first parameter that needs to be passed into Runtime.exec() to open the default web - * browser on Windows. - */ - private static final String FIRST_WINDOWS_PARAMETER = "/c"; - - /** The second parameter for Runtime.exec() on Windows. */ - private static final String SECOND_WINDOWS_PARAMETER = "start"; - - /** - * The third parameter for Runtime.exec() on Windows. This is a "title" - * parameter that the command line expects. Setting this parameter allows - * URLs containing spaces to work. - */ - private static final String THIRD_WINDOWS_PARAMETER = "\"\""; - - /** - * The shell parameters for Netscape that opens a given URL in an already-open copy of Netscape - * on many command-line systems. - */ - private static final String NETSCAPE_REMOTE_PARAMETER = "-remote"; - private static final String NETSCAPE_OPEN_PARAMETER_START = "'openURL("; - private static final String NETSCAPE_OPEN_PARAMETER_END = ")'"; - - /** - * The message from any exception thrown throughout the initialization process. - */ - private static String errorMessage; - - /** - * An initialization block that determines the operating system and loads the necessary - * runtime data. - */ - static { - loadedWithoutErrors = true; - String osName = System.getProperty("os.name"); - if (osName.startsWith("Mac OS")) { - String mrjVersion = System.getProperty("mrj.version"); - String majorMRJVersion = mrjVersion.substring(0, 3); - try { - double version = Double.valueOf(majorMRJVersion).doubleValue(); - if (version == 2) { - jvm = MRJ_2_0; - } else if (version >= 2.1 && version < 3) { - // Assume that all 2.x versions of MRJ work the same. MRJ 2.1 actually - // works via Runtime.exec() and 2.2 supports that but has an openURL() method - // as well that we currently ignore. - jvm = MRJ_2_1; - } else if (version == 3.0) { - jvm = MRJ_3_0; - } else if (version >= 3.1) { - // Assume that all 3.1 and later versions of MRJ work the same. - jvm = MRJ_3_1; - } else { - loadedWithoutErrors = false; - errorMessage = "Unsupported MRJ version: " + version; - } - } catch (NumberFormatException nfe) { - loadedWithoutErrors = false; - errorMessage = "Invalid MRJ version: " + mrjVersion; - } - } else if (osName.startsWith("Windows")) { - if (osName.indexOf("9") != -1) { - jvm = WINDOWS_9x; - } else { - jvm = WINDOWS_NT; - } - } else { - jvm = OTHER; - } - - if (loadedWithoutErrors) { // if we haven't hit any errors yet - loadedWithoutErrors = loadClasses(); - } - } - - /** - * This class should be never be instantiated; this just ensures so. - */ - private BrowserLauncher() { } - - /** - * Called by a static initializer to load any classes, fields, and methods required at runtime - * to locate the user's web browser. - * @return true if all intialization succeeded - * false if any portion of the initialization failed - */ - private static boolean loadClasses() { - switch (jvm) { - case MRJ_2_0: - try { - Class aeTargetClass = Class.forName("com.apple.MacOS.AETarget"); - Class osUtilsClass = Class.forName("com.apple.MacOS.OSUtils"); - Class appleEventClass = Class.forName("com.apple.MacOS.AppleEvent"); - Class aeClass = Class.forName("com.apple.MacOS.ae"); - aeDescClass = Class.forName("com.apple.MacOS.AEDesc"); - - aeTargetConstructor = aeTargetClass.getDeclaredConstructor(new Class [] { int.class }); - appleEventConstructor = appleEventClass.getDeclaredConstructor(new Class[] { int.class, int.class, aeTargetClass, int.class, int.class }); - aeDescConstructor = aeDescClass.getDeclaredConstructor(new Class[] { String.class }); - - makeOSType = osUtilsClass.getDeclaredMethod("makeOSType", new Class [] { String.class }); - putParameter = appleEventClass.getDeclaredMethod("putParameter", new Class[] { int.class, aeDescClass }); - sendNoReply = appleEventClass.getDeclaredMethod("sendNoReply", new Class[] { }); - - Field keyDirectObjectField = aeClass.getDeclaredField("keyDirectObject"); - keyDirectObject = (Integer) keyDirectObjectField.get(null); - Field autoGenerateReturnIDField = appleEventClass.getDeclaredField("kAutoGenerateReturnID"); - kAutoGenerateReturnID = (Integer) autoGenerateReturnIDField.get(null); - Field anyTransactionIDField = appleEventClass.getDeclaredField("kAnyTransactionID"); - kAnyTransactionID = (Integer) anyTransactionIDField.get(null); - } catch (ClassNotFoundException cnfe) { - errorMessage = cnfe.getMessage(); - return false; - } catch (NoSuchMethodException nsme) { - errorMessage = nsme.getMessage(); - return false; - } catch (NoSuchFieldException nsfe) { - errorMessage = nsfe.getMessage(); - return false; - } catch (IllegalAccessException iae) { - errorMessage = iae.getMessage(); - return false; - } - break; - case MRJ_2_1: - try { - mrjFileUtilsClass = Class.forName("com.apple.mrj.MRJFileUtils"); - mrjOSTypeClass = Class.forName("com.apple.mrj.MRJOSType"); - Field systemFolderField = mrjFileUtilsClass.getDeclaredField("kSystemFolderType"); - kSystemFolderType = systemFolderField.get(null); - findFolder = mrjFileUtilsClass.getDeclaredMethod("findFolder", new Class[] { mrjOSTypeClass }); - getFileCreator = mrjFileUtilsClass.getDeclaredMethod("getFileCreator", new Class[] { File.class }); - getFileType = mrjFileUtilsClass.getDeclaredMethod("getFileType", new Class[] { File.class }); - } catch (ClassNotFoundException cnfe) { - errorMessage = cnfe.getMessage(); - return false; - } catch (NoSuchFieldException nsfe) { - errorMessage = nsfe.getMessage(); - return false; - } catch (NoSuchMethodException nsme) { - errorMessage = nsme.getMessage(); - return false; - } catch (SecurityException se) { - errorMessage = se.getMessage(); - return false; - } catch (IllegalAccessException iae) { - errorMessage = iae.getMessage(); - return false; - } - break; - case MRJ_3_0: - try { - Class linker = Class.forName("com.apple.mrj.jdirect.Linker"); - Constructor constructor = linker.getConstructor(new Class[]{ Class.class }); - linkage = constructor.newInstance(new Object[] { BrowserLauncher.class }); - } catch (ClassNotFoundException cnfe) { - errorMessage = cnfe.getMessage(); - return false; - } catch (NoSuchMethodException nsme) { - errorMessage = nsme.getMessage(); - return false; - } catch (InvocationTargetException ite) { - errorMessage = ite.getMessage(); - return false; - } catch (InstantiationException ie) { - errorMessage = ie.getMessage(); - return false; - } catch (IllegalAccessException iae) { - errorMessage = iae.getMessage(); - return false; - } - break; - case MRJ_3_1: - try { - mrjFileUtilsClass = Class.forName("com.apple.mrj.MRJFileUtils"); - openURL = mrjFileUtilsClass.getDeclaredMethod("openURL", new Class[] { String.class }); - } catch (ClassNotFoundException cnfe) { - errorMessage = cnfe.getMessage(); - return false; - } catch (NoSuchMethodException nsme) { - errorMessage = nsme.getMessage(); - return false; - } - break; - default: - break; - } - return true; - } - - /** - * Attempts to locate the default web browser on the local system. Caches results so it - * only locates the browser once for each use of this class per JVM instance. - * @return The browser for the system. Note that this may not be what you would consider - * to be a standard web browser; instead, it's the application that gets called to - * open the default web browser. In some cases, this will be a non-String object - * that provides the means of calling the default browser. - */ - private static Object locateBrowser() { - if (browser != null) { - return browser; - } - switch (jvm) { - case MRJ_2_0: - try { - Integer finderCreatorCode = (Integer) makeOSType.invoke(null, new Object[] { FINDER_CREATOR }); - Object aeTarget = aeTargetConstructor.newInstance(new Object[] { finderCreatorCode }); - Integer gurlType = (Integer) makeOSType.invoke(null, new Object[] { GURL_EVENT }); - Object appleEvent = appleEventConstructor.newInstance(new Object[] { gurlType, gurlType, aeTarget, kAutoGenerateReturnID, kAnyTransactionID }); - // Don't set browser = appleEvent because then the next time we call - // locateBrowser(), we'll get the same AppleEvent, to which we'll already have - // added the relevant parameter. Instead, regenerate the AppleEvent every time. - // There's probably a way to do this better; if any has any ideas, please let - // me know. - return appleEvent; - } catch (IllegalAccessException iae) { - browser = null; - errorMessage = iae.getMessage(); - return browser; - } catch (InstantiationException ie) { - browser = null; - errorMessage = ie.getMessage(); - return browser; - } catch (InvocationTargetException ite) { - browser = null; - errorMessage = ite.getMessage(); - return browser; - } - case MRJ_2_1: - File systemFolder; - try { - systemFolder = (File) findFolder.invoke(null, new Object[] { kSystemFolderType }); - } catch (IllegalArgumentException iare) { - browser = null; - errorMessage = iare.getMessage(); - return browser; - } catch (IllegalAccessException iae) { - browser = null; - errorMessage = iae.getMessage(); - return browser; - } catch (InvocationTargetException ite) { - browser = null; - errorMessage = ite.getTargetException().getClass() + ": " + ite.getTargetException().getMessage(); - return browser; - } - String[] systemFolderFiles = systemFolder.list(); - // Avoid a FilenameFilter because that can't be stopped mid-list - for(int i = 0; i < systemFolderFiles.length; i++) { - try { - File file = new File(systemFolder, systemFolderFiles[i]); - if (!file.isFile()) { - continue; - } - // We're looking for a file with a creator code of 'MACS' and - // a type of 'FNDR'. Only requiring the type results in non-Finder - // applications being picked up on certain Mac OS 9 systems, - // especially German ones, and sending a GURL event to those - // applications results in a logout under Multiple Users. - Object fileType = getFileType.invoke(null, new Object[] { file }); - if (FINDER_TYPE.equals(fileType.toString())) { - Object fileCreator = getFileCreator.invoke(null, new Object[] { file }); - if (FINDER_CREATOR.equals(fileCreator.toString())) { - browser = file.toString(); // Actually the Finder, but that's OK - return browser; - } - } - } catch (IllegalArgumentException iare) { - browser = browser; - errorMessage = iare.getMessage(); - return null; - } catch (IllegalAccessException iae) { - browser = null; - errorMessage = iae.getMessage(); - return browser; - } catch (InvocationTargetException ite) { - browser = null; - errorMessage = ite.getTargetException().getClass() + ": " + ite.getTargetException().getMessage(); - return browser; - } - } - browser = null; - break; - case MRJ_3_0: - case MRJ_3_1: - browser = ""; // Return something non-null - break; - case WINDOWS_NT: - browser = "cmd.exe"; - break; - case WINDOWS_9x: - browser = "command.com"; - break; - case OTHER: - default: - browser = "netscape"; - break; - } - return browser; - } - - /** - * Attempts to open the default web browser to the given URL. - * @param url The URL to open - * @throws IOException If the web browser could not be located or does not run - */ - public static void openURL(String url) throws IOException { - if (!loadedWithoutErrors) { - throw new IOException("Exception in finding browser: " + errorMessage); - } - Object browser = locateBrowser(); - if (browser == null) { - throw new IOException("Unable to locate browser: " + errorMessage); - } - - switch (jvm) { - case MRJ_2_0: - Object aeDesc = null; - try { - aeDesc = aeDescConstructor.newInstance(new Object[] { url }); - putParameter.invoke(browser, new Object[] { keyDirectObject, aeDesc }); - sendNoReply.invoke(browser, new Object[] { }); - } catch (InvocationTargetException ite) { - throw new IOException("InvocationTargetException while creating AEDesc: " + ite.getMessage()); - } catch (IllegalAccessException iae) { - throw new IOException("IllegalAccessException while building AppleEvent: " + iae.getMessage()); - } catch (InstantiationException ie) { - throw new IOException("InstantiationException while creating AEDesc: " + ie.getMessage()); - } finally { - aeDesc = null; // Encourage it to get disposed if it was created - browser = null; // Ditto - } - break; - case MRJ_2_1: - Runtime.getRuntime().exec(new String[] { (String) browser, url } ); - break; - case MRJ_3_0: - int[] instance = new int[1]; - int result = ICStart(instance, 0); - if (result == 0) { - int[] selectionStart = new int[] { 0 }; - byte[] urlBytes = url.getBytes(); - int[] selectionEnd = new int[] { urlBytes.length }; - result = ICLaunchURL(instance[0], new byte[] { 0 }, urlBytes, - urlBytes.length, selectionStart, - selectionEnd); - if (result == 0) { - // Ignore the return value; the URL was launched successfully - // regardless of what happens here. - ICStop(instance); - } else { - throw new IOException("Unable to launch URL: " + result); - } - } else { - throw new IOException("Unable to create an Internet Config instance: " + result); - } - break; - case MRJ_3_1: - try { - openURL.invoke(null, new Object[] { url }); - } catch (InvocationTargetException ite) { - throw new IOException("InvocationTargetException while calling openURL: " + ite.getMessage()); - } catch (IllegalAccessException iae) { - throw new IOException("IllegalAccessException while calling openURL: " + iae.getMessage()); - } - break; - case WINDOWS_NT: - case WINDOWS_9x: - // Add quotes around the URL to allow ampersands and other special - // characters to work. - Process process = Runtime.getRuntime().exec(new String[] { (String) browser, - FIRST_WINDOWS_PARAMETER, - SECOND_WINDOWS_PARAMETER, - THIRD_WINDOWS_PARAMETER, - '"' + url + '"' }); - // This avoids a memory leak on some versions of Java on Windows. - // That's hinted at in . - try { - process.waitFor(); - process.exitValue(); - } catch (InterruptedException ie) { - throw new IOException("InterruptedException while launching browser: " + ie.getMessage()); - } - break; - case OTHER: - // Assume that we're on Unix and that Netscape is installed - - // First, attempt to open the URL in a currently running session of Netscape - process = Runtime.getRuntime().exec(new String[] { (String) browser, - NETSCAPE_REMOTE_PARAMETER, - NETSCAPE_OPEN_PARAMETER_START + - url + - NETSCAPE_OPEN_PARAMETER_END }); - try { - int exitCode = process.waitFor(); - if (exitCode != 0) { // if Netscape was not open - Runtime.getRuntime().exec(new String[] { (String) browser, url }); - } - } catch (InterruptedException ie) { - throw new IOException("InterruptedException while launching browser: " + ie.getMessage()); - } - break; - default: - // This should never occur, but if it does, we'll try the simplest thing possible - Runtime.getRuntime().exec(new String[] { (String) browser, url }); - break; - } - } - - /** - * Methods required for Mac OS X. The presence of native methods does not cause - * any problems on other platforms. - */ - private native static int ICStart(int[] instance, int signature); - private native static int ICStop(int[] instance); - private native static int ICLaunchURL(int instance, byte[] hint, byte[] data, int len, - int[] selectionStart, int[] selectionEnd); -} diff --git a/source/ch/cyberduck/Attic/util/URLExporter.java b/source/ch/cyberduck/Attic/util/URLExporter.java deleted file mode 100644 index c28d02da98..0000000000 --- a/source/ch/cyberduck/Attic/util/URLExporter.java +++ /dev/null @@ -1,97 +0,0 @@ -package ch.cyberduck.util; - -/* - * ch.cyberduck.util.Export.java - * Cyberduck - * - * $Header$ - * $Revision$ - * $Date$ - * - * Copyright (c) 2003 David Kocher. All rights reserved. - * http://icu.unizh.ch/~dkocher/ - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * Bug fixes, suggestions and comments should be sent to: - * dkocher@cyberduck.ch - */ - -import javax.swing.JOptionPane; -import java.io.BufferedWriter; -import java.io.File; -import java.io.FileWriter; -import java.io.IOException; -import java.util.Iterator; - -import ch.cyberduck.Cyberduck; -import ch.cyberduck.connection.Bookmark; -import ch.cyberduck.ui.model.BookmarkTableModel; - -/** - * Export bookmarks as tab delimited text file - */ -public class URLExporter extends Thread { - File file; - BookmarkTableModel tableModel; - - public URLExporter(File file, BookmarkTableModel tableModel) { - Cyberduck.DEBUG("[URLExporter] URLExporter(" + file.toString() + ")"); - this.file = file; - this.tableModel = tableModel; - } - - public void run() { - Cyberduck.DEBUG("[URLExporter] exportAll(" + tableModel.toString() + ")"); - FileWriter fw = null; - BufferedWriter bw = null; - try { - bw = new BufferedWriter(fw = new FileWriter(file)); - Iterator iterator = tableModel.iterator(); - Bookmark bookmark = null; -// bw.write("Host\tPort\tPath\tAddress"); - while(iterator.hasNext()) { - bookmark = (Bookmark)iterator.next(); - /* - bw.write(bookmark.getHost()); - bw.write("\t"); - bw.write(bookmark.getPort()); - bw.write("\t"); - if(bookmark.isDownload()) { - bw.write(bookmark.getLocalFilename()); - } - else if(bookmark.isDownload()) { - bw.write(bookmark.getServerDirectoryAsString()); - } - bw.write("\t"); - */ - bw.write(bookmark.getAddressAsString()); - bw.newLine(); - } - bw.flush(); - } - catch(IOException e) { - JOptionPane.showMessageDialog(null, "Failed to export table content\n" + "to file " + file.toString() + ".\n" + e.getMessage(), "Export failed", JOptionPane.ERROR_MESSAGE); - } - finally { - try { - if(bw != null) - bw.close(); - if(fw != null) - fw.close(); - } - catch(IOException close) { - System.err.println("[Log] Error: " + close.getMessage()); - close.printStackTrace(); - } - } - } -} diff --git a/source/ch/cyberduck/Attic/util/URLImporter.java b/source/ch/cyberduck/Attic/util/URLImporter.java deleted file mode 100644 index dce614838e..0000000000 --- a/source/ch/cyberduck/Attic/util/URLImporter.java +++ /dev/null @@ -1,107 +0,0 @@ -package ch.cyberduck.util; - -/* - * ch.cyberduck.util.PreferencesDialog.java - * Cyberduck - * - * $Header$ - * $Revision$ - * $Date$ - * - * Copyright (c) 2003 David Kocher. All rights reserved. - * http://icu.unizh.ch/~dkocher/ - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * Bug fixes, suggestions and comments should be sent to: - * dkocher@cyberduck.ch - */ - -import javax.swing.Action; -import javax.swing.JOptionPane; -import java.awt.event.ActionEvent; -import java.io.BufferedReader; -import java.io.File; -import java.io.FileReader; -import java.io.IOException; -import java.net.URL; - -import ch.cyberduck.connection.Bookmark; - -/** - * Import URLs from any text file - */ -public class URLImporter extends Thread { - File path; - Action addBookmarkAction; - - public URLImporter(File path, Action addBookmarkAction) { - this.path = path; - this.addBookmarkAction = addBookmarkAction; - } - - public void run() { - FileReader fr = null; - BufferedReader br = null; - boolean eof = false; - int url_hits = 0; - int line_count = 0; - try { - br = new BufferedReader(fr = new FileReader(path)); - while (!eof) { - String line = br.readLine(); - if (line == null) { - JOptionPane.showMessageDialog( - null, - "Found " + url_hits + " URLs from " + line_count + "\n" + - "parsed lines.", - "Import succeeded", - JOptionPane.INFORMATION_MESSAGE, - null - ); - eof = true; - } - else { - line_count++; - boolean moreURLs = true; - URL url; - int index = 0; - while (moreURLs) { - int hit = line.indexOf("http://", index); - if (hit == -1) { - hit = line.indexOf("ftp://", index); - } - if(hit == -1) - moreURLs = false; - else { - url_hits++; - int end = line.indexOf(' ', hit); - if (end == - 1) { - url = new URL(line.substring(hit)); - moreURLs = false; - } - else { - url = new URL(line.substring(hit, end)); - index = end; - } - Bookmark bookmark = new Bookmark(url); - addBookmarkAction.actionPerformed(new ActionEvent(bookmark, ActionEvent.ACTION_PERFORMED, "Import")); -// table.addEntry(bookmark); - } - } // end of while (moreurls) - } - } // end of while(!eof) - } // end of try - catch(IOException e) { - JOptionPane.showMessageDialog(null, "Failed to extract URLs from '" + path.getName() + "':\n" + e.getMessage(), "Import failed", JOptionPane.ERROR_MESSAGE); - } - } -} diff --git a/source/ch/cyberduck/ui/BookmarkPanel.java b/source/ch/cyberduck/ui/BookmarkPanel.java deleted file mode 100644 index bc7b1d7f62..0000000000 --- a/source/ch/cyberduck/ui/BookmarkPanel.java +++ /dev/null @@ -1,882 +0,0 @@ -package ch.cyberduck.ui; - -/* - * ch.cyberduck.ui.BookmarkPanel.java - * Cyberduck - * - * $Header$ - * $Revision$ - * $Date$ - * - * Copyright (c) 2003 David Kocher. All rights reserved. - * http://icu.unizh.ch/~dkocher/ - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * Bug fixes, suggestions and comments should be sent to: - * dkocher@cyberduck.ch - */ - -import javax.swing.*; -import java.awt.BorderLayout; -import java.awt.FlowLayout; -import java.awt.datatransfer.DataFlavor; -import java.awt.datatransfer.Transferable; -import java.awt.dnd.*; -import java.awt.event.ActionEvent; -import java.awt.event.KeyEvent; -import java.io.*; -import java.util.*; - -import ch.cyberduck.Cyberduck; -import ch.cyberduck.Preferences; -import ch.cyberduck.connection.Bookmark; -import ch.cyberduck.connection.Status; -import ch.cyberduck.ui.action.ActionMap; -import ch.cyberduck.ui.common.GUIFactory; -import ch.cyberduck.ui.model.BookmarkTableColumnModel; -import ch.cyberduck.ui.model.BookmarkTableModel; -import ch.cyberduck.util.URLExporter; -import ch.cyberduck.util.URLImporter; - -/** - * The top component in the main windows's splitpane - * Contiains a JTable for bookmark entries, a ComboBox for selecting - * the bookmarks file to display and some buttons - * @see ch.cyberduck.ui.BookmarkTable - * @version $Id$ - */ -public class BookmarkPanel extends JPanel implements Observer { - - private BookmarksSelectorModel bookmarksSelectorModel; - private BookmarkTable bookmarkTable; - - //private List observers = new ArrayList(); - - /** - * The currently selected bookmark - */ - private Bookmark selected; - - public BookmarkPanel() { - Cyberduck.DEBUG("[BookmarkPanel]"); - this.init(); - } - - /** - * Initialize all inner class actions - */ - private void initActions() { - new ExportAction(); - new ImportAction(); - new DeleteAllAction(); - new DeleteCompletedAction(); - new ConnectAllAction(); - new StopAllAction(); - - new AddBookmarkFileAction(); - new RenameBookmarkFileAction(); - new DeleteBookmarkFileAction(); - new NewBookmarkAction(); - - new OpenSelectedAction(); - new ConnectSelectedAction(); -// new EditSelectedAction(); - new StopSelectedAction(); - new DeleteSelectedAction(); - } - - public void update(Observable o, Object arg) { - if(o instanceof Status) { - if(arg.equals(Status.CURRENT)) { - for (int i = 0; i < ((BookmarkTableModel) ((BookmarkTableModel)bookmarkTable.getModel())).getRowCount(); i++) { - ((BookmarkTableModel)bookmarkTable.getModel()).fireTableCellUpdated(i, BookmarkTableColumnModel.PROGRESSCOLUMN); - } - } - else if(arg.equals(Status.ACTIVE)) { - for (int i = 0; i < ((BookmarkTableModel)bookmarkTable.getModel()).getRowCount(); i++) { - ((BookmarkTableModel)bookmarkTable.getModel()).fireTableCellUpdated(i, BookmarkTableColumnModel.STATUSCOLUMN); - } - } - else if(arg.equals(Status.STOP)) { - for (int i = 0; i < ((BookmarkTableModel)bookmarkTable.getModel()).getRowCount(); i++) { - ((BookmarkTableModel)bookmarkTable.getModel()).fireTableCellUpdated(i, BookmarkTableColumnModel.STATUSCOLUMN); - } - } - else if(arg.equals(Status.COMPLETE)) { - for (int i = 0; i < ((BookmarkTableModel)bookmarkTable.getModel()).getRowCount(); i++) { - ((BookmarkTableModel)bookmarkTable.getModel()).fireTableCellUpdated(i, BookmarkTableColumnModel.STATUSCOLUMN); - } - } - } - if(o instanceof Bookmark) { - // display/switch to other transfer - if(arg.equals(Bookmark.SELECTION)) { - selected = (Bookmark)o; - } - } - ((Observer)ActionMap.instance().get("Connect Selected")).update(o, arg); -// ((Observer)ActionMap.instance().get("Edit Selected")).update(o, arg); - ((Observer)ActionMap.instance().get("Stop Selected")).update(o, arg); - } - - /** - * Accept drops of String flavors - */ - private class DropListener implements DropTargetListener { - public synchronized void drop(DropTargetDropEvent e) { - Cyberduck.DEBUG(e.toString()); - if(e.isLocalTransfer()) { - Cyberduck.DEBUG("[DropListener] isLocalTransfer=true)"); - e.rejectDrop(); - } - try { - Transferable transferable = e.getTransferable(); - if(transferable.isDataFlavorSupported(DataFlavor.stringFlavor)) { - Cyberduck.DEBUG("[DropListener] DataFlavor.stringFlavor=true)"); - // int row = table.rowAtPoint(e.getLocation()); - e.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE); - Bookmark transfer = new Bookmark(); - transfer.setAddress((String)transferable.getTransferData(DataFlavor.stringFlavor)); - ((Action)ActionMap.instance().get("New Bookmark")).actionPerformed(new ActionEvent(transfer, ActionEvent.ACTION_PERFORMED, null)); - e.dropComplete(true); - } - else { - Cyberduck.DEBUG("[DropListener] DataFlavor.stringFlavor=false)"); - e.rejectDrop(); - } - } - catch(java.io.IOException ioe) { - ioe.printStackTrace(); - e.rejectDrop(); - } - catch(java.awt.datatransfer.UnsupportedFlavorException ufe) { - ufe.printStackTrace(); - e.rejectDrop(); - } - } - - public void dragEnter(DropTargetDragEvent e) { - if(e.isDataFlavorSupported(DataFlavor.stringFlavor)) - bookmarkTable.setBorder(javax.swing.BorderFactory.createLineBorder(java.awt.Color.red)); - } - public void dragExit(DropTargetEvent e) { - bookmarkTable.setBorder(null); - } - public void dragOver(DropTargetDragEvent e) { - int row = bookmarkTable.rowAtPoint(e.getLocation()); - if(row != -1) { - ((JTable)e.getDropTargetContext().getComponent()).setRowSelectionInterval(row, row); - } - } - public void dropActionChanged(DropTargetDragEvent e) { - Cyberduck.DEBUG(e.toString()); - if(e.getDropAction() != DnDConstants.ACTION_COPY_OR_MOVE) { - e.rejectDrag(); - } - } - } - - - /** - * Initialize the graphical user interface - */ - private void init() { - this.initActions(); - - JScrollPane tableScrollPane = new JScrollPane(this.bookmarkTable = new BookmarkTable()); - tableScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); - tableScrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); - - new java.awt.dnd.DropTarget(bookmarkTable, - java.awt.dnd.DnDConstants.ACTION_COPY_OR_MOVE, - new DropListener()); - - //CONTROLPANEL - JPanel controlPanel = new JPanel(); - controlPanel.setLayout(new FlowLayout(FlowLayout.LEFT)); - controlPanel.add(GUIFactory.buttonBuilder(GUIFactory.FONT_NORMAL, (Action)ActionMap.instance().get("New Bookmark"))); - controlPanel.add(GUIFactory.buttonBuilder("Connect", GUIFactory.FONT_NORMAL, (Action)ActionMap.instance().get("Connect Selected"))); -// controlPanel.add(GUIFactory.buttonBuilder("Edit", GUIFactory.FONT_NORMAL, (Action)ActionMap.instance().get("Edit Selected"))); - - JComboBox bookmarksSelector = new JComboBox(this.bookmarksSelectorModel = new BookmarksSelectorModel()); - bookmarksSelector.setEditable(false); - this.setLayout(new BorderLayout()); - this.setBorder(BorderFactory.createEmptyBorder(10, 0, 5, 0)); - this.add(bookmarksSelector, BorderLayout.NORTH); - this.add(tableScrollPane, BorderLayout.CENTER); - this.add(controlPanel, BorderLayout.SOUTH); - ObserverList.instance().registerObserver((Observer)this); - } - - private class BookmarksSelectorModel extends AbstractListModel implements ComboBoxModel { - //hashmap containing different bookmark lists ('files') with associated key (string like 'My Bookmarks') - Map bookmarkFiles = new HashMap(); - //key mapped to index - List indexes = new ArrayList(); - //the currently selected boomark file key - String file = null; - - public BookmarksSelectorModel() { - super(); - } - - /** - * @return key of the selected bookmark file - */ - public Object getSelectedItem() { - //Cyberduck.DEBUG("[BookmarksSelectorModel] getSelectedItem()"); - return file; - } - - /** - * @return key of the selected bookmark file at parameter index - */ - public Object getElementAt(int index) { - //Cyberduck.DEBUG("[BookmarksSelectorModel] getElementAt(" + index + ")"); - return indexes.get(index); - } - - public void setSelectedItem(Object key) { - Cyberduck.DEBUG("[BookmarksSelectorModel] setSelectedItem(" + key + ")"); - file = (String)key; - if(selected != null) - selected.callObservers(Bookmark.DESELECTION); - ((BookmarkTableModel)bookmarkTable.getModel()).setData((List)this.get(key)); - Preferences.instance().setProperty("bookmarks.default", (String)key); - } - - public int getSize() { - //Cyberduck.DEBUG("[BookmarksSelectorModel] getSize()"); - return bookmarkFiles.size(); - } - - public Map getData() { - Cyberduck.DEBUG("[BookmarksSelectorModel] getData()"); - return this.bookmarkFiles; - } - - public void add(Object key, Object o) { - Cyberduck.DEBUG("[BookmarksSelectorModel] add(" + key + ")"); - this.bookmarkFiles.put(key, o); - this.indexes.add(indexes.size(), key); - Iterator i = ((List)o).iterator(); - while(i.hasNext()) { - //addObservers((Bookmark)i.next()); - ObserverList map = ObserverList.instance(); - Bookmark b = (Bookmark)i.next(); - map.registerObservable(b); - map.registerObservable(b.status); - } - this.fireContentsChanged(this, 0, this.getSize()); - } - - public void remove(Object key) { - Cyberduck.DEBUG("[BookmarksSelectorModel] removeElement(" + key + ")"); - this.indexes.remove(this.indexes.indexOf(key)); - this.bookmarkFiles.remove(key); - this.fireContentsChanged(this, 0, this.getSize()); - } - - public boolean isEmpty() { - return bookmarkFiles.isEmpty(); - } - - public Object get(Object key) { - Cyberduck.DEBUG("[ComboPathModel] get(" + key + ")"); - return bookmarkFiles.get(key); - } - } - - /** - * Store all bookmarks in /Cyberduck.PREFS_DIRECTORY/.bookmarks - */ - public void saveBookmarkFiles() { - Cyberduck.DEBUG("[BookmarkPanel] saveBookmarkFiles()"); - FileOutputStream st1 = null; - ObjectOutputStream st2 = null; - Iterator keys = bookmarksSelectorModel.getData().keySet().iterator(); - Object key; - List data; - while(keys.hasNext()) { - key = keys.next(); - Cyberduck.DEBUG("Saving bookmark file: " + key.toString()); - data = (List)bookmarksSelectorModel.get(key); - try { - st1 = new FileOutputStream(new File(Cyberduck.PREFS_DIRECTORY, (String)key + ".bookmarks")); - st2 = new ObjectOutputStream(st1); - Iterator iterator = data.iterator(); - while (iterator.hasNext()) { - Bookmark next = (Bookmark)iterator.next(); - next.cleanup(); - /* - if(! next.status.isStopped()) { - Object[] values = {"Quit", "Cancel"}; - int option = JOptionPane.showOptionDialog( - null, - "Session to host " + next.getHost() + "\nnot closed.\nQuit anyway?", - "Download in progress", - JOptionPane.DEFAULT_OPTION, - JOptionPane.QUESTION_MESSAGE, - null, - values, - values[1] - ); - switch(option) { - case 1: - return false; - } - } - */ - - /* - if(! next.status.isStopped()) { - Cyberduck.DEBUG("starting confirm thread"); - ConfirmThread confirm = new ConfirmThread(next); - try { - javax.swing.SwingUtilities.invokeLater(confirm); - } - catch(Exception e) { - e.printStackTrace(); - } - if(!confirm.quit) { - Cyberduck.DEBUG("returning false"); - return false; - } - else - Cyberduck.DEBUG("continue"); - } - Cyberduck.DEBUG("writing:"+next.toString()); - */ - st2.writeObject(next); - } - } - catch(IOException e) { - System.err.println("Problem saving boomarks: " + e.getMessage()); - } - finally { - try { - if (st1 != null) - st1.close(); - if (st2 != null) - st2.close(); - } - catch(IOException e) { - System.err.println("Problem closing output stream: " + e.getMessage()); - e.printStackTrace(); - } - } - } - } - - /** - * Load all bookmarks into the table. - */ - public void loadBookmarkFiles() { - Cyberduck.DEBUG("[BookmarkPanel] loadBoomarkFiles()"); - try { - File f = new File(Cyberduck.PREFS_DIRECTORY, Preferences.instance().getProperty("bookmarks.default") + ".bookmarks"); - f.createNewFile(); - } - catch(java.io.IOException e) { - System.err.println("Error loading bookmarks: " + e.getMessage()); - } - FileInputStream st1 = null; - ObjectInputStream st2 = null; - File path = Cyberduck.PREFS_DIRECTORY; - if (path.exists()) { - String[] files = path.list(); - for(int i = 0; i< files.length; i++) { - int index; - if((index = files[i].indexOf(".bookmarks")) != -1) { - File file = new File(path, files[i]); - Cyberduck.DEBUG("Loading " + file.toString()); - List data = new ArrayList(); - try { - st1 = new FileInputStream(file); - st2 = new ObjectInputStream(st1); - while(true) { - try { - Bookmark bookmark = (Bookmark)st2.readObject(); - bookmark.status.fireStopEvent(); - data.add(bookmark); - } - catch(ClassNotFoundException e) { - System.err.println("Error loading boomarks: " + e.getMessage()); - } - } - } - catch(EOFException e) {} - catch(IOException e) { - Cyberduck.DEBUG("Error reading from '" + files[i] + "': " + e.getMessage()); - } - finally { - this.bookmarksSelectorModel.add(files[i].substring(0, index), data); - try { - if (st1 != null) - st1.close(); - if (st2 != null) - st2.close(); - } - catch(IOException e) { - System.err.println("Error closing output stream: " + e.getMessage()); - } - } - } - } - this.bookmarksSelectorModel.setSelectedItem(Preferences.instance().getProperty("bookmarks.default")); - } - } - - // ************************************************************************************************************ - - - private class OpenSelectedAction extends AbstractAction { - public OpenSelectedAction() { - super("Open Dialog"); - this.putValue(SHORT_DESCRIPTION, "Open new dialog for selected bookmarks."); - this.putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_O, GUIFactory.MENU_MASK)); - ActionMap.instance().put(this.getValue(NAME), this); - } - public void actionPerformed(ActionEvent ae) { - Cyberduck.DEBUG(ae.paramString()); - if(bookmarkTable.getSelectedRowCount() < 1) - Cyberduck.beep(); - else { - int[] selected = bookmarkTable.getSelectedRows(); - for (int i = 0; i < selected.length; i++) { - Bookmark b = (Bookmark)((BookmarkTableModel)bookmarkTable.getModel()).getEntry(selected[i]); -// cocoa-version b.getStatusDialog().show(); - } - } - } - } - - private class NewBookmarkAction extends AbstractAction { - public NewBookmarkAction() { - super("New Bookmark"); - this.putValue(SHORT_DESCRIPTION, "Insert new bookmark"); - this.putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_N, GUIFactory.MENU_MASK)); - this.setEnabled(true); - ActionMap.instance().put(this.getValue(NAME), this); - } - public void actionPerformed(ActionEvent ae) { - Cyberduck.DEBUG(ae.paramString()); - Object source = ae.getSource(); - Bookmark bookmark; - if(source instanceof Bookmark) - bookmark = (Bookmark)source; - else - bookmark = new Bookmark(); - bookmarkTable.editingStopped(new javax.swing.event.ChangeEvent(this)); - int row = bookmarkTable.getSelectedRow(); - if(row != -1) { - ((BookmarkTableModel)bookmarkTable.getModel()).addEntry(bookmark, row + 1); - bookmarkTable.setRowSelectionInterval(row+1, row+1); - } - else { - ((BookmarkTableModel)bookmarkTable.getModel()).addEntry(bookmark); - bookmarkTable.setRowSelectionInterval(((BookmarkTableModel)bookmarkTable.getModel()).getRowCount() - 1, ((BookmarkTableModel)bookmarkTable.getModel()).getRowCount() - 1); - } - ObserverList.instance().registerObservable(bookmark); - ObserverList.instance().registerObservable(bookmark.status); - bookmark.callObservers(Bookmark.SELECTION); - } - } - - private class AddBookmarkFileAction extends AbstractAction { - public AddBookmarkFileAction() { - super("New Bookmark File..."); - this.putValue(SHORT_DESCRIPTION, "Create new bookmarks file"); - ActionMap.instance().put(this.getValue(NAME), this); - } - public void actionPerformed(ActionEvent ae) { - Cyberduck.DEBUG(ae.paramString()); - Object input = JOptionPane.showInputDialog( - null, - "Name of the new bookmark file:", - "New Bookmark file", - JOptionPane.QUESTION_MESSAGE, - null, - null, - null - ); - if(input != null) { - File f = new File(Cyberduck.PREFS_DIRECTORY, (String)input + ".bookmarks"); - if(f.exists()) { - JOptionPane.showMessageDialog( - null, - "Please choose another name.", - "File already exists", - JOptionPane.ERROR_MESSAGE, - null - ); - } - else { - bookmarksSelectorModel.add((String)input, new ArrayList()); - bookmarksSelectorModel.setSelectedItem((String)input); - } - } - } - } - - private class DeleteBookmarkFileAction extends AbstractAction { - public DeleteBookmarkFileAction() { - super("Delete Bookmark File..."); - this.putValue(SHORT_DESCRIPTION, "Delete selected Bookmark file"); - this.setEnabled(true); - ActionMap.instance().put(this.getValue(NAME), this); - } - public void actionPerformed(ActionEvent ae) { - Cyberduck.DEBUG(ae.paramString()); - String selected = (String)bookmarksSelectorModel.getSelectedItem(); - int option = JOptionPane.showConfirmDialog( - null, - "Do you want to delete the\nbookmark file '" + selected + "'?", - "Delete bookmark file", - JOptionPane.WARNING_MESSAGE - ); - if(option == JOptionPane.OK_OPTION) { - File f = new File(Cyberduck.PREFS_DIRECTORY, selected + ".bookmarks"); - f.delete(); - bookmarksSelectorModel.remove(selected); - this.setEnabled(bookmarksSelectorModel.getSize() > 1); - bookmarksSelectorModel.setSelectedItem(bookmarksSelectorModel.getElementAt(bookmarksSelectorModel.getSize()-1)); - } - } - } - - private class RenameBookmarkFileAction extends AbstractAction { - public RenameBookmarkFileAction() { - super("Rename Bookmark File..."); - this.putValue(SHORT_DESCRIPTION, "Rename selected Bookmark file"); - this.setEnabled(true); - ActionMap.instance().put(this.getValue(NAME), this); - } - public void actionPerformed(ActionEvent ae) { - Cyberduck.DEBUG(ae.paramString()); - String oldName = (String)bookmarksSelectorModel.getSelectedItem(); - Object newName = JOptionPane.showInputDialog( - null, - "Rename '" + oldName + "' to:", - "Rename Bookmark file", - JOptionPane.QUESTION_MESSAGE, - null, - null, - null - ); - if(newName != null) { - File oldFile = new File(Cyberduck.PREFS_DIRECTORY, (String)oldName + ".bookmarks"); - File newFile = new File(Cyberduck.PREFS_DIRECTORY, (String)newName + ".bookmarks"); - if(newFile.exists()) { - JOptionPane.showMessageDialog( - null, - "Please choose another name.", - "File already exists", - JOptionPane.ERROR_MESSAGE, - null - ); - } - else { - oldFile.renameTo(newFile); - bookmarksSelectorModel.add(newName, bookmarksSelectorModel.get(oldName)); - bookmarksSelectorModel.remove(oldName); - bookmarksSelectorModel.setSelectedItem(newName); - } - } - } - } - - /** - * Delete all selected bookmarks - */ - private class DeleteSelectedAction extends AbstractAction { - public DeleteSelectedAction() { - super("Delete Selected"); - this.putValue(SHORT_DESCRIPTION, "Delete selected bookmarks."); - this.putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_BACK_SPACE, GUIFactory.MENU_MASK)); - //this.setEnabled(false); - ActionMap.instance().put(this.getValue(NAME), this); - } - public void actionPerformed(ActionEvent ae) { - Cyberduck.DEBUG(ae.paramString()); - if(bookmarkTable.getSelectedRowCount() < 1) - Cyberduck.beep(); - else { - bookmarkTable.editingStopped(new javax.swing.event.ChangeEvent(this)); - ((BookmarkTableModel)bookmarkTable.getModel()).deleteSelected(bookmarkTable.getSelectedRows()); - if(bookmarkTable.getModel().getRowCount() > 0) - bookmarkTable.setRowSelectionInterval(bookmarkTable.getModel().getRowCount() - 1, bookmarkTable.getModel().getRowCount() - 1); - } - } - } - - /** - * Delete all bookmarks - */ - private class DeleteAllAction extends AbstractAction { - public DeleteAllAction() { - super("Delete All"); - this.putValue(SHORT_DESCRIPTION, "Delete all bookmarks."); - this.putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_BACK_SPACE, GUIFactory.MENU_MASK | java.awt.Event.SHIFT_MASK)); - ActionMap.instance().put(this.getValue(NAME), this); - } - public void actionPerformed(ActionEvent ae) { - Cyberduck.DEBUG(ae.paramString()); - bookmarkTable.editingStopped(new javax.swing.event.ChangeEvent(this)); - ((BookmarkTableModel)bookmarkTable.getModel()).clear(); - if(bookmarkTable.getModel().getRowCount() > 0) - bookmarkTable.setRowSelectionInterval(bookmarkTable.getModel().getRowCount() - 1, bookmarkTable.getModel().getRowCount() - 1); - } - } - - /** - * Delete all bookmarks which have the complete attribute set to true - * @see ch.cyberduck.connection.Status#isComplete - */ - private class DeleteCompletedAction extends AbstractAction { - public DeleteCompletedAction() { - super("Delete Completed"); - this.putValue(SHORT_DESCRIPTION, "Delete completed bookmarks."); - ActionMap.instance().put(this.getValue(NAME), this); - } - public void actionPerformed(ActionEvent ae) { - Cyberduck.DEBUG(ae.paramString()); - bookmarkTable.editingStopped(new javax.swing.event.ChangeEvent(this)); - ((BookmarkTableModel)bookmarkTable.getModel()).deleteCompleted(); - if(bookmarkTable.getModel().getRowCount() > 0) - bookmarkTable.setRowSelectionInterval(bookmarkTable.getModel().getRowCount() - 1, bookmarkTable.getModel().getRowCount() - 1); - } - } - - /** - * Read URLs from a text file and put them into currently selected table - */ - private class ImportAction extends AbstractAction { - public ImportAction() { - super("Import..."); - this.putValue(SHORT_DESCRIPTION, "Extract URLs from text file."); - this.putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_I, GUIFactory.MENU_MASK | java.awt.Event.SHIFT_MASK)); - ActionMap.instance().put(this.getValue(NAME), this); - } - public void actionPerformed(ActionEvent ae) { - Cyberduck.DEBUG(ae.paramString()); - java.awt.FileDialog chooser = new java.awt.FileDialog(new java.awt.Frame(), "Import Bookmarks...", java.awt.FileDialog.LOAD); - chooser.setTitle("Choose a text file to extract the URLs from:"); - chooser.setDirectory(System.getProperty("user.home")); - chooser.setVisible(true); - String resultPath = chooser.getDirectory(); - String resultFile = chooser.getFile(); - if(resultPath != null && resultFile != null) { - File file = new File(resultPath, resultFile); - if(file != null) { - URLImporter importer = new URLImporter(file, (Action)ActionMap.instance().get("New Bookmark")); - importer.start(); - } - } - } - } - - /** - * Export all bookmarks from the currently selected bookmark file into a text file - */ - private class ExportAction extends AbstractAction { - public ExportAction() { - super("Export..."); - putValue(SHORT_DESCRIPTION, "Export bookmarks as text."); - putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_E, GUIFactory.MENU_MASK | java.awt.Event.SHIFT_MASK)); - ActionMap.instance().put(this.getValue(NAME), this); - } - public void actionPerformed(ActionEvent ae) { - Cyberduck.DEBUG(ae.paramString()); - java.awt.FileDialog chooser = new java.awt.FileDialog(new java.awt.Frame(), "Export Bookmarks...", java.awt.FileDialog.SAVE); - chooser.setDirectory(System.getProperty("user.home")); - chooser.setFile("Cyberduck Bookmark List.txt"); - chooser.setVisible(true); - String resultPath = chooser.getDirectory(); - String resultFile = chooser.getFile(); - if(resultPath != null && resultFile != null) { - File file = new File(resultPath, resultFile); - if(file != null) { - URLExporter exporter = new URLExporter(file, ((BookmarkTableModel) ((BookmarkTableModel)bookmarkTable.getModel()))); - exporter.start(); - } - } - } - } - - // ************************************************************************************************************ - - private class ConnectAllAction extends AbstractAction { - public ConnectAllAction() { - super("Connect All"); - this.putValue(SHORT_DESCRIPTION, "Connect to all bookmarks"); - ActionMap.instance().put(this.getValue(NAME), this); - } - public void actionPerformed(ActionEvent ae) { - Cyberduck.DEBUG(ae.paramString()); - bookmarkTable.editingStopped(new javax.swing.event.ChangeEvent(this)); - int n = bookmarkTable.getRowCount(); - Bookmark t = null; - for (int i = 0; i < n; i++) { - t = (Bookmark)((BookmarkTableModel) bookmarkTable.getModel()).getEntry(i); - t.transfer(); - } - } - } - - private class ConnectSelectedAction extends AbstractAction implements Observer { - public ConnectSelectedAction() { - super("Connect Selected"); - this.putValue(SHORT_DESCRIPTION, "Connect to all selected bookmarks"); - this.putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_T, GUIFactory.MENU_MASK)); - this.setEnabled(false); - ActionMap.instance().put(this.getValue(NAME), this); - } - public void actionPerformed(ActionEvent ae) { - Cyberduck.DEBUG(ae.paramString()); - if(bookmarkTable.getSelectedRowCount() < 1) - Cyberduck.beep(); - else { - int[] selected = bookmarkTable.getSelectedRows(); - for (int i = 0; i < selected.length; i++) { - Bookmark b = (Bookmark)((BookmarkTableModel)bookmarkTable.getModel()).getEntry(selected[i]); - b.transfer(); - } - } - } - public void update(java.util.Observable o, Object arg) { - if (arg.equals(Status.ACTIVE) || - arg.equals(Status.STOP) || - arg.equals(Status.COMPLETE) || - arg.equals(Bookmark.SELECTION)) - { - String name = "Connect"; - if(selected.isDownload()) { - if(selected.getHandler().equals(Status.RELOAD)) - name = "Reload"; - if(selected.getHandler().equals(Status.RESUME)) - name = "Resume"; - if(selected.getHandler().equals(Status.INITIAL)) - name = "Download"; - } - if(selected.isListing()) { - if(selected.getHandler().equals(Status.RELOAD)) - name = "Refresh"; - else - name = "Connect"; - } - this.putValue(NAME, name); - this.setEnabled(selected.isValid() && selected.status.isStopped()); - } - } - } - - private class StopAllAction extends AbstractAction { - Bookmark selected = null; - public StopAllAction() { - super("Stop All"); - this.putValue(SHORT_DESCRIPTION, "Stop all active transfers"); - ActionMap.instance().put(this.getValue(NAME), this); - } - public void actionPerformed(ActionEvent ae) { - Cyberduck.DEBUG(ae.paramString()); - int n = bookmarkTable.getRowCount() -1; - for (int i = 0; i < n; i++) { - Bookmark b = (Bookmark)((BookmarkTableModel)bookmarkTable.getModel()).getEntry(i); - b.status.setCanceled(true); -// ((Action)ActionMap.instance().get("Stop")).actionPerformed(new ActionEvent( ((BookmarkTableModel) ((BookmarkTableModel)bookmarkTable.getModel())).getEntry(i), ae.getID(), ae.getActionCommand())); - } - } - } - - private class StopSelectedAction extends AbstractAction implements Observer { - public StopSelectedAction() { - super("Stop Selected"); - this.putValue(SHORT_DESCRIPTION, "Stop selected transfers"); - this.putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_PERIOD, GUIFactory.MENU_MASK)); - this.setEnabled(false); - ActionMap.instance().put(this.getValue(NAME), this); - } - public void actionPerformed(ActionEvent ae) { - Cyberduck.DEBUG(ae.paramString()); - if(bookmarkTable.getSelectedRowCount() < 1) - Cyberduck.beep(); - else { - int[] selected = bookmarkTable.getSelectedRows(); - for (int i = 0; i < selected.length; i++) { - Bookmark b = (Bookmark)((BookmarkTableModel)bookmarkTable.getModel()).getEntry(selected[i]); - b.status.setCanceled(true); - - //((Action)ActionMap.instance().get("Stop")).actionPerformed(new ActionEvent( ((BookmarkTableModel) ((BookmarkTableModel)bookmarkTable.getModel())).getEntry(selected[i]), ae.getID(), ae.getActionCommand())); - } - } - } - public void update(java.util.Observable o, Object arg) { - if (arg.equals(Status.ACTIVE) || - arg.equals(Status.STOP) || - arg.equals(Status.COMPLETE) || - arg.equals(Bookmark.SELECTION)) - { - this.putValue(NAME, "Stop"); - this.setEnabled(!selected.status.isStopped()); - } - } - } -/* - private class EditSelectedAction extends AbstractAction implements Observer { - public EditSelectedAction() { - super("Edit Selected"); - this.putValue(SHORT_DESCRIPTION, "Edit selected bookmark"); - this.putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_E, GUIFactory.MENU_MASK)); - this.setEnabled(false); - ActionMap.instance().put(this.getValue(NAME), this); - } - public void actionPerformed(ActionEvent ae) { - Cyberduck.DEBUG(ae.paramString()); - if(bookmarkTable.getSelectedRowCount() < 1) - Cyberduck.beep(); - else { - int[] selected = bookmarkTable.getSelectedRows(); - for (int i = 0; i < selected.length; i++) { - Bookmark b = (Bookmark)((BookmarkTableModel)bookmarkTable.getModel()).getEntry(selected[i]); - b.edit(); - //((Action)ActionMap.instance().get("Edit")).actionPerformed(new ActionEvent( ((BookmarkTableModel) ((BookmarkTableModel)bookmarkTable.getModel())).getEntry(selected[i]), ae.getID(), ae.getActionCommand())); - } - } - } - public void update(java.util.Observable o, Object arg) { - if (arg.equals(Status.ACTIVE) || - arg.equals(Status.STOP) || - arg.equals(Status.COMPLETE) || - arg.equals(Bookmark.SELECTION)) - { - this.setEnabled(selected.status.isStopped()); - } - } - } -*/ - - // ************************************************************************************************************ - - public void saveProperties() { - Preferences.instance().setProperty("table.column0.width", new Integer(this.bookmarkTable.getColumnModel().getColumn(BookmarkTableColumnModel.STATUSCOLUMN).getWidth()).toString()); - Preferences.instance().setProperty("table.column1.width", new Integer(this.bookmarkTable.getColumnModel().getColumn(BookmarkTableColumnModel.ADDRESSCOLUMN).getWidth()).toString()); - Preferences.instance().setProperty("table.column2.width", new Integer(this.bookmarkTable.getColumnModel().getColumn(BookmarkTableColumnModel.TYPECOLUMN).getWidth()).toString()); - Preferences.instance().setProperty("table.column3.width", new Integer(bookmarkTable.getColumnModel().getColumn(BookmarkTableColumnModel.PROGRESSCOLUMN).getWidth()).toString()); - /* - Preferences.instance().setProperty("table.column0.position", new Integer(this.bookmarkTable.getColumnModel().getColumnIndexAtX(BookmarkTableColumnModel.STATUSCOLUMN)).toString()); - Preferences.instance().setProperty("table.column1.position", new Integer(this.bookmarkTable.getColumnModel().getColumnIndexAtX(BookmarkTableColumnModel.ADDRESSCOLUMN)).toString()); - Preferences.instance().setProperty("table.column2.position", new Integer(this.bookmarkTable.getColumnModel().getColumnIndexAtX(BookmarkTableColumnModel.TYPECOLUMN)).toString()); - Preferences.instance().setProperty("table.column3.position", new Integer(this.bookmarkTable.getColumnModel().getColumnIndexAtX(BookmarkTableColumnModel.PROGRESSCOLUMN)).toString()); - */ - } -} diff --git a/source/ch/cyberduck/ui/BookmarkTable.java b/source/ch/cyberduck/ui/BookmarkTable.java deleted file mode 100644 index 7f6ea82e3a..0000000000 --- a/source/ch/cyberduck/ui/BookmarkTable.java +++ /dev/null @@ -1,204 +0,0 @@ -package ch.cyberduck.ui; - -/* - * ch.cyberduck.ui.BookmarkTable.java - * Cyberduck - * - * $Header$ - * $Revision$ - * $Date$ - * - * Copyright (c) 2003 David Kocher. All rights reserved. - * http://icu.unizh.ch/~dkocher/ - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * Bug fixes, suggestions and comments should be sent to: - * dkocher@cyberduck.ch - */ - -import javax.swing.Action; -import javax.swing.JTable; -import java.awt.dnd.*; -import java.awt.event.MouseEvent; - -import ch.cyberduck.Cyberduck; -import ch.cyberduck.connection.Bookmark; -import ch.cyberduck.ui.action.ActionMap; -import ch.cyberduck.ui.common.TableColumnSorter; -import ch.cyberduck.ui.model.BookmarkTableColumnModel; -import ch.cyberduck.ui.model.BookmarkTableModel; - -/** -* @version $Id$ - */ -public class BookmarkTable extends JTable { - - private BookmarkTable table = this; - private BookmarkTableModel tableModel; - private BookmarkTableColumnModel columnModel; - - public BookmarkTable() { - super(); - Cyberduck.DEBUG("[BookmarkTable]"); - this.setModel(this.tableModel = new BookmarkTableModel()); - this.setColumnModel(this.columnModel = new BookmarkTableColumnModel()); - this.getSelectionModel().setSelectionMode(javax.swing.ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); - - // TableListener tl = new TableListener(); -// this.getSelectionModel().addListSelectionListener(tl); - - this.getSelectionModel().addListSelectionListener(new javax.swing.event.ListSelectionListener() { - Bookmark last; - public void valueChanged(javax.swing.event.ListSelectionEvent e) { - if(!e.getValueIsAdjusting()) { - javax.swing.ListSelectionModel lsm = (javax.swing.ListSelectionModel)e.getSource(); - if(!lsm.isSelectionEmpty()) { - int selectedRow = lsm.getMinSelectionIndex(); - Bookmark bookmark = (Bookmark)tableModel.getEntry(selectedRow); - if(bookmark != null) { - if(last != null) - last.status.setSelected(false); - bookmark.status.setSelected(true); - bookmark.callObservers(Bookmark.SELECTION); - this.last = bookmark; - } - } - // no selection - else { - if(last != null) { - last.status.setSelected(false); - last.callObservers(Bookmark.DESELECTION); - } - } - } - } - }); - - final javax.swing.JPopupMenu popupMenu = new javax.swing.JPopupMenu(); - popupMenu.add(new javax.swing.JMenuItem((Action)ActionMap.instance().get("New Bookmark"))); - popupMenu.addSeparator(); - popupMenu.add(new javax.swing.JMenuItem((Action)ActionMap.instance().get("Connect Selected"))); -// popupMenu.add(new javax.swing.JMenuItem((Action)ActionMap.instance().get("Edit Selected"))); - - DragSource.getDefaultDragSource(). - createDefaultDragGestureRecognizer( - this, - DnDConstants.ACTION_COPY_OR_MOVE, - new DragStartListener() - ); - // make the columns sortable - this.getTableHeader().addMouseListener(new TableColumnSorter(this, tableModel, columnModel)); - } - - public boolean editCellAt(int row, int col, java.util.EventObject event) { - if(event instanceof MouseEvent) { - //Cyberduck.DEBUG("***editCellAt --> MouseEvent"); - //Cyberduck.DEBUG("***editCellAt --> row:"+(row == this.getSelectedRow())); - //Cyberduck.DEBUG("***editCellAt --> col:"+(col == this.getSelectedColumn())); - if(row == this.getSelectedRow() && col == this.getSelectedColumn()) { - if( ((MouseEvent)event).getClickCount() == 2) { - //Cyberduck.DEBUG("---getClickCount()==2"); - Bookmark b = (Bookmark)tableModel.getEntry(row); -// cocoa-version b.getStatusDialog().show(); - return false; - } - else if( ((MouseEvent)event).getClickCount() == 1) { - //Cyberduck.DEBUG("---getClickCount()==1"); - return super.editCellAt(row, col, null); - // this.editCellAt(row, col); - } - } - else { - return super.editCellAt(row, col, event); - } - } - else if(event instanceof java.awt.event.KeyEvent) { - //Cyberduck.DEBUG("***editCellAt --> KeyEvent"); - return false; - } - return super.editCellAt(row, col, event); -// Cyberduck.DEBUG("[BookmarkTable] editCellAt("+row+","+col+"):"+edit); - } - - public BookmarkTableModel getTableModel() { - return this.tableModel; - } - - private class DragStartListener implements DragGestureListener { - public void dragGestureRecognized(DragGestureEvent e) { - Cyberduck.DEBUG(e.toString()); - if(getSelectedRowCount() == 1) { - int row = getSelectedRow(); - int col = BookmarkTableColumnModel.ADDRESSCOLUMN; - java.awt.Rectangle bounds = getCellRect(row, col, false); - if(bounds.contains(e.getDragOrigin())) { - Object bookmark = tableModel.getEntry(row); - if (bookmark != null) { - String url = ((Bookmark)bookmark).getAddressAsString(); - java.awt.Component rect = getCellRenderer(row, col).getTableCellRendererComponent( - table, - url, - true, - true, - row, - col - ); - rect.setSize(bounds.width, bounds.height); - java.awt.Image image = createImage(bounds.width, bounds.height); - java.awt.Graphics g = image.getGraphics(); - rect.paint(g); - g.dispose(); - e.startDrag(DragSource.DefaultMoveDrop, // cursor - image, - new java.awt.Point(0, 0), //offset - new java.awt.datatransfer.StringSelection(url), // transferable - new DragMoveListener() - ); // drag source listener - } - } - } - } - } - - private class DragMoveListener implements DragSourceListener { - public void dragDropEnd(DragSourceDropEvent e) { - Cyberduck.DEBUG(e.toString()); - if(e.getDropSuccess()) { - } - else { - } - } - public void dragExit(DragSourceEvent e) { - Cyberduck.DEBUG(e.toString()); - } - public void dragEnter(DragSourceDragEvent e) { - Cyberduck.DEBUG(e.toString()); - } - public void dragOver(DragSourceDragEvent e) { - Cyberduck.DEBUG(e.toString()); - } - public void dropActionChanged(DragSourceDragEvent e) { - Cyberduck.DEBUG(e.toString()); - } - } - - /** - * Overwritten to return allways the size of the whole viewport. (Important for DND) - */ - public boolean getScrollableTracksViewportHeight() { - java.awt.Component parent = this.getParent(); - if (parent instanceof javax.swing.JViewport) { - return parent.getHeight() > this.getPreferredSize().height; - } - return false; - } -} diff --git a/source/ch/cyberduck/ui/EditPanel.java b/source/ch/cyberduck/ui/EditPanel.java deleted file mode 100644 index f99e37b0dd..0000000000 --- a/source/ch/cyberduck/ui/EditPanel.java +++ /dev/null @@ -1,366 +0,0 @@ -package ch.cyberduck.ui; - -/* - * ch.cyberduck.ui.EditPanel.java - * Cyberduck - * - * $Header$ - * $Revision$ - * $Date$ - * - * Copyright (c) 2003 David Kocher. All rights reserved. - * http://icu.unizh.ch/~dkocher/ - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * Bug fixes, suggestions and comments should be sent to: - * dkocher@cyberduck.ch - */ - -import javax.swing.*; -import java.awt.BorderLayout; -import java.awt.FlowLayout; -import java.awt.event.*; -import java.io.File; -import java.net.URL; -import java.util.Observable; -import java.util.Observer; - -import com.enterprisedt.net.ftp.FTPTransferType; -import ch.cyberduck.Cyberduck; -import ch.cyberduck.Preferences; -import ch.cyberduck.connection.Bookmark; -import ch.cyberduck.connection.Session; -import ch.cyberduck.ui.common.*; -import ch.cyberduck.ui.layout.ParagraphLayout; - -/** -* @version $Id$ - */ -public class EditPanel extends JPanel implements Observer { - - private Bookmark selected; - - private JLabel urlLabel; - private JButton saveButton, connectButton; - private JTextField hostField, portField; - private JTextField nameField; - private JPasswordField passwdField; - private JTextField pathField, saveToField; - private JCheckBox anonymousCheckbox, sslCheckbox; - private JRadioButton httpRadiobutton, ftpRadiobutton, sftpRadiobutton; - private JRadioButton asciiRadio, binaryRadio; - private JPanel parameterPanel; - - public EditPanel() { - Cyberduck.DEBUG("[EditPanel]"); - this.init(); - } - - public void update(Observable o, Object arg) { - if(o instanceof Bookmark) { - Cyberduck.DEBUG("[EditPanel] update("+arg.toString()+")"); - if(arg.equals(Bookmark.SELECTION)) { - this.selected = (Bookmark)o; - - sslCheckbox.setSelected(selected.getProtocol().equalsIgnoreCase(Session.HTTPS)); - - hostField.setText(selected.getHost()); - pathField.setText(selected.getServerPathAsString()); - portField.setText(String.valueOf(selected.getPort())); - - nameField.setText(selected.getUsername()); - passwdField.setText(selected.getPassword()); - - asciiRadio.setSelected(selected.getTransferType().equals(FTPTransferType.ASCII)); - binaryRadio.setSelected(selected.getTransferType().equals(FTPTransferType.BINARY)); - - saveToField.setText(selected.getLocalPathAsString()); - - sftpRadiobutton.setSelected(selected.getProtocol().equalsIgnoreCase(Session.SFTP)); - ftpRadiobutton.setSelected(selected.getProtocol().equalsIgnoreCase(Session.FTP)); - httpRadiobutton.setSelected(selected.getProtocol().equalsIgnoreCase(Session.HTTP) || selected.getProtocol().equalsIgnoreCase(Session.HTTPS)); - - parameterPanel.setBorder( - BorderFactory.createTitledBorder( - BorderFactory.createEtchedBorder(javax.swing.border.EtchedBorder.LOWERED), selected.getHost())); - urlLabel.setText(selected.getAddressAsString()); - new ConfigurationAction().actionPerformed(new ActionEvent(this, ActionEvent.ACTION_PERFORMED, null)); - } - } - } - - private class ConfigurationAction extends AbstractAction { - public ConfigurationAction() { - super(); - } - public ConfigurationAction(String name) { - super(name); - } - public void actionPerformed(ActionEvent ae) { - // URL url = null; - String url = null; - // try { - // update url label - int port; - try { - port = Integer.parseInt(portField.getText()); - } - catch(NumberFormatException e) { - port = httpRadiobutton.isSelected() ? Session.HTTP_PORT : Session.FTP_PORT; - } - if(httpRadiobutton.isSelected()) { - String protocol = sslCheckbox.isSelected() ? Session.HTTPS : Session.HTTP; -// url = new URL(protocol, hostField.getText(), port, pathField.getText()); - url = protocol+"://"+hostField.getText()+port+pathField.getText(); - } - if(ftpRadiobutton.isSelected()) { - String protocol = Session.FTP; -// url = new URL(protocol, nameField.getText() + "@" + hostField.getText(), port, pathField.getText()); - url = protocol+"://"+nameField.getText()+"@"+hostField.getText()+port+pathField.getText(); - } - if(sftpRadiobutton.isSelected()) { - String protocol = Session.SFTP; - url = protocol+"://"+nameField.getText()+"@"+hostField.getText()+port+pathField.getText(); -// url = new URL(protocol, nameField.getText() + "@" + hostField.getText(), port, pathField.getText()); - } - //Cyberduck.DEBUG("setting url label:\n"+url.toString()); - urlLabel.setText(url); -// urlLabel.setText(url.toString()); - if(pathField.getText() != null) { - if(pathField.getText().equals("") || pathField.getText().endsWith("/")) { - saveToField.setText(""); - saveToField.setEnabled(false); - } - else { - saveToField.setText(Preferences.instance().getProperty("download.path") + pathField.getText().substring(pathField.getText().lastIndexOf('/') + 1 )); - saveToField.setEnabled(true); - } - } - // } -// catch(java.net.MalformedURLException ex) { -// ex.printStackTrace(); - // } - - anonymousCheckbox.setSelected(nameField.getText()!=null && nameField.getText().equals(Preferences.instance().getProperty("ftp.login.anonymous.name"))); - sslCheckbox.setEnabled(httpRadiobutton.isSelected()); - anonymousCheckbox.setEnabled(ftpRadiobutton.isSelected() | sftpRadiobutton.isSelected()); - nameField.setEnabled(ftpRadiobutton.isSelected() | sftpRadiobutton.isSelected() ); - passwdField.setEnabled(ftpRadiobutton.isSelected() | sftpRadiobutton.isSelected() ); - asciiRadio.setEnabled(ftpRadiobutton.isSelected()); - binaryRadio.setEnabled(ftpRadiobutton.isSelected()); - - } - } - - public JButton getDefaultButton() { - return this.saveButton; - } - -/* - public java.awt.Dimension getMinimumSize() { - java.awt.Dimension d = super.getMinimumSize(); - Cyberduck.DEBUG("[EditPanel] getMinimumSize():" + d.toString()); - return d; - } - */ - - private class ButtonPanel extends JPanel { - public ButtonPanel() { - super(); - this.init(); - } - - private void init() { - this.setLayout(new FlowLayout(FlowLayout.RIGHT)); - // this.add(cancelButton = GUIFactory.buttonBuilder(GUIFactory.FONT_SMALL, new CancelAction())); - this.add(saveButton = GUIFactory.buttonBuilder(GUIFactory.FONT_SMALL, new SaveAction())); - saveButton.setDefaultCapable(true); - this.add(connectButton = GUIFactory.buttonBuilder(GUIFactory.FONT_SMALL, new ConnectAction())); - } - } - - private class ParameterPanel extends JPanel { - public ParameterPanel() { - super(); - this.init(); - } - - private void init() { - this.setLayout(new ParagraphLayout()); - - // protocol selection - ButtonGroup protocolGroup = new ButtonGroup(); - this.add(GUIFactory.labelBuilder("URL:", GUIFactory.FONT_SMALL), ParagraphLayout.NEW_PARAGRAPH); - this.add(urlLabel = new DraggableLabel("", GUIFactory.FONT_SMALL)); - - //@todo replace with combobox - this.add(GUIFactory.labelBuilder("Protocol:", GUIFactory.FONT_SMALL), ParagraphLayout.NEW_PARAGRAPH); - this.add(sftpRadiobutton = GUIFactory.radiobuttonBuilder(protocolGroup, GUIFactory.FONT_SMALL, new ConfigurationAction("SFTP"))); - this.add(httpRadiobutton = GUIFactory.radiobuttonBuilder(protocolGroup, GUIFactory.FONT_SMALL, new ConfigurationAction("HTTP"))); - this.add(ftpRadiobutton = GUIFactory.radiobuttonBuilder(protocolGroup, GUIFactory.FONT_SMALL, new ConfigurationAction("FTP"))); - sslCheckbox = GUIFactory.checkboxBuilder("Use SSL", GUIFactory.FONT_SMALL, false, new ItemListener() { - public void itemStateChanged(ItemEvent e) { - if(sftpRadiobutton.isSelected()) - portField.setText(""+Session.SFTP_PORT); - if(ftpRadiobutton.isSelected()) - portField.setText(""+Session.FTP_PORT); - if(httpRadiobutton.isSelected()) - portField.setText(sslCheckbox.isSelected() ? ""+Session.HTTPS_PORT : ""+Session.HTTP_PORT); - }; - }); - sslCheckbox = GUIFactory.checkboxBuilder("Use SSL", GUIFactory.FONT_SMALL, false, new ItemListener() { - public void itemStateChanged(ItemEvent e) { - if(httpRadiobutton.isSelected()) - portField.setText(sslCheckbox.isSelected() ? ""+Session.HTTPS_PORT : ""+Session.HTTP_PORT); - }; - }); - this.add(sslCheckbox); - - - this.add(GUIFactory.labelBuilder("Host:", GUIFactory.FONT_SMALL), ParagraphLayout.NEW_PARAGRAPH); - this.add(hostField = GUIFactory.textFieldBuilder(GUIFactory.FONT_SMALL, 30, new DummyVerifier())); - hostField.setAction(new ConfigurationAction("Host")); - hostField.addKeyListener(new KeyAdapter() { - public void keyReleased(KeyEvent ev) { - hostField.getAction().actionPerformed(new ActionEvent(ev.getSource(), ev.getID(), "KEY")); - } - } - ); - this.add(GUIFactory.labelBuilder("Port:", GUIFactory.FONT_SMALL)); - this.add(portField = GUIFactory.textFieldBuilder(GUIFactory.FONT_SMALL, 4, new IntegerVerifier())); - portField.setAction( new ConfigurationAction("Port")); - portField.addKeyListener(new KeyAdapter() { - public void keyReleased(KeyEvent ev) { - portField.getAction().actionPerformed(new ActionEvent(ev.getSource(), ev.getID(), "KEY")); - } - } - ); - this.add(GUIFactory.labelBuilder("Remote Path:", GUIFactory.FONT_SMALL), ParagraphLayout.NEW_PARAGRAPH); - this.add(pathField = GUIFactory.textFieldBuilder(GUIFactory.FONT_SMALL, 30)); - pathField.setAction(new ConfigurationAction("Remote Path")); - pathField.addKeyListener(new KeyAdapter() { - public void keyReleased(KeyEvent ev) { - pathField.getAction().actionPerformed(new ActionEvent(ev.getSource(), ev.getID(), "KEY")); - } - } - ); - - this.add(GUIFactory.labelBuilder("Save As:", GUIFactory.FONT_SMALL), ParagraphLayout.NEW_PARAGRAPH); - JLabel pathErrorLabel = GUIFactory.labelBuilder("The directory does not exist.", GUIFactory.FONT_SMALL); - pathErrorLabel.setVisible(false); - this.add(saveToField = GUIFactory.textFieldBuilder("", GUIFactory.FONT_SMALL, 30, new ParentPathVerifier(pathErrorLabel))); - this.add(pathErrorLabel, ParagraphLayout.NEW_LINE); - this.add(GUIFactory.labelBuilder("Login:", GUIFactory.FONT_SMALL), ParagraphLayout.NEW_PARAGRAPH); - // NameField - this.add(nameField = GUIFactory.textFieldBuilder(GUIFactory.FONT_SMALL, 20, new DummyVerifier())); - this.add(GUIFactory.labelBuilder("User ID", GUIFactory.FONT_SMALL)); - nameField.setAction(new ConfigurationAction("User")); - nameField.addKeyListener(new KeyAdapter() { - public void keyReleased(KeyEvent ev) { - nameField.getAction().actionPerformed(new ActionEvent(ev.getSource(), ev.getID(), "KEY")); - } - } - ); - // PasswdField - this.add(passwdField = GUIFactory.passwordFieldBuilder(GUIFactory.FONT_SMALL, 20, new DummyVerifier()), ParagraphLayout.NEW_LINE); - this.add(GUIFactory.labelBuilder("Password", GUIFactory.FONT_SMALL)); - passwdField.setAction(new ConfigurationAction("Password")); - passwdField.addKeyListener(new KeyAdapter() { - public void keyReleased(KeyEvent ev) { - passwdField.getAction().actionPerformed(new ActionEvent(ev.getSource(), ev.getID(), "KEY")); - } - } - ); - this.add(anonymousCheckbox = GUIFactory.checkboxBuilder("Anonymous Login", GUIFactory.FONT_SMALL), ParagraphLayout.NEW_LINE); - anonymousCheckbox.addItemListener(new ItemListener() { - public void itemStateChanged(ItemEvent e) { - if(e.getStateChange() == ItemEvent.SELECTED) { - nameField.setText(Preferences.instance().getProperty("ftp.login.anonymous.name")); - passwdField.setText(Preferences.instance().getProperty("ftp.login.anonymous.pass")); - } - /* - else { - nameField.setText(""); - passwdField.setText(""); - } - */ - } - } - ); - - - ButtonGroup transferModeGroup = new ButtonGroup(); - this.add(GUIFactory.labelBuilder("Transfer Mode:", GUIFactory.FONT_SMALL), ParagraphLayout.NEW_PARAGRAPH); - // this.add(autoRadio = GUIFactory.radiobuttonBuilder(transferModeGroup, "Auto", GUIFactory.FONT_SMALL, Preferences.instance().getProperty("connection.transfertype.default").equals("auto"), null)); - this.add(asciiRadio = GUIFactory.radiobuttonBuilder(transferModeGroup, "ASCII", GUIFactory.FONT_SMALL)); - this.add(binaryRadio = GUIFactory.radiobuttonBuilder(transferModeGroup, "Binary", GUIFactory.FONT_SMALL)); - } - } - - /** - * Initialize the graphical user interface - */ - private void init() { - Cyberduck.DEBUG("[EditPanel] init()"); - this.setLayout(new BorderLayout()); - this.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); - this.add(parameterPanel = new ParameterPanel(), BorderLayout.CENTER); - this.add(new ButtonPanel(), BorderLayout.SOUTH); - } - - - // ************************************************************************************************************ - - private class ConnectAction extends SaveAction { - public ConnectAction () { - this.putValue(NAME, "Connect"); - this.putValue(SHORT_DESCRIPTION, "Save changes and connect"); - } - public void actionPerformed(ActionEvent ae) { - Cyberduck.DEBUG(ae.paramString()); - super.actionPerformed(ae); - selected.transfer(); - } - } - - - private class SaveAction extends AbstractAction {//extends CancelAction { - public SaveAction() { - this.putValue(NAME, "Save"); - this.putValue(SHORT_DESCRIPTION, "Save changes"); - } - public void actionPerformed(ActionEvent ae) { - Cyberduck.DEBUG(ae.paramString()); - if(httpRadiobutton.isSelected()) - selected.setProtocol(sslCheckbox.isSelected() ? Session.HTTPS : Session.HTTP); - if(ftpRadiobutton.isSelected()) { - selected.setProtocol(Session.FTP); - selected.setUserInfo(nameField.getText()+":"+new String(passwdField.getPassword())); - } - if(sftpRadiobutton.isSelected()) { - selected.setProtocol(Session.SFTP); - selected.setUserInfo(nameField.getText()+":"+new String(passwdField.getPassword())); - } - selected.setTransferType(asciiRadio.isSelected() ? FTPTransferType.ASCII : FTPTransferType.BINARY); - try { - selected.setPort(Integer.parseInt(portField.getText())); - } - catch(NumberFormatException e) { - selected.setPort(Session.FTP_PORT); - } - selected.setHost(hostField.getText()); - selected.setServerPath(pathField.getText()); - if(selected.isDownload()) - selected.setLocalPath(new File(saveToField.getText())); - } - } -} diff --git a/source/ch/cyberduck/ui/ListPanel.java b/source/ch/cyberduck/ui/ListPanel.java deleted file mode 100644 index db992fe07a..0000000000 --- a/source/ch/cyberduck/ui/ListPanel.java +++ /dev/null @@ -1,596 +0,0 @@ -package ch.cyberduck.ui; - -/* - * ch.cyberduck.ui.ListPanel.java - * Cyberduck - * - * $Header$ - * $Revision$ - * $Date$ - * - * Copyright (c) 2003 David Kocher. All rights reserved. - * http://icu.unizh.ch/~dkocher/ - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * Bug fixes, suggestions and comments should be sent to: - * dkocher@cyberduck.ch - */ - -import javax.swing.*; -import javax.swing.event.ListSelectionEvent; -import javax.swing.event.ListSelectionListener; -import java.awt.*; -import java.awt.event.*; -import java.util.Observable; -import java.util.Observer; -import java.util.Vector; - -import ch.cyberduck.Cyberduck; -import ch.cyberduck.CyberduckMenu; -import ch.cyberduck.Preferences; -import ch.cyberduck.connection.Bookmark; -import ch.cyberduck.connection.Path; -import ch.cyberduck.connection.TransferAction; -import ch.cyberduck.ui.action.ActionMap; -import ch.cyberduck.ui.common.GUIFactory; -import ch.cyberduck.ui.model.ListTableModel; - -/** -* @version $Id$ - */ -public class ListPanel extends JPanel implements Observer { - - private ListTable listingTable; - private ListTableModel listingTableModel; - - /** - * The currently selected bookmark - */ - private Bookmark selected; - - private JScrollPane pane; - private JComboBox comboBox; - private ComboPathModel comboModel; - private ActionListener comboActionListener; - private ItemListener comboItemListener; - - private Action backAction; - private Action upAction; - private Action refreshAction; - private Action newDirectoryAction; - private Action renameAction; - private Action deleteAction; - private Action downloadAction; - private Action permissionAction; - private Action abortAction; - private Action disconnectAction; - - public ListPanel() { - super(); - this.init(); - } - - public void update(Observable o, Object arg) { - this.listingTable.update(o, arg); - if(arg.equals(Bookmark.SELECTION) || arg.equals(Bookmark.LIST)) { - this.selected = (Bookmark)o; - boolean valid = false; - { - valid = selected.isValid(); - valid = selected.getProtocol().equals(ch.cyberduck.connection.Session.FTP); - valid = selected.isListing() && selected.getListing() != null; - } - backAction.setEnabled(valid); - upAction.setEnabled(valid); - refreshAction.setEnabled(valid); - newDirectoryAction.setEnabled(valid); - abortAction.setEnabled(valid); - disconnectAction.setEnabled(valid); - - downloadAction.setEnabled(false); - renameAction.setEnabled(false); - deleteAction.setEnabled(false); - permissionAction.setEnabled(false); - - if(selected.isListing()) { - Path cwd = selected.getCurrentPath(); - if(cwd != null) { - //@workaround because changing the model of JComboBox fires the ActionListener - this.comboBox.removeItemListener(comboItemListener); - this.comboModel.removeAll(); - int depth = cwd.getPathDepth(); - for(int i = 0; i <= depth; i++) { - this.comboModel.addElement(cwd.getPathFragment(i)); - } - // selected the last added item - this.comboModel.setSelectedItem(comboModel.getElementAt(comboModel.getSize()-1)); - this.comboBox.addItemListener(comboItemListener); - } - } - } - } - - public Dimension getPreferredSize() { - Cyberduck.DEBUG("[ListPanel] getMinimumSize()"); - return listingTable.getPreferredScrollableViewportSize(); - } - - - public Dimension getMinimumSize() { - Dimension d = new Dimension(listingTable.getPreferredScrollableViewportSize().width, 300); - Cyberduck.DEBUG("[ListPanel] getMinimumSize():" + d.toString()); - return d; - } - - - /* - * Initialize the graphical user interface; the table and associated TableModel - */ - private void init() { - Cyberduck.DEBUG("[ListPanel] init()"); - listingTable = new ListTable(); - listingTableModel = (ListTableModel)listingTable.getModel(); - this.setLayout(new BorderLayout()); - - backAction = new BackAction(); - upAction = new UpAction(); - refreshAction = new RefreshAction(); - abortAction = new AbortAction(); - downloadAction = new ListingDownloadAction(); - newDirectoryAction = new NewDirectoryAction(); - renameAction = new RenameAction(); - deleteAction = new DeleteAction(); - permissionAction = new PermissionAction(); - disconnectAction = new DisconnectAction(); - - this.updateFtpMenu(); - - ListSelectionModel selectionModel = listingTable.getSelectionModel(); - selectionModel.addListSelectionListener(new ListSelectionListener() { - public void valueChanged(ListSelectionEvent e) { - if(!e.getValueIsAdjusting()) { - //Cyberduck.DEBUG(e.paramString()); - ListSelectionModel lsm = (ListSelectionModel)e.getSource(); - boolean selection = !(lsm.isSelectionEmpty()); - - downloadAction.setEnabled(selection); - renameAction.setEnabled(selection); - deleteAction.setEnabled(selection); - permissionAction.setEnabled(selection); - - updateFtpMenu(); - } - } - } - ); - - //table - pane = new JScrollPane(listingTable); - pane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); - pane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); - - { - final javax.swing.JPopupMenu popupMenu = new javax.swing.JPopupMenu(); - popupMenu.add(downloadAction); - popupMenu.addSeparator(); - popupMenu.add(newDirectoryAction); - popupMenu.add(renameAction); - popupMenu.add(deleteAction); - popupMenu.add(permissionAction); - - listingTable.addMouseListener(new java.awt.event.MouseAdapter() { - public void mousePressed(java.awt.event.MouseEvent e) { - maybeShowPopup(e); - } - public void mouseReleased(java.awt.event.MouseEvent e) { - maybeShowPopup(e); - } - private void maybeShowPopup(java.awt.event.MouseEvent e) { - if (e.isPopupTrigger()) { - popupMenu.show(e.getComponent(), e.getX(), e.getY()); - } - } - } - ); - } - - this.add(new NavigationPanel(), BorderLayout.NORTH); - this.add(pane, BorderLayout.CENTER); - this.add(new ButtonPanel(), BorderLayout.SOUTH); - } - - private void updateFtpMenu() { - final JMenuItem[] ftpMenuItems = { - CyberduckMenu.instance().menuItemBuilder(newDirectoryAction), - CyberduckMenu.instance().menuItemBuilder(renameAction), - CyberduckMenu.instance().menuItemBuilder(deleteAction), - CyberduckMenu.instance().menuItemBuilder(permissionAction), - //null, - CyberduckMenu.instance().menuItemBuilder(disconnectAction) - }; - - JMenu ftpMenu = CyberduckMenu.instance().getMenu(CyberduckMenu.FTP_MENU); - ftpMenu.removeAll(); - for(int i = 0; i < ftpMenuItems.length; i++) { - ftpMenu.add(ftpMenuItems[i]); - } - } - - private class ButtonPanel extends JPanel { - public ButtonPanel() { - super(); - this.setLayout(new FlowLayout(FlowLayout.LEFT)); - JButton downloadButton = GUIFactory.buttonBuilder(GUIFactory.FONT_SMALL, downloadAction); - downloadButton.setIcon(new ImageIcon("ToolBarUI")); - JButton newDirectoryButton = GUIFactory.buttonBuilder(GUIFactory.FONT_SMALL, newDirectoryAction); - newDirectoryButton.setIcon(new ImageIcon("ToolBarUI")); - JButton renameButton = GUIFactory.buttonBuilder(GUIFactory.FONT_SMALL, renameAction); - renameButton.setIcon(new ImageIcon("ToolBarUI")); - JButton deleteButton = GUIFactory.buttonBuilder(GUIFactory.FONT_SMALL, deleteAction); - deleteButton.setIcon(new ImageIcon("ToolBarUI")); - JButton permissionButton = GUIFactory.buttonBuilder(GUIFactory.FONT_SMALL, permissionAction); - permissionButton.setIcon(new ImageIcon("ToolBarUI")); - JButton disconnectButton = GUIFactory.buttonBuilder(GUIFactory.FONT_SMALL, disconnectAction); - disconnectButton.setIcon(new ImageIcon("ToolBarUI")); - - this.add(downloadButton); - this.add(newDirectoryButton); - this.add(renameButton); - this.add(deleteButton); - this.add(permissionButton); - this.add(disconnectButton); - } - } - - private class NavigationPanel extends JPanel { - public NavigationPanel() { - super(); - this.setLayout(new FlowLayout(FlowLayout.LEFT)); - this.add(GUIFactory.buttonBuilder(backAction)); - this.add(GUIFactory.buttonBuilder(upAction)); - this.add(GUIFactory.buttonBuilder(refreshAction)); - //directory selection - comboBox = new JComboBox(); - comboBox.setEditable(false); - comboBox.setModel(comboModel = new ComboPathModel()); - comboBox.setRenderer(new ComboPathRenderer()); - comboBox.addItemListener(comboItemListener = new ItemListener() { - public void itemStateChanged(ItemEvent e) { - if(e.getStateChange() == ItemEvent.SELECTED) { - Cyberduck.DEBUG(e.paramString()); - Path p = (Path)e.getItem(); - selected.transfer(new TransferAction(TransferAction.LIST, p)); - } - } - } - ); - this.add(comboBox); - this.add(GUIFactory.buttonBuilder(abortAction)); - } - } - - // ************************************************************************************************************ - - private class ComboPathRenderer extends DefaultListCellRenderer { - public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { - super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); - if(value instanceof Path) { - Path p = (Path)value; - if(p.getPathDepth() > 0) { - this.setIcon(new IndentIcon(GUIFactory.FOLDER_ICON, p.getPathDepth())); - this.setText(p.getName()); - } - else { - this.setIcon(new IndentIcon(GUIFactory.HARDDRIVE_ICON, p.getPathDepth())); - this.setText(selected.getHost()); - } - } - return this; - } - }; - - private class IndentIcon implements Icon { - Icon icon = null; - int depth = 0; - - public IndentIcon(Icon i, int d) { - icon = i; - depth = d; - } - public void paintIcon(Component c, Graphics g, int x, int y) { - if(icon!=null) - icon.paintIcon(c, g, 10 + x + depth * 10, y); - } - public int getIconWidth() { - return 10 + depth * 10 + (icon != null ? icon.getIconWidth() : 0); - } - public int getIconHeight() { - return (icon != null ? icon.getIconHeight() : 1); - } - } - - // ************************************************************************************************************ - - private class ComboPathModel extends AbstractListModel implements MutableComboBoxModel { - Object selected = null; - Vector paths = new Vector(); - - public int getSize() { - return paths.size(); - } - - public void addElement(Object o) { -// Cyberduck.DEBUG("[ComboPathModel] addElement(" + o + ")"); - paths.add(o); -// this.fireIntervalAdded(this, this.getSize() - 1, this.getSize() - 1); - } - public void insertElementAt(Object o, int index) { - Cyberduck.DEBUG("[ComboPathModel] insertElementAt(" + o + "," + index + ")"); - paths.add(index, o); - this.fireIntervalAdded(this, index, index); - } - public void removeElement(Object o) { - Cyberduck.DEBUG("[ComboPathModel] removeElement(" + o + ")"); - paths.removeElement(o); - this.fireContentsChanged(this, 0, this.getSize()); - } - public void removeElementAt(int index) { - Cyberduck.DEBUG("[ComboPathModel] removeElementAt(" + index + ")"); - paths.removeElementAt(index); - this.fireIntervalRemoved(this, index, index); - } - public void removeAll() { - paths.clear(); - this.fireContentsChanged(this, 0, this.getSize()); - } - public boolean isEmpty() { - return paths.isEmpty(); - } - public Object getElementAt(int index) { -// Cyberduck.DEBUG("[ComboPathModel] getElementAt(" + index + ")"); - return paths.elementAt(index);//.getPath(); - } - public void setSelectedItem(Object item) { -// Cyberduck.DEBUG("[ComboPathModel] setSelectedItem(" + item + ")"); - this.selected = item; - this.fireContentsChanged(this, 0, this.getSize()); -// comboBox.addActionListener(comboActionListener); - } - - public Object getSelectedItem() { -// Cyberduck.DEBUG("[ComboPathModel] getSelectedItem()"); - if(selected instanceof java.lang.String) - return new Path((String)selected); - return this.selected; - } - } - - - // ************************************************************************************************************ - - private class UpAction extends AbstractAction { - public UpAction() { -// super("List parent"); - this.putValue(SHORT_DESCRIPTION, "List parent directory"); - this.putValue(SMALL_ICON, Cyberduck.getIcon(Cyberduck.getResource(this.getClass(), "up_small.gif"))); - this.setEnabled(true); - //ActionMap.instance().put(this.getValue(NAME), this); - } - public void actionPerformed(ActionEvent ae) { - Cyberduck.DEBUG(ae.paramString()); - selected.transfer(new TransferAction(TransferAction.LIST, selected.getCurrentPath().getParent())); - } - } - - private class BackAction extends AbstractAction { - public BackAction() { -// super("Go Back"); - this.putValue(SHORT_DESCRIPTION, "List previous directory"); - this.putValue(SMALL_ICON, Cyberduck.getIcon(Cyberduck.getResource(this.getClass(), "back_small.gif"))); - this.setEnabled(true); - //ActionMap.instance().put(this.getValue(NAME), this); - } - public void actionPerformed(ActionEvent ae) { - Cyberduck.DEBUG(ae.paramString()); - selected.transfer(new TransferAction(TransferAction.LIST, selected.getPreviousPath())); - } - } - - private class RefreshAction extends AbstractAction { - public RefreshAction() { -// super("Refresh"); - this.putValue(SHORT_DESCRIPTION, "Refresh directory listing"); - this.putValue(SMALL_ICON, Cyberduck.getIcon(Cyberduck.getResource(this.getClass(), "refresh_small.gif"))); - this.setEnabled(true); - //ActionMap.instance().put(this.getValue(NAME), this); - } - public void actionPerformed(ActionEvent ae) { - Cyberduck.DEBUG(ae.paramString()); - selected.transfer(new TransferAction(TransferAction.LIST, comboModel.getElementAt(comboModel.getSize() - 1))); - } - } - - private class AbortAction extends AbstractAction { - public AbortAction() { - //super("Stop"); - this.putValue(SHORT_DESCRIPTION, "Abort last action"); - this.putValue(SMALL_ICON, Cyberduck.getIcon(Cyberduck.getResource(this.getClass(), "stop_small.gif"))); - this.setEnabled(true); - //ActionMap.instance().put(this.getValue(NAME), this); - } - public void actionPerformed(ActionEvent ae) { - Cyberduck.DEBUG(ae.paramString()); - //selected.transfer(new TransferAction(TransferAction.ABORT)); - selected.status.setCanceled(true); - //((Action)ActionMap.instance().get("Stop")).actionPerformed(new ActionEvent(selected, ae.getID(), ae.getActionCommand())); - } - } - - private class NewDirectoryAction extends AbstractAction { - public NewDirectoryAction() { - super("New Folder"); - this.putValue(SHORT_DESCRIPTION, "Create new directory"); - //this.putValue(SMALL_ICON, GUIFactory.NEW_FOLDER_ICON); - this.setEnabled(false); - //ActionMap.instance().put(this.getValue(NAME), this); - } - public void actionPerformed(ActionEvent ae) { - Cyberduck.DEBUG(ae.paramString()); - Object input = JOptionPane.showInputDialog( - null, - "Name of the new folder:", - "New Folder", - JOptionPane.QUESTION_MESSAGE, - null, - null, - null - ); - if(input != null) { - if(input instanceof String) { - selected.transfer(new TransferAction(TransferAction.MKDIR, (String)input)); - } - } - } - } - - private class DeleteAction extends AbstractAction { - public DeleteAction() { - super("Delete"); - this.putValue(SHORT_DESCRIPTION, "Delete file or folder"); - this.setEnabled(false); - //ActionMap.instance().put(this.getValue(NAME), this); - } - public void actionPerformed(ActionEvent ae) { - Cyberduck.DEBUG(ae.paramString()); - if(listingTable.getSelectedRowCount() < 1 ) - Cyberduck.beep(); - else { - int[] rows = listingTable.getSelectedRows(); - StringBuffer candidates = new StringBuffer(); - for (int i = 0; i < rows.length; i++) { - candidates.append("\t"+listingTableModel.getEntry(rows[i])+"\n"); - if(i > 10) { - candidates.append("\t... and "+(rows.length - i)+" more files."); - break; - } - } - String sep = System.getProperty("line.separator"); - int input = JOptionPane.showConfirmDialog(null, - "Do you really want to delete all selected files?"+sep+candidates.toString()+sep+"You cannot undo this action.", - "Delete", - JOptionPane.YES_NO_OPTION, - JOptionPane.QUESTION_MESSAGE - ); - if(input == JOptionPane.YES_OPTION) { - Path delete = null; - Cyberduck.DEBUG("[ListPanel] Deleting " + rows.length + " files"); - for(int i = 0; i < rows.length; i++) { - delete = (Path)listingTableModel.getEntry(rows[i]); - selected.transfer(new TransferAction(TransferAction.DELE, delete), true); - } - selected.startQueue(); - } - } - } - } - - private class RenameAction extends AbstractAction { - public RenameAction() { - super("Rename"); - this.putValue(SHORT_DESCRIPTION, "Rename file or folder"); - this.setEnabled(false); - //ActionMap.instance().put(this.getValue(NAME), this); - } - public void actionPerformed(ActionEvent ae) { - Cyberduck.DEBUG(ae.paramString()); - if(listingTable.getSelectedRowCount() > 1) - Cyberduck.beep(); - if(listingTable.getSelectedRowCount() < 1) - Cyberduck.beep(); - else { - Path from = (Path)listingTableModel.getEntry(listingTable.getSelectedRow()); - Object input = JOptionPane.showInputDialog(null, - "Rename '" + from.getName() + "' to:", - "Rename", - JOptionPane.QUESTION_MESSAGE, - null, - null, - from.getName() - ); - if(input != null) { - if(input instanceof String) { - selected.transfer(new TransferAction(TransferAction.RNFR, from, new Path(from.getParent().getPath(), (String)input))); - } - } - } - } - } - - private class DisconnectAction extends AbstractAction { - public DisconnectAction() { - super("Disconnect"); - this.putValue(SHORT_DESCRIPTION, "Disconnect from remote host"); - this.setEnabled(false); - //ActionMap.instance().put(this.getValue(NAME), this); - } - public void actionPerformed(ActionEvent ae) { - Cyberduck.DEBUG(ae.paramString()); - selected.transfer(new TransferAction(TransferAction.QUIT)); - } - } - - private class ListingDownloadAction extends AbstractAction { - public ListingDownloadAction() { - super("Download"); - this.putValue(SHORT_DESCRIPTION, "Download selected file or folder"); - this.setEnabled(false); - //ActionMap.instance().put(this.getValue(NAME), this); - } - public void actionPerformed(ActionEvent ae) { - Cyberduck.DEBUG(ae.paramString()); - if(listingTable.getSelectedRowCount() < 1 ) - Cyberduck.beep(); - else { - Bookmark t = selected.copy(); - Path p = (Path)listingTableModel.getEntry(listingTable.getSelectedRow()); - t.setServerPath(p.toString()); - t.setLocalPath(new java.io.File(Preferences.instance().getProperty("download.path"), p.getName())); - ((Action)(ActionMap.instance().get("New Bookmark"))).actionPerformed(new ActionEvent(t, ActionEvent.ACTION_PERFORMED, "New Bookmark")); - t.transfer(new TransferAction(TransferAction.GET)); - } - } - } - - /** - * Show permission dialog - * @see ch.cyberduck.ui.PermissionDialog - */ - private class PermissionAction extends AbstractAction { - public PermissionAction() { - super("Set Permissions"); - this.putValue(SHORT_DESCRIPTION, "Edit file permissions"); - this.putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_I, GUIFactory.MENU_MASK)); - this.setEnabled(false); - //ActionMap.instance().put(this.getValue(NAME), this); - } - public void actionPerformed(ActionEvent ae) { - Cyberduck.DEBUG(ae.paramString()); - if(listingTable.getSelectedRowCount() < 1 ) - Cyberduck.beep(); - else { - Path file = (Path)listingTableModel.getEntry(listingTable.getSelectedRow()); - javax.swing.JDialog d = new PermissionDialog(selected, file); - d.show(); - } - } - } -} diff --git a/source/ch/cyberduck/ui/ListTable.java b/source/ch/cyberduck/ui/ListTable.java deleted file mode 100644 index 6da68a94c3..0000000000 --- a/source/ch/cyberduck/ui/ListTable.java +++ /dev/null @@ -1,351 +0,0 @@ -package ch.cyberduck.ui; - -/* - * ch.cyberduck.ui.ListTable.java - * Cyberduck - * - * $Header$ - * $Revision$ - * $Date$ - * - * Copyright (c) 2003 David Kocher. All rights reserved. - * http://icu.unizh.ch/~dkocher/ - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * Bug fixes, suggestions and comments should be sent to: - * dkocher@cyberduck.ch - */ - -import javax.swing.Action; -import javax.swing.JTable; -import javax.swing.table.JTableHeader; -import java.awt.Component; -import java.awt.datatransfer.DataFlavor; -import java.awt.datatransfer.Transferable; -import java.awt.datatransfer.UnsupportedFlavorException; -import java.awt.dnd.*; -import java.awt.event.*; -import java.util.Observable; -import java.util.Observer; - -import ch.cyberduck.Cyberduck; -import ch.cyberduck.Preferences; -import ch.cyberduck.connection.Bookmark; -import ch.cyberduck.connection.Path; -import ch.cyberduck.connection.TransferAction; -import ch.cyberduck.ui.action.ActionMap; -import ch.cyberduck.ui.common.TableColumnSorter; -import ch.cyberduck.ui.model.ListTableColumnModel; -import ch.cyberduck.ui.model.ListTableModel; - -/** -* @version $Id$ - */ -public class ListTable extends JTable implements Observer { - - private ListTable table = this; - private ListTableModel listModel = null; - private ListTableColumnModel columnModel = null; - - private Bookmark selected = null; - - public void update(Observable o, Object arg) { - if(o instanceof Bookmark) { - if(arg.equals(Bookmark.SELECTION) || arg.equals(Bookmark.LIST)) { - this.selected = (Bookmark)o; - java.util.Iterator iterator = selected.getListing().iterator(); - int i = 0; - Path p = null; - listModel.clear(); - while(iterator.hasNext()) { - p = (Path)iterator.next(); - if(p.isVisible()) { - listModel.addEntry(p, i); - i++; - } - } - listModel.fireTableDataChanged(); - } - } - } - - public ListTable() { - Cyberduck.DEBUG("[ListTable] new ListTable()"); - this.setModel(listModel = new ListTableModel()); - this.setColumnModel(columnModel = new ListTableColumnModel()); - - this.addKeyListener( - new KeyAdapter() { - public void keyReleased(KeyEvent e) { -// Cyberduck.DEBUG("[ListTable:KeyAdapter] keyReleased(" + e.toString() + ")"); - e.consume(); - int row = getSelectedRow(); - if(e.isMetaDown() || e.isControlDown()) { - if(e.getKeyCode() == KeyEvent.VK_UP) { - handleListing(null, KeyEvent.VK_UP); - } - else if(e.getKeyCode() == KeyEvent.VK_DOWN) { - if(row > -1) { - Path p = (Path)listModel.getEntry(row); - if(p.isFile()) { - handleDownload(p, row); - } - else if(p.isDirectory()) { - handleListing(p, KeyEvent.VK_DOWN); - } - } - } - } - } - - public void keyTyped(KeyEvent e) { - char c = e.getKeyChar(); - int selected[] = getSelectedRows(); - if(e.getModifiers() != InputEvent.SHIFT_MASK) { - for(int i = (selected.length > 0 ? selected[selected.length-1] + 1 : 0); i < listModel.getRowCount(); i++) { - if(((String)listModel.getValueAt(i, ListTableColumnModel.FILENAMECOLUMN)).charAt(0) == c) { - setRowSelectionInterval(i, i); - return; - } - } - for(int i = 0; i < listModel.getRowCount(); i++) { - if(((String)listModel.getValueAt(i, ListTableColumnModel.FILENAMECOLUMN)).charAt(0) == c) { - setRowSelectionInterval(i, i); - return; - } - } - } - else { - for(int i = (selected.length > 0 ? selected[selected.length-1]-1 : 0); i >= 0; i--) { - if(((String)listModel.getValueAt(i, ListTableColumnModel.FILENAMECOLUMN)).charAt(0) == c) { - setRowSelectionInterval(i, i); - return; - } - } - for(int i = listModel.getRowCount() - 1; i >= 0; i--) { - if(((String)listModel.getValueAt(i, ListTableColumnModel.FILENAMECOLUMN)).charAt(0) == c) { - setRowSelectionInterval(i, i); - return; - } - } - } - } - } - ); - JTableHeader tableHeader = this.getTableHeader(); - //make the columns sortable - tableHeader.addMouseListener(new TableColumnSorter(this, listModel, columnModel)); - new DropTarget(this, DnDConstants.ACTION_MOVE, new FileDropTargetListener()); - DragSource.getDefaultDragSource(). - createDefaultDragGestureRecognizer( - this, - DnDConstants.ACTION_COPY_OR_MOVE, - new DragStartListener() - ); - } - - public boolean editCellAt(int row, int col, java.util.EventObject event) { - if(event instanceof MouseEvent) { - if(row == this.getSelectedRow() && col == this.getSelectedColumn()) { - if( ((MouseEvent)event).getClickCount() == 2) { - //Cyberduck.DEBUG("---getClickCount()==2"); - Path p = (Path)listModel.getEntry(row); - if(p.isFile()) { - handleDownload(p, row); - } - else if(p.isDirectory()) { - handleListing(p, KeyEvent.VK_DOWN); - } - return false; - } - else if( ((MouseEvent)event).getClickCount() == 1) { - //Cyberduck.DEBUG("---getClickCount()==1"); - return false; - } - } - else { - return super.editCellAt(row, col, event); - } - } - else if(event instanceof java.awt.event.KeyEvent) { - return false; - } - return super.editCellAt(row, col, event); -// Cyberduck.DEBUG("[BookmarkTable] editCellAt("+row+","+col+"):"+edit); - } - - private void handleDownload(Path p, int row) { - Bookmark t = selected.copy(); - t.setServerPath(p.toString()); - t.setLocalPath(new java.io.File(Preferences.instance().getProperty("download.path"), p.getName())); - ((Action)(ActionMap.instance().get("New Bookmark"))).actionPerformed(new ActionEvent(t, ActionEvent.ACTION_PERFORMED, null)); - t.transfer(new TransferAction(TransferAction.GET)); - } - - private void handleListing(Path p, int key) { - if(key == KeyEvent.VK_UP) { - selected.transfer(new TransferAction(TransferAction.LIST, selected.getCurrentPath().getParent())); - } - else if(key == KeyEvent.VK_DOWN) { - selected.transfer(new TransferAction(TransferAction.LIST, p)); - } - } - - public boolean getScrollableTracksViewportHeight() { - Component parent = this.getParent(); - if (parent instanceof javax.swing.JViewport) { - return parent.getHeight() > this.getPreferredSize().getHeight(); - } - return false; - } - - - private class FileDropTargetListener implements DropTargetListener { - public void drop(DropTargetDropEvent e) { - Cyberduck.DEBUG("[FileDropTargetListener] drop(" + e.toString() + ")"); - if(e.isLocalTransfer()) { - Cyberduck.DEBUG("[FileDropTargetListener] isLocalTransfer(): true"); -// e.rejectDrop(); - } - try { - Transferable transferable = e.getTransferable(); - if(transferable.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) { - Cyberduck.DEBUG("[FileDropTargetListener] DataFlavor.javaFileListFlavor"); - e.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE); - int cursorRow = rowAtPoint(e.getLocation()); - int selectedRow = getSelectedRow(); - if((cursorRow == selectedRow) && (selectedRow != -1)) { - Path p = (Path)listModel.getEntry(selectedRow); - if(p.isDirectory()) { - selected.setCurrentPath(p); - } - } - java.util.List l = (java.util.List) transferable.getTransferData(DataFlavor.javaFileListFlavor); - java.util.Iterator i = l.iterator(); - while (i.hasNext()) { - selected.transfer(new TransferAction(TransferAction.PUT, i.next()), true); - } - selected.startQueue(); - e.dropComplete(true); - } - if(transferable.isDataFlavorSupported(Path.pathFlavor)) { - Cyberduck.DEBUG("[FileDropTargetListener] Path.pathFlavor"); - int cursorRow = rowAtPoint(e.getLocation()); - int selectedRow = getSelectedRow(); - if((cursorRow == selectedRow) && (selectedRow != -1)) { - Path dest = (Path)listModel.getEntry(selectedRow); - if(dest.isDirectory()) { - Path orig = (Path)transferable.getTransferData(Path.pathFlavor); - if(!(dest.getPath().equals(orig.getPath()))) { - e.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE); - selected.transfer(new TransferAction(TransferAction.RNFR, orig, new Path(dest.getPath(), orig.getName()))); - } - } - } - e.dropComplete(true); - } - else { - Cyberduck.DEBUG("[FileDropTargetListener] Data flavor unknown"); - e.rejectDrop(); - } - } - catch(java.io.IOException ioe) { - ioe.printStackTrace(); - e.rejectDrop(); - } - catch(UnsupportedFlavorException ufe) { - ufe.printStackTrace(); - e.rejectDrop(); - } - } - - public void dragEnter(DropTargetDragEvent e) { - Cyberduck.DEBUG(e.toString()); - if(e.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) - setBorder(javax.swing.BorderFactory.createLineBorder(java.awt.Color.red)); - } - public void dragExit(DropTargetEvent e) { - Cyberduck.DEBUG(e.toString()); - setBorder(null); - } - public void dragOver(DropTargetDragEvent e) { - Cyberduck.DEBUG(e.toString()); - int row = rowAtPoint(e.getLocation()); - if(row != -1) { - setRowSelectionInterval(row, row); - } - } - public void dropActionChanged(DropTargetDragEvent e) { - Cyberduck.DEBUG(e.toString()); - if(e.getDropAction() != DnDConstants.ACTION_COPY_OR_MOVE) { - e.rejectDrag(); - } - } - } - - private class DragStartListener implements DragGestureListener { - public void dragGestureRecognized(DragGestureEvent e) { - Cyberduck.DEBUG(e.toString()); - if(getSelectedRowCount() == 1) { - int row = getSelectedRow(); - int col = ListTableColumnModel.FILENAMECOLUMN; - java.awt.Rectangle bounds = getCellRect(row, col, false); - if(bounds.contains(e.getDragOrigin())) { - Path path = (Path)listModel.getEntry(row); - if (path != null) { - java.awt.Component rect = getCellRenderer(row, col).getTableCellRendererComponent( - table, - path.getName(), - true, - true, - row, - col - ); - rect.setSize(bounds.width, bounds.height); - java.awt.Image image = createImage(bounds.width, bounds.height); - java.awt.Graphics g = image.getGraphics(); - rect.paint(g); - g.dispose(); - e.startDrag(DragSource.DefaultMoveDrop, // cursor - image, - new java.awt.Point(0, 0), //offset - path, // transferable - new DragMoveListener() - ); // drag source listener - } - } - } - } - } - - private class DragMoveListener implements DragSourceListener { - public void dragDropEnd(DragSourceDropEvent e) { - Cyberduck.DEBUG(e.toString()); - if(e.getDropSuccess()) { - } - else { - } - } - public void dragExit(DragSourceEvent e) { - Cyberduck.DEBUG(e.toString()); - } - public void dragEnter(DragSourceDragEvent e) { - Cyberduck.DEBUG(e.toString()); - } - public void dragOver(DragSourceDragEvent e) { - Cyberduck.DEBUG(e.toString()); - } - public void dropActionChanged(DragSourceDragEvent e) { - Cyberduck.DEBUG(e.toString()); - } - } -} diff --git a/source/ch/cyberduck/ui/LogPanel.java b/source/ch/cyberduck/ui/LogPanel.java deleted file mode 100644 index c696c410cb..0000000000 --- a/source/ch/cyberduck/ui/LogPanel.java +++ /dev/null @@ -1,84 +0,0 @@ -package ch.cyberduck.ui; - -/* - * ch.cyberduck.ui.LogPanel.java - * Cyberduck - * - * $Header$ - * $Revision$ - * $Date$ - * - * Copyright (c) 2003 David Kocher. All rights reserved. - * http://icu.unizh.ch/~dkocher/ - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * Bug fixes, suggestions and comments should be sent to: - * dkocher@cyberduck.ch - */ - -import javax.swing.JPanel; -import javax.swing.JScrollPane; -import javax.swing.JTextArea; -import java.awt.BorderLayout; -import java.awt.FlowLayout; -import java.awt.GridLayout; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; - -import ch.cyberduck.Cyberduck; -import ch.cyberduck.connection.Log; -import ch.cyberduck.ui.common.GUIFactory; - -/** -* @version $Id$ -*/ - public class LogPanel extends JPanel implements ActionListener { - private JTextArea logField; - - public LogPanel() { - Cyberduck.DEBUG("[LogPanel]"); - setLayout(new BorderLayout()); - - JPanel log1 = new JPanel(); - log1.setLayout(new GridLayout(1, 1)); - - JPanel log2 = new JPanel(); - log2.setLayout(new FlowLayout(FlowLayout.LEFT)); - - logField = new JTextArea(); - logField.setEditable(false); - logField.setFont(GUIFactory.FONT_MONOSPACED_SMALL); - logField.setText(Log.open()); - logField.setSelectionStart(logField.getText().length()); - JScrollPane logScrollPane = new JScrollPane(logField); - logScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); - - log2.add(GUIFactory.buttonBuilder("Load", GUIFactory.FONT_NORMAL, this)); - log2.add(GUIFactory.buttonBuilder("Delete", GUIFactory.FONT_NORMAL, this)); - - log1.add(logScrollPane); - add(log1, BorderLayout.CENTER); - add(log2, BorderLayout.SOUTH); - } - public void actionPerformed(ActionEvent e) { - String source = e.getActionCommand(); - if(source.equals("Delete")) { - logField.setText(""); - Log.delete(); - } - if(source.equals("Load")) { - logField.setText(Log.open()); - logField.setSelectionStart(logField.getText().length()); - logField.revalidate(); - } - } -} diff --git a/source/ch/cyberduck/ui/LoginPanel.java b/source/ch/cyberduck/ui/LoginPanel.java deleted file mode 100644 index 1fca553efa..0000000000 --- a/source/ch/cyberduck/ui/LoginPanel.java +++ /dev/null @@ -1,145 +0,0 @@ -package ch.cyberduck.ui; - -/* - * ch.cyberduck.ui.LoginPanel.java - * Cyberduck - * - * $Header$ - * $Revision$ - * $Date$ - * - * Copyright (c) 2003 David Kocher. All rights reserved. - * http://icu.unizh.ch/~dkocher/ - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * Bug fixes, suggestions and comments should be sent to: - * dkocher@cyberduck.ch - */ - -import javax.swing.*; -import java.awt.BorderLayout; -import java.awt.FlowLayout; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.ItemEvent; -import java.awt.event.ItemListener; -import java.util.Observable; -import java.util.Observer; - -import ch.cyberduck.Cyberduck; -import ch.cyberduck.Preferences; -import ch.cyberduck.connection.Bookmark; -import ch.cyberduck.connection.Status; -import ch.cyberduck.ui.common.DummyVerifier; -import ch.cyberduck.ui.common.GUIFactory; -import ch.cyberduck.ui.layout.ParagraphLayout; - -/** -* @version $Id$ - */ -public class LoginPanel extends JPanel implements Observer { - - // The currently selected bookmark - private Bookmark selected; - - private JTextField nameField; - private JPasswordField passwdField; - private JButton loginButton; - private JButton cancelButton; - private JCheckBox anonymousCheckbox; - private JPanel parameterPanel; - - public LoginPanel() { - Cyberduck.DEBUG("[LoginPanel]"); - this.init(); - } - - public void update(Observable o, Object arg) { - if(o instanceof Bookmark) { - if(arg.equals(Bookmark.SELECTION)) { - this.selected = (Bookmark)o; - } - } - if(arg.equals(Status.LOGINPANEL)) { - this.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(javax.swing.border.EtchedBorder.LOWERED), "Login to " + selected.getHost())); - nameField.setText(Preferences.instance().getProperty("ftp.login.name")); - nameField.requestFocus(); - passwdField.setText(""); - anonymousCheckbox.setSelected(false); - } - - } - - public JButton getDefaultButton() { - return this.loginButton; - } - - private class ParameterPanel extends JPanel { - public ParameterPanel() { - super(); - this.setLayout(new ParagraphLayout()); - - // NameField - this.add(GUIFactory.labelBuilder("User ID: ", GUIFactory.FONT_SMALL), ParagraphLayout.NEW_PARAGRAPH); - this.add(nameField = GUIFactory.textFieldBuilder(GUIFactory.FONT_SMALL, new DummyVerifier())); - nameField.setColumns(30); - // PasswdField - this.add(GUIFactory.labelBuilder("Password: ", GUIFactory.FONT_SMALL), ParagraphLayout.NEW_PARAGRAPH); - this.add(passwdField = GUIFactory.passwordFieldBuilder(GUIFactory.FONT_SMALL, new DummyVerifier())); - passwdField.setColumns(30); - this.add(anonymousCheckbox = GUIFactory.checkboxBuilder("Anonymous Login", GUIFactory.FONT_SMALL, false), ParagraphLayout.NEW_LINE); - anonymousCheckbox.addItemListener(new ItemListener() { - public void itemStateChanged(ItemEvent e) { - if(e.getStateChange() == ItemEvent.SELECTED) { - nameField.setText(Preferences.instance().getProperty("ftp.login.anonymous.name")); - passwdField.setText(Preferences.instance().getProperty("ftp.login.anonymous.pass")); - } - else { - nameField.setText(""); - passwdField.setText(""); - } - } - }); - } - } - - private class ButtonPanel extends JPanel { - public ButtonPanel() { - super(); - this.setLayout(new FlowLayout(FlowLayout.RIGHT)); - this.add(cancelButton = GUIFactory.buttonBuilder("Cancel", GUIFactory.FONT_SMALL)); - cancelButton.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - selected.status.setPanelProperty(selected.status.getLastPanelProperty()); - } - }); - this.add(loginButton = GUIFactory.buttonBuilder("Login", GUIFactory.FONT_SMALL)); - loginButton.setDefaultCapable(true); - loginButton.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent ae) { - selected.setUserInfo(nameField.getText()+":"+new String(passwdField.getPassword())); - selected.transfer(); - //((Action)ActionMap.instance().get("Connect")).actionPerformed(new ActionEvent(selected, ae.getID(), ae.getActionCommand())); - } - }); - } - } - - /** - * Initialize the graphical user interface - */ - private void init() { - this.setLayout(new BorderLayout()); - this.add(new ParameterPanel(), BorderLayout.CENTER); - this.add(new ButtonPanel(), BorderLayout.SOUTH); - } -} diff --git a/source/ch/cyberduck/ui/PermissionDialog.java b/source/ch/cyberduck/ui/PermissionDialog.java deleted file mode 100644 index 846e2b7158..0000000000 --- a/source/ch/cyberduck/ui/PermissionDialog.java +++ /dev/null @@ -1,181 +0,0 @@ -package ch.cyberduck.ui; - -/* - * ch.cyberduck.ui.PermissionPanel.java - * Cyberduck - * - * $Header$ - * $Revision$ - * $Date$ - * - * Copyright (c) 2003 David Kocher. All rights reserved. - * http://icu.unizh.ch/~dkocher/ - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * Bug fixes, suggestions and comments should be sent to: - * dkocher@cyberduck.ch - */ - -import javax.swing.*; -import java.awt.BorderLayout; -import java.awt.FlowLayout; -import java.awt.event.*; - -import ch.cyberduck.Cyberduck; -import ch.cyberduck.connection.Bookmark; -import ch.cyberduck.connection.Path; -import ch.cyberduck.connection.Permission; -import ch.cyberduck.connection.TransferAction; -import ch.cyberduck.ui.common.GUIFactory; -import ch.cyberduck.ui.layout.ParagraphLayout; - -/** -* A dialog that lets change the unix file permissions of a remote file over ftp - * @see ch.cyberduck.connection.Permission - * @version $Id$ - */ -public class PermissionDialog extends JDialog implements ItemListener { - - private JCheckBox[] ownerButton = new JCheckBox[3]; - private JCheckBox[] groupButton = new JCheckBox[3]; - private JCheckBox[] otherButton = new JCheckBox[3]; - - private JPanel accessPanel; - - private Bookmark bookmark; - private Path file; - - /** - * @param b The bookmark being edited - * @param p The path to edit the permissions - */ - public PermissionDialog(Bookmark b, Path p) { - Cyberduck.DEBUG("[PermissionDialog]"); - this.bookmark = b; - this.file = p; - this.init(); - } - - private void init() { - JPanel mainPanel = new JPanel(); - mainPanel.setLayout(new BorderLayout()); - mainPanel.setBorder(BorderFactory.createEmptyBorder(12, 12, 12, 12)); - - this.setTitle(file.getName()); - this.setResizable(false); - - this.addKeyListener(new KeyAdapter() { - public void keyReleased(KeyEvent e) { - if(e.getKeyCode() == KeyEvent.VK_ESCAPE) - dispose(); - else if (e.isMetaDown() && (e.getKeyCode() == KeyEvent.VK_W)) - dispose(); - else if (e.isControlDown() && (e.getKeyCode() == KeyEvent.VK_W)) { - dispose(); - } - } - } - ); - this.addWindowListener(new WindowAdapter() { - public void windowClosing(WindowEvent e) { - dispose(); - } - } - ); - - JPanel infoPanel = GUIFactory.panelBuilder(new ParagraphLayout()); - accessPanel = GUIFactory.panelBuilder(new ParagraphLayout()); - JPanel buttonPanel = GUIFactory.panelBuilder(new FlowLayout(FlowLayout.RIGHT)); - - JLabel icon = new JLabel(); - if(file.isDirectory()) { - icon.setIcon(ch.cyberduck.ui.common.GUIFactory.FOLDER_ICON); - } - if(file.isFile()) { - icon.setIcon(ch.cyberduck.ui.common.GUIFactory.FILE_ICON); - } - infoPanel.add(icon, ParagraphLayout.NEW_PARAGRAPH); - infoPanel.add(GUIFactory.labelBuilder(file.getPath(), GUIFactory.FONT_SMALL)); - infoPanel.add(GUIFactory.labelBuilder("Size", GUIFactory.FONT_SMALL), ParagraphLayout.NEW_PARAGRAPH); - infoPanel.add(GUIFactory.labelBuilder(file.getSize(), GUIFactory.FONT_SMALL)); - infoPanel.add(GUIFactory.labelBuilder("Kind", GUIFactory.FONT_SMALL), ParagraphLayout.NEW_PARAGRAPH); - infoPanel.add(GUIFactory.labelBuilder(file.isFile() ? "File" : "Folder", GUIFactory.FONT_SMALL)); - infoPanel.add(GUIFactory.labelBuilder("Owner", GUIFactory.FONT_SMALL), ParagraphLayout.NEW_PARAGRAPH); - infoPanel.add(GUIFactory.labelBuilder(file.getOwner(), GUIFactory.FONT_SMALL)); - infoPanel.add(GUIFactory.labelBuilder("Group", GUIFactory.FONT_SMALL), ParagraphLayout.NEW_PARAGRAPH); - infoPanel.add(GUIFactory.labelBuilder(file.getGroup(), GUIFactory.FONT_SMALL)); - infoPanel.add(GUIFactory.labelBuilder("Modified", GUIFactory.FONT_SMALL), ParagraphLayout.NEW_PARAGRAPH); - infoPanel.add(GUIFactory.labelBuilder(file.getModified(), GUIFactory.FONT_SMALL)); - - Permission permission = file.getPermission(); - boolean[] ownerPerm = permission.getOwnerPermissions(); - boolean[] groupPerm = permission.getGroupPermissions(); - boolean[] otherPerm = permission.getOtherPermissions(); - - accessPanel.add(GUIFactory.labelBuilder("Owner", GUIFactory.FONT_SMALL), ParagraphLayout.NEW_PARAGRAPH); - accessPanel.add(ownerButton[Permission.READ] = GUIFactory.checkboxBuilder("Read", GUIFactory.FONT_SMALL, ownerPerm[Permission.READ], this)); - accessPanel.add(ownerButton[Permission.WRITE] = GUIFactory.checkboxBuilder("Write", GUIFactory.FONT_SMALL, ownerPerm[Permission.WRITE], this)); - accessPanel.add(ownerButton[Permission.EXECUTE] = GUIFactory.checkboxBuilder("Execute", GUIFactory.FONT_SMALL, ownerPerm[Permission.EXECUTE], this)); - - accessPanel.add(GUIFactory.labelBuilder("Group", GUIFactory.FONT_SMALL), ParagraphLayout.NEW_PARAGRAPH); - accessPanel.add(groupButton[Permission.READ] = GUIFactory.checkboxBuilder("Read", GUIFactory.FONT_SMALL, groupPerm[Permission.READ], this)); - accessPanel.add(groupButton[Permission.WRITE] = GUIFactory.checkboxBuilder("Write", GUIFactory.FONT_SMALL, groupPerm[Permission.WRITE], this)); - accessPanel.add(groupButton[Permission.EXECUTE] = GUIFactory.checkboxBuilder("Execute", GUIFactory.FONT_SMALL, groupPerm[Permission.EXECUTE], this)); - - accessPanel.add(GUIFactory.labelBuilder("Others", GUIFactory.FONT_SMALL), ParagraphLayout.NEW_PARAGRAPH); - accessPanel.add(otherButton[Permission.READ] = GUIFactory.checkboxBuilder("Read", GUIFactory.FONT_SMALL, otherPerm[Permission.READ], this)); - accessPanel.add(otherButton[Permission.WRITE] = GUIFactory.checkboxBuilder("Write", GUIFactory.FONT_SMALL, otherPerm[Permission.WRITE], this)); - accessPanel.add(otherButton[Permission.EXECUTE] = GUIFactory.checkboxBuilder("Execute", GUIFactory.FONT_SMALL, otherPerm[Permission.EXECUTE], this)); - - accessPanel.setBorder(BorderFactory.createTitledBorder("Permissions | "+file.getPermission().toString())); - buttonPanel.add(GUIFactory.buttonBuilder("Cancel", GUIFactory.FONT_SMALL, - new AbstractAction() { - public void actionPerformed(ActionEvent e) { - dispose(); - } - })); - buttonPanel.add(GUIFactory.buttonBuilder("Save", GUIFactory.FONT_SMALL, new SaveAction())); - - mainPanel.add(infoPanel, BorderLayout.NORTH); - mainPanel.add(accessPanel, BorderLayout.CENTER); - mainPanel.add(buttonPanel, BorderLayout.SOUTH); - this.getContentPane().add(mainPanel); - this.pack(); - } - - public void itemStateChanged(ItemEvent e) { - Cyberduck.DEBUG(e.paramString()); - boolean[][] p = new boolean[3][3]; - for(int k = Permission.READ; k <= Permission.EXECUTE; k++) { - p[Permission.OWNER][k] = ownerButton[k].isSelected(); - p[Permission.GROUP][k] = groupButton[k].isSelected(); - p[Permission.OTHER][k] = otherButton[k].isSelected(); - } - accessPanel.setBorder(BorderFactory.createTitledBorder("Permissions | "+new Permission(p).toString())); - } - - // ************************************************************************************************************ - - private class SaveAction extends AbstractAction { - public void actionPerformed(ActionEvent e) { - Cyberduck.DEBUG(e.paramString()); - boolean[][] p = new boolean[3][3]; - for(int k = Permission.READ; k <= Permission.EXECUTE; k++) { - p[Permission.OWNER][k] = ownerButton[k].isSelected(); - p[Permission.GROUP][k] = groupButton[k].isSelected(); - p[Permission.OTHER][k] = otherButton[k].isSelected(); - } - bookmark.transfer(new TransferAction(TransferAction.SITE, "CHMOD "+new Permission(p).getCode()+" "+file.getPath())); - dispose(); - } - } -} diff --git a/source/ch/cyberduck/ui/PreferencesPanel.java b/source/ch/cyberduck/ui/PreferencesPanel.java deleted file mode 100644 index ef8940a4b3..0000000000 --- a/source/ch/cyberduck/ui/PreferencesPanel.java +++ /dev/null @@ -1,730 +0,0 @@ -package ch.cyberduck.ui; - -/* - * ch.cyberduck.ui.PreferencesPanel.java - * Cyberduck - * - * $Header$ - * $Revision$ - * $Date$ - * - * Copyright (c) 2003 David Kocher. All rights reserved. - * http://icu.unizh.ch/~dkocher/ - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * Bug fixes, suggestions and comments should be sent to: - * dkocher@cyberduck.ch - */ - -import javax.swing.*; -import java.awt.BorderLayout; -import java.awt.FlowLayout; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.ItemEvent; -import java.awt.event.ItemListener; - -import ch.cyberduck.Cyberduck; -import ch.cyberduck.Preferences; -import ch.cyberduck.ui.action.ActionMap; -import ch.cyberduck.ui.common.DummyVerifier; -import ch.cyberduck.ui.common.GUIFactory; -import ch.cyberduck.ui.common.IntegerVerifier; -import ch.cyberduck.ui.common.PathVerifier; -import ch.cyberduck.ui.layout.ParagraphLayout; - -/** -* A panel with tabbed panes showing all user @link{Preferences} - * @see ch.cyberduck.Preferences - * @version $Id$ - */ -public class PreferencesPanel extends JPanel {//implements ItemListener { - - public PreferencesPanel() { - Cyberduck.DEBUG("[PreferencesPanel]"); - this.init(); - } - - /** - * Initialize the graphical user interface - */ - private void init() { - this.setLayout(new BorderLayout()); - JTabbedPane mainPane = new JTabbedPane(); - // tabs - JPanel tab1 = GUIFactory.panelBuilder(BoxLayout.Y_AXIS); - tab1.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); - JPanel tab2 = GUIFactory.panelBuilder(BoxLayout.Y_AXIS); - tab2.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); - JPanel tab3 = GUIFactory.panelBuilder(BoxLayout.Y_AXIS); - tab3.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); - JPanel tab4 = GUIFactory.panelBuilder(BoxLayout.Y_AXIS); - tab4.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); - JPanel tab5 = GUIFactory.panelBuilder(BoxLayout.Y_AXIS); - tab5.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); - -// JPanel generalBorder = GUIFactory.panelBuilder(BorderFactory.createTitledBorder("General")); - JPanel interfaceBorder = GUIFactory.panelBuilder(BorderFactory.createTitledBorder("Interface"));// (Needs relaunch)")); - //JPanel lafBorder = GUIFactory.panelBuilder(BorderFactory.createTitledBorder("Look and Feel")); - JPanel duplicateBorder = GUIFactory.panelBuilder(BorderFactory.createTitledBorder("Duplicate files")); - JPanel pathBorder = GUIFactory.panelBuilder(BorderFactory.createTitledBorder("Download Path")); - JPanel postProcessBorder = GUIFactory.panelBuilder(BorderFactory.createTitledBorder("Post Process (Mac only)")); -// JPanel statusBorder = GUIFactory.panelBuilder(BorderFactory.createTitledBorder("Status Display")); - JPanel loginBorder = GUIFactory.panelBuilder(BorderFactory.createTitledBorder("Login")); - JPanel connectmodeBorder = GUIFactory.panelBuilder(BorderFactory.createTitledBorder("Connect Mode")); -// JPanel transfermodeBorder = GUIFactory.panelBuilder(BorderFactory.createTitledBorder("Default Transfer Mode")); - JPanel timeoutBorder = GUIFactory.panelBuilder(BorderFactory.createTitledBorder("Timeout")); - //JPanel portBorder = GUIFactory.panelBuilder(BorderFactory.createTitledBorder("Default Port")); - JPanel defaultProtocolBorder = GUIFactory.panelBuilder(BorderFactory.createTitledBorder("Default Protocol")); - JPanel fontBorder = GUIFactory.panelBuilder(BorderFactory.createTitledBorder("Fonts")); - JPanel bufferBorder = GUIFactory.panelBuilder(BorderFactory.createTitledBorder("Buffer Size")); - //JPanel asciiTransfersBorder = GUIFactory.panelBuilder(BorderFactory.createTitledBorder("ASCII Transfers")); - JPanel soundBorder = GUIFactory.panelBuilder(BorderFactory.createTitledBorder("Sound")); - JPanel listingBorder = GUIFactory.panelBuilder(BorderFactory.createTitledBorder("Directory Listing (Needs relaunch)")); - JPanel proxyBorder = GUIFactory.panelBuilder(BorderFactory.createTitledBorder("Proxy")); - - duplicateBorder.add(new DuplicatePanel()); - pathBorder.add(new PathPanel()); - postProcessBorder.add(new PostProcessPanel()); - //statusBorder.add(new StatusPanel()); - loginBorder.add(new LoginPanel()); - connectmodeBorder.add(new ConnectModePanel()); -// transfermodeBorder.add(new TransferModePanel()); - timeoutBorder.add(new TimeoutPanel()); - //portBorder.add(new PortPanel()); - defaultProtocolBorder.add(new ProtocolPanel()); - fontBorder.add(new FontPanel()); - bufferBorder.add(new BufferPanel()); - interfaceBorder.add(new InterfacePanel()); - //lafBorder.add(new LafPanel()); - soundBorder.add(new SoundPanel()); - listingBorder.add(new ListingPanel()); - proxyBorder.add(new ProxyPanel()); - - // tab 1 // general - tab1.add(pathBorder); - tab1.add(postProcessBorder); - tab1.add(Box.createVerticalGlue()); - - tab2.add(interfaceBorder); - //tab2.add(statusBorder); - tab2.add(soundBorder); - tab2.add(fontBorder); - //tab2.add(lafBorder); - tab2.add(Box.createVerticalGlue()); - - tab3.add(duplicateBorder); - tab3.add(defaultProtocolBorder); -// tab3.add(transfermodeBorder); - tab3.add(Box.createVerticalGlue()); - - tab5.add(bufferBorder); - tab5.add(timeoutBorder); - tab5.add(proxyBorder); - tab5.add(Box.createVerticalGlue()); - - tab4.add(loginBorder); - tab4.add(connectmodeBorder); - tab4.add(listingBorder); - tab4.add(Box.createVerticalGlue()); - - mainPane.addTab("General", tab1); - mainPane.addTab("Look & Feel", tab2); - mainPane.addTab("Connection", tab3); - mainPane.addTab("Ftp", tab4); - mainPane.addTab("Advanced", tab5); - - this.add(mainPane, BorderLayout.CENTER); - JPanel bottomPanel = new JPanel(); - bottomPanel.setLayout(new FlowLayout(FlowLayout.CENTER)); - bottomPanel.add(GUIFactory.labelBuilder("Changes will take effect immediatly.", GUIFactory.FONT_SMALL)); - this.add(bottomPanel, BorderLayout.SOUTH); -} - /* - private class GeneralPanel extends JPanel { - public GeneralPanel() { - super(); - this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); - this.add(saveTableEntriesCheckbox = GUIFactory.checkboxBuilder("Save bookmarks", GUIFactory.FONT_SMALL, Preferences.instance().getProperty("table.save"), this)); - this.add(logConnectionCheckbox = GUIFactory.checkboxBuilder("Log connections", GUIFactory.FONT_SMALL, Preferences.instance().getProperty("connection.log"), this)); - this.add(encodeFilesCheckbox = GUIFactory.checkboxBuilder("Encode/Decode filenames", GUIFactory.FONT_SMALL, Preferences.instance().getProperty("files.encode"), this)); - this.add(speechCheckbox = GUIFactory.checkboxBuilder("Enable speech synthesis", GUIFactory.FONT_SMALL, Preferences.instance().getProperty("connection.log.speech"), this)); - speechCheckbox.setEnabled(false); - } - } - */ - - private class SoundPanel extends JPanel { - public SoundPanel() { - super(); - this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); - this.add(GUIFactory.checkboxBuilder("Play sound when opening connection", GUIFactory.FONT_SMALL, Preferences.instance().getProperty("status.sound.start"), new ItemListener() { - public void itemStateChanged(ItemEvent e) { - Preferences.instance().setProperty("status.sound.start", e.getStateChange() == ItemEvent.SELECTED); - } - }) - ); - - this.add(GUIFactory.checkboxBuilder("Play sound when connection is closed", GUIFactory.FONT_SMALL, Preferences.instance().getProperty("status.sound.stop"), new ItemListener() { - public void itemStateChanged(ItemEvent e) { - Preferences.instance().setProperty("status.sound.stop", e.getStateChange() == ItemEvent.SELECTED); - } - }) - ); - - this.add(GUIFactory.checkboxBuilder("Play sound when transfer is complete", GUIFactory.FONT_SMALL, Preferences.instance().getProperty("status.sound.complete"), new ItemListener() { - public void itemStateChanged(ItemEvent e) { - Preferences.instance().setProperty("status.sound.complete", e.getStateChange() == ItemEvent.SELECTED); - } - }) - ); - - } - } - - /* - private class LafPanel extends JPanel { - public LafPanel() { - super(); - this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); - JComboBox lafComboBox = new JComboBox(UIManager.getInstalledLookAndFeels()); - lafComboBox.setSelected(Preferences.instance().getProperty("laf.default")); - lafComboBox.addItemListener(new ItemListener() { - public void itemStateChanged(ItemEvent ie) { - Cyberduck.DEBUG(ie.paramString()); - if(ie.getStateChange() == ItemEvent.SELECTED) { - try { - String lafClassName = ((UIManager.LookAndFeelInfo)ie.getItem()).getClassName(); - Preferences.instance().setProperty("laf.default", lafClassName); - //UIManager.setLookAndFeel(lafClassName); - //SwingUtilities.updateComponentTreeUI(frame); - } - catch(Exception ex) { - ex.printStackTrace(); - } - } - } - } - ); - this.add(lafComboBox); - } - } - */ - - private class InterfacePanel extends JPanel { - public InterfacePanel() { - super(); - this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); - ButtonGroup windowModeGroup = new ButtonGroup(); - JPanel windowModePanel = GUIFactory.panelBuilder(new java.awt.GridLayout(2, 2)); - boolean multiplewindow = (Preferences.instance().getProperty("interface.multiplewindow")).equals("true"); - // windowModePanel.add(GUIFactory.labelBuilder(Cyberduck.getIcon(Cyberduck.getResource(this.getClass(), "singlewindow.jpg")))); - // windowModePanel.add(GUIFactory.labelBuilder(Cyberduck.getIcon(Cyberduck.getResource(this.getClass(), "multiplewindow.jpg")))); - this.add(GUIFactory.radiobuttonBuilder(windowModeGroup, "Single Window Mode", GUIFactory.FONT_SMALL, !multiplewindow, new ItemListener() { - public void itemStateChanged(ItemEvent e) { - Preferences.instance().setProperty("interface.multiplewindow", !(e.getStateChange() == ItemEvent.SELECTED)); - if(e.getStateChange() == ItemEvent.SELECTED) - ((Action)ActionMap.instance().get("Reconfigure Interface")).actionPerformed(new ActionEvent(this, ActionEvent.ACTION_PERFORMED, e.paramString())); - - } - }) - ); - this.add(GUIFactory.radiobuttonBuilder(windowModeGroup, "Multiple Window Mode", GUIFactory.FONT_SMALL, multiplewindow, new ItemListener() { - public void itemStateChanged(ItemEvent e) { - Preferences.instance().setProperty("interface.multiplewindow", e.getStateChange() == ItemEvent.SELECTED); - if(e.getStateChange() == ItemEvent.SELECTED) - ((Action)ActionMap.instance().get("Reconfigure Interface")).actionPerformed(new ActionEvent(this, ActionEvent.ACTION_PERFORMED, e.paramString())); - } - }) - ); - this.add(windowModePanel); - this.add(Box.createVerticalStrut(10)); - this.add(GUIFactory.checkboxBuilder("Show error dialogs", GUIFactory.FONT_SMALL, Preferences.instance().getProperty("interface.error-dialog"), new ItemListener() { - public void itemStateChanged(ItemEvent e) { - Preferences.instance().setProperty("interface.error-dialog", e.getStateChange() == ItemEvent.SELECTED); - } - }) - ); - } - } - - private class FontPanel extends JPanel { - public FontPanel() { - super(); - this.setLayout(new FlowLayout(FlowLayout.LEFT)); - this.add(GUIFactory.labelBuilder("Small font size: ", GUIFactory.FONT_SMALL)); - String[] fontsizes = {"8", "9", "10", "11", "12", "13", "14"}; - final JComboBox smallfontCombo; - this.add(smallfontCombo = GUIFactory.comboBuilder(fontsizes, Preferences.instance().getProperty("font.small"), GUIFactory.FONT_SMALL)); - smallfontCombo.addItemListener(new ItemListener() { - public void itemStateChanged(ItemEvent e) { - Preferences.instance().setProperty("font.small", (String)smallfontCombo.getSelectedItem()); - } - }); - - this.add(GUIFactory.labelBuilder("Normal font size: ", GUIFactory.FONT_SMALL)); - final JComboBox normalfontCombo; - this.add(normalfontCombo = GUIFactory.comboBuilder(fontsizes, Preferences.instance().getProperty("font.normal"), GUIFactory.FONT_SMALL)); - normalfontCombo.addItemListener(new ItemListener() { - public void itemStateChanged(ItemEvent e) { - if(e.getStateChange() == ItemEvent.SELECTED) - Preferences.instance().setProperty("font.normal", (String)normalfontCombo.getSelectedItem()); - } - }); - } - } - - private class DuplicatePanel extends JPanel { - public DuplicatePanel() { - super(); - this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); - ButtonGroup filenameRadioGroup = new ButtonGroup(); - this.add(GUIFactory.radiobuttonBuilder(filenameRadioGroup, "Ask me what to do", GUIFactory.FONT_SMALL, Preferences.instance().getProperty("duplicate.ask"), new ItemListener() { - public void itemStateChanged(ItemEvent e) { - Preferences.instance().setProperty("duplicate.ask", e.getStateChange() == ItemEvent.SELECTED); - } - }) - ); - - this.add(GUIFactory.radiobuttonBuilder(filenameRadioGroup, "Overwrite existing file", GUIFactory.FONT_SMALL, Preferences.instance().getProperty("duplicate.overwrite"), new ItemListener() { - public void itemStateChanged(ItemEvent e) { - Preferences.instance().setProperty("duplicate.overwrite", e.getStateChange() == ItemEvent.SELECTED); - } - }) - ); - this.add(GUIFactory.radiobuttonBuilder(filenameRadioGroup, "Use new but similar name", GUIFactory.FONT_SMALL, Preferences.instance().getProperty("duplicate.similar"), new ItemListener() { - public void itemStateChanged(ItemEvent e) { - Preferences.instance().setProperty("duplicate.similar", e.getStateChange() == ItemEvent.SELECTED); - } - }) - ); - this.add(GUIFactory.radiobuttonBuilder(filenameRadioGroup, "Resume transfer if possible", GUIFactory.FONT_SMALL, Preferences.instance().getProperty("duplicate.resume"), new ItemListener() { - public void itemStateChanged(ItemEvent e) { - Preferences.instance().setProperty("duplicate.resume", e.getStateChange() == ItemEvent.SELECTED); - } - }) - ); - } - } - - /* - private class StatusPanel extends JPanel { - public StatusPanel() { - super(); - this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); - this.add(showLocalPathCheckbox = GUIFactory.checkboxBuilder("Show local path", GUIFactory.FONT_SMALL, Preferences.instance().getProperty("statuspanel.localpath"), this)); - this.add(showTranscriptCheckbox = GUIFactory.checkboxBuilder("Show transcript messages", GUIFactory.FONT_SMALL, Preferences.instance().getProperty("statuspanel.transcriptmessage"), this)); - this.add(showProgressCheckbox = GUIFactory.checkboxBuilder("Show progress messages", GUIFactory.FONT_SMALL, Preferences.instance().getProperty("statuspanel.progressmessage"), this)); - this.add(showStatusCheckbox = GUIFactory.checkboxBuilder("Show status messages", GUIFactory.FONT_SMALL, Preferences.instance().getProperty("statuspanel.statusmessage"), this)); - this.add(showTranscriptCheckbox = GUIFactory.checkboxBuilder("Show transcript messages", GUIFactory.FONT_SMALL, Preferences.instance().getProperty("statuspanel.transcriptmessage"), this)); - } - } - */ - - private class ProtocolPanel extends JPanel { - public ProtocolPanel() { - super(); - this.setLayout(new FlowLayout(FlowLayout.LEFT)); - ButtonGroup protocolRadioGroup = new ButtonGroup(); - this.add(GUIFactory.radiobuttonBuilder(protocolRadioGroup, "SFTP", GUIFactory.FONT_SMALL, Preferences.instance().getProperty("connection.protocol.default").equals("sftp"), new ItemListener() { - public void itemStateChanged(ItemEvent e) { - if(e.getStateChange() == ItemEvent.SELECTED) - Preferences.instance().setProperty("connection.protocol.default", "sftp"); - } - }) - ); - this.add(GUIFactory.radiobuttonBuilder(protocolRadioGroup, "HTTP", GUIFactory.FONT_SMALL, Preferences.instance().getProperty("connection.protocol.default").equals("http"), new ItemListener() { - public void itemStateChanged(ItemEvent e) { - if(e.getStateChange() == ItemEvent.SELECTED) - Preferences.instance().setProperty("connection.protocol.default", "http"); - } - }) - ); - this.add(GUIFactory.radiobuttonBuilder(protocolRadioGroup, "FTP", GUIFactory.FONT_SMALL, Preferences.instance().getProperty("connection.protocol.default").equals("ftp"), new ItemListener() { - public void itemStateChanged(ItemEvent e) { - if(e.getStateChange() == ItemEvent.SELECTED) - Preferences.instance().setProperty("connection.protocol.default", "ftp"); - } - }) - ); - } - } - - private class ProxyPanel extends JPanel { - public ProxyPanel() { - super(); - this.setLayout(new ParagraphLayout()); - this.add(GUIFactory.checkboxBuilder("Use proxy", GUIFactory.FONT_SMALL, Preferences.instance().getProperty("connection.proxy"), new ItemListener() { - public void itemStateChanged(ItemEvent e) { - Preferences.instance().setProperty("connection.proxy", e.getStateChange() == ItemEvent.SELECTED); - } - }), ParagraphLayout.NEW_PARAGRAPH); - this.add(GUIFactory.textFieldBuilder(Preferences.instance().getProperty("connection.proxy.host"), GUIFactory.FONT_SMALL, 20, new DummyVerifier("connection.proxy.host"))); - this.add(GUIFactory.labelBuilder("Host", GUIFactory.FONT_SMALL)); - this.add(GUIFactory.textFieldBuilder(Preferences.instance().getProperty("connection.proxy.port"), GUIFactory.FONT_SMALL, 20, new IntegerVerifier("connection.proxy.port")), ParagraphLayout.NEW_LINE); - this.add(GUIFactory.labelBuilder("Port", GUIFactory.FONT_SMALL)); - this.add(GUIFactory.checkboxBuilder("Authentication", GUIFactory.FONT_SMALL, Preferences.instance().getProperty("connection.proxy.authenticate"), new ItemListener() { - public void itemStateChanged(ItemEvent e) { - Preferences.instance().setProperty("connection.proxy.authenticate", e.getStateChange() == ItemEvent.SELECTED); - } - }), ParagraphLayout.NEW_PARAGRAPH); - this.add(GUIFactory.textFieldBuilder(Preferences.instance().getProperty("connection.proxy.username"), GUIFactory.FONT_SMALL, 20, new DummyVerifier("connection.proxy.username"))); - this.add(GUIFactory.labelBuilder("User", GUIFactory.FONT_SMALL)); - this.add(GUIFactory.textFieldBuilder(Preferences.instance().getProperty("connection.proxy.password"), GUIFactory.FONT_SMALL, 20, new DummyVerifier("connection.proxy.password")), ParagraphLayout.NEW_LINE); - this.add(GUIFactory.labelBuilder("Password", GUIFactory.FONT_SMALL)); - } - } - - private class TimeoutPanel extends JPanel { - public TimeoutPanel() { - super(); - this.setLayout(new FlowLayout(FlowLayout.LEFT)); - final JTextField timeoutField = GUIFactory.textFieldBuilder(Preferences.instance().getProperty("connection.timeout"), GUIFactory.FONT_SMALL, new IntegerVerifier("connection.timeout")); - this.add(GUIFactory.labelBuilder("Timeout after ", GUIFactory.FONT_SMALL)); - this.add(timeoutField); - this.add(GUIFactory.labelBuilder(" minutes.", GUIFactory.FONT_SMALL)); - JButton defaultTimeoutButton = GUIFactory.buttonBuilder("Default", GUIFactory.FONT_SMALL); - defaultTimeoutButton.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - timeoutField.setText(Preferences.instance().getProperty("connection.timeout.default")); - } - }); - this.add(defaultTimeoutButton); - } - } - - private class BufferPanel extends JPanel { - public BufferPanel() { - super(); - this.setLayout(new FlowLayout(FlowLayout.LEFT)); - String[] buffersizes = {"1024", "2048", "4096", "8192"}; - final JComboBox bufferSizeCombo; - this.add(bufferSizeCombo = GUIFactory.comboBuilder(buffersizes, Preferences.instance().getProperty("connection.buffer"), GUIFactory.FONT_SMALL)); - bufferSizeCombo.setEditable(true); - bufferSizeCombo.setInputVerifier(new IntegerVerifier("connection.buffer")); - bufferSizeCombo.addItemListener(new ItemListener() { - public void itemStateChanged(ItemEvent e) { - Preferences.instance().setProperty("connection.buffer", (String)bufferSizeCombo.getSelectedItem()); - } - } - ); - } - } - - private class TransferModePanel extends JPanel { - public TransferModePanel() { - super(); - this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); - ButtonGroup downloadModeGroup = new ButtonGroup(); - //transfermodePanel.add(autoRadio = GUIFactory.radiobuttonBuilder(downloadModeGroup, "Auto", GUIFactory.FONT_SMALL, Preferences.instance().getProperty("connection.transfertype.default").equals("auto"), this)); - this.add(GUIFactory.radiobuttonBuilder(downloadModeGroup, "Binary", GUIFactory.FONT_SMALL, Preferences.instance().getProperty("connection.transfertype.default").equals("binary"), new ItemListener() { - public void itemStateChanged(ItemEvent e) { - if(e.getStateChange() == ItemEvent.SELECTED) - Preferences.instance().setProperty("connection.transfertype.default", "binary"); - } - }) - ); - this.add(GUIFactory.radiobuttonBuilder(downloadModeGroup, "ASCII", GUIFactory.FONT_SMALL, Preferences.instance().getProperty("connection.transfertype.default").equals("ascii"), new ItemListener() { - public void itemStateChanged(ItemEvent e) { - if(e.getStateChange() == ItemEvent.SELECTED) - Preferences.instance().setProperty("connection.transfertype.default", "ascii"); - } - }) - ); - - } - } - - private class PathPanel extends JPanel { - public PathPanel() { - super(); - this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); - JLabel errorLabel = GUIFactory.labelBuilder("The path does not exist.", GUIFactory.FONT_SMALL); - errorLabel.setVisible(false); - final JTextField pathField = GUIFactory.textFieldBuilder(Preferences.instance().getProperty("download.path"), GUIFactory.FONT_SMALL, new PathVerifier(errorLabel, "download.path")); - // pathField.selectAll(); - // pathField.setColumns(15); - JButton defaultDownloadLocation = GUIFactory.buttonBuilder("Default", GUIFactory.FONT_SMALL, new ActionListener() { - public void actionPerformed(ActionEvent e) { - pathField.setText(System.getProperty("user.dir") + "/"); - Preferences.instance().setProperty("download.path", pathField.getText() + "/"); - } - } - ); - JButton selectDownloadLocation = GUIFactory.buttonBuilder("Select...", GUIFactory.FONT_SMALL, new ActionListener() { - public void actionPerformed(ActionEvent e) { - java.awt.FileDialog chooser = new java.awt.FileDialog(new java.awt.Frame(), "Select Download Location", java.awt.FileDialog.LOAD); - chooser.setTitle("Select Download Location:"); - chooser.setDirectory(System.getProperty("user.home")); - chooser.setVisible(true); - String resultPath = chooser.getDirectory(); - if(resultPath != null) { - java.io.File file = new java.io.File(resultPath); - if(file != null) { - pathField.setText(file.getPath()); - Preferences.instance().setProperty("download.path", pathField.getText()); - } - } - } - } - ); - JPanel path1 = new JPanel(); - path1.setLayout(new FlowLayout(FlowLayout.LEFT)); - path1.add(pathField); - path1.add(defaultDownloadLocation); - path1.add(selectDownloadLocation); - JPanel path2 = new JPanel(); - path2.setLayout(new FlowLayout(FlowLayout.LEFT)); - path2.add(errorLabel); - this.add(path1); - this.add(path2); - } - } - - private class PostProcessPanel extends JPanel { - public PostProcessPanel() { - super(); - this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); - this.add(GUIFactory.checkboxBuilder("Post-process files after downloading", GUIFactory.FONT_SMALL, Preferences.instance().getProperty("files.postprocess"), new ItemListener() { - public void itemStateChanged(ItemEvent e) { - Preferences.instance().setProperty("files.postprocess", e.getStateChange() == ItemEvent.SELECTED); - } - }) - ); - } - } - - private class LoginPanel extends JPanel { - public LoginPanel() { - super(); - this.setLayout(new FlowLayout(FlowLayout.LEFT)); - this.add(GUIFactory.labelBuilder("Email for anonymous login: ", GUIFactory.FONT_SMALL)); - // this.add(Box.createVerticalStrut(5)); - this.add(GUIFactory.textFieldBuilder(Preferences.instance().getProperty("ftp.login.anonymous.pass"), GUIFactory.FONT_SMALL, new DummyVerifier("ftp.login.anonymous.pass"))); - } - } - - private class ConnectModePanel extends JPanel { - public ConnectModePanel() { - super(); - this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); - ButtonGroup connectModeGroup = new ButtonGroup(); - this.add(GUIFactory.radiobuttonBuilder(connectModeGroup, "Passive (PASV)", GUIFactory.FONT_SMALL, Preferences.instance().getProperty("ftp.passive"),new ItemListener() { - public void itemStateChanged(ItemEvent e) { - Preferences.instance().setProperty("ftp.passive", e.getStateChange() == ItemEvent.SELECTED); - } - }) - ); - this.add(GUIFactory.radiobuttonBuilder(connectModeGroup, "Active", GUIFactory.FONT_SMALL, Preferences.instance().getProperty("ftp.active"), new ItemListener() { - public void itemStateChanged(ItemEvent e) { - Preferences.instance().setProperty("ftp.active", e.getStateChange() == ItemEvent.SELECTED); - } - }) - ); - } - } - - private class ListingPanel extends JPanel { - public ListingPanel() { - super(); - this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); - this.add(GUIFactory.checkboxBuilder("Show files beginning with '.'", GUIFactory.FONT_SMALL, Preferences.instance().getProperty("ftp.showHidden"), new ItemListener() { - public void itemStateChanged(ItemEvent e) { - Preferences.instance().setProperty("ftp.showHidden", e.getStateChange() == ItemEvent.SELECTED); - } - }) - ); - - this.add(Box.createVerticalStrut(10)); - this.add(GUIFactory.labelBuilder("Show the following columns in listings:", GUIFactory.FONT_SMALL)); - this.add(Box.createVerticalStrut(5)); - this.add(GUIFactory.checkboxBuilder("Icon (Folder or File)", GUIFactory.FONT_SMALL, Preferences.instance().getProperty("ftp.listing.showType"), new ItemListener() { - public void itemStateChanged(ItemEvent e) { - Preferences.instance().setProperty("ftp.listing.showType", e.getStateChange() == ItemEvent.SELECTED); - } - }) - ); - - this.add(GUIFactory.checkboxBuilder("Filenames", GUIFactory.FONT_SMALL, Preferences.instance().getProperty("ftp.listing.showFilenames"), new ItemListener() { - public void itemStateChanged(ItemEvent e) { - Preferences.instance().setProperty("ftp.listing.showFilenames", e.getStateChange() == ItemEvent.SELECTED); - } - }) - ); - - this.add(GUIFactory.checkboxBuilder("Size", GUIFactory.FONT_SMALL, Preferences.instance().getProperty("ftp.listing.showSize"), new ItemListener() { - public void itemStateChanged(ItemEvent e) { - Preferences.instance().setProperty("ftp.listing.showSize", e.getStateChange() == ItemEvent.SELECTED); - } - }) - ); - - this.add(GUIFactory.checkboxBuilder("Modification Date", GUIFactory.FONT_SMALL, Preferences.instance().getProperty("ftp.listing.showDate"), new ItemListener() { - public void itemStateChanged(ItemEvent e) { - Preferences.instance().setProperty("ftp.listing.showDate", e.getStateChange() == ItemEvent.SELECTED); - } - }) - ); - - this.add(GUIFactory.checkboxBuilder("Owner", GUIFactory.FONT_SMALL, Preferences.instance().getProperty("ftp.listing.showOwner"), new ItemListener() { - public void itemStateChanged(ItemEvent e) { - Preferences.instance().setProperty("ftp.listing.showOwner", e.getStateChange() == ItemEvent.SELECTED); - } - }) - ); - this.add(GUIFactory.checkboxBuilder("Access rights", GUIFactory.FONT_SMALL, Preferences.instance().getProperty("ftp.listing.showAccess"), new ItemListener() { - public void itemStateChanged(ItemEvent e) { - Preferences.instance().setProperty("ftp.listing.showAccess", e.getStateChange() == ItemEvent.SELECTED); - } - }) - ); - } - } - - /* - private class PortPanel extends JPanel { - public PortPanel() { - super(); - this.setLayout(new FlowLayout(FlowLayout.LEFT)); - this.add(GUIFactory.labelBuilder("Connect to port number: ", GUIFactory.FONT_SMALL)); - this.add(GUIFactory.textFieldBuilder(Preferences.instance().getProperty("ftp.port.default"), GUIFactory.FONT_SMALL, new IntegerVerifier("ftp.port.default"))); - } - } - */ -} - - // ************************************************************************************************************ -/* - public void itemStateChanged(ItemEvent event) { -// Cyberduck.DEBUG("[PreferencesPanel] itemStateChanged()"); - Object source = event.getSource(); - boolean selected = (event.getStateChange() == ItemEvent.SELECTED); - if(source instanceof JRadioButton) { - if (source == passivemodeRadio) - Preferences.instance().setProperty("ftp.passive", selected); - else if (source == activemodeRadio) - Preferences.instance().setProperty("ftp.active", selected); - */ - /* - else if (source == autoRadio) - Preferences.instance().setProperty("connection.transfertype.default", "auto"); - */ - /* - else if (source == asciiRadio) - Preferences.instance().setProperty("connection.transfertype.default", "ascii"); - else if (source == binaryRadio) - Preferences.instance().setProperty("connection.transfertype.default", "binary"); - */ - /* - else if (source == askMeRadio) - Preferences.instance().setProperty("duplicate.ask", selected); - else if (source == overwriteRadio) - Preferences.instance().setProperty("duplicate.overwrite", selected); - else if (source == similarNameRadio) - Preferences.instance().setProperty("duplicate.similar", selected); - else if (source == resumeRadio) - Preferences.instance().setProperty("duplicate.resume", selected); - */ - /* - else if (source == httpRadio) { - if(selected) - Preferences.instance().setProperty("connection.protocol.default", "http"); - } - else if (source == ftpRadio) { - if(selected) - Preferences.instance().setProperty("connection.protocol.default", "ftp"); - } - */ - //} - /* - if(source instanceof JComboBox) { - JComboBox combo = (JComboBox)source;*/ -/* - if (source == normalfontCombo) - Preferences.instance().setProperty("font.normal", (String)combo.getSelectedItem()); - else if (source == smallfontCombo) - Preferences.instance().setProperty("font.small", (String)combo.getSelectedItem()); - */ -/* else if (source == bufferSizeCombo) - Preferences.instance().setProperty("connection.buffer", (String)combo.getSelectedItem());*/ - /* - - else if (source == startSoundCombo) - Preferences.instance().setProperty("sound.sound.start", (String)startSoundCombo.getSelectedItem()); - else if (source == stopSoundCombo) - Preferences.instance().setProperty("sound.sound.stop", (String)stopSoundCombo.getSelectedItem()); - else if (source == completeSoundCombo) - Preferences.instance().setProperty("sound.sound.complete", (String)completeSoundCombo.getSelectedItem()); - */ - /* - } - else if(source instanceof JCheckBox) {*/ - /* - if(source == errorDialogCheckbox) - Preferences.instance().setProperty("interface.error-dialog", selected); - */ - /* - if (source == startSound) - Preferences.instance().setProperty("status.sound.start", selected); - else if (source == stopSound) - Preferences.instance().setProperty("status.sound.stop", selected); - else if (source == completeSound) - Preferences.instance().setProperty("status.sound.complete", selected); - */ - - /* - else if (source == saveTableEntriesCheckbox) - Preferences.instance().setProperty("table.save", selected); - */ - /* - else if (source == encodeFilesCheckbox) - Preferences.instance().setProperty("files.encode", selected); - */ - /* - else if (source == showHiddenCheckbox) - Preferences.instance().setProperty("ftp.showHidden", selected); - else if (source == postProcessCheckbox) - Preferences.instance().setProperty("files.postprocess", selected); -*/ - /* - else if (source == logConnectionCheckbox) - Preferences.instance().setProperty("connection.log", selected); - */ - - /* - else if (source == showTranscriptCheckbox) - Preferences.instance().setProperty("statuspanel.transcriptmessage", selected); - else if (source == showProgressCheckbox) - Preferences.instance().setProperty("statuspanel.progressmessage", selected); - else if (source == showLocalPathCheckbox) - Preferences.instance().setProperty("statuspanel.localpath", selected); - */ - /* - else if (source == proxyCheckbox) - Preferences.instance().setProperty("connection.proxy", selected); - else if (source == proxyAuthCheckbox) - Preferences.instance().setProperty("connection.proxy.authenticate", selected); - */ -/* - else if (source == listing_Type) - Preferences.instance().setProperty("ftp.listing.showType", selected); - else if (source == listing_Filenames) - Preferences.instance().setProperty("ftp.listing.showFilenames", selected); - else if (source == listing_Size) - Preferences.instance().setProperty("ftp.listing.showSize", selected); - else if (source == listing_Date) - Preferences.instance().setProperty("ftp.listing.showDate", selected); - else if (source == listing_Owner) - Preferences.instance().setProperty("ftp.listing.showOwner", selected); - else if (source == listing_Access) - Preferences.instance().setProperty("ftp.listing.showAccess", selected); - */ diff --git a/source/ch/cyberduck/ui/ProgressPanel.java b/source/ch/cyberduck/ui/ProgressPanel.java deleted file mode 100644 index 3e29e3f331..0000000000 --- a/source/ch/cyberduck/ui/ProgressPanel.java +++ /dev/null @@ -1,311 +0,0 @@ -package ch.cyberduck.ui; - -/* - * ch.cyberduck.ui.ProgressPanel.java - * Cyberduck - * - * $Header$ - * $Revision$ - * $Date$ - * - * Copyright (c) 2003 David Kocher. All rights reserved. - * http://icu.unizh.ch/~dkocher/ - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * Bug fixes, suggestions and comments should be sent to: - * dkocher@cyberduck.ch - */ - -import javax.swing.*; -import java.awt.Dimension; -import java.awt.BorderLayout; -import java.awt.FlowLayout; -import java.awt.event.ActionEvent; -import java.util.Observable; -import java.util.Observer; - -import ch.cyberduck.Cyberduck; -import ch.cyberduck.connection.Bookmark; -import ch.cyberduck.connection.Status; -import ch.cyberduck.ui.common.DraggableLabel; -import ch.cyberduck.ui.common.GUIFactory; - -/** - * The ProgressPanel is the stanard detailed view of a bookmark displayed - * in the bottom of the app's splitpane. - * It contains a progressbar and labels with URL and local path - * Must be registered to the BookmarkPanel as an Observer to be notified about - * a bookmark's status - * @version $Id$ - */ -public class ProgressPanel extends JPanel implements Observer { - private Bookmark selected; - - private JButton connectButton; - private JLabel labelb; - private JLabel labelc; - private JLabel percentLabel; - private JLabel progressLabel; - private JProgressBar progressBar; - private Action connectAction, stopAction; - - private JPanel paramPanel, buttonPanel; - - public ProgressPanel() { - Cyberduck.DEBUG("[ProgressPanel]"); - this.init(); - } - - public void update(Observable o, Object argument) { - if(o instanceof Bookmark) { - if(argument.equals(Bookmark.SELECTION)) { - this.selected = (Bookmark)o; - this.refresh(); - } - } - if(o instanceof Status) { - if (argument.equals(Status.CURRENT)) { - this.progressBar.setModel(selected.status.getProgressModel()); - this.percentLabel.setText((int)(progressBar.getPercentComplete()*100) + "% "); - this.progressLabel.setText(selected.status.getMessage(Status.DATA)); - } - else if (argument.equals(Status.PROGRESS)) { - this.progressLabel.setText(selected.status.getMessage(Status.DATA)); - } - else { //@todo - this.refresh(); - } - } - ((Observer)connectAction).update(o, argument); - ((Observer)stopAction).update(o, argument); - } - - public JButton getDefaultButton() { - return this.connectButton; - } - - /** - * Update labels and progressbar with informations of the currently - * selected bookmark - */ - private void refresh() { - progressBar.setModel(selected.status.getProgressModel()); - - labelb.setText(selected.getAddressAsString()); - labelc.setText("Local: " + selected.getLocalPathAsString()); - percentLabel.setText((int)(progressBar.getPercentComplete()*100) + "% "); - progressLabel.setText(selected.status.getMessage(Status.DATA)); - labelc.setVisible(selected.isDownload()); - progressLabel.setVisible(selected.isDownload()); - } - - private class ParameterPanel extends JPanel { - public ParameterPanel() { - super(); - this.init(); - } - private void init() { - this.setLayout(new BorderLayout()); - JPanel barPanel = new JPanel(); - barPanel.setLayout(new FlowLayout(FlowLayout.LEFT)); - progressBar = new JProgressBar(0, 1); - progressBar.setStringPainted(false); - progressBar.setBorderPainted(true); - barPanel.add(progressBar); - barPanel.add(percentLabel = GUIFactory.labelBuilder("", GUIFactory.FONT_SMALL)); - - JPanel labelPanel = new JPanel(); - labelPanel.setLayout(new FlowLayout(FlowLayout.LEFT)); - - Box labelBox = new Box(BoxLayout.Y_AXIS); - //labelBox.add(labela = new DraggableLabel("", GUIFactory.FONT_SMALL)); - labelBox.add(labelb = new DraggableLabel("", GUIFactory.FONT_SMALL)); - labelBox.add(labelc = GUIFactory.labelBuilder("", GUIFactory.FONT_SMALL)); - labelBox.add(progressLabel = GUIFactory.labelBuilder("", GUIFactory.FONT_SMALL)); - labelPanel.add(labelBox); - - this.add(labelPanel, BorderLayout.CENTER); - this.add(barPanel, BorderLayout.SOUTH); - } - } - - - private class ButtonPanel extends JPanel { - public ButtonPanel() { - super(); - this.init(); - } - private void init() { - this.setLayout(new FlowLayout(FlowLayout.RIGHT)); - this.add(GUIFactory.buttonBuilder(GUIFactory.FONT_SMALL, stopAction = new StopAction())); - this.add(connectButton = GUIFactory.buttonBuilder(GUIFactory.FONT_SMALL, connectAction = new ConnectAction())); - } - public Dimension getMinimumSize() { - return new Dimension(super.getMinimumSize().width, 80); - } - } - - /** - * Initialize the graphical user interface - */ - private void init() { - this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); - this.add(paramPanel = new ParameterPanel()); - this.add(buttonPanel = new ButtonPanel()); - } - - /* - public java.awt.Dimension getMinimumSize() { - int h = (int)paramPanel.getMinimumSize().height + (int)buttonPanel.getMinimumSize().height; - int w = (int)super.getMinimumSize().width; - java.awt.Dimension d = new java.awt.Dimension(w, h); -// java.awt.Dimension d = new java.awt.Dimension((int)super.getMinimumSize().width, 150); - Cyberduck.DEBUG("[ProgressPanel] getMinimumSize():" + d.toString()); - return d; - } - */ - - // ************************************************************************************************************ - - private class ConnectAction extends AbstractAction implements java.util.Observer { - public ConnectAction() { - this("Connect"); - } - - public ConnectAction(String label) { - super(label); - this.putValue(SHORT_DESCRIPTION, "Connect to remote host"); - this.setEnabled(false); - //ActionMap.instance().put(this.getValue(NAME), this); - } - - public void actionPerformed(ActionEvent ae) { - selected.transfer(); - } - - public void update(java.util.Observable o, Object arg) { - if (arg.equals(Status.ACTIVE) || - arg.equals(Status.STOP) || - arg.equals(Status.COMPLETE) || - arg.equals(Bookmark.SELECTION)) - { - String name = "Connect"; - if(selected.isDownload()) { - if(selected.getHandler().equals(Status.RELOAD)) - name = "Reload"; - if(selected.getHandler().equals(Status.RESUME)) - name = "Resume"; - if(selected.getHandler().equals(Status.INITIAL)) - name = "Download"; - } - if(selected.isListing()) { - if(selected.getHandler().equals(Status.RELOAD)) - name = "Refresh"; - else - name = "Connect"; - } - this.putValue(NAME, name); - this.setEnabled(selected.isValid() && selected.status.isStopped()); - } - } - } - - - private class StopAction extends AbstractAction implements java.util.Observer { - public StopAction() { - this("Stop"); - } - - public StopAction(String label) { - super(label); - this.putValue(SHORT_DESCRIPTION, "Stop transfer"); - //this.putValue(SMALL_ICON, Cyberduck.getIcon(Cyberduck.getResource("stop_small.gif"))); - this.setEnabled(false); - //ActionMap.instance().put(this.getValue(NAME), this); - } - - public void actionPerformed(ActionEvent ae) { - Cyberduck.DEBUG(ae.paramString()); - selected.status.setCanceled(true); - - //((Action)ActionMap.instance().get("Stop")).actionPerformed(new ActionEvent(selected, ae.getID(), ae.getActionCommand())); - } - - public void update(java.util.Observable o, Object arg) { - if (arg.equals(Status.ACTIVE) || - arg.equals(Status.STOP) || - arg.equals(Status.COMPLETE) || - arg.equals(Bookmark.SELECTION)) - { - //this.putValue(NAME, "Stop"); - this.setEnabled(!selected.status.isStopped()); - } - } - } - -/* - private class EditAction extends AbstractAction implements java.util.Observer { - public EditAction() { - this("Edit"); - } - public EditAction(String label) { - super(label); - this.putValue(SHORT_DESCRIPTION, "Edit bookmark"); - this.setEnabled(false); - //ActionMap.instance().put(this.getValue(NAME), this); - } - - public void actionPerformed(ActionEvent ae) { - Cyberduck.DEBUG(ae.paramString()); - selected.edit(); - } - - public void update(java.util.Observable o, Object arg) { - if (arg.equals(Status.ACTIVE) || - arg.equals(Status.STOP) || - arg.equals(Status.COMPLETE) || - arg.equals(Bookmark.SELECTION)) - { - this.setEnabled(selected.status.isStopped()); - } - } - } - */ - -/* - private class ShowInFinderAction extends javax.swing.AbstractAction implements java.util.Observer { - public ShowInFinderAction() { - super("Reveal In Finder"); - this.putValue(SHORT_DESCRIPTION, "Show file in Finder (Mac only)"); - this.setEnabled(System.getProperty("os.name").indexOf("Mac") != -1); - //ActionMap.instance().put(this.getValue(NAME), this); - } - - public void actionPerformed(ActionEvent ae) { - Cyberduck.DEBUG(ae.paramString()); - try { - com.apple.mrj.MRJFileUtils.openURL("file://" + selected.getLocalDirectory()); - } - catch(java.io.IOException e) { - e.printStackTrace(); - } - } - - public void update(java.util.Observable o, Object arg) { - if(arg.equals(Bookmark.SELECTION)) { - boolean macos = System.getProperty("os.name").indexOf("Mac OS") != -1; - this.setEnabled(((Bookmark)o).isDownload() && macos); - } - } - } - */ -} diff --git a/source/ch/cyberduck/ui/StatusPanel.java b/source/ch/cyberduck/ui/StatusPanel.java deleted file mode 100644 index 23d1c62af3..0000000000 --- a/source/ch/cyberduck/ui/StatusPanel.java +++ /dev/null @@ -1,280 +0,0 @@ -package ch.cyberduck.ui; - -/* - * ch.cyberduck.ui.StatusPanel.java - * Cyberduck - * - * $Header$ - * $Revision$ - * $Date$ - * - * Copyright (c) 2003 David Kocher. All rights reserved. - * http://icu.unizh.ch/~dkocher/ - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * Bug fixes, suggestions and comments should be sent to: - * dkocher@cyberduck.ch - */ - -import javax.swing.BorderFactory; -import javax.swing.JLabel; -import javax.swing.JDialog; -import javax.swing.JPanel; -import javax.swing.JTabbedPane; -import javax.swing.JSplitPane; -import javax.swing.JFrame; -import javax.swing.JComponent; -import java.awt.Container; -import java.awt.BorderLayout; -import java.awt.GridLayout; -import java.awt.CardLayout; -import java.awt.Dimension; -import java.util.Observable; -import java.util.Observer; - -import ch.cyberduck.Cyberduck; -import ch.cyberduck.connection.Bookmark; -import ch.cyberduck.connection.Status; -import ch.cyberduck.ui.common.GUIFactory; - -/** - * The StatusPanel is the detailed view of a bookmark. - * It contains in most cases a ProgressPanel. The appropriate - * panel is determined according to the PANELPROPERTY in the bookmark's - * status - * @version $Id$ - */ -public class StatusPanel extends JPanel implements Observer { - private Container parent; - - private JTabbedPane tabPane; - private ListPanel listPanel; - private LoginPanel loginPanel; - private ProgressPanel progressPanel; - private EditPanel editPanel; - - private ContentPanel contentPanel; - private JPanel messagePanel; - private JLabel statusLabel; - - private Bookmark selected; - - /** - * The default constructor - */ - public StatusPanel() { - Cyberduck.DEBUG("[StatusPanel()]"); - this.init(); - ObserverList.instance().registerObserver((Observer)this); - } - - /** - * New instance initialized with the properties of the @link{Bookmark} argument. - * Instances created with this constructor will get notified by the Observable passed as - * the argument. - * @param bookmark The Observable and model of this panel - * @see ch.cyberduck.connection.Bookmark - */ - public StatusPanel(Bookmark bookmark) { - Cyberduck.DEBUG("[StatusPanel("+bookmark.toString()+")]"); - this.init(); - this.update(bookmark, Bookmark.SELECTION); - bookmark.addObserver(this); - bookmark.status.addObserver(this); - } - - /** - * @param parent The parent component - */ - public void setParent(Container parent) { - this.parent = parent; - } - - /** - * Initialize all subpanels - */ - private void init() { - contentPanel = new ContentPanel(); - editPanel = new EditPanel(); - messagePanel = new MessagePanel(); - this.setLayout(new BorderLayout()); - tabPane = new JTabbedPane() { - public Dimension getMinimumSize() { - Cyberduck.DEBUG("[JTabbedPane] getMinimumSize()"); - return this.getSelectedComponent().getMinimumSize(); - } - public Dimension getPreferredSize() { - Cyberduck.DEBUG("[JTabbedPane] getPreferredSize()"); - return this.getSelectedComponent().getPreferredSize(); - } - }; - tabPane.addChangeListener(new javax.swing.event.ChangeListener() { - public void stateChanged(javax.swing.event.ChangeEvent e) { - Cyberduck.DEBUG(e.toString()); - resize(); - } - }); -// tabPane.setBorder(BorderFactory.createEmptyBorder(0, -5, -5, -5)); - tabPane.setFont(GUIFactory.FONT_SMALL); - tabPane.add("Progress", contentPanel); - tabPane.add("Edit", editPanel); - this.add(tabPane, BorderLayout.CENTER); - this.add(messagePanel, BorderLayout.SOUTH); - this.setVisible(false); - } - - private class ContentPanel extends JPanel { - public ContentPanel() { - this.setLayout(new CardLayout()); - this.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); - this.add(progressPanel = new ProgressPanel(), Status.PROGRESSPANEL); - this.add(listPanel = new ListPanel(), Status.LISTPANEL); - this.add(loginPanel = new LoginPanel(), Status.LOGINPANEL); - } - - /* - protected void setDefaultButton() { - if(this.getRootPane() != null) { - String property = selected.status.getPanelProperty(); - if (property.equals(Status.PROGRESSPANEL)) { - this.getRootPane().setDefaultButton(progressPanel.getDefaultButton()); - return; - } - if (property.equals(Status.LOGINPANEL)) { - this.getRootPane().setDefaultButton(loginPanel.getDefaultButton()); - return; - } - } - } - */ - - public Dimension getMinimumSize() { - Cyberduck.DEBUG("[ContentPanel] getMinimumSize()"); - if(selected != null) { - String property = selected.status.getPanelProperty(); - if (property.equals(Status.PROGRESSPANEL)) { - return progressPanel.getMinimumSize(); - } - else if (property.equals(Status.LOGINPANEL)) { - return loginPanel.getMinimumSize(); - } - else if (property.equals(Status.LISTPANEL)) { - return listPanel.getMinimumSize(); - } - } - return super.getMinimumSize(); - } - - public Dimension getPreferredSize() { - Cyberduck.DEBUG("[ContentPanel] getPreferredSize()"); - if(selected != null) { - String property = selected.status.getPanelProperty(); - if (property.equals(Status.PROGRESSPANEL)) { - return progressPanel.getPreferredSize(); - } - else if (property.equals(Status.LOGINPANEL)) { - return loginPanel.getPreferredSize(); - } - else if (property.equals(Status.LISTPANEL)) { - return listPanel.getPreferredSize(); - } - } - return super.getPreferredSize(); - } - } - - private class MessagePanel extends JPanel { - public MessagePanel() { - this.setLayout(new GridLayout(1, 1)); - this.setBorder(BorderFactory.createCompoundBorder( - BorderFactory.createEmptyBorder(5, 5, 5, 5), - BorderFactory.createEtchedBorder(javax.swing.border.EtchedBorder.LOWERED)) - ); - this.add(statusLabel = GUIFactory.labelBuilder(ch.cyberduck.ui.common.GUIFactory.GRAY_ICON, "Idle", GUIFactory.FONT_SMALL)); - } - } - - - /** - * Show the panel specified by the argument - * @param property The panel property (specified as public static final in @link{Status}) - * @see ch.cyberduck.connection.Status - */ - protected void showPanel(String property) { - Cyberduck.DEBUG("[ContentPanel] showPanel("+property+")"); - CardLayout cl = (CardLayout)(contentPanel.getLayout()); - cl.show(contentPanel, property); - tabPane.setSelectedIndex(tabPane.indexOfTab("Progress")); - cl.invalidateLayout(contentPanel); - resize(); - //requestFocus(); - //this.setDefaultButton(); - } - - /** - * Resizes the parent component to fit this panel nicely. - */ - protected void resize() { - // Cyberduck.DEBUG("Parent:\n"+this.getParent()); - if(parent == null) - parent = this.getParent(); - if(parent != null) { - if(parent instanceof JSplitPane) { - ((JSplitPane)parent).resetToPreferredSizes(); - } - if(parent instanceof JDialog) { - ((JDialog)parent).pack(); - } - } - } - - /** - * Get's called by either the download's or status's notifyObservers() method - */ - public void update(Observable o, Object arg) { -// Cyberduck.DEBUG("[StatusPanel] update("+arg.toString()+")"); - this.progressPanel.update(o, arg); - this.listPanel.update(o, arg); - this.editPanel.update(o, arg); - this.loginPanel.update(o, arg); - - if(o instanceof Status) { - if(o.equals(selected.status)) { - if(arg.equals(Status.TIME) || arg.equals(Status.PROGRESS) || arg.equals(Status.ERROR)) { - statusLabel.setText(selected.status.getMessage(Status.TIME) + " : " + selected.status.getMessage(Status.PROGRESS) + " : " + selected.status.getMessage(Status.ERROR)); - } - if(arg.equals(Status.COMPLETE) || arg.equals(Status.STOP) || arg.equals(Status.ACTIVE)) { - tabPane.setEnabledAt(tabPane.indexOfTab("Edit"), !arg.equals(Status.ACTIVE)); - tabPane.setEnabledAt(tabPane.indexOfTab("Edit"), arg.equals(Status.STOP)); - tabPane.setSelectedIndex(tabPane.indexOfTab("Progress")); - statusLabel.setIcon(selected.status.getIcon()); - } - if (arg.equals(Status.PROGRESSPANEL) || arg.equals(Status.LISTPANEL) || arg.equals(Status.LOGINPANEL)) - showPanel((String)arg); - } - } - if(o instanceof Bookmark) { - // display/switch to other transfer - if(arg.equals(Bookmark.SELECTION)) { - selected = (Bookmark)o; - this.setVisible(true); - showPanel(selected.status.getPanelProperty()); - statusLabel.setText(selected.status.getMessage(Status.TIME) + " : " + selected.status.getMessage(Status.PROGRESS) + " : " + selected.status.getMessage(Status.ERROR)); - tabPane.setEnabledAt(tabPane.indexOfTab("Edit"), selected.status.isStopped()); - statusLabel.setIcon(selected.status.getIcon()); - } - if(arg.equals(Bookmark.DESELECTION)) { - this.setVisible(false); - } - } - } -} -- 2.11.4.GIT