annotate java/src/uk/ac/qmul/eecs/ccmi/diagrammodel/TreeModel.java @ 1:e3935c01cde2 tip

moved license of PdPersistenceManager to the beginning of the file
author Fiore Martin <f.martin@qmul.ac.uk>
date Tue, 08 Jul 2014 19:52:03 +0100
parents 78b7fc5391a2
children
rev   line source
f@0 1 /*
f@0 2 CCmI Editor - A Collaborative Cross-Modal Diagram Editing Tool
f@0 3
f@0 4 Copyright (C) 2011 Queen Mary University of London (http://ccmi.eecs.qmul.ac.uk/)
f@0 5
f@0 6 This program is free software: you can redistribute it and/or modify
f@0 7 it under the terms of the GNU General Public License as published by
f@0 8 the Free Software Foundation, either version 3 of the License, or
f@0 9 (at your option) any later version.
f@0 10
f@0 11 This program is distributed in the hope that it will be useful,
f@0 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
f@0 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
f@0 14 GNU General Public License for more details.
f@0 15
f@0 16 You should have received a copy of the GNU General Public License
f@0 17 along with this program. If not, see <http://www.gnu.org/licenses/>.
f@0 18 */
f@0 19 package uk.ac.qmul.eecs.ccmi.diagrammodel;
f@0 20
f@0 21 import java.util.Set;
f@0 22 import java.util.concurrent.locks.ReentrantLock;
f@0 23
f@0 24 /**
f@0 25 *
f@0 26 * Represents the tree side of a DiagramModel instance.
f@0 27 *
f@0 28 * @param <N> a type extending DiagramNode
f@0 29 * @param <E> a type extending DiagramEdge
f@0 30 */
f@0 31 public interface TreeModel<N extends DiagramNode, E extends DiagramEdge> extends javax.swing.tree.TreeModel {
f@0 32
f@0 33 /**
f@0 34 * insert a DiagramNode into the diagram model
f@0 35 *
f@0 36 * @param treeNode the DiagramNode to be inserted in the collection
f@0 37 * @param source the source of the action. This will be reported as the source of the event
f@0 38 * generated by this action to the registered listeners. If null the TreeModel instance
f@0 39 * itself will be used as source
f@0 40 * @return true if the model changed as a result of the call
f@0 41 */
f@0 42 boolean insertTreeNode(N treeNode, Object source);
f@0 43
f@0 44 /**
f@0 45 * insert a DiagramEdge into the diagram model
f@0 46 *
f@0 47 * @param treeNode the DiagramEdge to be inserted in the collection
f@0 48 * @param source the source of the action. This will be reported as the source of the event
f@0 49 * generated by this action to the registered listeners. If null the TreeModel instance
f@0 50 * itself will be used as source
f@0 51 * @return true if the model changed as a result of the call
f@0 52 */
f@0 53 boolean insertTreeNode(E treeNode, Object source);
f@0 54
f@0 55 /**
f@0 56 * remove a DiagramElement from the model
f@0 57 *
f@0 58 * @param treeNode the diagramElement to be removed
f@0 59 * @param source the source of the action. This will be reported as the source of the event
f@0 60 * generated by this action to the registered listeners. If null the TreeModel instance
f@0 61 * itself will be used as source
f@0 62 * @return true if the model changed as a result of the call
f@0 63 */
f@0 64 boolean takeTreeNodeOut(DiagramElement treeNode, Object source);
f@0 65
f@0 66 /**
f@0 67 *
f@0 68 * Add a bookmark for the specified tree node in the internal collection
f@0 69 *
f@0 70 * @param bookmark a bookmark
f@0 71 * @param treeNode the tree node to be bookmarked
f@0 72 * @param source the sorce of the action that triggered this method
f@0 73 * @return previous value associated with specified key, or null if there was no mapping for key.
f@0 74 * @throws IllegalArgumentException if bookmark is null
f@0 75 */
f@0 76 DiagramTreeNode putBookmark(String bookmark, DiagramTreeNode treeNode, Object source);
f@0 77
f@0 78 /**
f@0 79 * Returns a bookmarked tree node
f@0 80 * @param bookmark the bookmark associated with the tree node
f@0 81 * @return the bookmarked tree node or null if no tree node was bookmarked with the argument
f@0 82 */
f@0 83 DiagramTreeNode getBookmarkedTreeNode(String bookmark);
f@0 84
f@0 85 /**
f@0 86 * Returns the list of all the bookmarks of this tree model
f@0 87 * @return the list of all the bookmarks
f@0 88 */
f@0 89 Set<String> getBookmarks();
f@0 90
f@0 91 /**
f@0 92 * Remove the bookmark from the bookmark internal collection
f@0 93 *
f@0 94 * @param bookmark the bookmark to remove
f@0 95 * @param source the source of the action that triggered this method
f@0 96 * @return previous value associated with specified key, or null if there was no mapping for key.
f@0 97 */
f@0 98 DiagramTreeNode removeBookmark(String bookmark, Object source);
f@0 99
f@0 100 /**
f@0 101 * Set the notes for the specified tree node. Passing an empty string as notes
f@0 102 * means actually to remove the notes from the tree node.
f@0 103 *
f@0 104 * @param treeNode the tree node to be noted
f@0 105 * @param notes the notes to be assigned to the tree node
f@0 106 * @param source the source of the action. This will be reported as the source of the event
f@0 107 * generated by this action to the registered listeners
f@0 108 */
f@0 109 void setNotes(DiagramTreeNode treeNode, String notes, Object source);
f@0 110
f@0 111 /**
f@0 112 * Add a {@code DiagramNodeListener} to this object. The listeners will be fired each time the model
f@0 113 * goes from the unmodified to modified state. The model is modified when a either a
f@0 114 * node or an edge are inserted or removed or changed when they are within the model.
f@0 115 * @param l a {@code DiagramNodeListener} to add to the model
f@0 116 */
f@0 117 void addDiagramTreeNodeListener(DiagramTreeNodeListener l);
f@0 118
f@0 119 /**
f@0 120 * Removes a {@code DiagramNodeListener} from this object.
f@0 121 * @param l a {@code DiagramNodeListener} to remove from ththis object.
f@0 122 */
f@0 123 void removeDiagramTreeNodeListener(DiagramTreeNodeListener l);
f@0 124
f@0 125 /**
f@0 126 * Returns true if the model has been modified
f@0 127 * @return true if the model has been modified
f@0 128 */
f@0 129 boolean isModified();
f@0 130
f@0 131 /**
f@0 132 * Sets the model as unmodified. This entails that {@link #isModified()} will return
f@0 133 * false unless the model doesn't get modified again. After this call a new modification
f@0 134 * of the model would trigger the associated change listeners again.
f@0 135 */
f@0 136 public void setUnmodified();
f@0 137
f@0 138 /**
f@0 139 * Returns a reentrant lock that can be used to access the nodes and edges in a synchronized fashion.
f@0 140 * @return a lock object
f@0 141 */
f@0 142 public ReentrantLock getMonitor();
f@0 143 }