Share My Creation Quickly create get/setters in a class

Utility app to create get / setters in a class to be copied an pasted.

Enter a list of variable names and their corresponding types and click Create.

Global declarations will be generated with the specified prefix, along the get /set methods. You can copy the Global declarations, or the methods to the clipboard to paste into your class, or you can copy a new class definition to the clipboard to paste if you are creating a new class.

You can also paste an existing type definition into the Type field to migrate it to a class.

In the class definition, an initialize call will be created for any List or Map type variables. You can add an initialize for any other types you like by adding them to the ToInitialize List at the top of the tfType_Action sub.

Depends on:
Required for v0.4+
  • CSSUtils
  • jRandomAccessFile
  • jReflection
  • jSQL
  • jXUI

I hope this saves you some time :)

Update to V0.2
  • Allow pasting of preformatted variable definitions (into the Var Name field) as per post #9. Types and Const are excluded, multiple variables on one line are allowed. Does not deal with multiple assignments, i.e. Private PUX = 200, PUY= 200,PUWidth = 200, PUHeight = 200 As Double
Update to v0.3
  • Allow multi input on one line parsed : B,C,D,E
  • Allow multiple assignments on one line in name input (pasted and typed)
  • Replaced context menu and capture paste
  • Check for initialize requred for List and Maps on all input not just Types
  • Added generated Initialize code for List and Map types
Update to v0.4
  • Deals with assignments at the end of pasted or entered VarType
  • Basic format pattern check on vartypes in Unvalidated tab : Matches Type(String) or Type(String) = String or Type(String) = "String"
  • Added validated Tab, VarTypes must be in the validation list, which can be added to via prompt if it doesn't already exist.
  • Added readonly to unvalidated tab which is still required to allow assignments.

The Type_Validated tab uses a modified version of Erels MiniSearchView to validate entries against a stored list.

You will be prompted to add types that are not on the list. To add a type that has less characters than an existing matched one, press the Escape key to dismiss the list, then press return. To delete an entry, type the first few characters to get it in the list, then right click on the list entry.

upload_2018-11-3_16-25-47.png


upload_2018-11-3_16-26-55.png



14
 

Attachments

  • jKeyEvent.zip
    5.9 KB · Views: 318
  • jKeyEvent-lib.zip
    7.4 KB · Views: 321
  • upload_2018-10-24_17-39-49.png
    upload_2018-10-24_17-39-49.png
    62.2 KB · Views: 2,647
  • CreateGetSetters-v0.4.zip
    30 KB · Views: 332
Last edited:

Myr0n

Active Member
Licensed User
Longtime User
Is it possible to get reference link about the required libraries please, like jkeyevent.
 

stevel05

Expert
Licensed User
Longtime User
Is it possible to get reference link about the required libraries please, like jkeyevent.
Sorry, I meant to take that out and replace it with JavaObject, but as I didn't, the library is attached to the first post. Just load it and compile it to a library.
 

Myr0n

Active Member
Licensed User
Longtime User
Sorry, I meant to take that out and replace it with JavaObject, but as I didn't, the library is attached to the first post. Just load it and compile it to a library.
Thank you so much
 

stevel05

Expert
Licensed User
Longtime User
Just uploaded the compiled jKeyEvent libraries as well in case you don't want to compile the source, unzip and copy the jar and xml files to you addllibs folder.
 
Last edited:

Jeffrey Cameron

Well-Known Member
Licensed User
Longtime User
I created this same tool for both .NET classes and B4A classes some time ago. My utility reads the Windows Clipboard and looks for Dim/Private/Public statements rather than having to type in all the variables and their types again. You should consider adding an "Import from clipboard" function that does that same thing, it will make your life much easier ;)
 

stevel05

Expert
Licensed User
Longtime User
You need to consider adding functionality for adding comments to this tool otherwise maintaining code can be cumbersome.
Meaningful comments cannot be autogenerated, you would have to type them in, there would be very little benefit adding them to the tool. You can add them afterwards into the class.

You should consider adding an "Import from clipboard" function that does that same thing, it will make your life much easier
The point is that you don't have to type Dim or Private at all, it does it for you if you just type the variable name and type once, in the tool. Then copy the top pane to the Globals section and the bottom pane the is code.
 
Last edited:

Jeffrey Cameron

Well-Known Member
Licensed User
Longtime User
type the variable name and type once, in the tool.
Point taken, however in this case you need to construct the variable, make sure you've got the type spelled correctly (I can't tell you HOW many times I type "Integer" instead of "Int" without thinking :s) and then setup your prefixing accordingly.

In my example, you just type the Dim block(s) as you wish them to appear, the language editor checks for syntax, typing, etc. as you do so. Highlight the dim block, Ctrl+C and then click the button on your tool (I actually have my utility hooked to WIN+V for .NET and WIN+B for B4A, because, I'm basically lazy ;)
 

stevel05

Expert
Licensed User
Longtime User
make sure you've got the type spelled correctly

I think it would still be quicker doing it this way, even if you have to use search and replace afterwards to correct those sort of errors.
 

stevel05

Expert
Licensed User
Longtime User
@Jeffrey Cameron On reflection I've added a paste option (Into the name field, it will clear any other data). I can see that it might also be useful for adding get/setters to an existing class.
 
Last edited:

LucaMs

Expert
Licensed User
Longtime User
you need to construct the variable, make sure you've got the type spelled correctly (I can't tell you HOW many times I type "Integer" instead of "Int" without thinking
xCustomListView with an EditText for the variable name and a Combo (or AutoCompleteEditText) for its type.

Meaningful comments cannot be autogenerated, you would have to type them in,
A (user) custom txt template. My example:

B4X:
'  - Standard Class
' Author: LucaMs - AKA Mario
#Region + VERSIONS
' V. 1.0   00/00/2018
#End Region

#Region + EVENTS' DECLARATIONS
#End Region

Sub Class_Globals
   Private mCallback As Object
   Private mEventName As String
  
#Region + PROPERTIES' MEMBER VARIABLES
   Private mProp As Int
#End Region
  
End Sub

Public Sub Initialize(Callback As Object, EventName As String)
   mCallback = Callback
   mEventName = EventName
End Sub

#Region + PROPERTIES

Public Sub setProp(Prop As Int)
   mProp = Prop
End Sub
Public Sub getProp As Int
   Return mProp
End Sub

#End Region

#Region + METHODS

#Region + PUBLIC METHODS
#End Region

#Region + PRIVATE METHODS
#End Region

#End Region

#Region + EVENTS
#End Region

???
 

stevel05

Expert
Licensed User
Longtime User
I'm not sure I understand your question. If you are asking how it would apply, then you would copy the globals and methods into the appropriate places.
 

stevel05

Expert
Licensed User
Longtime User
No, I tried to give you two suggestions.
Sorry, it was late and the wine was open :)

Both are eminently do able, the initial ideas was that this was a quick in and out utility, The app has no footprint apart from the app itself.

To implement the custom listview, there would have to be a mechanism to store and maintain the list of Types, i.e. adding new types and removal of incorrectly typed entries.

To implement the Templates, there would need to be a mechanism to store the templates or import them from an existing folder, select the current template, which would mean displaying it on selection and adding the generated lines in the correct place, probably just a search and replace of 2 tags, so not a big deal.

It would mean spending more time in this app when you can already import your own templates in to the B4x ide, copy and paste the generated Globals and Methods to the correct place and easily correct any type name errors identified within the ide after pasting with search and replace.
 

stevel05

Expert
Licensed User
Longtime User
Yes, that's what I meant. I don't want to replace the mechanism to create templates. So you can just add all the property global definitions and methods in less time using this tool.
 

stevel05

Expert
Licensed User
Longtime User
Update to V0.3
  • Allow multi input on one line parsed : B,C,D,E
  • Allow multiple assignments on one line in name input (pasted and typed)
  • Replaced context menu and capture paste
  • Check for initialize requred for List and Maps on all input not just Types
  • Added generated Initialize code for List and Map types
 
Top