fiore@0: /*
fiore@0: CCmI Editor - A Collaborative Cross-Modal Diagram Editing Tool
fiore@0:
fiore@0: Copyright (C) 2011 Queen Mary University of London (http://ccmi.eecs.qmul.ac.uk/)
fiore@0:
fiore@0: This program is free software: you can redistribute it and/or modify
fiore@0: it under the terms of the GNU General Public License as published by
fiore@0: the Free Software Foundation, either version 3 of the License, or
fiore@0: (at your option) any later version.
fiore@0:
fiore@0: This program is distributed in the hope that it will be useful,
fiore@0: but WITHOUT ANY WARRANTY; without even the implied warranty of
fiore@0: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
fiore@0: GNU General Public License for more details.
fiore@0:
fiore@0: You should have received a copy of the GNU General Public License
fiore@0: along with this program. If not, see .
fiore@0: */
fiore@0: package uk.ac.qmul.eecs.ccmi.diagrammodel;
fiore@0:
fiore@0: import java.util.Set;
fiore@3: import java.util.concurrent.locks.ReentrantLock;
fiore@0:
fiore@0: /**
fiore@0: *
fiore@0: * Represents the tree side of a DiagramModel instance.
fiore@0: *
fiore@0: * @param a type extending DiagramNode
fiore@0: * @param a type extending DiagramEdge
fiore@0: */
fiore@0: public interface TreeModel extends javax.swing.tree.TreeModel {
fiore@0:
fiore@0: /**
fiore@0: * insert a DiagramNode into the diagram model
fiore@0: *
fiore@0: * @param treeNode the DiagramNode to be inserted in the collection
fiore@3: * @param source the source of the action. This will be reported as the source of the event
fiore@3: * generated by this action to the registered listeners. If null the TreeModel instance
fiore@3: * itself will be used as source
fiore@0: * @return true if the model changed as a result of the call
fiore@0: */
fiore@3: boolean insertTreeNode(N treeNode, Object source);
fiore@0:
fiore@0: /**
fiore@0: * insert a DiagramEdge into the diagram model
fiore@0: *
fiore@0: * @param treeNode the DiagramEdge to be inserted in the collection
fiore@3: * @param source the source of the action. This will be reported as the source of the event
fiore@3: * generated by this action to the registered listeners. If null the TreeModel instance
fiore@3: * itself will be used as source
fiore@0: * @return true if the model changed as a result of the call
fiore@0: */
fiore@3: boolean insertTreeNode(E treeNode, Object source);
fiore@0:
fiore@0: /**
fiore@0: * remove a DiagramElement from the model
fiore@0: *
fiore@0: * @param treeNode the diagramElement to be removed
fiore@3: * @param source the source of the action. This will be reported as the source of the event
fiore@3: * generated by this action to the registered listeners. If null the TreeModel instance
fiore@3: * itself will be used as source
fiore@0: * @return true if the model changed as a result of the call
fiore@0: */
fiore@3: boolean takeTreeNodeOut(DiagramElement treeNode, Object source);
fiore@0:
fiore@0: /**
fiore@0: *
fiore@0: * Add a bookmark for the specified tree node in the internal collection
fiore@0: *
fiore@0: * @param bookmark a bookmark
fiore@0: * @param treeNode the tree node to be bookmarked
fiore@5: * @param source the sorce of the action that triggered this method
fiore@0: * @return previous value associated with specified key, or null if there was no mapping for key.
fiore@0: * @throws IllegalArgumentException if bookmark is null
fiore@0: */
fiore@3: DiagramTreeNode putBookmark(String bookmark, DiagramTreeNode treeNode, Object source);
fiore@0:
fiore@0: /**
fiore@0: * Returns a bookmarked tree node
fiore@0: * @param bookmark the bookmark associated with the tree node
fiore@0: * @return the bookmarked tree node or null if no tree node was bookmarked with the argument
fiore@0: */
fiore@3: DiagramTreeNode getBookmarkedTreeNode(String bookmark);
fiore@0:
fiore@0: /**
fiore@0: * Returns the list of all the bookmarks of this tree model
fiore@0: * @return the list of all the bookmarks
fiore@0: */
fiore@0: Set getBookmarks();
fiore@0:
fiore@0: /**
fiore@0: * Remove the bookmark from the bookmark internal collection
fiore@0: *
fiore@0: * @param bookmark the bookmark to remove
fiore@5: * @param source the source of the action that triggered this method
fiore@0: * @return previous value associated with specified key, or null if there was no mapping for key.
fiore@0: */
fiore@3: DiagramTreeNode removeBookmark(String bookmark, Object source);
fiore@0:
fiore@0: /**
fiore@0: * Set the notes for the specified tree node. Passing an empty string as notes
fiore@0: * means actually to remove the notes from the tree node.
fiore@0: *
fiore@0: * @param treeNode the tree node to be noted
fiore@0: * @param notes the notes to be assigned to the tree node
fiore@3: * @param source the source of the action. This will be reported as the source of the event
fiore@3: * generated by this action to the registered listeners
fiore@0: */
fiore@3: void setNotes(DiagramTreeNode treeNode, String notes, Object source);
fiore@0:
fiore@0: /**
fiore@3: * Add a {@code DiagramNodeListener} to this object. The listeners will be fired each time the model
fiore@0: * goes from the unmodified to modified state. The model is modified when a either a
fiore@0: * node or an edge are inserted or removed or changed when they are within the model.
fiore@3: * @param l a {@code DiagramNodeListener} to add to the model
fiore@0: */
fiore@3: void addDiagramTreeNodeListener(DiagramTreeNodeListener l);
fiore@0:
fiore@0: /**
fiore@3: * Removes a {@code DiagramNodeListener} from this object.
fiore@3: * @param l a {@code DiagramNodeListener} to remove from ththis object.
fiore@0: */
fiore@3: void removeDiagramTreeNodeListener(DiagramTreeNodeListener l);
fiore@0:
fiore@0: /**
fiore@0: * Returns true if the model has been modified
fiore@0: * @return true if the model has been modified
fiore@0: */
fiore@0: boolean isModified();
fiore@0:
fiore@0: /**
fiore@0: * Sets the model as unmodified. This entails that {@link #isModified()} will return
fiore@0: * false unless the model doesn't get modified again. After this call a new modification
fiore@0: * of the model would trigger the associated change listeners again.
fiore@0: */
fiore@0: public void setUnmodified();
fiore@0:
fiore@0: /**
fiore@3: * Returns a reentrant lock that can be used to access the nodes and edges in a synchronized fashion.
fiore@3: * @return a lock object
fiore@0: */
fiore@3: public ReentrantLock getMonitor();
fiore@0: }