View Javadoc

1   /**********************************************
2    * Copyright (C) 2011 Lukas Laag
3    * This file is part of svgreal.
4    * 
5    * svgreal is free software: you can redistribute it and/or modify
6    * it under the terms of the GNU General Public License as published by
7    * the Free Software Foundation, either version 3 of the License, or
8    * (at your option) any later version.
9    * 
10   * svgreal is distributed in the hope that it will be useful,
11   * but WITHOUT ANY WARRANTY; without even the implied warranty of
12   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13   * GNU General Public License for more details.
14   * 
15   * You should have received a copy of the GNU General Public License
16   * along with svgreal.  If not, see http://www.gnu.org/licenses/
17   **********************************************/
18  package org.vectomatic.svg.edit.client.event;
19  
20  import org.vectomatic.svg.edit.client.command.ICommandFactory;
21  
22  import com.google.gwt.event.shared.GwtEvent;
23  
24  /**
25   * Event emitted when the command factory selector changes
26   * @author laaglu
27   */
28  public class CommandFactorySelectorChangeEvent extends GwtEvent<CommandFactorySelectorChangeHandler> {
29  	/**
30  	 * Handler type.
31  	 */
32  	private static Type<CommandFactorySelectorChangeHandler> TYPE;
33  
34  	private final ICommandFactory commandFactory;
35  
36  	public CommandFactorySelectorChangeEvent(ICommandFactory commandFactory) {
37  		this.commandFactory = commandFactory;
38  	}
39  
40  	@Override
41  	public com.google.gwt.event.shared.GwtEvent.Type<CommandFactorySelectorChangeHandler> getAssociatedType() {
42  		if (TYPE == null) {
43  			TYPE = new Type<CommandFactorySelectorChangeHandler>();
44  		}
45  		return TYPE;
46  	}
47  
48  	/**
49  	 * Ensures the existence of the handler hook and then returns it.
50  	 * 
51  	 * @return returns a handler hook
52  	 */
53  	public static Type<CommandFactorySelectorChangeHandler> getType() {
54  		if (TYPE == null) {
55  			TYPE = new Type<CommandFactorySelectorChangeHandler>();
56  		}
57  		return TYPE;
58  	}
59  
60  	@Override
61  	protected void dispatch(CommandFactorySelectorChangeHandler handler) {
62  		handler.onChange(this);
63  	}
64  
65  	public ICommandFactory getCommandFactory() {
66  		return commandFactory;
67  	}
68  
69  }