Package net.rim.device.api.ui.component.table

Examples of net.rim.device.api.ui.component.table.TableView


                new RegionStyles(BorderFactory.createSimpleBorder(new XYEdges(
                        1, 1, 1, 1), Border.STYLE_SOLID), null, null, null,
                        RegionStyles.ALIGN_LEFT, RegionStyles.ALIGN_TOP);

        // Create the view and controller
        final TableView tableView = new TableView(_tableModel);
        final TableController tableController =
                new TableController(_tableModel, tableView);

        // 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) {
                Dialog.alert("Command Executed");
            }
        }));

        tableView.setController(tableController);

        // Create a DataTemplate that suppresses the third column
        final DataTemplate dataTemplate = new DataTemplate(tableView, 2, 3) {
            /**
             * @see DataTemplate#getDataFields(int)
             */
            public Field[] getDataFields(final int modelRowIndex) {
                final Object[] data =
                        (Object[]) ((TableModel) getView().getModel())
                                .getRow(modelRowIndex);

                final Field[] fields = new Field[4];
                fields[0] = new BitmapField((Bitmap) data[0]);
                fields[1] =
                        new LabelField(data[1], Field.FOCUSABLE
                                | DrawStyle.HCENTER);
                fields[2] = new LabelField(data[3], Field.FOCUSABLE);
                fields[3] = new LabelField(data[4], Field.FOCUSABLE);

                return fields;
            }
        };

        // Set up regions
        dataTemplate.createRegion(new XYRect(0, 0, 1, 2), style);
        dataTemplate.createRegion(new XYRect(1, 0, 2, 1), style);
        dataTemplate.createRegion(new XYRect(1, 1, 1, 1), style);
        dataTemplate.createRegion(new XYRect(2, 1, 1, 1), style);

        // Specify the size of each column by percentage, and the height of a
        // row
        dataTemplate.setColumnProperties(0, new TemplateColumnProperties(15,
                TemplateColumnProperties.PERCENTAGE_WIDTH));
        dataTemplate.setColumnProperties(1, new TemplateColumnProperties(15,
                TemplateColumnProperties.PERCENTAGE_WIDTH));
        dataTemplate.setColumnProperties(2, new TemplateColumnProperties(70,
                TemplateColumnProperties.PERCENTAGE_WIDTH));
        dataTemplate.setRowProperties(0, new TemplateRowProperties(ROW_HEIGHT));
        dataTemplate.setRowProperties(1, new TemplateRowProperties(ROW_HEIGHT));

        // Apply the template to the view
        tableView.setDataTemplate(dataTemplate);
        dataTemplate.useFixedHeight(true);

        add(tableView);
    }
View Full Code Here


            _tableModel.addRow(row);
        }

        // Set up table view and controller
        final TableView tableView = new TableView(_tableModel);
        tableView.setDataTemplateFocus(BackgroundFactory
                .createLinearGradientBackground(Color.WHITE, Color.WHITE,
                        Color.BLUEVIOLET, Color.BLUEVIOLET));
        final TableController tableController =
                new TableController(_tableModel, tableView);
        tableController.setFocusPolicy(TableController.ROW_FOCUS);
        tableView.setController(tableController);

        // Specify a simple data template for displaying 3 columns
        final DataTemplate dataTemplate =
                new DataTemplate(tableView, NUM_ROWS, NUM_COLUMNS) {
                    /**
                     * @see DataTemplate#getDataFields(int)
                     */
                    public Field[] getDataFields(final int modelRowIndex) {
                        final Object[] data =
                                (Object[]) _tableModel.getRow(modelRowIndex);
                        final Field[] fields =
                                { new BitmapField((Bitmap) data[0]),
                                        new LabelField(data[1]),
                                        new LabelField(data[2]) };
                        return fields;
                    }
                };

        dataTemplate.useFixedHeight(true);

        // Define regions and row height
        dataTemplate.setRowProperties(0, new TemplateRowProperties(ROW_HEIGHT));
        for (int i = 0; i < NUM_COLUMNS; i++) {
            dataTemplate.createRegion(new XYRect(i, 0, 1, 1));
            dataTemplate.setColumnProperties(i, new TemplateColumnProperties(
                    Display.getWidth() / NUM_COLUMNS));
        }

        // Apply the template to the view
        tableView.setDataTemplate(dataTemplate);

        add(tableView);
    }
View Full Code Here

                return super.keyChar(key, status, time);
            }
        };

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

        // Create the controller
        _controller = new TableController(_model, _view);
        _controller.setCommand(new Command(new CommandHandler() {
            /**
 
View Full Code Here

        // Create an adapter to display meetings list in a table
        _model = new MeetingTableModelAdapter();

        // Create the view and controller
        _view = new TableView(_model);
        final TableController controller = new TableController(_model, _view);
        controller.setFocusPolicy(TableController.ROW_FOCUS);
        _view.setController(controller);

        _view.setDataTemplateFocus(BackgroundFactory
View Full Code Here

        initializeContacts();

        // Create an adapter for displaying contact data in table
        _model = new ContactTableModelAdapter();

        _view = new TableView(_model);
        final TableController controller = new TableController(_model, _view);
        controller.setFocusPolicy(TableController.ROW_FOCUS);
        _view.setController(controller);

        // Set the highlight style for the view
View Full Code Here

        }

        _model = new BlackBerryMemoTableModel();

        // Create the view and the controller
        _view = new TableView(_model);
        final TableController controller = new TableController(_model, _view);
        controller.setFocusPolicy(TableController.ROW_FOCUS);
        _view.setController(controller);

        _view.setDataTemplateFocus(BackgroundFactory
View Full Code Here

        private PhoneApiDemoMainScreen() {
            super(Manager.NO_VERTICAL_SCROLL);

            setTitle("Phone API Demo");

            _view = new TableView(_model);

            final TableController controller =
                    new TableController(_model, _view);
            _view.setController(controller);
View Full Code Here

        // Create an adapter to display memos list in a table
        _model = new MemoTableModelAdapter();

        // Create the view and controller
        _view = new TableView(_model);
        final TableController controller = new TableController(_model, _view);
        controller.setFocusPolicy(TableController.ROW_FOCUS);
        _view.setController(controller);

        _view.setDataTemplateFocus(BackgroundFactory
View Full Code Here

         *            display
         */
        public PhoneCallTable(final PhoneCallTableModelAdapter model) {
            _model = model;

            _view = new TableView(_model);

            final TableController controller =
                    new TableController(_model, _view);
            controller.setFocusPolicy(TableController.ROW_FOCUS);
            _view.setController(controller);
View Full Code Here

        try {
            Dialog.alert("Search for Devices");

            _model = new BluetoothTableModelAdapter();

            _view = new TableView(_model);
            final TableController controller =
                    new TableController(_model, _view);
            controller.setFocusPolicy(TableController.ROW_FOCUS);
            _view.setController(controller);
View Full Code Here

TOP

Related Classes of net.rim.device.api.ui.component.table.TableView

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.