Lazarus

Programming => General => Topic started by: elidorio on March 07, 2016, 02:11:10 am

Title: Replace TDBZVDateTimePicker components by TDBDateTimePicker
Post by: elidorio on March 07, 2016, 02:11:10 am
I was using the TDBDateTimePicker components, now I want to replace  TDBZVDateTimePicker.
Replacing components of automatic way?


Title: Re: Replace TDBZVDateTimePicker components by TDBDateTimePicker
Post by: JuhaManninen on March 07, 2016, 02:36:58 am
I was using the TDBDateTimePicker components, now I want to replace TDBDateTimePicker.

Replace with what?
 
Title: Re: Replace TDBZVDateTimePicker components by TDBDateTimePicker
Post by: elidorio on March 07, 2016, 02:46:09 am
ops!
Per  TDBZVDateTimePicker
Title: Re: Replace TDBZVDateTimePicker components by TDBDateTimePicker
Post by: GetMem on March 07, 2016, 06:20:05 am
@elidorio
You need a find/replace tool(text crawler):
 1. set your project folder
 2. set the filters(*.pas; *.pp; *.lfm)
 3. search for TDBDateTimePicker then replace with TDBZVDateTimePicker.

The whole process shouldn't take more then 5 minutes. After this you should manually change properties/methods there are no longer valid, because of the different component.

PS: Alternatively you can use the built-in Search/Find in files dialog(Shift+Ctrl+F).
Title: Re: Replace TDBZVDateTimePicker components by TDBDateTimePicker
Post by: taazz on March 07, 2016, 06:20:39 am
There isn't any tool/addin that does that automatically you have to run a search and replace in both pas and lfm files either one by one or with an external text editor
Title: Re: Replace TDBZVDateTimePicker components by TDBDateTimePicker
Post by: Zoran on March 07, 2016, 09:01:44 am
@elidorio
You need a find/replace tool(text crawler):
 1. set your project folder
 2. set the filters(*.pas; *.pp; *.lfm)
 3. search for TDBDateTimePicker then replace with TDBZVDateTimePicker.


3. should be "search for TDBZVDateTimePicker then replace with TDBDateTimePicker."
OR BETTER search for ZVDateTimePicker and replace with DateTimePicker (this will in one move replace all TZVDateTimePickers with TDateTimePickers and all TDBZVDateTimePickers with TDBDateTimePickers, and also will conveniently replace control names on your forms - eg. ZVDateTimePicker1 will become DateTimePicker1).

After this you should manually change properties/methods there are no longer valid, because of the different component.

There shouldn't be any.

Plus, open Project Inspector (Project->Project Inspector in main menu) and remove dependency of ZVDateTimeCtrls package. Then uninstall ZVDateTimeCtrls from the IDE, you will not need it any more.
Title: Re: Replace TDBZVDateTimePicker components by TDBDateTimePicker
Post by: GetMem on March 07, 2016, 09:17:04 am
Quote
@Zoran
3. should be "search for TDBZVDateTimePicker then replace with TDBDateTimePicker."
If I understood this correctly, he want to replace TDBDateTimePicker with TDBZVDateTimePicker. So he should search for TDBDateTimePicker.
Title: Re: Replace TDBZVDateTimePicker components by TDBDateTimePicker
Post by: taazz on March 07, 2016, 09:51:49 am
Quote
@Zoran
3. should be "search for TDBZVDateTimePicker then replace with TDBDateTimePicker."
If I understood this correctly, he want to replace TDBDateTimePicker with TDBZVDateTimePicker. So he should search for TDBDateTimePicker.
That would be unwise,  TDBDateTimePicker is TDBZVDateTimePicker merged in the lcl it self. I would think that TDBZVDateTimePicker development is halted at this time and every effort is targeted on TDBDateTimePicker.
Title: Re: Replace TDBZVDateTimePicker components by TDBDateTimePicker
Post by: Zoran on March 07, 2016, 10:07:26 am
Quote
@Zoran
3. should be "search for TDBZVDateTimePicker then replace with TDBDateTimePicker."
If I understood this correctly, he want to replace TDBDateTimePicker with TDBZVDateTimePicker. So he should search for TDBDateTimePicker.

Perhaps he said that, but then I believe he made mistake.
Anyway, I strongly recommend using controls from DateTimeCtrls package (http://wiki.freepascal.org/DateTimeCtrls_Package) over "ZV" controls (http://wiki.freepascal.org/ZVDateTimeControls_Package).
These are same controls, but when they got included in Lazarus distribution, the name was changed for Delphi compatibility. So, ZVDateTimeControls are no more updated and it is suggested to switch to DateTimeCtrls package which is included in Lazarus (the controls are automatically installed in component palette).

That would be unwise,  TDBDateTimePicker is TDBZVDateTimePicker merged in the lcl it self. I would think that TDBZVDateTimePicker development is halted at this time and every effort is targeted on TDBDateTimePicker.

Exactly.
Title: Re: Replace TDBZVDateTimePicker components by TDBDateTimePicker
Post by: GetMem on March 07, 2016, 10:27:38 am
@Zoran
I'm not arguing about which component is better. I know you're the current maintainer of TDBDateTimePicker :), I'm also aware that you put a lot of effort lately to make it better(http://forum.lazarus.freepascal.org/index.php/topic,31679.msg203242.html#msg203242). But perhaps the OP has a good reason the switch back to an older, obsolete component, or maybe he has absolutely no idea what he is doing. I was only trying to help him to switch from one component to another...
Anyway, I believe hes has more then enough information know. 
Title: Re: Replace TDBZVDateTimePicker components by TDBDateTimePicker
Post by: Zoran on March 07, 2016, 11:27:06 am
@Zoran
I'm not arguing about which component is better. I know you're the current maintainer of TDBDateTimePicker :), I'm also aware that you put a lot of effort lately to make it better(http://forum.lazarus.freepascal.org/index.php/topic,31679.msg203242.html#msg203242). But perhaps the OP has a good reason the switch back to an older, obsolete component, or maybe he has absolutely no idea what he is doing. I was only trying to help him to switch from one component to another...
I know :)

Anyway, I believe hes has more then enough information know. 
Yes, I agree.
Title: Re: Replace TDBZVDateTimePicker components by TDBDateTimePicker
Post by: elidorio on March 08, 2016, 09:29:44 pm
To work I had to click on each TDBZDateTimePicker and Change class and switch to TDBDateTimePicker
Title: Re: Replace TDBZVDateTimePicker components by TDBDateTimePicker
Post by: Zoran on March 09, 2016, 12:33:00 pm
To work I had to click on each TDBZDateTimePicker and Change class and switch to TDBDateTimePicker

Couldn't you do what GetMem proposed? Even better, corrected with what I said here:
@elidorio
You need a find/replace tool(text crawler):
 1. set your project folder
 2. set the filters(*.pas; *.pp; *.lfm)
 3. search for TDBDateTimePicker then replace with TDBZVDateTimePicker.


3. should be "search for TDBZVDateTimePicker then replace with TDBDateTimePicker."
OR BETTER search for ZVDateTimePicker and replace with DateTimePicker (this will in one move replace all TZVDateTimePickers with TDateTimePickers and all TDBZVDateTimePickers with TDBDateTimePickers, and also will conveniently replace control names on your forms - eg. ZVDateTimePicker1 will become DateTimePicker1).

After this you should manually change properties/methods there are no longer valid, because of the different component.

There shouldn't be any.

Plus, open Project Inspector (Project->Project Inspector in main menu) and remove dependency of ZVDateTimeCtrls package. Then uninstall ZVDateTimeCtrls from the IDE, you will not need it any more.

As GetMem said, it shouldn't take more than couple of minutes. Anyway, I am sorry for this inconvenience caused by name change, but it would be too much work for me to continue maintaining the same package with different name in parallel. I'll see if I can create a tool which will do this conversion.
Title: Re: Replace TDBZVDateTimePicker components by TDBDateTimePicker
Post by: wp on March 09, 2016, 12:36:48 pm
To work I had to click on each TDBZDateTimePicker and Change class and switch to TDBDateTimePicker
Couldn't you do what GetMem proposed?
What's wrong with it? That's the way for changing classes provided by Lazarus.
Title: Re: Replace TDBZVDateTimePicker components by TDBDateTimePicker
Post by: taazz on March 09, 2016, 12:56:57 pm
To work I had to click on each TDBZDateTimePicker and Change class and switch to TDBDateTimePicker
Couldn't you do what GetMem proposed?
What's wrong with it? That's the way for changing classes provided by Lazarus.
it has to be done for each control instead of once for all.
Title: Re: Replace TDBZVDateTimePicker components by TDBDateTimePicker
Post by: elidorio on March 10, 2016, 12:51:15 am
1. Perform the procedures that GetMem propos.
2 - click on each TDBZDateTimePicker and Change class and switch to TDBDateTimePick

Note: If I only procedure 1, still generating errors that TDBZVDateTimePicker class was not found.
You have to perform the procedure 2 for each component TDBZVDateTimePicker
Title: Re: Replace TDBZVDateTimePicker components by TDBDateTimePicker
Post by: taazz on March 10, 2016, 12:53:38 am
1. Perform the procedures that GetMem propos.
2 - click on each TDBZDateTimePicker and Change class and switch to TDBDateTimePick

Note: If I only procedure 1, still generating errors that TDBZVDateTimePicker class was not found.
You have to perform the procedure 2 for each component TDBZVDateTimePicker
you need to replace the type both in pas and lfm files.
Title: Re: Replace TDBZVDateTimePicker components by TDBDateTimePicker
Post by: wp on March 10, 2016, 01:04:32 am
1. Perform the procedures that GetMem propos.
2 - click on each TDBZDateTimePicker and Change class and switch to TDBDateTimePick

Note: If I only procedure 1, still generating errors that TDBZVDateTimePicker class was not found.
You have to perform the procedure 2 for each component TDBZVDateTimePicker
Of course, in procedure 1 you have to replace the unit TDBZVDateTimePicker (I don't know its name, it's in your uses list) with the one for TDBDateTimePicker (DBDateTimePicker). In procedure 2 this is done automatically.
Title: Re: Replace TDBZVDateTimePicker components by TDBDateTimePicker
Post by: elidorio on March 10, 2016, 03:16:57 am
I'll wait a few more days, perhaps @Zoran, create a tool to replace these components more easily. I have several projects to upgrade.
Title: Re: Replace TDBZVDateTimePicker components by TDBDateTimePicker
Post by: Zoran on March 10, 2016, 03:10:38 pm
I'll wait a few more days, perhaps @Zoran, create a tool to replace these components more easily. I have several projects to upgrade.

Okay, I created this utility.
Here it is, attached to this post. Compile and run the application and please tell us if this solves the problem.

Note:
With this tool the conversion should run very smoothly if you don't have mixed old ZVDateTimeCtrls and new DateTimeCtrls dependencies in your project. However, if you have, you will encounter double references to DateTimeCtrls, which you should then correct manually.

Regards, Zoran.
Title: Re: Replace TDBZVDateTimePicker components by TDBDateTimePicker
Post by: elidorio on March 13, 2016, 05:36:30 am
Hello Zoran,
It worked perfectly for me, perform the replacement of components.
Thank you.
TinyPortal © 2005-2018