gate.gui.ontology
Class OntologyEditor

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JPanel
                  extended by gate.creole.AbstractVisualResource
                      extended by gate.gui.ontology.OntologyEditor
All Implemented Interfaces:
OntologyModificationListener, ResizableVisualResource, Resource, FeatureBearer, NameBearer, VisualResource, ImageObserver, MenuContainer, Serializable, EventListener, Accessible

public class OntologyEditor
extends AbstractVisualResource
implements ResizableVisualResource, OntologyModificationListener

The GUI for the Ontology Editor

Author:
niraj
See Also:
Serialized Form

Nested Class Summary
protected  class OntologyEditor.AnnotationPropertyValueAction
           
protected  class OntologyEditor.DatatypePropertyValueAction
           
protected  class OntologyEditor.ObjectPropertyValueAction
           
 
Nested classes/interfaces inherited from class javax.swing.JPanel
JPanel.AccessibleJPanel
 
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
protected  JButton annotationProperty
           
protected  AnnotationPropertyAction annotationPropertyAction
           
protected  JButton datatypeProperty
           
protected  DatatypePropertyAction datatypePropertyAction
           
protected  JButton delete
           
protected  DeleteOntologyResourceAction deleteOntoResourceAction
           
protected  JTable detailsTable
          The list view used to display item details
protected  DetailsTableModel detailsTableModel
           
protected  JScrollPane detailsTableScroller
           
protected  JButton instance
           
protected  InstanceAction instanceAction
           
protected  OntologyItemComparator itemComparator
          Ontology Item Comparator
protected  ArrayList<TreeNodeSelectionListener> listeners
           
protected  JSplitPane mainSplit
          The main split
protected  JButton objectProperty
           
protected  ObjectPropertyAction objectPropertyAction
           
protected  Ontology ontology
          the ontology instance
protected  ArrayList<String> ontologyClassesURIs
           
protected  JTable propertyDetailsTable
           
protected  PropertyDetailsTableModel propertyDetailsTableModel
           
protected  JScrollPane propertyDetailsTableScroller
           
protected  DefaultMutableTreeNode propertyRootNode
          The property root node of the tree
protected  JScrollPane propertyScroller
           
protected  gate.gui.ontology.OntologyEditor.DnDJTree propertyTree
          The property treeView
protected  DefaultTreeModel propertyTreeModel
          The property model, for the tree
protected  JButton queryBtn
           
protected  JButton refreshOntologyBtn
           
protected  JButton restriction
           
protected  RestrictionAction restrictionAction
           
protected  HashMap<DefaultMutableTreeNode,ONodeID> reverseMap
           
protected  DefaultMutableTreeNode rootNode
          The root node of the tree.
protected  JScrollPane scroller
           
protected  JButton search
           
protected  SearchAction searchAction
           
protected  ArrayList<DefaultMutableTreeNode> selectedNodes
           
protected  JButton subClass
           
protected  SubClassAction subClassAction
           
protected  JButton symmetricProperty
           
protected  SymmetricPropertyAction symmetricPropertyAction
           
protected  JTabbedPane tabbedPane
           
protected  JToolBar toolBar
          ToolBar
protected  JButton topClass
           
protected  TopClassAction topClassAction
           
protected  JButton transitiveProperty
           
protected  TransitivePropertyAction transitivePropertyAction
           
protected  gate.gui.ontology.OntologyEditor.DnDJTree tree
          The tree view.
protected  DefaultTreeModel treeModel
          The mode, for the tree.
protected  HashMap<String,ArrayList<DefaultMutableTreeNode>> uri2TreeNodesListMap
           
 
Fields inherited from class gate.creole.AbstractVisualResource
features, handle
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
OntologyEditor()
           
 
Method Summary
protected  void addChidrenRec(DefaultMutableTreeNode parent, List<OResource> children, Comparator<OResource> comparator)
          Adds the children nodes to a node using values from a list of classes and instances.
protected  void addPropertyChidrenRec(DefaultMutableTreeNode parent, List<RDFProperty> children, Comparator<OResource> comparator)
          Adds the children nodes to a node using values from a list of classes and instances.
 void addTreeNodeSelectionListener(TreeNodeSelectionListener listener)
           
protected  void classIsAdded(OClass aClass)
          Update the class tree model.
protected  void expandNode(JTree tree)
           
 Resource init()
          Init method, that creates this object and returns this object as a resource
protected  void initGUIComponents()
          Initialize the GUI Components
protected  void initListeners()
          Initializes various listeners
protected  void initLocalData()
          Initialize the local data
protected  void instanceIsAdded(OInstance anInstance)
          Update the class tree model.
 void ontologyModified(Ontology ontology, OResource resource, int eventType)
          This method is invoked from ontology whenever it is modified
 void ontologyReset(Ontology ontology)
          This method is called whenever ontology is reset.
 void processGateEvent(GateEvent e)
           
protected  void propertyIsAdded(RDFProperty p)
          Update the property tree model.
protected  void rebuildModel()
          Called when the target of this editor has changed
 void removeTreeNodeSelectionListener(TreeNodeSelectionListener listener)
           
 void resourceAdded(Ontology ontology, OResource resource)
          This method is invoked whenever a resource (class/property/instance) is added to the ontology.
 void resourcePropertyValueChanged(Ontology ontology, OResource resource, RDFProperty property, Object value, int eventType)
          This method should be invoked when a property value is added or removed (specified by the event type).
 void resourceRelationChanged(Ontology ontology, OResource resource1, OResource resouce2, int eventType)
          This method is invoked whenever a relation between two objects of the same class (e.g.
 void resourcesRemoved(Ontology ontology, String[] resources)
          This method is invoked whenever a resource (class/property/instance) is removed from the ontology.
 void selectResourceInClassTree(OResource resource)
           
 void setTarget(Object target)
          Called by the GUI when this viewer/editor has to initialise itself for a specific object.
protected  void subClassIsAdded(OClass c)
          Update the class tree model.
protected  void subClassIsDeleted(OClass c)
          Update the class tree model.
protected  void subPropertyIsAdded(RDFProperty p)
          Update the property tree model.
protected  void subPropertyIsDeleted(RDFProperty p)
          Update the property tree model.
 
Methods inherited from class gate.creole.AbstractVisualResource
cleanup, getFeatures, getInitParameterValues, getParameterValue, setFeatures, setHandle, setParameterValue, setParameterValues
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface gate.VisualResource
setHandle
 
Methods inherited from interface gate.Resource
cleanup, getParameterValue, setParameterValue, setParameterValues
 
Methods inherited from interface gate.util.FeatureBearer
getFeatures, setFeatures
 
Methods inherited from interface gate.util.NameBearer
getName, setName
 

Field Detail

ontology

protected Ontology ontology
the ontology instance


itemComparator

protected OntologyItemComparator itemComparator
Ontology Item Comparator


tree

protected gate.gui.ontology.OntologyEditor.DnDJTree tree
The tree view.


propertyTree

protected gate.gui.ontology.OntologyEditor.DnDJTree propertyTree
The property treeView


treeModel

protected DefaultTreeModel treeModel
The mode, for the tree.


propertyTreeModel

protected DefaultTreeModel propertyTreeModel
The property model, for the tree


detailsTable

protected JTable detailsTable
The list view used to display item details


propertyDetailsTable

protected JTable propertyDetailsTable

detailsTableModel

protected DetailsTableModel detailsTableModel

propertyDetailsTableModel

protected PropertyDetailsTableModel propertyDetailsTableModel

mainSplit

protected JSplitPane mainSplit
The main split


rootNode

protected DefaultMutableTreeNode rootNode
The root node of the tree.


propertyRootNode

protected DefaultMutableTreeNode propertyRootNode
The property root node of the tree


detailsTableScroller

protected JScrollPane detailsTableScroller

propertyDetailsTableScroller

protected JScrollPane propertyDetailsTableScroller

toolBar

protected JToolBar toolBar
ToolBar


queryBtn

protected JButton queryBtn

refreshOntologyBtn

protected JButton refreshOntologyBtn

topClass

protected JButton topClass

subClass

protected JButton subClass

restriction

protected JButton restriction

instance

protected JButton instance

annotationProperty

protected JButton annotationProperty

datatypeProperty

protected JButton datatypeProperty

objectProperty

protected JButton objectProperty

symmetricProperty

protected JButton symmetricProperty

transitiveProperty

protected JButton transitiveProperty

delete

protected JButton delete

search

protected JButton search

selectedNodes

protected ArrayList<DefaultMutableTreeNode> selectedNodes

ontologyClassesURIs

protected ArrayList<String> ontologyClassesURIs

searchAction

protected SearchAction searchAction

topClassAction

protected TopClassAction topClassAction

subClassAction

protected SubClassAction subClassAction

instanceAction

protected InstanceAction instanceAction

annotationPropertyAction

protected AnnotationPropertyAction annotationPropertyAction

datatypePropertyAction

protected DatatypePropertyAction datatypePropertyAction

objectPropertyAction

protected ObjectPropertyAction objectPropertyAction

symmetricPropertyAction

protected SymmetricPropertyAction symmetricPropertyAction

transitivePropertyAction

protected TransitivePropertyAction transitivePropertyAction

deleteOntoResourceAction

protected DeleteOntologyResourceAction deleteOntoResourceAction

restrictionAction

protected RestrictionAction restrictionAction

listeners

protected ArrayList<TreeNodeSelectionListener> listeners

uri2TreeNodesListMap

protected HashMap<String,ArrayList<DefaultMutableTreeNode>> uri2TreeNodesListMap

reverseMap

protected HashMap<DefaultMutableTreeNode,ONodeID> reverseMap

propertyScroller

protected JScrollPane propertyScroller

scroller

protected JScrollPane scroller

tabbedPane

protected JTabbedPane tabbedPane
Constructor Detail

OntologyEditor

public OntologyEditor()
Method Detail

setTarget

public void setTarget(Object target)
Description copied from class: AbstractVisualResource
Called by the GUI when this viewer/editor has to initialise itself for a specific object.

Specified by:
setTarget in interface VisualResource
Overrides:
setTarget in class AbstractVisualResource
Parameters:
target - the object (be it a Resource, DataStore or whatever) this viewer has to display

init

public Resource init()
              throws ResourceInstantiationException
Init method, that creates this object and returns this object as a resource

Specified by:
init in interface Resource
Overrides:
init in class AbstractVisualResource
Throws:
ResourceInstantiationException

initLocalData

protected void initLocalData()
Initialize the local data


initGUIComponents

protected void initGUIComponents()
Initialize the GUI Components


initListeners

protected void initListeners()
Initializes various listeners


expandNode

protected void expandNode(JTree tree)

rebuildModel

protected void rebuildModel()
Called when the target of this editor has changed


addChidrenRec

protected void addChidrenRec(DefaultMutableTreeNode parent,
                             List<OResource> children,
                             Comparator<OResource> comparator)
Adds the children nodes to a node using values from a list of classes and instances.

Parameters:
parent - the parent node.
children - the List of children objects.
comparator - the Comparator used to sort the children.

addPropertyChidrenRec

protected void addPropertyChidrenRec(DefaultMutableTreeNode parent,
                                     List<RDFProperty> children,
                                     Comparator<OResource> comparator)
Adds the children nodes to a node using values from a list of classes and instances.

Parameters:
parent - the parent node.
children - the lsit of children objects.
comparator - the Comparator used to sort the children.

processGateEvent

public void processGateEvent(GateEvent e)

classIsAdded

protected void classIsAdded(OClass aClass)
Update the class tree model. To call when a class is added.

Parameters:
aClass - class to add

propertyIsAdded

protected void propertyIsAdded(RDFProperty p)
Update the property tree model. To call when a property is added.

Parameters:
p - property to add

instanceIsAdded

protected void instanceIsAdded(OInstance anInstance)
Update the class tree model. To call when an instance is added.

Parameters:
anInstance - instance to add

subPropertyIsAdded

protected void subPropertyIsAdded(RDFProperty p)
Update the property tree model. To call when a subproperty is added.

Parameters:
p - subproperty to add

subPropertyIsDeleted

protected void subPropertyIsDeleted(RDFProperty p)
Update the property tree model. To call when a subproperty is deleted.

Parameters:
p - subproperty to delete

subClassIsAdded

protected void subClassIsAdded(OClass c)
Update the class tree model. To call when a subclass is added.

Parameters:
c - subclass to add

subClassIsDeleted

protected void subClassIsDeleted(OClass c)
Update the class tree model. To call when a subclass is deleted.

Parameters:
c - subclass to delete

resourcesRemoved

public void resourcesRemoved(Ontology ontology,
                             String[] resources)
Description copied from interface: OntologyModificationListener
This method is invoked whenever a resource (class/property/instance) is removed from the ontology.

Specified by:
resourcesRemoved in interface OntologyModificationListener
Parameters:
ontology - the source of the event
resources - an array of URIs of resources which were deleted (including the resource which was asked to be deleted).

resourceAdded

public void resourceAdded(Ontology ontology,
                          OResource resource)
Description copied from interface: OntologyModificationListener
This method is invoked whenever a resource (class/property/instance) is added to the ontology.

Specified by:
resourceAdded in interface OntologyModificationListener
Parameters:
ontology - the source of the event
resource - an instance of OResource, which was created as a result of addition of a resource.

resourceRelationChanged

public void resourceRelationChanged(Ontology ontology,
                                    OResource resource1,
                                    OResource resouce2,
                                    int eventType)
Description copied from interface: OntologyModificationListener
This method is invoked whenever a relation between two objects of the same class (e.g. OClass and OClass, RDFPRoeprty and RDFProeprty etc) is changed.

Specified by:
resourceRelationChanged in interface OntologyModificationListener
Parameters:
ontology - the source of the event
resource1 - the affected OResource
resouce2 - the affected OResource
eventType - the type of an event (@see OConstants) for more details

resourcePropertyValueChanged

public void resourcePropertyValueChanged(Ontology ontology,
                                         OResource resource,
                                         RDFProperty property,
                                         Object value,
                                         int eventType)
Description copied from interface: OntologyModificationListener
This method should be invoked when a property value is added or removed (specified by the event type).

Specified by:
resourcePropertyValueChanged in interface OntologyModificationListener
Parameters:
ontology - the source of the event
resource - the affected resource whose property value is added or removed
property - the property whose value has been added or removed
value - the actual value that is added or removed. If the value is null - it indicates all the values related to the property are deleted.
eventType - type of the event (@see OConstants) for more details

ontologyModified

public void ontologyModified(Ontology ontology,
                             OResource resource,
                             int eventType)
This method is invoked from ontology whenever it is modified


ontologyReset

public void ontologyReset(Ontology ontology)
This method is called whenever ontology is reset.

Specified by:
ontologyReset in interface OntologyModificationListener
Parameters:
ontology -

addTreeNodeSelectionListener

public void addTreeNodeSelectionListener(TreeNodeSelectionListener listener)

removeTreeNodeSelectionListener

public void removeTreeNodeSelectionListener(TreeNodeSelectionListener listener)

selectResourceInClassTree

public void selectResourceInClassTree(OResource resource)