Source Code Cross Referenced for SubParamsGUI.java in  » Content-Management-System » apache-lenya-2.0 » org » apache » lenya » config » impl » 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 » Content Management System » apache lenya 2.0 » org.apache.lenya.config.impl 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.apache.lenya.config.impl;
002:
003:        import java.awt.Container;
004:        import java.awt.FlowLayout;
005:        import java.awt.GridBagConstraints;
006:        import java.awt.GridBagLayout;
007:        import java.awt.Insets;
008:        import java.awt.Toolkit;
009:        import java.awt.event.ActionEvent;
010:        import java.awt.event.ActionListener;
011:        import java.awt.event.MouseEvent;
012:        import java.awt.event.MouseListener;
013:        import java.awt.event.WindowEvent;
014:        import java.awt.event.WindowListener;
015:
016:        import javax.swing.BoxLayout;
017:        import javax.swing.ButtonGroup;
018:        import javax.swing.JButton;
019:        import javax.swing.JCheckBox;
020:        import javax.swing.JFrame;
021:        import javax.swing.JLabel;
022:        import javax.swing.JPanel;
023:        import javax.swing.JRadioButton;
024:        import javax.swing.JTextField;
025:
026:        import org.apache.lenya.config.core.ContextEventQueue;
027:        import org.apache.lenya.config.core.Parameter;
028:
029:        public class SubParamsGUI {
030:
031:            private ConfigureGUI cGui;
032:            protected JButton nextSubButton;
033:            protected JFrame subFrame;
034:            private JPanel contentPanel;
035:            private JPanel checkBoxPanel;
036:            private JPanel buttonPanel;
037:            private JLabel defaultValueLabel;
038:            private JLabel localValueLabel;
039:            private JLabel newLocalValueLabel;
040:            private JLabel stepsLabel;
041:            private JTextField defaultValueTextField;
042:            private JTextField localValueTextField;
043:            private JTextField newLocalValueTextField;
044:            private JRadioButton radioButtonDefault;
045:            private JRadioButton radioButtonLocal;
046:            private JRadioButton radioButtonNewLocal;
047:            private JButton closeButton;
048:            private JButton backButton;
049:            private JButton nextButton;
050:            private JButton doneButton;
051:            protected JCheckBox[] checkBoxes;
052:            private JLabel paraValueLabel;
053:            private Parameter[] subParams;
054:            private Parameter[] tmpSubParams;
055:            private String selectedComboBoxValue;
056:            int steps = 0;
057:
058:            /**
059:             * 
060:             * @param cGui
061:             * @param tmpSubParams
062:             * @param subParams
063:             */
064:            public SubParamsGUI(ConfigureGUI cGui, Parameter[] tmpSubParams,
065:                    Parameter[] subParams, String selectedComboBoxValue) {
066:
067:                this .cGui = cGui;
068:                this .subParams = subParams;
069:                this .tmpSubParams = tmpSubParams;
070:                this .selectedComboBoxValue = selectedComboBoxValue;
071:
072:                // clearing the second temporary array
073:                for (int i = 0; i < tmpSubParams.length; i++) {
074:                    tmpSubParams[i].setLocalValue("");
075:                }
076:                createSubParamsGui();
077:            }
078:
079:            public void createSubParamsGui() {
080:
081:                Toolkit.getDefaultToolkit().getSystemEventQueue().push(
082:                        new ContextEventQueue());
083:
084:                subFrame = new JFrame("Apache Subparameter \""
085:                        + selectedComboBoxValue + "\" Configuration");
086:                subFrame.setLocation(cGui.frame.getX() + 0,
087:                        cGui.frame.getY() + 0);
088:
089:                contentPanel = new JPanel();
090:                checkBoxPanel = new JPanel();
091:                buttonPanel = new JPanel();
092:
093:                defaultValueLabel = new JLabel();
094:                localValueLabel = new JLabel();
095:                newLocalValueLabel = new JLabel();
096:
097:                defaultValueTextField = new JTextField(20);
098:                localValueTextField = new JTextField(20);
099:                newLocalValueTextField = new JTextField(20);
100:
101:                radioButtonDefault = new JRadioButton();
102:                radioButtonLocal = new JRadioButton();
103:                radioButtonNewLocal = new JRadioButton();
104:                ButtonGroup g = new ButtonGroup();
105:
106:                closeButton = new JButton();
107:                backButton = new JButton();
108:                nextButton = new JButton();
109:                doneButton = new JButton();
110:
111:                Container contentPane = subFrame.getContentPane();
112:                contentPane.setLayout(new FlowLayout(FlowLayout.LEFT));
113:
114:                contentPanel.setLayout(new GridBagLayout());
115:                GridBagConstraints c = new GridBagConstraints();
116:
117:                stepsLabel = new JLabel();
118:                stepsLabel.setText("Parameters  ");
119:                c.gridx = 0;
120:                c.gridy = 0;
121:                contentPanel.add(stepsLabel, c);
122:
123:                checkBoxPanel = new JPanel();
124:                checkBoxPanel.setLayout(new BoxLayout(checkBoxPanel,
125:                        BoxLayout.Y_AXIS));
126:                c.gridx = 0;
127:                c.gridy = 1;
128:                c.gridheight = 4;
129:                c.ipadx = 20;
130:                contentPanel.add(checkBoxPanel, c);
131:
132:                checkBoxes = new JCheckBox[subParams.length];
133:
134:                for (int i = 0; i < subParams.length; ++i) {
135:                    checkBoxes[i] = new JCheckBox();
136:                    checkBoxes[i].setEnabled(false);
137:                    checkBoxes[i].setText(subParams[i].getName());
138:                    checkBoxes[0].setSelected(true);
139:                    checkBoxPanel.add(checkBoxes[i]);
140:                }
141:
142:                c.gridx = 1;
143:                c.gridy = 0;
144:                c.gridwidth = 1;
145:                c.gridheight = 1;
146:                paraValueLabel = new JLabel(subParams[0].getName());
147:                paraValueLabel.repaint();
148:                contentPanel.add(paraValueLabel, c);
149:
150:                defaultValueLabel.setText("Default Value:");
151:                contentPanel.add(defaultValueLabel, new GridBagConstraints(1,
152:                        1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
153:                        GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
154:                contentPanel.add(defaultValueTextField, new GridBagConstraints(
155:                        2, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
156:                        GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
157:                defaultValueTextField.setText(subParams[0].getDefaultValue());
158:                defaultValueTextField.setEditable(false);
159:                defaultValueTextField.addMouseListener(new MouseListener() {
160:
161:                    public void mouseClicked(MouseEvent event) {
162:                        radioButtonDefault.setSelected(true);
163:                    }
164:
165:                    public void mousePressed(MouseEvent event) {
166:                    }
167:
168:                    public void mouseReleased(MouseEvent event) {
169:                    }
170:
171:                    public void mouseEntered(MouseEvent event) {
172:                    }
173:
174:                    public void mouseExited(MouseEvent event) {
175:                    }
176:                });
177:
178:                contentPanel.add(radioButtonDefault, new GridBagConstraints(3,
179:                        1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
180:                        GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
181:                g.add(radioButtonDefault);
182:
183:                localValueLabel.setText("Local Value:");
184:                contentPanel.add(localValueLabel, new GridBagConstraints(1, 2,
185:                        1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
186:                        GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
187:                contentPanel.add(localValueTextField, new GridBagConstraints(2,
188:                        2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
189:                        GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
190:                localValueTextField.setText(subParams[0].getLocalValue());
191:                localValueTextField.setEditable(false);
192:                localValueTextField.addMouseListener(new MouseListener() {
193:
194:                    public void mouseClicked(MouseEvent event) {
195:                    }
196:
197:                    public void mousePressed(MouseEvent event) {
198:                        radioButtonLocal.setSelected(true);
199:                    }
200:
201:                    public void mouseReleased(MouseEvent event) {
202:                    }
203:
204:                    public void mouseEntered(MouseEvent event) {
205:                    }
206:
207:                    public void mouseExited(MouseEvent event) {
208:                    }
209:                });
210:
211:                contentPanel.add(radioButtonLocal, new GridBagConstraints(3, 2,
212:                        1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
213:                        GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
214:                g.add(radioButtonLocal);
215:                radioButtonLocal.setSelected(true);
216:
217:                newLocalValueLabel.setText("New Local Value:");
218:                contentPanel.add(newLocalValueLabel, new GridBagConstraints(1,
219:                        3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
220:                        GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
221:                contentPanel.add(newLocalValueTextField,
222:                        new GridBagConstraints(2, 3, 1, 1, 0.0, 0.0,
223:                                GridBagConstraints.CENTER,
224:                                GridBagConstraints.BOTH,
225:                                new Insets(0, 0, 0, 0), 0, 0));
226:                newLocalValueTextField.addMouseListener(new MouseListener() {
227:
228:                    public void mouseClicked(MouseEvent event) {
229:                    }
230:
231:                    public void mousePressed(MouseEvent event) {
232:                        radioButtonNewLocal.setSelected(true);
233:                    }
234:
235:                    public void mouseEntered(MouseEvent event) {
236:                    }
237:
238:                    public void mouseExited(MouseEvent event) {
239:                    }
240:
241:                    public void mouseReleased(MouseEvent event) {
242:                    }
243:                });
244:
245:                contentPanel.add(radioButtonNewLocal, new GridBagConstraints(3,
246:                        3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
247:                        GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
248:                g.add(radioButtonNewLocal);
249:
250:                buttonPanel = new JPanel();
251:                buttonPanel.setLayout(new BoxLayout(buttonPanel,
252:                        BoxLayout.X_AXIS));
253:
254:                closeButton.setText("Close");
255:                closeButton.setPreferredSize(new java.awt.Dimension(74, 22));
256:                closeButton.addActionListener(new ActionListener() {
257:
258:                    public void actionPerformed(ActionEvent evt) {
259:                        subFrame.setVisible(false);
260:                        cGui.frame.setEnabled(true);
261:                        cGui.frame.setVisible(true);
262:                    }
263:                });
264:
265:                backButton.setText("<Back");
266:                backButton.setPreferredSize(new java.awt.Dimension(74, 22));
267:                backButton.addActionListener(new ActionListener() {
268:
269:                    public void actionPerformed(ActionEvent e) {
270:                        moveBack();
271:                    }
272:                });
273:
274:                backButton.setEnabled(false);
275:
276:                nextButton.setText("Next>");
277:                nextButton.setPreferredSize(new java.awt.Dimension(74, 22));
278:                nextButton.addActionListener(new ActionListener() {
279:
280:                    public void actionPerformed(ActionEvent e) {
281:
282:                        backButton.setEnabled(true);
283:                        if (contentPanel.isVisible())
284:                            nextButton.setEnabled(true);
285:                        moveNext();
286:                    }
287:                });
288:
289:                buttonPanel.add(closeButton);
290:                buttonPanel.add(backButton);
291:                buttonPanel.add(nextButton);
292:
293:                contentPanel.add(buttonPanel, new GridBagConstraints(1, 4, 6,
294:                        0, 0.0, 0.0, GridBagConstraints.CENTER,
295:                        GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
296:
297:                subFrame.addWindowListener(new WindowListener() {
298:
299:                    public void windowOpened(WindowEvent e) {
300:                    }
301:
302:                    public void windowClosing(WindowEvent e) {
303:                        cGui.frame.setEnabled(true);
304:                    }
305:
306:                    public void windowClosed(WindowEvent e) {
307:                        cGui.frame.setEnabled(true);
308:                    }
309:
310:                    public void windowIconified(WindowEvent e) {
311:                    }
312:
313:                    public void windowDeiconified(WindowEvent e) {
314:                    }
315:
316:                    public void windowActivated(WindowEvent e) {
317:                    }
318:
319:                    public void windowDeactivated(WindowEvent e) {
320:                    }
321:                });
322:
323:                contentPane.add(contentPanel);
324:                contentPanel.revalidate();
325:                subFrame.pack();
326:                subFrame.setVisible(true);
327:            }
328:
329:            /**
330:             * Controls behavior if back button is pressed
331:             */
332:            public void moveBack() {
333:                steps--;
334:                subFrame.repaint();
335:                nextButton.setVisible(true);
336:                doneButton.setVisible(false);
337:                checkFirst();
338:                currentStep("down");
339:                showNormalOptions();
340:                checkLast();
341:                newLocalValueTextField.setText(tmpSubParams[getStep()]
342:                        .getLocalValue());
343:                setRadioButton();
344:            }
345:
346:            /**
347:             * Controls behavior if next button is pressed
348:             */
349:            public void moveNext() {
350:                setLocalValue();
351:                steps++;
352:                subFrame.repaint();
353:                checkFirst();
354:                currentStep("up");
355:                showNormalOptions();
356:                checkLast();
357:                newLocalValueTextField.setText(tmpSubParams[getStep()]
358:                        .getLocalValue());
359:                setRadioButton();
360:            }
361:
362:            /**
363:             * Set radio button
364:             */
365:            public void setRadioButton() {
366:                if (tmpSubParams[getStep()].getLocalValue() != "") {
367:                    radioButtonNewLocal.setSelected(true);
368:                } else if (subParams[getStep()].getLocalValue() != "") {
369:                    radioButtonLocal.setSelected(true);
370:                } else {
371:                    radioButtonDefault.setSelected(true);
372:                }
373:            }
374:
375:            /**
376:             * Set local value depending on chosen value
377:             */
378:            public void setLocalValue() {
379:
380:                if (radioButtonDefault.isSelected()) {
381:                    tmpSubParams[getStep()].setLocalValue(defaultValueTextField
382:                            .getText());
383:                } else if (radioButtonLocal.isSelected()) {
384:                    tmpSubParams[getStep()].setLocalValue(localValueTextField
385:                            .getText());
386:                } else if (radioButtonNewLocal.isSelected()) {
387:                    tmpSubParams[getStep()]
388:                            .setLocalValue(newLocalValueTextField.getText());
389:                } else {
390:                    System.err.println("Fatal Error 0123456789!");
391:                }
392:            }
393:
394:            /**
395:             * Takes care about the steps progress (list on left side)
396:             * 
397:             * @param direction
398:             */
399:            public void currentStep(String direction) {
400:                if (direction.equals("up")) {
401:                    for (int i = 1; i <= getStep(); ++i) {
402:                        checkBoxes[i].setSelected(true);
403:                    }
404:                }
405:                if (direction.equals("down")) {
406:                    checkBoxes[getStep() + 1].setSelected(false);
407:                }
408:            }
409:
410:            /**
411:             * Checks if its first step and disables the back button
412:             */
413:            public void checkFirst() {
414:
415:                if (getStep() == 0) {
416:                    backButton.setEnabled(false);
417:                } else {
418:                    backButton.setEnabled(true);
419:                }
420:            }
421:
422:            /**
423:             * Checks if its last step and disables next button but adding a save button
424:             */
425:            public void checkLast() {
426:                doneButton = new JButton("Done");
427:
428:                if (getStep() == subParams.length - 1) {
429:                    nextButton.setEnabled(false);
430:                    nextButton.setVisible(false);
431:
432:                    buttonPanel.add(doneButton);
433:                    contentPanel.revalidate();
434:
435:                    doneButton.setPreferredSize(new java.awt.Dimension(74, 22));
436:                    doneButton.addActionListener(new ActionListener() {
437:
438:                        public void actionPerformed(ActionEvent e) {
439:                            setLocalValue();
440:                            subFrame.setVisible(false);
441:                            cGui.frame.setEnabled(true);
442:                            cGui.frame.setVisible(true);
443:                        }
444:                    });
445:
446:                } else {
447:                    nextButton.setEnabled(true);
448:                }
449:            }
450:
451:            /**
452:             * Shows the normal options (paramaters)
453:             */
454:            public void showNormalOptions() {
455:
456:                if (getStep() < subParams.length) {
457:
458:                    defaultValueTextField.setText(subParams[getStep()]
459:                            .getDefaultValue());
460:                    localValueTextField.setText(subParams[getStep()]
461:                            .getLocalValue());
462:                    paraValueLabel.setText(subParams[getStep()].getName());
463:                    subFrame.pack();
464:                }
465:
466:            }
467:
468:            /**
469:             * Returns the current step
470:             * 
471:             * @return steps
472:             */
473:            public int getStep() {
474:                return steps;
475:            }
476:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.