DBE-1242 Having focus in "Database Console" and pressing "close tab" with CMD-w always closes SQL console instead

This commit is contained in:
Gregory.Shrago
2016-02-29 23:56:09 +03:00
parent 3e56beceb3
commit d98986512a
2 changed files with 13 additions and 1 deletions
@@ -22,6 +22,7 @@ import com.intellij.execution.ui.layout.actions.CloseViewAction;
import com.intellij.execution.ui.layout.actions.MinimizeViewAction;
import com.intellij.execution.ui.layout.actions.RestoreViewAction;
import com.intellij.ide.DataManager;
import com.intellij.ide.actions.CloseAction;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.actionSystem.*;
import com.intellij.openapi.project.Project;
@@ -1400,6 +1401,17 @@ public class RunnerContentUi implements ContentUI, Disposable, CellTransform.Fac
if (KEY.is(dataId)) {
return RunnerContentUi.this;
}
else if (CloseAction.CloseTarget.KEY.is(dataId)) {
Content content = getContentManager().getSelectedContent();
if (content != null && content.getManager().canCloseContents() && content.isCloseable()) {
return new CloseAction.CloseTarget() {
@Override
public void close() {
content.getManager().removeContent(content, true, true, true);
}
};
}
}
ContentManager originalContentManager = myOriginal == null ? null : myOriginal.getContentManager();
JComponent originalContentComponent = originalContentManager == null ? null : originalContentManager.getComponent();
@@ -64,7 +64,7 @@ public class RunnerLayoutUiImpl implements Disposable.Parent, RunnerLayoutUi, La
runnerTitle + " - " + sessionName);
Disposer.register(this, myContentUI);
myViewsContentManager = getContentFactory().createContentManager(myContentUI.getContentUI(), false, project);
myViewsContentManager = getContentFactory().createContentManager(myContentUI.getContentUI(), true, project);
myViewsContentManager.addDataProvider(this);
Disposer.register(this, myViewsContentManager);
}