Patch for bug ID 3598585 posted here: https://sourceforge.net/tracker/?func=detail&aid=3598585&group_id=588&atid=100588
The reason for NullPointerException wasnt specified well. The real problem was, that
if user wanted to add new tool to toolbar and forgot to select an action to be performed
by the new toolbar icon, then the NullPointerException occured, but the user didnt
see any action. It could be quite confusing.
My simple patch gives the user more info, when he forgets to select an action and
presses the OK button in toolbar Add dialog.
When user presses OK and action is not selected, the message dialog appears and warns
him.
Submitted | danisluk - 2013-05-06 - 11:55:34z | Assigned | nobody |
---|---|---|---|
Priority | 5 | Category | None |
Status | Open | Group | None |
Resolution | None | Visibility | No |
2013-05-06 - 11:56:48z danisluk |
Index: jEdit/trunk/org/gjt/sp/jedit/options/ToolBarOptionPane.java =================================================================== --- jEdit/trunk/org/gjt/sp/jedit/options/ToolBarOptionPane.java(revision 22966) +++ jEdit/trunk/org/gjt/sp/jedit/options/ToolBarOptionPane.java(working copy) @@ -656,13 +656,16 @@ { ToolBarOptionPane.Button button = (ToolBarOptionPane.Button)list -.getSelectedValue(); +.getSelectedValue(); +if(button==null){ +JOptionPane.showMessageDialog(null, "No action was selected"); +return null; +} label = button.label; actionName = button.actionName; } else throw new InternalError(); - return new ToolBarOptionPane.Button(actionName, iconName,icon,label); } |
---|---|
2013-05-06 - 12:39:05z danisluk |
I updated the patch to use text resource from properties |
2013-05-07 - 09:50:42z kpouer |
Maybe it would be better to not activate the buttons if the action is not selected ? |
2013-05-07 - 10:21:34z danisluk |
Ok, I can do as you suggested. |
2013-05-08 - 22:53:09z danisluk |
To kpouer : I have made another patch, which does what you suggested to me. The OK button is disabled when is not set any action or the separator radio button is not selected, otherwise the OK button is enabled. |
2013-05-16 - 09:09:41z kpouer |
I think there is something wrong. If you do control+click on the list you can unselect
the action and the button will remains activated. Also could you following coding rules (place opening braces on next line) |
2013-05-06 - 12:37:54z danisluk |
patch.patch better patch with updated localization properties |
---|---|
2013-05-08 - 22:50:24z danisluk |
patch2.patch fixed , as kpouer suggested by disabling ok button |