00001 package edu.ksu.cis.bandera.pdgslicer.dependency;
00002
00003 import javax.swing.*;
00004 import javax.swing.tree.*;
00005 import edu.ksu.cis.bandera.annotation.*;
00006 import edu.ksu.cis.bandera.jjjc.CompilationManager;
00007 import ca.mcgill.sable.soot.*;
00008 import edu.ksu.cis.bandera.pdgslicer.*;
00009 import ca.mcgill.sable.util.Set;
00010 import ca.mcgill.sable.util.ArraySet;
00011 import ca.mcgill.sable.util.Iterator;
00012 import java.util.Vector;
00013 import java.util.Enumeration;
00014 import java.util.Hashtable;
00015 import edu.ksu.cis.bandera.util.Preferences;
00016
00017
00018
00019
00020
00021 public class QueryPanel extends JPanel implements java.awt.event.ActionListener, java.awt.event.MouseListener, javax.swing.event.TreeSelectionListener {
00022 private boolean setQueryIndexByProgram = false;
00023 private Dependencies dependFrame = null;
00024 DefaultMutableTreeNode currentQueryResultTreeRoot = null;
00025 private String queries[] = {"none", "Slice trace from current stmt", "All conditionals in the slice", "All conditionals influence current node"};
00026 static final int NO_QUERY = 0;
00027 static final int SLICE_TRACE = 1;
00028 static final int ALL_CONDITIONALS = 2;
00029 static final int CONDITIONALS_TO_CURRENT_STMT = 3;
00030 private JComboBox ivjQueryKindComboBox = null;
00031 private JLabel ivjQueryKindLabel = null;
00032 private JScrollPane ivjQueryResultScrollPane = null;
00033 private JTree ivjQueryResultTree = null;
00034
00035
00036
00037 public QueryPanel() {
00038 super();
00039 initialize();
00040 }
00041
00042
00043
00044
00045 public QueryPanel(java.awt.LayoutManager layout) {
00046 super(layout);
00047 }
00048
00049
00050
00051
00052
00053 public QueryPanel(java.awt.LayoutManager layout, boolean isDoubleBuffered) {
00054 super(layout, isDoubleBuffered);
00055 }
00056
00057
00058
00059
00060 public QueryPanel(boolean isDoubleBuffered) {
00061 super(isDoubleBuffered);
00062 }
00063
00064
00065
00066
00067
00068 public void actionPerformed(java.awt.event.ActionEvent e) {
00069
00070
00071 if (e.getSource() == getQueryKindComboBox())
00072 connEtoC1();
00073
00074
00075 }
00076
00077
00078
00079
00080 private void connEtoC1() {
00081 try {
00082
00083 if (!setQueryIndexByProgram)
00084
00085 this.queryKindComboBox_ActionEvents();
00086
00087
00088 } catch (java.lang.Throwable ivjExc) {
00089
00090
00091 handleException(ivjExc);
00092 }
00093 }
00094
00095
00096
00097
00098 private void connEtoC2() {
00099 try {
00100
00101
00102 this.queryResultTree_TreeSelectionEvents();
00103
00104
00105 } catch (java.lang.Throwable ivjExc) {
00106
00107
00108 handleException(ivjExc);
00109 }
00110 }
00111
00112
00113
00114
00115
00116 private void connEtoC3(java.awt.event.MouseEvent arg1) {
00117 try {
00118
00119
00120 this.queryResultTree_MouseClicked(arg1);
00121
00122
00123 } catch (java.lang.Throwable ivjExc) {
00124
00125
00126 handleException(ivjExc);
00127 }
00128 }
00129
00130
00131
00132
00133
00134
00135
00136 private DefaultMutableTreeNode cuttingTreeWRT(DefaultMutableTreeNode root, SliceTraceNode sliceTraceNode) {
00137
00138 if (!sliceTraceContains(root, sliceTraceNode))
00139 return null;
00140 if (traceRootIs(root, sliceTraceNode))
00141 return root;
00142 Set workSetOfNextLevel;
00143 Set workSetOfCurrentLevel = new ArraySet();
00144 workSetOfCurrentLevel.add(root);
00145 do {
00146 workSetOfNextLevel = new ArraySet();
00147 for (Iterator nodeIt = workSetOfCurrentLevel.iterator(); nodeIt.hasNext();) {
00148 DefaultMutableTreeNode currentNode = (DefaultMutableTreeNode) nodeIt.next();
00149 Vector removableChildren = new Vector();
00150 for (int i = 0; i < currentNode.getChildCount(); i++) {
00151 DefaultMutableTreeNode oneChild = (DefaultMutableTreeNode) currentNode.getChildAt(i);
00152 if (sliceTraceContains(oneChild, sliceTraceNode)) {
00153 if (!traceRootIs(oneChild, sliceTraceNode))
00154 workSetOfNextLevel.add(oneChild);
00155 } else
00156 removableChildren.addElement(oneChild);
00157 }
00158 for (Enumeration enum = removableChildren.elements(); enum.hasMoreElements();) {
00159 DefaultMutableTreeNode removableNode = (DefaultMutableTreeNode) enum.nextElement();
00160 currentNode.remove(removableNode);
00161 }
00162 }
00163 workSetOfCurrentLevel = workSetOfNextLevel;
00164 } while (!workSetOfNextLevel.isEmpty());
00165 return root;
00166
00167 }
00168 private DefaultMutableTreeNode getBackwardSliceTraceFrom(SliceTraceNode stn) {
00169 DefaultMutableTreeNode pathTreeRoot = new DefaultMutableTreeNode(stn);
00170 Set visitedTraceNode = new ArraySet();
00171 visitedTraceNode.add(stn);
00172 Hashtable traceNodeForCurrentLevel = new Hashtable();
00173 traceNodeForCurrentLevel.put(stn, pathTreeRoot);
00174 Hashtable traceNodeForNextLevel;
00175 do {
00176 traceNodeForNextLevel = new Hashtable();
00177 for (java.util.Iterator nodeIt = traceNodeForCurrentLevel.keySet().iterator(); nodeIt.hasNext();) {
00178 SliceTraceNode sNode = (SliceTraceNode) nodeIt.next();
00179 DefaultMutableTreeNode currentRoot = (DefaultMutableTreeNode) traceNodeForCurrentLevel.get(sNode);
00180 for (java.util.Iterator childIt = sNode.children.keySet().iterator(); childIt.hasNext();) {
00181 SliceTraceNode child = (SliceTraceNode) childIt.next();
00182 if (!visitedTraceNode.contains(child)) {
00183 if (child != Slicer.sliceTraceRoot && !child.stmtAnnotation.toString().equals("")) {
00184 DefaultMutableTreeNode treeChild = new DefaultMutableTreeNode(child);
00185 currentRoot.add(treeChild);
00186 visitedTraceNode.add(child);
00187 traceNodeForNextLevel.put(child, treeChild);
00188 }
00189 }
00190 }
00191 }
00192 traceNodeForCurrentLevel = traceNodeForNextLevel;
00193 } while (!traceNodeForNextLevel.isEmpty());
00194 return pathTreeRoot;
00195 }
00196
00197
00198
00199
00200 private static void getBuilderData() {
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228 }
00229 private DefaultMutableTreeNode getDependencyPathTreeStartFrom(Object startingNode) {
00230 Annotation nodeAnnotation = null;
00231 Annotation mda = null;
00232 if (startingNode instanceof StmtTreeNode) {
00233 StmtTreeNode startTreeNode = (StmtTreeNode) startingNode;
00234 mda = startTreeNode.currentMethodDeclarationAnnotation;
00235 nodeAnnotation = startTreeNode.currentStmtAnnotation;
00236 } else
00237 if (startingNode instanceof Annotation) {
00238 if ((startingNode instanceof MethodDeclarationAnnotation) || (startingNode instanceof ConstructorDeclarationAnnotation))
00239 return null;
00240 else {
00241 mda = (Annotation) CompilationManager.getAnnotationManager().getMethodAnnotationContainingAnnotation((Annotation) startingNode);
00242 nodeAnnotation = (Annotation) startingNode;
00243 }
00244 } else
00245 return null;
00246 SootMethod sm = null;
00247 if (mda instanceof MethodDeclarationAnnotation)
00248 sm = ((MethodDeclarationAnnotation) mda).getSootMethod();
00249 else
00250 if (mda instanceof ConstructorDeclarationAnnotation)
00251 sm = ((ConstructorDeclarationAnnotation) mda).getSootMethod();
00252 SliceTraceNode stn = SlicingMethod.sliceTraceContains(new SliceTraceNode(sm, nodeAnnotation));
00253 if (stn == null)
00254 return null;
00255 DefaultMutableTreeNode pathTreeRoot = getBackwardSliceTraceFrom(stn);
00256 return pathTreeRoot;
00257 }
00258 private DefaultMutableTreeNode getForwardSliceTraceFrom(SliceTraceNode stn) {
00259 DefaultMutableTreeNode pathTreeRoot = new DefaultMutableTreeNode(stn);
00260 Set visitedTraceNode = new ArraySet();
00261 visitedTraceNode.add(stn);
00262 Hashtable traceNodeForCurrentLevel = new Hashtable();
00263 traceNodeForCurrentLevel.put(stn, pathTreeRoot);
00264 Hashtable traceNodeForNextLevel;
00265 do {
00266 traceNodeForNextLevel = new Hashtable();
00267 for (java.util.Iterator nodeIt = traceNodeForCurrentLevel.keySet().iterator(); nodeIt.hasNext();) {
00268 SliceTraceNode sNode = (SliceTraceNode) nodeIt.next();
00269 DefaultMutableTreeNode currentRoot = (DefaultMutableTreeNode) traceNodeForCurrentLevel.get(sNode);
00270 for (java.util.Iterator parentIt = sNode.parents.keySet().iterator(); parentIt.hasNext();) {
00271 SliceTraceNode parent = (SliceTraceNode) parentIt.next();
00272 if (!visitedTraceNode.contains(parent)) {
00273 if (parent != Slicer.sliceTraceRoot && !parent.stmtAnnotation.toString().equals("")) {
00274 DefaultMutableTreeNode treeChild = new DefaultMutableTreeNode(parent);
00275 currentRoot.add(treeChild);
00276 visitedTraceNode.add(parent);
00277 traceNodeForNextLevel.put(parent, treeChild);
00278 }
00279 }
00280 }
00281 }
00282 traceNodeForCurrentLevel = traceNodeForNextLevel;
00283 } while (!traceNodeForNextLevel.isEmpty());
00284 return pathTreeRoot;
00285 }
00286 private DefaultMutableTreeNode getIfDependencyPathTree() {
00287 DefaultMutableTreeNode pathTreeRoot = new DefaultMutableTreeNode("Conditionals");
00288 Set visitedConditionals = new ArraySet();
00289 for (Iterator traceNodeIt = Slicer.allSliceTraceNodes.iterator(); traceNodeIt.hasNext();) {
00290 SliceTraceNode stn = (SliceTraceNode) traceNodeIt.next();
00291 if ((stn.stmtAnnotation instanceof ControlFlowAnnotation) || (stn.stmtAnnotation instanceof ConditionalAnnotation)) {
00292 if (!visitedConditionals.contains(stn)) {
00293 DefaultMutableTreeNode trace = getForwardSliceTraceFrom(stn);
00294 pathTreeRoot.add(trace);
00295 visitedConditionals.add(stn);
00296 }
00297 }
00298 }
00299
00300 return pathTreeRoot;
00301 }
00302 private DefaultMutableTreeNode getIfDependencyPathTreeForNode(Object startingNode) {
00303 Annotation nodeAnnotation = null;
00304 Annotation mda = null;
00305 if (startingNode instanceof StmtTreeNode) {
00306 StmtTreeNode startTreeNode = (StmtTreeNode) startingNode;
00307 mda = startTreeNode.currentMethodDeclarationAnnotation;
00308 nodeAnnotation = startTreeNode.currentStmtAnnotation;
00309 } else
00310 if (startingNode instanceof Annotation) {
00311 if ((startingNode instanceof MethodDeclarationAnnotation) || (startingNode instanceof ConstructorDeclarationAnnotation))
00312 return null;
00313 else {
00314 mda = (Annotation) CompilationManager.getAnnotationManager().getMethodAnnotationContainingAnnotation((Annotation) startingNode);
00315 nodeAnnotation = (Annotation) startingNode;
00316 }
00317 } else
00318 return null;
00319 SootMethod sm = null;
00320 if (mda instanceof MethodDeclarationAnnotation)
00321 sm = ((MethodDeclarationAnnotation) mda).getSootMethod();
00322 else
00323 if (mda instanceof ConstructorDeclarationAnnotation)
00324 sm = ((ConstructorDeclarationAnnotation) mda).getSootMethod();
00325 SliceTraceNode stnForCond = SlicingMethod.sliceTraceContains(new SliceTraceNode(sm, nodeAnnotation));
00326 if (stnForCond == null)
00327 return null;
00328 DefaultMutableTreeNode pathTreeRoot = new DefaultMutableTreeNode("Conditionals");
00329 Set visitedConditionals = new ArraySet();
00330 for (Iterator traceNodeIt = Slicer.allSliceTraceNodes.iterator(); traceNodeIt.hasNext();) {
00331 SliceTraceNode stn = (SliceTraceNode) traceNodeIt.next();
00332 if ((stn.stmtAnnotation instanceof ControlFlowAnnotation) || (stn.stmtAnnotation instanceof ConditionalAnnotation)) {
00333 if (!visitedConditionals.contains(stn)) {
00334 DefaultMutableTreeNode trace = getForwardSliceTraceFrom(stn);
00335 DefaultMutableTreeNode cuttedTrace = cuttingTreeWRT(trace, stnForCond);
00336 if (cuttedTrace != null) {
00337 pathTreeRoot.add(cuttedTrace);
00338 visitedConditionals.add(stn);
00339 }
00340 }
00341 }
00342 }
00343 return pathTreeRoot;
00344 }
00345
00346
00347
00348
00349
00350 public javax.swing.JComboBox getQueryKindComboBox() {
00351 if (ivjQueryKindComboBox == null) {
00352 try {
00353 ivjQueryKindComboBox = new javax.swing.JComboBox();
00354 ivjQueryKindComboBox.setName("QueryKindComboBox");
00355
00356 for (int i = 0; i < queries.length; i++)
00357 ivjQueryKindComboBox.addItem(queries[i]);
00358
00359 } catch (java.lang.Throwable ivjExc) {
00360
00361
00362 handleException(ivjExc);
00363 }
00364 }
00365 return ivjQueryKindComboBox;
00366 }
00367
00368
00369
00370
00371
00372 private javax.swing.JLabel getQueryKindLabel() {
00373 if (ivjQueryKindLabel == null) {
00374 try {
00375 ivjQueryKindLabel = new javax.swing.JLabel();
00376 ivjQueryKindLabel.setName("QueryKindLabel");
00377 ivjQueryKindLabel.setText("Query Kind : ");
00378 ivjQueryKindLabel.setForeground(java.awt.Color.black);
00379
00380
00381 } catch (java.lang.Throwable ivjExc) {
00382
00383
00384 handleException(ivjExc);
00385 }
00386 }
00387 return ivjQueryKindLabel;
00388 }
00389
00390
00391
00392
00393
00394 private javax.swing.JScrollPane getQueryResultScrollPane() {
00395 if (ivjQueryResultScrollPane == null) {
00396 try {
00397 ivjQueryResultScrollPane = new javax.swing.JScrollPane();
00398 ivjQueryResultScrollPane.setName("QueryResultScrollPane");
00399 getQueryResultScrollPane().setViewportView(getQueryResultTree());
00400
00401
00402 } catch (java.lang.Throwable ivjExc) {
00403
00404
00405 handleException(ivjExc);
00406 }
00407 }
00408 return ivjQueryResultScrollPane;
00409 }
00410
00411
00412
00413
00414
00415 private javax.swing.JTree getQueryResultTree() {
00416 if (ivjQueryResultTree == null) {
00417 try {
00418 ivjQueryResultTree = new javax.swing.JTree();
00419 ivjQueryResultTree.setName("QueryResultTree");
00420 ivjQueryResultTree.setBackground(new java.awt.Color(204,204,204));
00421 ivjQueryResultTree.setBounds(0, 0, 78, 72);
00422
00423 currentQueryResultTreeRoot = new DefaultMutableTreeNode("");
00424 getQueryResultTree().setModel(new DefaultTreeModel(currentQueryResultTreeRoot));
00425 getQueryResultScrollPane().validate();
00426 getQueryResultScrollPane().repaint();
00427 ivjQueryResultTree.setUI(new javax.swing.plaf.metal.MetalTreeUI() {
00428 public javax.swing.plaf.metal.MetalTreeUI setAngledColor() {
00429 setHashColor(java.awt.Color.black);
00430 return this;
00431 }
00432 }
00433 .setAngledColor());
00434 ivjQueryResultTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
00435 ivjQueryResultTree.setCellRenderer(new DefaultTreeCellRenderer() {
00436 public java.awt.Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded, boolean leaf, int row, boolean hasFocus) {
00437 super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus);
00438 Object o = ((DefaultMutableTreeNode) value).getUserObject();
00439 setForeground(java.awt.Color.black);
00440 setIcon(null);
00441 return this;
00442 }
00443 });
00444 ((DefaultTreeCellRenderer) ivjQueryResultTree.getCellRenderer()).setBackgroundNonSelectionColor(new java.awt.Color(204, 204, 204));
00445 ((DefaultTreeCellRenderer) ivjQueryResultTree.getCellRenderer()).setBackgroundSelectionColor(Preferences.getHighlightColor());
00446 ivjQueryResultTree.putClientProperty("JTree.lineStyle", "Angled");
00447
00448
00449 } catch (java.lang.Throwable ivjExc) {
00450
00451
00452 handleException(ivjExc);
00453 }
00454 }
00455 return ivjQueryResultTree;
00456 }
00457
00458
00459
00460
00461 private void handleException(java.lang.Throwable exception) {
00462
00463
00464
00465
00466 }
00467
00468
00469
00470
00471
00472 private void initConnections() throws java.lang.Exception {
00473
00474
00475 getQueryKindComboBox().addActionListener(this);
00476 getQueryResultTree().addTreeSelectionListener(this);
00477 getQueryResultTree().addMouseListener(this);
00478 }
00479
00480
00481
00482
00483 private void initialize() {
00484 try {
00485
00486
00487 setName("QueryPanel");
00488 setLayout(new java.awt.GridBagLayout());
00489 setSize(501, 289);
00490
00491 java.awt.GridBagConstraints constraintsQueryKindLabel = new java.awt.GridBagConstraints();
00492 constraintsQueryKindLabel.gridx = 0; constraintsQueryKindLabel.gridy = 0;
00493 constraintsQueryKindLabel.insets = new java.awt.Insets(4, 4, 4, 4);
00494 add(getQueryKindLabel(), constraintsQueryKindLabel);
00495
00496 java.awt.GridBagConstraints constraintsQueryKindComboBox = new java.awt.GridBagConstraints();
00497 constraintsQueryKindComboBox.gridx = 1; constraintsQueryKindComboBox.gridy = 0;
00498 constraintsQueryKindComboBox.fill = java.awt.GridBagConstraints.HORIZONTAL;
00499 constraintsQueryKindComboBox.weightx = 1.0;
00500 constraintsQueryKindComboBox.insets = new java.awt.Insets(4, 4, 4, 4);
00501 add(getQueryKindComboBox(), constraintsQueryKindComboBox);
00502
00503 java.awt.GridBagConstraints constraintsQueryResultScrollPane = new java.awt.GridBagConstraints();
00504 constraintsQueryResultScrollPane.gridx = 0; constraintsQueryResultScrollPane.gridy = 1;
00505 constraintsQueryResultScrollPane.gridwidth = 2;
00506 constraintsQueryResultScrollPane.fill = java.awt.GridBagConstraints.BOTH;
00507 constraintsQueryResultScrollPane.weightx = 1.0;
00508 constraintsQueryResultScrollPane.weighty = 1.0;
00509 constraintsQueryResultScrollPane.insets = new java.awt.Insets(4, 4, 4, 4);
00510 add(getQueryResultScrollPane(), constraintsQueryResultScrollPane);
00511 initConnections();
00512 } catch (java.lang.Throwable ivjExc) {
00513 handleException(ivjExc);
00514 }
00515
00516
00517 }
00518
00519
00520
00521
00522 public static void main(java.lang.String[] args) {
00523 try {
00524 JFrame frame = new javax.swing.JFrame();
00525 QueryPanel aQueryPanel;
00526 aQueryPanel = new QueryPanel();
00527 frame.setContentPane(aQueryPanel);
00528 frame.setSize(aQueryPanel.getSize());
00529 frame.addWindowListener(new java.awt.event.WindowAdapter() {
00530 public void windowClosing(java.awt.event.WindowEvent e) {
00531 System.exit(0);
00532 };
00533 });
00534 frame.setVisible(true);
00535 } catch (Throwable exception) {
00536 System.err.println("Exception occurred in main() of javax.swing.JPanel");
00537 exception.printStackTrace(System.out);
00538 }
00539 }
00540
00541
00542
00543
00544
00545 public void mouseClicked(java.awt.event.MouseEvent e) {
00546
00547
00548 if (e.getSource() == getQueryResultTree())
00549 connEtoC3(e);
00550
00551
00552 }
00553
00554
00555
00556
00557
00558 public void mouseEntered(java.awt.event.MouseEvent e) {
00559
00560
00561
00562
00563 }
00564
00565
00566
00567
00568
00569 public void mouseExited(java.awt.event.MouseEvent e) {
00570
00571
00572
00573
00574 }
00575
00576
00577
00578
00579
00580 public void mousePressed(java.awt.event.MouseEvent e) {
00581
00582
00583
00584
00585 }
00586
00587
00588
00589
00590
00591 public void mouseReleased(java.awt.event.MouseEvent e) {
00592
00593
00594
00595
00596 }
00597
00598
00599
00600 public void queryKindComboBox_ActionEvents() {
00601 int selectedIndex = getQueryKindComboBox().getSelectedIndex();
00602 if (selectedIndex == NO_QUERY) {
00603 currentQueryResultTreeRoot = new DefaultMutableTreeNode("");
00604 getQueryResultTree().setModel(new DefaultTreeModel(currentQueryResultTreeRoot));
00605 } else {
00606 if (dependFrame.currentNode == null) {
00607 JOptionPane.showMessageDialog(this, "Please select one statement for query.", "Select Statement", JOptionPane.WARNING_MESSAGE);
00608 getQueryKindComboBox().setSelectedIndex(NO_QUERY);
00609 return;
00610 }
00611 dependFrame.criterionViewer.runSlicerWithCurrentCriterion();
00612 if (dependFrame.criterionViewer.runningCriterion == null) {
00613 JOptionPane.showMessageDialog(this, "You can not query on the current node, since the node is not a statement.", "Can not run slicer", JOptionPane.WARNING_MESSAGE);
00614 getQueryKindComboBox().setSelectedIndex(NO_QUERY);
00615 return;
00616 }
00617 if (selectedIndex == SLICE_TRACE) {
00618 currentQueryResultTreeRoot = getDependencyPathTreeStartFrom(dependFrame.currentNode);
00619 getQueryResultTree().setModel(new DefaultTreeModel(currentQueryResultTreeRoot));
00620 } else
00621 if (selectedIndex == ALL_CONDITIONALS) {
00622 currentQueryResultTreeRoot = getIfDependencyPathTree();
00623 getQueryResultTree().setModel(new DefaultTreeModel(currentQueryResultTreeRoot));
00624 } else
00625 if (selectedIndex == CONDITIONALS_TO_CURRENT_STMT) {
00626 currentQueryResultTreeRoot = getIfDependencyPathTreeForNode(dependFrame.currentNode);
00627 getQueryResultTree().setModel(new DefaultTreeModel(currentQueryResultTreeRoot));
00628 }
00629 }
00630 return;
00631 }
00632
00633
00634
00635 public void queryResultTree_MouseClicked(java.awt.event.MouseEvent mouseEvent) {
00636 int selRow = getQueryResultTree().getRowForLocation(mouseEvent.getX(), mouseEvent.getY());
00637
00638 if (selRow != -1) {
00639 if (mouseEvent.getClickCount() == 1) {
00640
00641
00642 } else
00643 if (mouseEvent.getClickCount() == 2) {
00644
00645
00646 DefaultMutableTreeNode queryTreeSelected = (DefaultMutableTreeNode) getQueryResultTree().getLastSelectedPathComponent();
00647 if (queryTreeSelected == null)
00648 return;
00649 Object userObject = queryTreeSelected.getUserObject();
00650 StmtTreeNode selectedNode = dependFrame.getDependencyValueViewer().getSelectedStmtTreeNode(userObject);
00651 dependFrame.addSelectedNodeToDependFrame(selectedNode);
00652
00653 }
00654 }
00655 return;
00656 }
00657
00658
00659
00660 public void queryResultTree_TreeSelectionEvents() {
00661 DefaultMutableTreeNode lastSelectedNode = (DefaultMutableTreeNode) getQueryResultTree().getLastSelectedPathComponent();
00662 if (lastSelectedNode == null)
00663 return;
00664 if (lastSelectedNode.isRoot()) {
00665 dependFrame.getCodeBrowserPane().setCurrentNodeSelected(dependFrame.currentNode);
00666 return;
00667 }
00668 Object userObject = lastSelectedNode.getUserObject();
00669 if (userObject.equals(dependFrame.currentNode) || (userObject instanceof String))
00670 return;
00671 StmtTreeNode selectedNode = dependFrame.getDependencyValueViewer().getSelectedStmtTreeNode(userObject);
00672 dependFrame.getCodeBrowserPane().setCurrentNodeSelected(selectedNode);
00673 return;
00674 }
00675
00676
00677
00678
00679
00680 void setDependFrame(Dependencies df) {
00681 dependFrame = df;
00682 }
00683
00684
00685
00686
00687
00688
00689 private boolean sliceTraceContains(DefaultMutableTreeNode root, SliceTraceNode sliceTraceNode) {
00690 for (Enumeration enum = root.depthFirstEnumeration(); enum.hasMoreElements();) {
00691 DefaultMutableTreeNode node = (DefaultMutableTreeNode) enum.nextElement();
00692 SliceTraceNode stn = (SliceTraceNode) node.getUserObject();
00693 if (stn.equals(sliceTraceNode))
00694 return true;
00695 }
00696 return false;
00697 }
00698
00699
00700
00701
00702
00703
00704
00705 private boolean traceRootIs(DefaultMutableTreeNode root, SliceTraceNode stn) {
00706 SliceTraceNode rootNode = (SliceTraceNode) root.getUserObject();
00707 if (rootNode.equals(stn))
00708 return true;
00709 else
00710 return false;
00711 }
00712
00713
00714
00715
00716
00717 public void valueChanged(javax.swing.event.TreeSelectionEvent e) {
00718
00719
00720 if (e.getSource() == getQueryResultTree())
00721 connEtoC2();
00722
00723
00724 }
00725 }