View | Details | Raw Unified | Return to bug 156152 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/team/internal/ui/synchronize/SubscriberRefreshSchedule.java (-2 / +37 lines)
Lines 7-16 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *     Trevor S. Kaufman <endante@gmail.com> - bug 156152
10
 *******************************************************************************/
11
 *******************************************************************************/
11
package org.eclipse.team.internal.ui.synchronize;
12
package org.eclipse.team.internal.ui.synchronize;
12
13
13
import com.ibm.icu.text.DateFormat;
14
import java.util.Date;
14
import java.util.Date;
15
15
16
import org.eclipse.core.runtime.jobs.Job;
16
import org.eclipse.core.runtime.jobs.Job;
Lines 20-25 Link Here
20
import org.eclipse.ui.IMemento;
20
import org.eclipse.ui.IMemento;
21
import org.eclipse.ui.actions.ActionFactory;
21
import org.eclipse.ui.actions.ActionFactory;
22
22
23
import com.ibm.icu.text.DateFormat;
24
import com.ibm.icu.util.Calendar;
25
23
/**
26
/**
24
 * Schedule to refresh a subscriber at a specified interval. The schedule can be disabled or enabled
27
 * Schedule to refresh a subscriber at a specified interval. The schedule can be disabled or enabled
25
 * and will create the refresh job.
28
 * and will create the refresh job.
Lines 28-33 Link Here
28
 */
31
 */
29
public class SubscriberRefreshSchedule {
32
public class SubscriberRefreshSchedule {
30
	private long refreshInterval = 3600; // 1 hour default
33
	private long refreshInterval = 3600; // 1 hour default
34
	private Date refreshStart = new Date();
31
	
35
	
32
	private boolean enabled = false;
36
	private boolean enabled = false;
33
	
37
	
Lines 46-51 Link Here
46
	 * Key for schedule in memento
50
	 * Key for schedule in memento
47
	 */
51
	 */
48
	private static final String CTX_REFRESHSCHEDULE_ENABLED = TeamUIPlugin.ID + ".CTX_REFRESHSCHEDULE_ENABLED"; //$NON-NLS-1$
52
	private static final String CTX_REFRESHSCHEDULE_ENABLED = TeamUIPlugin.ID + ".CTX_REFRESHSCHEDULE_ENABLED"; //$NON-NLS-1$
53
	
54
	/**
55
	 * Key for schedule in memento
56
	 */
57
	private static final String CTX_REFRESHSCHEDULE_START = TeamUIPlugin.ID + ".CTX_REFRESHSCHEDULE_START"; //$NON-NLS-1$
49
		
58
		
50
	private IRefreshSubscriberListener refreshSubscriberListener = new IRefreshSubscriberListener() {
59
	private IRefreshSubscriberListener refreshSubscriberListener = new IRefreshSubscriberListener() {
51
		public void refreshStarted(IRefreshEvent event) {
60
		public void refreshStarted(IRefreshEvent event) {
Lines 128-134 Link Here
128
		job.setRestartOnCancel(true);
137
		job.setRestartOnCancel(true);
129
		job.setReschedule(true);
138
		job.setReschedule(true);
130
		// Schedule delay is in mills.
139
		// Schedule delay is in mills.
131
		job.schedule(getRefreshInterval() * 1000);		
140
		Calendar now = Calendar.getInstance();
141
		Calendar start = Calendar.getInstance();
142
		start.setTime(refreshStart);
143
		start.set(now.get(Calendar.YEAR), now.get(Calendar.MONTH), now.get(Calendar.DATE));
144
		
145
		if (now.after(start)) {
146
			start.add(Calendar.DATE, 1);
147
		}
148
		long offset = start.getTimeInMillis() - now.getTimeInMillis();
149
		job.schedule(offset);		
132
	}
150
	}
133
	
151
	
134
	protected void stopJob() {
152
	protected void stopJob() {
Lines 148-153 Link Here
148
	public void saveState(IMemento memento) {
166
	public void saveState(IMemento memento) {
149
		memento.putString(CTX_REFRESHSCHEDULE_ENABLED, Boolean.toString(enabled));
167
		memento.putString(CTX_REFRESHSCHEDULE_ENABLED, Boolean.toString(enabled));
150
		memento.putInteger(CTX_REFRESHSCHEDULE_INTERVAL, (int)refreshInterval);
168
		memento.putInteger(CTX_REFRESHSCHEDULE_INTERVAL, (int)refreshInterval);
169
		memento.putString(CTX_REFRESHSCHEDULE_START, Long.toString(refreshStart.getTime()));
151
	}
170
	}
152
171
153
	public static SubscriberRefreshSchedule init(IMemento memento, IRefreshable refreshable) {
172
	public static SubscriberRefreshSchedule init(IMemento memento, IRefreshable refreshable) {
Lines 155-160 Link Here
155
		if(memento != null) {
174
		if(memento != null) {
156
			String enabled = memento.getString(CTX_REFRESHSCHEDULE_ENABLED);
175
			String enabled = memento.getString(CTX_REFRESHSCHEDULE_ENABLED);
157
			int interval = memento.getInteger(CTX_REFRESHSCHEDULE_INTERVAL).intValue();
176
			int interval = memento.getInteger(CTX_REFRESHSCHEDULE_INTERVAL).intValue();
177
			long start = Long.parseLong(memento.getString(CTX_REFRESHSCHEDULE_START));
178
			schedule.setRefreshStartTime(new Date(start));
158
			schedule.setRefreshInterval(interval);
179
			schedule.setRefreshInterval(interval);
159
			schedule.setEnabled("true".equals(enabled) ? true : false, false /* don't start job */); //$NON-NLS-1$
180
			schedule.setEnabled("true".equals(enabled) ? true : false, false /* don't start job */); //$NON-NLS-1$
160
		}
181
		}
Lines 212-215 Link Here
212
	public IRefreshable getRefreshable() {
233
	public IRefreshable getRefreshable() {
213
		return refreshable;
234
		return refreshable;
214
	}
235
	}
236
237
	public Date getRefreshStartTime() {
238
		return refreshStart;
239
	}
240
	
241
	public void setRefreshStartTime(Date refreshStart) {
242
		if(refreshStart != getRefreshStartTime()) {
243
			stopJob();
244
			this.refreshStart = refreshStart;
245
			if(isEnabled()) {
246
				startJob();
247
			}
248
		}
249
	}
215
}
250
}
(-)src/org/eclipse/team/internal/ui/synchronize/ConfigureSynchronizeScheduleComposite.java (-16 / +41 lines)
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) {
(-)src/org/eclipse/team/internal/ui/messages.properties (-1 / +3 lines)
Lines 7-12 Link Here
7
#
7
#
8
# Contributors:
8
# Contributors:
9
#     IBM Corporation - initial API and implementation
9
#     IBM Corporation - initial API and implementation
10
#     Trevor S. Kaufman - <endante@gmail.com> - bug 156152
10
###############################################################################
11
###############################################################################
11
###############################################
12
###############################################
12
# Message catalog for org.eclipse.team.ui
13
# Message catalog for org.eclipse.team.ui
Lines 239-245 Link Here
239
ConfigureMultipleProjectsWizard_1=There are still projects that have not been shared. Finishing the wizard now will leave them in that state.
240
ConfigureMultipleProjectsWizard_1=There are still projects that have not been shared. Finishing the wizard now will leave them in that state.
240
ConfigureRefreshScheduleDialog_2=Do not schedule the synchronize operation to run periodically.
241
ConfigureRefreshScheduleDialog_2=Do not schedule the synchronize operation to run periodically.
241
ConfigureRefreshScheduleDialog_3=Using the following schedule:
242
ConfigureRefreshScheduleDialog_3=Using the following schedule:
242
ConfigureRefreshScheduleDialog_4=Every:
243
ConfigureRefreshScheduleDialog_3a=Syncronize at:
244
ConfigureRefreshScheduleDialog_4=Repeat Every:
243
ConfigureRefreshScheduleDialog_5=hour(s)
245
ConfigureRefreshScheduleDialog_5=hour(s)
244
ConfigureRefreshScheduleDialog_6=minute(s)
246
ConfigureRefreshScheduleDialog_6=minute(s)
245
ConfigureRefreshScheduleDialog_7=Number must be a positive number greater than 0
247
ConfigureRefreshScheduleDialog_7=Number must be a positive number greater than 0
(-)src/org/eclipse/team/internal/ui/TeamUIMessages.java (+2 lines)
Lines 7-12 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 * IBM - Initial API and implementation
9
 * IBM - Initial API and implementation
10
 * Trevor S. Kaufman - <endante@gmail.com> - bug 156152
10
 *******************************************************************************/
11
 *******************************************************************************/
11
package org.eclipse.team.internal.ui;
12
package org.eclipse.team.internal.ui;
12
13
Lines 412-417 Link Here
412
	public static String ConfigureRefreshScheduleDialog_1a;
413
	public static String ConfigureRefreshScheduleDialog_1a;
413
	public static String ConfigureRefreshScheduleDialog_2;
414
	public static String ConfigureRefreshScheduleDialog_2;
414
	public static String ConfigureRefreshScheduleDialog_3;
415
	public static String ConfigureRefreshScheduleDialog_3;
416
	public static String ConfigureRefreshScheduleDialog_3a;
415
	public static String ConfigureRefreshScheduleDialog_4;
417
	public static String ConfigureRefreshScheduleDialog_4;
416
	public static String ConfigureRefreshScheduleDialog_5;
418
	public static String ConfigureRefreshScheduleDialog_5;
417
	public static String ConfigureRefreshScheduleDialog_6;
419
	public static String ConfigureRefreshScheduleDialog_6;

Return to bug 156152