KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > web > jsf > navigation > graph > actions > DeleteAction


1 /*
2  * LinkCreateProvider.java
3  *
4  * Created on January 29, 2007, 12:55 PM
5  *
6  * To change this template, choose Tools | Template Manager
7  * and open the template in the editor.
8  */

9
10 package org.netbeans.modules.web.jsf.navigation.graph.actions;
11
12 import org.netbeans.modules.web.jsf.navigation.vwmodel.Link;
13 import org.netbeans.modules.web.jsf.navigation.vwmodel.Page;
14 import org.netbeans.modules.web.jsf.navigation.vwmodel.Pin;
15 import org.netbeans.modules.web.jsf.navigation.graph.NavigationBridgeUtilities;
16 import java.awt.event.KeyEvent JavaDoc;
17 import org.netbeans.api.visual.action.WidgetAction;
18 import org.netbeans.api.visual.graph.GraphPinScene;
19 import org.netbeans.api.visual.widget.Widget;
20
21 /**
22  *
23  * @author joelle
24  */

25 public class DeleteAction extends WidgetAction.Adapter {
26     
27     GraphPinScene graphScene;
28     
29     public DeleteAction (GraphPinScene graphScene ){
30         super();
31         this.graphScene = graphScene;
32     }
33     
34     public WidgetAction.State keyTyped(Widget widget, WidgetAction.WidgetKeyEvent widgetKeyEvent) {
35 // public State keyPressed(Widget widget, WidgetAction.WidgetKeyEvent widgetKeyEvent) {
36

37         System.out.println("\nKey Pressed and seen by DeleteAction class");
38         if( widgetKeyEvent.getKeyChar() != (char)KeyEvent.VK_DELETE ){
39             return WidgetAction.State.REJECTED;
40         }
41         
42         Object JavaDoc object = graphScene.findObject(widget);
43         if (graphScene.isEdge(object)) {
44             NavigationBridgeUtilities.getInstance().removeLink((Link)object);
45             return WidgetAction.State.CONSUMED;
46         } else if (graphScene.isNode(object)) {
47             NavigationBridgeUtilities.getInstance().removeNode((Page)object);
48             return WidgetAction.State.CONSUMED;
49         } else if (graphScene.isPin(object)) {
50             NavigationBridgeUtilities.getInstance().removePin((Pin)object);
51         }
52         
53         return WidgetAction.State.REJECTED;
54     }
55     
56 }
57
Popular Tags