Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413
  1. /* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved.
  2. *
  3. * This is free software; you can redistribute it and/or modify
  4. * it under the terms of the GNU General Public License as published by
  5. * the Free Software Foundation; either version 2 of the License, or
  6. * (at your option) any later version.
  7. *
  8. * This software is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. *
  13. * You should have received a copy of the GNU General Public License
  14. * along with this software; if not, write to the Free Software
  15. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
  16. * USA.
  17. */
  18. package com.tigervnc.vncviewer;
  19. import java.awt.*;
  20. import java.awt.event.*;
  21. import javax.swing.*;
  22. import javax.swing.border.*;
  23. import javax.swing.filechooser.*;
  24. import javax.swing.ImageIcon;
  25. import java.net.URL;
  26. import java.io.IOException;
  27. import com.tigervnc.rfb.*;
  28. import com.tigervnc.rfb.Exception;
  29. class OptionsDialog extends Dialog implements
  30. ActionListener,
  31. ItemListener
  32. {
  33. // Constants
  34. // Static variables
  35. static LogWriter vlog = new LogWriter("OptionsDialog");
  36. OptionsDialogCallback cb;
  37. JPanel FormatPanel, InputsPanel, MiscPanel, DefaultsPanel, SecPanel;
  38. JCheckBox autoSelect, customCompressLevel, noJpeg;
  39. JComboBox menuKey, compressLevel, qualityLevel, scalingFactor;
  40. ButtonGroup encodingGroup, colourGroup;
  41. JRadioButton zrle, hextile, tight, raw;
  42. JRadioButton fullColour, mediumColour, lowColour, veryLowColour;
  43. JCheckBox viewOnly, acceptClipboard, sendClipboard, acceptBell;
  44. JCheckBox fullScreen, shared, useLocalCursor, fastCopyRect;
  45. JCheckBox secVeNCrypt, encNone, encTLS, encX509;
  46. JCheckBox secNone, secVnc, secPlain, secIdent, sendLocalUsername;
  47. JButton okButton, cancelButton;
  48. JButton ca, crl;
  49. JButton defSaveButton;
  50. UserPrefs defaults;
  51. boolean autoScale = false;
  52. boolean fixedRatioScale = false;
  53. public OptionsDialog(OptionsDialogCallback cb_) {
  54. super(false);
  55. cb = cb_;
  56. setResizable(false);
  57. setTitle("VNC Viewer Options");
  58. defaults = new UserPrefs("vncviewer");
  59. getContentPane().setLayout(
  60. new BoxLayout(getContentPane(), BoxLayout.PAGE_AXIS));
  61. JTabbedPane tabPane = new JTabbedPane();
  62. ButtonGroup encodingGroup = new ButtonGroup();
  63. ButtonGroup colourGroup = new ButtonGroup();
  64. // Colour & Encoding tab
  65. FormatPanel=new JPanel(new GridBagLayout());
  66. autoSelect = new JCheckBox("Auto Select");
  67. autoSelect.addItemListener(this);
  68. JPanel encodingPanel = new JPanel(new GridBagLayout());
  69. encodingPanel.setBorder(BorderFactory.createTitledBorder("Preferred encoding"));
  70. zrle = addRadioCheckbox("ZRLE", encodingGroup, encodingPanel);
  71. hextile = addRadioCheckbox("Hextile", encodingGroup, encodingPanel);
  72. tight = addRadioCheckbox("Tight", encodingGroup, encodingPanel);
  73. raw = addRadioCheckbox("Raw", encodingGroup, encodingPanel);
  74. JPanel tightPanel = new JPanel(new GridBagLayout());
  75. customCompressLevel = new JCheckBox("Custom Compression Level");
  76. customCompressLevel.addItemListener(this);
  77. Object[] compressionLevels = { 1, 2, 3, 4, 5, 6 };
  78. compressLevel = new JComboBox(compressionLevels);
  79. compressLevel.setEditable(true);
  80. JLabel compressionLabel = new JLabel("Level (1=fast, 6=best [4-6 are rarely useful])");
  81. noJpeg = new JCheckBox("Allow JPEG Compression");
  82. noJpeg.addItemListener(this);
  83. Object[] qualityLevels = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
  84. qualityLevel = new JComboBox(qualityLevels);
  85. JLabel qualityLabel = new JLabel("Level (0=poor, 9=best)");
  86. compressLevel.setPreferredSize(qualityLevel.getPreferredSize());
  87. // Hack to set the left inset on editable JComboBox
  88. if (UIManager.getLookAndFeel().getID() == "Windows") {
  89. compressLevel.setBorder(BorderFactory.createCompoundBorder(compressLevel.getBorder(),
  90. BorderFactory.createEmptyBorder(0,1,0,0)));
  91. } else {
  92. ComboBoxEditor editor = compressLevel.getEditor();
  93. JTextField jtf = (JTextField)editor.getEditorComponent();
  94. jtf.setBorder(new CompoundBorder(jtf.getBorder(), new EmptyBorder(0,1,0,0)));
  95. }
  96. addGBComponent(customCompressLevel, tightPanel, 0, 0, 2, 1, 2, 2, 1, 0, GridBagConstraints.HORIZONTAL, GridBagConstraints.FIRST_LINE_START, new Insets(0,2,0,0));
  97. addGBComponent(compressLevel, tightPanel, 0, 1, 1, 1, 2, 2, 0, 0, GridBagConstraints.NONE, GridBagConstraints.FIRST_LINE_START, new Insets(0,20,0,0));
  98. addGBComponent(compressionLabel, tightPanel, 1, 1, 1, 1, 2, 2, 1, 0, GridBagConstraints.HORIZONTAL, GridBagConstraints.LINE_START, new Insets(0,5,0,0));
  99. addGBComponent(noJpeg, tightPanel, 0, 2, 2, 1, 2, 2, 1, 0, GridBagConstraints.HORIZONTAL, GridBagConstraints.FIRST_LINE_START, new Insets(0,2,0,0));
  100. addGBComponent(qualityLevel, tightPanel, 0, 3, 1, 1, 2, 2, 0, 0, GridBagConstraints.NONE, GridBagConstraints.FIRST_LINE_START, new Insets(0,20,0,0));
  101. addGBComponent(qualityLabel, tightPanel, 1, 3, 1, 1, 2, 2, 1, 0, GridBagConstraints.HORIZONTAL, GridBagConstraints.LINE_START, new Insets(0,5,0,0));
  102. JPanel colourPanel = new JPanel(new GridBagLayout());
  103. colourPanel.setBorder(BorderFactory.createTitledBorder("Colour level"));
  104. fullColour = addRadioCheckbox("Full (all available colours)", colourGroup, colourPanel);
  105. mediumColour = addRadioCheckbox("Medium (256 colours)", colourGroup, colourPanel);
  106. lowColour = addRadioCheckbox("Low (64 colours)", colourGroup, colourPanel);
  107. veryLowColour = addRadioCheckbox("Very low(8 colours)", colourGroup, colourPanel);
  108. addGBComponent(autoSelect,FormatPanel, 0, 0, 2, 1, 2, 2, 1, 0, GridBagConstraints.HORIZONTAL, GridBagConstraints.FIRST_LINE_START, new Insets(0,2,0,0));
  109. addGBComponent(encodingPanel,FormatPanel, 0, 1, 1, 1, 2, 2, 1, 0, GridBagConstraints.HORIZONTAL, GridBagConstraints.LINE_START, new Insets(0,2,0,0));
  110. addGBComponent(colourPanel,FormatPanel, 1, 1, 1, 1, 2, 2, 1, 0, GridBagConstraints.HORIZONTAL, GridBagConstraints.LINE_END, new Insets(0,2,0,0));
  111. addGBComponent(tightPanel,FormatPanel, 0, 2, 2, GridBagConstraints.REMAINDER, 2, 2, 1, 1, GridBagConstraints.HORIZONTAL, GridBagConstraints.FIRST_LINE_START, new Insets(0,2,0,0));
  112. // Inputs tab
  113. InputsPanel=new JPanel(new GridBagLayout());
  114. viewOnly = new JCheckBox("View Only (ignore mouse & keyboard)");
  115. viewOnly.addItemListener(this);
  116. acceptClipboard = new JCheckBox("Accept clipboard from server");
  117. acceptClipboard.addItemListener(this);
  118. sendClipboard = new JCheckBox("Send clipboard to server");
  119. sendClipboard.addItemListener(this);
  120. JLabel menuKeyLabel = new JLabel("Menu Key");
  121. String[] menuKeys =
  122. { "F1", "F2", "F3", "F4", "F5", "F6", "F7", "F8", "F9", "F10", "F11", "F12" };
  123. menuKey = new JComboBox(menuKeys);
  124. menuKey.addItemListener(this);
  125. addGBComponent(viewOnly,InputsPanel, 0, 0, 2, 1, 0, 0, 1, 0, GridBagConstraints.HORIZONTAL, GridBagConstraints.LINE_START, new Insets(4,4,0,4));
  126. addGBComponent(acceptClipboard,InputsPanel, 0, 1, 2, 1, 0, 0, 1, 0, GridBagConstraints.HORIZONTAL, GridBagConstraints.LINE_START, new Insets(4,4,0,4));
  127. addGBComponent(sendClipboard,InputsPanel, 0, 2, 2, 1, 0, 0, 1, 0, GridBagConstraints.HORIZONTAL, GridBagConstraints.LINE_START, new Insets(4,4,0,4));
  128. addGBComponent(menuKeyLabel,InputsPanel, 0, 3, 1, GridBagConstraints.REMAINDER, 0, 0, 1, 1, GridBagConstraints.NONE, GridBagConstraints.FIRST_LINE_START, new Insets(8,8,0,4));
  129. addGBComponent(menuKey,InputsPanel, 1, 3, 1, GridBagConstraints.REMAINDER, 0, 0, 25, 1, GridBagConstraints.NONE, GridBagConstraints.FIRST_LINE_START, new Insets(4,4,0,4));
  130. // Misc tab
  131. MiscPanel=new JPanel(new GridBagLayout());
  132. fullScreen = new JCheckBox("Full-screen mode");
  133. fullScreen.addItemListener(this);
  134. shared = new JCheckBox("Shared connection (do not disconnect other viewers)");
  135. shared.addItemListener(this);
  136. useLocalCursor = new JCheckBox("Render cursor locally");
  137. useLocalCursor.addItemListener(this);
  138. fastCopyRect = new JCheckBox("Fast CopyRect");
  139. fastCopyRect.addItemListener(this);
  140. acceptBell = new JCheckBox("Beep when requested by the server");
  141. acceptBell.addItemListener(this);
  142. JLabel scalingFactorLabel = new JLabel("Scaling Factor");
  143. Object[] scalingFactors = {
  144. "Auto", "Fixed Aspect Ratio", "50%", "75%", "95%", "100%", "105%",
  145. "125%", "150%", "175%", "200%", "250%", "300%", "350%", "400%" };
  146. scalingFactor = new JComboBox(scalingFactors);
  147. scalingFactor.setEditable(true);
  148. scalingFactor.addItemListener(this);
  149. addGBComponent(fullScreen,MiscPanel, 0, 0, 2, 1, 0, 0, 1, 0, GridBagConstraints.HORIZONTAL, GridBagConstraints.LINE_START, new Insets(4,4,0,4));
  150. addGBComponent(shared,MiscPanel, 0, 1, 2, 1, 0, 0, 1, 0, GridBagConstraints.HORIZONTAL, GridBagConstraints.LINE_START, new Insets(4,4,0,4));
  151. addGBComponent(useLocalCursor,MiscPanel, 0, 2, 2, 1, 0, 0, 1, 0, GridBagConstraints.HORIZONTAL, GridBagConstraints.LINE_START, new Insets(4,4,0,4));
  152. addGBComponent(fastCopyRect,MiscPanel, 0, 3, 2, 1, 0, 0, 1, 0, GridBagConstraints.HORIZONTAL, GridBagConstraints.LINE_START, new Insets(4,4,0,4));
  153. addGBComponent(acceptBell,MiscPanel, 0, 4, 2, 1, 0, 0, 1, 0, GridBagConstraints.HORIZONTAL, GridBagConstraints.FIRST_LINE_START, new Insets(4,4,0,4));
  154. addGBComponent(scalingFactorLabel,MiscPanel, 0, 5, 1, GridBagConstraints.REMAINDER, 0, 0, 1, 1, GridBagConstraints.NONE, GridBagConstraints.FIRST_LINE_START, new Insets(8,8,0,4));
  155. addGBComponent(scalingFactor,MiscPanel, 1, 5, 1, GridBagConstraints.REMAINDER, 0, 0, 25, 1, GridBagConstraints.NONE, GridBagConstraints.FIRST_LINE_START, new Insets(4,4,0,4));
  156. // load/save tab
  157. DefaultsPanel=new JPanel(new GridBagLayout());
  158. JPanel configPanel = new JPanel(new GridBagLayout());
  159. configPanel.setBorder(BorderFactory.createTitledBorder("Configuration File"));
  160. JButton cfReloadButton = new JButton("Reload");
  161. cfReloadButton.addActionListener(this);
  162. addGBComponent(cfReloadButton,configPanel, 0, 0, 1, 1, 0, 0, 0, 0, GridBagConstraints.HORIZONTAL, GridBagConstraints.CENTER, new Insets(4,8,4,8));
  163. JButton cfSaveButton = new JButton("Save");
  164. cfSaveButton.addActionListener(this);
  165. addGBComponent(cfSaveButton,configPanel, 0, 1, 1, 1, 0, 0, 0, 0, GridBagConstraints.HORIZONTAL, GridBagConstraints.CENTER, new Insets(4,8,4,8));
  166. JButton cfSaveAsButton = new JButton("Save As...");
  167. cfSaveAsButton.addActionListener(this);
  168. addGBComponent(cfSaveAsButton,configPanel, 0, 2, 1, 1, 0, 0, 1, 1, GridBagConstraints.HORIZONTAL, GridBagConstraints.CENTER, new Insets(4,8,4,8));
  169. cfReloadButton.setEnabled(false);
  170. cfSaveButton.setEnabled(false);
  171. //cfSaveAsButton.setEnabled(!applet);
  172. JPanel defaultsPanel = new JPanel(new GridBagLayout());
  173. defaultsPanel.setBorder(BorderFactory.createTitledBorder("Defaults"));
  174. JButton defReloadButton = new JButton("Reload");
  175. defReloadButton.addActionListener(this);
  176. addGBComponent(defReloadButton,defaultsPanel, 0, 0, 1, 1, 0, 0, 1, 0, GridBagConstraints.HORIZONTAL, GridBagConstraints.CENTER, new Insets(4,8,4,8));
  177. defSaveButton = new JButton("Save");
  178. defSaveButton.addActionListener(this);
  179. addGBComponent(defSaveButton,defaultsPanel, 0, 1, 1, 1, 0, 0, 0, 1, GridBagConstraints.HORIZONTAL, GridBagConstraints.CENTER, new Insets(4,8,4,8));
  180. addGBComponent(configPanel,DefaultsPanel, 0, 0, 1, GridBagConstraints.REMAINDER, 0, 0, 1, 1, GridBagConstraints.HORIZONTAL, GridBagConstraints.PAGE_START, new Insets(4,4,4,4));
  181. addGBComponent(defaultsPanel,DefaultsPanel, 1, 0, 1, GridBagConstraints.REMAINDER, 0, 0, 1, 1, GridBagConstraints.HORIZONTAL, GridBagConstraints.PAGE_START, new Insets(4,4,4,4));
  182. //defReloadButton.setEnabled(!applet);
  183. //defSaveButton.setEnabled(!applet);
  184. // security tab
  185. SecPanel=new JPanel(new GridBagLayout());
  186. JPanel encryptionPanel = new JPanel(new GridBagLayout());
  187. encryptionPanel.setBorder(BorderFactory.createTitledBorder("Session Encryption"));
  188. encNone = addCheckbox("None", null, encryptionPanel);
  189. encTLS = addCheckbox("Anonymous TLS", null, encryptionPanel);
  190. encX509 = addJCheckBox("TLS with X.509 certificates", null, encryptionPanel, new GridBagConstraints(0,2,1,1,1,1,GridBagConstraints.LINE_START,GridBagConstraints.REMAINDER,new Insets(0,0,0,60),0,0));
  191. JPanel x509Panel = new JPanel(new GridBagLayout());
  192. x509Panel.setBorder(BorderFactory.createTitledBorder("X.509 certificates"));
  193. ca = new JButton("Load CA certificate");
  194. ca.setPreferredSize(new Dimension(145,25));
  195. ca.addActionListener(this);
  196. crl = new JButton("Load CRL certificate");
  197. crl.setPreferredSize(new Dimension(145,25));
  198. crl.addActionListener(this);
  199. addGBComponent(ca, x509Panel, 0, 0, 1, 1, 2, 2, 0, 1, GridBagConstraints.NONE, GridBagConstraints.LINE_START, new Insets(2,2,2,2));
  200. addGBComponent(crl, x509Panel, 1, 0, 1, 1, 2, 2, 1, 1, GridBagConstraints.NONE, GridBagConstraints.LINE_START, new Insets(2,2,2,2));
  201. JPanel authPanel = new JPanel(new GridBagLayout());
  202. authPanel.setBorder(BorderFactory.createTitledBorder("Authentication"));
  203. secNone = addCheckbox("None", null, authPanel);
  204. secVnc = addCheckbox("Standard VNC", null, authPanel);
  205. secPlain = addJCheckBox("Plaintext", null, authPanel, new GridBagConstraints(0,2,1,1,1,1,GridBagConstraints.LINE_START,GridBagConstraints.NONE,new Insets(0,0,0,5),0,0));
  206. secIdent = addJCheckBox("Ident", null, authPanel, new GridBagConstraints(0,3,1,1,1,1,GridBagConstraints.LINE_START,GridBagConstraints.NONE,new Insets(0,0,0,5),0,0));
  207. sendLocalUsername = new JCheckBox("Send Local Username");
  208. sendLocalUsername.addItemListener(this);
  209. addGBComponent(sendLocalUsername, authPanel, 1, 2, 1, 2, 0, 0, 2, 1, GridBagConstraints.HORIZONTAL, GridBagConstraints.LINE_START, new Insets(0,20,0,0));
  210. secVeNCrypt = new JCheckBox("Extended encryption and authentication methods (VeNCrypt)");
  211. secVeNCrypt.addItemListener(this);
  212. addGBComponent(secVeNCrypt,SecPanel, 0, 0, 1, 1, 2, 2, 1, 0, GridBagConstraints.HORIZONTAL, GridBagConstraints.FIRST_LINE_START, new Insets(0,2,0,20));
  213. addGBComponent(encryptionPanel,SecPanel, 0, 1, 1, 1, 2, 2, 1, 0, GridBagConstraints.NONE, GridBagConstraints.LINE_START, new Insets(0,4,2,4));
  214. addGBComponent(x509Panel,SecPanel, 0, 2, 1, 1, 2, 2, 1, 0, GridBagConstraints.NONE, GridBagConstraints.LINE_START, new Insets(2,4,2,4));
  215. addGBComponent(authPanel,SecPanel, 0, 3, 1, 1, 2, 2, 1, 1, GridBagConstraints.NONE, GridBagConstraints.FIRST_LINE_START, new Insets(2,4,2,4));
  216. tabPane.add(FormatPanel);
  217. tabPane.add(InputsPanel);
  218. tabPane.add(MiscPanel);
  219. tabPane.add(DefaultsPanel);
  220. tabPane.add(SecPanel);
  221. tabPane.addTab("Colour & Encoding", FormatPanel);
  222. tabPane.addTab("Inputs", InputsPanel);
  223. tabPane.addTab("Misc", MiscPanel);
  224. tabPane.addTab("Load / Save", DefaultsPanel);
  225. tabPane.addTab("Security", SecPanel);
  226. tabPane.setBorder(BorderFactory.createEmptyBorder(4,4,0,4));
  227. okButton = new JButton("OK");
  228. okButton.setPreferredSize(new Dimension(90,30));
  229. okButton.addActionListener(this);
  230. cancelButton = new JButton("Cancel");
  231. cancelButton.setPreferredSize(new Dimension(90,30));
  232. cancelButton.addActionListener(this);
  233. JPanel buttonPane = new JPanel();
  234. buttonPane.setLayout(new BoxLayout(buttonPane, BoxLayout.LINE_AXIS));
  235. buttonPane.setBorder(BorderFactory.createEmptyBorder(4,0,0,0));
  236. buttonPane.add(Box.createHorizontalGlue());
  237. buttonPane.add(okButton);
  238. buttonPane.add(Box.createRigidArea(new Dimension(4,0)));
  239. buttonPane.add(cancelButton);
  240. buttonPane.add(Box.createRigidArea(new Dimension(4,0)));
  241. this.getContentPane().add(tabPane);
  242. this.getContentPane().add(buttonPane);
  243. pack();
  244. }
  245. public void initDialog() {
  246. if (cb != null) cb.setOptions();
  247. zrle.setEnabled(!autoSelect.isSelected());
  248. hextile.setEnabled(!autoSelect.isSelected());
  249. tight.setEnabled(!autoSelect.isSelected());
  250. raw.setEnabled(!autoSelect.isSelected());
  251. fullColour.setEnabled(!autoSelect.isSelected());
  252. mediumColour.setEnabled(!autoSelect.isSelected());
  253. lowColour.setEnabled(!autoSelect.isSelected());
  254. veryLowColour.setEnabled(!autoSelect.isSelected());
  255. compressLevel.setEnabled(customCompressLevel.isSelected());
  256. qualityLevel.setEnabled(noJpeg.isSelected());
  257. autoScale = (scalingFactor.getSelectedItem().equals("Auto"));
  258. fixedRatioScale =
  259. (scalingFactor.getSelectedItem().equals("Fixed Aspect Ratio"));
  260. sendLocalUsername.setEnabled(secVeNCrypt.isEnabled()&&
  261. (secPlain.isSelected()||secIdent.isSelected()));
  262. }
  263. JRadioButton addRadioCheckbox(String str, ButtonGroup group, JPanel panel) {
  264. JRadioButton c = new JRadioButton(str);
  265. GridBagConstraints gbc = new GridBagConstraints();
  266. gbc.anchor = GridBagConstraints.LINE_START;
  267. gbc.gridwidth = GridBagConstraints.REMAINDER;
  268. gbc.weightx = 1;
  269. gbc.weighty = 1;
  270. panel.add(c,gbc);
  271. group.add(c);
  272. c.addItemListener(this);
  273. return c;
  274. }
  275. JCheckBox addCheckbox(String str, ButtonGroup group, JPanel panel) {
  276. JCheckBox c = new JCheckBox(str);
  277. GridBagConstraints gbc = new GridBagConstraints();
  278. gbc.anchor = GridBagConstraints.LINE_START;
  279. gbc.gridwidth = GridBagConstraints.REMAINDER;
  280. gbc.weightx = 1;
  281. gbc.weighty = 1;
  282. panel.add(c,gbc);
  283. if (group != null)
  284. group.add(c);
  285. c.addItemListener(this);
  286. return c;
  287. }
  288. JCheckBox addJCheckBox(String str, ButtonGroup group, JPanel panel,
  289. GridBagConstraints gbc) {
  290. JCheckBox c = new JCheckBox(str);
  291. panel.add(c,gbc);
  292. if (group != null)
  293. group.add(c);
  294. c.addItemListener(this);
  295. return c;
  296. }
  297. public void actionPerformed(ActionEvent e) {
  298. Object s = e.getSource();
  299. if (s instanceof JButton && (JButton)s == okButton) {
  300. autoScale = (scalingFactor.getSelectedItem().equals("Auto"));
  301. fixedRatioScale =
  302. (scalingFactor.getSelectedItem().equals("Fixed Aspect Ratio"));
  303. ok = true;
  304. if (cb != null) cb.getOptions();
  305. endDialog();
  306. } else if (s instanceof JButton && (JButton)s == cancelButton) {
  307. ok = false;
  308. endDialog();
  309. } else if (s instanceof JButton && (JButton)s == defSaveButton) {
  310. try {
  311. defaults.Save();
  312. } catch (java.lang.Exception x) { }
  313. } else if (s instanceof JButton && (JButton)s == ca) {
  314. JFileChooser fc = new JFileChooser();
  315. fc.setDialogTitle("Path to X509 CA certificate");
  316. int ret = fc.showOpenDialog(this);
  317. if (ret == JFileChooser.APPROVE_OPTION)
  318. CSecurityTLS.x509ca.setParam(fc.getSelectedFile().toString());
  319. } else if (s instanceof JButton && (JButton)s == crl) {
  320. JFileChooser fc = new JFileChooser();
  321. fc.setDialogTitle("Path to X509 CRL file");
  322. int ret = fc.showOpenDialog(this);
  323. if (ret == JFileChooser.APPROVE_OPTION)
  324. CSecurityTLS.x509crl.setParam(fc.getSelectedFile().toString());
  325. }
  326. }
  327. public void itemStateChanged(ItemEvent e) {
  328. Object s = e.getSource();
  329. if (s instanceof JCheckBox && (JCheckBox)s == autoSelect) {
  330. zrle.setEnabled(!autoSelect.isSelected());
  331. hextile.setEnabled(!autoSelect.isSelected());
  332. tight.setEnabled(!autoSelect.isSelected());
  333. raw.setEnabled(!autoSelect.isSelected());
  334. fullColour.setEnabled(!autoSelect.isSelected());
  335. mediumColour.setEnabled(!autoSelect.isSelected());
  336. lowColour.setEnabled(!autoSelect.isSelected());
  337. veryLowColour.setEnabled(!autoSelect.isSelected());
  338. defaults.setPref("autoSelect",(autoSelect.isSelected()) ? "on" : "off");
  339. }
  340. if (s instanceof JCheckBox && (JCheckBox)s == customCompressLevel) {
  341. compressLevel.setEnabled(customCompressLevel.isSelected());
  342. defaults.setPref("customCompressLevel",(customCompressLevel.isSelected()) ? "on" : "off");
  343. }
  344. if (s instanceof JCheckBox && (JCheckBox)s == noJpeg) {
  345. qualityLevel.setEnabled(noJpeg.isSelected());
  346. defaults.setPref("noJpeg",(noJpeg.isSelected()) ? "on" : "off");
  347. }
  348. if (s instanceof JCheckBox && (JCheckBox)s == sendLocalUsername) {
  349. defaults.setPref("sendLocalUsername",(sendLocalUsername.isSelected()) ? "on" : "off");
  350. }
  351. if (s instanceof JCheckBox && (JCheckBox)s == secVeNCrypt) {
  352. encNone.setEnabled(secVeNCrypt.isSelected());
  353. encTLS.setEnabled(secVeNCrypt.isSelected());
  354. encX509.setEnabled(secVeNCrypt.isSelected());
  355. ca.setEnabled(secVeNCrypt.isSelected());
  356. crl.setEnabled(secVeNCrypt.isSelected());
  357. secIdent.setEnabled(secVeNCrypt.isSelected());
  358. secNone.setEnabled(secVeNCrypt.isSelected());
  359. secVnc.setEnabled(secVeNCrypt.isSelected());
  360. secPlain.setEnabled(secVeNCrypt.isSelected());
  361. sendLocalUsername.setEnabled(secVeNCrypt.isSelected());
  362. }
  363. if (s instanceof JCheckBox && (JCheckBox)s == secIdent ||
  364. s instanceof JCheckBox && (JCheckBox)s == secPlain) {
  365. sendLocalUsername.setEnabled(secIdent.isSelected()||secPlain.isSelected());
  366. }
  367. }
  368. }