Difference between revisions of "ReadOnlyForms"

From Protege Wiki
Jump to: navigation, search
(New page: * Making slot-widgets read-only programmatically * Below is a snippet of code that shows how to make a slot widget from a class form read-only by using the API. The example uses the Newsp...)
 
Line 15: Line 15:
  
 
The code above changes the form of class Article, so all instances of Article that you will display will have the page_number slot widget read-only.
 
The code above changes the form of class Article, so all instances of Article that you will display will have the page_number slot widget read-only.
 +
 +
See also:
 +
* [[UseProtegeFormsInApplications]]
 +
* [[Changing_forms_programtically]]

Revision as of 17:44, July 8, 2008

  • Making slot-widgets read-only programmatically *

Below is a snippet of code that shows how to make a slot widget from a class form read-only by using the API. The example uses the Newspaper ontology - it will show the form for "Destination Mars" instance of class "Article" and make the "page_number" slot widget read-only.

Cls article = kb.getCls("Article");
Slot pageNo = kb.getSlot("page_number");
Instance inst = kb.getInstance("instance_00044"); // "Destination Mars"
//this is the actual code
ClsWidget clsWidget = prj.getDesignTimeClsWidget(article);
SlotWidget slotWidget = clsWidget.getSlotWidget(pageNo);
((AbstractSlotWidget)slotWidget).setReadOnlyWidget(true);

prj.show(inst);


The code above changes the form of class Article, so all instances of Article that you will display will have the page_number slot widget read-only.

See also: