net.nitus.missatges
Class MsgUtils

java.lang.Object
  extended by net.nitus.missatges.MsgUtils

public class MsgUtils
extends java.lang.Object

Static methods to generate and show messages using JOptionPane.

There are methods to generate dialogs for error, warning, and question messages.

Features:


Field Summary
static int DEFAULT_LINE_LENGTH
           
static java.lang.String errorDefaultTitle
           
static java.lang.String questionDefaultTitle
           
static java.lang.String warningDefaultTitle
           
 
Constructor Summary
MsgUtils()
           
 
Method Summary
static java.lang.Object formatMsg(java.lang.Object o)
          Splits a string into lines of DEFAULT_LINE_LENGTH length.
static java.lang.Object formatMsg(java.lang.Object o, int len)
          Splits a string into substring adjusting the substring length to a maximum of len characters.
static java.lang.String getErrorDefaultTitle()
           
static java.lang.String getQuestionDefaultTitle()
           
static java.lang.String getWarningDefaultTitle()
           
static void noFet()
          Pita i mostra un missatge amb el t�tol "No implementat:" i el missatge "Funci� no implementada.
static void noFet(java.lang.String missatge)
          Pita i mostra un missatge amb el t�tol "No implementat:" i el missatge que ens passen com a par�metre.
static void setErrorDefaultTitle(java.lang.String errorDefaultTitle)
          Sets the error messages dialogs title.
static void setQuestionDefaultTitle(java.lang.String questionDefaultTitle)
          Sets the question messages dialogs title.
static void setWarningDefaultTitle(java.lang.String newValue)
          Sets the warning messages dialogs title.
static void showError(java.awt.Component comp, java.lang.Object msg)
          Displays an error dialog using the JOptionPane.showMessageDialog() method.
static void showError(java.awt.Component comp, java.lang.Object msg, boolean formated)
          Displays an error dialog using the JOptionPane.showMessageDialog() method.
static void showError(java.awt.Component comp, java.lang.String title, java.lang.Object msg)
          Displays an error dialog using the JOptionPane.showMessageDialog() method.
static void showError(java.awt.Component comp, java.lang.String title, java.lang.Object msg, boolean formated)
          Displays an error dialog using the JOptionPane.showMessageDialog() method.
static int showQuestion(java.awt.Component comp, java.lang.Object msg)
          Shows a confirm dialog using JOptionPane.showConfirmDialog() method and the default question title.
static int showQuestion(java.awt.Component comp, java.lang.Object msg, boolean formatted)
          Shows a confirm dialog using JOptionPane.showConfirmDialog() method and the default question title.
static int showQuestion(java.awt.Component comp, java.lang.String title, java.lang.Object msg)
          Shows a confirm dialog using JOptionPane.showConfirmDialog() method.
static int showQuestion(java.awt.Component comp, java.lang.String title, java.lang.Object msg, boolean formatted)
          Shows a confirm dialog using JOptionPane.showConfirmDialog() method and the default question title.
static void showWarning(java.awt.Component comp, java.lang.Object msg)
          Mostra una caixa de di�leg d'av�s (Usa una JOptionPane).
static void showWarning(java.awt.Component comp, java.lang.Object msg, boolean formatted)
          Mostra una caixa de di�leg d'av�s (Usa una JOptionPane).
static void showWarning(java.awt.Component comp, java.lang.String title, java.lang.Object msg)
          Mostra una caixa de di�leg d'av�s (Usa una JOptionPane).
static void showWarning(java.awt.Component comp, java.lang.String title, java.lang.Object msg, boolean formatted)
          Mostra una caixa de di�leg d'av�s (Usa una JOptionPane).
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

warningDefaultTitle

public static java.lang.String warningDefaultTitle

errorDefaultTitle

public static java.lang.String errorDefaultTitle

questionDefaultTitle

public static java.lang.String questionDefaultTitle

DEFAULT_LINE_LENGTH

public static int DEFAULT_LINE_LENGTH
Constructor Detail

MsgUtils

public MsgUtils()
Method Detail

formatMsg

public static java.lang.Object formatMsg(java.lang.Object o)
Splits a string into lines of DEFAULT_LINE_LENGTH length. DEFAULT_LINE_LENGTH.

Parameters:
s - String to be formatted
Returns:
The formatted string
See Also:
formatMsg(Object, int)

formatMsg

public static java.lang.Object formatMsg(java.lang.Object o,
                                         int len)
Splits a string into substring adjusting the substring length to a maximum of len characters. The split point is ever between two words. The parameter len must be a positive whole number.

Ignores the existing line feeds into s.

Parameters:
s - String to be formatted
len - Splitted line maximum length
Returns:
The formatted string
Throws:
java.lang.IllegalArgumentException - If len is'nt a positive whole number.

getWarningDefaultTitle

public static java.lang.String getWarningDefaultTitle()
Returns:
Returns the warningDefaultTitle.

getErrorDefaultTitle

public static java.lang.String getErrorDefaultTitle()
Returns:
Returns the errorDefaultTitle.

setErrorDefaultTitle

public static void setErrorDefaultTitle(java.lang.String errorDefaultTitle)
Sets the error messages dialogs title.

Parameters:
errorDefaultTitle - The errorDefaultTitle to set.

setWarningDefaultTitle

public static void setWarningDefaultTitle(java.lang.String newValue)
Sets the warning messages dialogs title.

Parameters:
newValue - The questionDefaultTitle to set.

getQuestionDefaultTitle

public static java.lang.String getQuestionDefaultTitle()
Returns:
Returns the questionDefaultTitle.

setQuestionDefaultTitle

public static void setQuestionDefaultTitle(java.lang.String questionDefaultTitle)
Sets the question messages dialogs title.

Parameters:
questionDefaultTitle - The questionDefaultTitle to set.

showError

public static void showError(java.awt.Component comp,
                             java.lang.Object msg)
Displays an error dialog using the JOptionPane.showMessageDialog() method.

The dialog title is the errorDefaultTitle.

Parameters:
comp - java.awt.Component
msg - java.lang.Object

showError

public static void showError(java.awt.Component comp,
                             java.lang.String title,
                             java.lang.Object msg)
Displays an error dialog using the JOptionPane.showMessageDialog() method.

Parameters:
comp - java.awt.Component
title - java.lang.String
msg - java.lang.Object

showError

public static void showError(java.awt.Component comp,
                             java.lang.String title,
                             java.lang.Object msg,
                             boolean formated)
Displays an error dialog using the JOptionPane.showMessageDialog() method.

You can specify if the msg must be formatted or not.

Parameters:
comp - java.awt.Component
title - java.lang.String
msg - java.lang.Object
formated - boolean

showError

public static void showError(java.awt.Component comp,
                             java.lang.Object msg,
                             boolean formated)
Displays an error dialog using the JOptionPane.showMessageDialog() method.

The dialog title is the errorDefaultTitle.

You can specify if the msg must be formatted or not.

Parameters:
comp - java.awt.Component
msg - java.lang.Object
formated - boolean

showWarning

public static void showWarning(java.awt.Component comp,
                               java.lang.Object msg)
Mostra una caixa de di�leg d'av�s (Usa una JOptionPane).

El t�tol de la caixa de di�leg per defecte �s Aviso:.

Parameters:
comp - java.awt.Component
msg - java.lang.Object

showWarning

public static void showWarning(java.awt.Component comp,
                               java.lang.String title,
                               java.lang.Object msg)
Mostra una caixa de di�leg d'av�s (Usa una JOptionPane).

Parameters:
comp - java.awt.Component
title - java.lang.String
msg - java.lang.Object

showWarning

public static void showWarning(java.awt.Component comp,
                               java.lang.Object msg,
                               boolean formatted)
Mostra una caixa de di�leg d'av�s (Usa una JOptionPane).

El t�tol de la caixa de di�leg per defecte �s Aviso:.

Permet especificar si cal formatar el missatge o no. Creation date: (28/7/01 18:30:40)

Parameters:
comp - Determines the Frame in which the dialog is displayed; if null, or if the parentComponent has no Frame, a default Frame is used
msg - Object containing the message to display
formatted - boolean

showWarning

public static void showWarning(java.awt.Component comp,
                               java.lang.String title,
                               java.lang.Object msg,
                               boolean formatted)
Mostra una caixa de di�leg d'av�s (Usa una JOptionPane).

El t�tol de la caixa de di�leg per defecte �s Aviso:.

Permet especificar si cal formatar el missatge o no. Creation date: (28/7/01 18:30:40)

Parameters:
comp - Determines the Frame in which the dialog is displayed; if null, or if the parentComponent has no Frame, a default Frame is used
msg - Object containing the message to display
formatted - boolean

showQuestion

public static int showQuestion(java.awt.Component comp,
                               java.lang.String title,
                               java.lang.Object msg)
Shows a confirm dialog using JOptionPane.showConfirmDialog() method.

Parameters:
comp - Determines the Frame in which the dialog is displayed; if null, or if the parentComponent has no Frame, a default Frame is used
msg - Object containing the message to display
title - The dialog title
Returns:
An int indicating the option selected by the user

showQuestion

public static int showQuestion(java.awt.Component comp,
                               java.lang.Object msg)
Shows a confirm dialog using JOptionPane.showConfirmDialog() method and the default question title.

Parameters:
comp - Determines the Frame in which the dialog is displayed; if null, or if the parentComponent has no Frame, a default Frame is used
msg - Object containing the message to display
Returns:
An int indicating the option selected by the user

showQuestion

public static int showQuestion(java.awt.Component comp,
                               java.lang.Object msg,
                               boolean formatted)
Shows a confirm dialog using JOptionPane.showConfirmDialog() method and the default question title.

Parameters:
comp - Determines the Frame in which the dialog is displayed; if null, or if the parentComponent has no Frame, a default Frame is used
msg - Object containing the message to display
formatted - Indicates if the msg will be formatted with DEFAULT_LINE_LENGTH (true) or not (false)
Returns:
An int indicating the option selected by the user

showQuestion

public static int showQuestion(java.awt.Component comp,
                               java.lang.String title,
                               java.lang.Object msg,
                               boolean formatted)
Shows a confirm dialog using JOptionPane.showConfirmDialog() method and the default question title.

Parameters:
comp - Determines the Frame in which the dialog is displayed; if null, or if the parentComponent has no Frame, a default Frame is used
msg - Object containing the message to display
title - The dialog title
formatted - Indicates if the msg will be formatted with DEFAULT_LINE_LENGTH (true) or not (false)
Returns:
An int indicating the option selected by the user

noFet

public static void noFet(java.lang.String missatge)
Pita i mostra un missatge amb el t�tol "No implementat:" i el missatge que ens passen com a par�metre.

Parameters:
missatge -

noFet

public static void noFet()
Pita i mostra un missatge amb el t�tol "No implementat:" i el missatge "Funci� no implementada. Contacteu amb l'administrador."