public ContentTabLabel(final Content content, TabContentLayout layout) { super(layout.myUi, true); myLayout = layout; myContent = content; update(); myBehavior = new BaseButtonBehavior(this) { protected void execute(final MouseEvent e) { final ContentManager mgr = contentManager(); if (mgr.getIndexOfContent(myContent) >= 0) { mgr.setSelectedContent(myContent, true); } } }; myBehavior.setActionTrigger(MouseEvent.MOUSE_PRESSED); myBehavior.setMouseDeadzone(TimedDeadzone.NULL); }
private ToolbarAlikeButton(@NotNull final Icon icon) { myIcon = icon; myBehavior = new BaseButtonBehavior(this, TimedDeadzone.NULL) { @Override protected void execute(MouseEvent e) { onClick(e); } }; setOpaque(false); }
@Override @NotNull public JBTabsPresentation setTabLabelActionsMouseDeadzone(final TimedDeadzone.Length length) { myTabActionsMouseDeadzone = length; final List<TabInfo> all = getTabs(); for (TabInfo each : all) { final TabLabel eachLabel = myInfo2Label.get(each); eachLabel.updateTabActions(); } return this; }
public ActionButton(JBTabsImpl tabs, TabInfo tabInfo, AnAction action, String place, Pass<MouseEvent> pass, TimedDeadzone.Length deadzone) { super(null, action.getTemplatePresentation().getIcon()); myTabs = tabs; myTabInfo = tabInfo; myAction = action; myPlace = place; myButton = new InplaceButton(this, this, pass, deadzone) { @Override protected void doRepaintComponent(Component c) { repaintComponent(c); } }; myButton.setVisible(false); }
private ToolbarAlikeButton(@NotNull Icon icon) { myIcon = icon; myBehavior = new BaseButtonBehavior(this, TimedDeadzone.NULL) { @Override protected void execute(MouseEvent e) { onClick(e); } }; setOpaque(false); }
private ToolWindowsWidget() { new BaseButtonBehavior(this, TimedDeadzone.NULL) { @Override protected void execute(MouseEvent e) { performAction(); } }.setActionTrigger(MouseEvent.MOUSE_PRESSED); UISettings.getInstance().addUISettingsListener(this, this); KeyboardFocusManager.getCurrentKeyboardFocusManager().addPropertyChangeListener("focusOwner", this); }
@Override @Nonnull public JBTabsPresentation setTabLabelActionsMouseDeadzone(final TimedDeadzone.Length length) { myTabActionsMouseDeadzone = length; final List<TabInfo> all = getTabs(); for (TabInfo each : all) { final TabLabel eachLabel = myInfo2Label.get(each); eachLabel.updateTabActions(); } return this; }
ToolWindowsWidget(@Nonnull Disposable parent) { new BaseButtonBehavior(this, TimedDeadzone.NULL) { @Override protected void execute(MouseEvent e) { performAction(); } }.setActionTrigger(MouseEvent.MOUSE_PRESSED); IdeEventQueue.getInstance().addDispatcher(e -> { if (e instanceof MouseEvent) { MouseEvent mouseEvent = (MouseEvent)e; if (mouseEvent.getComponent() == null || !SwingUtilities.isDescendingFrom(mouseEvent.getComponent(), SwingUtilities.getWindowAncestor(this))) { return false; } if (e.getID() == MouseEvent.MOUSE_MOVED && isShowing()) { Point p = mouseEvent.getLocationOnScreen(); Point screen = this.getLocationOnScreen(); if (new Rectangle(screen.x - 4, screen.y - 2, getWidth() + 4, getHeight() + 4).contains(p)) { mouseEntered(); wasExited = false; } else { if (!wasExited) { wasExited = mouseExited(p); } } } else if (e.getID() == MouseEvent.MOUSE_EXITED) { //mouse exits WND mouseExited(mouseEvent.getLocationOnScreen()); } } return false; }, parent); ApplicationManager.getApplication().getMessageBus().connect(this).subscribe(UISettingsListener.TOPIC, this); KeyboardFocusManager.getCurrentKeyboardFocusManager().addPropertyChangeListener("focusOwner", this); myAlarm = new Alarm(parent); }
ToolbarAlikeButton(@Nonnull final Icon icon) { myIcon = icon; myBehavior = new BaseButtonBehavior(this, TimedDeadzone.NULL) { @Override protected void execute(MouseEvent e) { onClick(e); } }; setOpaque(false); }
public InplaceButton(IconButton source, final ActionListener listener, final Pass<MouseEvent> me) { this(source, listener, me, TimedDeadzone.DEFAULT); }
public void setMouseDeadzone(final TimedDeadzone.Length deadZone) { myBehavior.setMouseDeadzone(deadZone); }
@NotNull JBTabsPresentation setTabLabelActionsMouseDeadzone(TimedDeadzone.Length length);
public TimedDeadzone.Length getTabActionsMouseDeadzone() { return myTabActionsMouseDeadzone; }
public void setMouseDeadZone(TimedDeadzone.Length deadZone) { myButton.setMouseDeadzone(deadZone); }
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() { @NotNull @Override public ActionCallback execute(TabInfo info, boolean requestFocus, @NotNull 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); myTabs.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { if (myTabs.findInfo(e) != null || isFloating()) return; if (!e.isPopupTrigger() && SwingUtilities.isLeftMouseButton(e) && e.getClickCount() == 2) { final ActionManager mgr = ActionManager.getInstance(); mgr.tryToExecute(mgr.getAction("HideAllWindows"), e, null, ActionPlaces.UNKNOWN, 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); }
@Nonnull JBTabsPresentation setTabLabelActionsMouseDeadzone(TimedDeadzone.Length length);
EditorTabbedContainer(final DesktopEditorWindow window, Project project) { myWindow = window; myProject = project; final ActionManager actionManager = ActionManager.getInstance(); myTabs = new JBEditorTabs(project, actionManager, IdeFocusManager.getInstance(project), this); myTabs.setBorder(new MyShadowBorder(myTabs)); myTabs.setTransferHandler(new MyTransferHandler()); myTabs.setDataProvider(new MyDataProvider()) .setPopupGroup(() -> (ActionGroup)CustomActionsSchema.getInstance().getCorrectedAction(IdeActions.GROUP_EDITOR_TAB_POPUP), ActionPlaces.EDITOR_TAB_POPUP, false).addTabMouseListener(new TabMouseListener()).getPresentation().setTabDraggingEnabled(true) .setUiDecorator(() -> new UiDecorator.UiDecoration(null, new Insets(TabsUtil.TAB_VERTICAL_PADDING, 8, TabsUtil.TAB_VERTICAL_PADDING, 8))) .setTabLabelActionsMouseDeadzone(TimedDeadzone.NULL).setGhostsAlwaysVisible(true).setTabLabelActionsAutoHide(false) .setActiveTabFillIn(EditorColorsManager.getInstance().getGlobalScheme().getDefaultBackground()).setPaintFocus(false).getJBTabs() .addListener(new TabsListener.Adapter() { @Override 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(); } VirtualFile newFile = (VirtualFile)newSelection.getObject(); final FileEditor newEditor = editorManager.getSelectedEditor(newFile); if (newEditor != null) { newEditor.selectNotify(); } if (GeneralSettings.getInstance().isSyncOnFrameActivation()) { VfsUtil.markDirtyAndRefresh(true, false, false, newFile); } } }).setSelectionChangeHandler((info, requestFocus, doChangeSelection) -> { final ActionCallback result = new ActionCallback(); CommandProcessor.getInstance().executeCommand(myProject, () -> { ((IdeDocumentHistoryImpl)IdeDocumentHistory.getInstance(myProject)).onSelectionChanged(); result.notify(doChangeSelection.run()); }, "EditorChange", null); return result; }).getPresentation().setRequestFocusOnLastFocusedComponent(true); myTabs.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { if (myTabs.findInfo(e) != null || isFloating()) return; if (!e.isPopupTrigger() && SwingUtilities.isLeftMouseButton(e) && e.getClickCount() == 2) { final ActionManager mgr = ActionManager.getInstance(); mgr.tryToExecute(mgr.getAction("HideAllWindows"), e, null, ActionPlaces.UNKNOWN, true); } } }); setTabPlacement(UISettings.getInstance().EDITOR_TAB_PLACEMENT); updateTabBorder(); ((ToolWindowManagerEx)ToolWindowManager.getInstance(myProject)).addToolWindowManagerListener(new ToolWindowManagerAdapter() { @Override public void stateChanged() { updateTabBorder(); } @Override public void toolWindowRegistered(@Nonnull final String id) { updateTabBorder(); } }); project.getMessageBus().connect().subscribe(UISettingsListener.TOPIC, uiSettings -> updateTabBorder()); Disposer.register(project, this); }