### Eclipse Workspace Patch 1.0 #P org.eclipse.team.ui Index: src/org/eclipse/team/internal/ui/synchronize/SubscriberRefreshSchedule.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SubscriberRefreshSchedule.java,v retrieving revision 1.18 diff -u -r1.18 SubscriberRefreshSchedule.java --- src/org/eclipse/team/internal/ui/synchronize/SubscriberRefreshSchedule.java 18 Dec 2006 14:54:45 -0000 1.18 +++ src/org/eclipse/team/internal/ui/synchronize/SubscriberRefreshSchedule.java 31 Jul 2008 18:38:34 -0000 @@ -7,10 +7,10 @@ * * Contributors: * IBM Corporation - initial API and implementation + * Trevor S. Kaufman - bug 156152 *******************************************************************************/ package org.eclipse.team.internal.ui.synchronize; -import com.ibm.icu.text.DateFormat; import java.util.Date; import org.eclipse.core.runtime.jobs.Job; @@ -20,6 +20,9 @@ import org.eclipse.ui.IMemento; import org.eclipse.ui.actions.ActionFactory; +import com.ibm.icu.text.DateFormat; +import com.ibm.icu.util.Calendar; + /** * Schedule to refresh a subscriber at a specified interval. The schedule can be disabled or enabled * and will create the refresh job. @@ -28,6 +31,7 @@ */ public class SubscriberRefreshSchedule { private long refreshInterval = 3600; // 1 hour default + private Date refreshStart = new Date(); private boolean enabled = false; @@ -46,6 +50,11 @@ * Key for schedule in memento */ private static final String CTX_REFRESHSCHEDULE_ENABLED = TeamUIPlugin.ID + ".CTX_REFRESHSCHEDULE_ENABLED"; //$NON-NLS-1$ + + /** + * Key for schedule in memento + */ + private static final String CTX_REFRESHSCHEDULE_START = TeamUIPlugin.ID + ".CTX_REFRESHSCHEDULE_START"; //$NON-NLS-1$ private IRefreshSubscriberListener refreshSubscriberListener = new IRefreshSubscriberListener() { public void refreshStarted(IRefreshEvent event) { @@ -128,7 +137,16 @@ job.setRestartOnCancel(true); job.setReschedule(true); // Schedule delay is in mills. - job.schedule(getRefreshInterval() * 1000); + Calendar now = Calendar.getInstance(); + Calendar start = Calendar.getInstance(); + start.setTime(refreshStart); + start.set(now.get(Calendar.YEAR), now.get(Calendar.MONTH), now.get(Calendar.DATE)); + + if (now.after(start)) { + start.add(Calendar.DATE, 1); + } + long offset = start.getTimeInMillis() - now.getTimeInMillis(); + job.schedule(offset); } protected void stopJob() { @@ -148,6 +166,7 @@ public void saveState(IMemento memento) { memento.putString(CTX_REFRESHSCHEDULE_ENABLED, Boolean.toString(enabled)); memento.putInteger(CTX_REFRESHSCHEDULE_INTERVAL, (int)refreshInterval); + memento.putString(CTX_REFRESHSCHEDULE_START, Long.toString(refreshStart.getTime())); } public static SubscriberRefreshSchedule init(IMemento memento, IRefreshable refreshable) { @@ -155,6 +174,8 @@ if(memento != null) { String enabled = memento.getString(CTX_REFRESHSCHEDULE_ENABLED); int interval = memento.getInteger(CTX_REFRESHSCHEDULE_INTERVAL).intValue(); + long start = Long.parseLong(memento.getString(CTX_REFRESHSCHEDULE_START)); + schedule.setRefreshStartTime(new Date(start)); schedule.setRefreshInterval(interval); schedule.setEnabled("true".equals(enabled) ? true : false, false /* don't start job */); //$NON-NLS-1$ } @@ -212,4 +233,18 @@ public IRefreshable getRefreshable() { return refreshable; } + + public Date getRefreshStartTime() { + return refreshStart; + } + + public void setRefreshStartTime(Date refreshStart) { + if(refreshStart != getRefreshStartTime()) { + stopJob(); + this.refreshStart = refreshStart; + if(isEnabled()) { + startJob(); + } + } + } } Index: src/org/eclipse/team/internal/ui/synchronize/ConfigureSynchronizeScheduleComposite.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/ConfigureSynchronizeScheduleComposite.java,v retrieving revision 1.14 diff -u -r1.14 ConfigureSynchronizeScheduleComposite.java --- src/org/eclipse/team/internal/ui/synchronize/ConfigureSynchronizeScheduleComposite.java 21 Jun 2006 19:26:16 -0000 1.14 +++ src/org/eclipse/team/internal/ui/synchronize/ConfigureSynchronizeScheduleComposite.java 31 Jul 2008 18:38:34 -0000 @@ -8,12 +8,14 @@ * Contributors: * IBM Corporation - initial API and implementation * Sebastian Davids - bug 54630 + * Trevor S. Kaufman - bug 156152 *******************************************************************************/ package org.eclipse.team.internal.ui.synchronize; +import java.util.Date; + +import org.eclipse.jface.dialogs.*; import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.resource.JFaceResources; import org.eclipse.osgi.util.NLS; import org.eclipse.swt.SWT; @@ -22,15 +24,13 @@ import org.eclipse.swt.graphics.GC; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Combo; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Text; +import org.eclipse.swt.widgets.*; import org.eclipse.team.internal.ui.TeamUIMessages; import org.eclipse.team.internal.ui.Utils; import org.eclipse.team.ui.synchronize.ISynchronizeParticipant; +import com.ibm.icu.util.Calendar; + /** * A composite that allows editing a subscriber refresh schedule. A validator can be used to allow * containers to show page completion. @@ -42,9 +42,10 @@ private SubscriberRefreshSchedule schedule; private Button userRefreshOnly; private Button enableBackgroundRefresh; - private Text time; + private Text timeInterval; private Combo hoursOrSeconds; private IPageValidator validator; + private DateTime startTime; public ConfigureSynchronizeScheduleComposite(Composite parent, SubscriberRefreshSchedule schedule, IPageValidator validator) { super(parent, SWT.NONE); @@ -72,7 +73,12 @@ hours = true; } hoursOrSeconds.select(hours ? 0 : 1); - time.setText(Long.toString(minutes)); + timeInterval.setText(Long.toString(minutes)); + + Date start = schedule.getRefreshStartTime(); + Calendar cal = Calendar.getInstance(); + cal.setTime(start); + startTime.setTime(cal.get(Calendar.HOUR_OF_DAY), cal.get(Calendar.MINUTE), cal.get(Calendar.SECOND)); } /* (non-Javadoc) @@ -143,19 +149,29 @@ composite.setLayout(gridLayout_1); { final Label label = new Label(composite, SWT.NONE); + label.setText(TeamUIMessages.ConfigureRefreshScheduleDialog_3a); + } + { + startTime = new DateTime(composite, SWT.TIME); + final GridData gridData_1 = new GridData(); + gridData_1.horizontalSpan = 2; + startTime.setLayoutData(gridData_1); + } + { + final Label label = new Label(composite, SWT.NONE); label.setText(TeamUIMessages.ConfigureRefreshScheduleDialog_4); } { - time = new Text(composite, SWT.BORDER | SWT.RIGHT); + timeInterval = new Text(composite, SWT.BORDER | SWT.RIGHT); final GridData gridData_1 = new GridData(); gridData_1.widthHint = 35; - time.setLayoutData(gridData_1); - time.addModifyListener(new ModifyListener() { + timeInterval.setLayoutData(gridData_1); + timeInterval.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { updateEnablements(); } }); - time.addVerifyListener(new VerifyListener() { + timeInterval.addVerifyListener(new VerifyListener() { public void verifyText(VerifyEvent e) { String string = e.text; char [] chars = new char [string.length ()]; @@ -184,7 +200,7 @@ public void saveValues() { int hours = hoursOrSeconds.getSelectionIndex(); try { - long seconds = Long.parseLong(time.getText()); + long seconds = Long.parseLong(timeInterval.getText()); if(hours == 0) { seconds = seconds * 3600; } else { @@ -194,6 +210,14 @@ } catch (NumberFormatException e) { // keep old value } + + Calendar cal = Calendar.getInstance(); + cal.set(Calendar.HOUR_OF_DAY, startTime.getHours()); + cal.set(Calendar.MINUTE, startTime.getMinutes()); + cal.set(Calendar.SECOND, startTime.getSeconds()); + + schedule.setRefreshStartTime(cal.getTime()); + if(schedule.isEnabled() != enableBackgroundRefresh.getSelection()) { schedule.setEnabled(enableBackgroundRefresh.getSelection(), true /* allow to start */); } @@ -216,7 +240,7 @@ validator.setComplete(null); } else { try { - long number = Long.parseLong(time.getText()); + long number = Long.parseLong(timeInterval.getText()); if(number <= 0) { validator.setComplete(TeamUIMessages.ConfigureRefreshScheduleDialog_7); } else { @@ -226,8 +250,9 @@ validator.setComplete(TeamUIMessages.ConfigureRefreshScheduleDialog_8); } } - time.setEnabled(enableBackgroundRefresh.getSelection()); + timeInterval.setEnabled(enableBackgroundRefresh.getSelection()); hoursOrSeconds.setEnabled(enableBackgroundRefresh.getSelection()); + startTime.setEnabled(enableBackgroundRefresh.getSelection()); } private Label createWrappingLabel(Composite parent, String text, int indent, int horizontalSpan) { Index: src/org/eclipse/team/internal/ui/messages.properties =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/messages.properties,v retrieving revision 1.237 diff -u -r1.237 messages.properties --- src/org/eclipse/team/internal/ui/messages.properties 28 Jul 2008 12:00:58 -0000 1.237 +++ src/org/eclipse/team/internal/ui/messages.properties 31 Jul 2008 18:38:34 -0000 @@ -7,6 +7,7 @@ # # Contributors: # IBM Corporation - initial API and implementation +# Trevor S. Kaufman - - bug 156152 ############################################################################### ############################################### # Message catalog for org.eclipse.team.ui @@ -239,7 +240,8 @@ ConfigureMultipleProjectsWizard_1=There are still projects that have not been shared. Finishing the wizard now will leave them in that state. ConfigureRefreshScheduleDialog_2=Do not schedule the synchronize operation to run periodically. ConfigureRefreshScheduleDialog_3=Using the following schedule: -ConfigureRefreshScheduleDialog_4=Every: +ConfigureRefreshScheduleDialog_3a=Syncronize at: +ConfigureRefreshScheduleDialog_4=Repeat Every: ConfigureRefreshScheduleDialog_5=hour(s) ConfigureRefreshScheduleDialog_6=minute(s) ConfigureRefreshScheduleDialog_7=Number must be a positive number greater than 0 Index: src/org/eclipse/team/internal/ui/TeamUIMessages.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/TeamUIMessages.java,v retrieving revision 1.70 diff -u -r1.70 TeamUIMessages.java --- src/org/eclipse/team/internal/ui/TeamUIMessages.java 28 Jul 2008 12:00:58 -0000 1.70 +++ src/org/eclipse/team/internal/ui/TeamUIMessages.java 31 Jul 2008 18:38:34 -0000 @@ -7,6 +7,7 @@ * * Contributors: * IBM - Initial API and implementation + * Trevor S. Kaufman - - bug 156152 *******************************************************************************/ package org.eclipse.team.internal.ui; @@ -412,6 +413,7 @@ public static String ConfigureRefreshScheduleDialog_1a; public static String ConfigureRefreshScheduleDialog_2; public static String ConfigureRefreshScheduleDialog_3; + public static String ConfigureRefreshScheduleDialog_3a; public static String ConfigureRefreshScheduleDialog_4; public static String ConfigureRefreshScheduleDialog_5; public static String ConfigureRefreshScheduleDialog_6;