KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > ca > mcgill > sable > soot > ui > AnalysisTypeView


1 /* Soot - a J*va Optimization Framework
2  * Copyright (C) 2004 Jennifer Lhotak
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */

19
20 package ca.mcgill.sable.soot.ui;
21
22 import org.eclipse.swt.widgets.Composite;
23 import org.eclipse.ui.part.*;
24 import org.eclipse.jface.viewers.*;
25 import org.eclipse.swt.SWT;
26 import org.eclipse.swt.widgets.*;
27 import java.util.*;
28 import org.eclipse.core.resources.*;
29 import ca.mcgill.sable.soot.attributes.*;
30 import ca.mcgill.sable.soot.*;
31 import org.eclipse.ui.*;
32
33 public class AnalysisTypeView extends ViewPart implements ICheckStateListener {
34
35     private CheckboxTableViewer viewer;
36     private ArrayList inputTypes;
37     private boolean allTypesChecked;
38     private ArrayList typesChecked;
39     private IFile file;
40     
41     public AnalysisTypeView() {
42         super();
43     }
44
45     /* (non-Javadoc)
46      * @see org.eclipse.ui.IWorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
47      */

48     public void createPartControl(Composite parent) {
49         Table table = new Table(parent, SWT.CHECK);
50         setViewer(new CheckboxTableViewer(table));
51         getViewer().setContentProvider(new ArrayContentProvider());
52         getViewer().setLabelProvider(new LabelProvider());
53         getViewer().addCheckStateListener(this);
54     }
55
56     public void checkStateChanged(CheckStateChangedEvent event){
57         SootAttributesHandler handler = SootPlugin.getDefault().getManager().getAttributesHandlerForFile(getFile());
58                     
59         ArrayList toShow = new ArrayList();
60         for (int i = 0; i < getViewer().getCheckedElements().length; i++){
61             toShow.add(getViewer().getCheckedElements()[i]);
62         }
63         handler.setTypesToShow(toShow);
64         handler.setShowAllTypes(false);
65         // also update currently shown editor and legend
66
handler.setUpdate(true);
67         final IEditorPart activeEdPart = SootPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
68         SootPlugin.getDefault().getPartManager().updatePart(activeEdPart);
69     
70     }
71     
72     /* (non-Javadoc)
73      * @see org.eclipse.ui.IWorkbenchPart#setFocus()
74      */

75     public void setFocus() {
76     }
77
78     /**
79      * @return
80      */

81     public CheckboxTableViewer getViewer() {
82         return viewer;
83     }
84
85     /**
86      * @param viewer
87      */

88     public void setViewer(CheckboxTableViewer viewer) {
89         this.viewer = viewer;
90     }
91
92     /**
93      * @return
94      */

95     public ArrayList getInputTypes() {
96         return inputTypes;
97     }
98
99     /**
100      * @param list
101      */

102     public void setInputTypes(ArrayList list) {
103         inputTypes = list;
104         getViewer().setInput(inputTypes);
105         if (isAllTypesChecked()){
106             getViewer().setAllChecked(true);
107         }
108         else {
109             getViewer().setAllChecked(false);
110             getViewer().setCheckedElements(getTypesChecked().toArray());
111         }
112     }
113
114     
115     /**
116      * @return
117      */

118     public boolean isAllTypesChecked() {
119         return allTypesChecked;
120     }
121
122     /**
123      * @return
124      */

125     public ArrayList getTypesChecked() {
126         return typesChecked;
127     }
128
129     /**
130      * @param b
131      */

132     public void setAllTypesChecked(boolean b) {
133         allTypesChecked = b;
134     }
135
136     /**
137      * @param list
138      */

139     public void setTypesChecked(ArrayList list) {
140         typesChecked = list;
141     }
142
143     /**
144      * @return
145      */

146     public IFile getFile() {
147         return file;
148     }
149
150     /**
151      * @param file
152      */

153     public void setFile(IFile file) {
154         this.file = file;
155     }
156
157 }
158
Popular Tags