From 3b5ce72032e3293557bbe15c1f4ca72590397230 Mon Sep 17 00:00:00 2001 From: Brian Hinz Date: Sun, 26 Aug 2012 18:06:52 +0000 Subject: [PATCH] Change name of menu key class to be consistent with Java style guidelines. git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@4959 3789f03b-4d11-0410-bbf8-ca57d06f2519 --- java/com/tigervnc/vncviewer/CConn.java | 8 ++-- .../com/tigervnc/vncviewer/DesktopWindow.java | 2 +- java/com/tigervnc/vncviewer/F8Menu.java | 2 +- .../vncviewer/{menukey.java => MenuKey.java} | 37 +++++++++++-------- .../com/tigervnc/vncviewer/OptionsDialog.java | 6 +-- 5 files changed, 31 insertions(+), 24 deletions(-) rename java/com/tigervnc/vncviewer/{menukey.java => MenuKey.java} (76%) diff --git a/java/com/tigervnc/vncviewer/CConn.java b/java/com/tigervnc/vncviewer/CConn.java index 2faf787d..814b0df7 100644 --- a/java/com/tigervnc/vncviewer/CConn.java +++ b/java/com/tigervnc/vncviewer/CConn.java @@ -165,7 +165,7 @@ public class CConn extends CConnection autoSelect = viewer.autoSelect.getValue(); formatChange = false; encodingChange = false; fullScreen = viewer.fullScreen.getValue(); - menuKeyCode = menukey.getMenuKeyCode(); + menuKeyCode = MenuKey.getMenuKeyCode(); options = new OptionsDialog(this); options.initDialog(); clipboardDialog = new ClipboardDialog(this); @@ -875,7 +875,7 @@ public class CConn extends CConnection options.viewOnly.setSelected(viewer.viewOnly.getValue()); options.acceptClipboard.setSelected(viewer.acceptClipboard.getValue()); options.sendClipboard.setSelected(viewer.sendClipboard.getValue()); - options.menuKey.setSelectedItem(KeyEvent.getKeyText(menukey.getMenuKeyCode())); + options.menuKey.setSelectedItem(KeyEvent.getKeyText(MenuKey.getMenuKeyCode())); options.sendLocalUsername.setSelected(viewer.sendLocalUsername.getValue()); if (state() == RFBSTATE_NORMAL) { @@ -1067,8 +1067,8 @@ public class CConn extends CConnection } clipboardDialog.setSendingEnabled(viewer.sendClipboard.getValue()); - viewer.menuKey.setParam(menukey.getMenuKeySymbols()[options.menuKey.getSelectedIndex()].name); - F8Menu.f8.setText("Send "+KeyEvent.getKeyText(menukey.getMenuKeyCode())); + viewer.menuKey.setParam(MenuKey.getMenuKeySymbols()[options.menuKey.getSelectedIndex()].name); + F8Menu.f8.setText("Send "+KeyEvent.getKeyText(MenuKey.getMenuKeyCode())); setShared(options.shared.isSelected()); viewer.useLocalCursor.setParam(options.useLocalCursor.isSelected()); diff --git a/java/com/tigervnc/vncviewer/DesktopWindow.java b/java/com/tigervnc/vncviewer/DesktopWindow.java index 3ef25f3a..27d1dce7 100644 --- a/java/com/tigervnc/vncviewer/DesktopWindow.java +++ b/java/com/tigervnc/vncviewer/DesktopWindow.java @@ -409,7 +409,7 @@ class DesktopWindow extends JPanel implements public void keyReleased(KeyEvent e) {} /** Handle the key-pressed event. */ public void keyPressed(KeyEvent e) { - if (e.getKeyCode() == menukey.getMenuKeyCode()) { + if (e.getKeyCode() == MenuKey.getMenuKeyCode()) { int sx = (scaleWidthRatio == 1.00) ? lastX : (int)Math.floor(lastX*scaleWidthRatio); int sy = (scaleHeightRatio == 1.00) diff --git a/java/com/tigervnc/vncviewer/F8Menu.java b/java/com/tigervnc/vncviewer/F8Menu.java index 317caf35..b346db95 100644 --- a/java/com/tigervnc/vncviewer/F8Menu.java +++ b/java/com/tigervnc/vncviewer/F8Menu.java @@ -51,7 +51,7 @@ public class F8Menu extends JPopupMenu implements ActionListener { addSeparator(); clipboard = addMenuItem("Clipboard..."); addSeparator(); - f8 = addMenuItem("Send "+KeyEvent.getKeyText(menukey.getMenuKeyCode()), menukey.getMenuKeyCode()); + f8 = addMenuItem("Send "+KeyEvent.getKeyText(MenuKey.getMenuKeyCode()), MenuKey.getMenuKeyCode()); ctrlAltDel = addMenuItem("Send Ctrl-Alt-Del"); addSeparator(); refresh = addMenuItem("Refresh Screen", KeyEvent.VK_H); diff --git a/java/com/tigervnc/vncviewer/menukey.java b/java/com/tigervnc/vncviewer/MenuKey.java similarity index 76% rename from java/com/tigervnc/vncviewer/menukey.java rename to java/com/tigervnc/vncviewer/MenuKey.java index 10f1d103..0a240149 100644 --- a/java/com/tigervnc/vncviewer/menukey.java +++ b/java/com/tigervnc/vncviewer/MenuKey.java @@ -24,7 +24,7 @@ import java.awt.event.KeyEvent; import com.tigervnc.rfb.*; -public class menukey +public class MenuKey { static class MenuKeySymbol { public MenuKeySymbol(String name_, int keycode_) { @@ -59,28 +59,35 @@ public class menukey new MenuKeySymbol("Page_Down", KeyEvent.VK_PAGE_DOWN) }; - static int getMenuKeySymbolCount() - { + static int getMenuKeySymbolCount() { return menuSymbols.length; } - public static MenuKeySymbol[] getMenuKeySymbols() - { + public static MenuKeySymbol[] getMenuKeySymbols() { return menuSymbols; } + + public static String getMenuKeyValueStr() { + String s = ""; + for (int i = 0; i < getMenuKeySymbolCount(); i++) { + s += menuSymbols[i].name; + if (i < getMenuKeySymbolCount() - 1) + s += ", "; + } + return s; + } - static int getMenuKeyCode() - { - String menuKeyStr; - int menuKeyCode = KeyEvent.VK_F8; + static int getMenuKeyCode() { + String menuKeyStr; + int menuKeyCode = KeyEvent.VK_F8; - menuKeyStr = - Configuration.global().getParam("menuKey").getValueStr(); - for(int i = 0; i < getMenuKeySymbolCount(); i++) - if (menuSymbols[i].name.equals(menuKeyStr)) - menuKeyCode = menuSymbols[i].keycode; + menuKeyStr = + Configuration.global().getParam("menuKey").getValueStr(); + for(int i = 0; i < getMenuKeySymbolCount(); i++) + if (menuSymbols[i].name.equals(menuKeyStr)) + menuKeyCode = menuSymbols[i].keycode; - return menuKeyCode; + return menuKeyCode; } } diff --git a/java/com/tigervnc/vncviewer/OptionsDialog.java b/java/com/tigervnc/vncviewer/OptionsDialog.java index 1be5ece8..afeaf2d7 100644 --- a/java/com/tigervnc/vncviewer/OptionsDialog.java +++ b/java/com/tigervnc/vncviewer/OptionsDialog.java @@ -132,9 +132,9 @@ class OptionsDialog extends Dialog implements sendClipboard = new JCheckBox("Send clipboard to server"); sendClipboard.addItemListener(this); JLabel menuKeyLabel = new JLabel("Menu Key"); - String[] menuKeys = new String[menukey.getMenuKeySymbolCount()]; - for (int i = 0; i < menukey.getMenuKeySymbolCount(); i++) - menuKeys[i] = KeyEvent.getKeyText(menukey.getMenuKeySymbols()[i].keycode); + String[] menuKeys = new String[MenuKey.getMenuKeySymbolCount()]; + for (int i = 0; i < MenuKey.getMenuKeySymbolCount(); i++) + menuKeys[i] = KeyEvent.getKeyText(MenuKey.getMenuKeySymbols()[i].keycode); menuKey = new JComboBox(menuKeys); menuKey.addItemListener(this); addGBComponent(viewOnly,InputsPanel, 0, 0, 2, 1, 2, 2, 1, 0, GridBagConstraints.HORIZONTAL, GridBagConstraints.LINE_START, new Insets(4,5,0,5)); -- 2.39.5