Example usage for org.eclipse.jface.viewers ViewerCell getElement

List of usage examples for org.eclipse.jface.viewers ViewerCell getElement

Introduction

In this page you can find the example usage for org.eclipse.jface.viewers ViewerCell getElement.

Prototype

public Object getElement() 

Source Link

Document

Get the element this row represents.

Usage

From source file:net.tourbook.ui.views.rawData.RawDataView.java

License:Open Source License

/**
 * column: import file name//from w w w  .j  av a  2s . c om
 */
private void defineColumn_Data_ImportFileName() {

    final ColumnDefinition colDef = TableColumnFactory.DATA_IMPORT_FILE_NAME.createColumn(_columnManager, _pc);

    colDef.setColumnSelectionListener(_columnSortListener);
    colDef.setLabelProvider(new CellLabelProvider() {
        @Override
        public void update(final ViewerCell cell) {

            final TourData tourData = (TourData) cell.getElement();
            final String importFileName = tourData.getImportFileName();

            if (importFileName != null) {
                cell.setText(importFileName);
            }
        }
    });

    _columnId_ImportFileName = colDef.getColumnId();
}

From source file:net.tourbook.ui.views.rawData.RawDataView.java

License:Open Source License

/**
 * column: import file path// w  w w  . ja  v a  2 s.  co  m
 */
private void defineColumn_Data_ImportFilePath() {

    final ColumnDefinition colDef = TableColumnFactory.DATA_IMPORT_FILE_PATH.createColumn(_columnManager, _pc);

    colDef.setLabelProvider(new CellLabelProvider() {
        @Override
        public void update(final ViewerCell cell) {

            final TourData tourData = (TourData) cell.getElement();
            final String importFilePath = tourData.getImportFilePath();

            if (importFilePath != null) {
                cell.setText(importFilePath);
            }
        }
    });
}

From source file:net.tourbook.ui.views.rawData.RawDataView.java

License:Open Source License

/**
 * column: time interval//from  w ww.  j  av  a2 s  .c om
 */
private void defineColumn_Date_TimeInterval() {

    final ColumnDefinition colDef = TableColumnFactory.DATA_TIME_INTERVAL.createColumn(_columnManager, _pc);

    colDef.setLabelProvider(new CellLabelProvider() {
        @Override
        public void update(final ViewerCell cell) {
            cell.setText(Integer.toString(((TourData) cell.getElement()).getDeviceTimeInterval()));
        }
    });
}

From source file:net.tourbook.ui.views.rawData.RawDataView.java

License:Open Source License

/**
 * column: device name//w  w w.j  a  v a 2s .c  o  m
 */
private void defineColumn_Device_Name() {

    final ColumnDefinition colDef = TableColumnFactory.DEVICE_NAME.createColumn(_columnManager, _pc);

    colDef.setColumnSelectionListener(_columnSortListener);
    colDef.setLabelProvider(new CellLabelProvider() {
        @Override
        public void update(final ViewerCell cell) {

            final TourData tourData = (TourData) cell.getElement();

            final String deviceName = tourData.getDeviceName();
            final String firmwareVersion = tourData.getDeviceFirmwareVersion();

            final String name = firmwareVersion.length() == 0//
                    ? deviceName
                    : deviceName + UI.SPACE + UI.SYMBOL_BRACKET_LEFT + firmwareVersion
                            + UI.SYMBOL_BRACKET_RIGHT;

            cell.setText(name);
        }
    });

    _columnId_DeviceName = colDef.getColumnId();
}

From source file:net.tourbook.ui.views.rawData.RawDataView.java

License:Open Source License

/**
 * column: device profile/* w  ww.ja v a2  s .c om*/
 */
private void defineColumn_Device_Profile() {

    final ColumnDefinition colDef = TableColumnFactory.DEVICE_PROFILE.createColumn(_columnManager, _pc);

    colDef.setLabelProvider(new CellLabelProvider() {
        @Override
        public void update(final ViewerCell cell) {
            cell.setText(((TourData) cell.getElement()).getDeviceModeName());
        }
    });
}

From source file:net.tourbook.ui.views.rawData.RawDataView.java

License:Open Source License

/**
 * column: average pace//from   ww  w  .j a  v  a 2  s. c om
 */
private void defineColumn_Motion_AvgPace() {

    final ColumnDefinition colDef = TableColumnFactory.MOTION_AVG_PACE.createColumn(_columnManager, _pc);

    colDef.setIsDefaultColumn();
    colDef.setLabelProvider(new CellLabelProvider() {
        @Override
        public void update(final ViewerCell cell) {

            final TourData tourData = (TourData) cell.getElement();

            final float tourDistance = tourData.getTourDistance();
            final long drivingTime = tourData.getTourDrivingTime();

            final float pace = tourDistance == 0 ? //
            0 : drivingTime * 1000 / tourDistance * net.tourbook.ui.UI.UNIT_VALUE_DISTANCE;

            if (pace == 0) {
                cell.setText(UI.EMPTY_STRING);
            } else {
                cell.setText(UI.format_mm_ss((long) pace));
            }
        }
    });
}

From source file:net.tourbook.ui.views.rawData.RawDataView.java

License:Open Source License

/**
 * column: avg speed/* w w w  .  j a  va  2s .  c om*/
 */
private void defineColumn_Motion_AvgSpeed() {

    final ColumnDefinition colDef = TableColumnFactory.MOTION_AVG_SPEED.createColumn(_columnManager, _pc);

    // show avg speed to verify the tour type by speed
    colDef.setIsDefaultColumn();
    colDef.setLabelProvider(new CellLabelProvider() {
        @Override
        public void update(final ViewerCell cell) {

            final TourData tourData = ((TourData) cell.getElement());
            final float tourDistance = tourData.getTourDistance();
            final long drivingTime = tourData.getTourDrivingTime();

            double value = 0;

            if (drivingTime != 0) {
                value = tourDistance / drivingTime * 3.6 / net.tourbook.ui.UI.UNIT_VALUE_DISTANCE;
            }

            colDef.printDetailValue(cell, value);
        }
    });
}

From source file:net.tourbook.ui.views.rawData.RawDataView.java

License:Open Source License

/**
 * column: distance (km/mile)/*from   w  w  w. ja va 2  s  .c  om*/
 */
private void defineColumn_Motion_Distance() {

    final ColumnDefinition colDef = TableColumnFactory.MOTION_DISTANCE.createColumn(_columnManager, _pc);

    colDef.setIsDefaultColumn();
    colDef.setLabelProvider(new CellLabelProvider() {
        @Override
        public void update(final ViewerCell cell) {

            final double tourDistance = ((TourData) cell.getElement()).getTourDistance();
            final double value = tourDistance / 1000 / net.tourbook.ui.UI.UNIT_VALUE_DISTANCE;

            colDef.printDetailValue(cell, value);
        }
    });
}

From source file:net.tourbook.ui.views.rawData.RawDataView.java

License:Open Source License

/**
 * Column: Database state/*w  ww. j a  va2 s  . co  m*/
 */
private void defineColumn_State_Database() {

    final ColumnDefinition colDef = TableColumnFactory.STATE_DB_STATUS.createColumn(_columnManager, _pc);

    colDef.setIsDefaultColumn();
    colDef.setCanModifyVisibility(false);
    colDef.setLabelProvider(new CellLabelProvider() {
        @Override
        public void update(final ViewerCell cell) {

            // show the database indicator for the person who owns the tour

            final TourData tourData = (TourData) cell.getElement();

            cell.setImage(getStateImage_Db(tourData));
        }
    });
}

From source file:net.tourbook.ui.views.rawData.RawDataView.java

License:Open Source License

/**
 * Column: Import state//  w  ww .  jav  a  2s .  co  m
 */
private void defineColumn_State_Import() {

    final ColumnDefinition colDef = TableColumnFactory.STATE_IMPORT_STATE.createColumn(_columnManager, _pc);

    colDef.setIsDefaultColumn();
    colDef.setCanModifyVisibility(false);
    colDef.setLabelProvider(new CellLabelProvider() {
        @Override
        public void update(final ViewerCell cell) {

            final TourData tourData = (TourData) cell.getElement();
            final Image stateImage = getStateImage_Import(tourData);

            cell.setImage(stateImage);
        }
    });
}