diff --git a/platform/platform-impl/src/com/intellij/internal/validation/CheckMessagesButtonsOrderAction.java b/platform/platform-impl/src/com/intellij/internal/validation/CheckMessagesButtonsOrderAction.java new file mode 100644 index 000000000000..87f3ad9db1a6 --- /dev/null +++ b/platform/platform-impl/src/com/intellij/internal/validation/CheckMessagesButtonsOrderAction.java @@ -0,0 +1,141 @@ +/* + * 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.internal.validation; + +import com.intellij.CommonBundle; +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() { + + + // Case 1 + + Messages.showDialog("unchecked unfocused checkbox, [Proceed], ____,Cancel, *Show ussages*", + "Message 1", new String [] {"Show usages", "Cancel", "Proceed"}, 0, 0, + Messages.getQuestionIcon(), new ProjectNewWindowDoNotAskOption()); + + // Case 2 + + Messages.showDialog("unchecked unfocused checkbox, [Proceed], ____,Cancel, *Show ussages*", + "Message 2", new String [] {"Show usages", "Cancel", "Proceed"}, 0, 1, + Messages.getQuestionIcon(), new ProjectNewWindowDoNotAskOption()); + + // Case 3 + + Messages.showDialog("unchecked unfocused checkbox, [Proceed], ____, *Cancel*, Show ussages", + "Message 3", new String [] {"Show usages", "Cancel", "Proceed"}, 1, 0, + Messages.getQuestionIcon(), new ProjectNewWindowDoNotAskOption()); + + // Case 4 + + Messages.showDialog("unchecked unfocused checkbox, [Proceed], ____, *Cancel*, Show ussages", + "Message 4", new String [] {"Show usages", "Cancel", "Proceed"}, 1, 1, + Messages.getQuestionIcon(), new ProjectNewWindowDoNotAskOption()); + + // Case 5 + + Messages.showDialog("[Proceed], ____, Cancel, *Show ussages*", + "Message 5", new String [] {"Show usages", "Cancel", "Proceed"}, 0, 1, + Messages.getQuestionIcon(), null); + + // Case 6 + + Messages.showYesNoCancelDialog("unchecked unfocused checkbox, [New Window], ____, Cancel, *This Window*", + "Message 6", + "This window", + "New Window", + CommonBundle.getCancelButtonText(), + Messages.getQuestionIcon(), + new ProjectNewWindowDoNotAskOption()); + + // Case 7 + + Messages.showDialog("[Variant 1], Variant 2, Variant 3, Cancel, *Ok*", + "Message 7", + new String[]{"Ok", "Cancel", "Variant 3", "Variant 2", "Variant 1"}, + 0, 1, Messages.getQuestionIcon(), null); + + // Case 8 + + Messages.showDialog( "unchecked unfocused checkbox, [Variant 1], Variant 2, Variant 3, Cancel, *Ok*", + "Message 8", + new String [] {"Ok", "Cancel", "Variant 3", "Variant 2", "Variant 1"}, + 0, 0, Messages.getQuestionIcon(), new ProjectNewWindowDoNotAskOption()); + + // Case 9 + + Messages.showDialog( "unchecked unfocused checkbox, [Variant 1], Variant 2, Variant 3, *Cancel*, Ok", + "Message 9", + new String [] {"Ok", "Cancel", "Variant 3", "Variant 2", "Variant 1"}, + 1, 1, Messages.getQuestionIcon(), new ProjectNewWindowDoNotAskOption()); + + // Case 10 + + Messages.showDialog( "unchecked unfocused checkbox, [Variant 1], Variant 2, Variant 3, Cancel, *Ok*", + "Message 10", + new String [] {"Ok", "Cancel", "Variant 3", "Variant 2", "Variant 1"}, + 0, 1, Messages.getQuestionIcon(), new ProjectNewWindowDoNotAskOption()); + + // Case 11 + + Messages.showDialog( "unchecked unfocused checkbox, [Variant 1], Variant 2, Variant 3, Cancel, *Ok*", + "Message 11", + new String [] {"Ok", "Cancel", "Variant 3", "Variant 2", "Variant 1"}, + 0, 1, Messages.getQuestionIcon(), new ProjectNewWindowDoNotAskOption()); + + // Case 12 + + Messages.showDialog( "unchecked unfocused checkbox, [Cancel], Variant 1, Variant 2, Variant 3, *Ok*", + "Message 12", + new String [] {"Ok", "Variant 3", "Variant 2", "Variant 1", "Cancel"}, + 0, 1, Messages.getQuestionIcon(), new ProjectNewWindowDoNotAskOption()); + + // Case 13 + + Messages.showDialog( "unchecked unfocused checkbox, [Cancel], Variant 1, Ok, Variant 2, Variant 3, *Ok*", + "Message 13", + new String [] {"Variant 3", "Variant 2", "Ok", "Variant 1", "Cancel"}, + 0, 1, Messages.getQuestionIcon(), new ProjectNewWindowDoNotAskOption()); + + } + }); + + } + }.start(); + + } +} diff --git a/platform/platform-impl/src/com/intellij/notification/impl/actions/CheckMessagesButtonsOrderAction.java b/platform/platform-impl/src/com/intellij/notification/impl/actions/CheckMessagesButtonsOrderAction.java deleted file mode 100644 index e622e71777d0..000000000000 --- a/platform/platform-impl/src/com/intellij/notification/impl/actions/CheckMessagesButtonsOrderAction.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * 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(); - - } -} diff --git a/platform/platform-impl/src/com/intellij/ui/messages/SheetController.java b/platform/platform-impl/src/com/intellij/ui/messages/SheetController.java index 4dff65a20d06..35ae51bda1c6 100755 --- a/platform/platform-impl/src/com/intellij/ui/messages/SheetController.java +++ b/platform/platform-impl/src/com/intellij/ui/messages/SheetController.java @@ -111,6 +111,9 @@ public class SheetController { myResult = null; + int defaultButtonIndex = -1; + int focusedButtonIndex = -1; + for (int i = 0; i < buttons.length; i++) { String buttonTitle = buttonTitles[i]; @@ -119,13 +122,18 @@ public class SheetController { handleMnemonics(i, buttonTitle); if (buttonTitle.equals(defaultButtonTitle)) { - myDefaultButton = buttons[i]; + defaultButtonIndex = i; } if (buttonTitle.equals(focusedButton)) { - myFocusedButton = buttons[i]; + focusedButtonIndex = i; } } + myFocusedButton = (focusedButtonIndex == -1) ? buttons[buttons.length - 1] : buttons[focusedButtonIndex]; + myDefaultButton = (defaultButtonIndex == -1 && focusedButtonIndex != defaultButtonIndex) ? buttons[0] : buttons[defaultButtonIndex]; + + myDefaultButton = buttons[0]; + if (myFocusedButton == null) { myFocusedButton = myDefaultButton; } diff --git a/platform/platform-resources/src/idea/PlatformActions.xml b/platform/platform-resources/src/idea/PlatformActions.xml index d1f98e7d62ae..e9ee321e85f1 100644 --- a/platform/platform-resources/src/idea/PlatformActions.xml +++ b/platform/platform-resources/src/idea/PlatformActions.xml @@ -635,7 +635,7 @@ -