From 31b1b182e5b1e92bb0bcd3fc6cb016a2ee7c648a Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Fri, 17 Jan 2014 16:37:16 +0400 Subject: [PATCH] duplicate code --- .../src/com/intellij/openapi/ui/Messages.java | 22 +++---------------- .../util/src/com/intellij/util/ui/UIUtil.java | 20 ++++++++++------- 2 files changed, 15 insertions(+), 27 deletions(-) diff --git a/platform/platform-api/src/com/intellij/openapi/ui/Messages.java b/platform/platform-api/src/com/intellij/openapi/ui/Messages.java index e95efbc12a66..9cad5112adc9 100644 --- a/platform/platform-api/src/com/intellij/openapi/ui/Messages.java +++ b/platform/platform-api/src/com/intellij/openapi/ui/Messages.java @@ -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); diff --git a/platform/util/src/com/intellij/util/ui/UIUtil.java b/platform/util/src/com/intellij/util/ui/UIUtil.java index edb846107878..95d108478841 100644 --- a/platform/util/src/com/intellij/util/ui/UIUtil.java +++ b/platform/util/src/com/intellij/util/ui/UIUtil.java @@ -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);