Setting WidgetType of a slot

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Setting WidgetType of a slot

Benhur


Hi,

I want to set the widget type of a slot of a given class to none. How can I do this programmatically? I am using Protege 2.1 version. If anyone has any code snippets, please send me. Thanks.

TIA
Benhur

**************** CAUTION - Disclaimer *****************
This e-mail contains PRIVILEGED AND CONFIDENTIAL INFORMATION intended solely for the use of the addressee(s). If you are not the intended recipient, please notify the sender by e-mail and delete the original message. Further, you are not to copy, disclose, or distribute this e-mail or its contents to any other person and any such actions are unlawful. This e-mail may contain viruses. Infosys has taken every reasonable precaution to minimize this risk, but is not liable for any damage you may sustain as a result of any virus in this e-mail. You should carry out your own virus checks before opening the e-mail or attachment. Infosys reserves the right to monitor and review the content of all messages sent to or from this e-mail address. Messages sent to or from this e-mail address may be stored on the Infosys e-mail system.
***INFOSYS******** End of Disclaimer ********INFOSYS***
-------------------------------------------------------------------------
To unsubscribe go to http://protege.stanford.edu/community/subscribe.html

Reply | Threaded
Open this post in threaded view
|

Re: Setting WidgetType of a slot

Tania Tudorache

Benhur,

you can replace the slot widget type with null. Here is a snipet of code:

      Cls myCls = kb.getCls("myCls");
      Slot mySlot = kb.getSlot("mySlot");

      FormWidget formWidget = (FormWidget)
kb.getProject().getDesignTimeClsWidget(myCls);        
      formWidget.replaceWidget(mySlot, null);

This code works with protege 3.1, but it should work also with 2.1.

Tania


Benhur wrote:

>Hi,
>
>I want to set the widget type of a slot of a given class to none. How can I do this programmatically? I am using Protege 2.1 version. If anyone has any code snippets, please send me. Thanks.
>
>TIA
>Benhur
>
>**************** CAUTION - Disclaimer *****************
>This e-mail contains PRIVILEGED AND CONFIDENTIAL INFORMATION intended solely for the use of the addressee(s). If you are not the intended recipient, please notify the sender by e-mail and delete the original message. Further, you are not to copy, disclose, or distribute this e-mail or its contents to any other person and any such actions are unlawful. This e-mail may contain viruses. Infosys has taken every reasonable precaution to minimize this risk, but is not liable for any damage you may sustain as a result of any virus in this e-mail. You should carry out your own virus checks before opening the e-mail or attachment. Infosys reserves the right to monitor and review the content of all messages sent to or from this e-mail address. Messages sent to or from this e-mail address may be stored on the Infosys e-mail system.
>***INFOSYS******** End of Disclaimer ********INFOSYS***
>-------------------------------------------------------------------------
>To unsubscribe go to http://protege.stanford.edu/community/subscribe.html
>
>
>  
>

-------------------------------------------------------------------------
To unsubscribe go to http://protege.stanford.edu/community/subscribe.html

Reply | Threaded
Open this post in threaded view
|

RE: [protégé-discussion] Re: Setting WidgetType of a slot

Benhur
In reply to this post by Benhur

Thanks Tania for the reply. However the below code is not working as expected, though I thought it should work. Before executing the below line of code, and after creating the slot,

formWidget.replaceWidget(mySlot, null);

I tried to print the widget type of mySlot using the code formWidget.getSlotWidget(mySlot). This code is returning a null value. So, even after setting the widget type to null, the expected result is not found.

My problem goes like this.

When I open Protégé 2.1.2 version tool, go to classes tab and create a class (say Person) and create a slot (say personName) with value type as "String" and attach to class. Now, if I go to Forms tab in Protégé tool, and see the widget type of personName slot, the widget type will be displayed as "TextFieldWidget". This can be changed to "<none>", just by double clicking in the forms tab and setting the widget type to none. That means, the customization is done at the class-level for one slot. This is precisely I want to get, but programmatically.

Do I need to do something more than the below code? Please let me know.

TIA
Benhur

-----Original Message-----
From: [hidden email]
[mailto:[hidden email]]On Behalf Of Tania
Tudorache
Sent: Saturday, March 18, 2006 6:43 AM
To: [hidden email]
Subject: [protege-discussion] Re: Setting WidgetType of a slot



Benhur,

you can replace the slot widget type with null. Here is a snipet of code:

      Cls myCls = kb.getCls("myCls");
      Slot mySlot = kb.getSlot("mySlot");

      FormWidget formWidget = (FormWidget)
kb.getProject().getDesignTimeClsWidget(myCls);        
      formWidget.replaceWidget(mySlot, null);

This code works with protege 3.1, but it should work also with 2.1.

Tania


Benhur wrote:

>Hi,
>
>I want to set the widget type of a slot of a given class to none. How can I do this programmatically? I am using Protege 2.1 version. If anyone has any code snippets, please send me. Thanks.
>
>TIA
>Benhur
>
>**************** CAUTION - Disclaimer *****************
>This e-mail contains PRIVILEGED AND CONFIDENTIAL INFORMATION intended solely for the use of the addressee(s). If you are not the intended recipient, please notify the sender by e-mail and delete the original message. Further, you are not to copy, disclose, or distribute this e-mail or its contents to any other person and any such actions are unlawful. This e-mail may contain viruses. Infosys has taken every reasonable precaution to minimize this risk, but is not liable for any damage you may sustain as a result of any virus in this e-mail. You should carry out your own virus checks before opening the e-mail or attachment. Infosys reserves the right to monitor and review the content of all messages sent to or from this e-mail address. Messages sent to or from this e-mail address may be stored on the Infosys e-mail system.
>***INFOSYS******** End of Disclaimer ********INFOSYS***
>-------------------------------------------------------------------------
>To unsubscribe go to http://protege.stanford.edu/community/subscribe.html
>
>
>  
>

-------------------------------------------------------------------------
To unsubscribe go to http://protege.stanford.edu/community/subscribe.html

-------------------------------------------------------------------------
To unsubscribe go to http://protege.stanford.edu/community/subscribe.html

Reply | Threaded
Open this post in threaded view
|

Re: [protégé-discussion] Re: Setting WidgetType of a slot

Benhur
In reply to this post by Benhur


Thanks Tania for the reply. However the below code is not working as expected, though I thought it should work. Before executing the below line of code, and after creating the slot,

formWidget.replaceWidget(mySlot, null);

I tried to print the widget type of mySlot using the code formWidget.getSlotWidget(mySlot). This code is returning a null value. So, even after setting the widget type to null, the expected result is not found.

My problem goes like this.

When I open Protégé 2.1.2 version tool, go to classes tab and create a class (say Person) and create a slot (say personName) with value type as "String" and attach to class. Now, if I go to Forms tab in Protégé tool, and see the widget type of personName slot, the widget type will be displayed as "TextFieldWidget". This can be changed to "<none>", just by double clicking in the forms tab and setting the widget type to none. That means, the customization is done at the class-level for one slot. This is precisely I want to get, but programmatically.

Do I need to do something more than the below code? Please let me know.

TIA
Benhur

-----Original Message-----
From: [hidden email]
[mailto:[hidden email]]On Behalf Of Tania
Tudorache
Sent: Saturday, March 18, 2006 6:43 AM
To: [hidden email]
Subject: [protege-discussion] Re: Setting WidgetType of a slot



Benhur,

you can replace the slot widget type with null. Here is a snipet of code:

      Cls myCls = kb.getCls("myCls");
      Slot mySlot = kb.getSlot("mySlot");

      FormWidget formWidget = (FormWidget)
kb.getProject().getDesignTimeClsWidget(myCls);        
      formWidget.replaceWidget(mySlot, null);

This code works with protege 3.1, but it should work also with 2.1.

Tania


Benhur wrote:

>Hi,
>
>I want to set the widget type of a slot of a given class to none. How can I do this programmatically? I am using Protege 2.1 version. If anyone has any code snippets, please send me. Thanks.
>
>TIA
>Benhur

**************** CAUTION - Disclaimer *****************
This e-mail contains PRIVILEGED AND CONFIDENTIAL INFORMATION intended solely for the use of the addressee(s). If you are not the intended recipient, please notify the sender by e-mail and delete the original message. Further, you are not to copy, disclose, or distribute this e-mail or its contents to any other person and any such actions are unlawful. This e-mail may contain viruses. Infosys has taken every reasonable precaution to minimize this risk, but is not liable for any damage you may sustain as a result of any virus in this e-mail. You should carry out your own virus checks before opening the e-mail or attachment. Infosys reserves the right to monitor and review the content of all messages sent to or from this e-mail address. Messages sent to or from this e-mail address may be stored on the Infosys e-mail system.
***INFOSYS******** End of Disclaimer ********INFOSYS***
-------------------------------------------------------------------------
To unsubscribe go to http://protege.stanford.edu/community/subscribe.html

Reply | Threaded
Open this post in threaded view
|

Re: [protégé-discussion] Re: Setting WidgetType of a slot

Tania Tudorache

Benhur,

Try this code on the newspaper project:

          Cls editorCls = kb.getCls("Editor");
          FormWidget formWidget = (FormWidget)
kb.getProject().getDesignTimeClsWidget(editorCls);
          Slot testSlot = kb.getSlot("other_information");
         
          System.out.println("Slot widget: " +
formWidget.getSlotWidget(testSlot));
          formWidget.replaceWidget(testSlot, null);                
          System.out.println("Slot widget: " +
formWidget.getSlotWidget(testSlot));

The console output is the following:
Slot widget:
edu.stanford.smi.protege.widget.TextFieldWidget[TextFieldWidget,...]
Slot widget: null

As you see, before replacing the widget, the widget of the slot
"other_information" is the TextFieldWidget. After replacing the widget,
the slot widget is null, as expected. This is the programmatic
correspondent of what you described in your email.

The forms are associated to classes. That is why, you get the form
widget of a certain class, in our case "Editor" and then change (only
for that class) the slot widget for slot "other_information".

Please try the code from above, and save the project. Then open it
again, and see if the form of Editor has changed.

I have tested this code and it worked for me.

Tania



Benhur wrote:

>Thanks Tania for the reply. However the below code is not working as expected, though I thought it should work. Before executing the below line of code, and after creating the slot,
>
>formWidget.replaceWidget(mySlot, null);
>
>I tried to print the widget type of mySlot using the code formWidget.getSlotWidget(mySlot). This code is returning a null value. So, even after setting the widget type to null, the expected result is not found.
>
>My problem goes like this.
>
>When I open Protégé 2.1.2 version tool, go to classes tab and create a class (say Person) and create a slot (say personName) with value type as "String" and attach to class. Now, if I go to Forms tab in Protégé tool, and see the widget type of personName slot, the widget type will be displayed as "TextFieldWidget". This can be changed to "<none>", just by double clicking in the forms tab and setting the widget type to none. That means, the customization is done at the class-level for one slot. This is precisely I want to get, but programmatically.
>
>Do I need to do something more than the below code? Please let me know.
>
>TIA
>Benhur
>
>-----Original Message-----
>From: [hidden email]
>[mailto:[hidden email]]On Behalf Of Tania
>Tudorache
>Sent: Saturday, March 18, 2006 6:43 AM
>To: [hidden email]
>Subject: [protege-discussion] Re: Setting WidgetType of a slot
>
>
>
>Benhur,
>
>you can replace the slot widget type with null. Here is a snipet of code:
>
>      Cls myCls = kb.getCls("myCls");
>      Slot mySlot = kb.getSlot("mySlot");
>
>      FormWidget formWidget = (FormWidget)
>kb.getProject().getDesignTimeClsWidget(myCls);        
>      formWidget.replaceWidget(mySlot, null);
>
>This code works with protege 3.1, but it should work also with 2.1.
>
>Tania
>
>
>Benhur wrote:
>
>  
>
>>Hi,
>>
>>I want to set the widget type of a slot of a given class to none. How can I do this programmatically? I am using Protege 2.1 version. If anyone has any code snippets, please send me. Thanks.
>>
>>TIA
>>Benhur
>>    
>>
>
>**************** CAUTION - Disclaimer *****************
>This e-mail contains PRIVILEGED AND CONFIDENTIAL INFORMATION intended solely for the use of the addressee(s). If you are not the intended recipient, please notify the sender by e-mail and delete the original message. Further, you are not to copy, disclose, or distribute this e-mail or its contents to any other person and any such actions are unlawful. This e-mail may contain viruses. Infosys has taken every reasonable precaution to minimize this risk, but is not liable for any damage you may sustain as a result of any virus in this e-mail. You should carry out your own virus checks before opening the e-mail or attachment. Infosys reserves the right to monitor and review the content of all messages sent to or from this e-mail address. Messages sent to or from this e-mail address may be stored on the Infosys e-mail system.
>***INFOSYS******** End of Disclaimer ********INFOSYS***
>-------------------------------------------------------------------------
>To unsubscribe go to http://protege.stanford.edu/community/subscribe.html
>
>
>  
>

-------------------------------------------------------------------------
To unsubscribe go to http://protege.stanford.edu/community/subscribe.html