Skip to content

Commit

Permalink
• Edit Object <SHIFT+COMMAND+E>
Browse files Browse the repository at this point in the history
- in Workspace Browser is invokes editing of selected item
- in any editor if something is selected it takes the selection as object name and invokes obj <- edit(obj)
- in any editor if nothing is selected it takes the current word due to cursor position, checks if found word is a valid object name in ls(), and if so invokes obj <- edit(obj)
• fixed bug for adding a new column in R Data Editor

git-svn-id: https://svn.r-project.org/R-packages/trunk/Mac-GUI@5866 694ef91d-65df-0310-b7bb-92e67a308ead
  • Loading branch information
Hans-Jörg Bibiko committed Jul 3, 2011
1 parent d7a8d1b commit f5b67d2
Show file tree
Hide file tree
Showing 11 changed files with 178 additions and 42 deletions.
20 changes: 16 additions & 4 deletions English.lproj/MainMenu.xib
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@
</object>
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
<bool key="EncodedWithXMLCoder">YES</bool>
<integer value="1717"/>
<integer value="795"/>
<integer value="1717"/>
<integer value="169"/>
</object>
<object class="NSArray" key="IBDocument.PluginDependencies">
<bool key="EncodedWithXMLCoder">YES</bool>
Expand Down Expand Up @@ -4757,6 +4758,7 @@
</object>
<string key="NSFrame">{{1, 17}, {478, 342}}</string>
<reference key="NSSuperview" ref="49354047"/>
<reference key="NSNextKeyView" ref="783549011"/>
<reference key="NSDocView" ref="783549011"/>
<reference key="NSBGColor" ref="650509342"/>
<int key="NScvFlags">4</int>
Expand Down Expand Up @@ -4789,6 +4791,7 @@
</object>
<string key="NSFrame">{{1, 0}, {478, 17}}</string>
<reference key="NSSuperview" ref="49354047"/>
<reference key="NSNextKeyView" ref="272087171"/>
<reference key="NSDocView" ref="272087171"/>
<reference key="NSBGColor" ref="650509342"/>
<int key="NScvFlags">4</int>
Expand All @@ -4797,6 +4800,7 @@
</object>
<string key="NSFrameSize">{480, 360}</string>
<reference key="NSSuperview" ref="465510747"/>
<reference key="NSNextKeyView" ref="576351995"/>
<int key="NSsFlags">562</int>
<reference key="NSVScroller" ref="850038370"/>
<reference key="NSHScroller" ref="698895697"/>
Expand Down Expand Up @@ -7555,6 +7559,14 @@
</object>
<int key="connectionID">1741</int>
</object>
<object class="IBConnectionRecord">
<object class="IBActionConnection" key="connection">
<string key="label">editObject:</string>
<reference key="source" ref="841731700"/>
<reference key="destination" ref="625211532"/>
</object>
<int key="connectionID">1742</int>
</object>
</object>
<object class="IBMutableOrderedSet" key="objectRecords">
<object class="NSArray" key="orderedObjects">
Expand Down Expand Up @@ -12263,9 +12275,9 @@
<boolean value="YES"/>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<boolean value="YES"/>
<string>{{721, 396}, {480, 360}}</string>
<string>{{472, 396}, {480, 360}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>{{721, 396}, {480, 360}}</string>
<string>{{472, 396}, {480, 360}}</string>
<boolean value="YES"/>
<boolean value="YES"/>
<string>{213, 107}</string>
Expand Down Expand Up @@ -12445,7 +12457,7 @@
</object>
</object>
<nil key="sourceID"/>
<int key="maxID">1741</int>
<int key="maxID">1742</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
Expand Down
11 changes: 11 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
NEWS for R.app GUI for Mac OS X

Last-update: 2011-07-03 [HJBB]
* Edit Object <SHIFT+COMMAND+E>
- in Workspace Browser is invokes editing of selected
item
- in any editor if something is selected it takes the
selection as object name and invokes obj <- edit(obj)
- in any editor if nothing is selected it takes the
current word due to cursor position, checks if found
word is a valid object name in ls(), and if so invokes
obj <- edit(obj)

Last-update: 2011-06-27 [HJBB]
* R Data Editor
- after initialising resize columns due content
Expand Down
1 change: 1 addition & 0 deletions RController.h
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@
- (IBAction)toggleDataManager:(id)sender;
- (IBAction)toggleWSBrowser:(id)sender;
- (IBAction)performHelpSearch:(id)sender;
- (IBAction)editObject:(id)sender;

- (IBAction)sourceFile:(id)sender;
- (IBAction)sourceOrLoadFile:(id)sender;
Expand Down
55 changes: 55 additions & 0 deletions RController.m
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
#import "Quartz/QuartzDevice.h"
#import "Tools/Authorization.h"
#import "RChooseEncodingPopupAccessory.h"
#import "NSTextView_RAdditions.h"

#import "Preferences.h"
#import "SearchTable.h"
Expand Down Expand Up @@ -2611,6 +2612,35 @@ - (BOOL)validateMenuItem:(NSMenuItem *)menuItem

}

if ([menuItem action] == @selector(editObject:)) {
id fr = [[NSApp keyWindow] firstResponder];
if([fr respondsToSelector:@selector(getRangeForCurrentWord)]) {

NSString *objName = nil;

// if user selected something allow it since s/he is responsible
// otherwise take the current word due to cursor position and
// check if it is a valid object name in the workspace “ls()”
if([(NSTextView*)fr selectedRange].length)
return YES;
else if([(NSTextView*)fr getRangeForCurrentWord].length)
objName = [[(NSTextView*)fr string] substringWithRange:[(RTextView*)fr getRangeForCurrentWord]];
else
return NO;

if(!objName) return NO;

// check if found object name is defined in workspace “ls()”
RSEXP *check = [[REngine mainEngine] evaluateString:[NSString stringWithFormat:@"ifelse(\"%@\" %%in%% ls(), '1', '')", objName]];
if(check && [check string].length) {
[check release];
return YES;
}
return NO;
}
return NO;
}

return YES;

}
Expand Down Expand Up @@ -3401,6 +3431,31 @@ - (IBAction)sourceFile:(id)sender

}

- (IBAction)editObject:(id)sender
{
id fr = [[NSApp keyWindow] firstResponder];

if([fr respondsToSelector:@selector(getRangeForCurrentWord)]) {

NSString *objName = nil;

// take the selected word if any otherwise the current word due to cursor position
if([(NSTextView*)fr selectedRange].length)
objName = [[(NSTextView*)fr string] substringWithRange:[(RTextView*)fr selectedRange]];
else if([(NSTextView*)fr getRangeForCurrentWord].length)
objName = [[(NSTextView*)fr string] substringWithRange:[(RTextView*)fr getRangeForCurrentWord]];

if(!objName) {
NSBeep();
return;
}

[[REngine mainEngine] executeString:[NSString stringWithFormat:@"%@ <- edit(%@)", objName, objName]];

}

}

- (IBAction)printDocument:(id)sender
{

Expand Down
17 changes: 9 additions & 8 deletions REditor.m
Original file line number Diff line number Diff line change
Expand Up @@ -261,9 +261,9 @@ - (BOOL)initData
if(objectData) [objectData release], objectData = nil;
if(objectColumnNames) [objectColumnNames release], objectColumnNames = nil;
if(objectColumnTypes) [objectColumnTypes release], objectColumnTypes = nil;
objectData = (NSMutableArray*)CFArrayCreateMutable(NULL, xmaxused, NULL);
objectColumnNames = (NSMutableArray*)CFArrayCreateMutable(NULL, xmaxused, NULL);
objectColumnTypes = (NSMutableArray*)CFArrayCreateMutable(NULL, xmaxused, NULL);
objectData = [[NSMutableArray alloc] initWithCapacity:xmaxused];
objectColumnNames = [[NSMutableArray alloc] initWithCapacity:xmaxused];
objectColumnTypes = [[NSMutableArray alloc] initWithCapacity:xmaxused];

numberOfRows = ymaxused;

Expand Down Expand Up @@ -891,8 +891,9 @@ - (IBAction)addCol:(id)sender
newColType = [[objectColumnTypes objectAtIndex:lastcol] intValue];

newvar++;
NSLog(@"%d %d %d", nCols, lastcol, newColType);

if(nCols == lastcol) {
if((nCols-1) == lastcol) {
[objectColumnNames addObject:[NSString stringWithFormat:@"var %d", newvar]];
[objectColumnTypes addObject:[NSNumber numberWithInteger:newColType]];
[objectData addObject:[NSMutableArray array]];
Expand All @@ -902,12 +903,12 @@ - (IBAction)addCol:(id)sender
[objectData insertObject:[NSMutableArray array] atIndex:lastcol+1];
}

if(!isEmpty)
for(i = 0; i < [[objectData objectAtIndex:lastcol] count]; i++)
[[objectData objectAtIndex:lastcol+1] addObject:(newColType == NUMERIC) ? @"NA" : @""];

numberOfColumns++;

if(!isEmpty)
for(i = 0; i < numberOfRows; i++)
[NSArrayObjectAtIndex(objectData, (lastcol+1)) addObject:(newColType == NUMERIC) ? @"NA" : @""];

[self setDataTable:NO];

}
Expand Down
11 changes: 11 additions & 0 deletions WSBrowser.m
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,17 @@ - (BOOL) validateToolbarItem: (NSToolbarItem *) toolbarItem {
return enable;
}

- (BOOL)validateMenuItem:(NSMenuItem *)menuItem
{

if ([menuItem action] == @selector(editObject:)) {
return ([WSBDataSource numberOfSelectedRows] == 1);
}

return YES;

}

- (IBAction) reloadWSBData:(id)sender
{

Expand Down
17 changes: 13 additions & 4 deletions de.lproj/MainMenu.xib
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@
</object>
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
<bool key="EncodedWithXMLCoder">YES</bool>
<integer value="1714"/>
<integer value="798"/>
<integer value="1714"/>
<integer value="169"/>
</object>
<object class="NSArray" key="IBDocument.PluginDependencies">
<bool key="EncodedWithXMLCoder">YES</bool>
Expand Down Expand Up @@ -7553,6 +7554,14 @@
</object>
<int key="connectionID">1735</int>
</object>
<object class="IBConnectionRecord">
<object class="IBActionConnection" key="connection">
<string key="label">editObject:</string>
<reference key="source" ref="841731700"/>
<reference key="destination" ref="625211532"/>
</object>
<int key="connectionID">1736</int>
</object>
</object>
<object class="IBMutableOrderedSet" key="objectRecords">
<object class="NSArray" key="orderedObjects">
Expand Down Expand Up @@ -11849,7 +11858,7 @@
<bytes key="NSTransformStruct">P4AAAL+AAABBmAAAxAQAAA</bytes>
</object>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>{{156, 298}, {223, 393}}</string>
<string>{{199, 145}, {320, 393}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<boolean value="YES"/>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
Expand Down Expand Up @@ -11945,7 +11954,7 @@
<boolean value="YES"/>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<boolean value="YES"/>
<string>{{74, 4}, {798, 20}}</string>
<string>{{94, 538}, {798, 20}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<boolean value="YES"/>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
Expand Down Expand Up @@ -12441,7 +12450,7 @@
</object>
</object>
<nil key="sourceID"/>
<int key="maxID">1735</int>
<int key="maxID">1736</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
Expand Down
Loading

0 comments on commit f5b67d2

Please sign in to comment.