Example usage for org.eclipse.jface.dialogs ProgressMonitorDialog ProgressMonitorDialog

List of usage examples for org.eclipse.jface.dialogs ProgressMonitorDialog ProgressMonitorDialog

Introduction

In this page you can find the example usage for org.eclipse.jface.dialogs ProgressMonitorDialog ProgressMonitorDialog.

Prototype

public ProgressMonitorDialog(Shell parent) 

Source Link

Document

Creates a progress monitor dialog under the given shell.

Usage

From source file:com.nokia.s60tools.compatibilityanalyser.utils.CompatibilityAnalyserUtils.java

License:Open Source License

/**
 * Starts the downloading core tools from web server with progress monitor.
 *//*  w w w . j  a va  2  s  .  c o m*/
public static String initiateDownloadingCoreTools() {
    IRunnableWithProgress op = new IRunnableWithProgress() {
        public void run(IProgressMonitor monitor) {
            IPreferenceStore prefStore = CompatibilityAnalyserPlugin.getCompatabilityAnalyserPrefStore();
            String urlInPref = prefStore.getString(CompatibilityAnalyserPreferencesConstants.CORETOOLS_URL);
            //If core tools were already downloaded from web server earlier, they will be deleted. 
            String previousContents = prefStore
                    .getString(CompatibilityAnalyserPreferencesConstants.PREVIOUS_WEB_CORE_TOOLS_ROOTDIR);
            if (previousContents != null && !previousContents.equals("")) //$NON-NLS-1$
            {
                File oldContents = new File(previousContents);
                if (oldContents.exists())
                    FileMethods.deleteFolder(previousContents);
            }
            String targetPath = FileMethods.appendPathSeparator(CompatibilityAnalyserEngine.getWorkspacePath())
                    + Messages.getString("HeaderAnalyserEngine.WebServerContentsNew"); //$NON-NLS-1$
            String coreToolsExtraction = CompatibilityAnalyserEngine
                    .readAndDownloadSupportedCoretools(urlInPref, targetPath, monitor);
            if (coreToolsExtraction == null) {
                temp = null;
                prefStore.setValue(CompatibilityAnalyserPreferencesConstants.PREVIOUS_WEB_CORE_TOOLS_URL,
                        urlInPref);
                prefStore.setValue(CompatibilityAnalyserPreferencesConstants.PREVIOUS_WEB_CORE_TOOLS_PATH,
                        CompatibilityAnalyserEngine.getWebServerToolsPath());
                prefStore.setValue(CompatibilityAnalyserPreferencesConstants.PREVIOUS_WEB_CORE_TOOLS_ROOTDIR,
                        targetPath);
            } else
                temp = coreToolsExtraction;
        }
    };
    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 e) {
        e.printStackTrace();
        return "Error!";
    } catch (InterruptedException e) {
        e.printStackTrace();
        return "Error!";
    }

    //If download not successful 
    if (temp != null)
        return temp;

    return null;
}

From source file:com.nokia.s60tools.imaker.internal.model.Environment.java

License:Open Source License

public List<UIConfiguration> load() throws InvocationTargetException {
    if (loaded) {
        return configurations;
    }/*  w  ww.ja  v a 2s. c o m*/
    IRunnableWithProgress op = new IMakerCoreRunnable();
    ProgressMonitorDialog progressMonitorDialog = new ProgressMonitorDialog(getDisplay().getActiveShell());
    try {
        progressMonitorDialog.run(true, true, op);
    } catch (InvocationTargetException e) {
        configurations = null;
        loaded = false;
        throw e;
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
    loaded = true;
    return configurations;
}

From source file:com.nokia.s60tools.imaker.internal.model.Environment.java

License:Open Source License

public String getTargetSteps(final String target) {
    targetSteps = null;/*  w w  w .  j  a v a2s . com*/
    ProgressMonitorDialog progressMonitorDialog = new ProgressMonitorDialog(getDisplay().getActiveShell());
    try {
        progressMonitorDialog.run(true, false, new IRunnableWithProgress() {

            //            @Override
            public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                try {
                    targetSteps = wrapper.getTargetSteps(target, getCurrentProduct().getFilePath(), monitor);
                } catch (IMakerCoreExecutionException e) {
                    throw new InvocationTargetException(e);
                }
            }
        });
    } catch (InvocationTargetException e) {
    } catch (InterruptedException e) {
    }
    return targetSteps;
}

From source file:com.nokia.s60tools.imaker.internal.viewers.PreferencesTab.java

License:Open Source License

private void executeRunnable(IRunnableWithProgress op) {
    IWorkbench wb = PlatformUI.getWorkbench();
    IWorkbenchWindow win = wb.getActiveWorkbenchWindow();
    Shell shell = win != null ? win.getShell() : null;
    try {/*  ww w.  j  a  v  a  2 s  . c o  m*/
        ProgressMonitorDialog progressMonitorDialog = new ProgressMonitorDialog(shell);
        progressMonitorDialog.run(true, false, op);
        settingsTab.getTableViewer().refresh();
    } catch (InvocationTargetException e) {
        StatusHandler.handle(IStatus.ERROR, Messages.getString("Error.1"), e.getTargetException()); //$NON-NLS-1$
        e.printStackTrace();
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
}

From source file:com.nokia.s60tools.imaker.UIConfiguration.java

License:Open Source License

public void load() throws Throwable {
    if (loaded) {
        return;// ww  w.j av  a2 s  .co m
    }
    Display display = PlatformUI.getWorkbench().getDisplay();
    IRunnableWithProgress op = new IMakerCoreRunnable();
    ProgressMonitorDialog progressMonitorDialog = new ProgressMonitorDialog(display.getActiveShell());
    try {
        progressMonitorDialog.run(true, false, op);
    } catch (InvocationTargetException e) {
        throw e.getTargetException();
    } catch (InterruptedException e) {
        throw e;
    }
    loaded = true;
}

From source file:com.nokia.s60tools.swmtanalyser.editors.SWMTEditor.java

License:Open Source License

/**
 * Creates Anlysis page in the SWMT Editor
 *
 *///from  w ww  . java2 s .  com
private void createAnalysisPage() {
    Composite parentComposite = new Composite(getContainer(), SWT.NONE);
    parentComposite.setLayout(new FormLayout());

    Composite titleBar = new Composite(parentComposite, SWT.NONE);
    Composite holder = new Composite(parentComposite, SWT.NONE);

    Label graph_title = new Label(titleBar, SWT.CENTER | SWT.BORDER);
    graph_title.setBackground(parentComposite.getDisplay().getSystemColor(SWT.COLOR_DARK_BLUE));
    graph_title.setForeground(parentComposite.getDisplay().getSystemColor(SWT.COLOR_WHITE));

    Font roman_8 = new Font(parentComposite.getDisplay(), "Arial", 10, SWT.BOLD);
    graph_title.setFont(roman_8);
    graph_title.setText("");

    FormData formData = new FormData();
    formData.top = new FormAttachment(0);
    formData.left = new FormAttachment(0);
    formData.right = new FormAttachment(100);
    titleBar.setLayoutData(formData);
    titleBar.setLayout(new FormLayout());

    FormData data = new FormData();
    data.left = new FormAttachment(0);
    data.right = new FormAttachment(100);
    graph_title.setLayoutData(data);

    // FormData for the overall holder composite
    formData = new FormData();
    formData.top = new FormAttachment(titleBar);
    formData.bottom = new FormAttachment(100);
    formData.left = new FormAttachment(0);
    formData.right = new FormAttachment(100);
    holder.setLayoutData(formData);
    holder.setLayout(new FormLayout());

    graphSash = new SashForm(holder, SWT.VERTICAL | SWT.SMOOTH | SWT.BORDER);
    graphSash.SASH_WIDTH = 5;
    graphSash.setLayout(new FillLayout());

    Composite bottomComposite = new SashForm(holder, SWT.VERTICAL);
    final Sash acrossSash = new Sash(holder, SWT.HORIZONTAL);

    formData = new FormData();
    formData.top = new FormAttachment(0);
    formData.bottom = new FormAttachment(acrossSash);
    formData.left = new FormAttachment(0);
    formData.right = new FormAttachment(100);
    graphSash.setLayoutData(formData);
    graphSash.setLayout(new FormLayout());

    // FormData for bottom
    formData = new FormData();
    formData.top = new FormAttachment(acrossSash);
    formData.bottom = new FormAttachment(100);
    formData.left = new FormAttachment(0);
    formData.right = new FormAttachment(100);
    bottomComposite.setLayoutData(formData);
    bottomComposite.setLayout(new FormLayout());

    // FormData for acrossSash
    // Put it initially in the middle
    formData = new FormData();
    formData.top = new FormAttachment(50);
    formData.width = 20;
    formData.left = new FormAttachment(0);
    formData.right = new FormAttachment(100);
    acrossSash.setLayoutData(formData);

    final FormData acrossSashData = formData;
    final Composite parentFinal = acrossSash.getParent();
    acrossSash.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent event) {
            if (event.detail != SWT.DRAG) {
                acrossSashData.top = new FormAttachment(0, event.y);
                parentFinal.layout();
            }
        }
    });

    Composite parent = new Composite(bottomComposite, SWT.NONE);
    parent.setLayout(new GridLayout(7, false));
    parent.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    Label title = new Label(parent, SWT.WRAP);
    title.setText("Linear Analysis Results");
    title.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    //Action button used for creation of report file.
    generate_report_btn = new Button(parent, SWT.PUSH);
    generate_report_btn.setText("Generate report...");
    generate_report_btn.setToolTipText("Click here to generate pdf report for the selected issues.");
    generate_report_btn.addSelectionListener(this);

    Label separator = new Label(parent, SWT.SEPARATOR);
    GridData sepGD = new GridData();
    sepGD.heightHint = 25;
    separator.setLayoutData(sepGD);

    Label severity = new Label(parent, SWT.NONE);
    severity.setText("Severity:");

    severity_label = new Label(parent, SWT.WRAP);
    severity_label.setText("     ");
    GridData d = new GridData(GridData.FILL);
    d.heightHint = 20;
    severity_label.setLayoutData(d);

    severity_combo = new Combo(parent, SWT.BORDER | SWT.READ_ONLY);
    d = new GridData();
    d.widthHint = 100;
    severity_combo.setLayoutData(d);
    severity_combo.setItems(new String[] { "All", AnalyserConstants.Priority.CRITICAL.name(),
            AnalyserConstants.Priority.HIGH.name(), AnalyserConstants.Priority.NORMAL.name(),
            "Custom filter" });
    severity_combo.addSelectionListener(this);
    severity_combo.select(0);
    severity_combo.setToolTipText("Severity of an issue.");

    //Action button used to launch Custom filter dialog.
    advanced_filter_button = new Button(parent, SWT.PUSH);
    advanced_filter_button.setText("Set Custom filter...");
    advanced_filter_button.addSelectionListener(this);
    advanced_filter_button.setToolTipText("Advanced settings to filter issues below.");
    advanced_filter_button.setEnabled(false);

    issues_tree = new Tree(parent,
            SWT.FULL_SELECTION | SWT.MULTI | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL | SWT.CHECK);
    GridData gd = new GridData(GridData.FILL_BOTH);
    gd.horizontalSpan = 7;
    gd.grabExcessVerticalSpace = true;
    issues_tree.addSelectionListener(this);

    LinearIssuesGraph issue_graph = new LinearIssuesGraph(graphSash);
    issue_graph.setLogData(parsedData);

    //Creates issues viewer.
    viewer = new IssuesViewer(issues_tree, issue_graph);
    viewer.createIssuesViewerAndGraph();
    viewer.setContentProvider(new IssuesTreeContentProvider());
    viewer.setLabelProvider(new IssuesTreeLabelProvider());
    filter = new IssuesFilter();
    viewer.addFilter(filter);

    ANALYSIS_PAGE = addPage(parentComposite);
    setPageText(ANALYSIS_PAGE, " Analysis ");

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

    //Set top 5 issues in the overview tab
    setTopIssues(analysis_results_obj);

    issues_tree.setFocus();
}

From source file:com.nokia.s60tools.swmtanalyser.editors.SWMTEditor.java

License:Open Source License

public void widgetSelected(SelectionEvent e) {

    //When Export button is selected, data from given log files 
    //will be exported to an excel file.
    if (e.widget == export) {
        FileDialog dlg = new FileDialog(Display.getCurrent().getActiveShell(), SWT.SAVE);
        dlg.setFilterExtensions(new String[] { "*.xls" });
        String fileName = dlg.open();
        if (fileName == null)
            return;

        SWMTExcelCreationRunnableWithProcess process = new SWMTExcelCreationRunnableWithProcess(fileName,
                parsedData, toCombo.getSelectionIndex() + 1);
        IWorkbench wb = PlatformUI.getWorkbench();
        IWorkbenchWindow win = wb.getActiveWorkbenchWindow();
        Shell shell = win != null ? win.getShell() : null;
        try {// w  w  w .jav  a2 s. c o  m
            new ProgressMonitorDialog(shell).run(true, true, process);
        } catch (InvocationTargetException err) {
            err.printStackTrace();
        } catch (InterruptedException err) {
            err.printStackTrace();
        }
    } else if (e.widget == allBtn) {
        toCombo.setEnabled(false);
    } else if (e.widget == notAllBtn) {
        toCombo.setEnabled(true);
    } else if (e.widget == viewAll_btn) {
        this.setActivePage(ANALYSIS_PAGE);
    }
    /*
     * When Events list selection is changed, all previous selections should be cleared
     * and they should be moved to Graphed items tab.
     * Also, listeners of enabled tables should be notified.
     */
    else if (e.widget == eventList) {
        selectedEvent = eventList.getSelection()[0];
        title.setText(selectedEvent);
        updateGraphedItemsList(lastSelectedEvent);

        if (!selectedEvent.equals(lastSelectedEvent)) {
            chunkTble.cancelSelectionList();
            threadTble.cancelSelectionList();
            diskTble.cancelSelectionList();
            sysinfoTble.cancelSelectionList();
        }

        if (!selectedEvent.equals(lastSelectedEvent) && graph != null)
            graph.clearGraph();

        if (Arrays.asList(RAM_GRP).contains(selectedEvent)) {
            threadTble.setEnabled(false);
            chunkTble.setEnabled(false);
            diskTble.setEnabled(false);
            sysinfoTble.setEnabled(false);

            DisksGraph diskGraph = new DisksGraph();
            GenericGraph.EventTypes eventType = GraphsUtils.getMappedEvent(selectedEvent);
            diskGraph.setEvent(eventType);
            diskGraph.setCyclesData(parsedData);

            if (graph != null)
                graph.redraw(diskGraph);
        } else {
            if (Arrays.asList(CHUNKS_GRP).contains(selectedEvent)) {
                if (Arrays.asList(CHUNKS_GRP).indexOf(selectedEvent) == 0
                        && !selectedEvent.equals(lastSelectedEvent))
                    chunkTble.setInput(chunks);
                else if (Arrays.asList(CHUNKS_GRP).indexOf(selectedEvent) == 1
                        && !selectedEvent.equals(lastSelectedEvent))
                    chunkTble.setInput(nonHeapChunks);
                innerTabFolder.setSelection(chunksTab);

                CheckStateChangedEvent event = new CheckStateChangedEvent(chunksViewer, null, false);

                if (chunkTble.getCheckStateListener() != null)
                    chunkTble.getCheckStateListener().checkStateChanged(event);
            } else if (Arrays.asList(HEAP_GRP).contains(selectedEvent)
                    || Arrays.asList(FILES_GRP).contains(selectedEvent)
                    || Arrays.asList(HPAS_GRP).contains(selectedEvent)) {
                innerTabFolder.setSelection(threadTab);

                CheckStateChangedEvent event = new CheckStateChangedEvent(threadViewer, null, false);
                if (threadTble.getCheckStateListener() != null)
                    threadTble.getCheckStateListener().checkStateChanged(event);
            } else if (Arrays.asList(DISK_GRP).contains(selectedEvent)) {
                innerTabFolder.setSelection(diskTab);

                CheckStateChangedEvent event = new CheckStateChangedEvent(disksViewer, null, false);
                if (diskTble.getCheckStateListener() != null)
                    diskTble.getCheckStateListener().checkStateChanged(event);
            } else if (Arrays.asList(SYSINFO_GRP).contains(selectedEvent)) {
                innerTabFolder.setSelection(sysInfoTab);

                CheckStateChangedEvent event = new CheckStateChangedEvent(sysElemsViewer, null, false);

                if (sysinfoTble.getCheckStateListener() != null)
                    sysinfoTble.getCheckStateListener().checkStateChanged(event);
            }

            threadTble.setEnabled(innerTabFolder.getItem(innerTabFolder.getSelectionIndex()) == threadTab);
            chunkTble.setEnabled(innerTabFolder.getItem(innerTabFolder.getSelectionIndex()) == chunksTab);
            diskTble.setEnabled(innerTabFolder.getItem(innerTabFolder.getSelectionIndex()) == diskTab);
            sysinfoTble.setEnabled(innerTabFolder.getItem(innerTabFolder.getSelectionIndex()) == sysInfoTab);

        }

        lastSelectedEvent = selectedEvent;
    }
    //Events list will be modified based on the selection of 
    //event category from the drop down box.
    else if (e.widget == eventsCombo) {
        eventList.removeAll();
        CATEGORIES index = CATEGORIES.valueOf(eventsCombo.getText());
        switch (index) {
        case All_events:
            eventList.setItems(ALL_GRP);
            break;
        case Chunks:
            eventList.setItems(CHUNKS_GRP);
            break;
        case Disk:
            eventList.setItems(DISK_GRP);
            break;
        case Files:
            eventList.setItems(FILES_GRP);
            break;
        case Heap:
            eventList.setItems(HEAP_GRP);
            break;
        case HPAS:
            eventList.setItems(HPAS_GRP);
            break;
        case RAM:
            eventList.setItems(RAM_GRP);
            break;
        case System_info:
            eventList.setItems(SYSINFO_GRP);
            break;
        }
        eventList.select(0);

        if (eventList.getItemCount() > 0) {
            eventList.notifyListeners(SWT.Selection, new Event());
        }
    } else if (e.widget == mainTabFolder && mainTabFolder.getSelectionIndex() != -1
            && mainTabFolder.getSelection()[0].getText().trim().equalsIgnoreCase(GRAPHED_ITEMS_LABEL)) {
        selectedEvent = eventList.getSelection()[0];
        updateGraphedItemsList(selectedEvent);

        title.setText("Graphed Items");

        Object[] checkedElems = graphedItemsViewer.getCheckedElements();
        ArrayList<GraphedItemsInput> selectedItems = new ArrayList<GraphedItemsInput>();

        for (Object obj : checkedElems) {
            GraphedItemsInput graphInput = (GraphedItemsInput) obj;
            selectedItems.add(graphInput);
        }

        allEventsGraph.setGraphedItemsInput(selectedItems);
        allEventsGraph.constructGraphArea();

    } else if (e.widget == mainTabFolder && mainTabFolder.getSelectionIndex() != -1
            && mainTabFolder.getSelection()[0] == eventsTab) {
        if (graphedItemsViewer.getInput() == null) {
            graphed.clear();
        }
        graph.constructGraphArea();

        if (eventList.getSelectionIndex() != -1) {
            title.setText(eventList.getItem(eventList.getSelectionIndex()));
            eventList.notifyListeners(SWT.Selection, new Event());
        } else
            title.setText("");

    }

    //Issues list gets modified based on the selection of Severity 
    //from the drop down box.
    else if (e.widget == severity_combo) {
        advanced_filter_button.setEnabled(false);
        filter.setAdvancedSearchOptions(null);
        Image img = null;
        String icon_name = "";
        switch (severity_combo.getSelectionIndex()) {
        case 1:
            icon_name = "\\red.png";
            filter.setFilterText(AnalyserConstants.Priority.CRITICAL.name());
            break;
        case 2:
            icon_name = "\\yellow.png";
            filter.setFilterText(AnalyserConstants.Priority.HIGH.name());
            break;
        case 3:
            icon_name = "\\green.png";
            filter.setFilterText(AnalyserConstants.Priority.NORMAL.name());
            break;
        case 4:
            advanced_filter_button.setEnabled(true);
        default:
            icon_name = null;
            filter.setFilterText(null);
            break;
        }
        if (icon_name != null) {
            try {
                img = new Image(Display.getCurrent(),
                        SwmtAnalyserPlugin.getPluginInstallPath() + "\\icons" + icon_name);
            } catch (RuntimeException e1) {
                e1.printStackTrace();
            }
        }
        severity_label.setImage(img);
        issues_tree.setFocus();
        viewer.refresh();
    } else if (e.widget == issues_table) {
        analyse_menuItem.setEnabled(!issues_table.getSelection()[0].getText(0).startsWith(NO_ISSUES_MSG));
    } else if (e.widget == advanced_filter_button) {
        AdvancedFilterDialog dlg = new AdvancedFilterDialog(Display.getCurrent().getActiveShell());
        int status = dlg.open();
        if (status == Dialog.OK) {
            FilterInput input = dlg.getFilterOptions();
            filter.setAdvancedSearchOptions(input);
            issues_tree.setFocus();
            viewer.refresh();
        }
    } else if (e.widget == generate_report_btn) {
        //Save graph in temporary location
        GC gc = new GC(graphSash);
        Image image = new Image(Display.getCurrent(), graphSash.getClientArea().width,
                graphSash.getClientArea().height);
        graphSash.setFocus();
        gc.copyArea(image, 0, 0);
        gc.dispose();
        ImageData data = image.getImageData();
        ImageLoader loader = new ImageLoader();
        loader.data = new ImageData[] { data };
        loader.save(SwmtAnalyserPlugin.getPluginInstallPath() + "\\swmt_graph.bmp", SWT.IMAGE_BMP);
        image.dispose();

        // Now open the wizard
        Runnable showWizardRunnable = new Runnable() {
            public void run() {
                WizardDialog wizDialog;
                ReportGenerationWizard wiz = new ReportGenerationWizard(ov,
                        parsedData.getLogData()[0].getRomCheckSum(), parsedData.getLogData()[0].getRomVersion(),
                        issues_tree);
                wizDialog = new WizardDialog(Display.getCurrent().getActiveShell(), wiz);
                wizDialog.create();
                wizDialog.getShell().setSize(400, 500);
                wizDialog.addPageChangedListener(wiz);
                wizDialog.open();
            }
        };
        Display.getDefault().asyncExec(showWizardRunnable);
    }
}

From source file:com.nokia.s60tools.swmtanalyser.ui.actions.SwmtAnalyser.java

License:Open Source License

/**
 * Analyse given logs files.//from  ww w .  ja  va 2 s . c om
 * @param swmtFiles list of swmt log files to be analysed
 */
public void analyse(ArrayList<String> swmtFilePaths) {
    if (swmtFilePaths != null) {
        inputs = swmtFilePaths;
        cycleData = new ArrayList<CycleData>();

        isCancelled = false;
        IRunnableWithProgress op = new IRunnableWithProgress() {
            public void run(IProgressMonitor monitor) {
                monitor.beginTask("Reading log files..", 10);
                status = logReader.getCycleDataArrayFromLogFiles(inputs, cycleData, monitor);
                if (monitor.isCanceled())
                    isCancelled = true;

                monitor.done();
            }
        };

        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 e) {
            e.printStackTrace();
            return;
        } catch (InterruptedException e) {
            e.printStackTrace();
            return;
        }

        if (isCancelled)
            return;

        if (status != null) {
            MessageDialog.openError(Display.getCurrent().getActiveShell(), "SWMT Analyser", status);
            return;
        } else if (cycleData.size() > 1) {
            cycleData = logReader.checkCycleOrder(cycleData);
            if (cycleData == null) {
                MessageDialog.openError(Display.getCurrent().getActiveShell(), "SWMT Analyser",
                        "Invalid order of the log files. The selected files must be in consecutive order and must start from the first cycle.");
                return;
            }

            if (!logReader.checkRomInfo(cycleData)) {
                MessageDialog.openError(Display.getCurrent().getActiveShell(), "SWMT Analyser",
                        "Selected logs do not have common ROM Checksum and Version. Hence, they cannot be compared.");
                return;
            }
            int ret = logReader.checkTimeStamp(cycleData);
            if (ret != 0) {
                MessageDialog.openError(Display.getCurrent().getActiveShell(), "SWMT Analyser",
                        "In selected logs, the time stamp of log cycle " + ret + " is lesser than log cycle "
                                + (ret - 1) + ". Hence, they cannot be analysed together.");
                return;
            }
        } else if (cycleData.size() == 1 && cycleData.get(0).getCycleNumber() != 1) {
            boolean ok = MessageDialog.openQuestion(Display.getCurrent().getActiveShell(), "SWMT Analyser",
                    "This is a delta file. It does not contain the complete information.  Do you still want to continue ?");
            if (!ok)
                return;
        }

        //Files are valid and the cycle numbers are in order.
        //So, get overview information to be displayed in the editor view
        OverviewData ov = logReader.getOverviewInformationFromCyclesData(cycleData.toArray(new CycleData[0]),
                cycleData.size());

        Runnable runnable = new Runnable() {
            public void run() {
                for (int i = 0; i < cycleData.size(); i++) {
                    CycleData cycle = cycleData.get(i);
                    cycle.clear();

                    try {
                        SwmtParser.parseSwmtLog(cycle.getFileName(), cycle);
                    } catch (SwmtFormatException e) {
                        parserError = e.getMessage();
                        Runnable runnable = new Runnable() {
                            public void run() {
                                MessageDialog.openError(Display.getCurrent().getActiveShell(), "SWMT Analyser",
                                        "Error while parsing the log file " + parserError);
                            }
                        };
                        Display.getDefault().asyncExec(runnable);
                        return;
                    }
                }
            }
        };
        Display.getDefault().syncExec(runnable);

        IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
        try {
            IEditorDescriptor descriptor = PlatformUI.getWorkbench().getEditorRegistry()
                    .findEditor(SWMT_EDITOR_ID);
            if (descriptor == null) {
                MessageDialog.openError(Display.getDefault().getActiveShell(), "SWMT Analyser",
                        "SWMT Editor is not found");
                return;
            }

            ParsedData logData = new ParsedData();
            logData.setParsedData(cycleData);
            page.openEditor(new SWMTEditorInput(logData, ov), descriptor.getId(), true,
                    IWorkbenchPage.MATCH_INPUT);

        } catch (PartInitException e) {
            e.printStackTrace();
        }
    } else {
        MessageDialog.openError(Display.getCurrent().getActiveShell(), "SWMT Analyser",
                "Invalid input. Unable to open SWMT Editor");
        return;
    }
}

From source file:com.nokia.sdt.editor.EditorServices.java

License:Open Source License

/**
 * Run a task, showing a progress dialog only when the workbench
 * is up and no editors are open, when we presume that load times 
 * will be much longer./*from ww w. jav  a 2s . co  m*/
 * @param shell
 * @param runWithStatus
 * @return null for success, else IStatus for error
 */
public static IStatus runWithProgressAndStatus(Shell shell,
        final IRunnableWithProgressAndStatus runWithStatus) {
    final IStatus status[] = { null };
    IRunnableWithProgress runnable = new IRunnableWithProgress() {
        public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
            status[0] = runWithStatus.run(monitor);
        }
    };

    try {
        // the first load is likely to take long, so show a dialog in this case
        if (!stiflingProgress && !EditorServices.isAnyEditorOpen() && EditorServices.isEditorVisible(shell))
            new ProgressMonitorDialog(shell).run(false, false, runnable);
        else
            runnable.run(new NullProgressMonitor());

        if (status[0] == null || status[0] == Status.OK_STATUS)
            return null;
        else
            return status[0];
    } catch (Exception e) {
        return Logging.newStatus(UIModelPlugin.getDefault(), e);
    }

}

From source file:com.nokia.sdt.uidesigner.ui.utils.EditorUtils.java

License:Open Source License

private static void doUpdateSession(IProject project, boolean showProjectUpdateDialog) {
    Shell shell = WorkbenchUtils.getSafeShell();
    if (shell == null || !shell.isVisible())
        return;/*from   ww  w. ja va  2  s  .c  o m*/

    IProjectUpdateSession updateSession = CarbideUpdaterPlugin.getProjectUpdateManager().createSession();
    updateSession.addUpdatableProject(project);
    updateSession.addRefactoringProject(project);
    updateSession.setShowProjectUpdateDialog(showProjectUpdateDialog);
    updateSession.setSilentIfEmpty(true);

    UpdaterRunnable operation = new UpdaterRunnable(updateSession);
    try {
        new ProgressMonitorDialog(shell).run(true, false, operation);
    } catch (InvocationTargetException x) {
        UIDesignerPlugin.getDefault().log(x);

    } catch (InterruptedException x) {
        UIDesignerPlugin.getDefault().log(x);
    }
}