new control variant for BBj - the confirmation button - the anatomy of the confirmation button is to click twice in order to trigger the final click event - The difference to a doubleclick behavior is the changing button text after the first click asking the user if he is really sure. - With the leave of the button control is the text gonna be resetted and the inner confirmation state is null again.
This kind of button was the first time introduced by Ralf van den Heuvel in 2008. It was required in for the deletion of a single workshop planning appointment. The workshop planning was a html/javascript application and was asking again to be sure to delete the workshop appointment after clicking once on it.
In the meantime - when googling for such button behavior - you will find also implementations for jquery/javascript by others.
Here comes the code implementation of the confirmation button in BBJ:
REM /**
REM * BBjButtonExt.bbj
REM * @author Ralf van den Heuvel
REM * Click behavior extension
REM */
class public BBjButtonExt
field protected BBjButton parentCtrl!
field protected CustomObject parentClassObject!
field protected BBjString parentClassName!
field private BBjString parentMethodNameOnButtonPush$
field private BBjString parentButtonTextDefault$
field private BBjString parentButtonTextCurrent$
field private BBjString parentButtonTextConfirm$
REM /**
REM * constructor of the extended BBjButton ctrl
REM * @param BBjButton control object to be extended
REM * @param BBjString of the full qualified parent class name like '::myClass.bbj::myClass'
REM * @param CustomObject of the parent class handled over like #this!
REM * @param BBjString of the binded button push method within the parent class
REM * @param BBjString of the interim button confirmation text. If the button is clicked once, the button text will swap to this confirmation text. If the button is clicked twice or the mouse leaves the button control, the text will be reset.
REM */
method public BBjButtonExt(BBjButton parentCtrl!,BBjString parentClassName!,CustomObject parentClassObject!,BBjString parentMethodNameOnButtonPush$,BBjString confirmQuestion$)
#parentCtrl!=cast(BBjButton,parentCtrl!)
#parentClassName!=parentClassName!; REM like '::myClass.bbj::myClass'
#parentClassObject!=parentClassObject!; REM mostly #this! in the parent class +++ java.lang.Class +++ ?#class!.getClass().getName()
#parentMethodNameOnButtonPush$=parentMethodNameOnButtonPush$
#parentButtonTextDefault$=#parentCtrl!.getText()
#parentButtonTextCurrent$=#getparentButtonTextDefault()
#parentButtonTextConfirm$=iff(confirmQuestion$<>#parentButtonTextDefault$,confirmQuestion$,"")
if #parentButtonTextConfirm$>""
#parentCtrl!.setCallback(#parentCtrl!.ON_BUTTON_PUSH,#this!,"OnButtonPush")
#parentCtrl!.setCallback(#parentCtrl!.ON_MOUSE_EXIT,#this!,"OnMouseExit")
#parentCtrl!.setCallback(#parentCtrl!.ON_LOST_FOCUS,#this!,"OnLostFocus")
fi
methodend
REM /**
REM * button clicked - Analyse state - show confirmation question or trigger the button push method of the parent class
REM * @param BBjButtonPushEvent according to control.
REM */
method public void OnButtonPush(BBjButtonPushEvent pe!)
if #parentButtonTextCurrent$=#parentButtonTextConfirm$
#parentButtonTextCurrent$=#parentButtonTextDefault$
#parentCtrl!.setText(#parentButtonTextCurrent$)
stmt$="cast("+#parentClassName!+",#parentClassObject!)."+#parentMethodNameOnButtonPush$+"(pe!)"
eval(stmt$)
else
#parentButtonTextCurrent$=#parentButtonTextConfirm$
#parentCtrl!.setText(#parentButtonTextCurrent$)
fi
methodend
REM /**
REM * mouse exists control - analyze state - reset button text
REM * @param BBjButtonPushEvent according to control.
REM */
method public void OnMouseExit(BBjMouseExitEvent pe!)
if #parentButtonTextCurrent$=#parentButtonTextConfirm$
#parentButtonTextCurrent$=#parentButtonTextDefault$
#parentCtrl!.setText(#parentButtonTextCurrent$)
fi
methodend
REM /**
REM * control looses focus - analyze state - reset buttom text
REM * @param BBjButtonPushEvent according to control.
REM */
method public void OnLostFocus(BBjLostFocusEvent pe!)
if #parentButtonTextCurrent$=#parentButtonTextConfirm$
#parentButtonTextCurrent$=#parentButtonTextDefault$
#parentCtrl!.setText(#parentButtonTextCurrent$)
fi
methodend
classend
REM /**
REM * demo - focus on #abtn!
REM */
class public demo
field protected BBjButtonExt abtn!
field protected BBjButton btn!
method public demo()
sysgui = unt
open (sysgui)"X0"
sysgui! = bbjapi().getSysGui()
window! = sysgui!.addWindow(25,25,200,275,"BBjButton",$00090003$)
window!.setCallback(window!.ON_CLOSE,"eoj")
window!.addButton(1,25,25,150,25,"figurant1",$$)
#btn! = cast(BBjButton,window!.addButton(2,25,75,150,25,"delete all foo - click me",$$))
#btn!.setCallback(#btn!.ON_BUTTON_PUSH,#this!,"parentOnButtonPush")
#abtn!=new BBjButtonExt(#btn!,"::BBjButtonExt.bbj::demo",#this!,"parentOnButtonPush","sure?"); REM btn ctrl, classname, this class, btn push event name, alternative confirmation text
window!.addButton(3,25,125,150,25,"figurant2",$$)
process_events,err=*next
release
methodend
method public void parentOnButtonPush(BBjButtonPushEvent pe!)
declare BBjButton ctrl!
ctrl!=cast(BBjButton,pe!.getControl())
accu$=ctrl!.getText()
ctrl!.setText("foo works")
void=msgbox("parent class push method",0,"",tim=2)
ctrl!.setText(accu$)
methodend
method public static void run()
declare demo d!
d!=new demo()
methodend
classend
PREFIX cast(BBjString,pgm(-2)).replace("BBjButtonExt.bbj","") + " " + PFX
demo.run()
BBj
Sonntag, 12. Mai 2019
Mittwoch, 8. Mai 2019
xml node replacement variant (schematic)
schema - xmlsuit is decoration only - Document object required - REPLACEMENT variant
use org.w3c.dom.Document
use org.w3c.dom.NodeList
use org.w3c.dom.Node
use org.w3c.dom.NamedNodeMap
use org.w3c.dom.Element
declare auto Document d!
declare auto NodeList nl!
declare auto Node n!
declare auto Node c!
declare Element e!
declare xmlsuit xml!declare auto Node newHeaderNode!
markup$="<?xml version=""1.0"" encoding=""UTF-8""?><MESSAGE DTD=""XMLMSG"" VERSION=""1.0""><HEADER><FROM>.....</DATA></REQUEST></COMMAND></MESSAGE>"
xml!=new xmlsuit(markup$)d!=xml!.getDocument()
n!=xml!.getDocument().getFirstChild(); REM MESSAGE
c!=n!.getFirstChild(); REM HEADER
newHeaderNode!=c!.cloneNode(Boolean.FALSE)
nl!=d!.getElementsByTagName("COMMAND")
e!=d!.createElement("NEWTAG")
e!.appendChild(newHeaderNode!)
REM nl!.item(0).getParentNode().insertBefore(newHeaderNode!,nl!.item(0))nl!.item(0).getParentNode().insertBefore(e!,nl!.item(0))
n!.removeChild(c!)
?xml!.getDocumentAsPrettyString().substring(0,1000)
Montag, 9. April 2018
BBjVector from ResultSet column
BBjVector from ResultSet column using a version above BBj 17.13.
use com.basiscomponents.db.ResultSet
use com.basiscomponents.db.util.ResultSetValuesListProvider
declare BBjVector v!
declare ResultSet rs!
REM ... filling rs! using the column name "MyColumnOfRs" ....
v! = ResultSetValuesListProvider.getFieldValuesAsList(rs!,"MyColumnOfRs")
Donnerstag, 31. August 2017
date calendar functions / adding number of month to a date
use java.util.Calendar
declare Calendar endCal!
xyear=2017
xmonth=8
xday=31
endCal! = Calendar.getInstance()
endCal!.set(xyear,xmonth-1,xday)
?str(endCal!.getTime())
endCal!.add(Calendar.MONTH,2)
?str(endCal!.getTime())
?endCal!.get(Calendar.YEAR)
?endCal!.get(Calendar.MONTH) + 1
?endCal!.get(Calendar.DATE)
---------------------------------------------------
declare Calendar endCal!
DATE_STA=-1
DATE_END=-1
num_of_month_to_add = 6
tmp$="2017-08-30T20:02:46.000+02:00"
if len(tmp$)>9 then
if tmp$(5,1)="-" and tmp$(8,1)="-" then
DATE_STA=jul(tmp$(1,10),"%Yl-%Mz-%Dz",err=*endif)
endCal! = Calendar.getInstance()
endCal!.set( num(date(DATE_STA:"%Yl")) , num(date(DATE_STA:"%Mz")) -1 , num(date(DATE_STA:"%Dz")))
endCal!.add(Calendar.MONTH, num_of_month_to_add )
endYear=int(endCal!.get(Calendar.YEAR))
endMonth=int(endCal!.get(Calendar.MONTH) + 1)
endDay=int(endCal!.get(Calendar.DATE))
DATE_END = jul(endYear, endMonth, endDay)
fi
fi
?DATE_STA
?DATE_END
?DATE_END-FIN_DATE_STA
Benefit from the best Windows Desktop app in the world and use Strokey.Net!
declare Calendar endCal!
xyear=2017
xmonth=8
xday=31
endCal! = Calendar.getInstance()
endCal!.set(xyear,xmonth-1,xday)
?str(endCal!.getTime())
endCal!.add(Calendar.MONTH,2)
?str(endCal!.getTime())
?endCal!.get(Calendar.YEAR)
?endCal!.get(Calendar.MONTH) + 1
?endCal!.get(Calendar.DATE)
---------------------------------------------------
declare Calendar endCal!
DATE_STA=-1
DATE_END=-1
num_of_month_to_add = 6
tmp$="2017-08-30T20:02:46.000+02:00"
if len(tmp$)>9 then
if tmp$(5,1)="-" and tmp$(8,1)="-" then
DATE_STA=jul(tmp$(1,10),"%Yl-%Mz-%Dz",err=*endif)
endCal! = Calendar.getInstance()
endCal!.set( num(date(DATE_STA:"%Yl")) , num(date(DATE_STA:"%Mz")) -1 , num(date(DATE_STA:"%Dz")))
endCal!.add(Calendar.MONTH, num_of_month_to_add )
endYear=int(endCal!.get(Calendar.YEAR))
endMonth=int(endCal!.get(Calendar.MONTH) + 1)
endDay=int(endCal!.get(Calendar.DATE))
DATE_END = jul(endYear, endMonth, endDay)
fi
fi
?DATE_STA
?DATE_END
?DATE_END-FIN_DATE_STA
Benefit from the best Windows Desktop app in the world and use Strokey.Net!
Mittwoch, 12. Oktober 2016
getting Files and Directories of a Folder in BBj
showcase demonstrates how to get the used jasper version of BBj by using a complete scan of the lib directory files:
jasperVersion$="?.?.?"Benefit from the best Windows Desktop app in the world and use Strokey.Net!
declare java.io.File f!
declare BBjString path!
path! = cast(BBjString,System.getProperty("basis.BBjHome")+"\lib\").replaceAll("/\\","\").replace("\\","\")
f! = new java.io.File( path! )
if (f!<>null()) then
javaList! = java.util.Arrays.asList( f!.listFiles() )
for i=0 to javaList!.size()-1
f! = cast(java.io.File,javaList!.get(i))
if (!f!.isDirectory()) then
if (f!.getName().contains("jasperreports-javaflow-")) then
jasperVersion$ = f!.getName().replaceAll("jasperreports-javaflow-|.jar","")
endif
endif
next i
endif
Samstag, 24. September 2016
iterating through the keySet (of a HashMap)
declare java.util.HashMap hm!
hm! = new java.util.HashMap()
hm!.put("myKey1",100)
hm!.put("myKey2",200)
declare BBjVector v!
v!=new BBjVector(java.util.Arrays.asList(hm!.keySet().toArray()))
v!=new BBjVector(java.util.Arrays.asList(hm!.values().toArray()))
java.util.Collections.sort(v!); REM sorting vector
x = v!.contains(IdOrValue$)
i = v!.indexOf(IdOrValue$)
ks! = hm!.keySet()
i! = ks!.iterator()
while i!.hasNext()
key!=i!.next()
value=hm!.get(key!)
?">>"+key!+"="+str(value)+"<<"
wend
firstValue=num(java.util.Arrays.asList(hm!.keySet().toArray()).get(0))
Dienstag, 30. August 2016
info function sample and more system information
REM /**
REM * infoFunction.bbj
REM * @author VANDEN
REM */
tc! = bbjapi().getThinClient()
tc!=BBjAPI().getThinClient()
txt$=txt$+tc!.toString()
txt$=txt$+""+
: "+++BBx Betriebssystem (0,0): "+info(0,0)+
: "+++BBx Betriebssystem Version (0,1): "+info(0,1)+
: "+++Server Basis Port ID (0,2): "+info(0,2)+
: "+++Client Basis Port ID ( tc!.getClientPortID() ): "+tc!.getClientPortID()+
: "+++CPU ID (1,0): "+info(1,0)+
: "+++server JVM unque ID (1,5) : "+hta(info(1,5))+
: "+++client JVM unque ID (1,6) : "+hta(info(1,6))+
: "+++Current User Slot Number (2,4): "+str(dec(info(2,4)))+
: "+++license Version (2,7): "+str(dec(info(2,7)))+
: "+++unique Task ID 4byte (3,0): "+str(dec(info(3,0)))+
: "+++unique Task ID 8byte (3,1): "+str(dec(info(3,1)))+
: "+++Username (3,2): "+info(3,2)+
: "+++Login Beschreibung (3,3): "+info(3,3)+
: "+++Hostname (3,4): "+info(3,4)+""+
: "+++Aktivierungsschlüssel (3,5): "+info(3,5)+
: "+++GUI System (6,0): "+info(6,0)
x=msgbox( cast(BBjString,txt$).replace("+++",$0d0a$) )
for i=0 to 99999
if (i>0 and mod(i,20)=0) input "press enter to continue",a$
?"INFO(7,"+str(i)+") = "+info(7,i,err=*break)
next i
end
Benefit from the best Windows Desktop app in the world and use Strokey.Net!
REM * infoFunction.bbj
REM * @author VANDEN
REM */
tc! = bbjapi().getThinClient()
tc!=BBjAPI().getThinClient()
txt$=txt$+tc!.toString()
txt$=txt$+""+
: "+++BBx Betriebssystem (0,0): "+info(0,0)+
: "+++BBx Betriebssystem Version (0,1): "+info(0,1)+
: "+++Server Basis Port ID (0,2): "+info(0,2)+
: "+++Client Basis Port ID ( tc!.getClientPortID() ): "+tc!.getClientPortID()+
: "+++CPU ID (1,0): "+info(1,0)+
: "+++server JVM unque ID (1,5) : "+hta(info(1,5))+
: "+++client JVM unque ID (1,6) : "+hta(info(1,6))+
: "+++Current User Slot Number (2,4): "+str(dec(info(2,4)))+
: "+++license Version (2,7): "+str(dec(info(2,7)))+
: "+++unique Task ID 4byte (3,0): "+str(dec(info(3,0)))+
: "+++unique Task ID 8byte (3,1): "+str(dec(info(3,1)))+
: "+++Username (3,2): "+info(3,2)+
: "+++Login Beschreibung (3,3): "+info(3,3)+
: "+++Hostname (3,4): "+info(3,4)+""+
: "+++Aktivierungsschlüssel (3,5): "+info(3,5)+
: "+++GUI System (6,0): "+info(6,0)
x=msgbox( cast(BBjString,txt$).replace("+++",$0d0a$) )
for i=0 to 99999
if (i>0 and mod(i,20)=0) input "press enter to continue",a$
?"INFO(7,"+str(i)+") = "+info(7,i,err=*break)
next i
end
Benefit from the best Windows Desktop app in the world and use Strokey.Net!
Abonnieren
Posts (Atom)