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