CMenuComponent.m revision 6055
0N/A/*
1879N/A * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
0N/A * published by the Free Software Foundation. Oracle designates this
0N/A * particular file as subject to the "Classpath" exception as provided
0N/A * by Oracle in the LICENSE file that accompanied this code.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
1472N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
1472N/A *
1472N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
0N/A * or visit www.oracle.com if you need additional information or have any
0N/A * questions.
0N/A */
1879N/A
1879N/A#import "CMenuComponent.h"
1879N/A#import <JavaNativeFoundation/JavaNativeFoundation.h>
1879N/A
1879N/A#import "ThreadUtilities.h"
1879N/A
1879N/A@class CMenuItem;
0N/A
0N/A@implementation CMenuComponent
0N/A
0N/A-(id) initWithPeer:(jobject)peer {
0N/A self = [super init];
0N/A if (self) {
0N/A // the peer has been made clobal ref before
0N/A fPeer = peer;
0N/A }
0N/A return self;
518N/A}
518N/A
0N/A-(void) cleanup {
0N/A // Used by subclasses
0N/A}
0N/A
0N/A-(void) disposer {
518N/A JNIEnv *env = [ThreadUtilities getJNIEnvUncached];
518N/A JNFDeleteGlobalRef(env, fPeer);
518N/A fPeer = NULL;
0N/A
0N/A [self cleanup];
0N/A
0N/A CFRelease(self); // GC
0N/A}
0N/A
0N/A// The method is used by all subclasses, since the process of the creation
0N/A// is the same. The only exception is the CMenuItem class.
0N/A- (void) _create_OnAppKitThread: (NSMutableArray *)argValue {
0N/A jobject cPeerObjGlobal = (jobject)[[argValue objectAtIndex: 0] pointerValue];
0N/A CMenuItem *aCMenuItem = [self initWithPeer:cPeerObjGlobal];
0N/A [argValue removeAllObjects];
0N/A [argValue addObject: aCMenuItem];
0N/A}
0N/A
0N/A//-(void) dealloc { [super dealloc]; }
0N/A//- (void)finalize { [super finalize]; }
0N/A
0N/A@end
0N/A
0N/A/*
0N/A * Class: sun_lwawt_macosx_CMenuComponent
0N/A * Method: nativeDispose
0N/A * Signature: (J)V
0N/A */
0N/AJNIEXPORT void JNICALL
0N/AJava_sun_lwawt_macosx_CMenuComponent_nativeDispose
0N/A(JNIEnv *env, jobject peer, jlong menuItemObj)
0N/A{
0N/AJNF_COCOA_ENTER(env);
0N/A
0N/A [ThreadUtilities performOnMainThread:@selector(disposer)
0N/A on:((id)jlong_to_ptr(menuItemObj))
0N/A withObject:nil
0N/A waitUntilDone:NO];
0N/A
1155N/AJNF_COCOA_EXIT(env);
0N/A}
0N/A