0
|
1 package treeVnc;
|
|
2 //
|
|
3 // Copyright (C) 2001,2002 HorizonLive.com, Inc. All Rights Reserved.
|
|
4 // Copyright (C) 1999 AT&T Laboratories Cambridge. All Rights Reserved.
|
|
5 //
|
|
6 // This is free software; you can redistribute it and/or modify
|
|
7 // it under the terms of the GNU General Public License as published by
|
|
8 // the Free Software Foundation; either version 2 of the License, or
|
|
9 // (at your option) any later version.
|
|
10 //
|
|
11 // This software is distributed in the hope that it will be useful,
|
|
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
14 // GNU General Public License for more details.
|
|
15 //
|
|
16 // You should have received a copy of the GNU General Public License
|
|
17 // along with this software; if not, write to the Free Software
|
|
18 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
|
19 // USA.
|
|
20 //
|
|
21
|
|
22 //
|
|
23 // ButtonPanel class implements panel with four buttons in the
|
|
24 // VNCViewer desktop window.
|
|
25 //
|
|
26
|
|
27 import java.awt.*;
|
|
28 import java.awt.event.*;
|
|
29 import java.io.*;
|
|
30
|
|
31 class ButtonPanel extends Panel implements ActionListener {
|
|
32
|
|
33 /**
|
|
34 *
|
|
35 */
|
|
36 private static final long serialVersionUID = 1L;
|
|
37 VncViewer viewer;
|
|
38 Button disconnectButton;
|
|
39 Button optionsButton;
|
|
40 Button recordButton;
|
|
41 Button clipboardButton;
|
|
42 Button ctrlAltDelButton;
|
|
43 Button refreshButton;
|
|
44 Button changeHost;
|
|
45
|
|
46 ButtonPanel(VncViewer v) {
|
|
47 viewer = v;
|
|
48
|
|
49 setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
|
|
50 disconnectButton = new Button("Disconnect");
|
|
51 disconnectButton.setEnabled(false);
|
|
52 add(disconnectButton);
|
|
53 disconnectButton.addActionListener(this);
|
|
54 optionsButton = new Button("Options");
|
|
55 add(optionsButton);
|
|
56 optionsButton.addActionListener(this);
|
|
57 clipboardButton = new Button("Clipboard");
|
|
58 clipboardButton.setEnabled(false);
|
|
59 add(clipboardButton);
|
|
60 clipboardButton.addActionListener(this);
|
|
61 if (viewer.rec != null) {
|
|
62 recordButton = new Button("Record");
|
|
63 add(recordButton);
|
|
64 recordButton.addActionListener(this);
|
|
65 }
|
|
66 ctrlAltDelButton = new Button("Send Ctrl-Alt-Del");
|
|
67 ctrlAltDelButton.setEnabled(false);
|
|
68 add(ctrlAltDelButton);
|
|
69 ctrlAltDelButton.addActionListener(this);
|
|
70 refreshButton = new Button("Refresh");
|
|
71 refreshButton.setEnabled(false);
|
|
72 add(refreshButton);
|
|
73 refreshButton.addActionListener(this);
|
|
74 changeHost = new Button("Change Host");
|
|
75 add(changeHost);
|
|
76 changeHost.addActionListener(this);
|
|
77 }
|
|
78
|
|
79 //
|
|
80 // Enable buttons on successful connection.
|
|
81 //
|
|
82
|
|
83 public void enableButtons() {
|
|
84 disconnectButton.setEnabled(true);
|
|
85 clipboardButton.setEnabled(true);
|
|
86 refreshButton.setEnabled(true);
|
|
87 }
|
|
88
|
|
89 //
|
|
90 // Disable all buttons on disconnect.
|
|
91 //
|
|
92
|
|
93 public void disableButtonsOnDisconnect() {
|
|
94 remove(disconnectButton);
|
|
95 disconnectButton = new Button("Hide desktop");
|
|
96 disconnectButton.setEnabled(true);
|
|
97 add(disconnectButton, 0);
|
|
98 disconnectButton.addActionListener(this);
|
|
99
|
|
100 optionsButton.setEnabled(false);
|
|
101 clipboardButton.setEnabled(false);
|
|
102 ctrlAltDelButton.setEnabled(false);
|
|
103 refreshButton.setEnabled(false);
|
|
104
|
|
105 validate();
|
|
106 }
|
|
107
|
|
108 //
|
|
109 // Enable/disable controls that should not be available in view-only
|
|
110 // mode.
|
|
111 //
|
|
112
|
|
113 public void enableRemoteAccessControls(boolean enable) {
|
|
114 ctrlAltDelButton.setEnabled(enable);
|
|
115 }
|
|
116
|
|
117 //
|
|
118 // Event processing.
|
|
119 //
|
|
120
|
|
121 public void actionPerformed(ActionEvent evt) {
|
|
122
|
|
123 viewer.moveFocusToDesktop();
|
|
124
|
|
125 if (evt.getSource() == disconnectButton) {
|
|
126 viewer.disconnect();
|
|
127
|
|
128 } else if (evt.getSource() == optionsButton) {
|
|
129 viewer.options.setVisible(!viewer.options.isVisible());
|
|
130
|
|
131 } else if (evt.getSource() == recordButton) {
|
|
132 viewer.rec.setVisible(!viewer.rec.isVisible());
|
|
133
|
|
134 } else if (evt.getSource() == clipboardButton) {
|
|
135 viewer.clipboard.setVisible(!viewer.clipboard.isVisible());
|
|
136
|
|
137 }else if (evt.getSource() == changeHost) {
|
|
138 //write when click to "Change Host"
|
|
139
|
|
140 } else if (evt.getSource() == ctrlAltDelButton) {
|
|
141 try {
|
|
142 final int modifiers = InputEvent.CTRL_MASK | InputEvent.ALT_MASK;
|
|
143
|
|
144 KeyEvent ctrlAltDelEvent =
|
|
145 new KeyEvent(this, KeyEvent.KEY_PRESSED, 0, modifiers, 127,KeyEvent.CHAR_UNDEFINED);
|
|
146 viewer.rfb.writeKeyEvent(ctrlAltDelEvent);
|
|
147
|
|
148 ctrlAltDelEvent =
|
|
149 new KeyEvent(this, KeyEvent.KEY_RELEASED, 0, modifiers, 127,KeyEvent.CHAR_UNDEFINED);
|
|
150 viewer.rfb.writeKeyEvent(ctrlAltDelEvent);
|
|
151
|
|
152 } catch (IOException e) {
|
|
153 e.printStackTrace();
|
|
154 }
|
|
155 } else if (evt.getSource() == refreshButton) {
|
|
156 try {
|
|
157 RfbProto rfb = viewer.rfb;
|
|
158 rfb.writeFramebufferUpdateRequest(0, 0, rfb.framebufferWidth,
|
|
159 rfb.framebufferHeight, false);
|
|
160 } catch (IOException e) {
|
|
161 e.printStackTrace();
|
|
162 }
|
|
163 }
|
|
164 }
|
|
165 }
|
|
166
|