Mercurial > projects > dwt-mac
diff dwt/internal/cocoa/NSObjectController.d @ 0:380af2bdd8e5
Upload of whole dwt tree
author | Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com> |
---|---|
date | Sat, 09 Aug 2008 17:00:02 +0200 |
parents | |
children | 8b48be5454ce |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/cocoa/NSObjectController.d Sat Aug 09 17:00:02 2008 +0200 @@ -0,0 +1,196 @@ +/******************************************************************************* + * Copyright (c) 2007 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + * + * Port to the D Programming language: + * Jacob Carlborg <jacob.carlborg@gmail.com> + *******************************************************************************/ +module dwt.internal.cocoa.NSObjectController; + +import dwt.internal.cocoa.NSArray; +import dwt.internal.cocoa.NSController; +import dwt.internal.cocoa.NSPredicate; +import dwt.internal.cocoa.NSString; +import dwt.internal.cocoa.OS; +import objc = dwt.internal.objc.runtime; + +public class NSObjectController : NSController +{ + public this () + { + super(); + } + + public this (objc.id id) + { + super(id); + } + + public void add (id sender) + { + OS.objc_msgSend(this.id, OS.sel_add_1, sender !is null ? sender.id : null); + } + + public void addObject (id object) + { + OS.objc_msgSend(this.id, OS.sel_addObject_1, object !is null ? object.id : null); + } + + public bool automaticallyPreparesContent () + { + return OS.objc_msgSend(this.id, OS.sel_automaticallyPreparesContent) !is null; + } + + public bool canAdd () + { + return OS.objc_msgSend(this.id, OS.sel_canAdd) !is null; + } + + public bool canRemove () + { + return OS.objc_msgSend(this.id, OS.sel_canRemove) !is null; + } + + public id content () + { + objc.id result = OS.objc_msgSend(this.id, OS.sel_content); + return result !is null ? new id(result) : null; + } + + //public NSFetchRequest defaultFetchRequest() { + // objc.id result = OS.objc_msgSend(this.id, OS.sel_defaultFetchRequest); + // return result !is null ? new NSFetchRequest(result) : null; + //} + + public NSString entityName () + { + objc.id result = OS.objc_msgSend(this.id, OS.sel_entityName); + return result !is null ? new NSString(result) : null; + } + + public void fetch (id sender) + { + OS.objc_msgSend(this.id, OS.sel_fetch_1, sender !is null ? sender.id : null); + } + + public NSPredicate fetchPredicate () + { + objc.id result = OS.objc_msgSend(this.id, OS.sel_fetchPredicate); + return result !is null ? new NSPredicate(result) : null; + } + + // + //public bool fetchWithRequest(NSFetchRequest fetchRequest, bool merge, objc.id** error) { + // return OS.objc_msgSend(this.id, OS.sel_fetchWithRequest_1merge_1error_1, fetchRequest !is null ? fetchRequest.id : null, merge, error) !is null; + //} + + public NSObjectController initWithContent (id content) + { + objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithContent_1, content !is null ? content.id : null); + return result !is null ? this : null; + } + + public bool isEditable () + { + return OS.objc_msgSend(this.id, OS.sel_isEditable) !is null; + } + + //public NSManagedObjectContext managedObjectContext() { + // objc.id result = OS.objc_msgSend(this.id, OS.sel_managedObjectContext); + // return result !is null ? new NSManagedObjectContext(result) : null; + //} + + public id newObject () + { + objc.id result = OS.objc_msgSend(this.id, OS.sel_newObject); + return result !is null ? new id(result) : null; + } + + public objc.Class objectClass () + { + return cast(objc.Class) OS.objc_msgSend(this.id, OS.sel_objectClass); + } + + public void prepareContent () + { + OS.objc_msgSend(this.id, OS.sel_prepareContent); + } + + public void remove (id sender) + { + OS.objc_msgSend(this.id, OS.sel_remove_1, sender !is null ? sender.id : null); + } + + public void removeObject (id object) + { + OS.objc_msgSend(this.id, OS.sel_removeObject_1, object !is null ? object.id : null); + } + + public NSArray selectedObjects () + { + objc.id result = OS.objc_msgSend(this.id, OS.sel_selectedObjects); + return result !is null ? new NSArray(result) : null; + } + + public id selection () + { + objc.id result = OS.objc_msgSend(this.id, OS.sel_selection); + return result !is null ? new id(result) : null; + } + + public void setAutomaticallyPreparesContent (bool flag) + { + OS.objc_msgSend(this.id, OS.sel_setAutomaticallyPreparesContent_1, flag); + } + + public void setContent (id content) + { + OS.objc_msgSend(this.id, OS.sel_setContent_1, content !is null ? content.id : null); + } + + public void setEditable (bool flag) + { + OS.objc_msgSend(this.id, OS.sel_setEditable_1, flag); + } + + public void setEntityName (NSString entityName) + { + OS.objc_msgSend(this.id, OS.sel_setEntityName_1, entityName !is null ? entityName.id : null); + } + + public void setFetchPredicate (NSPredicate predicate) + { + OS.objc_msgSend(this.id, OS.sel_setFetchPredicate_1, predicate !is null ? predicate.id : null); + } + + //public void setManagedObjectContext(NSManagedObjectContext managedObjectContext) { + // OS.objc_msgSend(this.id, OS.sel_setManagedObjectContext_1, managedObjectContext !is null ? managedObjectContext.id : null); + //} + + public void setObjectClass (objc.Class objectClass) + { + OS.objc_msgSend(this.id, OS.sel_setObjectClass_1, objectClass); + } + + public void setUsesLazyFetching (bool enabled) + { + OS.objc_msgSend(this.id, OS.sel_setUsesLazyFetching_1, enabled); + } + + public bool usesLazyFetching () + { + return OS.objc_msgSend(this.id, OS.sel_usesLazyFetching) !is null; + } + + public bool validateUserInterfaceItem (id item) + { + return OS.objc_msgSend(this.id, OS.sel_validateUserInterfaceItem_1, item !is null ? item.id : null) !is null; + } + +}