1- import { BaseClass , DefaultPortCandidate , INode , IPortCandidate , IPortCandidateProvider , List , PortCandidateProviderBase } from 'yfiles' ;
1+ import { BaseClass , DefaultPortCandidate , IEnumerable , IInputModeContext , INode , IPortCandidate , IPortCandidateProvider , List , PortCandidateProviderBase } from 'yfiles' ;
22import { FlowPortModel } from './FlowPortModel' ;
33import { PortType } from '../core/PortType' ;
44import { IFlowPortViewModel } from '../core/IFlowPortViewModel' ;
@@ -18,19 +18,12 @@ export default class PortCandidateProvider extends PortCandidateProviderBase {
1818 * @returns {IEnumerable.<IPortCandidate> }
1919 */
2020 getAllSourcePortCandidates ( context ) {
21- // create a port candidate at the right side of the node
21+
2222 const candidates = new List < IPortCandidate > ( ) ;
23- const found = this . node . ports . filter ( p => p . tag && ( p . tag as IFlowPortViewModel ) . portType == PortType . OUTPUT ) ;
24- if ( found . size === 0 ) {
25- return candidates ;
26- }
27- // const defaultPortCandidate: IPortCandidate = new DefaultPortCandidate(
28- // this.node,
29- // found.first().locationParameter
30- // );
31- // candidates.add(defaultPortCandidate);
23+ // add all
3224 this . addExistingPorts ( this . node , candidates ) ;
33- return candidates
25+ // but keep only the output
26+ return candidates . filter ( p => p . port . tag && ( p . port . tag as IFlowPortViewModel ) . portType == PortType . OUTPUT )
3427 }
3528
3629 /**
@@ -40,13 +33,10 @@ export default class PortCandidateProvider extends PortCandidateProviderBase {
4033 */
4134 getAllTargetPortCandidates ( context ) {
4235 const candidates = new List < IPortCandidate > ( ) ;
43- const found = this . node . ports . filter ( p => p . tag && ( p . tag as IFlowPortViewModel ) . portType == PortType . INPUT ) ;
44- if ( found . size === 0 ) {
45- return candidates ;
46- }
47-
36+ // add all
4837 this . addExistingPorts ( this . node , candidates ) ;
49- return candidates
38+ // but keep only the output
39+ return candidates . filter ( p => p . port . tag && ( p . port . tag as IFlowPortViewModel ) . portType == PortType . INPUT ) ;
5040 }
5141
5242 /**
@@ -66,4 +56,8 @@ export default class PortCandidateProvider extends PortCandidateProviderBase {
6656 getTargetPortCandidates ( context , source ) {
6757 return this . getAllTargetPortCandidates ( context )
6858 }
59+
60+ getPortCandidates ( context : IInputModeContext ) : IEnumerable < IPortCandidate > {
61+ return undefined ;
62+ }
6963}
0 commit comments