The R Project SVN R-packages

Rev

Rev 816 | Rev 5535 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
714 iacus 1
/*
2
 *  R.app : a Cocoa front end to: "R A Computer Language for Statistical Data Analysis"
3
 *  
4
 *  R.app Copyright notes:
1254 iacus 5
 *                     Copyright (C) 2004-5  The R Foundation
714 iacus 6
 *                     written by Stefano M. Iacus and Simon Urbanek
7
 *
8
 *                  
9
 *  R Copyright notes:
10
 *                     Copyright (C) 1995-1996   Robert Gentleman and Ross Ihaka
11
 *                     Copyright (C) 1998-2001   The R Development Core Team
12
 *                     Copyright (C) 2002-2004   The R Foundation
13
 *
14
 *  This program is free software; you can redistribute it and/or modify
15
 *  it under the terms of the GNU General Public License as published by
16
 *  the Free Software Foundation; either version 2 of the License, or
17
 *  (at your option) any later version.
18
 *
19
 *  This program is distributed in the hope that it will be useful,
20
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
21
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22
 *  GNU General Public License for more details.
23
 *
24
 *  A copy of the GNU General Public License is available via WWW at
25
 *  http://www.gnu.org/copyleft/gpl.html.  You can also obtain it by
26
 *  writing to the Free Software Foundation, Inc., 59 Temple Place,
27
 *  Suite 330, Boston, MA  02111-1307  USA.
28
 */
29
 
568 iacus 30
#import "DataManager.h"
31
#import "RController.h"
816 urbaneks 32
#import "REngine/REngine.h"
568 iacus 33
 
34
#import <WebKit/WebKit.h>
35
#import <WebKit/WebFrame.h>
36
 
688 urbaneks 37
static id sharedController;
568 iacus 38
 
39
@implementation DataManager
40
 
41
- (void)awakeFromNib
42
{
688 urbaneks 43
	[RDataSource setDoubleAction:@selector(loadRData:)];
700 urbaneks 44
	[RDataSource setDataSource: dataSource];
568 iacus 45
}
46
 
47
- (id)init
48
{
49
    self = [super init];
50
    if (self) {
688 urbaneks 51
		sharedController = self;
700 urbaneks 52
		dataSource = [[SortableDataSource alloc] init];
568 iacus 53
	}
54
 
55
    return self;
56
}
57
 
58
- (void)dealloc {
59
	[super dealloc];
60
}
61
 
688 urbaneks 62
- (void) resetDatasets
63
{
700 urbaneks 64
	[dataSource reset];
688 urbaneks 65
}
66
 
67
- (void) updateDatasets: (int) count withNames: (char**) name descriptions: (char**) desc packages: (char**) pkg URLs: (char**) url
568 iacus 68
{
700 urbaneks 69
	[dataSource reset];
70
	[dataSource addColumnOfLength:count withCStrings:name name:@"data"];
71
	[dataSource addColumnOfLength:count withCStrings:desc name:@"description"];
72
	[dataSource addColumnOfLength:count withCStrings:pkg name:@"package"];
73
	[dataSource addColumnOfLength:count withCStrings:url name:@"URL"];
688 urbaneks 74
	[self show];
568 iacus 75
}
76
 
77
- (id) window
78
{
79
	return DataManagerWindow;
80
}
81
 
688 urbaneks 82
+ (DataManager*) sharedController{
83
	return sharedController;
568 iacus 84
}
85
 
688 urbaneks 86
- (void) reloadData
568 iacus 87
{
88
	[RDataSource reloadData];
89
}
90
 
91
- (IBAction)loadRData:(id)sender
92
{
93
	int row = [sender selectedRow];
94
	if(row>=0)
700 urbaneks 95
		[[REngine mainEngine] evaluateString:[NSString stringWithFormat:@"data(%@,package=\"%@\")",
96
			[dataSource objectAtColumn:@"data" row:row], [dataSource objectAtColumn:@"package" row:row]]];
568 iacus 97
}
98
 
99
- (IBAction)showHelp:(id)sender
100
{
101
	int row = [sender selectedRow];
102
	if(row<0) return;
700 urbaneks 103
	NSString *urlText = [NSString stringWithFormat:@"file://%@",[dataSource objectAtColumn:@"URL" row:row]];
568 iacus 104
	[[dataInfoView mainFrame] loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:urlText]]];
105
}
106
 
688 urbaneks 107
- (int) count
568 iacus 108
{
700 urbaneks 109
	return [dataSource count];
568 iacus 110
}
111
 
688 urbaneks 112
- (void) show
113
{
114
	[self reloadData];
115
	[DataManagerWindow makeKeyAndOrderFront:self];
116
}
117
 
568 iacus 118
@end