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

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

Introduction

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

Prototype

boolean getBoolean(String name);

Source Link

Document

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

Usage

From source file:com.nokia.carbide.internal.bugdatacollector.ui.preferences.BugDataCollectorPreferencePage.java

License:Open Source License

private void getPrefsStoreValues() {
    IPreferenceStore store = BugDataCollectorPlugin.getPrefsStore();
    String username = store.getString(BugDataCollectorPreferenceConstants.BR_USERNAME);
    emailText.setText(username);//from  w  w  w  .j  a v a 2 s  .  co m
    String password = store.getString(BugDataCollectorPreferenceConstants.BR_PASSWORD);
    DesEncrypter encrypter = new DesEncrypter();
    passwordText.setText(encrypter.decrypt(password));
    boolean sdk = store.getBoolean(BugDataCollectorPreferenceConstants.BR_SEND_SDK_INFO);
    sdkButton.setSelection(sdk);
    boolean diagnostic = store.getBoolean(BugDataCollectorPreferenceConstants.BR_SEND_DIAGNOSTIC_LOG);
    logButton.setSelection(diagnostic);
}

From source file:com.nokia.carbide.internal.bugdatacollector.ui.preferences.BugDataCollectorPreferencePage.java

License:Open Source License

/**
 * Returns true if devices.xml is to be send with the report, false if not.
 * @return true if devices.xml is to be send with the report, false if not.
 *///  ww w  .j  av a2s  .c o  m
public static boolean sendSdkData() {
    IPreferenceStore store = BugDataCollectorPlugin.getPrefsStore();
    return store.getBoolean(BugDataCollectorPreferenceConstants.BR_SEND_SDK_INFO);
}

From source file:com.nokia.carbide.internal.bugdatacollector.ui.preferences.BugDataCollectorPreferencePage.java

License:Open Source License

/**
 * Returns true if Carbide_Debugger_Log.xml is to be send with the report, false if not.
 * @return true if Carbide_Debugger_Log.xml is to be send with the report, false if not.
 *//*from w  w w .  j  av a  2 s .co m*/
public static boolean sendDiagnostic() {
    IPreferenceStore store = BugDataCollectorPlugin.getPrefsStore();
    return store.getBoolean(BugDataCollectorPreferenceConstants.BR_SEND_DIAGNOSTIC_LOG);
}

From source file:com.nokia.cpp.internal.api.utils.ui.WorkbenchUtils.java

License:Open Source License

/**
 * Reads the General > Workspace > Save automatically before build option and, if true,
 * saves all open editor windows// ww  w .jav a  2 s.com
 *
 */
public static void saveOpenEditorsIfRequired() {
    IPreferenceStore store = IDEWorkbenchPlugin.getDefault().getPreferenceStore();
    if (store != null && store.getBoolean(IDEInternalPreferences.SAVE_ALL_BEFORE_BUILD)) {
        PlatformUI.getWorkbench().saveAllEditors(false);
    }
}

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

License:Open Source License

/**
 * Cancels AnalyzeTool build./*from  w w w  . j  a  v  a 2s .c  o m*/
 * 
 * @param monitor
 *            Currently running progress monitor
 * @param continueBuild
 *            False stops the whole build chain (including Carbide and other
 *            builders) otherwise other than AnalyzeTool builds are executed
 *            normally.
 */
public final void buildCancelled(final IProgressMonitor monitor, final boolean continueBuild) {

    IPreferenceStore store = Activator.getPreferences();

    store.setValue(Constants.PREFS_BUILD_CANCELLED, true);

    // if user wants to continue build
    if (!continueBuild) {
        // write info to the Carbide console view
        getCarbideCommandLauncher().writeToConsole(Constants.BUILD_CANCELLED);

        // update monitor state
        monitor.setCanceled(true);
        monitor.done();
    }

    boolean promptMPPChange = store.getBoolean(Constants.PREFS_PROMPT_MMP);
    boolean manageDeps = store.getBoolean(Constants.PREFS_MANAGE_DEPS);
    boolean useConcBuild = store.getBoolean(Constants.PREFS_CONC_BUILD);

    // build canceled set project preference back to normal
    IPreferenceStore cStore = CarbideBuilderPlugin.getDefault().getPreferenceStore();
    cStore.setValue(com.nokia.carbide.cdt.builder.BuilderPreferenceConstants.PREF_MMP_CHANGED_ACTION_PROMPT,
            promptMPPChange);
    cStore.setValue(com.nokia.carbide.cdt.builder.BuilderPreferenceConstants.PREF_MANAGE_DEPENDENCIES,
            manageDeps);
    cStore.setValue(com.nokia.carbide.cdt.builder.BuilderPreferenceConstants.PREF_USE_CONCURRENT_BUILDING,
            useConcBuild);

    // CarbideCPPBuilder to forgot build state
    super.forgetLastBuiltState();
}

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

License:Open Source License

/**
 * Executes atool.exe with options.//from ww  w.j a  va  2s .  c  om
 * 
 * @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.builder.AnalyzeToolBuilder.java

License:Open Source License

/**
 * Runs AnalyzeTool build./*from w w  w  . ja v  a2 s .co m*/
 * 
 * @param type
 *            Type of execution. Possible types ATOOL_INST or ATOOL_UNINST
 * @param monitor
 *            Progress monitor reference
 * @param cpi
 *            ICarbideProjectInfo reference
 * @param files
 *            List of user selected mmp files
 * @return True is no errors otherwise False
 */
protected final boolean runBuild(final String type, final IProgressMonitor monitor,
        final ICarbideProjectInfo cpi, final List<IFile> files) {

    // get preference store
    IPreferenceStore store = Activator.getPreferences();

    // get active logging mode
    String loggingMode = store.getString(Constants.LOGGING_MODE);

    verbose = store.getBoolean(Constants.ATOOL_VERBOSE);

    // possible error code from command line engine
    int errorCode = Constants.COMMAND_LINE_ERROR_CODE.OK.getCode();

    // if logging mode is set to "ask always"
    // ask for user used logging mode
    if (Constants.LOGGING_ASK_ALLWAYS.equals(loggingMode)) {

        String[] outputMode = Util.openOutputModeDialog();

        // user press "Cancel"
        if (outputMode == null) {
            buildCancelled(monitor, true);
            return false;
        }
        // if user selects S60 log file and mode
        // and data file must ask for user
        else if (Constants.LOGGING_S60.equals(outputMode[0])) {
            String logPath = outputMode[1];
            String logFileName = outputMode[2];

            errorCode = executeAtool(logPath, logFileName, type, outputMode[0], files, cpi, monitor);
        } else { // no need to ask data file for the user => just build
            // with
            // user selected logging mode
            errorCode = executeAtool(null, null, type, outputMode[0], files, cpi, monitor);
        }
    }
    // if used logging mode is s60
    // and data file name must ask for the user
    else if (Constants.LOGGING_S60.equals(loggingMode)) {
        String path = store.getString(Constants.DEVICE_LOG_FILE_PATH);
        String fileName = store.getString(Constants.DEVICE_LOG_FILE_NAME);

        errorCode = executeAtool(path, fileName, type, loggingMode, files, cpi, monitor);
    }
    // build with selected mode
    else {
        errorCode = executeAtool(null, null, type, loggingMode, files, cpi, monitor);
    }

    // no errors from command line engine
    if (errorCode == Constants.COMMAND_LINE_ERROR_CODE.OK.getCode()) {
        return true;
    }

    // if some error code is returned from command line engine display it to
    // user and cancel build
    Constants.COMMAND_LINE_ERROR_CODE error = Util.getErrorCode(errorCode);
    Util.displayCommandLineError(error);
    buildCancelled(monitor, false);
    return false;
}

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

License:Open Source License

/**
 * After the built is finished set preferences back to normal.
 * /*from ww  w.  j a  v  a  2  s  .  co  m*/
 * @param cpi
 *            ICarbideProjectInfo refernece
 */
public final void runPostSteps(ICarbideProjectInfo cpi) {

    IPreferenceStore store = Activator.getPreferences();
    boolean keepFilesSync = store.getBoolean(Constants.PREFS_KEEP_IN_SYNC);
    boolean promptMPPChange = store.getBoolean(Constants.PREFS_PROMPT_MMP);
    boolean manageDeps = store.getBoolean(Constants.PREFS_MANAGE_DEPS);
    boolean useConcBuild = store.getBoolean(Constants.PREFS_CONC_BUILD);

    // try to load ProjectUIPlugin class
    try {
        Class.forName("com.nokia.carbide.cpp.project.ui.utils.ProjectUIUtils");

        // no need to keep project files in sync
        // this should fix the mmp selection dialog prompt
        com.nokia.carbide.cpp.project.ui.utils.ProjectUIUtils.setKeepProjectsInSync(keepFilesSync);
    } catch (ClassNotFoundException cnte) {
        // Do nothing by design
    }

    // set builder preference to not prompt mmp file change dialog
    IPreferenceStore cStore = CarbideBuilderPlugin.getDefault().getPreferenceStore();

    // add existing/default values of Carbide builder settings
    cStore.setValue(com.nokia.carbide.cdt.builder.BuilderPreferenceConstants.PREF_MMP_CHANGED_ACTION_PROMPT,
            promptMPPChange);
    cStore.setValue(com.nokia.carbide.cdt.builder.BuilderPreferenceConstants.PREF_MANAGE_DEPENDENCIES,
            manageDeps);
    cStore.setValue(com.nokia.carbide.cdt.builder.BuilderPreferenceConstants.PREF_USE_CONCURRENT_BUILDING,
            useConcBuild);

    // try to remove -debug parameter from the build arguments list
    try {
        // get build configuration
        ICarbideBuildConfiguration config = cpi.getDefaultConfiguration();

        // get build arguments info
        BuildArgumentsInfo info = config.getBuildArgumentsInfoCopy();

        // get used platform
        String platform = config.getPlatformString();

        String debug = "-debug";
        String abldArgs = info.abldBuildArgs;

        // if platform is set to ARMV5 or GCCE
        if (platform.contains(Constants.BUILD_TARGET_ARMV5) || platform.contains(Constants.BUILD_TARGET_GCEE)) {

            // get "-debug" string index
            int index = abldArgs.indexOf(debug);

            // if abld build arguments contains only "-debug" parameter
            if (abldArgs.equals(debug)) {
                info.abldBuildArgs = "";
                config.setBuildArgumentsInfo(info);
            }
            // remove just "-debug" word
            else if (abldArgs.contains(debug) && index != -1) {
                info.abldBuildArgs = abldArgs.substring(0, index)
                        + abldArgs.substring(index + debug.length(), abldArgs.length());
                config.setBuildArgumentsInfo(info);
            }
        }

    } catch (java.lang.NoSuchMethodError nsme) {
        // Do nothing by design
        // user might run AT with too old Carbide version
    } catch (Exception e) {
        e.printStackTrace();
    }

    // after the build is finished => open the console view
    Util.openConsoleView();
}

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

License:Open Source License

/**
 * Checks is atool.exe available and modifies Carbide preferences.
 * /* ww  w . j av  a  2  s.com*/
 * @param launcher
 *            Command launcher
 * @param monitor
 *            Progress monitor
 * @param cpi
 *            Carbide project info
 * @return True if all checks are OK, otherwise False
 */
protected final boolean runPreSteps(final CarbideCommandLauncher launcher, final IProgressMonitor monitor,
        final ICarbideProjectInfo cpi) {

    // set command launchers
    cmdLauncher = launcher;

    // check is atool.exe available
    if (!Util.isAtoolAvailable()) {
        launcher.writeToConsole(Constants.INFO_ATOOL_NOT_AVAILABLE);
        buildCancelled(monitor, false);
        Util.showMessageDialog(Constants.CLE_VERSION_MISMATCH, Constants.ERROR_ATOOL_NOT_AVAILABLE,
                SWT.ICON_ERROR);

        return false;
    }

    // check supported AnalyzeTool version
    String atoolVersion = Util.getAtoolVersionNumber(Util.getAtoolInstallFolder());
    int compared = Util.compareVersionNumber(atoolVersion, Constants.MIN_CLE_SUPPORTED);
    if (compared == Constants.VERSION_NUMBERS_SECOND || compared == Constants.VERSION_NUMBERS_INVALID) {
        launcher.writeToConsole(
                MessageFormat.format(Constants.CLE_OLDER_THAN_MIN, Constants.MIN_CLE_SUPPORTED));
        buildCancelled(monitor, false);
        Util.showMessageDialog(Constants.CLE_VERSION_MISMATCH,
                MessageFormat.format(Constants.CLE_OLDER_THAN_MIN, Constants.MIN_CLE_SUPPORTED),
                SWT.ICON_ERROR);
        return false;
    }

    /**
     * 
     * Below is code a sample which are related to the AT-682, but it is
     * decided to let out from current release. String coreVersion =
     * Util.getAtoolCoreVersion(cpi.getProject()); compared =
     * Util.compareVersionNumber(coreVersion, atoolVersion); if( compared !=
     * Constants.VERSION_NUMBERS_EQUALS ) { boolean retValue =
     * Util.openConfirmationDialog(
     * "AnalyzeTool command line engine and AnalyzeTool core version mismatch.\n"
     * + "This usually leads to problems.\n\nDo you want to continue?"); if(
     * !retValue ) { buildCancelled(monitor, false); return false; } }
     */
    // remove existing error markers
    try {
        CarbideCPPBuilder.removeAllMarkers(cpi.getProject());
    } catch (CoreException ce) {
        ce.printStackTrace();
        return false;
    }

    // check used platform
    if (!checkPlatform(cpi)) {
        buildCancelled(monitor, Util.openConfirmationDialog(Constants.PLATFORM_NOT_SUPPORTED));
        return false;
    }

    // check AnalyzeTool libraries
    final String libsCheck = Util.checkAtoolLibs(cpi);
    if (!libsCheck.equals(Constants.ATOOL_LIBS_OK)) {
        Util.showMessageDialog(Constants.DIALOG_TITLE, libsCheck, SWT.ICON_ERROR);
        buildCancelled(monitor, false);
        return false;
    }

    // use CarbideCPPBuilder to bldmake bldfiles for selected project
    String[] bldmakeArgs = { "bldfiles" };
    CarbideCPPBuilder.invokeBldmakeCommand(cpi.getDefaultConfiguration(), launcher, bldmakeArgs, true);

    IPreferenceStore store = Activator.getPreferences();

    // try to load ProjectUIPlugin class
    try {
        Class.forName("com.nokia.carbide.cpp.project.ui.ProjectUIPlugin");

        // get keep project files in sync flag
        boolean keepFilesSync = com.nokia.carbide.cpp.project.ui.utils.ProjectUIUtils.keepProjectsInSync();

        store.setValue(Constants.PREFS_KEEP_IN_SYNC, keepFilesSync);

        // no need to keep project files in sync
        // this should fix the mmp selection dialog prompt
        com.nokia.carbide.cpp.project.ui.utils.ProjectUIUtils.setKeepProjectsInSync(false);
    } catch (ClassNotFoundException cnfe) {
        // Do nothing by design
    }

    // set builder preference to not prompt mmp file change dialog
    IPreferenceStore cStore = CarbideBuilderPlugin.getDefault().getPreferenceStore();

    // get existing values
    boolean promptMPPChange = cStore.getBoolean(
            com.nokia.carbide.cdt.builder.BuilderPreferenceConstants.PREF_MMP_CHANGED_ACTION_PROMPT);
    boolean manageDeps = cStore
            .getBoolean(com.nokia.carbide.cdt.builder.BuilderPreferenceConstants.PREF_MANAGE_DEPENDENCIES);
    boolean useConcBuild = cStore
            .getBoolean(com.nokia.carbide.cdt.builder.BuilderPreferenceConstants.PREF_USE_CONCURRENT_BUILDING);

    // store existing values
    store.setValue(Constants.PREFS_PROMPT_MMP, promptMPPChange);
    store.setValue(Constants.PREFS_MANAGE_DEPS, manageDeps);
    store.setValue(Constants.PREFS_CONC_BUILD, useConcBuild);
    // add custom values for AnalyzeTool build
    cStore.setValue(com.nokia.carbide.cdt.builder.BuilderPreferenceConstants.PREF_MMP_CHANGED_ACTION_PROMPT,
            false);
    cStore.setValue(com.nokia.carbide.cdt.builder.BuilderPreferenceConstants.PREF_MANAGE_DEPENDENCIES, false);
    cStore.setValue(com.nokia.carbide.cdt.builder.BuilderPreferenceConstants.PREF_USE_CONCURRENT_BUILDING,
            false);

    // try to add -debug parameter to the build arguments list
    try {
        // get selected build configuration
        ICarbideBuildConfiguration config = cpi.getDefaultConfiguration();

        // get build arguments info
        BuildArgumentsInfo info = config.getBuildArgumentsInfoCopy();

        // get selected platform
        String platform = cpi.getDefaultConfiguration().getPlatformString();

        // if platform is ARMV5 or GCCE and the "-debug" parameter is not
        // set => we need set the parameter
        if ((platform.contains(Constants.BUILD_TARGET_ARMV5) || platform.contains(Constants.BUILD_TARGET_GCEE))
                && !info.abldBuildArgs.contains("-debug")) {
            if (info.abldBuildArgs.length() > 0 && !info.abldBuildArgs.endsWith(" ")) {
                info.abldBuildArgs += " ";
            }
            info.abldBuildArgs += "-debug";
            config.setBuildArgumentsInfo(info);
        }
    }
    // catch NoSuchMethodError because is it possible to use older versions
    // where this method is not available
    catch (java.lang.NoSuchMethodError nsme) {
        // Do nothing by design
    }
    return true;
}

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

License:Open Source License

/**
 * Executes AnalyzeTool post actions when user builds projects.
 * //from  w  w w .  j av a 2  s .  c o  m
 * 
 * @see com.nokia.carbide.cdt.builder.builder.CarbideCPPBuilder#build(int,
 *      java.util.Map, org.eclipse.core.runtime.IProgressMonitor)
 */
@Override
@SuppressWarnings("unchecked")
protected IProject[] build(int kind, java.util.Map args, IProgressMonitor monitor) {

    // get project reference
    IProject project = super.getProject();

    // get project info
    ICarbideProjectInfo cpi = CarbideBuilderPlugin.getBuildManager().getProjectInfo(project);

    IPreferenceStore store = Activator.getPreferences();
    boolean buildCanceled = store.getBoolean(Constants.PREFS_BUILD_CANCELLED);
    // if the AnalyzeTool is canceled
    if (buildCanceled) {
        getCarbideCommandLauncher().writeToConsole(Constants.BUILD_CANCELLED);
        buildCanceled = false;
        // if atool.exe is not available write info to console view
        if (!Util.isAtoolAvailable()) {
            getCarbideCommandLauncher().writeToConsole(Constants.INFO_ATOOL_NOT_AVAILABLE);
        }
        super.forgetLastBuiltState();
        runPostSteps(cpi);
        return null;
    }

    // execute atool.exe
    if (CarbideCPPBuilder.projectHasBuildErrors(cpi.getProject())) {
        runUninstrument(Constants.ATOOL_UNINST_FAILED, cpi, monitor);
    } else {
        runUninstrument(Constants.ATOOL_UNINST, cpi, monitor);
    }
    monitor.worked(1);
    runPostSteps(cpi);

    return new IProject[0];
}