IDEA-163208: disabled default buttons can't be colored

This commit is contained in:
Artem Bochkarev
2018-06-18 18:43:53 +07:00
parent 158b2a84b8
commit ae4237f9b6
2 changed files with 13 additions and 8 deletions
@@ -181,7 +181,7 @@ class BuildUtils {
if (defIndex >= 0)
group.addButton().setText(DialogWrapper.extractMnemonic(buttons[defIndex]).second).setThreadSafeAction(actions[defIndex])
.setFlags(false, false, true);
.setColored(true);
result.setPrincipal(gr);
result.selectVisibleItemsToShow();
@@ -232,7 +232,7 @@ class BuildUtils {
if (jbdef != null) {
final AnAction anAct = _createAnAction(jbdef.getAction(), jbdef, false);
if (anAct != null)
group.addAnActionButton(anAct, TBItemAnActionButton.SHOWMODE_TEXT_ONLY, ms).setComponent(jbdef).setFlags(false, false, true);
group.addAnActionButton(anAct, TBItemAnActionButton.SHOWMODE_TEXT_ONLY, ms).setComponent(jbdef).setColored(true);
}
result.selectVisibleItemsToShow();
@@ -123,10 +123,8 @@ class TBItemButton extends TBItem {
return this;
}
TBItemButton setFlags(boolean isSelected, boolean isDisabled, boolean isColored) {
int flags = _applyFlag(myFlags, isSelected, NSTLibrary.BUTTON_FLAG_SELECTED);
flags = _applyFlag(flags, isDisabled, NSTLibrary.BUTTON_FLAG_DISABLED);
flags = _applyFlag(flags, isColored, NSTLibrary.BUTTON_FLAG_COLORED);
TBItemButton setColored(boolean isColored) {
final int flags = _applyFlag(myFlags, isColored, NSTLibrary.BUTTON_FLAG_COLORED);
if (flags != myFlags) {
myFlags = flags;
if (myNativePeer != ID.NIL) {
@@ -183,14 +181,21 @@ class TBItemButton extends TBItem {
final String text = (myUpdateOptions & NSTLibrary.BUTTON_UPDATE_TEXT) != 0 ? myText : null;
final NSTLibrary.Action callback = (myUpdateOptions & NSTLibrary.BUTTON_UPDATE_ACTION) != 0 ? myNativeCallback : null;
// System.out.printf("_updateNativePeer, button [%s]: updateOptions 0x%X\n", myUid, myUpdateOptions);
NST.updateButton(myNativePeer, myUpdateOptions, myWidth, myFlags, text, icon, callback);
final int validFlags = _validateFlags();
NST.updateButton(myNativePeer, myUpdateOptions, myWidth, validFlags, text, icon, callback);
myUpdateOptions = 0;
}
@Override
synchronized protected ID _createNativePeer() {
// System.out.printf("_createNativePeer, button [%s]\n", myUid);
return NST.createButton(myUid, myWidth, myFlags, myText, myIcon, myNativeCallback);
return NST.createButton(myUid, myWidth, _validateFlags(), myText, myIcon, myNativeCallback);
}
private int _validateFlags() {
if ((myFlags & NSTLibrary.BUTTON_FLAG_COLORED) != 0 && (myFlags & NSTLibrary.BUTTON_FLAG_DISABLED) != 0)
return myFlags & ~NSTLibrary.BUTTON_FLAG_COLORED;
return myFlags;
}
private static int _applyFlag(int src, boolean include, int flag) {