Advice on techniques

Forums for specific tips, techniques and example code
ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Advice on techniques

Postby ConvertFromOldNGs » Fri Aug 07, 2009 2:40 pm

by tyc >> Fri, 22 Nov 2002 6:33:50 GMT

Hi Jade Developers,
My developers had come up with some questions which I am unable to
answer so far, thus need advise on these.

1) In the development environment, we are able to select CLASS, and
get the References from the Menu bar and be able to see all the references made by the Class.
Is there anyway we can code this functionality and what would be
the correct way of doing that.

2) Again in development stage, we have Forms which we can change the values in the Controls.Since to change it in the Developement
environment [especially when there are a lot of forms] means a lot of effort, we tried to change it using coding. Yet we found that no
matter how we change the properties in the Form, whenever we use the Painter to view the forms, it remains unchanged.

Is there any way we can use codes to change the properties of the Form and let it update to the Forms permanently?

Below is an excerpt of our codes. Was it done wrongly?

vars
cls : Class;
p : Property;
ctr : Control;
i,id,j : Integer;
form : Form;
aMethod : Method;
frm : FrmFAMast;
binOld,binNew : Binary; begin

id := 5129;
beginTransaction;
foreach cls in currentSchema.getAllClasses(false) do
if cls.transient = true and (cls.inheritsFrom (Form))
then
form := currentSchema.findFormForLocale(cls.name,id);
if (not global.isValidObject(form)) then
continue;
endif;

foreach i in 1 to form.controlCount() do
ctr := form.controls(i);
if (ctr.isKindOf(Label) and ctr.fontSize <=9)
then
ctl.fontSize :=10;
endif;
endforeach;
endforeach;
commitTransaction;


Advise and comments appreciated
Thanks

Regards,
L.C. Lim
end;

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: Advice on techniques

Postby ConvertFromOldNGs » Fri Aug 07, 2009 2:40 pm

by torrie >> Fri, 22 Nov 2002 9:48:08 GMT

1) Jade does store this information in the database but the properties are hidden from developers. You will need to use the Class.getProperties method and the Type.getMethods() methods to find out what properties are available on the Class, Property and Method classes (I think there is an earlier post on this somewhere) Then after identifying the likely properties (getMethodsRefs on Feature for example) use the getPropertyValue method to retreive the data. I'm not sure if these are populated in a production system though.
NOTE As these are not published etc by Jade they are subject to change and you should be careful about relying on them for a production system.

2) With reguard to changing the forms, the Jade painter builds a binary image of the form when you save it. This is what Jade uses to build the form, not the data stored in the Control classes. If you do want to change the controls you will need to force Jade to rebuild the forms. If all your forms are subclassed from a common super form, all you need to do is run the code above and then open the top level form in painter and save it. This forces Jade to rebuild all the forms from the data stored in the instances of the Control class and its subclass. If you just want to change a single form you will need to open that form in painter and then save it. Again this seems to work but is not supported so you will need to be careful (ie backup before you try it!)

Torrie

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: Advice on techniques

Postby ConvertFromOldNGs » Fri Aug 07, 2009 2:41 pm

by allistar >> Fri, 22 Nov 2002 22:47:35 GMT

More on this:

1) You can get the references to classes/methodfs/properties at runtime. There are hidden properties and methods on the metadata object that store this information. We have done exactly this to find out where a methods is called from at runtime.

2) Setting the property on a controlas per your example won't work, first you need to find the persistent object for that property. There is a method on the Window class called "getPersientControl". This will return the instance of the control object that you should modify. (This is from memory - I don't have Jade in front of me - alas it won't run on Linux yet).

We use this quite a bit in our development, expecially for repetiitive changes. The improtant thing is that after running the code you MUST open the form in the painter and save it again.

Hope this helps,
Allistar.


Return to “Tips and Techniques”

Who is online

Users browsing this forum: No registered users and 8 guests