Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

#496 Patch for bug ID 3598585 NullPointerException .....

None
open
None
5
2014-04-25
2013-05-06
danisluk
No

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.

Discussion

  • danisluk
    danisluk
    2013-05-06

    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);
    }

     
  • danisluk
    danisluk
    2013-05-06

    better patch with updated localization properties

     
    Attachments
  • danisluk
    danisluk
    2013-05-06

    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 ?

     
  • danisluk
    danisluk
    2013-05-07

    Ok, I can do as you suggested.

     
  • danisluk
    danisluk
    2013-05-08

    fixed , as kpouer suggested by disabling ok button

     
    Attachments
  • danisluk
    danisluk
    2013-05-08

    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)

     
  • Alan Ezust
    Alan Ezust
    2014-04-25

    • assigned_to: Alan Ezust --> Matthieu Casanova