()
| 98 | } |
| 99 | |
| 100 | public void open() { |
| 101 | viewFrame = new STViewFrame(); |
| 102 | updateStack(currentScope, viewFrame); |
| 103 | updateAttributes(currentScope, viewFrame); |
| 104 | List<InterpEvent> events = currentScope.events; |
| 105 | tmodel = new JTreeSTModel(interp, (EvalTemplateEvent)events.get(events.size()-1)); |
| 106 | viewFrame.tree.setModel(tmodel); |
| 107 | viewFrame.tree.addTreeSelectionListener(new TreeSelectionListener() { |
| 108 | @Override |
| 109 | public void valueChanged(TreeSelectionEvent treeSelectionEvent) { |
| 110 | int depth = updateDepth.incrementAndGet(); |
| 111 | try { |
| 112 | if ( depth!=1 ) { |
| 113 | return; |
| 114 | } |
| 115 | currentEvent = ((JTreeSTModel.Wrapper)viewFrame.tree.getLastSelectedPathComponent()).event; |
| 116 | currentScope = currentEvent.scope; |
| 117 | updateCurrentST(viewFrame); |
| 118 | } |
| 119 | finally { |
| 120 | updateDepth.decrementAndGet(); |
| 121 | } |
| 122 | } |
| 123 | }); |
| 124 | JTreeASTModel astModel = new JTreeASTModel(new CommonTreeAdaptor(), currentScope.st.impl.ast); |
| 125 | viewFrame.ast.setModel(astModel); |
| 126 | viewFrame.ast.addTreeSelectionListener(new TreeSelectionListener() { |
| 127 | @Override |
| 128 | public void valueChanged(TreeSelectionEvent treeSelectionEvent) { |
| 129 | int depth = updateDepth.incrementAndGet(); |
| 130 | try { |
| 131 | if ( depth!=1 ) { |
| 132 | return; |
| 133 | } |
| 134 | TreePath path = treeSelectionEvent.getNewLeadSelectionPath(); |
| 135 | if ( path==null ) return; |
| 136 | CommonTree node = (CommonTree)treeSelectionEvent.getNewLeadSelectionPath().getLastPathComponent(); |
| 137 | //System.out.println("select AST: "+node); |
| 138 | CommonToken a = (CommonToken)currentScope.st.impl.tokens.get(node.getTokenStartIndex()); |
| 139 | CommonToken b = (CommonToken)currentScope.st.impl.tokens.get(node.getTokenStopIndex()); |
| 140 | highlight(viewFrame.template, a.getStartIndex(), b.getStopIndex()); |
| 141 | } |
| 142 | finally { |
| 143 | updateDepth.decrementAndGet(); |
| 144 | } |
| 145 | } |
| 146 | }); |
| 147 | |
| 148 | // Track selection of attr but do nothing for now |
| 149 | // viewFrame.attributes.addListSelectionListener( |
| 150 | // new ListSelectionListener() { |
| 151 | // public void valueChanged(ListSelectionEvent e) { |
| 152 | // int minIndex = viewFrame.attributes.getMinSelectionIndex(); |
| 153 | // int maxIndex = viewFrame.attributes.getMaxSelectionIndex(); |
| 154 | // for (int i = minIndex; i <= maxIndex; i++) { |
| 155 | // if (viewFrame.attributes.isSelectedIndex(i)) { |
| 156 | // //System.out.println("index="+i); |
| 157 | // } |
no test coverage detected