rem ' getProperty
precision 16
sysgui = unt
open (sysgui)"X0"
sysgui! = bbjapi().getSysGui()
window! = sysgui!.addWindow(50,50,500,500,"getProperty",$00090083$)
window!.setCallback(window!.ON_CLOSE,"eoj")
window!.setCallback(window!.ON_RESIZE,"resize")
window!.addStaticText(101,25,25,100,25,"Property:",$8000$)
property! = window!.addEditBox(102,150,25,300,25,"x",$$)
setProperty! = window!.addButton(103,25,75,100,25,"setProperty",$$)
setProperty!.setCallback(setProperty!.ON_BUTTON_PUSH,"setProperty")
setProperty!.setToolTipText("Click this button to set the named property in the target element to the selected value")
value! = window!.addListButton(104,150,75,300,300,"",$$)
getProperty! = window!.addButton(105,25,125,100,25,"getProperty",$$)
getProperty!.setCallback(getProperty!.ON_BUTTON_PUSH,"getProperty")
getProperty!.setToolTipText("Click this button to get the named property from the target element as the selected class type")
type! = window!.addListButton(106,150,125,300,300,"",$$)
target! = window!.addStaticText(107,150,175,300,300,"",$$)
target!.setBackColor(BBjColor.YELLOW)
listitem! = new ListItem("United States of America", "USA", "USA")
listitems! = new java.util.ArrayList()
listitems!.add(new ListItem("United States of America", "USA", "USA"))
listitems!.add(new ListItem("Canada", "CAN", "CAN"))
listitems!.add(new ListItem("Germany", "GER", "GER"))
values! = new java.util.ArrayList()
value!.addItem("42"); values!.add(42)
value!.addItem("sqr(2)"); values!.add(sqr(2))
value!.addItem("Integer.MAX_VALUE"); values!.add(Integer.MAX_VALUE)
value!.addItem("Math.PI"); values!.add(Math.PI)
value!.addItem("""xyzzy"""); values!.add("xyzzy")
value!.addItem("ListItem!"); values!.add(ListItem!)
value!.addItem("ListItems!"); values!.add(ListItems!)
types! = new java.util.ArrayList()
type!.addItem(""); types!.add(null())
type!.addItem("Object.class"); types!.add(Object.class)
type!.addItem("Integer.class"); types!.add(Integer.class)
type!.addItem("Double.class"); types!.add(Double.class)
type!.addItem("int.class"); types!.add(int.class)
type!.addItem("double.class"); types!.add(double.class)
type!.addItem("String.class"); types!.add(String.class)
type!.addItem("ListItem.class"); types!.add(ListItem.class)
type!.addItem("ListItems!.getClass().getName()"); types!.add(ListItems!.getClass().getName())
type!.addItem("java.util.List.class"); types!.add(java.util.List.class)
type!.addItem("java.util.ArrayList.class"); types!.add(java.util.ArrayList.class)
type!.addItem("java.util.LinkedList.class"); types!.add(java.util.LinkedList.class)
type!.addItem("BBjVector.class"); types!.add(BBjVector.class)
process_events
eoj:
release
resize:
event! = sysgui!.getLastEvent()
width = event!.getWidth()
height = event!.getHeight()
property!.setSize(width-200, property!.getHeight())
value!.setSize(width-200, value!.getHeight())
type!.setSize(width-200, type!.getHeight())
target!.setSize(width-200, height-200)
return
setProperty:
property$ = property!.getText()
index = value!.getSelectedIndex()
if index<0 then item! = null() else item! = values!.get(index)
if index<0 then item$ = "null()" else item$ = value!.getItemAt(index)
target$ = "setProperty("""+property$+""","+item$+")"
target!.setProperty(property$,item!,err=setPropertyError)
target!.setText(target$)
return
setPropertyError:
target!.setText(target$+$0a$+errmes(-1))
return
getProperty:
property$ = property!.getText()
index = type!.getSelectedIndex()
if index<=0 then
class! = null(), class$ = ""
info$ = "getProperty("""+property$+""")"
prop! = target!.getProperty(property$,err=getPropertyError)
else
class$ = type!.getItemAt(index)
class! = types!.get(index)
info$ = "getProperty("""+property$+""","+class$+")"
prop! = target!.getProperty(property$,class!,err=getPropertyError)
endif
info$ = info$ + $0a0a$ + str(prop!)
if prop!<>null() then info$ = info$ + $0a$ + prop!.getClass().getName()
i = msgbox(info$,64,"getProperty")
return
getPropertyError:
info$ = info$ + $0a0a$ + errmes(-1)
i = msgbox(info$,48,"getProperty")
return
class public ListItem
field public String label!
field public String value!
field public String suffix!
method public ListItem(String label!, String value!, String suffix!)
#label! = label!
#value! = value!
#suffix! = suffix!
methodend
classend
|