This repository has been archived by the owner on Nov 22, 2019. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TEIIDTOOLS-467: begin hooking up the canvas to the view editor
* Use the subscriptions and events to hook in the actions of the canvas to the models in the view editor and let the latter drive the creation of objects with the canvas responding accordingly.
- Loading branch information
1 parent
0a123d9
commit a65dfb8
Showing
8 changed files
with
288 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
.../dataservices/virtualization/view-editor/view-canvas/event/view-canvas-event-type.enum.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/** | ||
* @license | ||
* Copyright 2017 JBoss Inc | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
export enum ViewCanvasEventType { | ||
|
||
/** | ||
* An event indicating the selection of objects in the canvas has changed. | ||
*/ | ||
CANVAS_SELECTION_CHANGED = "CANVAS_SELECTION_CHANGED", | ||
|
||
/** | ||
* An event indicating a source node should be created | ||
*/ | ||
CREATE_SOURCE = "CREATE_SOURCE", | ||
|
||
/** | ||
* An event indicating a composition node should be created | ||
*/ | ||
CREATE_COMPOSITION = "CREATE_COMPOSITION", | ||
|
||
/** | ||
* An event indicating a node should be deleted | ||
*/ | ||
DELETE_NODE = "DELETE_NODE", | ||
|
||
} |
88 changes: 88 additions & 0 deletions
88
ngapp/src/app/dataservices/virtualization/view-editor/view-canvas/event/view-canvas-event.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
/** | ||
* @license | ||
* Copyright 2017 JBoss Inc | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import { ViewCanvasEventType } from "@dataservices/virtualization/view-editor/view-canvas/event/view-canvas-event-type.enum"; | ||
|
||
export class ViewCanvasEvent { | ||
|
||
private readonly _args: any[] = []; | ||
private readonly _type: ViewCanvasEventType; | ||
|
||
/** | ||
* Factory method to create an event. | ||
* | ||
* @param {ViewCanvasEventType} type the type of event | ||
* @param {object[]} args the optional args | ||
* @returns {ViewCanvasEvent} the created event | ||
*/ | ||
public static create( type: ViewCanvasEventType, | ||
args?: any[] ): ViewCanvasEvent { | ||
return new ViewCanvasEvent( type, args ); | ||
} | ||
|
||
private constructor( type: ViewCanvasEventType, | ||
args?: any[] ) { | ||
this._type = type; | ||
|
||
if ( args ) { | ||
this._args = args; | ||
} | ||
} | ||
|
||
/** | ||
* @returns {any[]} the optional args to the event (never `null` but can be empty) | ||
*/ | ||
public get args(): any[] { | ||
return this._args; | ||
} | ||
|
||
/** | ||
* @returns {string} a string representation of the event | ||
*/ | ||
public toString(): string { | ||
let text = `event type: ${this.type}, args: `; | ||
let firstTime = true; | ||
|
||
if ( this.args && this.args.length !== 0 ) { | ||
for ( const arg of this.args ) { | ||
if ( firstTime ) { | ||
firstTime = false; | ||
} else { | ||
text += ", "; | ||
} | ||
|
||
text += arg; | ||
} | ||
} | ||
|
||
return text; | ||
} | ||
|
||
/** | ||
* @returns {ViewCanvasEventType} the event type | ||
*/ | ||
public get type(): ViewCanvasEventType { | ||
return this._type; | ||
} | ||
|
||
/** | ||
* @returns {boolean} `true` if the type is `ViewCanvasEventType.CANVAS_SELECTION_CHANGED` | ||
*/ | ||
public typeIsCanvasSelectionChanged(): boolean { | ||
return this.type === ViewCanvasEventType.CANVAS_SELECTION_CHANGED; | ||
} | ||
} |
Oops, something went wrong.