/** Angular */ import * as ng from "@angular/core"; /** Core */ import { CoreComponent } from "cmf.core/src/core"; /** Joint Js*/ import "graphlib"; import "dagre"; import * as joint from "jointjs"; /** Model */ import * as Model from "./nodeEditorModel"; import { PortHighlightedArgs } from "./baseGraphNode"; /** i18n */ import { SelectionMode } from "cmf.core/src/domain/extensions/feedback"; export { Model }; /** * HandleOutput interface - used to generate the data (object array) based on the lbo call output. * The parent component must implement this method. */ export declare type HandlePageEnterAndExit = () => any; /** * LinkOptionClickedEventArgs */ export interface LinkOptionClickedEventArgs { link: Model.NodeEditorLink; option: Model.NodeEditorLinkOption; } /** * LinkEventArgs */ export interface LinkEventArgs { link: Model.NodeEditorLink; data: Model.NodeEditorModel; } /** * LinkStartEventArgs */ export declare type LinkStartEventArgs = LinkEventArgs; /** * LinkCancelEventArgs */ export declare type LinkCancelEventArgs = LinkEventArgs; /** * LinkRemovedEventArgs */ export declare type LinkRemovedEventArgs = LinkEventArgs; /** * LinkConnectedEventArgs */ export declare type LinkConnectedEventArgs = LinkEventArgs; /** * LinkVerticesChangedEventArgs */ export interface LinkVerticesChangedEventArgs { vertices: Model.NodeEditorPoint[]; link: Model.NodeEditorLink; data: Model.NodeEditorModel; } /** * NodeRemovedEventArgs */ export interface NodeRemovedEventArgs { node: Model.NodeEditorNode; data: Model.NodeEditorModel; } /** * NodeCollapsedEventArgs */ export interface NodeCollapsedEventArgs { collapsed: boolean; node: Model.NodeEditorNode; } /** * NodePositionChanged */ export interface NodePositionChangedEventArgs { position: Model.NodeEditorPoint; node: Model.NodeEditorNode; data: Model.NodeEditorModel; } /** * Edit Link arguments */ export interface NodeEditorLinkEditArgs { id: string; vertices?: Model.NodeEditorPoint[]; menuOptions?: Model.NodeEditorLinkOption[]; info?: Model.NodeEditorLinkInfo; icon?: string; } /** * Edit Node arguments */ export interface NodeEditorNodeEditArgs { id: string; position?: Model.NodeEditorPoint; } /** * Extends the default clipboard event with the default mouse coordinates */ export interface NodeEditorClipboardEvent extends ClipboardEvent { /** * Local mouse coordinates relative to node editor */ localMouseCoordinates: Model.NodeEditorPoint; } /** * Selection mode enum. */ export { SelectionMode }; /** * Replace links labels token */ export declare const TO_REPLACE_WITH_ICON_ID: string; /** * Default diagram grid size */ export declare const DEFAULT_DIAGRAM_GRID_SIZE: number; /** * 'In' port group */ export declare const IN_PORT_GROUP: string; /** * 'Out' port group */ export declare const OUT_PORT_GROUP: string; /** * Minimum zoom */ export declare const MIN_ZOOM: number; /** * Maximum zoom */ export declare const MAX_ZOOM: number; /** * Multiplier for the graph paper size */ export declare const GRAPH_PAPER_RELATIVE_SIZE_MULTIPLIER: number; /** * Used to throttle mouse move cursor capture */ export declare const MOUSE_MOVE_THROTTLE_MS: number; export declare abstract class NodeEditor extends CoreComponent { abstract _viewContainerRef: ng.ViewContainerRef; abstract _loader: ng.NgModuleFactoryLoader; abstract _compiler: ng.Compiler; abstract _injector: ng.Injector; /** * Highlighted port */ abstract _highlightedPort: PortHighlightedArgs; /** * Defines the selection mode for the nodes present in the component (the selection can be none, single or multiple) */ abstract selectionMode: SelectionMode; /** * Highlighted link */ abstract _highlightedLink: Model.NodeEditorLink; /** * Highlighted link popup pivot */ abstract _highlightedLinkOPopupPivot: Model.NodeEditorPoint; /** * Clicked link */ abstract _clickedLink: Model.NodeEditorLink; /** * Clicked link popup pivot */ abstract _clickedLinkPopupPivot: Model.NodeEditorPoint; /** * Node Editor Model */ abstract data: Model.NodeEditorModel; /** * Link default options */ abstract linkDefaultOptions: Model.NodeEditorLinkOption[]; /** * Validate link callback */ abstract validateLink: (source: any, target: any) => boolean; /** * Defines if the component will allow self linking */ abstract selfLinking: boolean; /** * Defined if the component will allow to create or remove links */ abstract canChangeLinks: boolean; /** * On link clicked * @event onLinkClicked emits when a new link is double clicked */ abstract linkOptionClicked: ng.EventEmitter; /** * Linked start add event * @event linkStart */ abstract linkStart: ng.EventEmitter; /** * Linked cancel add event * @event linkCancel */ abstract linkCancel: ng.EventEmitter; /** * Link removed event * @event linkRemoved emits the new data model when internally changed */ abstract linkRemoved: ng.EventEmitter; /** * Link connected * @event linkConnected */ abstract linkConnected: ng.EventEmitter; /** * Link vertices changed * @event linkVerticesChanged */ abstract linkVerticesChanged: ng.EventEmitter; /** * Node removed event * @event nodeRemoved */ abstract nodeRemoved: ng.EventEmitter; /** * Node collapsed/expanded event * @event nodeCollapsed */ abstract nodeCollapsed: ng.EventEmitter; /** * Node selection event * @event nodeSelectionChanged */ abstract nodeSelectionChanged: ng.EventEmitter; /** * Node position changed * @event nodePositionChanged */ abstract nodePositionChanged: ng.EventEmitter; /** * Zoom changed * @event zoomChanged */ abstract zoomChanged: ng.EventEmitter; /** * Pan changed * @event panChanged */ abstract panChanged: ng.EventEmitter; /** * Browser "cut" event * @event cut */ abstract cut: ng.EventEmitter; /** * Browser "copy" event * @event copy */ abstract copy: ng.EventEmitter; /** * Browser "paste" event * @event paste */ abstract paste: ng.EventEmitter; /** * Browser "copy" event * @event keyboardCopy */ abstract keyboardCopy: ng.EventEmitter; /** * Browser "paste" event * @event keyboardPaste */ abstract keyboardPaste: ng.EventEmitter; abstract onEnterPage: HandlePageEnterAndExit; abstract onExitPage: HandlePageEnterAndExit; /** * On link menu option click */ abstract onLinkOptionClick(link: Model.NodeEditorLink, option: Model.NodeEditorLinkOption): any; /** * Update node inputs * @param cell Element that contains the nested component, which inputs are going to be updated * @param selected Value of "selected" input */ abstract updateSelected(cell: joint.dia.Cell, selected: boolean): void; /** * Remove element from graph */ abstract removeElement(id: string): boolean; /** * Gets the current data model * @returns the current data model */ abstract getCurrentData(): Model.NodeEditorModel; /** * Adds a new node to the diagram * @param node the new node definition * @returns the modified data model after the operation */ abstract addNode(node: Model.NodeEditorNode): string; /** * Add a new link to the diagram * @param node the new link definition * @returns the modified data model after the operation */ abstract addLink(link: Model.NodeEditorLink): string; /** * Edit a node * @param args the properties to edit * @return success of operation */ abstract editNode(args: NodeEditorNodeEditArgs): Model.NodeEditorModel; /** * Edit a link * @param args the properties to edit * @return success of operation */ abstract editLink(args: NodeEditorLinkEditArgs): Model.NodeEditorModel; /** * Removes a node from the diagram * @param id the id of the node to remove * @returns the modified data model after the operation */ abstract removeNode(id: string): boolean; /** * Removes a link from the diagram * @param id the id of the link to remove * @returns the modified data model after the operation */ abstract removeLink(id: string): boolean; /** * Applies an auto-grid-layout to the diagram to rearrange the items * @param options the new layout options * @returns the modified data model after the operation */ abstract applyGridLayout(options: Model.NodeEditorGridLayoutOptions): Promise; /** * Fit content of the graph to window */ abstract fitToWindow(): void; /** * Expand/Collapse all nodes * @param collapsed true to collapse all and false to expand all */ abstract toggleCollapseAll(collapsed: boolean): void; /** * Zoom in */ abstract zoomIn(): void; /** * Zoom out */ abstract zoomOut(): void; /** * Set paper zoom * @param newZoom the new zoom * @param notifyPanChanged used to avoid notification on first setZoom */ abstract setZoom(newZoom: number, notifyPanChanged: boolean): void; /** abstract * Set min zoom */ abstract setMinZoom(): void; /** * Set max zoom */ abstract setMaxZoom(): void; /** * Set pan * @param h amount horizontally * @param v amount vertically */ abstract setPan(point: Model.NodeEditorPoint): void; /** * Scroll to initial position */ abstract panInitial(): void; /** * Get current pan */ abstract getCurrentPan(): Model.NodeEditorPoint; /** * Get current zoom */ abstract getCurrentZoom(): number; /** * Get local mouse coordinates */ abstract getLocalMouseCoordinates(originalMousePosition: Model.NodeEditorPoint): Model.NodeEditorPoint; /** * Updates the inner component inputs and outputs * Should receive an object with the inputs and outputs that must be updated * @param nodeId Node ID * @param properties Properties to update */ abstract updateComponentProperties(nodeId: string, properties: { [key: string]: any; }): void; /** * Animates a link in the model * @param linkId Link ID * @param duration Animation duration in seconds, 1 by default */ abstract animateLink(linkId: string, duration?: number): void; }