Source Code Cross Referenced for AnalysisVisManipDialog.java in  » Code-Analyzer » soot » ca » mcgill » sable » soot » ui » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Code Analyzer » soot » ca.mcgill.sable.soot.ui 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* Soot - a J*va Optimization Framework
002:         * Copyright (C) 2004 Jennifer Lhotak
003:         *
004:         * This library is free software; you can redistribute it and/or
005:         * modify it under the terms of the GNU Lesser General Public
006:         * License as published by the Free Software Foundation; either
007:         * version 2.1 of the License, or (at your option) any later version.
008:         *
009:         * This library is distributed in the hope that it will be useful,
010:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
011:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
012:         * Lesser General Public License for more details.
013:         *
014:         * You should have received a copy of the GNU Lesser General Public
015:         * License along with this library; if not, write to the
016:         * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
017:         * Boston, MA 02111-1307, USA.
018:         */
019:
020:        package ca.mcgill.sable.soot.ui;
021:
022:        import org.eclipse.jface.dialogs.TitleAreaDialog;
023:        import org.eclipse.jface.viewers.*;
024:        import org.eclipse.swt.widgets.*;
025:        import org.eclipse.swt.events.*;
026:        import org.eclipse.swt.layout.*;
027:        import org.eclipse.swt.custom.*;
028:        import org.eclipse.swt.*;
029:        import java.util.*;
030:        import org.eclipse.core.resources.*;
031:        import ca.mcgill.sable.soot.attributes.*;
032:
033:        public class AnalysisVisManipDialog extends TitleAreaDialog implements 
034:                ISelectionChangedListener {
035:
036:            private HashMap dataMap;
037:            private ArrayList fileList;
038:            private IProject proj;
039:            private ArrayList allSelected;
040:            private HashMap currentSettingsMap;
041:
042:            /**
043:             * @param parentShell
044:             */
045:            public AnalysisVisManipDialog(Shell parentShell) {
046:                super (parentShell);
047:            }
048:
049:            protected void configureShell(Shell shell) {
050:                super .configureShell(shell);
051:                shell.setText(Messages.getString("AnalysisVisManDialog.Title"));
052:            }
053:
054:            public void setDataMap(HashMap map) {
055:                dataMap = map;
056:            }
057:
058:            protected Control createDialogArea(Composite parent) {
059:                GridData gd;
060:
061:                Composite dialogComp = (Composite) super 
062:                        .createDialogArea(parent);
063:                Composite topComp = new Composite(dialogComp, SWT.NONE);
064:                gd = new GridData(GridData.FILL_BOTH);
065:                topComp.setLayoutData(gd);
066:                GridLayout topLayout = new GridLayout();
067:                topLayout.numColumns = 2;
068:                topComp.setLayout(topLayout);
069:
070:                setTitle("Project: " + getProj().getName());
071:                setMessage("");
072:
073:                TabFolder tabFolder = new TabFolder(topComp, SWT.NONE);
074:                gd = new GridData(GridData.FILL_BOTH);
075:                tabFolder.setLayoutData(gd);
076:
077:                TabItem singleFileItem = new TabItem(tabFolder, SWT.NONE);
078:                singleFileItem.setText("By File");
079:                TabItem globalItem = new TabItem(tabFolder, SWT.NONE);
080:                globalItem.setText("By Project");
081:
082:                /* create single file tab */
083:                SashForm sash = new SashForm(tabFolder, SWT.NONE);
084:                singleFileItem.setControl(sash);
085:                sash.setOrientation(SWT.HORIZONTAL);
086:
087:                gd = new GridData(GridData.FILL_BOTH);
088:                sash.setLayoutData(gd);
089:
090:                Composite selection = createSelectionArea(sash);
091:                gd = new GridData(GridData.FILL_VERTICAL);
092:                gd.horizontalSpan = 1;
093:
094:                selection.setLayoutData(gd);
095:
096:                Composite types = createCheckArea(sash);
097:                gd = new GridData(GridData.FILL_VERTICAL);
098:                gd.horizontalSpan = 1;
099:
100:                types.setLayoutData(gd);
101:
102:                /* create global tab */
103:                Composite global = new Composite(tabFolder, SWT.NONE);
104:                GridLayout globalLayout = new GridLayout();
105:
106:                global.setLayout(globalLayout);
107:
108:                Table allTable = new Table(global, SWT.CHECK);
109:                TableViewer allTypesList = new TableViewer(allTable);
110:                allTypesList.setContentProvider(new ArrayContentProvider());
111:                allTypesList.setLabelProvider(new LabelProvider());
112:
113:                gd = new GridData(GridData.FILL_BOTH);
114:                allTypesList.getControl().setLayoutData(gd);
115:
116:                Composite buttonPanel = new Composite(global, SWT.NONE);
117:                GridLayout bpLayout = new GridLayout();
118:                bpLayout.numColumns = 2;
119:                buttonPanel.setLayout(bpLayout);
120:
121:                Button selectAll = new Button(buttonPanel, SWT.PUSH);
122:                selectAll.setText("Select All");
123:                gd = new GridData();
124:                gd.horizontalSpan = 1;
125:                selectAll.setLayoutData(gd);
126:
127:                Button deselectAll = new Button(buttonPanel, SWT.PUSH);
128:                deselectAll.setText("De-select All");
129:                gd = new GridData();
130:                gd.horizontalSpan = 1;
131:                deselectAll.setLayoutData(gd);
132:
133:                globalItem.setControl(global);
134:
135:                return dialogComp;
136:            }
137:
138:            private CheckboxTableViewer checkTypes;
139:
140:            private Composite createCheckArea(Composite parent) {
141:                Composite comp = new Composite(parent, SWT.NONE);
142:                GridLayout layout = new GridLayout();
143:
144:                layout.numColumns = 1;
145:
146:                comp.setLayout(layout);
147:
148:                GridData gd = new GridData();
149:                Table table = new Table(comp, SWT.CHECK);
150:                checkTypes = new CheckboxTableViewer(table);
151:
152:                gd = new GridData(GridData.FILL_BOTH);
153:
154:                checkTypes.getControl().setLayoutData(gd);
155:
156:                checkTypes.setContentProvider(new ArrayContentProvider());
157:                checkTypes.setLabelProvider(new LabelProvider());
158:                return comp;
159:            }
160:
161:            private Composite createSelectionArea(Composite parent) {
162:                Composite comp = new Composite(parent, SWT.NONE);
163:
164:                GridLayout layout = new GridLayout();
165:
166:                layout.numColumns = 1;
167:
168:                comp.setLayout(layout);
169:
170:                GridData gd = new GridData();
171:
172:                TreeViewer files = new TreeViewer(comp);
173:                gd = new GridData(GridData.FILL_BOTH);
174:
175:                files.getControl().setLayoutData(gd);
176:
177:                files.setContentProvider(new VisManContentProvider());
178:                files.setLabelProvider(new VisManLabelProvider());
179:                files.setInput(getInitialInput());
180:
181:                files.addSelectionChangedListener(this );
182:
183:                files.getControl().addKeyListener(new KeyAdapter() {
184:                    public void keyPressed(KeyEvent e) {
185:                        handleKeyPressed(e);
186:                    }
187:                });
188:
189:                return comp;
190:            }
191:
192:            public void selectionChanged(SelectionChangedEvent event) {
193:                IStructuredSelection selection = (IStructuredSelection) event
194:                        .getSelection();
195:                if (selection.isEmpty()) {
196:                    checkTypes.setInput(getCheckInput(""));
197:                } else {
198:                    Object elem = selection.getFirstElement();
199:                    if (!(elem instanceof  IFile))
200:                        return;
201:                    ArrayList list = (ArrayList) getCheckInput(elem);
202:                    handleLast();
203:                    checkTypes.setInput(list);
204:                    Object[] checkElems;
205:                    if ((currentSettingsMap != null)
206:                            && (currentSettingsMap.containsKey(elem))) {
207:                        checkElems = (Object[]) currentSettingsMap.get(elem);
208:                        checkTypes.setCheckedElements(checkElems);
209:                    } else {
210:                        SootAttributesHandler handler = getHandlerForFile((IFile) elem);
211:                        if (handler != null) {
212:                            if (handler.isShowAllTypes()) {
213:                                if (list != null) {
214:                                    Object[] elems = new Object[list.size()];
215:
216:                                    for (int i = 0; i < list.size(); i++) {
217:                                        elems[i] = checkTypes.getElementAt(i);
218:
219:                                    }
220:                                    checkTypes.setCheckedElements(elems);
221:                                }
222:                            } else {
223:                                Iterator it = handler.getTypesToShow()
224:                                        .iterator();
225:                                Object[] elems = new Object[handler
226:                                        .getTypesToShow().size()];
227:                                int i = 0;
228:                                while (it.hasNext()) {
229:                                    elems[i] = it.next();
230:                                    i++;
231:                                }
232:                                checkTypes.setCheckedElements(elems);
233:
234:                            }
235:                        }
236:                    }
237:                    if (getAllSelected() == null) {
238:                        setAllSelected(new ArrayList());
239:                    }
240:                    getAllSelected().add(elem);
241:                }
242:            }
243:
244:            protected void okPressed() {
245:                handleLast();
246:                super .okPressed();
247:            }
248:
249:            private void handleLast() {
250:                if (getAllSelected() == null)
251:                    return;
252:                Object lastElem = getAllSelected().get(
253:                        getAllSelected().size() - 1);
254:                if (lastElem != null) {
255:                    Object[] checkElems = checkTypes.getCheckedElements();
256:                    if (currentSettingsMap == null) {
257:                        currentSettingsMap = new HashMap();
258:                    }
259:                    currentSettingsMap.put(lastElem, checkElems);
260:
261:                }
262:            }
263:
264:            private IContainer getInitialInput() {
265:                IContainer proj = getProj();
266:                return proj;
267:            }
268:
269:            private SootAttributesHandler getHandlerForFile(IFile next) {
270:                SootAttributesHandler handler = null;
271:                if (next.getFileExtension().equals("java")) {
272:                    JavaAttributesComputer jac = new JavaAttributesComputer();
273:                    jac.setProj(getProj());
274:                    jac.setRec(next);
275:                    handler = jac.getAttributesHandler(next);
276:                } else {
277:                    JimpleAttributesComputer jac = new JimpleAttributesComputer();
278:                    jac.setProj(getProj());
279:                    jac.setRec(next);
280:                    handler = jac.getAttributesHandler(next);
281:                }
282:                return handler;
283:            }
284:
285:            private ArrayList getAllTypesInput() {
286:                ArrayList allTypes = new ArrayList();
287:                Iterator it = getFileList().iterator();
288:                while (it.hasNext()) {
289:                    SootAttributesHandler handler = getHandlerForFile((IFile) it
290:                            .next());
291:                    if ((handler != null) && (handler.getAttrList() != null)) {
292:                        Iterator attrsIt = handler.getAttrList().iterator();
293:
294:                        while (attrsIt.hasNext()) {
295:                            SootAttribute sa = (SootAttribute) attrsIt.next();
296:                            Iterator typesIt = sa.getAnalysisTypes().iterator();
297:                            while (typesIt.hasNext()) {
298:                                String val = (String) typesIt.next();
299:                                if (!allTypes.contains(val)) {
300:                                    allTypes.add(val);
301:                                }
302:                            }
303:                        }
304:                    }
305:
306:                }
307:
308:                return allTypes;
309:            }
310:
311:            private ArrayList getCheckInput(Object key) {
312:                ArrayList list = new ArrayList();
313:                if (!(key instanceof  IFile))
314:                    return list;
315:                IFile next = (IFile) key;
316:                SootAttributesHandler handler = getHandlerForFile(next);
317:
318:                if ((handler != null) && (handler.getAttrList() != null)) {
319:                    Iterator attrsIt = handler.getAttrList().iterator();
320:                    ArrayList types = new ArrayList();
321:                    while (attrsIt.hasNext()) {
322:                        SootAttribute sa = (SootAttribute) attrsIt.next();
323:                        Iterator typesIt = sa.getAnalysisTypes().iterator();
324:                        while (typesIt.hasNext()) {
325:                            String val = (String) typesIt.next();
326:                            if (!types.contains(val)) {
327:                                types.add(val);
328:                            }
329:                        }
330:                    }
331:                    return types;
332:                } else {
333:                    return null;
334:                }
335:            }
336:
337:            private void handleKeyPressed(KeyEvent e) {
338:            }
339:
340:            /**
341:             * @return
342:             */
343:            public ArrayList getFileList() {
344:                return fileList;
345:            }
346:
347:            /**
348:             * @param list
349:             */
350:            public void setFileList(ArrayList list) {
351:                fileList = list;
352:            }
353:
354:            /**
355:             * @return
356:             */
357:            public IProject getProj() {
358:                return proj;
359:            }
360:
361:            /**
362:             * @param project
363:             */
364:            public void setProj(IProject project) {
365:                proj = project;
366:            }
367:
368:            /**
369:             * @return
370:             */
371:            public ArrayList getAllSelected() {
372:                return allSelected;
373:            }
374:
375:            /**
376:             * @param list
377:             */
378:            public void setAllSelected(ArrayList list) {
379:                allSelected = list;
380:            }
381:
382:            /**
383:             * @return
384:             */
385:            public HashMap getCurrentSettingsMap() {
386:                return currentSettingsMap;
387:            }
388:
389:            /**
390:             * @param map
391:             */
392:            public void setCurrentSettingsMap(HashMap map) {
393:                currentSettingsMap = map;
394:            }
395:
396:            /**
397:             * @return
398:             */
399:            public CheckboxTableViewer getCheckTypes() {
400:                return checkTypes;
401:            }
402:
403:            /**
404:             * @param viewer
405:             */
406:            public void setCheckTypes(CheckboxTableViewer viewer) {
407:                checkTypes = viewer;
408:            }
409:
410:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.