0
|
1 |
/*
|
|
2 |
* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description:
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
package com.nokia.s60tools.creator.dialogs;
|
|
20 |
|
|
21 |
|
|
22 |
import org.eclipse.swt.widgets.Composite;
|
|
23 |
import org.eclipse.swt.widgets.Control;
|
|
24 |
import org.eclipse.swt.widgets.Shell;
|
|
25 |
|
|
26 |
import com.nokia.s60tools.creator.components.AbstractComponent;
|
|
27 |
import com.nokia.s60tools.creator.components.AbstractValue;
|
|
28 |
import com.nokia.s60tools.creator.components.AbstractVariables;
|
|
29 |
import com.nokia.s60tools.creator.components.AbstractValue.ModeTypes;
|
|
30 |
import com.nokia.s60tools.creator.components.calendar.Calendar;
|
|
31 |
import com.nokia.s60tools.creator.components.calendar.CalendarValue;
|
|
32 |
import com.nokia.s60tools.creator.components.calendar.CalendarVariables;
|
|
33 |
import com.nokia.s60tools.creator.core.CreatorEditorSettings;
|
|
34 |
import com.nokia.s60tools.creator.editors.IComponentProvider;
|
|
35 |
|
|
36 |
|
|
37 |
/**
|
|
38 |
*
|
|
39 |
*/
|
|
40 |
public class CalendarDialog extends AbstractDialog {
|
|
41 |
|
|
42 |
|
|
43 |
|
|
44 |
|
|
45 |
private String calendarType = null;
|
|
46 |
|
|
47 |
|
|
48 |
// public CalendarDialog(IShellProvider parentShell, IComponentProvider provider) {
|
|
49 |
//
|
|
50 |
// super(parentShell, provider);
|
|
51 |
//
|
|
52 |
//
|
|
53 |
// }
|
|
54 |
|
|
55 |
public CalendarDialog(Shell parentShell, String calendarType, IComponentProvider provider) {
|
|
56 |
super(parentShell, provider);
|
|
57 |
this.calendarType = calendarType;
|
|
58 |
init(calendarType);
|
|
59 |
}
|
|
60 |
// public CalendarDialog(IShellProvider parentShell, IComponentProvider provider, String calendarType) {
|
|
61 |
// this(parentShell, provider);
|
|
62 |
// this.calendarType = calendarType;
|
|
63 |
// init(calendarType);
|
|
64 |
// }
|
|
65 |
|
|
66 |
public CalendarDialog(Shell sh, IComponentProvider provider) {
|
|
67 |
super(sh, provider);
|
|
68 |
Calendar cal = (Calendar)provider.getEditable();
|
|
69 |
init(cal.getEventType());
|
|
70 |
}
|
|
71 |
/**
|
|
72 |
* Initialize, creates Contact object
|
|
73 |
*/
|
|
74 |
private void init(String calendarType){
|
|
75 |
this.calendarType = calendarType.toLowerCase();
|
|
76 |
if(getComponent() == null){
|
|
77 |
AbstractComponent comp = new Calendar(AbstractComponent.NULL_ID, calendarType);
|
|
78 |
setComponent(comp);
|
|
79 |
}
|
|
80 |
setAmountFieldsEnabled(false);
|
|
81 |
}
|
|
82 |
|
|
83 |
|
|
84 |
|
|
85 |
/* (non-Javadoc)
|
|
86 |
* @see com.nokia.s60tools.creator.dialogs.AbstractDialog#createNewComponent()
|
|
87 |
*/
|
|
88 |
protected Calendar createNewComponent(){
|
|
89 |
return new Calendar(AbstractComponent.NULL_ID, calendarType);
|
|
90 |
}
|
|
91 |
|
|
92 |
|
|
93 |
protected CalendarValue createNewValue(String type, String value, String random, String amount) {
|
|
94 |
|
|
95 |
int amout_ = 0;
|
|
96 |
ModeTypes random_ = ModeTypes.RandomTypeNotRandom;
|
|
97 |
String value_ = value;
|
|
98 |
|
|
99 |
//If amount is set
|
|
100 |
if(amount != null && amount.trim().length() > 0){
|
|
101 |
amout_ = Integer.parseInt(amount);
|
|
102 |
}
|
|
103 |
|
|
104 |
//if random is selected
|
|
105 |
if(random != null && random.trim().length() > 0 && !random.equals(AbstractValue.EMPTY_STRING)){
|
|
106 |
random_ = AbstractValue.getModeTypeByText(random);
|
|
107 |
if(random_ != ModeTypes.RandomTypeNotRandom){
|
|
108 |
value_ = AbstractValue.RANDOM_TEXT;
|
|
109 |
}
|
|
110 |
}
|
|
111 |
CalendarValue cal = new CalendarValue(type, value_, random_, amout_);
|
|
112 |
return cal;
|
|
113 |
}
|
|
114 |
|
|
115 |
|
|
116 |
/* (non-Javadoc)
|
|
117 |
* @see com.nokia.s60tools.creator.dialogs.AbstractDialog#getItemValueAsString()
|
|
118 |
*/
|
|
119 |
protected String[] getItemTypesAsString() {
|
|
120 |
return CalendarVariables.getInstance().getItemValuesAsString(calendarType);
|
|
121 |
}
|
|
122 |
|
|
123 |
/* Creating all items to dialog area
|
|
124 |
* (non-Javadoc)
|
|
125 |
* @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
|
|
126 |
*/
|
|
127 |
protected Control createDialogArea(Composite parent) {
|
|
128 |
|
|
129 |
Composite composite = createDialogAreaComposite(parent);
|
|
130 |
setTableColumnHeaderAmount(MAX_AMOUNT_TEXT);
|
|
131 |
|
|
132 |
//If type is Appointment, there is Attendees, showing additional help information for that
|
|
133 |
boolean isAppointment = calendarType.equalsIgnoreCase(CreatorEditorSettings.TYPE_APPOINTMENT)
|
|
134 |
|| calendarType.equalsIgnoreCase(CreatorEditorSettings.TYPE_APPOINTMENT_XML_ELEMENT);
|
|
135 |
|
|
136 |
//Create also add new contact set button, if this is appointment dialog
|
|
137 |
createAmountArea(composite, isAppointment);
|
|
138 |
|
|
139 |
createTableArea(composite);
|
|
140 |
|
|
141 |
if(isAppointment){
|
|
142 |
|
|
143 |
String attendeInfo = "For '" +CalendarVariables.ATTENDEE +"' use format: 'attendee email' or 'attendee email | attendee common name'";
|
|
144 |
addInformation(composite, attendeInfo);
|
|
145 |
|
|
146 |
String possibleValuesInfoText =
|
|
147 |
CalendarVariables.RECURRENTFREQUENCY_POSSIBLE_VALUES_HELP_TEXT
|
|
148 |
+POSSIBLE_VALUES_FOR_TXT_PART_3;
|
|
149 |
addInformation(composite, possibleValuesInfoText);
|
|
150 |
|
|
151 |
}
|
|
152 |
//If type is Appointment, there is Attendees, showing additional help information for that
|
|
153 |
else if(calendarType.equalsIgnoreCase(CreatorEditorSettings.TYPE_TODO)
|
|
154 |
|| calendarType.equalsIgnoreCase(CreatorEditorSettings.TYPE_TODO_XML_ELEMENT)){
|
|
155 |
|
|
156 |
|
|
157 |
String possibleValuesInfoText =
|
|
158 |
POSSIBLE_VALUES_FOR_TXT_PART_1
|
|
159 |
+CalendarVariables.PRIORITY
|
|
160 |
+POSSIBLE_VALUES_FOR_TXT_PART_2
|
|
161 |
+CalendarVariables.PRIORITY_POSSIBLE_VALUES_HELP_TEXT
|
|
162 |
+POSSIBLE_VALUES_FOR_TXT_PART_3;
|
|
163 |
addInformation(composite, possibleValuesInfoText);
|
|
164 |
}
|
|
165 |
addInformation(composite, AbstractVariables.DATE_TIME_AND_DATE_FORMAT_HELP_TEXT);
|
|
166 |
|
|
167 |
if(wasErrors()){
|
|
168 |
showErrorDialog("Errors occured when dialog opened", getErrors());
|
|
169 |
}
|
|
170 |
return composite;
|
|
171 |
}
|
|
172 |
|
|
173 |
|
|
174 |
/* (non-Javadoc)
|
|
175 |
* @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell)
|
|
176 |
*/
|
|
177 |
protected void configureShell(Shell shell) {
|
|
178 |
super.configureShell(shell);
|
|
179 |
// Calendar cal = (Calendar)getComponent();
|
|
180 |
if(isInEditMode()){
|
|
181 |
shell.setText("Edit " +getComponent().getValueById(calendarType) +"(s)");
|
|
182 |
}else{
|
|
183 |
shell.setText("Add " + getComponent().getValueById(calendarType) +"(s)");
|
|
184 |
}
|
|
185 |
}
|
|
186 |
|
|
187 |
|
|
188 |
}
|