private void createUIComponents() { myRootPanel = new TransparentPanel(0.5f) { @Override public boolean isVisible() { UISettings ui = UISettings.getInstance(); return ui.PRESENTATION_MODE || !ui.SHOW_STATUS_BAR && Registry.is("ide.show.progress.without.status.bar"); } }; IconButton iconButton = new IconButton(myProgress.getInfo().getCancelTooltipText(), AllIcons.Process.Stop, AllIcons.Process.StopHovered); myCancelButton = new InplaceButton(iconButton, new ActionListener() { public void actionPerformed(@NotNull ActionEvent e) { myProgress.cancelRequest(); } }).setFillBg(false); }
@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 > 1 && !isFloating()) { final ActionManager mgr = ActionManager.getInstance(); mgr.tryToExecute(mgr.getAction("HideAllWindows"), e, null, ActionPlaces.UNKNOWN, true); } } }
ActionButton(@NotNull AnAction action) { myAction = action; Icon icon = action.getTemplatePresentation().getIcon(); Icon hoveredIcon = action.getTemplatePresentation().getHoveredIcon(); if (hoveredIcon == null) { hoveredIcon = icon; } String toolTip = KeymapUtil.createTooltipText(action.getTemplatePresentation().getText(), action); myButton = new InplaceButton(toolTip, icon, this); myButton.setIcons(icon, icon, hoveredIcon); myButton.setHoveringEnabled(!SystemInfo.isMac); setContent(myButton); setOpaque(false); }
@NotNull private InplaceButton createSettingsButton(@NotNull final FindUsagesHandler handler, @NotNull final RelativePoint popupPosition, final Editor editor, final int maxUsages, @NotNull final Runnable cancelAction) { String shortcutText = ""; KeyboardShortcut shortcut = UsageViewImpl.getShowUsagesWithSettingsShortcut(); if (shortcut != null) { shortcutText = "(" + KeymapUtil.getShortcutText(shortcut) + ")"; } return new InplaceButton("Settings..." + shortcutText, AllIcons.General.Settings, new ActionListener() { @Override public void actionPerformed(ActionEvent e) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { showDialogAndFindUsages(handler, popupPosition, editor, maxUsages); } }); cancelAction.run(); } } ); }
@NotNull private InplaceButton createSettingsButton(@NotNull final FindUsagesHandler handler, @NotNull final RelativePoint popupPosition, final Editor editor, final int maxUsages, @NotNull final Runnable cancelAction) { String shortcutText = ""; KeyboardShortcut shortcut = UsageViewImpl.getShowUsagesWithSettingsShortcut(); if (shortcut != null) { shortcutText = "(" + KeymapUtil.getShortcutText(shortcut) + ")"; } return new InplaceButton("Settings..." + shortcutText, AllIcons.General.Settings, new ActionListener() { @Override public void actionPerformed(ActionEvent e) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { showDialogAndFindUsages(handler, popupPosition, editor, maxUsages); } }); cancelAction.run(); } }); }
public ActionPanel(JBTabsImpl tabs, TabInfo tabInfo, Pass<MouseEvent> pass) { myTabs = tabs; ActionGroup group = tabInfo.getTabLabelActions() != null ? tabInfo.getTabLabelActions() : new DefaultActionGroup(); AnAction[] children = group.getChildren(null); final NonOpaquePanel wrapper = new NonOpaquePanel(new BorderLayout()); wrapper.add(Box.createHorizontalStrut(2), BorderLayout.WEST); NonOpaquePanel inner = new NonOpaquePanel(); inner.setLayout(new BoxLayout(inner, BoxLayout.X_AXIS)); wrapper.add(inner, BorderLayout.CENTER); for (AnAction each : children) { ActionButton eachButton = new ActionButton(myTabs, tabInfo, each, tabInfo.getTabActionPlace(), pass, tabs.getTabActionsMouseDeadzone()) { @Override protected void repaintComponent(final Component c) { TabLabel tabLabel = (TabLabel) SwingUtilities.getAncestorOfClass(TabLabel.class, c); if (tabLabel != null) { Point point = SwingUtilities.convertPoint(c, new Point(0, 0), tabLabel); Dimension d = c.getSize(); tabLabel.repaint(point.x, point.y, d.width, d.height); } else { super.repaintComponent(c); } } }; myButtons.add(eachButton); InplaceButton component = eachButton.getComponent(); inner.add(component); } add(wrapper); }
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); }
@Nullable private TabLabel findLabel(Point dragPoint) { final Component at = myTabs.findComponentAt(dragPoint); if (at instanceof InplaceButton) return null; final TabLabel label = findLabel(at); return label != null && label.getParent() == myTabs && label.getInfo() != myDragSource ? label : null; }
private ChangelistConflictNotificationPanel(ChangelistConflictTracker tracker, VirtualFile file, LocalChangeList changeList) { myTracker = tracker; myFile = file; final ChangeListManager manager = tracker.getChangeListManager(); myChangeList = changeList; myLabel.setText("File from non-active changelist is modified"); createActionLabel("Move changes", new Runnable() { public void run() { ChangelistConflictResolution.MOVE.resolveConflict(myTracker.getProject(), myChangeList.getChanges()); } }).setToolTipText("Move changes to active changelist (" + manager.getDefaultChangeList().getName() + ")"); createActionLabel("Switch changelist", new Runnable() { public void run() { Change change = myTracker.getChangeListManager().getChange(myFile); if (change == null) { Messages.showInfoMessage("No changes for this file", "Message"); } else { ChangelistConflictResolution.SWITCH.resolveConflict(myTracker.getProject(), Collections.singletonList(change)); } } }).setToolTipText("Set active changelist to '" + myChangeList.getName() + "'"); createActionLabel("Ignore", new Runnable() { public void run() { myTracker.ignoreConflict(myFile, true); } }).setToolTipText("Hide this notification"); myLinksPanel.add(new InplaceButton("Show options dialog", AllIcons.General.Settings, new ActionListener() { public void actionPerformed(ActionEvent e) { ShowSettingsUtil.getInstance().editConfigurable(myTracker.getProject(), new ChangelistConflictConfigurable((ChangeListManagerImpl)manager)); } })); }
@NotNull private JComponent createHintComponent(@NotNull String text, @NotNull final FindUsagesHandler handler, @NotNull final RelativePoint popupPosition, final Editor editor, @NotNull final Runnable cancelAction, final int maxUsages, @NotNull final FindUsagesOptions options) { JComponent label = HintUtil.createInformationLabel(suggestSecondInvocation(options, handler, text + " ")); InplaceButton button = createSettingsButton(handler, popupPosition, editor, maxUsages, cancelAction); JPanel panel = new JPanel(new BorderLayout()) { @Override public void addNotify() { mySearchEverywhereRunnable = new Runnable() { @Override public void run() { searchEverywhere(options, handler, editor, popupPosition, maxUsages); } }; super.addNotify(); } @Override public void removeNotify() { mySearchEverywhereRunnable = null; super.removeNotify(); } }; button.setBackground(label.getBackground()); panel.setBackground(label.getBackground()); label.setOpaque(false); label.setBorder(null); panel.setBorder(HintUtil.createHintBorder()); panel.add(label, BorderLayout.CENTER); panel.add(button, BorderLayout.EAST); return panel; }
private ProgressButton createCancelButton() { InplaceButton cancelButton = new InplaceButton( new IconButton(myInfo.getCancelTooltipText(), myCompact ? AllIcons.Process.StopSmall : AllIcons.Process.Stop, myCompact ? AllIcons.Process.StopSmallHovered : AllIcons.Process.StopHovered), new ActionListener() { @Override public void actionPerformed(final ActionEvent e) { cancelRequest(); } }).setFillBg(false); cancelButton.setVisible(myInfo.isCancellable()); return new ProgressButton(cancelButton, () -> cancelButton.setPainting(!isStopping())); }
private ChangelistConflictNotificationPanel(ChangelistConflictTracker tracker, VirtualFile file, LocalChangeList changeList) { myTracker = tracker; myFile = file; final ChangeListManager manager = tracker.getChangeListManager(); myChangeList = changeList; myLabel.setText("File from non-active changelist is modified"); createActionLabel("Move changes", () -> ChangelistConflictResolution.MOVE.resolveConflict(myTracker.getProject(), myChangeList.getChanges(), myFile)). setToolTipText("Move changes to active changelist (" + manager.getDefaultChangeList().getName() + ")"); createActionLabel("Switch changelist", () -> { Change change = myTracker.getChangeListManager().getChange(myFile); if (change == null) { Messages.showInfoMessage("No changes for this file", "Message"); } else { ChangelistConflictResolution.SWITCH.resolveConflict(myTracker.getProject(), Collections.singletonList(change), null); } }).setToolTipText("Set active changelist to '" + myChangeList.getName() + "'"); createActionLabel("Ignore", () -> myTracker.ignoreConflict(myFile, true)).setToolTipText("Hide this notification"); myLinksPanel.add(new InplaceButton("Show options dialog", AllIcons.General.Settings, new ActionListener() { public void actionPerformed(ActionEvent e) { ShowSettingsUtil.getInstance().editConfigurable(myTracker.getProject(), new ChangelistConflictConfigurable((ChangeListManagerImpl)manager)); } })); }
public InplaceButton getComponent() { return myButton; }
public InlineProgressIndicator(boolean compact, @NotNull TaskInfo processInfo) { myCompact = compact; myInfo = processInfo; myCancelButton = new InplaceButton(new IconButton(processInfo.getCancelTooltipText(), AllIcons.Process.Stop, AllIcons.Process.StopHovered) { }, new ActionListener() { public void actionPerformed(final ActionEvent e) { cancelRequest(); } }).setFillBg(true); myCancelButton.setVisible(myInfo.isCancellable()); myCancelButton.setOpaque(false); myCancelButton.setToolTipText(processInfo.getCancelTooltipText()); myCancelButton.setFillBg(false); myProgress = new JProgressBar(SwingConstants.HORIZONTAL); myProgress.putClientProperty("JComponent.sizeVariant", "mini"); myComponent = new MyComponent(compact, myProcessName); if (myCompact) { myComponent.setOpaque(false); myComponent.setLayout(new BorderLayout(2, 0)); final JPanel textAndProgress = new JPanel(new BorderLayout()); textAndProgress.setOpaque(false); textAndProgress.add(myText, BorderLayout.CENTER); final NonOpaquePanel progressWrapper = new NonOpaquePanel(new GridBagLayout()); progressWrapper.setBorder(BorderFactory.createEmptyBorder(0, 4, 0, 0)); final GridBagConstraints c = new GridBagConstraints(); c.weightx = 1; c.weighty = 1; c.insets = new Insets(SystemInfo.isMacOSLion ? 1 : 0, 0, 1, myInfo.isCancellable() ? 0 : 4); c.fill = GridBagConstraints.HORIZONTAL; progressWrapper.add(myProgress, c); textAndProgress.add(progressWrapper, BorderLayout.EAST); myComponent.add(textAndProgress, BorderLayout.CENTER); myComponent.add(myCancelButton, BorderLayout.EAST); myComponent.setToolTipText(processInfo.getTitle() + ". " + IdeBundle.message("progress.text.clickToViewProgressWindow")); } else { myComponent.setLayout(new BorderLayout()); myProcessName.setText(processInfo.getTitle()); myComponent.add(myProcessName, BorderLayout.NORTH); myProcessName.setForeground(UIUtil.getPanelBackground().brighter().brighter()); myProcessName.setBorder(new EmptyBorder(2, 2, 2, 2)); final NonOpaquePanel content = new NonOpaquePanel(new BorderLayout()); content.setBorder(new EmptyBorder(2, 2, 2, myInfo.isCancellable() ? 2 : 4)); myComponent.add(content, BorderLayout.CENTER); final Wrapper cancelWrapper = new Wrapper(myCancelButton); cancelWrapper.setOpaque(false); cancelWrapper.setBorder(new EmptyBorder(0, 3, 0, 2)); content.add(cancelWrapper, BorderLayout.EAST); content.add(myText, BorderLayout.NORTH); content.add(myProgress, BorderLayout.CENTER); content.add(myText2, BorderLayout.SOUTH); myComponent.setBorder(new EmptyBorder(2, 2, 2, 2)); } if (!myCompact) { myProcessName.recomputeSize(); myText.recomputeSize(); myText2.recomputeSize(); } }
public ActionButton(AnAction action, AnAction alternativeAction, @NotNull Icon activeIcon, Icon inactiveIcon, Icon alternativeIcon) { myAction = action; myAlternativeAction = alternativeAction; myActiveIcon = activeIcon; myInactiveIcon = inactiveIcon; myAlternativeIcon = alternativeIcon; myCurrentAction = myAction; myButton = new InplaceButton(getToolTipTextByAction(action), EmptyIcon.ICON_16, this) { @Override public boolean isActive() { return ActionButton.this.isActive(); } }; myButton.setHoveringEnabled(!SystemInfo.isMac); setContent(myButton); setOpaque(false); setIcon(getActiveIcon(), getInactiveIcon() == null ? getActiveIcon() : getInactiveIcon(), getActiveHoveredIcon()); PropertyChangeListener listener = new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { if (myAlternativeAction == null) return; if ("ancestor".equals(evt.getPropertyName())) { if (evt.getNewValue() == null) { AltStateManager.getInstance().removeListener(ActionButton.this); switchAlternativeAction(false); } else { AltStateManager.getInstance().addListener(ActionButton.this); } } } }; addPropertyChangeListener(listener); }
public InlineProgressIndicator(boolean compact, TaskInfo processInfo) { myCompact = compact; myInfo = processInfo; myCancelButton = new InplaceButton(new IconButton(processInfo.getCancelTooltipText(), AllIcons.Process.Stop, AllIcons.Process.StopHovered) { }, new ActionListener() { public void actionPerformed(final ActionEvent e) { cancelRequest(); } }).setFillBg(true); myCancelButton.setVisible(myInfo.isCancellable()); myCancelButton.setOpaque(false); myCancelButton.setToolTipText(processInfo.getCancelTooltipText()); myCancelButton.setFillBg(false); myProgress = new MyProgressBar(JProgressBar.HORIZONTAL, compact); myComponent = new MyComponent(compact, myProcessName); if (myCompact) { myComponent.setOpaque(false); myComponent.setLayout(new BorderLayout(2, 0)); final JPanel textAndProgress = new JPanel(new BorderLayout()); textAndProgress.setOpaque(false); textAndProgress.add(myText, BorderLayout.CENTER); final NonOpaquePanel progressWrapper = new NonOpaquePanel(new GridBagLayout()); progressWrapper.setBorder(BorderFactory.createEmptyBorder(0, 4, 0, 0)); final GridBagConstraints c = new GridBagConstraints(); c.weightx = 1; c.weighty = 1; c.insets = new Insets(SystemInfo.isMacOSLion ? 1 : 0, 0, 1, myInfo.isCancellable() ? 0 : 4); c.fill = GridBagConstraints.HORIZONTAL; progressWrapper.add(myProgress, c); textAndProgress.add(progressWrapper, BorderLayout.EAST); myComponent.add(textAndProgress, BorderLayout.CENTER); myComponent.add(myCancelButton, BorderLayout.EAST); myComponent.setToolTipText(processInfo.getTitle() + ". " + IdeBundle.message("progress.text.clickToViewProgressWindow")); myProgress.setActive(false); } else { myComponent.setLayout(new BorderLayout()); myProcessName.setText(processInfo.getTitle()); myComponent.add(myProcessName, BorderLayout.NORTH); myProcessName.setForeground(UIUtil.getPanelBackground().brighter().brighter()); myProcessName.setBorder(new EmptyBorder(2, 2, 2, 2)); myProcessName.setDecorate(false); final NonOpaquePanel content = new NonOpaquePanel(new BorderLayout()); content.setBorder(new EmptyBorder(2, 2, 2, myInfo.isCancellable() ? 2 : 4)); myComponent.add(content, BorderLayout.CENTER); final Wrapper cancelWrapper = new Wrapper(myCancelButton); cancelWrapper.setOpaque(false); cancelWrapper.setBorder(new EmptyBorder(0, 3, 0, 2)); content.add(cancelWrapper, BorderLayout.EAST); content.add(myText, BorderLayout.NORTH); content.add(myProgress, BorderLayout.CENTER); content.add(myText2, BorderLayout.SOUTH); myText.setDecorate(false); myText2.setDecorate(false); myComponent.setBorder(new EmptyBorder(2, 2, 2, 2)); myProgress.setActive(false); } if (!myCompact) { myProcessName.recomputeSize(); myText.recomputeSize(); myText2.recomputeSize(); } }
private static Wrapper withBorder(InplaceButton button) { Wrapper wrapper = new Wrapper(button); wrapper.setBorder(JBUI.Borders.empty(0, 3, 0, 2)); return wrapper; }
ProgressButton(InplaceButton button, Runnable updateAction) { this.button = button; this.updateAction = updateAction; }
private void showPauseIcons(InplaceButton button) { setIcons(button, ProgressPauseSmall, ProgressPause, ProgressPauseSmallHover, ProgressPauseHover); }
private void showResumeIcons(InplaceButton button) { setIcons(button, ProgressResumeSmall, ProgressResume, ProgressResumeSmallHover, ProgressResumeHover); }
private void setIcons(InplaceButton button, Icon compactRegular, Icon regular, Icon compactHovered, Icon hovered) { button.setIcons(isCompact() ? compactRegular : regular, null, isCompact() ? compactHovered : hovered); }
public ActionButton(AnAction action, AnAction alternativeAction, @Nonnull Icon activeIcon, Icon inactiveIcon, Icon alternativeIcon) { myAction = action; myAlternativeAction = alternativeAction; myActiveIcon = activeIcon; myInactiveIcon = inactiveIcon; myAlternativeIcon = alternativeIcon; myCurrentAction = myAction; myButton = new InplaceButton(getToolTipTextByAction(action), EmptyIcon.ICON_16, this) { @Override public boolean isActive() { return ActionButton.this.isActive(); } }; myButton.setHoveringEnabled(!SystemInfo.isMac); setContent(myButton); setOpaque(false); setIcon(getActiveIcon(), getInactiveIcon() == null ? getActiveIcon() : getInactiveIcon(), getActiveHoveredIcon()); PropertyChangeListener listener = new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { if (myAlternativeAction == null) return; if ("ancestor".equals(evt.getPropertyName())) { if (evt.getNewValue() == null) { AltStateManager.getInstance().removeListener(ActionButton.this); switchAlternativeAction(false); } else { AltStateManager.getInstance().addListener(ActionButton.this); } } } }; addPropertyChangeListener(listener); }