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.EventObject; f@0: f@0: /** f@0: * ElementChangedEvent is used to notify the model listeners that an element ({@code DiagramNode} f@0: * or {@code DiagramEdge}) in the model has been changed (e.g. it has a new name). f@0: * f@0: */ f@0: @SuppressWarnings("serial") f@0: public class ElementChangedEvent extends EventObject { f@0: f@0: /** f@0: * Creates a new instance of {@code ElementChangedEvent} f@0: * f@0: * @param element the element that has been changed f@0: * @param args the arguments of this change event, if any f@0: * @param changeType it's a {@code String} identifying the change type. Subclasses of {@code DiagramNode} and f@0: * {@code DiagramEdge} can define their own change events and and make listeners aware of them via their f@0: * {@code notifyChnage()} method. Listeners (defined outside this package as well) can then identify such changes using this string. f@0: * @param source the source of the change that triggered this event f@0: */ f@0: public ElementChangedEvent( DiagramElement element, Object args, String changeType, Object source) { f@0: super(source); f@0: this.changeType = changeType; f@0: this.element = element; f@0: this.arguments = args; f@0: } f@0: f@0: /** f@0: * A String representing the change type. Subclasses of DiagramNode and DiagramEdge f@0: * can throw their own events by passing as argument a String that describes the change. f@0: * Such events will have no effect in the model but will be fired to all the registered ChangeEventListener. f@0: * f@0: * @return a String describing the change type f@0: */ f@0: public String getChangeType(){ f@0: return changeType; f@0: } f@0: f@0: /** f@0: * Returns the DiagramElement that has been affected by this change f@0: * @return the DiagramElement that has been affected by this change f@0: */ f@0: public DiagramElement getDiagramElement(){ f@0: return element; f@0: } f@0: f@0: /** f@0: * Returns the arguments of the change if the the change type has any f@0: * f@0: * @return an object representing the arguments or null f@0: */ f@0: public Object getArguments(){ f@0: return arguments; f@0: } f@0: f@0: private String changeType; f@0: private DiagramElement element; f@0: private Object arguments; f@0: f@0: /** f@0: * This class is returned by {@link ElementChangedEvent#getArguments()} when a node property is f@0: * changed. It holds the informations about the property type and the property index, so that f@0: * listeners can retrieve the property when handling the event. f@0: * f@0: */ f@0: public static class PropertyChangeArgs { f@0: public PropertyChangeArgs(String type, int index, String oldValue){ f@0: this.type = type; f@0: this.index = index; f@0: this.oldValue = oldValue; f@0: } f@0: f@0: public String getPropertyType(){ f@0: return type; f@0: } f@0: f@0: public int getPropertyIndex(){ f@0: return index; f@0: } f@0: f@0: public String getOldValue(){ f@0: return oldValue; f@0: } f@0: f@0: private String type; f@0: private String oldValue; f@0: private int index; f@0: } f@0: }