Source Code Cross Referenced for NewGroupWin.java in  » Report » datavision-1.1.0 » jimm » datavision » 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 » Report » datavision 1.1.0 » jimm.datavision.gui 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package jimm.datavision.gui;
002:
003:        import jimm.datavision.*;
004:        import jimm.datavision.gui.cmd.NewGroupCommand;
005:        import jimm.util.I18N;
006:        import java.awt.*;
007:        import java.awt.event.*;
008:        import java.util.Iterator;
009:        import javax.swing.*;
010:
011:        /**
012:         * A dialog for creating a new group.
013:         * <p>
014:         * This dialog should only be created if the report has at least one field.
015:         * The method {@link Designer#enableMenuItems} makes sure this is true.
016:         *
017:         * @author Jim Menard, <a href="mailto:jimm@io.com">jimm@io.com</a>
018:         */
019:        class NewGroupWin extends JDialog implements  ActionListener {
020:
021:            protected Designer designer;
022:            protected Report report;
023:            protected JComboBox combo;
024:            protected JRadioButton ascendingButton, descendingButton;
025:
026:            /**
027:             * Constructor; uses format of first selected field.
028:             *
029:             * @param designer the window to which this dialog belongs
030:             * @param report the report
031:             */
032:            public NewGroupWin(Designer designer, Report report) {
033:                super (designer.getFrame(), I18N.get("NewGroupWin.title"));
034:                this .designer = designer;
035:                this .report = report;
036:                buildWindow();
037:                pack();
038:                setVisible(true);
039:            }
040:
041:            /**
042:             * Builds the window contents.
043:             */
044:            protected void buildWindow() {
045:                JPanel gutsPanel = buildGuts();
046:                JPanel buttonPanel = buildButtonPanel();
047:
048:                getContentPane().add(gutsPanel, BorderLayout.CENTER);
049:                getContentPane().add(buttonPanel, BorderLayout.SOUTH);
050:            }
051:
052:            /**
053:             * Builds and returns a panel containing the stuff from which groups are
054:             * made.
055:             *
056:             * @return a panel
057:             */
058:            protected JPanel buildGuts() {
059:                GridBagLayout bag = new GridBagLayout();
060:                GridBagConstraints c = new GridBagConstraints();
061:                c.insets = new Insets(6, 6, 6, 6);
062:
063:                JPanel panel = new JPanel();
064:                panel.setLayout(bag);
065:                panel
066:                        .setBorder(BorderFactory.createEmptyBorder(20, 20, 20,
067:                                20));
068:
069:                // "Group Column" label
070:                JLabel label;
071:                label = new JLabel(I18N.get("NewGroupWin.group_column"));
072:                c.gridx = 0;
073:                c.gridy = 0;
074:                c.anchor = GridBagConstraints.EAST;
075:                bag.setConstraints(label, c);
076:                panel.add(label);
077:
078:                // Group column dropdown
079:                JPanel comboPanel = buildColumnComboBox();
080:                c.gridx = 1;
081:                c.gridy = 0;
082:                c.anchor = GridBagConstraints.NORTHWEST;
083:                bag.setConstraints(comboPanel, c);
084:                panel.add(comboPanel);
085:
086:                // "Sort Order" label
087:                label = new JLabel(I18N.get("NewGroupWin.sort_order"));
088:                c.gridx = 0;
089:                c.gridy = 1;
090:                c.anchor = GridBagConstraints.EAST;
091:                bag.setConstraints(label, c);
092:                panel.add(label);
093:
094:                // Sort order radion buttons
095:                Box rbBox = buildSortOrderRadioButtons();
096:                c.gridx = 1;
097:                c.gridy = 1;
098:                c.anchor = GridBagConstraints.NORTHWEST;
099:                c.gridheight = 2;
100:                bag.setConstraints(rbBox, c);
101:                panel.add(rbBox);
102:
103:                return panel;
104:            }
105:
106:            protected JPanel buildColumnComboBox() {
107:                DefaultComboBoxModel model = new DefaultComboBoxModel();
108:
109:                // Iterate through columns in tables used by report. We will remove
110:                // those associated with extant groups in a moment.
111:                Iterator iter;
112:                for (iter = report.userColumns(); iter.hasNext();)
113:                    model.addElement((Selectable) iter.next());
114:                for (iter = report.getDataSource()
115:                        .columnsInTablesUsedInReport(); iter.hasNext();)
116:                    model.addElement((Selectable) iter.next());
117:
118:                // Remove all user columns and columns already in a group.
119:                for (iter = report.groups(); iter.hasNext();) {
120:                    Group group = (Group) iter.next();
121:                    model.removeElement(group.getSelectable());
122:                }
123:
124:                combo = new JComboBox(model);
125:                combo.setSelectedIndex(0);
126:
127:                JPanel panel = new JPanel();
128:                panel.add(combo);
129:                return panel;
130:            }
131:
132:            protected Box buildSortOrderRadioButtons() {
133:                Box box = Box.createVerticalBox();
134:
135:                ButtonGroup bg = new ButtonGroup();
136:
137:                ascendingButton = new JRadioButton(I18N.get("GUI.ascending"));
138:                ascendingButton.addActionListener(this );
139:                box.add(ascendingButton);
140:                bg.add(ascendingButton);
141:
142:                descendingButton = new JRadioButton(I18N.get("GUI.descending"));
143:                descendingButton.addActionListener(this );
144:                box.add(descendingButton);
145:                bg.add(descendingButton);
146:
147:                ascendingButton.setSelected(true);
148:                return box;
149:            }
150:
151:            /**
152:             * Builds and returns a panel containing the OK and Cancel
153:             *
154:             * @return a panel
155:             */
156:            protected JPanel buildButtonPanel() {
157:                JPanel buttonPanel = new JPanel();
158:                JButton button;
159:
160:                buttonPanel.add(button = new JButton(I18N.get("GUI.ok")));
161:                button.addActionListener(this );
162:                button.setDefaultCapable(true);
163:
164:                buttonPanel.add(button = new JButton(I18N.get("GUI.cancel")));
165:                button.addActionListener(this );
166:
167:                return buttonPanel;
168:            }
169:
170:            /**
171:             * Handles the OK and Cancel buttons.
172:             *
173:             * @param e action event
174:             */
175:            public void actionPerformed(ActionEvent e) {
176:                String cmd = e.getActionCommand();
177:                if (I18N.get("GUI.ok").equals(cmd)) {
178:                    int sortOrder = ascendingButton.isSelected() ? Group.SORT_ASCENDING
179:                            : Group.SORT_DESCENDING;
180:                    NewGroupCommand ngc = new NewGroupCommand(designer, report,
181:                            (Selectable) combo.getSelectedItem(), sortOrder);
182:                    designer.performCommand(ngc);
183:                    dispose();
184:                } else if (I18N.get("GUI.cancel").equals(cmd)) {
185:                    dispose();
186:                }
187:            }
188:
189:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.