Package org.rococoa

Examples of org.rococoa.ObjCObject


    public void testShow() {
        new JFrame().setVisible(true); // otherwise no panel
        NSOpenPanel panel = NSOpenPanel.CLASS.openPanel();
       
        // Keep this reference!
        ObjCObject ocProxy = Rococoa.proxy(new Object() {
            @SuppressWarnings("unused")
            public boolean panel_shouldShowFilename(ID panel, String filename) {
                char initialChar = new File(filename).getName().toLowerCase().charAt(0);
                return initialChar % 2 == 0;
            }
        });
       
        panel.setDelegate(ocProxy.id());
        int button = panel.runModalForTypes(null);
//              or, eg       
//                NSArray.CLASS.arrayWithObjects(
//                    NSString.stringWithString("txt"), null));
        NSString filenameAsNSString = panel.filename();
View Full Code Here


            return null;
        }
        if (arg instanceof ObjCObjectByReference) {
      // Forward conversion (another backwards conversion will take place in fillInReferences)
            IDByReference idref = new IDByReference();
      ObjCObject ob = ((ObjCObjectByReference)arg).getValueAs(ObjCObject.class);
      if (ob != null) {
        idref.setValue(ob.id());
            }
      return idref;
    }
        return arg;
    }
View Full Code Here

    @Test
    public void testDelegate() {
        NSAutoreleasePool pool = NSAutoreleasePool.new_();
        TestShunt shunt = Rococoa.create("TestShunt", TestShunt.class);
        final CountDownLatch count = new CountDownLatch(1);
        final ObjCObject callback = Rococoa.proxy(new TestShuntDelegate() {
            public void callback(ObjCObjectByReference reference) {
                // Success
                count.countDown();
            }
        });
        final ID delegate = callback.id();
        shunt.testCallbackWithReference(delegate);
        assertEquals("Callback to delegate failed", 0, count.getCount());
        pool.drain();
    }
View Full Code Here

    // Takes an NSObject and returns its id as Integer or Long
    public Object toNative(Object value, ToNativeContext context) {
        if (value == null) {
            return null;
        }
        ObjCObject valueAsNSObject = (ObjCObject) value;
        ID idToReturn = valueAsNSObject.id();
        return idToReturn.toNative();
    }
View Full Code Here

TOP

Related Classes of org.rococoa.ObjCObject

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.