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