|
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; |
| 49 |
private Button immediately; |
| 50 |
private Button runOnce; |
| 48 |
|
51 |
|
| 49 |
public ConfigureSynchronizeScheduleComposite(Composite parent, SubscriberRefreshSchedule schedule, IPageValidator validator) { |
52 |
public ConfigureSynchronizeScheduleComposite(Composite parent, SubscriberRefreshSchedule schedule, IPageValidator validator) { |
| 50 |
super(parent, SWT.NONE); |
53 |
super(parent, SWT.NONE); |
|
Lines 72-78
Link Here
|
| 72 |
hours = true; |
75 |
hours = true; |
| 73 |
} |
76 |
} |
| 74 |
hoursOrSeconds.select(hours ? 0 : 1); |
77 |
hoursOrSeconds.select(hours ? 0 : 1); |
| 75 |
time.setText(Long.toString(minutes)); |
78 |
timeInterval.setText(Long.toString(minutes)); |
|
|
79 |
runOnce.setSelection(schedule.getRunOnce()); |
| 80 |
|
| 81 |
Date start = schedule.getRefreshStartTime(); |
| 82 |
Calendar cal = Calendar.getInstance(); |
| 83 |
cal.setTime(start); |
| 84 |
startTime.setTime(cal.get(Calendar.HOUR_OF_DAY), cal.get(Calendar.MINUTE), cal.get(Calendar.SECOND)); |
| 76 |
} |
85 |
} |
| 77 |
|
86 |
|
| 78 |
/* (non-Javadoc) |
87 |
/* (non-Javadoc) |
|
Lines 135-141
Link Here
|
| 135 |
gridData.horizontalSpan = 2; |
144 |
gridData.horizontalSpan = 2; |
| 136 |
composite.setLayoutData(gridData); |
145 |
composite.setLayoutData(gridData); |
| 137 |
final GridLayout gridLayout_1 = new GridLayout(); |
146 |
final GridLayout gridLayout_1 = new GridLayout(); |
| 138 |
gridLayout_1.numColumns = 3; |
147 |
gridLayout_1.numColumns = 4; |
| 139 |
gridLayout_1.marginWidth = 0; |
148 |
gridLayout_1.marginWidth = 0; |
| 140 |
gridLayout_1.marginHeight = 0; |
149 |
gridLayout_1.marginHeight = 0; |
| 141 |
gridLayout_1.horizontalSpacing = Dialog.convertHorizontalDLUsToPixels(fontMetrics, IDialogConstants.HORIZONTAL_SPACING); |
150 |
gridLayout_1.horizontalSpacing = Dialog.convertHorizontalDLUsToPixels(fontMetrics, IDialogConstants.HORIZONTAL_SPACING); |
|
Lines 143-161
Link Here
|
| 143 |
composite.setLayout(gridLayout_1); |
152 |
composite.setLayout(gridLayout_1); |
| 144 |
{ |
153 |
{ |
| 145 |
final Label label = new Label(composite, SWT.NONE); |
154 |
final Label label = new Label(composite, SWT.NONE); |
|
|
155 |
label.setText(TeamUIMessages.ConfigureRefreshScheduleDialog_3a); |
| 156 |
} |
| 157 |
{ |
| 158 |
startTime = new DateTime(composite, SWT.TIME | SWT.BORDER); |
| 159 |
final GridData gridData_1 = new GridData(); |
| 160 |
gridData_1.horizontalSpan = 2; |
| 161 |
startTime.setLayoutData(gridData_1); |
| 162 |
|
| 163 |
} |
| 164 |
{ |
| 165 |
immediately = new Button(composite, SWT.CHECK); |
| 166 |
immediately.setText(TeamUIMessages.ConfigureRefreshScheduleDialog_3b); |
| 167 |
immediately.addSelectionListener(new SelectionAdapter() { |
| 168 |
public void widgetSelected(SelectionEvent e) { |
| 169 |
updateEnablements(); |
| 170 |
} |
| 171 |
}); |
| 172 |
} |
| 173 |
{ |
| 174 |
final Label label = new Label(composite, SWT.NONE); |
| 146 |
label.setText(TeamUIMessages.ConfigureRefreshScheduleDialog_4); |
175 |
label.setText(TeamUIMessages.ConfigureRefreshScheduleDialog_4); |
| 147 |
} |
176 |
} |
| 148 |
{ |
177 |
{ |
| 149 |
time = new Text(composite, SWT.BORDER | SWT.RIGHT); |
178 |
timeInterval = new Text(composite, SWT.BORDER | SWT.RIGHT); |
| 150 |
final GridData gridData_1 = new GridData(); |
179 |
final GridData gridData_1 = new GridData(); |
| 151 |
gridData_1.widthHint = 35; |
180 |
gridData_1.widthHint = 35; |
| 152 |
time.setLayoutData(gridData_1); |
181 |
timeInterval.setLayoutData(gridData_1); |
| 153 |
time.addModifyListener(new ModifyListener() { |
182 |
timeInterval.addModifyListener(new ModifyListener() { |
| 154 |
public void modifyText(ModifyEvent e) { |
183 |
public void modifyText(ModifyEvent e) { |
| 155 |
updateEnablements(); |
184 |
updateEnablements(); |
| 156 |
} |
185 |
} |
| 157 |
}); |
186 |
}); |
| 158 |
time.addVerifyListener(new VerifyListener() { |
187 |
timeInterval.addVerifyListener(new VerifyListener() { |
| 159 |
public void verifyText(VerifyEvent e) { |
188 |
public void verifyText(VerifyEvent e) { |
| 160 |
String string = e.text; |
189 |
String string = e.text; |
| 161 |
char [] chars = new char [string.length ()]; |
190 |
char [] chars = new char [string.length ()]; |
|
Lines 174-179
Link Here
|
| 174 |
hoursOrSeconds.setItems(new String[] { TeamUIMessages.ConfigureRefreshScheduleDialog_5, TeamUIMessages.ConfigureRefreshScheduleDialog_6 }); // |
203 |
hoursOrSeconds.setItems(new String[] { TeamUIMessages.ConfigureRefreshScheduleDialog_5, TeamUIMessages.ConfigureRefreshScheduleDialog_6 }); // |
| 175 |
hoursOrSeconds.setLayoutData(new GridData()); |
204 |
hoursOrSeconds.setLayoutData(new GridData()); |
| 176 |
} |
205 |
} |
|
|
206 |
{ |
| 207 |
runOnce = new Button(composite, SWT.CHECK); |
| 208 |
runOnce.setText("Run Once"); //$NON-NLS-1$ |
| 209 |
runOnce.addSelectionListener(new SelectionAdapter() { |
| 210 |
public void widgetSelected(SelectionEvent e) { |
| 211 |
updateEnablements(); |
| 212 |
} |
| 213 |
}); |
| 214 |
} |
| 177 |
} |
215 |
} |
| 178 |
initializeValues(); |
216 |
initializeValues(); |
| 179 |
} |
217 |
} |
|
Lines 182-199
Link Here
|
| 182 |
* @see org.eclipse.jface.dialogs.Dialog#okPressed() |
220 |
* @see org.eclipse.jface.dialogs.Dialog#okPressed() |
| 183 |
*/ |
221 |
*/ |
| 184 |
public void saveValues() { |
222 |
public void saveValues() { |
| 185 |
int hours = hoursOrSeconds.getSelectionIndex(); |
223 |
if (!runOnce.getSelection()) { |
| 186 |
try { |
224 |
int hours = hoursOrSeconds.getSelectionIndex(); |
| 187 |
long seconds = Long.parseLong(time.getText()); |
225 |
try { |
| 188 |
if(hours == 0) { |
226 |
long seconds = Long.parseLong(timeInterval.getText()); |
| 189 |
seconds = seconds * 3600; |
227 |
if(hours == 0) { |
| 190 |
} else { |
228 |
seconds = seconds * 3600; |
| 191 |
seconds = seconds * 60; |
229 |
} else { |
| 192 |
} |
230 |
seconds = seconds * 60; |
| 193 |
schedule.setRefreshInterval(seconds); |
231 |
} |
| 194 |
} catch (NumberFormatException e) { |
232 |
schedule.setRefreshInterval(seconds); |
| 195 |
// keep old value |
233 |
} catch (NumberFormatException e) { |
|
|
234 |
// keep old value |
| 235 |
} |
| 236 |
} else { |
| 237 |
schedule.setRunOnce(runOnce.getSelection()); |
| 196 |
} |
238 |
} |
|
|
239 |
|
| 240 |
Calendar cal = Calendar.getInstance(); |
| 241 |
if (! immediately.getSelection()) { |
| 242 |
cal.set(Calendar.HOUR_OF_DAY, startTime.getHours()); |
| 243 |
cal.set(Calendar.MINUTE, startTime.getMinutes()); |
| 244 |
cal.set(Calendar.SECOND, startTime.getSeconds()); |
| 245 |
} else { |
| 246 |
cal.add(Calendar.SECOND, 1); // ensure time is today |
| 247 |
} |
| 248 |
schedule.setRefreshStartTime(cal.getTime()); |
| 249 |
|
| 197 |
if(schedule.isEnabled() != enableBackgroundRefresh.getSelection()) { |
250 |
if(schedule.isEnabled() != enableBackgroundRefresh.getSelection()) { |
| 198 |
schedule.setEnabled(enableBackgroundRefresh.getSelection(), true /* allow to start */); |
251 |
schedule.setEnabled(enableBackgroundRefresh.getSelection(), true /* allow to start */); |
| 199 |
} |
252 |
} |
|
Lines 216-222
Link Here
|
| 216 |
validator.setComplete(null); |
269 |
validator.setComplete(null); |
| 217 |
} else { |
270 |
} else { |
| 218 |
try { |
271 |
try { |
| 219 |
long number = Long.parseLong(time.getText()); |
272 |
long number = Long.parseLong(timeInterval.getText()); |
| 220 |
if(number <= 0) { |
273 |
if(number <= 0) { |
| 221 |
validator.setComplete(TeamUIMessages.ConfigureRefreshScheduleDialog_7); |
274 |
validator.setComplete(TeamUIMessages.ConfigureRefreshScheduleDialog_7); |
| 222 |
} else { |
275 |
} else { |
|
Lines 226-233
Link Here
|
| 226 |
validator.setComplete(TeamUIMessages.ConfigureRefreshScheduleDialog_8); |
279 |
validator.setComplete(TeamUIMessages.ConfigureRefreshScheduleDialog_8); |
| 227 |
} |
280 |
} |
| 228 |
} |
281 |
} |
| 229 |
time.setEnabled(enableBackgroundRefresh.getSelection()); |
282 |
timeInterval.setEnabled(enableBackgroundRefresh.getSelection()); |
| 230 |
hoursOrSeconds.setEnabled(enableBackgroundRefresh.getSelection()); |
283 |
hoursOrSeconds.setEnabled(enableBackgroundRefresh.getSelection()); |
|
|
284 |
runOnce.setEnabled(enableBackgroundRefresh.getSelection()); |
| 285 |
if (runOnce.isEnabled()) { |
| 286 |
timeInterval.setEnabled(!runOnce.getSelection()); |
| 287 |
hoursOrSeconds.setEnabled(!runOnce.getSelection()); |
| 288 |
} |
| 289 |
|
| 290 |
startTime.setEnabled(enableBackgroundRefresh.getSelection()); |
| 291 |
immediately.setEnabled(enableBackgroundRefresh.getSelection()); |
| 292 |
if (immediately.isEnabled()) { |
| 293 |
startTime.setEnabled(!immediately.getSelection()); |
| 294 |
} |
| 231 |
} |
295 |
} |
| 232 |
|
296 |
|
| 233 |
private Label createWrappingLabel(Composite parent, String text, int indent, int horizontalSpan) { |
297 |
private Label createWrappingLabel(Composite parent, String text, int indent, int horizontalSpan) { |