summaryrefslogtreecommitdiffstats
path: root/Liaison/ApplicationController.m
blob: edff915394a8a30bbd947e5f5934a3c21294dccc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#import "ApplicationController.h"

#import "FileTableDelegate.h"
#import "Group.h"
#import "GroupTableDelegate.h"
#import "NIBConnector.h"
#import "PluginManager.h"
#import "RenManager.h"
#import "WindowController.h"

@implementation ApplicationController
// Set in awakeFromNib.
static ApplicationController *theApp = nil;

+ (ApplicationController *)theApp;
{
    return theApp;
}

- (void)awakeFromNib
{
    theApp = self;
}

- (void)applicationDidFinishLaunching: (NSNotification *)aNotification
{
    RenManager *renManager;
    NSArray *fileStorePlugins;
    NSString *libraryPath;
    id <LiFileStorePlugin>plugin;

    // Make sure the library exists.
    libraryPath = [[[Preferences sharedPreferences] libraryPath] stringByDeletingLastPathComponent];
    [[NSFileManager defaultManager] createDirectoryAtPath: libraryPath
                                               attributes: nil];

    // Load the plugins.
    fileStorePlugins = [[PluginManager defaultManager] fileStorePlugins];
    plugin = [fileStorePlugins objectAtIndex: 0]; // XXX
    [plugin initFileStore];
    
    renManager = [RenManager sharedManager];
    [renManager setFileStore: [plugin fileStore]];
    [renManager startup];
}

- (BOOL)application: (NSApplication *)anApp openFile: (NSString *)aPath
{
    [[NSWorkspace sharedWorkspace] openFile: aPath];
    [[NSDocumentController sharedDocumentController] noteNewRecentDocumentURL: [NSURL fileURLWithPath: aPath]];
    return YES;
}

- (IBAction)openHomepage:(id)sender
{
    [[NSWorkspace sharedWorkspace] openURL:
        [NSURL URLWithString: @"http://www.kublai.com/~shmit/software/Liaison/"]];
}


- (IBAction)showInspectorWindow:(id)sender
{
    [inspectorWindow makeKeyAndOrderFront: self];
}

- (IBAction)showMainWindow:(id)sender
{
    [mainWindow makeKeyAndOrderFront: self];
}
@synthesize theFileStore;
@synthesize inspectorWindow;
@synthesize mainWindow;
@end

@implementation ApplicationController (AppleScript)
- (BOOL)application: (NSApplication *)anApp
 delegateHandlesKey: (NSString *)aKey
{
    [LiLog logAsDebug: @"[ApplicationController application:delegateHandlesKey: %@", aKey];
    if ([aKey isEqualToString: @"orderedFileStores"])
        return YES;
    return NO;
}

- (NSArray *)orderedFileStores
{
    [LiLog logAsDebug: @"[ApplicationController orderedFileStores]"];
    return [LiFileStore allFileStores];
}
@end