Package net.rim.device.api.command

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


        add(_view);

        // Menu item to create a new meeting
        final MenuItem newMeetingItem =
                new MenuItem(new StringProvider("New Meeting"), 0x230010, 0);
        newMeetingItem.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 Meeting meeting = new Meeting();
                _uiApp.pushScreen(new MeetingScreen(meeting, -1, true));
            }
        }));

        viewItem = new MenuItem(new StringProvider("View"), 0x230020, 1);
        viewItem.setCommand(new Command(new CommandHandler() {
            /**
             * @see net.rim.device.api.command.CommandHandler#execute(ReadOnlyCommandMetadata,
             *      Object)
             */
            public void execute(final ReadOnlyCommandMetadata metadata,
                    final Object context) {
                displayMeeting(false);
            }
        }));

        editItem = new MenuItem(new StringProvider("Edit"), 0x230030, 2);
        editItem.setCommand(new Command(new CommandHandler() {
            /**
             * @see net.rim.device.api.command.CommandHandler#execute(ReadOnlyCommandMetadata,
             *      Object)
             */
            public void execute(final ReadOnlyCommandMetadata metadata,
                    final Object context) {
                displayMeeting(true);
            }
        }));

        deleteItem = new MenuItem(new StringProvider("Delete"), 0x230040, 3);
        deleteItem.setCommand(new Command(new CommandHandler() {
            /**
             * @see net.rim.device.api.command.CommandHandler#execute(ReadOnlyCommandMetadata,
             *      Object)
             */
            public void execute(final ReadOnlyCommandMetadata metadata,
                    final Object context) {
                // Retrieve the highlighted Meeting object and remove it from
                // the
                // vector, then update the list field to reflect the change.
                final int i = _view.getRowNumberWithFocus();
                final String meetingName =
                        ((Meeting) _uiApp.getMeetings().elementAt(i))
                                .getField(Meeting.MEETING_NAME);
                final int result =
                        Dialog.ask(Dialog.DELETE, "Delete " + meetingName + "?");
                if (result == Dialog.YES) {
                    _model.removeRowAt(i);
                }
            }
        }));

        // Menu item to gain access to the controlled object
        final MenuItem retrieveItem =
                new MenuItem(new StringProvider("Access controlled object"),
                        0x230050, 0);
        retrieveItem.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


        // Create the view
        _view = new TableView(_model);

        // Create the controller
        _controller = new TableController(_model, _view);
        _controller.setCommand(new Command(new CommandHandler() {
            /**
             * @see CommandHandler#execute(ReadOnlyCommandMetadata, Object)
             */
            public void execute(final ReadOnlyCommandMetadata metadata,
                    final Object context) {
                displayWayPoint();
            }

        }));

        _view.setController(_controller);

        // Set the highlight style for the view
        _view.setDataTemplateFocus(BackgroundFactory
                .createLinearGradientBackground(Color.LIGHTBLUE,
                        Color.LIGHTBLUE, Color.BLUE, Color.BLUE));

        // Create a data template that will format the model data as an array of
        // LabelFields
        final DataTemplate dataTemplate = new DataTemplate(_view, 1, 1) {
            public Field[] getDataFields(final int modelRowIndex) {
                final Field[] fields =
                        { new LabelField("Waypoint " + modelRowIndex,
                                DrawStyle.ELLIPSIS | Field.NON_FOCUSABLE) };

                return fields;
            }
        };

        // Define the regions of the data template and column/row size
        dataTemplate.createRegion(new XYRect(0, 0, 1, 1));
        dataTemplate.setColumnProperties(0, new TemplateColumnProperties(
                Display.getWidth()));
        dataTemplate.setRowProperties(0, new TemplateRowProperties(24));

        _view.setDataTemplate(dataTemplate);
        dataTemplate.useFixedHeight(true);

        vfm.add(_view);
        add(vfm);

        _viewPointAction =
                new MenuItem(new StringProvider("View"), 0x230010, 0);
        _viewPointAction.setCommand(new Command(new CommandHandler() {
            /**
             * @see net.rim.device.api.command.CommandHandler#execute(ReadOnlyCommandMetadata,
             *      Object)
             */
            public void execute(final ReadOnlyCommandMetadata metadata,
                    final Object context) {
                displayWayPoint();
            }
        }));

        _deletePointAction =
                new MenuItem(new StringProvider("Delete"), 0x230020, 1);
        _deletePointAction.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

            _turnOffAutoFocusMenuItem =
                    new MenuItem(new StringProvider("Turn Off Auto-Focus"),
                            0x230020, 0);
            _turnOffAutoFocusMenuItem.setCommand(new Command(
                    new CommandHandler() {
                        /**
                         * @see CommandHandler#execute(ReadOnlyCommandMetadata,
                         *      Object)
                         */
                        public void execute(
                                final ReadOnlyCommandMetadata metadata,
                                final Object context) {
                            try {
                                if (_efc != null) {
                                    _efc.stopAutoFocus();
                                } else {
                                    CameraDemo
                                            .errorDialog("ERROR: Focus control not initialized.");
                                }
                            } catch (final Exception e) {
                                CameraDemo.errorDialog("ERROR " + e.getClass()
                                        + ":  " + e.getMessage());
                            }
                        }
                    }));

            _turnOnAutoFocusMenuItem =
                    new MenuItem(new StringProvider("Turn on Auto-Focus"),
                            0x230020, 0);
            _turnOnAutoFocusMenuItem.setCommand(new Command(
                    new CommandHandler() {
                        /**
                         * @see CommandHandler#execute(ReadOnlyCommandMetadata,
                         *      Object)
                         */
                        public void execute(
                                final ReadOnlyCommandMetadata metadata,
                                final Object context) {
                            try {
                                if (_efc != null) {
                                    _efc.startAutoFocus();
                                } else {
                                    CameraDemo
                                            .errorDialog("ERROR: Focus control not initialized.");
                                }
                            } catch (final Exception e) {
                                CameraDemo.errorDialog("ERROR " + e.getClass()
                                        + ":  " + e.getMessage());
                            }
                        }
                    }));

            final MenuItem encodingMenuItem =
                    new MenuItem(new StringProvider("Encoding Settings"),
                            0x230010, 0);
            encodingMenuItem.setCommand(new Command(new CommandHandler() {
                /**
                 * @see CommandHandler#execute(ReadOnlyCommandMetadata, Object)
                 */
                public void execute(final ReadOnlyCommandMetadata metadata,
                        final Object context) {
View Full Code Here

            // Check for fixed focus mode support
            if (_efc.isFocusModeSupported(EnhancedFocusControl.FOCUS_MODE_FIXED)) {
                final MenuItem enableFixedFocus =
                        new MenuItem(new StringProvider(
                                "Enable Fixed Auto Focus"), 0x230010, 0);
                enableFixedFocus.setCommand(new Command(new CommandHandler() {
                    /**
                     * @see CommandHandler#execute(ReadOnlyCommandMetadata,
                     *      Object)
                     */
                    public void execute(final ReadOnlyCommandMetadata metadata,
                            final Object context) {
                        final EnhancedFocusControl efc =
                                (EnhancedFocusControl) _player
                                        .getControl("net.rim.device.api.amms.control.camera.EnhancedFocusControl");
                        efc.setFocusMode(EnhancedFocusControl.FOCUS_MODE_FIXED);
                    };
                }));

                focusMenuItems.addElement(enableFixedFocus);
            }

            // Check for continuous focus mode support
            if (_efc.isFocusModeSupported(EnhancedFocusControl.FOCUS_MODE_CONTINUOUS)) {
                final MenuItem enableContinuousAutoFocus =
                        new MenuItem(new StringProvider(
                                "Enable Continuous Auto Focus"), 0x230020, 0);
                enableContinuousAutoFocus.setCommand(new Command(
                        new CommandHandler() {
                            /**
                             * @see CommandHandler#execute(ReadOnlyCommandMetadata,
                             *      Object)
                             */
                            public void execute(
                                    final ReadOnlyCommandMetadata metadata,
                                    final Object context) {
                                final EnhancedFocusControl efc =
                                        (EnhancedFocusControl) _player
                                                .getControl("net.rim.device.api.amms.control.camera.EnhancedFocusControl");
                                efc.setFocusMode(EnhancedFocusControl.FOCUS_MODE_CONTINUOUS);
                            };
                        }));

                focusMenuItems.addElement(enableContinuousAutoFocus);
            }

            // Check for single shot focus mode support
            if (_efc.isFocusModeSupported(EnhancedFocusControl.FOCUS_MODE_SINGLESHOT)) {
                final MenuItem enableSingleShotAutoFocus =
                        new MenuItem(new StringProvider(
                                "Enable Single Shot Auto Focus"), 0x230030, 0);
                enableSingleShotAutoFocus.setCommand(new Command(
                        new CommandHandler() {
                            /**
                             * @see CommandHandler#execute(ReadOnlyCommandMetadata,
                             *      Object)
                             */
                            public void execute(
View Full Code Here

                final MenuItem enableSceneModeAuto =
                        new MenuItem(new StringProvider(
                                "Enable Scene Mode: AUTO"), Integer.MAX_VALUE,
                                0);
                enableSceneModeAuto.setCommand(new Command(
                        new CommandHandler() {
                            /**
                             * @see CommandHandler#execute(ReadOnlyCommandMetadata,
                             *      Object)
                             */
                            public void execute(
                                    final ReadOnlyCommandMetadata metadata,
                                    final Object context) {
                                featureControl
                                        .setSceneMode(FeatureControl.SCENE_MODE_AUTO);
                            };
                        }));

                sceneModeMenuItems.addElement(enableSceneModeAuto);
            }

            // Check for beach scene mode support
            if (featureControl
                    .isSceneModeSupported(FeatureControl.SCENE_MODE_BEACH)) {
                final MenuItem enableSceneModeBeach =
                        new MenuItem(new StringProvider(
                                "Enable Scene Mode: BEACH"), Integer.MAX_VALUE,
                                0);
                enableSceneModeBeach.setCommand(new Command(
                        new CommandHandler() {
                            /**
                             * @see CommandHandler#execute(ReadOnlyCommandMetadata,
                             *      Object)
                             */
                            public void execute(
                                    final ReadOnlyCommandMetadata metadata,
                                    final Object context) {
                                featureControl
                                        .setSceneMode(FeatureControl.SCENE_MODE_BEACH);
                            };
                        }));

                sceneModeMenuItems.addElement(enableSceneModeBeach);
            }

            // Check for face detection scene mode support
            if (featureControl
                    .isSceneModeSupported(FeatureControl.SCENE_MODE_FACEDETECTION)) {
                final MenuItem enableSceneModeFaceDetection =
                        new MenuItem(new StringProvider(
                                "Enable Scene Mode: FACE DETECTION"),
                                Integer.MAX_VALUE, 0);
                enableSceneModeFaceDetection.setCommand(new Command(
                        new CommandHandler() {
                            /**
                             * @see CommandHandler#execute(ReadOnlyCommandMetadata,
                             *      Object)
                             */
                            public void execute(
                                    final ReadOnlyCommandMetadata metadata,
                                    final Object context) {
                                featureControl
                                        .setSceneMode(FeatureControl.SCENE_MODE_FACEDETECTION);
                            };
                        }));

                sceneModeMenuItems.addElement(enableSceneModeFaceDetection);
            }

            // Check for landscape scene mode support
            if (featureControl
                    .isSceneModeSupported(FeatureControl.SCENE_MODE_LANDSCAPE)) {
                final MenuItem enableSceneModeLandscape =
                        new MenuItem(new StringProvider(
                                "Enable Scene Mode: LANDSCAPE"),
                                Integer.MAX_VALUE, 0);
                enableSceneModeLandscape.setCommand(new Command(
                        new CommandHandler() {
                            /**
                             * @see CommandHandler#execute(ReadOnlyCommandMetadata,
                             *      Object)
                             */
                            public void execute(
                                    final ReadOnlyCommandMetadata metadata,
                                    final Object context) {
                                featureControl
                                        .setSceneMode(FeatureControl.SCENE_MODE_LANDSCAPE);
                            };
                        }));

                sceneModeMenuItems.addElement(enableSceneModeLandscape);
            }

            // Check for macro scene mode support
            if (featureControl
                    .isSceneModeSupported(FeatureControl.SCENE_MODE_MACRO)) {
                final MenuItem enableSceneModeMacro =
                        new MenuItem(new StringProvider(
                                "Enable Scene Mode: MACRO"), Integer.MAX_VALUE,
                                0);
                enableSceneModeMacro.setCommand(new Command(
                        new CommandHandler() {
                            /**
                             * @see CommandHandler#execute(ReadOnlyCommandMetadata,
                             *      Object)
                             */
                            public void execute(
                                    final ReadOnlyCommandMetadata metadata,
                                    final Object context) {
                                featureControl
                                        .setSceneMode(FeatureControl.SCENE_MODE_MACRO);
                            };
                        }));

                sceneModeMenuItems.addElement(enableSceneModeMacro);
            }

            // Check for night scene mode support
            if (featureControl
                    .isSceneModeSupported(FeatureControl.SCENE_MODE_NIGHT)) {
                final MenuItem enableSceneModeNight =
                        new MenuItem(new StringProvider(
                                "Enable Scene Mode: NIGHT"), Integer.MAX_VALUE,
                                0);
                enableSceneModeNight.setCommand(new Command(
                        new CommandHandler() {
                            /**
                             * @see CommandHandler#execute(ReadOnlyCommandMetadata,
                             *      Object)
                             */
                            public void execute(
                                    final ReadOnlyCommandMetadata metadata,
                                    final Object context) {
                                featureControl
                                        .setSceneMode(FeatureControl.SCENE_MODE_NIGHT);
                            };
                        }));

                sceneModeMenuItems.addElement(enableSceneModeNight);
            }

            // Check for party scene mode support
            if (featureControl
                    .isSceneModeSupported(FeatureControl.SCENE_MODE_PARTY)) {
                final MenuItem enableSceneModeParty =
                        new MenuItem(new StringProvider(
                                "Enable Scene Mode: PARTY"), Integer.MAX_VALUE,
                                0);
                enableSceneModeParty.setCommand(new Command(
                        new CommandHandler() {
                            /**
                             * @see CommandHandler#execute(ReadOnlyCommandMetadata,
                             *      Object)
                             */
                            public void execute(
                                    final ReadOnlyCommandMetadata metadata,
                                    final Object context) {
                                featureControl
                                        .setSceneMode(FeatureControl.SCENE_MODE_PARTY);
                            };
                        }));

                sceneModeMenuItems.addElement(enableSceneModeParty);
            }

            // Check for portrait scene mode support
            if (featureControl
                    .isSceneModeSupported(FeatureControl.SCENE_MODE_PORTRAIT)) {
                final MenuItem enableSceneModePortrait =
                        new MenuItem(new StringProvider(
                                "Enable Scene Mode: PORTRAIT"),
                                Integer.MAX_VALUE, 0);
                enableSceneModePortrait.setCommand(new Command(
                        new CommandHandler() {
                            /**
                             * @see CommandHandler#execute(ReadOnlyCommandMetadata,
                             *      Object)
                             */
                            public void execute(
                                    final ReadOnlyCommandMetadata metadata,
                                    final Object context) {
                                featureControl
                                        .setSceneMode(FeatureControl.SCENE_MODE_PORTRAIT);
                            };
                        }));

                sceneModeMenuItems.addElement(enableSceneModePortrait);
            }

            // Check for snow scene mode support
            if (featureControl
                    .isSceneModeSupported(FeatureControl.SCENE_MODE_SNOW)) {
                final MenuItem enableSceneModeSnow =
                        new MenuItem(new StringProvider(
                                "Enable Scene Mode: SNOW"), Integer.MAX_VALUE,
                                0);
                enableSceneModeSnow.setCommand(new Command(
                        new CommandHandler() {
                            /**
                             * @see CommandHandler#execute(ReadOnlyCommandMetadata,
                             *      Object)
                             */
                            public void execute(
                                    final ReadOnlyCommandMetadata metadata,
                                    final Object context) {
                                featureControl
                                        .setSceneMode(FeatureControl.SCENE_MODE_SNOW);
                            };
                        }));

                sceneModeMenuItems.addElement(enableSceneModeSnow);
            }

            // Check for sport scene mode support
            if (featureControl
                    .isSceneModeSupported(FeatureControl.SCENE_MODE_SPORT)) {
                final MenuItem enableSceneModeSport =
                        new MenuItem(new StringProvider(
                                "Enable Scene Mode: SPORT"), Integer.MAX_VALUE,
                                0);
                enableSceneModeSport.setCommand(new Command(
                        new CommandHandler() {
                            /**
                             * @see CommandHandler#execute(ReadOnlyCommandMetadata,
                             *      Object)
                             */
                            public void execute(
                                    final ReadOnlyCommandMetadata metadata,
                                    final Object context) {
                                featureControl
                                        .setSceneMode(FeatureControl.SCENE_MODE_SPORT);
                            };
                        }));

                sceneModeMenuItems.addElement(enableSceneModeSport);
            }

            // Check for text scene mode support
            if (featureControl
                    .isSceneModeSupported(FeatureControl.SCENE_MODE_TEXT)) {
                final MenuItem enableSceneModeText =
                        new MenuItem(new StringProvider(
                                "Enable Scene Mode: TEXT"), Integer.MAX_VALUE,
                                0);
                enableSceneModeText.setCommand(new Command(
                        new CommandHandler() {
                            /**
                             * @see CommandHandler#execute(ReadOnlyCommandMetadata,
                             *      Object)
                             */
                            public void execute(
View Full Code Here

        private USBScreen() {
            // Connects through a GCF USB connection
            final MenuItem connectGCF =
                    new MenuItem(new StringProvider("Connect (GCF)"), 0x230010,
                            0);
            connectGCF.setCommand(new Command(new CommandHandler() {
                /**
                 * @see net.rim.device.api.command.CommandHandler#execute(ReadOnlyCommandMetadata,
                 *      Object)
                 */
                public void execute(final ReadOnlyCommandMetadata metadata,
                        final Object context) {
                    // Cleanup the old thread if present
                    onExit();

                    _usbThread = new GCFUsbThread();
                    connect();
                }
            }));
            /*
             * Connects through a low level USB connection.
             */
            final MenuItem connectLowLevel =
                    new MenuItem(new StringProvider("Connect (low level)"),
                            0x230020, 1);
            connectLowLevel.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(_statusField);

        _message = new StringBuffer();

        _go = new MenuItem(new StringProvider("Go"), 0x230010, 0);
        _go.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);
        add(_statusField);
        final MenuItem downloadItem =
                new MenuItem(new StringProvider("Download Attachments"),
                        0x230010, 0);
        downloadItem.setCommand(new Command(new CommandHandler() {
            /**
             * @see net.rim.device.api.command.CommandHandler#execute(ReadOnlyCommandMetadata,
             *      Object)
             */
            public void execute(final ReadOnlyCommandMetadata metadata,
                    final Object context) {
                _statusField.setText("");
                if (_action.getMessages()) {
                    try {
                        _action.download(Dialog.ask(Dialog.D_YES_NO,
                                "Download only png and msword attachments?") == Dialog.NO);
                    } catch (final IOException ex) {
                        AttachmentDemo
                                .errorDialog("DownloadManager.download() threw "
                                        + ex.toString());
                    }
                } else {
                    displayStatus("Mailbox is empty.");
                }
            }
        }));
        final MenuItem uploadItem =
                new MenuItem(new StringProvider("Send Attachment"), 0x230020, 1);
        uploadItem.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

     * MenuItem class to display a contact's email address
     */
    private class ViewEmailMenuItem extends MenuItem {
        public ViewEmailMenuItem() {
            super(new StringProvider("View Email"), 0x230020, 0);
            this.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(_status);

        // Menu item to attach a picture to the MMS
        final MenuItem attachPicture =
                new MenuItem(new StringProvider("Attach Picture"), 0x230010, 0);
        attachPicture.setCommand(new Command(new CommandHandler() {
            /**
             * @see net.rim.device.api.command.CommandHandler#execute(ReadOnlyCommandMetadata,
             *      Object)
             */
            public void execute(final ReadOnlyCommandMetadata metadata,
                    final Object context) {
                _app.attach(MMSDemo.PICTURE);
            }
        }));

        // Menu item to attach an audio file to the MMS
        final MenuItem attachAudio =
                new MenuItem(new StringProvider("Attach Audio"), 0x230020, 1);
        attachAudio.setCommand(new Command(new CommandHandler() {
            /**
             * @see net.rim.device.api.command.CommandHandler#execute(ReadOnlyCommandMetadata,
             *      Object)
             */
            public void execute(final ReadOnlyCommandMetadata metadata,
                    final Object context) {
                _app.attach(MMSDemo.AUDIO);
            }
        }));

        // Menu item to send the MMS
        final MenuItem sendMenuItem =
                new MenuItem(new StringProvider("Send"), 0x230030, 3);
        sendMenuItem.setCommand(new Command(new CommandHandler() {
            /**
             * @see net.rim.device.api.command.CommandHandler#execute(ReadOnlyCommandMetadata,
             *      Object)
             */
            public void execute(final ReadOnlyCommandMetadata metadata,
                    final Object context) {
                // Send MMS on non-event thread
                final Thread t = new Thread() {
                    public void run() {
                        _app.sendMMS(_addressField, _subjectField,
                                _messageField);
                    }
                };
                t.start();
            }
        }));

        _removeAttachment =
                new MenuItem(new StringProvider("Remove Attachment"), 0x230040,
                        4);
        _removeAttachment.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.