annotate src/myVncProxy/RecordingFrame.java @ 145:8bdbed4c4505

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