use of com.intellij.ui.components.JBOptionButton in project intellij-community by JetBrains.
the class DialogWrapper method createSouthPanel.
/**
* Creates panel located at the south of the content pane. By default that
* panel contains dialog's buttons. This default implementation uses <code>createActions()</code>
* and <code>createJButtonForAction(Action)</code> methods to construct the panel.
*
* @return south panel
*/
protected JComponent createSouthPanel() {
List<Action> actions = ContainerUtil.filter(createActions(), Condition.NOT_NULL);
List<Action> leftSideActions = ContainerUtil.newArrayList(createLeftSideActions());
if (!ApplicationInfo.contextHelpAvailable()) {
actions.remove(getHelpAction());
}
boolean hasHelpToMoveToLeftSide = false;
if (isRemoveHelpButton()) {
actions.remove(getHelpAction());
} else if (isMoveHelpButtonLeft() && actions.contains(getHelpAction())) {
hasHelpToMoveToLeftSide = true;
actions.remove(getHelpAction());
}
if (SystemInfo.isMac) {
Action macOtherAction = ContainerUtil.find(actions, MacOtherAction.class::isInstance);
if (macOtherAction != null) {
leftSideActions.add(macOtherAction);
actions.remove(macOtherAction);
}
// move ok action to the right
int okNdx = actions.indexOf(getOKAction());
if (okNdx >= 0 && okNdx != actions.size() - 1) {
actions.remove(getOKAction());
actions.add(getOKAction());
}
// move cancel action to the left
int cancelNdx = actions.indexOf(getCancelAction());
if (cancelNdx > 0) {
actions.remove(getCancelAction());
actions.add(0, getCancelAction());
}
} else if (UIUtil.isUnderGTKLookAndFeel() && actions.contains(getHelpAction())) {
leftSideActions.add(getHelpAction());
actions.remove(getHelpAction());
}
if (!UISettings.getShadowInstance().getAllowMergeButtons()) {
actions = flattenOptionsActions(actions);
leftSideActions = flattenOptionsActions(leftSideActions);
}
List<JButton> leftSideButtons = createButtons(leftSideActions);
List<JButton> rightSideButtons = createButtons(actions);
myButtonMap.clear();
for (JButton button : ContainerUtil.concat(leftSideButtons, rightSideButtons)) {
myButtonMap.put(button.getAction(), button);
if (button instanceof JBOptionButton) {
myOptionsButtons.add((JBOptionButton) button);
}
}
return createSouthPanel(leftSideButtons, rightSideButtons, hasHelpToMoveToLeftSide);
}
use of com.intellij.ui.components.JBOptionButton in project intellij-community by JetBrains.
the class DialogWrapper method createJOptionsButton.
@NotNull
private JButton createJOptionsButton(@NotNull OptionAction action) {
JBOptionButton optionButton = new JBOptionButton(action, action.getOptions());
optionButton.setOkToProcessDefaultMnemonics(false);
optionButton.setOptionTooltipText("Press " + KeymapUtil.getKeystrokeText(SHOW_OPTION_KEYSTROKE) + " to expand or use a mnemonic of a contained action");
final Set<JBOptionButton.OptionInfo> infos = optionButton.getOptionInfos();
for (final JBOptionButton.OptionInfo eachInfo : infos) {
if (eachInfo.getMnemonic() >= 0) {
final char mnemonic = (char) eachInfo.getMnemonic();
JRootPane rootPane = getPeer().getRootPane();
if (rootPane != null) {
new DumbAwareAction("Show JBOptionButton popup") {
@Override
public void actionPerformed(AnActionEvent e) {
final JBOptionButton buttonToActivate = eachInfo.getButton();
buttonToActivate.showPopup(eachInfo.getAction(), true);
}
}.registerCustomShortcutSet(MnemonicHelper.createShortcut(mnemonic), rootPane, myDisposable);
}
}
}
return optionButton;
}
Aggregations