use of ch.hsr.ifs.pasta.tree.Node in project ch.hsr.ifs.cdttesting by IFS-HSR.
the class ASTWidget method setupCanvas.
private void setupCanvas() {
resizeCanvas();
canvas.setBackground(WHITE);
canvas.addPaintListener(new PaintListener() {
@Override
public void paintControl(final PaintEvent e) {
if (lastControl != null) {
adjustView(lastControl);
}
if (root != null) {
root.visit(node -> {
if (node.data().getFirst().isVisible()) {
if (node.parent() != null) {
drawArrowFromParent(e.gc, node);
}
return NodeVisitor.AfterVisitBehaviour.Continue;
}
return NodeVisitor.AfterVisitBehaviour.Abort;
});
}
}
});
}
use of ch.hsr.ifs.pasta.tree.Node in project ch.hsr.ifs.cdttesting by IFS-HSR.
the class ASTWidget method createNode.
private Node<Pair<Button, IASTNode>> createNode(final Button button, final IASTNode astNode) {
final Node<Pair<Button, IASTNode>> node = new Node<>(new Pair<>(button, astNode));
final Point minButtonSize = button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
nodeHeight = Math.max(nodeHeight, minButtonSize.y);
node.setWidth(minButtonSize.x);
node.treatAsLeaf(true);
if (astNode instanceof ICPPASTTranslationUnit) {
button.setBackground(GOLDEN_YELLOW);
button.getFont().getFontData()[0].setStyle(SWT.BOLD);
}
button.addMouseListener(new MouseAdapter() {
@Override
public void mouseDown(final MouseEvent e) {
int selectKey = 0;
if (prefStore.getString(PreferenceConstants.P_HOW_TO_SELECT).equals(PreferenceConstants.P_SELECT_BY_RIGHT_CLICK)) {
selectKey = 3;
} else if (prefStore.getString(PreferenceConstants.P_HOW_TO_SELECT).equals(PreferenceConstants.P_SELECT_BY_LEFT_CLICK)) {
selectKey = 1;
}
if (e.button == selectKey) {
setNodeInNodeView(astNode);
}
if (e.button == 1) {
buildChildrenAndRefresh(node);
}
}
});
button.addMouseTrackListener(new MouseTrackListener() {
@Override
public void mouseHover(final MouseEvent e) {
if (prefStore.getString(PreferenceConstants.P_HOW_TO_SELECT).equals(PreferenceConstants.P_SELECT_BY_MOUSE_OVER)) {
setNodeInNodeView(astNode);
}
IASTFileLocation fileLocation = astNode.getFileLocation();
while (fileLocation.getContextInclusionStatement() != null) {
final IASTPreprocessorIncludeStatement contextInclusionStatement = fileLocation.getContextInclusionStatement();
fileLocation = contextInclusionStatement.getFileLocation();
}
final TextSelection textSelection = new TextSelection(fileLocation.getNodeOffset(), fileLocation.getNodeLength());
CUIPlugin.getActivePage().getActiveEditor().getEditorSite().getSelectionProvider().setSelection(textSelection);
}
@Override
public void mouseExit(final MouseEvent e) {
}
@Override
public void mouseEnter(final MouseEvent e) {
}
});
return node;
}
Aggregations