ManageLicense.ts 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. import EditorEvents = require("../../editor/EditorEvents");
  2. import EditorUI = require("../EditorUI");
  3. import ModalWindow = require("../modal/ModalWindow");
  4. import ProgressModal = require("../modal/ProgressModal");
  5. class ManageLicense extends ModalWindow {
  6. constructor() {
  7. super();
  8. this.init("Product Activation", "AtomicEditor/editor/ui/managelicense.tb.txt");
  9. this.progressModal = new ProgressModal("License Management", "Returning license, please wait...");
  10. }
  11. handleWidgetEvent(ev: Atomic.UIWidgetEvent) {
  12. if (ev.type == Atomic.UI_EVENT_TYPE_CLICK) {
  13. var id = ev.target.id;
  14. if (id == "ok") {
  15. this.hide();
  16. return true;
  17. }
  18. if (ev.target.id == "confirm_license_return") {
  19. if (ev.refid == "TBMessageWindow.ok") {
  20. if (ToolCore.licenseSystem.deactivate()) {
  21. this.progressModal.show();
  22. this.subscribeToEvent("LicenseDeactivationSuccess", (ev) => {
  23. this.progressModal.hide();
  24. this.hide();
  25. EditorUI.getModelOps().showActivationWindow();
  26. });
  27. this.subscribeToEvent("LicenseDeactivationError", (ev: ToolCore.LicenseDeactivationErrorEvent) => {
  28. this.progressModal.hide();
  29. EditorUI.showModalError("Deactivation Error", ev.message);
  30. });
  31. }
  32. }
  33. return true;
  34. }
  35. if (id == "return_activation") {
  36. if (ToolCore.toolSystem.project) {
  37. EditorUI.showModalError("Project Open",
  38. "Please close the current project before deactivating license");
  39. }
  40. else {
  41. var confirm = new Atomic.UIMessageWindow(this, "confirm_license_return");
  42. confirm.show("Return License", "Are you sure you want to return the installed license?", Atomic.UI_MESSAGEWINDOW_SETTINGS_OK_CANCEL, true, 300, 140);
  43. }
  44. return true;
  45. }
  46. }
  47. }
  48. progressModal: ProgressModal;
  49. }
  50. export = ManageLicense;