KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > nightlabs > editor2d > editpolicy > DrawComponentEditPolicy


1 /**
2  * <p> Project: com.nightlabs.editor2d </p>
3  * <p> Copyright: Copyright (c) 2004 </p>
4  * <p> Company: NightLabs GmbH (Germany) </p>
5  * <p> Creation Date: 26.10.2004 </p>
6  * <p> Author: Daniel Mazurek </p>
7 **/

8 package com.nightlabs.editor2d.editpolicy;
9
10 import org.eclipse.gef.commands.Command;
11 import org.eclipse.gef.editpolicies.ComponentEditPolicy;
12 import org.eclipse.gef.requests.GroupRequest;
13
14 import com.nightlabs.editor2d.DrawComponent;
15 import com.nightlabs.editor2d.DrawComponentContainer;
16 import com.nightlabs.editor2d.command.DeleteDrawComponentCommand;
17
18 public class DrawComponentEditPolicy
19 extends ComponentEditPolicy
20 {
21     /* (non-Javadoc)
22      * @see org.eclipse.gef.editpolicies.ComponentEditPolicy#createDeleteCommand(org.eclipse.gef.requests.GroupRequest)
23      */

24     protected Command createDeleteCommand(GroupRequest deleteRequest)
25     {
26         Object JavaDoc parent = getHost().getParent().getModel();
27         Object JavaDoc child = getHost().getModel();
28 // if (parent instanceof MultiLayerDrawComponent && child instanceof DrawComponent) {
29
// return new DeleteDrawComponentCommand((MultiLayerDrawComponent) parent, (DrawComponent) child);
30
// }
31
if (parent instanceof DrawComponentContainer && child instanceof DrawComponent) {
32             return new DeleteDrawComponentCommand((DrawComponentContainer) parent, (DrawComponent) child);
33         }
34         return super.createDeleteCommand(deleteRequest);
35     }
36 }
Popular Tags