60 // Headless: NO 61 // Embedded: NO 62 // Multiple Calls: NO 63 // Caller: +[NSApplication sharedApplication] 64 65 AWT_ASSERT_APPKIT_THREAD; 66 fApplicationName = nil; 67 dummyEventTimestamp = 0.0; 68 seenDummyEventLock = nil; 69 70 71 // NSApplication will call _RegisterApplication with the application's bundle, but there may not be one. 72 // So, we need to call it ourselves to ensure the app is set up properly. 73 [self registerWithProcessManager]; 74 75 return [super init]; 76 } 77 78 - (void)dealloc 79 { 80 [fApplicationName release]; 81 fApplicationName = nil; 82 83 [super dealloc]; 84 } 85 86 - (void)finishLaunching 87 { 88 AWT_ASSERT_APPKIT_THREAD; 89 90 JNIEnv *env = [ThreadUtilities getJNIEnv]; 91 92 // Get default nib file location 93 // NOTE: This should learn about the current java.version. Probably best thru 94 // the Makefile system's -DFRAMEWORK_VERSION define. Need to be able to pass this 95 // thru to PB from the Makefile system and for local builds. 96 NSString *defaultNibFile = [PropertiesUtilities javaSystemPropertyForKey:@"apple.awt.application.nib" withEnv:env]; 97 if (!defaultNibFile) { 98 NSBundle *javaBundle = [NSBundle bundleWithPath:SHARED_FRAMEWORK_BUNDLE]; 99 defaultNibFile = [javaBundle pathForResource:@"DefaultApp" ofType:@"nib"]; 121 NSMenuItem *appMenuItem = [theMainMenu itemAtIndex:0]; 122 NSMenu *appMenu = [appMenuItem submenu]; 123 itemCount = [appMenu numberOfItems]; 124 125 for (i = 0; i < itemCount; i++) { 126 NSMenuItem *anItem = [appMenu itemAtIndex:i]; 127 NSString *oldTitle = [anItem title]; 128 [anItem setTitle:[NSString stringWithFormat:oldTitle, fApplicationName]]; 129 } 130 } 131 132 if (applicationDelegate) { 133 [self setDelegate:applicationDelegate]; 134 } else { 135 qad = [QueuingApplicationDelegate sharedDelegate]; 136 [self setDelegate:qad]; 137 } 138 139 [super finishLaunching]; 140 141 // inform any interested parties that the AWT has arrived and is pumping 142 [[NSNotificationCenter defaultCenter] postNotificationName:JNFRunLoopDidStartNotification object:self]; 143 } 144 145 - (void) registerWithProcessManager 146 { 147 // Headless: NO 148 // Embedded: NO 149 // Multiple Calls: NO 150 // Caller: -[NSApplicationAWT init] 151 152 AWT_ASSERT_APPKIT_THREAD; 153 JNIEnv *env = [ThreadUtilities getJNIEnv]; 154 155 char envVar[80]; 156 157 // The following environment variable is set from the -Xdock:name param. It should be UTF8. 158 snprintf(envVar, sizeof(envVar), "APP_NAME_%d", getpid()); 159 char *appName = getenv(envVar); 160 if (appName != NULL) { 161 fApplicationName = [NSString stringWithUTF8String:appName]; 162 unsetenv(envVar); 163 } 164 | 60 // Headless: NO 61 // Embedded: NO 62 // Multiple Calls: NO 63 // Caller: +[NSApplication sharedApplication] 64 65 AWT_ASSERT_APPKIT_THREAD; 66 fApplicationName = nil; 67 dummyEventTimestamp = 0.0; 68 seenDummyEventLock = nil; 69 70 71 // NSApplication will call _RegisterApplication with the application's bundle, but there may not be one. 72 // So, we need to call it ourselves to ensure the app is set up properly. 73 [self registerWithProcessManager]; 74 75 return [super init]; 76 } 77 78 - (void)dealloc 79 { 80 [[NSUserNotificationCenter defaultUserNotificationCenter] setDelegate:nil]; 81 82 [fApplicationName release]; 83 fApplicationName = nil; 84 85 [super dealloc]; 86 } 87 88 - (void)finishLaunching 89 { 90 AWT_ASSERT_APPKIT_THREAD; 91 92 JNIEnv *env = [ThreadUtilities getJNIEnv]; 93 94 // Get default nib file location 95 // NOTE: This should learn about the current java.version. Probably best thru 96 // the Makefile system's -DFRAMEWORK_VERSION define. Need to be able to pass this 97 // thru to PB from the Makefile system and for local builds. 98 NSString *defaultNibFile = [PropertiesUtilities javaSystemPropertyForKey:@"apple.awt.application.nib" withEnv:env]; 99 if (!defaultNibFile) { 100 NSBundle *javaBundle = [NSBundle bundleWithPath:SHARED_FRAMEWORK_BUNDLE]; 101 defaultNibFile = [javaBundle pathForResource:@"DefaultApp" ofType:@"nib"]; 123 NSMenuItem *appMenuItem = [theMainMenu itemAtIndex:0]; 124 NSMenu *appMenu = [appMenuItem submenu]; 125 itemCount = [appMenu numberOfItems]; 126 127 for (i = 0; i < itemCount; i++) { 128 NSMenuItem *anItem = [appMenu itemAtIndex:i]; 129 NSString *oldTitle = [anItem title]; 130 [anItem setTitle:[NSString stringWithFormat:oldTitle, fApplicationName]]; 131 } 132 } 133 134 if (applicationDelegate) { 135 [self setDelegate:applicationDelegate]; 136 } else { 137 qad = [QueuingApplicationDelegate sharedDelegate]; 138 [self setDelegate:qad]; 139 } 140 141 [super finishLaunching]; 142 143 [[NSUserNotificationCenter defaultUserNotificationCenter] setDelegate:self]; 144 145 // inform any interested parties that the AWT has arrived and is pumping 146 [[NSNotificationCenter defaultCenter] postNotificationName:JNFRunLoopDidStartNotification object:self]; 147 } 148 149 - (BOOL)userNotificationCenter:(NSUserNotificationCenter *)center 150 shouldPresentNotification:(NSUserNotification *)notification 151 { 152 return YES; // We always show notifications to the user 153 } 154 155 - (void) registerWithProcessManager 156 { 157 // Headless: NO 158 // Embedded: NO 159 // Multiple Calls: NO 160 // Caller: -[NSApplicationAWT init] 161 162 AWT_ASSERT_APPKIT_THREAD; 163 JNIEnv *env = [ThreadUtilities getJNIEnv]; 164 165 char envVar[80]; 166 167 // The following environment variable is set from the -Xdock:name param. It should be UTF8. 168 snprintf(envVar, sizeof(envVar), "APP_NAME_%d", getpid()); 169 char *appName = getenv(envVar); 170 if (appName != NULL) { 171 fApplicationName = [NSString stringWithUTF8String:appName]; 172 unsetenv(envVar); 173 } 174 |