From be52981bcc983dfb90c5aa7ca051c2f6d38d6f52 Mon Sep 17 00:00:00 2001 From: Fredrik Osterlind Date: Fri, 1 Jun 2012 10:49:56 +0200 Subject: [PATCH] added getting started quickhelp menu item, made quick help sticky --- tools/cooja/java/se/sics/cooja/GUI.java | 38 +++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/tools/cooja/java/se/sics/cooja/GUI.java b/tools/cooja/java/se/sics/cooja/GUI.java index 6112ea43f..c47460ae1 100644 --- a/tools/cooja/java/se/sics/cooja/GUI.java +++ b/tools/cooja/java/se/sics/cooja/GUI.java @@ -387,11 +387,28 @@ public class GUI extends Observable { )); quickHelpScroll.setVisible(false); loadQuickHelp("KEYBOARD_SHORTCUTS"); + loadQuickHelp("GETTING_STARTED"); // Load default and overwrite with user settings (if any) loadExternalToolsDefaultSettings(); loadExternalToolsUserSettings(); + final boolean showQuickhelp = getExternalToolsSetting("SHOW_QUICKHELP", "true").equalsIgnoreCase("true"); + if (showQuickhelp) { + SwingUtilities.invokeLater(new Runnable() { + public void run() { + JCheckBoxMenuItem checkBox = ((JCheckBoxMenuItem)showQuickHelpAction.getValue("checkbox")); + if (checkBox == null) { + return; + } + if (checkBox.isSelected()) { + return; + } + checkBox.doClick(); + } + }); + } + /* Debugging - Break on repaints outside EDT */ /*RepaintManager.setCurrentManager(new RepaintManager() { public void addDirtyRegion(JComponent comp, int a, int b, int c, int d) { @@ -1003,6 +1020,7 @@ public class GUI extends Observable { /* Help */ menu = new JMenu("Help"); menu.setMnemonic(KeyEvent.VK_H); + menu.add(new JMenuItem(showGettingStartedAction)); menu.add(new JMenuItem(showKeyboardShortcutsAction)); JCheckBoxMenuItem checkBox = new JCheckBoxMenuItem(showQuickHelpAction); showQuickHelpAction.putValue("checkbox", checkBox); @@ -1971,6 +1989,7 @@ public class GUI extends Observable { * @return Plugin instance * @deprecated */ + @Deprecated public Plugin getStartedPlugin(String classname) { return getPlugin(classname); } @@ -4502,6 +4521,7 @@ public class GUI extends Observable { boolean show = ((JCheckBoxMenuItem) e.getSource()).isSelected(); quickHelpTextPane.setVisible(show); quickHelpScroll.setVisible(show); + setExternalToolsSetting("SHOW_QUICKHELP", new Boolean(show).toString()); ((JPanel)frame.getContentPane()).revalidate(); updateDesktopSize(getDesktopPane()); } @@ -4510,6 +4530,24 @@ public class GUI extends Observable { return true; } }; + GUIAction showGettingStartedAction = new GUIAction("Getting started") { + private static final long serialVersionUID = 2382848024856978524L; + public void actionPerformed(ActionEvent e) { + loadQuickHelp("GETTING_STARTED"); + JCheckBoxMenuItem checkBox = ((JCheckBoxMenuItem)showQuickHelpAction.getValue("checkbox")); + if (checkBox == null) { + return; + } + if (checkBox.isSelected()) { + return; + } + checkBox.doClick(); + } + + public boolean shouldBeEnabled() { + return true; + } + }; GUIAction showKeyboardShortcutsAction = new GUIAction("Keyboard shortcuts") { private static final long serialVersionUID = 2382848024856978524L; public void actionPerformed(ActionEvent e) {