Search in sources :

Example 1 with TracingResultsNode

use of org.erlide.tracing.core.mvc.model.treenodes.TracingResultsNode 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 TracingResultsNode

use of org.erlide.tracing.core.mvc.model.treenodes.TracingResultsNode in project erlide_eclipse by erlang.

the class TreeViewerView method updateButtonsPanel.

private void updateButtonsPanel() {
    final TracingResultsNode resultSet = TraceBackend.getInstance().getActiveResultSet();
    if (resultSet != null) {
        index = TraceBackend.getInstance().getStartIndex();
        final int size = TraceCollections.getTracesList().size();
        final boolean previousEnabled = index > 1;
        final boolean nextEnabled = index + size - 1 < resultSet.getSize();
        previousButton.setEnabled(previousEnabled);
        nextButton.setEnabled(nextEnabled);
        showButton.setEnabled(previousEnabled || nextEnabled);
        traceIndexField.setEnabled(previousEnabled || nextEnabled);
        traceIndexField.setText(String.valueOf(index));
        buttonsPanel.setEnabled(true);
        final StringBuilder stringBuilder = new StringBuilder(" (");
        if (resultSet.getSize() == 0) {
            stringBuilder.append("no traces)");
        } else {
            stringBuilder.append(index).append(" - ").append(index + size - 1).append(" of ").append(resultSet.getSize()).append(" traces)");
        }
        label.setText(stringBuilder.toString());
    } else {
        traceIndexField.setText("");
        label.setText("");
        buttonsPanel.setEnabled(false);
    }
}
Also used : TracingResultsNode(org.erlide.tracing.core.mvc.model.treenodes.TracingResultsNode)

Example 3 with TracingResultsNode

use of org.erlide.tracing.core.mvc.model.treenodes.TracingResultsNode in project erlide_eclipse by erlang.

the class TraceDataHandler method processFileInfo.

private ITreeNode processFileInfo(final OtpErlangTuple tuple) {
    TracingResultsNode node = null;
    if (tuple.elementAt(TraceDataHandler.INDEX_INFO_START_DATE) instanceof OtpErlangAtom) {
        // file contains no trace events
        return null;
    }
    try {
        final Date from = readDateTuple((OtpErlangTuple) tuple.elementAt(TraceDataHandler.INDEX_INFO_START_DATE));
        final Date to = readDateTuple((OtpErlangTuple) tuple.elementAt(TraceDataHandler.INDEX_INFO_END_DATE));
        final String path = ((OtpErlangString) tuple.elementAt(TraceDataHandler.INDEX_INFO_PATH)).stringValue();
        final long size = ((OtpErlangLong) tuple.elementAt(TraceDataHandler.INDEX_INFO_COUNT)).longValue();
        node = new TracingResultsNode();
        node.setStartDate(from);
        node.setEndDate(to);
        node.setFileName(path);
        node.setSize(size);
        // node label
        String builder = infoDateFormatter.format(from) + " - " + infoDateFormatter.format(to) + " (" + size + " traces): " + path;
        node.setLabel(builder);
    } catch (final OtpErlangRangeException e) {
        ErlLogger.error(e);
    }
    return node;
}
Also used : OtpErlangLong(com.ericsson.otp.erlang.OtpErlangLong) TracingResultsNode(org.erlide.tracing.core.mvc.model.treenodes.TracingResultsNode) OtpErlangRangeException(com.ericsson.otp.erlang.OtpErlangRangeException) OtpErlangAtom(com.ericsson.otp.erlang.OtpErlangAtom) OtpErlangString(com.ericsson.otp.erlang.OtpErlangString) Date(java.util.Date) OtpErlangString(com.ericsson.otp.erlang.OtpErlangString)

Example 4 with TracingResultsNode

use of org.erlide.tracing.core.mvc.model.treenodes.TracingResultsNode in project erlide_eclipse by erlang.

the class TraceBrowserView method doSelection.

/**
 * Action performed when user clicks on tree element.
 *
 * @param event
 */
private void doSelection(final SelectionChangedEvent event) {
    final IStructuredSelection selection = (IStructuredSelection) event.getSelection();
    final ITreeNode treeNode = (ITreeNode) selection.getFirstElement();
    if (treeNode != null) {
        task = new RunnableWithProgress("Loading trace results...") {

            @Override
            public void doAction() {
                TraceBackend.getInstance().setActiveResultSet((TracingResultsNode) treeNode);
                final int limit = Activator.getDefault().getPreferenceStore().getInt(PreferenceNames.TRACES_LOAD_LIMIT);
                TraceBackend.getInstance().loadDataFromFile(1, limit);
            }
        };
        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;
        }
    }
}
Also used : Shell(org.eclipse.swt.widgets.Shell) ITreeNode(org.erlide.tracing.core.mvc.model.treenodes.ITreeNode) 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)

Aggregations

TracingResultsNode (org.erlide.tracing.core.mvc.model.treenodes.TracingResultsNode)4 ProgressMonitorDialog (org.eclipse.jface.dialogs.ProgressMonitorDialog)2 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)2 Shell (org.eclipse.swt.widgets.Shell)2 RunnableWithProgress (org.erlide.tracing.core.ui.dialogs.RunnableWithProgress)2 OtpErlangAtom (com.ericsson.otp.erlang.OtpErlangAtom)1 OtpErlangLong (com.ericsson.otp.erlang.OtpErlangLong)1 OtpErlangRangeException (com.ericsson.otp.erlang.OtpErlangRangeException)1 OtpErlangString (com.ericsson.otp.erlang.OtpErlangString)1 Date (java.util.Date)1 Action (org.eclipse.jface.action.Action)1 IToolBarManager (org.eclipse.jface.action.IToolBarManager)1 DirectoryDialog (org.eclipse.swt.widgets.DirectoryDialog)1 ITreeNode (org.erlide.tracing.core.mvc.model.treenodes.ITreeNode)1