Source Code Cross Referenced for ChoiceSelector.java in  » Testing » KeY » de » uka » ilkd » key » gui » configuration » 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.configuration 
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:        //
010:
011:        package de.uka.ilkd.key.gui.configuration;
012:
013:        import java.awt.Dimension;
014:        import java.awt.BorderLayout;
015:        import java.awt.event.ActionEvent;
016:        import java.awt.event.ActionListener;
017:        import java.util.HashMap;
018:        import java.util.Set;
019:
020:        import javax.swing.*;
021:        import javax.swing.border.TitledBorder;
022:        import javax.swing.event.ListSelectionEvent;
023:        import javax.swing.event.ListSelectionListener;
024:
025:        public class ChoiceSelector extends JDialog {
026:
027:            private ChoiceSettings settings;
028:            private HashMap category2DefaultChoice;
029:            private HashMap category2Choices;
030:            private boolean changed = false;
031:
032:            /** the JList with the categories of choices*/
033:            private JList catList;
034:            /** the JList with the choices for one category */
035:            private JList choiceList;
036:
037:            /** creates a new ChoiceSelector, using the <code>ChoiceSettings</code>
038:             * from <code>settings</code> */
039:            public ChoiceSelector(ChoiceSettings settings) {
040:                super (new JFrame(), "Select Default Choices", true);
041:                this .settings = settings;
042:                category2DefaultChoice = settings.getDefaultChoices();
043:                if (category2DefaultChoice.isEmpty()) {
044:                    JOptionPane.showConfirmDialog(ChoiceSelector.this ,
045:                            "There are no Taclet Options available as the rule-files "
046:                                    + "have not been parsed yet!",
047:                            "No Options available", JOptionPane.DEFAULT_OPTION);
048:                    dispose();
049:                } else {
050:                    category2Choices = settings.getChoices();
051:                    layoutChoiceSelector();
052:                    pack();
053:                    setLocation(70, 70);
054:                    setVisible(true);
055:                }
056:            }
057:
058:            /** creates a new ChoiceSelector */
059:            public ChoiceSelector() {
060:                this (ProofSettings.DEFAULT_SETTINGS.getChoiceSettings());
061:            }
062:
063:            /** layout */
064:            protected void layoutChoiceSelector() {
065:                Object[] cats = category2DefaultChoice.keySet().toArray();
066:                java.util.Arrays.sort(cats);
067:                catList = new JList(cats);
068:                catList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
069:                catList.setSelectedIndex(0);
070:                catList.addListSelectionListener(new ListSelectionListener() {
071:                    public void valueChanged(ListSelectionEvent e) {
072:                        setChoiceList();
073:                    }
074:                });
075:                choiceList = new JList(((Set) category2Choices.get(cats[0]))
076:                        .toArray());
077:                choiceList
078:                        .setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
079:                choiceList.setSelectedValue(
080:                        category2DefaultChoice.get(cats[0]), true);
081:                choiceList
082:                        .addListSelectionListener(new ListSelectionListener() {
083:                            public void valueChanged(ListSelectionEvent e) {
084:                                setDefaultChoice((String) choiceList
085:                                        .getSelectedValue());
086:                            }
087:                        });
088:
089:                JScrollPane catListScroll = new JScrollPane(
090:                        JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
091:                        JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
092:                catListScroll.getViewport().setView(catList);
093:                catListScroll.setBorder(new TitledBorder("Category"));
094:
095:                JScrollPane choiceScrollPane = new JScrollPane(
096:                        JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
097:                        JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
098:                choiceScrollPane.getViewport().setView(choiceList);
099:                choiceScrollPane.setBorder(new TitledBorder("Default Option"));
100:
101:                JButton ok = new JButton("OK");
102:                ok.addActionListener(new ActionListener() {
103:                    public void actionPerformed(ActionEvent e) {
104:                        if (changed) {
105:                            int res = JOptionPane.showOptionDialog(
106:                                    ChoiceSelector.this ,
107:                                    "Your changes will become effective when "
108:                                            + "the next problem is loaded.\n",
109:                                    "Taclet Option Settings",
110:                                    JOptionPane.DEFAULT_OPTION,
111:                                    JOptionPane.QUESTION_MESSAGE, null,
112:                                    new Object[] { "OK", "Cancel" }, "OK");
113:                            if (res == 0) {
114:                                settings
115:                                        .setDefaultChoices(category2DefaultChoice);
116:                            }
117:                        }
118:                        setVisible(false);
119:                        dispose();
120:                    }
121:                });
122:                JButton cancel = new JButton("Cancel");
123:                cancel.addActionListener(new ActionListener() {
124:                    public void actionPerformed(ActionEvent e) {
125:                        setVisible(false);
126:                        dispose();
127:                    }
128:                });
129:                JPanel buttonPanel = new JPanel();
130:                buttonPanel.add(ok);
131:                buttonPanel.add(cancel);
132:
133:                Dimension paneDim = new Dimension(300, 300);
134:                choiceScrollPane.setPreferredSize(paneDim);
135:                choiceScrollPane.setMinimumSize(paneDim);
136:                paneDim = new Dimension(200, 300);
137:                catListScroll.setPreferredSize(paneDim);
138:                catListScroll.setMinimumSize(paneDim);
139:
140:                JPanel listPanel = new JPanel();
141:                listPanel.setLayout(new BoxLayout(listPanel, BoxLayout.X_AXIS));
142:                listPanel.add(catListScroll);
143:                listPanel.add(choiceScrollPane);
144:
145:                getContentPane().setLayout(new BorderLayout());
146:                getContentPane().add(listPanel, BorderLayout.CENTER);
147:                getContentPane().add(buttonPanel, BorderLayout.SOUTH);
148:            }
149:
150:            /** is called to set the selected choice in 
151:             * <code>category2DefaultChoice</code>*/
152:            private void setDefaultChoice(String sel) {
153:                String category = (String) catList.getSelectedValue();
154:                if (sel != null) {
155:                    category2DefaultChoice.put(category, sel);
156:                    changed = true;
157:                }
158:            }
159:
160:            /** is called if the selection of left list has changed, and causes the
161:             * right one to display the possible choices for the category chosen on
162:             * the left side
163:             */
164:            private void setChoiceList() {
165:                String selection = (String) catList.getSelectedValue();
166:                choiceList.setListData(((Set) category2Choices.get(selection))
167:                        .toArray());
168:                choiceList.setSelectedValue(category2DefaultChoice
169:                        .get(selection), false);
170:            }
171:
172:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.