private void updateParseTree(final TreeViewer treeViewer) { this.parseTreeViewer = treeViewer; if ( treeViewer == null ) { parseTreeContainer.setViewportView(null); } else { parseTreeContainer.setViewportView(treeViewer); treeViewer.setScale(parseTreeScale.getValue() / 1000.0 + 1.0); new DragScroller().install(treeViewer); treeViewer.addMouseWheelListener(new MouseAdapter() { @Override public void mouseWheelMoved(MouseWheelEvent e) { parseTreeScale.setValue(parseTreeScale.getValue() - e.getWheelRotation() * 100); } }); } }
private static void showTree(ArabicPrologParser parser, ParseTree tree) { // TODO Auto-generated method stub JFrame frame = new JFrame("Antlr AST"); JPanel panel = new JPanel(); TreeViewer viewr = new TreeViewer(Arrays.asList( parser.getRuleNames()),tree); viewr.setScale(1.5);//scale a little panel.add(viewr); frame.add(panel); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setSize(200,200); frame.setVisible(true); }
public Future<JDialog> inspect(@Nullable List<String> ruleNames) { TreeViewer viewer = new TreeViewer(ruleNames, this); return viewer.open(); }