diff options
Diffstat (limited to 'platform/platform-api/src/com/intellij/openapi/ui')
4 files changed, 93 insertions, 20 deletions
diff --git a/platform/platform-api/src/com/intellij/openapi/ui/DialogWrapper.java b/platform/platform-api/src/com/intellij/openapi/ui/DialogWrapper.java index 741f67dee2c4..a291ab32e950 100644 --- a/platform/platform-api/src/com/intellij/openapi/ui/DialogWrapper.java +++ b/platform/platform-api/src/com/intellij/openapi/ui/DialogWrapper.java @@ -2001,12 +2001,19 @@ public abstract class DialogWrapper { */ public interface DoNotAskOption { + /** + * @return default selection state of checkbox (false -> checkbox selected) + */ boolean isToBeShown(); - void setToBeShown(boolean value, int exitCode); + /** + * @param toBeShown - if dialog should be shown next time (checkbox selected -> false) + * @param exitCode of corresponding DialogWrapper + */ + void setToBeShown(boolean toBeShown, int exitCode); /** - * Should be 'true' for checkbox to be visible. + * @return true if checkbox should be shown */ boolean canBeHidden(); diff --git a/platform/platform-api/src/com/intellij/openapi/ui/MasterDetailsComponent.java b/platform/platform-api/src/com/intellij/openapi/ui/MasterDetailsComponent.java index a262ea0a3b85..547fa03e438d 100644 --- a/platform/platform-api/src/com/intellij/openapi/ui/MasterDetailsComponent.java +++ b/platform/platform-api/src/com/intellij/openapi/ui/MasterDetailsComponent.java @@ -131,7 +131,7 @@ public abstract class MasterDetailsComponent implements Configurable, DetailsCom protected MasterDetailsComponent(MasterDetailsState state) { myState = state; - mySplitter = Registry.is("ide.new.project.settings") ? new OnePixelSplitter(false, .2f) : new JBSplitter(false, .2f); + mySplitter = isNewProjectSettings() ? new OnePixelSplitter(false, .2f) : new JBSplitter(false, .2f); mySplitter.setSplitterProportionKey("ProjectStructure.SecondLevelElements"); mySplitter.setHonorComponentsMinimumSize(true); @@ -139,6 +139,20 @@ public abstract class MasterDetailsComponent implements Configurable, DetailsCom reInitWholePanelIfNeeded(); } + private boolean isNewProjectSettings() { + if (!Registry.is("ide.new.project.settings")) { + return false; + } + try { + // assume that only project structure dialog uses the following base class for details: + String name = "com.intellij.openapi.roots.ui.configuration.projectRoot.BaseStructureConfigurable"; + return Class.forName(name).isAssignableFrom(getClass()); + } + catch (ClassNotFoundException ignored) { + return false; + } + } + protected void reInitWholePanelIfNeeded() { if (!myToReInitWholePanel) return; @@ -170,7 +184,7 @@ public abstract class MasterDetailsComponent implements Configurable, DetailsCom } }; - if (Registry.is("ide.new.project.settings")) { + if (isNewProjectSettings()) { ToolbarDecorator decorator = ToolbarDecorator.createDecorator(myTree); DefaultActionGroup group = createToolbarActionGroup(); if (group != null) { @@ -281,7 +295,7 @@ public abstract class MasterDetailsComponent implements Configurable, DetailsCom } private void initToolbar() { - if (Registry.is("ide.new.project.settings")) return; + if (isNewProjectSettings()) return; DefaultActionGroup group = createToolbarActionGroup(); if (group != null) { final JComponent component = ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, group, true).getComponent(); 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 1a07b33d696d..e963871cfd5f 100644 --- a/platform/platform-api/src/com/intellij/openapi/ui/Messages.java +++ b/platform/platform-api/src/com/intellij/openapi/ui/Messages.java @@ -377,6 +377,33 @@ public class Messages { * @return {@link #YES} if user pressed "Yes" or {@link #NO} if user pressed "No" button. */ @YesNoResult + public static int showYesNoDialog(@Nullable Project project, + String message, + @NotNull String title, + @NotNull String yesText, + @NotNull String noText, + @Nullable Icon icon, + @Nullable DialogWrapper.DoNotAskOption doNotAskOption) { + try { + if (canShowMacSheetPanel()) { + return MacMessages.getInstance() + .showYesNoDialog(title, message, yesText, noText, WindowManager.getInstance().suggestParentWindow(project), doNotAskOption); + } + } + catch (Exception exception) { + LOG.error(exception); + } + + int result = showDialog(project, message, title, new String[]{yesText, noText}, 0, icon, doNotAskOption) == 0 ? YES : NO; + //noinspection ConstantConditions + LOG.assertTrue(result == YES || result == NO, result); + return result; + } + + /** + * @return {@link #YES} if user pressed "Yes" or {@link #NO} if user pressed "No" button. + */ + @YesNoResult public static int showYesNoDialog(@Nullable Project project, String message, @NotNull String title, @Nullable Icon icon) { try { if (canShowMacSheetPanel()) { @@ -394,6 +421,31 @@ public class Messages { return result; } + /** + * @return {@link #YES} if user pressed "Yes" or {@link #NO} if user pressed "No" button. + */ + @YesNoResult + public static int showYesNoDialog(@Nullable Project project, + String message, + @NotNull String title, + @Nullable Icon icon, + @Nullable DialogWrapper.DoNotAskOption doNotAskOption) { + try { + if (canShowMacSheetPanel()) { + return MacMessages.getInstance().showYesNoDialog(title, message, YES_BUTTON, NO_BUTTON, + WindowManager.getInstance().suggestParentWindow(project), doNotAskOption); + } + } + catch (Exception exception) { + LOG.error(exception); + } + + int result = showYesNoDialog(project, message, title, YES_BUTTON, NO_BUTTON, icon, doNotAskOption); + + LOG.assertTrue(result == YES || result == NO, result); + return result; + } + /** * @return {@link #YES} if user pressed "Yes" or {@link #NO} if user pressed "No" button. diff --git a/platform/platform-api/src/com/intellij/openapi/ui/popup/util/BaseListPopupStep.java b/platform/platform-api/src/com/intellij/openapi/ui/popup/util/BaseListPopupStep.java index 2a55c3bd342a..3bb5302e7f2e 100644 --- a/platform/platform-api/src/com/intellij/openapi/ui/popup/util/BaseListPopupStep.java +++ b/platform/platform-api/src/com/intellij/openapi/ui/popup/util/BaseListPopupStep.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2011 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. @@ -32,16 +32,16 @@ public class BaseListPopupStep<T> extends BaseStep<T> implements ListPopupStep<T private List<Icon> myIcons; private int myDefaultOptionIndex = -1; - public BaseListPopupStep(@Nullable String aTitle, T[] aValues) { - this(aTitle, aValues, new Icon[]{}); + public BaseListPopupStep(@Nullable String title, T[] values) { + this(title, values, new Icon[]{}); } - public BaseListPopupStep(@Nullable String aTitle, List<? extends T> aValues) { - this(aTitle, aValues, new ArrayList<Icon>()); + public BaseListPopupStep(@Nullable String title, List<? extends T> values) { + this(title, values, new ArrayList<Icon>()); } - public BaseListPopupStep(@Nullable String aTitle, T[] aValues, Icon[] aIcons) { - this(aTitle, Arrays.asList(aValues), Arrays.asList(aIcons)); + public BaseListPopupStep(@Nullable String title, T[] values, Icon[] icons) { + this(title, Arrays.asList(values), Arrays.asList(icons)); } public BaseListPopupStep(@Nullable String aTitle, @NotNull List<? extends T> aValues, Icon aSameIcon) { @@ -53,16 +53,16 @@ public class BaseListPopupStep<T> extends BaseStep<T> implements ListPopupStep<T init(aTitle, aValues, icons); } - public BaseListPopupStep(@Nullable String aTitle, @NotNull List<? extends T> aValues, List<Icon> aIcons) { - init(aTitle, aValues, aIcons); + public BaseListPopupStep(@Nullable String title, @NotNull List<? extends T> values, List<Icon> icons) { + init(title, values, icons); } protected BaseListPopupStep() { } - protected final void init(@Nullable String aTitle, @NotNull List<? extends T> aValues, @Nullable List<Icon> aIcons) { - myTitle = aTitle; - myValues = new ArrayList<T>(aValues); - myIcons = aIcons; + protected final void init(@Nullable String title, @NotNull List<? extends T> values, @Nullable List<Icon> icons) { + myTitle = title; + myValues = new ArrayList<T>(values); + myIcons = icons; } @Nullable @@ -79,8 +79,8 @@ public class BaseListPopupStep<T> extends BaseStep<T> implements ListPopupStep<T return FINAL_CHOICE; } - public Icon getIconFor(T aValue) { - int index = myValues.indexOf(aValue); + public Icon getIconFor(T value) { + int index = myValues.indexOf(value); if (index != -1 && myIcons != null && index < myIcons.size()) { return myIcons.get(index); } |