diff options
author | Frank Becker | 2013-03-03 20:08:07 +0000 |
---|---|---|
committer | Gerrit Code Review @ Eclipse.org | 2013-08-12 17:54:37 +0000 |
commit | 784655946dad87c784b454edc071eb523a7f2afa (patch) | |
tree | 1c88f2ffd88aa2b0fce484a5e820148fa677bc35 | |
parent | 7e23336cddc377a9ef827a71c687c229fa2990bb (diff) | |
download | org.eclipse.mylyn.tasks-784655946dad87c784b454edc071eb523a7f2afa.tar.gz org.eclipse.mylyn.tasks-784655946dad87c784b454edc071eb523a7f2afa.tar.xz org.eclipse.mylyn.tasks-784655946dad87c784b454edc071eb523a7f2afa.zip |
398835: add error icon when LastSynchronizedTimeStamp() is <never> and
we get SocketTimeout
Change-Id: Ib94a98e7eacc45d91071f0c9c5348bd3f30732c0
Task-Url: https://bugs.eclipse.org/bugs/show_bug.cgi?id=398835
7 files changed, 67 insertions, 23 deletions
diff --git a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaClient.java b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaClient.java index 06647e699..b3d6f4cb4 100644 --- a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaClient.java +++ b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaClient.java @@ -14,6 +14,7 @@ package org.eclipse.mylyn.internal.bugzilla.core; import java.io.BufferedReader; +import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; @@ -337,27 +338,39 @@ public class BugzillaClient { throw new CoreException(new BugzillaStatus(IStatus.ERROR, BugzillaCorePlugin.ID_PLUGIN, RepositoryStatus.ERROR_IO, repositoryUrl.toString(), e)); } - - if (code == HttpURLConnection.HTTP_OK) { + switch (code) { + case HttpURLConnection.HTTP_OK: return getMethod; - } else { + case HttpURLConnection.HTTP_NOT_MODIFIED: WebUtil.releaseConnection(getMethod, monitor); - if (code == HttpURLConnection.HTTP_NOT_MODIFIED) { - throw new CoreException(new Status(IStatus.WARNING, BugzillaCorePlugin.ID_PLUGIN, "Not changed")); //$NON-NLS-1$ - } else if (code == HttpURLConnection.HTTP_UNAUTHORIZED || code == HttpURLConnection.HTTP_FORBIDDEN) { - // login or reauthenticate due to an expired session - loggedIn = false; - authenticate(monitor); - } else if (code == HttpURLConnection.HTTP_PROXY_AUTH) { - loggedIn = false; - throw new CoreException(new BugzillaStatus(IStatus.ERROR, BugzillaCorePlugin.ID_PLUGIN, - RepositoryStatus.ERROR_REPOSITORY_LOGIN, repositoryUrl.toString(), - "Proxy authentication required")); //$NON-NLS-1$ - } else { - throw new CoreException(new BugzillaStatus(IStatus.ERROR, BugzillaCorePlugin.ID_PLUGIN, - RepositoryStatus.ERROR_NETWORK, "Http error: " + HttpStatus.getStatusText(code))); //$NON-NLS-1$ - } + throw new CoreException(new Status(IStatus.WARNING, BugzillaCorePlugin.ID_PLUGIN, "Not changed")); //$NON-NLS-1$ + case HttpURLConnection.HTTP_UNAUTHORIZED: + case HttpURLConnection.HTTP_FORBIDDEN: + // login or reauthenticate due to an expired session + loggedIn = false; + WebUtil.releaseConnection(getMethod, monitor); + authenticate(monitor); + break; + case HttpURLConnection.HTTP_PROXY_AUTH: + loggedIn = false; + WebUtil.releaseConnection(getMethod, monitor); + throw new CoreException(new BugzillaStatus(IStatus.ERROR, BugzillaCorePlugin.ID_PLUGIN, + RepositoryStatus.ERROR_REPOSITORY_LOGIN, repositoryUrl.toString(), + "Proxy authentication required")); //$NON-NLS-1$ + case HttpURLConnection.HTTP_INTERNAL_ERROR: + loggedIn = false; + InputStream stream = getResponseStream(getMethod, monitor); + ByteArrayOutputStream ou = new ByteArrayOutputStream(1024); + transferData(stream, ou); + WebUtil.releaseConnection(getMethod, monitor); + throw new CoreException(new BugzillaStatus(IStatus.ERROR, BugzillaCorePlugin.ID_PLUGIN, + RepositoryStatus.ERROR_NETWORK, repositoryUrl.toString(), "Error = 500")); //$NON-NLS-1$ + default: + WebUtil.releaseConnection(getMethod, monitor); + throw new CoreException(new BugzillaStatus(IStatus.ERROR, BugzillaCorePlugin.ID_PLUGIN, + RepositoryStatus.ERROR_NETWORK, "Http error: " + HttpStatus.getStatusText(code))); //$NON-NLS-1$ } + } throw new CoreException(new BugzillaStatus(IStatus.ERROR, BugzillaCorePlugin.ID_PLUGIN, diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/dialogs/Messages.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/dialogs/Messages.java index ec143d0d2..61a34e5e3 100644 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/dialogs/Messages.java +++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/dialogs/Messages.java @@ -117,6 +117,8 @@ public class Messages extends NLS { public static String UiLegendControl_Synchronization_failed; + public static String UiLegendControl_Synchronization_error; + public static String UiLegendControl_Task; public static String UiLegendControl_Task_Activity; diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/dialogs/UiLegendControl.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/dialogs/UiLegendControl.java index a580a6475..60365bd9f 100644 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/dialogs/UiLegendControl.java +++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/dialogs/UiLegendControl.java @@ -435,6 +435,10 @@ public class UiLegendControl extends Composite { toolkit.createLabel(synchroClient, Messages.UiLegendControl_Synchronization_failed); imageLabel = toolkit.createLabel(synchroClient, ""); //$NON-NLS-1$ + imageLabel.setImage(CommonImages.getImage(CommonImages.OVERLAY_SYNC_ERROR)); + toolkit.createLabel(synchroClient, Messages.UiLegendControl_Synchronization_error); + + imageLabel = toolkit.createLabel(synchroClient, ""); //$NON-NLS-1$ imageLabel.setImage(CommonImages.getImage(CommonImages.OVERLAY_SYNC_CONFLICT)); toolkit.createLabel(synchroClient, Messages.UiLegendControl_Conflicting_changes); } diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/dialogs/messages.properties b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/dialogs/messages.properties index fbfe2786a..bad7b336c 100644 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/dialogs/messages.properties +++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/dialogs/messages.properties @@ -56,6 +56,7 @@ UiLegendControl_Query=Query UiLegendControl_Scheduled_for_today=Scheduled for today UiLegendControl_Synchronization=Synchronization UiLegendControl_Synchronization_failed=Synchronization failed, mouse over for details +UiLegendControl_Synchronization_error=Synchronization error, mouse over for details UiLegendControl_Task=Task UiLegendControl_Task_Activity=Task Activity UiLegendControl_Task_Context=Task Context diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/TasksUiInternal.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/TasksUiInternal.java index 219132f7e..c68636eda 100644 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/TasksUiInternal.java +++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/TasksUiInternal.java @@ -14,6 +14,7 @@ package org.eclipse.mylyn.internal.tasks.ui.util; import java.net.MalformedURLException; +import java.net.SocketTimeoutException; import java.net.URL; import java.text.MessageFormat; import java.util.ArrayList; @@ -1454,4 +1455,21 @@ public class TasksUiInternal { return taskDropHandler; } + public static ImageDescriptor getIconFromStatusOfQuery(RepositoryQuery query) { + ImageDescriptor image; + boolean showError = false; + Throwable exception = query.getStatus().getException(); + showError = (query.getLastSynchronizedTimeStamp().equals("<never>") //$NON-NLS-1$ + && ((RepositoryStatus.ERROR_IO == query.getStatus().getCode() && exception != null && exception instanceof SocketTimeoutException) || // + // only when we change SocketTimeout or Eclipse.org change there timeout for long running Queries + (RepositoryStatus.ERROR_NETWORK) == query.getStatus().getCode() + && query.getStatus().getMessage().equals("Http error: Internal Server Error"))); //$NON-NLS-1$ + if (showError) { + image = CommonImages.OVERLAY_SYNC_ERROR; + } else { + image = CommonImages.OVERLAY_SYNC_WARNING; + } + return image; + } + } diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/views/CustomTaskListDecorationDrawer.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/views/CustomTaskListDecorationDrawer.java index 26d1d3498..c1e1ccd18 100644 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/views/CustomTaskListDecorationDrawer.java +++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/views/CustomTaskListDecorationDrawer.java @@ -25,6 +25,7 @@ import org.eclipse.mylyn.internal.tasks.core.UnmatchedTaskContainer; import org.eclipse.mylyn.internal.tasks.ui.AbstractTaskListFilter; import org.eclipse.mylyn.internal.tasks.ui.ITasksUiPreferenceConstants; import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin; +import org.eclipse.mylyn.internal.tasks.ui.util.TasksUiInternal; import org.eclipse.mylyn.tasks.core.IRepositoryQuery; import org.eclipse.mylyn.tasks.core.ITask; import org.eclipse.mylyn.tasks.core.ITask.SynchronizationState; @@ -204,7 +205,7 @@ public class CustomTaskListDecorationDrawer implements Listener { } else if (element instanceof IRepositoryQuery) { RepositoryQuery query = (RepositoryQuery) element; if (query.getStatus() != null) { - image = CommonImages.getImage(CommonImages.OVERLAY_SYNC_WARNING); + image = CommonImages.getImage(TasksUiInternal.getIconFromStatusOfQuery(query)); if (synchronizationOverlaid) { imageOffset = 11; } else { @@ -306,9 +307,7 @@ public class CustomTaskListDecorationDrawer implements Listener { } } else if (element instanceof IRepositoryQuery) { RepositoryQuery query = (RepositoryQuery) element; - if (query.getStatus() != null) { - return CommonImages.OVERLAY_SYNC_WARNING; - } + return TasksUiInternal.getIconFromStatusOfQuery(query); } // HACK: need a proper blank image return CommonImages.OVERLAY_CLEAR; diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/views/TaskListToolTip.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/views/TaskListToolTip.java index 32ff4b1fb..40d7bf0c2 100644 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/views/TaskListToolTip.java +++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/views/TaskListToolTip.java @@ -331,6 +331,13 @@ public class TaskListToolTip extends GradientToolTip { return null; } + private Image getStatusIcon(IRepositoryElement element) { + if (element instanceof RepositoryQuery) { + return CommonImages.getImage(TasksUiInternal.getIconFromStatusOfQuery((RepositoryQuery) element)); + } + return CommonImages.getImage(CommonImages.WARNING); + } + private String getStatusText(IRepositoryElement element) { IStatus status = null; if (element instanceof AbstractTask) { @@ -556,7 +563,7 @@ public class TaskListToolTip extends GradientToolTip { String statusText = getStatusText(currentTipElement); if (statusText != null) { - addIconAndLabel(composite, CommonImages.getImage(CommonImages.WARNING), statusText); + addIconAndLabel(composite, getStatusIcon(currentTipElement), statusText); } String helpText = getHelpText(currentTipElement); |