IDEA-123409 Sheet dialogs: Order of buttons and their sizes and positions are incorrect

This commit is contained in:
Denis Fokin
2015-02-19 18:23:51 +03:00
parent b5985c493c
commit bbb76813f5
4 changed files with 76 additions and 11 deletions
@@ -0,0 +1,63 @@
/*
* Copyright 2000-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.notification.impl.actions;
import com.intellij.CommonBundle;
import com.intellij.ide.IdeBundle;
import com.intellij.ide.impl.ProjectNewWindowDoNotAskOption;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.project.DumbAware;
import com.intellij.openapi.ui.Messages;
import javax.swing.*;
/**
* @author Denis Fokin
*/
public class CheckMessagesButtonsOrderAction extends AnAction implements DumbAware {
@Override
public void actionPerformed(AnActionEvent e) {
new Thread() {
@Override
public void run() {
super.run();
//noinspection SSBasedInspection
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
String message = "Proceed - focused, [space] ,Cancel - Nothing, Show ussages - default";
String[] options = {"Show usages", "Cancel", "Proceed"};
Messages.showDialog(message, "First Message", options, 0, 1, Messages.getQuestionIcon(), null);
Messages.showYesNoCancelDialog("unchecked unfocused checkbox, Yes - focused, space, Cancel, No Text - default",
IdeBundle.message("title.open.project"),
"This window",
"New Window",
CommonBundle.getCancelButtonText(),
Messages.getQuestionIcon(),
new ProjectNewWindowDoNotAskOption());
}
});
}
}.start();
}
}
@@ -49,7 +49,9 @@ public class JBMacMessages extends MacMessagesEmulation {
window = getForemostWindow(null);
}
SheetMessage sheetMessage = new SheetMessage(window, title, message, UIUtil.getQuestionIcon(),
new String [] {defaultButton, alternateButton, otherButton}, doNotAskOption, defaultButton, alternateButton);
new String [] {defaultButton, otherButton, alternateButton},
doNotAskOption, defaultButton, alternateButton);
String resultString = sheetMessage.getResult();
int result = resultString.equals(defaultButton) ? Messages.YES : resultString.equals(alternateButton) ? Messages.NO : Messages.CANCEL;
if (doNotAskOption != null) {
@@ -73,12 +75,8 @@ public class JBMacMessages extends MacMessagesEmulation {
Icon icon = errorStyle ? UIUtil.getErrorIcon() : UIUtil.getInformationIcon();
if (focusedOptionIndex != -1) {
focusedOptionIndex = (defaultOptionIndex == focusedOptionIndex) ? buttons.length - 1 : focusedOptionIndex;
}
final String defaultOptionTitle = defaultOptionIndex == -1 ? null : buttons[defaultOptionIndex];
final String focusedButtonTitle = focusedOptionIndex == -1 ? null : buttons[focusedOptionIndex];
final String defaultOptionTitle = defaultOptionIndex != -1 ? buttons[buttons.length - 1 - defaultOptionIndex] : null;
final String focusedButtonTitle = focusedOptionIndex != -1 ? buttons[buttons.length - 1 - focusedOptionIndex] : null;
final SheetMessage sheetMessage = new SheetMessage(window, title, message, icon, buttons, doNotAskDialogOption, defaultOptionTitle, focusedButtonTitle);
String result = sheetMessage.getResult();
@@ -171,12 +171,11 @@ public class SheetController {
}
void requestFocus() {
final JComponent focusedComponent = (myDoNotAskOption == null) ? myFocusedButton : doNotAskCheckBox;
if (focusedComponent == null) return; // it might be we have only one button. it is a default one in that case
if (myFocusedButton == null) return; // it might be we have only one button. it is a default one in that case
if (SystemInfo.isAppleJvm) {
focusedComponent.requestFocus();
myFocusedButton.requestFocus();
} else {
focusedComponent.requestFocusInWindow();
myFocusedButton.requestFocusInWindow();
}
}
@@ -629,11 +629,16 @@
<action id="LaggingMode" internal="true" class="com.intellij.internal.ToggleLaggingModeAction" text="Lagging mode"/>
<separator/>
<group id="Internal.UI" popup="true" text="&amp;UI">
<action id="GoToClassPopupStressTest" internal="true" class="com.intellij.internal.validation.GoToClassPopupStressTestAction"
text="Stress Test Go To Popup"/>
<action id="NotificationTestAction" internal="true" class="com.intellij.notification.impl.actions.NotificationTestAction"
text="Add Test Notification"/>
<action id="TestMessageBoxAction" internal="true" class="com.intellij.diagnostic.TestMessageBoxAction" text="Show Test Dialog"/>
<separator/>
<group id="Internal.focusAndModality" popup="true" text="Focus and modality testing">
<action id="CheckMessagesButtonsOrderAction" internal="true" class="com.intellij.notification.impl.actions.CheckMessagesButtonsOrderAction"
text="Check Messages Buttons Order"/>
<action id="ShowDelayedMessageInternalAction" internal="true" class="com.intellij.notification.impl.actions.ShowDelayedMessageInternalAction"
text="Show Delayed Message"/>
<action id="ManualMacMessagesTest" internal="true" class="com.intellij.internal.validation.MacMessagesTest"