com.intellij.ui.InplaceButton Java Examples

The following examples show how to use com.intellij.ui.InplaceButton. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ShowUsagesAction.java    From dagger-intellij-plugin with Apache License 2.0 6 votes vote down vote up
@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();
        }
      }
  );
}
 
Example #2
Source File: EditorTabbedContainer.java    From consulo with Apache License 2.0 6 votes vote down vote up
@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);
    }
  }
}
 
Example #3
Source File: ShowUsagesAction.java    From otto-intellij-plugin with Apache License 2.0 6 votes vote down vote up
@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();
    }
  });
}
 
Example #4
Source File: SelectedDependenciesTableModel.java    From intellij-spring-assistant with MIT License 5 votes vote down vote up
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected,
    boolean hasFocus, int row, int column) {
  InplaceButton inplaceButton = new InplaceButton(
      new IconButton("Click to delete", DeleteContentFolder, DeleteContentFolderRollover),
      e -> {
      });
  Couple<Color> colors = UIUtil.getCellColors(table, isSelected, row, column);
  setForeground(colors.getFirst());
  setBackground(colors.getSecond());
  setEnabled(true);
  inplaceButton.setOpaque(false);
  return inplaceButton;
}
 
Example #5
Source File: ShowUsagesAction.java    From dagger-intellij-plugin with Apache License 2.0 5 votes vote down vote up
@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 + "&nbsp;"));
  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;
}
 
Example #6
Source File: ActionPanel.java    From consulo with Apache License 2.0 5 votes vote down vote up
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);
}
 
Example #7
Source File: ActionButton.java    From consulo with Apache License 2.0 5 votes vote down vote up
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);
}
 
Example #8
Source File: DragHelper.java    From consulo with Apache License 2.0 5 votes vote down vote up
@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;

}
 
Example #9
Source File: InlineProgressIndicator.java    From consulo with Apache License 2.0 5 votes vote down vote up
private ProgressButton createCancelButton() {
  InplaceButton cancelButton = new InplaceButton(new IconButton(myInfo.getCancelTooltipText(), AllIcons.Process.Stop, 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()));
}
 
Example #10
Source File: ChangelistConflictNotificationPanel.java    From consulo with Apache License 2.0 5 votes vote down vote up
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));
    }
  }));
}
 
Example #11
Source File: ShowUsagesAction.java    From otto-intellij-plugin with Apache License 2.0 5 votes vote down vote up
@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 + "&nbsp;"));
  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;
}
 
Example #12
Source File: SelectedDependencyListItem.java    From intellij-spring-assistant with MIT License 4 votes vote down vote up
private void createUIComponents() {
  deleteButton = new InplaceButton(
      new IconButton("Click to delete", DeleteContentFolder, DeleteContentFolderRollover),
      e -> listener.onDeleteClicked());
}
 
Example #13
Source File: ActionButton.java    From consulo with Apache License 2.0 4 votes vote down vote up
public InplaceButton getComponent() {
  return myButton;
}
 
Example #14
Source File: InlineProgressIndicator.java    From consulo with Apache License 2.0 4 votes vote down vote up
private static Wrapper withBorder(InplaceButton button) {
  Wrapper wrapper = new Wrapper(button);
  wrapper.setBorder(JBUI.Borders.empty(0, 3, 0, 2));
  return wrapper;
}
 
Example #15
Source File: InlineProgressIndicator.java    From consulo with Apache License 2.0 4 votes vote down vote up
ProgressButton(InplaceButton button, Runnable updateAction) {
  this.button = button;
  this.updateAction = updateAction;
}