Improves the ErrorDialog, which can now display html tags correctly (originally proposed by Daniel Veljjanoski).

cusax-fix
Vincent Lucas 18 years ago
parent 6deaaac532
commit ad539ebdf2

@ -43,7 +43,7 @@ public class ErrorDialog
private StyledHTMLEditorPane htmlMsgEditorPane = new StyledHTMLEditorPane();
private SIPCommMsgTextArea msgTextArea = new SIPCommMsgTextArea();
private JLabel msgJLabel = new JLabel();
private JTextArea stackTraceTextArea = new JTextArea();
@ -57,6 +57,13 @@ public class ErrorDialog
private JPanel mainPanel = new JPanel(new BorderLayout(10, 10));
/**
* Set visible or hide the details of the error.
* By default, this boolean is set to true, beacause while initialization it
* will be reversed and set to false.
*/
private boolean isDetailsShowed = true;
public static final int WARNING = 1;
public static final int ERROR = 0;
@ -89,12 +96,9 @@ public ErrorDialog( Frame owner,
this.infoMessagePanel.setLayout(
new BoxLayout(infoMessagePanel, BoxLayout.Y_AXIS));
this.infoMessagePanel.add(msgTextArea);
this.msgTextArea.setLineWrap(true);
this.msgTextArea.setWrapStyleWord(true);
this.msgTextArea.setText(message);
msgJLabel.setText("<html><body><p align=\"left\">"+message+"</p></body></html>");
this.infoMessagePanel.add(msgJLabel);
this.init();
}
@ -120,14 +124,7 @@ public ErrorDialog( Frame owner,
this.htmlMsgEditorPane.addHyperlinkListener(this);
String startDivTag = "<DIV id=\"message\">";
String endDivTag = "</DIV>";
String msgString = startDivTag
+ " <A href=''>more info</A>"
+ endDivTag;
htmlMsgEditorPane.appendToEnd(msgString);
displayOrHideDetails();
this.infoMessagePanel.add(htmlMsgEditorPane);
@ -198,12 +195,37 @@ private void init()
}
/**
* Sets the message to be displayed.
* @param message The message to be displayed.
* This function show (if previously hided) or hide (if previously showed) the details of the error.
* Function called when the "more" link is clicked.
*/
public void setMessage(String message)
public void displayOrHideDetails()
{
this.msgTextArea.setText(message);
String startDivTag = "<div id=\"message\">";
String endDivTag = "</div>";
String msgString;
isDetailsShowed = !isDetailsShowed;
if(isDetailsShowed)
{
msgString = startDivTag
+ " <p align=\"right\"><a href=\"\">&lt;&lt; Hide info</a></p>"
+ endDivTag;
this.messagePanel.add(stackTraceScrollPane, BorderLayout.CENTER);
}
else
{
msgString = startDivTag
+ " <p align=\"right\"><a href=\"\">More info &gt;&gt;</a></p>"
+ endDivTag;
this.messagePanel.remove(stackTraceScrollPane);
}
htmlMsgEditorPane.setText(msgString);
this.messagePanel.revalidate();
this.messagePanel.repaint();
this.pack();
}
/**
@ -237,19 +259,28 @@ public void actionPerformed(ActionEvent e)
this.dispose();
}
/**
* Close the ErrorDialog. This function is invoked when user
* presses the Escape key.
*
* @param isEscaped Specifies whether the close was triggered by pressing
* the escape key.
*/
protected void close(boolean isEscaped)
{
this.okButton.doClick();
}
/**
* Update the ErrorDialog when the user clicks on the hyperlink.
*
* @param e The event generated by the click on the hyperlink.
*/
public void hyperlinkUpdate(HyperlinkEvent e)
{
if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED)
{
this.messagePanel.add(stackTraceScrollPane, BorderLayout.CENTER);
this.messagePanel.revalidate();
this.messagePanel.repaint();
this.pack();
displayOrHideDetails();
}
}
}

@ -13,5 +13,5 @@
*/
public class NightlyBuildID
{
public static final String BUILD_ID="0.build.by.SVN";
public static final String BUILD_ID="0.build.by.chenzo";
}

Loading…
Cancel
Save