Source Code Cross Referenced for ClassSelectionDialog.java in  » Testing » KeY » de » uka » ilkd » key » gui » 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 » Testing » KeY » de.uka.ilkd.key.gui 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        // This file is part of KeY - Integrated Deductive Software Design
002:        // Copyright (C) 2001-2007 Universitaet Karlsruhe, Germany
003:        //                         Universitaet Koblenz-Landau, Germany
004:        //                         Chalmers University of Technology, Sweden
005:        //
006:        // The KeY system is protected by the GNU General Public License. 
007:        // See LICENSE.TXT for details.
008:
009:        package de.uka.ilkd.key.gui;
010:
011:        import java.awt.Dimension;
012:        import java.awt.FlowLayout;
013:        import java.awt.event.ActionEvent;
014:        import java.awt.event.ActionListener;
015:        import java.util.Arrays;
016:        import java.util.Comparator;
017:
018:        import javax.swing.*;
019:        import javax.swing.border.TitledBorder;
020:
021:        import de.uka.ilkd.key.casetool.*;
022:
023:        /**
024:         * A dialog for selecting classes (including interfaces).
025:         */
026:        public class ClassSelectionDialog extends JDialog {
027:
028:            private boolean successful = false;
029:            private JList classList;
030:
031:            /**
032:             * Creates and displays a dialog box asking the user to make a choice from 
033:             * a set of classes.
034:             * @param windowTitle Title for the dialog window.
035:             * @param classesTitle Title for the list of available classes.
036:             * @param modelClasses The available classes.
037:             * @param allowMultipleSelection Whether multiple classes or a single class 
038:             * are to be selected
039:             */
040:            public ClassSelectionDialog(String dialogTitle,
041:                    String classesTitle, ListOfModelClass modelClasses,
042:                    ModelClass defaultClass, boolean allowMultipleSelection) {
043:                super (new JFrame(), dialogTitle, true);
044:
045:                //create type list
046:                classList = new JList();
047:                if (allowMultipleSelection) {
048:                    classList
049:                            .setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
050:                } else {
051:                    classList
052:                            .setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
053:                }
054:                ModelClass[] classesArray = modelClasses.toArray();
055:                Arrays.sort(classesArray, new Comparator() {
056:                    public int compare(Object o1, Object o2) {
057:                        ModelClass mc1 = (ModelClass) o1;
058:                        ModelClass mc2 = (ModelClass) o2;
059:                        return mc1.getClassName().compareTo(mc2.getClassName());
060:                    }
061:                });
062:                classList.setListData(classesArray);
063:
064:                //select default class
065:                if (defaultClass != null) {
066:                    String defaultName = defaultClass.getFullClassName();
067:                    IteratorOfModelClass it = modelClasses.iterator();
068:                    while (it.hasNext()) {
069:                        ModelClass modelClass = it.next();
070:                        if (modelClass.getFullClassName().equals(defaultName)) {
071:                            classList.setSelectedValue(modelClass, true);
072:                            break;
073:                        }
074:                    }
075:                }
076:
077:                //create type scroll pane
078:                JScrollPane typeScrollPane = new JScrollPane(classList);
079:                typeScrollPane.setBorder(new TitledBorder(classesTitle));
080:                Dimension typeScrollPaneDim = new Dimension(275, 300);
081:                typeScrollPane.setPreferredSize(typeScrollPaneDim);
082:                typeScrollPane.setMinimumSize(typeScrollPaneDim);
083:                getContentPane().add(typeScrollPane);
084:
085:                //create button panel
086:                JPanel buttonPanel = new JPanel();
087:                buttonPanel.setLayout(new FlowLayout(FlowLayout.RIGHT, 5, 5));
088:                getContentPane().add(buttonPanel);
089:                Dimension buttonDim = new Dimension(80, 25);
090:
091:                //create "ok" button
092:                JButton okButton = new JButton("OK");
093:                okButton.setPreferredSize(buttonDim);
094:                okButton.setMinimumSize(buttonDim);
095:                okButton.addActionListener(new ActionListener() {
096:                    public void actionPerformed(ActionEvent e) {
097:                        successful = true;
098:                        setVisible(false);
099:                    }
100:                });
101:                buttonPanel.add(okButton);
102:                getRootPane().setDefaultButton(okButton);
103:
104:                //create "cancel" button
105:                JButton cancelButton = new JButton("Cancel");
106:                cancelButton.setPreferredSize(buttonDim);
107:                cancelButton.setMinimumSize(buttonDim);
108:                cancelButton.addActionListener(new ActionListener() {
109:                    public void actionPerformed(ActionEvent e) {
110:                        setVisible(false);
111:                    }
112:                });
113:                buttonPanel.add(cancelButton);
114:
115:                getContentPane().setLayout(
116:                        new BoxLayout(getContentPane(), BoxLayout.Y_AXIS));
117:                pack();
118:                setLocation(70, 70);
119:                setVisible(true);
120:            }
121:
122:            public ClassSelectionDialog(String dialogTitle,
123:                    String classesTitle, ListOfModelClass modelClasses,
124:                    boolean allowMultipleSelection) {
125:                this (dialogTitle, classesTitle, modelClasses, null,
126:                        allowMultipleSelection);
127:            }
128:
129:            /**
130:             * Tells whether the user clicked "ok".
131:             */
132:            public boolean wasSuccessful() {
133:                return successful;
134:            }
135:
136:            /**
137:             * Returns the selected classes.
138:             */
139:            public ListOfModelClass getSelection() {
140:                Object[] selectedClasses = classList.getSelectedValues();
141:
142:                ListOfModelClass result = SLListOfModelClass.EMPTY_LIST;
143:                for (int i = selectedClasses.length - 1; i >= 0; i--) {
144:                    result = result.prepend((UMLModelClass) selectedClasses[i]);
145:                }
146:
147:                return result;
148:            }
149:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.