org.ceryle.graph.tm
Class TMPanelEditor

java.lang.Object
  extended by org.ceryle.graph.tm.TMPanelEditor

public class TMPanelEditor
extends Object

A utility class that provides editing functions on a given TMPanel and its underlying TopicMap document object.

Since:
JDK1.3
Version:
$Id: TMPanelEditor.java,v 3.3 2007-06-20 01:28:12 altheim Exp $
Author:
Murray Altheim

Field Summary
static int ADD_OCCUR
          Indicates a new occurrence directive.
static int DEL_ASSOC
          Indicates a delete association directive.
static int DEL_SCOPE
          Indicates a delete scope directive.
static int DEL_SEL
          Indicates a delete selected directive.
static int DEL_TOPIC
          Indicates a delete topic directive.
static int MOD_ASSOC
          Indicates a modify association directive.
static int MOD_OCCUR
          Indicates a modify occurrence directive.
static int MOD_SCOPE
          Indicates a modify scope directive.
static int MOD_TOPIC
          Indicates a modify topic directive.
static int NEW_ASSOC
          Indicates a new association directive.
static int NEW_OCCUR
          Indicates a new occurrence directive.
static int NEW_SCOPE
          Indicates a new scope directive.
static int NEW_TOPIC
          Indicates a new topic directive.
static int REM_OCCUR
          Indicates a remove occurrence directive.
static int SUB_TOPIC
          Indicates a subtopic directive.
static boolean SWITCH_TEMPLATE_DIRECTION
          For reasons that remain shrouded in mystical obscurity, the direction of terms appearing in Association templates will appear reverse to the 'normal' direction when editing Associations.
protected  TopicMapProcessor tmproc
          A reference to the TopicMapProcessor used to create the displayed Topic, necessary to perform any post-creation modifications.
 
Constructor Summary
TMPanelEditor()
          Default constructor.
TMPanelEditor(Desktop desktop, TMLayoutPanel tmpanel)
          Constructor with Desktop and the TMLayoutPanel to edit.
 
Method Summary
 void action(TMLayoutPanel tmpanel, int directive, Object o)
          Receives a directive to manifest some editing change to the graph, based on a bitwise int directive.
 Occurrence addOccurrence()
          Adds an existing resource as an Occurrence to the currently-selected Topic, querying the user for the URI.
 Occurrence addOccurrence(Topic topic)
          Adds an existing resource as an Occurrence to the provided Topic, querying the user for the URI.
 Occurrence addOccurrence(Topic topic, Locator loc)
          The worker method that actually adds the Occurrence to the Topic, using the supplied Locator to create the new Occurrence.
 Occurrence addOccurrence(Topic topic, String uriref)
          Adds an existing resource as an Occurrence to the currently-selected Topic, using the provided String as a URI.
 void changeAssociation(ANode anode)
          Alters the association type and roles on the provided binary association.
 Association createAssociationToTopic(TNode tnode, Point2D.Double p, boolean useLast)
          Associates a new Topic at Point p to the Topic tnode, using the last Association template if useLast is true and within this session a previous Association has been created.
 boolean deleteANode(ANode anode, boolean confirm)
          Deletes the ANode anode from the graph, as well as its corresponding Association from the underlying Topic Map.
 boolean deleteAssertion(boolean confirm)
          Delete the currently-selected assertion from the graph.
 boolean deleteAssociation(Association assoc, boolean confirm)
          Delete the Association assoc from the graph.
 boolean deleteAssociation(boolean confirm)
          Delete the currently-selected association(s) from the graph.
 boolean deleteNode(GraphNode node, boolean confirm)
          Deletes the GraphNode node; what happens depends on its type.
 boolean deleteSelected(boolean confirm)
          Deletes the selected nodes, depending on the number of type.
 boolean deleteSNode(SNode snode, boolean confirm)
          Deletes the SNode snode from the graph, as well as from the underlying Topic Map.
 boolean deleteTNode(TNode tnode, boolean confirm)
          Deletes the TNode tnode from the graph, as well as from the underlying Topic Map.
 boolean deleteTopic(boolean confirm)
          Delete the selected topic(s) and its membership in any associations.
 boolean deleteTopic(Topic topic, boolean confirm)
          Delete the Topic topic and its membership in any associations.
 void editAssertion()
           
 void editAssociation()
           
 void editOccurrence()
           
 void editTopic()
           
protected  Document getBlankDocument()
          Turns the String content into an XML Document, either as valid or well-formed XML, or as a CDATA section.
 Association getLastTemplate()
          If within this session an Association has been created, it is returned, otherwise null.
 void newAssertion()
           
 void newAssociation()
          Create a new binary association from the two currently-selected topics.
 void newAssociation(Topic subject, Topic object)
          Create a new binary association from the two currently-selected topics.
 ANode newAssociation(Topic subject, Topic object, Association predicate)
          Create a new binary association from the two currently-selected topics.
 Occurrence newOccurrence()
          Creates a new resource as an Occurrence of the currently-selected Topic.
 Occurrence newOccurrence(Topic topic)
          Creates a new resource as an Occurrence of the currently-selected Topic.
 Occurrence newOccurrence(Topic topic, String cid, String nid, String title)
          Connects a resource as an Occurrence of the provided Topic, using the optional Collection and Node IDs and title as defaults to the dialog box.
 void newSubtopic()
           
 TNode newTopic(Point2D.Double p)
          Creates a new Topic, returning the created TNode.
 TNode newTopic(Point2D.Double p, String label)
          Creates a new Topic, returning the created TNode.
 void removeOccurrence()
           
 boolean removeOccurrence(Topic topic, Occurrence occur)
          Removes the Occurrence from the Topic, returning true if successful.
 void setTMLayoutPanel(TMLayoutPanel tmpanel)
          Set the TMLayoutPanel (and by extension, its TMPanel) to be edited by this TMPanelEditor.
 void swapRoles(ANode anode)
          Swap the roles of the provided ANode's underlying Association, updating the displayed graph accordingly.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SWITCH_TEMPLATE_DIRECTION

public static boolean SWITCH_TEMPLATE_DIRECTION
For reasons that remain shrouded in mystical obscurity, the direction of terms appearing in Association templates will appear reverse to the 'normal' direction when editing Associations.

When the value of this boolean is true the template iterator will reverse the order so that edited Associations will maintain the order of the original Association. When false, they will be switched to their opposite direction, which might be considered rude by those without a sense of appropriate irony.

Actually, this has to do with the order of the terms in the LTM definitions for the templates (which one is labeled 'From' and which 'To'), which is dependent upon the way a relation is expressed (e.g., isParentOf vs. isChildOf), so it's rather arbitrary. In the LTM files delivered with Ceryle this should be set to true for the least gratuitous violence, though there will still be some vulgarity now and then.


NEW_TOPIC

public static final int NEW_TOPIC
Indicates a new topic directive.

See Also:
Constant Field Values

SUB_TOPIC

public static final int SUB_TOPIC
Indicates a subtopic directive.

See Also:
Constant Field Values

MOD_TOPIC

public static final int MOD_TOPIC
Indicates a modify topic directive.

See Also:
Constant Field Values

DEL_TOPIC

public static final int DEL_TOPIC
Indicates a delete topic directive.

See Also:
Constant Field Values

NEW_ASSOC

public static final int NEW_ASSOC
Indicates a new association directive.

See Also:
Constant Field Values

MOD_ASSOC

public static final int MOD_ASSOC
Indicates a modify association directive.

See Also:
Constant Field Values

DEL_ASSOC

public static final int DEL_ASSOC
Indicates a delete association directive.

See Also:
Constant Field Values

NEW_SCOPE

public static final int NEW_SCOPE
Indicates a new scope directive.

See Also:
Constant Field Values

MOD_SCOPE

public static final int MOD_SCOPE
Indicates a modify scope directive.

See Also:
Constant Field Values

DEL_SCOPE

public static final int DEL_SCOPE
Indicates a delete scope directive.

See Also:
Constant Field Values

NEW_OCCUR

public static final int NEW_OCCUR
Indicates a new occurrence directive.

See Also:
Constant Field Values

ADD_OCCUR

public static final int ADD_OCCUR
Indicates a new occurrence directive.

See Also:
Constant Field Values

MOD_OCCUR

public static final int MOD_OCCUR
Indicates a modify occurrence directive.

See Also:
Constant Field Values

REM_OCCUR

public static final int REM_OCCUR
Indicates a remove occurrence directive.

See Also:
Constant Field Values

DEL_SEL

public static final int DEL_SEL
Indicates a delete selected directive.

See Also:
Constant Field Values

tmproc

protected TopicMapProcessor tmproc
A reference to the TopicMapProcessor used to create the displayed Topic, necessary to perform any post-creation modifications.

Constructor Detail

TMPanelEditor

public TMPanelEditor()
              throws TopicMapException
Default constructor.

Throws:
TopicMapException

TMPanelEditor

public TMPanelEditor(Desktop desktop,
                     TMLayoutPanel tmpanel)
              throws TopicMapException
Constructor with Desktop and the TMLayoutPanel to edit.

Throws:
TopicMapException
Method Detail

setTMLayoutPanel

public void setTMLayoutPanel(TMLayoutPanel tmpanel)
Set the TMLayoutPanel (and by extension, its TMPanel) to be edited by this TMPanelEditor.


action

public void action(TMLayoutPanel tmpanel,
                   int directive,
                   Object o)
Receives a directive to manifest some editing change to the graph, based on a bitwise int directive. The optional Object o is included on some directives as the parameter to be operated upon.

This generally comes from either the TMPopupMenu or the TMPanelEditorDialog.

See Also:
TopicEditorDialog, AssociationEditorDialog

deleteSelected

public boolean deleteSelected(boolean confirm)
Deletes the selected nodes, depending on the number of type.

Returns:
true if the deletion occurred

deleteNode

public boolean deleteNode(GraphNode node,
                          boolean confirm)
Deletes the GraphNode node; what happens depends on its type.

Returns:
true if the node was deleted

newTopic

public TNode newTopic(Point2D.Double p)
Creates a new Topic, returning the created TNode.


newTopic

public TNode newTopic(Point2D.Double p,
                      String label)
Creates a new Topic, returning the created TNode.


newSubtopic

public void newSubtopic()

editTopic

public void editTopic()

deleteTopic

public boolean deleteTopic(boolean confirm)
Delete the selected topic(s) and its membership in any associations.

If the boolean confirm is true, a confirm dialog is displayed.


deleteTopic

public boolean deleteTopic(Topic topic,
                           boolean confirm)
Delete the Topic topic and its membership in any associations.

If the boolean confirm is true, a confirm dialog is displayed.


deleteTNode

public boolean deleteTNode(TNode tnode,
                           boolean confirm)
Deletes the TNode tnode from the graph, as well as from the underlying Topic Map.

Returns:
true if the node was deleted

newAssociation

public void newAssociation()
Create a new binary association from the two currently-selected topics. The first selected Topic is considered as the 'subject' of a sentence, the second as the 'object', e.g., "'Wanda' 'is a' 'Fish'", where 'Wanda' is the subject, 'Fish' is the object. For class-instance and superclass-subclass associations, this is the reverse order from the association type's title. If the selection is not currently two topics, an error message is displayed.


getLastTemplate

public Association getLastTemplate()
If within this session an Association has been created, it is returned, otherwise null.


createAssociationToTopic

public Association createAssociationToTopic(TNode tnode,
                                            Point2D.Double p,
                                            boolean useLast)
Associates a new Topic at Point p to the Topic tnode, using the last Association template if useLast is true and within this session a previous Association has been created.


newAssociation

public void newAssociation(Topic subject,
                           Topic object)
Create a new binary association from the two currently-selected topics. (This method should only be called when there is a selection of two.) The first selected Topic is given priority as the 'subject' of a sentence, the second as the 'object'.


newAssociation

public ANode newAssociation(Topic subject,
                            Topic object,
                            Association predicate)
Create a new binary association from the two currently-selected topics. (This method should only be called when there is a selection of two.) The first selected Topic is given priority as the 'subject' of a sentence, the second as the 'object', the Association as the 'predicate.' If there is no provided predicate, the user is queried for it from the available list of association templates.


editAssociation

public void editAssociation()

changeAssociation

public void changeAssociation(ANode anode)
Alters the association type and roles on the provided binary association.


deleteAssociation

public boolean deleteAssociation(boolean confirm)
Delete the currently-selected association(s) from the graph.

If the boolean confirm is true, a confirm dialog is displayed.

Returns:
true if the Association(s) was/were deleted

deleteAssociation

public boolean deleteAssociation(Association assoc,
                                 boolean confirm)
Delete the Association assoc from the graph.

If the boolean confirm is true, a confirm dialog is displayed.


deleteANode

public boolean deleteANode(ANode anode,
                           boolean confirm)
Deletes the ANode anode from the graph, as well as its corresponding Association from the underlying Topic Map.

Returns:
true if the Association was deleted

swapRoles

public void swapRoles(ANode anode)
Swap the roles of the provided ANode's underlying Association, updating the displayed graph accordingly.


newAssertion

public void newAssertion()

editAssertion

public void editAssertion()

deleteAssertion

public boolean deleteAssertion(boolean confirm)
Delete the currently-selected assertion from the graph.

If the boolean confirm is true, a confirm dialog is displayed.


deleteSNode

public boolean deleteSNode(SNode snode,
                           boolean confirm)
Deletes the SNode snode from the graph, as well as from the underlying Topic Map.

Returns:
true if the node was deleted

newOccurrence

public Occurrence newOccurrence()
Creates a new resource as an Occurrence of the currently-selected Topic.

Returns:
the Occurrence, null if unsuccessful

newOccurrence

public Occurrence newOccurrence(Topic topic)
Creates a new resource as an Occurrence of the currently-selected Topic.

Returns:
the Occurrence, null if unsuccessful

newOccurrence

public Occurrence newOccurrence(Topic topic,
                                String cid,
                                String nid,
                                String title)
Connects a resource as an Occurrence of the provided Topic, using the optional Collection and Node IDs and title as defaults to the dialog box. If the specific Collection and Node ID does not already exist, this creates it.

Parameters:
topic - the Topic to which to add the Occurrence
cid - the collection ID of the new Occurrence
nid - the node ID of the new Occurrence
title - the title of the new Occurrence
Returns:
the Occurrence, null if unsuccessful

getBlankDocument

protected Document getBlankDocument()
Turns the String content into an XML Document, either as valid or well-formed XML, or as a CDATA section. If unable, returns null.


addOccurrence

public Occurrence addOccurrence()
Adds an existing resource as an Occurrence to the currently-selected Topic, querying the user for the URI.

Returns:
the Occurrence, null if unsuccessful

addOccurrence

public Occurrence addOccurrence(Topic topic)
Adds an existing resource as an Occurrence to the provided Topic, querying the user for the URI.

Returns:
the Occurrence, null if unsuccessful

addOccurrence

public Occurrence addOccurrence(Topic topic,
                                String uriref)
Adds an existing resource as an Occurrence to the currently-selected Topic, using the provided String as a URI.

Returns:
the Occurrence, null if unsuccessful

addOccurrence

public Occurrence addOccurrence(Topic topic,
                                Locator loc)
                         throws TopicMapException
The worker method that actually adds the Occurrence to the Topic, using the supplied Locator to create the new Occurrence. This first checks to see if the Occurrence isn't already included.

Returns:
the added Occurrence, or null if it was not added.
Throws:
TopicMapException

editOccurrence

public void editOccurrence()

removeOccurrence

public void removeOccurrence()

removeOccurrence

public boolean removeOccurrence(Topic topic,
                                Occurrence occur)
Removes the Occurrence from the Topic, returning true if successful.



The Ceryle Project. Copyright ©2001-2007 Murray Altheim, All Rights Reserved. See LICENSE included with distribution.