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