Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 109985 Details for
Bug 156152
[Sync View] Schedule a synchronize at night
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Patch v04
patch-156152-4.txt (text/plain), 20.27 KB, created by
Tomasz Zarna
on 2008-08-14 10:12:28 EDT
(
hide
)
Description:
Patch v04
Filename:
MIME Type:
Creator:
Tomasz Zarna
Created:
2008-08-14 10:12:28 EDT
Size:
20.27 KB
patch
obsolete
>### 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 14 Aug 2008 13:50:28 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2003, 2006 IBM Corporation and others. >+ * Copyright (c) 2003, 2008 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -7,10 +7,10 @@ > * > * Contributors: > * IBM Corporation - initial API and implementation >+ * Trevor S. Kaufman <endante@gmail.com> - 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,8 @@ > */ > public class SubscriberRefreshSchedule { > private long refreshInterval = 3600; // 1 hour default >+ private Date refreshStart; >+ private boolean runOnce = false; > > private boolean enabled = false; > >@@ -46,6 +51,16 @@ > * Key for schedule in memento > */ > private static final String CTX_REFRESHSCHEDULE_ENABLED = TeamUIPlugin.ID + ".CTX_REFRESHSCHEDULE_ENABLED"; //$NON-NLS-1$ >+ >+ /** >+ * Key for start date in memento >+ */ >+ private static final String CTX_REFRESHSCHEDULE_START = TeamUIPlugin.ID + ".CTX_REFRESHSCHEDULE_START"; //$NON-NLS-1$ >+ >+ /** >+ * Key for run once in memento >+ */ >+ private static final String CTX_REFRESHSCHEDULE_RUNONCE = TeamUIPlugin.ID + ".CTX_REFRESHSCHEDULE_RUNONCE"; //$NON-NLS-1$ > > private IRefreshSubscriberListener refreshSubscriberListener = new IRefreshSubscriberListener() { > public void refreshStarted(IRefreshEvent event) { >@@ -69,6 +84,10 @@ > public SubscriberRefreshSchedule(IRefreshable refreshable) { > this.refreshable = refreshable; > RefreshParticipantJob.addRefreshListener(refreshSubscriberListener); >+ >+// Calendar cal = Calendar.getInstance(); >+// cal.clear(); >+// refreshStart = cal.getTime(); > } > > /** >@@ -80,6 +99,7 @@ > > /** > * @param enabled The enabled to set. >+ * @param allowedToStart Is the job allowed to start. > */ > public void setEnabled(boolean enabled, boolean allowedToStart) { > boolean wasEnabled = isEnabled(); >@@ -111,6 +131,7 @@ > if(refreshInterval != getRefreshInterval()) { > stopJob(); > this.refreshInterval = refreshInterval; >+ runOnce = false; > if(isEnabled()) { > startJob(); > } >@@ -126,9 +147,25 @@ > } > job.setRefreshInterval(getRefreshInterval()); > job.setRestartOnCancel(true); >- job.setReschedule(true); >- // Schedule delay is in mills. >- job.schedule(getRefreshInterval() * 1000); >+ job.setReschedule(!runOnce); >+ if (refreshStart != null) { >+ job.schedule(getJobDelay()); >+ } else { >+ job.schedule(); >+ } >+ } >+ >+ /** >+ * @return schedule delay in milliseconds >+ */ >+ private long getJobDelay() { >+ Calendar now = Calendar.getInstance(); >+ Calendar start = Calendar.getInstance(); >+ start.setTime(refreshStart); >+ if (now.after(start)) { >+ start.add(Calendar.DATE, 1); // tomorrow >+ } >+ return start.getTimeInMillis() - now.getTimeInMillis(); > } > > protected void stopJob() { >@@ -148,6 +185,9 @@ > public void saveState(IMemento memento) { > memento.putString(CTX_REFRESHSCHEDULE_ENABLED, Boolean.toString(enabled)); > memento.putInteger(CTX_REFRESHSCHEDULE_INTERVAL, (int)refreshInterval); >+ if (refreshStart != null) >+ memento.putString(CTX_REFRESHSCHEDULE_START, Long.toString(refreshStart.getTime())); >+ memento.putString(CTX_REFRESHSCHEDULE_RUNONCE, Boolean.toString(runOnce)); > } > > public static SubscriberRefreshSchedule init(IMemento memento, IRefreshable refreshable) { >@@ -155,7 +195,14 @@ > if(memento != null) { > String enabled = memento.getString(CTX_REFRESHSCHEDULE_ENABLED); > int interval = memento.getInteger(CTX_REFRESHSCHEDULE_INTERVAL).intValue(); >+ String startString = memento.getString(CTX_REFRESHSCHEDULE_START); >+ String runOnce = memento.getString(CTX_REFRESHSCHEDULE_RUNONCE); >+ if (startString != null) { >+ long start = Long.parseLong(startString); >+ schedule.setRefreshStartTime(new Date(start)); >+ } > schedule.setRefreshInterval(interval); >+ schedule.setRunOnce("true".equals(runOnce) ? true : false); //$NON-NLS-1$ > schedule.setEnabled("true".equals(enabled) ? true : false, false /* don't start job */); //$NON-NLS-1$ > } > // Use the defaults if a schedule hasn't been saved or can't be found. >@@ -190,6 +237,8 @@ > } > > private String getRefreshIntervalAsString() { >+ if (runOnce) >+ return TeamUIMessages.RefreshSchedule_16; > boolean hours = false; > long seconds = getRefreshInterval(); > if(seconds <= 60) { >@@ -202,9 +251,9 @@ > } > String unit; > if(minutes >= 1) { >- unit = (hours ? TeamUIMessages.RefreshSchedule_9 : TeamUIMessages.RefreshSchedule_10); // >+ unit = (hours ? TeamUIMessages.RefreshSchedule_9 : TeamUIMessages.RefreshSchedule_10); > } else { >- unit = (hours ? TeamUIMessages.RefreshSchedule_11 : TeamUIMessages.RefreshSchedule_12); // >+ unit = (hours ? TeamUIMessages.RefreshSchedule_11 : TeamUIMessages.RefreshSchedule_12); > } > return NLS.bind(TeamUIMessages.RefreshSchedule_13, new String[] { Long.toString(minutes), unit }); > } >@@ -212,4 +261,40 @@ > public IRefreshable getRefreshable() { > return refreshable; > } >+ >+ /** >+ * @return The time when the job should start or <code>null</code> when it >+ * should be run immediately. >+ */ >+ public Date getRefreshStartTime() { >+ return refreshStart; >+ } >+ >+ public void setRefreshStartTime(Date refreshStart) { >+ if(refreshStart==null || refreshStart != getRefreshStartTime()) { >+ stopJob(); >+ this.refreshStart = refreshStart; >+ if(isEnabled()) { >+ startJob(); >+ } >+ } >+ } >+ >+ /** >+ * @return Return <code>false</code> if the job should be run again when >+ * finished, or <code>true</code> otherwise. >+ */ >+ public boolean getRunOnce() { >+ return runOnce; >+ } >+ >+ public void setRunOnce(boolean runOnce) { >+ if (runOnce != getRunOnce()) { >+ stopJob(); >+ this.runOnce = runOnce; >+ 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 14 Aug 2008 13:50:28 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2006 IBM Corporation and others. >+ * Copyright (c) 2000, 2008 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -8,12 +8,14 @@ > * Contributors: > * IBM Corporation - initial API and implementation > * Sebastian Davids <sdavids@gmx.de> - bug 54630 >+ * Trevor S. Kaufman <endante@gmail.com> - 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,12 @@ > private SubscriberRefreshSchedule schedule; > private Button userRefreshOnly; > private Button enableBackgroundRefresh; >- private Text time; >- private Combo hoursOrSeconds; >+ private Text timeInterval; >+ private Combo hoursOrMinutes; > private IPageValidator validator; >+ private DateTime startTime; >+ private Button immediately; >+ private Button runOnce; > > public ConfigureSynchronizeScheduleComposite(Composite parent, SubscriberRefreshSchedule schedule, IPageValidator validator) { > super(parent, SWT.NONE); >@@ -71,8 +74,19 @@ > minutes = minutes / 60; > hours = true; > } >- hoursOrSeconds.select(hours ? 0 : 1); >- time.setText(Long.toString(minutes)); >+ hoursOrMinutes.select(hours ? 0 : 1); >+ timeInterval.setText(Long.toString(minutes)); >+ runOnce.setSelection(schedule.getRunOnce()); >+ >+ Date start = schedule.getRefreshStartTime(); >+ if (start!=null) { >+ Calendar cal = Calendar.getInstance(); >+ cal.setTime(start); >+ startTime.setTime(cal.get(Calendar.HOUR_OF_DAY), cal.get(Calendar.MINUTE), cal.get(Calendar.SECOND)); >+ } else { >+ // ran immediately, no startTime available >+ } >+ > } > > /* (non-Javadoc) >@@ -135,7 +149,7 @@ > gridData.horizontalSpan = 2; > composite.setLayoutData(gridData); > final GridLayout gridLayout_1 = new GridLayout(); >- gridLayout_1.numColumns = 3; >+ gridLayout_1.numColumns = 4; > gridLayout_1.marginWidth = 0; > gridLayout_1.marginHeight = 0; > gridLayout_1.horizontalSpacing = Dialog.convertHorizontalDLUsToPixels(fontMetrics, IDialogConstants.HORIZONTAL_SPACING); >@@ -143,19 +157,39 @@ > composite.setLayout(gridLayout_1); > { > final Label label = new Label(composite, SWT.NONE); >+ label.setText(TeamUIMessages.ConfigureRefreshScheduleDialog_3a); >+ } >+ { >+ startTime = new DateTime(composite, SWT.TIME | SWT.BORDER); >+ final GridData gridData_1 = new GridData(); >+ gridData_1.horizontalSpan = 2; >+ startTime.setLayoutData(gridData_1); >+ >+ } >+ { >+ immediately = new Button(composite, SWT.CHECK); >+ immediately.setText(TeamUIMessages.ConfigureRefreshScheduleDialog_3b); >+ immediately.addSelectionListener(new SelectionAdapter() { >+ public void widgetSelected(SelectionEvent e) { >+ updateEnablements(); >+ } >+ }); >+ } >+ { >+ 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 ()]; >@@ -170,30 +204,55 @@ > }); > } > { >- hoursOrSeconds = new Combo(composite, SWT.READ_ONLY); >- hoursOrSeconds.setItems(new String[] { TeamUIMessages.ConfigureRefreshScheduleDialog_5, TeamUIMessages.ConfigureRefreshScheduleDialog_6 }); // >- hoursOrSeconds.setLayoutData(new GridData()); >+ hoursOrMinutes = new Combo(composite, SWT.READ_ONLY); >+ hoursOrMinutes.setItems(new String[] { TeamUIMessages.ConfigureRefreshScheduleDialog_5, TeamUIMessages.ConfigureRefreshScheduleDialog_6 }); // >+ hoursOrMinutes.setLayoutData(new GridData()); >+ } >+ { >+ runOnce = new Button(composite, SWT.CHECK); >+ runOnce.setText(TeamUIMessages.ConfigureRefreshScheduleDialog_8); >+ runOnce.addSelectionListener(new SelectionAdapter() { >+ public void widgetSelected(SelectionEvent e) { >+ updateEnablements(); >+ } >+ }); > } > } > initializeValues(); >+ updateEnablements(); > } > > /* (non-Javadoc) > * @see org.eclipse.jface.dialogs.Dialog#okPressed() > */ > public void saveValues() { >- int hours = hoursOrSeconds.getSelectionIndex(); >- try { >- long seconds = Long.parseLong(time.getText()); >- if(hours == 0) { >- seconds = seconds * 3600; >- } else { >- seconds = seconds * 60; >- } >- schedule.setRefreshInterval(seconds); >- } catch (NumberFormatException e) { >- // keep old value >+ if (!runOnce.getSelection()) { >+ int hours = hoursOrMinutes.getSelectionIndex(); >+ try { >+ long seconds = Long.parseLong(timeInterval.getText()); >+ if(hours == 0) { >+ seconds = seconds * 3600; >+ } else { >+ seconds = seconds * 60; >+ } >+ schedule.setRefreshInterval(seconds); >+ } catch (NumberFormatException e) { >+ // keep old value >+ } >+ } else { >+ schedule.setRunOnce(runOnce.getSelection() /* true */); >+ } >+ >+ if (!immediately.getSelection()) { >+ 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()); >+ } else { >+ schedule.setRefreshStartTime(null); > } >+ > if(schedule.isEnabled() != enableBackgroundRefresh.getSelection()) { > schedule.setEnabled(enableBackgroundRefresh.getSelection(), true /* allow to start */); > } >@@ -216,18 +275,29 @@ > 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 { > validator.setComplete(null); > } > } catch (NumberFormatException e) { >- validator.setComplete(TeamUIMessages.ConfigureRefreshScheduleDialog_8); >+ validator.setComplete(TeamUIMessages.ConfigureRefreshScheduleDialog_7); > } > } >- time.setEnabled(enableBackgroundRefresh.getSelection()); >- hoursOrSeconds.setEnabled(enableBackgroundRefresh.getSelection()); >+ timeInterval.setEnabled(enableBackgroundRefresh.getSelection()); >+ hoursOrMinutes.setEnabled(enableBackgroundRefresh.getSelection()); >+ runOnce.setEnabled(enableBackgroundRefresh.getSelection()); >+ if (runOnce.isEnabled()) { >+ timeInterval.setEnabled(!runOnce.getSelection()); >+ hoursOrMinutes.setEnabled(!runOnce.getSelection()); >+ } >+ >+ startTime.setEnabled(enableBackgroundRefresh.getSelection()); >+ immediately.setEnabled(enableBackgroundRefresh.getSelection()); >+ if (immediately.isEnabled()) { >+ startTime.setEnabled(!immediately.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 14 Aug 2008 13:50:28 -0000 >@@ -7,6 +7,7 @@ > # > # Contributors: > # IBM Corporation - initial API and implementation >+# Trevor S. Kaufman - <endante@gmail.com> - bug 156152 > ############################################################################### > ############################################### > # Message catalog for org.eclipse.team.ui >@@ -237,13 +238,15 @@ > ConfigureRefreshScheduleDialog_1a=The last synchronize occurred at: {0} > ConfigureMultipleProjectsWizard_0=Unshared Projects > 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_2=&Do not schedule the synchronize operation to run periodically. >+ConfigureRefreshScheduleDialog_3=&Using the following schedule: >+ConfigureRefreshScheduleDialog_3a=Synchronize &at: >+ConfigureRefreshScheduleDialog_3b=&Immediately >+ConfigureRefreshScheduleDialog_4=&Repeat Every: > ConfigureRefreshScheduleDialog_5=hour(s) > ConfigureRefreshScheduleDialog_6=minute(s) > ConfigureRefreshScheduleDialog_7=Number must be a positive number greater than 0 >-ConfigureRefreshScheduleDialog_8=Number must be a positive number greater than 0 >+ConfigureRefreshScheduleDialog_8=Run &Once > RefreshSchedule_changesSingular=\ ({0} change found) > RefreshSchedule_changesPlural=\ ({0} changes found) > RefreshSchedule_7=\ (No changes found) >@@ -254,6 +257,7 @@ > RefreshSchedule_13=Every {0} {1} > RefreshSchedule_14=Scheduled Synchronize > RefreshSchedule_15={0} {1} >+RefreshSchedule_16=Run Once > ChangesSection_8=Show Errors > ChangesSection_9=Reset View > ChangesSection_10=Errors have occurred calculating the synchronization state for {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 14 Aug 2008 13:50:28 -0000 >@@ -7,6 +7,7 @@ > * > * Contributors: > * IBM - Initial API and implementation >+ * Trevor S. Kaufman - <endante@gmail.com> - bug 156152 > *******************************************************************************/ > package org.eclipse.team.internal.ui; > >@@ -412,6 +413,8 @@ > public static String ConfigureRefreshScheduleDialog_1a; > public static String ConfigureRefreshScheduleDialog_2; > public static String ConfigureRefreshScheduleDialog_3; >+ public static String ConfigureRefreshScheduleDialog_3a; >+ public static String ConfigureRefreshScheduleDialog_3b; > public static String ConfigureRefreshScheduleDialog_4; > public static String ConfigureRefreshScheduleDialog_5; > public static String ConfigureRefreshScheduleDialog_6; >@@ -427,6 +430,7 @@ > public static String RefreshSchedule_13; > public static String RefreshSchedule_14; > public static String RefreshSchedule_15; >+ public static String RefreshSchedule_16; > public static String ChangesSection_8; > public static String ChangesSection_9; > public static String ChangesSection_10;
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 156152
:
104474
|
108891
|
109070
|
109547
|
109795
| 109985 |
109986