-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
2,451 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// | ||
// LDAppDelegate.h | ||
// LiveDiag | ||
// | ||
// Created by Taichiro Yoshida on 2013/08/05. | ||
// Copyright (c) 2013年 dataich.com. All rights reserved. | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
|
||
@interface LDAppDelegate : NSObject <NSApplicationDelegate> | ||
|
||
@property (unsafe_unretained) IBOutlet NSWindow *windowPreferences; | ||
|
||
- (IBAction)showPreferences:(id)sender; | ||
- (void)showPreferences; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// | ||
// LDAppDelegate.m | ||
// LiveDiag | ||
// | ||
// Created by Taichiro Yoshida on 2013/08/05. | ||
// Copyright (c) 2013年 dataich.com. All rights reserved. | ||
// | ||
|
||
#import "LDAppDelegate.h" | ||
#import "LDUtils.h" | ||
|
||
@implementation LDAppDelegate | ||
|
||
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification | ||
{ | ||
//check path settings, any commands | ||
if([LDUtils pathTo:@"blockdiag"] == nil || [LDUtils pathTo:@"seqdiag"] == nil || [LDUtils pathTo:@"actdiag"] == nil || [LDUtils pathTo:@"nwdiag"] == nil || [LDUtils pathTo:@"rackdiag"] == nil) { | ||
NSAlert *alert = [NSAlert alertWithMessageText:@"Path Setting" defaultButton:@"OK" alternateButton:@"Cancel" otherButton:nil informativeTextWithFormat:@"Please specify a path to blockdiag and the other."]; | ||
if ([alert runModal] == NSAlertDefaultReturn) { | ||
LDAppDelegate *delegate = (LDAppDelegate *)[[NSApplication sharedApplication] delegate]; | ||
[delegate showPreferences]; | ||
} | ||
} | ||
} | ||
|
||
- (IBAction)showPreferences:(id)sender { | ||
[self showPreferences]; | ||
} | ||
|
||
- (void)showPreferences { | ||
[NSApp runModalForWindow:self.windowPreferences]; | ||
[self.windowPreferences orderOut:self]; | ||
// [self.windowPreferences makeKeyAndOrderFront:self]; | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// | ||
// LDPreferencesViewController.h | ||
// LiveDiag | ||
// | ||
// Created by Taichiro Yoshida on 2013/08/02. | ||
// Copyright (c) 2013 dataich.com. All rights reserved. | ||
// | ||
|
||
#import <Cocoa/Cocoa.h> | ||
|
||
@interface LDPreferencesViewController : NSViewController | ||
|
||
@property (weak) IBOutlet NSTextField *textBlockdiag; | ||
@property (weak) IBOutlet NSTextField *textSeqdiag; | ||
@property (weak) IBOutlet NSTextField *textActdiag; | ||
@property (weak) IBOutlet NSTextField *textNwdiag; | ||
@property (weak) IBOutlet NSTextField *textRackdiag; | ||
@property (weak) IBOutlet NSUserDefaultsController *defaultsController; | ||
@property (unsafe_unretained) IBOutlet NSWindow *windowPreferences; | ||
|
||
- (IBAction)browse:(NSButton *)sender; | ||
- (IBAction)save:(id)sender; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
// | ||
// LDPreferencesViewController.m | ||
// LiveDiag | ||
// | ||
// Created by Taichiro Yoshida on 2013/08/02. | ||
// Copyright (c) 2013 dataich.com. All rights reserved. | ||
// | ||
|
||
#import "LDPreferencesViewController.h" | ||
|
||
@interface LDPreferencesViewController () | ||
|
||
@end | ||
|
||
@implementation LDPreferencesViewController | ||
|
||
/** | ||
* save user preferences to NSUserDefaultsController | ||
* I bind NSTextField to NSUserDefaultsController on xib, but it's saved only when the field loses focus... | ||
* Provisionally I create 'save' action which sent from 'OK' button. | ||
*/ | ||
- (IBAction)save:(id)sender { | ||
[self setValueToDefauls:self.textBlockdiag.stringValue forKeyPath:@"values.path_blockdiag"]; | ||
[self setValueToDefauls:self.textSeqdiag.stringValue forKeyPath:@"values.path_seqdiag"]; | ||
[self setValueToDefauls:self.textActdiag.stringValue forKeyPath:@"values.path_actdiag"]; | ||
[self setValueToDefauls:self.textNwdiag.stringValue forKeyPath:@"values.path_nwdiag"]; | ||
[self setValueToDefauls:self.textRackdiag.stringValue forKeyPath:@"values.path_rackdiag"]; | ||
|
||
[NSApp stopModalWithCode:0]; | ||
} | ||
|
||
- (void)setValueToDefauls:(NSString *)value forKeyPath:(NSString *)forKeyPath{ | ||
if(value == nil || [value isEqualToString:@""]) { | ||
[self.defaultsController setValue:nil forKeyPath:forKeyPath]; | ||
} else { | ||
[self.defaultsController setValue:value forKeyPath:forKeyPath]; | ||
} | ||
} | ||
|
||
- (IBAction)browse:(NSButton *)sender { | ||
NSOpenPanel *panel = [NSOpenPanel openPanel]; | ||
[panel beginSheetModalForWindow:self.view.window completionHandler:^(NSInteger result) { | ||
if(result == NSFileHandlingPanelOKButton) { | ||
NSString *path = [[panel URL] path]; | ||
switch (sender.tag) { | ||
case 0: | ||
self.textBlockdiag.stringValue = path; | ||
break; | ||
case 1: | ||
self.textSeqdiag.stringValue = path; | ||
break; | ||
case 2: | ||
self.textActdiag.stringValue = path; | ||
break; | ||
case 3: | ||
self.textNwdiag.stringValue = path; | ||
break; | ||
case 4: | ||
self.textRackdiag.stringValue = path; | ||
break; | ||
default: | ||
break; | ||
} | ||
} | ||
}]; | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// | ||
// LDUtils.h | ||
// LiveDiag | ||
// | ||
// Created by Taichiro Yoshida on 2013/08/06. | ||
// Copyright (c) 2013 dataich.com. All rights reserved. | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
|
||
@interface LDUtils : NSObject | ||
|
||
+ (NSString *)pathTo:(NSString *)command; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// | ||
// LDUtils.m | ||
// LiveDiag | ||
// | ||
// Created by Taichiro Yoshida on 2013/08/06. | ||
// Copyright (c) 2013 dataich.com. All rights reserved. | ||
// | ||
|
||
#import "LDUtils.h" | ||
|
||
@implementation LDUtils | ||
|
||
+ (NSString *)pathTo:(NSString *)command { | ||
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults]; | ||
return [userDefaults stringForKey:[NSString stringWithFormat:@"path_%@", command]]; | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.