mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-163208: add close button into 'stop running' panel
This commit is contained in:
@@ -105,8 +105,7 @@ public class StopAction extends DumbAwareAction implements AnAction.TransparentU
|
||||
}
|
||||
|
||||
if (e.getPlace().equals(ActionPlaces.TOUCHBAR_GENERAL)) {
|
||||
final TouchBar tb = createStopSelectTouchBar(stoppableDescriptors);
|
||||
TouchBarsManager.showTempTouchBar(tb);
|
||||
_showStopRunningBar(stoppableDescriptors);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -263,25 +262,30 @@ public class StopAction extends DumbAwareAction implements AnAction.TransparentU
|
||||
|| processHandler instanceof KillableProcess && ((KillableProcess)processHandler).canKillProcess());
|
||||
}
|
||||
|
||||
private static TouchBar createStopSelectTouchBar(List<RunContentDescriptor> stoppableDescriptors) {
|
||||
private static void _showStopRunningBar(List<RunContentDescriptor> stoppableDescriptors) {
|
||||
if (!TouchBarsManager.isTouchBarAvailable())
|
||||
return;
|
||||
|
||||
final TouchBar tb;
|
||||
try (NSAutoreleaseLock lock = new NSAutoreleaseLock()) {
|
||||
TouchBar result = new TouchBar("select_running_to_stop", false);
|
||||
result.addButton(null, "Stop all", () -> {
|
||||
tb = new TouchBar("select_running_to_stop", true, true);
|
||||
tb.addButton(null, "Stop all", () -> {
|
||||
for (RunContentDescriptor sd : stoppableDescriptors)
|
||||
ExecutionManagerImpl.stopProcess(sd);
|
||||
TouchBarsManager.closeTouchBar(result, true);
|
||||
TouchBarsManager.closeTouchBar(tb, true);
|
||||
});
|
||||
final TBItemScrubber stopScrubber = result.addScrubber();
|
||||
final TBItemScrubber stopScrubber = tb.addScrubber();
|
||||
List<TBItemScrubber.ItemData> scrubItems = new ArrayList<>();
|
||||
for (RunContentDescriptor sd : stoppableDescriptors) {
|
||||
scrubItems.add(new TBItemScrubber.ItemData(sd.getIcon(), sd.getDisplayName(), () -> {
|
||||
ExecutionManagerImpl.stopProcess(sd);
|
||||
TouchBarsManager.closeTouchBar(result, true);
|
||||
TouchBarsManager.closeTouchBar(tb, true);
|
||||
}));
|
||||
}
|
||||
stopScrubber.setItems(scrubItems);
|
||||
return result;
|
||||
}
|
||||
|
||||
TouchBarsManager.showStopRunningBar(tb);
|
||||
}
|
||||
|
||||
abstract static class HandlerItem {
|
||||
|
||||
@@ -428,7 +428,7 @@ public class DialogWrapperPeerImpl extends DialogWrapperPeer {
|
||||
myDialog.getWindow().setAutoRequestFocus(true);
|
||||
|
||||
if (myTouchBarButtons != null && myProject != null)
|
||||
myTouchBar = TouchBarsManager.showTempButtonsBar(myTouchBarButtons, myProject);
|
||||
myTouchBar = TouchBarsManager.showDlgButtonsBar(myTouchBarButtons, myProject);
|
||||
|
||||
try {
|
||||
myDialog.show();
|
||||
|
||||
@@ -20,6 +20,7 @@ public class TouchBar implements NSTLibrary.ItemCreator {
|
||||
protected ID myNativePeer; // java wrapper holds native object
|
||||
protected long myCounter = 0;
|
||||
protected final List<TBItem> myItems = new ArrayList<>();
|
||||
protected final boolean myReleaseOnClose;
|
||||
|
||||
protected final TBItemButton myCustomEsc;
|
||||
|
||||
@@ -29,12 +30,18 @@ public class TouchBar implements NSTLibrary.ItemCreator {
|
||||
myName = "EMPTY_STUB_TOUCHBAR";
|
||||
myCustomEsc = null;
|
||||
myNativePeer = ID.NIL;
|
||||
myReleaseOnClose = false;
|
||||
}
|
||||
|
||||
public TouchBar(@NotNull String touchbarName, boolean replaceEsc) {
|
||||
this(touchbarName, replaceEsc, false);
|
||||
}
|
||||
|
||||
public TouchBar(@NotNull String touchbarName, boolean replaceEsc, boolean releaseOnClose) {
|
||||
myName = touchbarName;
|
||||
myCustomEsc = replaceEsc ? new TBItemButton(genNewID("esc"), AllIcons.Actions.Cancel, null, this::_closeSelf) : null;
|
||||
myNativePeer = NST.createTouchBar(touchbarName, this, myCustomEsc != null ? myCustomEsc.myUid : null);
|
||||
myReleaseOnClose = releaseOnClose;
|
||||
}
|
||||
|
||||
public boolean isManualClose() { return myCustomEsc != null; }
|
||||
@@ -149,7 +156,10 @@ public class TouchBar implements NSTLibrary.ItemCreator {
|
||||
public void setPrincipal(@NotNull TBItem item) { NST.setPrincipal(myNativePeer, item.myUid); }
|
||||
|
||||
public void onBeforeShow() {}
|
||||
public void onHide() {}
|
||||
public void onHide() {
|
||||
if (myReleaseOnClose)
|
||||
release();
|
||||
}
|
||||
|
||||
String genNewID(String desc) { return String.format("%s.%s.%d", myName, desc, myCounter++); }
|
||||
|
||||
|
||||
@@ -85,8 +85,6 @@ public class TouchBarActionBase extends TouchBarProjectBase {
|
||||
});
|
||||
}
|
||||
|
||||
public void addActionGroupButtons(ActionGroup actionGroup, ModalityState modality, int showMode) { addActionGroupButtons(actionGroup, modality, showMode, null, null); }
|
||||
|
||||
public void addActionGroupButtons(ActionGroup actionGroup, ModalityState modality, int showMode, INodeFilter filter, ICustomizer customizer) {
|
||||
_traverse(actionGroup, new ILeafVisitor() {
|
||||
private int mySeparatorCounter = 0;
|
||||
|
||||
@@ -91,7 +91,7 @@ public class TouchBarsManager {
|
||||
);
|
||||
}
|
||||
|
||||
public static TouchBar showTempButtonsBar(List<JButton> jbuttons, Project project) {
|
||||
public static TouchBar showDlgButtonsBar(List<JButton> jbuttons, Project project) {
|
||||
final TouchBar tb = _createButtonsBar(jbuttons, project);
|
||||
_showTempTouchBar(tb, BarType.DIALOG);
|
||||
return tb;
|
||||
@@ -220,7 +220,7 @@ public class TouchBarsManager {
|
||||
}
|
||||
|
||||
|
||||
synchronized public static void showTempTouchBar(TouchBar tb) {
|
||||
synchronized public static void showStopRunningBar(TouchBar tb) {
|
||||
_showTempTouchBar(tb, BarType.DIALOG);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user