annotate java/src/uk/ac/qmul/eecs/ccmi/diagrammodel/ElementChangedEvent.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.EventObject;
f@0 22
f@0 23 /**
f@0 24 * ElementChangedEvent is used to notify the model listeners that an element ({@code DiagramNode}
f@0 25 * or {@code DiagramEdge}) in the model has been changed (e.g. it has a new name).
f@0 26 *
f@0 27 */
f@0 28 @SuppressWarnings("serial")
f@0 29 public class ElementChangedEvent extends EventObject {
f@0 30
f@0 31 /**
f@0 32 * Creates a new instance of {@code ElementChangedEvent}
f@0 33 *
f@0 34 * @param element the element that has been changed
f@0 35 * @param args the arguments of this change event, if any
f@0 36 * @param changeType it's a {@code String} identifying the change type. Subclasses of {@code DiagramNode} and
f@0 37 * {@code DiagramEdge} can define their own change events and and make listeners aware of them via their
f@0 38 * {@code notifyChnage()} method. Listeners (defined outside this package as well) can then identify such changes using this string.
f@0 39 * @param source the source of the change that triggered this event
f@0 40 */
f@0 41 public ElementChangedEvent( DiagramElement element, Object args, String changeType, Object source) {
f@0 42 super(source);
f@0 43 this.changeType = changeType;
f@0 44 this.element = element;
f@0 45 this.arguments = args;
f@0 46 }
f@0 47
f@0 48 /**
f@0 49 * A String representing the change type. Subclasses of DiagramNode and DiagramEdge
f@0 50 * can throw their own events by passing as argument a String that describes the change.
f@0 51 * Such events will have no effect in the model but will be fired to all the registered ChangeEventListener.
f@0 52 *
f@0 53 * @return a String describing the change type
f@0 54 */
f@0 55 public String getChangeType(){
f@0 56 return changeType;
f@0 57 }
f@0 58
f@0 59 /**
f@0 60 * Returns the DiagramElement that has been affected by this change
f@0 61 * @return the DiagramElement that has been affected by this change
f@0 62 */
f@0 63 public DiagramElement getDiagramElement(){
f@0 64 return element;
f@0 65 }
f@0 66
f@0 67 /**
f@0 68 * Returns the arguments of the change if the the change type has any
f@0 69 *
f@0 70 * @return an object representing the arguments or null
f@0 71 */
f@0 72 public Object getArguments(){
f@0 73 return arguments;
f@0 74 }
f@0 75
f@0 76 private String changeType;
f@0 77 private DiagramElement element;
f@0 78 private Object arguments;
f@0 79
f@0 80 /**
f@0 81 * This class is returned by {@link ElementChangedEvent#getArguments()} when a node property is
f@0 82 * changed. It holds the informations about the property type and the property index, so that
f@0 83 * listeners can retrieve the property when handling the event.
f@0 84 *
f@0 85 */
f@0 86 public static class PropertyChangeArgs {
f@0 87 public PropertyChangeArgs(String type, int index, String oldValue){
f@0 88 this.type = type;
f@0 89 this.index = index;
f@0 90 this.oldValue = oldValue;
f@0 91 }
f@0 92
f@0 93 public String getPropertyType(){
f@0 94 return type;
f@0 95 }
f@0 96
f@0 97 public int getPropertyIndex(){
f@0 98 return index;
f@0 99 }
f@0 100
f@0 101 public String getOldValue(){
f@0 102 return oldValue;
f@0 103 }
f@0 104
f@0 105 private String type;
f@0 106 private String oldValue;
f@0 107 private int index;
f@0 108 }
f@0 109 }