From bacbb7b3c7b2c8213cd24c8027974cebf0d584a4 Mon Sep 17 00:00:00 2001 From: Christian Walther Date: Thu, 12 Oct 2017 13:53:47 +0200 Subject: [PATCH] Bug 378302 - Only bring build console to top on problem output. When the "Bring console to top when building (if present)" was enabled (which it is by default as of bug 447703), the console would come to the top on every line of output, i.e. constantly during a busy build. That made it impossible to reach other views in the same part, in particular the Progress view in order to stop the build. Instead, only bring the console to the top at the start of the build and when output arrives that is associated with a problem marker (error, warning, info). Change-Id: Iabda4858b443c330e9209c27ea3635b0485c7d98 Signed-off-by: Christian Walther --- .../ui/buildconsole/BuildConsoleFactory.java | 2 +- .../ui/buildconsole/BuildConsoleManager.java | 15 ++++++------ .../buildconsole/BuildConsolePartitioner.java | 2 +- .../BuildConsolePartitionerEditData.java | 23 +++++++++++++++++++ 4 files changed, 32 insertions(+), 10 deletions(-) diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsoleFactory.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsoleFactory.java index dd204e3c27f..51caea277dc 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsoleFactory.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsoleFactory.java @@ -24,7 +24,7 @@ public class BuildConsoleFactory implements IConsoleFactory { public void openConsole() { IBuildConsoleManager manager = CUIPlugin.getDefault().getConsoleManager(); if (manager instanceof BuildConsoleManager) { - ((BuildConsoleManager)manager).showConsole(); + ((BuildConsoleManager)manager).showConsole(true); } } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsoleManager.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsoleManager.java index fe99ece5efc..4fa892cf111 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsoleManager.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsoleManager.java @@ -132,14 +132,15 @@ public class BuildConsoleManager implements IBuildConsoleManager, IResourceChang listener.consoleChange(event); } } - showConsole(); + showConsole(true); } /** * Opens the console view. If the view is already open, it is brought to the - * front. The console that is shown is the console that was last on top. + * front if requested and the respective user preference is set. The console + * that is shown is the console that was last on top. */ - protected void showConsole() { + protected void showConsole(boolean bringToTop) { IWorkbenchWindow window = CUIPlugin.getActiveWorkbenchWindow(); if (window != null) { IWorkbenchPage page = window.getActivePage(); @@ -155,11 +156,9 @@ public class BuildConsoleManager implements IBuildConsoleManager, IResourceChang //restore focus stolen by the creation of the // console page.activate(activePart); - } else { - boolean bringToTop = shouldBringToTop(consoleView); - if (bringToTop) { - page.bringToTop(consoleView); - } + } + if (bringToTop && shouldBringToTop(consoleView)) { + page.bringToTop(consoleView); } if (consoleView instanceof IConsoleView) { if (BuildConsole.getCurrentPage() == null) diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsolePartitioner.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsolePartitioner.java index a0bc8421da1..57ba6e1321a 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsolePartitioner.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsolePartitioner.java @@ -242,6 +242,7 @@ public class BuildConsolePartitioner // notify all streams with data we are about to update update.getStreamsNeedingNotifcation().forEach(this::warnOfContentChange); + fManager.showConsole(update.hasProblemsAdded()); /* * The order of these statements matters, the setting the contents of @@ -306,7 +307,6 @@ public class BuildConsolePartitioner if (stream != null) { ConsolePlugin.getDefault().getConsoleManager().warnOfContentChange(stream.getConsole()); } - fManager.showConsole(); } public IDocument getDocument() { diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsolePartitionerEditData.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsolePartitionerEditData.java index d28550bcf5c..eac79240c3b 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsolePartitionerEditData.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsolePartitionerEditData.java @@ -55,6 +55,12 @@ public class BuildConsolePartitionerEditData { * All the streams that have been written to since the last update. */ List getStreamsNeedingNotifcation(); + + /** + * True if partitions with problem markers have been added since the last + * update. + */ + boolean hasProblemsAdded(); } /** @@ -95,6 +101,12 @@ public class BuildConsolePartitionerEditData { * Set of streams that have been updated since the last UI update. */ private Set fEditStreams = new HashSet<>(); + + /** + * True if partitions with problem markers have been added since the last UI + * update. + */ + private boolean fEditProblemsAdded = false; public BuildConsolePartitionerEditData(int maxLines) { @@ -151,6 +163,9 @@ public class BuildConsolePartitionerEditData { } else { partitionType = BuildConsolePartition.ERROR_PARTITION_TYPE; } + if (marker != null) { + fEditProblemsAdded = true; + } if (fEditPartitions.isEmpty()) { fEditPartitions.add(new BuildConsolePartition(stream, fEditStringBuilder.length(), text.length(), partitionType, marker, newlines)); @@ -300,6 +315,7 @@ public class BuildConsolePartitionerEditData { */ public UpdateUIData getUpdate() { boolean clearDocumentMarkerManager; + boolean problemsAdded; long newOffset; String newConents; List newPartitions; @@ -313,6 +329,8 @@ public class BuildConsolePartitionerEditData { fClearDocumentMarkerManager = false; streamsNeedingNotifcation = new ArrayList<>(fEditStreams); fEditStreams.clear(); + problemsAdded = fEditProblemsAdded; + fEditProblemsAdded = false; } return new UpdateUIData() { @@ -341,6 +359,11 @@ public class BuildConsolePartitionerEditData { public long getOffset() { return newOffset; } + + @Override + public boolean hasProblemsAdded() { + return problemsAdded; + } }; }