Bug #4147
closedError message with selectable text
Added by Chris Weed over 15 years ago. Updated over 12 years ago.
0%
Description
When Kepler displays an error message in the pop-up dialog, the text is not selectable so I can copy-paste it into an email. This makes it tedious to report errors or problems, because I have to retype the whole message.
Updated by Christopher Brooks over 15 years ago
This would likely be an issue with the Ptolemy Query widget in ptolemy.gui.
I tend not to see this because most error dialogs should be thrown with
an Exception and the dialog should have a "Show Stack Trace" button.
The error message is selectable in the Stack Trace Window.
However, if someone is invoking GraphicalMessageHandler directly, then
the text is probably not selectable.
Updated by Chris Weed over 15 years ago
Ah, I never noticed you could get the text from the Stack Trace.
Updated by Christopher Brooks over 15 years ago
I'm lowering the priority of this and changing it to an enhancement because
the code works as expected.
I agree that it would be nice if the dialog text was selectable, retyping
an error message is a waste of human effort.
ptolemy.gui.GraphicalMessageHandler extends
ptolemy.gui.UndeferredGraphicalMessageHandler which uses JOptionPane.
It appears to be a limitation of JOptionPane that the text is not selectable.
See http://java.sun.com/docs/books/tutorial/uiswing/components/dialog.html
for JOptionPane examples,
However, all is not lost. JOptionPane has a message argument and if that
argument is a String, then a JLabel is created.
http://java.sun.com/j2se/1.4.2/docs/api/javax/swing/JOptionPane.html says:
--start--
message
A descriptive message to be placed in the dialog box. In the most common usage, message is just a String or String constant. However, the type of this parameter is actually Object. Its interpretation depends on its type:
Object[]
An array of objects is interpreted as a series of messages (one per object) arranged in a vertical stack. The interpretation is recursive -- each object in the array is interpreted according to its type.
Component
The Component is displayed in the dialog.
Icon
The Icon is wrapped in a JLabel and displayed in the dialog.
others
The object is converted to a String by calling its toString method. The result is wrapped in a JLabel and displayed.
--end--
So instead of passing a String, I created a method that creates a JTextArea
that looks like a JLabel, but is selectable. I found code at
http://www.rgagnon.com/javadetails/java-0296.html
that got me most of the way there.
So, I modified ptolemy.gui.UndeferredGraphicalMessageHandler so that we
use a JTextField, which looks like a JLabel, but is selectable.
As a fallback, we will return a String if there is a problem.
Updated by Christopher Brooks over 15 years ago
It turns out that this fix causes the dialogs to be very wide because
the JTextArea is one line, whereas JLabel wraps to fit the window.
I backed out my changes to ptolemy.gui.UndeferredGraphicalMessageHandler.
Thus, I'm reopening this bug.
Updated by Christopher Brooks over 15 years ago
Using a JTextField does not wrap text, so we use a JTextArea.
I'm closing this one, but let's keep an eye out for impossibly wide dialogs.
Updated by ben leinfelder over 15 years ago
Now I'm seeing a frame that is too small to accommodate the text and the buttons - they are chopped off.
The text is wrapping, however!
Anyone else?
I'm using MessageHandler.error(String, throwable)
Updated by Christopher Brooks over 12 years ago
In 2009-08-11, Ben wrote:
Now I'm seeing a frame that is too small to accommodate the text and the
buttons - they are chopped off.
The text is wrapping, however!
Anyone else?I'm using MessageHandler.error(String, throwable)
I can't reproduce this.
This can probably be closed. I'm assigning it to Ben pending his approval.
Updated by ben leinfelder over 12 years ago
If Christopher is happy, I am too. (Not even sure when/where I saw the small dialog those 3 years ago)