Source Code Cross Referenced for RecurrenceDialog.java in  » Mail-Clients » columba-1.4 » org » columba » calendar » ui » dialog » 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 » Mail Clients » columba 1.4 » org.columba.calendar.ui.dialog 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.columba.calendar.ui.dialog;
002:
003:        import java.awt.BorderLayout;
004:        import java.awt.Component;
005:        import java.awt.Frame;
006:        import java.awt.GridLayout;
007:        import java.awt.event.ActionEvent;
008:        import java.awt.event.ActionListener;
009:        import java.awt.event.KeyEvent;
010:
011:        import javax.swing.BorderFactory;
012:        import javax.swing.ButtonGroup;
013:        import javax.swing.JComboBox;
014:        import javax.swing.JComponent;
015:        import javax.swing.JDialog;
016:        import javax.swing.JPanel;
017:        import javax.swing.JRadioButton;
018:        import javax.swing.JTextField;
019:        import javax.swing.KeyStroke;
020:        import javax.swing.SwingConstants;
021:
022:        import org.columba.calendar.model.Recurrence;
023:        import org.columba.calendar.model.api.IEventInfo;
024:        import org.columba.calendar.model.api.IRecurrence;
025:        import org.columba.calendar.ui.comp.DatePicker;
026:        import org.columba.core.gui.base.ButtonWithMnemonic;
027:        import org.columba.core.gui.base.SingleSideEtchedBorder;
028:        import org.columba.core.gui.util.DialogHeaderPanel;
029:        import org.columba.core.help.HelpManager;
030:        import org.columba.core.resourceloader.IconKeys;
031:        import org.columba.core.resourceloader.ImageLoader;
032:        import org.columba.mail.util.MailResourceLoader;
033:
034:        import com.jgoodies.forms.builder.PanelBuilder;
035:        import com.jgoodies.forms.layout.CellConstraints;
036:        import com.jgoodies.forms.layout.FormLayout;
037:
038:        public class RecurrenceDialog extends JDialog implements  ActionListener {
039:
040:            private static final String RECURRENCE_DAILY = "Daily";
041:
042:            private static final String RECURRENCE_WEEKLY = "Weekly";
043:
044:            private static final String RECURRENCE_MONTHLY = "Monthly";
045:
046:            private static final String RECURRENCE_ANNUALLY = "Annually";
047:
048:            private static final IRecurrence DEFAULT_RECURRENCE = new Recurrence(
049:                    Recurrence.RECURRENCE_DAILY);
050:
051:            private IEventInfo model;
052:
053:            private boolean success = false;
054:
055:            // frequency
056:            JComboBox freqComboBox = new JComboBox();
057:
058:            // no end
059:            JRadioButton rNoEnd = new JRadioButton();
060:
061:            // maximum occurrences
062:            JRadioButton rMaxOccurrences = new JRadioButton();
063:            JTextField maxOccurrences = new JTextField("0");
064:
065:            // end date
066:            JRadioButton rUntilDate = new JRadioButton();
067:            DatePicker endDatePicker;
068:
069:            public RecurrenceDialog(Frame parentFrame, IEventInfo model) {
070:                super (parentFrame, true);
071:
072:                endDatePicker = new DatePicker();
073:
074:                this .model = model;
075:
076:                setLayout(new BorderLayout());
077:                getContentPane().add(
078:                        new DialogHeaderPanel("Recurrence",
079:                                "Edit Recurrence Properties", ImageLoader
080:                                        .getIcon(IconKeys.USER)),
081:                        BorderLayout.NORTH);
082:                getContentPane().add(createPanel(), BorderLayout.CENTER);
083:                getContentPane().add(createButtonPanel(), BorderLayout.SOUTH);
084:
085:                getRootPane().registerKeyboardAction(this , "CANCEL",
086:                        KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0),
087:                        JComponent.WHEN_IN_FOCUSED_WINDOW);
088:
089:                updateComponents(true);
090:
091:                pack();
092:                setLocationRelativeTo(null);
093:                setVisible(true);
094:
095:            }
096:
097:            private Component createPanel() {
098:                JPanel jpanel1 = new JPanel();
099:                FormLayout formlayout1 = new FormLayout(
100:                        "3dlu,FILL:DEFAULT:NONE,FILL:DEFAULT:GROW(1.0),3dlu",
101:                        "3dlu,CENTER:DEFAULT:NONE,3dlu,FILL:DEFAULT:NONE,6dlu,FILL:DEFAULT:NONE,3dlu,FILL:DEFAULT:NONE,3dlu,FILL:DEFAULT:NONE,3dlu,FILL:DEFAULT:NONE,3dlu");
102:                CellConstraints cc = new CellConstraints();
103:                jpanel1.setLayout(formlayout1);
104:
105:                PanelBuilder b = new PanelBuilder(formlayout1);
106:                b.setDefaultDialogBorder();
107:
108:                b.addSeparator("Recurrence", cc.xywh(2, 2, 2, 1));
109:
110:                freqComboBox.addItem(RECURRENCE_DAILY);
111:                freqComboBox.addItem(RECURRENCE_WEEKLY);
112:                freqComboBox.addItem(RECURRENCE_MONTHLY);
113:                freqComboBox.addItem(RECURRENCE_ANNUALLY);
114:
115:                b.add(freqComboBox, cc.xy(3, 4));
116:
117:                b.addSeparator("End", cc.xywh(2, 6, 2, 1));
118:
119:                rNoEnd.setActionCommand("forever");
120:                rNoEnd.addActionListener(this );
121:                rNoEnd.setText("Forever");
122:                b.add(rNoEnd, cc.xy(3, 8));
123:
124:                b.add(createMaxOccurrencesPanel(), cc.xy(3, 10));
125:
126:                b.add(createUntilDatePanel(), cc.xy(3, 12));
127:
128:                // enable all radio buttons
129:                rNoEnd.setEnabled(true);
130:                rMaxOccurrences.setEnabled(true);
131:                rUntilDate.setEnabled(true);
132:
133:                ButtonGroup group = new ButtonGroup();
134:                group.add(rNoEnd);
135:                group.add(rMaxOccurrences);
136:                group.add(rUntilDate);
137:
138:                rNoEnd.setSelected(true);
139:
140:                // disable all
141:                endDatePicker.setEnabled(false);
142:                maxOccurrences.setEnabled(false);
143:
144:                return b.getPanel();
145:            }
146:
147:            private JPanel createMaxOccurrencesPanel() {
148:
149:                JPanel panel = new JPanel();
150:
151:                FormLayout formlayout1 = new FormLayout(
152:                        "FILL:DEFAULT:NONE,FILL:DEFAULT:NONE",
153:                        "CENTER:DEFAULT:NONE");
154:                CellConstraints cc = new CellConstraints();
155:                panel.setLayout(formlayout1);
156:
157:                rMaxOccurrences.setText("Maximum recurrences");
158:                rMaxOccurrences.setActionCommand("maximum");
159:                rMaxOccurrences.addActionListener(this );
160:                panel.add(rMaxOccurrences, cc.xy(1, 1));
161:
162:                maxOccurrences.setColumns(2);
163:                panel.add(maxOccurrences, cc.xy(2, 1));
164:
165:                return panel;
166:            }
167:
168:            private JPanel createUntilDatePanel() {
169:                JPanel panel = new JPanel();
170:
171:                FormLayout formlayout1 = new FormLayout(
172:                        "FILL:DEFAULT:NONE,FILL:DEFAULT:NONE",
173:                        "CENTER:DEFAULT:NONE");
174:                CellConstraints cc = new CellConstraints();
175:                panel.setLayout(formlayout1);
176:
177:                rUntilDate.setText("Until ");
178:                rUntilDate.setActionCommand("until");
179:                rUntilDate.addActionListener(this );
180:                panel.add(rUntilDate, cc.xy(1, 1));
181:                panel.add(endDatePicker, cc.xy(2, 1));
182:
183:                return panel;
184:
185:            }
186:
187:            private void updateComponents(boolean b) {
188:                IRecurrence r = model.getEvent().getRecurrence();
189:                if (b) {
190:                    if (r == null) {
191:                        r = DEFAULT_RECURRENCE;
192:                        model.getEvent().setRecurrence(r);
193:                    }
194:                    if (r.getType() == IRecurrence.RECURRENCE_DAILY) {
195:                        freqComboBox.setSelectedItem(RECURRENCE_DAILY);
196:                    } else if (r.getType() == IRecurrence.RECURRENCE_WEEKLY) {
197:                        freqComboBox.setSelectedItem(RECURRENCE_WEEKLY);
198:                    } else if (r.getType() == IRecurrence.RECURRENCE_MONTHLY) {
199:                        freqComboBox.setSelectedItem(RECURRENCE_MONTHLY);
200:                    } else if (r.getType() == IRecurrence.RECURRENCE_ANNUALLY) {
201:                        freqComboBox.setSelectedItem(RECURRENCE_ANNUALLY);
202:                    } else {
203:                        // it has to be set
204:                        freqComboBox.setSelectedItem(RECURRENCE_DAILY);
205:                        r.setType(IRecurrence.RECURRENCE_DAILY);
206:                    }
207:
208:                    if (r.getEndType() == IRecurrence.RECURRENCE_END_FOREVER) {
209:                        rNoEnd.setSelected(true);
210:                        maxOccurrences.setEnabled(false);
211:                        endDatePicker.setEnabled(false);
212:                    } else if (r.getEndType() == IRecurrence.RECURRENCE_END_MAXOCCURRENCES) {
213:                        rMaxOccurrences.setSelected(true);
214:                        maxOccurrences.setEnabled(true);
215:                        endDatePicker.setEnabled(false);
216:                        maxOccurrences.setText((new Integer(r
217:                                .getEndMaxOccurrences()).toString()));
218:                    } else if (r.getEndType() == IRecurrence.RECURRENCE_END_ENDDATE) {
219:                        rUntilDate.setSelected(true);
220:                        endDatePicker.setDate(r.getEndDate());
221:                        maxOccurrences.setEnabled(false);
222:                        endDatePicker.setEnabled(true);
223:                    } else {
224:                        // it has to be set
225:                        rNoEnd.setSelected(true);
226:                        maxOccurrences.setEnabled(false);
227:                        endDatePicker.setEnabled(false);
228:                        r.setEndType(IRecurrence.RECURRENCE_END_FOREVER);
229:                    }
230:                } else {
231:                    if (freqComboBox.getSelectedItem().equals(RECURRENCE_DAILY)) {
232:                        r.setType(IRecurrence.RECURRENCE_DAILY);
233:                    } else if (freqComboBox.getSelectedItem().equals(
234:                            RECURRENCE_WEEKLY)) {
235:                        r.setType(IRecurrence.RECURRENCE_WEEKLY);
236:                    } else if (freqComboBox.getSelectedItem().equals(
237:                            RECURRENCE_MONTHLY)) {
238:                        r.setType(IRecurrence.RECURRENCE_MONTHLY);
239:                    } else if (freqComboBox.getSelectedItem().equals(
240:                            RECURRENCE_ANNUALLY)) {
241:                        r.setType(IRecurrence.RECURRENCE_ANNUALLY);
242:                    }
243:
244:                    if (rNoEnd.isSelected()) {
245:                        r.setEndType(IRecurrence.RECURRENCE_END_FOREVER);
246:                    } else if (rMaxOccurrences.isSelected()) {
247:                        r.setEndType(IRecurrence.RECURRENCE_END_MAXOCCURRENCES);
248:                        try {
249:                            r.setEndMaxOccurrences(Integer
250:                                    .parseInt(maxOccurrences.getText()));
251:                        } catch (NumberFormatException e) {
252:                            // LOG.severe("no number!")
253:                            r.setEndMaxOccurrences(1);
254:                        }
255:                    } else if (rUntilDate.isSelected()) {
256:                        r.setEndType(IRecurrence.RECURRENCE_END_ENDDATE);
257:                        r.setEndDate(endDatePicker.getDate());
258:                    }
259:                }
260:            }
261:
262:            private JPanel createButtonPanel() {
263:                JPanel bottom = new JPanel();
264:                bottom.setLayout(new BorderLayout());
265:                bottom
266:                        .setBorder(new SingleSideEtchedBorder(
267:                                SwingConstants.TOP));
268:
269:                ButtonWithMnemonic cancelButton = new ButtonWithMnemonic(
270:                        MailResourceLoader.getString("global", "cancel"));
271:
272:                //$NON-NLS-1$ //$NON-NLS-2$
273:                cancelButton.addActionListener(this );
274:                cancelButton.setActionCommand("CANCEL"); //$NON-NLS-1$
275:
276:                ButtonWithMnemonic okButton = new ButtonWithMnemonic(
277:                        MailResourceLoader.getString("global", "ok"));
278:
279:                //$NON-NLS-1$ //$NON-NLS-2$
280:                okButton.addActionListener(this );
281:                okButton.setActionCommand("OK"); //$NON-NLS-1$
282:                okButton.setDefaultCapable(true);
283:                getRootPane().setDefaultButton(okButton);
284:
285:                ButtonWithMnemonic helpButton = new ButtonWithMnemonic(
286:                        MailResourceLoader.getString("global", "help"));
287:
288:                // associate with JavaHelp
289:                HelpManager.getInstance().enableHelpOnButton(helpButton,
290:                        "configuring_columba");
291:
292:                JPanel buttonPanel = new JPanel();
293:                buttonPanel.setBorder(BorderFactory.createEmptyBorder(12, 12,
294:                        12, 12));
295:                buttonPanel.setLayout(new GridLayout(1, 3, 6, 0));
296:                buttonPanel.add(okButton);
297:                buttonPanel.add(cancelButton);
298:                buttonPanel.add(helpButton);
299:
300:                bottom.add(buttonPanel, BorderLayout.EAST);
301:
302:                return bottom;
303:            }
304:
305:            public boolean success() {
306:                return success;
307:            }
308:
309:            public void actionPerformed(ActionEvent arg0) {
310:                String action = arg0.getActionCommand();
311:
312:                if (action.equals("OK")) //$NON-NLS-1$
313:                {
314:                    // check if the user entered valid data
315:                    success = true;
316:
317:                    updateComponents(false);
318:
319:                    setVisible(false);
320:                } else if (action.equals("CANCEL")) {
321:                    success = false;
322:                    setVisible(false);
323:                } else if (action.equals("maximum")) {
324:                    // disable date picker
325:                    endDatePicker.setEnabled(false);
326:                    // enable max occurrences
327:                    maxOccurrences.setEnabled(true);
328:                } else if (action.equals("until")) {
329:                    // disable max occurrences
330:                    maxOccurrences.setEnabled(false);
331:                    // enable until
332:                    endDatePicker.setEnabled(true);
333:                } else if (action.equals("forever")) {
334:                    // disable other
335:                    endDatePicker.setEnabled(false);
336:                    maxOccurrences.setEnabled(false);
337:                }
338:            }
339:
340:            /**
341:             * @return Returns the model.
342:             */
343:            public IEventInfo getModel() {
344:                return model;
345:            }
346:
347:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.