Tools plugin for everybody

Questions and answers on developing, deploying and using plugins and JavaBeans

Tools plugin for everybody

Postby IT2Be » Sat Jan 10, 2004 2:13 am

Tools plugin for everybody

Hello forum,

Just for the fun of it I wanted to be the first (I hope or else one of the first) to give you the taste of a homebrew Plugin for Servoy.

Not too much but for me very convenient with three methods:

- dateFormat: very much like the Java dateFormat class to convert a date to a string and the other way around with (or without) a formatting string;
- secondsFormat: to make a number of seconds a string formatted like HH:mm:ss
- validateEmail: based on a method I posted earlier on this forum now as a method in this plugin. It takes a string with one or more email adresses and checks if the format is right.

The reason I made them (initially for my own use) was that I needed to do the same calculation over and over again on different forms. However you can't reach a method via a calculation field.

I didn't want to ask for a feature since the guys at Servoy are already busy enough and to trigger myself to learn Java and making a Plugin.

The result is attached. Just drop it in your plugins folder and restart Servoy.

Feel free to use it and distribute it.

Any suggestions? Please let me know!
Any bugs? Please tell me!
Any new features needed? Please ask me?
Any questions? I don't know if we are allowed to use this forum for it but for now: Ask me!
Happpy? Don't hasitate to share it with me...

Cheers

BTW you need at least Servoy v2.0b6
Last edited by IT2Be on Wed Feb 04, 2004 11:55 am, edited 4 times in total.
Marcel J.G. Trapman (IT2BE)
SAN partner - Freelance Java and Servoy
Servoy Components - IT2BE Plug-ins and Beans for Servoy
ServoyForge - Open Source Components for Servoy
User avatar
IT2Be
Servoy Expert
 
Posts: 4766
Joined: Tue Oct 14, 2003 7:09 pm
Location: Germany

Postby bcusick » Fri Jan 30, 2004 3:17 pm

Marcel,

EXCELLENT JOB! Inspiring!

I love your idea of the email validation. Would be cool to have a plug-in that did validations (isNumeric, isTextOnly, isInRange, etc.).

Now if only I could find the time... :lol:

Cheers,

Bob Cusick
bcusick
 
Posts: 1255
Joined: Wed Apr 23, 2003 11:27 pm
Location: Thousand Oaks, CA USA

Postby IT2Be » Fri Jan 30, 2004 3:35 pm

Well, this is a glove I have to pick up (is this know in English? In Duch it is "deze handschoen moet ik oppakken") :lol:
Marcel J.G. Trapman (IT2BE)
SAN partner - Freelance Java and Servoy
Servoy Components - IT2BE Plug-ins and Beans for Servoy
ServoyForge - Open Source Components for Servoy
User avatar
IT2Be
Servoy Expert
 
Posts: 4766
Joined: Tue Oct 14, 2003 7:09 pm
Location: Germany

Postby IT2Be » Sat Jan 31, 2004 1:51 am

OK here it is. v2 with 5 new functions:

1. getMaxDay: returns the last day of the given month;
2. isInteger: returns a boolean value, checks a string;
3. isNumber: returns a boolean value after checking a string;
= localized but will return false when you input thousand seperators...
4. numberFormat: formats the number to the formatString;
= localized
5. getIT2Be: returns my name, email and GSM :lol:

And Bob, what exactly do you expect of isInRange and isTextOnly?
And what further suggestions do you have?
Last edited by IT2Be on Mon Feb 02, 2004 7:47 pm, edited 1 time in total.
Marcel J.G. Trapman (IT2BE)
SAN partner - Freelance Java and Servoy
Servoy Components - IT2BE Plug-ins and Beans for Servoy
ServoyForge - Open Source Components for Servoy
User avatar
IT2Be
Servoy Expert
 
Posts: 4766
Joined: Tue Oct 14, 2003 7:09 pm
Location: Germany

Postby bcusick » Sat Jan 31, 2004 2:01 am

IT2BE wrote:OK here it is. v2 with 5 new functions:

1. getMaxDay: returns the last day of the given month;
2. isInteger: returns a boolean value, checks a string;
3. isNumber: returns a boolean value after checking a string;
= localized but will return false when you input thousand seperators...
4. numberFormat: formats the number to the formatString;
= localized
5. getIT2Be: returns my name, email and GSM :lol:


WOW! EXCELLENT JOB!! :o

IT2BE wrote:And Bob, what exactly do you expect of isInRange and isTextOnly?
And what further suggestions do you have?


isInRange would return a boolean and would allow you to specify:

isInRange(checkValue, dataType, lowerValue, upperValue)

For Example:
isInRange(elements.dateField, 'date', '1/30/2003|M/d/yyyy', '3/20/2003|M/d/yyyy')

isInRange(elements.numberField, 'number', '975.12', '1576.4885')

isInRange(elements.numberField, 'integer', '1000', '1576')


The isTextOnly() function would only take the string to compare. So, for example:

var isText = plugins.myplug.isTextOnly('This has 1 num in it');
//returns FALSE

var isText = plugins.myplug.isTextOnly('This has zero nums in it');
//returns TRUE

This will help tell if the user entered a number where text only is required. (needs to check if there is a numeric character in the passed string)

Again - GREAT JOB!

Bob
bcusick
 
Posts: 1255
Joined: Wed Apr 23, 2003 11:27 pm
Location: Thousand Oaks, CA USA

Version 3 of tools plugin

Postby IT2Be » Mon Feb 02, 2004 1:14 am

Here it is, version 3 of the tools plugin. I added the following 4 new methods:

- isExpired
takes a year, month and (optional) day and returns a boolean when expired. Can be used to check the expiration date of a credit card...

- isInRange
takes dates, numbers/integers and strings and returns true or false...
* dates: dates need to be set with new Date() not a db timestamp
* string: there is an option to be set to true if you want to ignore cases

- isTextOnly
takes a string and returns false if it finds numbers...

- modulus10
takes a string, filters all numbers and tells you the result of a modulus10 check. Can be used to check a credit card number...

Cheers
Last edited by IT2Be on Mon Feb 02, 2004 8:37 pm, edited 1 time in total.
Marcel J.G. Trapman (IT2BE)
SAN partner - Freelance Java and Servoy
Servoy Components - IT2BE Plug-ins and Beans for Servoy
ServoyForge - Open Source Components for Servoy
User avatar
IT2Be
Servoy Expert
 
Posts: 4766
Joined: Tue Oct 14, 2003 7:09 pm
Location: Germany

Postby Jan Blok » Mon Feb 02, 2004 10:58 am

Nice plugin, well done, one remark:

We are setting up a plugin registry (web page) to list all available plugins and prevent JavaScript plugin name collisions in future.
On that page will suggest to use names like "Company name" abbreviation followed with "_" and the goal of the plugin (and also name the jar that way)

So a nice JavaScript name for your plugin whould be:
"it2be_tools" packed in a file it2be_tools.jar

You might consider updating your plugin (before its widely used), also seen the fact your name get more exposure (it's in all the scripts :-) )
Jan Blok
Servoy
Jan Blok
 
Posts: 2684
Joined: Mon Jun 23, 2003 11:15 am
Location: Amsterdam

Postby IT2Be » Mon Feb 02, 2004 11:11 am

Hai Jan,

No problemo. But I personally don't like very long plugin names. Makes me type more or chances that a line falls off a screen are bigger.

Why not put the name in the .jar file and for the name usage in Servoy just "first-come-first-serve"?

Just a suggestion, otherwise I will upload the renamed version this morning...

BTW do you know how to 'lock-out' the .jar from reading the code?
Marcel J.G. Trapman (IT2BE)
SAN partner - Freelance Java and Servoy
Servoy Components - IT2BE Plug-ins and Beans for Servoy
ServoyForge - Open Source Components for Servoy
User avatar
IT2Be
Servoy Expert
 
Posts: 4766
Joined: Tue Oct 14, 2003 7:09 pm
Location: Germany

Postby Jan Blok » Mon Feb 02, 2004 11:31 am

Well it a suggestion, not a requirement, good practice like Java code package naming...
Most people will use "move" code anyway or use code completion (CTRL-SPACE), so typing will not be the problem.

At least name your plugin that way.

Tip: do only pack the files needed in the jar (.class/.gif)

To obscurify your code have a look at: retroguard
Last edited by Jan Blok on Mon Feb 02, 2004 9:04 pm, edited 1 time in total.
Jan Blok
Servoy
Jan Blok
 
Posts: 2684
Joined: Mon Jun 23, 2003 11:15 am
Location: Amsterdam

Tools plugin version 4 available...

Postby IT2Be » Mon Feb 02, 2004 7:46 pm

Version 4 of the Tools plugin is now renamed to it2be_tools upon request of Servoy.

PLEASE ONLY USE THIS RELEASE AND DELETE THE OLD ONE...

I optimized some code, corrected an error in the isModulus10 function and renamed validateEmail into isEmail and modulus10 into isModulus10...

The tools plugin holds the following twelve functions:

CALCULATION
1. getMaxDay
returns the last day of the given month.

2. getIT2Be
returns my name, email and GSM :lol:

(STRING) FORMATTING
1. dateFormat
very much like the Java dateFormat class to convert a date to a string and the other way around with (or without) a formatting string.

2. numberFormat
formats the (localized) number to the formatString.

3. secondsFormat
to make a number of seconds a string and the other way around. formatting like HH:mm:ss.

VALIDATION
1. isEmail
based on a method I posted earlier on this forum now available in this plugin. It takes a string with one or more email adresses and checks if the format is correct.

2. isExpired
takes a year, month and (optional) day and returns a boolean when expired. Can be used to check the expiration date of a credit card.

3. isInteger
returns a boolean value, checks a string.

4. isInRange
takes dates, numbers/integers and strings and returns true or false.
* dates: dates need to be set with new Date() not a db timestamp
* string: there is an option to be set to true if you want to ignore cases

5. isModulus10
takes a string, filters all numbers and tells you the result of a modulus10 check. Can be used to check a credit card number.

6. isNumber
returns a boolean value after checking a string.
* localized but will return false when you input thousand seperators.

7. isTextOnly
takes a string and returns false if it finds numbers.

The result is attached. Just drop it in your plugins folder and restart Servoy.

REMARK: When you used my old plugin please do a global search and replace for:

plugins.tools = plugins.it2be_tools
tools.modulus10 = tools.isModulus10
tools.validateEmail = tools.isEmail

Feel free to use it and distribute it but give me credit for it.
The plugin is provided M-^Qas isM-^R and I can not take any responsibility for the way it behaves or works

Any suggestions? Please let me know!
Any bugs? Please tell me!
Any new features needed? Please ask me?
Any questions? I don't know if we are allowed to use this forum for it but for now: Ask me!
Happpy? Don't hesitate to share it with me...

Cheers

BTW the tools plugin is written to work with Servoy v2M-^E
Last edited by IT2Be on Wed Feb 04, 2004 2:15 am, edited 2 times in total.
Marcel J.G. Trapman (IT2BE)
SAN partner - Freelance Java and Servoy
Servoy Components - IT2BE Plug-ins and Beans for Servoy
ServoyForge - Open Source Components for Servoy
User avatar
IT2Be
Servoy Expert
 
Posts: 4766
Joined: Tue Oct 14, 2003 7:09 pm
Location: Germany

Postby Ron » Mon Feb 02, 2004 10:03 pm

Congrats!

This is a great plugin Marcel!
Especially taking into consideration that untill recently you were a newby to Java and Javascripting.
I did'nt test all features but the I can't get the secondsFormat working.
I set the variable to a datefield.
I get an error saying: 'seconds2time is not a function'
I assume I do something wrong, can you give me a script example?
BTW maybe it is a good ID to give a little bit more info in your sample info.

TIA

Ron
Ron
 
Posts: 315
Joined: Fri May 23, 2003 12:30 am
Location: Netherlands

Postby IT2Be » Mon Feb 02, 2004 10:19 pm

Oh, I am sorry. seconds2time is the first name I gave secondsFormat and forgot to update it in the tooltip. So change the example to secondsFormat, input an integer and it will work... Or just transfer the function without example.

As for the examples. I tried to make a compromise between the amount of work an self expanatory examples... Not enough so it seems.

I will try to make this a little better in a next version...

Thanks for the compliments. Keep complimenting and challenging me and I will proceed with the plugin...

Ciao
Marcel J.G. Trapman (IT2BE)
SAN partner - Freelance Java and Servoy
Servoy Components - IT2BE Plug-ins and Beans for Servoy
ServoyForge - Open Source Components for Servoy
User avatar
IT2Be
Servoy Expert
 
Posts: 4766
Joined: Tue Oct 14, 2003 7:09 pm
Location: Germany

Postby pbakker » Mon Feb 02, 2004 10:22 pm

Well, you also got my compliments.... :D

I asked one question and next thing I know you have made the function I was looking for! :D Great job

Paul
pbakker
 
Posts: 2822
Joined: Wed Oct 01, 2003 8:12 pm
Location: Amsterdam, the Netherlands

Postby Harjo » Tue Feb 03, 2004 12:56 pm

I love the date <--> string functions

Keep up the good work!
Harjo
 
Posts: 4321
Joined: Fri Apr 25, 2003 11:42 pm
Location: DEN HAM OV, The Netherlands


Return to Plugins and Beans

Who is online

Users browsing this forum: No registered users and 16 guests