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

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


        }));

        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


                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);
View Full Code Here

                .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 =
View Full Code Here

        _view.setController(controller);

        _view.setDataTemplateFocus(BackgroundFactory
                .createLinearGradientBackground(Color.LIGHTBLUE,
                        Color.LIGHTBLUE, Color.BLUE, Color.BLUE));
        final DataTemplate dataTemplate = new DataTemplate(_view, 1, 1) {
            public Field[] getDataFields(final int modelRowIndex) {
                final String text =
                        ((Meeting) _model.getRow(modelRowIndex))
                                .getField(Meeting.MEETING_NAME);
                final Field[] fields =
                        { new LabelField(text, Field.NON_FOCUSABLE) };

                return fields;
            }
        };
        dataTemplate.createRegion(new XYRect(0, 0, 1, 1));
        dataTemplate.setColumnProperties(0, new TemplateColumnProperties(
                Display.getWidth()));
        dataTemplate.setRowProperties(0, new TemplateRowProperties(32));
        _view.setDataTemplate(dataTemplate);
        dataTemplate.useFixedHeight(true);

        add(_view);

        // Menu item to create a new meeting
        final MenuItem newMeetingItem =
View Full Code Here

                .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(((SampleContact) _model
                                .getRow(modelRowIndex)).toString(),
                                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);

        // Add the contact list to the screen
        add(_view);
    }
View Full Code Here

                .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 FileHolder fileholder =
                        (FileHolder) _model.getRow(modelRowIndex);

                String text;

                if (fileholder.isDirectory()) {
                    int pathIndex = fileholder.getPath().lastIndexOf('/');
                    pathIndex =
                            fileholder.getPath().substring(0, pathIndex)
                                    .lastIndexOf('/');
                    text = fileholder.getPath().substring(pathIndex + 1);
                } else {
                    text = fileholder.getFileName();
                }

                final Field[] fields =
                        { new LabelField(text, 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);

        // Add the TableView to the screen
        add(_view);

        readRoots(ROOT);
View Full Code Here

                .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 MessagePart message =
                        (MessagePart) _app.getMessageParts().getRow(
                                modelRowIndex);
                final Field[] fields =
                        { new LabelField(message.getContentLocation(),
                                Field.NON_FOCUSABLE | DrawStyle.ELLIPSIS) };
                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);

        // Add the file to the screen
        add(_view);

        _status = new EditField();
View Full Code Here

        _view.setController(controller);

        _view.setDataTemplateFocus(BackgroundFactory
                .createLinearGradientBackground(Color.LIGHTBLUE,
                        Color.LIGHTBLUE, Color.BLUE, Color.BLUE));
        final DataTemplate dataTemplate = new DataTemplate(_view, 1, 1) {
            public Field[] getDataFields(final int modelRowIndex) {
                final BlackBerryMemo memo =
                        (BlackBerryMemo) _model.getRow(modelRowIndex);

                final Field[] fields =
                        { new LabelField(memo
                                .getString(BlackBerryMemo.TITLE, 0),
                                Field.NON_FOCUSABLE) };
                return fields;
            }
        };
        dataTemplate.createRegion(new XYRect(0, 0, 1, 1));
        dataTemplate.setColumnProperties(0, new TemplateColumnProperties(
                Display.getWidth()));
        dataTemplate.setRowProperties(0, new TemplateRowProperties(32));
        _view.setDataTemplate(dataTemplate);
        dataTemplate.useFixedHeight(true);

        add(_view);

        _addItem = new AddItem();
    }
View Full Code Here

            _view.setController(controller);

            _view.setDataTemplateFocus(BackgroundFactory
                    .createLinearGradientBackground(Color.LIGHTBLUE,
                            Color.LIGHTBLUE, Color.BLUE, Color.BLUE));
            final DataTemplate dataTemplate = new DataTemplate(_view, 1, 1) {
                public Field[] getDataFields(final int modelRowIndex) {
                    final PhoneNumberRecord record =
                            (PhoneNumberRecord) _model.getRow(modelRowIndex);
                    final String text =
                            (String) record
                                    .getField(PhoneNumberRecord.PHONE_NUMBER);

                    final Field[] fields =
                            { new LabelField(text, Field.NON_FOCUSABLE) };

                    return fields;
                }
            };
            dataTemplate.createRegion(new XYRect(0, 0, 1, 1));
            dataTemplate.setColumnProperties(0, new TemplateColumnProperties(
                    Display.getWidth()));
            dataTemplate.setRowProperties(0, new TemplateRowProperties(32));
            _view.setDataTemplate(dataTemplate);
            dataTemplate.useFixedHeight(true);

            add(_view);

            // Menu item that deletes all the phone number records.
            _deleteAllItem =
View Full Code Here

        _view.setController(controller);

        _view.setDataTemplateFocus(BackgroundFactory
                .createLinearGradientBackground(Color.LIGHTBLUE,
                        Color.LIGHTBLUE, Color.BLUE, Color.BLUE));
        final DataTemplate dataTemplate = new DataTemplate(_view, 1, 1) {
            public Field[] getDataFields(final int modelRowIndex) {
                final String text =
                        ((Memo) _model.getRow(modelRowIndex))
                                .getField(Memo.MEMO_NAME);
                final Field[] fields =
                        { new LabelField(text, Field.NON_FOCUSABLE) };

                return fields;
            }
        };
        dataTemplate.createRegion(new XYRect(0, 0, 1, 1));
        dataTemplate.setColumnProperties(0, new TemplateColumnProperties(
                Display.getWidth()));
        dataTemplate.setRowProperties(0, new TemplateRowProperties(32));
        _view.setDataTemplate(dataTemplate);
        dataTemplate.useFixedHeight(true);

        add(_view);

        // Menu item to create a new memo
        final MenuItem newMemoItem =
View Full Code Here

TOP

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

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.