@wcardinal/wcardinal-ui 0.258.0 → 0.259.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/types/wcardinal/ui/d-command-clear.d.ts +3 -3
- package/dist/types/wcardinal/ui/d-command-create.d.ts +3 -3
- package/dist/types/wcardinal/ui/d-command-save-as.d.ts +3 -3
- package/dist/types/wcardinal/ui/d-command-save.d.ts +3 -3
- package/dist/types/wcardinal/ui/d-command.d.ts +3 -3
- package/dist/types/wcardinal/ui/d-controller-command-impl.d.ts +9 -12
- package/dist/types/wcardinal/ui/index.d.ts +0 -3
- package/dist/wcardinal/ui/d-command-clear.js.map +1 -1
- package/dist/wcardinal/ui/d-command-create.js.map +1 -1
- package/dist/wcardinal/ui/d-command-save-as.js +2 -1
- package/dist/wcardinal/ui/d-command-save-as.js.map +1 -1
- package/dist/wcardinal/ui/d-command-save.js +2 -1
- package/dist/wcardinal/ui/d-command-save.js.map +1 -1
- package/dist/wcardinal/ui/d-command.js.map +1 -1
- package/dist/wcardinal/ui/d-controller-command-impl.js +68 -147
- package/dist/wcardinal/ui/d-controller-command-impl.js.map +1 -1
- package/dist/wcardinal/ui/index.js +0 -3
- package/dist/wcardinal/ui/index.js.map +1 -1
- package/dist/wcardinal-ui-theme-dark.js +1 -1
- package/dist/wcardinal-ui-theme-dark.min.js +1 -1
- package/dist/wcardinal-ui-theme-white.js +1 -1
- package/dist/wcardinal-ui-theme-white.min.js +1 -1
- package/dist/wcardinal-ui.cjs.js +73 -226
- package/dist/wcardinal-ui.js +73 -226
- package/dist/wcardinal-ui.min.js +2 -2
- package/dist/wcardinal-ui.min.js.map +1 -1
- package/package.json +1 -1
- package/dist/types/wcardinal/ui/d-command-delete.d.ts +0 -9
- package/dist/types/wcardinal/ui/d-command-redo.d.ts +0 -9
- package/dist/types/wcardinal/ui/d-command-undo.d.ts +0 -9
- package/dist/wcardinal/ui/d-command-delete.js +0 -28
- package/dist/wcardinal/ui/d-command-delete.js.map +0 -1
- package/dist/wcardinal/ui/d-command-redo.js +0 -27
- package/dist/wcardinal/ui/d-command-redo.js.map +0 -1
- package/dist/wcardinal/ui/d-command-undo.js +0 -27
- package/dist/wcardinal/ui/d-command-undo.js.map +0 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { DCommand } from "./d-command";
|
|
2
2
|
import { DCommandFlag } from "./d-command-flag";
|
|
3
3
|
export declare class DCommandClear implements DCommand {
|
|
4
|
-
execute():
|
|
5
|
-
redo():
|
|
6
|
-
undo():
|
|
4
|
+
execute(): boolean;
|
|
5
|
+
redo(): boolean;
|
|
6
|
+
undo(): boolean;
|
|
7
7
|
destroy(): void;
|
|
8
8
|
getFlag(): DCommandFlag;
|
|
9
9
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { DCommand } from "./d-command";
|
|
2
2
|
import { DCommandFlag } from "./d-command-flag";
|
|
3
3
|
export declare abstract class DCommandCreate implements DCommand {
|
|
4
|
-
abstract execute():
|
|
5
|
-
redo():
|
|
6
|
-
undo():
|
|
4
|
+
abstract execute(): boolean;
|
|
5
|
+
redo(): boolean;
|
|
6
|
+
undo(): boolean;
|
|
7
7
|
destroy(): void;
|
|
8
8
|
getFlag(): DCommandFlag;
|
|
9
9
|
}
|
|
@@ -4,9 +4,9 @@ export declare class DCommandSaveAs implements DCommand {
|
|
|
4
4
|
protected _name: string;
|
|
5
5
|
constructor(name: string);
|
|
6
6
|
get name(): string;
|
|
7
|
-
execute():
|
|
8
|
-
redo():
|
|
9
|
-
undo():
|
|
7
|
+
execute(): boolean;
|
|
8
|
+
redo(): boolean;
|
|
9
|
+
undo(): boolean;
|
|
10
10
|
destroy(): void;
|
|
11
11
|
getFlag(): DCommandFlag;
|
|
12
12
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { DCommand } from "./d-command";
|
|
2
2
|
import { DCommandFlag } from "./d-command-flag";
|
|
3
3
|
export declare class DCommandSave implements DCommand {
|
|
4
|
-
execute():
|
|
5
|
-
redo():
|
|
6
|
-
undo():
|
|
4
|
+
execute(): boolean;
|
|
5
|
+
redo(): boolean;
|
|
6
|
+
undo(): boolean;
|
|
7
7
|
destroy(): void;
|
|
8
8
|
getFlag(): DCommandFlag;
|
|
9
9
|
}
|
|
@@ -3,9 +3,9 @@ export interface DCommand {
|
|
|
3
3
|
/**
|
|
4
4
|
* Called to executed this command.
|
|
5
5
|
*/
|
|
6
|
-
execute():
|
|
7
|
-
redo():
|
|
8
|
-
undo():
|
|
6
|
+
execute(): boolean;
|
|
7
|
+
redo(): boolean;
|
|
8
|
+
undo(): boolean;
|
|
9
9
|
destroy(): void;
|
|
10
10
|
getFlag(): DCommandFlag;
|
|
11
11
|
}
|
|
@@ -1,30 +1,27 @@
|
|
|
1
1
|
import { utils } from "pixi.js";
|
|
2
2
|
import { DCommand } from "./d-command";
|
|
3
|
-
import { DCommandRedo } from "./d-command-redo";
|
|
4
|
-
import { DCommandUndo } from "./d-command-undo";
|
|
5
3
|
import { DControllerCommand } from "./d-controller-command";
|
|
6
4
|
export declare class DControllerCommandImpl extends utils.EventEmitter implements DControllerCommand {
|
|
7
5
|
protected _position: number;
|
|
8
6
|
protected _done: DCommand[];
|
|
9
|
-
protected _waiting: DCommand[];
|
|
10
|
-
protected _executing: Promise<void> | null;
|
|
11
7
|
constructor();
|
|
12
8
|
last(): DCommand | null;
|
|
13
9
|
push(command: DCommand): void;
|
|
14
|
-
next(): void;
|
|
15
|
-
protected executeUndo(command: DCommandUndo): void;
|
|
16
|
-
protected executeRedo(command: DCommandRedo): void;
|
|
17
10
|
protected execute(command: DCommand): void;
|
|
18
|
-
protected cleanup(): void;
|
|
19
|
-
protected remove(size: number): boolean;
|
|
20
11
|
protected onSuccess(command: DCommand): void;
|
|
21
|
-
protected onSuccessUndo(undoed: DCommand): void;
|
|
22
|
-
protected onSuccessRedo(redoed: DCommand): void;
|
|
23
12
|
protected onFail(command: DCommand): void;
|
|
13
|
+
protected cleanup(): void;
|
|
14
|
+
protected remove(size: number): boolean;
|
|
24
15
|
size(): number;
|
|
25
16
|
clear(): void;
|
|
26
17
|
redo(): void;
|
|
27
|
-
|
|
18
|
+
protected doRedo(): void;
|
|
19
|
+
protected onRedoSuccess(redoed: DCommand): void;
|
|
20
|
+
protected onRedoFail(command: DCommand): void;
|
|
28
21
|
isRedoable(): boolean;
|
|
22
|
+
undo(): void;
|
|
23
|
+
protected doUndo(): void;
|
|
24
|
+
protected onUndoSuccess(undoed: DCommand): void;
|
|
25
|
+
protected onUndoFail(command: DCommand): void;
|
|
29
26
|
isUndoable(): boolean;
|
|
30
27
|
}
|
|
@@ -167,12 +167,9 @@ export * from "./d-color-gradient-point-observable";
|
|
|
167
167
|
export * from "./d-color-gradient";
|
|
168
168
|
export * from "./d-command-clear";
|
|
169
169
|
export * from "./d-command-create";
|
|
170
|
-
export * from "./d-command-delete";
|
|
171
170
|
export * from "./d-command-flag";
|
|
172
|
-
export * from "./d-command-redo";
|
|
173
171
|
export * from "./d-command-save-as";
|
|
174
172
|
export * from "./d-command-save";
|
|
175
|
-
export * from "./d-command-undo";
|
|
176
173
|
export * from "./d-command";
|
|
177
174
|
export * from "./d-content";
|
|
178
175
|
export * from "./d-controller-command-impl";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"d-command-clear.js","sourceRoot":"","sources":["../../../src/main/typescript/wcardinal/ui/d-command-clear.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEhD;IAAA;IAoBA,CAAC;IAnBA,+BAAO,GAAP;QACC,OAAO,IAAI,CAAC;IACb,CAAC;IAED,4BAAI,GAAJ;QACC,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC5C,CAAC;IAED,4BAAI,GAAJ;QACC,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC5C,CAAC;IAED,+BAAO,GAAP;QACC,aAAa;IACd,CAAC;IAED,+BAAO,GAAP;QACC,OAAO,YAAY,CAAC,UAAU,GAAG,YAAY,CAAC,KAAK,CAAC;IACrD,CAAC;IACF,oBAAC;AAAD,CAAC,AApBD,IAoBC","sourcesContent":["/*\n * Copyright (C) 2019 Toshiba Corporation\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { DCommand } from \"./d-command\";\nimport { DCommandFlag } from \"./d-command-flag\";\n\nexport class DCommandClear implements DCommand {\n\texecute():
|
|
1
|
+
{"version":3,"file":"d-command-clear.js","sourceRoot":"","sources":["../../../src/main/typescript/wcardinal/ui/d-command-clear.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEhD;IAAA;IAoBA,CAAC;IAnBA,+BAAO,GAAP;QACC,OAAO,IAAI,CAAC;IACb,CAAC;IAED,4BAAI,GAAJ;QACC,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC5C,CAAC;IAED,4BAAI,GAAJ;QACC,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC5C,CAAC;IAED,+BAAO,GAAP;QACC,aAAa;IACd,CAAC;IAED,+BAAO,GAAP;QACC,OAAO,YAAY,CAAC,UAAU,GAAG,YAAY,CAAC,KAAK,CAAC;IACrD,CAAC;IACF,oBAAC;AAAD,CAAC,AApBD,IAoBC","sourcesContent":["/*\n * Copyright (C) 2019 Toshiba Corporation\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { DCommand } from \"./d-command\";\nimport { DCommandFlag } from \"./d-command-flag\";\n\nexport class DCommandClear implements DCommand {\n\texecute(): boolean {\n\t\treturn true;\n\t}\n\n\tredo(): boolean {\n\t\tthrow new Error(\"Method not implemented.\");\n\t}\n\n\tundo(): boolean {\n\t\tthrow new Error(\"Method not implemented.\");\n\t}\n\n\tdestroy(): void {\n\t\t// DO NOTHING\n\t}\n\n\tgetFlag(): DCommandFlag {\n\t\treturn DCommandFlag.UNSTORABLE | DCommandFlag.CLEAR;\n\t}\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"d-command-create.js","sourceRoot":"","sources":["../../../src/main/typescript/wcardinal/ui/d-command-create.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEhD;IAAA;IAkBA,CAAC;IAfA,6BAAI,GAAJ;QACC,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC5C,CAAC;IAED,6BAAI,GAAJ;QACC,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC5C,CAAC;IAED,gCAAO,GAAP;QACC,aAAa;IACd,CAAC;IAED,gCAAO,GAAP;QACC,OAAO,YAAY,CAAC,UAAU,GAAG,YAAY,CAAC,KAAK,CAAC;IACrD,CAAC;IACF,qBAAC;AAAD,CAAC,AAlBD,IAkBC","sourcesContent":["/*\n * Copyright (C) 2019 Toshiba Corporation\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { DCommand } from \"./d-command\";\nimport { DCommandFlag } from \"./d-command-flag\";\n\nexport abstract class DCommandCreate implements DCommand {\n\tabstract execute():
|
|
1
|
+
{"version":3,"file":"d-command-create.js","sourceRoot":"","sources":["../../../src/main/typescript/wcardinal/ui/d-command-create.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEhD;IAAA;IAkBA,CAAC;IAfA,6BAAI,GAAJ;QACC,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC5C,CAAC;IAED,6BAAI,GAAJ;QACC,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC5C,CAAC;IAED,gCAAO,GAAP;QACC,aAAa;IACd,CAAC;IAED,gCAAO,GAAP;QACC,OAAO,YAAY,CAAC,UAAU,GAAG,YAAY,CAAC,KAAK,CAAC;IACrD,CAAC;IACF,qBAAC;AAAD,CAAC,AAlBD,IAkBC","sourcesContent":["/*\n * Copyright (C) 2019 Toshiba Corporation\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { DCommand } from \"./d-command\";\nimport { DCommandFlag } from \"./d-command-flag\";\n\nexport abstract class DCommandCreate implements DCommand {\n\tabstract execute(): boolean;\n\n\tredo(): boolean {\n\t\tthrow new Error(\"Method not implemented.\");\n\t}\n\n\tundo(): boolean {\n\t\tthrow new Error(\"Method not implemented.\");\n\t}\n\n\tdestroy(): void {\n\t\t// DO NOTHING\n\t}\n\n\tgetFlag(): DCommandFlag {\n\t\treturn DCommandFlag.UNSTORABLE | DCommandFlag.CLEAR;\n\t}\n}\n"]}
|
|
@@ -16,7 +16,8 @@ var DCommandSaveAs = /** @class */ (function () {
|
|
|
16
16
|
configurable: true
|
|
17
17
|
});
|
|
18
18
|
DCommandSaveAs.prototype.execute = function () {
|
|
19
|
-
|
|
19
|
+
DControllers.getDocumentController().saveAs(this._name);
|
|
20
|
+
return true;
|
|
20
21
|
};
|
|
21
22
|
DCommandSaveAs.prototype.redo = function () {
|
|
22
23
|
return true;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"d-command-save-as.js","sourceRoot":"","sources":["../../../src/main/typescript/wcardinal/ui/d-command-save-as.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C;IAGC,wBAAY,IAAY;QACvB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;IACnB,CAAC;IAED,sBAAI,gCAAI;aAAR;YACC,OAAO,IAAI,CAAC,KAAK,CAAC;QACnB,CAAC;;;OAAA;IAED,gCAAO,GAAP;QACC,
|
|
1
|
+
{"version":3,"file":"d-command-save-as.js","sourceRoot":"","sources":["../../../src/main/typescript/wcardinal/ui/d-command-save-as.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C;IAGC,wBAAY,IAAY;QACvB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;IACnB,CAAC;IAED,sBAAI,gCAAI;aAAR;YACC,OAAO,IAAI,CAAC,KAAK,CAAC;QACnB,CAAC;;;OAAA;IAED,gCAAO,GAAP;QACC,YAAY,CAAC,qBAAqB,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACxD,OAAO,IAAI,CAAC;IACb,CAAC;IAED,6BAAI,GAAJ;QACC,OAAO,IAAI,CAAC;IACb,CAAC;IAED,6BAAI,GAAJ;QACC,OAAO,IAAI,CAAC;IACb,CAAC;IAED,gCAAO,GAAP;QACC,aAAa;IACd,CAAC;IAED,gCAAO,GAAP;QACC,OAAO,YAAY,CAAC,UAAU,CAAC;IAChC,CAAC;IACF,qBAAC;AAAD,CAAC,AA/BD,IA+BC","sourcesContent":["/*\n * Copyright (C) 2019 Toshiba Corporation\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { DCommand } from \"./d-command\";\nimport { DCommandFlag } from \"./d-command-flag\";\nimport { DControllers } from \"./d-controllers\";\n\nexport class DCommandSaveAs implements DCommand {\n\tprotected _name: string;\n\n\tconstructor(name: string) {\n\t\tthis._name = name;\n\t}\n\n\tget name(): string {\n\t\treturn this._name;\n\t}\n\n\texecute(): boolean {\n\t\tDControllers.getDocumentController().saveAs(this._name);\n\t\treturn true;\n\t}\n\n\tredo(): boolean {\n\t\treturn true;\n\t}\n\n\tundo(): boolean {\n\t\treturn true;\n\t}\n\n\tdestroy(): void {\n\t\t// DO NOTHING\n\t}\n\n\tgetFlag(): DCommandFlag {\n\t\treturn DCommandFlag.UNSTORABLE;\n\t}\n}\n"]}
|
|
@@ -8,7 +8,8 @@ var DCommandSave = /** @class */ (function () {
|
|
|
8
8
|
function DCommandSave() {
|
|
9
9
|
}
|
|
10
10
|
DCommandSave.prototype.execute = function () {
|
|
11
|
-
|
|
11
|
+
DControllers.getDocumentController().save();
|
|
12
|
+
return true;
|
|
12
13
|
};
|
|
13
14
|
DCommandSave.prototype.redo = function () {
|
|
14
15
|
return true;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"d-command-save.js","sourceRoot":"","sources":["../../../src/main/typescript/wcardinal/ui/d-command-save.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C;IAAA;
|
|
1
|
+
{"version":3,"file":"d-command-save.js","sourceRoot":"","sources":["../../../src/main/typescript/wcardinal/ui/d-command-save.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C;IAAA;IAqBA,CAAC;IApBA,8BAAO,GAAP;QACC,YAAY,CAAC,qBAAqB,EAAE,CAAC,IAAI,EAAE,CAAC;QAC5C,OAAO,IAAI,CAAC;IACb,CAAC;IAED,2BAAI,GAAJ;QACC,OAAO,IAAI,CAAC;IACb,CAAC;IAED,2BAAI,GAAJ;QACC,OAAO,IAAI,CAAC;IACb,CAAC;IAED,8BAAO,GAAP;QACC,aAAa;IACd,CAAC;IAED,8BAAO,GAAP;QACC,OAAO,YAAY,CAAC,UAAU,CAAC;IAChC,CAAC;IACF,mBAAC;AAAD,CAAC,AArBD,IAqBC","sourcesContent":["/*\n * Copyright (C) 2019 Toshiba Corporation\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { DCommand } from \"./d-command\";\nimport { DCommandFlag } from \"./d-command-flag\";\nimport { DControllers } from \"./d-controllers\";\n\nexport class DCommandSave implements DCommand {\n\texecute(): boolean {\n\t\tDControllers.getDocumentController().save();\n\t\treturn true;\n\t}\n\n\tredo(): boolean {\n\t\treturn true;\n\t}\n\n\tundo(): boolean {\n\t\treturn true;\n\t}\n\n\tdestroy(): void {\n\t\t// DO NOTHING\n\t}\n\n\tgetFlag(): DCommandFlag {\n\t\treturn DCommandFlag.UNSTORABLE;\n\t}\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"d-command.js","sourceRoot":"","sources":["../../../src/main/typescript/wcardinal/ui/d-command.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/*\n * Copyright (C) 2019 Toshiba Corporation\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { DCommandFlag } from \"./d-command-flag\";\n\nexport interface DCommand {\n\t/**\n\t * Called to executed this command.\n\t */\n\texecute():
|
|
1
|
+
{"version":3,"file":"d-command.js","sourceRoot":"","sources":["../../../src/main/typescript/wcardinal/ui/d-command.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/*\n * Copyright (C) 2019 Toshiba Corporation\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { DCommandFlag } from \"./d-command-flag\";\n\nexport interface DCommand {\n\t/**\n\t * Called to executed this command.\n\t */\n\texecute(): boolean;\n\n\tredo(): boolean;\n\tundo(): boolean;\n\tdestroy(): void;\n\tgetFlag(): DCommandFlag;\n}\n"]}
|
|
@@ -6,8 +6,6 @@ import { __extends } from "tslib";
|
|
|
6
6
|
import { utils } from "pixi.js";
|
|
7
7
|
import { DCommandClear } from "./d-command-clear";
|
|
8
8
|
import { DCommandFlag } from "./d-command-flag";
|
|
9
|
-
import { DCommandRedo } from "./d-command-redo";
|
|
10
|
-
import { DCommandUndo } from "./d-command-undo";
|
|
11
9
|
var isCommandStorable = function (command) {
|
|
12
10
|
return !(command.getFlag() & DCommandFlag.UNSTORABLE);
|
|
13
11
|
};
|
|
@@ -23,108 +21,22 @@ var DControllerCommandImpl = /** @class */ (function (_super) {
|
|
|
23
21
|
var _this = _super.call(this) || this;
|
|
24
22
|
_this._position = 0;
|
|
25
23
|
_this._done = [];
|
|
26
|
-
_this._waiting = [];
|
|
27
|
-
_this._executing = null;
|
|
28
24
|
return _this;
|
|
29
25
|
}
|
|
30
26
|
DControllerCommandImpl.prototype.last = function () {
|
|
31
27
|
var done = this._done;
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
if (0 < done.length) {
|
|
35
|
-
return done[done.length - 1];
|
|
36
|
-
}
|
|
37
|
-
else {
|
|
38
|
-
return null;
|
|
39
|
-
}
|
|
28
|
+
if (0 < done.length) {
|
|
29
|
+
return done[done.length - 1];
|
|
40
30
|
}
|
|
41
31
|
else {
|
|
42
|
-
return
|
|
32
|
+
return null;
|
|
43
33
|
}
|
|
44
34
|
};
|
|
45
35
|
DControllerCommandImpl.prototype.push = function (command) {
|
|
46
|
-
this.
|
|
47
|
-
this._waiting.push(command);
|
|
48
|
-
this.next();
|
|
49
|
-
};
|
|
50
|
-
DControllerCommandImpl.prototype.next = function () {
|
|
51
|
-
if (this._executing != null) {
|
|
52
|
-
// Still executing a command.
|
|
53
|
-
// So do nothing.
|
|
54
|
-
return;
|
|
55
|
-
}
|
|
56
|
-
var waiting = this._waiting;
|
|
57
|
-
if (waiting.length <= 0) {
|
|
58
|
-
// There is no waiting commands.
|
|
59
|
-
// So do nothing.
|
|
60
|
-
return;
|
|
61
|
-
}
|
|
62
|
-
var command = waiting.shift();
|
|
63
|
-
if (command == null) {
|
|
64
|
-
// There is no waiting commands.
|
|
65
|
-
// So do nothing.
|
|
66
|
-
return;
|
|
67
|
-
}
|
|
68
|
-
if (command instanceof DCommandUndo) {
|
|
69
|
-
this.executeUndo(command);
|
|
70
|
-
}
|
|
71
|
-
else if (command instanceof DCommandRedo) {
|
|
72
|
-
this.executeRedo(command);
|
|
73
|
-
}
|
|
74
|
-
else {
|
|
75
|
-
this.execute(command);
|
|
76
|
-
}
|
|
77
|
-
};
|
|
78
|
-
DControllerCommandImpl.prototype.executeUndo = function (command) {
|
|
79
|
-
var _this = this;
|
|
80
|
-
var done = this._done;
|
|
81
|
-
if (this._position < done.length) {
|
|
82
|
-
var current_1 = done[done.length - 1 - this._position];
|
|
83
|
-
this._position += 1;
|
|
84
|
-
this.emit("change", this);
|
|
85
|
-
this.emit("undoing", current_1, this);
|
|
86
|
-
var result = current_1.undo();
|
|
87
|
-
if (result === true) {
|
|
88
|
-
this.onSuccessUndo(current_1);
|
|
89
|
-
}
|
|
90
|
-
else if (result === false) {
|
|
91
|
-
this.onFail(command);
|
|
92
|
-
}
|
|
93
|
-
else {
|
|
94
|
-
this._executing = result.then(function () {
|
|
95
|
-
_this.onSuccessUndo(current_1);
|
|
96
|
-
}, function () {
|
|
97
|
-
_this.onFail(command);
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
};
|
|
102
|
-
DControllerCommandImpl.prototype.executeRedo = function (command) {
|
|
103
|
-
var _this = this;
|
|
104
|
-
var done = this._done;
|
|
105
|
-
if (0 < this._position) {
|
|
106
|
-
var current_2 = done[done.length - this._position];
|
|
107
|
-
this._position -= 1;
|
|
108
|
-
this.emit("change", this);
|
|
109
|
-
this.emit("redoing", current_2, this);
|
|
110
|
-
var result = current_2.redo();
|
|
111
|
-
if (result === true) {
|
|
112
|
-
this.onSuccessRedo(current_2);
|
|
113
|
-
}
|
|
114
|
-
else if (result === false) {
|
|
115
|
-
this.onFail(command);
|
|
116
|
-
}
|
|
117
|
-
else {
|
|
118
|
-
this._executing = result.then(function () {
|
|
119
|
-
_this.onSuccessRedo(current_2);
|
|
120
|
-
}, function () {
|
|
121
|
-
_this.onFail(command);
|
|
122
|
-
});
|
|
123
|
-
}
|
|
124
|
-
}
|
|
36
|
+
this.execute(command);
|
|
125
37
|
};
|
|
126
38
|
DControllerCommandImpl.prototype.execute = function (command) {
|
|
127
|
-
|
|
39
|
+
this.emit("executing", command, this);
|
|
128
40
|
var isClear = isCommandClear(command);
|
|
129
41
|
var isStorable = isCommandStorable(command);
|
|
130
42
|
if (isClear || isStorable) {
|
|
@@ -132,25 +44,28 @@ var DControllerCommandImpl = /** @class */ (function (_super) {
|
|
|
132
44
|
if (0 < size) {
|
|
133
45
|
this.remove(size);
|
|
134
46
|
this._position = 0;
|
|
135
|
-
this.emit("change", this);
|
|
136
47
|
}
|
|
137
48
|
this.cleanup();
|
|
138
49
|
}
|
|
139
|
-
this.emit("executing", command, this);
|
|
140
50
|
var result = command.execute();
|
|
141
51
|
if (result === true) {
|
|
142
52
|
this.onSuccess(command);
|
|
143
53
|
}
|
|
144
|
-
else
|
|
54
|
+
else {
|
|
145
55
|
this.onFail(command);
|
|
146
56
|
}
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
57
|
+
};
|
|
58
|
+
DControllerCommandImpl.prototype.onSuccess = function (command) {
|
|
59
|
+
if (isCommandStorable(command)) {
|
|
60
|
+
this._done.push(command);
|
|
61
|
+
if (!isCommandClean(command)) {
|
|
62
|
+
this.emit("dirty", this);
|
|
63
|
+
}
|
|
153
64
|
}
|
|
65
|
+
this.emit("executed", command, this);
|
|
66
|
+
};
|
|
67
|
+
DControllerCommandImpl.prototype.onFail = function (command) {
|
|
68
|
+
command.destroy();
|
|
154
69
|
};
|
|
155
70
|
DControllerCommandImpl.prototype.cleanup = function () {
|
|
156
71
|
var done = this._done;
|
|
@@ -177,69 +92,75 @@ var DControllerCommandImpl = /** @class */ (function (_super) {
|
|
|
177
92
|
}
|
|
178
93
|
return false;
|
|
179
94
|
};
|
|
180
|
-
DControllerCommandImpl.prototype.
|
|
181
|
-
this.
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
95
|
+
DControllerCommandImpl.prototype.size = function () {
|
|
96
|
+
return this._done.length;
|
|
97
|
+
};
|
|
98
|
+
DControllerCommandImpl.prototype.clear = function () {
|
|
99
|
+
this.push(new DCommandClear());
|
|
100
|
+
};
|
|
101
|
+
DControllerCommandImpl.prototype.redo = function () {
|
|
102
|
+
if (this.isRedoable()) {
|
|
103
|
+
this.doRedo();
|
|
187
104
|
}
|
|
188
|
-
this.emit("change", this);
|
|
189
|
-
this.emit("executed", command, this);
|
|
190
|
-
this.next();
|
|
191
105
|
};
|
|
192
|
-
DControllerCommandImpl.prototype.
|
|
193
|
-
|
|
194
|
-
if (
|
|
195
|
-
|
|
106
|
+
DControllerCommandImpl.prototype.doRedo = function () {
|
|
107
|
+
var done = this._done;
|
|
108
|
+
if (0 < this._position) {
|
|
109
|
+
var current = done[done.length - this._position];
|
|
110
|
+
this._position -= 1;
|
|
111
|
+
this.emit("redoing", current, this);
|
|
112
|
+
var result = current.redo();
|
|
113
|
+
if (result === true) {
|
|
114
|
+
this.onRedoSuccess(current);
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
this.onRedoFail(current);
|
|
118
|
+
}
|
|
196
119
|
}
|
|
197
|
-
this.emit("change", this);
|
|
198
|
-
this.emit("undoed", undoed, this);
|
|
199
|
-
this.next();
|
|
200
120
|
};
|
|
201
|
-
DControllerCommandImpl.prototype.
|
|
202
|
-
this._executing = null;
|
|
121
|
+
DControllerCommandImpl.prototype.onRedoSuccess = function (redoed) {
|
|
203
122
|
if (!isCommandClean(redoed)) {
|
|
204
123
|
this.emit("dirty", this);
|
|
205
124
|
}
|
|
206
|
-
this.emit("change", this);
|
|
207
125
|
this.emit("redoed", redoed, this);
|
|
208
|
-
this.next();
|
|
209
126
|
};
|
|
210
|
-
DControllerCommandImpl.prototype.
|
|
211
|
-
|
|
212
|
-
var waiting = this._waiting;
|
|
213
|
-
command.destroy();
|
|
214
|
-
for (var i = 0, imax = waiting.length; i < imax; ++i) {
|
|
215
|
-
waiting[i].destroy();
|
|
216
|
-
}
|
|
217
|
-
waiting.length = 0;
|
|
218
|
-
this.emit("change", this);
|
|
127
|
+
DControllerCommandImpl.prototype.onRedoFail = function (command) {
|
|
128
|
+
// DO NOTHING
|
|
219
129
|
};
|
|
220
|
-
DControllerCommandImpl.prototype.
|
|
221
|
-
return this.
|
|
130
|
+
DControllerCommandImpl.prototype.isRedoable = function () {
|
|
131
|
+
return 0 < this._position;
|
|
222
132
|
};
|
|
223
|
-
DControllerCommandImpl.prototype.
|
|
224
|
-
this.
|
|
133
|
+
DControllerCommandImpl.prototype.undo = function () {
|
|
134
|
+
if (this.isUndoable()) {
|
|
135
|
+
this.doUndo();
|
|
136
|
+
}
|
|
225
137
|
};
|
|
226
|
-
DControllerCommandImpl.prototype.
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
this.
|
|
138
|
+
DControllerCommandImpl.prototype.doUndo = function () {
|
|
139
|
+
var done = this._done;
|
|
140
|
+
if (this._position < done.length) {
|
|
141
|
+
var current = done[done.length - 1 - this._position];
|
|
142
|
+
this._position += 1;
|
|
143
|
+
this.emit("undoing", current, this);
|
|
144
|
+
var result = current.undo();
|
|
145
|
+
if (result === true) {
|
|
146
|
+
this.onUndoSuccess(current);
|
|
147
|
+
}
|
|
148
|
+
else {
|
|
149
|
+
this.onUndoFail(current);
|
|
150
|
+
}
|
|
230
151
|
}
|
|
231
152
|
};
|
|
232
|
-
DControllerCommandImpl.prototype.
|
|
233
|
-
if (
|
|
234
|
-
this.
|
|
235
|
-
this.next();
|
|
153
|
+
DControllerCommandImpl.prototype.onUndoSuccess = function (undoed) {
|
|
154
|
+
if (!isCommandClean(undoed)) {
|
|
155
|
+
this.emit("dirty", this);
|
|
236
156
|
}
|
|
157
|
+
this.emit("undoed", undoed, this);
|
|
237
158
|
};
|
|
238
|
-
DControllerCommandImpl.prototype.
|
|
239
|
-
|
|
159
|
+
DControllerCommandImpl.prototype.onUndoFail = function (command) {
|
|
160
|
+
// DO NOTHING
|
|
240
161
|
};
|
|
241
162
|
DControllerCommandImpl.prototype.isUndoable = function () {
|
|
242
|
-
return this._position < this._done.length
|
|
163
|
+
return this._position < this._done.length;
|
|
243
164
|
};
|
|
244
165
|
return DControllerCommandImpl;
|
|
245
166
|
}(utils.EventEmitter));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"d-controller-command-impl.js","sourceRoot":"","sources":["../../../src/main/typescript/wcardinal/ui/d-controller-command-impl.ts"],"names":[],"mappings":"AAAA;;;GAGG;;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAGhD,IAAM,iBAAiB,GAAG,UAAC,OAAiB;IAC3C,OAAO,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE,GAAG,YAAY,CAAC,UAAU,CAAC,CAAC;AACvD,CAAC,CAAC;AAEF,IAAM,cAAc,GAAG,UAAC,OAAiB;IACxC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC;AACnD,CAAC,CAAC;AAEF,IAAM,cAAc,GAAG,UAAC,OAAiB;IACxC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC;AACnD,CAAC,CAAC;AAEF;IAA4C,0CAAkB;IAM7D;QAAA,YACC,iBAAO,SAMP;QAJA,KAAI,CAAC,SAAS,GAAG,CAAC,CAAC;QACnB,KAAI,CAAC,KAAK,GAAG,EAAE,CAAC;QAChB,KAAI,CAAC,QAAQ,GAAG,EAAE,CAAC;QACnB,KAAI,CAAC,UAAU,GAAG,IAAI,CAAC;;IACxB,CAAC;IAED,qCAAI,GAAJ;QACC,IAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC;QACxB,IAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC;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AAO,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,IAAI,IAAI,CAAC,UAAU,IAAI,IAAI,CAAC;IACtE,CAAC;IACF,6BAAC;AAAD,CAAC,AAvPD,CAA4C,KAAK,CAAC,YAAY,GAuP7D","sourcesContent":["/*\n * Copyright (C) 2019 Toshiba Corporation\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { utils } from \"pixi.js\";\nimport { DCommand } from \"./d-command\";\nimport { DCommandClear } from \"./d-command-clear\";\nimport { DCommandFlag } from \"./d-command-flag\";\nimport { DCommandRedo } from \"./d-command-redo\";\nimport { DCommandUndo } from \"./d-command-undo\";\nimport { DControllerCommand } from \"./d-controller-command\";\n\nconst isCommandStorable = (command: DCommand): boolean => {\n\treturn !(command.getFlag() & DCommandFlag.UNSTORABLE);\n};\n\nconst isCommandClear = (command: DCommand): boolean => {\n\treturn !!(command.getFlag() & DCommandFlag.CLEAR);\n};\n\nconst isCommandClean = (command: DCommand): boolean => {\n\treturn !!(command.getFlag() & DCommandFlag.CLEAN);\n};\n\nexport class DControllerCommandImpl extends utils.EventEmitter implements DControllerCommand {\n\tprotected _position: number;\n\tprotected _done: DCommand[];\n\tprotected _waiting: DCommand[];\n\tprotected _executing: Promise<void> | null;\n\n\tconstructor() {\n\t\tsuper();\n\n\t\tthis._position = 0;\n\t\tthis._done = [];\n\t\tthis._waiting = [];\n\t\tthis._executing = null;\n\t}\n\n\tlast(): DCommand | null {\n\t\tconst done = this._done;\n\t\tconst waiting = this._waiting;\n\n\t\tif (waiting.length <= 0) {\n\t\t\tif (0 < done.length) {\n\t\t\t\treturn done[done.length - 1];\n\t\t\t} else {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t} else {\n\t\t\treturn waiting[waiting.length - 1];\n\t\t}\n\t}\n\n\tpush(command: DCommand): void {\n\t\tthis.emit(\"push\", command, this);\n\t\tthis._waiting.push(command);\n\t\tthis.next();\n\t}\n\n\tnext(): void {\n\t\tif (this._executing != null) {\n\t\t\t// Still executing a command.\n\t\t\t// So do nothing.\n\t\t\treturn;\n\t\t}\n\n\t\tconst waiting = this._waiting;\n\t\tif (waiting.length <= 0) {\n\t\t\t// There is no waiting commands.\n\t\t\t// So do nothing.\n\t\t\treturn;\n\t\t}\n\n\t\tconst command = waiting.shift();\n\t\tif (command == null) {\n\t\t\t// There is no waiting commands.\n\t\t\t// So do nothing.\n\t\t\treturn;\n\t\t}\n\n\t\tif (command instanceof DCommandUndo) {\n\t\t\tthis.executeUndo(command);\n\t\t} else if (command instanceof DCommandRedo) {\n\t\t\tthis.executeRedo(command);\n\t\t} else {\n\t\t\tthis.execute(command);\n\t\t}\n\t}\n\n\tprotected executeUndo(command: DCommandUndo): void {\n\t\tconst done = this._done;\n\t\tif (this._position < done.length) {\n\t\t\tconst current = done[done.length - 1 - this._position];\n\t\t\tthis._position += 1;\n\t\t\tthis.emit(\"change\", this);\n\t\t\tthis.emit(\"undoing\", current, this);\n\t\t\tconst result = current.undo();\n\t\t\tif (result === true) {\n\t\t\t\tthis.onSuccessUndo(current);\n\t\t\t} else if (result === false) {\n\t\t\t\tthis.onFail(command);\n\t\t\t} else {\n\t\t\t\tthis._executing = result.then(\n\t\t\t\t\t() => {\n\t\t\t\t\t\tthis.onSuccessUndo(current);\n\t\t\t\t\t},\n\t\t\t\t\t() => {\n\t\t\t\t\t\tthis.onFail(command);\n\t\t\t\t\t}\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\tprotected executeRedo(command: DCommandRedo): void {\n\t\tconst done = this._done;\n\t\tif (0 < this._position) {\n\t\t\tconst current = done[done.length - this._position];\n\t\t\tthis._position -= 1;\n\t\t\tthis.emit(\"change\", this);\n\t\t\tthis.emit(\"redoing\", current, this);\n\t\t\tconst result = current.redo();\n\t\t\tif (result === true) {\n\t\t\t\tthis.onSuccessRedo(current);\n\t\t\t} else if (result === false) {\n\t\t\t\tthis.onFail(command);\n\t\t\t} else {\n\t\t\t\tthis._executing = result.then(\n\t\t\t\t\t() => {\n\t\t\t\t\t\tthis.onSuccessRedo(current);\n\t\t\t\t\t},\n\t\t\t\t\t() => {\n\t\t\t\t\t\tthis.onFail(command);\n\t\t\t\t\t}\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\tprotected execute(command: DCommand): void {\n\t\tconst isClear = isCommandClear(command);\n\t\tconst isStorable = isCommandStorable(command);\n\t\tif (isClear || isStorable) {\n\t\t\tconst size = isClear ? this._done.length : this._position;\n\t\t\tif (0 < size) {\n\t\t\t\tthis.remove(size);\n\t\t\t\tthis._position = 0;\n\t\t\t\tthis.emit(\"change\", this);\n\t\t\t}\n\t\t\tthis.cleanup();\n\t\t}\n\t\tthis.emit(\"executing\", command, this);\n\t\tconst result = command.execute();\n\t\tif (result === true) {\n\t\t\tthis.onSuccess(command);\n\t\t} else if (result === false) {\n\t\t\tthis.onFail(command);\n\t\t} else {\n\t\t\tthis._executing = result.then(\n\t\t\t\t() => {\n\t\t\t\t\tthis.onSuccess(command);\n\t\t\t\t},\n\t\t\t\t() => {\n\t\t\t\t\tthis.onFail(command);\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\t}\n\n\tprotected cleanup(): void {\n\t\tconst done = this._done;\n\t\tconst size = done.length - 100;\n\t\tif (0 < size) {\n\t\t\tfor (let i = 0; i < size; ++i) {\n\t\t\t\tdone[i].destroy();\n\t\t\t\tdone.shift();\n\t\t\t}\n\t\t}\n\t}\n\n\tprotected remove(size: number): boolean {\n\t\tconst done = this._done;\n\t\tif (0 < size) {\n\t\t\tconst ifrom = Math.max(0, done.length - size);\n\t\t\tsize = done.length - ifrom;\n\t\t\tif (0 < size) {\n\t\t\t\tfor (let i = ifrom, imax = done.length; i < imax; ++i) {\n\t\t\t\t\tdone[i].destroy();\n\t\t\t\t}\n\n\t\t\t\tdone.splice(ifrom, done.length - ifrom);\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t\treturn false;\n\t}\n\n\tprotected onSuccess(command: DCommand): void {\n\t\tthis._executing = null;\n\t\tif (isCommandStorable(command)) {\n\t\t\tthis._done.push(command);\n\t\t\tif (!isCommandClean(command)) {\n\t\t\t\tthis.emit(\"dirty\", this);\n\t\t\t}\n\t\t}\n\t\tthis.emit(\"change\", this);\n\t\tthis.emit(\"executed\", command, this);\n\t\tthis.next();\n\t}\n\n\tprotected onSuccessUndo(undoed: DCommand): void {\n\t\tthis._executing = null;\n\t\tif (!isCommandClean(undoed)) {\n\t\t\tthis.emit(\"dirty\", this);\n\t\t}\n\t\tthis.emit(\"change\", this);\n\t\tthis.emit(\"undoed\", undoed, this);\n\t\tthis.next();\n\t}\n\n\tprotected onSuccessRedo(redoed: DCommand): void {\n\t\tthis._executing = null;\n\t\tif (!isCommandClean(redoed)) {\n\t\t\tthis.emit(\"dirty\", this);\n\t\t}\n\t\tthis.emit(\"change\", this);\n\t\tthis.emit(\"redoed\", redoed, this);\n\t\tthis.next();\n\t}\n\n\tprotected onFail(command: DCommand): void {\n\t\tthis._executing = null;\n\t\tconst waiting = this._waiting;\n\t\tcommand.destroy();\n\t\tfor (let i = 0, imax = waiting.length; i < imax; ++i) {\n\t\t\twaiting[i].destroy();\n\t\t}\n\t\twaiting.length = 0;\n\t\tthis.emit(\"change\", this);\n\t}\n\n\tsize(): number {\n\t\treturn this._done.length;\n\t}\n\n\tclear(): void {\n\t\tthis.push(new DCommandClear());\n\t}\n\n\tredo(): void {\n\t\tif (this.isRedoable()) {\n\t\t\tthis._waiting.push(new DCommandRedo());\n\t\t\tthis.next();\n\t\t}\n\t}\n\n\tundo(): void {\n\t\tif (this.isUndoable()) {\n\t\t\tthis._waiting.push(new DCommandUndo());\n\t\t\tthis.next();\n\t\t}\n\t}\n\n\tisRedoable(): boolean {\n\t\treturn 0 < this._position && this._executing == null;\n\t}\n\n\tisUndoable(): boolean {\n\t\treturn this._position < this._done.length && this._executing == null;\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"d-controller-command-impl.js","sourceRoot":"","sources":["../../../src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,SAAS,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;YACpC,IAAM,MAAM,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;YAC9B,IAAI,MAAM,KAAK,IAAI,EAAE;gBACpB,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;aAC5B;iBAAM;gBACN,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;aACzB;SACD;IACF,CAAC;IAES,8CAAa,GAAvB,UAAwB,MAAgB;QACvC,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,EAAE;YAC5B,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;SACzB;QACD,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC;IACnC,CAAC;IAES,2CAAU,GAApB,UAAqB,OAAiB;QACrC,aAAa;IACd,CAAC;IAED,2CAAU,GAAV;QACC,OAAO,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC;IAC3C,CAAC;IACF,6BAAC;AAAD,CAAC,AApKD,CAA4C,KAAK,CAAC,YAAY,GAoK7D","sourcesContent":["/*\n * Copyright (C) 2019 Toshiba Corporation\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { utils } from \"pixi.js\";\nimport { DCommand } from \"./d-command\";\nimport { DCommandClear } from \"./d-command-clear\";\nimport { DCommandFlag } from \"./d-command-flag\";\nimport { DControllerCommand } from \"./d-controller-command\";\n\nconst isCommandStorable = (command: DCommand): boolean => {\n\treturn !(command.getFlag() & DCommandFlag.UNSTORABLE);\n};\n\nconst isCommandClear = (command: DCommand): boolean => {\n\treturn !!(command.getFlag() & DCommandFlag.CLEAR);\n};\n\nconst isCommandClean = (command: DCommand): boolean => {\n\treturn !!(command.getFlag() & DCommandFlag.CLEAN);\n};\n\nexport class DControllerCommandImpl extends utils.EventEmitter implements DControllerCommand {\n\tprotected _position: number;\n\tprotected _done: DCommand[];\n\n\tconstructor() {\n\t\tsuper();\n\t\tthis._position = 0;\n\t\tthis._done = [];\n\t}\n\n\tlast(): DCommand | null {\n\t\tconst done = this._done;\n\t\tif (0 < done.length) {\n\t\t\treturn done[done.length - 1];\n\t\t} else {\n\t\t\treturn null;\n\t\t}\n\t}\n\n\tpush(command: DCommand): void {\n\t\tthis.execute(command);\n\t}\n\n\tprotected execute(command: DCommand): void {\n\t\tthis.emit(\"executing\", command, this);\n\t\tconst isClear = isCommandClear(command);\n\t\tconst isStorable = isCommandStorable(command);\n\t\tif (isClear || isStorable) {\n\t\t\tconst size = isClear ? this._done.length : this._position;\n\t\t\tif (0 < size) {\n\t\t\t\tthis.remove(size);\n\t\t\t\tthis._position = 0;\n\t\t\t}\n\t\t\tthis.cleanup();\n\t\t}\n\t\tconst result = command.execute();\n\t\tif (result === true) {\n\t\t\tthis.onSuccess(command);\n\t\t} else {\n\t\t\tthis.onFail(command);\n\t\t}\n\t}\n\n\tprotected onSuccess(command: DCommand): void {\n\t\tif (isCommandStorable(command)) {\n\t\t\tthis._done.push(command);\n\t\t\tif (!isCommandClean(command)) {\n\t\t\t\tthis.emit(\"dirty\", this);\n\t\t\t}\n\t\t}\n\t\tthis.emit(\"executed\", command, this);\n\t}\n\n\tprotected onFail(command: DCommand): void {\n\t\tcommand.destroy();\n\t}\n\n\tprotected cleanup(): void {\n\t\tconst done = this._done;\n\t\tconst size = done.length - 100;\n\t\tif (0 < size) {\n\t\t\tfor (let i = 0; i < size; ++i) {\n\t\t\t\tdone[i].destroy();\n\t\t\t\tdone.shift();\n\t\t\t}\n\t\t}\n\t}\n\n\tprotected remove(size: number): boolean {\n\t\tconst done = this._done;\n\t\tif (0 < size) {\n\t\t\tconst ifrom = Math.max(0, done.length - size);\n\t\t\tsize = done.length - ifrom;\n\t\t\tif (0 < size) {\n\t\t\t\tfor (let i = ifrom, imax = done.length; i < imax; ++i) {\n\t\t\t\t\tdone[i].destroy();\n\t\t\t\t}\n\n\t\t\t\tdone.splice(ifrom, done.length - ifrom);\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t\treturn false;\n\t}\n\n\tsize(): number {\n\t\treturn this._done.length;\n\t}\n\n\tclear(): void {\n\t\tthis.push(new DCommandClear());\n\t}\n\n\tredo(): void {\n\t\tif (this.isRedoable()) {\n\t\t\tthis.doRedo();\n\t\t}\n\t}\n\n\tprotected doRedo(): void {\n\t\tconst done = this._done;\n\t\tif (0 < this._position) {\n\t\t\tconst current = done[done.length - this._position];\n\t\t\tthis._position -= 1;\n\t\t\tthis.emit(\"redoing\", current, this);\n\t\t\tconst result = current.redo();\n\t\t\tif (result === true) {\n\t\t\t\tthis.onRedoSuccess(current);\n\t\t\t} else {\n\t\t\t\tthis.onRedoFail(current);\n\t\t\t}\n\t\t}\n\t}\n\n\tprotected onRedoSuccess(redoed: DCommand): void {\n\t\tif (!isCommandClean(redoed)) {\n\t\t\tthis.emit(\"dirty\", this);\n\t\t}\n\t\tthis.emit(\"redoed\", redoed, this);\n\t}\n\n\tprotected onRedoFail(command: DCommand): void {\n\t\t// DO NOTHING\n\t}\n\n\tisRedoable(): boolean {\n\t\treturn 0 < this._position;\n\t}\n\n\tundo(): void {\n\t\tif (this.isUndoable()) {\n\t\t\tthis.doUndo();\n\t\t}\n\t}\n\n\tprotected doUndo(): void {\n\t\tconst done = this._done;\n\t\tif (this._position < done.length) {\n\t\t\tconst current = done[done.length - 1 - this._position];\n\t\t\tthis._position += 1;\n\t\t\tthis.emit(\"undoing\", current, this);\n\t\t\tconst result = current.undo();\n\t\t\tif (result === true) {\n\t\t\t\tthis.onUndoSuccess(current);\n\t\t\t} else {\n\t\t\t\tthis.onUndoFail(current);\n\t\t\t}\n\t\t}\n\t}\n\n\tprotected onUndoSuccess(undoed: DCommand): void {\n\t\tif (!isCommandClean(undoed)) {\n\t\t\tthis.emit(\"dirty\", this);\n\t\t}\n\t\tthis.emit(\"undoed\", undoed, this);\n\t}\n\n\tprotected onUndoFail(command: DCommand): void {\n\t\t// DO NOTHING\n\t}\n\n\tisUndoable(): boolean {\n\t\treturn this._position < this._done.length;\n\t}\n}\n"]}
|
|
@@ -171,12 +171,9 @@ export * from "./d-color-gradient-point-observable";
|
|
|
171
171
|
export * from "./d-color-gradient";
|
|
172
172
|
export * from "./d-command-clear";
|
|
173
173
|
export * from "./d-command-create";
|
|
174
|
-
export * from "./d-command-delete";
|
|
175
174
|
export * from "./d-command-flag";
|
|
176
|
-
export * from "./d-command-redo";
|
|
177
175
|
export * from "./d-command-save-as";
|
|
178
176
|
export * from "./d-command-save";
|
|
179
|
-
export * from "./d-command-undo";
|
|
180
177
|
export * from "./d-command";
|
|
181
178
|
export * from "./d-content";
|
|
182
179
|
export * from "./d-controller-command-impl";
|