PageRenderTime 4ms CodeModel.GetById 1ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

/bundles/plugins-trunk/Console/console/bsh/commandoTOGGLE_ENTRY.bsh

#
Unknown | 38 lines | 31 code | 7 blank | 0 comment | 0 complexity | 7471653ba26f699e3309f1b3824f6585 MD5 | raw file
 1import org.gjt.sp.jedit.bsh.Primitive;
 2
 3commandoTOGGLE_ENTRY(view,pane,ns,label,var,options)
 4{
 5    toggle = new JCheckBox(label);
 6    entry = new JTextField(20);
 7
 8    if(ns.getVariable(var + "Toggle") == Primitive.VOID)
 9    {
10        ns.setVariable(var + "Toggle", new Primitive(false));
11    }
12    toggle.setSelected(ns.getVariable(var + "Toggle").booleanValue());
13    entry.setEnabled(toggle.isSelected());
14
15    if(ns.getVariable(var) == Primitive.VOID)
16    {
17        ns.setVariable(var, "");
18    }
19    entry.setText(ns.getVariable(var).toString());
20
21    listener = new ActionListener() {
22        actionPerformed(evt)
23        {
24            ns.setVariable(var + "Toggle", new Primitive(toggle.isSelected()));
25            entry.setEnabled(toggle.isSelected());
26        }
27    };
28    toggle.addActionListener(listener);
29
30    valueChanged()
31    {
32        ns.setVariable(var,entry.getText());
33    }
34
35    pane.addComponent(toggle,entry);
36
37    return this;
38}