import javax.swing.JProgressBar;
import javax.swing.SwingUtilities;
import javax.swing.event.HyperlinkEvent;
+import javax.swing.event.HyperlinkEvent.EventType;
import javax.swing.event.MenuEvent;
import javax.swing.event.MenuListener;
-import javax.swing.event.HyperlinkEvent.EventType;
/**
* Jalview Desktop
else
{
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
- setBounds((int) (screenSize.width - 900) / 2,
- (int) (screenSize.height - 650) / 2, 900, 650);
+ setBounds((screenSize.width - 900) / 2,
+ (screenSize.height - 650) / 2, 900, 650);
}
jconsole = new Console(this, showjconsole);
// add essential build information
{
try
{
- ClassLoader cl = jalview.gui.Desktop.class.getClassLoader();
- java.net.URL url = javax.help.HelpSet.findHelpSet(cl, "help/help");
- javax.help.HelpSet hs = new javax.help.HelpSet(cl, url);
-
- javax.help.HelpBroker hb = hs.createHelpBroker();
- hb.setCurrentID("home");
- hb.setDisplayed(true);
+ Help.showHelpWindow();
} catch (Exception ex)
{
}
"call setProgressBar before registering the progress bar's handler.");
}
progressBarHandlers.put(new Long(id), handler);
- final JPanel progressPanel = (JPanel) progressBars.get(new Long(id));
+ final JPanel progressPanel = progressBars.get(new Long(id));
if (handler.canCancel())
{
JButton cancel = new JButton(
--- /dev/null
+package jalview.gui;
+
+import java.net.URL;
+
+import javax.help.HelpBroker;
+import javax.help.HelpSet;
+import javax.help.HelpSetException;
+
+/**
+ * Utility class to show the help documentation window.
+ *
+ * @author gmcarstairs
+ *
+ */
+public class Help
+{
+
+ private static final long HALF_A_MO = 500; // half a second
+
+ private static long lastOpenedTime = 0L;
+
+ /**
+ * Not instantiable
+ */
+ private Help()
+ {
+
+ }
+
+ /**
+ * Show help text in a new window. But do nothing if within half a second of
+ * the last invocation.
+ *
+ * This is a workaround for issue JAL-914 - both Desktop and AlignFrame
+ * responding to F1 key, resulting in duplicate help windows opened.
+ *
+ * @throws HelpSetException
+ */
+ public static void showHelpWindow() throws HelpSetException
+ {
+ long timeNow = System.currentTimeMillis();
+
+ if (timeNow - lastOpenedTime > HALF_A_MO)
+ {
+ lastOpenedTime = timeNow;
+ ClassLoader cl = Desktop.class.getClassLoader();
+ URL url = HelpSet.findHelpSet(cl, "help/help"); // $NON-NLS-$
+ HelpSet hs = new HelpSet(cl, url);
+
+ HelpBroker hb = hs.createHelpBroker();
+ hb.setCurrentID("home");
+ hb.setDisplayed(true);
+ }
+ }
+}