/** Angular */ import * as ng from "@angular/core"; /** Core */ import { CoreComponent } from "cmf.core/src/core"; /** Model */ import * as Model from "./nodeEditorModel"; /** * When a new model is set */ export interface LinksChangedArgs { links: Model.NodeEditorLink[]; } /** * NodeCollapsedOrExpandedArgs */ export interface NodeCollapsedOrExpandedArgs { id: string; collapsed: boolean; fromUser: boolean; } /** * PortHighlightedArgs */ export interface GraphNodePortHighlightedArgs { port: string; ownerId: string; } /** * PortHighlightedArgs */ export interface PortHighlightedArgs { port: string; owner: Model.NodeEditorNode; } /** * PortLinkedArgs */ export interface PortLinkedArgs { targetPort: string; link: Model.NodeEditorLink; } /** * LinkCreatedArgs */ export interface LinkCreatedArgs { sourcePort: string; targetPort: string; link: Model.NodeEditorLink; } /** * LinkRemovedArgs */ export declare type LinkRemovedArgs = LinkCreatedArgs; /** * GraphNodeIOEntry Link State */ export declare enum GraphNodeIOPortState { NONE = 0, HIGHLIGHTED = 1, GOOD_LINK_HOVER = 3, BAD_LINK_HOVER = 4 } /** * BaseGraphNode i/o */ export interface GraphNodeIOPort { id: string; name: string; description: string; state: GraphNodeIOPortState; tag: any; } /** * @whatItDoes * * This component is the base component with the required features to be used for the nodes in a `NodeEditor` * * @howToUse * * This interface must be implemented by all the components that represent a node editor graph node, * to implement base internal node editor features * * Also, the ports must be explicit identified in the HTML of every GraphNode component ([attr.port-id]="port_X_id") * * ### Inputs * * `string` : **id** - The id of the node * * `PortHighlightedArgs` : **portHighlighted** - Port highlighted * * `PortLinkedArgs` : **internalPortLinked** - When a link is magnetized to a port during link creation drag (port id) * * `LinkCreatedArgs` : **linkCreated** - When a link is connected (created) * * `LinkRemovedArgs` : **linkRemoved** - When a link is removed * * `LinksChangedArgs` : **linksChanged** - When links change, used to update ports * * `string` : **headerIcon** - The header icon class * * `string` : **headerTitle** - The header title * * `boolean` : **isGhost** - If the aspect of the component is in "ghost" mode witch consists in a shape more rounded and more transparent * * `GraphNodeIOPort[]` : **inputPorts** - The input ports * * `GraphNodeIOPort[]` : **outputPorts** - The output ports * * `boolean` : **collapsed** - If the node is collapsed * * `boolean` : **selected** - If the node is selected * * `string` : **invalidLinkMessage** - The message to show when a link is invalid * * `function` : **internalPortMagnetizedCallback** - The callback to be executed when a port of * this node is magnetized with a link when user is dragging a new link * * `function` : **outputPortHighlightedCallback** - The callback to be executed when an output port * from any node in the NodeEditor is highlighted * * ### Outputs * * `NodeCollapsedOrExpandedArgs` : **collapseClicked** - When an option to collapse or expand this node is clicked * * `string` : **removeClicked** - When an option to removed this node is clicked (sends the id of the node) * * `PortHighlightedArgs` : **internalPortHighlighted** - When an internal port of this node is highlighted * * `string` : **settingsClicked** - When an option to open the settings of this node is clicked (sends the id of the node) * * `void` : **nodeEditorComponentResized** - When the component size (view) changes and needs to be updated */ export declare abstract class BaseGraphNode extends CoreComponent implements ng.OnChanges { /** * If the component is collapsed */ protected _collapsed: boolean; /** * Highlighted Ports */ private _highlightedPorts; /** * Links by port */ protected _numberOfLinksByPort: Map; /** * Graph node id */ id: string; /** * Port highlighted */ portHighlighted: PortHighlightedArgs; /** * When a link is magnetized to a port during link creation drag (port id) */ internalPortLinked: PortLinkedArgs; /** * When a link is connected (created) */ linkCreated: LinkCreatedArgs; /** * When a link is removed */ linkRemoved: LinkRemovedArgs; /** * When the node editor model changes */ linksChanged: LinksChangedArgs; /** * If the node is collapsed */ collapsed: boolean; /** * If the node is selected */ selected: boolean; /** * All the input ports */ inputPorts: Array; /** * All the output ports */ outputPorts: Array; /** * Internal port magnetized callback */ internalPortMagnetizedCallback: (id: string, internalPortLinked: PortLinkedArgs) => boolean; /** * Output port highlighted callback */ outputPortHighlightedCallback: (id: string, portHighlighted: PortHighlightedArgs, inputPorts: GraphNodeIOPort[]) => number[]; /** * On port highlighted * * @event onPortHighlighted */ internalPortHighlighted: ng.EventEmitter; /** * When the option 'collapse' is clicked * * @event collapseClicked */ collapseClicked: ng.EventEmitter; /** * When the option 'remove' is clicked * * @event removeClicked */ removeClicked: ng.EventEmitter; /** * When the option 'settings' is clicked * * @event settingsClicked */ settingsClicked: ng.EventEmitter; /** * When the component view size changes and needs to be refreshed to match the ports and links * * @event nodeEditorComponentResized */ nodeEditorComponentResized: ng.EventEmitter; /** * Highlight port * @param portId */ protected highlightPort(portId: string): void; /** * Output to remove this node */ protected remove(): void; /** * Output to open settings of this node */ protected openSettings(): void; /** * Collapse/Expand the node */ protected collapse(args: { collapsed?: boolean; fromUser?: boolean; }): void; /** * Validate a link * @param internalPortLinked */ private validateLink; /** * On collapse or expand */ protected abstract onCollapseOrExpand(): void; /** * Update ports - used when a links are created or removed * @param connected true for link creations, false for deletions */ private updatePorts; /** * On changes * @param changes */ ngOnChanges(changes: ng.SimpleChanges): void; }