|
Lines 8-14
Link Here
|
| 8 |
|
8 |
|
| 9 |
package org.eclipse.mylyn.internal.tasks.ui; |
9 |
package org.eclipse.mylyn.internal.tasks.ui; |
| 10 |
|
10 |
|
| 11 |
import java.util.Calendar; |
|
|
| 12 |
import java.util.List; |
11 |
import java.util.List; |
| 13 |
import java.util.Set; |
12 |
import java.util.Set; |
| 14 |
|
13 |
|
|
Lines 45-52
Link Here
|
| 45 |
|
44 |
|
| 46 |
private static long count = 0; |
45 |
private static long count = 0; |
| 47 |
|
46 |
|
| 48 |
private static Calendar lastRepositoryRefresh; |
|
|
| 49 |
|
| 50 |
private TaskListManager taskListManager; |
47 |
private TaskListManager taskListManager; |
| 51 |
|
48 |
|
| 52 |
private List<TaskRepository> repositories = null; |
49 |
private List<TaskRepository> repositories = null; |
|
Lines 110-142
Link Here
|
| 110 |
|
107 |
|
| 111 |
RepositorySynchronizationManager synchronizationManager = TasksUiPlugin.getSynchronizationManager(); |
108 |
RepositorySynchronizationManager synchronizationManager = TasksUiPlugin.getSynchronizationManager(); |
| 112 |
Set<AbstractRepositoryQuery> queries = taskList.getRepositoryQueries(repository.getUrl()); |
109 |
Set<AbstractRepositoryQuery> queries = taskList.getRepositoryQueries(repository.getUrl()); |
| 113 |
|
110 |
try { |
| 114 |
// Occasionally request update of repository configuration attributes |
111 |
// Occasionally request update of repository configuration attributes |
| 115 |
if ((lastRepositoryRefresh == null || lastRepositoryRefresh.get(Calendar.DAY_OF_MONTH) != Calendar.getInstance() |
112 |
if (queries != null && queries.size() > 0 && connector.isRepositoryConfigurationStale(repository)) { |
| 116 |
.get(Calendar.DAY_OF_MONTH)) |
113 |
Job updateJob = new Job("Updating attributes for " + repository.getUrl()) { |
| 117 |
&& queries != null && queries.size() > 0) { |
114 |
|
| 118 |
Job updateJob = new Job("Updating attributes for " + repository.getUrl()) { |
115 |
@Override |
| 119 |
|
116 |
protected IStatus run(IProgressMonitor monitor) { |
| 120 |
@Override |
117 |
try { |
| 121 |
protected IStatus run(IProgressMonitor monitor) { |
|
|
| 122 |
try { |
| 123 |
if (connector.isRepositoryConfigurationStale(repository)) { |
| 124 |
connector.updateAttributes(repository, new SubProgressMonitor(monitor, 1)); |
118 |
connector.updateAttributes(repository, new SubProgressMonitor(monitor, 1)); |
| 125 |
// HACK: A configuration update occurred. Save on behalf of connector which |
119 |
// HACK: A configuration update occurred. Save on behalf of connector which |
| 126 |
// currently can't access the repository manager itself |
120 |
// currently can't access the repository manager itself |
| 127 |
TasksUiPlugin.getRepositoryManager().saveRepositories( |
121 |
TasksUiPlugin.getRepositoryManager().saveRepositories( |
|
|
122 |
// ignore, since we might not be connected |
| 128 |
TasksUiPlugin.getDefault().getRepositoriesFilePath()); |
123 |
TasksUiPlugin.getDefault().getRepositoriesFilePath()); |
|
|
124 |
|
| 125 |
} catch (Exception e) { |
| 126 |
// ignore, since we might not be connected |
| 129 |
} |
127 |
} |
| 130 |
} catch (Exception e) { |
128 |
return Status.OK_STATUS; |
| 131 |
// ignore, since we might not be connected |
|
|
| 132 |
} |
129 |
} |
| 133 |
return Status.OK_STATUS; |
130 |
}; |
| 134 |
} |
131 |
//updateJob.setSystem(true); |
| 135 |
}; |
132 |
updateJob.setPriority(Job.LONG); |
| 136 |
//updateJob.setSystem(true); |
133 |
updateJob.schedule(); |
| 137 |
updateJob.setPriority(Job.LONG); |
134 |
} |
| 138 |
updateJob.schedule(); |
135 |
} catch (Exception e) { |
| 139 |
lastRepositoryRefresh = null; |
136 |
// ignore, since we might not be connected |
| 140 |
} |
137 |
} |
| 141 |
|
138 |
|
| 142 |
synchronizationManager.synchronize(connector, repository, queries, null, Job.DECORATE, 0, false, |
139 |
synchronizationManager.synchronize(connector, repository, queries, null, Job.DECORATE, 0, false, |
|
Lines 146-154
Link Here
|
| 146 |
} |
143 |
} |
| 147 |
} finally { |
144 |
} finally { |
| 148 |
count = count >= UPDATE_ATTRIBUTES_FREQUENCY ? 0 : count + 1; |
145 |
count = count >= UPDATE_ATTRIBUTES_FREQUENCY ? 0 : count + 1; |
| 149 |
if (lastRepositoryRefresh == null) { |
|
|
| 150 |
lastRepositoryRefresh = Calendar.getInstance(); |
| 151 |
} |
| 152 |
if (monitor != null) { |
146 |
if (monitor != null) { |
| 153 |
monitor.done(); |
147 |
monitor.done(); |
| 154 |
} |
148 |
} |
|
Lines 165-177
Link Here
|
| 165 |
} |
159 |
} |
| 166 |
|
160 |
|
| 167 |
/** |
161 |
/** |
| 168 |
* for testing purposes |
162 |
* for testing purposes ONLY! |
| 169 |
*/ |
163 |
*/ |
| 170 |
public static long getCount() { |
164 |
public static long getCount() { |
| 171 |
return count; |
165 |
return count; |
| 172 |
} |
166 |
} |
| 173 |
|
167 |
|
| 174 |
/** for testing */ |
168 |
/** |
|
|
169 |
* for testing purposes ONLY! |
| 170 |
*/ |
| 175 |
public static void resetCount() { |
171 |
public static void resetCount() { |
| 176 |
try { |
172 |
try { |
| 177 |
if (TasksUiPlugin.getSynchronizationScheduler().getRefreshJob() != null) { |
173 |
if (TasksUiPlugin.getSynchronizationScheduler().getRefreshJob() != null) { |