32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
|
# File 'lib/cheri/jruby/explorer/dialogs.rb', line 32
def initialize(main)
swing[:auto=>true]
@main = main
@main_frame = main.main_frame
@dialog = dialog @main_frame, 'New Connection', true do |d|
box_layout(d, :Y_AXIS)
size 240,180
default_close_operation :HIDE_ON_CLOSE
y_glue
x_box do
y_box do
label 'Host:'
y_spacer 4
label 'Port:'
y_spacer 4
label 'Display name:'
end
x_spacer 10
y_box do
@con_host = text_field do
columns 10
maximum_size dimension(100,24)
text 'localhost'
end
y_spacer 4
@con_port = text_field do
columns 10
maximum_size dimension(100,24)
end
y_spacer 4
@con_name = text_field do
columns 10
maximum_size dimension(100,24)
end
end
end
y_spacer 16
x_box do
x_glue
button 'Connect' do
on_click do
host = @con_host.text
host.strip! if host
port = @con_port.text
port.strip! if port
name = @con_name.text
if name
name.strip!
name = nil if name.empty?
end
if !port || port.empty?
JOptionPane.show_message_dialog(@main_frame,"Please enter a port number",
'Connection Error', JOptionPane::ERROR_MESSAGE)
elsif !(port = Integer(port) rescue nil)
JOptionPane.show_message_dialog(@main_frame,"Invalid port: #{@con_port.text}",
'Connection Error', JOptionPane::ERROR_MESSAGE)
else
@dialog.visible = false
reset_fields
@main.new_connection(port,name,host)
end
end
end
x_spacer 10
button 'Cancel' do
on_click do
@dialog.visible = false
reset_fields
end
end
x_glue
end
y_glue
end
reset_fields
@main.center(@main_frame,@dialog)
end
|