Mercurial > hg > Applications > TreeVNC
annotate src/viewer_swing/java/com/glavsoft/viewer/Viewer.java @ 401:94c520535ef1
Fix selection panel
author | Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 13 Oct 2015 18:21:46 +0900 |
parents | 845698fd6fb6 |
children | 73c96a1d4a3a |
rev | line source |
---|---|
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1 // Copyright (C) 2010, 2011, 2012, 2013 GlavSoft LLC. |
0
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
2 // All rights reserved. |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
3 // |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
4 //------------------------------------------------------------------------- |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
5 // This file is part of the TightVNC software. Please visit our Web site: |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
6 // |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
7 // http://www.tightvnc.com/ |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
8 // |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
9 // This program is free software; you can redistribute it and/or modify |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
10 // it under the terms of the GNU General Public License as published by |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
11 // the Free Software Foundation; either version 2 of the License, or |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
12 // (at your option) any later version. |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
13 // |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
14 // This program is distributed in the hope that it will be useful, |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
15 // but WITHOUT ANY WARRANTY; without even the implied warranty of |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
17 // GNU General Public License for more details. |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
18 // |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
19 // You should have received a copy of the GNU General Public License along |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
20 // with this program; if not, write to the Free Software Foundation, Inc., |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
21 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
22 //------------------------------------------------------------------------- |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
23 // |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
24 |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
25 package com.glavsoft.viewer; |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
26 |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
27 import com.glavsoft.rfb.protocol.ProtocolSettings; |
383 | 28 import com.glavsoft.transport.Reader; |
29 import com.glavsoft.transport.Writer; | |
0
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
30 import com.glavsoft.viewer.cli.Parser; |
368
b60780e1fafc
Add ServerChangeThread to inhelitClients method
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
366
diff
changeset
|
31 import com.glavsoft.viewer.swing.*; |
0
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
32 |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
33 import javax.swing.*; |
129 | 34 |
0
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
35 import java.awt.*; |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
36 import java.awt.event.WindowEvent; |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
37 import java.awt.event.WindowListener; |
0
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
38 import java.io.IOException; |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
39 import java.io.InputStream; |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
40 import java.net.Socket; |
301 | 41 import java.util.ArrayList; |
0
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
42 import java.util.jar.Attributes; |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
43 import java.util.jar.Manifest; |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
44 import java.util.logging.*; |
0
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
45 |
60 | 46 import jp.ac.u_ryukyu.treevnc.CreateConnectionParam; |
207 | 47 import jp.ac.u_ryukyu.treevnc.TreeRFBProto; |
32 | 48 |
0
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
49 @SuppressWarnings("serial") |
179 | 50 public class Viewer extends JApplet implements Runnable, WindowListener , ViewerInterface { |
0
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
51 |
224 | 52 private Logger logger; |
368
b60780e1fafc
Add ServerChangeThread to inhelitClients method
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
366
diff
changeset
|
53 public int paramsMask; |
b60780e1fafc
Add ServerChangeThread to inhelitClients method
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
366
diff
changeset
|
54 public boolean allowAppletInteractiveConnections; |
0
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
55 |
60 | 56 public final ConnectionParams connectionParams; |
368
b60780e1fafc
Add ServerChangeThread to inhelitClients method
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
366
diff
changeset
|
57 public String passwordFromParams; |
b60780e1fafc
Add ServerChangeThread to inhelitClients method
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
366
diff
changeset
|
58 public boolean isSeparateFrame = true; |
b60780e1fafc
Add ServerChangeThread to inhelitClients method
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
366
diff
changeset
|
59 public boolean isApplet = true; |
b60780e1fafc
Add ServerChangeThread to inhelitClients method
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
366
diff
changeset
|
60 public final ProtocolSettings settings; |
b60780e1fafc
Add ServerChangeThread to inhelitClients method
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
366
diff
changeset
|
61 public UiSettings uiSettings; |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
62 private volatile boolean isAppletStopped = false; |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
63 private ConnectionPresenter connectionPresenter; |
65 | 64 boolean isTreeVNC = false; |
368
b60780e1fafc
Add ServerChangeThread to inhelitClients method
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
366
diff
changeset
|
65 public TreeRFBProto myRfb; |
b60780e1fafc
Add ServerChangeThread to inhelitClients method
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
366
diff
changeset
|
66 public boolean noConnection; |
175 | 67 public int vncport = ConnectionParams.DEFAULT_RFB_PORT; |
68 private int fbWidth; | |
224 | 69 private boolean showTree = false; |
225 | 70 public int width; |
71 public int height; | |
257 | 72 public int fixingSizeWidth; |
73 public int fixingSizeHeight; | |
139 | 74 |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
75 public static void main(String[] args) { |
224 | 76 Parser parser = new Parser(); |
77 ParametersHandler.completeParserOptions(parser); | |
0
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
78 |
224 | 79 parser.parse(args); |
80 if (parser.isSet(ParametersHandler.ARG_HELP)) { | |
81 printUsage(parser.optionsUsage()); | |
82 System.exit(0); | |
83 } | |
84 Viewer viewer = new Viewer(parser); | |
85 SwingUtilities.invokeLater(viewer); | |
86 } | |
0
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
87 |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
88 public static void printUsage(String additional) { |
224 | 89 System.out.println("Usage: java -jar (progfilename) [hostname [port_number]] [Options]Â¥n" + |
368
b60780e1fafc
Add ServerChangeThread to inhelitClients method
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
366
diff
changeset
|
90 " or¥n" + |
224 | 91 " java -jar (progfilename) [Options]Â¥n" + |
92 " or¥n java -jar (progfilename) -help¥n to view this help¥n¥n" + | |
93 "Where Options are:Â¥n" + additional + | |
94 "¥nOptions format: -optionName=optionValue. Ex. -host=localhost -port=5900 -viewonly=yes¥n" + | |
95 "Both option name and option value are case insensitive."); | |
96 } | |
0
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
97 |
224 | 98 public Viewer() { |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
99 logger = Logger.getLogger(getClass().getName()); |
224 | 100 connectionParams = new ConnectionParams(); |
101 settings = ProtocolSettings.getDefaultSettings(); | |
102 uiSettings = new UiSettings(); | |
103 } | |
0
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
104 |
224 | 105 private Viewer(Parser parser) { |
106 this(); | |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
107 setLoggingLevel(parser.isSet(ParametersHandler.ARG_VERBOSE) ? Level.FINE : |
224 | 108 parser.isSet(ParametersHandler.ARG_VERBOSE_MORE) ? Level.FINER : |
109 Level.INFO); | |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
110 |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
111 paramsMask = ParametersHandler.completeSettingsFromCLI(parser, connectionParams, settings, uiSettings); |
224 | 112 passwordFromParams = parser.getValueFor(ParametersHandler.ARG_PASSWORD); |
113 logger.info("TightVNC Viewer version " + ver()); | |
114 isApplet = false; | |
115 } | |
0
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
116 |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
117 private void setLoggingLevel(Level levelToSet) { |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
118 final Logger appLogger = Logger.getLogger("com.glavsoft"); |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
119 appLogger.setLevel(levelToSet); |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
120 ConsoleHandler ch = null; |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
121 for (Handler h : appLogger.getHandlers()) { |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
122 if (h instanceof ConsoleHandler) { |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
123 ch = (ConsoleHandler) h; |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
124 break; |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
125 } |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
126 } |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
127 if (null == ch) { |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
128 ch = new ConsoleHandler(); |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
129 appLogger.addHandler(ch); |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
130 } |
224 | 131 // ch.setFormatter(new SimpleFormatter()); |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
132 ch.setLevel(levelToSet); |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
133 } |
0
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
134 |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
135 |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
136 @Override |
224 | 137 public void windowClosing(WindowEvent e) { |
138 if (e != null && e.getComponent() != null) { | |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
139 final Window w = e.getWindow(); |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
140 if (w != null) { |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
141 w.setVisible(false); |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
142 w.dispose(); |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
143 } |
224 | 144 } |
145 closeApp(); | |
146 } | |
0
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
147 |
224 | 148 /** |
149 * Closes App(lication) or stops App(let). | |
150 */ | |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
151 public void closeApp() { |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
152 if (connectionPresenter != null) { |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
153 connectionPresenter.cancelConnection(); |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
154 logger.info("Connections cancelled."); |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
155 } |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
156 if (isApplet) { |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
157 if ( ! isAppletStopped) { |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
158 logger.severe("Applet is stopped."); |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
159 isAppletStopped = true; |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
160 repaint(); |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
161 stop(); |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
162 } |
224 | 163 } else { |
164 System.exit(0); | |
165 } | |
166 } | |
0
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
167 |
224 | 168 @Override |
169 public void paint(Graphics g) { | |
170 if ( ! isAppletStopped) { | |
171 super.paint(g); | |
172 } else { | |
173 getContentPane().removeAll(); | |
174 g.clearRect(0, 0, getWidth(), getHeight()); | |
175 g.drawString("Disconnected", 10, 20); | |
176 } | |
177 } | |
0
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
178 |
224 | 179 @Override |
180 public void destroy() { | |
181 closeApp(); | |
182 super.destroy(); | |
183 } | |
0
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
184 |
224 | 185 @Override |
186 public void init() { | |
187 paramsMask = ParametersHandler.completeSettingsFromApplet(this, connectionParams, settings, uiSettings); | |
188 isSeparateFrame = ParametersHandler.isSeparateFrame; | |
189 passwordFromParams = getParameter(ParametersHandler.ARG_PASSWORD); | |
190 isApplet = true; | |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
191 allowAppletInteractiveConnections = ParametersHandler.allowAppletInteractiveConnections; |
224 | 192 repaint(); |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
193 |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
194 try { |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
195 SwingUtilities.invokeAndWait(this); |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
196 } catch (Exception e) { |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
197 logger.severe(e.getMessage()); |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
198 } |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
199 } |
0
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
200 |
224 | 201 @Override |
202 public void start() { | |
203 super.start(); | |
204 } | |
0
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
205 |
368
b60780e1fafc
Add ServerChangeThread to inhelitClients method
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
366
diff
changeset
|
206 public boolean checkJsch() { |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
207 try { |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
208 Class.forName("com.jcraft.jsch.JSch"); |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
209 return true; |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
210 } catch (ClassNotFoundException e) { |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
211 return false; |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
212 } |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
213 } |
224 | 214 |
85 | 215 public void setNoConnection(boolean c){ |
224 | 216 noConnection = c; |
85 | 217 } |
224 | 218 |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
219 @Override |
224 | 220 public void run() { |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
221 final boolean hasJsch = checkJsch(); |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
222 final boolean allowInteractive = allowAppletInteractiveConnections || ! isApplet; |
368
b60780e1fafc
Add ServerChangeThread to inhelitClients method
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
366
diff
changeset
|
223 connectionPresenter = new ConnectionPresenter(hasJsch, allowInteractive); |
85 | 224 connectionPresenter.setNoConnection(noConnection); |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
225 connectionPresenter.addModel("ConnectionParamsModel", connectionParams); |
395
704ac9e79e25
Call startVNCConnectionWithSocket for directedServerChangeReqeust
innparusu
parents:
383
diff
changeset
|
226 connectionPresenter.startVNCConnection(this, false, null, null); |
224 | 227 } |
0
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
228 |
224 | 229 @Override |
370 | 230 public ConnectionPresenter getConnectionPresenter() { |
231 return connectionPresenter; | |
363 | 232 } |
233 | |
234 @Override | |
370 | 235 public void setConnectionPresenter(ConnectionPresenter connectionPresenter) { |
236 this.connectionPresenter = connectionPresenter; | |
369 | 237 } |
238 | |
239 @Override | |
224 | 240 public void windowOpened(WindowEvent e) { /* nop */ } |
241 @Override | |
242 public void windowClosed(WindowEvent e) { /* nop */ } | |
243 @Override | |
244 public void windowIconified(WindowEvent e) { /* nop */ } | |
245 @Override | |
246 public void windowDeiconified(WindowEvent e) { /* nop */ } | |
247 @Override | |
248 public void windowActivated(WindowEvent e) { /* nop */ } | |
249 @Override | |
250 public void windowDeactivated(WindowEvent e) { /* nop */ } | |
0
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
251 |
224 | 252 public static String ver() { |
253 final InputStream mfStream = Viewer.class.getClassLoader().getResourceAsStream( | |
254 "META-INF/MANIFEST.MF"); | |
255 if (null == mfStream) { | |
256 System.out.println("No Manifest file found."); | |
257 return "-1"; | |
258 } | |
259 try { | |
260 Manifest mf = new Manifest(); | |
261 mf.read(mfStream); | |
262 Attributes atts = mf.getMainAttributes(); | |
263 return atts.getValue(Attributes.Name.IMPLEMENTATION_VERSION); | |
264 } catch (IOException e) { | |
265 return "-2"; | |
266 } | |
267 } | |
0
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
268 |
59 | 269 |
224 | 270 public void setSocket(Socket soc) { |
271 connectionParams.setConnectionParam(soc.getInetAddress().getHostAddress(),soc.getPort()); | |
272 } | |
59 | 273 |
224 | 274 public void setOpenPort(int parseInt) { |
275 } | |
59 | 276 |
328
1a2ab6bd5ba3
add function lost child node, remove deadChild nodeList.
oc
parents:
327
diff
changeset
|
277 public void setTerminationType(boolean b) { |
224 | 278 myRfb.setTerminationType(b); |
279 } | |
280 | |
281 /** | |
174 | 282 * Start client with new parent (including reconnection) |
283 * @param port | |
284 * @param hostname | |
285 * @throws IOException | |
286 */ | |
224 | 287 @Override |
334 | 288 public void connectToParenet(int port, String hostname) throws IOException { |
328
1a2ab6bd5ba3
add function lost child node, remove deadChild nodeList.
oc
parents:
327
diff
changeset
|
289 setTerminationType(false); |
174 | 290 closeApp(); |
179 | 291 connectionParams.setConnectionParam(hostname, port); |
174 | 292 run(); |
293 } | |
224 | 294 |
295 public void setIsTreeVNC(boolean flag) { | |
296 isTreeVNC = flag; | |
297 } | |
65 | 298 |
224 | 299 public TreeRFBProto getRfb() { |
300 return myRfb; | |
301 } | |
302 | |
303 public boolean getCuiVersion() { | |
304 return myRfb.getCuiVersion(); | |
305 } | |
306 public void setCuiVersion(boolean flag) { | |
307 myRfb.setCuiVersion(flag); | |
308 } | |
309 | |
377 | 310 public void setVncport(int vncport) { |
311 this.vncport = vncport; | |
312 } | |
313 | |
175 | 314 /** |
315 * start new VNC server receiver with | |
316 * inherited clients | |
317 * @param vs | |
318 * @param hostName | |
369 | 319 * @param newVNCServerId |
175 | 320 */ |
176 | 321 @Override |
369 | 322 public void inhelitClients(ViewerInterface vs, String hostName, short newVNCServerId) { |
383 | 323 final ConnectionPresenter connectionPresenter = createNewConnectionPresenter(hostName, newVNCServerId); |
324 isApplet = true; | |
325 this.setNoConnection(false); | |
326 final Viewer v = this; | |
327 new Thread(new Runnable() { | |
328 @Override | |
329 public void run() { | |
395
704ac9e79e25
Call startVNCConnectionWithSocket for directedServerChangeReqeust
innparusu
parents:
383
diff
changeset
|
330 connectionPresenter.startVNCConnection(v, false, null, null); |
383 | 331 } |
332 }, "ServerChangeThread").start(); | |
333 } | |
334 | |
335 public void changeToDirectConnectedServer(String hostName, Reader is, Writer os) { | |
336 final ConnectionPresenter connectionPresenter = createNewConnectionPresenter(hostName, (short)-1); | |
395
704ac9e79e25
Call startVNCConnectionWithSocket for directedServerChangeReqeust
innparusu
parents:
383
diff
changeset
|
337 connectionPresenter.startVNCConnection(this, true, is, os); |
383 | 338 }; |
339 | |
340 private ConnectionPresenter createNewConnectionPresenter(String hostName, short newVNCServerId) { | |
368
b60780e1fafc
Add ServerChangeThread to inhelitClients method
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
366
diff
changeset
|
341 final boolean hasJsch = checkJsch(); |
b60780e1fafc
Add ServerChangeThread to inhelitClients method
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
366
diff
changeset
|
342 final boolean allowInteractive = allowAppletInteractiveConnections || ! isApplet; |
b60780e1fafc
Add ServerChangeThread to inhelitClients method
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
366
diff
changeset
|
343 final ConnectionPresenter connectionPresenter = new ConnectionPresenter(hasJsch, allowInteractive); |
b60780e1fafc
Add ServerChangeThread to inhelitClients method
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
366
diff
changeset
|
344 connectionPresenter.setNoConnection(noConnection); |
b60780e1fafc
Add ServerChangeThread to inhelitClients method
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
366
diff
changeset
|
345 ConnectionParams connectionParams = new ConnectionParams(); |
179 | 346 connectionParams.setConnectionParam(hostName, vncport); |
368
b60780e1fafc
Add ServerChangeThread to inhelitClients method
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
366
diff
changeset
|
347 connectionPresenter.addModel("ConnectionParamsModel", connectionParams); |
369 | 348 connectionPresenter.setConnectionParams(connectionParams); |
349 connectionPresenter.setReconnectingId(newVNCServerId); | |
370 | 350 connectionPresenter.setIsTreeVNC(true); |
351 connectionPresenter.setNoConnection(false); | |
383 | 352 return connectionPresenter; |
174 | 353 } |
354 | |
343 | 355 /** |
356 * start TreeVNC viewer | |
357 */ | |
379 | 358 public void startTreeViewer(String hostName, boolean cui, boolean addSerialNum) { |
343 | 359 TreeRFBProto rfb = new TreeRFBProto(false, this); |
360 rfb.setCuiVersion(cui); | |
379 | 361 rfb.setAddSerialNum(addSerialNum); |
343 | 362 rfb.setHasViewer(true); |
363 rfb.createConnectionAndStart(this); | |
364 CreateConnectionParam cp = new CreateConnectionParam(rfb); | |
365 if (hostName!=null) { | |
366 cp.setHostName(hostName); | |
367 } else { | |
368 cp.findTreeVncRoot(); | |
400
845698fd6fb6
Remove synchronized
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
399
diff
changeset
|
369 |
401
94c520535ef1
Fix selection panel
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
400
diff
changeset
|
370 // selected "Start Display Mode" or "Start as TreeVNC Root" for start selection panel |
94c520535ef1
Fix selection panel
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
400
diff
changeset
|
371 if (cp.isDisplayMode() || cp.isRootMode()) { |
400
845698fd6fb6
Remove synchronized
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
399
diff
changeset
|
372 myRfb = rfb; |
399
28d67bbfa9f1
Implement SelectionPanel processing
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
395
diff
changeset
|
373 return; |
28d67bbfa9f1
Implement SelectionPanel processing
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
395
diff
changeset
|
374 } |
343 | 375 } |
376 cp.sendWhereToConnect(this); | |
377 isTreeVNC = true; | |
378 myRfb = rfb; | |
379 settings.setViewOnly(true); // too avoid unnecessary upward traffic | |
380 rfb.getAcceptThread().waitForShutdown(); | |
381 } | |
382 | |
377 | 383 public void proxyStart(String[] argv, String hostName, int width, int height, boolean showTree, boolean checkDelay, boolean addSerialNum, boolean fixingSize, boolean filterSingleDisplay) { |
224 | 384 fbWidth = width; |
385 this.showTree = showTree; | |
175 | 386 // input into arguments Decision |
387 Parser parser = new Parser(); | |
388 ParametersHandler.completeParserOptions(parser); | |
389 if (fbWidth == 0) | |
390 parser.parse(argv); | |
391 if (parser.isSet(ParametersHandler.ARG_HELP)) { | |
392 printUsage(parser.optionsUsage()); | |
393 System.exit(0); | |
394 } | |
327
293c35aa902b
add error message, add assure stream close, delete firstTime value in TreeRFBProto.
oc
parents:
322
diff
changeset
|
395 TreeRFBProto rfb = new TreeRFBProto(true, this); |
179 | 396 myRfb = rfb; |
188 | 397 rfb.setShowTree(showTree); |
240 | 398 rfb.setCheckDelay(checkDelay); |
241 | 399 rfb.setAddSerialNum(addSerialNum); |
257 | 400 rfb.setFixingSize(fixingSize); |
266 | 401 if(fixingSize) { |
402 rfb.fixingSizeWidth = fixingSizeWidth; | |
403 rfb.fixingSizeHeight = fixingSizeHeight; | |
404 } | |
267 | 405 rfb.setFilterSingleDisplay(filterSingleDisplay); |
179 | 406 rfb.setCuiVersion(false); |
220 | 407 rfb.setHasViewer(true); // this flag will be overwrited after this method. Do we have to set here? |
179 | 408 rfb.createConnectionAndStart(this); |
409 setIsTreeVNC(true); | |
377 | 410 if (hostName == null) { |
411 hostName = "localhost"; | |
412 } | |
413 connectionParams.setConnectionParam(hostName, vncport); | |
179 | 414 isApplet = true; |
415 settings.setViewOnly(true); // too avoid unnecessary upward traffic | |
301 | 416 |
417 ArrayList<Rectangle> rectangles = getScreenRectangles(); | |
418 int leftScreenNumber = 0; | |
306 | 419 int singleWidth = (int) rectangles.get(leftScreenNumber).getWidth(); |
420 int singleHeight = (int) rectangles.get(leftScreenNumber).getHeight(); | |
421 getRfb().setSingleDisplaySize(singleWidth, singleHeight); | |
301 | 422 |
179 | 423 run(); |
424 } | |
425 | |
207 | 426 public void initRoot(TreeRFBProto myRfbProto, String hostName) { |
179 | 427 setIsTreeVNC(true); |
428 connectionParams.setConnectionParam(hostName, vncport); | |
429 isApplet = true; | |
430 myRfbProto.createConnectionAndStart(this); | |
431 run(); | |
175 | 432 } |
224 | 433 |
192 | 434 @Override |
435 public void setVisible(boolean b) { | |
366 | 436 if(connectionPresenter == null) return; |
224 | 437 SwingViewerWindow v = connectionPresenter.getViewer(); |
438 if (v != null) | |
439 v.setVisible(b); | |
192 | 440 } |
188 | 441 |
224 | 442 @Override |
443 public Socket getVNCSocket() { | |
444 return connectionPresenter.getSocket(); | |
445 } | |
202 | 446 |
204
d9d234715853
TreeManager for each interface
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
203
diff
changeset
|
447 @Override |
d9d234715853
TreeManager for each interface
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
203
diff
changeset
|
448 public boolean getShowTree() { |
d9d234715853
TreeManager for each interface
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
203
diff
changeset
|
449 return showTree; |
d9d234715853
TreeManager for each interface
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
203
diff
changeset
|
450 } |
d9d234715853
TreeManager for each interface
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
203
diff
changeset
|
451 |
225 | 452 @Override |
453 public void setWidth(int w) { | |
454 width = w; | |
455 } | |
456 | |
457 @Override | |
458 public void setHeight(int h) { | |
459 height = h; | |
460 } | |
461 | |
257 | 462 @Override |
463 public void setFixingSize(int width, int height) { | |
464 this.fixingSizeWidth = width; | |
465 this.fixingSizeHeight = height; | |
466 } | |
301 | 467 |
468 @Override | |
469 public ArrayList<Rectangle> getScreenRectangles() { | |
314 | 470 // before change the screen server, data from previous server |
301 | 471 // should be stopped. |
472 setCuiVersion(false); | |
314 | 473 // New screen server has one or more screens. |
474 // Screens are numbered in the order from left. | |
475 // put screens in an ArrayList. | |
301 | 476 ArrayList<Rectangle> rectangles = new ArrayList<Rectangle>(); |
477 GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); | |
478 GraphicsDevice[] gs = ge.getScreenDevices(); | |
314 | 479 for (GraphicsDevice gd : gs) { |
480 for (GraphicsConfiguration r : gd.getConfigurations()) { | |
481 rectangles.add(r.getBounds()); | |
301 | 482 } |
483 } | |
484 return rectangles; | |
485 } | |
486 | |
363 | 487 |
317 | 488 @Override |
489 public void setFitScreen() { | |
490 SwingViewerWindow v = connectionPresenter.getViewer(); | |
491 if (v != null) { | |
375 | 492 v.zoomToFit(); |
317 | 493 } |
494 } | |
495 | |
0
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
496 } |