@Override public void update(final AnActionEvent e) { e.getPresentation().setIcon(myTabs.isEditorTabs() ? myNewIcon : myIcon); e.getPresentation().setHoveredIcon(myTabs.isEditorTabs() ? myNewHoveredIcon : myHoveredIcon); e.getPresentation().setVisible(UISettings.getInstance().SHOW_CLOSE_BUTTON); e.getPresentation().setText("Close. Alt-click to close others."); }
@Override public void actionPerformed(AnActionEvent e) { JPanel result = new JPanel(new BorderLayout()); JLabel label = new JLabel("Lines around:"); label.setBorder(BorderFactory.createEmptyBorder(4, 4, 0, 0)); JPanel wrapper = new JPanel(new BorderLayout()); wrapper.add(label, BorderLayout.NORTH); result.add(wrapper, BorderLayout.WEST); final JSlider slider = new JSlider(JSlider.HORIZONTAL, 1, 5, 1); slider.setMinorTickSpacing(1); slider.setPaintTicks(true); slider.setPaintTrack(true); slider.setSnapToTicks(true); UIUtil.setSliderIsFilled(slider, true); slider.setPaintLabels(true); slider.setLabelTable(LABELS); result.add(slider, BorderLayout.CENTER); final VcsConfiguration configuration = VcsConfiguration.getInstance(myProject); for (int i = 0; i < ourMarks.length; i++) { int mark = ourMarks[i]; if (mark == configuration.SHORT_DIFF_EXTRA_LINES) { slider.setValue(i + 1); } } JBPopup popup = JBPopupFactory.getInstance().createComponentPopupBuilder(result, slider).createPopup(); popup.setFinalRunnable( new Runnable() { @Override public void run() { int value = slider.getModel().getValue(); if (configuration.SHORT_DIFF_EXTRA_LINES != ourMarks[value - 1]) { configuration.SHORT_DIFF_EXTRA_LINES = ourMarks[value - 1]; myFragmentedContent.recalculate(); refreshData(myFragmentedContent); } } }); InputEvent inputEvent = e.getInputEvent(); if (inputEvent instanceof MouseEvent) { int width = result.getPreferredSize().width; MouseEvent inputEvent1 = (MouseEvent) inputEvent; Point point1 = new Point(inputEvent1.getX() - width / 2, inputEvent1.getY()); RelativePoint point = new RelativePoint(inputEvent1.getComponent(), point1); popup.show(point); } else { popup.showInBestPositionFor(e.getDataContext()); } }
private JComponent createActionPanel() { JPanel actions = new NonOpaquePanel(); actions.setBorder(JBUI.Borders.emptyLeft(10)); actions.setLayout(new BoxLayout(actions, BoxLayout.Y_AXIS)); ActionManager actionManager = ActionManager.getInstance(); ActionGroup quickStart = (ActionGroup) actionManager.getAction(IdeActions.GROUP_WELCOME_SCREEN_QUICKSTART); DefaultActionGroup group = new DefaultActionGroup(); collectAllActions(group, quickStart); for (AnAction action : group.getChildren(null)) { JPanel button = new JPanel(new BorderLayout()); button.setOpaque(false); button.setBorder(JBUI.Borders.empty(8, 20)); AnActionEvent e = AnActionEvent.createFromAnAction( action, null, ActionPlaces.WELCOME_SCREEN, DataManager.getInstance().getDataContext(this)); action.update(e); Presentation presentation = e.getPresentation(); if (presentation.isVisible()) { String text = presentation.getText(); if (text != null && text.endsWith("...")) { text = text.substring(0, text.length() - 3); } Icon icon = presentation.getIcon(); if (icon.getIconHeight() != JBUI.scale(16) || icon.getIconWidth() != JBUI.scale(16)) { icon = JBUI.emptyIcon(16); } action = wrapGroups(action); ActionLink link = new ActionLink(text, icon, action, createUsageTracker(action)); link.setPaintUnderline(false); link.setNormalColor(getLinkNormalColor()); button.add(link); if (action instanceof WelcomePopupAction) { button.add(createArrow(link), BorderLayout.EAST); } installFocusable(button, action, KeyEvent.VK_UP, KeyEvent.VK_DOWN, true); actions.add(button); } } WelcomeScreenActionsPanel panel = new WelcomeScreenActionsPanel(); panel.actions.add(actions); return panel.root; }
private JComponent createSettingsAndDocs() { JPanel panel = new NonOpaquePanel(new BorderLayout()); NonOpaquePanel toolbar = new NonOpaquePanel(); AnAction register = ActionManager.getInstance().getAction("Register"); boolean registeredVisible = false; if (register != null) { AnActionEvent e = AnActionEvent.createFromAnAction( register, null, ActionPlaces.WELCOME_SCREEN, DataManager.getInstance().getDataContext(this)); register.update(e); Presentation presentation = e.getPresentation(); if (presentation.isEnabled()) { ActionLink registerLink = new ActionLink("Register", register); registerLink.setNormalColor(getLinkNormalColor()); NonOpaquePanel button = new NonOpaquePanel(new BorderLayout()); button.setBorder(JBUI.Borders.empty(4, 10)); button.add(registerLink); installFocusable(button, register, KeyEvent.VK_UP, KeyEvent.VK_RIGHT, true); NonOpaquePanel wrap = new NonOpaquePanel(); wrap.setBorder(JBUI.Borders.emptyLeft(10)); wrap.add(button); panel.add(wrap, BorderLayout.WEST); registeredVisible = true; } } toolbar.setLayout(new BoxLayout(toolbar, BoxLayout.X_AXIS)); toolbar.add( createActionLink( "Configure", IdeActions.GROUP_WELCOME_SCREEN_CONFIGURE, AllIcons.General.GearPlain, !registeredVisible)); toolbar.add(createActionLink("Get Help", IdeActions.GROUP_WELCOME_SCREEN_DOC, null, false)); panel.add(toolbar, BorderLayout.EAST); panel.setBorder(JBUI.Borders.empty(0, 0, 8, 11)); return panel; }
public void actionPerformed(final AnActionEvent e) { final FileEditorManagerEx mgr = FileEditorManagerEx.getInstanceEx(myProject); EditorWindow window; final VirtualFile file = (VirtualFile) myTabInfo.getObject(); if (ActionPlaces.EDITOR_TAB.equals(e.getPlace())) { window = myWindow; } else { window = mgr.getCurrentWindow(); } if (window != null) { if ((e.getModifiers() & InputEvent.ALT_MASK) != 0) { window.closeAllExcept(file); } else { if (window.findFileComposite(file) != null) { mgr.closeFile(file, window); } } } }
@Override public void update(AnActionEvent e) { Component focusOwner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner(); e.getPresentation().setEnabled(false); if (focusOwner instanceof JComponent && SpeedSearchBase.hasActiveSpeedSearch((JComponent) focusOwner)) { return; } if (StackingPopupDispatcher.getInstance().isPopupFocused()) return; if (focusOwner instanceof JTree) { JTree tree = (JTree) focusOwner; if (!tree.isEditing()) { e.getPresentation().setEnabled(true); } } else if (focusOwner instanceof JTable) { JTable table = (JTable) focusOwner; if (!table.isEditing()) { e.getPresentation().setEnabled(true); } } }
@Override public void actionPerformed(AnActionEvent e) { final DefaultActionGroup dag = new DefaultActionGroup(); dag.add(myUsual); dag.add(myNumbered); dag.add(mySoftWrapsAction); final ListPopup popup = JBPopupFactory.getInstance() .createActionGroupPopup( null, dag, e.getDataContext(), JBPopupFactory.ActionSelectionAid.SPEEDSEARCH, false); if (e.getInputEvent() instanceof MouseEvent) { popup.show(new RelativePoint((MouseEvent) e.getInputEvent())); } else { // todo correct /*final Dimension dimension = popup.getContent().getPreferredSize(); final Point at = new Point(-dimension.width / 2, 0); popup.show(new RelativePoint(myParent, at));*/ popup.showInBestPositionFor(e.getDataContext()); } }
private void updateIcon(AnAction action) { if (isToggleable() && (myPresentation.getIcon() == null || myInsideCheckedGroup || !UISettings.getInstance().SHOW_ICONS_IN_MENUS)) { action.update(myEvent); myToggled = Boolean.TRUE.equals( myEvent.getPresentation().getClientProperty(Toggleable.SELECTED_PROPERTY)); if (ActionPlaces.MAIN_MENU.equals(myPlace) && SystemInfo.isMacSystemMenu || UIUtil.isUnderNimbusLookAndFeel() || UIUtil.isUnderWindowsLookAndFeel() && SystemInfo.isWin7OrNewer) { setState(myToggled); } else if (!(getUI() instanceof GtkMenuItemUI)) { if (myToggled) { setIcon(ourCheckedIcon); setDisabledIcon(IconLoader.getDisabledIcon(ourCheckedIcon)); } else { setIcon(ourUncheckedIcon); setDisabledIcon(IconLoader.getDisabledIcon(ourUncheckedIcon)); } } } else { if (UISettings.getInstance().SHOW_ICONS_IN_MENUS) { Icon icon = myPresentation.getIcon(); if (action instanceof ToggleAction && ((ToggleAction) action).isSelected(myEvent)) { icon = new PoppedIcon(icon, 16, 16); } setIcon(icon); if (myPresentation.getDisabledIcon() != null) { setDisabledIcon(myPresentation.getDisabledIcon()); } else { setDisabledIcon(IconLoader.getDisabledIcon(icon)); } } } }
@Override public void update(AnActionEvent e) { super.update(e); e.getPresentation().setEnabled(myEnabled); }
@Override public void update(AnActionEvent e) { super.update(e); e.getPresentation().setIcon(myConfiguration.SOFT_WRAPS_IN_SHORT_DIFF ? myIcon : null); }
@Override public void actionPerformed(AnActionEvent e) { myWrapper.doCancelAction(e.getInputEvent()); }