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);
}
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;
}
}
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();
}
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();
}
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;
}
}
Aggregations