Skip to content

Commit

Permalink
STS-2724: put descriptor download error messages in the header of New
Browse files Browse the repository at this point in the history
Template Wizard instead of popping up a dialog.
  • Loading branch information
katesherwood committed Jul 4, 2012
1 parent 1a0a512 commit 2513dd8
Showing 1 changed file with 20 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ public void linkActivated(HyperlinkEvent event) {
PreferenceDialog dialog = PreferencesUtil.createPreferenceDialogOn(null,
TemplatesPreferencePage.EXAMPLE_PREFERENCES_PAGE_ID, null, null);
refreshButton.setEnabled(false);
setErrorMessage(null);

dialog.open();
if (ContentPlugin.getDefault().getManager().isDirty()) {
Expand All @@ -296,6 +297,7 @@ public void linkActivated(HyperlinkEvent event) {
refreshButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
setErrorMessage(null);
// under most circumstances, we don't want to download templates
// if there has not been any change. However, when the user
// presses Refresh, they really do want to see something happen.
Expand Down Expand Up @@ -374,6 +376,7 @@ public void run() {

@Override
public IWizardPage getNextPage() {
setErrorMessage(null);

if (firstPage != null) {
return firstPage;
Expand Down Expand Up @@ -669,20 +672,27 @@ public void run(IProgressMonitor monitor) throws InvocationTargetException,
InterruptedException {
try {
IStatus results = manager.refresh(monitor, true);
if (results.isOK()) {
return;
}
final String message = (results.getChildren()[0]).getMessage();
if (!results.isOK()) {
if (results.isMultiStatus() && results.getChildren().length > 0) {
throw new InvocationTargetException(new CoreException(results.getChildren()[0]));
}
else {
throw new InvocationTargetException(new CoreException(results));
}
PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
public void run() {
setErrorMessage(message);
}
});

}
}
catch (OperationCanceledException e) {
// If we don't catch and throw the exception
// *here*, cancellations don't get recognized
// until the download is finished.
throw e;
final String message = ("Download of descriptor files cancelled.");

PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
public void run() {
setErrorMessage(message);
}
});
}
}
});
Expand Down

0 comments on commit 2513dd8

Please sign in to comment.