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

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

Introduction

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

Prototype

void setValue(String name, boolean value);

Source Link

Document

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

Usage

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  a v  a2  s . c o  m*/
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.analyzetool.preferences.AnalyzeToolPreferencePage.java

License:Open Source License

/**
 * Stores selected values When user press "Ok" or "apply" button this method
 * is called/*from  w ww  .  ja  v a  2s  .com*/
 */
@Override
public final boolean performOk() {

    IPreferenceStore store = Activator.getPreferences();

    // use default location is selected
    if (useDefaultLocation.getSelection()) {
        store.setValue(Constants.ATOOL_FOLDER, Util.getDefaultAtoolLocation());
        store.setValue(Constants.USE_INTERNAL, true);
    }
    // using user specified atool.exe location and the folder contains
    // atool.exe
    else {
        store.setValue(Constants.ATOOL_FOLDER, atoolDirText.getText());
        store.setValue(Constants.USER_SELECTED_FOLDER, atoolDirText.getText());
        store.setValue(Constants.USE_INTERNAL, false);
    }

    // store logging mode
    if (askButton.getSelection()) {
        store.setValue(Constants.LOGGING_MODE, Constants.LOGGING_ASK_ALLWAYS);
    } else if (s60Button.getSelection()) {
        store.setValue(Constants.LOGGING_MODE, Constants.LOGGING_S60);
    } else if (externalFastButton.getSelection()) {
        store.setValue(Constants.LOGGING_MODE, Constants.LOGGING_EXT_FAST);
    }
    store.setValue(Constants.DEVICE_LOG_FILE_PATH, logPathText.getText());
    store.setValue(Constants.DEVICE_LOG_FILE_NAME, fileNameText.getText());

    // store value of verbose atool.exe output
    store.setValue(Constants.ATOOL_VERBOSE, verboseButton.getSelection());

    // update preference value
    // this values is used later when UI creates/update toolbar options and
    // when building project with "ask always" option
    if (externalFastButton.isEnabled()) {
        store.setValue(Constants.LOGGING_FAST_ENABLED, true);
    } else {
        store.setValue(Constants.LOGGING_FAST_ENABLED, false);
    }

    // get callstack size
    int size = 0;
    boolean userDefinedCSSize = false;
    if (zeroButton.getSelection() && zeroButton.isEnabled()) {
        userDefinedCSSize = true;
    } else if (fortyButton.getSelection() && fortyButton.isEnabled()) {
        size = 40;
        userDefinedCSSize = true;
    } else if (hundredButton.getSelection() && hundredButton.isEnabled()) {
        size = 100;
        userDefinedCSSize = true;
    } else if (customButton.getSelection() && customButton.isEnabled()) {
        size = spinner.getSelection();
        userDefinedCSSize = true;
    }

    // store callstack size
    store.setValue(Constants.USE_CALLSTACK_SIZE, userDefinedCSSize);
    store.setValue(Constants.CALLSTACK_SIZE, size);

    // update view with new settings
    IActionListener listener = Activator.getActionListener();
    if (listener != null) {
        listener.preferenceChanged();
    }

    // store report detail level prefs
    return super.performOk();
}

From source file:com.nokia.s60tools.analyzetool.ui.MainView.java

License:Open Source License

/**
 * Change report detail level./*from  w ww. j  av  a 2s.  c o  m*/
 */
public final void changeDetailLevel() {

    // sync with UI thread
    PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {
        public void run() {
            // get preference store
            IPreferenceStore store = Activator.getPreferences();

            // get active report level
            String reportLevel = store.getString(Constants.REPORT_LEVEL);

            boolean updateMemLeakAlso = false;

            // set new report level
            if (Constants.REPORT_EVERY.equals(reportLevel)) {
                store.setValue(Constants.REPORT_LEVEL, Constants.REPORT_KNOWN);
                updateMemLeakAlso = true;
            } else if (Constants.REPORT_KNOWN.equals(reportLevel)) {
                store.setValue(Constants.REPORT_LEVEL, Constants.REPORT_TOPMOST);
            } else if (Constants.REPORT_TOPMOST.equals(reportLevel)) {
                store.setValue(Constants.REPORT_LEVEL, Constants.REPORT_EVERY);
                updateMemLeakAlso = true;
            }

            if (updateMemLeakAlso && runView != null) {
                activeTreeItem = null;

                // set view content
                runView.setInput(getResults(false));

                // refresh view
                runView.refresh();

                // if last selected item not found current item list
                if (activeTreeItem == null) {
                    runView.setAutoExpandLevel(2);
                } else {
                    // set selection to correct item
                    runView.setSelection(new StructuredSelection(activeTreeItem), true);
                }
            }

            if (callstackView != null) {
                // update view callstack view content
                callstackView.setInput(getCallStack(activeTreeItem));

                // expand all the trees on call stack view
                callstackView.expandAll();

            }
            // change tooltip
            changeReportActionTooltip();
        }
    });
}

From source file:com.nokia.s60tools.analyzetool.ui.MainView.java

License:Open Source License

/**
 * Change logging mode.//  w  w  w. j a  va2 s . co  m
 * 
 * @param loggingMode
 *            Used logging mode
 */
public final void changeLogTarget(final String loggingMode) {

    if (logTargetMenu == null) {
        return;
    }

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

    // if no logging mode given get it from the AnalyzeTool preferences
    if (loggingMode == null) {
        usedLoggingMode = store.getString(Constants.LOGGING_MODE);
    }
    // logging mode is given => so start to use it
    else {
        store.setValue(Constants.LOGGING_MODE, loggingMode);
        usedLoggingMode = loggingMode;
    }

    if (Constants.LOGGING_S60.equals(usedLoggingMode)) {

        logTargetMenu.setImageDescriptor(Activator.getImageDescriptor(Constants.BUTTON_CELLURAR));
        logTargetMenu.setToolTipText(Constants.ACTION_CHANGE_LOGGING_MODE_TOOLTIP_S60);
        if (loggingMode == null) {
            s60LogTargetAction.setChecked(true);
            externalFastLogTargetAction.setChecked(false);
            askLogTargetAction.setChecked(false);
        }
    } else if (Constants.LOGGING_EXT_FAST.equals(usedLoggingMode)) {
        logTargetMenu.setImageDescriptor(Activator.getImageDescriptor(Constants.BUTTON_COMPUTER_FAST));
        logTargetMenu.setToolTipText(Constants.ACTION_CHANGE_LOGGING_MODE_TOOLTIP_FAST);
        if (loggingMode == null) {
            s60LogTargetAction.setChecked(false);
            externalFastLogTargetAction.setChecked(true);
            askLogTargetAction.setChecked(false);
        }
    }
    // current logging mode is "ask_always"
    else {
        logTargetMenu.setImageDescriptor(Activator.getImageDescriptor(Constants.BUTTON_ASK));
        logTargetMenu.setToolTipText(Constants.ACTION_CHANGE_LOGGING_MODE_TOOLTIP_ASK);
        if (loggingMode == null) {
            s60LogTargetAction.setChecked(false);
            externalFastLogTargetAction.setChecked(false);
            askLogTargetAction.setChecked(true);
        }
    }

    // if the fast data gathering mode is enabled by the preference page =>
    // enable also toolbar option
    // else disable fast data gathering mode
    externalFastLogTargetAction.setEnabled(store.getBoolean(Constants.LOGGING_FAST_ENABLED));
}

From source file:com.nokia.s60tools.analyzetool.ui.MainView.java

License:Open Source License

/**
 * Creates memory results view//from w w w  .  ja v a 2  s  .c  om
 * 
 * @param parent
 *            View parent ( CTabFolder )
 */
public void createMainView(CTabFolder parent) {

    // Create SashForm this form includes all the current view components
    SashForm sashForm = new SashForm(parent, SWT.HORIZONTAL);

    mainTab = new CTabItem(parent, SWT.NONE);
    mainTab.setControl(sashForm);
    mainTab.setText(Constants.MAIN_TAB_TITLE);

    // create new treeviewer to shown memory analysis runs and leaks
    runView = new TreeViewer(sashForm, SWT.VIRTUAL);

    // create SashForm to display call stack addresses and more detailed
    // information
    // of selected run or leak
    SashForm callstackForm = new SashForm(sashForm, SWT.VERTICAL);

    // set content and label providers
    runView.setContentProvider(new ViewContentProvider());
    runView.setLabelProvider(new ViewLabelProvider());

    // get init content
    runView.setInput(getStartupContent());

    // add listener to provide selection change events
    runView.addTreeListener(this);

    runView.setAutoExpandLevel(2);

    // create new information label
    // this label contains more detailed information of selected item
    informationLabel = new Label(callstackForm, SWT.BORDER | SWT.CENTER);

    // create grid data => this provides layout changes
    GridData data = new GridData();

    // add grid data to label, this enables label ui modifications e.g. line
    // feed
    informationLabel.setLayoutData(data);

    // set init text
    informationLabel.setText(Constants.INFO_NO_DATA);

    // create new call stack view
    // this components contains information of one memory leak call stack
    // addresses
    callstackView = new TreeViewer(callstackForm, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);

    // modify UI components layouts
    // reserve more space for left side of UI
    sashForm.setWeights(new int[] { 5, 3 });
    callstackForm.setWeights(new int[] { 2, 8 });

    // add content and label providers
    callstackView.setContentProvider(new ViewContentProvider());
    callstackView.setLabelProvider(new ViewLabelProvider());

    // make actions and construct click listeners
    makeActions();
    hookContextMenu();
    hookDoubleClickAction();
    hookClicks();
    contributeToActionBars();

    // set view title
    viewTitle = String.format(Constants.ANALYZE_TOOL_TITLE_WITH_VERSION, Util.getAToolFeatureVersionNumber());
    this.setContentDescription(viewTitle);

    // add selection listener
    if (getSite() != null) {
        getSite().getPage().addSelectionListener(this);
        runView.getControl().addKeyListener(this);
    }

    // set actionlistener
    Activator.setActionListener(this);

    // set help shortcuts
    PlatformUI.getWorkbench().getHelpSystem().setHelp(callstackView.getControl(),
            AnalyzeToolHelpContextIDs.ANALYZE_MAIN);
    PlatformUI.getWorkbench().getHelpSystem().setHelp(runView.getControl(),
            AnalyzeToolHelpContextIDs.ANALYZE_MAIN);

    ResourcesPlugin.getWorkspace().addResourceChangeListener(new ATResourceListener());

    IPreferenceStore store = Activator.getPreferences();
    store.setValue(Constants.LOGGING_FAST_ENABLED, true);

    // get default value for logging mode
    preferenceChanged();
}

From source file:com.nokia.s60tools.compatibilityanalyser.model.HeaderAnalyserEngine.java

License:Open Source License

/**
 * This method validates the Current SDK and Baseline SDK data and
 * throws back error messages back to UI. 
 * Also, it prepares the config file used in invoking HA through Checkbc
 * @param currentData specifies the Current SDK data
 * @param baselineData specifies the Baseline SDK data
 * @returns any error in the Input/*from  ww w . j  a va2  s .  c o  m*/
 */
public String readAndCheckInput(ProductSdkData currentData, BaselineSdkData baselineData) {
    pythonPath = PythonUtilities.getPythonPath();

    if (pythonPath == null)
        return Messages.getString("HeaderAnalyserEngine.PythonNotFoundError"); //$NON-NLS-1$

    // Validating the python version
    boolean python_validity = PythonUtilities
            .validatePython(CompatibilityAnalyserEngine.SUPPORTED_PYTHON_VERSION);
    if (!python_validity)
        return Messages.getString("CompatibilityAnalyserEngine.InstallValidPython") //$NON-NLS-1$
                + CompatibilityAnalyserEngine.SUPPORTED_PYTHON_VERSION;

    if (baselineData == null) {
        return Messages.getString("HeaderAnalyserEngine.BaselineNotExistError");
    }

    String coreToolsExtraction = null;
    if (currentData.useWebServerCoreTools) {
        if (CompatibilityAnalyserEngine.isDownloadAndExtractionNeeded(currentData.urlPathofCoreTools)) {
            IPreferenceStore prefStore = CompatibilityAnalyserPlugin.getCompatabilityAnalyserPrefStore();
            //If core tools were already downloaded from web server earlier, they will be deleted. 
            String previousContents = prefStore
                    .getString(CompatibilityAnalyserPreferencesConstants.PREVIOUS_WEB_CORE_TOOLS_ROOTDIR);
            if (previousContents != null && !previousContents.equals("")) //$NON-NLS-1$
            {
                File oldContents = new File(previousContents);
                if (oldContents.exists())
                    FileMethods.deleteFolder(previousContents);
            }
            String targetPath = FileMethods.appendPathSeparator(CompatibilityAnalyserEngine.getWorkspacePath())
                    + Messages.getString("HeaderAnalyserEngine.WebServerContentsNew"); //$NON-NLS-1$
            coreToolsExtraction = CompatibilityAnalyserEngine
                    .readAndDownloadSupportedCoretools(currentData.urlPathofCoreTools, targetPath, monitor);
            if (coreToolsExtraction == null) {
                prefStore.setValue(CompatibilityAnalyserPreferencesConstants.PREVIOUS_WEB_CORE_TOOLS_URL,
                        currentData.urlPathofCoreTools);
                prefStore.setValue(CompatibilityAnalyserPreferencesConstants.PREVIOUS_WEB_CORE_TOOLS_PATH,
                        CompatibilityAnalyserEngine.getWebServerToolsPath());
                prefStore.setValue(CompatibilityAnalyserPreferencesConstants.PREVIOUS_WEB_CORE_TOOLS_ROOTDIR,
                        targetPath);
                currentData.coreToolsPath = CompatibilityAnalyserEngine.getWebServerToolsPath();
            }
        } else {
            IPreferenceStore prefStore = CompatibilityAnalyserPlugin.getCompatabilityAnalyserPrefStore();
            currentData.coreToolsPath = prefStore
                    .getString(CompatibilityAnalyserPreferencesConstants.PREVIOUS_WEB_CORE_TOOLS_PATH);
        }
    }

    if (currentData.useDefaultCoreTools) {
        String corePath = CompatibilityAnalyserPlugin.getInstallPathOfToolsPlugin();

        if (corePath == null || corePath.equalsIgnoreCase("")) //$NON-NLS-1$
        {
            return Messages.getString("HeaderAnalyserEngine.CouldnotfindToolsPluginError"); //$NON-NLS-1$
        } else {
            File toolsFolder = new File(FileMethods.appendPathSeparator(corePath)
                    + Messages.getString("HeaderAnalyserEngine.BCTools")); //$NON-NLS-1$
            if (!toolsFolder.exists())
                return new String(
                        Messages.getString("HeaderAnalyserEngine.ToolsPluginDoesNotContainCoreComponents")); //$NON-NLS-1$

            currentData.coreToolsPath = FileMethods.appendPathSeparator(corePath)
                    + Messages.getString("HeaderAnalyserEngine.BCTools") + File.separator;
        }
    }

    if (coreToolsExtraction == null) {
        try {
            //Validating the DATA VERSION
            String dv = CompatibilityAnalyserEngine.getDataVersion(currentData.coreToolsPath);
            int num = Integer.parseInt(dv);
            if (num != CompatibilityAnalyserPlugin.DATA_VERSION) {
                if (!currentData.coreToolsPath
                        .equalsIgnoreCase(CompatibilityAnalyserPlugin.getDefaltCoretoolsPath())) {
                    feedbackHandler.reStartAnalysisUsingSameData("Compatibility Analyser - Header Analysis",
                            Messages.getString("HeaderAnalyserEngine.CoreToolsAreNotCompatible")
                                    + CompatibilityAnalyserPlugin.DATA_VERSION
                                    + ".\n\nWould you like to run analysis with the default core tools?");
                    return "";
                }
                return "Please update the " + CompatibilityAnalyserPlugin.CORE_COMPONENTS_PLUGIN_ID
                        + " plugin. The one being used is incompatible with the tool.";
            }
        } catch (Exception e1) {
            return Messages.getString("HeaderAnalyserEngine.InvalidDataVersion"); //$NON-NLS-1$
        }

        try {
            config_folder = engine.getCurrentSdkData().getconfigfolder();
            configFile = new File(
                    config_folder + File.separator + Messages.getString("HeaderAnalyserEngine.carbide_ha.cf")); //$NON-NLS-1$
            temp_folder = config_folder + File.separator + "temp";
            if (!configFile.getParentFile().exists())
                return Messages.getString("HeaderAnalyserEngine.InvalidCoreToolsPathError"); //$NON-NLS-1$

            if (configFile.exists())
                configFile.delete();

            if (!configFile.createNewFile()) {
                return Messages.getString("HeaderAnalyserEngine.ErrorInConfigFileCreation");
            }

            FileOutputStream outStr = new FileOutputStream(configFile);
            outStr.write((Messages.getString("HeaderAnalyserEngine.BASELINE_NAME")
                    + baselineData.baselineSdkName + "\n").getBytes()); //$NON-NLS-1$
            outStr.write(
                    (Messages.getString("HeaderAnalyserEngine.BASELINE_SDK_DIR") + baselineData.epocRoot + "\n") //$NON-NLS-2$
                            .getBytes());
            outStr.write((Messages.getString("HeaderAnalyserEngine.BASELINE_SDK_S60_VERSION")
                    + baselineData.baselineSdkVersion + "\n").getBytes()); //$NON-NLS-1$

            outStr.write((Messages.getString("HeaderAnalyserEngine.CURRENT_NAME") + currentData.productSdkName
                    + "\n").getBytes()); //$NON-NLS-1$
            outStr.write(
                    (Messages.getString("HeaderAnalyserEngine.CURRENT_SDK_DIR") + currentData.epocRoot + "\n") //$NON-NLS-2$
                            .getBytes());
            outStr.write((Messages.getString("HeaderAnalyserEngine.CURRENT_SDK_S60_VERSION")
                    + currentData.productSdkVersion + "\n").getBytes()); //$NON-NLS-1$
            outStr.write((Messages.getString("HeaderAnalyserEngine.TEMP") + temp_folder + "\n").getBytes()); //$NON-NLS-2$ //$NON-NLS-3$
            outStr.write((Messages.getString("HeaderAnalyserEngine.BASELINE_HEADERS")
                    + FileMethods.convertToOneString(baselineData.baselineHeaderDir) + "\n").getBytes()); //$NON-NLS-1$
            outStr.write((Messages.getString("HeaderAnalyserEngine.CURRENT_HEADERS")
                    + FileMethods.convertToOneString(currentData.currentHeaderDir) + "\n").getBytes()); //$NON-NLS-1$
            outStr.write((Messages.getString("HeaderAnalyserEngine.BASELINE_SYSTEMINCLUDEDIR")
                    + baselineData.baselineIncludes + "\n").getBytes()); //$NON-NLS-1$
            outStr.write((Messages.getString("HeaderAnalyserEngine.CURRENT_SYSTEMINCLUDEDIR")
                    + currentData.readIncludePaths() + "\n").getBytes()); //$NON-NLS-1$

            outStr.write((Messages.getString("HeaderAnalyserEngine.USE_PLATFORM_DATA")
                    + currentData.usePlatformData + "\n").getBytes()); //$NON-NLS-1$
            outStr.write((Messages.getString("HeaderAnalyserEngine.RECURSIVE_HEADERS")
                    + currentData.useRecursive + "\n").getBytes()); //$NON-NLS-1$

            if (currentData.replaceSet != null && currentData.replaceSet.size() > 0) {
                StringBuffer sb = new StringBuffer("");

                for (String s : currentData.replaceSet) {
                    sb.append(s + ";");
                }
                outStr.write((Messages.getString("HeaderAnalyserEngine.REPLACE_HEADERS") + sb.toString() + "\n") //$NON-NLS-2$
                        .getBytes());
            }

            if (currentData.forcedHeaders != null && currentData.forcedHeaders.size() > 0) {
                currentForcedHeaders = new File(
                        config_folder + File.separator + "carbide_currentforced_headers.h");
                if (currentForcedHeaders.exists())
                    currentForcedHeaders.delete();

                if (!currentForcedHeaders.createNewFile()) {
                    return "Unable to prepare Forced Headers List. CoreTools path is write protected.";
                }
                FileOutputStream forcedOutStr = new FileOutputStream(currentForcedHeaders);

                for (String s : currentData.forcedHeaders) {
                    forcedOutStr.write(("#include <" + s + ">" + "\n").getBytes());
                }
                if (forcedOutStr != null)
                    forcedOutStr.close();
                outStr.write(
                        ("CURRENT_FORCED_HEADERS=" + currentForcedHeaders.getAbsolutePath() + "\n").getBytes());
            }
            if (baselineData.forcedHeaders != null && baselineData.forcedHeaders.length > 0) {
                baselineForcedHeaders = new File(
                        config_folder + File.separator + "carbide_baselineforced_headers.h");
                if (baselineForcedHeaders.exists())
                    baselineForcedHeaders.delete();

                if (!baselineForcedHeaders.createNewFile()) {
                    return "Unable to prepare Forced Headers List. CoreTools path is write protected.";
                }
                FileOutputStream forcedOutStr = new FileOutputStream(baselineForcedHeaders);

                for (String s : baselineData.forcedHeaders) {
                    forcedOutStr.write(("#include <" + s + ">" + "\n").getBytes());
                }
                if (forcedOutStr != null)
                    forcedOutStr.close();

                outStr.write(("BASELINE_FORCED_HEADERS=" + baselineForcedHeaders.getAbsolutePath() + "\n")
                        .getBytes());
            }
            reportName = FileMethods.appendPathSeparator(currentData.reportPath)
                    + Messages.getString("HeaderAnalyserEngine.Headers_") + currentData.reportName;
            outStr.write(
                    (Messages.getString("HeaderAnalyserEngine.REPORT_FILE_HEADERS") + currentData.reportPath
                            + File.separator + Messages.getString("HeaderAnalyserEngine.Headers_") //$NON-NLS-1$
                            + currentData.reportName + "\n").getBytes()); //$NON-NLS-1$

            if (outStr != null)
                outStr.close();

            if (currentData.filterNeeded)
                prepareKnownIssuesPath();

        } catch (Exception e) {
            e.printStackTrace();
            return e.getMessage();
        }
    } else
        return coreToolsExtraction;

    return null;
}

From source file:com.nokia.s60tools.compatibilityanalyser.model.LibraryAnalyserEngine.java

License:Open Source License

/**
 * This method validates the Current SDK and Baseline SDK data and
 * throws back error messages to UI./*from   w ww.  jav  a  2s  .co  m*/
 * Also, it prepares the config file used in invoking OC through Checkbc
 * @param currentData specifies the Current SDK data
 * @param baselineData specifies the Baseline SDK data
 * @returns any error in the Input
 */
public String readAndCheckInput(ProductSdkData currentData, BaselineSdkData baselineData) {

    pythonPath = PythonUtilities.getPythonPath();

    if (pythonPath == null)
        return Messages.getString("LibraryAnalyserEngine.PythonNotFoundError"); //$NON-NLS-1$

    boolean python_validity = PythonUtilities
            .validatePython(CompatibilityAnalyserEngine.SUPPORTED_PYTHON_VERSION);

    if (!python_validity)
        return Messages.getString("CompatibilityAnalyserEngine.CompatibilityAnalyserEngine.InstallValidPython")
                + CompatibilityAnalyserEngine.SUPPORTED_PYTHON_VERSION;

    if (baselineData == null)
        return Messages.getString("LibraryAnalyserEngine.BaselineProfileNotFoundError"); //$NON-NLS-1$

    String coreToolsExtraction = null;

    if (currentData.useWebServerCoreTools) {
        if (CompatibilityAnalyserEngine.isDownloadAndExtractionNeeded(currentData.urlPathofCoreTools)) {
            IPreferenceStore prefStore = CompatibilityAnalyserPlugin.getCompatabilityAnalyserPrefStore();

            //If coretools are downloaded earlier from webserver, they will be deleted
            String previousContents = prefStore
                    .getString(CompatibilityAnalyserPreferencesConstants.PREVIOUS_WEB_CORE_TOOLS_ROOTDIR);
            if (previousContents != null && !previousContents.equals("")) //$NON-NLS-1$
            {
                File oldContents = new File(previousContents);
                if (oldContents.exists())
                    FileMethods.deleteFolder(previousContents);
            }

            String targetPath = CompatibilityAnalyserEngine.getWorkspacePath() + File.separator
                    + Messages.getString("LibraryAnalyserEngine.WebServerContentsNew"); //$NON-NLS-1$
            coreToolsExtraction = CompatibilityAnalyserEngine
                    .readAndDownloadSupportedCoretools(currentData.urlPathofCoreTools, targetPath, monitor);

            if (coreToolsExtraction == null) {

                prefStore.setValue(CompatibilityAnalyserPreferencesConstants.PREVIOUS_WEB_CORE_TOOLS_URL,
                        currentData.urlPathofCoreTools);
                prefStore.setValue(CompatibilityAnalyserPreferencesConstants.PREVIOUS_WEB_CORE_TOOLS_PATH,
                        CompatibilityAnalyserEngine.getWebServerToolsPath());
                prefStore.setValue(CompatibilityAnalyserPreferencesConstants.PREVIOUS_WEB_CORE_TOOLS_ROOTDIR,
                        targetPath);
                currentData.coreToolsPath = CompatibilityAnalyserEngine.getWebServerToolsPath();
            }
        } else {
            IPreferenceStore prefStore = CompatibilityAnalyserPlugin.getCompatabilityAnalyserPrefStore();
            currentData.coreToolsPath = prefStore
                    .getString(CompatibilityAnalyserPreferencesConstants.PREVIOUS_WEB_CORE_TOOLS_PATH);
        }
    }
    if (currentData.useDefaultCoreTools) {
        String corePath = CompatibilityAnalyserPlugin.getInstallPathOfToolsPlugin();

        if (corePath.equalsIgnoreCase("")) //$NON-NLS-1$
        {
            return Messages.getString("LibraryAnalyserEngine.ToolsPluginNotFoundError"); //$NON-NLS-1$
        } else {
            File toolsFolder = new File(FileMethods.appendPathSeparator(corePath)
                    + Messages.getString("LibraryAnalyserEngine.Bctools")); //$NON-NLS-1$
            if (!toolsFolder.exists())
                return new String(
                        Messages.getString("LibraryAnalyserEngine.CoreComponentsNotFoundInPluginError")); //$NON-NLS-1$
            currentData.coreToolsPath = FileMethods.appendPathSeparator(corePath)
                    + Messages.getString("LibraryAnalyserEngine.Bctools") + File.separator; //$NON-NLS-1$
        }
    }

    if (coreToolsExtraction == null) {
        try {
            //Validating the DATA VERSION
            String dv = CompatibilityAnalyserEngine.getDataVersion(currentData.coreToolsPath);
            int num = Integer.parseInt(dv);
            if (num != CompatibilityAnalyserPlugin.DATA_VERSION) {
                if (!currentData.coreToolsPath
                        .equalsIgnoreCase(CompatibilityAnalyserPlugin.getDefaltCoretoolsPath())) {
                    feedbackHandler.reStartAnalysisUsingSameData("Compatibility Analyser - Library Analysis",
                            Messages.getString("HeaderAnalyserEngine.CoreToolsAreNotCompatible")
                                    + CompatibilityAnalyserPlugin.DATA_VERSION
                                    + ".\n\nWould you like to run analysis with the default core tools?");
                    return "";
                }
                return "Please update the " + CompatibilityAnalyserPlugin.CORE_COMPONENTS_PLUGIN_ID
                        + " plugin. The one being used is incompatible with the tool.";
            }
        } catch (Exception e1) {
            return Messages.getString("LibraryAnalyserEngine.InvalidDataVersion"); //$NON-NLS-1$
        }

        try {
            config_folder = engine.getCurrentSdkData().getconfigfolder();
            configFile = new File(
                    config_folder + File.separator + Messages.getString("LibraryAnalyserEngine.carbide_oc.cf"));
            temp_folder = config_folder + File.separator + "temp";
            if (configFile.exists())
                configFile.delete();

            if (!configFile.createNewFile()) {
                return Messages.getString("LibraryAnalyserEngine.CouldNotFindConfigFile"); //$NON-NLS-1$
            }
            FileOutputStream outStr = new FileOutputStream(configFile);

            outStr.write((Messages.getString("LibraryAnalyserEngine.CURRENT_NAME") + currentData.productSdkName
                    + "\n").getBytes());
            outStr.write(
                    (Messages.getString("LibraryAnalyserEngine.CURRENT_SDK_DIR") + currentData.epocRoot + "\n")
                            .getBytes());
            outStr.write((Messages.getString("LibraryAnalyserEngine.CURRENT_SDK_S60_VERSION")
                    + currentData.productSdkVersion + "\n").getBytes());

            outStr.write((Messages.getString("LibraryAnalyserEngine.BASELINE_NAME")
                    + baselineData.baselineSdkName + "\n").getBytes());
            outStr.write((Messages.getString("LibraryAnalyserEngine.BASELINE_SDK_DIR") + baselineData.epocRoot
                    + "\n").getBytes());
            outStr.write((Messages.getString("LibraryAnalyserEngine.BASELINE_SDK_S60_VERSION")
                    + baselineData.baselineSdkVersion + "\n").getBytes());

            outStr.write((Messages.getString("LibraryAnalyserEngine.TOOLCHAIN") + currentData.toolChain + "\n")
                    .getBytes());

            outStr.write((Messages.getString("LibraryAnalyserEngine.CURRENT_IMPORTLIBRARIES")
                    + FileMethods.convertToOneString(currentData.currentLibsDir) + "\n").getBytes());
            outStr.write((Messages.getString("LibraryAnalyserEngine.CURRENT_IMPORTDLLS")
                    + FileMethods.convertToOneString(currentData.currentDllDir) + "\n").getBytes());
            outStr.write((Messages.getString("LibraryAnalyserEngine.BASELINE_IMPORTLIBRARIES")
                    + FileMethods.convertToOneString(baselineData.baselineLibsDir) + "\n").getBytes());
            outStr.write((Messages.getString("LibraryAnalyserEngine.BASELINE_IMPORTDLLS")
                    + FileMethods.convertToOneString(baselineData.baselineDllDir) + "\n").getBytes());
            outStr.write((Messages.getString("LibraryAnalyserEngine.TOOLCHAIN_PATH") + currentData.toolChainPath
                    + "\n").getBytes());
            reportName = currentData.reportPath + File.separator
                    + Messages.getString("LibraryAnalyserEngine.Libraries_") + currentData.reportName;
            outStr.write(
                    (Messages.getString("LibraryAnalyserEngine.REPORT_FILE_LIBRARIES") + currentData.reportPath
                            + File.separator + Messages.getString("LibraryAnalyserEngine.Libraries_")
                            + currentData.reportName + "\n").getBytes()); //$NON-NLS-1$
            outStr.write((Messages.getString("LibraryAnalyserEngine.TEMP") + temp_folder + "\n").getBytes()); //$NON-NLS-3$

            if (outStr != null)
                outStr.close();

            if (currentData.filterNeeded)
                getKnonwIssuesData();

        } catch (FileNotFoundException e) {
            e.printStackTrace();
            return e.getMessage();
        } catch (IOException e1) {
            e1.printStackTrace();
            return e1.getMessage();
        } catch (Exception e2) {
            e2.printStackTrace();
            return e2.getMessage();
        }
    } else
        return coreToolsExtraction;

    return null;
}

From source file:com.nokia.s60tools.compatibilityanalyser.model.ReportFilterEngine.java

License:Open Source License

@Override
protected IStatus run(IProgressMonitor monitor) {
    this.monitor = monitor;

    monitor.setTaskName(Messages.getString("ReportFilterEngine.FilteringReports")); //$NON-NLS-1$
    if (data.useDefaultCoreTools) {
        data.bcFilterPath = CompatibilityAnalyserPlugin.getDefaltCoretoolsPath();
        if (data.bcFilterPath == null) //$NON-NLS-1$
        {/* w  w w . j a  v a2  s.  c  om*/
            feedbackHandler.HandleFeedback("Compatibility Analyser - Report Filteration", //$NON-NLS-1$
                    Messages.getString("ReportFilterEngine.ToolsPluginDoesNotContainCoreComponents"));
            return Status.OK_STATUS;
        }
        monitor.worked(1);
    } else if (data.useWebServerCoreTools) {
        String coreToolsExtraction = null;

        IPreferenceStore store = CompatibilityAnalyserPlugin.getCompatabilityAnalyserPrefStore();
        String currentUrl = store.getString(CompatibilityAnalyserPreferencesConstants.CORETOOLS_URL);
        if (CompatibilityAnalyserEngine.isDownloadAndExtractionNeeded(currentUrl)) {
            monitor.setTaskName(Messages.getString("ReportFilterEngine.ExtractingCoretoolsFromWebServer")); //$NON-NLS-1$
            //IPreferenceStore prefStore = CompatibilityAnalyserPlugin.getCompatabilityAnalyserPrefStore();

            String previousContents = store
                    .getString(CompatibilityAnalyserPreferencesConstants.PREVIOUS_WEB_CORE_TOOLS_ROOTDIR);
            if (previousContents != null && !previousContents.equals("")) //$NON-NLS-1$
            {
                File oldContents = new File(previousContents);
                if (oldContents.exists())
                    FileMethods.deleteFolder(previousContents);
            }

            String targetPath = CompatibilityAnalyserEngine.getWorkspacePath() + File.separator
                    + Messages.getString("ReportFilterEngine.WebServerContentsNew"); //$NON-NLS-1$
            coreToolsExtraction = CompatibilityAnalyserEngine.readAndDownloadSupportedCoretools(currentUrl,
                    targetPath, monitor);

            if (coreToolsExtraction == null) {

                store.setValue(CompatibilityAnalyserPreferencesConstants.PREVIOUS_WEB_CORE_TOOLS_URL,
                        currentUrl);
                store.setValue(CompatibilityAnalyserPreferencesConstants.PREVIOUS_WEB_CORE_TOOLS_PATH,
                        CompatibilityAnalyserEngine.getWebServerToolsPath());
                store.setValue(CompatibilityAnalyserPreferencesConstants.PREVIOUS_WEB_CORE_TOOLS_ROOTDIR,
                        targetPath);
                data.bcFilterPath = CompatibilityAnalyserEngine.getWebServerToolsPath() + File.separator;
            } else {
                feedbackHandler.HandleFeedback("Compatibility Analyser - Report Filteration",
                        coreToolsExtraction);
                return Status.OK_STATUS;
            }
            monitor.worked(10);
        } else {
            IPreferenceStore prefStore = CompatibilityAnalyserPlugin.getCompatabilityAnalyserPrefStore();
            data.bcFilterPath = prefStore.getString(
                    CompatibilityAnalyserPreferencesConstants.PREVIOUS_WEB_CORE_TOOLS_PATH) + File.separator;
        }
    }
    if (!data.bcFilterPath.endsWith("\\"))
        data.bcFilterPath = data.bcFilterPath + "\\";

    String pythonPath = null;

    pythonPath = PythonUtilities.getPythonPath();

    if (pythonPath == null) {
        feedbackHandler.HandleFeedback("Compatibility Analyser - Report Filteration", //$NON-NLS-1$
                Messages.getString("ReportFilterEngine.PythonNotFoundError"));
        return Status.OK_STATUS;
    }

    //Validating the python
    boolean python_validity = PythonUtilities
            .validatePython(CompatibilityAnalyserEngine.SUPPORTED_PYTHON_VERSION);

    if (!python_validity) {
        feedbackHandler.HandleFeedback("Compatibility Analyser - Report Filteration",
                Messages.getString("CompatibilityAnalyserEngine.InvalidPythonVersion")
                        + CompatibilityAnalyserEngine.SUPPORTED_PYTHON_VERSION);
        return Status.OK_STATUS;
    }

    try {
        //Validating the DATA VERSION of core tools
        String dv = CompatibilityAnalyserEngine.getDataVersion(data.bcFilterPath);
        int num = Integer.parseInt(dv);
        if (num != CompatibilityAnalyserPlugin.DATA_VERSION) {
            if (!data.bcFilterPath.equalsIgnoreCase(CompatibilityAnalyserPlugin.getDefaltCoretoolsPath()))
                feedbackHandler.reStartFilterationUsingSameData("Compatibility Analyser - Report Filteration",
                        Messages.getString("HeaderAnalyserEngine.CoreToolsAreNotCompatible")
                                + CompatibilityAnalyserPlugin.DATA_VERSION
                                + ".\n\nWould you like to run analysis with the default core tools?");
            else
                feedbackHandler.HandleFeedback("Compatibility Analyser - Report Filteration",
                        "Please update the " + CompatibilityAnalyserPlugin.CORE_COMPONENTS_PLUGIN_ID
                                + " plugin. The one being used is incompatible with the tool.");

            return Status.OK_STATUS;
        }
    } catch (Exception e1) {
        e1.printStackTrace();
        feedbackHandler.HandleFeedback("Compatibility Analyser - Report Filteration", //$NON-NLS-1$
                "Invalid data version of coretools. Please check the coretools.");
        return Status.OK_STATUS;
    }

    data.knownissuesPath = getKnownissuesPath();
    FileMethods.copyBBCResultsFileIfNotExists(data.outputDir, data.bcFilterPath);
    if (data.bcFilterPath != null && data.knownissuesPath != null) {
        config_folder = data.getconfigfolder();
        configFile = new File(
                config_folder + File.separator + Messages.getString("ReportFilterEngine.bcfilter_config.cf")); //$NON-NLS-1$
        if (configFile.exists())
            configFile.delete();
        try {
            FileOutputStream outStream = new FileOutputStream(configFile, true);

            outStream.write((Messages.getString("ReportFilterEngine.TEMP") + data.bcFilterPath //$NON-NLS-1$
                    + Messages.getString("ReportFilterEngine.temp")).getBytes()); //$NON-NLS-1$

            Iterator<String> itr = data.reportFiles.iterator();

            StringBuffer inputfiles = new StringBuffer(); //$NON-NLS-1$
            StringBuffer outputfiles = new StringBuffer(); //$NON-NLS-1$
            while (itr.hasNext()) {
                File file = new File(itr.next());
                outputfiles = outputfiles.append(data.outputDir + File.separator + file.getName());
                outputfiles = outputfiles.append(";"); //$NON-NLS-1$
                inputfiles = inputfiles.append(file.getAbsolutePath());
                inputfiles = inputfiles.append(";"); //$NON-NLS-1$
            }
            inputfiles.deleteCharAt(inputfiles.lastIndexOf(";"));
            outputfiles.deleteCharAt(outputfiles.lastIndexOf(";"));

            outStream.write((Messages.getString("ReportFilterEngine.REPORT_FILE_FILTER") + inputfiles + "\n") //$NON-NLS-1$//$NON-NLS-2$
                    .getBytes());
            outStream.write((Messages.getString("ReportFilterEngine.OUTPUT_FILE_FILTER") + outputfiles + "\n") //$NON-NLS-1$//$NON-NLS-2$
                    .getBytes());
            outStream.write((Messages.getString("ReportFilterEngine.ISSUES_FILE") + data.knownissuesPath + "\n") //$NON-NLS-1$//$NON-NLS-2$
                    .getBytes());

            String[] args = { pythonPath,
                    "\"" + data.bcFilterPath + Messages.getString("ReportFilterEngine.Checkbc.py") + "\"", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
                    "\"" + configFile.getAbsolutePath() + "\"", "-c", "-f" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$

            ICmdLineCommandExecutor cmdLineExecutor = CmdLineCommandExecutorFactory
                    .CreateOsDependentCommandLineExecutor(this, CompatibilityAnalysisConsole.getInstance());
            stdOutReader = new ReportFilterLineReader();
            progressReader = (ReportFilterLineReader) stdOutReader;
            cmdLineExecutor.runCommand(args, stdOutReader, null, this);

        } catch (FileNotFoundException e) {
            feedbackHandler.HandleFeedback("Compatibility Analyser - Report Filteration", e.getMessage());
        } catch (IOException e) {
            feedbackHandler.HandleFeedback("Compatibility Analyser - Report Filteration", e.getMessage());
        } catch (UnsupportedOSException e) {
            feedbackHandler.HandleFeedback("Compatibility Analyser - Report Filteration", e.getMessage());
        }

        return Job.ASYNC_FINISH;
    } else {
        return Status.OK_STATUS;
    }
}

From source file:com.nokia.s60tools.compatibilityanalyser.ui.dialogs.KnownissuesDilaog.java

License:Open Source License

public void widgetSelected(SelectionEvent e) {

    if (e.widget == cancel) {
        if (shell != null)
            shell.getShell().dispose();//from w  w w  . j  a v a2s .  c om
    } else if (e.widget == browse) {
        FileDialog fileSelector = new FileDialog(shell.getShell(), SWT.MULTI);
        fileSelector.setText(Messages.getString("KnownissuesDilaog.AddFiles")); //$NON-NLS-1$
        String[] filterExt = { "*.xml", "*.*" }; //$NON-NLS-1$ //$NON-NLS-2$
        fileSelector.setFilterExtensions(filterExt);

        if ((fileSelector.open()) != null) {
            String[] files = fileSelector.getFileNames();
            String filterPath = fileSelector.getFilterPath();

            ArrayList<String> invalidfiles = new ArrayList<String>();
            for (String s : files) {
                if (!filterPath.endsWith(File.separator))
                    filterPath += File.separator;

                try {
                    DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new File(filterPath + s));
                } catch (Exception e1) {
                    invalidfiles.add(filterPath + s);
                    continue;
                }
                cmb.add(filterPath + s);
                cmb.select(0);
            }
            if (invalidfiles.size() > 0) {
                String set = "";
                for (String f : invalidfiles)
                    set = set + f + "\n";
                MessageDialog.openError(Display.getDefault().getActiveShell(), "Knownissues...",
                        "Selected file(s) are invalid xml files,\n" + set);
            }
            ok.setEnabled(cmb.getItemCount() > 0);
            remove.setEnabled(cmb.getItemCount() > 0);
        } else
            return;
    } else if (e.widget == ok) {
        IPreferenceStore store = CompatibilityAnalyserPlugin.getCompatabilityAnalyserPrefStore();
        store.setValue(CompatibilityAnalyserPreferencesConstants.DEFAULT_ISSUES, radio1.getSelection());
        store.setValue(CompatibilityAnalyserPreferencesConstants.LATEST_ISSUES, radio2.getSelection());
        store.setValue(CompatibilityAnalyserPreferencesConstants.WEB_ISSUES, radio3.getSelection());
        store.setValue(CompatibilityAnalyserPreferencesConstants.LOCAL_ISSUES, radio4.getSelection());

        if (radio3.getSelection() == true) {
            if (!issuesUrl.endsWith("/")) //$NON-NLS-1$
                issuesUrl = issuesUrl + "/"; //$NON-NLS-1$
            String[] fullURLs = list.getSelection();
            for (int i = 0; i < fullURLs.length; i++) {
                fullURLs[i] = issuesUrl + fullURLs[i];
            }
            issuesStore.saveValues(LastUsedKnownissues.ValueTypes.ISSUES_URL, fullURLs);
            String[] temp = { issuesUrl, "" }; //$NON-NLS-1$
            issuesStore.saveValues(LastUsedKnownissues.ValueTypes.WEBSERVER_MAIN_URL, temp);
        } else if (radio4.getSelection() == true) {
            issuesStore.saveValues(LastUsedKnownissues.ValueTypes.LOCAL_ISSUES_PATH, cmb.getItems());
        }

        if (shell != null)
            shell.getShell().dispose();

    } else if (e.widget == radio1) {
        list.setEnabled(false);
        cmb.setEnabled(false);
        browse.setEnabled(false);
        remove.setEnabled(false);
        ok.setEnabled(true);
    } else if (e.widget == radio2) {
        list.setEnabled(false);
        cmb.setEnabled(false);
        browse.setEnabled(false);
        remove.setEnabled(false);
        ok.setEnabled(true);
    } else if (e.widget == radio3 && radio3.getSelection()) {
        ArrayList<String> issuesList = new ArrayList<String>();
        String status = CompatibilityAnalyserEngine.readMetadataFileFromWebServer(issuesUrl.trim(),
                Messages.getString("CompatibilityAnalyserEngine.knownissues_metadata"), issuesList);
        list.setEnabled(true);

        if (status == null) {
            radio3.setText(Messages.getString("KnownissuesDilaog.UseSelectedFilesFromWeb")); //$NON-NLS-1$
            String[] items = issuesList.toArray(new String[0]);
            if (items != null) {
                list.setItems(items);
                list.setSelection(0);
            }
            ok.setEnabled(true);
        } else {
            MessageDialog.openError(Display.getDefault().getActiveShell(), "Knownissues...", status);
            radio3.setText(Messages.getString("KnownissuesDilaog.UseIssuesFromWebCouldNotFound")); //$NON-NLS-1$
            ok.setEnabled(false);
            list.setEnabled(false);
        }

        cmb.setEnabled(false);
        browse.setEnabled(false);
        remove.setEnabled(false);
    } else if (e.widget == radio4) {
        list.setEnabled(false);
        cmb.setEnabled(true);
        browse.setEnabled(true);
        remove.setEnabled(cmb.getItemCount() > 0);
        ok.setEnabled(cmb.getItemCount() > 0);
    } else if (e.widget == remove) {
        cmb.remove(cmb.getSelectionIndices());
        remove.setEnabled(cmb.getItemCount() > 0);
        if (cmb.getItemCount() != 0)
            cmb.select(0);
        else
            ok.setEnabled(false);

    }
}

From source file:com.nokia.s60tools.compatibilityanalyser.ui.wizards.AnalysisWizard.java

License:Open Source License

public boolean performFinish() {
    engine = new CompatibilityAnalyserEngine();
    currentSdk = new ProductSdkData();

    currentSdk.productSdkName = sdkPage.sdkNameCombo.getText();
    currentSdk.productSdkVersion = sdkPage.versionCombo.getText();
    currentSdk.epocRoot = sdkPage.epocDirectory.getText();

    if (!currentSdk.epocRoot.endsWith("\\"))
        currentSdk.epocRoot = currentSdk.epocRoot + "\\";

    SavingUserData userData = new SavingUserData();

    IPreferenceStore prefStore = CompatibilityAnalyserPlugin.getCompatabilityAnalyserPrefStore();

    if (prefStore.getBoolean(CompatibilityAnalyserPreferencesConstants.DEFAULT_TOOLS)) {
        currentSdk.useDefaultCoreTools = true;
        currentSdk.useLocalCoreTools = false;
        currentSdk.useSdkCoreTools = false;
        currentSdk.useWebServerCoreTools = false;
    } else if (prefStore.getBoolean(CompatibilityAnalyserPreferencesConstants.LOCAL_TOOLS)) {
        currentSdk.useDefaultCoreTools = false;
        currentSdk.useLocalCoreTools = true;
        currentSdk.useSdkCoreTools = false;
        currentSdk.useWebServerCoreTools = false;
        currentSdk.coreToolsPath = prefStore
                .getString(CompatibilityAnalyserPreferencesConstants.LOCAL_TOOLS_PATH);
    } else if (prefStore.getBoolean(CompatibilityAnalyserPreferencesConstants.SDK_TOOLS)) {
        currentSdk.useDefaultCoreTools = false;
        currentSdk.useLocalCoreTools = false;
        currentSdk.useSdkCoreTools = true;
        currentSdk.useWebServerCoreTools = false;
        currentSdk.coreToolsPath = prefStore
                .getString(CompatibilityAnalyserPreferencesConstants.SDK_TOOLS_PATH);
    } else if (prefStore.getBoolean(CompatibilityAnalyserPreferencesConstants.WEB_TOOLS)) {
        currentSdk.useDefaultCoreTools = false;
        currentSdk.useLocalCoreTools = false;
        currentSdk.useSdkCoreTools = false;
        currentSdk.useWebServerCoreTools = true;
        currentSdk.urlPathofCoreTools = prefStore
                .getString(CompatibilityAnalyserPreferencesConstants.CORETOOLS_URL);
    }//from   w  w  w. j  a v  a2 s  .  c  o  m

    ISymbianSDK selectedSdk = sdkPage.selectedSDK;

    if (selectedSdk.getSDKVersion().toString().equalsIgnoreCase(Messages.getString("AnalysisWizard.13"))) { //$NON-NLS-1$
        userData.saveSDKNameAndVersion(selectedSdk.getUniqueId(), sdkPage.versionCombo.getText());
    }
    if (sdkPage.headersButton.getSelection()) {
        engine.setHeaderAnalysis(true);

        if (headersPage.defaultRootDir.getSelection()) {
            String s = FileMethods.appendPathSeparator(sdkPage.epocDirectory.getText());
            String[] defIncPath = { s + Messages.getString("AnalysisWizard.epoc32Include") };
            currentSdk.currentHeaderDir = defIncPath;
        } else {

            currentSdk.currentHeaderDir = headersPage.getSelectedHdrPaths();
            currentSdk.defaultHeaderDir = false;
            LastUsedKnownissues saveData = new LastUsedKnownissues();
            saveData.saveValues(LastUsedKnownissues.ValueTypes.CURRENT_HEADERS, currentSdk.currentHeaderDir);
        }
        if (!headersPage.allFiles.getSelection()) {
            currentSdk.analyseAll = false;
            int size = headersPage.filesList.getItemCount();
            ArrayList<String> validFiles = new ArrayList<String>();
            ArrayList<String> currentFiles = new ArrayList<String>();

            for (int i = 0; i < size; i++) {
                TableItem item = headersPage.filesList.getItem(i);
                if (!item.getForeground().equals(headersPage.invalidColor)) {
                    currentFiles.add(item.getText(0));
                    if (item.getText(1).equalsIgnoreCase("")) //$NON-NLS-1$
                        validFiles.add(item.getText(0));
                    else
                        validFiles.add(item.getText(1));
                }
            }
            currentSdk.currentFiles = currentFiles.toArray(new String[0]);
            currentSdk.HeaderFilesList = validFiles.toArray(new String[0]);
        }
        if (!headersPage.allTypes.getSelection()) {
            currentSdk.allTypes = false;
            if (headersPage.hType.getSelection())
                currentSdk.hTypes = true;
            if (headersPage.hrhType.getSelection())
                currentSdk.hrhTypes = true;
            if (headersPage.rsgType.getSelection())
                currentSdk.rsgTypes = true;
            if (headersPage.mbgType.getSelection())
                currentSdk.mbgTypes = true;
            if (headersPage.hppType.getSelection())
                currentSdk.hppTypes = true;
            if (headersPage.panType.getSelection())
                currentSdk.panTypes = true;
        }
        if (headersPage.allFiles.getSelection() && !headersPage.useRecursive.getSelection()) {
            currentSdk.useRecursive = false;
        }
        prefStore.setValue(CompatibilityAnalyserPreferencesConstants.USERECURSION_LAST_SELECTION,
                headersPage.useRecursive.getSelection());

        if (headersPage.currentSdkData.usePlatformData) {
            currentSdk.usePlatformData = true;
        }

        if (!isOpenedFromProject)
            prefStore.setValue(CompatibilityAnalyserPreferencesConstants.USEPLATFORMDATA_LAST_SELECTION,
                    headersPage.currentSdkData.usePlatformData);

        if (headersPage.currentSdkData.currentIncludes != null
                && headersPage.currentSdkData.currentIncludes.length > 0) {
            currentSdk.currentIncludes = headersPage.currentSdkData.currentIncludes;
        }

        currentSdk.forcedHeaders = headersPage.currentSdkData.forcedHeaders;

        currentSdk.replaceSet = headersPage.replaceSet;
    }
    if (sdkPage.libsButton.getSelection()) {
        engine.setLibraryAnalysis(true);

        if (libsPage.buildtarget_radioBtn.getSelection()) {
            currentSdk.platfromSelection = true;
            currentSdk.default_platfrom_selection = false;
            currentSdk.selected_library_dirs = false;
            currentSdk.libsTargetPlat = libsPage.selectedPlatform;
            currentSdk.currentLibsDir = new String[currentSdk.libsTargetPlat.length];
            currentSdk.currentDllDir = new String[currentSdk.libsTargetPlat.length];

            for (int i = 0; i < currentSdk.libsTargetPlat.length; i++) {
                currentSdk.currentLibsDir[i] = CompatibilityAnalyserEngine
                        .getLibsPathFromPlatform(sdkPage.selectedSDK, libsPage.selectedPlatform[i]);
                currentSdk.currentDllDir[i] = CompatibilityAnalyserEngine
                        .getDllPathFromPlatform(sdkPage.selectedSDK, libsPage.selectedPlatform[i]);
            }
        } else if (libsPage.userDirs_radioBtn.getSelection()) {
            currentSdk.platfromSelection = false;
            currentSdk.selected_library_dirs = true;
            currentSdk.default_platfrom_selection = false;

            currentSdk.currentLibsDir = libsPage.getSelectedDSOPaths();
            currentSdk.currentDllDir = libsPage.getSelectedDLLPaths();
            LastUsedKnownissues saveData = new LastUsedKnownissues();
            saveData.saveValues(LastUsedKnownissues.ValueTypes.LIBRARY_DIRECTORIES, currentSdk.currentLibsDir);
            saveData.saveValues(LastUsedKnownissues.ValueTypes.DLL_DIRECTORIES, currentSdk.currentDllDir);
        }

        if (!libsPage.analyseAllFiles_radioBtn.getSelection()) {
            currentSdk.analyzeAllLibs = false;
            int size = libsPage.dsoFiles_list.getItemCount();

            currentSdk.libraryFilesList = new String[size];
            for (int i = 0; i < size; i++)
                currentSdk.libraryFilesList[i] = libsPage.dsoFiles_list.getItem(i).getText();
        }
        currentSdk.toolChain = libsPage.selectedToolChain.getName();
        currentSdk.toolChainPath = libsPage.selectedToolChain.getToolChainPath();

    }
    currentSdk.reportName = reportPage.fileName.getText();
    currentSdk.reportPath = reportPage.pathCombo.getText();
    userData.saveValue(SavingUserData.ValueTypes.REPORT_PATH, currentSdk.reportPath);

    currentSdk.filterNeeded = reportPage.yes.getSelection();
    prefStore.setValue(CompatibilityAnalyserPreferencesConstants.FILTER_REPORTS_LAST_SELECTION,
            reportPage.yes.getSelection());
    engine.setCurrentSdkData(currentSdk);
    engine.setBaselineProfile(sdkPage.profileCombo.getText());
    userData.saveValue(SavingUserData.ValueTypes.PROFILENAME, sdkPage.profileCombo.getText());
    prefStore.setValue(CompatibilityAnalyserPreferencesConstants.LAST_USED_BASELINE_PROFILE,
            sdkPage.profileCombo.getText());

    if (isOpenedFromConfigFile) {
        try {
            ParserEngine.saveSettingsToFile(engine, configFilePath);
        } catch (ParserConfigurationException e) {
            MessageDialog.openError(Display.getCurrent().getActiveShell(), "Compatibility Analyser",
                    "Error in saving the configuration " + e.getMessage());
        }
        return true;
    }
    if (!isOpenedFromConfigFile && savePage.isSavingNeeded()) {
        currentSdk.container = savePage.getContainerName();
        currentSdk.configName = savePage.getFileName();

        if (currentSdk.configName != null && !currentSdk.configName.endsWith(".comptanalyser"))
            currentSdk.configName += ".comptanalyser";

        try {
            if (currentSdk.container.length() > 0 && currentSdk.configName.length() > 0) {
                IPath path = new Path(
                        FileMethods.appendPathSeparator(currentSdk.container) + currentSdk.configName);
                IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(path);

                ParserEngine.saveSettingsToFile(engine, file.getLocation().toString());
            }
        } catch (ParserConfigurationException e) {
            MessageDialog.openError(Display.getCurrent().getActiveShell(), "Compatibility Analyser",
                    "Error in saving the configuration " + e.getMessage());
        }
    }

    String currentDateTime = FileMethods.getDateTime();
    FileMethods.createFolder(
            FileMethods.convertForwardToBackwardSlashes(CompatibilityAnalyserPlugin.stateLocation.toString())
                    + File.separator + currentDateTime);
    currentSdk.setconfigfolder(
            FileMethods.convertForwardToBackwardSlashes(CompatibilityAnalyserPlugin.stateLocation.toString())
                    + File.separator + currentDateTime);

    MainView mainView = MainView.showAndReturnYourself();
    if (mainView != null)
        mainView.startAnalysis(engine);

    return true;
}