Example usage for org.eclipse.jface.operation IRunnableWithProgress IRunnableWithProgress

List of usage examples for org.eclipse.jface.operation IRunnableWithProgress IRunnableWithProgress

Introduction

In this page you can find the example usage for org.eclipse.jface.operation IRunnableWithProgress IRunnableWithProgress.

Prototype

IRunnableWithProgress

Source Link

Usage

From source file:com.nokia.carbide.remoteconnections.interfaces.AbstractConnectedService2.java

License:Open Source License

public void testStatus() {
    if (!(isEnabled() || externalTesting))
        return;//from  w  ww.  jav  a  2s  .c o m

    final TestResult result[] = { null };
    if (runnableContext != null && (!(runnableContext instanceof WizardDialog)
            || ((WizardDialog) runnableContext).getShell() != null)) {
        Display.getDefault().syncExec(new Runnable() {
            public void run() {
                try {
                    runnableContext.run(true, false, new IRunnableWithProgress() {
                        public void run(IProgressMonitor monitor)
                                throws InvocationTargetException, InterruptedException {
                            result[0] = runTestStatus(monitor);
                        }
                    });
                } catch (InvocationTargetException e) {
                } catch (InterruptedException e) {
                }
            }
        });
    } else {
        result[0] = runTestStatus(new NullProgressMonitor());
    }

    if (!(isEnabled() || externalTesting)) // could be waiting for response past when service testing was disabled
        return;
    if (result[0].shortDescription != null && result[0].longDescription != null) {
        currentStatus.setEStatus(result[0].estatus, result[0].shortDescription, result[0].longDescription);
    }
}

From source file:com.nokia.carbide.remoteconnections.tests.extensions.TestInstallerProvider.java

License:Open Source License

public List<String> getSDKFamilyNames(IRunnableContext runnableContext) {
    if (!initialized) {
        try {// ww  w  .  ja v  a 2  s .com
            if (runnableContext != null)
                runnableContext.run(false, false, new IRunnableWithProgress() {
                    public void run(IProgressMonitor monitor)
                            throws InvocationTargetException, InterruptedException {
                        getMockData(monitor);
                    }
                });
        } catch (Exception e) {
            e.printStackTrace();
        }
        initialized = true;
    }
    String[] familyNames = { S60, UIQ };
    return new ArrayList<String>(Arrays.asList(familyNames));
}

From source file:com.nokia.carbide.search.system2.internal.ui.InternalSearchUI.java

License:Open Source License

private IStatus doRunSearchInForeground(final SearchJobRecord rec, IRunnableContext context) {
    try {/*from w w w  .j  a  v  a  2 s .  c  om*/
        context.run(true, true, new IRunnableWithProgress() {
            public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                searchJobStarted(rec);
                try {
                    IStatus status = rec.query.run(monitor);
                    if (status.matches(IStatus.CANCEL)) {
                        throw new InterruptedException();
                    }
                    if (!status.isOK()) {
                        throw new InvocationTargetException(new CoreException(status));
                    }
                } catch (OperationCanceledException e) {
                    throw new InterruptedException();
                } finally {
                    searchJobFinished(rec);
                }
            }
        });
    } catch (InvocationTargetException e) {
        Throwable innerException = e.getTargetException();
        if (innerException instanceof CoreException) {
            return ((CoreException) innerException).getStatus();
        }
        return new Status(IStatus.ERROR, SearchPlugin.getID(), 0,
                SearchMessages.InternalSearchUI_error_unexpected, innerException);
    } catch (InterruptedException e) {
        return Status.CANCEL_STATUS;
    }
    return Status.OK_STATUS;
}

From source file:com.nokia.s60ct.cenrep.gui.editors.CRBrowser.java

License:Open Source License

@Override
public void doSave(IProgressMonitor monitor) {
    final Map<Object, Object> saveOptions = new HashMap<Object, Object>();
    saveOptions.put(Resource.OPTION_SAVE_ONLY_IF_CHANGED, Resource.OPTION_SAVE_ONLY_IF_CHANGED_MEMORY_BUFFER);

    // Do the work within an operation because this is a long running activity that modifies the workbench.
    ////  w  ww. j  av  a 2 s  .c om
    IRunnableWithProgress operation = new IRunnableWithProgress() {
        // This is the method that gets invoked when the operation runs.
        //
        public void run(IProgressMonitor monitor) {
            // Save the resources to the file system.
            //
            boolean first = true;
            for (Resource resource : editingDomain.getResourceSet().getResources()) {
                if ((first || !resource.getContents().isEmpty() || isPersisted(resource))
                        && !editingDomain.isReadOnly(resource)) {
                    try {
                        savedResources.add(resource);
                        resource.save(saveOptions);
                    } catch (Exception exception) {
                        //                        resourceToDiagnosticMap.put(resource, analyzeResourceProblems(resource, exception));
                    }
                    first = false;
                }
            }
        }
    };

    //      updateProblemIndication = false;
    try {
        // This runs the options, and shows progress.
        //
        new ProgressMonitorDialog(getSite().getShell()).run(true, false, operation);

        // Refresh the necessary state.
        //
        ((BasicCommandStack) editingDomain.getCommandStack()).saveIsDone();
        firePropertyChange(IEditorPart.PROP_DIRTY);
    } catch (Exception exception) {

        CenRepPlugin.INSTANCE.log(exception);
    }
}

From source file:com.nokia.s60ct.gui.editors.ConfigurationBrowser.java

License:Open Source License

@Override
public void doSave(IProgressMonitor monitor) {

    checkUndefinedTypes();/*from   www  .jav a  2s. co  m*/

    final Map<Object, Object> saveOptions = new HashMap<Object, Object>();
    saveOptions.put(Resource.OPTION_SAVE_ONLY_IF_CHANGED, Resource.OPTION_SAVE_ONLY_IF_CHANGED_MEMORY_BUFFER);

    // Do the work within an operation because this is a long running activity that modifies the workbench.
    //
    IRunnableWithProgress operation = new IRunnableWithProgress() {
        // This is the method that gets invoked when the operation runs.
        //
        public void run(IProgressMonitor monitor) {
            // Save the resources to the file system.
            //
            boolean first = true;
            for (Resource resource : editingDomain.getResourceSet().getResources()) {
                if ((first || !resource.getContents().isEmpty() || isPersisted(resource))
                        && !editingDomain.isReadOnly(resource)) {
                    try {
                        savedResources.add(resource);
                        Object rootConf = resource.getContents().get(0);
                        if (rootConf instanceof RootConf && ((RootConf) rootConf).getRoot() == null)
                            resource.save(saveOptions);
                    } catch (Exception exception) {
                        //                        resourceToDiagnosticMap.put(resource, analyzeResourceProblems(resource, exception));
                    }
                    first = false;
                }
            }
        }
    };

    //      updateProblemIndication = false;
    try {
        // This runs the options, and shows progress.
        //
        new ProgressMonitorDialog(getSite().getShell()).run(true, false, operation);

        // Refresh the necessary state.
        //
        ((BasicCommandStack) editingDomain.getCommandStack()).saveIsDone();
        firePropertyChange(IEditorPart.PROP_DIRTY);
    } catch (Exception exception) {

        S60CtEditorPlugin.INSTANCE.log(exception);
    }

}

From source file:com.nokia.s60ct.gui.wizard.NewConfigurationWizard.java

License:Open Source License

/**
 * Do the work after everything is specified.
 * <!-- begin-user-doc -->/*w  ww. j av a2 s.  c om*/
 * <!-- end-user-doc -->
 * @generated
 */
@Override
public boolean performFinish() {
    try {
        // Get the URI of the model file.
        //
        URI uri = getModelURI();
        File file = new File(uri.toFileString());

        if (uri.toFileString().startsWith(File.separator)
                && System.getProperties().getProperty("os.name").startsWith("Windows")) {//unusual case, but user typed path that starts with "\"
            String userDir = System.getProperty("user.dir");
            char driveLetter = userDir.charAt(0);
            file = new File(driveLetter + ":" + uri.toFileString());
            uri = URI.createFileURI(file.toString());
        }

        final URI fileURI = uri; //final uri for innerclass

        readOnlyError = false;

        if (file.exists()) {
            if (!MessageDialog.openQuestion(getShell(),
                    S60CtEditorPlugin.INSTANCE.getString("_UI_Question_title"), S60CtEditorPlugin.INSTANCE
                            .getString("_WARN_FileConflict", new String[] { fileURI.toFileString() }))) {
                initialObjectCreationPage.selectFileField();
                return false;
            }
        }

        // Do the work within an operation.
        //
        IRunnableWithProgress operation = new IRunnableWithProgress() {
            public void run(IProgressMonitor progressMonitor) {
                try {
                    // Create a resource set
                    //
                    //                     ResourceSet resourceSet = new ResourceSetImpl();

                    // Create a resource for this file.
                    //
                    Resource resource = new ConfigurationemfResourceImpl(fileURI);

                    // Add the initial model object to the contents.
                    //
                    EObject rootObject = createInitialModel();
                    if (rootObject != null) {
                        resource.getContents().add(rootObject);
                    }
                    resource.save(null);
                } catch (java.io.FileNotFoundException ioe) {
                    //folder is read-only
                    readOnlyError = true;

                } catch (Exception exception) {
                    S60CtEditorPlugin.INSTANCE.log(exception);
                } finally {
                    progressMonitor.done();
                }
            }
        };

        getContainer().run(false, false, operation);

        if (readOnlyError) {
            MessageDialog.openError(getShell(), S60CtEditorPlugin.INSTANCE.getString("_UI_Error_title"),
                    S60CtEditorPlugin.INSTANCE.getString("_UI_ReadOnlyFolderError_message",
                            new String[] { fileURI.toFileString() }));
            return false;
        }

        OpenConfiguration.openEditor(fileURI);
        return true;
    } catch (Exception exception) {
        S60CtEditorPlugin.INSTANCE.log(exception);
        return false;
    }
}

From source file:com.nokia.s60tools.compatibilityanalyser.ui.actions.AnalyseDirOnlyAction.java

License:Open Source License

/**
 * This method gets invoked when user selects the option,
 * 'Run static analysis for this directory in project...' from
 * the submenu of a folder./* w w w  .jav  a2 s . c  om*/
 */
public void run(IAction action) {

    IWorkbenchWindow window = CompatibilityAnalyserPlugin.getDefault().getWorkbench()
            .getActiveWorkbenchWindow();
    ISelection selection = (ISelection) window.getSelectionService().getSelection();

    engine = new CompatibilityAnalyserEngine();
    currentSdk = new ProductSdkData();

    currentSdk.isOpenedFromProject = true;

    try {
        isCancelled = false;
        engine.setHeaderAnalysis(true);
        if (selection instanceof TreeSelection) {
            IStructuredSelection treeSelection = (IStructuredSelection) selection;

            //In Carbide, some folders are instances of ICContainer class. 
            if (treeSelection.getFirstElement() instanceof IFolder
                    || treeSelection.getFirstElement() instanceof ICContainer) {
                IFolder selectedFolder = null;
                ICContainer container = null;
                IProject parentProj = null;

                if (treeSelection.getFirstElement() instanceof IFolder) {
                    selectedFolder = (IFolder) treeSelection.getFirstElement();
                    parentProj = selectedFolder.getProject();
                    folderPath = FileMethods
                            .convertForwardToBackwardSlashes(selectedFolder.getLocation().toString());
                } else if (treeSelection.getFirstElement() instanceof ICContainer) {
                    container = (ICContainer) treeSelection.getFirstElement();
                    parentProj = container.getCProject().getProject();
                    folderPath = FileMethods
                            .convertForwardToBackwardSlashes(container.getResource().getLocation().toString());
                }

                ICarbideBuildManager mngr = CarbideBuilderPlugin.getBuildManager();

                //Selected folder path is added to the list of
                //directories, in Headers page of the wizard.

                if (folderPath != null) {
                    currentSdk.defaultHeaderDir = false;
                    currentSdk.currentHeaderDir = new String[] { folderPath };
                    currentSdk.analyseAll = false;
                } else {
                    MessageDialog.openInformation(Display.getCurrent().getActiveShell(),
                            Messages.getString("ProjectViewPopupAction.CompatibilityAnalyserError"),
                            "Unable to read selected Resource");
                    currentSdk.isOpenedFromProject = false;
                    return;
                }
                if (parentProj != null && mngr.isCarbideProject(parentProj)) {
                    prjInfo = mngr.getProjectInfo(parentProj);
                } else {
                    MessageDialog.openInformation(Display.getCurrent().getActiveShell(),
                            Messages.getString("ProjectViewPopupAction.CompatibilityAnalyserError"),
                            Messages.getString("ProjectViewPopupAction.CouldNotReadInfoFromProject"));
                    currentSdk.isOpenedFromProject = false;
                    return;
                }

                currentSdk.projectName = parentProj.getName();
                currentSdk.productSdkName = prjInfo.getDefaultConfiguration().getSDK().getUniqueId();

                IRunnableWithProgress projProgInfo = new IRunnableWithProgress() {

                    public void run(IProgressMonitor monitor) {

                        try {
                            monitor.beginTask("Reading folder data...", 10);
                            filesList = getHeaderFilesFromFolder(folderPath, monitor);

                            ArrayList<String> sysIncList = new ArrayList<String>();

                            getSystemIncludesFromThisProject(prjInfo, sysIncList, monitor);

                            currentSdk.HeaderFilesList = filesList.toArray(new String[0]);
                            monitor.worked(6);
                            currentSdk.currentIncludes = sysIncList.toArray(new String[0]);

                            if (!isCancelled) {
                                libsList = getCorrespondingDsos(filesList, monitor);
                                monitor.worked(9);
                            }
                            if (libsList.size() != 0) {
                                engine.setLibraryAnalysis(true);
                                currentSdk.analyzeAllLibs = false;
                                currentSdk.libraryFilesList = libsList.toArray(new String[0]);
                            }

                        } catch (Exception e) {
                            e.printStackTrace();
                        }

                        monitor.done();
                    }
                };

                new ProgressMonitorDialog(Display.getDefault().getActiveShell()).run(true, true, projProgInfo);
            }
        }

        engine.setCurrentSdkData(currentSdk);

    } catch (Exception e) {
        e.printStackTrace();
    }

    if (isCancelled)
        return;

    Runnable showWizardRunnable = new Runnable() {
        public void run() {
            WizardDialog wizDialog;
            AnalysisWizard wiz = new AnalysisWizard(engine);
            wizDialog = new WizardDialog(Display.getCurrent().getActiveShell(), wiz);
            wizDialog.create();
            //wizDialog.getShell().setSize(550, 620);
            wizDialog.addPageChangedListener(wiz);
            try {
                wizDialog.open();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    };

    Display.getDefault().syncExec(showWizardRunnable);

}

From source file:com.nokia.s60tools.compatibilityanalyser.ui.actions.ProjectViewPopupAction.java

License:Open Source License

public void run(IAction action) {

    engine = new CompatibilityAnalyserEngine();
    ProductSdkData currentSdk = new ProductSdkData();
    engine.setCurrentSdkData(currentSdk);
    isCancelled = false;//from  w  ww  .  j ava  2 s .  c o m

    IRunnableWithProgress projProgInfo = new IRunnableWithProgress() {

        public void run(IProgressMonitor monitor) {

            try {
                getSettingsForGivenSelection(selection, engine, monitor);

            } catch (Exception e) {
                e.printStackTrace();
                return;
            }

        }

    };

    try {
        new ProgressMonitorDialog(Display.getDefault().getActiveShell()).run(true, true, projProgInfo);
    } catch (Exception ex) {
        ex.printStackTrace();
    }

    if (isCancelled)
        return;

    if (engine.isLibraryAnalysisChecked()) {
        currentSdk.analyzeAllLibs = false;
    }
    engine.setCurrentSdkData(currentSdk);

    Runnable showWizardRunnable = new Runnable() {
        public void run() {
            WizardDialog wizDialog;
            //CompatibilityAnalyserEngine engine = new CompatibilityAnalyserEngine();

            AnalysisWizard wiz = new AnalysisWizard(engine);
            wizDialog = new WizardDialog(Display.getCurrent().getActiveShell(), wiz);
            wizDialog.create();
            wizDialog.getShell().setSize(wizDialog.getShell().getSize().x,
                    wizDialog.getShell().getSize().y + 70);
            wizDialog.addPageChangedListener(wiz);
            try {
                wizDialog.open();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    };

    Display.getDefault().syncExec(showWizardRunnable);

}

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

License:Open Source License

private void openFilesListDialog() {
    numOfFiles = new ArrayList<String>();
    displayFiles = new ArrayList<String>();
    children = new ArrayList<String>();
    subChildren = new ArrayList<String>();
    isMonitorCancelled = false;// w w w. j  a  v a  2 s.com

    addDialog = new ShowFilesListDialog(Display.getCurrent().getActiveShell(), forced_table, this, "", true);
    ArrayList<String> paths = new ArrayList<String>();
    for (int i = 0; i < syspath_table.getItems().length; i++) {
        if (!paths.contains(syspath_table.getItem(i).getText(0)))
            paths.add(syspath_table.getItem(i).getText(0));
    }
    if (!paths.contains(epocRoot + "epoc32" + File.separator + "include"))
        paths.add(epocRoot + "epoc32" + File.separator + "include");

    allSysIncHdrPaths = paths.toArray(new String[paths.size()]);
    IRunnableWithProgress op = new IRunnableWithProgress() {
        public void run(IProgressMonitor monitor) {
            try {
                int i = 1;
                for (String path : allSysIncHdrPaths) {
                    absolutePath = FileMethods.convertForwardToBackwardSlashes(path);
                    monitor.beginTask("Getting files from " + absolutePath, allSysIncHdrPaths.length);
                    getFiles(absolutePath, monitor);
                    getFilesFromSubDirs(absolutePath, monitor);
                    monitor.worked(i++);
                }
                monitor.done();

            } catch (Exception e1) {
                e1.printStackTrace();
            }
        }
    };

    try {
        IWorkbench wb = PlatformUI.getWorkbench();
        IWorkbenchWindow win = wb.getActiveWorkbenchWindow();
        Shell shell = win != null ? win.getShell() : null;
        progDlg = new ProgressMonitorDialog(shell);
        progDlg.run(true, true, op);
        progDlg.setBlockOnOpen(true);
    } catch (InvocationTargetException err) {
        err.printStackTrace();
    } catch (InterruptedException err) {
        err.printStackTrace();
    }

    if (!isMonitorCancelled) {
        for (String name : numOfFiles)
            if (!isPreviouslySelected(name))
                displayFiles.add(name);

        if (displayFiles.size() != 0) {
            Collections.sort(displayFiles);
            addDialog.children = children;
            addDialog.subChildren = subChildren;
            addDialog.open();
            addDialog.filesList.setItems(displayFiles.toArray(new String[displayFiles.size()]));
            addDialog.filesList.select(0);
        }
    }
    if (isMonitorCancelled) {
    } else if (displayFiles.size() == 0 && numOfFiles.size() != 0) {
        Runnable showMessageRunnable = new Runnable() {
            public void run() {
                MessageDialog.openInformation(Display.getCurrent().getActiveShell(),
                        Messages.getString("HeaderFilesPage.CompatibilityAnalyser"), //$NON-NLS-1$
                        Messages.getString("HeaderFilesPage.hdrsAlreadyExists")); //$NON-NLS-1$
            }
        };
        Display.getDefault().asyncExec(showMessageRunnable);
    }

    else if (numOfFiles.size() == 0) {
        Runnable showMessageRunnable = new Runnable() {
            public void run() {
                MessageDialog.openInformation(Display.getCurrent().getActiveShell(),
                        Messages.getString("HeaderFilesPage.CompatibilityAnalyser"), //$NON-NLS-1$
                        Messages.getString("HeaderFilesPage.NoHdrsExists")); //$NON-NLS-1$
            }
        };
        Display.getDefault().asyncExec(showMessageRunnable);
    } else {
        addDialog.fileNamesList = addDialog.filesList.getItems();
    }

}

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

License:Open Source License

public void widgetSelected(SelectionEvent e) {

    if (e.widget == saveBtn) {
        if (profileCmb.getText().length() == 0) {
            MessageDialog.openError(Display.getCurrent().getActiveShell(),
                    Messages.getString("BaselineEditor.Error"), //$NON-NLS-1$
                    Messages.getString("BaselineEditor.ProfileNameMustNotBeEmpty")); //$NON-NLS-1$
            return;
        }/*from   w ww .ja v a  2  s .c  om*/

        String profileName = profileCmb.getText();
        Object profile = BaselineProfileUtils.getBaselineProfileData(profileName);
        if (profile instanceof BaselineProfile && ((BaselineProfile) profile).isPredefined()) {
            prevData.saveValue(SavingUserData.ValueTypes.PROFILENAME, profileCmb.getText());
            shell.getParent().dispose();
            return;
        }

        if (isProfileDataCorrect()) {
            if (profileCmb.indexOf(profileCmb.getText()) != -1) {
                String[] str = { Messages.getString("BaselineEditor.Yes"), //$NON-NLS-1$
                        Messages.getString("BaselineEditor.69"), Messages.getString("BaselineEditor.No") }; //$NON-NLS-1$ //$NON-NLS-2$
                MessageDialog dlg = new MessageDialog(Display.getCurrent().getActiveShell(),
                        Messages.getString("BaselineEditor.Confirmation"), null, //$NON-NLS-1$
                        Messages.getString("BaselineEditor.ThisProfileAlreadyExists"), MessageDialog.QUESTION, //$NON-NLS-1$
                        str, 0);
                dlg.create();
                int res = dlg.open();
                if (res == 0) {
                    saveProfile();
                    prevData.saveValue(SavingUserData.ValueTypes.PROFILENAME, profileCmb.getText());
                }
            } else {
                saveProfile();
                prevData.saveValue(SavingUserData.ValueTypes.PROFILENAME, profileCmb.getText());
            }

            //Delete the project, if the profile is created by using blf.inf 
            try {
                if (selectedProj != null) {
                    prevData.saveValue(SavingUserData.ValueTypes.BLDINF_PATH, bldInfPath.getText());
                    if (selectedProj.exists() && projDeletionReq) {
                        selectedProj.delete(IResource.NEVER_DELETE_PROJECT_CONTENT, null);
                        projDeletionReq = false;
                    }
                }
            } catch (Exception ex) {
                ex.printStackTrace();
            }
            shell.getParent().dispose();
        }
    } else if (e.widget == deleteBtn) {
        String[] str = { Messages.getString("BaselineEditor.Yes"), Messages.getString("BaselineEditor.No2"),
                Messages.getString("BaselineEditor.Cancel") };
        MessageDialog dlg = new MessageDialog(Display.getCurrent().getActiveShell(),
                Messages.getString("BaselineEditor.Confirmation"), null,
                Messages.getString("BaselineEditor.DoUWantToDeleteTheProfile") + profileCmb.getText() + "'?",
                MessageDialog.QUESTION, str, 0);
        dlg.create();
        int res = dlg.open();
        if (res == 0) {
            BaselineProfileUtils.deleteProfile(profileCmb.getText());
            shell.getParent().dispose();
        }
    } else if (e.widget == cancelBtn) {
        try {
            if (selectedProj != null && selectedProj.exists() && projDeletionReq) {
                selectedProj.delete(IResource.NEVER_DELETE_PROJECT_CONTENT, null);
                projDeletionReq = false;
            }
        } catch (Exception ex) {
            ex.printStackTrace();
        }
        shell.getParent().dispose();
    } else if (e.widget == profileCmb) {
        Object obj = BaselineProfileUtils.getBaselineProfileData(profileCmb.getText());
        if (obj instanceof BaselineProfile) {
            BaselineProfile pro = (BaselineProfile) obj;
            if (!pro.isPredefined())
                openBaselineProfileIfExists(profileCmb.getText());
            else {
                if (!pro.isUpdated()) {
                    targetPath = "c:\\apps\\ca-baselines\\" + pro.getProfileName();
                    targetURL = pro.getSdkUrl();

                    IRunnableWithProgress op = new IRunnableWithProgress() {
                        public void run(IProgressMonitor monitor) {
                            if (new File(targetPath).exists())
                                FileMethods.deleteFolder(targetPath);
                            downloadStatus = CompatibilityAnalyserEngine.downloadAndExtractFileFromWebServer(
                                    targetURL, targetPath, CompatibilityAnalyserEngine.ElementTypes.FolderType,
                                    "include", monitor);
                        }
                    };
                    IWorkbench wb = PlatformUI.getWorkbench();
                    IWorkbenchWindow win = wb.getActiveWorkbenchWindow();
                    Shell shell = win != null ? win.getShell() : null;
                    try {
                        new ProgressMonitorDialog(shell).run(true, true, op);
                    } catch (InvocationTargetException err) {
                        err.printStackTrace();
                    } catch (InterruptedException err) {
                        err.printStackTrace();
                    }

                    if (downloadStatus == null) {
                        File epocRoot = new File(CompatibilityAnalyserEngine.getEpocFolderPath());
                        BaselineProfile profile = (BaselineProfile) obj;
                        profile.setSdkName(profile.getProfileName());
                        profile.setRadio_default_hdr(true);
                        profile.setRadio_dir_hdr(false);
                        profile.setRadio_default_build_target(true);
                        profile.setRadio_build_target(false);
                        profile.setRadio_dir_libs(false);
                        profile.setSdkEpocRoot(
                                FileMethods.appendPathSeparator(epocRoot.getParentFile().getAbsolutePath()));
                        profile.setUpdated(true);
                        BaselineProfileUtils.saveProfileOnFileSystem(profile);
                        openBaselineProfileIfExists(profileCmb.getText());
                        prevData.saveValue(SavingUserData.ValueTypes.PROFILENAME, profile.getProfileName());
                    } else {
                        openBaselineProfileIfExists(null);
                        MessageDialog.openError(this.getShell(), "Compatibility Analyser", downloadStatus);
                        downloadStatus = null;
                    }
                }
                openBaselineProfileIfExists(pro.getProfileName());
            }
        }
        hdrGrp.layout();
        shell.layout();
    } else if (e.widget == sdkCmb) {
        sdkrootLbl.setText(sdkItems[sdkCmb.getSelectionIndex()].getEPOCROOT());
        if (versionCmb
                .indexOf(sdkItems[sdkCmb.getSelectionIndex()].getSDKVersion().toString().substring(0, 3)) != -1)
            versionCmb.select(versionCmb
                    .indexOf(sdkItems[sdkCmb.getSelectionIndex()].getSDKVersion().toString().substring(0, 3)));
        else
            versionCmb.setText(""); //$NON-NLS-1$

        String[] platformsList = CompatibilityAnalyserUtils
                .getPlatformList(sdkItems[sdkCmb.getSelectionIndex()]);

        if (platformsList != null)
            list_build_Config.setItems(platformsList);

        if (list_build_Config.getItemCount() > 0) {
            int i = list_build_Config.indexOf(Messages.getString("BaselineEditor.armv5")); //$NON-NLS-1$
            if (i != -1)
                list_build_Config.select(i);
            else
                list_build_Config.select(0);

            String selected = list_build_Config.getItem(list_build_Config.getSelectionIndex());
            radio_build_target.setText(Messages.getString("BaselineEditor.UseLibrariesUnder") + selected //$NON-NLS-1$
                    + Messages.getString("BaselineEditor.BuildConfig")); //$NON-NLS-1$
        }
        if (infCheck.getSelection() && bldInfPath.getText().length() != 0) {
            String bldPath = bldInfPath.getText();

            File bldFile = new File(bldPath);
            File Project = bldFile.getParentFile().getParentFile();

            userFiles = new ArrayList<File>();
            systemFiles = new ArrayList<File>();

            projName = Project.getName();
            projLocation = Project.getAbsolutePath();

            projExists = false;

            selectedSdk = sdkItems[sdkCmb.getSelectionIndex()];

            IRunnableWithProgress runnable = new IRunnableWithProgress() {
                public void run(IProgressMonitor monitor) {
                    try {

                        isCancelled = false;
                        selectedProj = ResourcesPlugin.getWorkspace().getRoot()
                                .getProject("CompatibilityAnalyser_" + projName);
                        if (selectedProj.exists()) {
                            projExists = true;
                        } else {
                            for (IProject wsProj : ResourcesPlugin.getWorkspace().getRoot().getProjects()) {
                                projLocation = FileMethods.convertForwardToBackwardSlashes(projLocation);
                                if (FileMethods.convertForwardToBackwardSlashes(wsProj.getLocation().toString())
                                        .equals(projLocation)) {
                                    projExists = true;
                                    selectedProj = wsProj;
                                    break;
                                }
                            }
                        }

                        java.util.List<ISymbianBuildContext> buildList = selectedSdk
                                .getFilteredBuildConfigurations();

                        if (projExists) {
                            monitor.beginTask("Reading system includes using selected SDK Configuration ...",
                                    10);
                            selectedProj.open(null);
                            ICarbideBuildManager buildMgr = CarbideBuilderPlugin.getBuildManager();
                            ICarbideProjectModifier modifier = buildMgr.getProjectModifier(selectedProj);

                            monitor.worked(2);

                            if (monitor.isCanceled()) {
                                isCancelled = true;
                                monitor.done();
                                return;
                            }
                            ICarbideProjectInfo projectInfo = buildMgr.getProjectInfo(selectedProj);
                            ICarbideBuildConfiguration origConf = projectInfo.getDefaultConfiguration();

                            ICarbideBuildConfiguration configTobeSet = null;
                            configTobeSet = modifier.createNewConfiguration(buildList.get(0), true);

                            configTobeSet.saveConfiguration(false);
                            modifier.setDefaultConfiguration(configTobeSet);
                            modifier.saveChanges();

                            monitor.worked(5);
                            if (monitor.isCanceled()) {
                                modifier.setDefaultConfiguration(origConf);
                                modifier.saveChanges();
                                monitor.done();

                                return;
                            }

                            if (projectInfo != null) {
                                EpocEngineHelper.getProjectIncludePaths(projectInfo,
                                        projectInfo.getDefaultConfiguration(), userFiles, systemFiles);
                                getExportPathsAndFiles(projectInfo, userFiles);
                                srcRoots = CompatibilityAnalyserEngine.getIncludesFromSrcFiles(selectedProj)
                                        .toArray(new String[0]);
                            }

                            monitor.worked(8);
                            modifier.setDefaultConfiguration(origConf);
                            modifier.saveChanges();

                            monitor.worked(10);
                            if (monitor.isCanceled())
                                isCancelled = true;
                            monitor.done();
                        } else {
                            monitor.beginTask("Getting system includes using selected SDK Configuration...",
                                    10);
                            selectedProj = ProjectCorePlugin.createProject(projName, projLocation);
                            projDeletionReq = true;

                            monitor.worked(2);

                            if (monitor.isCanceled()) {
                                isCancelled = true;
                                if (selectedProj != null && selectedProj.exists()) {
                                    try {
                                        selectedProj.delete(IResource.NEVER_DELETE_PROJECT_CONTENT, null);
                                    } catch (Exception e1) {
                                        e1.printStackTrace();
                                    }
                                }
                                monitor.done();
                                projDeletionReq = false;
                                return;
                            }
                            java.util.List<String> infsList = new ArrayList<String>();

                            ProjectCorePlugin.postProjectCreatedActions(selectedProj, "group/bld.inf",
                                    buildList, infsList, null, null, new NullProgressMonitor());
                            monitor.worked(5);
                            if (monitor.isCanceled()) {
                                isCancelled = true;
                                if (selectedProj != null && selectedProj.exists()) {
                                    try {
                                        selectedProj.delete(IResource.NEVER_DELETE_PROJECT_CONTENT, null);
                                    } catch (Exception e1) {
                                        e1.printStackTrace();
                                    }
                                }
                                monitor.done();
                                projDeletionReq = false;
                                return;
                            }
                            ICarbideProjectInfo projInfo = CarbideBuilderPlugin.getBuildManager()
                                    .getProjectInfo(selectedProj);

                            if (projInfo != null) {
                                EpocEngineHelper.getProjectIncludePaths(projInfo,
                                        projInfo.getDefaultConfiguration(), userFiles, systemFiles);
                                getExportPathsAndFiles(projInfo, userFiles);
                                monitor.worked(7);
                                srcRoots = CompatibilityAnalyserEngine.getIncludesFromSrcFiles(selectedProj)
                                        .toArray(new String[0]);

                                monitor.worked(9);
                                if (monitor.isCanceled())
                                    isCancelled = true;
                            }
                            monitor.done();
                        }

                    } catch (CoreException ex) {
                        ex.printStackTrace();
                        try {
                            if (selectedProj != null && selectedProj.exists() && projDeletionReq) {
                                selectedProj.delete(IResource.NEVER_DELETE_PROJECT_CONTENT, null);
                                projDeletionReq = false;
                            }
                            return;
                        } catch (Exception e1) {
                            e1.printStackTrace();
                        }
                    }
                }

            };

            try {
                new ProgressMonitorDialog(this.shell.getShell()).run(true, true, runnable);
            } catch (Exception ex) {
                ex.printStackTrace();
            }

            String[] sysIncludes = new String[systemFiles.size()];
            int s = 0;

            if (isCancelled)
                return;

            for (File f : systemFiles) {
                sysIncludes[s] = f.toString();
                s++;
            }
            if (srcRoots != null && srcRoots.length > 0) {
                forced_hdrs_list.setItems(srcRoots);
            }

            if (userFiles.size() > 0) {
                ArrayList<String> userIncludes = new ArrayList<String>();

                for (int i = 0; i < userFiles.size(); i++) {
                    if (userFiles.get(i).exists())
                        userIncludes
                                .add(FileMethods.convertForwardToBackwardSlashes(userFiles.get(i).toString()));
                }
                Event modEvent = new Event();
                modEvent.type = SWT.Selection;
                radio_Hdr_dir.setSelection(true);
                hdr_dir_list.setItems(userIncludes.toArray(new String[0]));
                hdr_dir_list.select(0);
                radio_Hdr_dir.notifyListeners(SWT.Selection, modEvent);

            }
            if (sysIncludes.length > 0) {
                list_systemInc.setItems(sysIncludes);
                removeBtn_sysIncGrp.setEnabled(true);
                removeAllBtn_sysIncGrp.setEnabled(true);
                list_systemInc.select(0);
            }
            updateButtons();
            return;
        }
    } else if (e.widget == addBtn_hdrGrp) {
        DirectoryDialog dirDlg = new DirectoryDialog(Display.getDefault().getActiveShell());
        String dirName = null;
        if ((dirName = dirDlg.open()) != null) {
            hdr_dir_list.add(dirName);
            hdr_dir_list.select(0);
            updateButtons();
        } else
            return;

    } else if (e.widget == removeBtn_hdrGrp) {
        hdr_dir_list.remove(hdr_dir_list.getSelectionIndices());
        hdr_dir_list.select(0);
        updateButtons();
    } else if (e.widget == removeAllBtn_hdrGrp) {
        hdr_dir_list.removeAll();
        updateButtons();
    } else if (e.widget == addDsoDir_btn) {
        DirectoryDialog dirDlg = new DirectoryDialog(Display.getDefault().getActiveShell());
        String dirName = null;
        if ((dirName = dirDlg.open()) != null) {
            dso_dir_list.add(dirName);
            dso_dir_list.select(0);
            updateButtons();
        } else
            return;
    } else if (e.widget == addDllDir_btn) {
        DirectoryDialog dirDlg = new DirectoryDialog(Display.getDefault().getActiveShell());
        String dirName = null;
        if ((dirName = dirDlg.open()) != null) {
            dll_dir_list.add(dirName);
            dll_dir_list.select(0);
            updateButtons();
        } else
            return;
    } else if (e.widget == removeDsoDir_Btn) {
        dso_dir_list.remove(dso_dir_list.getSelectionIndices());
        dso_dir_list.select(0);
        updateButtons();
    } else if (e.widget == removeDllDir_btn) {
        dll_dir_list.remove(dll_dir_list.getSelectionIndices());
        dll_dir_list.select(0);
        updateButtons();
    } else if (e.widget == removeAllDsoDirs_Btn) {
        dso_dir_list.removeAll();
        updateButtons();
    } else if (e.widget == removeAllDllDir_Btn) {
        dll_dir_list.removeAll();
        updateButtons();
    } else if (e.widget == addBtn_sysIncGrp) {
        DirectoryDialog dirDlg = new DirectoryDialog(Display.getDefault().getActiveShell());
        String dirName = null;
        if ((dirName = dirDlg.open()) != null) {
            list_systemInc.add(dirName);
            list_systemInc.select(0);
            updateButtons();
        } else
            return;

    } else if (e.widget == removeBtn_sysIncGrp) {
        list_systemInc.remove(list_systemInc.getSelectionIndices());
        list_systemInc.select(0);
        updateButtons();
    } else if (e.widget == radio_Hdr_dir) {
        GridData d = (GridData) hdr_dirs_comp.getLayoutData();
        d.exclude = !radio_Hdr_dir.getSelection();
        hdr_dirs_comp.setVisible(radio_Hdr_dir.getSelection());

        hdr_dir_list.setEnabled(radio_Hdr_dir.getSelection());
        addBtn_hdrGrp.setEnabled(radio_Hdr_dir.getSelection());
        updateButtons();
    } else if (e.widget == radio_dir_Libs || e.widget == radio_build_target) {
        //dso_dir_list.setEnabled(radio_dir_Libs.getSelection());

        addDsoDir_btn.setEnabled(radio_dir_Libs.getSelection());
        addDllDir_btn.setEnabled(radio_dir_Libs.getSelection());

        //removeDsoDir_Btn.setEnabled(radio_dir_Libs.getSelection());
        //removeAllDsoDirs_Btn.setEnabled(radio_dir_Libs.getSelection());
        //list_build_Config.setEnabled(!radio_dir_Libs.getSelection());

        GridData data = (GridData) list_build_Config.getLayoutData();
        data.exclude = !radio_build_target.getSelection();
        list_build_Config.setVisible(radio_build_target.getSelection());

        GridData data2 = (GridData) dllPaths_Folder.getLayoutData();
        data2.exclude = !radio_dir_Libs.getSelection();
        dllPaths_Folder.setVisible(radio_dir_Libs.getSelection());

        dllPaths_Folder.getParent().layout(false);

        updateButtons();
    } else if (e.widget == list_build_Config) {
        if (list_build_Config.getSelectionCount() > 1)
            radio_build_target.setText("Use libraries under selected build configurations");
        else {
            String selected = list_build_Config.getItem(list_build_Config.getSelectionIndex());
            radio_build_target.setText(Messages.getString("BaselineEditor.UseLibrariesUnder") + selected //$NON-NLS-1$
                    + Messages.getString("BaselineEditor.BuildConfig")); //$NON-NLS-1$
        }
    } else if (e.widget == removeAllBtn_sysIncGrp) {
        list_systemInc.removeAll();
        updateButtons();
    } else if (e.widget == browseBld) {
        FileDialog dialog = new FileDialog(Display.getDefault().getActiveShell());
        dialog.setFilterExtensions(new String[] { "*.inf" });
        String fileName = null;

        if ((fileName = dialog.open()) != null) {
            bldInfPath.add(fileName, 0);
            bldInfPath.select(0);

            Event event = new Event();
            event.type = SWT.Selection;
            bldInfPath.notifyListeners(SWT.Selection, event);
        }
    } else if (e.widget == infCheck) {
        projExists = false;
        if (infCheck.getSelection()) {
            bldInfPath.setEnabled(true);
            browseBld.setEnabled(true);

            if (bldInfPath.getText().length() > 0) {
                userFiles = new ArrayList<File>();
                systemFiles = new ArrayList<File>();

                bldPath = bldInfPath.getText();
                selectedSdk = sdkItems[sdkCmb.getSelectionIndex()];

                File bldFile = new File(bldPath);
                File Project = bldFile.getParentFile().getParentFile();

                if (!bldFile.exists()) {
                    MessageDialog.openInformation(Display.getCurrent().getActiveShell(),
                            Messages.getString("HeaderFilesPage.CompatibilityAnalyser"),
                            "Given Bld.inf does not exist. Please provide a valid path");
                    return;
                }

                projName = Project.getName();
                projLocation = Project.getAbsolutePath();

                IRunnableWithProgress runnable = new IRunnableWithProgress() {
                    public void run(IProgressMonitor monitor) {
                        try {
                            isCancelled = false;
                            selectedProj = ResourcesPlugin.getWorkspace().getRoot()
                                    .getProject("CompatibilityAnalyser_" + projName);
                            if (selectedProj.exists()) {
                                projExists = true;
                            } else {
                                for (IProject wsProj : ResourcesPlugin.getWorkspace().getRoot().getProjects()) {
                                    projLocation = FileMethods.convertForwardToBackwardSlashes(projLocation);
                                    if (FileMethods
                                            .convertForwardToBackwardSlashes(wsProj.getLocation().toString())
                                            .equals(projLocation)) {
                                        projExists = true;
                                        selectedProj = wsProj;
                                        break;
                                    }
                                }
                            }

                            java.util.List<ISymbianBuildContext> buildList = selectedSdk
                                    .getFilteredBuildConfigurations();
                            java.util.List<String> infsList = new ArrayList<String>();

                            if (!projExists) {
                                monitor.beginTask("Getting Project Info", 10);
                                selectedProj = ProjectCorePlugin
                                        .createProject("CompatibilityAnalyser_" + projName, projLocation);
                                projDeletionReq = true;
                                monitor.worked(2);

                                if (monitor.isCanceled()) {
                                    isCancelled = true;
                                    if (selectedProj != null && selectedProj.exists()) {
                                        try {
                                            selectedProj.delete(IResource.NEVER_DELETE_PROJECT_CONTENT, null);
                                        } catch (Exception e1) {
                                            e1.printStackTrace();
                                        }
                                    }
                                    monitor.done();
                                    projDeletionReq = false;
                                    return;
                                }

                                ProjectCorePlugin.postProjectCreatedActions(selectedProj, "group/bld.inf",
                                        buildList, infsList, null, null, monitor);
                                monitor.worked(5);

                                if (monitor.isCanceled()) {
                                    isCancelled = true;
                                    if (selectedProj != null && selectedProj.exists()) {
                                        try {
                                            selectedProj.delete(IResource.NEVER_DELETE_PROJECT_CONTENT, null);
                                        } catch (Exception e1) {
                                            e1.printStackTrace();
                                        }
                                    }
                                    monitor.done();
                                    projDeletionReq = false;
                                    return;
                                }
                                ICarbideProjectInfo projInfo = CarbideBuilderPlugin.getBuildManager()
                                        .getProjectInfo(selectedProj);

                                if (projInfo != null) {

                                    EpocEngineHelper.getProjectIncludePaths(projInfo,
                                            projInfo.getDefaultConfiguration(), userFiles, systemFiles);
                                    getExportPathsAndFiles(projInfo, userFiles);
                                    monitor.worked(7);
                                    srcRoots = CompatibilityAnalyserEngine.getIncludesFromSrcFiles(selectedProj)
                                            .toArray(new String[0]);

                                    monitor.worked(9);
                                    if (monitor.isCanceled())
                                        isCancelled = true;
                                }
                                monitor.done();
                            } else {
                                monitor.beginTask("Reading Project Info..", 10);
                                selectedProj.open(null);
                                monitor.worked(2);

                                if (monitor.isCanceled()) {
                                    isCancelled = true;
                                    monitor.done();
                                    return;
                                }
                                ICarbideProjectInfo projInfo = CarbideBuilderPlugin.getBuildManager()
                                        .getProjectInfo(selectedProj);

                                ICarbideBuildManager manager = CarbideBuilderPlugin.getBuildManager();
                                ICarbideProjectModifier modifier = manager.getProjectModifier(selectedProj);

                                ICarbideBuildConfiguration origConf = projInfo.getDefaultConfiguration();

                                ICarbideBuildConfiguration configTobeSet = null;
                                java.util.List<ISymbianBuildContext> all = selectedSdk
                                        .getFilteredBuildConfigurations();
                                configTobeSet = modifier.createNewConfiguration(all.get(0), true);
                                configTobeSet.saveConfiguration(false);
                                modifier.setDefaultConfiguration(configTobeSet);
                                modifier.saveChanges();

                                if (monitor.isCanceled()) {
                                    isCancelled = true;
                                    modifier.setDefaultConfiguration(origConf);
                                    modifier.saveChanges();

                                    monitor.done();
                                    return;
                                }
                                monitor.worked(5);

                                if (projInfo != null) {

                                    EpocEngineHelper.getProjectIncludePaths(projInfo,
                                            projInfo.getDefaultConfiguration(), userFiles, systemFiles);
                                    getExportPathsAndFiles(projInfo, userFiles);
                                    srcRoots = CompatibilityAnalyserEngine.getIncludesFromSrcFiles(selectedProj)
                                            .toArray(new String[0]);
                                }

                                monitor.worked(8);
                                modifier.setDefaultConfiguration(origConf);
                                modifier.saveChanges();

                                if (monitor.isCanceled())
                                    isCancelled = true;

                                monitor.worked(10);

                                monitor.done();
                            }

                        } catch (CoreException ex) {
                            ex.printStackTrace();
                            try {
                                if (selectedProj != null && selectedProj.exists() && projDeletionReq) {
                                    selectedProj.delete(IResource.NEVER_DELETE_PROJECT_CONTENT, null);
                                    projDeletionReq = false;
                                }
                                return;
                            } catch (Exception e1) {
                                e1.printStackTrace();
                            }
                        }
                    }

                };

                try {
                    new ProgressMonitorDialog(this.shell.getShell()).run(true, true, runnable);
                } catch (Exception ex) {
                    ex.printStackTrace();
                }

                if (isCancelled)
                    return;

                if (srcRoots != null && srcRoots.length > 0) {
                    forced_hdrs_list.setItems(srcRoots);
                }

                if (systemFiles != null && systemFiles.size() > 0) {
                    String[] sysIncludes = new String[systemFiles.size()];

                    for (int i = 0; i < systemFiles.size(); i++)
                        sysIncludes[i] = systemFiles.get(i).toString();

                    list_systemInc.setItems(sysIncludes);
                    list_systemInc.select(0);
                    removeBtn_sysIncGrp.setEnabled(true);
                    removeAllBtn_sysIncGrp.setEnabled(true);
                }
                if (userFiles != null && userFiles.size() > 0) {
                    ArrayList<String> userIncludes = new ArrayList<String>();

                    for (int i = 0; i < userFiles.size(); i++) {
                        if (userFiles.get(i).exists())
                            userIncludes.add(
                                    FileMethods.convertForwardToBackwardSlashes(userFiles.get(i).toString()));
                    }

                    radio_default_Hdr.setSelection(false);
                    radio_Hdr_dir.setSelection(true);
                    hdr_dir_list.setItems(userIncludes.toArray(new String[0]));
                    hdr_dir_list.select(0);
                    Event selEvent = new Event();
                    selEvent.type = SWT.Selection;
                    radio_Hdr_dir.notifyListeners(SWT.Selection, selEvent);
                }
            }
        }

        else {
            bldInfPath.setEnabled(false);
            browseBld.setEnabled(false);

            if (bldInfPath.getText().length() > 0) {
                Event modEvent = new Event();
                modEvent.type = SWT.Selection;
                radio_default_Hdr.setSelection(true);
                radio_Hdr_dir.setSelection(false);
                list_systemInc.removeAll();
                hdr_dir_list.removeAll();
                forced_hdrs_list.removeAll();

                radio_default_Hdr.notifyListeners(SWT.Selection, modEvent);
            }
        }
    } else if (e.widget == bldInfPath) {
        radio_default_Hdr.setSelection(true);
        radio_Hdr_dir.setSelection(false);
        list_systemInc.removeAll();
        forced_hdrs_list.removeAll();

        Event modEvent = new Event();
        modEvent.type = SWT.Selection;
        radio_default_Hdr.notifyListeners(SWT.Selection, modEvent);

        bldPath = bldInfPath.getText();
        selectedSdk = sdkItems[sdkCmb.getSelectionIndex()];
        projExists = false;
        if (bldPath.length() > 0 && infCheck.getSelection()) {
            userFiles = new ArrayList<File>();
            systemFiles = new ArrayList<File>();

            File bldFile = new File(bldPath);
            File Project = bldFile.getParentFile().getParentFile();

            if (!bldFile.exists()) {
                MessageDialog.openInformation(Display.getCurrent().getActiveShell(),
                        Messages.getString("HeaderFilesPage.CompatibilityAnalyser"),
                        "Given Bld.inf does not exist. Please provide a valid path");
                return;
            }
            if (!bldFile.getName().equalsIgnoreCase("bld.inf")) {
                return;
            }
            projName = Project.getName();
            projLocation = Project.getAbsolutePath();

            if (selectedProj != null && selectedProj.exists() && projDeletionReq) {
                try {
                    selectedProj.delete(IResource.NEVER_DELETE_PROJECT_CONTENT, null);
                } catch (Exception e1) {
                    e1.printStackTrace();
                }

                projDeletionReq = false;
            }

            IRunnableWithProgress runP = new IRunnableWithProgress() {
                public void run(IProgressMonitor monitor) {
                    try {

                        isCancelled = false;

                        selectedProj = ResourcesPlugin.getWorkspace().getRoot()
                                .getProject("CompatibilityAnalyser_" + projName);

                        if (selectedProj.exists()) {
                            projExists = true;
                        } else {

                            for (IProject wsProj : ResourcesPlugin.getWorkspace().getRoot().getProjects()) {
                                if (FileMethods.convertForwardToBackwardSlashes(wsProj.getLocation().toString())
                                        .equals(FileMethods.convertForwardToBackwardSlashes(projLocation))) {
                                    projExists = true;
                                    selectedProj = wsProj;
                                    break;
                                }
                            }
                        }

                        java.util.List<ISymbianBuildContext> buildList = selectedSdk
                                .getFilteredBuildConfigurations();
                        java.util.List<String> infsList = new ArrayList<String>();

                        if (!projExists) {
                            monitor.beginTask("Getting Project Info...", 10);
                            selectedProj = ProjectCorePlugin.createProject("CompatibilityAnalyser_" + projName,
                                    projLocation);
                            projDeletionReq = true;
                            monitor.worked(2);

                            if (monitor.isCanceled()) {
                                isCancelled = true;
                                if (selectedProj != null && selectedProj.exists()) {
                                    try {
                                        selectedProj.delete(IResource.NEVER_DELETE_PROJECT_CONTENT, null);
                                    } catch (Exception e1) {
                                        e1.printStackTrace();
                                    }
                                }
                                monitor.done();
                                projDeletionReq = false;
                                return;
                            }

                            ProjectCorePlugin.postProjectCreatedActions(selectedProj, "group/bld.inf",
                                    buildList, infsList, null, null, monitor);

                            if (monitor.isCanceled()) {
                                isCancelled = true;
                                if (selectedProj != null && selectedProj.exists()) {
                                    try {
                                        selectedProj.delete(IResource.NEVER_DELETE_PROJECT_CONTENT, null);
                                    } catch (Exception e1) {
                                        e1.printStackTrace();
                                    }
                                }
                                monitor.done();
                                projDeletionReq = false;

                                return;
                            }
                            monitor.worked(5);
                            ICarbideProjectInfo projInfo = CarbideBuilderPlugin.getBuildManager()
                                    .getProjectInfo(selectedProj);

                            if (projInfo != null) {

                                EpocEngineHelper.getProjectIncludePaths(projInfo,
                                        projInfo.getDefaultConfiguration(), userFiles, systemFiles);
                                getExportPathsAndFiles(projInfo, userFiles);
                                monitor.worked(7);

                                srcRoots = CompatibilityAnalyserEngine.getIncludesFromSrcFiles(selectedProj)
                                        .toArray(new String[0]);

                                monitor.worked(9);
                                if (monitor.isCanceled())
                                    isCancelled = true;
                            }
                            monitor.done();
                        } else {
                            monitor.beginTask("Reading Project Info..", 10);
                            selectedProj.open(null);
                            monitor.worked(2);

                            if (monitor.isCanceled()) {
                                isCancelled = true;
                                monitor.done();
                                return;
                            }
                            ICarbideProjectInfo projInfo = CarbideBuilderPlugin.getBuildManager()
                                    .getProjectInfo(selectedProj);

                            ICarbideBuildManager manager = CarbideBuilderPlugin.getBuildManager();
                            ICarbideProjectModifier modifier = manager.getProjectModifier(selectedProj);

                            ICarbideBuildConfiguration origConf = projInfo.getDefaultConfiguration();

                            ICarbideBuildConfiguration configTobeSet = null;

                            configTobeSet = modifier.createNewConfiguration(buildList.get(0), true);
                            configTobeSet.saveConfiguration(false);
                            modifier.setDefaultConfiguration(configTobeSet);
                            modifier.saveChanges();

                            if (monitor.isCanceled()) {
                                isCancelled = true;
                                monitor.done();
                                modifier.setDefaultConfiguration(origConf);
                                modifier.saveChanges();

                                return;
                            }
                            monitor.worked(5);
                            if (projInfo != null) {
                                EpocEngineHelper.getProjectIncludePaths(projInfo,
                                        projInfo.getDefaultConfiguration(), userFiles, systemFiles);
                                getExportPathsAndFiles(projInfo, userFiles);
                                srcRoots = CompatibilityAnalyserEngine.getIncludesFromSrcFiles(selectedProj)
                                        .toArray(new String[0]);
                            }
                            if (monitor.isCanceled()) {
                                isCancelled = true;
                                monitor.done();
                            }
                            monitor.worked(8);
                            modifier.setDefaultConfiguration(origConf);
                            modifier.saveChanges();
                            monitor.worked(10);
                            monitor.done();
                        }

                    } catch (CoreException ex) {
                        ex.printStackTrace();
                        try {
                            if (selectedProj != null && selectedProj.exists() && projDeletionReq) {
                                selectedProj.delete(IResource.NEVER_DELETE_PROJECT_CONTENT, null);
                                projDeletionReq = false;
                            }
                            return;
                        } catch (Exception e1) {
                            e1.printStackTrace();
                        }
                    }
                }

            };
            try {
                new ProgressMonitorDialog(this.shell.getShell()).run(true, true, runP);
            } catch (Exception ex) {
                ex.printStackTrace();
            }

            if (isCancelled)
                return;

            if (srcRoots != null && srcRoots.length > 0) {
                Event eve = new Event();
                eve.type = SWT.Selection;
                forced_hdrs_list.setItems(srcRoots);
            }
            if (userFiles != null && userFiles.size() > 0) {
                ArrayList<String> userIncludes = new ArrayList<String>();

                for (int i = 0; i < userFiles.size(); i++) {
                    if (userFiles.get(i).exists())
                        userIncludes
                                .add(FileMethods.convertForwardToBackwardSlashes(userFiles.get(i).toString()));
                }

                radio_default_Hdr.setSelection(false);
                radio_Hdr_dir.setSelection(true);
                hdr_dir_list.setItems(userIncludes.toArray(new String[0]));
                hdr_dir_list.select(0);
                Event selEvent = new Event();
                selEvent.type = SWT.Selection;
                radio_Hdr_dir.notifyListeners(SWT.Selection, selEvent);
            }

            if (systemFiles != null && systemFiles.size() > 0) {
                String[] sysIncludes = new String[systemFiles.size()];

                for (int i = 0; i < systemFiles.size(); i++)
                    sysIncludes[i] = systemFiles.get(i).toString();

                list_systemInc.setItems(sysIncludes);
                list_systemInc.select(0);
                removeBtn_sysIncGrp.setEnabled(true);
                removeAllBtn_sysIncGrp.setEnabled(true);
            }
        }
    } else if (e.widget == forced_addBtn) {
        displayFiles = new ArrayList<String>();
        numOfFiles = new ArrayList<String>();
        children = new ArrayList<String>();
        subChildren = new ArrayList<String>();
        isMonitorCancelled = false;

        if (list_systemInc.getItemCount() > 0) {
            ArrayList<String> paths = new ArrayList<String>(Arrays.asList(list_systemInc.getItems()));
            paths.add(FileMethods.appendPathSeparator(sdkrootLbl.getText()) + "epoc32" + File.separator
                    + "include" + File.separator);
            addDialog = new ShowFilesListDialog(Display.getCurrent().getActiveShell(), forced_hdrs_list, this,
                    "", true);
            allSysIncHdrPaths = paths.toArray(new String[paths.size()]);
            IRunnableWithProgress op = new IRunnableWithProgress() {
                public void run(IProgressMonitor monitor) {
                    try {
                        int i = 1;
                        for (String path : allSysIncHdrPaths) {
                            absolutePath = FileMethods.convertForwardToBackwardSlashes(path);
                            monitor.beginTask("Getting files from " + absolutePath, allSysIncHdrPaths.length);
                            getFiles(absolutePath, monitor);
                            getFilesFromSubDirs(absolutePath, monitor);
                            monitor.worked(i++);
                        }
                        monitor.done();

                    } catch (Exception e1) {
                        e1.printStackTrace();
                    }
                }
            };

            try {
                IWorkbench wb = PlatformUI.getWorkbench();
                IWorkbenchWindow win = wb.getActiveWorkbenchWindow();
                Shell shell = win != null ? win.getShell() : null;
                progDlg = new ProgressMonitorDialog(shell);
                progDlg.run(true, true, op);
                progDlg.setBlockOnOpen(true);
            } catch (InvocationTargetException err) {
                err.printStackTrace();
            } catch (InterruptedException err) {
                err.printStackTrace();
            }
        } else {
            addDialog = new ShowFilesListDialog(Display.getCurrent().getActiveShell(), forced_hdrs_list, this,
                    FileMethods.appendPathSeparator(sdkrootLbl.getText()) + "epoc32" + File.separator
                            + "include" + File.separator,
                    true);
            absolutePath = FileMethods.appendPathSeparator(sdkrootLbl.getText()) + "epoc32" + File.separator
                    + "include" + File.separator;
            IRunnableWithProgress op = new IRunnableWithProgress() {
                public void run(IProgressMonitor monitor) {
                    try {
                        addFiles_monitor = monitor;
                        monitor.beginTask("Getting files from " + absolutePath, 10);
                        getFiles(absolutePath, monitor);
                        addFiles_monitor.worked(5);
                        getFilesFromSubDirs(absolutePath, monitor);
                        monitor.done();
                    } catch (Exception e1) {
                        e1.printStackTrace();
                    }
                }
            };

            try {
                IWorkbench wb = PlatformUI.getWorkbench();
                IWorkbenchWindow win = wb.getActiveWorkbenchWindow();
                Shell shell = win != null ? win.getShell() : null;
                progDlg = new ProgressMonitorDialog(shell);
                progDlg.run(true, true, op);
                progDlg.setBlockOnOpen(true);
            } catch (InvocationTargetException err) {
                err.printStackTrace();
            } catch (InterruptedException err) {
                err.printStackTrace();
            }
        }

        if (!isMonitorCancelled) {
            if (numOfFiles.size() != forced_hdrs_list.getItemCount())
                for (String name : numOfFiles)
                    if (!isPreviouslySelected(name))
                        displayFiles.add(name);

            if (displayFiles.size() != 0) {
                Collections.sort(displayFiles);
                addDialog.children = children;
                addDialog.subChildren = subChildren;
                addDialog.open();
                addDialog.filesList.setItems(displayFiles.toArray(new String[displayFiles.size()]));
                addDialog.filesList.select(0);
            }
        }

        if (isMonitorCancelled) {

        } else if (displayFiles.size() == 0 && numOfFiles.size() != 0) {

            Runnable showMessageRunnable = new Runnable() {
                public void run() {
                    MessageDialog.openInformation(Display.getCurrent().getActiveShell(),
                            Messages.getString("HeaderFilesPage.CompatibilityAnalyser"), //$NON-NLS-1$
                            Messages.getString("HeaderFilesPage.hdrsAlreadyExists")); //$NON-NLS-1$
                }
            };
            Display.getDefault().asyncExec(showMessageRunnable);

        } else if (numOfFiles.size() == 0) {
            Runnable showMessageRunnable = new Runnable() {
                public void run() {
                    MessageDialog.openInformation(Display.getCurrent().getActiveShell(),
                            Messages.getString("HeaderFilesPage.CompatibilityAnalyser"), //$NON-NLS-1$
                            Messages.getString("HeaderFilesPage.NoHdrsExists")); //$NON-NLS-1$
                }
            };
            Display.getDefault().asyncExec(showMessageRunnable);
        } else {
            addDialog.fileNamesList = addDialog.filesList.getItems();
        }
    } else if (e.widget == forced_removeBtn) {
        forced_hdrs_list.remove(forced_hdrs_list.getSelectionIndices());
        forced_hdrs_list.select(0);

        forced_removeBtn.setEnabled(forced_hdrs_list.getItemCount() > 0);
        forced_removeAllBtn.setEnabled(forced_hdrs_list.getItemCount() > 0);
    } else if (e.widget == forced_removeAllBtn) {
        forced_hdrs_list.removeAll();
        forced_removeBtn.setEnabled(false);
        forced_removeAllBtn.setEnabled(false);
    } else if (e.widget == show_btn) {
        GridData data = (GridData) adv_options_comp.getLayoutData();
        data.exclude = false;
        adv_options_comp.setVisible(true);

        ((StackLayout) show_hide_button_comp.getLayout()).topControl = hide_btn;
        show_hide_button_comp.layout();
    } else if (e.widget == hide_btn) {
        GridData data = (GridData) adv_options_comp.getLayoutData();
        data.exclude = true;
        adv_options_comp.setVisible(false);

        ((StackLayout) show_hide_button_comp.getLayout()).topControl = show_btn;
        show_hide_button_comp.layout();
    }

    if (!shell.isDisposed()) {
        hdrGrp.layout();
        shell.layout();
    }
}