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

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

Introduction

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

Prototype

String getString(String name);

Source Link

Document

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

Usage

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$
        {//from  w w  w.  j  a  v a2  s. c o  m
            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.model.ReportFilterEngine.java

License:Open Source License

/**
 * This method returns the path of the selected knownissues from the knownissues dialog.
 * i.e, If default is selected, returns the knownissues path from the core tools provided by the tool
 * And if the local issues is selected, returns the path provided in the combo
 * And if the web server issues is selected, returns the path of the issues files which is extracted from webserver
 * And if latest issues is selected, returns the path of the latest issues file which is extracted from webserver    
 * @return string path of the issues file. 
 *///  w  w  w .  j a va2 s.  c  om
public String getKnownissuesPath() {
    LastUsedKnownissues issuesData = new LastUsedKnownissues();

    IPreferenceStore prefStore = CompatibilityAnalyserPlugin.getCompatabilityAnalyserPrefStore();
    if (prefStore.getBoolean(CompatibilityAnalyserPreferencesConstants.LOCAL_ISSUES)) {
        String[] issuesArr = issuesData.getPreviousValues(LastUsedKnownissues.ValueTypes.LOCAL_ISSUES_PATH);
        if (issuesArr != null && issuesArr.length != 0) {
            String all = issuesArr[0];
            for (int i = 1; i < issuesArr.length; i++) {
                all = all + ";" + issuesArr[i]; //$NON-NLS-1$
            }
            data.knownissuesPath = all;

        }
    }

    else if (prefStore.getBoolean(CompatibilityAnalyserPreferencesConstants.DEFAULT_ISSUES)) {
        String corePath = CompatibilityAnalyserPlugin.getInstallPathOfToolsPlugin();

        data.knownissuesPath = corePath + File.separator + Messages.getString("ReportFilterEngine.Bctools") //$NON-NLS-1$
                + File.separator + Messages.getString("ReportFilterEngine.data") + File.separator //$NON-NLS-1$
                + Messages.getString("ReportFilterEngine.knownissues.xml"); //$NON-NLS-1$
    } else if (prefStore.getBoolean(CompatibilityAnalyserPreferencesConstants.WEB_ISSUES)) {
        String[] issuesArr = issuesData.getPreviousValues(LastUsedKnownissues.ValueTypes.ISSUES_URL);
        if (issuesArr != null && issuesArr.length != 0) {
            String all = issuesArr[0];
            for (int i = 1; i < issuesArr.length; i++) {
                all = all + ";" + issuesArr[i]; //$NON-NLS-1$
            }
            data.knownissuesPath = all;
        }

    } else if (prefStore.getBoolean(CompatibilityAnalyserPreferencesConstants.LATEST_ISSUES)) {
        data.knownissuesPath = prefStore.getString(CompatibilityAnalyserPreferencesConstants.KNOWNISSUES_URL);
    }

    return data.knownissuesPath;
}

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

License:Open Source License

public boolean isMetadataFileUpdated() {
    IPreferenceStore prefStore = CompatibilityAnalyserPlugin.getCompatabilityAnalyserPrefStore();
    String currentURL = prefStore.getString(CompatibilityAnalyserPreferencesConstants.BASELINES_URL);
    String prevURL = prefStore.getString(CompatibilityAnalyserPreferencesConstants.PREVIOUS_BASELINE_URL);
    Long lastModified_metadata = prefStore
            .getLong(CompatibilityAnalyserPreferencesConstants.LASTMODIFIED_DATE_METADATA);

    if (!prevURL.equals("") && prevURL.equals(currentURL)) {
        try {//  ww  w . j a v  a2  s.c o  m
            URL url = new URL(currentURL);
            URLConnection connection = url.openConnection();

            Long webServerModTime = connection.getLastModified();
            if (webServerModTime <= lastModified_metadata)
                return false;

        } catch (MalformedURLException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    return true;
}

From source file:com.nokia.s60tools.compatibilityanalyser.ui.editors.ComptAnalyserLauncher.java

License:Open Source License

private void runStaticAnalysis(CompatibilityAnalyserEngine engine) {
    ProductSdkData currentSdk = engine.getCurrentSdkData();

    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);
    }//  www .j  a v a2  s  .com

    MainView mainView = MainView.showAndReturnYourself();

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

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

}

From source file:com.nokia.s60tools.compatibilityanalyser.ui.views.MainView.java

License:Open Source License

/**
 * Opens the analysis wizard.//from  w  w w  .j  a v  a2 s . c  o  m
 *
 */
public void showWizard() {
    //First Check if web server core tools are selected in preferences
    //If yes, check whether core tools are updated or not.
    IPreferenceStore prefStore = CompatibilityAnalyserPlugin.getCompatabilityAnalyserPrefStore();
    String urlInPref = prefStore.getString(CompatibilityAnalyserPreferencesConstants.CORETOOLS_URL);
    boolean webToolsSelected = prefStore.getBoolean(CompatibilityAnalyserPreferencesConstants.WEB_TOOLS);
    if (webToolsSelected && CompatibilityAnalyserEngine.isDownloadAndExtractionNeeded(urlInPref)) {
        //If not, ask for the confirmation
        boolean okPressed = MessageDialog.openConfirm(Display.getCurrent().getActiveShell(),
                "Compatibility Analyser",
                "Core components from Web server are in use.\nPress Ok to download them, or Cancel and change the settings in preferences page.");
        if (okPressed) {
            String status = CompatibilityAnalyserUtils.initiateDownloadingCoreTools();
            if (status != null) {
                status = status + "\n\nNote: Using the different core tools may solve your problem.";
                MessageDialog.openError(tableviewer.getControl().getShell(), "Compatibility Analyser", status);
                return;
            }
        } else {
            return;
        }
    }

    //If the opened from the view, set false 
    Runnable showWizardRunnable = new Runnable() {
        public void run() {
            WizardDialog wizDialog;
            CompatibilityAnalyserEngine engine = new CompatibilityAnalyserEngine();
            AnalysisWizard wiz = new AnalysisWizard(engine);
            wiz.setNeedsProgressMonitor(true);
            wiz.setNeedsProgressMonitor(true);
            wizDialog = new WizardDialog(getViewSite().getShell(), wiz);
            wizDialog.create();
            wizDialog.addPageChangedListener(wiz);
            wizDialog.getShell().setSize(wizDialog.getShell().getSize().x,
                    wizDialog.getShell().getSize().y + 70);
            wizDialog.open();
        }
    };

    Display.getDefault().asyncExec(showWizardRunnable);
}

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

License:Open Source License

public void widgetSelected(SelectionEvent e) {
    if (e.widget == issuesBtn) {

        Runnable showDialogRunnable = new Runnable() {
            public void run() {
                IPreferenceStore prefStore = CompatibilityAnalyserPlugin.getCompatabilityAnalyserPrefStore();
                String serverUrl = prefStore
                        .getString(CompatibilityAnalyserPreferencesConstants.KNOWNISSUES_URL);
                KnownissuesDilaog dlg = new KnownissuesDilaog(Display.getCurrent().getActiveShell(), serverUrl);
                dlg.open();//from  w ww .  j  ava2s . c om
            }
        };
        Display.getDefault().syncExec(showDialogRunnable);

        showTextKnownissuesLabel();
        this.getContainer().updateButtons();
    } else if (e.widget == browseBtn) {
        DirectoryDialog dirDlg = new DirectoryDialog(Display.getCurrent().getActiveShell());
        String dirName = null;
        if ((dirName = dirDlg.open()) != null) {
            dirCmb.setText(dirName);
        } else
            return;

        this.getContainer().updateButtons();
    } else if (e.widget == addBtn) {
        FileDialog fileSelector = new FileDialog(this.getShell(), SWT.MULTI);
        fileSelector.setText("Add files"); //$NON-NLS-1$
        String[] filterExt = { "*.xml", "*.*" }; //$NON-NLS-1$ //$NON-NLS-2$
        fileSelector.setFilterExtensions(filterExt);
        fileSelector.open();

        String[] files = fileSelector.getFileNames();
        String filterPath = fileSelector.getFilterPath();

        for (String s : files) {
            if (!filterPath.endsWith(File.separator))
                filterPath += File.separator;

            list.add(filterPath + s);
        }
        list.select(0);
        this.getContainer().updateButtons();
    } else if (e.widget == removeBtn) {
        list.remove(list.getSelectionIndices());
        this.getContainer().updateButtons();
    } else if (e.widget == selectAllBtn) {
        list.removeAll();
        this.getContainer().updateButtons();
    }
}

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

License:Open Source License

/**
 * Constructs the page//w w  w.ja va2  s.com
 */
public void createControl(Composite parent) {

    Composite composite = new Composite(parent, SWT.NONE);

    GridLayout layout = new GridLayout(6, false);
    composite.setLayout(layout);
    composite.setLayoutData(new GridData(GridData.FILL_BOTH));

    Label lbl1 = new Label(composite, SWT.NONE);
    lbl1.setText(Messages.getString("AddReportFilesPage.ListofReportFiles")); //$NON-NLS-1$

    GridData data1 = new GridData(GridData.FILL_HORIZONTAL);
    data1.horizontalSpan = 6;
    lbl1.setLayoutData(data1);

    list = new List(composite, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL);
    list.setToolTipText(Messages.getString("AddReportFilesPage.AddReportFiles")); //$NON-NLS-1$
    GridData data2 = new GridData(GridData.FILL_HORIZONTAL);
    data2.horizontalSpan = 6;
    data2.heightHint = 200;
    list.setLayoutData(data2);

    if (this.files != null) {
        list.setItems(files);
    }
    GridData data3 = new GridData(GridData.FILL_HORIZONTAL);
    data3.verticalIndent = 10;
    data3.horizontalSpan = 2;
    addBtn = new Button(composite, SWT.PUSH);
    addBtn.setText(Messages.getString("AddReportFilesPage.AddFiles")); //$NON-NLS-1$
    addBtn.setLayoutData(data3);
    addBtn.addSelectionListener(this);

    removeBtn = new Button(composite, SWT.PUSH);
    removeBtn.setText(Messages.getString("AddReportFilesPage.Remove")); //$NON-NLS-1$
    removeBtn.setLayoutData(data3);
    removeBtn.addSelectionListener(this);

    selectAllBtn = new Button(composite, SWT.PUSH);
    selectAllBtn.setText(Messages.getString("AddReportFilesPage.RemoveAll")); //$NON-NLS-1$
    selectAllBtn.setLayoutData(data3);
    selectAllBtn.addSelectionListener(this);

    Label lbl2 = new Label(composite, SWT.NONE);
    GridData data4 = new GridData(GridData.FILL);
    data4.verticalIndent = 10;
    data4.horizontalSpan = 6;
    lbl2.setText(Messages.getString("AddReportFilesPage.OutputFilesDirectory")); //$NON-NLS-1$
    lbl2.setLayoutData(data4);

    dirCmb = new Combo(composite, SWT.BORDER | SWT.DROP_DOWN);
    GridData data5 = new GridData(GridData.FILL_HORIZONTAL);
    data5.horizontalSpan = 5;
    dirCmb.setLayoutData(data5);

    SavingUserData data = new SavingUserData();
    String[] lastUsedDirs = data.getPreviousValues(SavingUserData.ValueTypes.REPORT_PATH);

    if (lastUsedDirs != null) {
        dirCmb.setItems(lastUsedDirs);
        dirCmb.select(0);
    } else {
        IPreferenceStore prefStore = CompatibilityAnalyserPlugin.getCompatabilityAnalyserPrefStore();
        if (prefStore.getBoolean(CompatibilityAnalyserPreferencesConstants.DEFAULT_TOOLS)) {
            dirCmb.setText("C:\\temp"); //$NON-NLS-1$
        } else if (prefStore.getBoolean(CompatibilityAnalyserPreferencesConstants.LOCAL_TOOLS)) {
            dirCmb.setText(prefStore.getString(CompatibilityAnalyserPreferencesConstants.LOCAL_TOOLS_PATH)
                    + File.separator + Messages.getString("AddReportFilesPage.reports")); //$NON-NLS-1$
        } else if (prefStore.getBoolean(CompatibilityAnalyserPreferencesConstants.SDK_TOOLS)) {
            dirCmb.setText(prefStore.getString(CompatibilityAnalyserPreferencesConstants.SDK_TOOLS_PATH)
                    + File.separator + Messages.getString("AddReportFilesPage.reports")); //$NON-NLS-1$
        } else
            dirCmb.setText("C:\\temp"); //$NON-NLS-1$
    }
    dirCmb.addModifyListener(this);

    browseBtn = new Button(composite, SWT.PUSH);
    GridData data8 = new GridData(GridData.FILL_HORIZONTAL);
    browseBtn.setText(Messages.getString("AddReportFilesPage.Browse")); //$NON-NLS-1$
    browseBtn.setLayoutData(data8);
    browseBtn.addSelectionListener(this);

    Group grp = new Group(composite, SWT.NONE);
    grp.setLayout(new GridLayout(2, false));
    grp.setText(Messages.getString("AddReportFilesPage.Knownissues")); //$NON-NLS-1$
    GridData data9 = new GridData(GridData.FILL_HORIZONTAL);
    data9.horizontalSpan = 6;

    grp.setLayoutData(data9);

    label3 = new Label(grp, SWT.WRAP | SWT.VERTICAL);
    GridData data6 = new GridData(GridData.FILL_HORIZONTAL);
    data6.horizontalSpan = 2;
    showTextKnownissuesLabel();
    label3.setLayoutData(data6);

    Label lbl5 = new Label(grp, SWT.WRAP | SWT.SHADOW_OUT);
    lbl5.setText(""); //$NON-NLS-1$

    issuesBtn = new Button(grp, SWT.PUSH);
    issuesBtn.setText(Messages.getString("AddReportFilesPage.ConfigureKnownissuesFile")); //$NON-NLS-1$
    issuesBtn.setToolTipText(Messages.getString("AddReportFilesPage.Tooltip_OPensKnownissuesDialog")); //$NON-NLS-1$
    issuesBtn.addSelectionListener(this);

    setHelp();
    setControl(composite);

}

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

License:Open Source License

/**
 * Checkes the status of the page, whether can be finished or not.
 * @return boolean /*  w  w w  . j  av  a2s  .  c o m*/
 */
public boolean canFinish() {
    boolean value = true;
    setErrorMessage(null);
    removeBtn.setEnabled(list.getItemCount() > 0);
    selectAllBtn.setEnabled(list.getItemCount() > 0);
    if (list.getItemCount() == 0) {
        value = false;
        setErrorMessage(Messages.getString("AddReportFilesPage.Error_AddMinOneReport")); //$NON-NLS-1$
    }
    if (dirCmb.getText().length() == 0) {
        value = false;
        setErrorMessage(Messages.getString("AddReportFilesPage.SelectOutPutDir")); //$NON-NLS-1$
    }

    File dir = new File(dirCmb.getText());
    if (!dir.isDirectory()) {
        value = false;
        setErrorMessage(Messages.getString("AddReportFilesPage.InvalidDirectory")); //$NON-NLS-1$
    }

    IPreferenceStore store = CompatibilityAnalyserPlugin.getCompatabilityAnalyserPrefStore();
    String urlInPref = store.getString(CompatibilityAnalyserPreferencesConstants.KNOWNISSUES_URL);

    LastUsedKnownissues data = new LastUsedKnownissues();
    String[] urlInDialog = data.getPreviousValues(LastUsedKnownissues.ValueTypes.WEBSERVER_MAIN_URL);
    if (urlInPref != null && urlInDialog != null
            && store.getBoolean(CompatibilityAnalyserPreferencesConstants.WEB_ISSUES)) {
        if (!urlInPref.endsWith("/")) //$NON-NLS-1$
            urlInPref = urlInPref + "/"; //$NON-NLS-1$
        if (!urlInDialog[0].endsWith("/")) //$NON-NLS-1$
            urlInDialog[0] = urlInPref + "/"; //$NON-NLS-1$

        if (!urlInPref.equalsIgnoreCase(urlInDialog[0])) {
            setMessage(Messages.getString("AddReportFilesPage.URLmismatch"), DialogPage.WARNING); //$NON-NLS-1$
        } else
            setMessage(null);
    }

    return value;
}

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. jav  a  2  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;
}

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

License:Open Source License

/**
 * Stores the latest values to preference store object.
 *///from  w ww  .  j  a v  a 2s .  c om
public boolean performOk() {
    IPreferenceStore store = CompatibilityAnalyserPlugin.getCompatabilityAnalyserPrefStore();
    SavingUserData userData = new SavingUserData();

    String url2 = knowniss_webLink.getText();

    if (url2.length() != 0) {
        store.setValue(CompatibilityAnalyserPreferencesConstants.KNOWNISSUES_URL, url2);
    }
    /*else
    {
       MessageDialog.openError(Display.getCurrent().getActiveShell(), Messages.getString("CompatibilityAnalyserPreferences.25"), Messages.getString("CompatibilityAnalyserPreferences.26")); //$NON-NLS-1$ //$NON-NLS-2$
       return false;
    }*/
    if (localcoreBtn.getSelection() == true) {
        File checkbc = null;
        if (localCmb.getText().length() != 0) {
            checkbc = new File(FileMethods.appendPathSeparator(localCmb.getText())
                    + Messages.getString("CompatibilityAnalyserPreferences.27")); //$NON-NLS-1$
        } else {
            MessageDialog.openError(Display.getCurrent().getActiveShell(),
                    Messages.getString("CompatibilityAnalyserPreferences.28"), //$NON-NLS-1$
                    Messages.getString("CompatibilityAnalyserPreferences.29")); //$NON-NLS-1$
            return false;
        }

        //check whether the checkbc.py exists or not 
        if (checkbc.exists() && checkbc.isFile()) {
            try {
                String dv = CompatibilityAnalyserEngine
                        .getDataVersion(checkbc.getParentFile().getAbsolutePath());
                int num = Integer.parseInt(dv);
                if (num != CompatibilityAnalyserPlugin.DATA_VERSION) {
                    if (!checkbc.getParentFile().getAbsolutePath()
                            .equalsIgnoreCase(CompatibilityAnalyserPlugin.getDefaltCoretoolsPath()))
                        MessageDialog.openError(Display.getCurrent().getActiveShell(),
                                Messages.getString("CompatibilityAnalyserPreferences.42"),
                                "Invalid data version of coretools. Please check the coretools.\nPlease select the coretools of data version "
                                        + CompatibilityAnalyserPlugin.DATA_VERSION + ".");
                    return false;
                }
            } catch (NumberFormatException e) {
                MessageDialog.openError(Display.getCurrent().getActiveShell(),
                        Messages.getString("CompatibilityAnalyserPreferences.42"),
                        "Invalid data version of coretools. Please check the coretools.\nPlease select the coretools of data version "
                                + CompatibilityAnalyserPlugin.DATA_VERSION + ".");
                return false;
            } catch (Exception e) {
                MessageDialog.openError(Display.getCurrent().getActiveShell(),
                        Messages.getString("CompatibilityAnalyserPreferences.42"),
                        "Invalid data version of coretools. Please check the coretools.\nPlease select the coretools of data version "
                                + CompatibilityAnalyserPlugin.DATA_VERSION + ".");
                return false;
            }
            store.setValue(CompatibilityAnalyserPreferencesConstants.LOCAL_TOOLS_PATH, localCmb.getText());
            userData.saveValue(SavingUserData.ValueTypes.CORE_PATH, localCmb.getText());
        } else {
            MessageDialog.openError(Display.getCurrent().getActiveShell(),
                    Messages.getString("CompatibilityAnalyserPreferences.30"), //$NON-NLS-1$
                    Messages.getString("CompatibilityAnalyserPreferences.31")); //$NON-NLS-1$ //$NON-NLS-3$
            return false;
        }
    }
    if (webcoreBtn.getSelection() == true) {
        String url1 = webLink.getText();
        if (url1.length() != 0) {
            if (isRefreshInvoked) {
                String prevFolder = store
                        .getString(CompatibilityAnalyserPreferencesConstants.PREVIOUS_WEB_CORE_TOOLS_ROOTDIR);

                FileMethods.deleteFolder(prevFolder);

                File currentFolder = new File(targetPath);
                currentFolder.renameTo(new File(CompatibilityAnalyserEngine.getWorkspacePath() + File.separator
                        + Messages.getString("CompatibilityAnalyserPreferences.WebServerContentsNew"))); //$NON-NLS-1$

                String corePath = CompatibilityAnalyserEngine.getWebServerToolsPath();

                if (corePath != null && corePath.equalsIgnoreCase(targetPath)) {
                    store.setValue(CompatibilityAnalyserPreferencesConstants.PREVIOUS_WEB_CORE_TOOLS_PATH,
                            CompatibilityAnalyserEngine.getWorkspacePath() + File.separator + Messages
                                    .getString("CompatibilityAnalyserPreferences.WebServerContentsNew"));
                } else if (!corePath.equalsIgnoreCase(targetPath)) {
                    String coreRoot = CompatibilityAnalyserEngine.getWebServerToolsPath()
                            .substring(targetPath.length() + 1);
                    store.setValue(CompatibilityAnalyserPreferencesConstants.PREVIOUS_WEB_CORE_TOOLS_PATH,
                            CompatibilityAnalyserEngine.getWorkspacePath() + File.separator
                                    + Messages
                                            .getString("CompatibilityAnalyserPreferences.WebServerContentsNew")
                                    + File.separator + coreRoot);
                }

                store.setValue(CompatibilityAnalyserPreferencesConstants.PREVIOUS_WEB_CORE_TOOLS_URL, url1);
                store.setValue(CompatibilityAnalyserPreferencesConstants.PREVIOUS_WEB_CORE_TOOLS_ROOTDIR,
                        CompatibilityAnalyserEngine.getWorkspacePath() + File.separator
                                + Messages.getString("CompatibilityAnalyserPreferences.WebServerContentsNew")); //$NON-NLS-1$

                isRefreshInvoked = false;

            }
            store.setValue(CompatibilityAnalyserPreferencesConstants.CORETOOLS_URL, url1);
        } else {
            MessageDialog.openError(Display.getCurrent().getActiveShell(),
                    Messages.getString("CompatibilityAnalyserPreferences.38"), //$NON-NLS-1$
                    Messages.getString("CompatibilityAnalyserPreferences.39")); //$NON-NLS-1$
            return false;
        }
    }
    if (sdkcoreBtn.getSelection() == true) {
        if (sdkCmb.getText().length() != 0) {
            store.setValue(CompatibilityAnalyserPreferencesConstants.SDK_NAME, sdkCmb.getText());
            ISymbianSDK selectedSdk = rndSdkList.elementAt(sdkCmb.getSelectionIndex());
            String bctoolsPath = FileMethods.appendPathSeparator(selectedSdk.getEPOCROOT())
                    + Messages.getString("CompatibilityAnalyserPreferences.40"); //$NON-NLS-1$
            File cbc = new File(
                    bctoolsPath + File.separator + Messages.getString("CompatibilityAnalyserPreferences.41")); //$NON-NLS-1$
            if (!cbc.exists()) {
                MessageDialog.openError(Display.getCurrent().getActiveShell(),
                        Messages.getString("CompatibilityAnalyserPreferences.42"), //$NON-NLS-1$
                        bctoolsPath + Messages.getString("CompatibilityAnalyserPreferences.43")); //$NON-NLS-1$
                return false;
            }

            try {
                String dv = CompatibilityAnalyserEngine.getDataVersion(bctoolsPath);
                int num = Integer.parseInt(dv);
                if (num != CompatibilityAnalyserPlugin.DATA_VERSION) {
                    if (!bctoolsPath.equalsIgnoreCase(CompatibilityAnalyserPlugin.getDefaltCoretoolsPath()))
                        MessageDialog.openError(Display.getCurrent().getActiveShell(),
                                Messages.getString("CompatibilityAnalyserPreferences.42"),
                                "Invalid data version of coretools. Please check the coretools.\nPlease select the coretools of data version "
                                        + CompatibilityAnalyserPlugin.DATA_VERSION + ".");
                    return false;
                }
            } catch (NumberFormatException e) {
                MessageDialog.openError(Display.getCurrent().getActiveShell(),
                        Messages.getString("CompatibilityAnalyserPreferences.42"),
                        "Invalid data version of coretools. Please check the coretools.\nPlease select the coretools of data version "
                                + CompatibilityAnalyserPlugin.DATA_VERSION + ".");
                return false;
            } catch (Exception e) {
                MessageDialog.openError(Display.getCurrent().getActiveShell(),
                        Messages.getString("CompatibilityAnalyserPreferences.42"),
                        "Invalid data version of coretools. Please check the coretools.\nPlease select the coretools of data version "
                                + CompatibilityAnalyserPlugin.DATA_VERSION + ".");
                return false;
            }

            store.setValue(CompatibilityAnalyserPreferencesConstants.SDK_TOOLS_PATH, bctoolsPath);
        } else {
            MessageDialog.openError(Display.getCurrent().getActiveShell(),
                    Messages.getString("CompatibilityAnalyserPreferences.44"), //$NON-NLS-1$
                    "Please provide a R&D SDK for coretools"); //$NON-NLS-1$
            return false;
        }
    }

    store.setValue(CompatibilityAnalyserPreferencesConstants.DEFAULT_TOOLS, defaultcoreBtn.getSelection());
    store.setValue(CompatibilityAnalyserPreferencesConstants.LOCAL_TOOLS, localcoreBtn.getSelection());
    store.setValue(CompatibilityAnalyserPreferencesConstants.WEB_TOOLS, webcoreBtn.getSelection());
    store.setValue(CompatibilityAnalyserPreferencesConstants.SDK_TOOLS, sdkcoreBtn.getSelection());

    store.setValue(CompatibilityAnalyserPreferencesConstants.BASELINES_URL, baselineTxt.getText());

    return super.performOk();
}