UIResourceOps.ts 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. import EditorEvents = require("../../editor/EditorEvents");
  2. import EditorUI = require("../EditorUI");
  3. import ModalWindow = require("./ModalWindow");
  4. import ResourceOps = require("../../resources/ResourceOps");
  5. export class ResourceDelete extends ModalWindow {
  6. constructor(asset: ToolCore.Asset) {
  7. super();
  8. this.asset = asset;
  9. this.init("Delete Resource", "AtomicEditor/editor/ui/resourcedelete.tb.txt");
  10. var message = <Atomic.UIEditField> this.getWidget("message");
  11. var text = "Are you sure you want to delete resource:\n\n";
  12. text += asset.path;
  13. text += "\n\nThis operation cannot be undone";
  14. message.text = text;
  15. this.resizeToFitContent();
  16. this.center();
  17. }
  18. handleWidgetEvent(ev: Atomic.UIWidgetEvent) {
  19. if (ev.type == Atomic.UI_EVENT_TYPE_CLICK) {
  20. var id = ev.target.id;
  21. if (id == "delete") {
  22. this.hide();
  23. var db = ToolCore.getAssetDatabase();
  24. db.deleteAsset(this.asset);
  25. return true;
  26. }
  27. if (id == "cancel") {
  28. this.hide();
  29. return true;
  30. }
  31. }
  32. }
  33. asset: ToolCore.Asset;
  34. }
  35. export class CreateFolder extends ModalWindow {
  36. constructor(resourcePath: string) {
  37. super();
  38. this.resourcePath = resourcePath;
  39. this.init("New Folder", "AtomicEditor/editor/ui/resourcenewfolder.tb.txt");
  40. this.nameField = <Atomic.UIEditField> this.getWidget("folder_name");
  41. }
  42. handleWidgetEvent(ev: Atomic.UIWidgetEvent) {
  43. if (ev.type == Atomic.UI_EVENT_TYPE_CLICK) {
  44. var id = ev.target.id;
  45. if (id == "create") {
  46. var resourcePath = Atomic.addTrailingSlash(this.resourcePath) + this.nameField.text;
  47. if (ResourceOps.CreateNewFolder(resourcePath)) {
  48. this.hide();
  49. }
  50. return true;
  51. }
  52. if (id == "cancel") {
  53. this.hide();
  54. return true;
  55. }
  56. }
  57. }
  58. resourcePath: string;
  59. nameField: Atomic.UIEditField;
  60. }