annotate src/myVncClient/RecordingFrame.java @ 18:4881586aead9

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