Skip to content

Commit

Permalink
• improved R Data Editor
Browse files Browse the repository at this point in the history
- now tableView data are cached in a NSMutableArray to decouple them from R's 'work' variable since it led to crashes if one removed e.g. many columns at the same time
- some minor stability issues and improvements

git-svn-id: https://svn.r-project.org/R-packages/trunk/Mac-GUI@5865 694ef91d-65df-0310-b7bb-92e67a308ead
  • Loading branch information
Hans-Jörg Bibiko committed Jul 2, 2011
1 parent d5cf8f9 commit d7a8d1b
Show file tree
Hide file tree
Showing 8 changed files with 526 additions and 398 deletions.
46 changes: 46 additions & 0 deletions NSArray_RAdditions.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* R.app : a Cocoa front end to: "R A Computer Language for Statistical Data Analysis"
*
* R.app Copyright notes:
* Copyright (C) 2004-11 The R Foundation
* written by Stefano M. Iacus and Simon Urbanek
*
*
* R Copyright notes:
* Copyright (C) 1995-1996 Robert Gentleman and Ross Ihaka
* Copyright (C) 1998-2001 The R Development Core Team
* Copyright (C) 2002-2004 The R Foundation
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* A copy of the GNU General Public License is available via WWW at
* http://www.gnu.org/copyleft/gpl.html. You can also obtain it by
* writing to the Free Software Foundation, Inc., 59 Temple Place,
* Suite 330, Boston, MA 02111-1307 USA.
*
* NSArray_RAdditions.h
*
* Created by Hans-J. Bibiko on 01/07/2011.
*
*/

#import <Cocoa/Cocoa.h>

static inline id NSArrayObjectAtIndex(NSArray *self, NSUInteger i)
{
return (id)CFArrayGetValueAtIndex((CFArrayRef)self, (long)i);
}

@interface NSArray (NSArray_RAdditions)

- (NSArray *)subarrayWithIndexes:(NSIndexSet *)indexes;

@end
57 changes: 57 additions & 0 deletions NSArray_RAdditions.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
* R.app : a Cocoa front end to: "R A Computer Language for Statistical Data Analysis"
*
* R.app Copyright notes:
* Copyright (C) 2004-11 The R Foundation
* written by Stefano M. Iacus and Simon Urbanek
*
*
* R Copyright notes:
* Copyright (C) 1995-1996 Robert Gentleman and Ross Ihaka
* Copyright (C) 1998-2001 The R Development Core Team
* Copyright (C) 2002-2004 The R Foundation
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* A copy of the GNU General Public License is available via WWW at
* http://www.gnu.org/copyleft/gpl.html. You can also obtain it by
* writing to the Free Software Foundation, Inc., 59 Temple Place,
* Suite 330, Boston, MA 02111-1307 USA.
*
* NSArray_RAdditions.h
*
* Created by Hans-J. Bibiko on 01/07/2011.
*
*/

#import "NSArray_RAdditions.h"


@implementation NSArray (NSArray_RAdditions)

- (NSArray *)subarrayWithIndexes:(NSIndexSet *)indexes
{
NSMutableArray *subArray = [NSMutableArray arrayWithCapacity:[indexes count]];
NSUInteger count = [self count];

NSUInteger index = [indexes firstIndex];
while ( index != NSNotFound )
{
if ( index < count )
[subArray addObject: [self objectAtIndex: index]];

index = [indexes indexGreaterThanIndex: index];
}

return subArray;
}

@end
8 changes: 8 additions & 0 deletions R.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,8 @@
BC33799F133A0970006758D9 /* RHistoryTableView.m in Sources */ = {isa = PBXBuildFile; fileRef = BC33799D133A0970006758D9 /* RHistoryTableView.m */; };
BC469AED13B655270079D4E9 /* RDataEditorTableHeaderCell.h in Headers */ = {isa = PBXBuildFile; fileRef = BC469AEB13B655270079D4E9 /* RDataEditorTableHeaderCell.h */; };
BC469AEE13B655270079D4E9 /* RDataEditorTableHeaderCell.m in Sources */ = {isa = PBXBuildFile; fileRef = BC469AEC13B655270079D4E9 /* RDataEditorTableHeaderCell.m */; };
BC53A82013BDB5ED009488EE /* NSArray_RAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = BC53A81E13BDB5ED009488EE /* NSArray_RAdditions.h */; };
BC53A82113BDB5ED009488EE /* NSArray_RAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = BC53A81F13BDB5ED009488EE /* NSArray_RAdditions.m */; };
BC81712F13321873004B52A0 /* SelectEncodingsPanel.xib in Resources */ = {isa = PBXBuildFile; fileRef = BC81712D13321873004B52A0 /* SelectEncodingsPanel.xib */; };
BCBA744713B089D8001B440B /* RDataEditorTableView.h in Headers */ = {isa = PBXBuildFile; fileRef = BCBA744513B089D8001B440B /* RDataEditorTableView.h */; };
BCBA744813B089D8001B440B /* RDataEditorTableView.m in Sources */ = {isa = PBXBuildFile; fileRef = BCBA744613B089D8001B440B /* RDataEditorTableView.m */; };
Expand Down Expand Up @@ -458,6 +460,8 @@
BC33799D133A0970006758D9 /* RHistoryTableView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RHistoryTableView.m; sourceTree = "<group>"; };
BC469AEB13B655270079D4E9 /* RDataEditorTableHeaderCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RDataEditorTableHeaderCell.h; sourceTree = "<group>"; };
BC469AEC13B655270079D4E9 /* RDataEditorTableHeaderCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RDataEditorTableHeaderCell.m; sourceTree = "<group>"; };
BC53A81E13BDB5ED009488EE /* NSArray_RAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NSArray_RAdditions.h; sourceTree = "<group>"; };
BC53A81F13BDB5ED009488EE /* NSArray_RAdditions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NSArray_RAdditions.m; sourceTree = "<group>"; };
BC6682FE13390A06005ACB30 /* fr */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = fr; path = fr.lproj/EditorPrefPane.xib; sourceTree = "<group>"; };
BC6682FF13390A15005ACB30 /* fr */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = fr; path = fr.lproj/SyntaxColorsPrefPane.xib; sourceTree = "<group>"; };
BC6DECCE133267F900C852C1 /* it */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = it; path = it.lproj/SelectEncodingsPanel.xib; sourceTree = "<group>"; };
Expand Down Expand Up @@ -879,6 +883,8 @@
children = (
BC0D31981334B1410071B76A /* NSTextView_RAdditions.h */,
BC0D31991334B1410071B76A /* NSTextView_RAdditions.m */,
BC53A81E13BDB5ED009488EE /* NSArray_RAdditions.h */,
BC53A81F13BDB5ED009488EE /* NSArray_RAdditions.m */,
);
name = "Category Additions";
sourceTree = "<group>";
Expand Down Expand Up @@ -966,6 +972,7 @@
BC33799E133A0970006758D9 /* RHistoryTableView.h in Headers */,
BCBA744713B089D8001B440B /* RDataEditorTableView.h in Headers */,
BC469AED13B655270079D4E9 /* RDataEditorTableHeaderCell.h in Headers */,
BC53A82013BDB5ED009488EE /* NSArray_RAdditions.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -1217,6 +1224,7 @@
BC33799F133A0970006758D9 /* RHistoryTableView.m in Sources */,
BCBA744813B089D8001B440B /* RDataEditorTableView.m in Sources */,
BC469AEE13B655270079D4E9 /* RDataEditorTableHeaderCell.m in Sources */,
BC53A82113BDB5ED009488EE /* NSArray_RAdditions.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
12 changes: 11 additions & 1 deletion REditor.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,24 @@
IBOutlet NSWindow *dataWindow;
NSToolbar *toolbar;
NSInteger editedColumnNameIndex;
NSMutableArray *objectData;
NSMutableArray *objectColumnNames;
NSMutableArray *objectColumnTypes;
NSInteger numberOfRows;
NSInteger numberOfColumns;
}

+ (id) getDEController;
+ (void)startDataEntry;

- (id)window;

- (void)setDatas:(BOOL)removeAll;
- (BOOL)initData;
- (BOOL)writeDataBackToObject;
- (NSArray*)objectData;
- (NSArray*)objectColumnTypes;
- (void)clearData;
- (void)setDataTable:(BOOL)removeAll;
- (void)editColumnNameOfTableColumn:(NSTableColumn *)aTableColumn;

- (void)setupToolbar;
Expand Down
Loading

0 comments on commit d7a8d1b

Please sign in to comment.