view dwt/internal/cocoa/NSObjectController.d @ 1:8b48be5454ce

The internal cocoa classes compile now
author Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
date Tue, 19 Aug 2008 17:35:17 +0200
parents 380af2bdd8e5
children f565d3a95c0a
line wrap: on
line source

/*******************************************************************************
 * 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.id;
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;
    }

}