1 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 ; 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 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 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 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 |