From b308b41268bf81351f4a97f29a42cf314e00c2f0 Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Thu, 15 Aug 2013 14:51:03 +0400 Subject: [PATCH] cleanup --- .../intellij/openapi/ui/ex/MessagesEx.java | 46 ++++++++++++++----- 1 file changed, 34 insertions(+), 12 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/openapi/ui/ex/MessagesEx.java b/platform/platform-impl/src/com/intellij/openapi/ui/ex/MessagesEx.java index 70e4870d8ef9..543efbfcdfd8 100644 --- a/platform/platform-impl/src/com/intellij/openapi/ui/ex/MessagesEx.java +++ b/platform/platform-impl/src/com/intellij/openapi/ui/ex/MessagesEx.java @@ -23,6 +23,7 @@ import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.ui.UIBundle; import com.intellij.util.ArrayUtil; +import org.jetbrains.annotations.NotNull; import javax.swing.*; @@ -52,34 +53,42 @@ public class MessagesEx extends Messages { return error(project, message, UIBundle.message("error.dialog.title")); } + @NotNull public static MessageInfo error(Project project, String message, String title) { return new MessageInfo(project, message, title); } - public static abstract class BaseDialogInfo { - private Project myProject; + public abstract static class BaseDialogInfo { + private final Project myProject; private String myMessage; private String myTitle; private Icon myIcon; - private String[] myOptions = new String[]{CommonBundle.getOkButtonText()}; + private String[] myOptions = {CommonBundle.getOkButtonText()}; private int myDefaultOption = 0; protected BaseDialogInfo(Project project) { myProject = project; } - public BaseDialogInfo(Project project, String message, String title, Icon icon) { + public BaseDialogInfo(Project project, @NotNull String message, String title, Icon icon) { this(project); myMessage = message; myTitle = title; myIcon = icon; } - public ThisClass setTitle(String title) { myTitle = title; return getThis(); } + @NotNull + public ThisClass setTitle(String title) { + myTitle = title; + return getThis(); + } - public String getMessage() { return myMessage; } + public String getMessage() { + return myMessage; + } - public ThisClass appendMessage(String message) { + @NotNull + public ThisClass appendMessage(@NotNull String message) { myMessage += message; return getThis(); } @@ -89,11 +98,16 @@ public class MessagesEx extends Messages { myDefaultOption = defaultOption; } + @NotNull protected abstract ThisClass getThis(); - public ThisClass setIcon(Icon icon) { myIcon = icon; return getThis(); } + @NotNull + public ThisClass setIcon(Icon icon) { + myIcon = icon; + return getThis(); + } - public void setMessage(String message) { + public void setMessage(@NotNull String message) { myMessage = message; } @@ -129,11 +143,11 @@ public class MessagesEx extends Messages { public void showLater() { ApplicationManager.getApplication().invokeLater(new Runnable() { + @Override public void run() { - if (ApplicationManager.getApplication().isDisposed()) return; showNow(); } - }); + }, ApplicationManager.getApplication().getDisposed()); } public int askYesNo() { @@ -146,6 +160,8 @@ public class MessagesEx extends Messages { return showNow(); } + @NotNull + @Override protected MessageInfo getThis() { return this; } @@ -161,6 +177,8 @@ public class MessagesEx extends Messages { setOptions(new String[]{CommonBundle.getOkButtonText()}, 0); } + @NotNull + @Override public ChoiceInfo getThis() { return this; } @@ -171,6 +189,7 @@ public class MessagesEx extends Messages { return getThis(); } + @Override public UserInput askUser() { ChooseDialog dialog = new ChooseDialog(getProject(), getMessage(), getTitle(), getIcon(), myChoises, myDefaultChoice, getOptions(), getDefaultOption()); dialog.setValidator(null); @@ -209,12 +228,15 @@ public class MessagesEx extends Messages { setOptions(new String[]{CommonBundle.getOkButtonText(), CommonBundle.getCancelButtonText()}, 0); } + @Override public UserInput askUser() { InputDialog dialog = new InputDialog(getProject(), getMessage(), getTitle(), getIcon(), myDefaultValue, null, getOptions(), getDefaultOption()); dialog.show(); return new UserInput(dialog.getTextField().getText(), dialog.getExitCode()); } + @NotNull + @Override public InputInfo getThis() { return this; } @@ -224,7 +246,7 @@ public class MessagesEx extends Messages { } } - public static abstract class BaseInputInfo extends BaseDialogInfo { + public abstract static class BaseInputInfo extends BaseDialogInfo { public BaseInputInfo(Project project) {