#1112 Console Commando: Beanshell error for TOGGLE_ENTRY GUI eleme

closed-accepted
Alan Ezust
None
5
2011-11-27
2008-11-29
Robert Schwenn
No

When I invoke a commando which has a TOGGLE_ENTRY element for the GUI, I get the following beanshell error:

Sourced file: inline evaluation of: ``commandoTOGGLE_ENTRY(view,pane,ns,label,var,options);'' : Unknown class: Primitive : at Line: 10 : in file: commandoTOGGLE_ENTRY : new Primitive ( true )

jEdit 4.3pre15
Console Plugin 4.3.8
SUN JRE 1.6.0_10
WinXP SP3

Discussion

  • Hi,

    commandoTOGGLE_ENTRY.bsh has been changed several times since 2008-11-29, but it is still buggy.
    Here attached is a proposal to fix the bug (not sure it is the exact original behaviour as I added a listener to the JCheckBox component), but it seems to work now (jedit 4.3pre17, windows vista and jdk5.0u22).
    I also attach a small commando file to check the fix.

    (sorry, I copy both files here after as I did not find how to attach them)

    commandoTOGGLE_ENTRY.bsh
    *************************************
    import org.gjt.sp.jedit.bsh.Primitive;

    commandoTOGGLE_ENTRY(view,pane,ns,label,var,options)
    {
    toggle = new JCheckBox(label);
    entry = new JTextField(20);

    if(ns.getVariable(var + "Toggle") == Primitive.VOID)
    {
    ns.setVariable(var + "Toggle", new Primitive(false));
    }
    toggle.setSelected(ns.getVariable(var + "Toggle").booleanValue());
    entry.setEnabled(toggle.isSelected());

    if(ns.getVariable(var) == Primitive.VOID)
    {
    ns.setVariable(var, "");
    }
    entry.setText(ns.getVariable(var).toString());

    listener = new ActionListener() {
    actionPerformed(evt)
    {
    ns.setVariable(var + "Toggle", new Primitive(toggle.isSelected()));
    entry.setEnabled(toggle.isSelected());
    }
    };
    toggle.addActionListener(listener);

    valueChanged()
    {
    ns.setVariable(var,entry.getText());
    }

    pane.addComponent(toggle,entry);

    return this;
    }

    commando to test the new script
    ************************************
    <?xml version="1.0" ?>

    <!-- This was based around Sun JRE 1.3.1. It will work with earlier Java
    versions, or versions from other vendors, but some of the
    non-standard options might not be supported. -->

    <!DOCTYPE COMMANDO SYSTEM "commando.dtd">

    <COMMANDO>
    <UI>
    <CAPTION LABEL="Optional parameter 1">
    <TOGGLE_ENTRY LABEL="Parameter (optional)"
    VARNAME="param1"
    DEFAULT="default parameter 1"/>
    </CAPTION>
    <CAPTION LABEL="Optional parameter 2">
    <TOGGLE_ENTRY LABEL="Parameter (optional)"
    VARNAME="param2"
    DEFAULT="default parameter 2"/>
    </CAPTION>
    </UI>

    <COMMANDS>
    <COMMAND SHELL="BeanShell" CONFIRM="FALSE" TO_BUFFER="FALSE">
    buf = new StringBuffer("print(\"");
    buf.append("Parameter 1\\n");
    buf.append(" toggle value = " + param1Toggle + "\\n");
    buf.append(" user value = " + param1 + "\\n");

    buf.append("Parameter 2\\n");
    buf.append(" toggle value = " + param2Toggle + "\\n");
    buf.append(" user value = " + param2 + "\\n");

    buf.append("\");");
    buf;
    </COMMAND>
    </COMMANDS>
    </COMMANDO>

    Michaël Michaud

     
  • Skeeve
    Skeeve
    2011-05-17

    Please add this fix!

    It works!

     
  • Alan Ezust
    Alan Ezust
    2011-11-27

    • assigned_to: nobody --> ezust
    • status: open --> closed-accepted
     
  • Alan Ezust
    Alan Ezust
    2011-11-27

    Committed to svn . Rev# 20429.