/tmp/DoxyObjc/src/NIBManagerHandler.m

Go to the documentation of this file.
00001 //
00002 //  NIBManagerHandler.m
00003 //  DynamicNIB
00004 //
00005 //  Copyright 2005 __MyCompanyName__. All rights reserved.
00006 //
00007 
00008 #ifndef INCLUDED_NIBMANAGERHANDLER_H
00009 #import "NIBManagerHandler.h"
00010 #endif
00011 #ifndef INCLUDED_NIBMANAGER_H
00012 #import "NIBManager.h"
00013 #endif
00014 #ifndef INCLUDED_NIBCALLBACK_H
00015 #import "NIBCallback.h"
00016 #endif
00017 #ifndef INCLUDED_NIBCONTEXT_H
00018 #import "NIBContext.h"
00019 #endif
00020 
00021 
00022 
00023 NSString*               LOCALE_ENGLISH          = @"en";
00024 NSString*               LOCALE_JAPANESE         = @"jp";
00025 NSString*               KEY_IDENTIFIER          = @"key.identifier";
00026 
00027 int             MANAGER_STAFFWARE   = 1;
00028 int             MANAGER_DOCUMENTUM  = 2;
00029 int             MANAGER_PENTAHO         = 3;
00030 int             MANAGER_MAINFRAME       = 4;
00031 int             LOGGING_NONE        = 0;
00032 int             LOGGING_NOTICE      = 1;
00033 int             LOGGING_INFO        = 2;
00034 int             LOGGING_DEBUG       = 3;
00035 int             EMBEDDED                        = 0;
00036 int             WINDOWED                        = 1;
00037 int             DOCUMENT                        = 0;
00038 int             UNIQUE                          = 1;
00039 
00040 
00041 static NIBManagerHandler * __THIS   = nil;
00042 static int                 __LEVEL  = 0;
00043 
00044 
00045 @implementation NIBManagerHandler
00046 
00047 
00048 - (id)init {
00049     self = [super init];
00050     if (self) {
00051         __THIS = self;
00052         if (__LEVEL == LOGGING_NONE)
00053             __LEVEL = LOGGING_DEBUG;
00054         managers = [[NSMutableDictionary dictionary] retain];
00055                 if ([NIBManagerHandler getLoggingLevel] >= LOGGING_NOTICE)
00056                         NSLog(@"DynamicNIB.framework bundle version: %s", [[NIBManagerHandler getBundleVersion] UTF8String]);
00057     }
00058     return self;
00059 }
00060 
00061 
00062 - (void)dealloc {
00063     if (managers)
00064         [managers release];
00065     [super dealloc];
00066 }
00067 
00068 
00069 
00070 -(void)awakeFromNib {
00071     __THIS = self;
00072 }
00073 
00074 
00075 +(NSString *)getBundleVersion {
00076     return [[[NSBundle bundleForClass:[NIBManagerHandler class]] infoDictionary] objectForKey:@"CFBundleVersion"];
00077 }
00078 
00079 
00080 +(NSString *)getLocaleIdentifier {
00081         NSUserDefaults*         myDefaults = [NSUserDefaults standardUserDefaults];
00082         NSArray*                        myLanguages = [myDefaults objectForKey:@"AppleLanguages"];
00083 
00084         // Hack to convert the locale identifier of 'ja' to 'jp'
00085         if ([[myLanguages objectAtIndex:0] isEqualToString:@"ja"]) {
00086                 return LOCALE_JAPANESE;
00087         }
00088         return [myLanguages objectAtIndex:0];
00089 }
00090 
00091 
00092 +(BOOL)isEnglish {
00093     return [[NIBManagerHandler getLocaleIdentifier] isEqualTo:LOCALE_ENGLISH];
00094 }
00095 
00096 
00097 +(BOOL)isJapanese {
00098     return [[NIBManagerHandler getLocaleIdentifier] isEqualTo:LOCALE_JAPANESE];
00099 }
00100 
00101 
00102 +(NIBManagerHandler *)getHandler {
00103     if (__THIS)
00104         return __THIS;
00105     return (__THIS = [[[NIBManagerHandler alloc] init] retain]);
00106 }
00107 
00108 
00109 +(int)getLoggingLevel {
00110     return __LEVEL;
00111 }
00112 
00113 
00114 +(void)setLoggingLevel:(int)level {
00115         if (level == LOGGING_NONE)
00116                 NSLog(@"DynamicNIB.framework assigning logging level: NONE");
00117         if (level == LOGGING_NOTICE)
00118                 NSLog(@"DynamicNIB.framework assigning logging level: NOTICE");
00119         if (level == LOGGING_INFO)
00120                 NSLog(@"DynamicNIB.framework assigning logging level: INFO");
00121         if (level == LOGGING_DEBUG)
00122                 NSLog(@"DynamicNIB.framework assigning logging level: DEBUG");
00123     __LEVEL = level;
00124 }
00125 
00126 
00127 -(NIBContext *)getContext:(NSString *)type withIndex:(int)index {
00128         return [[self getManager:type] getContext:index];
00129 }
00130 
00131 
00132 -(NIBManager *)getManager:(NSString *)type {
00133         return [managers objectForKey:type];
00134 }
00135 
00136 
00137 -(void)setManager:(NIBManager *)manager withType:(NSString *)type {
00138         [managers setValue:manager forKey:type];
00139 }
00140 
00141 
00142 - (void)setBackingType:(NSString *)myType {
00143         NSArray *               types = [managers allKeys];
00144         int                             i ;
00145         
00146         for (i = 0; i < [types count]; i++)
00147                 [[self getManager:[types objectAtIndex:i]] setBackingType:myType];
00148 }
00149 
00150 
00151 - (void)setBackingStore:(NSString *)myStore {
00152         NSArray *               types = [managers allKeys];
00153         int                             i ;
00154         
00155         for (i = 0; i < [types count]; i++)
00156                 [[self getManager:[types objectAtIndex:i]] setBackingStore:myStore];
00157 }
00158 
00159 
00160 - (void)setScrolling:(BOOL)isScrolling {
00161         NSArray *               types = [managers allKeys];
00162         int                             i ;
00163         
00164         for (i = 0; i < [types count]; i++)
00165                 [[self getManager:[types objectAtIndex:i]] setScrolling:isScrolling];
00166 }
00167 
00168 
00169 - (void)setFlipped:(BOOL)isFlipped {
00170         NSArray *               types = [managers allKeys];
00171         int                             i ;
00172         
00173         for (i = 0; i < [types count]; i++)
00174                 [[self getManager:[types objectAtIndex:i]] setFlipped:isFlipped];
00175 }
00176 
00177 
00178 - (void)setDecorated:(BOOL)isDecorated {
00179         NSArray *               types = [managers allKeys];
00180         int                             i ;
00181         
00182         for (i = 0; i < [types count]; i++)
00183                 [[self getManager:[types objectAtIndex:i]] setDecorated:isDecorated];
00184 }
00185 
00186 
00187 - (void)setBounds:(NSRect)myBounds {
00188         NSArray *               types = [managers allKeys];
00189         int                             i ;
00190         
00191         for (i = 0; i < [types count]; i++)
00192                 [[self getManager:[types objectAtIndex:i]] setBounds:myBounds];
00193 }
00194 
00195 
00196 - (void)setAdjustment:(NSPoint)myAdjustment {
00197         NSArray *               types = [managers allKeys];
00198         int                             i ;
00199         
00200         for (i = 0; i < [types count]; i++)
00201                 [[self getManager:[types objectAtIndex:i]] setAdjustment:myAdjustment];
00202 }
00203 
00204 
00205 -(NIBManager *)doRegister:(NSString *)manager withType:(int)type {
00206         return [self doRegister:manager withType:type withPersistence:DOCUMENT];
00207 }
00208         
00209         
00210 -(NIBManager *)doRegister:(NSString *)identifier withType:(int)type withPersistence:(int)persistence {
00211         NIBManager *    manager;
00212         
00213         if ([NIBManagerHandler getLoggingLevel] >= LOGGING_NOTICE)
00214                 NSLog(@"DynamicNIB.framework creating/registering NIBManager: %s", [identifier UTF8String]);
00215      if (type == MANAGER_STAFFWARE) {
00216                 manager = [[[NIBManager alloc] init] retain];
00217         } else if (type == MANAGER_DOCUMENTUM) {
00218                 manager = [[[NIBManager alloc] init] retain];
00219         } else if (type == MANAGER_MAINFRAME) {
00220                 manager = [[[NIBManager alloc] init] retain];
00221         } else if (type == MANAGER_PENTAHO) {
00222                 manager = [[[NIBManager alloc] init] retain];
00223         }
00224         [manager setPersistenceMode:persistence];
00225         if (persistence != DOCUMENT) {
00226                 [managers setValue:manager forKey:identifier];
00227         }
00228         return manager;
00229 }
00230 
00231 
00232 - (void)doInitialise:(NSString *)type withPath:(NSString *)myPath {
00233         [self doInitialise:type withPath:myPath withCallback:nil];
00234 }
00235 
00236 
00237 - (void)doInitialise:(NSString *)type withPath:(NSString *)myPath withCallback:(NIBCallback *)myCallback {
00238         [self doInitialise:type withPath:myPath withCallback:myCallback withValidator:nil];
00239 }
00240 
00241 
00242 - (void)doInitialise:(NSString *)type withPath:(NSString *)myPath withCallback:(NIBCallback *)myCallback withValidator:(NIBValidator *)myValidator {
00243     NIBManager *      manager = [self getManager:type];
00244     
00245     if (manager)
00246         [manager doInitialise:myPath withCallback:myCallback withValidator:myValidator];
00247 }
00248 
00249 
00250 - (int)determineTag:(NSString *)type {
00251         NSArray *               types = [managers allKeys];
00252         int                             tag = -1;
00253         int                             i ;
00254         
00255         for (i = 0; i < [types count]; i++) {
00256                 tag = [[self getManager:[types objectAtIndex:i]] determineTag:type];
00257                 if (tag >= 0)
00258                         return tag;
00259         }
00260         return tag;
00261 }
00262 
00263 
00264 @end

Generated on Mon Dec 25 10:09:02 2006 for DoxyObjc by  doxygen 1.5.1