Lines 8-19
Link Here
|
8 |
* Contributors: |
8 |
* Contributors: |
9 |
* IBM Corporation - initial API and implementation |
9 |
* IBM Corporation - initial API and implementation |
10 |
* Sebastian Davids <sdavids@gmx.de> - bug 54630 |
10 |
* Sebastian Davids <sdavids@gmx.de> - bug 54630 |
|
|
11 |
* Trevor S. Kaufman <endante@gmail.com> - bug 156152 |
11 |
*******************************************************************************/ |
12 |
*******************************************************************************/ |
12 |
package org.eclipse.team.internal.ui.synchronize; |
13 |
package org.eclipse.team.internal.ui.synchronize; |
13 |
|
14 |
|
|
|
15 |
import java.util.Date; |
16 |
|
17 |
import org.eclipse.jface.dialogs.*; |
14 |
import org.eclipse.jface.dialogs.Dialog; |
18 |
import org.eclipse.jface.dialogs.Dialog; |
15 |
import org.eclipse.jface.dialogs.IDialogConstants; |
|
|
16 |
import org.eclipse.jface.dialogs.MessageDialog; |
17 |
import org.eclipse.jface.resource.JFaceResources; |
19 |
import org.eclipse.jface.resource.JFaceResources; |
18 |
import org.eclipse.osgi.util.NLS; |
20 |
import org.eclipse.osgi.util.NLS; |
19 |
import org.eclipse.swt.SWT; |
21 |
import org.eclipse.swt.SWT; |
Lines 22-36
Link Here
|
22 |
import org.eclipse.swt.graphics.GC; |
24 |
import org.eclipse.swt.graphics.GC; |
23 |
import org.eclipse.swt.layout.GridData; |
25 |
import org.eclipse.swt.layout.GridData; |
24 |
import org.eclipse.swt.layout.GridLayout; |
26 |
import org.eclipse.swt.layout.GridLayout; |
25 |
import org.eclipse.swt.widgets.Button; |
27 |
import org.eclipse.swt.widgets.*; |
26 |
import org.eclipse.swt.widgets.Combo; |
|
|
27 |
import org.eclipse.swt.widgets.Composite; |
28 |
import org.eclipse.swt.widgets.Label; |
29 |
import org.eclipse.swt.widgets.Text; |
30 |
import org.eclipse.team.internal.ui.TeamUIMessages; |
28 |
import org.eclipse.team.internal.ui.TeamUIMessages; |
31 |
import org.eclipse.team.internal.ui.Utils; |
29 |
import org.eclipse.team.internal.ui.Utils; |
32 |
import org.eclipse.team.ui.synchronize.ISynchronizeParticipant; |
30 |
import org.eclipse.team.ui.synchronize.ISynchronizeParticipant; |
33 |
|
31 |
|
|
|
32 |
import com.ibm.icu.util.Calendar; |
33 |
|
34 |
/** |
34 |
/** |
35 |
* A composite that allows editing a subscriber refresh schedule. A validator can be used to allow |
35 |
* A composite that allows editing a subscriber refresh schedule. A validator can be used to allow |
36 |
* containers to show page completion. |
36 |
* containers to show page completion. |
Lines 42-50
Link Here
|
42 |
private SubscriberRefreshSchedule schedule; |
42 |
private SubscriberRefreshSchedule schedule; |
43 |
private Button userRefreshOnly; |
43 |
private Button userRefreshOnly; |
44 |
private Button enableBackgroundRefresh; |
44 |
private Button enableBackgroundRefresh; |
45 |
private Text time; |
45 |
private Text timeInterval; |
46 |
private Combo hoursOrSeconds; |
46 |
private Combo hoursOrSeconds; |
47 |
private IPageValidator validator; |
47 |
private IPageValidator validator; |
|
|
48 |
private DateTime startTime; |
48 |
|
49 |
|
49 |
public ConfigureSynchronizeScheduleComposite(Composite parent, SubscriberRefreshSchedule schedule, IPageValidator validator) { |
50 |
public ConfigureSynchronizeScheduleComposite(Composite parent, SubscriberRefreshSchedule schedule, IPageValidator validator) { |
50 |
super(parent, SWT.NONE); |
51 |
super(parent, SWT.NONE); |
Lines 72-78
Link Here
|
72 |
hours = true; |
73 |
hours = true; |
73 |
} |
74 |
} |
74 |
hoursOrSeconds.select(hours ? 0 : 1); |
75 |
hoursOrSeconds.select(hours ? 0 : 1); |
75 |
time.setText(Long.toString(minutes)); |
76 |
timeInterval.setText(Long.toString(minutes)); |
|
|
77 |
|
78 |
Date start = schedule.getRefreshStartTime(); |
79 |
Calendar cal = Calendar.getInstance(); |
80 |
cal.setTime(start); |
81 |
startTime.setTime(cal.get(Calendar.HOUR_OF_DAY), cal.get(Calendar.MINUTE), cal.get(Calendar.SECOND)); |
76 |
} |
82 |
} |
77 |
|
83 |
|
78 |
/* (non-Javadoc) |
84 |
/* (non-Javadoc) |
Lines 143-161
Link Here
|
143 |
composite.setLayout(gridLayout_1); |
149 |
composite.setLayout(gridLayout_1); |
144 |
{ |
150 |
{ |
145 |
final Label label = new Label(composite, SWT.NONE); |
151 |
final Label label = new Label(composite, SWT.NONE); |
|
|
152 |
label.setText(TeamUIMessages.ConfigureRefreshScheduleDialog_3a); |
153 |
} |
154 |
{ |
155 |
startTime = new DateTime(composite, SWT.TIME); |
156 |
final GridData gridData_1 = new GridData(); |
157 |
gridData_1.horizontalSpan = 2; |
158 |
startTime.setLayoutData(gridData_1); |
159 |
} |
160 |
{ |
161 |
final Label label = new Label(composite, SWT.NONE); |
146 |
label.setText(TeamUIMessages.ConfigureRefreshScheduleDialog_4); |
162 |
label.setText(TeamUIMessages.ConfigureRefreshScheduleDialog_4); |
147 |
} |
163 |
} |
148 |
{ |
164 |
{ |
149 |
time = new Text(composite, SWT.BORDER | SWT.RIGHT); |
165 |
timeInterval = new Text(composite, SWT.BORDER | SWT.RIGHT); |
150 |
final GridData gridData_1 = new GridData(); |
166 |
final GridData gridData_1 = new GridData(); |
151 |
gridData_1.widthHint = 35; |
167 |
gridData_1.widthHint = 35; |
152 |
time.setLayoutData(gridData_1); |
168 |
timeInterval.setLayoutData(gridData_1); |
153 |
time.addModifyListener(new ModifyListener() { |
169 |
timeInterval.addModifyListener(new ModifyListener() { |
154 |
public void modifyText(ModifyEvent e) { |
170 |
public void modifyText(ModifyEvent e) { |
155 |
updateEnablements(); |
171 |
updateEnablements(); |
156 |
} |
172 |
} |
157 |
}); |
173 |
}); |
158 |
time.addVerifyListener(new VerifyListener() { |
174 |
timeInterval.addVerifyListener(new VerifyListener() { |
159 |
public void verifyText(VerifyEvent e) { |
175 |
public void verifyText(VerifyEvent e) { |
160 |
String string = e.text; |
176 |
String string = e.text; |
161 |
char [] chars = new char [string.length ()]; |
177 |
char [] chars = new char [string.length ()]; |
Lines 184-190
Link Here
|
184 |
public void saveValues() { |
200 |
public void saveValues() { |
185 |
int hours = hoursOrSeconds.getSelectionIndex(); |
201 |
int hours = hoursOrSeconds.getSelectionIndex(); |
186 |
try { |
202 |
try { |
187 |
long seconds = Long.parseLong(time.getText()); |
203 |
long seconds = Long.parseLong(timeInterval.getText()); |
188 |
if(hours == 0) { |
204 |
if(hours == 0) { |
189 |
seconds = seconds * 3600; |
205 |
seconds = seconds * 3600; |
190 |
} else { |
206 |
} else { |
Lines 194-199
Link Here
|
194 |
} catch (NumberFormatException e) { |
210 |
} catch (NumberFormatException e) { |
195 |
// keep old value |
211 |
// keep old value |
196 |
} |
212 |
} |
|
|
213 |
|
214 |
Calendar cal = Calendar.getInstance(); |
215 |
cal.set(Calendar.HOUR_OF_DAY, startTime.getHours()); |
216 |
cal.set(Calendar.MINUTE, startTime.getMinutes()); |
217 |
cal.set(Calendar.SECOND, startTime.getSeconds()); |
218 |
|
219 |
schedule.setRefreshStartTime(cal.getTime()); |
220 |
|
197 |
if(schedule.isEnabled() != enableBackgroundRefresh.getSelection()) { |
221 |
if(schedule.isEnabled() != enableBackgroundRefresh.getSelection()) { |
198 |
schedule.setEnabled(enableBackgroundRefresh.getSelection(), true /* allow to start */); |
222 |
schedule.setEnabled(enableBackgroundRefresh.getSelection(), true /* allow to start */); |
199 |
} |
223 |
} |
Lines 216-222
Link Here
|
216 |
validator.setComplete(null); |
240 |
validator.setComplete(null); |
217 |
} else { |
241 |
} else { |
218 |
try { |
242 |
try { |
219 |
long number = Long.parseLong(time.getText()); |
243 |
long number = Long.parseLong(timeInterval.getText()); |
220 |
if(number <= 0) { |
244 |
if(number <= 0) { |
221 |
validator.setComplete(TeamUIMessages.ConfigureRefreshScheduleDialog_7); |
245 |
validator.setComplete(TeamUIMessages.ConfigureRefreshScheduleDialog_7); |
222 |
} else { |
246 |
} else { |
Lines 226-233
Link Here
|
226 |
validator.setComplete(TeamUIMessages.ConfigureRefreshScheduleDialog_8); |
250 |
validator.setComplete(TeamUIMessages.ConfigureRefreshScheduleDialog_8); |
227 |
} |
251 |
} |
228 |
} |
252 |
} |
229 |
time.setEnabled(enableBackgroundRefresh.getSelection()); |
253 |
timeInterval.setEnabled(enableBackgroundRefresh.getSelection()); |
230 |
hoursOrSeconds.setEnabled(enableBackgroundRefresh.getSelection()); |
254 |
hoursOrSeconds.setEnabled(enableBackgroundRefresh.getSelection()); |
|
|
255 |
startTime.setEnabled(enableBackgroundRefresh.getSelection()); |
231 |
} |
256 |
} |
232 |
|
257 |
|
233 |
private Label createWrappingLabel(Composite parent, String text, int indent, int horizontalSpan) { |
258 |
private Label createWrappingLabel(Composite parent, String text, int indent, int horizontalSpan) { |