private JPanel createToolbarPanel() {
    RunAction runAction = new RunAction(this);
    runAction.registerCustomShortcutSet(CommonShortcuts.getRerun(), this);

    DefaultActionGroup leftActionGroup = new DefaultActionGroup();
    leftActionGroup.add(runAction);
    leftActionGroup.add(new PauseOutputAction(this));
    leftActionGroup.add(new StopAction(this));
    leftActionGroup.add(new CloseAction());
    leftActionGroup.add(new PreviousOccurenceToolbarAction(this));
    leftActionGroup.add(new NextOccurenceToolbarAction(this));
    leftActionGroup.add(new ContextHelpAction(HelpID.ANT));

    DefaultActionGroup rightActionGroup = new DefaultActionGroup();
    rightActionGroup.add(new ChangeViewAction(this));
    rightActionGroup.add(new VerboseAction(this));
    rightActionGroup.add(
        CommonActionsManager.getInstance().createExpandAllAction(myTreeExpander, this));
    rightActionGroup.add(
        CommonActionsManager.getInstance().createCollapseAllAction(myTreeExpander, this));
    rightActionGroup.add(myTreeView.createToggleAutoscrollAction());

    myLeftToolbar =
        ActionManager.getInstance()
            .createActionToolbar(ActionPlaces.ANT_MESSAGES_TOOLBAR, leftActionGroup, false);
    JPanel toolbarPanel = new JPanel(new GridLayout(1, 2, 2, 0));
    toolbarPanel.add(myLeftToolbar.getComponent());
    myRightToolbar =
        ActionManager.getInstance()
            .createActionToolbar(ActionPlaces.ANT_MESSAGES_TOOLBAR, rightActionGroup, false);
    toolbarPanel.add(myRightToolbar.getComponent());

    return toolbarPanel;
  }
  public final ActionGroup createPopupGroup(boolean skipHideAction) {
    final DefaultActionGroup group = createGearPopupGroup();
    if (!ToolWindowId.PREVIEW.equals(myInfo.getId())) {
      group.add(myToggleContentUiTypeAction);
    }

    final DefaultActionGroup moveGroup =
        new DefaultActionGroup(UIBundle.message("tool.window.move.to.action.group.name"), true);
    final ToolWindowAnchor anchor = myInfo.getAnchor();
    if (anchor != ToolWindowAnchor.TOP) {
      final AnAction topAction =
          new ChangeAnchorAction(
              UIBundle.message("tool.window.move.to.top.action.name"), ToolWindowAnchor.TOP);
      moveGroup.add(topAction);
    }
    if (anchor != ToolWindowAnchor.LEFT) {
      final AnAction leftAction =
          new ChangeAnchorAction(
              UIBundle.message("tool.window.move.to.left.action.name"), ToolWindowAnchor.LEFT);
      moveGroup.add(leftAction);
    }
    if (anchor != ToolWindowAnchor.BOTTOM) {
      final AnAction bottomAction =
          new ChangeAnchorAction(
              UIBundle.message("tool.window.move.to.bottom.action.name"), ToolWindowAnchor.BOTTOM);
      moveGroup.add(bottomAction);
    }
    if (anchor != ToolWindowAnchor.RIGHT) {
      final AnAction rightAction =
          new ChangeAnchorAction(
              UIBundle.message("tool.window.move.to.right.action.name"), ToolWindowAnchor.RIGHT);
      moveGroup.add(rightAction);
    }
    group.add(moveGroup);

    DefaultActionGroup resize =
        new DefaultActionGroup(ActionsBundle.groupText("ResizeToolWindowGroup"), true);
    resize.add(new ResizeToolWindowAction.Left(myToolWindow, this));
    resize.add(new ResizeToolWindowAction.Right(myToolWindow, this));
    resize.add(new ResizeToolWindowAction.Up(myToolWindow, this));
    resize.add(new ResizeToolWindowAction.Down(myToolWindow, this));
    resize.add(ActionManager.getInstance().getAction("MaximizeToolWindow"));

    group.add(resize);
    if (!skipHideAction) {
      group.addSeparator();
      group.add(new HideAction());
    }
    return group;
  }
 @Override
 public void mousePressed(final MouseEvent e) {
   if (UIUtil.isActionClick(e)) {
     if (e.getClickCount() == 1) {
       myActionClickCount = 0;
     }
     // clicks on the close window button don't count in determining whether we have a
     // double-click on tab (IDEA-70403)
     final Component deepestComponent =
         SwingUtilities.getDeepestComponentAt(e.getComponent(), e.getX(), e.getY());
     if (!(deepestComponent instanceof InplaceButton)) {
       myActionClickCount++;
     }
     if (myActionClickCount == 2 && !isFloating()) {
       final ActionManager mgr = ActionManager.getInstance();
       mgr.tryToExecute(mgr.getAction("HideAllWindows"), e, null, ActionPlaces.UNKNOWN, true);
     }
   }
 }
  @Override
  public void initComponent() {
    EditorFactory.getInstance()
        .addEditorFactoryListener(new StudyEditorFactoryListener(), myProject);
    ActionManager.getInstance()
        .addAnActionListener(
            new AnActionListener() {
              @Override
              public void beforeActionPerformed(
                  AnAction action, DataContext dataContext, AnActionEvent event) {
                AnAction[] newGroupActions =
                    ((ActionGroup) ActionManager.getInstance().getAction("NewGroup"))
                        .getChildren(null);
                for (AnAction newAction : newGroupActions) {
                  if (newAction == action) {
                    myListener = new FileCreatedByUserListener();
                    VirtualFileManager.getInstance().addVirtualFileListener(myListener);
                    break;
                  }
                }
              }

              @Override
              public void afterActionPerformed(
                  AnAction action, DataContext dataContext, AnActionEvent event) {
                AnAction[] newGroupActions =
                    ((ActionGroup) ActionManager.getInstance().getAction("NewGroup"))
                        .getChildren(null);
                for (AnAction newAction : newGroupActions) {
                  if (newAction == action) {
                    VirtualFileManager.getInstance().removeVirtualFileListener(myListener);
                  }
                }
              }

              @Override
              public void beforeEditorTyping(char c, DataContext dataContext) {}
            });
  }
  EditorTabbedContainer(final EditorWindow window, Project project, final int tabPlacement) {
    myWindow = window;
    myProject = project;
    final ActionManager actionManager = ActionManager.getInstance();
    myTabs = new JBEditorTabs(project, actionManager, IdeFocusManager.getInstance(project), this);
    myTabs
        .setDataProvider(new MyDataProvider())
        .setPopupGroup(
            new Getter<ActionGroup>() {
              public ActionGroup get() {
                return (ActionGroup)
                    CustomActionsSchema.getInstance()
                        .getCorrectedAction(IdeActions.GROUP_EDITOR_TAB_POPUP);
              }
            },
            ActionPlaces.EDITOR_TAB_POPUP,
            false)
        .setNavigationActionsEnabled(false)
        .addTabMouseListener(new TabMouseListener())
        .getPresentation()
        .setTabDraggingEnabled(true)
        .setUiDecorator(
            new UiDecorator() {
              @NotNull
              public UiDecoration getDecoration() {
                return new UiDecoration(
                    null,
                    new Insets(
                        TabsUtil.TAB_VERTICAL_PADDING, 10, TabsUtil.TAB_VERTICAL_PADDING, 10));
              }
            })
        .setTabLabelActionsMouseDeadzone(TimedDeadzone.NULL)
        .setGhostsAlwaysVisible(true)
        .setTabLabelActionsAutoHide(false)
        .setActiveTabFillIn(
            EditorColorsManager.getInstance().getGlobalScheme().getDefaultBackground())
        .setPaintFocus(false)
        .getJBTabs()
        .addListener(
            new TabsListener.Adapter() {
              public void selectionChanged(final TabInfo oldSelection, final TabInfo newSelection) {
                final FileEditorManager editorManager = FileEditorManager.getInstance(myProject);
                final FileEditor oldEditor =
                    oldSelection != null
                        ? editorManager.getSelectedEditor((VirtualFile) oldSelection.getObject())
                        : null;
                if (oldEditor != null) {
                  oldEditor.deselectNotify();
                }

                final FileEditor newEditor =
                    editorManager.getSelectedEditor((VirtualFile) newSelection.getObject());
                if (newEditor != null) {
                  newEditor.selectNotify();
                }
              }
            })
        .setAdditionalSwitchProviderWhenOriginal(new MySwitchProvider())
        .setSelectionChangeHandler(
            new JBTabs.SelectionChangeHandler() {
              @Override
              public ActionCallback execute(
                  TabInfo info, boolean requestFocus, final ActiveRunnable doChangeSelection) {
                final ActionCallback result = new ActionCallback();
                CommandProcessor.getInstance()
                    .executeCommand(
                        myProject,
                        new Runnable() {
                          @Override
                          public void run() {
                            ((IdeDocumentHistoryImpl) IdeDocumentHistory.getInstance(myProject))
                                .onSelectionChanged();
                            result.notify(doChangeSelection.run());
                          }
                        },
                        "EditorChange",
                        null);
                return result;
              }
            })
        .getPresentation()
        .setRequestFocusOnLastFocusedComponent(true);

    setTabPlacement(UISettings.getInstance().EDITOR_TAB_PLACEMENT);

    updateTabBorder();

    ((ToolWindowManagerEx) ToolWindowManager.getInstance(myProject))
        .addToolWindowManagerListener(
            new ToolWindowManagerAdapter() {
              public void stateChanged() {
                updateTabBorder();
              }

              public void toolWindowRegistered(@NotNull final String id) {
                updateTabBorder();
              }
            });

    UISettings.getInstance()
        .addUISettingsListener(
            new UISettingsListener() {
              public void uiSettingsChanged(UISettings source) {
                updateTabBorder();
              }
            },
            this);

    Disposer.register(project, this);
  }
 public CloseTab(JComponent c, TabInfo info) {
   myTabInfo = info;
   myShadow =
       new ShadowAction(this, ActionManager.getInstance().getAction(IdeActions.ACTION_CLOSE), c);
 }
 private ToggleContentUiTypeAction() {
   copyFrom(ActionManager.getInstance().getAction(TOGGLE_CONTENT_UI_TYPE_ACTION_ID));
 }
 public HideAction() {
   copyFrom(ActionManager.getInstance().getAction(HIDE_ACTIVE_WINDOW_ACTION_ID));
   getTemplatePresentation().setText(UIBundle.message("tool.window.hide.action.name"));
 }
 public ToggleSideModeAction() {
   copyFrom(ActionManager.getInstance().getAction(TOGGLE_SIDE_MODE_ACTION_ID));
 }
 public ToggleWindowedModeAction() {
   copyFrom(ActionManager.getInstance().getAction(TOGGLE_WINDOWED_MODE_ACTION_ID));
 }
 public ToggleFloatingModeAction() {
   copyFrom(ActionManager.getInstance().getAction(TOGGLE_FLOATING_MODE_ACTION_ID));
 }
 public ToggleDockModeAction() {
   copyFrom(ActionManager.getInstance().getAction(TOGGLE_DOCK_MODE_ACTION_ID));
 }
 public TogglePinnedModeAction() {
   copyFrom(ActionManager.getInstance().getAction(TOGGLE_PINNED_MODE_ACTION_ID));
 }