Package net.rim.device.api.command

Examples of net.rim.device.api.command.CommandHandler


        add(_views[5]);

        final MenuItem cancelItem =
                new MenuItem(new StringProvider("Cancel spinners "), 0x230020,
                        0);
        cancelItem.setCommand(new Command(new CommandHandler() {
            /**
             * @see net.rim.device.api.command.CommandHandler#execute(ReadOnlyCommandMetadata,
             *      Object)
             */
            public void execute(final ReadOnlyCommandMetadata metadata,
                    final Object context) {
                for (int i = _views.length - 1; i >= 0; --i) {
                    _views[i].getModel().cancel();
                }
            }
        }));

        final MenuItem resetItem =
                new MenuItem(new StringProvider("Reset spinners "), 0x230030, 0);
        resetItem.setCommand(new Command(new CommandHandler() {
            /**
             * @see net.rim.device.api.command.CommandHandler#execute(ReadOnlyCommandMetadata,
             *      Object)
             */
            public void execute(final ReadOnlyCommandMetadata metadata,
                    final Object context) {
                for (int i = _views.length - 1; i >= 0; --i) {
                    _views[i].getModel().reset();
                }
            }
        }));

        final MenuItem resumeItem =
                new MenuItem(new StringProvider("Resume spinners "), 0x230040,
                        0);
        resumeItem.setCommand(new Command(new CommandHandler() {
            /**
             * @see net.rim.device.api.command.CommandHandler#execute(ReadOnlyCommandMetadata,
             *      Object)
             */
            public void execute(final ReadOnlyCommandMetadata metadata,
                    final Object context) {
                for (int i = _views.length - 1; i >= 0; --i) {
                    _views[i].getModel().resume();
                }
            }
        }));

        final MenuItem delayedStop =
                new MenuItem(new StringProvider("Delayed start"), 0x230050, 0);
        delayedStop.setCommand(new Command(new CommandHandler() {
            /**
             * @see net.rim.device.api.command.CommandHandler#execute(ReadOnlyCommandMetadata,
             *      Object)
             */
            public void execute(final ReadOnlyCommandMetadata metadata,
                    final Object context) {
                for (int i = _views.length - 1; i >= 0; --i) {
                    final DelayedStart ds = new DelayedStart(_views[i]);
                    ds.start();
                }
            }
        }));

        final MenuItem delayedStart =
                new MenuItem(new StringProvider("Delayed stop"), 0x230060, 0);
        delayedStart.setCommand(new Command(new CommandHandler() {
            /**
             * @see net.rim.device.api.command.CommandHandler#execute(ReadOnlyCommandMetadata,
             *      Object)
             */
            public void execute(final ReadOnlyCommandMetadata metadata,
                    final Object context) {
                for (int i = _views.length - 1; i >= 0; --i) {
                    final DelayedStop ds = new DelayedStop(_views[i]);
                    ds.start();
                }
            }
        }));

        final MenuItem showPopupItem =
                new MenuItem(new StringProvider("Show Popup"), 0x230010, 0);
        showPopupItem.setCommand(new Command(new CommandHandler() {
            /**
             * @see net.rim.device.api.command.CommandHandler#execute(ReadOnlyCommandMetadata,
             *      Object)
             */
            public void execute(final ReadOnlyCommandMetadata metadata,
View Full Code Here


        add(instructions);

        // Invokes BlackBerry Maps application using a MapView object
        final MenuItem viewMapItem =
                new MenuItem(new StringProvider("View Map"), 0x230010, 0);
        viewMapItem.setCommand(new Command(new CommandHandler() {
            /**
             * @see net.rim.device.api.command.CommandHandler#execute(ReadOnlyCommandMetadata,
             *      Object)
             */
            public void execute(final ReadOnlyCommandMetadata metadata,
View Full Code Here

            rowObjects[YEAR] = year;
            rowObjects[INTERFACES] = interfaces;
            richList.add(rowObjects);
        }

        richList.setCommand(new Command(new CommandHandler() {
            /**
             * @see net.rim.device.api.command.CommandHandler#execute(ReadOnlyCommandMetadata,
             *      Object)
             */
            public void execute(final ReadOnlyCommandMetadata metadata,
View Full Code Here

     */
    void addMenuItems(final MainScreen mainScreen) {
        final MenuItemWithIcon appendUnreadMessage =
                new MenuItemWithIcon("Append Unread Message", 0,
                        "img/sm_add_message.png");
        appendUnreadMessage.setCommand(new Command(new CommandHandler() {
            /**
             * @see net.rim.device.api.command.CommandHandler#execute(ReadOnlyCommandMetadata,
             *      Object)
             */
            public void execute(final ReadOnlyCommandMetadata metadata,
                    final Object context) {
                // Create a new message
                final DemoMessage message = new DemoMessage();
                message.setSender("John Smith");
                message.setSubject("Hello from John");
                message.setMessage("Hello Chris. Do you know that you can get a BlackBerry Smartphone cheaper through the Message List Demo Store?");
                message.setReceivedTime(System.currentTimeMillis());
                message.setPreviewPicture(CommunicationSimulatorThread
                        .getRandomPhotoImage());

                // Store message
                final MessageListDemoStore messageStore =
                        MessageListDemoStore.getInstance();
                synchronized (messageStore) {
                    messageStore.addInboxMessage(message);
                }

                Dialog.alert("Unread message was added to inbox");

                // Notify folder
                final ApplicationMessageFolder inboxFolder =
                        messageStore.getInboxFolder();
                inboxFolder.fireElementAdded(message, true);
            }
        }));
        mainScreen.addMenuItem(appendUnreadMessage);

        final MenuItemWithIcon appendOpenedMessage =
                new MenuItemWithIcon("Append Opened Message", 1,
                        "img/sm_add_message.png");
        appendOpenedMessage.setCommand(new Command(new CommandHandler() {
            /**
             * @see net.rim.device.api.command.CommandHandler#execute(ReadOnlyCommandMetadata,
             *      Object)
             */
            public void execute(final ReadOnlyCommandMetadata metadata,
                    final Object context) {
                // Create a new message
                final DemoMessage message = new DemoMessage();
                message.setSender("Maria Rosevelt");
                message.setSubject("How have you been?");
                message.setMessage("Hi Chris. I haven't seen you in ages.  Let's do lunch!");
                message.setReceivedTime(System.currentTimeMillis() - 2 * 24
                        * 60 * 60 * 1000L);
                message.setPreviewPicture(CommunicationSimulatorThread
                        .getRandomPhotoImage());
                message.markRead();

                // Store message
                final MessageListDemoStore messageStore =
                        MessageListDemoStore.getInstance();
                synchronized (messageStore) {
                    messageStore.addInboxMessage(message);
                }

                Dialog.alert("Opened message was added to inbox");

                // Notify folder
                messageStore.getInboxFolder().fireElementAdded(message);
            }
        }));
        mainScreen.addMenuItem(appendOpenedMessage);

        final MenuItemWithIcon appendMessagesInBulk =
                new MenuItemWithIcon("Append Messages in Bulk", 2,
                        "sm_add_messages_bulk");
        appendMessagesInBulk.setCommand(new Command(new CommandHandler() {
            /**
             * @see net.rim.device.api.command.CommandHandler#execute(ReadOnlyCommandMetadata,
             *      Object)
             */
            public void execute(final ReadOnlyCommandMetadata metadata,
                    final Object context) {
                final MessageListDemoStore messageStore =
                        MessageListDemoStore.getInstance();
                synchronized (messageStore) {
                    for (int i = 1; i <= MAX_MSGS; i++) {
                        // Create a new message
                        final DemoMessage message = new DemoMessage();
                        message.setSender("Mark Duval");
                        message.setSubject(i + " of " + MAX_MSGS);
                        message.setMessage("Please pick up milk and bread on the way home.");
                        message.setReceivedTime(System.currentTimeMillis());
                        message.setPreviewPicture(CommunicationSimulatorThread
                                .getRandomPhotoImage());

                        // Store message in the runtime store
                        messageStore.addInboxMessage(message);
                    }

                    // Notify folder
                    final ApplicationMessageFolder inboxFolder =
                            messageStore.getInboxFolder();
                    inboxFolder.fireReset(true);
                }

                Dialog.alert("Bulk messages were added to inbox");
            }
        }));
        mainScreen.addMenuItem(appendMessagesInBulk);

        final MenuItemWithIcon startCommunicationThread =
                new MenuItemWithIcon("Start Communication Thread", 3,
                        "sm_start_auto");
        startCommunicationThread.setCommand(new Command(new CommandHandler() {
            /**
             * @see net.rim.device.api.command.CommandHandler#execute(ReadOnlyCommandMetadata,
             *      Object)
             */
            public void execute(final ReadOnlyCommandMetadata metadata,
                    final Object context) {
                if (_commThread != null) {
                    Dialog.alert("Communication thread already running");
                    return;
                }

                _commThread = new CommunicationSimulatorThread();
                _commThread.start();

                Dialog.alert("Communication thread started successfully.\n After dismissing this dialog, press the End (red phone) key and"
                        + " open the Messages application from the home screen.");
            }
        }));
        mainScreen.addMenuItem(startCommunicationThread);

        final MenuItemWithIcon stopCommunicationThread =
                new MenuItemWithIcon("Stop Communication Thread", 4,
                        "sm_stop_auto");
        stopCommunicationThread.setCommand(new Command(new CommandHandler() {
            /**
             * @see net.rim.device.api.command.CommandHandler#execute(ReadOnlyCommandMetadata,
             *      Object)
             */
            public void execute(final ReadOnlyCommandMetadata metadata,
                    final Object context) {
                if (_commThread == null) {
                    Dialog.alert("Communication thread is not running");
                    return;
                }
                _commThread.stopRunning();
                _commThread = null;
                Dialog.alert("Communication thread stopped.");
            }
        }));
        mainScreen.addMenuItem(stopCommunicationThread);

        final MenuItemWithIcon viewMessagesInMessageList =
                new MenuItemWithIcon("View Messages In Message List", 5,
                        "sm_open_messages_app");
        viewMessagesInMessageList.setCommand(new Command(new CommandHandler() {
            /**
             * @see net.rim.device.api.command.CommandHandler#execute(ReadOnlyCommandMetadata,
             *      Object)
             */
            public void execute(final ReadOnlyCommandMetadata metadata,
View Full Code Here

        // Set the controller focus policy to highlight rows
        tableController.setFocusPolicy(TableController.ROW_FOCUS);

        // Set the behaviour of the controller when a table item is clicked
        tableController.setCommand(new Command(new CommandHandler() {
            /**
             * @see CommandHandler#execute(ReadOnlyCommandMetadata, Object)
             */
            public void execute(final ReadOnlyCommandMetadata metadata,
                    final Object context) {
View Full Code Here

        _scalableGraphics = ScalableGraphics.createInstance();

        // A menu item used to erase all elements on the screen
        final MenuItem eraseMenu =
                new MenuItem(new StringProvider("Erase Canvas"), 0x230010, 0);
        eraseMenu.setCommand(new Command(new CommandHandler() {
            /**
             * @see net.rim.device.api.command.CommandHandler#execute(ReadOnlyCommandMetadata,
             *      Object)
             */
            public void execute(final ReadOnlyCommandMetadata metadata,
                    final Object context) {
                // Reset the last x and y coordinates.
                _lastX = -1;
                _lastY = -1;

                // Remove all children from the svg node.
                SVGElement line = (SVGElement) _svg.getFirstElementChild();
                while (line != null) {
                    _svg.removeChild(line);
                    line = (SVGElement) _svg.getFirstElementChild();
                }

                // Indicate that the screen requires re-painting.
                invalidate();
            }
        }));

        // A menu item used to select a line color
        final MenuItem colourMenu =
                new MenuItem(new StringProvider("Change Colour"), 0x230020, 1);
        colourMenu.setCommand(new Command(new CommandHandler() {
            /**
             * @see net.rim.device.api.command.CommandHandler#execute(ReadOnlyCommandMetadata,
             *      Object)
             */
            public void execute(final ReadOnlyCommandMetadata metadata,
                    final Object context) {
                final ColorChangeDialog dialog =
                        new ColorChangeDialog(_colorIndex);

                if (dialog.doModal() == Dialog.OK) {
                    _colorIndex = dialog.getColorIndex();
                    _color = dialog.getColor(_colorIndex);
                }
            }
        }));

        // A menu item used to select a line color
        final MenuItem widthMenu =
                new MenuItem(new StringProvider("Change Width"), 0x230030, 2);
        widthMenu.setCommand(new Command(new CommandHandler() {
            /**
             * @see net.rim.device.api.command.CommandHandler#execute(ReadOnlyCommandMetadata,
             *      Object)
             */
            public void execute(final ReadOnlyCommandMetadata metadata,
View Full Code Here

            // Add a menu item to display an animation in a popup screen
            final MenuItem showAnimation =
                    new MenuItem(new StringProvider("Show Animation"),
                            0x230010, 0);
            showAnimation.setCommand(new Command(new CommandHandler() {
                /**
                 * @see net.rim.device.api.command.CommandHandler#execute(ReadOnlyCommandMetadata,
                 *      Object)
                 */
                public void execute(final ReadOnlyCommandMetadata metadata,
View Full Code Here

        /**
         * Creates a new BackMenuItem object
         */
        private BackMenuItem() {
            super(new StringProvider("Back"), 0x230020, 5);
            this.setCommand(new Command(new CommandHandler() {

                /**
                 * Closes this screen
                 *
                 * @see net.rim.device.api.command.CommandHandler#execute(ReadOnlyCommandMetadata,
View Full Code Here

            // Menu Item to add the current location to the list of WayPoints
            final MenuItem markWayPoint =
                    new MenuItem(new StringProvider("Mark waypoint"), 0x230010,
                            0);
            markWayPoint.setCommand(new Command(new CommandHandler() {
                /**
                 * @see net.rim.device.api.command.CommandHandler#execute(ReadOnlyCommandMetadata,
                 *      Object)
                 */
                public void execute(final ReadOnlyCommandMetadata metadata,
                        final Object context) {
                    GPSDemo.this.markPoint();
                }
            }));

            // Menu Item to view the marked WayPoints
            final MenuItem viewWayPoints =
                    new MenuItem(new StringProvider("View waypoints"),
                            0x230020, 1);
            viewWayPoints.setCommand(new Command(new CommandHandler() {
                /**
                 * @see net.rim.device.api.command.CommandHandler#execute(ReadOnlyCommandMetadata,
                 *      Object)
                 */
                public void execute(final ReadOnlyCommandMetadata metadata,
View Full Code Here

                Field.NON_FOCUSABLE));

        // Displays a map of a specified locaton.
        final MenuItem viewMapItem =
                new MenuItem(new StringProvider("View Map"), 0x230020, 0);
        viewMapItem.setCommand(new Command(new CommandHandler() {
            /**
             * @see net.rim.device.api.command.CommandHandler#execute(ReadOnlyCommandMetadata,
             *      Object)
             */
            public void execute(final ReadOnlyCommandMetadata metadata,
View Full Code Here

TOP

Related Classes of net.rim.device.api.command.CommandHandler

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.