|
Lines 10-25
Link Here
|
| 10 |
*******************************************************************************/ |
10 |
*******************************************************************************/ |
| 11 |
package org.eclipse.team.internal.ccvs.ui.tags; |
11 |
package org.eclipse.team.internal.ccvs.ui.tags; |
| 12 |
|
12 |
|
| 13 |
|
13 |
|
| 14 |
import org.eclipse.jface.dialogs.Dialog; |
14 |
import org.eclipse.jface.dialogs.Dialog; |
| 15 |
import org.eclipse.jface.dialogs.IDialogConstants; |
15 |
import org.eclipse.jface.dialogs.IDialogConstants; |
|
|
16 |
import org.eclipse.jface.dialogs.MessageDialog; |
| 16 |
import org.eclipse.jface.util.IPropertyChangeListener; |
17 |
import org.eclipse.jface.util.IPropertyChangeListener; |
| 17 |
import org.eclipse.jface.util.PropertyChangeEvent; |
18 |
import org.eclipse.jface.util.PropertyChangeEvent; |
|
|
19 |
import org.eclipse.jface.window.Window; |
| 20 |
|
| 18 |
import org.eclipse.swt.SWT; |
21 |
import org.eclipse.swt.SWT; |
|
|
22 |
import org.eclipse.swt.events.DisposeEvent; |
| 23 |
import org.eclipse.swt.events.DisposeListener; |
| 19 |
import org.eclipse.swt.graphics.Point; |
24 |
import org.eclipse.swt.graphics.Point; |
| 20 |
import org.eclipse.swt.layout.GridData; |
25 |
import org.eclipse.swt.layout.GridData; |
| 21 |
import org.eclipse.swt.widgets.*; |
26 |
import org.eclipse.swt.widgets.*; |
|
|
27 |
|
| 28 |
import org.eclipse.core.runtime.IProgressMonitor; |
| 29 |
import org.eclipse.core.runtime.IStatus; |
| 30 |
import org.eclipse.core.runtime.Status; |
| 31 |
import org.eclipse.core.runtime.jobs.Job; |
| 32 |
|
| 33 |
import org.eclipse.team.core.TeamException; |
| 22 |
import org.eclipse.team.internal.ccvs.core.CVSTag; |
34 |
import org.eclipse.team.internal.ccvs.core.CVSTag; |
|
|
35 |
import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin; |
| 36 |
import org.eclipse.team.internal.ccvs.ui.ICVSUIConstants; |
| 23 |
import org.eclipse.team.internal.ccvs.ui.IHelpContextIds; |
37 |
import org.eclipse.team.internal.ccvs.ui.IHelpContextIds; |
| 24 |
import org.eclipse.team.internal.ccvs.ui.Policy; |
38 |
import org.eclipse.team.internal.ccvs.ui.Policy; |
| 25 |
|
39 |
|
|
Lines 147-153
Link Here
|
| 147 |
* Subclasses should override. |
161 |
* Subclasses should override. |
| 148 |
* </p> |
162 |
* </p> |
| 149 |
* |
163 |
* |
| 150 |
* @param the parent composite to contain the dialog area |
164 |
* @param parent the parent composite to contain the dialog area |
| 151 |
* @return the dialog area control |
165 |
* @return the dialog area control |
| 152 |
*/ |
166 |
*/ |
| 153 |
protected Control createDialogArea(Composite parent) { |
167 |
protected Control createDialogArea(Composite parent) { |
|
Lines 220-225
Link Here
|
| 220 |
*/ |
234 |
*/ |
| 221 |
protected void initialize() { |
235 |
protected void initialize() { |
| 222 |
okButton.setEnabled(false); |
236 |
okButton.setEnabled(false); |
|
|
237 |
if (CVSUIPlugin.getPlugin().getPreferenceStore().getBoolean(ICVSUIConstants.PREF_AUTO_REFRESH_TAGS_IN_TAG_SELECTION_DIALOG)) |
| 238 |
refreshFromRepository(); |
| 223 |
} |
239 |
} |
| 224 |
|
240 |
|
| 225 |
|
241 |
|
|
Lines 243-247
Link Here
|
| 243 |
} else if (property.equals(TagSelectionArea.OPEN_SELECTED_TAG)) { |
259 |
} else if (property.equals(TagSelectionArea.OPEN_SELECTED_TAG)) { |
| 244 |
okPressed(); |
260 |
okPressed(); |
| 245 |
} |
261 |
} |
|
|
262 |
} |
| 263 |
|
| 264 |
/** |
| 265 |
* Refreshes the tags from the repository. |
| 266 |
* |
| 267 |
* @since 3.1 |
| 268 |
*/ |
| 269 |
private void refreshFromRepository() { |
| 270 |
final Job refreshJob = new Job(Policy.bind("TagSelectionDialog.7")) { //$NON-NLS-1$ |
| 271 |
protected IStatus run(IProgressMonitor monitor) { |
| 272 |
CVSTag[] tags; |
| 273 |
try { |
| 274 |
if (monitor.isCanceled()) |
| 275 |
return Status.CANCEL_STATUS; |
| 276 |
tags= tagSource.refresh(false, Policy.subMonitorFor(monitor, 70)); |
| 277 |
if (tags.length == 0 && !monitor.isCanceled() && promptForBestEffort()) { |
| 278 |
if (!monitor.isCanceled()) |
| 279 |
tagSource.refresh(true, Policy.subMonitorFor(monitor, 30)); |
| 280 |
} |
| 281 |
} catch (TeamException e) { |
| 282 |
return e.getStatus(); |
| 283 |
} |
| 284 |
if (monitor.isCanceled()) |
| 285 |
return Status.CANCEL_STATUS; |
| 286 |
else |
| 287 |
return Status.OK_STATUS; |
| 288 |
} |
| 289 |
}; |
| 290 |
refreshJob.setUser(true); |
| 291 |
refreshJob.setPriority(Job.DECORATE); |
| 292 |
getShell().addDisposeListener(new DisposeListener() { |
| 293 |
/* (non-Javadoc) |
| 294 |
* @see org.eclipse.swt.events.DisposeListener#widgetDisposed(org.eclipse.swt.events.DisposeEvent) |
| 295 |
*/ |
| 296 |
public void widgetDisposed(DisposeEvent e) { |
| 297 |
refreshJob.cancel(); |
| 298 |
} |
| 299 |
}); |
| 300 |
refreshJob.schedule(); |
| 301 |
} |
| 302 |
|
| 303 |
/** |
| 304 |
* Prompts the user in cases where no tags could be found. |
| 305 |
* |
| 306 |
* @return <code>true</code> if not canceled |
| 307 |
* @since 3.1 |
| 308 |
*/ |
| 309 |
private boolean promptForBestEffort() { |
| 310 |
final boolean[] prompt = new boolean[] { false }; |
| 311 |
getShell().getDisplay().syncExec(new Runnable() { |
| 312 |
public void run() { |
| 313 |
MessageDialog dialog = new MessageDialog( |
| 314 |
getShell(), |
| 315 |
Policy.bind("TagSelectionDialog.2"), null, //$NON-NLS-1$ |
| 316 |
Policy.bind("TagSelectionDialog.6", tagSource.getShortDescription()), //$NON-NLS-1$ |
| 317 |
MessageDialog.INFORMATION, |
| 318 |
new String[] { |
| 319 |
Policy.bind("TagSelectionDialog.3"), //$NON-NLS-1$ |
| 320 |
Policy.bind("TagSelectionDialog.4"), //$NON-NLS-1$ |
| 321 |
Policy.bind("TagSelectionDialog.5") //$NON-NLS-1$ |
| 322 |
}, 1); |
| 323 |
int code = dialog.open(); |
| 324 |
if (code == Window.OK) { |
| 325 |
prompt[0] = true; |
| 326 |
} else if (code == 1) { |
| 327 |
TagConfigurationDialog d = new TagConfigurationDialog(getShell(), tagSource); |
| 328 |
d.open(); |
| 329 |
} |
| 330 |
} |
| 331 |
}); |
| 332 |
return prompt[0]; |
| 246 |
} |
333 |
} |
| 247 |
} |
334 |
} |