Show
Ignore:
Timestamp:
03/05/10 12:05:44 (2 years ago)
Author:
mathieu.leclaire
Message:

Refactor TaskCapsule and TaskComposite creation calls

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/simexplorer-ide/simexplorer-ide-ant/org.openmole.ui/src/org/openmole/ui/workflow/implementation/MoleScene.java

    r3142 r3148  
    77import java.awt.Dimension; 
    88import javax.swing.JComponent; 
     9import org.netbeans.api.visual.anchor.AnchorFactory; 
     10import org.netbeans.api.visual.anchor.AnchorShape; 
     11import org.netbeans.api.visual.anchor.PointShape; 
    912import org.netbeans.api.visual.graph.GraphScene; 
    1013import org.netbeans.api.visual.graph.layout.GraphLayout; 
     
    1215import org.netbeans.api.visual.layout.LayoutFactory; 
    1316import org.netbeans.api.visual.layout.SceneLayout; 
     17import org.netbeans.api.visual.widget.ConnectionWidget; 
    1418import org.netbeans.api.visual.widget.LayerWidget; 
    1519import org.netbeans.api.visual.widget.Widget; 
     
    2832public class MoleScene extends GraphScene.StringGraph implements IMoleScene { 
    2933 
    30     private LayerWidget mainLayer; 
     34    private LayerWidget mainLayer = new LayerWidget(this); 
     35    private LayerWidget connectLayer = new LayerWidget(this); 
    3136    private IObjectViewUI obUI = null; 
    3237    private JComponent view; 
     
    3439    public MoleScene() { 
    3540        super(); 
    36         mainLayer = new LayerWidget(this); 
    3741        addChild(mainLayer); 
    3842 
    39         setPreferredSize(new Dimension((int)(ApplicationCustomize.SCREEN_WIDTH*0.8),(int)(ApplicationCustomize.SCREEN_HEIGHT*0.8))); 
     43        setPreferredSize(new Dimension((int) (ApplicationCustomize.SCREEN_WIDTH * 0.8), (int) (ApplicationCustomize.SCREEN_HEIGHT * 0.8))); 
    4044        view = createView(); 
    4145 
     
    4650        return view; 
    4751    } 
    48     public IObjectViewUI createXXTask(IGenericTaskCapsule obj, 
    49             String n, 
    50             boolean composite) throws InternalProcessingError { 
    51         if (composite) { 
    52            obUI = new TaskCompositeViewUI(this, 
    53                                           (ITaskModelUI) UIFactory.getInstance().create(obj.getAssignedTask()), 
    54                                           n); 
    55           // obUI = new TaskViewUI(this, (ITaskModelUI) UIFactory.getInstance().create(obj.getAssignedTask()), n); 
    56             addNode(n); 
    57         } else { 
    58             obUI = new TaskCapsuleViewUI(this); 
    59             addNode(n); 
    60         } 
    61         return obUI; 
     52 
     53    public void createTaskComposite(IGenericTaskCapsule obj, 
     54                                    String n) throws InternalProcessingError { 
     55        obUI = new TaskCompositeViewUI(this, 
     56                (ITaskModelUI) UIFactory.getInstance().create(obj.getAssignedTask()), 
     57                n); 
     58        addNode(n); 
     59    } 
     60 
     61    public void createTaskCapsule(String n) { 
     62        obUI = new TaskCapsuleViewUI(this); 
     63        addNode(n); 
     64    } 
     65 
     66    void createEdge(String edgeID, String sourceNodeID, String targetNodeID) { 
     67        System.out.println("EDGE: " + edgeID + ", " + sourceNodeID + "," + targetNodeID); 
     68        System.out.println("contains " + getEdges().contains(edgeID)); 
     69        addEdge(edgeID); 
     70        setEdgeSource(edgeID, sourceNodeID); 
     71        setEdgeTarget(edgeID, targetNodeID); 
    6272    } 
    6373 
     
    7585    @Override 
    7686    protected Widget attachEdgeWidget(String e) { 
    77         throw new UnsupportedOperationException("Not supported yet."); 
     87        ConnectionWidget connection = new ConnectionWidget(this); 
     88        connection.setTargetAnchorShape(AnchorShape.TRIANGLE_FILLED); 
     89        connection.setEndPointShape(PointShape.SQUARE_FILLED_BIG); 
     90        connection.getActions().addAction(createObjectHoverAction()); 
     91        connection.getActions().addAction(createSelectAction()); 
     92        // connection.getActions ().addAction (reconnectAction); 
     93        connectLayer.addChild(connection); 
     94        return connection; 
    7895    } 
    7996 
    8097    @Override 
    81     protected void attachEdgeSourceAnchor(String e, String n, String n1) { 
    82         throw new UnsupportedOperationException("Not supported yet."); 
     98    protected void attachEdgeSourceAnchor(String edge, String oldSourceNode, String sourceNode) { 
     99        Widget w = sourceNode != null ? findWidget(sourceNode) : null; 
     100        ((ConnectionWidget) findWidget(edge)).setSourceAnchor(AnchorFactory.createRectangularAnchor(w)); 
    83101    } 
    84102 
    85103    @Override 
    86     protected void attachEdgeTargetAnchor(String e, String n, String n1) { 
    87         throw new UnsupportedOperationException("Not supported yet."); 
     104    protected void attachEdgeTargetAnchor(String edge, String oldTargetNode, String targetNode) { 
     105        Widget w = targetNode != null ? findWidget(targetNode) : null; 
     106        ((ConnectionWidget) findWidget(edge)).setTargetAnchor(AnchorFactory.createRectangularAnchor(w)); 
    88107    } 
    89108 

logo cemagref

logo iscpif

logo lifegrid

logo region auvergne

logo patres project