duplicate code

This commit is contained in:
Alexey Kudravtsev
2014-01-21 13:32:56 +04:00
parent ba9f665d2b
commit 31b1b182e5
2 changed files with 15 additions and 27 deletions
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
* Copyright 2000-2014 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.
@@ -426,13 +426,7 @@ public class Messages {
*/
@OkCancelResult
public static int showOkCancelDialog(Project project, String message, @NotNull String title, @NotNull String okText, @NotNull String cancelText, Icon icon) {
if (canShowMacSheetPanel()) {
int result = MacMessages.getInstance()
.showYesNoDialog(title, message, okText, cancelText, WindowManager.getInstance().suggestParentWindow(project));
return result == YES ? OK : CANCEL;
}
return showDialog(project, message, title, new String[]{okText, cancelText}, 0, icon) == 0 ? OK : CANCEL;
return showOkCancelDialog(project, message, title, okText, cancelText, icon, null);
}
/**
@@ -1218,22 +1212,12 @@ public class Messages {
actions[i].putValue(FOCUSED_ACTION, Boolean.TRUE);
}
assignMnemonic(option, actions[i]);
UIUtil.assignMnemonic(option, actions[i]);
}
return actions;
}
private static void assignMnemonic(@NotNull String option, Action action) {
int mnemoPos = option.indexOf("&");
if (mnemoPos >= 0 && mnemoPos < option.length() - 2) {
String mnemoChar = option.substring(mnemoPos + 1, mnemoPos + 2).trim();
if (mnemoChar.length() == 1) {
action.putValue(Action.MNEMONIC_KEY, Integer.valueOf(mnemoChar.charAt(0)));
}
}
}
@Override
public void doCancelAction() {
close(-1);
@@ -433,18 +433,22 @@ public class UIUtil {
return ArrayUtil.toStringArray(lines);
}
public static void setActionNameAndMnemonic(String text, Action action) {
int mnemoPos = text.indexOf('&');
if (mnemoPos >= 0 && mnemoPos < text.length() - 2) {
String mnemoChar = text.substring(mnemoPos + 1, mnemoPos + 2).trim();
if (mnemoChar.length() == 1) {
action.putValue(Action.MNEMONIC_KEY, Integer.valueOf((int)mnemoChar.charAt(0)));
}
}
public static void setActionNameAndMnemonic(@NotNull String text, @NotNull Action action) {
assignMnemonic(text, action);
text = text.replaceAll("&", "");
action.putValue(Action.NAME, text);
}
public static void assignMnemonic(@NotNull String text, @NotNull Action action) {
int mnemoPos = text.indexOf('&');
if (mnemoPos >= 0 && mnemoPos < text.length() - 2) {
String mnemoChar = text.substring(mnemoPos + 1, mnemoPos + 2).trim();
if (mnemoChar.length() == 1) {
action.putValue(Action.MNEMONIC_KEY, Integer.valueOf(mnemoChar.charAt(0)));
}
}
}
public static Font getLabelFont(@NotNull FontSize size) {
return getFont(size, null);