Main Page   Packages   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members  

CriterionViewer.java

00001 package edu.ksu.cis.bandera.pdgslicer.dependency;
00002 
00003 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
00004  * Bandera, a Java(TM) analysis and transformation toolkit           *
00005  * Copyright (C) 1998-2001 SAnToS Laboratories (santos@cis.ksu.edu)  *
00006 
00007  * All rights reserved.                                              *
00008  *                                                                   *
00009  * This work was done as a project in the SAnToS Laboratory,         *
00010  * Department of Computing and Information Sciences, Kansas State    *
00011  * University, USA (http://www.cis.ksu.edu/santos).                  *
00012  * It is understood that any modification not identified as such is  *
00013  * not covered by the preceding statement.                           *
00014  *                                                                   *
00015  * This work is free software; you can redistribute it and/or        *
00016  * modify it under the terms of the GNU Library General Public       *
00017  * License as published by the Free Software Foundation; either      *
00018  * version 2 of the License, or (at your option) any later version.  *
00019  *                                                                   *
00020  * This work is distributed in the hope that it will be useful,      *
00021  * but WITHOUT ANY WARRANTY; without even the implied warranty of    *
00022  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU *
00023  * Library General Public License for more details.                  *
00024  *                                                                   *
00025  * You should have received a copy of the GNU Library General Public *
00026  * License along with this toolkit; if not, write to the             *
00027  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,      *
00028  * Boston, MA  02111-1307, USA.                                      *
00029  *                                                                   *
00030  * Java is a trademark of Sun Microsystems, Inc.                     *
00031  *                                                                   *
00032  * To submit a bug report, send a comment, or get the latest news on *
00033  * this project and other SAnToS projects, please visit the web-site *
00034  *                http://www.cis.ksu.edu/santos                      *
00035  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
00036 import javax.swing.*;
00037 import java.util.*;
00038 import edu.ksu.cis.bandera.pdgslicer.datastructure.*;
00039 import edu.ksu.cis.bandera.jjjc.CompilationManager;
00040 import edu.ksu.cis.bandera.annotation.*;
00041 import ca.mcgill.sable.soot.*;
00042 import ca.mcgill.sable.soot.jimple.*;
00043 /**
00044  * Insert the type's description here.
00045  * Creation date: (00-10-24 10:40:14)
00046  * @author: 
00047  */
00048 public class CriterionViewer extends JPanel {
00049     private boolean setSelectedByProgram = false;
00050     private Vector currentCriterion = new Vector();
00051     private Vector lastTimeRunningCriterion = new Vector();
00052     Vector runningCriterion = null;
00053     private JLabel ivjLocationsLabel = null;
00054     private DroppableLocationsList ivjLocationsList = null;
00055     private JPanel ivjLocationsPanel = null;
00056     private JScrollPane ivjLocationsScrollPane = null;
00057     private JSplitPane ivjPointVarSplitPane = null;
00058     private JButton ivjRemoveLocationButton = null;
00059     private JButton ivjRemoveStatementButton = null;
00060     private JButton ivjRemoveVarsButton = null;
00061     private JLabel ivjStatementLabel = null;
00062     private JPanel ivjStatementPanel = null;
00063     private JScrollPane ivjStatementScrollPane = null;
00064     private JSplitPane ivjStmtControlSplitPane = null;
00065     private JLabel ivjVarsLabel = null;
00066     private DroppableVariablesList ivjVarsList = null;
00067     private JPanel ivjVarsPanel = null;
00068     private JScrollPane ivjVarsScrollPane = null;
00069     private JSplitPane ivjLocationsVarsSplitPane = null;
00070     private DraggableVariablesList ivjLocationVarsList = null;
00071     private JScrollPane ivjLocationVarsScrollPane = null;
00072     private DroppableStatementsList ivjStatementsList = null;
00073     private Dependencies dependFrame;
00074     IvjEventHandler ivjEventHandler = new IvjEventHandler();
00075 
00076 class IvjEventHandler implements java.awt.event.ActionListener, java.awt.event.MouseListener, javax.swing.event.ListSelectionListener {
00077         public void actionPerformed(java.awt.event.ActionEvent e) {
00078             if (e.getSource() == CriterionViewer.this.getRemoveStatementButton()) 
00079                 connEtoC1();
00080             if (e.getSource() == CriterionViewer.this.getRemoveLocationButton()) 
00081                 connEtoC2();
00082             if (e.getSource() == CriterionViewer.this.getRemoveVarsButton()) 
00083                 connEtoC3();
00084         };
00085         public void mouseClicked(java.awt.event.MouseEvent e) {
00086             if (e.getSource() == CriterionViewer.this.getStatementsList()) 
00087                 connEtoC6(e);
00088             if (e.getSource() == CriterionViewer.this.getLocationsList()) 
00089                 connEtoC7(e);
00090         };
00091         public void mouseEntered(java.awt.event.MouseEvent e) {};
00092         public void mouseExited(java.awt.event.MouseEvent e) {};
00093         public void mousePressed(java.awt.event.MouseEvent e) {};
00094         public void mouseReleased(java.awt.event.MouseEvent e) {};
00095         public void valueChanged(javax.swing.event.ListSelectionEvent e) {
00096             if (e.getSource() == CriterionViewer.this.getLocationsList()) 
00097                 connEtoC4();
00098             if (e.getSource() == CriterionViewer.this.getStatementsList()) 
00099                 connEtoC5();
00100             if (e.getSource() == CriterionViewer.this.getVarsList()) 
00101                 connEtoC8();
00102             if (e.getSource() == CriterionViewer.this.getLocationVarsList()) 
00103                 connEtoC9();
00104         };
00105     };
00106 /**
00107  * CriterionViewer constructor comment.
00108  */
00109 public CriterionViewer() {
00110     super();
00111     initialize();
00112 }
00113 /**
00114  * CriterionViewer constructor comment.
00115  * @param layout java.awt.LayoutManager
00116  */
00117 public CriterionViewer(java.awt.LayoutManager layout) {
00118     super(layout);
00119 }
00120 /**
00121  * CriterionViewer constructor comment.
00122  * @param layout java.awt.LayoutManager
00123  * @param isDoubleBuffered boolean
00124  */
00125 public CriterionViewer(java.awt.LayoutManager layout, boolean isDoubleBuffered) {
00126     super(layout, isDoubleBuffered);
00127 }
00128 /**
00129  * CriterionViewer constructor comment.
00130  * @param isDoubleBuffered boolean
00131  */
00132 public CriterionViewer(boolean isDoubleBuffered) {
00133     super(isDoubleBuffered);
00134 }
00135 /**
00136  * Insert the method's description here.
00137  * Creation date: (00-6-21 1:13:28)
00138  * @param var java.lang.Object
00139  */
00140 void addLocationToCriterion(Object location, Annotation locationAnnotation) {
00141     if (!dependFrame.getBackwardSliceToolBarButton().isEnabled())
00142         dependFrame.getBackwardSliceToolBarButton().setEnabled(true);
00143     int locationIndex = currentCriterion.indexOf(location);
00144     if (locationIndex >= 0) {
00145         System.out.println("the point has been in the current criterion");
00146         return;
00147     }
00148     currentCriterion.add(location);
00149     DefaultListModel listModel = null;
00150     //(DefaultListModel) getLocationsList().getModel();
00151     SlicePoint sp = (SlicePoint) location;
00152     LocationNodeInCriterionViewer ln = null;
00153     ln = new LocationNodeInCriterionViewer(sp.getSootMethod(), locationAnnotation, sp);
00154     listModel = (DefaultListModel) getLocationsList().getModel();
00155 
00156     listModel.addElement(ln);
00157     setSelectedByProgram = true;
00158     getLocationsList().setSelectedValue(ln, true);
00159     getStatementsList().clearSelection();
00160     calculateLocalsFor(ln);
00161     setSelectedByProgram = false;
00162 }
00163 /**
00164  * Insert the method's description here.
00165  * Creation date: (00-6-21 1:13:28)
00166  * @param var java.lang.Object
00167  */
00168 void addStatementToCriterion(Object location, SlicePoint[] locationArray, Annotation locationAnnotation) {
00169     if (!dependFrame.getBackwardSliceToolBarButton().isEnabled())
00170         dependFrame.getBackwardSliceToolBarButton().setEnabled(true);
00171     int locationIndex = currentCriterion.indexOf(location);
00172     if (locationIndex >= 0) {
00173         Object location2 = currentCriterion.get(locationIndex);
00174         if (location2 instanceof SliceStatement) {
00175             System.out.println("the statement has been in the current criterion");
00176             return;
00177         } else
00178             if (location2 instanceof SlicePoint) {
00179                 currentCriterion.remove(location2);
00180                 currentCriterion.add(location);
00181                 SlicePoint sp = (SlicePoint) location;
00182                 LocationNodeInCriterionViewer ln = new StatementNodeInCriterionViewer(sp.getSootMethod(), locationAnnotation, sp,locationArray);
00183                 DefaultListModel listModel = (DefaultListModel) getStatementsList().getModel();
00184                 listModel.addElement(ln);
00185                 setSelectedByProgram = true;
00186                 getStatementsList().setSelectedValue(ln, true);
00187                 getLocationsList().clearSelection();
00188                 calculateLocalsFor(ln);
00189                 setSelectedByProgram = false;
00190                 //remove location2 from location list
00191                 listModel = (DefaultListModel) getLocationsList().getModel();
00192                 removeLocationFrom(location2, listModel);
00193                 return;
00194             }
00195     }
00196     currentCriterion.add(location);
00197     DefaultListModel listModel = null;
00198     //(DefaultListModel) getLocationsList().getModel();
00199     SlicePoint sp = (SlicePoint) location;
00200     LocationNodeInCriterionViewer ln = null;
00201 
00202     //ln = new StatementNodeInCriterionViewer(sp.getSootMethod(), locationAnnotation, sp);
00203     listModel = (DefaultListModel) getStatementsList().getModel();
00204     if (!statementsListContains(listModel, locationAnnotation))
00205         ln = new StatementNodeInCriterionViewer(sp.getSootMethod(), locationAnnotation, sp, locationArray);
00206     if (ln == null)
00207         return;
00208     listModel.addElement(ln);
00209     setSelectedByProgram = true;
00210     getStatementsList().setSelectedValue(ln, true);
00211     getLocationsList().clearSelection();
00212     //calculateLocalsFor(ln);
00213     setSelectedByProgram = false;
00214 }
00215 /**
00216  * Insert the method's description here.
00217  * Creation date: (00-6-21 1:13:28)
00218  * @param var java.lang.Object
00219  */
00220 void addVarToCriterion(Object var) {
00221     if (!dependFrame.getBackwardSliceToolBarButton().isEnabled())
00222         dependFrame.getBackwardSliceToolBarButton().setEnabled(true);
00223     if (currentCriterion.contains(var)) {
00224         System.out.println("the variable has been in the current criterion");
00225         return;
00226     }
00227     currentCriterion.add(var);
00228     DefaultListModel listModel = (DefaultListModel) getVarsList().getModel();
00229     listModel.addElement(var);
00230 }
00231 /**
00232  * Insert the method's description here.
00233  * Creation date: (00-12-4 13:55:17)
00234  * @return java.util.Vector
00235  * @param currentNode java.lang.Object
00236  */
00237 private Vector buildCriterionForCurrentNode(Object currentNode) {
00238     Vector returnCriterion = null;
00239     if (currentNode instanceof StmtTreeNode) {
00240         StmtTreeNode stn = (StmtTreeNode) currentNode;
00241         Annotation currentStmtAnnotation = stn.currentStmtAnnotation;
00242         if ((currentStmtAnnotation instanceof MethodDeclarationAnnotation) || (currentStmtAnnotation instanceof ConstructorDeclarationAnnotation))
00243             return null;
00244         returnCriterion = new Vector();
00245         Annotation currentMda = stn.currentMethodDeclarationAnnotation;
00246         SootMethod sm = ((MethodDeclarationAnnotation) currentMda).getSootMethod();
00247         SootClass sc = stn.currentSootClass;
00248         Stmt stmts[] = currentStmtAnnotation.getStatements();
00249         for (int i = 0; i < stmts.length; i++) {
00250             Stmt stmt = stmts[i];
00251             int sind = SlicePoint.getStmtIndex(sm, stmt);
00252             SliceStatement sliceStmt = new SliceStatement(sc, sm, stmt, sind);
00253             returnCriterion.addElement(sliceStmt);
00254         }
00255     }
00256     return returnCriterion;
00257 }
00258 private Vector buildLocalListFor(Annotation annotation, SootMethod sm) {
00259     Vector localList = new Vector();
00260     String className = null;
00261     SootClass sc = null;
00262     Object leftAnnotation = CompilationManager.getAnnotationManager().getMethodAnnotationContainingAnnotation(annotation);
00263     sc = sm.getDeclaringClass();
00264     className = sc.getName().trim();
00265     Hashtable table = annotation.getDeclaredLocalVariables();
00266     for (Enumeration e = table.keys(); e.hasMoreElements();) {
00267         String name = (String) e.nextElement();
00268         Local local = (Local) table.get(name);
00269         if (local.getType() instanceof ca.mcgill.sable.soot.ArrayType) {
00270         } else
00271             if (local.getType() instanceof RefType) {
00272                 SliceLocal sl = new SliceLocal(sc, sm, local);
00273                 localList.addElement(sl);
00274             } else {
00275                 SliceLocal sl = new SliceLocal(sc, sm, local);
00276                 localList.addElement(sl);
00277             }
00278     }
00279     return localList;
00280 }
00281 /**
00282  * Insert the method's description here.
00283  * Creation date: (00-11-27 17:41:42)
00284  * @param ln edu.ksu.cis.bandera.pdgslicer.dependency.LocationNodeInCriterionViewer
00285  */
00286 private void calculateLocalsFor(LocationNodeInCriterionViewer locationNode) {
00287     Vector locals = buildLocalListFor(locationNode.stmtAnnotation, locationNode.sootMethod);
00288     DefaultListModel listModel = (DefaultListModel) getLocationVarsList().getModel();
00289     listModel.removeAllElements();
00290     for (Enumeration e = locals.elements(); e.hasMoreElements();)
00291         listModel.addElement(e.nextElement());
00292 }
00293 /**
00294  * Comment
00295  */
00296 SlicePoint calculateSlicePoint(Object userObjectInMethodTree) {
00297     if (!(userObjectInMethodTree instanceof Annotation))
00298         return null;
00299     SlicePoint sp = null;
00300     Annotation a = (Annotation) userObjectInMethodTree;
00301     Annotation leftAnnotation = CompilationManager.getAnnotationManager().getMethodAnnotationContainingAnnotation(a);
00302     if (leftAnnotation instanceof ConstructorDeclarationAnnotation) {
00303         ConstructorDeclarationAnnotation ann = (ConstructorDeclarationAnnotation) leftAnnotation;
00304         SootMethod sm = ann.getSootMethod();
00305         SootClass sc = sm.getDeclaringClass();
00306         Stmt stmts[] = a.getStatements();
00307         Stmt stmt = stmts[0];
00308         int sind = SlicePoint.getStmtIndex(sm, stmts[0]);
00309         sp = new SlicePoint(sc, sm, stmt, sind);
00310         //addLocationToCriterion(sp, a);
00311     } else
00312         if (leftAnnotation instanceof MethodDeclarationAnnotation) {
00313             MethodDeclarationAnnotation ann = (MethodDeclarationAnnotation) leftAnnotation;
00314             SootMethod sm = ann.getSootMethod();
00315             SootClass sc = sm.getDeclaringClass();
00316             Stmt stmts[] = a.getStatements();
00317             Stmt stmt = stmts[0];
00318             int sind = SlicePoint.getStmtIndex(sm, stmts[0]);
00319             sp = new SlicePoint(sc, sm, stmt, sind);
00320             //addLocationToCriterion(sp, a);
00321         }
00322     return sp;
00323 }
00324 /**
00325  * Comment
00326  */
00327 SlicePoint[] calculateSliceStatements(Object userObjectInMethodTree) {
00328     if (!(userObjectInMethodTree instanceof Annotation))
00329         return null;
00330     SlicePoint[] sp = null;
00331     Annotation a = (Annotation) userObjectInMethodTree;
00332     Annotation leftAnnotation = CompilationManager.getAnnotationManager().getMethodAnnotationContainingAnnotation(a);
00333     if (leftAnnotation instanceof ConstructorDeclarationAnnotation) {
00334         ConstructorDeclarationAnnotation ann = (ConstructorDeclarationAnnotation) leftAnnotation;
00335         SootMethod sm = ann.getSootMethod();
00336         SootClass sc = sm.getDeclaringClass();
00337         Stmt stmts[] = a.getStatements();
00338         sp = new SlicePoint[stmts.length];
00339         for (int i = 0; i < stmts.length; i++) {
00340             Stmt stmt = stmts[i];
00341             int sind = SlicePoint.getStmtIndex(sm, stmt);
00342             sp[i] = new SliceStatement(sc, sm, stmt, sind);
00343         }
00344         //addLocationToCriterion(sp, a);
00345     } else
00346         if (leftAnnotation instanceof MethodDeclarationAnnotation) {
00347             MethodDeclarationAnnotation ann = (MethodDeclarationAnnotation) leftAnnotation;
00348             SootMethod sm = ann.getSootMethod();
00349             SootClass sc = sm.getDeclaringClass();
00350             Stmt stmts[] = a.getStatements();
00351             sp = new SlicePoint[stmts.length];
00352             for (int i = 0; i < stmts.length; i++) {
00353                 Stmt stmt = stmts[i];
00354                 int sind = SlicePoint.getStmtIndex(sm, stmts[i]);
00355                 sp[i] = new SliceStatement(sc, sm, stmt, sind);
00356             }
00357             //addLocationToCriterion(sp, a);
00358         }
00359     return sp;
00360 }
00361 /**
00362  * connEtoC1:  (RemoveStatementButton.action. --> CriterionViewer.removeStatementButton_ActionEvents()V)
00363  */
00364 /* WARNING: THIS METHOD WILL BE REGENERATED. */
00365 private void connEtoC1() {
00366     try {
00367         // user code begin {1}
00368         // user code end
00369         this.removeStatementButton_ActionEvents();
00370         // user code begin {2}
00371         // user code end
00372     } catch (java.lang.Throwable ivjExc) {
00373         // user code begin {3}
00374         // user code end
00375         handleException(ivjExc);
00376     }
00377 }
00378 /**
00379  * connEtoC2:  (RemoveLocationButton.action. --> CriterionViewer.removeLocationButton_ActionEvents()V)
00380  */
00381 /* WARNING: THIS METHOD WILL BE REGENERATED. */
00382 private void connEtoC2() {
00383     try {
00384         // user code begin {1}
00385         // user code end
00386         this.removeLocationButton_ActionEvents();
00387         // user code begin {2}
00388         // user code end
00389     } catch (java.lang.Throwable ivjExc) {
00390         // user code begin {3}
00391         // user code end
00392         handleException(ivjExc);
00393     }
00394 }
00395 /**
00396  * connEtoC3:  (RemoveVarsButton.action. --> CriterionViewer.removeVarsButton_ActionEvents()V)
00397  */
00398 /* WARNING: THIS METHOD WILL BE REGENERATED. */
00399 private void connEtoC3() {
00400     try {
00401         // user code begin {1}
00402         // user code end
00403         this.removeVarsButton_ActionEvents();
00404         // user code begin {2}
00405         // user code end
00406     } catch (java.lang.Throwable ivjExc) {
00407         // user code begin {3}
00408         // user code end
00409         handleException(ivjExc);
00410     }
00411 }
00412 /**
00413  * connEtoC4:  (LocationsList.listSelection. --> CriterionViewer.locationsList_ListSelectionEvents()V)
00414  */
00415 /* WARNING: THIS METHOD WILL BE REGENERATED. */
00416 private void connEtoC4() {
00417     try {
00418         // user code begin {1}
00419         if (!setSelectedByProgram)
00420         // user code end
00421         this.locationsList_ListSelectionEvents();
00422         // user code begin {2}
00423         // user code end
00424     } catch (java.lang.Throwable ivjExc) {
00425         // user code begin {3}
00426         // user code end
00427         handleException(ivjExc);
00428     }
00429 }
00430 /**
00431  * connEtoC5:  (StatementsList.listSelection. --> CriterionViewer.statementsList_ListSelectionEvents()V)
00432  */
00433 /* WARNING: THIS METHOD WILL BE REGENERATED. */
00434 private void connEtoC5() {
00435     try {
00436         // user code begin {1}
00437         if (!setSelectedByProgram)
00438         // user code end
00439         this.statementsList_ListSelectionEvents();
00440         // user code begin {2}
00441         // user code end
00442     } catch (java.lang.Throwable ivjExc) {
00443         // user code begin {3}
00444         // user code end
00445         handleException(ivjExc);
00446     }
00447 }
00448 /**
00449  * connEtoC6:  (StatementsList.mouse.mouseClicked(java.awt.event.MouseEvent) --> CriterionViewer.statementsList_MouseClicked(Ljava.awt.event.MouseEvent;)V)
00450  * @param arg1 java.awt.event.MouseEvent
00451  */
00452 /* WARNING: THIS METHOD WILL BE REGENERATED. */
00453 private void connEtoC6(java.awt.event.MouseEvent arg1) {
00454     try {
00455         // user code begin {1}
00456         // user code end
00457         this.statementsList_MouseClicked(arg1);
00458         // user code begin {2}
00459         // user code end
00460     } catch (java.lang.Throwable ivjExc) {
00461         // user code begin {3}
00462         // user code end
00463         handleException(ivjExc);
00464     }
00465 }
00466 /**
00467  * connEtoC7:  (LocationsList.mouse.mouseClicked(java.awt.event.MouseEvent) --> CriterionViewer.locationsList_MouseClicked(Ljava.awt.event.MouseEvent;)V)
00468  * @param arg1 java.awt.event.MouseEvent
00469  */
00470 /* WARNING: THIS METHOD WILL BE REGENERATED. */
00471 private void connEtoC7(java.awt.event.MouseEvent arg1) {
00472     try {
00473         // user code begin {1}
00474         // user code end
00475         this.locationsList_MouseClicked(arg1);
00476         // user code begin {2}
00477         // user code end
00478     } catch (java.lang.Throwable ivjExc) {
00479         // user code begin {3}
00480         // user code end
00481         handleException(ivjExc);
00482     }
00483 }
00484 /**
00485  * connEtoC8:  (VarsList.listSelection. --> CriterionViewer.varsList_ListSelectionEvents()V)
00486  */
00487 /* WARNING: THIS METHOD WILL BE REGENERATED. */
00488 private void connEtoC8() {
00489     try {
00490         // user code begin {1}
00491         if (!setSelectedByProgram)
00492         // user code end
00493         this.varsList_ListSelectionEvents();
00494         // user code begin {2}
00495         // user code end
00496     } catch (java.lang.Throwable ivjExc) {
00497         // user code begin {3}
00498         // user code end
00499         handleException(ivjExc);
00500     }
00501 }
00502 /**
00503  * connEtoC9:  (LocationVarsList.listSelection. --> CriterionViewer.locationVarsList_ListSelectionEvents()V)
00504  */
00505 /* WARNING: THIS METHOD WILL BE REGENERATED. */
00506 private void connEtoC9() {
00507     try {
00508         // user code begin {1}
00509         if (!setSelectedByProgram)
00510         // user code end
00511         this.locationVarsList_ListSelectionEvents();
00512         // user code begin {2}
00513         // user code end
00514     } catch (java.lang.Throwable ivjExc) {
00515         // user code begin {3}
00516         // user code end
00517         handleException(ivjExc);
00518     }
00519 }
00520 /**
00521  * Return the LocationsLabel property value.
00522  * @return javax.swing.JLabel
00523  */
00524 /* WARNING: THIS METHOD WILL BE REGENERATED. */
00525 private javax.swing.JLabel getLocationsLabel() {
00526     if (ivjLocationsLabel == null) {
00527         try {
00528             ivjLocationsLabel = new javax.swing.JLabel();
00529             ivjLocationsLabel.setName("LocationsLabel");
00530             ivjLocationsLabel.setText("Control Slice");
00531             ivjLocationsLabel.setForeground(java.awt.Color.black);
00532             ivjLocationsLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
00533             // user code begin {1}
00534             // user code end
00535         } catch (java.lang.Throwable ivjExc) {
00536             // user code begin {2}
00537             // user code end
00538             handleException(ivjExc);
00539         }
00540     }
00541     return ivjLocationsLabel;
00542 }
00543 /**
00544  * Return the LocationsList property value.
00545  * @return edu.ksu.cis.bandera.pdgslicer.dependency.DroppableLocationsList
00546  */
00547 /* WARNING: THIS METHOD WILL BE REGENERATED. */
00548 private DroppableLocationsList getLocationsList() {
00549     if (ivjLocationsList == null) {
00550         try {
00551             ivjLocationsList = new edu.ksu.cis.bandera.pdgslicer.dependency.DroppableLocationsList();
00552             ivjLocationsList.setName("LocationsList");
00553             ivjLocationsList.setBounds(0, 0, 160, 120);
00554             // user code begin {1}
00555             ivjLocationsList.setCriterionViewer(this);
00556             // user code end
00557         } catch (java.lang.Throwable ivjExc) {
00558             // user code begin {2}
00559             // user code end
00560             handleException(ivjExc);
00561         }
00562     }
00563     return ivjLocationsList;
00564 }
00565 /**
00566  * Return the LocationsPanel property value.
00567  * @return javax.swing.JPanel
00568  */
00569 /* WARNING: THIS METHOD WILL BE REGENERATED. */
00570 private javax.swing.JPanel getLocationsPanel() {
00571     if (ivjLocationsPanel == null) {
00572         try {
00573             ivjLocationsPanel = new javax.swing.JPanel();
00574             ivjLocationsPanel.setName("LocationsPanel");
00575             ivjLocationsPanel.setLayout(new java.awt.BorderLayout());
00576             getLocationsPanel().add(getLocationsLabel(), "North");
00577             getLocationsPanel().add(getRemoveLocationButton(), "South");
00578             getLocationsPanel().add(getLocationsVarsSplitPane(), "Center");
00579             // user code begin {1}
00580             // user code end
00581         } catch (java.lang.Throwable ivjExc) {
00582             // user code begin {2}
00583             // user code end
00584             handleException(ivjExc);
00585         }
00586     }
00587     return ivjLocationsPanel;
00588 }
00589 /**
00590  * Return the LocationsScrollPane property value.
00591  * @return javax.swing.JScrollPane
00592  */
00593 /* WARNING: THIS METHOD WILL BE REGENERATED. */
00594 private javax.swing.JScrollPane getLocationsScrollPane() {
00595     if (ivjLocationsScrollPane == null) {
00596         try {
00597             ivjLocationsScrollPane = new javax.swing.JScrollPane();
00598             ivjLocationsScrollPane.setName("LocationsScrollPane");
00599             getLocationsScrollPane().setViewportView(getLocationsList());
00600             // user code begin {1}
00601             // user code end
00602         } catch (java.lang.Throwable ivjExc) {
00603             // user code begin {2}
00604             // user code end
00605             handleException(ivjExc);
00606         }
00607     }
00608     return ivjLocationsScrollPane;
00609 }
00610 /**
00611  * Return the LocationsVarsSplitPane property value.
00612  * @return javax.swing.JSplitPane
00613  */
00614 /* WARNING: THIS METHOD WILL BE REGENERATED. */
00615 public javax.swing.JSplitPane getLocationsVarsSplitPane() {
00616     if (ivjLocationsVarsSplitPane == null) {
00617         try {
00618             ivjLocationsVarsSplitPane = new javax.swing.JSplitPane(javax.swing.JSplitPane.HORIZONTAL_SPLIT);
00619             ivjLocationsVarsSplitPane.setName("LocationsVarsSplitPane");
00620             ivjLocationsVarsSplitPane.setDividerSize(1);
00621             ivjLocationsVarsSplitPane.setDividerLocation(40);
00622             getLocationsVarsSplitPane().add(getLocationsScrollPane(), "left");
00623             getLocationsVarsSplitPane().add(getLocationVarsScrollPane(), "right");
00624             // user code begin {1}
00625             ivjLocationsVarsSplitPane.setDividerLocation(80);
00626             // user code end
00627         } catch (java.lang.Throwable ivjExc) {
00628             // user code begin {2}
00629             // user code end
00630             handleException(ivjExc);
00631         }
00632     }
00633     return ivjLocationsVarsSplitPane;
00634 }
00635 /**
00636  * Return the LocationVarsList property value.
00637  * @return edu.ksu.cis.bandera.pdgslicer.dependency.DraggableVariablesList
00638  */
00639 /* WARNING: THIS METHOD WILL BE REGENERATED. */
00640 private DraggableVariablesList getLocationVarsList() {
00641     if (ivjLocationVarsList == null) {
00642         try {
00643             ivjLocationVarsList = new edu.ksu.cis.bandera.pdgslicer.dependency.DraggableVariablesList();
00644             ivjLocationVarsList.setName("LocationVarsList");
00645             ivjLocationVarsList.setBounds(0, 0, 160, 120);
00646             // user code begin {1}
00647             // user code end
00648         } catch (java.lang.Throwable ivjExc) {
00649             // user code begin {2}
00650             // user code end
00651             handleException(ivjExc);
00652         }
00653     }
00654     return ivjLocationVarsList;
00655 }
00656 /**
00657  * Return the LocationVarsScrollPane property value.
00658  * @return javax.swing.JScrollPane
00659  */
00660 /* WARNING: THIS METHOD WILL BE REGENERATED. */
00661 private javax.swing.JScrollPane getLocationVarsScrollPane() {
00662     if (ivjLocationVarsScrollPane == null) {
00663         try {
00664             ivjLocationVarsScrollPane = new javax.swing.JScrollPane();
00665             ivjLocationVarsScrollPane.setName("LocationVarsScrollPane");
00666             getLocationVarsScrollPane().setViewportView(getLocationVarsList());
00667             // user code begin {1}
00668             // user code end
00669         } catch (java.lang.Throwable ivjExc) {
00670             // user code begin {2}
00671             // user code end
00672             handleException(ivjExc);
00673         }
00674     }
00675     return ivjLocationVarsScrollPane;
00676 }
00677 /**
00678  * Return the PointVarSplitPane property value.
00679  * @return javax.swing.JSplitPane
00680  */
00681 /* WARNING: THIS METHOD WILL BE REGENERATED. */
00682 public javax.swing.JSplitPane getPointVarSplitPane() {
00683     if (ivjPointVarSplitPane == null) {
00684         try {
00685             ivjPointVarSplitPane = new javax.swing.JSplitPane(javax.swing.JSplitPane.HORIZONTAL_SPLIT);
00686             ivjPointVarSplitPane.setName("PointVarSplitPane");
00687             ivjPointVarSplitPane.setDividerSize(2);
00688             ivjPointVarSplitPane.setDividerLocation(200);
00689             getPointVarSplitPane().add(getStmtControlSplitPane(), "left");
00690             getPointVarSplitPane().add(getVarsPanel(), "right");
00691             // user code begin {1}
00692             //getPointVarSplitPane().setDividerLocation(800);
00693             // user code end
00694         } catch (java.lang.Throwable ivjExc) {
00695             // user code begin {2}
00696             // user code end
00697             handleException(ivjExc);
00698         }
00699     }
00700     return ivjPointVarSplitPane;
00701 }
00702 /**
00703  * Return the RemoveLocationButton property value.
00704  * @return javax.swing.JButton
00705  */
00706 /* WARNING: THIS METHOD WILL BE REGENERATED. */
00707 private javax.swing.JButton getRemoveLocationButton() {
00708     if (ivjRemoveLocationButton == null) {
00709         try {
00710             ivjRemoveLocationButton = new javax.swing.JButton();
00711             ivjRemoveLocationButton.setName("RemoveLocationButton");
00712             ivjRemoveLocationButton.setText("Remove Control Point");
00713             // user code begin {1}
00714             // user code end
00715         } catch (java.lang.Throwable ivjExc) {
00716             // user code begin {2}
00717             // user code end
00718             handleException(ivjExc);
00719         }
00720     }
00721     return ivjRemoveLocationButton;
00722 }
00723 /**
00724  * Return the RemoveStatementButton property value.
00725  * @return javax.swing.JButton
00726  */
00727 /* WARNING: THIS METHOD WILL BE REGENERATED. */
00728 private javax.swing.JButton getRemoveStatementButton() {
00729     if (ivjRemoveStatementButton == null) {
00730         try {
00731             ivjRemoveStatementButton = new javax.swing.JButton();
00732             ivjRemoveStatementButton.setName("RemoveStatementButton");
00733             ivjRemoveStatementButton.setText("Remove Statement");
00734             // user code begin {1}
00735             // user code end
00736         } catch (java.lang.Throwable ivjExc) {
00737             // user code begin {2}
00738             // user code end
00739             handleException(ivjExc);
00740         }
00741     }
00742     return ivjRemoveStatementButton;
00743 }
00744 /**
00745  * Return the RemoveVarsButton property value.
00746  * @return javax.swing.JButton
00747  */
00748 /* WARNING: THIS METHOD WILL BE REGENERATED. */
00749 private javax.swing.JButton getRemoveVarsButton() {
00750     if (ivjRemoveVarsButton == null) {
00751         try {
00752             ivjRemoveVarsButton = new javax.swing.JButton();
00753             ivjRemoveVarsButton.setName("RemoveVarsButton");
00754             ivjRemoveVarsButton.setText("Remove Variable");
00755             // user code begin {1}
00756             // user code end
00757         } catch (java.lang.Throwable ivjExc) {
00758             // user code begin {2}
00759             // user code end
00760             handleException(ivjExc);
00761         }
00762     }
00763     return ivjRemoveVarsButton;
00764 }
00765 /**
00766  * 
00767  * @return java.util.Vector
00768  */
00769 Vector getSliceInterests() {
00770     SliceInterestEnv sliceInterestEnv = new SliceInterestEnv();
00771     sliceInterestEnv.setCriterionViewer(this);
00772     sliceInterestEnv.setDependFrame(this.dependFrame);
00773     return sliceInterestEnv.getSliceInterests();
00774 }
00775 /**
00776  * Return the StatementLabel property value.
00777  * @return javax.swing.JLabel
00778  */
00779 /* WARNING: THIS METHOD WILL BE REGENERATED. */
00780 private javax.swing.JLabel getStatementLabel() {
00781     if (ivjStatementLabel == null) {
00782         try {
00783             ivjStatementLabel = new javax.swing.JLabel();
00784             ivjStatementLabel.setName("StatementLabel");
00785             ivjStatementLabel.setText("Statement Slice");
00786             ivjStatementLabel.setForeground(java.awt.Color.black);
00787             ivjStatementLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
00788             // user code begin {1}
00789             // user code end
00790         } catch (java.lang.Throwable ivjExc) {
00791             // user code begin {2}
00792             // user code end
00793             handleException(ivjExc);
00794         }
00795     }
00796     return ivjStatementLabel;
00797 }
00798 /**
00799  * Return the StatementPanel property value.
00800  * @return javax.swing.JPanel
00801  */
00802 /* WARNING: THIS METHOD WILL BE REGENERATED. */
00803 private javax.swing.JPanel getStatementPanel() {
00804     if (ivjStatementPanel == null) {
00805         try {
00806             ivjStatementPanel = new javax.swing.JPanel();
00807             ivjStatementPanel.setName("StatementPanel");
00808             ivjStatementPanel.setLayout(new java.awt.BorderLayout());
00809             getStatementPanel().add(getStatementLabel(), "North");
00810             getStatementPanel().add(getRemoveStatementButton(), "South");
00811             getStatementPanel().add(getStatementScrollPane(), "Center");
00812             // user code begin {1}
00813             // user code end
00814         } catch (java.lang.Throwable ivjExc) {
00815             // user code begin {2}
00816             // user code end
00817             handleException(ivjExc);
00818         }
00819     }
00820     return ivjStatementPanel;
00821 }
00822 /**
00823  * Return the StatementScrollPane property value.
00824  * @return javax.swing.JScrollPane
00825  */
00826 /* WARNING: THIS METHOD WILL BE REGENERATED. */
00827 private javax.swing.JScrollPane getStatementScrollPane() {
00828     if (ivjStatementScrollPane == null) {
00829         try {
00830             ivjStatementScrollPane = new javax.swing.JScrollPane();
00831             ivjStatementScrollPane.setName("StatementScrollPane");
00832             getStatementScrollPane().setViewportView(getStatementsList());
00833             // user code begin {1}
00834             // user code end
00835         } catch (java.lang.Throwable ivjExc) {
00836             // user code begin {2}
00837             // user code end
00838             handleException(ivjExc);
00839         }
00840     }
00841     return ivjStatementScrollPane;
00842 }
00843 /**
00844  * Return the StatementsList property value.
00845  * @return edu.ksu.cis.bandera.pdgslicer.dependency.DroppableStatementsList
00846  */
00847 /* WARNING: THIS METHOD WILL BE REGENERATED. */
00848 public DroppableStatementsList getStatementsList() {
00849     if (ivjStatementsList == null) {
00850         try {
00851             ivjStatementsList = new edu.ksu.cis.bandera.pdgslicer.dependency.DroppableStatementsList();
00852             ivjStatementsList.setName("StatementsList");
00853             ivjStatementsList.setBounds(0, 0, 160, 120);
00854             // user code begin {1}
00855             ivjStatementsList.setCriterionViewer(this);
00856             // user code end
00857         } catch (java.lang.Throwable ivjExc) {
00858             // user code begin {2}
00859             // user code end
00860             handleException(ivjExc);
00861         }
00862     }
00863     return ivjStatementsList;
00864 }
00865 /**
00866  * Return the StmtControlSplitPane property value.
00867  * @return javax.swing.JSplitPane
00868  */
00869 /* WARNING: THIS METHOD WILL BE REGENERATED. */
00870 public javax.swing.JSplitPane getStmtControlSplitPane() {
00871     if (ivjStmtControlSplitPane == null) {
00872         try {
00873             ivjStmtControlSplitPane = new javax.swing.JSplitPane(javax.swing.JSplitPane.HORIZONTAL_SPLIT);
00874             ivjStmtControlSplitPane.setName("StmtControlSplitPane");
00875             ivjStmtControlSplitPane.setDividerSize(2);
00876             ivjStmtControlSplitPane.setDividerLocation(240);
00877             getStmtControlSplitPane().add(getStatementPanel(), "left");
00878             getStmtControlSplitPane().add(getLocationsPanel(), "right");
00879             // user code begin {1}
00880             // user code end
00881         } catch (java.lang.Throwable ivjExc) {
00882             // user code begin {2}
00883             // user code end
00884             handleException(ivjExc);
00885         }
00886     }
00887     return ivjStmtControlSplitPane;
00888 }
00889 /**
00890  * Insert the method's description here.
00891  * Creation date: (00-11-29 11:00:17)
00892  * @return edu.ksu.cis.bandera.pdgslicer.dependency.StmtTreeNode
00893  * @param ln edu.ksu.cis.bandera.pdgslicer.dependency.LocationNode
00894  */
00895 private StmtTreeNode getStmtTreeNodeFromLocationNode(LocationNodeInCriterionViewer ln) {
00896     SootClass sc = ln.sootMethod.getDeclaringClass();
00897     Annotation mda = CompilationManager.getAnnotationManager().getAnnotation(sc, ln.sootMethod);
00898     Annotation stmtAnn = ln.stmtAnnotation;
00899     return new StmtTreeNode(sc, mda, stmtAnn);
00900 }
00901 /**
00902  * Return the VarsLabel property value.
00903  * @return javax.swing.JLabel
00904  */
00905 /* WARNING: THIS METHOD WILL BE REGENERATED. */
00906 private javax.swing.JLabel getVarsLabel() {
00907     if (ivjVarsLabel == null) {
00908         try {
00909             ivjVarsLabel = new javax.swing.JLabel();
00910             ivjVarsLabel.setName("VarsLabel");
00911             ivjVarsLabel.setText("Variable Slice");
00912             ivjVarsLabel.setForeground(java.awt.Color.black);
00913             ivjVarsLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
00914             // user code begin {1}
00915             // user code end
00916         } catch (java.lang.Throwable ivjExc) {
00917             // user code begin {2}
00918             // user code end
00919             handleException(ivjExc);
00920         }
00921     }
00922     return ivjVarsLabel;
00923 }
00924 /**
00925  * Return the VarsList property value.
00926  * @return edu.ksu.cis.bandera.pdgslicer.dependency.DroppableVariablesList
00927  */
00928 /* WARNING: THIS METHOD WILL BE REGENERATED. */
00929 private DroppableVariablesList getVarsList() {
00930     if (ivjVarsList == null) {
00931         try {
00932             ivjVarsList = new edu.ksu.cis.bandera.pdgslicer.dependency.DroppableVariablesList();
00933             ivjVarsList.setName("VarsList");
00934             ivjVarsList.setBounds(0, 0, 160, 120);
00935             // user code begin {1}
00936             ivjVarsList.setCriterionViewer(this);
00937             // user code end
00938         } catch (java.lang.Throwable ivjExc) {
00939             // user code begin {2}
00940             // user code end
00941             handleException(ivjExc);
00942         }
00943     }
00944     return ivjVarsList;
00945 }
00946 /**
00947  * Return the VarsPanel property value.
00948  * @return javax.swing.JPanel
00949  */
00950 /* WARNING: THIS METHOD WILL BE REGENERATED. */
00951 private javax.swing.JPanel getVarsPanel() {
00952     if (ivjVarsPanel == null) {
00953         try {
00954             ivjVarsPanel = new javax.swing.JPanel();
00955             ivjVarsPanel.setName("VarsPanel");
00956             ivjVarsPanel.setLayout(new java.awt.BorderLayout());
00957             getVarsPanel().add(getVarsLabel(), "North");
00958             getVarsPanel().add(getRemoveVarsButton(), "South");
00959             getVarsPanel().add(getVarsScrollPane(), "Center");
00960             // user code begin {1}
00961             // user code end
00962         } catch (java.lang.Throwable ivjExc) {
00963             // user code begin {2}
00964             // user code end
00965             handleException(ivjExc);
00966         }
00967     }
00968     return ivjVarsPanel;
00969 }
00970 /**
00971  * Return the VarsScrollPane property value.
00972  * @return javax.swing.JScrollPane
00973  */
00974 /* WARNING: THIS METHOD WILL BE REGENERATED. */
00975 private javax.swing.JScrollPane getVarsScrollPane() {
00976     if (ivjVarsScrollPane == null) {
00977         try {
00978             ivjVarsScrollPane = new javax.swing.JScrollPane();
00979             ivjVarsScrollPane.setName("VarsScrollPane");
00980             getVarsScrollPane().setViewportView(getVarsList());
00981             // user code begin {1}
00982             // user code end
00983         } catch (java.lang.Throwable ivjExc) {
00984             // user code begin {2}
00985             // user code end
00986             handleException(ivjExc);
00987         }
00988     }
00989     return ivjVarsScrollPane;
00990 }
00991 /**
00992  * Called whenever the part throws an exception.
00993  * @param exception java.lang.Throwable
00994  */
00995 private void handleException(java.lang.Throwable exception) {
00996 
00997     /* Uncomment the following lines to print uncaught exceptions to stdout */
00998     // System.out.println("--------- UNCAUGHT EXCEPTION ---------");
00999     // exception.printStackTrace(System.out);
01000 }
01001 /**
01002  * Initializes connections
01003  * @exception java.lang.Exception The exception description.
01004  */
01005 /* WARNING: THIS METHOD WILL BE REGENERATED. */
01006 private void initConnections() throws java.lang.Exception {
01007     // user code begin {1}
01008     // user code end
01009     getRemoveStatementButton().addActionListener(ivjEventHandler);
01010     getRemoveLocationButton().addActionListener(ivjEventHandler);
01011     getRemoveVarsButton().addActionListener(ivjEventHandler);
01012     getLocationsList().addListSelectionListener(ivjEventHandler);
01013     getStatementsList().addListSelectionListener(ivjEventHandler);
01014     getStatementsList().addMouseListener(ivjEventHandler);
01015     getLocationsList().addMouseListener(ivjEventHandler);
01016     getVarsList().addListSelectionListener(ivjEventHandler);
01017     getLocationVarsList().addListSelectionListener(ivjEventHandler);
01018 }
01019 /**
01020  * Initialize the class.
01021  */
01022 /* WARNING: THIS METHOD WILL BE REGENERATED. */
01023 private void initialize() {
01024     try {
01025         // user code begin {1}
01026         // user code end
01027         setName("CriterionViewer");
01028         setLayout(new java.awt.BorderLayout());
01029         setSize(766, 367);
01030         add(getPointVarSplitPane(), "Center");
01031         initConnections();
01032     } catch (java.lang.Throwable ivjExc) {
01033         handleException(ivjExc);
01034     }
01035     // user code begin {2}
01036 
01037     // user code end
01038 }
01039 /**
01040  * Comment
01041  */
01042 public void locationsList_ListSelectionEvents() {
01043     Object selectedValue = getLocationsList().getSelectedValue();
01044     if (selectedValue instanceof LocationNodeInCriterionViewer) {
01045         setSelectedByProgram = true;
01046         getStatementsList().clearSelection();
01047         getLocationVarsList().clearSelection();
01048         getVarsList().clearSelection();
01049         setSelectedByProgram = false;
01050         LocationNodeInCriterionViewer locationNode = (LocationNodeInCriterionViewer) selectedValue;
01051         calculateLocalsFor(locationNode);
01052         dependFrame.getCodeBrowserPane().setCurrentNodeSelected(selectedValue);
01053     } else
01054         System.out.println("selected value in the location list should be LocationNodeInCriterionViewer");
01055     return;
01056 }
01057 /**
01058  * Comment
01059  */
01060 public void locationsList_MouseClicked(java.awt.event.MouseEvent mouseEvent) {
01061         int selIndex = getLocationsList().locationToIndex(mouseEvent.getPoint());
01062     if (selIndex != -1) {
01063         if (mouseEvent.getClickCount() == 1) {
01064             //mySingleClick(selRow, selPath);
01065             //System.out.println("Do nothing --- My sigle click on the list");
01066         } else
01067             if (mouseEvent.getClickCount() == 2) {
01068                 //myDoubleClick(selRow, selPath);
01069                 //System.out.println("My DOUBLE click on the list");
01070                 LocationNodeInCriterionViewer selectedStmt = (LocationNodeInCriterionViewer) getLocationsList().getSelectedValue();
01071                 if (selectedStmt == null)
01072                     return;
01073                 StmtTreeNode selectedNode = getStmtTreeNodeFromLocationNode(selectedStmt);
01074                 dependFrame.addSelectedNodeToDependFrame(selectedNode);
01075                 //System.out.println("End adding by double clicking");
01076             }
01077     }
01078     return;
01079 }
01080 /**
01081  * Comment
01082  */
01083 public void locationVarsList_ListSelectionEvents() {
01084     Object selectedValue = getLocationVarsList().getSelectedValue();
01085     if (selectedValue instanceof SliceVariable) {
01086         setSelectedByProgram = true;
01087         getStatementsList().clearSelection();
01088         getLocationsList().clearSelection();
01089         getVarsList().clearSelection();
01090         setSelectedByProgram = false;
01091         if (selectedValue instanceof SliceField) {
01092             dependFrame.getCodeBrowserPane().setCurrentNodeSelected(selectedValue);
01093         } else
01094             if (selectedValue instanceof SliceLocal) {
01095                 dependFrame.getCodeBrowserPane().setCurrentNodeSelected(selectedValue);
01096             }
01097     } else
01098         System.out.println("selected value in the location variables list should be SliceVariable");
01099     return;
01100 }
01101 /**
01102  * main entrypoint - starts the part when it is run as an application
01103  * @param args java.lang.String[]
01104  */
01105 public static void main(java.lang.String[] args) {
01106     try {
01107         JFrame frame = new javax.swing.JFrame();
01108         CriterionViewer aCriterionViewer;
01109         aCriterionViewer = new CriterionViewer();
01110         frame.setContentPane(aCriterionViewer);
01111         frame.setSize(aCriterionViewer.getSize());
01112         frame.addWindowListener(new java.awt.event.WindowAdapter() {
01113             public void windowClosing(java.awt.event.WindowEvent e) {
01114                 System.exit(0);
01115             };
01116         });
01117         frame.setVisible(true);
01118     } catch (Throwable exception) {
01119         System.err.println("Exception occurred in main() of javax.swing.JPanel");
01120         exception.printStackTrace(System.out);
01121     }
01122 }
01123 /**
01124  * Comment
01125  */
01126 public void removeLocationButton_ActionEvents() {
01127     LocationNodeInCriterionViewer ln = (LocationNodeInCriterionViewer) getLocationsList().getSelectedValue();
01128     currentCriterion.remove(ln.slicePoint);
01129     //remove all variables related to this location and not used in any statement node
01130     DefaultListModel listModel = (DefaultListModel) getLocationsList().getModel();
01131     listModel.removeElement(getLocationsList().getSelectedValue());
01132     if (listModel.isEmpty()) {
01133         DefaultListModel varListModel = (DefaultListModel) getLocationVarsList().getModel();
01134         varListModel.removeAllElements();
01135     }
01136     return;
01137 }
01138 /**
01139  * Insert the method's description here.
01140  * Creation date: (00-11-27 16:16:01)
01141  * @param listModel javax.swing.DefaultListModel
01142  */
01143 private void removeLocationFrom(Object location, DefaultListModel listModel) {
01144     for (Enumeration en = listModel.elements(); en.hasMoreElements();) {
01145         LocationNodeInCriterionViewer ln = (LocationNodeInCriterionViewer) en.nextElement();
01146         if (location.equals(ln.slicePoint)) {
01147             listModel.removeElement(ln);
01148             return;
01149         }
01150     }
01151 }
01152 /**
01153  * Comment
01154  */
01155 public void removeStatementButton_ActionEvents() {
01156     StatementNodeInCriterionViewer ln = (StatementNodeInCriterionViewer) getStatementsList().getSelectedValue();
01157     for (int i = 0; i < ln.locationArray.length; i++)
01158         currentCriterion.remove(ln.locationArray[i]);
01159     DefaultListModel listModel = (DefaultListModel) getStatementsList().getModel();
01160     listModel.removeElement(getStatementsList().getSelectedValue());
01161     return;
01162 }
01163 /**
01164  * Comment
01165  */
01166 public void removeVarsButton_ActionEvents() {
01167     currentCriterion.remove(getVarsList().getSelectedValue());
01168     // if the var is not used in any statement node then can be removed
01169     // otherwise, warning?
01170     DefaultListModel listModel = (DefaultListModel) getVarsList().getModel();
01171     listModel.removeElement(getVarsList().getSelectedValue());
01172     return;
01173 }
01174 void runSlicerWithCurrentCriterion() {
01175     //currentCriterion is only for storing the criterion specified by users using criterion viewer
01176 
01177     if (currentCriterion.isEmpty()) {
01178         //make current statement in the dependency frame as the criterion
01179         runningCriterion = buildCriterionForCurrentNode(dependFrame.currentNode);
01180     } else
01181         runningCriterion = (Vector) currentCriterion.clone();
01182     if ((runningCriterion == null) || runningCriterion.isEmpty()) {
01183         System.out.println("The current criterion is null or empty");
01184         return;
01185     }
01186     if (runningCriterion.containsAll(lastTimeRunningCriterion) && lastTimeRunningCriterion.containsAll(runningCriterion)) {
01187         System.out.println("The current criterion is the same as the last one");
01188         return;
01189     }
01190     // else run slicer with current running criterion
01191     boolean emptyCriterion = dependFrame.slicer.preProcessing(runningCriterion);
01192     dependFrame.slicer.slicing();
01193     dependFrame.slicer.postProcessingOnAnnotation();
01194     //update display in codeBrowserPane
01195     CodeBrowserPane codeBrowserPane = dependFrame.getCodeBrowserPane();
01196     codeBrowserPane.setPostProcessValues();
01197     codeBrowserPane.repaintTrees();
01198     // finally
01199     lastTimeRunningCriterion = runningCriterion;
01200 }
01201 /**
01202  * Insert the method's description here.
01203  * Creation date: (00-11-27 17:19:22)
01204  * @param dp edu.ksu.cis.bandera.pdgslicer.dependency.Dependencies
01205  */
01206 void setDependFrame(Dependencies dp) {
01207     dependFrame = dp;
01208 }
01209 /**
01210  * 
01211  */
01212 void showCriterionInViewer(Vector sliceInterests) {
01213     //empty current criterion in the list;
01214     DefaultListModel listModel = (DefaultListModel) this.getVarsList().getModel();
01215     listModel.removeAllElements();
01216     listModel = (DefaultListModel) this.getLocationsList().getModel();
01217     listModel.removeAllElements();
01218     listModel = (DefaultListModel) this.getStatementsList().getModel();
01219     listModel.removeAllElements();
01220     for (Enumeration e = sliceInterests.elements(); e.hasMoreElements();) {
01221         SliceInterest si = (SliceInterest) e.nextElement();
01222         if ((si instanceof SliceStatement) || (si instanceof SlicePoint)) {
01223             boolean isStatementNode;
01224             if (si instanceof SliceStatement)
01225                 isStatementNode = true;
01226             else
01227                 isStatementNode = false;
01228             SlicePoint sp = (SlicePoint) si;
01229             SootClass sootClass = sp.getSootClass();
01230             SootMethod sootMethod = sp.getSootMethod();
01231             Stmt stmt = sp.getStmt();
01232             Annotation locationAnnotation = null;
01233             try {
01234                 locationAnnotation = CompilationManager.getAnnotationManager().getContainingAnnotation(sootClass, sootMethod, stmt);
01235             } catch (AnnotationException ae) {
01236                 //throw new AnnotationException("In showCriterionInViewer(): Can not find containing annotation for statement " + stmt);
01237             }
01238             if (locationAnnotation != null) {
01239                 if (!isStatementNode)
01240                     addLocationToCriterion(si, locationAnnotation);
01241                 else {
01242                     //addStatementToCriterieon(si, null, locationAnnotation);
01243                 }
01244             } else {
01245                 addVarToCriterion(si);
01246             }
01247         }
01248     }
01249 }
01250 /**
01251  * Comment
01252  */
01253 public void statementsList_ListSelectionEvents() {
01254     Object selectedValue = getStatementsList().getSelectedValue();
01255     if (selectedValue instanceof LocationNodeInCriterionViewer) {
01256         setSelectedByProgram = true;
01257         getLocationsList().clearSelection();
01258         getLocationVarsList().clearSelection();
01259         getVarsList().clearSelection();
01260         setSelectedByProgram = false;
01261         LocationNodeInCriterionViewer locationNode = (LocationNodeInCriterionViewer) selectedValue;
01262         calculateLocalsFor(locationNode);
01263         dependFrame.getCodeBrowserPane().setCurrentNodeSelected(selectedValue);
01264     } else
01265         System.out.println("selected value in the location list should be LocationNodeInCriterionViewer");
01266     return;
01267 }
01268 /**
01269  * Comment
01270  */
01271 public void statementsList_MouseClicked(java.awt.event.MouseEvent mouseEvent) {
01272     int selIndex = getStatementsList().locationToIndex(mouseEvent.getPoint());
01273     if (selIndex != -1) {
01274         if (mouseEvent.getClickCount() == 1) {
01275             //mySingleClick(selRow, selPath);
01276             //System.out.println("Do nothing --- My sigle click on the list");
01277         } else
01278             if (mouseEvent.getClickCount() == 2) {
01279                 //myDoubleClick(selRow, selPath);
01280                 //System.out.println("My DOUBLE click on the list");
01281                 LocationNodeInCriterionViewer selectedStmt = (LocationNodeInCriterionViewer) getStatementsList().getSelectedValue();
01282                 if (selectedStmt == null)
01283                     return;
01284                 StmtTreeNode selectedNode = getStmtTreeNodeFromLocationNode(selectedStmt);
01285                 dependFrame.addSelectedNodeToDependFrame(selectedNode);
01286                 //System.out.println("End adding by double clicking");
01287             }
01288     }
01289     return;
01290 }
01291 /**
01292  * Insert the method's description here.
01293  * Creation date: (6/13/2001 2:09:47 PM)
01294  * @return boolean
01295  * @param listModel javax.swing.DefaultListModel
01296  * @param annotation edu.ksu.cis.bandera.annotation.Annotation
01297  */
01298 private boolean statementsListContains(DefaultListModel listModel, Annotation annotation) {
01299     for (int i = 0; i < listModel.getSize(); i++) {
01300         Object element = listModel.elementAt(i);
01301         LocationNodeInCriterionViewer node = (LocationNodeInCriterionViewer) element;
01302         if (node.stmtAnnotation.equals(annotation))
01303             return true;
01304     }
01305     return false;
01306 }
01307 /**
01308  * Comment
01309  */
01310 public void varsList_ListSelectionEvents() {
01311     Object selectedValue = getVarsList().getSelectedValue();
01312     if (selectedValue instanceof SliceVariable) {
01313         setSelectedByProgram = true;
01314         getStatementsList().clearSelection();
01315         getLocationsList().clearSelection();
01316         getLocationVarsList().clearSelection();
01317         setSelectedByProgram = false;
01318         if (selectedValue instanceof SliceField) {
01319             dependFrame.getCodeBrowserPane().setCurrentNodeSelected(selectedValue);
01320         } else
01321             if (selectedValue instanceof SliceLocal) {
01322                 dependFrame.getCodeBrowserPane().setCurrentNodeSelected(selectedValue);
01323             }
01324     } else
01325         System.out.println("selected value in the variables list should be SliceVariable");
01326     return;
01327 }
01328 }

Generated at Thu Feb 7 06:43:12 2002 for Bandera by doxygen1.2.10 written by Dimitri van Heesch, © 1997-2001