use of abs.backend.java.observing.TaskView in project abstools by abstools.
the class DebugTreeStyledLabelProvider method getLabel.
private StyledString getLabel(Object element) {
if (element instanceof TaskView) {
String s = "Task " + ((TaskView) element).getID() + " (" + ((TaskView) element).getMethodName() + ")";
List<TaskView> schedulableTasks = getSchedulerRef().getSchedulableTasks();
if (schedulableTasks != null) {
for (TaskView taskView : schedulableTasks) {
if (taskView.getID() == ((TaskView) element).getID()) {
return new StyledString(s, STYLER_BLACK);
}
}
}
return new StyledString(s, STYLER_GREY);
} else if (element instanceof COGView) {
COGView cog = (COGView) element;
String s = "COG " + cog.getID() + " (" + getInitialObject(cog).getClassName() + " " + getInitialObject(cog).getID() + ")";
// for color of the string, check if there is a task that can be stepped
if (cog.getScheduler().getSchedulableTasks().size() > 0) {
return new StyledString(s, STYLER_BLACK);
} else {
return new StyledString(s, STYLER_GREY);
}
} else if (element instanceof Tasks) {
String s = "Tasks (" + getCOGInfo(((Tasks) element).getCOG()).getTasks().size() + ")";
// for color of the string, check if there is a task that can be stepped
if (((Tasks) element).getCOG().getScheduler().getSchedulableTasks().size() > 0) {
return new StyledString(s, STYLER_BLACK);
} else {
return new StyledString(s, STYLER_GREY);
}
} else if (element instanceof Objects) {
return new StyledString("Objects (" + ((Objects) element).getObjects().size() + ")", STYLER_BLACK);
} else if (element instanceof TaskStackFrameView) {
TaskStackFrameView tsv = ((TaskStackFrameView) element);
MethodView mv = tsv.getMethod();
return new StyledString("StackFrame (" + mv.toString() + ")", STYLER_BLACK);
} else if (element instanceof ObjectView) {
ObjectView obj = (ObjectView) element;
return new StyledString(obj.getClassName() + " " + obj.getID(), STYLER_BLACK);
} else if (element instanceof DebugModel) {
return new StyledString(getDebugger().getProjectName(), STYLER_BLACK);
} else {
return new StyledString("UnknownObject", STYLER_GREY);
}
}
use of abs.backend.java.observing.TaskView in project abstools by abstools.
the class DebugView method createViewer.
@Override
protected Viewer createViewer(Composite parent) {
final TreeViewer viewer = new TreeViewer(parent);
viewer.setContentProvider(new DebugTreeContentProvider());
viewer.setLabelProvider(new DebugTreeStyledLabelProvider());
viewer.setInput(debugger.getModel());
viewer.setAutoExpandLevel(TreeViewer.ALL_LEVELS);
viewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
refreshButtonEnablement();
Object selection = ((IStructuredSelection) event.getSelection()).getFirstElement();
if (selection instanceof TaskView || selection instanceof ObjectView || selection instanceof TaskStackFrameView) {
refreshVariableView();
if (selection instanceof TaskView) {
TaskView tv = (TaskView) selection;
TaskInfo taskInfo = getDebugger().getModel().getTaskInfo(tv);
highlightLine(taskInfo);
}
}
getSchedulerRef().taskSelectionChanged(selection);
}
});
viewer.addDoubleClickListener(new IDoubleClickListener() {
@Override
public void doubleClick(DoubleClickEvent event) {
Object selection = ((IStructuredSelection) event.getSelection()).getFirstElement();
if (selection instanceof ObjectView || selection instanceof TaskStackFrameView) {
openVariableView();
refreshVariableView();
} else {
viewer.setExpandedState(selection, !viewer.getExpandedState(selection));
}
}
});
viewer.expandAll();
return viewer;
}
Aggregations