mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-163208: colored default buttons (of dialogs)
This commit is contained in:
@@ -17,18 +17,19 @@ public class TBItemButton extends TBItem {
|
||||
|
||||
private int myUpdateOptions;
|
||||
|
||||
protected TBItemButton(@NotNull String uid) { this(uid, null, null, null, -1); }
|
||||
protected TBItemButton(@NotNull String uid) { this(uid, null, null, null, -1, 0); }
|
||||
|
||||
TBItemButton(@NotNull String uid, Icon icon, String text, NSTLibrary.Action action) {
|
||||
this(uid, icon, text, action, -1);
|
||||
}
|
||||
TBItemButton(@NotNull String uid, Icon icon, String text, NSTLibrary.Action action) { this(uid, icon, text, action, -1, 0); }
|
||||
|
||||
TBItemButton(@NotNull String uid, Icon icon, String text, NSTLibrary.Action action, int buttWidth) {
|
||||
TBItemButton(@NotNull String uid, Icon icon, String text, NSTLibrary.Action action, int buttWidth) { this(uid, icon, text, action, buttWidth, 0); }
|
||||
|
||||
TBItemButton(@NotNull String uid, Icon icon, String text, NSTLibrary.Action action, int buttWidth, int buttonFlags) {
|
||||
super(uid);
|
||||
myAction = action;
|
||||
myIcon = icon;
|
||||
myText = text;
|
||||
myWidth = buttWidth;
|
||||
myFlags = buttonFlags;
|
||||
}
|
||||
|
||||
void update(Icon icon, String text, NSTLibrary.Action action) { _update(icon, text, action, myWidth, myFlags); }
|
||||
|
||||
@@ -67,6 +67,13 @@ public class TouchBar implements NSTLibrary.ItemCreator {
|
||||
return butt;
|
||||
}
|
||||
|
||||
public TBItemButton addButton(Icon icon, String text, NSTLibrary.Action action, int buttonFlags) {
|
||||
final String uid = String.format("%s.button.%d", myName, myCounter++);
|
||||
final TBItemButton butt = new TBItemButton(uid, icon, text, action, -1, buttonFlags);
|
||||
myItems.add(butt);
|
||||
return butt;
|
||||
}
|
||||
|
||||
public TBItemButton addButton(Icon icon, String text, String actionId) {
|
||||
final String uid = String.format("%s.button.%d", myName, myCounter++);
|
||||
final TBItemButton butt = new TBItemButton(uid, icon, text, new PlatformAction(actionId));
|
||||
|
||||
@@ -15,6 +15,7 @@ import com.intellij.openapi.project.DumbAwareAction;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.project.ProjectManager;
|
||||
import com.intellij.openapi.project.ProjectManagerListener;
|
||||
import com.intellij.openapi.ui.DialogWrapper;
|
||||
import com.intellij.openapi.ui.OptionAction;
|
||||
import com.intellij.openapi.ui.popup.JBPopupListener;
|
||||
import com.intellij.openapi.ui.popup.LightweightWindowEvent;
|
||||
@@ -268,7 +269,8 @@ public class TouchBarsManager {
|
||||
}
|
||||
|
||||
final NSTLibrary.Action act = () -> ApplicationManager.getApplication().invokeLater(() -> jb.doClick(), ms);
|
||||
result.addButton(null, jb.getText(), act);
|
||||
final boolean isDefault = jb.getAction().getValue(DialogWrapper.DEFAULT_ACTION) != null;
|
||||
result.addButton(null, jb.getText(), act, isDefault ? NSTLibrary.BUTTON_FLAG_COLORED : 0);
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
@@ -8,6 +8,7 @@ import com.intellij.openapi.application.ModalityState;
|
||||
import com.intellij.openapi.application.impl.LaterInvocator;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.ui.DialogWrapper;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.ui.Gray;
|
||||
import com.intellij.ui.JBColor;
|
||||
@@ -143,7 +144,7 @@ class SheetMessage implements Disposable {
|
||||
}
|
||||
|
||||
LaterInvocator.enterModal(myWindow);
|
||||
final TouchBar tb = createModalMsgDlgTouchBar(buttons);
|
||||
final TouchBar tb = createModalMsgDlgTouchBar(buttons, defaultButton);
|
||||
TouchBarsManager.showTempTouchBar(tb);
|
||||
myWindow.setVisible(true);
|
||||
TouchBarsManager.closeTempTouchBar(tb);
|
||||
@@ -170,7 +171,7 @@ class SheetMessage implements Disposable {
|
||||
myWindow.dispose();
|
||||
}
|
||||
|
||||
private TouchBar createModalMsgDlgTouchBar(String[] buttons) {
|
||||
private TouchBar createModalMsgDlgTouchBar(String[] buttons, String defaultButton) {
|
||||
if (!TouchBarsManager.isTouchBarAvailable())
|
||||
return null;
|
||||
|
||||
@@ -179,7 +180,7 @@ class SheetMessage implements Disposable {
|
||||
final ModalityState ms = LaterInvocator.getCurrentModalityState();
|
||||
for (String sb: buttons) {
|
||||
final NSTLibrary.Action act = () -> ApplicationManager.getApplication().invokeLater(()->myController.setResultAndStartClose(sb), ms);
|
||||
result.addButton(null, sb, act);
|
||||
result.addButton(null, sb, act, Comparing.equal(sb, defaultButton) ? NSTLibrary.BUTTON_FLAG_COLORED : 0);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user