diff --git a/platform/platform-api/src/com/intellij/openapi/ui/MessageDialogBuilder.java b/platform/platform-api/src/com/intellij/openapi/ui/MessageDialogBuilder.java index 9bf9ab6ad79e..279cb893ecd0 100644 --- a/platform/platform-api/src/com/intellij/openapi/ui/MessageDialogBuilder.java +++ b/platform/platform-api/src/com/intellij/openapi/ui/MessageDialogBuilder.java @@ -1,18 +1,4 @@ -/* - * Copyright 2000-2016 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. - */ +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.openapi.ui; import com.intellij.openapi.project.Project; @@ -23,6 +9,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import javax.swing.*; +import java.awt.*; public abstract class MessageDialogBuilder { protected final String myMessage; @@ -30,7 +17,6 @@ public abstract class MessageDialogBuilder { protected String myYesText; protected String myNoText; - protected Project myProject; protected Icon myIcon; protected DialogWrapper.DoNotAskOption myDoNotAskOption; @@ -100,13 +86,14 @@ public abstract class MessageDialogBuilder { String noText = ObjectUtils.chooseNotNull(myNoText, Messages.NO_BUTTON); try { if (Messages.canShowMacSheetPanel() && !Messages.isApplicationInUnitTestOrHeadless()) { - return MacMessages.getInstance().showYesNoDialog(myTitle, myMessage, yesText, noText, WindowManager.getInstance().suggestParentWindow(myProject), myDoNotAskOption); + Window window = WindowManager.getInstance().suggestParentWindow(myProject); + return MacMessages.getInstance().showYesNoDialog(myTitle, myMessage, yesText, noText, window, myDoNotAskOption); } } - catch (Exception ignored) { - } + catch (Exception ignored) { } - return Messages.showDialog(myProject, myMessage, myTitle, new String[]{yesText, noText}, 0, myIcon, myDoNotAskOption) == 0 ? Messages.YES : Messages.NO; + String[] options = {yesText, noText}; + return Messages.showDialog(myProject, myMessage, myTitle, options, 0, myIcon, myDoNotAskOption) == 0 ? Messages.YES : Messages.NO; } public boolean isYes() { @@ -138,14 +125,15 @@ public abstract class MessageDialogBuilder { String cancelText = ObjectUtils.chooseNotNull(myCancelText, Messages.CANCEL_BUTTON); try { if (Messages.canShowMacSheetPanel() && !Messages.isApplicationInUnitTestOrHeadless()) { - return MacMessages.getInstance().showYesNoCancelDialog(myTitle, myMessage, yesText, noText, cancelText, WindowManager.getInstance().suggestParentWindow(myProject), myDoNotAskOption); + Window window = WindowManager.getInstance().suggestParentWindow(myProject); + return MacMessages.getInstance().showYesNoCancelDialog(myTitle, myMessage, yesText, noText, cancelText, window, myDoNotAskOption); } } catch (Exception ignored) {} - int buttonNumber = Messages.showDialog(myProject, myMessage, myTitle, new String[]{yesText, noText, cancelText}, 0, myIcon, myDoNotAskOption); + String[] options = {yesText, noText, cancelText}; + int buttonNumber = Messages.showDialog(myProject, myMessage, myTitle, options, 0, myIcon, myDoNotAskOption); return buttonNumber == 0 ? Messages.YES : buttonNumber == 1 ? Messages.NO : Messages.CANCEL; - } } -} +} \ No newline at end of file