B4A Library SD: BindingNavigator (Sqlite GUI Navigator)

Star-Dust

Expert
Licensed User
This is a first version of the BindingNavigator Library, which wants to somehow reproduce the corresponding BindingNavigator of VB.NET.
What is needed? I want to get something similar to the tools available on VB.NET to link the views to the DB. As in the pictures.

upload_2018-3-25_11-53-29.pngupload_2018-3-25_11-53-35.png

A DataSet Class is available that allows to associate some views (EditText, Label, ImageView, ToggleButton, CheckBox) with specific fields of a Sqlite DataBase.

By scrolling the position of the DataSet the fields will be updated and if the fields in some way undergo a variation by the user, raising the UpdateChange event will in turn be modified in the DataBase.
This very Agevolent construction of GUI related to the DB.

In addition you have a Second ViewCalss NavigatorBar that adds a new Seek view to the design that is linked to the DataSet. Scrolling through the Seek will change all the views linked to the DataSet. And if the UpdateChange eventio is updated, the DB will be updated based on changes in the views linked to the fields.

VERY IMPORTANT:
  1. The sql database must always have a Primarykey field, of type int with auto-increment, in the example i call it ID, but it could be called as you want.
    The name of the field that will be the Primarykey must be communicated to the DataSet when call query method.
  2. If you use NavigatorBar, in your code you must load FontAwesone, as in the example at post#2, or in the Wish you can have a view set with FontAwesone


SD_BindingNavigator

Author: Star-Dust
Version: 0.50
  • DataSet
    • Functions:
      • AddGroupView (Panel As Panel) As String
      • AddLinkView (V As View, Field As String) As String
      • AddRecord As String
      • Class_Globals As String
      • ClearLinkView As String
      • DeleteRecord As String
      • getBitmap (Field As String) As Bitmap
      • getBlob (Field As String) As Byte()
      • getCurrentTable As String
      • getDouble (Field As String) As Double
      • getInt (Field As String) As Int
      • getLong (Field As String) As Long
      • getPosition As Int
        Return -3 : Not Initialized
        Return -2 : Is empty
        Return -1 : Not positoned
      • getSize As Int
        Return -1 id Query non execute
      • getSQL As SQL
      • getString (Field As String) As String
      • Initialize (Path As String, FileName As String, CreateIfNecessary As Boolean) As String
        Initializes the object. You can add parameters to this method if needed.
      • IsInitialized As Boolean
        Verifica se l'oggetto sia stato inizializzato.
      • NextRecord As String
      • PreviousRecord As String
      • Query (StringQuery As String, PrimaryKeyName As String) As String
      • Query2 (StringQuery As String, StringArg As String(), PrimaryKeyName As String) As String
      • RefreshField As String
      • setPosition (Index As Int) As Boolean
        Return false if Query not execute, index out of range or other error
      • UpdateChange As String
    • Properties:
      • CurrentTable As String [read only]
      • Position As Int
        Return -3 : Not Initialized
        Return -2 : Is empty
        Return -1 : Not positoned
      • Size As Int [read only]
        Return -1 id Query non execute
      • SQL As SQL [read only]
  • NavigatorBar
    • Events:
      • ValueChanged (Value As Int)
    • Fields:
      • Coefficent As Float
      • FontAW As Typeface
    • Functions:
      • AddGroupView (Panel As Panel) As String
      • AddLinkView (V As View, Field As String) As String
      • Class_Globals As String
      • ConnectDB (Path As String, FileName As String, CreateIfNecessary As Boolean) As String
      • DesignerCreateView (Base As Panel, Lbl As Label, Props As Map) As String
      • GetBase As Panel
      • getDataSet As DataSet
      • getPosition As Int
      • Initialize (Callback As Object, EventName As String) As String
      • IsInitialized As Boolean
        Verifica se l'oggetto sia stato inizializzato.
      • Query (StringQuery As String, PrimaryKeyName As String) As String
      • Query2 (StringQuery As String, StringArg As String(), PrimaryKeyName As String) As String
      • RefreshField As String
      • setDataSet (Dset As DataSet) As String
      • setPosition (pos As Int) As String
      • UpdateChange As String
    • Properties:
      • DataSet As DataSet
      • Position As Int
  • WizardMask
    • Events:
      • ValueChanged (Value As Int)
    • Fields:
      • Coefficent As Float
      • FontAW As Typeface
    • Functions:
      • AddAllField As String
      • AddField (FieldName As String, Hint As String) As String
      • Class_Globals As String
      • ClearField As String
      • ConnectDB (Path As String, FileName As String, CreateIfNecessary As Boolean) As String
      • CreateMask As String
      • DesignerCreateView (Base As Panel, Lbl As Label, Props As Map) As String
      • GetBase As Panel
      • getDataSet As DataSet
      • getPosition As Int
      • Initialize (Callback As Object, EventName As String) As String
      • IsInitialized As Boolean
        Verifica se l'oggetto sia stato inizializzato.
      • Query (StringQuery As String, PrimaryKeyName As String) As String
      • Query2 (StringQuery As String, StringArg As String(), PrimaryKeyName As String) As String
      • RefreshField As String
      • setDataSet (Dset As DataSet) As String
      • setPosition (pos As Int) As String
      • UpdateChange As String
    • Properties:
      • DataSet As DataSet
      • Position As Int


It is still undergoing improvements, if there are any suggestions or bugs, report them

Video1.gif 4a.gif 3.gif video1.gif
 

Attachments

Last edited:

Star-Dust

Expert
Licensed User
An example of a Code for NavigatorBar:

B4X:
CREATE TABLE [mytable] (
[ID] INTEGER  PRIMARY KEY AUTOINCREMENT NULL,
[bitmap] BLOB  NULL,
[name] TEXT  NULL,
[description] TEXT  NULL,
[mycheck] BOOLEAN DEFAULT '''false''' NULL,
[togglecheck] BOOLEAN  NULL
)
B4X:
Sub Globals
    Private DBn As NavigatorBar
 
    Private ImageView1 As ImageView
    Private LabelName As Label
    Private EditTextDescription As EditText
    Private CheckBox1 As CheckBox
    Private ToggleButton1 As ToggleButton
End Sub

Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("main")
 
    File.Copy(File.DirAssets,"test.sql",File.DirRootExternal,"test.sql")

    DBn.ConnectDB(File.DirRootExternal,"test.sql",False)
 
    DBn.AddLinkView(LabelName,"name")
    DBn.AddLinkView(EditTextDescription,"description")
    DBn.AddLinkView(CheckBox1,"mycheck")
    DBn.AddLinkView(ToggleButton1,"togglecheck")
    DBn.AddLinkView(ImageView1,"bitmap")
 
    DBn.Query("SELECT * FROM mytable","ID")
    DBn.Position=0
    ' IS IMPORTANT LOAD FONTAWESONE
    DBn.FontAW=Typeface.FONTAWESOME
B4X:
Sub Button1_Click
    ImageView1.Bitmap=LoadBitmap(File.DirAssets,"b4a.png")
End Sub

Sub Button2_Click
    ImageView1.Bitmap=LoadBitmap(File.DirAssets,"b4j.png")
End Sub
In the next update in the navigation bar will appear the buttons add, delete and update records

Result:

upload_2018-3-19_23-12-48.pngVideo1.gif
 

Attachments

Last edited:

Star-Dust

Expert
Licensed User
An example of a Code for DataSet:

B4X:
Sub Globals
    Private ImageView1 As ImageView
    Private LabelName As Label
    Private EditTextDescription As EditText
    Private SeekBar1 As SeekBar
 
    Private DBn As DataSet
End Sub
B4X:
Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("main")
    SeekBar1.Color=Colors.Gray
 
    File.Copy(File.DirAssets,"test.sql",File.DirRootExternal,"test.sql")
    DBn.Initialize(File.DirRootExternal,"test.sql",False)
 
    DBn.AddLinkView(ImageView1,"bitmap")
    DBn.AddLinkView(LabelName,"name")
    DBn.AddLinkView(EditTextDescription,"description")
 
    DBn.Query("SELECT * FROM mytable","ID")
    SeekBar1.Max=DBn.Size-1
    SeekBar1.Value=0
End Sub

Sub SeekBar1_ValueChanged (Value As Int, UserChanged As Boolean)
    DBn.Position=Value
End Sub
Result
3.gif
 

Attachments

Last edited:

Star-Dust

Expert
Licensed User
Coming soon (from release 0.45)

An example of a Code for DataSetWizard:

B4X:
Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    'Activity.LoadLayout("Layout1")
    Activity.LoadLayout("main")
  
    File.Copy(File.DirAssets,"test.sql",File.DirInternal,"test.sql")
  
    WM.ConnectDB(File.DirInternal,"test.sql",False)
  
    WM.Query("SELECT * FROM mytable","ID")
    WM.AddAllField
    WM.CreateMask
    WM.Position=0
    WM.FontAW=Typeface.FONTAWESOME
End Sub
Result
5.png 6.png
Video2.gif
 

Attachments

Last edited:

Luis Carrillo Escalona

Member
Licensed User
my cell phone display error
Registo conectado a: LENOVO Lenovo K50-t5
--------- beginning of main
--------- beginning of system
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
dataset_vvv6 (java line: 349)
java.lang.RuntimeException: Error loading bitmap.
at anywheresoftware.b4a.objects.drawable.CanvasWrapper$BitmapWrapper.Initialize2(CanvasWrapper.java:539)
at b4a.example.dataset._vvv6(dataset.java:349)
at b4a.example.dataset._vvvv6(dataset.java:575)
at b4a.example.dataset._setvvvv7(dataset.java:393)
at b4a.example.main._seekbar1_valuechanged(main.java:411)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:186)
at anywheresoftware.b4a.BA$1.run(BA.java:325)
at android.os.Handler.handleCallback(Handler.java:815)
at android.os.Handler.dispatchMessage(Handler.java:104)
at android.os.Looper.loop(Looper.java:194)
at android.app.ActivityThread.main(ActivityThread.java:5576)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:956)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:751)
 

Luis Carrillo Escalona

Member
Licensed User
set at 22 and same mistake with code :
If p.SdkVersion >= 9 Then
Dim R As Reflector
R.Target = R.CreateObject("android.os.StrictMode$ThreadPolicy$Builder")
R.Target = R.RunMethod("permitAll")
R.Target = R.RunMethod("build")
R.RunStaticMethod("android.os.StrictMode", "setThreadPolicy", _
Array As Object(R.Target), Array As String("android.os.StrictMode$ThreadPolicy"))
End If
 

Star-Dust

Expert
Licensed User
set at 22 and same mistake with code :
If p.SdkVersion >= 9 Then
Dim R As Reflector
R.Target = R.CreateObject("android.os.StrictMode$ThreadPolicy$Builder")
R.Target = R.RunMethod("permitAll")
R.Target = R.RunMethod("build")
R.RunStaticMethod("android.os.StrictMode", "setThreadPolicy", _
Array As Object(R.Target), Array As String("android.os.StrictMode$ThreadPolicy"))
End If
To give you better assistance and do not take up this thread dedicated to libraries and not to assistance, I ask you to open a thread in the forum in the "Androdi Question" section.

Download the library again, try the attached example, without modifying it, and copy exactly the error that signals you and on which line. In the late afternoon I will answer you.

P.S. The code you wrote does not exist in my library .. and is not found in my examples ...
 
Last edited:

Luis Carrillo Escalona

Member
Licensed User
error:
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
dataset_vvvvv1 (java line: 858)
java.lang.RuntimeException: Object should first be initialized (Bitmap).
at anywheresoftware.b4a.AbsObjectWrapper.getObject(AbsObjectWrapper.java:50)
at b4a.example.dataset._vvvvv1(dataset.java:858)
at b4a.example.dataset._setvvvvv2(dataset.java:519)
at b4a.example.main._seekbar1_valuechanged(main.java:411)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:186)
at anywheresoftware.b4a.BA$1.run(BA.java:325)
at android.os.Handler.handleCallback(Handler.java:815)
at android.os.Handler.dispatchMessage(Handler.java:104)
at android.os.Looper.loop(Looper.java:194)
at android.app.ActivityThread.main(ActivityThread.java:5576)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:956)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:751)
 

Star-Dust

Expert
Licensed User
I have updated the library, to work even with older versions of android. You can download the version.

I would ask you in the future to ask for assistance in the "ANDROID QUESTION" forum and not here, as I wrote before, because in the future I will no longer answer assistance questions in this thread.
it would be nice if you would delete your posts on this thread.
 

Star-Dust

Expert
Licensed User
Update release 0.50

In this version there are 2 important updates:

1. The WizardMask class. Which adds a new CustomView. By linking to a SQLite database, this customView will automatically create the machera with all the views related to the various fields of the chosen table. You will find an example at the next post.

2. The new AddGroupView method has been added in the two existing classes DataSet and NavigatorBar. With this method it will be enough to create a custom mask with the Design.
There must be a main panel where all the views you want will be attached. The name of the field to which they are to be associated must be entered in the View Tag.
The class will be passed as a parameter only the main panel. The rest will do the class, update the views as the DataSet or the NavigatorBar will scroll through the table.
 
Last edited:

Star-Dust

Expert
Licensed User
WizardMask

B4X:
Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.

    Private WM As WizardMask
End Sub

Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    'Activity.LoadLayout("Layout1")
    Activity.LoadLayout("main")
  
    File.Copy(File.DirAssets,"test.sql",File.DirInternal,"test.sql")
  
    WM.ConnectDB(File.DirInternal,"test.sql",False)
  
    WM.Query("SELECT * FROM mytable","ID")
    WM.AddAllField
    WM.CreateMask
    WM.Position=0
    WM.FontAW=Typeface.FONTAWESOME
End Sub
 

Attachments

Last edited:
Top