View Javadoc

1   /*
2    * This file is a part of CAST project.
3    * (c) Copyright 2007, AGH University of Science & Technology
4    * https://caribou.iisg.agh.edu.pl/trac/cast
5    *
6    * Licensed under the Eclipse Public License, Version 1.0 (the "License").
7    * You may not use this file except in compliance with the License.
8    * You may obtain a copy of the License at
9    * http://www.eclipse.org/legal/epl-v10.html
10   */
11  /*
12   * File: EntityCreationTool.java
13   * Created: 2007-00-00
14   * Author: awos
15   * $Id: EntityCreationTool.java 2774 2009-04-22 13:56:23Z tmilos $
16   */
17  
18  package pl.edu.agh.cast.backward.editor;
19  
20  import java.util.Map;
21  
22  import org.eclipse.gef.Request;
23  import org.eclipse.gef.tools.CreationTool;
24  
25  import pl.edu.agh.cast.model.visual.backward.NodeFactory;
26  
27  /**
28   * {@link CreationTool} for adding new entities to a diagram.
29   *
30   * @author AGH CAST Team
31   */
32  public class EntityCreationTool extends CreationTool {
33  
34  	/**
35  	 * Id of the property containing new entitie's icon image id.
36  	 */
37  	public static final String IMAGE_ID = "IMAGE_ID"; //$NON-NLS-1$
38  
39  	/**
40  	 * {@inheritDoc}
41  	 *
42  	 * @see org.eclipse.gef.tools.CreationTool#createTargetRequest()
43  	 */
44  	@SuppressWarnings("unchecked")
45  	@Override
46  	protected Request createTargetRequest() {
47  		Request req = super.createTargetRequest();
48  		Map data = req.getExtendedData();
49  		NodeFactory factory = (NodeFactory)getFactory();
50  		data.put(EntityCreationTool.IMAGE_ID, factory.getImageId());
51  		req.setExtendedData(data);
52  		return req;
53  	}
54  }