Mercurial > hg > Applications > TreeVNC
annotate src/viewer_swing/java/com/glavsoft/viewer/Viewer.java @ 345:47e351909227
add stop children sender when change server.
author | one@firefly.cr.ie.u-ryukyu.ac.jp |
---|---|
date | Tue, 10 Feb 2015 18:18:49 +0900 |
parents | f1721ec54899 |
children | bc5624e3e9c5 |
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; |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
28 import com.glavsoft.viewer.cli.Parser; |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
29 import com.glavsoft.viewer.mvp.View; |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
30 import com.glavsoft.viewer.swing.ConnectionParams; |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
31 import com.glavsoft.viewer.swing.ParametersHandler; |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
32 import com.glavsoft.viewer.swing.SwingConnectionWorkerFactory; |
192 | 33 import com.glavsoft.viewer.swing.SwingViewerWindow; |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
34 import com.glavsoft.viewer.swing.SwingViewerWindowFactory; |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
35 import com.glavsoft.viewer.swing.gui.ConnectionView; |
0
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
36 |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
37 import javax.swing.*; |
129 | 38 |
0
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
39 import java.awt.*; |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
40 import java.awt.event.WindowEvent; |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
41 import java.awt.event.WindowListener; |
0
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
42 import java.io.IOException; |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
43 import java.io.InputStream; |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
44 import java.net.Socket; |
301 | 45 import java.util.ArrayList; |
0
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
46 import java.util.jar.Attributes; |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
47 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
|
48 import java.util.logging.*; |
0
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
49 |
60 | 50 import jp.ac.u_ryukyu.treevnc.CreateConnectionParam; |
207 | 51 import jp.ac.u_ryukyu.treevnc.TreeRFBProto; |
32 | 52 |
0
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
53 @SuppressWarnings("serial") |
179 | 54 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
|
55 |
224 | 56 private Logger logger; |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
57 private int paramsMask; |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
58 private boolean allowAppletInteractiveConnections; |
0
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
59 |
60 | 60 public final ConnectionParams connectionParams; |
59 | 61 protected String passwordFromParams; |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
62 boolean isSeparateFrame = true; |
59 | 63 protected boolean isApplet = true; |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
64 private final ProtocolSettings settings; |
59 | 65 protected UiSettings uiSettings; |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
66 private volatile boolean isAppletStopped = false; |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
67 private ConnectionPresenter connectionPresenter; |
65 | 68 boolean isTreeVNC = false; |
207 | 69 protected TreeRFBProto myRfb; |
224 | 70 private boolean noConnection; |
175 | 71 public int vncport = ConnectionParams.DEFAULT_RFB_PORT; |
72 private int fbWidth; | |
224 | 73 private boolean showTree = false; |
225 | 74 public int width; |
75 public int height; | |
257 | 76 public int fixingSizeWidth; |
77 public int fixingSizeHeight; | |
139 | 78 |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
79 public static void main(String[] args) { |
224 | 80 Parser parser = new Parser(); |
81 ParametersHandler.completeParserOptions(parser); | |
0
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
82 |
224 | 83 parser.parse(args); |
84 if (parser.isSet(ParametersHandler.ARG_HELP)) { | |
85 printUsage(parser.optionsUsage()); | |
86 System.exit(0); | |
87 } | |
88 Viewer viewer = new Viewer(parser); | |
89 SwingUtilities.invokeLater(viewer); | |
90 } | |
0
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
91 |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
92 public static void printUsage(String additional) { |
224 | 93 System.out.println("Usage: java -jar (progfilename) [hostname [port_number]] [Options]Â¥n" + |
94 " or¥n"+ | |
95 " java -jar (progfilename) [Options]Â¥n" + | |
96 " or¥n java -jar (progfilename) -help¥n to view this help¥n¥n" + | |
97 "Where Options are:Â¥n" + additional + | |
98 "¥nOptions format: -optionName=optionValue. Ex. -host=localhost -port=5900 -viewonly=yes¥n" + | |
99 "Both option name and option value are case insensitive."); | |
100 } | |
0
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
101 |
224 | 102 public Viewer() { |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
103 logger = Logger.getLogger(getClass().getName()); |
224 | 104 connectionParams = new ConnectionParams(); |
105 settings = ProtocolSettings.getDefaultSettings(); | |
106 uiSettings = new UiSettings(); | |
107 } | |
0
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
108 |
224 | 109 private Viewer(Parser parser) { |
110 this(); | |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
111 setLoggingLevel(parser.isSet(ParametersHandler.ARG_VERBOSE) ? Level.FINE : |
224 | 112 parser.isSet(ParametersHandler.ARG_VERBOSE_MORE) ? Level.FINER : |
113 Level.INFO); | |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
114 |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
115 paramsMask = ParametersHandler.completeSettingsFromCLI(parser, connectionParams, settings, uiSettings); |
224 | 116 passwordFromParams = parser.getValueFor(ParametersHandler.ARG_PASSWORD); |
117 logger.info("TightVNC Viewer version " + ver()); | |
118 isApplet = false; | |
119 } | |
0
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
120 |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
121 private void setLoggingLevel(Level levelToSet) { |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
122 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
|
123 appLogger.setLevel(levelToSet); |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
124 ConsoleHandler ch = null; |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
125 for (Handler h : appLogger.getHandlers()) { |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
126 if (h instanceof ConsoleHandler) { |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
127 ch = (ConsoleHandler) h; |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
128 break; |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
129 } |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
130 } |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
131 if (null == ch) { |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
132 ch = new ConsoleHandler(); |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
133 appLogger.addHandler(ch); |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
134 } |
224 | 135 // ch.setFormatter(new SimpleFormatter()); |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
136 ch.setLevel(levelToSet); |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
137 } |
0
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
138 |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
139 |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
140 @Override |
224 | 141 public void windowClosing(WindowEvent e) { |
142 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
|
143 final Window w = e.getWindow(); |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
144 if (w != null) { |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
145 w.setVisible(false); |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
146 w.dispose(); |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
147 } |
224 | 148 } |
149 closeApp(); | |
150 } | |
0
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
151 |
224 | 152 /** |
153 * Closes App(lication) or stops App(let). | |
154 */ | |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
155 public void closeApp() { |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
156 if (connectionPresenter != null) { |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
157 connectionPresenter.cancelConnection(); |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
158 logger.info("Connections cancelled."); |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
159 } |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
160 if (isApplet) { |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
161 if ( ! isAppletStopped) { |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
162 logger.severe("Applet is stopped."); |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
163 isAppletStopped = true; |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
164 repaint(); |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
165 stop(); |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
166 } |
224 | 167 } else { |
168 System.exit(0); | |
169 } | |
170 } | |
0
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
171 |
224 | 172 @Override |
173 public void paint(Graphics g) { | |
174 if ( ! isAppletStopped) { | |
175 super.paint(g); | |
176 } else { | |
177 getContentPane().removeAll(); | |
178 g.clearRect(0, 0, getWidth(), getHeight()); | |
179 g.drawString("Disconnected", 10, 20); | |
180 } | |
181 } | |
0
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
182 |
224 | 183 @Override |
184 public void destroy() { | |
185 closeApp(); | |
186 super.destroy(); | |
187 } | |
0
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
188 |
224 | 189 @Override |
190 public void init() { | |
191 paramsMask = ParametersHandler.completeSettingsFromApplet(this, connectionParams, settings, uiSettings); | |
192 isSeparateFrame = ParametersHandler.isSeparateFrame; | |
193 passwordFromParams = getParameter(ParametersHandler.ARG_PASSWORD); | |
194 isApplet = true; | |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
195 allowAppletInteractiveConnections = ParametersHandler.allowAppletInteractiveConnections; |
224 | 196 repaint(); |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
197 |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
198 try { |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
199 SwingUtilities.invokeAndWait(this); |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
200 } catch (Exception e) { |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
201 logger.severe(e.getMessage()); |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
202 } |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
203 } |
0
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
204 |
224 | 205 @Override |
206 public void start() { | |
207 super.start(); | |
208 } | |
0
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
209 |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
210 private boolean checkJsch() { |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
211 try { |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
212 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
|
213 return true; |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
214 } catch (ClassNotFoundException e) { |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
215 return false; |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
216 } |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
217 } |
224 | 218 |
85 | 219 public void setNoConnection(boolean c){ |
224 | 220 noConnection = c; |
85 | 221 } |
224 | 222 |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
223 @Override |
224 | 224 public void run() { |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
225 final boolean hasJsch = checkJsch(); |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
226 final boolean allowInteractive = allowAppletInteractiveConnections || ! isApplet; |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
227 connectionPresenter = new ConnectionPresenter(hasJsch, allowInteractive); |
85 | 228 connectionPresenter.setNoConnection(noConnection); |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
229 connectionPresenter.addModel("ConnectionParamsModel", connectionParams); |
224 | 230 ConnectionView connectionView = new ConnectionView( |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
231 Viewer.this, // appWindowListener |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
232 connectionPresenter, hasJsch); |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
233 connectionPresenter.addView(ConnectionPresenter.CONNECTION_VIEW, connectionView); |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
234 if (isApplet) { |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
235 connectionPresenter.addView("AppletStatusStringView", new View() { |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
236 @Override |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
237 public void showView() { /*nop*/ } |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
238 @Override |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
239 public void closeView() { /*nop*/ } |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
240 }); |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
241 } |
224 | 242 |
225 | 243 SwingViewerWindowFactory viewerWindowFactory = new SwingViewerWindowFactory(isSeparateFrame, isApplet, this, width, height); |
224 | 244 |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
245 connectionPresenter.setConnectionWorkerFactory( |
60 | 246 new SwingConnectionWorkerFactory(connectionView.getFrame(), passwordFromParams, connectionPresenter, viewerWindowFactory, myRfb)); |
89 | 247 connectionPresenter.setNeedReconnection(!noConnection); |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
248 connectionPresenter.startConnection(settings, uiSettings, paramsMask); |
224 | 249 } |
0
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
250 |
224 | 251 @Override |
252 public void windowOpened(WindowEvent e) { /* nop */ } | |
253 @Override | |
254 public void windowClosed(WindowEvent e) { /* nop */ } | |
255 @Override | |
256 public void windowIconified(WindowEvent e) { /* nop */ } | |
257 @Override | |
258 public void windowDeiconified(WindowEvent e) { /* nop */ } | |
259 @Override | |
260 public void windowActivated(WindowEvent e) { /* nop */ } | |
261 @Override | |
262 public void windowDeactivated(WindowEvent e) { /* nop */ } | |
0
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
263 |
224 | 264 public static String ver() { |
265 final InputStream mfStream = Viewer.class.getClassLoader().getResourceAsStream( | |
266 "META-INF/MANIFEST.MF"); | |
267 if (null == mfStream) { | |
268 System.out.println("No Manifest file found."); | |
269 return "-1"; | |
270 } | |
271 try { | |
272 Manifest mf = new Manifest(); | |
273 mf.read(mfStream); | |
274 Attributes atts = mf.getMainAttributes(); | |
275 return atts.getValue(Attributes.Name.IMPLEMENTATION_VERSION); | |
276 } catch (IOException e) { | |
277 return "-2"; | |
278 } | |
279 } | |
0
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
280 |
59 | 281 |
224 | 282 public void setSocket(Socket soc) { |
283 connectionParams.setConnectionParam(soc.getInetAddress().getHostAddress(),soc.getPort()); | |
284 } | |
59 | 285 |
224 | 286 public void setOpenPort(int parseInt) { |
287 } | |
59 | 288 |
328
1a2ab6bd5ba3
add function lost child node, remove deadChild nodeList.
oc
parents:
327
diff
changeset
|
289 public void setTerminationType(boolean b) { |
224 | 290 myRfb.setTerminationType(b); |
291 } | |
292 | |
293 /** | |
174 | 294 * Start client with new parent (including reconnection) |
295 * @param port | |
296 * @param hostname | |
297 * @throws IOException | |
298 */ | |
224 | 299 @Override |
334 | 300 public void connectToParenet(int port, String hostname) throws IOException { |
328
1a2ab6bd5ba3
add function lost child node, remove deadChild nodeList.
oc
parents:
327
diff
changeset
|
301 setTerminationType(false); |
174 | 302 closeApp(); |
179 | 303 connectionParams.setConnectionParam(hostname, port); |
174 | 304 run(); |
305 } | |
224 | 306 |
307 public void setIsTreeVNC(boolean flag) { | |
308 isTreeVNC = flag; | |
309 } | |
65 | 310 |
224 | 311 public TreeRFBProto getRfb() { |
312 return myRfb; | |
313 } | |
314 | |
315 public boolean getCuiVersion() { | |
316 return myRfb.getCuiVersion(); | |
317 } | |
318 public void setCuiVersion(boolean flag) { | |
319 myRfb.setCuiVersion(flag); | |
320 } | |
321 | |
175 | 322 /** |
323 * start new VNC server receiver with | |
324 * inherited clients | |
325 * @param vs | |
326 * @param hostName | |
327 */ | |
176 | 328 @Override |
329 public void inhelitClients(ViewerInterface vs, String hostName) { | |
202 | 330 myRfb.vncConnected(false); |
179 | 331 connectionParams.setConnectionParam(hostName, vncport); |
175 | 332 isApplet = true; |
333 this.setNoConnection(false); | |
334 run(); | |
174 | 335 } |
336 | |
343 | 337 /** |
338 * start TreeVNC viewer | |
339 */ | |
340 public void startTreeViewer(String hostName,boolean cui) { | |
341 TreeRFBProto rfb = new TreeRFBProto(false, this); | |
342 rfb.setCuiVersion(cui); | |
343 rfb.setHasViewer(true); | |
344 rfb.createConnectionAndStart(this); | |
345 CreateConnectionParam cp = new CreateConnectionParam(rfb); | |
346 if (hostName!=null) { | |
347 cp.setHostName(hostName); | |
348 } else { | |
349 cp.findTreeVncRoot(); | |
350 } | |
351 cp.sendWhereToConnect(this); | |
352 isTreeVNC = true; | |
353 myRfb = rfb; | |
354 settings.setViewOnly(true); // too avoid unnecessary upward traffic | |
355 rfb.getAcceptThread().waitForShutdown(); | |
356 } | |
357 | |
267 | 358 public void proxyStart(String[] argv, int width, int height, boolean showTree, boolean checkDelay, boolean addSerialNum, boolean fixingSize, boolean filterSingleDisplay) { |
224 | 359 fbWidth = width; |
360 this.showTree = showTree; | |
175 | 361 // input into arguments Decision |
362 Parser parser = new Parser(); | |
363 ParametersHandler.completeParserOptions(parser); | |
364 if (fbWidth == 0) | |
365 parser.parse(argv); | |
366 if (parser.isSet(ParametersHandler.ARG_HELP)) { | |
367 printUsage(parser.optionsUsage()); | |
368 System.exit(0); | |
369 } | |
179 | 370 String hostname = "localhost"; |
327
293c35aa902b
add error message, add assure stream close, delete firstTime value in TreeRFBProto.
oc
parents:
322
diff
changeset
|
371 TreeRFBProto rfb = new TreeRFBProto(true, this); |
179 | 372 myRfb = rfb; |
188 | 373 rfb.setShowTree(showTree); |
240 | 374 rfb.setCheckDelay(checkDelay); |
241 | 375 rfb.setAddSerialNum(addSerialNum); |
257 | 376 rfb.setFixingSize(fixingSize); |
266 | 377 if(fixingSize) { |
378 rfb.fixingSizeWidth = fixingSizeWidth; | |
379 rfb.fixingSizeHeight = fixingSizeHeight; | |
380 } | |
267 | 381 rfb.setFilterSingleDisplay(filterSingleDisplay); |
179 | 382 rfb.setCuiVersion(false); |
220 | 383 rfb.setHasViewer(true); // this flag will be overwrited after this method. Do we have to set here? |
179 | 384 rfb.createConnectionAndStart(this); |
385 setIsTreeVNC(true); | |
386 connectionParams.setConnectionParam(hostname, vncport); | |
387 isApplet = true; | |
388 settings.setViewOnly(true); // too avoid unnecessary upward traffic | |
186
f76ee760c2d2
dead lock on command line root
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
179
diff
changeset
|
389 rfb.setReconnecting(true); |
301 | 390 |
391 ArrayList<Rectangle> rectangles = getScreenRectangles(); | |
392 int leftScreenNumber = 0; | |
306 | 393 int singleWidth = (int) rectangles.get(leftScreenNumber).getWidth(); |
394 int singleHeight = (int) rectangles.get(leftScreenNumber).getHeight(); | |
395 getRfb().setSingleDisplaySize(singleWidth, singleHeight); | |
301 | 396 |
179 | 397 run(); |
398 } | |
399 | |
207 | 400 public void initRoot(TreeRFBProto myRfbProto, String hostName) { |
179 | 401 setIsTreeVNC(true); |
402 connectionParams.setConnectionParam(hostName, vncport); | |
403 isApplet = true; | |
404 myRfbProto.createConnectionAndStart(this); | |
186
f76ee760c2d2
dead lock on command line root
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
179
diff
changeset
|
405 myRfbProto.setReconnecting(true); |
179 | 406 run(); |
175 | 407 } |
224 | 408 |
192 | 409 @Override |
410 public void setVisible(boolean b) { | |
224 | 411 SwingViewerWindow v = connectionPresenter.getViewer(); |
412 if (v != null) | |
413 v.setVisible(b); | |
192 | 414 } |
188 | 415 |
224 | 416 @Override |
417 public Socket getVNCSocket() { | |
418 return connectionPresenter.getSocket(); | |
419 } | |
202 | 420 |
204
d9d234715853
TreeManager for each interface
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
203
diff
changeset
|
421 @Override |
d9d234715853
TreeManager for each interface
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
203
diff
changeset
|
422 public boolean getShowTree() { |
d9d234715853
TreeManager for each interface
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
203
diff
changeset
|
423 return showTree; |
d9d234715853
TreeManager for each interface
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
203
diff
changeset
|
424 } |
d9d234715853
TreeManager for each interface
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
203
diff
changeset
|
425 |
225 | 426 @Override |
427 public void setWidth(int w) { | |
428 width = w; | |
429 } | |
430 | |
431 @Override | |
432 public void setHeight(int h) { | |
433 height = h; | |
434 } | |
435 | |
257 | 436 @Override |
437 public void setFixingSize(int width, int height) { | |
438 this.fixingSizeWidth = width; | |
439 this.fixingSizeHeight = height; | |
440 } | |
301 | 441 |
442 @Override | |
443 public ArrayList<Rectangle> getScreenRectangles() { | |
314 | 444 // before change the screen server, data from previous server |
301 | 445 // should be stopped. |
446 setCuiVersion(false); | |
314 | 447 // New screen server has one or more screens. |
448 // Screens are numbered in the order from left. | |
449 // put screens in an ArrayList. | |
301 | 450 ArrayList<Rectangle> rectangles = new ArrayList<Rectangle>(); |
451 GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); | |
452 GraphicsDevice[] gs = ge.getScreenDevices(); | |
314 | 453 for (GraphicsDevice gd : gs) { |
454 for (GraphicsConfiguration r : gd.getConfigurations()) { | |
455 rectangles.add(r.getBounds()); | |
301 | 456 } |
457 } | |
458 return rectangles; | |
459 } | |
460 | |
317 | 461 @Override |
462 public void setFitScreen() { | |
463 SwingViewerWindow v = connectionPresenter.getViewer(); | |
464 if (v != null) { | |
465 v.fitScreen(); | |
466 } | |
467 } | |
468 | |
0
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
469 } |