Project

General

Profile

Actions

Bug #4147

closed

Error message with selectable text

Added by Chris Weed almost 15 years ago. Updated almost 12 years ago.

Status:
Resolved
Priority:
Normal
Category:
core
Target version:
Start date:
06/11/2009
Due date:
% Done:

0%

Estimated time:
Bugzilla-Id:
4147

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.

Actions #1

Updated by Christopher Brooks almost 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.

Actions #2

Updated by Chris Weed almost 15 years ago

Ah, I never noticed you could get the text from the Stack Trace.

Actions #3

Updated by Christopher Brooks almost 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.

Actions #4

Updated by Christopher Brooks almost 15 years ago

Fixed!

Actions #5

Updated by Christopher Brooks almost 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.

Actions #6

Updated by Christopher Brooks over 14 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.

Actions #7

Updated by ben leinfelder over 14 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)

Actions #8

Updated by Christopher Brooks almost 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.

Actions #9

Updated by ben leinfelder almost 12 years ago

If Christopher is happy, I am too. (Not even sure when/where I saw the small dialog those 3 years ago)

Actions #10

Updated by Redmine Admin about 11 years ago

Original Bugzilla ID was 4147

Actions

Also available in: Atom PDF