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.statistics.StatisticYear.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.j  a  v  a  2s  .co m*/
    fActiveTourTypeFilter = tourTypeFilter;
    fCurrentYear = currentYear;
    fNumberOfYears = numberOfYears;

    fTourYearData = DataProviderTourYear.getInstance().getYearData(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.tour.DialogQuickEdit.java

License:Open Source License

private void createUI_110_Title(final Composite parent) {

    Label label;/*from w w  w .j  a va2 s.com*/
    final int defaultTextWidth = _pc.convertWidthInCharsToPixels(40);

    final Composite section = createSection(parent, Messages.tour_editor_section_tour, true);
    GridLayoutFactory.fillDefaults().numColumns(2).applyTo(section);
    {
        /*
         * title
         */

        label = _tk.createLabel(section, Messages.tour_editor_label_tour_title);
        _firstColumnControls.add(label);

        // combo: tour title with history
        _comboTitle = new Combo(section, SWT.BORDER | SWT.FLAT);
        _comboTitle.setText(UI.EMPTY_STRING);

        _tk.adapt(_comboTitle, true, false);

        GridDataFactory.fillDefaults()//
                .grab(true, false).hint(defaultTextWidth, SWT.DEFAULT).applyTo(_comboTitle);

        // fill combobox
        final TreeSet<String> dbTitles = TourDatabase.getAllTourTitles();
        for (final String title : dbTitles) {
            _comboTitle.add(title);
        }

        new AutocompleteComboInput(_comboTitle);

        /*
         * description
         */
        label = _tk.createLabel(section, Messages.tour_editor_label_description);
        GridDataFactory.swtDefaults().align(SWT.FILL, SWT.BEGINNING).applyTo(label);
        _firstColumnControls.add(label);

        _txtDescription = _tk.createText(section, //
                UI.EMPTY_STRING, SWT.BORDER | SWT.WRAP | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL//
        );

        final IPreferenceStore store = TourbookPlugin.getDefault().getPreferenceStore();

        int descLines = store.getInt(ITourbookPreferences.TOUR_EDITOR_DESCRIPTION_HEIGHT);
        descLines = descLines == 0 ? 5 : descLines;

        GridDataFactory.fillDefaults()//
                .grab(true, true)
                //
                // SWT.DEFAULT causes lot's of problems with the layout therefore the hint is set
                //
                .hint(defaultTextWidth, _pc.convertHeightInCharsToPixels(descLines)).applyTo(_txtDescription);
    }
}

From source file:net.tourbook.ui.tourChart.TourChartPropertyView.java

License:Open Source License

private void restoreSettings() {

    final IPreferenceStore store = TourbookPlugin.getDefault().getPreferenceStore();

    // get values from pref store

    fChkUseCustomClipSettings/*from www  .  j  av a  2 s .  c o m*/
            .setSelection(store.getBoolean(ITourbookPreferences.GRAPH_PROPERTY_IS_VALUE_CLIPPING));
    fSpinnerClipValues.setSelection(store.getInt(ITourbookPreferences.GRAPH_PROPERTY_VALUE_CLIPPING_TIMESLICE));

    fChkUseCustomPaceClipping
            .setSelection(store.getBoolean(ITourbookPreferences.GRAPH_PROPERTY_IS_PACE_CLIPPING));
    fSpinnerPaceClipping.setSelection(store.getInt(ITourbookPreferences.GRAPH_PROPERTY_PACE_CLIPPING_VALUE));

    // chart type
    final int speedChartType = store.getInt(ITourbookPreferences.GRAPH_PROPERTY_CHARTTYPE);
    if (speedChartType == 0 || speedChartType == ChartDataModel.CHART_TYPE_LINE) {
        fRadioLineChartType.setSelection(true);
    } else {
        fRadioBarChartType.setSelection(true);
    }

    enableControls();
}

From source file:net.tourbook.ui.views.tourCatalog.WizardPageReferenceTour.java

License:Open Source License

private void showReferenceTour(final SelectionChangedEvent event) {

    final IStructuredSelection selection = (IStructuredSelection) event.getSelection();

    final TourReference refTour = (TourReference) selection.getFirstElement();

    if (refTour != null) {

        // get tour data from the database
        final TourData tourData = refTour.getTourData();

        // set the altitude visible
        final TourChartConfiguration chartConfig = new TourChartConfiguration(false);
        chartConfig.addVisibleGraph(TourManager.GRAPH_ALTITUDE);

        final ChartDataModel chartDataModel = TourManager.getInstance().createChartDataModel(tourData,
                chartConfig);//  w  w  w  .  jav a 2s  . c o  m

        final ChartDataXSerie xData = chartDataModel.getXData();

        xData.setSynchMarkerValueIndex(refTour.getStartValueIndex(), refTour.getEndValueIndex());

        _chartGroup.setText(NLS.bind(refTour.getLabel() + ": " //$NON-NLS-1$
                + Messages.tourCatalog_wizard_Group_chart_title, TourManager.getTourDateShort(tourData)));

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

        _refTourChart.updateChart(chartDataModel, false);

    } else {

        // hide the chart
        _refTourChart.updateChart(null, false);
        _chartGroup.setText(UI.EMPTY_STRING);
    }
}

From source file:nz.co.senanque.madura.Utils.java

License:Open Source License

public static int getBufferSize() {
    IPreferenceStore store = MaduraPlugin.getDefault().getPreferenceStore();
    return store.getInt(PreferenceConstants.P_BUFFER_SIZE);
}

From source file:org.acoveo.callcenter.sipclient.PjsuaClient.java

License:Open Source License

/** ATTENTION: This method MUST NOT be called from within the display thread
 * in order to prevent deadlocks/* ww w. j  a v a  2  s.  co  m*/
 */
public static synchronized void connectToSipServer() throws RuntimeException {
    if (!isPjsuaInitialised) {
        initialisePjsua();
    }
    // Disable the phone tester
    removePhoneStateListener(phoneTester);

    // Put the phone into deregistered state
    phoneState.registrationFailed(defaultAccountId);

    final IPreferenceStore store = Activator.getDefault().getPreferenceStore();
    if (store == null) {
        throw new RuntimeException("Could not get the preference store"); //$NON-NLS-1$
    }

    // Runtime exceptions thrown within the runnable are thrown by the following call
    PjsuaClient.pjsuaWorker.syncExec(new Runnable() {
        @Override
        public void run() {
            String host = store.getString(AccountPreferencePage.PREF_SIP_HOST);
            int port = store.getInt(AccountPreferencePage.PREF_SIP_SERVER_PORT);
            String hostString = host + ":" + port; //$NON-NLS-1$

            String authRealm = store.getString(AccountPreferencePage.PREF_SIP_AUTH_REALM);

            /* Remove all accounts and all transports */
            //XXX To port Maybe we should hangup all calls too?
            Collection<pjsua_acc_info> accInfos = getAllAccountInfo();
            for (pjsua_acc_info info : accInfos) {
                acc_del(info.getId());
            }

            String publicIp = store.getString(AccountPreferencePage.PREF_SIP_NETWORK_ADDRESS);

            //XXX We only configure the network once on startup (removing transports did not work last time I checked)
            Collection<pjsua_transport_info> transportInfos = getAllTransportInfo();
            if (transportInfos.isEmpty()) {
                /* Add UDP transport. */
                pjsua_transport_config transp_cfg = new pjsua_transport_config();
                transport_config_default(transp_cfg);
                if (!publicIp.isEmpty()) {
                    transp_cfg.setPublic_addr(pj_str_copy(publicIp));
                }
                int status = transport_create(pjsip_transport_type_e.PJSIP_TRANSPORT_UDP, transp_cfg, null);
                if (status != pjsuaConstants.PJ_SUCCESS) {
                    throw new RuntimeException("Error creating SIP transport: " + status //$NON-NLS-1$
                            + " the UDP bind port you selected is probably already in use."); //$NON-NLS-1$
                }

                // We only add a media transport if we do not use the default IP
                // It is created automatically for us if we do not add it manually
                if (!publicIp.isEmpty()) {
                    transp_cfg = new pjsua_transport_config();
                    transport_config_default(transp_cfg);
                    transp_cfg.setPublic_addr(pj_str_copy(publicIp));
                    transp_cfg.setPort(4000); // This is just the port to start the search for a free port
                    status = media_transports_create(transp_cfg);
                    if (status != pjsuaConstants.PJ_SUCCESS) {
                        throw new RuntimeException("Error creating RTP transport: " + status + "."); //$NON-NLS-1$ //$NON-NLS-2$
                    }
                }
            }

            /* Initialization is done, now start pjsua */
            int status = start();
            if (status != pjsuaConstants.PJ_SUCCESS) {
                throw new RuntimeException("Error starting pjsua: " + status); //$NON-NLS-1$
            }

            /* Register to SIP server by creating SIP account. */
            pjsua_acc_config cfg = new pjsua_acc_config();

            acc_config_default(cfg);
            cfg.setId(pj_str_copy("sip:" + sipUser + "@" + hostString)); //$NON-NLS-1$ //$NON-NLS-2$
            cfg.setReg_uri(pj_str_copy("sip:" + hostString)); //$NON-NLS-1$
            cfg.setCred_count(1);
            pjsip_cred_info cred_info = cfg.getCred_info();
            cred_info.setRealm(pj_str_copy(authRealm));
            cred_info.setScheme(pj_str_copy("Digest")); //$NON-NLS-1$
            cred_info.setUsername(pj_str_copy(sipUser));
            cred_info.setData_type(pjsip_cred_data_type.PJSIP_CRED_DATA_PLAIN_PASSWD.swigValue());
            cred_info.setData(pj_str_copy(sipPwd));

            int[] acc_id = new int[1];
            status = pjsua.acc_add(cfg, pjsuaConstants.PJ_TRUE, acc_id);
            if (status != pjsuaConstants.PJ_SUCCESS) {
                Activator.getLogger().error("Error adding account: " + status); //$NON-NLS-1$
            }
        }
    });

    // Attach the phone tester if enabled
    if (store.getBoolean(SoftPhonePreferencePage.PREF_STRESS_TEST_MODE)) {
        addPhoneStateListener(phoneTester);
    }
}

From source file:org.acoveo.callcenter.sipclient.PjsuaClient.java

License:Open Source License

/** Try to create a valid sip URL from the given number
 * /*from w  w  w . jav a2s  .c  o  m*/
 * This method uses the server the phone is registered to in
 * order to create the '@HOSTNAME' portion and prepends 'sip:'
 * if that is missing.
 * @param number The number to process
 * @return An improved (and probably valid) SIP URL
 */
public static String createSipUrlFromNumber(String number) {
    String sipUrl = number;

    if (!number.contains("/") && !number.contains("@")) { //$NON-NLS-1$ //$NON-NLS-2$
        IPreferenceStore store = Activator.getDefault().getPreferenceStore();
        String host = store.getString(AccountPreferencePage.PREF_SIP_HOST);
        int port = store.getInt(AccountPreferencePage.PREF_SIP_SERVER_PORT);
        sipUrl = "sip:" + number + "@" + host + ":" + port; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    } else if (!number.startsWith("sip:")) { //$NON-NLS-1$
        sipUrl = "sip:" + number; //$NON-NLS-1$
    }
    return sipUrl;
}

From source file:org.acoveo.callcenter.sipclient.PjsuaClient.java

License:Open Source License

/** Try to simplify the given sip URL
 * //from   w  w  w .  j  a va2s. co m
 * This method uses the server the phone is registered to in
 * order to strip unneeded parts from the given sip url.
 * @param sipUrl The URL to simplify
 * @return A stripped sip URL number
 */
public static String simplifySipUrl(String sipUrl) {
    if (sipUrl != null) {
        StringBuilder simpleNumber = new StringBuilder(sipUrl);
        if (sipUrl.startsWith("<") && sipUrl.endsWith(">")) { //$NON-NLS-1$ //$NON-NLS-2$
            simpleNumber.replace(0, 1, ""); //$NON-NLS-1$
            simpleNumber.replace(simpleNumber.length() - 1, simpleNumber.length(), ""); //$NON-NLS-1$
        }
        if (simpleNumber.toString().startsWith("sip:")) { //$NON-NLS-1$
            simpleNumber.replace(0, "sip:".length(), ""); //$NON-NLS-1$ //$NON-NLS-2$
        }
        if (sipUrl.contains("@")) { //$NON-NLS-1$
            int atSignIndex = simpleNumber.indexOf("@"); //$NON-NLS-1$
            if (atSignIndex >= 0) {
                String hostPart = simpleNumber.substring(atSignIndex + 1, simpleNumber.length());
                IPreferenceStore store = Activator.getDefault().getPreferenceStore();
                String host = store.getString(AccountPreferencePage.PREF_SIP_HOST);
                int portSignIndex = simpleNumber.indexOf(":", atSignIndex); //$NON-NLS-1$
                if (portSignIndex > 0) {
                    host += ":" + store.getInt(AccountPreferencePage.PREF_SIP_SERVER_PORT); //$NON-NLS-1$
                }
                if (hostPart.equals(host)) {
                    simpleNumber.replace(atSignIndex, simpleNumber.length(), ""); //$NON-NLS-1$
                } else if (hostPart.equals("127.0.0.1")) { //$NON-NLS-1$
                    simpleNumber.replace(atSignIndex, simpleNumber.length(), ""); //$NON-NLS-1$
                }
            }
        }
        return simpleNumber.toString();
    } else {
        return null;
    }
}

From source file:org.acoveo.callcenter.sipclient.PjsuaClient.java

License:Open Source License

/** Creates the tones for the phone with the specified sample rate for the ringing device
 * /*w w w .ja v  a  2 s .com*/
 * The default sample rate is used for the ring tones which are connected to the conference bridge
 * @param ringingDeviceSampleRate If -1 the default sample rate will be used. Specified in kHz.
 */
protected static void generateTones(long ringingDeviceSampleRate) {
    destroyTones();
    if (ringingDeviceSampleRate < 0) {
        ringingDeviceSampleRate = mediaConfig.getClock_rate();
    }
    long samples_per_frame = getDefaultSamplesPerFrame();
    IPreferenceStore store = Activator.getDefault().getPreferenceStore();
    List<RingtoneSpecification> ringtoneSpecs = new LinkedList<RingtoneSpecification>();

    ringtoneSpecs
            .add(new RingtoneSpecification(store, Arrays.asList(SoftPhonePreferencePage.RING_TONE_PARAMETERS)));
    ringToneBridge = new ConferenceBridgeRingtone(memoryPool, mediaConfig, mediaConfig.getClock_rate(),
            samples_per_frame, ringtoneSpecs);
    try {
        ringToneBridge.createTone();
    } catch (Exception e) {
        Activator.getLogger().error("Creating the ring tone for the conference bridge failed", e); //$NON-NLS-1$
    }
    ringToneRingingDevice = new AudioDeviceRingtone(memoryPool, mediaConfig, ringingDeviceSampleRate,
            samples_per_frame, ringtoneSpecs, ringSoundPort);
    try {
        ringToneRingingDevice.createTone();
    } catch (Exception e) {
        Activator.getLogger().error("Creating the ring tone for the ringing device failed", e); //$NON-NLS-1$
    }

    ringtoneSpecs.clear();
    ringtoneSpecs.add(
            new RingtoneSpecification(store, Arrays.asList(SoftPhonePreferencePage.RING_BACK_TONE_PARAMETERS)));
    ringBackToneBridge = new ConferenceBridgeRingtone(memoryPool, mediaConfig, mediaConfig.getClock_rate(),
            samples_per_frame, ringtoneSpecs);
    try {
        ringBackToneBridge.createTone();
    } catch (Exception e) {
        Activator.getLogger().error("Creating the ring back tone for the conference bridge failed", e); //$NON-NLS-1$
    }
    ringBackToneRingingDevice = new AudioDeviceRingtone(memoryPool, mediaConfig, ringingDeviceSampleRate,
            samples_per_frame, ringtoneSpecs, ringSoundPort);
    try {
        ringBackToneRingingDevice.createTone();
    } catch (Exception e) {
        Activator.getLogger().error("Creating the ring back tone for the ringing device failed", e); //$NON-NLS-1$
    }

    ringtoneSpecs.clear();
    RingtoneSpecification spec = new RingtoneSpecification();
    spec.freq1 = (short) store.getInt(SoftPhonePreferencePage.PREF_SPECIALTONE_FREQ1);
    spec.freq2 = 0;
    spec.onMs = (short) store.getInt(SoftPhonePreferencePage.PREF_SPECIALTONE_ON_MS);
    spec.offMs = 0;
    spec.ringCount = 1;
    spec.intervalMs = 0;
    spec.volume = (short) store.getInt(SoftPhonePreferencePage.PREF_SPECIALTONE_VOLUME);
    ringtoneSpecs.add(spec);
    spec = new RingtoneSpecification();
    spec.freq1 = (short) store.getInt(SoftPhonePreferencePage.PREF_SPECIALTONE_FREQ2);
    spec.freq2 = 0;
    spec.onMs = (short) store.getInt(SoftPhonePreferencePage.PREF_SPECIALTONE_ON_MS);
    spec.offMs = 0;
    spec.ringCount = 1;
    spec.intervalMs = 0;
    spec.volume = (short) store.getInt(SoftPhonePreferencePage.PREF_SPECIALTONE_VOLUME);
    ringtoneSpecs.add(spec);
    spec = new RingtoneSpecification();
    spec.freq1 = (short) store.getInt(SoftPhonePreferencePage.PREF_SPECIALTONE_FREQ3);
    spec.freq2 = 0;
    spec.onMs = (short) store.getInt(SoftPhonePreferencePage.PREF_SPECIALTONE_ON_MS);
    spec.offMs = 0;
    spec.ringCount = 1;
    spec.intervalMs = (short) store.getInt(SoftPhonePreferencePage.PREF_SPECIALTONE_INTERVAL_MS);
    spec.volume = (short) store.getInt(SoftPhonePreferencePage.PREF_SPECIALTONE_VOLUME);
    ringtoneSpecs.add(spec);
    specialToneBridge = new ConferenceBridgeRingtone(memoryPool, mediaConfig, mediaConfig.getClock_rate(),
            samples_per_frame, ringtoneSpecs);
    try {
        specialToneBridge.createTone();
    } catch (Exception e) {
        Activator.getLogger().error("Creating the congestion tone for the conference bridge failed", e);
    }
    specialToneRingingDevice = new AudioDeviceRingtone(memoryPool, mediaConfig, ringingDeviceSampleRate,
            samples_per_frame, ringtoneSpecs, ringSoundPort);
    try {
        specialToneRingingDevice.createTone();
    } catch (Exception e) {
        Activator.getLogger().error("Creating the congestion tone for the ringing device failed", e);
    }
}

From source file:org.apache.cactus.eclipse.runner.ui.CactusPreferences.java

License:Apache License

/**
 * @return the context URL that should be used by the client, as 
 * configured in the plug-in preferences.
 *//*  w  w w.ja  v a  2s.  c  o  m*/
public static String getContextURL() {
    IPreferenceStore store = CactusPlugin.getDefault().getPreferenceStore();
    StringBuffer buf = new StringBuffer().append(store.getString(CONTEXT_URL_SCHEME)).append("://")
            .append(store.getString(CONTEXT_URL_HOST)).append(":").append(store.getInt(CONTEXT_URL_PORT))
            .append("/").append(store.getString(CONTEXT_URL_PATH));
    String result = buf.toString();
    return result;
}