/nu/Controller.nu

http://github.com/trawor/doxycleanapp · Nushell · 124 lines · 101 code · 23 blank · 0 comment · 0 complexity · 9392f5fc606778aed59883fd48edbc8e MD5 · raw file

  1. (class Controller is NSObject
  2. (ivar (id) PresetsPopupButton
  3. (id) DeletePresetButton
  4. (id) RunDoxygenButton
  5. (id) PresetWindow
  6. (id) PresetField
  7. (id) CommandTextView
  8. (id) configuration)
  9. (ivar-accessors)
  10. (- (void) awakeFromNib is
  11. (self setConfiguration:(dict))
  12. (if (== nil ((NSWorkspace sharedWorkspace) fullPathForApplication:"Doxygen"))
  13. ((self RunDoxygenButton) setEnabled:NO))
  14. (self updatePresets) )
  15. (- (void) run:(id)sender is
  16. ((sender window) makeFirstResponder:(sender window)) ; Propogate bindings changes
  17. (if (and (== YES ((self configuration) objectForKey:"shouldRunDoxygenFirst") )
  18. (!= 0 (((self configuration) objectForKey:"doxygenConfigPath") length) ))
  19. (set doxygen ((NSWorkspace sharedWorkspace) fullPathForApplication:"Doxygen"))
  20. (set doxygen (doxygen stringByAppendingPathComponent:"Contents/Resources/doxygen"))
  21. (NSTask launchedTaskWithLaunchPath:doxygen arguments:(array ((self configuration) objectForKey:"doxygenConfigPath"))) )
  22. (set doxyclean ((NSBundle mainBundle) pathForResource:"doxyclean" ofType:"py" inDirectory:"doxyclean"))
  23. (set args (array
  24. "-i" ((self configuration) objectForKey:"pathToXMLFolder")
  25. "-o" ((self configuration) objectForKey:"outputPath")
  26. "-n" ((self configuration) objectForKey:"projectName") ))
  27. (if (== YES ((self configuration) objectForKey:"shouldOnlyGenerateXML")) (args addObject:"-x"))
  28. (NSTask launchedTaskWithLaunchPath:doxyclean arguments:args) )
  29. (- (void) deletePreset:(id)sender is
  30. (set presets ((NSUserDefaults standardUserDefaults) objectForKey:"presets"))
  31. (presets removeObjectForKey:((self PresetsPopupButton) titleOfSelectedItem))
  32. ((NSUserDefaults standardUserDefaults) setObject:presets forKey:"presets")
  33. (self updatePresets)
  34. (self setConfiguration:(dict)) )
  35. (- (void) saveAsPreset:(id)sender is
  36. ((sender window) makeFirstResponder:(sender window))
  37. (set NSApp (NSApplication sharedApplication))
  38. (NSApp beginSheet:(self PresetWindow) modalForWindow:(NSApp mainWindow) modalDelegate:nil didEndSelector:nil contextInfo:nil)
  39. (NSApp runModalForWindow:(self PresetWindow))
  40. (NSApp endSheet:(self PresetWindow))
  41. ((self PresetWindow) orderOut:nil) )
  42. (- (void) closePresetNameWindow:(id)sender is
  43. (set ud (NSUserDefaults standardUserDefaults))
  44. (set presets (ud objectForKey:"presets"))
  45. (if (== nil presets) (set presets (dict)))
  46. (presets setObject:(self configuration) forKey:((self PresetField) stringValue))
  47. (ud setObject:presets forKey:"presets")
  48. (self updatePresets)
  49. ((NSApplication sharedApplication) stopModal) )
  50. (- (void) choosePathToXMLFolder:(id) sender is
  51. (set tmp (self runOpenPanel:NO))
  52. (if (!= nil tmp) ((self configuration) setObject:tmp forKey:"pathToXMLFolder")) )
  53. (- (void) chooseOutputPath:(id)sender is
  54. (set tmp (self runOpenPanel:NO))
  55. (if (!= nil tmp) ((self configuration) setObject:tmp forKey:"outputPath")) )
  56. (- (void) chooseDoxygenConfig:(id)sender is
  57. (set tmp (self runOpenPanel:YES))
  58. (if (!= nil tmp) ((self configuration) setObject:tmp forKey:"doxygenConfigPath")) )
  59. (- (void) changePreset:(id)sender is
  60. (set preset (((NSUserDefaults standardUserDefaults) objectForKey:"presets") objectForKey:(sender titleOfSelectedItem)) )
  61. (self setConfiguration:preset) )
  62. (- (id) runOpenPanel:(BOOL)canChooseFiles is
  63. (set op (NSOpenPanel openPanel))
  64. (if (!= YES canChooseFiles) (op setCanChooseDirectories:YES))
  65. (op setCanChooseFiles:canChooseFiles)
  66. (set filename nil)
  67. (if (> (op runModal) 0)
  68. (set filename (op filename)) )
  69. (filename) )
  70. (- (void) updatePresets is
  71. ((self PresetsPopupButton) removeAllItems)
  72. (set presets (((NSUserDefaults standardUserDefaults) objectForKey:"presets") allKeys) )
  73. ((self PresetsPopupButton) addItemWithTitle:"<<No preset>>")
  74. (((self PresetsPopupButton) menu) addItem:(NSMenuItem separatorItem))
  75. ((self PresetsPopupButton) addItemsWithTitles:presets) )
  76. (- (void) showCommand:(id)sender is
  77. (set command "")
  78. (if (and (== YES ((self configuration) objectForKey:"shouldRunDoxygenFirst") )
  79. (!= 0 (((self configuration) objectForKey:"doxygenConfigPath") length) ))
  80. (set doxygen ((NSWorkspace sharedWorkspace) fullPathForApplication:"Doxygen"))
  81. (set doxygen (doxygen stringByAppendingPathComponent:"Contents/Resources/doxygen"))
  82. (set command (+ doxygen " " ((self configuration) objectForKey:"doxygenConfigPath"))) )
  83. (set doxyclean ((NSBundle mainBundle) pathForResource:"doxyclean" ofType:"py" inDirectory:"doxyclean"))
  84. (set args (+
  85. "-i " ((self configuration) objectForKey:"pathToXMLFolder") " "
  86. "-o " ((self configuration) objectForKey:"outputPath") " "
  87. "-n " ((self configuration) objectForKey:"projectName") ))
  88. (if (== YES ((self configuration) objectForKey:"shouldOnlyGenerateXML")) (set args (+ args "-x")))
  89. (set command (+ command " && " doxyclean " " args))
  90. ((self CommandTextView) setString:command)
  91. (set win ((self CommandTextView) window))
  92. (set NSApp (NSApplication sharedApplication))
  93. (set mainWin (NSApp mainWindow))
  94. (mainWin makeFirstResponder:mainWin)
  95. (NSApp beginSheet:win modalForWindow:mainWin modalDelegate:nil didEndSelector:nil contextInfo:nil)
  96. (NSApp runModalForWindow:win)
  97. (NSApp endSheet:win)
  98. (win orderOut:nil) )
  99. (- (void) closeCommandWindow:(id)sender is
  100. ((NSApplication sharedApplication) stopModal) )
  101. )