Mercurial > hg > Applications > TreeVNC
annotate src/viewer_swing/java/com/glavsoft/viewer/Viewer.java @ 314:e95cb9a3dd9b
change code, delete firstTime.
author | oc |
---|---|
date | Wed, 28 Jan 2015 19:32:21 +0900 |
parents | 5e55cc34f789 |
children | 3c63bc88383e |
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 |
224 | 289 public void setTeminationType(boolean b) { |
290 myRfb.setTerminationType(b); | |
291 } | |
292 | |
293 /** | |
294 * start TreeVNC viewer | |
295 */ | |
296 public void startTreeViewer(String hostName,boolean cui) { | |
297 TreeRFBProto rfb = new TreeRFBProto(false); | |
298 rfb.setCuiVersion(cui); | |
299 rfb.setHasViewer(true); | |
204
d9d234715853
TreeManager for each interface
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
203
diff
changeset
|
300 rfb.setViewer(this); |
177 | 301 rfb.createConnectionAndStart(this); |
224 | 302 CreateConnectionParam cp = new CreateConnectionParam(rfb); |
303 if (hostName!=null) { | |
304 cp.setHostName(hostName); | |
305 } else { | |
306 try { | |
307 cp.findTreeVncRoot(); | |
308 } catch (InterruptedException e) { | |
309 System.out.println("cannot find TreeVNC Root "+e.getMessage()); | |
310 return; | |
311 } | |
312 } | |
313 cp.sendWhereToConnect(this); | |
314 isTreeVNC = true; | |
315 myRfb = rfb; | |
121 | 316 settings.setViewOnly(true); // too avoid unnecessary upward traffic |
176 | 317 rfb.getAcceptThread().waitForShutdown(); |
224 | 318 } |
319 | |
174 | 320 |
321 /** | |
322 * Start client with new parent (including reconnection) | |
323 * @param port | |
324 * @param hostname | |
325 * @throws IOException | |
326 */ | |
224 | 327 @Override |
174 | 328 public void connectToParenet(int port, String hostname) throws IOException { |
329 setTeminationType(false); | |
330 closeApp(); | |
179 | 331 connectionParams.setConnectionParam(hostname, port); |
174 | 332 run(); |
333 } | |
224 | 334 |
335 public void setIsTreeVNC(boolean flag) { | |
336 isTreeVNC = flag; | |
337 } | |
65 | 338 |
224 | 339 public TreeRFBProto getRfb() { |
340 return myRfb; | |
341 } | |
342 | |
343 public boolean getCuiVersion() { | |
344 return myRfb.getCuiVersion(); | |
345 } | |
346 public void setCuiVersion(boolean flag) { | |
347 myRfb.setCuiVersion(flag); | |
348 } | |
349 | |
175 | 350 /** |
351 * start new VNC server receiver with | |
352 * inherited clients | |
353 * @param vs | |
354 * @param hostName | |
355 */ | |
176 | 356 @Override |
357 public void inhelitClients(ViewerInterface vs, String hostName) { | |
202 | 358 myRfb.vncConnected(false); |
179 | 359 connectionParams.setConnectionParam(hostName, vncport); |
175 | 360 isApplet = true; |
361 this.setNoConnection(false); | |
204
d9d234715853
TreeManager for each interface
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
203
diff
changeset
|
362 if (myRfb.isTreeManager()) { |
224 | 363 setVisible(false); |
192 | 364 } |
175 | 365 run(); |
174 | 366 } |
367 | |
267 | 368 public void proxyStart(String[] argv, int width, int height, boolean showTree, boolean checkDelay, boolean addSerialNum, boolean fixingSize, boolean filterSingleDisplay) { |
224 | 369 fbWidth = width; |
370 this.showTree = showTree; | |
175 | 371 // input into arguments Decision |
372 Parser parser = new Parser(); | |
373 ParametersHandler.completeParserOptions(parser); | |
374 if (fbWidth == 0) | |
375 parser.parse(argv); | |
376 if (parser.isSet(ParametersHandler.ARG_HELP)) { | |
377 printUsage(parser.optionsUsage()); | |
378 System.exit(0); | |
379 } | |
179 | 380 String hostname = "localhost"; |
207 | 381 TreeRFBProto rfb = new TreeRFBProto(true); |
179 | 382 myRfb = rfb; |
188 | 383 rfb.setShowTree(showTree); |
240 | 384 rfb.setCheckDelay(checkDelay); |
241 | 385 rfb.setAddSerialNum(addSerialNum); |
257 | 386 rfb.setFixingSize(fixingSize); |
266 | 387 if(fixingSize) { |
388 rfb.fixingSizeWidth = fixingSizeWidth; | |
389 rfb.fixingSizeHeight = fixingSizeHeight; | |
390 } | |
267 | 391 rfb.setFilterSingleDisplay(filterSingleDisplay); |
179 | 392 rfb.setViewer(this); |
393 rfb.setCuiVersion(false); | |
220 | 394 rfb.setHasViewer(true); // this flag will be overwrited after this method. Do we have to set here? |
179 | 395 rfb.createConnectionAndStart(this); |
396 setIsTreeVNC(true); | |
397 connectionParams.setConnectionParam(hostname, vncport); | |
398 isApplet = true; | |
399 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
|
400 rfb.setReconnecting(true); |
301 | 401 |
402 ArrayList<Rectangle> rectangles = getScreenRectangles(); | |
403 int leftScreenNumber = 0; | |
306 | 404 int singleWidth = (int) rectangles.get(leftScreenNumber).getWidth(); |
405 int singleHeight = (int) rectangles.get(leftScreenNumber).getHeight(); | |
406 getRfb().setSingleDisplaySize(singleWidth, singleHeight); | |
301 | 407 |
179 | 408 run(); |
409 } | |
410 | |
207 | 411 public void initRoot(TreeRFBProto myRfbProto, String hostName) { |
179 | 412 setIsTreeVNC(true); |
413 connectionParams.setConnectionParam(hostName, vncport); | |
414 isApplet = true; | |
415 myRfbProto.createConnectionAndStart(this); | |
186
f76ee760c2d2
dead lock on command line root
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
179
diff
changeset
|
416 myRfbProto.setReconnecting(true); |
179 | 417 run(); |
175 | 418 } |
224 | 419 |
192 | 420 @Override |
421 public void setVisible(boolean b) { | |
224 | 422 SwingViewerWindow v = connectionPresenter.getViewer(); |
423 if (v != null) | |
424 v.setVisible(b); | |
192 | 425 } |
188 | 426 |
224 | 427 @Override |
428 public Socket getVNCSocket() { | |
429 return connectionPresenter.getSocket(); | |
430 } | |
202 | 431 |
204
d9d234715853
TreeManager for each interface
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
203
diff
changeset
|
432 @Override |
d9d234715853
TreeManager for each interface
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
203
diff
changeset
|
433 public boolean getShowTree() { |
d9d234715853
TreeManager for each interface
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
203
diff
changeset
|
434 return showTree; |
d9d234715853
TreeManager for each interface
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
203
diff
changeset
|
435 } |
d9d234715853
TreeManager for each interface
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
203
diff
changeset
|
436 |
225 | 437 @Override |
438 public void setWidth(int w) { | |
439 width = w; | |
440 } | |
441 | |
442 @Override | |
443 public void setHeight(int h) { | |
444 height = h; | |
445 } | |
446 | |
257 | 447 @Override |
448 public void setFixingSize(int width, int height) { | |
449 this.fixingSizeWidth = width; | |
450 this.fixingSizeHeight = height; | |
451 } | |
301 | 452 |
453 @Override | |
454 public ArrayList<Rectangle> getScreenRectangles() { | |
314 | 455 // before change the screen server, data from previous server |
301 | 456 // should be stopped. |
457 setCuiVersion(false); | |
314 | 458 // New screen server has one or more screens. |
459 // Screens are numbered in the order from left. | |
460 // put screens in an ArrayList. | |
301 | 461 ArrayList<Rectangle> rectangles = new ArrayList<Rectangle>(); |
462 GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); | |
463 GraphicsDevice[] gs = ge.getScreenDevices(); | |
314 | 464 for (GraphicsDevice gd : gs) { |
465 for (GraphicsConfiguration r : gd.getConfigurations()) { | |
466 rectangles.add(r.getBounds()); | |
301 | 467 } |
468 } | |
469 return rectangles; | |
470 } | |
471 | |
0
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
472 } |