Package net.rim.device.api.script

Examples of net.rim.device.api.script.Scriptable


    public void loadFeature( String feature, String version, Document doc, ScriptEngine scriptEngine ) throws Exception {
        if( feature.equals( FEATURE_NAME ) ) {
            _messageFeaturesHandler.addFeature( feature, new MessagingNamespace() );
        } else if( feature.equals( getFormattedFeatureName( FEATURE_NAME_SMS ) ) ) {
            Class cl = Class.forName( "blackberry.message.sms.SMSNamespace" );
            Scriptable smsNamespace = (Scriptable) cl.newInstance();
            _messageFeaturesHandler.addFeature( feature, smsNamespace );
        }

        scriptEngine.addExtension( FEATURE_NAME, _messageFeaturesHandler );
View Full Code Here


        /**
         * @see net.rim.device.api.script.Scriptable#getField(java.lang.String)
         */
        public Object getField( final String fieldName ) throws Exception {

            Scriptable featureImplementation = (Scriptable) _features.get( getFormattedFeatureName( fieldName ) );

            if( featureImplementation != null ) {
                return featureImplementation;
            } else {
                featureImplementation = (Scriptable) _features.get( FEATURE_NAME );

                if( featureImplementation != null ) {
                    return featureImplementation.getField( fieldName );
                }
            }

            return super.getField( fieldName );
        }
View Full Code Here

    protected void makeMenu(final Menu menu, final int instance) {
        super.makeMenu(menu, instance);
        if (_documentLoaded
                && _browserField.getDocumentUrl().equals("local:///index.html")) {
            try {
                final Scriptable contextMenuItems =
                        (Scriptable) _browserField.getScriptEngine()
                                .executeScript("makeContextMenu()", null);
                if (contextMenuItems != null) {
                    MenuItem defaultItem = null;
                    final Integer length =
                            (Integer) contextMenuItems.getField("length");
                    for (int i = 0; i < length.intValue(); i++) {
                        final Scriptable menuItem =
                                (Scriptable) contextMenuItems.getElement(i);
                        if (menuItem != null) {
                            final String label =
                                    (String) menuItem.getField("label");
                            final Object action = menuItem.getField("action");
                            MenuItem item = null;
                            if (action instanceof String) {
                                item =
                                        new ScriptableMenuItem(label,
                                                new SimpleScriptableFunction(
                                                        (String) action));
                            } else if (action instanceof ScriptableFunction) {
                                item =
                                        new ScriptableMenuItem(label,
                                                (ScriptableFunction) action);
                            }
                            if (item != null) {
                                menu.add(item);
                                final Object isDefault =
                                        menuItem.getField("defaultItem");
                                if (isDefault != null
                                        && Scriptable.UNDEFINED
                                                .equals(isDefault) == false
                                        && ((Boolean) isDefault).booleanValue()) {
                                    defaultItem = item;
View Full Code Here

TOP

Related Classes of net.rim.device.api.script.Scriptable

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.