Source Code Cross Referenced for CalendarDialogBox.java in  » Project-Management » OpenProj » com » projity » dialog » options » 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 » Project Management » OpenProj » com.projity.dialog.options 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:        The contents of this file are subject to the Common Public Attribution License 
003:        Version 1.0 (the "License"); you may not use this file except in compliance with 
004:        the License. You may obtain a copy of the License at 
005:        http://www.projity.com/license . The License is based on the Mozilla Public 
006:        License Version 1.1 but Sections 14 and 15 have been added to cover use of 
007:        software over a computer network and provide for limited attribution for the 
008:        Original Developer. In addition, Exhibit A has been modified to be consistent 
009:        with Exhibit B.
010:
011:        Software distributed under the License is distributed on an "AS IS" basis, 
012:        WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the 
013:        specific language governing rights and limitations under the License. The 
014:        Original Code is OpenProj. The Original Developer is the Initial Developer and 
015:        is Projity, Inc. All portions of the code written by Projity are Copyright (c) 
016:        2006, 2007. All Rights Reserved. Contributors Projity, Inc.
017:
018:        Alternatively, the contents of this file may be used under the terms of the 
019:        Projity End-User License Agreeement (the Projity License), in which case the 
020:        provisions of the Projity License are applicable instead of those above. If you 
021:        wish to allow use of your version of this file only under the terms of the 
022:        Projity License and not to allow others to use your version of this file under 
023:        the CPAL, indicate your decision by deleting the provisions above and replace 
024:        them with the notice and other provisions required by the Projity  License. If 
025:        you do not delete the provisions above, a recipient may use your version of this 
026:        file under either the CPAL or the Projity License.
027:
028:        [NOTE: The text of this license may differ slightly from the text of the notices 
029:        in Exhibits A and B of the license at http://www.projity.com/license. You should 
030:        use the latest text at http://www.projity.com/license for your modifications.
031:        You may not remove this license text from the source files.]
032:
033:        Attribution Information: Attribution Copyright Notice: Copyright © 2006, 2007 
034:        Projity, Inc. Attribution Phrase (not exceeding 10 words): Powered by OpenProj, 
035:        an open source solution from Projity. Attribution URL: http://www.projity.com 
036:        Graphic Image as provided in the Covered Code as file:  openproj_logo.png with 
037:        alternatives listed on http://www.projity.com/logo
038:
039:        Display of Attribution Information is required in Larger Works which are defined 
040:        in the CPAL as a work which combines Covered Code or portions thereof with code 
041:        not governed by the terms of the CPAL. However, in addition to the other notice 
042:        obligations, all copies of the Covered Code in Executable and Source Code form 
043:        distributed must, as a form of attribution of the original author, include on 
044:        each user interface screen the "OpenProj" logo visible to all users.  The 
045:        OpenProj logo should be located horizontally aligned with the menu bar and left 
046:        justified on the top left of the screen adjacent to the File menu.  The logo 
047:        must be at least 100 x 25 pixels.  When users click on the "OpenProj" logo it 
048:        must direct them back to http://www.projity.com.  
049:         */
050:        package com.projity.dialog.options;
051:
052:        import java.awt.Frame;
053:        import java.awt.event.ActionEvent;
054:        import java.awt.event.ActionListener;
055:
056:        import javax.swing.JButton;
057:        import javax.swing.JCheckBox;
058:        import javax.swing.JComboBox;
059:        import javax.swing.JComponent;
060:        import javax.swing.JLabel;
061:        import javax.swing.JSpinner;
062:        import javax.swing.JTextField;
063:        import javax.swing.SpinnerNumberModel;
064:
065:        import com.jgoodies.forms.builder.DefaultFormBuilder;
066:        import com.jgoodies.forms.layout.CellConstraints;
067:        import com.jgoodies.forms.layout.FormLayout;
068:        import com.projity.configuration.Settings;
069:        import com.projity.dialog.AbstractDialog;
070:        import com.projity.options.CalendarOption;
071:        import com.projity.strings.Messages;
072:
073:        /**
074:         *
075:         */
076:        public class CalendarDialogBox extends AbstractDialog {
077:            private static final long serialVersionUID = -6887419605301434923L;
078:
079:            public static class Form {
080:                Double hoursPerDay;
081:                Double hoursPerWeek;
082:                Double daysPerMonth;
083:                String startTime;
084:                String endTime;
085:                String weekStart;
086:                String fiscalYearStart;
087:                Boolean useStartingYear;
088:                Boolean setAsDefault;
089:
090:                Form(CalendarOption option) {
091:                    hoursPerDay = new Double(option.getHoursPerDay());
092:                    hoursPerWeek = new Double(option.getHoursPerWeek());
093:                    daysPerMonth = new Double(option.getDaysPerMonth());
094:                    startTime = option.getDefaultStartHour() + ""; //$NON-NLS-1$
095:                    endTime = option.getDefaultEndHour() + ""; //$NON-NLS-1$
096:
097:                }
098:
099:                public void copyToOption(CalendarOption option) {
100:                    option.setHoursPerDay(hoursPerDay.doubleValue());
101:                    option.setHoursPerWeek(hoursPerWeek.doubleValue());
102:                    option.setDaysPerMonth(daysPerMonth.doubleValue());
103:
104:                }
105:
106:                public Double getDaysPerMonth() {
107:                    return daysPerMonth;
108:                }
109:
110:                public void setDaysPerMonth(Double daysPerMonth) {
111:                    this .daysPerMonth = daysPerMonth;
112:                }
113:
114:                public String getEndTime() {
115:                    return endTime;
116:                }
117:
118:                public void setEndTime(String endTime) {
119:                    this .endTime = endTime;
120:                }
121:
122:                public String getFiscalYearStart() {
123:                    return fiscalYearStart;
124:                }
125:
126:                public void setFiscalYearStart(String fiscalYearStart) {
127:                    this .fiscalYearStart = fiscalYearStart;
128:                }
129:
130:                public Double getHoursPerDay() {
131:                    return hoursPerDay;
132:                }
133:
134:                public void setHoursPerDay(Double hoursPerDay) {
135:                    this .hoursPerDay = hoursPerDay;
136:                }
137:
138:                public Double getHoursPerWeek() {
139:                    return hoursPerWeek;
140:                }
141:
142:                public void setHoursPerWeek(Double hoursPerWeek) {
143:                    this .hoursPerWeek = hoursPerWeek;
144:                }
145:
146:                public Boolean getSetAsDefault() {
147:                    return setAsDefault;
148:                }
149:
150:                public void setSetAsDefault(Boolean setAsDefault) {
151:                    this .setAsDefault = setAsDefault;
152:                }
153:
154:                public String getStartTime() {
155:                    return startTime;
156:                }
157:
158:                public void setStartTime(String startTime) {
159:                    this .startTime = startTime;
160:                }
161:
162:                public Boolean getUseStartingYear() {
163:                    return useStartingYear;
164:                }
165:
166:                public void setUseStartingYear(Boolean useStartingYear) {
167:                    this .useStartingYear = useStartingYear;
168:                }
169:
170:                public String getWeekStart() {
171:                    return weekStart;
172:                }
173:
174:                public void setWeekStart(String weekStart) {
175:                    this .weekStart = weekStart;
176:                }
177:            }
178:
179:            private Form form;
180:
181:            JSpinner hoursPerDay;
182:            JSpinner hoursPerWeek;
183:            JSpinner daysPerMonth;
184:            JTextField startTime;
185:            JTextField endTime;
186:            JComboBox weekStart;
187:            JComboBox fiscalYearStart;
188:            JCheckBox useStartingYear;
189:            JButton setAsDefault;
190:
191:            public static CalendarDialogBox getInstance(Frame owner,
192:                    CalendarOption option) {
193:                return new CalendarDialogBox(owner, option);
194:            }
195:
196:            private CalendarDialogBox(Frame owner, CalendarOption option) {
197:                super (owner, Messages
198:                        .getString("CalendarDialogBox.DurationSettings"), true); //$NON-NLS-1$
199:                this .form = new Form(option);
200:                addDocHelp("Calendar_Options");
201:            }
202:
203:            protected void initControls() {
204:
205:                String[] week = new String[] {
206:                        Messages.getString("CalendarDialogBox.Monday"), Messages.getString("CalendarDialogBox.Tuesday"), Messages.getString("CalendarDialogBox.Wednesday"), Messages.getString("CalendarDialogBox.Thursday"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
207:                        Messages.getString("CalendarDialogBox.Friday"), Messages.getString("CalendarDialogBox.Saturday"), Messages.getString("CalendarDialogBox.Sunday") //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
208:                };
209:                String[] year = new String[] {
210:                        Messages.getString("CalendarDialogBox.January"), Messages.getString("CalendarDialogBox.February"), Messages.getString("CalendarDialogBox.March"), Messages.getString("CalendarDialogBox.April"), Messages.getString("CalendarDialogBox.May"), Messages.getString("CalendarDialogBox.June"), Messages.getString("CalendarDialogBox.July"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$
211:                        Messages.getString("CalendarDialogBox.August"), Messages.getString("CalendarDialogBox.September"), Messages.getString("CalendarDialogBox.October"), Messages.getString("CalendarDialogBox.November"), Messages.getString("CalendarDialogBox.December") //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
212:                };
213:                weekStart = new JComboBox(week);
214:                fiscalYearStart = new JComboBox(year);
215:                useStartingYear = new JCheckBox(
216:                        Messages
217:                                .getString("CalendarDialogBox.UserStartingYearForFVNumbering")); //$NON-NLS-1$
218:                useStartingYear.setEnabled(false);
219:
220:                startTime = new JTextField(Messages
221:                        .getString("CalendarDialogBox.EightAM")); //$NON-NLS-1$
222:                endTime = new JTextField(Messages
223:                        .getString("CalendarDialogBox.SixPM")); //$NON-NLS-1$
224:
225:                hoursPerDay = new JSpinner(new SpinnerNumberModel(form
226:                        .getHoursPerDay().doubleValue(), 0, 24.0, 0.5));
227:                JSpinner.NumberEditor editor1;
228:                editor1 = new JSpinner.NumberEditor(hoursPerDay, "##.##"); //$NON-NLS-1$
229:                hoursPerDay.setEditor(editor1);
230:
231:                hoursPerWeek = new JSpinner(new SpinnerNumberModel(form
232:                        .getHoursPerWeek().doubleValue(), 0, 168.0, 0.5));
233:                JSpinner.NumberEditor editor2;
234:                editor2 = new JSpinner.NumberEditor(hoursPerWeek, "##.##"); //$NON-NLS-1$
235:                hoursPerWeek.setEditor(editor2);
236:
237:                daysPerMonth = new JSpinner(new SpinnerNumberModel(form
238:                        .getDaysPerMonth().doubleValue(), 0, 31.0, 1.0));
239:                JSpinner.NumberEditor editor3;
240:                editor3 = new JSpinner.NumberEditor(daysPerMonth, "##.##"); //$NON-NLS-1$
241:                daysPerMonth.setEditor(editor3);
242:
243:                setAsDefault = new JButton(Messages
244:                        .getString("CalendarDialogBox.SetAsDefault")); //$NON-NLS-1$
245:
246:                fiscalYearStart.addActionListener(new ActionListener() {
247:                    public void actionPerformed(ActionEvent e) {
248:                        if (fiscalYearStart
249:                                .getSelectedItem()
250:                                .equals(
251:                                        Messages
252:                                                .getString("CalendarDialogBox.January"))) { //$NON-NLS-1$
253:                            useStartingYear.setEnabled(false);
254:                        } else {
255:                            useStartingYear.setEnabled(true);
256:                        }
257:                    }
258:                });
259:
260:            }
261:
262:            protected boolean bind(boolean get) {
263:                if (form == null)
264:                    return false;
265:                if (get) {
266:                    weekStart.setSelectedItem(form.getWeekStart());
267:                    fiscalYearStart.setSelectedItem(form.getFiscalYearStart());
268:                    useStartingYear.setSelected((form.getUseStartingYear())
269:                            .booleanValue());
270:                    startTime.setText(/*form.getStartTime()*/Messages
271:                            .getString("CalendarDialogBox.Eight")); //$NON-NLS-1$
272:                    endTime.setText(/*form.getEndTime()*/Messages
273:                            .getString("CalendarDialogBox.Seventeen")); //$NON-NLS-1$
274:                    hoursPerDay.setValue(form.getHoursPerDay());
275:                    hoursPerWeek.setValue(form.getHoursPerWeek());
276:                    daysPerMonth.setValue(form.getDaysPerMonth());
277:                    setAsDefault.setSelected((form.getSetAsDefault())
278:                            .booleanValue());
279:
280:                } else {
281:                    form.setWeekStart((String) weekStart.getSelectedItem());
282:                    form.setFiscalYearStart((String) fiscalYearStart
283:                            .getSelectedItem());
284:                    Boolean b1 = new Boolean(useStartingYear.isSelected());
285:                    form.setUseStartingYear(b1);
286:                    form.setStartTime(startTime.getText());
287:                    form.setEndTime(endTime.getText());
288:                    form.setHoursPerDay((Double) hoursPerDay.getValue());
289:                    form.setHoursPerWeek((Double) hoursPerWeek.getValue());
290:                    form.setDaysPerMonth((Double) daysPerMonth.getValue());
291:                    Boolean b2 = new Boolean(setAsDefault.isSelected());
292:                    form.setSetAsDefault(b2);
293:
294:                }
295:                return true;
296:            }
297:
298:            public JComponent createContentPanel() {
299:
300:                initControls();
301:
302:                FormLayout layout = new FormLayout("p,3dlu,p,p:grow", //$NON-NLS-1$
303:                        "p,3dlu,p,3dlu,p,3dlu,p"); //$NON-NLS-1$
304:
305:                DefaultFormBuilder builder = new DefaultFormBuilder(layout);
306:                builder.setDefaultDialogBorder();
307:                CellConstraints cc = new CellConstraints();
308:                builder
309:                        .add(
310:                                new JLabel(
311:                                        Messages
312:                                                .getString("CalendarDialogBox.TheseSettingsOnlyApplyToDuration")), cc.xyw(builder.getColumn(), builder //$NON-NLS-1$
313:                                                        .getRow(), 4));
314:                builder.nextLine(2);
315:                builder
316:                        .append(
317:                                Messages
318:                                        .getString("CalendarDialogBox.HoursPerday"), hoursPerDay); //$NON-NLS-1$
319:                builder.nextLine(2);
320:                builder
321:                        .append(
322:                                Messages
323:                                        .getString("CalendarDialogBox.HoursPerWeek"), hoursPerWeek); //$NON-NLS-1$
324:                builder.nextLine(2);
325:                builder
326:                        .append(
327:                                Messages
328:                                        .getString("CalendarDialogBox.DaysPerMonth"), daysPerMonth); //$NON-NLS-1$
329:
330:                return builder.getPanel();
331:            }
332:
333:            //    	public JComponent createContentPanel() {
334:            //        	
335:            //    		initControls();
336:            //    		
337:            //    		FormLayout layout = new FormLayout(
338:            //    		        "left:80dlu,3dlu,50dlu, 3dlu,130dlu,3dlu",
339:            //    	    		  "p,3dlu,p,3dlu,p,3dlu,p,3dlu,p,3dlu,p,3dlu,p,3dlu,p,3dlu,p,3dlu,p,3dlu,p,3dlu,p,3dlu,p,3dlu,p,3dlu,p,3dlu,p,3dlu,p,3dlu,p,3dlu,fill:10dlu:grow");
340:            //
341:            //    		DefaultFormBuilder builder = new DefaultFormBuilder(layout);
342:            //    		builder.setDefaultDialogBorder();
343:            //    		CellConstraints cc = new CellConstraints();
344:            //    		
345:            //    		builder.addSeparator("Local calendar options");
346:            //    		builder.nextLine(4);
347:            //    		builder.append("Week starts on :",weekStart);
348:            //    		builder.nextLine(2);
349:            //    		builder.append("Fiscal year starts in :",fiscalYearStart);
350:            //    		builder.nextLine(2);
351:            //    		builder.nextColumn(4);
352:            //    		builder.append(useStartingYear);
353:            //    		builder.nextLine(4);
354:            //    		builder.addSeparator("");
355:            //    		builder.nextLine(4);
356:            //    		builder.append("Default start time :",startTime);
357:            //    		builder.nextLine(2);
358:            //    		builder.append("Default end time :",endTime);
359:            //    		builder.nextLine(4);
360:            //    		builder.addSeparator("");
361:            //    		builder.nextLine(4);
362:            //    		builder.append("Hours per day :",hoursPerDay);
363:            //    		builder.nextLine(2);
364:            //    		builder.append("Hours per week :",hoursPerWeek);
365:            //    		builder.nextLine(2);
366:            //    		builder.append("Days per month :",daysPerMonth);
367:            //    		builder.nextLine(4);
368:            //    		builder.append(setAsDefault);
369:            //    		builder.nextLine(2);
370:            //  
371:            //
372:            //    		return builder.getPanel();
373:            //    	}
374:
375:            public Object getBean() {
376:                return form;
377:            }
378:
379:            public Form getForm() {
380:                return form;
381:            }
382:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.