mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-194199: replace 'esc' with 'cross'-button for popups, vcs-diff, editor-search
This commit is contained in:
@@ -174,7 +174,7 @@ class BuildUtils {
|
||||
}
|
||||
|
||||
static TouchBar createMessageDlgBar(@NotNull String[] buttons, @NotNull Runnable[] actions, String defaultButton) {
|
||||
final TouchBar result = new TouchBar("message_dlg_bar", false, false);
|
||||
final TouchBar result = new TouchBar("message_dlg_bar", false, false, false);
|
||||
final TBItemGroup gr = result.addGroup();
|
||||
final ItemsContainer group = gr.getContainer();
|
||||
|
||||
@@ -206,7 +206,7 @@ class BuildUtils {
|
||||
|
||||
// creates releaseOnClose touchbar
|
||||
static TouchBar createButtonsBar(List<JButton> jbuttons) {
|
||||
final TouchBar result = new TouchBar("dialog_buttons", false, false);
|
||||
final TouchBar result = new TouchBar("dialog_buttons", false, false, false);
|
||||
final ModalityState ms = LaterInvocator.getCurrentModalityState();
|
||||
|
||||
// 1. add option buttons (at left)
|
||||
@@ -262,7 +262,7 @@ class BuildUtils {
|
||||
|
||||
// creates releaseOnClose touchbar
|
||||
static TouchBar createScrubberBarFromPopup(@NotNull ListPopupImpl listPopup) {
|
||||
final TouchBar result = new TouchBar("popup_scrubber_bar" + listPopup, false, false);
|
||||
final TouchBar result = new TouchBar("popup_scrubber_bar" + listPopup, true, false, true);
|
||||
|
||||
final TBItemScrubber scrub = result.addScrubber();
|
||||
final ModalityState ms = LaterInvocator.getCurrentModalityState();
|
||||
@@ -292,7 +292,7 @@ class BuildUtils {
|
||||
|
||||
// creates releaseOnClose touchbar
|
||||
static TouchBar createStopRunningBar(List<Pair<RunContentDescriptor, Runnable>> stoppableDescriptors) {
|
||||
final TouchBar tb = new TouchBar("select_running_configuration_to_stop", true, true);
|
||||
final TouchBar tb = new TouchBar("select_running_configuration_to_stop", true, true, true);
|
||||
tb.addButton().setText("Stop All").setActionOnEDT(() -> {
|
||||
stoppableDescriptors.forEach((pair) -> { pair.second.run(); });
|
||||
});
|
||||
|
||||
@@ -15,6 +15,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
class TouchBar implements NSTLibrary.ItemCreator {
|
||||
@@ -40,10 +41,10 @@ class TouchBar implements NSTLibrary.ItemCreator {
|
||||
}
|
||||
|
||||
TouchBar(@NotNull String touchbarName, boolean replaceEsc) {
|
||||
this(touchbarName, replaceEsc, false);
|
||||
this(touchbarName, replaceEsc, false, false);
|
||||
}
|
||||
|
||||
TouchBar(@NotNull String touchbarName, boolean replaceEsc, boolean autoClose) {
|
||||
TouchBar(@NotNull String touchbarName, boolean replaceEsc, boolean autoClose, boolean emulateESC) {
|
||||
if (autoClose) {
|
||||
myItemListener = (src, evcode) -> {
|
||||
// NOTE: called from AppKit thread
|
||||
@@ -54,7 +55,18 @@ class TouchBar implements NSTLibrary.ItemCreator {
|
||||
|
||||
myItems = new ItemsContainer(touchbarName, myItemListener);
|
||||
if (replaceEsc)
|
||||
myCustomEsc = new TBItemButton(touchbarName + "_custom_esc_button", myItemListener).setIcon(AllIcons.Actions.Cancel).setThreadSafeAction(this::_closeSelf);
|
||||
myCustomEsc = new TBItemButton(touchbarName + "_custom_esc_button", myItemListener).setIcon(AllIcons.Actions.Cancel).setThreadSafeAction(()-> {
|
||||
_closeSelf();
|
||||
if (emulateESC) {
|
||||
try {
|
||||
Robot robot = new Robot();
|
||||
robot.keyPress(KeyEvent.VK_ESCAPE);
|
||||
robot.keyRelease(KeyEvent.VK_ESCAPE);
|
||||
} catch (AWTException e) {
|
||||
LOG.error(e);
|
||||
}
|
||||
}
|
||||
});
|
||||
else
|
||||
myCustomEsc = null;
|
||||
|
||||
@@ -77,8 +89,8 @@ class TouchBar implements NSTLibrary.ItemCreator {
|
||||
return result;
|
||||
}
|
||||
|
||||
static TouchBar buildFromGroup(@NotNull String touchbarName, @NotNull ActionGroup actions, boolean replaceEsc) {
|
||||
final TouchBar result = new TouchBar(touchbarName, replaceEsc);
|
||||
static TouchBar buildFromGroup(@NotNull String touchbarName, @NotNull ActionGroup actions, boolean replaceEsc, boolean emulateESC) {
|
||||
final TouchBar result = new TouchBar(touchbarName, replaceEsc, false, emulateESC);
|
||||
addActionGroup(result, actions);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -272,7 +272,7 @@ public class TouchBarsManager {
|
||||
ed.containerSearch.release();
|
||||
}
|
||||
|
||||
ed.containerSearch = new BarContainer(BarType.EDITOR_SEARCH, TouchBar.buildFromGroup("editor_search_" + header, actions, false), null, header);
|
||||
ed.containerSearch = new BarContainer(BarType.EDITOR_SEARCH, TouchBar.buildFromGroup("editor_search_" + header, actions, true, true), null, header);
|
||||
ourStack.showContainer(ed.containerSearch);
|
||||
}
|
||||
}
|
||||
@@ -314,7 +314,7 @@ public class TouchBarsManager {
|
||||
_findAllTouchbarProviders(actions, contentPane);
|
||||
if (!actions.isEmpty()) {
|
||||
final ActionGroup ag = actions.values().iterator().next();
|
||||
final TouchBar tb = TouchBar.buildFromGroup("dialog_with_actions", ag, false);
|
||||
final TouchBar tb = TouchBar.buildFromGroup("dialog_with_actions", ag, true, true);
|
||||
bc = new BarContainer(btype, tb, null, contentPane);
|
||||
final BarContainer fbc = bc;
|
||||
ag.addPropertyChangeListener(new PropertyChangeListener() {
|
||||
|
||||
Reference in New Issue
Block a user