annotate src/RecordingFrame.java @ 0:30bb7074acb1

upload all file of tighVNCProxy
author e085711
date Tue, 12 Apr 2011 12:58:05 +0900
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
1 //
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
2 // Copyright (C) 2002 Constantin Kaplinsky. All Rights Reserved.
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
3 //
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
4 // This is free software; you can redistribute it and/or modify
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
5 // it under the terms of the GNU General Public License as published by
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
6 // the Free Software Foundation; either version 2 of the License, or
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
7 // (at your option) any later version.
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
8 //
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
9 // This software is distributed in the hope that it will be useful,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
12 // GNU General Public License for more details.
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
13 //
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
14 // You should have received a copy of the GNU General Public License
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
15 // along with this software; if not, write to the Free Software
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
16 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
17 // USA.
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
18 //
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
19
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
20 //
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
21 // Recording frame. It allows to control recording RFB sessions into
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
22 // FBS (FrameBuffer Stream) files.
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
23 //
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
24
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
25 import java.io.*;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
26 import java.awt.*;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
27 import java.awt.event.*;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
28
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
29 class RecordingFrame extends Frame
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
30 implements WindowListener, ActionListener {
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
31
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
32 boolean recording;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
33
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
34 TextField fnameField;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
35 Button browseButton;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
36
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
37 Label statusLabel;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
38
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
39 Button recordButton, nextButton, closeButton;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
40 VncViewer viewer;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
41
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
42 //
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
43 // Check if current security manager allows to create a
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
44 // RecordingFrame object.
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
45 //
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
46
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
47 public static boolean checkSecurity() {
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
48 SecurityManager security = System.getSecurityManager();
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
49 if (security != null) {
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
50 try {
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
51 security.checkPropertyAccess("user.dir");
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
52 security.checkPropertyAccess("file.separator");
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
53 // Work around (rare) checkPropertyAccess bug
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
54 System.getProperty("user.dir");
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
55 } catch (SecurityException e) {
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
56 System.out.println("SecurityManager restricts session recording.");
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
57 return false;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
58 }
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
59 }
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
60 return true;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
61 }
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
62
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
63 //
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
64 // Constructor.
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
65 //
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
66
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
67 RecordingFrame(VncViewer v) {
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
68 super("TightVNC Session Recording");
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
69
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
70 viewer = v;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
71
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
72 // Determine initial filename for next saved session.
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
73 // FIXME: Check SecurityManager.
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
74
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
75 String fname = nextNewFilename(System.getProperty("user.dir") +
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
76 System.getProperty("file.separator") +
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
77 "vncsession.fbs");
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
78
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
79 // Construct new panel with file name field and "Browse" button.
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
80
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
81 Panel fnamePanel = new Panel();
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
82 GridBagLayout fnameGridbag = new GridBagLayout();
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
83 fnamePanel.setLayout(fnameGridbag);
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
84
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
85 GridBagConstraints fnameConstraints = new GridBagConstraints();
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
86 fnameConstraints.gridwidth = GridBagConstraints.RELATIVE;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
87 fnameConstraints.fill = GridBagConstraints.BOTH;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
88 fnameConstraints.weightx = 4.0;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
89
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
90 fnameField = new TextField(fname, 64);
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
91 fnameGridbag.setConstraints(fnameField, fnameConstraints);
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
92 fnamePanel.add(fnameField);
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
93 fnameField.addActionListener(this);
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
94
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
95 fnameConstraints.gridwidth = GridBagConstraints.REMAINDER;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
96 fnameConstraints.weightx = 1.0;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
97
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
98 browseButton = new Button("Browse");
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
99 fnameGridbag.setConstraints(browseButton, fnameConstraints);
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
100 fnamePanel.add(browseButton);
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
101 browseButton.addActionListener(this);
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
102
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
103 // Construct the frame.
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
104
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
105 GridBagLayout gridbag = new GridBagLayout();
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
106 setLayout(gridbag);
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
107
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
108 GridBagConstraints gbc = new GridBagConstraints();
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
109 gbc.gridwidth = GridBagConstraints.REMAINDER;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
110 gbc.fill = GridBagConstraints.BOTH;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
111 gbc.weighty = 1.0;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
112 gbc.insets = new Insets(10, 0, 0, 0);
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
113
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
114 Label helpLabel =
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
115 new Label("File name to save next recorded session in:", Label.CENTER);
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
116 gridbag.setConstraints(helpLabel, gbc);
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
117 add(helpLabel);
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
118
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
119 gbc.fill = GridBagConstraints.HORIZONTAL;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
120 gbc.weighty = 0.0;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
121 gbc.insets = new Insets(0, 0, 0, 0);
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
122
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
123 gridbag.setConstraints(fnamePanel, gbc);
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
124 add(fnamePanel);
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
125
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
126 gbc.fill = GridBagConstraints.BOTH;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
127 gbc.weighty = 1.0;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
128 gbc.insets = new Insets(10, 0, 10, 0);
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
129
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
130 statusLabel = new Label("", Label.CENTER);
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
131 gridbag.setConstraints(statusLabel, gbc);
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
132 add(statusLabel);
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
133
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
134 gbc.fill = GridBagConstraints.HORIZONTAL;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
135 gbc.weightx = 1.0;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
136 gbc.weighty = 0.0;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
137 gbc.gridwidth = 1;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
138 gbc.insets = new Insets(0, 0, 0, 0);
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
139
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
140 recordButton = new Button("Record");
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
141 gridbag.setConstraints(recordButton, gbc);
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
142 add(recordButton);
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
143 recordButton.addActionListener(this);
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
144
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
145 nextButton = new Button("Next file");
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
146 gridbag.setConstraints(nextButton, gbc);
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
147 add(nextButton);
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
148 nextButton.addActionListener(this);
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
149
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
150 closeButton = new Button("Close");
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
151 gridbag.setConstraints(closeButton, gbc);
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
152 add(closeButton);
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
153 closeButton.addActionListener(this);
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
154
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
155 // Set correct text, font and color for the statusLabel.
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
156 stopRecording();
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
157
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
158 pack();
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
159
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
160 addWindowListener(this);
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
161 }
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
162
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
163 //
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
164 // If the given string ends with ".NNN" where NNN is a decimal
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
165 // number, increase this number by one. Otherwise, append ".001"
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
166 // to the given string.
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
167 //
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
168
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
169 protected String nextFilename(String fname) {
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
170 int len = fname.length();
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
171 int suffixPos = len;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
172 int suffixNum = 1;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
173
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
174 if (len > 4 && fname.charAt(len - 4) == '.') {
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
175 try {
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
176 suffixNum = Integer.parseInt(fname.substring(len - 3, len)) + 1;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
177 suffixPos = len - 4;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
178 } catch (NumberFormatException e) { }
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
179 }
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
180
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
181 char[] zeroes = {'0', '0', '0'};
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
182 String suffix = String.valueOf(suffixNum);
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
183 if (suffix.length() < 3) {
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
184 suffix = new String(zeroes, 0, 3 - suffix.length()) + suffix;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
185 }
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
186
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
187 return fname.substring(0, suffixPos) + '.' + suffix;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
188 }
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
189
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
190 //
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
191 // Find next name of a file which does not exist yet.
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
192 //
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
193
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
194 protected String nextNewFilename(String fname) {
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
195 String newName = fname;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
196 File f;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
197 try {
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
198 do {
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
199 newName = nextFilename(newName);
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
200 f = new File(newName);
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
201 } while (f.exists());
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
202 } catch (SecurityException e) { }
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
203
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
204 return newName;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
205 }
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
206
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
207 //
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
208 // Let the user choose a file name showing a FileDialog.
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
209 //
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
210
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
211 protected boolean browseFile() {
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
212 File currentFile = new File(fnameField.getText());
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
213
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
214 FileDialog fd =
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
215 new FileDialog(this, "Save next session as...", FileDialog.SAVE);
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
216 fd.setDirectory(currentFile.getParent());
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
217 fd.setVisible(true);
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
218 if (fd.getFile() != null) {
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
219 String newDir = fd.getDirectory();
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
220 String sep = System.getProperty("file.separator");
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
221 if (newDir.length() > 0) {
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
222 if (!sep.equals(newDir.substring(newDir.length() - sep.length())))
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
223 newDir += sep;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
224 }
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
225 String newFname = newDir + fd.getFile();
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
226 if (newFname.equals(fnameField.getText())) {
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
227 fnameField.setText(newFname);
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
228 return true;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
229 }
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
230 }
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
231 return false;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
232 }
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
233
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
234 //
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
235 // Start recording.
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
236 //
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
237
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
238 public void startRecording() {
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
239 statusLabel.setText("Status: Recording...");
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
240 statusLabel.setFont(new Font("Helvetica", Font.BOLD, 12));
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
241 statusLabel.setForeground(Color.red);
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
242 recordButton.setLabel("Stop recording");
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
243
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
244 recording = true;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
245
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
246 viewer.setRecordingStatus(fnameField.getText());
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
247 }
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
248
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
249 //
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
250 // Stop recording.
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
251 //
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
252
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
253 public void stopRecording() {
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
254 statusLabel.setText("Status: Not recording.");
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
255 statusLabel.setFont(new Font("Helvetica", Font.PLAIN, 12));
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
256 statusLabel.setForeground(Color.black);
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
257 recordButton.setLabel("Record");
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
258
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
259 recording = false;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
260
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
261 viewer.setRecordingStatus(null);
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
262 }
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
263
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
264 //
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
265 // Close our window properly.
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
266 //
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
267
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
268 public void windowClosing(WindowEvent evt) {
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
269 setVisible(false);
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
270 }
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
271
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
272 //
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
273 // Ignore window events we're not interested in.
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
274 //
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
275
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
276 public void windowActivated(WindowEvent evt) {}
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
277 public void windowDeactivated (WindowEvent evt) {}
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
278 public void windowOpened(WindowEvent evt) {}
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
279 public void windowClosed(WindowEvent evt) {}
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
280 public void windowIconified(WindowEvent evt) {}
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
281 public void windowDeiconified(WindowEvent evt) {}
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
282
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
283
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
284 //
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
285 // Respond to button presses
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
286 //
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
287
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
288 public void actionPerformed(ActionEvent evt) {
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
289 if (evt.getSource() == browseButton) {
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
290 if (browseFile() && recording)
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
291 startRecording();
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
292
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
293 } else if (evt.getSource() == recordButton) {
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
294 if (!recording) {
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
295 startRecording();
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
296 } else {
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
297 stopRecording();
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
298 fnameField.setText(nextNewFilename(fnameField.getText()));
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
299 }
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
300
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
301 } else if (evt.getSource() == nextButton) {
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
302 fnameField.setText(nextNewFilename(fnameField.getText()));
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
303 if (recording)
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
304 startRecording();
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
305
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
306 } else if (evt.getSource() == closeButton) {
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
307 setVisible(false);
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
308
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
309 }
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
310 }
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
311 }