1 // Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
2 // Jad home page: http://www.kpdus.com/jad.html
3 // Decompiler options: packimports(3) fieldsfirst nonlb space
8 import java.awt.event.*;
10 import java.util.ArrayList;
13 // Referenced classes of package mcsClient:
14 // DefaultKeyArray, SavedSettings, Row, ComboKeyArray,
15 // KeyData, McsKeyAdapter, McsToolBar, DatagramReader
17 public final class Options extends JFrame
18 implements KeyListener, ActionListener {
20 public static final int MAX_BUTTONS = 12;
21 public static final int MAX_KEYS = 4;
22 public static final int EXPECTED_PREFS_VER = 1;
23 public static final int EXPECTED_COMBO_KEYS_VER = 1;
24 protected static final String EMPTY = "";
25 protected static final String CLEAR = "Clear";
26 private static final String KEY_FILE_NAME = "keys.dat";
27 private static final String PREFS_FILE_NAME = "prefs.dat";
28 private static final String RESTORE = "Restore Defaults";
29 private static final String CANCEL = "Cancel Changes";
30 private static final String SAVE = "Save Buttons";
31 private final DefaultKeyArray defaultKeys = new DefaultKeyArray();
33 private JButton restore;
34 private JButton cancel;
36 private String hostName;
37 private McsKeyAdapter keyAdapter;
38 private McsToolBar toolBar;
39 private McsToolBar countryKeyBar;
40 private JComboBox kbSelector;
41 private static final String KEYBOARDS[] = {
42 "US 104-key keyboard", "Belgian 105-key keyboard", "French 105-key keyboard", "German 105-key keyboard", "Italian 105-key keyboard (142)", "Japanese 109-key keyboard", "Spanish 105-key keyboard", "UK 105-key keyboard"
44 private JComboBox mouseSyncKey;
45 private static final String SYNC_KEYS[] = {
46 "None", "Escape", "Alt", "Right Mouse Button"
48 public static final String NO_KEY_SET = SYNC_KEYS[0];
49 public static final String RIGHT_MOUSE = SYNC_KEYS[3];
50 private SavedSettings savedSettings;
52 public Options(String s, McsKeyAdapter mcskeyadapter, DatagramReader datagramreader, McsToolBar mcstoolbar, McsToolBar mcstoolbar1) {
53 restore = new JButton("Restore Defaults");
54 cancel = new JButton("Cancel Changes");
55 save = new JButton("Save Buttons");
57 keyAdapter = mcskeyadapter;
59 countryKeyBar = mcstoolbar1;
60 restore.addActionListener(this);
61 restore.addKeyListener(this);
62 cancel.addActionListener(this);
63 cancel.addKeyListener(this);
64 save.addActionListener(this);
65 save.addKeyListener(this);
66 restore.setToolTipText("Restore buttons to factory default settings.");
67 cancel.setToolTipText("Cancel changes made to button settings.");
68 save.setToolTipText("Save changes made to button settings.");
69 setTitle("Remote Console Preferences");
70 setDefaultCloseOperation(1);
73 UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
75 catch (Exception exception) { }
77 savedSettings = (SavedSettings)getSerializedObject("prefs.dat");
79 catch (Exception exception1) {
80 savedSettings = new SavedSettings();
82 JPanel jpanel = new JPanel();
83 jpanel.setLayout(new GridBagLayout());
84 jpanel.setBackground(getBackground());
85 GridBagConstraints gridbagconstraints = new GridBagConstraints();
86 gridbagconstraints.fill = 0;
87 gridbagconstraints.anchor = 10;
88 gridbagconstraints.weightx = 1.0D;
89 gridbagconstraints.weighty = 1.0D;
90 gridbagconstraints.insets = new Insets(20, 20, 20, 20);
91 JTextArea jtextarea = new JTextArea("You can create key buttons to represent common key combinations or keys that would\nbe trapped by your computer. Create and customize the remote console key buttons\nby typing a key into each box below. Click on Save Buttons when you are finished, and \nthe customized buttons will appear on your console control bar.\n\nSimulate the Print Screen key by pressing and holding the 'P' key for 3 seconds.");
92 jtextarea.setBackground(getBackground());
93 jtextarea.setEditable(false);
94 jtextarea.setFont(new Font("Sans Serif", 0, 12));
95 add(jtextarea, jpanel, gridbagconstraints, 0, 0, 10, 4);
96 gridbagconstraints.insets = new Insets(0, 0, 0, 0);
97 JPanel jpanel1 = new JPanel();
99 for (int i = 0; i < 12; i++) {
100 row[i] = new Row(i + 1, this);
104 jpanel1.setPreferredSize(new Dimension((int)row[1].getPreferredSize().getWidth(), 12 * ((int)row[1].getPreferredSize().getHeight() + 10)));
105 JScrollPane jscrollpane = new JScrollPane(jpanel1);
106 jscrollpane.setPreferredSize(new Dimension((int)row[1].getPreferredSize().getWidth() + 30, 300));
107 add(jscrollpane, jpanel, gridbagconstraints, 0, 10, 10, 1);
108 jscrollpane.validate();
110 gridbagconstraints.anchor = 17;
111 gridbagconstraints.insets = new Insets(14, 20, 8, 0);
112 add(restore, jpanel, gridbagconstraints, 0, 22, 1, 1);
113 gridbagconstraints.anchor = 10;
114 gridbagconstraints.insets = new Insets(14, 0, 8, 0);
115 add(cancel, jpanel, gridbagconstraints, 4, 22, 1, 1);
116 gridbagconstraints.anchor = 13;
117 gridbagconstraints.insets = new Insets(14, 0, 8, 20);
118 add(save, jpanel, gridbagconstraints, 8, 22, 1, 1);
120 ComboKeyArray combokeyarray = (ComboKeyArray)getSerializedObject("keys.dat");
121 if (combokeyarray.getVersion() != 1)
122 throw new IOException("Old version of ComboKeyArray found.");
123 loadButtonArray(combokeyarray);
125 catch (ClassNotFoundException classnotfoundexception) {
126 System.out.println(classnotfoundexception);
128 catch (IOException ioexception) {
129 loadButtonArray(defaultKeys);
132 JTabbedPane jtabbedpane = new JTabbedPane();
133 jtabbedpane.setBackground(getBackground());
134 getContentPane().setLayout(new FlowLayout(0, 1, 5));
135 getContentPane().add(jtabbedpane);
136 jtabbedpane.addTab("Key Buttons", jpanel);
137 gridbagconstraints.insets = new Insets(20, 20, 0, 20);
138 gridbagconstraints.anchor = 11;
139 JPanel jpanel2 = new JPanel();
140 jpanel2.setLayout(new GridBagLayout());
141 jpanel2.setBackground(getBackground());
142 JTextArea jtextarea1 = new JTextArea("The keyboard selector enables you to select the keyboard type that will be emulated.");
143 jtextarea1.setBackground(getBackground());
144 jtextarea1.setEditable(false);
145 jtextarea1.setFont(new Font("Sans Serif", 0, 12));
146 add(jtextarea1, jpanel2, gridbagconstraints, 0, 0, 20, 8);
147 kbSelector = new JComboBox(KEYBOARDS);
148 kbSelector.setToolTipText("Keyboard type selector");
149 kbSelector.addActionListener(new ActionListener() {
151 public void actionPerformed(ActionEvent actionevent) {
152 String s1 = (String)kbSelector.getSelectedItem();
153 for (int j = 0; j < Options.KEYBOARDS.length; j++) {
154 if (!s1.equals(Options.KEYBOARDS[j]))
156 countryKeyBar.populateCountryKeyBar(j);
157 keyAdapter.setKeyboardType(j);
158 System.out.println("Keyboard selected: " + j);
160 savedSettings.setKeyboardNum(j);
161 saveSerializedObject("prefs.dat", savedSettings);
163 catch (IOException ioexception1) {
164 System.out.println("Could not save keyboard number.");
173 JPanel jpanel3 = new JPanel();
174 javax.swing.border.TitledBorder titledborder = BorderFactory.createTitledBorder("Keyboard Type");
175 jpanel3.setBorder(titledborder);
176 jpanel3.setBackground(getBackground());
177 jpanel3.add(kbSelector);
178 add(jpanel3, jpanel2, gridbagconstraints, 10, 8, 1, 1);
179 jtabbedpane.addTab("Keyboard Type", jpanel2);
180 JPanel jpanel4 = new JPanel();
181 jpanel4.setLayout(new GridBagLayout());
182 jpanel4.setBackground(getBackground());
183 JTextArea jtextarea2 = new JTextArea("The mouse sync selector enables you to designate the key or mouse button to use\nin order to align the client and server mouse cursors with each other. When you\nneed to synchronize the cursors, hold down the designated key or mouse button and\nmove the client mouse until the cursors are aligned. The server's mouse cursor\nwill not move while the designated key or button is held down.\n\nNote that using the mouse sync key or button may have the effect of making it\nimpossible to reach regions of the console with your mouse if a large correction is\nrequired. If necessary, close the Remote Control window and restart to realign the\ncursors.");
184 jtextarea2.setBackground(getBackground());
185 jtextarea2.setEditable(false);
186 jtextarea2.setFont(new Font("Sans Serif", 0, 12));
187 add(jtextarea2, jpanel4, gridbagconstraints, 0, 0, 20, 8);
188 keyAdapter.setMouseSyncKey(SYNC_KEYS[0]);
189 mouseSyncKey = new JComboBox(SYNC_KEYS);
190 mouseSyncKey.setToolTipText("Mouse synchronization key or button");
191 mouseSyncKey.addActionListener(new ActionListener() {
193 public void actionPerformed(ActionEvent actionevent) {
194 keyAdapter.setMouseSyncKey((String)mouseSyncKey.getSelectedItem());
196 savedSettings.setMouseSyncKeyNum(mouseSyncKey.getSelectedIndex());
197 saveSerializedObject("prefs.dat", savedSettings);
199 catch (IOException ioexception1) {
200 System.out.println("Could not save mouse sync key number.");
206 JPanel jpanel5 = new JPanel();
207 javax.swing.border.TitledBorder titledborder1 = BorderFactory.createTitledBorder("Mouse Sync");
208 jpanel5.setBorder(titledborder1);
209 jpanel5.setBackground(getBackground());
210 jpanel5.add(mouseSyncKey);
211 add(jpanel5, jpanel4, gridbagconstraints, 10, 8, 1, 1);
212 jtabbedpane.addTab("Mouse Sync", jpanel4);
213 if (savedSettings.getVersion() == 1) {
214 kbSelector.setSelectedIndex(savedSettings.getKeyboardNum());
215 mouseSyncKey.setSelectedIndex(savedSettings.getMouseSyncKeyNum());
220 public void actionPerformed(ActionEvent actionevent) {
221 if (actionevent.getSource() == restore)
222 loadButtonArray(defaultKeys);
224 if (actionevent.getSource() == cancel)
226 loadButtonArray((ComboKeyArray)getSerializedObject("keys.dat"));
228 catch (ClassNotFoundException classnotfoundexception) {
229 System.out.println(classnotfoundexception);
231 catch (IOException ioexception) {
232 loadButtonArray(defaultKeys);
235 if (actionevent.getSource() == save)
239 public void keyPressed(KeyEvent keyevent) {
240 if (keyevent.getKeyCode() != 10)
242 if (keyevent.getSource() == restore)
243 loadButtonArray(defaultKeys);
245 if (keyevent.getSource() == cancel)
247 loadButtonArray((ComboKeyArray)getSerializedObject("keys.dat"));
249 catch (ClassNotFoundException classnotfoundexception) {
250 System.out.println(classnotfoundexception);
252 catch (IOException ioexception) {
253 loadButtonArray(defaultKeys);
256 if (keyevent.getSource() == save)
260 public void keyTyped(KeyEvent keyevent) {
264 public void keyReleased(KeyEvent keyevent) {
267 protected void getFocusOnSaveButton() {
271 private void add(Component component, JPanel jpanel, GridBagConstraints gridbagconstraints, int i, int j, int k, int l) {
272 gridbagconstraints.gridx = i;
273 gridbagconstraints.gridy = j;
274 gridbagconstraints.gridwidth = k;
275 gridbagconstraints.gridheight = l;
276 jpanel.add(component, gridbagconstraints);
279 private void saveButtonClicked() {
280 ComboKeyArray combokeyarray = new ComboKeyArray();
281 for (int i = 0; i < 12; i++)
282 if (row[i].isValid()) {
283 ArrayList arraylist = new ArrayList();
284 for (int j = 0; j < 4; j++) {
285 String s = row[i].keyField[j].getText();
287 KeyData keydata = new KeyData(s, row[i].usageCode[j]);
288 arraylist.add(keydata);
292 combokeyarray.setKeysForButton(i, arraylist);
296 saveSerializedObject("keys.dat", combokeyarray);
298 catch (IOException ioexception) {
299 System.out.println(ioexception);
301 toolBar.buildCustomizedButtonBar(combokeyarray);
304 private void loadButtonArray(ComboKeyArray combokeyarray) {
305 for (int i = 0; i < 12; i++) {
306 row[i].setValid(false);
307 ArrayList arraylist = combokeyarray.getKeysForButton(i);
308 for (int j = 0; j < 4; j++) {
310 if (arraylist != null && j < arraylist.size()) {
311 keydata = (KeyData)arraylist.get(j);
312 row[i].setValid(true);
314 keydata = new KeyData("", 0);
316 row[i].keyField[j].setText(keydata.getKeyName());
317 row[i].usageCode[j] = keydata.getUsageCode();
324 private Object getSerializedObject(String s) throws ClassNotFoundException, IOException {
325 File file = new File(System.getProperty("user.home"), "IBM");
326 File file1 = new File(file, hostName);
327 File file2 = new File(file1, s);
328 FileInputStream fileinputstream = new FileInputStream(file2);
329 ObjectInputStream objectinputstream = new ObjectInputStream(fileinputstream);
330 Object obj = objectinputstream.readObject();
331 objectinputstream.close();
335 private void saveSerializedObject(String s, Object obj) throws IOException {
336 File file = new File(System.getProperty("user.home"), "IBM");
338 File file1 = new File(file, hostName);
340 File file2 = new File(file1, s);
341 FileOutputStream fileoutputstream = new FileOutputStream(file2);
342 ObjectOutputStream objectoutputstream = new ObjectOutputStream(fileoutputstream);
343 objectoutputstream.writeObject(obj);
344 objectoutputstream.flush();
345 objectoutputstream.close();