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

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


            // Create a DataTemplate to format Phone Log data for table rows
            _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 CallLog log = (CallLog) _model.getRow(modelRowIndex);
                    String text;
                    if (log instanceof PhoneCallLog) {
                        final PhoneCallLog phoneCallLog = (PhoneCallLog) log;
                        text = phoneCallLog.getParticipant().getNumber();
                    } else {
                        text = "Conference call";
                    }

                    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);

        }
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 Fields
            final DataTemplate dataTemplate = new DataTemplate(_view, 1, 1) {
                public Field[] getDataFields(final int modelRowIndex) {
                    final RemoteDevice _remoteDevice =
                            (RemoteDevice) _model.getRow(modelRowIndex);

                    final Field[] fields =
                            { new LabelField(_remoteDevice.toString(),
                                    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 bluetooth list to the screen
            add(_view);

            _remoteDevices.setSize(0);
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 FileExplorerDemoFileHolder fileholder =
                        (FileExplorerDemoFileHolder) _model
                                .getRow(modelRowIndex);

                String text;

                if (fileholder.isDirectory()) {
                    text = fileholder.getPath();
                } 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 contact list to the screen
        add(_view);

        // Populate the table
View Full Code Here

        // Specify a data template for each item describing a block with four
        // rows and
        // two columns. Create a region so that the image will be displayed
        // across
        // four rows.
        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 Field[data.length];
                        for (int i = 0; i < data.length; i++) {
                            if (data[i] instanceof Bitmap) {
                                fields[i] = new BitmapField((Bitmap) data[i]);
                            } else if (data[i] instanceof String) {
                                fields[i] =
                                        new LabelField(data[i], Field.FOCUSABLE);
                            } else {
                                fields[i] = (Field) data[i];
                            }
                        }

                        return fields;
                    }
                };

        // Set the style and apply it to the data template via the
        // setRowProperties() method
        dataTemplate.createRegion(new XYRect(0, 0, 1, 4), _style);

        dataTemplate.setRowProperties(0, new TemplateRowProperties(Font
                .getDefault().getHeight()
                + (_style.getBorder() == null ? 0 : _style.getBorder().getTop()
                        + _style.getBorder().getBottom())
                + (_style.getMargin() == null ? 0 : _style.getMargin().top
                        + _style.getMargin().bottom)));

        for (int i = 0; i < NUM_ROWS; i++) {
            dataTemplate.createRegion(new XYRect(1, i, 1, 1), _style);
            dataTemplate.setRowProperties(i, new TemplateRowProperties(Font
                    .getDefault().getHeight()
                    + (_style.getBorder() == null ? 0 : _style.getBorder()
                            .getTop()
                            + _style.getBorder().getBottom())
                    + (_style.getMargin() == null ? 0 : _style.getMargin().top
                            + _style.getMargin().bottom)));
        }

        // Calculate and programmatically set the width of the image section of
        // the table
        final int width =
                IMAGE_WIDTH
                        + (_style.getBorder() == null ? 0 : _style.getBorder()
                                .getTop()
                                + _style.getBorder().getBottom())
                        + (_style.getMargin() == null ? 0
                                : _style.getMargin().top
                                        + _style.getMargin().bottom);
        dataTemplate
                .setColumnProperties(0, new TemplateColumnProperties(width));

        // Set the width of the text portion of the table
        dataTemplate.setColumnProperties(1, new TemplateColumnProperties(
                Display.getWidth() - width));

        // Apply the template to the view
        _tableView.setDataTemplate(dataTemplate);
        dataTemplate.useFixedHeight(true);
    }
View Full Code Here

        // Set the highlight background for the row with focus
        _view.setDataTemplateFocus(BackgroundFactory
                .createLinearGradientBackground(Color.LIGHTBLUE,
                        Color.LIGHTBLUE, Color.BLUE, Color.BLUE));
        final DataTemplate dataTemplate = new DataTemplate(_view, 1, 1) {
            /**
             * @see net.rim.device.api.ui.component.table.DataTemplate#getDataFields(int)
             */
            public Field[] getDataFields(final int modelRowIndex) {
                // Format the contact name for display
                final OTAContactData contact =
                        (OTAContactData) _model.getRow(modelRowIndex);
                final String personal =
                        contact.getFirst() + " " + contact.getLast();

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

                return fields;
            }
        };

        // Create regions for formatting table
        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);

        screen.add(_view);

        // Push the screen onto the UI stack for rendering
        pushScreen(screen);
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 = (String) _model.getRow(modelRowIndex);
                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(new RichTextField("Attendees:", Field.NON_FOCUSABLE));
        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 String text = (String) _model.getRow(modelRowIndex);
                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 view the screen
        add(_view);

        enumerateDirectory(ROOT);
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 ContactData contact =
                        (ContactData) _model.getRow(modelRowIndex);

                final Field[] fields =
                        { new LabelField(contact.getFirst() + " "
                                + contact.getLast(), 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);

        _addContactAction = new AddContactAction();
        _viewContactAction = new ViewContactAction();

        // Create a new screen for the application
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.