| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| ArgoDiagram |
|
| 1.0;1 |
| 1 | /* $Id: ArgoDiagram.java 17850 2010-01-12 19:53:35Z linus $ | |
| 2 | ***************************************************************************** | |
| 3 | * Copyright (c) 2009 Contributors - see below | |
| 4 | * All rights reserved. This program and the accompanying materials | |
| 5 | * are made available under the terms of the Eclipse Public License v1.0 | |
| 6 | * which accompanies this distribution, and is available at | |
| 7 | * http://www.eclipse.org/legal/epl-v10.html | |
| 8 | * | |
| 9 | * Contributors: | |
| 10 | * bobtarling | |
| 11 | ***************************************************************************** | |
| 12 | * | |
| 13 | * Some portions of this file was previously release using the BSD License: | |
| 14 | */ | |
| 15 | ||
| 16 | // Copyright (c) 2007-2008 The Regents of the University of California. All | |
| 17 | // Rights Reserved. Permission to use, copy, modify, and distribute this | |
| 18 | // software and its documentation without fee, and without a written | |
| 19 | // agreement is hereby granted, provided that the above copyright notice | |
| 20 | // and this paragraph appear in all copies. This software program and | |
| 21 | // documentation are copyrighted by The Regents of the University of | |
| 22 | // California. The software program and documentation are supplied "AS | |
| 23 | // IS", without any accompanying services from The Regents. The Regents | |
| 24 | // does not warrant that the operation of the program will be | |
| 25 | // uninterrupted or error-free. The end-user understands that the program | |
| 26 | // was developed for research purposes and is advised not to rely | |
| 27 | // exclusively on the program for any reason. IN NO EVENT SHALL THE | |
| 28 | // UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, | |
| 29 | // SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, | |
| 30 | // ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF | |
| 31 | // THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF | |
| 32 | // SUCH DAMAGE. THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY | |
| 33 | // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | |
| 34 | // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE | |
| 35 | // PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF | |
| 36 | // CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT, | |
| 37 | // UPDATES, ENHANCEMENTS, OR MODIFICATIONS. | |
| 38 | ||
| 39 | package org.argouml.uml.diagram; | |
| 40 | ||
| 41 | import java.awt.Rectangle; | |
| 42 | import java.beans.PropertyChangeEvent; | |
| 43 | import java.beans.PropertyChangeListener; | |
| 44 | import java.beans.PropertyVetoException; | |
| 45 | import java.beans.VetoableChangeListener; | |
| 46 | import java.util.Iterator; | |
| 47 | import java.util.List; | |
| 48 | ||
| 49 | import org.argouml.application.events.ArgoDiagramAppearanceEventListener; | |
| 50 | import org.argouml.application.events.ArgoNotationEventListener; | |
| 51 | import org.argouml.kernel.Project; | |
| 52 | import org.argouml.util.ItemUID; | |
| 53 | import org.tigris.gef.base.LayerPerspective; | |
| 54 | import org.tigris.gef.graph.GraphModel; | |
| 55 | import org.tigris.gef.presentation.Fig; | |
| 56 | import org.tigris.gef.presentation.FigNode; | |
| 57 | ||
| 58 | /** | |
| 59 | * An interface to decouple ArgoUML from GEF and to untangle the Project <-> | |
| 60 | * ArgoDiagram ball of string. | |
| 61 | * <p> | |
| 62 | * Although this interface is implemented by {@link ArgoDiagramImpl}, it does | |
| 63 | * <em>NOT</em> extend any GEF interfaces (since GEF is made up entirely of | |
| 64 | * concrete classes), so any new methods which are added to | |
| 65 | * {@link org.tigris.gef.base.Diagram} and which are needed by ArgoUML will need | |
| 66 | * to be added to this interface manually. | |
| 67 | * | |
| 68 | * @author Tom Morris <tfmorris@gmail.com> | |
| 69 | * @since 0.25.4 when it replaced the implementation class of the same name | |
| 70 | */ | |
| 71 | public interface ArgoDiagram extends ArgoNotationEventListener, | |
| 72 | ArgoDiagramAppearanceEventListener { | |
| 73 | ||
| 74 | /** | |
| 75 | * Set the rendering settings for this diagram. | |
| 76 | * | |
| 77 | * @param settings the new diagram settings | |
| 78 | */ | |
| 79 | public void setDiagramSettings(DiagramSettings settings); | |
| 80 | ||
| 81 | /** | |
| 82 | * @return the current DiagramSettings object | |
| 83 | */ | |
| 84 | public DiagramSettings getDiagramSettings(); | |
| 85 | ||
| 86 | /* | |
| 87 | * @see org.tigris.gef.base.Diagram#setName(java.lang.String) | |
| 88 | */ | |
| 89 | public void setName(String n) throws PropertyVetoException; | |
| 90 | ||
| 91 | /** | |
| 92 | * @param i the new id | |
| 93 | */ | |
| 94 | public void setItemUID(ItemUID i); | |
| 95 | ||
| 96 | /** | |
| 97 | * USED BY pgml.tee!! | |
| 98 | * @return the item UID | |
| 99 | */ | |
| 100 | public ItemUID getItemUID(); | |
| 101 | ||
| 102 | /** | |
| 103 | * The bean property name denoting the diagram's namespace. Value is a | |
| 104 | * String. | |
| 105 | */ | |
| 106 | public static final String NAMESPACE_KEY = "namespace"; | |
| 107 | ||
| 108 | /** | |
| 109 | * The bean property name denoting the diagram's name. Value is a | |
| 110 | * String. | |
| 111 | */ | |
| 112 | public static final String NAME_KEY = "name"; | |
| 113 | ||
| 114 | /** | |
| 115 | * TODO: The reference to the method | |
| 116 | * org.argouml.uml.ui.VetoablePropertyChange#getVetoMessage(String) | |
| 117 | * was here but the class does exist anymore. Where is it? | |
| 118 | * This method is never used! | |
| 119 | * | |
| 120 | * @param propertyName is the name of the property | |
| 121 | * @return a message or null if not applicable. | |
| 122 | */ | |
| 123 | public String getVetoMessage(String propertyName); | |
| 124 | ||
| 125 | /** | |
| 126 | * Finds the presentation (the Fig) for some object. If the object | |
| 127 | * is a modelelement that is contained in some other modelelement | |
| 128 | * that has its own fig, that fig is returned. It extends | |
| 129 | * presentationFor that only gets the fig belonging to the node | |
| 130 | * obj.<p> | |
| 131 | * | |
| 132 | * @author jaap.branderhorst@xs4all.nl | |
| 133 | * @return the Fig for the object | |
| 134 | * @param obj is th object | |
| 135 | */ | |
| 136 | public Fig getContainingFig(Object obj); | |
| 137 | ||
| 138 | /** | |
| 139 | * This will mark the entire visible area of all Editors to be repaired | |
| 140 | * from any damage - i.e. repainted. | |
| 141 | */ | |
| 142 | public void damage(); | |
| 143 | ||
| 144 | /** | |
| 145 | * Get all the model elements in this diagram that are represented | |
| 146 | * by a FigEdge. | |
| 147 | * @see org.tigris.gef.base.Diagram#getEdges() | |
| 148 | */ | |
| 149 | public List getEdges(); | |
| 150 | ||
| 151 | /** | |
| 152 | * Get all the model elements in this diagram that are represented | |
| 153 | * by a FigNode. | |
| 154 | * @see org.tigris.gef.base.Diagram#getNodes() | |
| 155 | */ | |
| 156 | public List getNodes(); | |
| 157 | ||
| 158 | ||
| 159 | /** | |
| 160 | * We hang our heads in shame. There are still bugs in ArgoUML | |
| 161 | * and/or GEF that cause corruptions in the model. | |
| 162 | * Before a save takes place we repair the model in order to | |
| 163 | * be as certain as possible that the saved file will reload. | |
| 164 | * TODO: Split into small inner classes for each fix. | |
| 165 | * | |
| 166 | * @return A text that explains what is repaired. | |
| 167 | */ | |
| 168 | public String repair(); | |
| 169 | ||
| 170 | /** | |
| 171 | * Find all the Figs that visualise the given model element in | |
| 172 | * this layer, or null if there is none. | |
| 173 | * | |
| 174 | * TODO: once GEF includes this same method in Diagram then this can go | |
| 175 | * | |
| 176 | * @see org.tigris.gef.base.Diagram#presentationsFor(java.lang.Object) | |
| 177 | */ | |
| 178 | public List presentationsFor(Object obj); | |
| 179 | ||
| 180 | /** | |
| 181 | * Remove this diagram from existence. | |
| 182 | * | |
| 183 | * TODO: Move to GEF | |
| 184 | */ | |
| 185 | public void remove(); | |
| 186 | ||
| 187 | /** | |
| 188 | * Keeps track of the project that contains this diagram. | |
| 189 | * The Project determines many settings that reflect | |
| 190 | * the way the diagram is painted, such as font size. | |
| 191 | * | |
| 192 | * @param p the project that contains this diagram | |
| 193 | */ | |
| 194 | public void setProject(Project p); | |
| 195 | ||
| 196 | /** | |
| 197 | * @return the Project which owns this diagram | |
| 198 | */ | |
| 199 | public Project getProject(); | |
| 200 | ||
| 201 | /** | |
| 202 | * Called when the user releases a dragged FigNode. | |
| 203 | * | |
| 204 | * @param enclosed the enclosed FigNode that was dragged into the encloser | |
| 205 | * @param oldEncloser the previous encloser | |
| 206 | * @param newEncloser the FigNode that encloses the dragged FigNode | |
| 207 | */ | |
| 208 | public void encloserChanged(FigNode enclosed, FigNode oldEncloser, | |
| 209 | FigNode newEncloser); | |
| 210 | ||
| 211 | /** | |
| 212 | * This method shall return any UML modelelements | |
| 213 | * that should be deleted when the diagram gets deleted, | |
| 214 | * or null if there are none. The default implementation returns null; | |
| 215 | * e.g. a statechart diagram should return its statemachine. | |
| 216 | * | |
| 217 | * @author mvw@tigris.org | |
| 218 | * | |
| 219 | * @return the dependent element - in the general case there aren't, so null | |
| 220 | */ | |
| 221 | public Object getDependentElement(); | |
| 222 | ||
| 223 | /** | |
| 224 | * TODO: MVW: I am not completely sure of the following:<p> | |
| 225 | * The "namespace" of the diagram is e.g. used when creating new elements | |
| 226 | * that are shown on the diagram; they will have their namespace set | |
| 227 | * according this. It is NOT necessarily equal to the "owner". | |
| 228 | * | |
| 229 | * @return the namespace for the diagram | |
| 230 | */ | |
| 231 | public Object getNamespace(); | |
| 232 | ||
| 233 | /** | |
| 234 | * Sets the namespace of the Diagram, and | |
| 235 | * adds the diagram as a listener of its namespace in the UML model | |
| 236 | * (so that it can delete itself when the model element is deleted). | |
| 237 | * | |
| 238 | * @param ns the namespace for the diagram | |
| 239 | */ | |
| 240 | public void setNamespace(Object ns); | |
| 241 | ||
| 242 | /** | |
| 243 | * Set the namespace of a model element to the owner of | |
| 244 | * the given namespace. If the namespace is null | |
| 245 | * the namespace of the diagram is used instead. | |
| 246 | * If the modelElement is not valid in the given namespace | |
| 247 | * this method takes no action. | |
| 248 | * @param modelElement the model element | |
| 249 | * @param ns the namespace | |
| 250 | */ | |
| 251 | public void setModelElementNamespace(Object modelElement, Object ns); | |
| 252 | ||
| 253 | /** | |
| 254 | * This diagram listens to events from its namespace ModelElement; | |
| 255 | * when the modelelement is removed, we also want to delete this | |
| 256 | * diagram. <p> | |
| 257 | * | |
| 258 | * There is also a risk that if this diagram was the one shown in | |
| 259 | * the diagram panel, then it will remain after it has been | |
| 260 | * deleted. So we need to deselect this diagram. | |
| 261 | * There are other things to take care of, so all this is delegated to | |
| 262 | * {@link org.argouml.kernel.Project#moveToTrash(Object)}. | |
| 263 | * | |
| 264 | * @param evt A PropertyChangeEvent object describing the event source | |
| 265 | * and the property that has changed. | |
| 266 | * | |
| 267 | * @see PropertyChangeListener#propertyChange(PropertyChangeEvent) | |
| 268 | */ | |
| 269 | public void propertyChange(PropertyChangeEvent evt); | |
| 270 | ||
| 271 | /** | |
| 272 | * The owner of a diagram is the modelelement that is saved | |
| 273 | * with the project in the pgml file, and binds it to the model. <p> | |
| 274 | * | |
| 275 | * This value is shown in the diagram's properties panel | |
| 276 | * as the "Home model". | |
| 277 | * | |
| 278 | * @return the home model | |
| 279 | */ | |
| 280 | public Object getOwner(); | |
| 281 | ||
| 282 | /** | |
| 283 | * @return an iterator which iterates over all Figs in Diagram | |
| 284 | */ | |
| 285 | public Iterator<Fig> getFigIterator(); | |
| 286 | ||
| 287 | /** | |
| 288 | * Create a diagram element suitable for the base diagram type | |
| 289 | * @param modelElement the model element the diagram element | |
| 290 | * will represent | |
| 291 | * @param bounds the bounds of the newly created diagram element | |
| 292 | * @return the newly created diagram element. | |
| 293 | */ | |
| 294 | public DiagramElement createDiagramElement( | |
| 295 | final Object modelElement, | |
| 296 | final Rectangle bounds); | |
| 297 | ||
| 298 | ///////////////// GEF Methods //////////////////////////// | |
| 299 | // TODO: These should really be picked up automatically from | |
| 300 | // some GEF interface that we extend, but there is no such | |
| 301 | // thing. NOTE: We've only added methods used by ArgoUML, | |
| 302 | // so it's possible that external consumers need other methods. | |
| 303 | ||
| 304 | ||
| 305 | /** | |
| 306 | * @param listener | |
| 307 | * @see org.tigris.gef.base.Diagram#addVetoableChangeListener(VetoableChangeListener) | |
| 308 | */ | |
| 309 | public void addVetoableChangeListener(VetoableChangeListener listener); | |
| 310 | ||
| 311 | /** | |
| 312 | * @param listener | |
| 313 | * @see org.tigris.gef.base.Diagram#removeVetoableChangeListener(VetoableChangeListener) | |
| 314 | */ | |
| 315 | public void removeVetoableChangeListener(VetoableChangeListener listener); | |
| 316 | ||
| 317 | /** | |
| 318 | * @param property | |
| 319 | * @param listener | |
| 320 | * @see org.tigris.gef.base.Diagram#addPropertyChangeListener(String, PropertyChangeListener) | |
| 321 | */ | |
| 322 | public void addPropertyChangeListener(String property, | |
| 323 | PropertyChangeListener listener); | |
| 324 | ||
| 325 | /** | |
| 326 | * @param property | |
| 327 | * @param listener | |
| 328 | * @see org.tigris.gef.base.Diagram#removePropertyChangeListener(String, PropertyChangeListener) | |
| 329 | */ | |
| 330 | public void removePropertyChangeListener(String property, | |
| 331 | PropertyChangeListener listener); | |
| 332 | ||
| 333 | /** | |
| 334 | * @return the GEF graphmodel for this diagram | |
| 335 | * @see org.tigris.gef.base.Diagram#getGraphModel() | |
| 336 | */ | |
| 337 | public GraphModel getGraphModel(); | |
| 338 | ||
| 339 | /** | |
| 340 | * @return the GEF LayerPerspective of this diagram | |
| 341 | * @see org.tigris.gef.base.Diagram#getLayer() | |
| 342 | */ | |
| 343 | public LayerPerspective getLayer(); | |
| 344 | ||
| 345 | /** | |
| 346 | * @param figures list of Figures to check for in diagram | |
| 347 | * @return count of figures contained in this diagram | |
| 348 | * @see org.tigris.gef.base.Diagram#countContained(List) | |
| 349 | */ | |
| 350 | public int countContained(List figures); | |
| 351 | ||
| 352 | /** | |
| 353 | * @param o The object which owns the fig | |
| 354 | * @return the corresponding fig | |
| 355 | * @see org.tigris.gef.base.Diagram#presentationFor(Object) | |
| 356 | */ | |
| 357 | public Fig presentationFor(Object o); | |
| 358 | ||
| 359 | /** | |
| 360 | * @param f Fig to be added | |
| 361 | * @see org.tigris.gef.base.Diagram#add(Fig) | |
| 362 | */ | |
| 363 | public void add(Fig f); | |
| 364 | ||
| 365 | /** | |
| 366 | * Used by "argo.tee". | |
| 367 | * | |
| 368 | * @return the name of the diagram | |
| 369 | * @see org.tigris.gef.base.Diagram#getName() | |
| 370 | */ | |
| 371 | public String getName(); | |
| 372 | ||
| 373 | /** | |
| 374 | * Perform any pre-save actions. | |
| 375 | * @see org.tigris.gef.base.Diagram#preSave() | |
| 376 | */ | |
| 377 | public void preSave(); | |
| 378 | ||
| 379 | /** | |
| 380 | * Perform any post-save actions. | |
| 381 | * @see org.tigris.gef.base.Diagram#postSave() | |
| 382 | */ | |
| 383 | public void postSave(); | |
| 384 | ||
| 385 | /** | |
| 386 | * Perform any post-load actions. | |
| 387 | * @see org.tigris.gef.base.Diagram#postLoad() | |
| 388 | */ | |
| 389 | public void postLoad(); | |
| 390 | /////////////////// End GEF methods //////////////////////// | |
| 391 | ||
| 392 | } |