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.
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);
}
better patch with updated localization properties
I updated the patch to use text resource from properties
Maybe it would be better to not activate the buttons if the action is not selected ?
Ok, I can do as you suggested.
fixed , as kpouer suggested by disabling ok button
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.
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)
bug was fixed