/[cashew-s-editor]/cashews/src/nongnu/cashews/eclipse/composer/model/ConnectionElement.java
ViewVC logotype

Diff of /cashews/src/nongnu/cashews/eclipse/composer/model/ConnectionElement.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1 by gnu_andrew, Thu May 5 23:47:58 2005 UTC revision 1.2 by gnu_andrew, Thu May 19 10:51:48 2005 UTC
# Line 33  Line 33 
33   otherwise indicated below, the terms and conditions of the EPL still apply   otherwise indicated below, the terms and conditions of the EPL still apply
34   to any source code in the Content.   to any source code in the Content.
35    
36   */  */
   
37    
38  package nongnu.cashews.eclipse.composer.model;  package nongnu.cashews.eclipse.composer.model;
39    
40  import java.util.ArrayList;  import java.util.ArrayList;
41    
42  import nongnu.cashews.language.process.Connection;  import nongnu.cashews.language.process.Connection;
43    import nongnu.cashews.language.process.Performance;
44    
45  public class ConnectionElement extends Element  public class ConnectionElement
46      extends Element
47  {  {
48    
49    /**    /**
50     * Comment for <code>serialVersionUID</code>     * Serialization ID.
51     */     */
52    private static final long serialVersionUID = 1L;    private static final long serialVersionUID = 1L;
53    
54      /**
55       * The target node.
56       *
57       * @serial the target node.
58       */
59    private Node target;    private Node target;
60    
61      /**
62       * The source node.
63       *
64       * @serial the source node.
65       */
66    private Node source;    private Node source;
67        
68    private Connection conn;    /**
69       * The model of the connection.
70       *
71       * @serial the connection model.
72       */
73      private Connection connection;
74    
75    public ConnectionElement(Node source, Node target)    public ConnectionElement(Node source, Node target)
76    {    {
77      this.source = source;      this.source = source;
78      this.target = target;      this.target = target;
79      if (target.inputs != null)      if (target.inputs != null)
       {  
80          target.addInput(this);          target.addInput(this);
       }  
81      else      else
82        {        {
83          target.inputs = new ArrayList<ConnectionElement>();          target.inputs = new ArrayList<ConnectionElement>();
84          target.addInput(this);          target.addInput(this);
85        }        }
86      if (source.outputs != null)      if (source.outputs != null)
       {  
87          source.addOutput(this);          source.addOutput(this);
       }  
88      else      else
89        {        {
90          source.outputs = new ArrayList<ConnectionElement>();          source.outputs = new ArrayList<ConnectionElement>();
91          source.addOutput(this);          source.addOutput(this);
92        }        }
93            
94      conn = new Connection();      connection = new Connection();
95      PerformanceElement sourcePerformNode = (PerformanceElement) source;      Performance sourcePerform =
96      conn.setFromPerformance(sourcePerformNode.getPerformance().getName());        ((PerformanceElement) source).getPerformance();
97      PerformanceElement targetPerformNode = (PerformanceElement) target;      connection.setFromPerformance(sourcePerform.getName());
98      conn.setToPerformance(targetPerformNode.getPerformance().getName());        Performance targetPerform =
99              ((PerformanceElement) target).getPerformance();
100        connection.setToPerformance(targetPerform.getName());
101    }    }
102    
103    public Node getTarget()    public Node getTarget()
104    {    {
105      return this.target;      return target;
106    }    }
107    
108    public Node getSource()    public Node getSource()
109    {    {
110      return this.source;      return source;
111    }    }
112    
113      /**
114       * Retrieves the underlying <code>Connection</code> model for this element.
115       *
116       * @return the connection model.
117       */
118      public Connection getConnection()
119      {
120        return connection;
121      }
122    
123  }  }

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26