mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-23 17:05:26 +02:00
Bug 486033 - Add close button to CDT Build Console toolbar
This change adds a close action (org.eclipse.ui.console.actions.CloseConsoleAction) to the CDT build console. CDT accessing a closed console via BuildConsoleManager will result in re-adding the respective console page to the console view, if the console page was closed. Change-Id: Ifc4d4c6ed329f1c1c7e70f7903ed660ba85306c5 Signed-off-by: Simeon Andreev <simeon.danailov.andreev@gmail.com>
This commit is contained in:
parent
a655f7b4a5
commit
d4c6168964
4 changed files with 48 additions and 3 deletions
|
@ -20,6 +20,7 @@ import java.net.URI;
|
|||
import java.net.URL;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import org.eclipse.cdt.core.resources.IConsole;
|
||||
import org.eclipse.cdt.internal.core.LocalProjectScope;
|
||||
|
@ -55,6 +56,7 @@ import org.eclipse.ui.IWorkbenchWindow;
|
|||
import org.eclipse.ui.PartInitException;
|
||||
import org.eclipse.ui.console.ConsolePlugin;
|
||||
import org.eclipse.ui.console.IConsoleConstants;
|
||||
import org.eclipse.ui.console.IConsoleListener;
|
||||
import org.eclipse.ui.console.IConsoleView;
|
||||
import org.osgi.service.prefs.Preferences;
|
||||
|
||||
|
@ -114,10 +116,14 @@ public class BuildConsoleManager implements IBuildConsoleManager, IResourceChang
|
|||
|
||||
private IProject fLastProject;
|
||||
|
||||
private IConsoleListener fConsoleListener;
|
||||
private final AtomicBoolean fWasClosed;
|
||||
|
||||
/**
|
||||
* Default constructor.
|
||||
*/
|
||||
public BuildConsoleManager() {
|
||||
fWasClosed = new AtomicBoolean(false);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -222,6 +228,7 @@ public class BuildConsoleManager implements IBuildConsoleManager, IResourceChang
|
|||
problemInfoBackgroundColor.dispose();
|
||||
problemHighlightedColor.dispose();
|
||||
}
|
||||
ConsolePlugin.getDefault().getConsoleManager().removeConsoleListener(fConsoleListener);
|
||||
ConsolePlugin.getDefault().getConsoleManager()
|
||||
.removeConsoles(new org.eclipse.ui.console.IConsole[] { fConsole });
|
||||
CUIPlugin.getWorkspace().removeResourceChangeListener(this);
|
||||
|
@ -276,12 +283,26 @@ public class BuildConsoleManager implements IBuildConsoleManager, IResourceChang
|
|||
errorStream = new BuildConsoleStreamDecorator();
|
||||
fName = name;
|
||||
fContextMenuId = contextId;
|
||||
fConsoleListener = new IConsoleListener() {
|
||||
@Override
|
||||
public void consolesAdded(org.eclipse.ui.console.IConsole[] consoles) {
|
||||
// don't care
|
||||
}
|
||||
|
||||
@Override
|
||||
public void consolesRemoved(org.eclipse.ui.console.IConsole[] consoles) {
|
||||
for (org.eclipse.ui.console.IConsole console : consoles) {
|
||||
if (console == fConsole) {
|
||||
fWasClosed.set(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
ConsolePlugin.getDefault().getConsoleManager().addConsoleListener(fConsoleListener);
|
||||
|
||||
runUI(() -> {
|
||||
// add console to the Console view
|
||||
fConsole = createBuildConsole(fName, fContextMenuId, iconUrl);
|
||||
ConsolePlugin.getDefault().getConsoleManager()
|
||||
.addConsoles(new org.eclipse.ui.console.IConsole[] { fConsole });
|
||||
addConsole();
|
||||
|
||||
infoStream.setConsole(fConsole);
|
||||
infoColor = createColor(CUIPlugin.getStandardDisplay(),
|
||||
|
@ -311,6 +332,20 @@ public class BuildConsoleManager implements IBuildConsoleManager, IResourceChang
|
|||
CUIPlugin.getDefault().getPreferenceStore().addPropertyChangeListener(this);
|
||||
}
|
||||
|
||||
public void reinitaliazeIfNecessary() {
|
||||
if (!(this instanceof GlobalBuildConsoleManager)) {
|
||||
GlobalBuildConsoleManager.staticReinitaliazeIfNecessary();
|
||||
}
|
||||
if (fWasClosed.getAndSet(false)) {
|
||||
addConsole();
|
||||
}
|
||||
}
|
||||
|
||||
private void addConsole() {
|
||||
// add console to the Console view
|
||||
ConsolePlugin.getDefault().getConsoleManager().addConsoles(new org.eclipse.ui.console.IConsole[] { fConsole });
|
||||
}
|
||||
|
||||
@Override
|
||||
public void propertyChange(PropertyChangeEvent event) {
|
||||
String property = event.getProperty();
|
||||
|
|
|
@ -83,6 +83,7 @@ import org.eclipse.ui.actions.ActionFactory;
|
|||
import org.eclipse.ui.console.IConsoleConstants;
|
||||
import org.eclipse.ui.console.IConsoleView;
|
||||
import org.eclipse.ui.console.actions.ClearOutputAction;
|
||||
import org.eclipse.ui.console.actions.CloseConsoleAction;
|
||||
import org.eclipse.ui.console.actions.TextViewerAction;
|
||||
import org.eclipse.ui.console.actions.TextViewerGotoLineAction;
|
||||
import org.eclipse.ui.ide.IDE;
|
||||
|
@ -122,6 +123,7 @@ public class BuildConsolePage extends Page
|
|||
private NextErrorAction fNextErrorAction;
|
||||
private PreviousErrorAction fPreviousErrorAction;
|
||||
private ShowErrorAction fShowErrorAction;
|
||||
private CloseConsoleAction fCloseConsoleAction;
|
||||
private WrapLinesAction fWrapAction;
|
||||
private BringToTopOnBuild fBringToTopOnBuild;
|
||||
|
||||
|
@ -276,6 +278,7 @@ public class BuildConsolePage extends Page
|
|||
fPreviousErrorAction = new PreviousErrorAction(this);
|
||||
fShowErrorAction = new ShowErrorAction(this);
|
||||
fBringToTopOnBuild = new BringToTopOnBuild();
|
||||
fCloseConsoleAction = new CloseConsoleAction(this.fConsole);
|
||||
fSaveLogAction = new CopyBuildLogAction(this);
|
||||
|
||||
getViewer().setAutoScroll(!fIsLocked);
|
||||
|
@ -337,6 +340,8 @@ public class BuildConsolePage extends Page
|
|||
mgr.appendToGroup(IConsoleConstants.OUTPUT_GROUP, fWrapAction);
|
||||
mgr.appendToGroup(IConsoleConstants.OUTPUT_GROUP, fClearOutputAction);
|
||||
mgr.appendToGroup(IConsoleConstants.OUTPUT_GROUP, fBringToTopOnBuild);
|
||||
mgr.appendToGroup(IConsoleConstants.LAUNCH_GROUP, fCloseConsoleAction);
|
||||
mgr.appendToGroup(IConsoleConstants.LAUNCH_GROUP, new Separator());
|
||||
}
|
||||
|
||||
protected BuildConsoleViewer getViewer() {
|
||||
|
|
|
@ -82,6 +82,10 @@ public class GlobalBuildConsoleManager extends BuildConsoleManager {
|
|||
getInstance();
|
||||
}
|
||||
|
||||
static void staticReinitaliazeIfNecessary() {
|
||||
getInstance().reinitaliazeIfNecessary();
|
||||
}
|
||||
|
||||
/**
|
||||
* Stop the console and deallocate resources allocated during {@link #startup()}
|
||||
*/
|
||||
|
|
|
@ -560,6 +560,7 @@ public class CUIPlugin extends AbstractUIPlugin {
|
|||
fBuildConsoleManagers.put(contextId, manager);
|
||||
manager.startup(name, contextId, iconUrl);
|
||||
}
|
||||
manager.reinitaliazeIfNecessary();
|
||||
return manager;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue