2 * ch.cyberduck.ui.cocoa.CDConnectionDialog.java
5 * Copyright (c) 2002 David Kocher. All rights reserved.
6 * http://icu.unizh.ch/~dkocher/
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * Bug fixes, suggestions and comments should be sent to:
19 * dkocher@cyberduck.ch
22 package ch
.cyberduck
.ui
.cocoa
;
24 import com
.apple
.cocoa
.foundation
.*;
25 import com
.apple
.cocoa
.application
.*;
27 import org
.apache
.log4j
.Logger
;
29 public class CDConnectionDialog
extends NSWindow
{
31 private static Logger log
= Logger
.getLogger(CDConnectionDialog
.class);
33 public NSPopUpButton protocolPopup
;
34 public NSTextField hostNameField
;
35 public NSTextField pathField
;
36 public NSTextField portField
;
37 public NSTextField usernameField
;
38 public NSTextField urlLabel
;
40 public CDConnectionDialog() {
42 log
.debug("CDConnectionDialog");
45 public CDConnectionDialog(NSRect contentRect
, int styleMask
, int backingType
, boolean defer
) {
46 super(contentRect
, styleMask
, backingType
, defer
);
47 log
.debug("CDConnectionDialog");
50 public CDConnectionDialog(NSRect contentRect
, int styleMask
, int bufferingType
, boolean defer
, NSScreen aScreen
) {
51 super(contentRect
, styleMask
, bufferingType
, defer
, aScreen
);
52 log
.debug("CDConnectionDialog");
55 public void awakeFromNib() {
56 log
.debug("CDConnectionDialog:awakeFromNib");
57 this.textInputDidChange(null);
58 // this.urlLabel.setStringValue("");
59 // Notify the textInputDidChange() method if the user types.
60 (NSNotificationCenter
.defaultCenter()).addObserver(
62 new NSSelector("textInputDidChange", new Class
[]{NSNotification
.class}),
63 NSControl
.ControlTextDidChangeNotification
,
65 (NSNotificationCenter
.defaultCenter()).addObserver(
67 new NSSelector("textInputDidChange", new Class
[]{NSNotification
.class}),
68 NSControl
.ControlTextDidChangeNotification
,
70 (NSNotificationCenter
.defaultCenter()).addObserver(
72 new NSSelector("textInputDidChange", new Class
[]{NSNotification
.class}),
73 NSControl
.ControlTextDidChangeNotification
,
75 (NSNotificationCenter
.defaultCenter()).addObserver(
77 new NSSelector("textInputDidChange", new Class
[]{NSNotification
.class}),
78 NSControl
.ControlTextDidChangeNotification
,
82 private static final int SFTP_TAG
= 1;
83 private static final int FTP_TAG
= 2;
85 public void protocolSelectionChanged(NSObject sender
) {
86 NSMenuItem selectedItem
= protocolPopup
.selectedItem();
87 log
.debug("protocol selection changed");
88 if(selectedItem
.tag() == SFTP_TAG
)
89 portField
.setIntValue(22); //todo: use constant
90 if(selectedItem
.tag() == FTP_TAG
)
91 portField
.setIntValue(21);
94 public void textInputDidChange(NSNotification sender
) {
95 urlLabel
.setStringValue(usernameField
.stringValue()+"@"+hostNameField
.stringValue()+":"+portField
.stringValue()+"/"+pathField
.stringValue());
98 public void finalize() {
99 (NSNotificationCenter
.defaultCenter()).removeObserver(this);