From ad539ebdf2dc1c7d4516ef02a61379a5d97aedec Mon Sep 17 00:00:00 2001 From: Vincent Lucas Date: Fri, 6 Jun 2008 21:40:07 +0000 Subject: [PATCH] Improves the ErrorDialog, which can now display html tags correctly (originally proposed by Daniel Veljjanoski). --- .../impl/gui/customcontrols/ErrorDialog.java | 77 +++++++++++++------ .../impl/version/NightlyBuildID.java | 2 +- 2 files changed, 55 insertions(+), 24 deletions(-) diff --git a/src/net/java/sip/communicator/impl/gui/customcontrols/ErrorDialog.java b/src/net/java/sip/communicator/impl/gui/customcontrols/ErrorDialog.java index 2de496c72..8b0d80db3 100644 --- a/src/net/java/sip/communicator/impl/gui/customcontrols/ErrorDialog.java +++ b/src/net/java/sip/communicator/impl/gui/customcontrols/ErrorDialog.java @@ -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("

"+message+"

"); + this.infoMessagePanel.add(msgJLabel); + this.init(); } @@ -120,14 +124,7 @@ public ErrorDialog( Frame owner, this.htmlMsgEditorPane.addHyperlinkListener(this); - String startDivTag = "
"; - String endDivTag = "
"; - - String msgString = startDivTag - + " more info" - + 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 = "
"; + String endDivTag = "
"; + String msgString; + + isDetailsShowed = !isDetailsShowed; + + if(isDetailsShowed) + { + msgString = startDivTag + + "

<< Hide info

" + + endDivTag; + this.messagePanel.add(stackTraceScrollPane, BorderLayout.CENTER); + } + else + { + msgString = startDivTag + + "

More info >>

" + + 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(); } } } diff --git a/src/net/java/sip/communicator/impl/version/NightlyBuildID.java b/src/net/java/sip/communicator/impl/version/NightlyBuildID.java index 9b1a19e0d..8e5b2fcc2 100644 --- a/src/net/java/sip/communicator/impl/version/NightlyBuildID.java +++ b/src/net/java/sip/communicator/impl/version/NightlyBuildID.java @@ -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"; }