PDA

View Full Version : <AttributeEditorClass> customize


ng-first
02-02-2007, 05:46 AM
Hi all,

I'm trying to customize the attribute description, in the 'Properties DB' window in Model Maneger.
To do this I associated the <AttributeEditorClass>to the description attribute, and I wrote the java class.

Now in the java class, I'd like to obtain the ID of the (wm)object, which the description attribute refers. So I can populate the desciption combo box, with specific values that refer to the (wm)object.

I post belove my java code:

public class DescrizioneAttributeEditor extends WMAttEditorComboBox
{

public DescrizioneAttributeEditor(WMAttribute wmAttribute) throws WMException,IOException
{
super(wmAttribute);
init();
}

public void init() throws WMException
{
//trovo il nome della class
String className = wmAttribute.getClassName();

try
{
WMClass wmClass = WMSession.getWMSession().openClass(className, true);
wmClass.getObjID(); //return null pointer
}
}

Can anyone help me?
Thank in advaced,
Nadia

jdh
02-02-2007, 09:26 AM
I am sorry, but I may not completely understand the issue you are having. However, there is a getDBObject() call that will return the WMElement who's attribute is being edited. But the DBObject is not set until the editor is displayed (it will be null in your init() method). You may need to overwrite the setDBObject method (make sure you call the super) and then do whatever logic you need to do.

ng-first
02-06-2007, 12:29 AM
Hi all.
Thank JDH for your precious help !!!!

I followed your suggestion and I overwrote the setDBObject method.

But now when I run ModelManager StandAlone and select DB Properties window, tab Atrribute I have this error:
"java.lang.Nul.PointerExceptionl" at setDBObject( DescrizioneAtributeEditor)
at com.osm.property,AttributePanel.getAttributeEditor(Unknown Source) ... ""

I post below my java code:

public DescrizioneAttributeEditor(WMAttribute wmAttribute)
throws WMException
{
super(wmAttribute);
}

public void setDBObject(WMDBObject wmObject)
{
if (getDBObject() == null)
JOptionPane.showMessageDialog(parentComp, "getDBObject IS NULL");
super.setDBObject(this.getDBObject());
try
{
//trovo l'idel del dato originale
idel = getDBObject().getObjID();
....
}
catch (Exception e)
{}
}
When I run Model Manager StandAlone first of all I see the if message that tell me that getDBObject() is NULL !!!!

:eek: What's wrong in my java code ?!?!?!?

Thank in advenced,
Nadia

ng-first
02-06-2007, 02:08 AM
WOW !!!
It seems that setDBObject method is being reloaded several time: at the first time the wmObject is null, at the others onces the wmObject is not null.

So I introduced a controll, to be sure the wmObject is not null and the null pointer exception disappears :))))) !!!!

Thank all for help.

Is there a tutorial that explains to me this java method and their implementation ?!?!?

by,
Nadia

jdh
02-07-2007, 06:50 PM
There is nothing wrong with your code. The setDBObject method is sometimes called with null objects so you need to protect against null values. Also, it is called way too many times so your logic must be able to handle the method being called multiple times.

I am sorry this is so difficult. There are not many people trying to customize attribute editors so we have not tried to simplify the process.

What are you trying to do exactly? Maybe if I understood what you need to do I could help a little better.

ng-first
02-20-2007, 05:10 AM
Hi All !!!
I

ng-first
02-20-2007, 06:44 AM
Hi all!
I wrote several mails, all about attribute editor.
First of all, sorry for my 'confused' english and than ... I will try again to explain my tagert.
I have description attribute of mastardata, that is a coltype attribute, populate with a table named CLASSIFICAZIONE .
Now, this table has 3 coloums: DB_CLASS_NAME, SOTTOCLASSE, and DESCRIZIONE
and I filled records in this table, using the values of the attributes of our part/masterdata.
For examples :
row1:
- classe = 'alberi', //one of our class that extends MasterData
- sottoclasse = 'folle',
- descrizione = 'A RIFLESSIONE'
row2:
- classe = 'alberi', //one of our class that extends MasterData
- sottoclasse = 'folle',
- descrizione = 'A SBARRAMENTO'
....

Now, in the 'DB properties' window of a MasterData, the DESCRIZIONE atribute contains all records of the table CLASSIFICAZIONE !!!
I woul'd like to see only the descriptions (for DESCRIZIONE attribute) associates with the DB_CLASS_NAME and SOTTOCLASSE values of masterdata,
in the CLASSIFICAZIONE table.
For examples, if I'm working with a part that has DB_CLASS_NAME='alberi' and SOTTOCLASSE='folle', I woul'd like to see for the DESCRIZIONE attribute
only this value: 'A RIFLESSIONE', 'A SBARRAMENTO'.
1) How can I customize the values to display into coltype attribute? Making a query on CLASSIFICAZIONE table?
In the 'DB properties' window, I woul'd like that when the user changes value for the SOTTOCLASSE attribute, than the window
reloads the values for the DESCRIZIONE attribute, according to the selected value for SOTTOCLASSE attribute.
2)Is it possible to reload dinamically the values for a attribute, according to the selected value for another one?
I tried to add an addActionListener to the DESCRIZIONE Attribute Editor class,
but it seems that the actionPerformed method is being loaded while loading the 'DB properties' window, and not when a value of a attribute changes ...
Thank's a lot,
Nadia

ng-first
02-27-2007, 06:05 AM
Hi all !!!!
Why I received no answers ?!?!

1) How can I customize the values to display into coltype attribute?
2)Is it possible to reload dinamically the values for a attribute,
according to the selected value for another one?

... maybe my mails is not very clear ?!?!?!?

Thanks,
Nadia