@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); } } }
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); }