mirror of
https://github.com/gnustep/apps-gorm.git
synced 2025-04-22 22:20:44 +00:00
Add code to detect if we are in the tool
This commit is contained in:
parent
b5175a24e3
commit
55b46a186b
4 changed files with 63 additions and 8 deletions
|
@ -1913,9 +1913,18 @@
|
|||
@"actions/outlets to instances of class '%@' "
|
||||
@"and it's subclasses. Continue?");
|
||||
NSString *msg = [NSString stringWithFormat: messageFormat,
|
||||
className];
|
||||
NSInteger retval = NSRunAlertPanel(title, msg,_(@"OK"),_(@"Cancel"), nil, nil);
|
||||
className];
|
||||
NSInteger retval = 0;
|
||||
|
||||
if ([self respondsToSelector: @selector(isInTool)])
|
||||
{
|
||||
retval = NSAlertDefaultReturn;
|
||||
}
|
||||
else
|
||||
{
|
||||
retval = NSRunAlertPanel(title, msg,_(@"OK"),_(@"Cancel"), nil, nil);
|
||||
}
|
||||
|
||||
if (retval == NSAlertDefaultReturn)
|
||||
{
|
||||
// get the owner and reset the class name to NSApplication.
|
||||
|
|
|
@ -146,6 +146,11 @@
|
|||
[pair setArgument: obj];
|
||||
parse_val = YES;
|
||||
}
|
||||
else if ([obj isEqualToString: @"--import-class"])
|
||||
{
|
||||
[pair setArgument: obj];
|
||||
parse_val = YES;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -158,8 +163,6 @@
|
|||
|
||||
[NSClassSwapper setIsInInterfaceBuilder: YES];
|
||||
|
||||
NSLog(@"Processing... %@", [pi arguments]);
|
||||
|
||||
if ([[pi arguments] count] > 1)
|
||||
{
|
||||
NSString *file = [[pi arguments] lastObject];
|
||||
|
@ -168,8 +171,8 @@
|
|||
NSDictionary *args = [self parseArguments];
|
||||
ArgPair *opt = nil;
|
||||
|
||||
NSLog(@"args = %@", args);
|
||||
NSLog(@"file = %@", file);
|
||||
NSDebugLog(@"args = %@", args);
|
||||
NSDebugLog(@"file = %@", file);
|
||||
doc = [dc openDocumentWithContentsOfFile: file display: NO];
|
||||
NSDebugLog(@"Document = %@", doc);
|
||||
|
||||
|
@ -193,7 +196,6 @@
|
|||
else
|
||||
{
|
||||
opt = [args objectForKey: @"--import-strings-file"];
|
||||
|
||||
if (opt != nil)
|
||||
{
|
||||
NSString *stringsFile = [opt value];
|
||||
|
@ -235,6 +237,34 @@
|
|||
NSLog(@"Class named %@ not saved", className);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
opt = [args objectForKey: @"--import-class"];
|
||||
if (opt != nil)
|
||||
{
|
||||
NSString *classFile = [opt value];
|
||||
BOOL saved = NO;
|
||||
NSURL *file = [NSURL fileURLWithPath: outputFile isDirectory: YES];
|
||||
NSString *type = [dc typeFromFileExtension: [outputFile pathExtension]];
|
||||
NSError *error = nil;
|
||||
GormClassManager *cm = [doc classManager];
|
||||
|
||||
[cm parseHeader: classFile];
|
||||
saved = [doc saveToURL: file
|
||||
ofType: type
|
||||
forSaveOperation: NSSaveOperation
|
||||
error: &error];
|
||||
if (!saved)
|
||||
{
|
||||
NSLog(@"Document %@ of type %@ was not saved", file, type);
|
||||
}
|
||||
|
||||
if (error != nil)
|
||||
{
|
||||
NSLog(@"Error = %@", error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -246,7 +276,7 @@
|
|||
{
|
||||
puts("== gormtool");
|
||||
|
||||
NSLog(@"processInfo: %@", [NSProcessInfo processInfo]);
|
||||
NSDebugLog(@"processInfo: %@", [NSProcessInfo processInfo]);
|
||||
[self process];
|
||||
|
||||
[NSApp terminate: nil];
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
#import <GormCore/GormPlugin.h>
|
||||
#import <GormCore/GormDocumentController.h>
|
||||
#import <GormCore/GormDocument.h>
|
||||
#import <GormCore/GormClassManager.h>
|
||||
|
||||
#import <GNUstepGUI/GSNibLoading.h>
|
||||
|
||||
|
@ -48,6 +49,12 @@
|
|||
|
||||
@end
|
||||
|
||||
@interface GormClassManager (ToolPrivate)
|
||||
|
||||
- (BOOL) isInTool;
|
||||
|
||||
@end
|
||||
|
||||
@interface GormDocument (ToolPrivate)
|
||||
|
||||
+ (BOOL) isNativeType: (NSString *)type;
|
||||
|
|
|
@ -75,6 +75,15 @@ static NSMutableArray *__types = nil;
|
|||
|
||||
@end
|
||||
|
||||
@implementation GormClassManager (ToolPrivate)
|
||||
|
||||
- (BOOL) isInTool
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation GormPlugin (ToolPrivate)
|
||||
|
||||
- (void) registerDocumentTypeName: (NSString *)name
|
||||
|
|
Loading…
Reference in a new issue