2 * Copyright 2000-2009 JetBrains s.r.o.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package com
.intellij
.openapi
.wm
.impl
.status
;
18 import com
.intellij
.idea
.ActionsBundle
;
19 import com
.intellij
.openapi
.actionSystem
.AnActionEvent
;
20 import com
.intellij
.openapi
.actionSystem
.ToggleAction
;
21 import com
.intellij
.openapi
.wm
.impl
.IdeFrameImpl
;
22 import com
.intellij
.openapi
.project
.DumbAware
;
23 import org
.jetbrains
.annotations
.Nullable
;
27 public class ShowProcessWindowAction
extends ToggleAction
implements DumbAware
{
29 public ShowProcessWindowAction() {
30 super(ActionsBundle
.message("action.ShowProcessWindow.text"), ActionsBundle
.message("action.ShowProcessWindow.description"), null);
34 public boolean isSelected(final AnActionEvent e
) {
35 final IdeFrameImpl frame
= getFrame();
36 if (frame
== null) return false;
37 return frame
.getStatusBar().isProcessWindowOpen();
40 public void update(final AnActionEvent e
) {
42 e
.getPresentation().setEnabled(getFrame() != null);
46 private IdeFrameImpl
getFrame() {
47 Container window
= KeyboardFocusManager
.getCurrentKeyboardFocusManager().getFocusedWindow();
48 while (window
!= null) {
49 if (window
instanceof IdeFrameImpl
) return (IdeFrameImpl
)window
;
50 window
= window
.getParent();
56 public void setSelected(final AnActionEvent e
, final boolean state
) {
57 final IdeFrameImpl frame
= getFrame();
58 if (frame
== null) return;
59 frame
.getStatusBar().setProcessWindowOpen(state
);