O InterProlog e a Declarativa Miguel Calejo Declarativa

Download Report

Transcript O InterProlog e a Declarativa Miguel Calejo Declarativa

XJ: an introduction
Miguel Calejo
Declarativa
http://www.declarativa.com/interprolog
XJ (XSB+Java) history
• XSB Inc. uses Prolog with large DBs for high-end
data consolidation&cleaning, knowledge extraction,
etc., to support e-Procurement and other processes
• From 1999 to 2002 Declarativa developed XJ, an
InterProlog-based infrastructure for Java GUIs
wrapping Prolog applications
–
–
–
–
XJ 1.0 (1999-2000)
XJ 2.0 (2001-2002): more pragmatic, easier to customize
Additional components (2003-today) by XSB, Inc.
March 2006: open source release
• Most desktop tools referred in http://www.xsb.com/
have a XJ GUI
2
http://www.declarativa.com/interprolog
XJ - declarative GUI construction
• Why the need for XJ?
– LOTS of different Prolog data to display and edit!
– Heterogeneous, “kind of” relational but non normalized
• Vision
– GUI “deduced” from logic program + annotations,
complemented with specific Java classes
– Automatically supports data updating & visualization,
operation invocation, error handling, undo
– Ride on Swing (JFC) and InterProlog
• Application development with XJ
– Prolog program is developed, ignoring GUI issues
– GUI Term declarations added
– Additional Java classes may be added for specifics
3
http://www.declarativa.com/interprolog
XJ rationale
• Generic principles
– Prolog term structure conditions GUI structure and layout
– Prolog atomic data typically maps into simple GUI elements
such as a Swing JTextField
– A Prolog free variable is assumed to be an empty or “null”
value
– Sets of Prolog tuples may be displayed as more complex
GUI elements, such as a Swing JTable or JTree
• Specifics
– Each term node can have a property list
– The (InterProlog) TermModel class represents terms; its (XJ)
subclass GUITerm represents annotated terms
4
http://www.declarativa.com/interprolog
XJ example: term annotations
alloy_shape( 'STEEL'( alloy('852') ), 'MOLD CASTING’ ).
labels(alloy_shape/2,'Alloy shape'('Alloy','Shape')).
guiTerm(alloy_shape(_M,_S),
gt(_,[],[gt(_,[operation(XXX,sisa('OBJECT',XXX),'Show in Ontology'), biGuiLink(X1,sub(X1,_),isa(X1,'METAL')) ],
[gt(alloy,[constant],
[gt(_,[atomUPPER,minSize=3,maxSize=10,typicalSize=8,name='Name'],[])
])
]),
gt(_,[atomUPPER,typicalSize=15, biGuiLink(X2,sub(X2,_),isa(X2,'CASTING'))],[])
])).
5
http://www.declarativa.com/interprolog
XJ 1.0 example: derived GUI
• editList(alloy_shape(_,_)).
Navigation to other windows
For list
Inplace editing w/
basic type checking
Double-click
For term
6
http://www.declarativa.com/interprolog
XJ 1.0 - another example
•
editList(spec_attr(S,_,_), (name(S,Chars),append("AMS 40",_,Chars)), _).
7
http://www.declarativa.com/interprolog
XJ2.0: pushing the Swing envelope...
Data can be
(lazily) fetched
from Prolog as
needed
8
http://www.declarativa.com/interprolog
...in Prolog style (sort of)
guiTermSet(conceptTree/6,null,'Under a class',Context,
gt(
'XJ$LAZY',
[
caption='Concept hierarchy',
operation(terms(_GUIref,SelectedList),writeln(newSelection-SelectedList),selectionChanged), root,
lazytree(
[
gt(_,[typename=complexid,typicalSize=1,class='com.xsb.xj.ValueRow',tip='M if multiple parents',readonly,
root,operation(term(R,P),writeln(R+P),menu('one test'))],[
gt(_,[borderless,class='com.xsb.xj.XJLabel',color=blue,atom,tip='Concept',operation(term(R,P),writeln(R+P),menu('another'))],[]), % concept names
assumed atomic
gt(_,[invisible,borderless,opaque,tip='Complex Concept ID'],_),
gt(_,[integer,tip='Dummy percentage',class='com.xsb.xj.XJSlider'],[]),
gt(_,[caption='check here',class='com.xsb.xj.XJCheckBox',myGUI(Checker),operation(term(R,P),writeln(checkedR+P),gui(Checker))],[]),
gt(':)',[nonpersistent,class='com.xsb.xj.XJButton',color=magenta,icon='http://www.declarativa.com/logo/minilogo.gif'],[])
]),
gt(_,[typename=simpleid,root,typicalSize=1,tip='M if multiple parents',readonly,class='com.xsb.xj.ValueRow'],[
gt(_,[atom,class='com.xsb.xj.XJLabel',color=red,tip='Concept'],[]),
gt(_,[integer,typicalSize=5,tip='Simple Concept ID'],[]),
gt(_,[integer,tip='Dummy percentage',class='com.xsb.xj.XJSlider',myGUI(Slider),
operation(term(R,P),writeln(R+P),gui(Slider))],[]),
gt(_,[caption='check here',class='com.xsb.xj.XJCheckBox'],[])
])
]
)
],
lazy(scGconceptTree(_,_,Context),nGconceptTree(_,_,_,Context),Context)
9
)
).
http://www.declarativa.com/interprolog
XJ concepts
• GUITerm class, GT terms
– Property lists
– Building Java visual hierarchies
– Containers
• Your own components: XJComponent
• About lists and trees
• Operations and functions
10
http://www.declarativa.com/interprolog
An XJ example
• Showing and editing data about one tuple
• Showing and editing data about several tuples
11
http://www.declarativa.com/interprolog
Conclusion
• Integrated documentation missing
• ...but full source downloadable from
http://www.xsb.com/xj.aspx
– Currently uses slight variation of InterProlog 2.1.2;
hopefully this will get cleaned up soon
12