KickJava   Java API By Example, From Geeks To Geeks.

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


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.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 JavaDoc;
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 /**
26  *
27  * @author joelle
28  */

29 public class LinkCreateProvider implements ConnectProvider {
30     
31     private PageFlowScene graphScene;
32     AbstractNode source = null;
33     AbstractNode target = null;
34     String JavaDoc navComp = null;
35     
36     /**
37      * Creates a new instance of LinkCreateProvider
38      * @param graphScene
39      *
40      */

41     public LinkCreateProvider(PageFlowScene graphScene) {
42         this.graphScene = graphScene;
43     }
44     
45     public boolean isSourceWidget(Widget sourceWidget) {
46         
47         Object JavaDoc object = graphScene.findObject(sourceWidget);
48         source = null;
49 // navComp = null;
50
// if (graphScene.isPin(object)){
51
// Pin pin = (Pin)object;
52
// source = pin.getPage();
53
// navComp = pin.getNavComp();
54
// } else if ( graphScene.isNode(object) ){
55
// source = (Page)object;
56
// }
57
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 JavaDoc 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 //
73
// if (targetWidget instanceof VMDNodeWidget ) {
74
// return ConnectorState.ACCEPT;
75
// }
76
//
77
// // Only allow it to be attached to the default pin.
78
//// if (graphScene.isPin(targetWidget) &&
79
//// ((Pin)graphScene.findObject(targetWidget)).getNavComp() == null ) {
80
//// return ConnectorState.ACCEPT;
81
//// }
82
// return ConnectorState.REJECT_AND_STOP;
83
}
84     
85     public boolean hasCustomTargetWidgetResolver(Scene scene) {
86         return false;
87     }
88     
89     public Widget resolveTargetWidget(Scene scene, Point JavaDoc 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 // addEdge (edge);
99
// setEdgeSource (edge, source);
100
// setEdgeTarget (edge, target);
101
}
102     
103 }
104
Popular Tags