diff options
| author | Andrey Loskutov | 2018-09-23 07:05:11 +0000 |
|---|---|---|
| committer | Andrey Loskutov | 2018-09-23 07:05:11 +0000 |
| commit | 04c2613fa3940383de4d82a6cdb5e092b1a10774 (patch) | |
| tree | d0af58b18a32f46b1e1ace759b7a8c9989dba155 | |
| parent | 7bbb937dfe9c4862baef4cc46b9c3267ad32fbfc (diff) | |
| download | eclipse.platform.ui-04c2613fa3940383de4d82a6cdb5e092b1a10774.tar.gz eclipse.platform.ui-04c2613fa3940383de4d82a6cdb5e092b1a10774.tar.xz eclipse.platform.ui-04c2613fa3940383de4d82a6cdb5e092b1a10774.zip | |
Bug 539348 - Manually closed progress entries still shown in the errorI20180923-1800
dialog
WorkbenchStatusDialogManagerImpl should listen if the progress entries
for finished jobs are removed by user and cleanup the errors to be shown
accordingly.
Change-Id: Iabfb3a5e127c52dca1c4aec8c7e11fa61ae83c39
Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
2 files changed, 35 insertions, 9 deletions
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/progress/FinishedJobs.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/progress/FinishedJobs.java index 1f20160759d..378294ec347 100644 --- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/progress/FinishedJobs.java +++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/progress/FinishedJobs.java @@ -34,7 +34,7 @@ public final class FinishedJobs extends EventManager { /* * Interface for notify listeners. */ - interface KeptJobsListener { + public interface KeptJobsListener { /** * A job to be kept has finished @@ -46,7 +46,7 @@ public final class FinishedJobs extends EventManager { /** * A kept job has been removed. * - * @param jte + * @param jte {@code null} if all elements were removed */ void removed(JobTreeElement jte); } @@ -145,7 +145,7 @@ public final class FinishedJobs extends EventManager { /** * Register for notification. */ - void addListener(KeptJobsListener l) { + public void addListener(KeptJobsListener l) { addListenerObject(l); } diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/statushandlers/WorkbenchStatusDialogManagerImpl.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/statushandlers/WorkbenchStatusDialogManagerImpl.java index 881bc088b54..7e864e84a94 100644 --- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/statushandlers/WorkbenchStatusDialogManagerImpl.java +++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/statushandlers/WorkbenchStatusDialogManagerImpl.java @@ -30,6 +30,11 @@ import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.internal.WorkbenchPlugin; +import org.eclipse.ui.internal.progress.FinishedJobs; +import org.eclipse.ui.internal.progress.FinishedJobs.KeptJobsListener; +import org.eclipse.ui.internal.progress.JobInfo; +import org.eclipse.ui.internal.progress.JobTreeElement; +import org.eclipse.ui.internal.progress.StatusAdapterHelper; import org.eclipse.ui.progress.IProgressConstants; import org.eclipse.ui.statushandlers.IStatusAdapterConstants; import org.eclipse.ui.statushandlers.StatusAdapter; @@ -56,7 +61,7 @@ import org.eclipse.ui.statushandlers.StatusManager.INotificationTypes; * @noextend This class is not intended to be subclassed by clients. * @noinstantiate This class is not intended to be instantiated by clients. */ -public class WorkbenchStatusDialogManagerImpl { +public class WorkbenchStatusDialogManagerImpl implements KeptJobsListener { static final QualifiedName HINT = new QualifiedName( IStatusAdapterConstants.PROPERTY_PREFIX, "hint"); //$NON-NLS-1$ @@ -127,6 +132,7 @@ public class WorkbenchStatusDialogManagerImpl { "WorkbenchStatusDialogManager must be instantiated in UI thread"); //$NON-NLS-1$ dialogState = initDialogState(dialogState, displayMask, dialogTitle); + FinishedJobs.getInstance().addListener(this); } /** @@ -254,7 +260,7 @@ public class WorkbenchStatusDialogManagerImpl { // handled StatusManager.getManager().fireNotification( INotificationTypes.HANDLED, - (StatusAdapter[]) getErrors() + getErrors() .toArray(new StatusAdapter[] {})); if (dialog == null) { @@ -295,7 +301,7 @@ public class WorkbenchStatusDialogManagerImpl { * * @return collection of {@link StatusAdapter} objects */ - public Collection getStatusAdapters() { + public Collection<StatusAdapter> getStatusAdapters() { return Collections.unmodifiableCollection(getErrors()); } @@ -525,9 +531,9 @@ public class WorkbenchStatusDialogManagerImpl { * * @return Collection of StatusAdapters */ - private Collection getErrors() { - return (Collection) dialogState - .get(IStatusDialogConstants.STATUS_ADAPTERS); + @SuppressWarnings("unchecked") + private Collection<StatusAdapter> getErrors() { + return (Collection<StatusAdapter>) dialogState.get(IStatusDialogConstants.STATUS_ADAPTERS); } /** @@ -539,4 +545,24 @@ public class WorkbenchStatusDialogManagerImpl { return (Map) dialogState .get(IStatusDialogConstants.STATUS_MODALS); } + + @Override + public void finished(JobTreeElement jte) { + // no-op + } + + @Override + public void removed(JobTreeElement jte) { + if (jte instanceof JobInfo) { + JobInfo jobInfo = (JobInfo) jte; + StatusAdapter statusAdapter = StatusAdapterHelper.getInstance().getStatusAdapter(jobInfo); + if (statusAdapter != null) { + getErrors().remove(statusAdapter); + } + } else if (jte == null) { + StatusAdapterHelper.getInstance().clear(); + getErrors().clear(); + } + + } } |
