org.shaker.dwu
Class DocWhatsUp

java.lang.Object
  |
  +--org.shaker.dwu.DocWhatsUp

public final class DocWhatsUp
extends java.lang.Object

This static factory provides:

Author:
Philipp Bartsch (codeshaker@gmx.net), GPL License
See Also:
an implementation example...

Field Summary
(package private) static java.io.PrintWriter PRINTWRITER
          stacktrace storage provider
(package private) static Settings SETTINGS
          A reference to the settings
(package private) static java.io.CharArrayWriter STACKWR
          stacktrace storage provider
 
Constructor Summary
private DocWhatsUp()
          Invisible constructor.
 
Method Summary
static BugProfile createBugProfile(java.lang.Object message, java.lang.String eClass)
          Returns, based on a given message, a BugProfile that will be send to the "alt" address, if not specified otherwise.
Returns null, if such a Profile has already been submitted.
static BugProfile createBugProfile(java.lang.Object message, java.lang.String eClass, java.lang.String mailTo)
          Returns, based on the given message, a BugProfile or null, if such a Profile has already been submitted.
static javax.swing.JDialog getBBDialog(java.awt.Dialog parent)
          Returns a standalone, modal and invisible dialog that contains a BlackBoard.
static javax.swing.JDialog getBBDialog(java.awt.Frame parent)
          Returns a standalone, modal and invisible dialog that contains a BlackBoard.
static BlackBoard getBlackBoard(java.awt.Window parent)
          Returns new BlackBoard panel.
static javax.swing.ImageIcon getDWUIcon()
          Returns the icon of DWU.
static int getQueueCount()
          Returns the number of currently stored Profiles in the queue.
(package private) static BugProfile[] getQueuedBugs()
          Returns all queued BugProfiles as an array.
static void main(java.lang.String[] args)
          THIS MAIN METHOD IS FOR TESTING PURPOSES ONLY!
Example:
private static void printErrorMessageAndQuit()
          Prints a console info message and exits with code 1.
static void setLocale(java.util.Locale locale)
          Sets a new locale if you don`t want DWU to use the system locale.
Please provide the appropriate language ressource file dwu.jar!/data/i10n_LOCALENAME.properties or DWU falls back to english.
static void showErrDialog(BugProfile profile, java.awt.Frame parent, java.lang.String problem, java.lang.String hint)
          Returns a BugProfile driven error dialog.
static void showMsgDialog(java.awt.Frame parent, java.lang.String problem, java.lang.String hint)
          Returns a message dialog.
static java.lang.String submitBugQueue()
          Submits the whole BugProfile queue immediately without promting.
This method needs a working mail configuration (please use a custom configuration, not the delivered one!)
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

STACKWR

static final java.io.CharArrayWriter STACKWR
stacktrace storage provider

PRINTWRITER

static final java.io.PrintWriter PRINTWRITER
stacktrace storage provider

SETTINGS

static final Settings SETTINGS
A reference to the settings
Constructor Detail

DocWhatsUp

private DocWhatsUp()
Invisible constructor. This class is a factory, so it`s not meant to be instantiated.
Method Detail

showMsgDialog

public static final void showMsgDialog(java.awt.Frame parent,
                                       java.lang.String problem,
                                       java.lang.String hint)
Returns a message dialog.
Parameters:
parent - the parental Frame
problem - problem description; shouldn`t be empty
hint - optional error hint/solution (can be empty)

showErrDialog

public static final void showErrDialog(BugProfile profile,
                                       java.awt.Frame parent,
                                       java.lang.String problem,
                                       java.lang.String hint)
Returns a BugProfile driven error dialog.
Parameters:
profile - the BugProfile
parent - the parental Frame
problem - problem description
hint - optional error solution (can be empty)

getBlackBoard

public static final BlackBoard getBlackBoard(java.awt.Window parent)
Returns new BlackBoard panel.
Parameters:
parent - the parental window object (a dialog, frame ...)
Returns:
the BlackBoard panel

getBBDialog

public static final javax.swing.JDialog getBBDialog(java.awt.Frame parent)
Returns a standalone, modal and invisible dialog that contains a BlackBoard.
Parameters:
parent - parental frame
Returns:
the BlackBoard dialog

getBBDialog

public static final javax.swing.JDialog getBBDialog(java.awt.Dialog parent)
Returns a standalone, modal and invisible dialog that contains a BlackBoard.
Parameters:
parent - parental dialog
Returns:
the BlackBoard dialog

submitBugQueue

public static final java.lang.String submitBugQueue()
Submits the whole BugProfile queue immediately without promting.
This method needs a working mail configuration (please use a custom configuration, not the delivered one!)
Returns:
empty string or an error description

createBugProfile

public static final BugProfile createBugProfile(java.lang.Object message,
                                                java.lang.String eClass,
                                                java.lang.String mailTo)
Returns, based on the given message, a BugProfile or null, if such a Profile has already been submitted.
Parameters:
message - a thrown exception or an object, that returns a description/message on toString()
eClass - error class string (your error code)
mailTo - the address where this profile has to be send to
Returns:
the bugprofile or null, if it has already been submitted

createBugProfile

public static final BugProfile createBugProfile(java.lang.Object message,
                                                java.lang.String eClass)
Returns, based on a given message, a BugProfile that will be send to the "alt" address, if not specified otherwise.
Returns null, if such a Profile has already been submitted.
Parameters:
message - a thrown exception or an object, that returns a description/message by toString()
eClass - error class string (your error code)
Returns:
the BugProfile or null, if it has already been submitted

getQueuedBugs

static BugProfile[] getQueuedBugs()
Returns all queued BugProfiles as an array.
Returns:
the BugProfile array

getQueueCount

public static int getQueueCount()
Returns the number of currently stored Profiles in the queue.
Returns:
the number of currently stored BugProfiles

getDWUIcon

public static javax.swing.ImageIcon getDWUIcon()
Returns the icon of DWU.
Returns:
the dwu icon

setLocale

public static void setLocale(java.util.Locale locale)
Sets a new locale if you don`t want DWU to use the system locale.
Please provide the appropriate language ressource file dwu.jar!/data/i10n_LOCALENAME.properties or DWU falls back to english.
Parameters:
locale - the corresponding locale

main

public static void main(java.lang.String[] args)
THIS MAIN METHOD IS FOR TESTING PURPOSES ONLY!
Example:
 try {
    foo (); //malicious method, that throws an exception
 } catch (Exception e) {
 // Create a BugProfile based on the exception object and a error 
 // category
 BugProfile bugProfile = DocWhatsUp.createBugProfile(e,
                                                     "foo-error");

 // The BugProfile gets visualised by the ErrorDoc
 // (Alternativly you can send it (and all queued Profiles too) 
 // immediately and quietly with submitBugQueue ();!)  
 DocWhatsUp.getErrDialog(bugProfile,
                         parentalFrame,
                         errorMessageForTheUser,
                         hintMessageForTheUser);

 
Parameters:
args - the argument array

printErrorMessageAndQuit

private static final void printErrorMessageAndQuit()
Prints a console info message and exits with code 1.