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: 209
  • jKeyEvent-lib.zip
    7.4 KB · Views: 212
  • upload_2018-10-24_17-39-49.png
    upload_2018-10-24_17-39-49.png
    62.2 KB · Views: 2,525
  • CreateGetSetters-v0.4.zip
    30 KB · Views: 209
Last edited:

stevel05

Expert
Licensed User
Longtime User
Yes, it does not validate the Var Type field. I suppose it could, I have finished adding maintaining declared values i.e. Int = 10 will now be carried forward (Next release anyway) I'll take a look, probably Monday Now.
 

stevel05

Expert
Licensed User
Longtime User
I was thinking of just removing the additional declaration, so making Int, String just Int. But if it's left and not noticed, it will be obvious when pasted into the IDE, an error will be raised.

If I raise an error then it would prolong the process, and the correction is probably easier and quicker to do in the IDE.

I suppose an option is to remove it and notify the user that it has been removed.
 

LucaMs

Expert
Licensed User
Longtime User
I'm slightly lost :D because I do not know why I should be able to add directly texts like "Dim MyVar As Int".

I would do only one thing like...

upload_2018-10-25_1-40-31.png


Two buttons, to add a new property and to remove the selected one (or long click on the variable name to remove it).

"Set too" if you want to create both routines or just get (read only).
 

stevel05

Expert
Licensed User
Longtime User
I do not know why I should be able to add directly texts like "Dim MyVar As Int".
You can't, but you can paste them, which goes through an extra parse routine to format them as needed.

I can see where you are coming from but this is not integrated into the IDE and has no idea of all the possible class types. Creating an input along the lines you outline would I think, slow down the process. Also, the app would need to maintain it's own list of Types. Users would have to be able to add and remove types to cater for their own classes, not to mention the hundreds of classes in libraries. If you had to stop and add them before parsing, it would probably take longer than typing them directly, at least the first time.

As I said before, this is intended as a quick in and out utility. Type your Variable names and their types, Parse the code and copy and paste. Any errors in the var type names will be immediately obvious in the IDE when you do the first paste, and very quickly changed using search and replace in the IDE or come back to the open app and change it and re parse.
 

LucaMs

Expert
Licensed User
Longtime User
Thanks to my poor English :D, I still did not understand what you're talking about "parsing".

However, a solution to define a parameter of any type, still selecting it by Combo, could be set the first item of the Combo to "Custom" and display an input dialog (BTW, I looked for an "InputDialog" b4j e I did not find one!).
 

stevel05

Expert
Licensed User
Longtime User
@LucaMs See what you think of this version, 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.

It uses a few more libraries, but I think they are all standard libraries. I've also changed the text on the button Parse to Create.
 

Attachments

  • CreateGetSetters-v0.4-Beta.zip
    27.7 KB · Views: 162

stevel05

Expert
Licensed User
Longtime User
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.
File updated and more information in first post
 
Last edited:
Top