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