PageRenderTime 6ms CodeModel.GetById 1ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/nu/Controller.nu

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