Search in sources :

Example 1 with RunnableWithProgress

use of org.erlide.tracing.core.ui.dialogs.RunnableWithProgress in project erlide_eclipse by erlang.

the class TraceBrowserView method createActionBars.

private void createActionBars() {
    loadAction = new Action() {

        @Override
        public void run() {
            final DirectoryDialog dialog = new DirectoryDialog(PlatformUI.getWorkbench().getDisplay().getActiveShell(), SWT.OPEN);
            dialog.setFilterPath(ResourcesPlugin.getWorkspace().getRoot().getLocation().toString());
            // dialog.setFilterExtensions(new String[] { "*.*" });
            dialog.setText("Load trace data...");
            final String selected = dialog.open();
            if (selected != null) {
                task = new RunnableWithProgress("Load trace data...") {

                    @Override
                    public void doAction() {
                        TraceBackend.getInstance().loadFile(selected);
                    }
                };
                try {
                    final Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
                    new ProgressMonitorDialog(shell).run(true, false, task);
                    doAfterLoadingFile();
                } catch (final Exception e) {
                    ErlLogger.error(e);
                } finally {
                    task = null;
                }
            }
        }
    };
    loadAction.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_OBJ_FOLDER));
    loadAction.setToolTipText("Load results from disk...");
    removeAction = new Action() {

        @Override
        public void run() {
            final TracingResultsNode node = (TracingResultsNode) ((IStructuredSelection) treeViewer.getSelection()).getFirstElement();
            if (node != null) {
                TraceBackend.getInstance().removeTracingResult(node);
            }
        }
    };
    removeAction.setImageDescriptor(DebugUITools.getImageDescriptor(IDebugUIConstants.IMG_LCL_REMOVE));
    removeAction.setToolTipText("Remove selected");
    removeAllAction = new Action() {

        @Override
        public void run() {
            TraceBackend.getInstance().clearTraceLists();
        }
    };
    removeAllAction.setImageDescriptor(DebugUITools.getImageDescriptor(IDebugUIConstants.IMG_LCL_REMOVE_ALL));
    removeAllAction.setToolTipText("Remove all");
    final IToolBarManager manager = getViewSite().getActionBars().getToolBarManager();
    manager.add(loadAction);
    manager.add(removeAction);
    manager.add(removeAllAction);
}
Also used : Action(org.eclipse.jface.action.Action) Shell(org.eclipse.swt.widgets.Shell) IToolBarManager(org.eclipse.jface.action.IToolBarManager) ProgressMonitorDialog(org.eclipse.jface.dialogs.ProgressMonitorDialog) RunnableWithProgress(org.erlide.tracing.core.ui.dialogs.RunnableWithProgress) TracingResultsNode(org.erlide.tracing.core.mvc.model.treenodes.TracingResultsNode) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) DirectoryDialog(org.eclipse.swt.widgets.DirectoryDialog)

Example 2 with RunnableWithProgress

use of org.erlide.tracing.core.ui.dialogs.RunnableWithProgress in project erlide_eclipse by erlang.

the class ControlPanelView method doStopTracing.

/**
 * Method called when stopping tracing.
 */
private void doStopTracing() {
    task = new RunnableWithProgress("Loading trace results...") {

        @Override
        public void doAction() {
            TraceBackend.getInstance().stop();
        }
    };
    try {
        final Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
        new ProgressMonitorDialog(shell).run(true, false, task);
        startStopAction.setImageDescriptor(DebugUITools.getImageDescriptor(IDebugUIConstants.IMG_ACT_RUN));
        startStopAction.setToolTipText(ControlPanelView.START_LABEL);
        startStopAction.setEnabled(true);
        TracingStatusHandler.handleStatus(status);
    } catch (final Exception e) {
        ErlLogger.error(e);
    } finally {
        task = null;
    }
}
Also used : Shell(org.eclipse.swt.widgets.Shell) ProgressMonitorDialog(org.eclipse.jface.dialogs.ProgressMonitorDialog) RunnableWithProgress(org.erlide.tracing.core.ui.dialogs.RunnableWithProgress)

Example 3 with RunnableWithProgress

use of org.erlide.tracing.core.ui.dialogs.RunnableWithProgress in project erlide_eclipse by erlang.

the class TreeViewerView method createButtonsPanel.

private void createButtonsPanel(final Composite parent) {
    buttonsPanel = new Composite(parent, SWT.NONE);
    buttonsPanel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
    buttonsPanel.setLayout(new RowLayout());
    // "Previous" button
    previousButton = new Button(buttonsPanel, SWT.PUSH | SWT.CENTER);
    previousButton.setToolTipText("Show previous trace set");
    previousButton.setImage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_TOOL_BACK));
    previousButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(final SelectionEvent e) {
            task = new RunnableWithProgress("Loading trace results...") {

                @Override
                public void doAction() {
                    final int limit = Activator.getDefault().getPreferenceStore().getInt(PreferenceNames.TRACES_LOAD_LIMIT);
                    final long startIndex = Math.max(1L, index - limit);
                    final long endIndex = startIndex + limit - 1;
                    TraceBackend.getInstance().loadDataFromFile(startIndex, endIndex);
                }
            };
            executeTask();
        }
    });
    // "Next" button
    nextButton = new Button(buttonsPanel, SWT.PUSH | SWT.CENTER);
    nextButton.setToolTipText("Show next trace set");
    nextButton.setImage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_TOOL_FORWARD));
    nextButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(final SelectionEvent e) {
            task = new RunnableWithProgress("Loading trace results...") {

                @Override
                public void doAction() {
                    final int limit = Activator.getDefault().getPreferenceStore().getInt(PreferenceNames.TRACES_LOAD_LIMIT);
                    final long endIndex = Math.min(index + limit * 2 - 1, TraceBackend.getInstance().getActiveResultSet().getSize());
                    final long startIndex = endIndex - limit + 1;
                    TraceBackend.getInstance().loadDataFromFile(startIndex, endIndex);
                }
            };
            executeTask();
        }
    });
    // "Show" button
    showButton = new Button(buttonsPanel, SWT.PUSH | SWT.CENTER);
    showButton.setToolTipText("Show selected trace set");
    showButton.setImage(DebugUITools.getImage(IDebugUIConstants.IMG_OBJS_LAUNCH_RUN));
    showButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(final SelectionEvent e) {
            doSelection();
        }
    });
    // Text field
    traceIndexField = new Text(buttonsPanel, SWT.SINGLE | SWT.BORDER);
    traceIndexField.setToolTipText("Select index of first trace event to display");
    traceIndexField.setLayoutData(new RowData(60, SWT.DEFAULT));
    traceIndexField.addListener(SWT.Modify, event -> {
        try {
            correctInput = false;
            final Long value = new Long(traceIndexField.getText());
            if (value >= 1 && value <= TraceBackend.getInstance().getActiveResultSet().getSize()) {
                index = value;
                showButton.setEnabled(nextButton.isEnabled() || previousButton.isEnabled());
                correctInput = true;
            } else {
                showButton.setEnabled(false);
            }
        } catch (final Exception e) {
            showButton.setEnabled(false);
        }
    });
    traceIndexField.addKeyListener(new KeyListener() {

        @Override
        public void keyReleased(final KeyEvent e) {
            if (e.keyCode == SWT.CR && correctInput) {
                doSelection();
            }
        }

        @Override
        public void keyPressed(final KeyEvent e) {
        }
    });
    // label
    label = new Label(buttonsPanel, SWT.NONE);
    label.setLayoutData(new RowData(200, SWT.DEFAULT));
    updateButtonsPanel();
}
Also used : Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) RunnableWithProgress(org.erlide.tracing.core.ui.dialogs.RunnableWithProgress) Label(org.eclipse.swt.widgets.Label) Text(org.eclipse.swt.widgets.Text) CoreException(org.eclipse.core.runtime.CoreException) KeyEvent(org.eclipse.swt.events.KeyEvent) RowData(org.eclipse.swt.layout.RowData) Button(org.eclipse.swt.widgets.Button) RowLayout(org.eclipse.swt.layout.RowLayout) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) KeyListener(org.eclipse.swt.events.KeyListener)

Example 4 with RunnableWithProgress

use of org.erlide.tracing.core.ui.dialogs.RunnableWithProgress in project erlide_eclipse by erlang.

the class TreeViewerView method doSelection.

private void doSelection() {
    task = new RunnableWithProgress("Loading trace results...") {

        @Override
        public void doAction() {
            final int limit = Activator.getDefault().getPreferenceStore().getInt(PreferenceNames.TRACES_LOAD_LIMIT);
            TraceBackend.getInstance().loadDataFromFile(index, index + limit - 1);
        }
    };
    executeTask();
}
Also used : RunnableWithProgress(org.erlide.tracing.core.ui.dialogs.RunnableWithProgress)

Example 5 with RunnableWithProgress

use of org.erlide.tracing.core.ui.dialogs.RunnableWithProgress in project erlide_eclipse by erlang.

the class ControlPanelView method doStartTracing.

/**
 * Method called when starting tracing.
 */
private void doStartTracing() {
    try {
        task = new RunnableWithProgress("Starting tracing") {

            @Override
            public void doAction() {
                status = TraceBackend.getInstance().start();
                finish();
            }
        };
        PlatformUI.getWorkbench().getProgressService().busyCursorWhile(task);
        TracingStatusHandler.handleStatus(status);
    } catch (final Exception e) {
    } finally {
        task = null;
    }
}
Also used : RunnableWithProgress(org.erlide.tracing.core.ui.dialogs.RunnableWithProgress)

Aggregations

RunnableWithProgress (org.erlide.tracing.core.ui.dialogs.RunnableWithProgress)6 ProgressMonitorDialog (org.eclipse.jface.dialogs.ProgressMonitorDialog)3 Shell (org.eclipse.swt.widgets.Shell)3 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)2 TracingResultsNode (org.erlide.tracing.core.mvc.model.treenodes.TracingResultsNode)2 CoreException (org.eclipse.core.runtime.CoreException)1 Action (org.eclipse.jface.action.Action)1 IToolBarManager (org.eclipse.jface.action.IToolBarManager)1 KeyEvent (org.eclipse.swt.events.KeyEvent)1 KeyListener (org.eclipse.swt.events.KeyListener)1 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)1 SelectionEvent (org.eclipse.swt.events.SelectionEvent)1 GridData (org.eclipse.swt.layout.GridData)1 RowData (org.eclipse.swt.layout.RowData)1 RowLayout (org.eclipse.swt.layout.RowLayout)1 Button (org.eclipse.swt.widgets.Button)1 Composite (org.eclipse.swt.widgets.Composite)1 DirectoryDialog (org.eclipse.swt.widgets.DirectoryDialog)1 Label (org.eclipse.swt.widgets.Label)1 Text (org.eclipse.swt.widgets.Text)1