Example usage for org.eclipse.jface.preference IPreferenceStore getInt

List of usage examples for org.eclipse.jface.preference IPreferenceStore getInt

Introduction

In this page you can find the example usage for org.eclipse.jface.preference IPreferenceStore getInt.

Prototype

int getInt(String name);

Source Link

Document

Returns the current value of the integer-valued preference with the given name.

Usage

From source file:net.tourbook.preferences.PrefPageAppearanceTourEditor.java

License:Open Source License

public void init(final IWorkbench workbench) {
    final IPreferenceStore prefStore = TourbookPlugin.getDefault().getPreferenceStore();
    setPreferenceStore(prefStore);//from   w w w.  j  a va 2 s  . c om

    fOldDescriptionLines = prefStore.getInt(ITourbookPreferences.TOUR_EDITOR_DESCRIPTION_HEIGHT);
}

From source file:net.tourbook.preferences.PrefPageAppearanceTourEditor.java

License:Open Source License

@Override
public boolean performOk() {

    final boolean isOK = super.performOk();

    final IPreferenceStore prefStore = TourbookPlugin.getDefault().getPreferenceStore();
    final int newDescriptionLines = prefStore.getInt(ITourbookPreferences.TOUR_EDITOR_DESCRIPTION_HEIGHT);
    if (fOldDescriptionLines != newDescriptionLines) {
        MessageDialog.openInformation(Display.getCurrent().getActiveShell(),
                Messages.pref_tour_editor_dlg_desc_height_title,
                Messages.pref_tour_editor_dlg_desc_height_message);
    }//from w  w w. ja v a  2  s  .  c o  m
    return isOK;
}

From source file:net.tourbook.statistics.graphs.StatisticTour_Frequency.java

License:Open Source License

/**
 * create the units from the preference configuration
 * //ww w . jav  a  2s. co  m
 * @param store
 * @param prefInterval
 * @param prefLowValue
 * @param prefNumbers
 * @param unitType
 * @return
 */
private int[] getPrefUnits(final IPreferenceStore store, final String prefNumbers, final String prefLowValue,
        final String prefInterval, final int unitType) {

    final int lowValue = store.getInt(prefLowValue);
    final int interval = store.getInt(prefInterval);
    final int numbers = store.getInt(prefNumbers);

    final int[] units = new int[numbers];

    for (int number = 0; number < numbers; number++) {
        if (unitType == ChartDataSerie.AXIS_UNIT_HOUR_MINUTE) {
            // adjust the values to minutes
            units[number] = (lowValue * 60) + (interval * number * 60);
        } else {
            units[number] = lowValue + (interval * number);
        }
    }

    return units;
}

From source file:net.tourbook.statistics.StatisticDay.java

License:Open Source License

public void refreshStatistic(final TourPerson person, final TourTypeFilter tourTypeFilter, final int year,
        final int numberOfYears, final boolean refreshData) {

    _activePerson = person;//from   w w w  .  ja v  a2s  .  c  o  m
    _activeTourTypeFilter = tourTypeFilter;
    _currentYear = year;
    _numberOfYears = numberOfYears;

    /*
     * get currently selected tour id
     */
    long selectedTourId = -1;
    final ISelection selection = _chart.getSelection();
    if (selection instanceof SelectionBarChart) {
        final SelectionBarChart barChartSelection = (SelectionBarChart) selection;

        if (barChartSelection.serieIndex != -1) {

            int selectedValueIndex = barChartSelection.valueIndex;
            final long[] tourIds = _tourDayData.tourIds;

            if (tourIds.length > 0) {

                if (selectedValueIndex >= tourIds.length) {
                    selectedValueIndex = tourIds.length - 1;
                }

                selectedTourId = tourIds[selectedValueIndex];
            }
        }
    }

    _tourDayData = DataProviderTourDay.getInstance().getDayData(person, tourTypeFilter, year, numberOfYears,
            isDataDirtyWithReset() || refreshData);

    // reset min/max values
    if (_isSynchScaleEnabled == false && refreshData) {
        _minMaxKeeper.resetMinMax();
    }

    final ChartDataModel chartModel = updateChart();

    /*
     * set graph minimum width, these is the number of days in the year
     */
    _calendar.set(_currentYear, 11, 31);
    chartModel.setChartMinWidth(_calendar.get(Calendar.DAY_OF_YEAR));

    setChartProviders(_chart, chartModel);

    if (_isSynchScaleEnabled) {
        _minMaxKeeper.setMinMaxValues(chartModel);
    }

    // set grid size
    final IPreferenceStore prefStore = TourbookPlugin.getDefault().getPreferenceStore();
    _chart.setGridDistance(prefStore.getInt(ITourbookPreferences.GRAPH_GRID_HORIZONTAL_DISTANCE),
            prefStore.getInt(ITourbookPreferences.GRAPH_GRID_VERTICAL_DISTANCE));

    // show the data in the chart
    _chart.updateChart(chartModel, false, true);

    // try to select the previous selected tour
    selectTour(selectedTourId);
}

From source file:net.tourbook.statistics.StatisticMonth.java

License:Open Source License

public void refreshStatistic(final TourPerson person, final TourTypeFilter tourTypeFilter,
        final int currentYear, final int numberOfYears, final boolean refreshData) {

    fActivePerson = person;//w w  w .ja v a  2s  .  c om
    fActiveTourTypeFilter = tourTypeFilter;
    fCurrentYear = currentYear;
    fNumberOfYears = numberOfYears;

    fTourMonthData = DataProviderTourMonth.getInstance().getMonthData(person, tourTypeFilter, currentYear,
            numberOfYears, isDataDirtyWithReset() || refreshData);

    // reset min/max values
    if (fIsSynchScaleEnabled == false && refreshData) {
        fMinMaxKeeper.resetMinMax();
    }

    final ChartDataModel chartDataModel = updateChart();

    setChartProviders(chartDataModel);

    if (fIsSynchScaleEnabled) {
        fMinMaxKeeper.setMinMaxValues(chartDataModel);
    }

    // set grid size
    final IPreferenceStore prefStore = TourbookPlugin.getDefault().getPreferenceStore();
    fChart.setGridDistance(prefStore.getInt(ITourbookPreferences.GRAPH_GRID_HORIZONTAL_DISTANCE),
            prefStore.getInt(ITourbookPreferences.GRAPH_GRID_VERTICAL_DISTANCE));

    // show the fDataModel in the chart
    fChart.updateChart(chartDataModel, true);
}

From source file:net.tourbook.statistics.StatisticTourNumbers.java

License:Open Source License

private void updateChartAltitude(final Chart statAltitudeChart,
        final BarChartMinMaxKeeper statAltitudeMinMaxKeeper, final int[][] lowValues, final int[][] highValues,
        final int[][] colorIndex, final String unit, final String title) {

    final ChartDataModel chartDataModel = new ChartDataModel(ChartDataModel.CHART_TYPE_BAR);

    // set the x-axis
    final ChartDataXSerie xData = new ChartDataXSerie(_statAltitudeUnits);
    xData.setAxisUnit(ChartDataXSerie.AXIS_UNIT_NUMBER);
    xData.setUnitLabel(UI.UNIT_LABEL_ALTITUDE);
    chartDataModel.setXData(xData);/* www.j av a 2 s  . c  o  m*/

    // y-axis: altitude
    final ChartDataYSerie yData = new ChartDataYSerie(ChartDataModel.CHART_TYPE_BAR,
            ChartDataYSerie.BAR_LAYOUT_STACKED, lowValues, highValues);
    yData.setAxisUnit(ChartDataSerie.AXIS_UNIT_NUMBER);
    yData.setUnitLabel(unit);
    yData.setAllValueColors(0);
    yData.setYTitle(title);
    yData.setVisibleMinValue(0);
    chartDataModel.addYData(yData);

    StatisticServices.setDefaultColors(yData, GraphColorProvider.PREF_GRAPH_ALTITUDE);
    StatisticServices.setTourTypeColors(yData, GraphColorProvider.PREF_GRAPH_ALTITUDE, _activeTourTypeFilter);
    yData.setColorIndex(colorIndex);

    createToolTipProviderAltitude(chartDataModel);

    if (_isSynchScaleEnabled) {
        statAltitudeMinMaxKeeper.setMinMaxValues(chartDataModel);
    }

    // set grid size
    final IPreferenceStore prefStore = TourbookPlugin.getDefault().getPreferenceStore();
    statAltitudeChart.setGridDistance(prefStore.getInt(ITourbookPreferences.GRAPH_GRID_HORIZONTAL_DISTANCE),
            prefStore.getInt(ITourbookPreferences.GRAPH_GRID_VERTICAL_DISTANCE));

    // show the new data in the chart
    statAltitudeChart.updateChart(chartDataModel, true);
}

From source file:net.tourbook.statistics.StatisticTourNumbers.java

License:Open Source License

/**
 * @param statDistanceChart/*from w ww .  j  a v a 2s  .  com*/
 * @param statDistanceMinMaxKeeper
 * @param highValues
 * @param lowValues
 * @param statDistanceColorIndex
 * @param unit
 * @param title
 * @param valueDivisor
 */
private void updateChartDistance(final Chart statDistanceChart,
        final BarChartMinMaxKeeper statDistanceMinMaxKeeper, final int[][] lowValues, final int[][] highValues,
        final int[][] colorIndex, final String unit, final String title, final int valueDivisor) {

    final ChartDataModel chartDataModel = new ChartDataModel(ChartDataModel.CHART_TYPE_BAR);

    // set the x-axis
    final ChartDataXSerie xData = new ChartDataXSerie(_statDistanceUnits);
    xData.setAxisUnit(ChartDataXSerie.AXIS_UNIT_NUMBER);
    xData.setUnitLabel(UI.UNIT_LABEL_DISTANCE);
    chartDataModel.setXData(xData);

    // y-axis: distance
    final ChartDataYSerie yData = new ChartDataYSerie(ChartDataModel.CHART_TYPE_BAR,
            ChartDataYSerie.BAR_LAYOUT_STACKED, lowValues, highValues);
    yData.setAxisUnit(ChartDataSerie.AXIS_UNIT_NUMBER);
    yData.setUnitLabel(unit);
    yData.setAllValueColors(0);
    yData.setYTitle(title);
    yData.setVisibleMinValue(0);
    yData.setValueDivisor(valueDivisor);
    chartDataModel.addYData(yData);
    StatisticServices.setDefaultColors(yData, GraphColorProvider.PREF_GRAPH_DISTANCE);
    StatisticServices.setTourTypeColors(yData, GraphColorProvider.PREF_GRAPH_DISTANCE, _activeTourTypeFilter);
    yData.setColorIndex(colorIndex);

    createToolTipProviderDistance(chartDataModel);

    if (_isSynchScaleEnabled) {
        statDistanceMinMaxKeeper.setMinMaxValues(chartDataModel);
    }

    // set grid size
    final IPreferenceStore prefStore = TourbookPlugin.getDefault().getPreferenceStore();
    statDistanceChart.setGridDistance(prefStore.getInt(ITourbookPreferences.GRAPH_GRID_HORIZONTAL_DISTANCE),
            prefStore.getInt(ITourbookPreferences.GRAPH_GRID_VERTICAL_DISTANCE));

    // show the new data fDataModel in the chart
    statDistanceChart.updateChart(chartDataModel, true);
}

From source file:net.tourbook.statistics.StatisticTourNumbers.java

License:Open Source License

private void updateChartTime(final Chart statDurationChart, final BarChartMinMaxKeeper statDurationMinMaxKeeper,
        final int[][] lowValues, final int[][] highValues, final int[][] colorIndex, final int yUnit,
        final String unit, final String title) {

    final ChartDataModel chartDataModel = new ChartDataModel(ChartDataModel.CHART_TYPE_BAR);

    // set the x-axis
    final ChartDataXSerie xData = new ChartDataXSerie(_statTimeUnits);
    xData.setAxisUnit(ChartDataSerie.AXIS_UNIT_HOUR_MINUTE);
    xData.setUnitLabel(UI.UNIT_LABEL_TIME);
    chartDataModel.setXData(xData);/* w  w w.  j  a  va  2  s .  co m*/

    // y-axis: altitude
    final ChartDataYSerie yData = new ChartDataYSerie(ChartDataModel.CHART_TYPE_BAR,
            ChartDataYSerie.BAR_LAYOUT_STACKED, lowValues, highValues);
    yData.setAxisUnit(yUnit);
    yData.setUnitLabel(unit);
    yData.setAllValueColors(0);
    yData.setYTitle(title);
    yData.setVisibleMinValue(0);
    chartDataModel.addYData(yData);

    StatisticServices.setDefaultColors(yData, GraphColorProvider.PREF_GRAPH_TIME);
    StatisticServices.setTourTypeColors(yData, GraphColorProvider.PREF_GRAPH_TIME, _activeTourTypeFilter);
    yData.setColorIndex(colorIndex);

    createToolTipProviderDuration(chartDataModel);

    if (_isSynchScaleEnabled) {
        statDurationMinMaxKeeper.setMinMaxValues(chartDataModel);
    }

    // set grid size
    final IPreferenceStore prefStore = TourbookPlugin.getDefault().getPreferenceStore();
    statDurationChart.setGridDistance(prefStore.getInt(ITourbookPreferences.GRAPH_GRID_HORIZONTAL_DISTANCE),
            prefStore.getInt(ITourbookPreferences.GRAPH_GRID_VERTICAL_DISTANCE));

    // show the new data data model in the chart
    statDurationChart.updateChart(chartDataModel, true);
}

From source file:net.tourbook.statistics.StatisticTourTime.java

License:Open Source License

private void updateChart(final long selectedTourId) {

    final ChartDataModel chartModel = new ChartDataModel(ChartDataModel.CHART_TYPE_BAR);

    // set the x-axis
    final ChartDataXSerie xData = new ChartDataXSerie(_tourTimeData.fTourDOYValues);
    xData.setAxisUnit(ChartDataXSerie.AXIS_UNIT_DAY);
    xData.setVisibleMaxValue(_currentYear);
    xData.setChartSegments(createChartSegments(_tourTimeData));
    chartModel.setXData(xData);/*from  w ww .j a  va2  s  .c  om*/

    // set the bar low/high data
    final ChartDataYSerie yData = new ChartDataYSerie(ChartDataModel.CHART_TYPE_BAR,
            new int[][] { _tourTimeData.fTourTimeStartValues },
            new int[][] { _tourTimeData.fTourTimeEndValues });
    yData.setYTitle(Messages.LABEL_GRAPH_DAYTIME);
    yData.setUnitLabel(Messages.LABEL_GRAPH_TIME_UNIT);
    yData.setAxisUnit(ChartDataXSerie.AXIS_UNIT_HOUR_MINUTE_24H);
    yData.setYAxisDirection(false);

    yData.setColorIndex(new int[][] { _tourTimeData.fTypeColorIndex });
    StatisticServices.setTourTypeColors(yData, GraphColorProvider.PREF_GRAPH_TIME, _activeTourTypeFiler);
    StatisticServices.setDefaultColors(yData, GraphColorProvider.PREF_GRAPH_TIME);

    chartModel.addYData(yData);

    /*
     * set graph minimum width, this is the number of days in the year
     */
    _calendar.set(_currentYear, 11, 31);
    final int yearDays = _calendar.get(Calendar.DAY_OF_YEAR);
    chartModel.setChartMinWidth(yearDays);

    setChartProviders(_chart, chartModel);

    if (_ifIsSynchScaleEnabled) {
        _minMaxKeeper.setMinMaxValues(chartModel);
    }

    // set grid size
    final IPreferenceStore prefStore = TourbookPlugin.getDefault().getPreferenceStore();
    _chart.setGridDistance(prefStore.getInt(ITourbookPreferences.GRAPH_GRID_HORIZONTAL_DISTANCE),
            prefStore.getInt(ITourbookPreferences.GRAPH_GRID_VERTICAL_DISTANCE));

    // show the data in the chart
    _chart.updateChart(chartModel, false, true);

    // try to select the previous selected tour
    selectTour(selectedTourId);
}

From source file:net.tourbook.statistics.StatisticWeek.java

License:Open Source License

public void refreshStatistic(final TourPerson person, final TourTypeFilter typeId, final int currentYear,
        final int numberOfYears, final boolean refreshData) {

    _activePerson = person;//from w  w w.j  a va  2 s . c  o  m
    _activeTourTypeFilter = typeId;
    _currentYear = currentYear;
    _numberOfYears = numberOfYears;

    _tourWeekData = DataProviderTourWeek.getInstance().getWeekData(person, typeId, currentYear, numberOfYears,
            isDataDirtyWithReset() || refreshData);

    // set week start values
    _firstDayOfWeek = _prefStore.getInt(ITourbookPreferences.CALENDAR_WEEK_FIRST_DAY_OF_WEEK);
    _minimalDaysInFirstWeek = _prefStore.getInt(ITourbookPreferences.CALENDAR_WEEK_MIN_DAYS_IN_FIRST_WEEK);

    _calendar.setFirstDayOfWeek(_firstDayOfWeek);
    _calendar.setMinimalDaysInFirstWeek(_minimalDaysInFirstWeek);

    // reset min/max values
    if (_isSynchScaleEnabled == false && refreshData) {
        _minMaxKeeper.resetMinMax();
    }

    final ChartDataModel chartDataModel = createChartDataModel();

    setChartProviders(chartDataModel);

    if (_isSynchScaleEnabled) {
        _minMaxKeeper.setMinMaxValues(chartDataModel);
    }

    // set grid size
    final IPreferenceStore prefStore = TourbookPlugin.getDefault().getPreferenceStore();
    _chart.setGridDistance(prefStore.getInt(ITourbookPreferences.GRAPH_GRID_HORIZONTAL_DISTANCE),
            prefStore.getInt(ITourbookPreferences.GRAPH_GRID_VERTICAL_DISTANCE));

    _chart.updateChart(chartDataModel, true);
}