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:com.nokia.carbide.cpp.internal.qt.core.QtSDKUtils.java

License:Open Source License

/**
 * Add a Qt-SDK to the Qt global preferences
 * @param name/*from   w ww  .  ja v  a2 s  .c  om*/
 * @param binPath
 * @param incPath
 * @param makeDefault
 */
static private void addQtSDK(String name, IPath binPath, IPath incPath, boolean makeDefault) {

    IPreferenceStore store = QtProjectPlugin.getDefault().getPreferenceStore();
    int count = store.getInt(PreferenceConstants.QTVERSION_COUNT);

    // Store settings using zero-index base
    store.setValue(PreferenceConstants.QTVERSION_NAME + "." + Integer.toString(count), name);
    store.setValue(PreferenceConstants.QTVERSION_BINPATH + "." + Integer.toString(count), binPath.toOSString());
    store.setValue(PreferenceConstants.QTVERSION_INCLUDEPATH + "." + Integer.toString(count),
            incPath.toOSString());

    if (makeDefault || count == 0) {
        store.setValue(PreferenceConstants.QTVERSION_DEFAULT, count);
    }

    ResourcesPlugin.getPlugin().getLog()
            .log(Logging.newStatus(QtCorePlugin.getDefault(), IStatus.INFO,
                    "New Qt-Symbian SDK added to Qt global preferences: " + name, //$NON-NLS-1$
                    null));

    store.setValue(PreferenceConstants.QTVERSION_COUNT, count + 1); // # of table items, base is 1 (i.e. not zero)

    refreshQtStoredSDKs();
}

From source file:com.nokia.carbide.cpp.internal.qt.core.QtSDKUtils.java

License:Open Source License

/**
 * Update the internal list of Qt-SDKs found in the Qt global preferences
 *///from ww  w . j a  va2  s . c  om
static void refreshQtStoredSDKs() {
    synchronized (qtSDKList) {
        qtSDKList.clear();

        IPreferenceStore store = QtProjectPlugin.getDefault().getPreferenceStore();
        int count = store.getInt(PreferenceConstants.QTVERSION_COUNT);
        for (int i = 0; i < count; i++) {
            String nameKey = PreferenceConstants.QTVERSION_NAME + "." + Integer.toString(i);
            String binpathKey = PreferenceConstants.QTVERSION_BINPATH + "." + Integer.toString(i);
            String includepathKey = PreferenceConstants.QTVERSION_INCLUDEPATH + "." + Integer.toString(i);
            String name = "";
            String binPath = "";
            String incPath = "";
            if (store.contains(nameKey)) {
                name = store.getString(nameKey);
            }
            if (store.contains(binpathKey)) {
                binPath = store.getString(binpathKey);
            }
            if (store.contains(includepathKey)) {
                incPath = store.getString(includepathKey);
            }

            QtSDK qtSDK = new QtSDK(name, incPath, binPath);
            qtSDKList.add(qtSDK);
        }
    }
}

From source file:com.nokia.carbide.cpp.project.core.tests.QtPropertiesTest.java

License:Open Source License

public void testReadQtPropertiesFirstTime() throws Exception {

    IPreferenceStore store = QtProjectPlugin.getDefault().getPreferenceStore();

    assertNotNull("Can't get QtProjectPlugins prefs store.", store);

    QtSDKCount = store.getInt(PreferenceConstants.QTVERSION_COUNT);
    assertEquals("There should be no Qt SDKs installed.", 0, QtSDKCount);

    defaultQtVersionName = store.getString(PreferenceConstants.QTVERSION_DEFAULT);
    assertEquals("", defaultQtVersionName);
}

From source file:com.nokia.carbide.cpp.project.core.tests.QtPropertiesTest.java

License:Open Source License

public void testCreateQtSDKEntries() throws Exception {

    IPreferenceStore store = QtProjectPlugin.getDefault().getPreferenceStore();

    int count = store.getInt(PreferenceConstants.QTVERSION_COUNT);

    createQtSDKEntry(store, "TestSDK1", true);
    createQtSDKEntry(store, "TestSDK2", true);
    createQtSDKEntry(store, "TestSDK3", false);
    createQtSDKEntry(store, "TestSDK4", false);

    store.setValue(PreferenceConstants.QT_AUTOSETMKSPEC, false);
    store.setValue(PreferenceConstants.QT_AUTOSETMKCMD, false);

    count = store.getInt(PreferenceConstants.QTVERSION_COUNT);
    assertEquals("Number of Qt SDKs count if off", count, QtSDKCount);

    int defaultSDK = store.getInt(PreferenceConstants.QTVERSION_DEFAULT); // zero-based index
    assertEquals(1, defaultSDK);//from   w  w  w .  ja va2s .  c om
}

From source file:com.nokia.carbide.cpp.project.core.tests.QtPropertiesTest.java

License:Open Source License

private void createQtSDKEntry(IPreferenceStore store, String name, boolean makeDefault) {
    QtSDKCount = store.getInt(PreferenceConstants.QTVERSION_COUNT);

    store.setValue(PreferenceConstants.QTVERSION_COUNT, QtSDKCount + 1); // # of table items, not zero based
    store.setValue(PreferenceConstants.QTVERSION_NAME + "." + Integer.toString(QtSDKCount), name);
    store.setValue(PreferenceConstants.QTVERSION_BINPATH + "." + Integer.toString(QtSDKCount),
            "T:\\epoc32\\tools\\qt");
    store.setValue(PreferenceConstants.QTVERSION_INCLUDEPATH + "." + Integer.toString(QtSDKCount),
            "T:\\epoc32\\include\\mw");

    if (makeDefault) {
        store.setValue(PreferenceConstants.QTVERSION_DEFAULT, QtSDKCount);
    }//from ww w .  j av a  2s. co m

    QtSDKCount = store.getInt(PreferenceConstants.QTVERSION_COUNT);

}

From source file:com.nokia.carbide.cpp.project.core.tests.QtPropertiesTest.java

License:Open Source License

/**
 * Check and see if an SDK exists by name and return its zero-based index. Return -1 if not found.
 * @return/*from   w  w w .  ja  va  2s.  com*/
 */
private int findSDKByName(IPreferenceStore store, String sdkName) {
    int foundIndex = -1;

    int count = store.getInt(PreferenceConstants.QTVERSION_COUNT);
    for (int i = 0; i < count; i++) {
        String nameKey = PreferenceConstants.QTVERSION_NAME + "." + Integer.toString(i);
        String binpathKey = PreferenceConstants.QTVERSION_BINPATH + "." + Integer.toString(i);
        String includepathKey = PreferenceConstants.QTVERSION_INCLUDEPATH + "." + Integer.toString(i);
        String name = "";
        //String binpath = "";
        //String includepath = "";
        if (store.contains(nameKey)) {
            name = store.getString(nameKey);
            if (name.equalsIgnoreCase(sdkName)) {
                foundIndex = i;
                break;
            }
        }
    }

    return foundIndex;
}

From source file:com.nokia.s60tools.analyzetool.builder.AnalyzeToolBuilder.java

License:Open Source License

/**
 * Executes atool.exe with options.//  w  w  w .  j a  v  a2 s  .  com
 * 
 * @param path
 *            log path
 * @param fileName
 *            log file name
 * @param type
 *            Type of execution. Possible types ATOOL_INST or ATOOL_UNINST
 * @param loggingModeCommand
 *            Used logging mode
 * @param userSelectedMmpFiles
 *            List of user selected mmp files
 * @param cpi
 *            ICarbideProjectInfo reference
 * @param monitor
 *            Progress monitor reference
 * 
 * @return COMMAND_LINE_ERROR_CODE.OK if no errors, otherwise error code
 */
protected final int executeAtool(final String path, final String fileName, final String type,
        final String loggingModeCommand, final List<IFile> userSelectedMmpFiles, final ICarbideProjectInfo cpi,
        final IProgressMonitor monitor) {

    // get used platform
    String platform = cpi.getDefaultConfiguration().getPlatformString().toLowerCase(Locale.US);

    // get build target
    String buildTarget = cpi.getDefaultConfiguration().getTargetString().toLowerCase(Locale.US);

    // used arguments to atool.exe
    AbstractList<String> usedArguments = new ArrayList<String>();

    // which logging mode is used
    if (loggingModeCommand.equalsIgnoreCase(Constants.LOGGING_EXT_FAST)) {
        usedArguments.add(Constants.ATOOL_INST_EF);
    } else {
        usedArguments.add(Constants.ATOOL_INST_I);
        // if path is set
        if (path != null && !("").equals(path)) {
            usedArguments.add("-fp");
            usedArguments.add(path);
        }

        // if file name is set
        if (fileName != null && !("").equals(fileName)) {
            usedArguments.add("-f");
            usedArguments.add(fileName);
        }
    }

    // if "verbose atool.exe output" is enabled
    if (verbose) {
        usedArguments.add(Constants.ATOOL_SHOW_DEBUG);
    }

    // get callstack size
    IPreferenceStore store = Activator.getPreferences();
    if (store.getBoolean(Constants.USE_CALLSTACK_SIZE)) {
        int callstackSize = store.getInt(Constants.CALLSTACK_SIZE);
        usedArguments.add(Constants.CALLSTACK_SIZE_OPTION);
        usedArguments.add(Integer.toString(callstackSize));
    }

    // add build command
    // if project using SBSv2 build system
    boolean sbsBuild = isSBSBuildActivated(cpi);
    if (sbsBuild) {
        usedArguments.add("sbs");
        usedArguments.add("-c");
        StringBuffer buildCommand = new StringBuffer();
        buildCommand.append(platform);
        buildCommand.append('_');
        buildCommand.append(buildTarget);
        usedArguments.add(buildCommand.toString());
    } else // use abld
    {
        usedArguments.add("abld");
        usedArguments.add("build");
        usedArguments.add(platform);
        usedArguments.add(buildTarget);
    }

    int errorCode = Constants.COMMAND_LINE_ERROR_CODE.OK.getCode();
    // if user has selected custom setup of components =>build them
    // this means that call is come from CompileSymbianComponent class
    if (userSelectedMmpFiles != null && !userSelectedMmpFiles.isEmpty()) {

        // get atool.exe command
        Iterator<IFile> files = userSelectedMmpFiles.iterator();
        while (files.hasNext()) {
            IFile file = files.next();
            IPath location = file.getLocation();

            String mmpFileName = getMMPFileName(location, true);
            if (mmpFileName == null || ("").equals(mmpFileName)) {
                continue;
            }

            // if this is first mmp file add it parameter list
            usedArguments.add("-p");
            usedArguments.add(mmpFileName);
        }

        // now the command is ready
        // execute command
        // execute atool.exe via CommandLauncher class
        cmdLauncher.showCommand(true);
        String[] arguments = new String[usedArguments.size()];
        usedArguments.toArray(arguments);

        errorCode = cmdLauncher.executeCommand(new Path(Util.getAtoolInstallFolder()), arguments,
                CarbideCPPBuilder.getResolvedEnvVars(cpi.getDefaultConfiguration()),
                cpi.getINFWorkingDirectory());

        // if user press "Cancel"
        if (monitor.isCanceled()) {
            buildCancelled(monitor, false);
            monitor.done();
        }

        // thru selected files and build with the Carbide builder
        for (int i = 0; i < userSelectedMmpFiles.size(); i++) {

            // get one file
            IFile file = userSelectedMmpFiles.get(i);

            // get file location
            IPath fileLocation = file.getLocation();

            // invoke normal Carbide build
            try {
                CarbideCPPBuilder.invokeSymbianComponenetAction(cpi.getDefaultConfiguration(),
                        CarbideCPPBuilder.BUILD_COMPONENT_ACTION, fileLocation, cmdLauncher, monitor, true);
            } catch (CoreException e) {
                e.printStackTrace();
            }

            // if user press "Cancel"
            if (monitor.isCanceled()) {
                buildCancelled(monitor, false);
                monitor.done();
            }
        }

        // Carbide build is finished
        // now remove AnalyzeTool made modifications
        // if project contains build erros => only uninstrument mmp
        // file
        if (CarbideCPPBuilder.projectHasBuildErrors(cpi.getProject())) {
            usedArguments.set(0, Constants.ATOOL_UNINST_FAILED);
        }

        // project succesfully build => uninstrumet project
        runUninstrument(Constants.ATOOL_UNINST, cpi, monitor);
    }
    // if build from bld.inf file
    else if (cpi.isBuildingFromInf()) {
        cmdLauncher.showCommand(true);

        String[] arguments = new String[usedArguments.size()];
        usedArguments.toArray(arguments);
        errorCode = cmdLauncher.executeCommand(new Path(Util.getAtoolInstallFolder()), arguments,
                CarbideCPPBuilder.getResolvedEnvVars(cpi.getDefaultConfiguration()),
                cpi.getINFWorkingDirectory());

        if (mmpFiles != null) {
            mmpFiles.clear();
        }

        // if user press "Cancel"
        if (monitor.isCanceled()) {
            buildCancelled(monitor, false);
            monitor.done();
        }

    } else { // instrument only defined components
        // get build components
        mmpFiles = cpi.getInfBuildComponents();

        for (int i = 0; i < mmpFiles.size(); i++) {
            usedArguments.add("-p");
            usedArguments.add(mmpFiles.get(i));
        }
        cmdLauncher.showCommand(true);

        String[] arguments = new String[usedArguments.size()];
        usedArguments.toArray(arguments);
        errorCode = cmdLauncher.executeCommand(new Path(Util.getAtoolInstallFolder()), arguments,
                CarbideCPPBuilder.getResolvedEnvVars(cpi.getDefaultConfiguration()),
                cpi.getINFWorkingDirectory());

        // if user press "Cancel"
        if (monitor.isCanceled()) {
            buildCancelled(monitor, false);
            monitor.done();
        }
    }
    return errorCode;
}

From source file:com.nokia.s60tools.analyzetool.preferences.AnalyzeToolPreferencePage.java

License:Open Source License

/**
 * Checks preferences initial values if logging mode is not set to S60
 * disables S60 data file name selections.
 *///from w  w  w .j  av a2 s.  com
public final void checkInitValues() {
    IPreferenceStore store = Activator.getPreferences();

    // get stored atool folder
    String atoolFolder = store.getString(Constants.ATOOL_FOLDER);
    atoolVerLabel.setText(Constants.PREFS_ATOOL_VER_NOT_FOUND);

    // if atool folder is set to point default atool location
    if (atoolFolder.equals(Constants.DEFAULT_ATOOL_FOLDER)) {

        // check that stored atool location exists
        File file = new File(atoolFolder);
        if (file.exists()) { // if exists use this location and update
            // preference page buttons
            useDefaultLocation.setSelection(false);
            store.setValue(Constants.USE_INTERNAL, false);

        } else { // location could not found => use internal atool
            useDefaultLocation.setSelection(true);
            store.setValue(Constants.USE_INTERNAL, true);
        }
    } else {
        boolean useDef = store.getBoolean(Constants.USE_INTERNAL);
        useDefaultLocation.setSelection(useDef);
    }

    // get atool.exe path and set it atool.exe path field
    String atoolPath = store.getString(Constants.USER_SELECTED_FOLDER);
    atoolDirText.setText(atoolPath);

    // update preference page buttons
    handleDefaultLocationChange();

    // get logging mode and update buttons
    String fileMode = store.getString(Constants.LOGGING_MODE);
    setGroupButtons(fileMode);

    logPathText.setText(store.getString(Constants.DEVICE_LOG_FILE_PATH));
    fileNameText.setText(store.getString(Constants.DEVICE_LOG_FILE_NAME));

    logPathText.setText(store.getString(Constants.DEVICE_LOG_FILE_PATH));
    fileNameText.setText(store.getString(Constants.DEVICE_LOG_FILE_NAME));

    verboseButton.setSelection(store.getBoolean(Constants.ATOOL_VERBOSE));

    // get stored callstack size
    int callstackSize = store.getInt(Constants.CALLSTACK_SIZE);
    if (callstackSize == 0) {
        zeroButton.setSelection(true);
        spinner.setEnabled(false);
    } else if (callstackSize == 40) {
        fortyButton.setSelection(true);
        spinner.setEnabled(false);
    } else if (callstackSize == 100) {
        hundredButton.setSelection(true);
        spinner.setEnabled(false);
    } else {
        // if callstack size is set to custom area
        // enable spinner and set stored callstack size
        customButton.setSelection(true);
        spinner.setEnabled(true);
        spinner.setSelection(callstackSize);
    }
}

From source file:com.nokia.s60tools.memspy.preferences.MemSpyPreferences.java

License:Open Source License

/**
 * Gets SWMT category settings for this session.
 * @return SWMT category settings for this session
 *//*ww  w  .j  av a2 s .  c o m*/
public static int getSWMTCategorySetting() {

    IPreferenceStore store = MemSpyPlugin.getPrefsStore();

    boolean isProfileSelected = store
            .getBoolean(MemSpyPreferenceConstants.SWMT_CATEGORY_SETTING_PROFILE_SELECTED);
    int value;
    if (isProfileSelected) {
        value = getSWMTCategorySettingForProfile();
    } else {
        value = store.getInt(MemSpyPreferenceConstants.SWMT_CATEGORY_SETTINGS_CUSTOM);
    }
    return value;
}

From source file:com.nokia.s60tools.memspy.preferences.MemSpyPreferences.java

License:Open Source License

/**
 * Gets SWMT category settings for Profile selection.
 * @return SWMT category settings for profile
 *///from  ww w. j a va  2 s . co  m
public static int getSWMTCategorySettingForProfile() {
    IPreferenceStore store = MemSpyPlugin.getPrefsStore();
    return store.getInt(MemSpyPreferenceConstants.SWMT_CATEGORY_SETTING);
}