nl.nikhef.slcshttps.gui
Class GraphTools

java.lang.Object
  extended by nl.nikhef.slcshttps.gui.GraphTools

public class GraphTools
extends Object

Static class providing several static helper methods for user interaction via a GUI, including popup methods for confirmation, errors etc.

Version:
0.1
Author:
Mischa Sallé

Constructor Summary
GraphTools()
           
 
Method Summary
static boolean confirmPopup(String text)
          Shows a confirm (OK / cancel) popup.
static void errorPopup(String text)
          Shows an error message popup using given text (newlines replaced with <BR>).
static void errorPopup(String text, Exception e)
          Shows an error message popup using given text (newlines replaced with <BR>) and Exception (when non-null).
static boolean isGraphic()
          Method to determine if a GUI is available.
protected static void optionPaneSetFocus(JComponent c)
          Helper method to set the focus component of a JOptionPane.
static boolean retryPopup(String text)
          Shows an error message popup using given text (newlines replaced with <BR>) giving the user the option to choose to retry.
static boolean retryPopup(String text, Exception e)
          Shows an error message popup using given text (newlines replaced with <BR>) and Exception (when non-null) giving the user the option to choose to retry.
static void successPopup(String text)
          Shows a success message popup using given text.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GraphTools

public GraphTools()
Method Detail

errorPopup

public static void errorPopup(String text,
                              Exception e)
Shows an error message popup using given text (newlines replaced with <BR>) and Exception (when non-null).

Parameters:
text - text to print
e - Exception which was caught: used in errormessage, not thrown.
See Also:
retryPopup(String,Exception)

errorPopup

public static void errorPopup(String text)
Shows an error message popup using given text (newlines replaced with <BR>).

Parameters:
text - text to print
See Also:
errorPopup(String,Exception), retryPopup(String)

retryPopup

public static boolean retryPopup(String text,
                                 Exception e)
Shows an error message popup using given text (newlines replaced with <BR>) and Exception (when non-null) giving the user the option to choose to retry.

Parameters:
text - text to print
e - Exception which was caught: used in errormessage, not thrown.
Returns:
boolean true indicating whether to retry.
See Also:
errorPopup(String,Exception)

retryPopup

public static boolean retryPopup(String text)
Shows an error message popup using given text (newlines replaced with <BR>) giving the user the option to choose to retry.

Parameters:
text - text to print
Returns:
boolean true indicating whether to retry.
See Also:
errorPopup(String), retryPopup(String,Exception)

successPopup

public static void successPopup(String text)
Shows a success message popup using given text.

Parameters:
text - text to print

confirmPopup

public static boolean confirmPopup(String text)
Shows a confirm (OK / cancel) popup.

Parameters:
text - text to print
Returns:
boolean which is true upon confirmation.

isGraphic

public static boolean isGraphic()
Method to determine if a GUI is available. Works cross-platform (e.g. Linux and MacOS). Note that GraphicsEnvironment.isHeadless() is insufficient.

Returns:
boolean indicating whether a GUI is available
See Also:
GraphicsEnvironment.getLocalGraphicsEnvironment(), GraphicsEnvironment.getDefaultScreenDevice()()

optionPaneSetFocus

protected static void optionPaneSetFocus(JComponent c)
Helper method to set the focus component of a JOptionPane.

See explanation in Java bug 5018574

Parameters:
c - JComponent to give the focus.
See Also:
PasswordPopup


nl.nikhef.slcshttps Mischa Sallé - msalle(AT)nikhef.nl