1 9 10 package org.netbeans.modules.web.jsf.navigation.graph.actions; 11 12 import org.netbeans.modules.web.jsf.navigation.vwmodel.NavigableComponent; 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.Point ; 17 import org.netbeans.api.visual.action.ConnectProvider; 18 import org.netbeans.api.visual.action.ConnectorState; 19 import org.netbeans.api.visual.widget.Scene; 20 import org.netbeans.api.visual.widget.Widget; 21 import org.netbeans.modules.web.jsf.navigation.PageFlowController; 22 import org.netbeans.modules.web.jsf.navigation.graph.PageFlowScene; 23 import org.openide.nodes.AbstractNode; 24 25 29 public class LinkCreateProvider implements ConnectProvider { 30 31 private PageFlowScene graphScene; 32 AbstractNode source = null; 33 AbstractNode target = null; 34 String navComp = null; 35 36 41 public LinkCreateProvider(PageFlowScene graphScene) { 42 this.graphScene = graphScene; 43 } 44 45 public boolean isSourceWidget(Widget sourceWidget) { 46 47 Object object = graphScene.findObject(sourceWidget); 48 source = null; 49 if( graphScene.isNode(object)){ 58 source = (AbstractNode)object; 59 } 60 61 return source != null; 62 63 } 64 65 public ConnectorState isTargetWidget(Widget sourceWidget, Widget targetWidget) { 66 target = null; 67 Object object = graphScene.findObject(targetWidget); 68 target = graphScene.isNode(object) ? (AbstractNode) object : null; 69 if (target != null) 70 return ConnectorState.ACCEPT; 71 return object != null ? ConnectorState.REJECT_AND_STOP : ConnectorState.REJECT; 72 } 84 85 public boolean hasCustomTargetWidgetResolver(Scene scene) { 86 return false; 87 } 88 89 public Widget resolveTargetWidget(Scene scene, Point sceneLocation) { 90 return null; 91 } 92 93 public void createConnection(Widget sourceWidget, Widget targetWidget) { 94 PageFlowController pfc = graphScene.getPageFlowView().getPageFlowController(); 95 if ( pfc != null && sourceWidget != null && targetWidget != null ) { 96 pfc.createLink(source, target, navComp); 97 } 98 } 102 103 } 104 | Popular Tags |