diff options
Diffstat (limited to 'platform/platform-api/src/com/intellij/openapi')
19 files changed, 232 insertions, 95 deletions
diff --git a/platform/platform-api/src/com/intellij/openapi/actionSystem/ActionPlaces.java b/platform/platform-api/src/com/intellij/openapi/actionSystem/ActionPlaces.java index 16a81d2218d2..aa1248775a21 100644 --- a/platform/platform-api/src/com/intellij/openapi/actionSystem/ActionPlaces.java +++ b/platform/platform-api/src/com/intellij/openapi/actionSystem/ActionPlaces.java @@ -26,6 +26,9 @@ import org.jetbrains.annotations.NotNull; public abstract class ActionPlaces { public static final String UNKNOWN = "unknown"; + /** + * consider to use {@link #isMainMenuOrActionSearch(String)} instead + */ public static final String MAIN_MENU = "MainMenu"; public static final String MAIN_TOOLBAR = "MainToolbar"; public static final String EDITOR_POPUP = "EditorPopup"; @@ -45,6 +48,7 @@ public abstract class ActionPlaces { public static final String STATUS_BAR_PLACE = "StatusBarPlace"; public static final String SCOPE_VIEW_POPUP = "ScopeViewPopup"; + public static final String ACTION_SEARCH = "GoToAction"; public static final String TESTTREE_VIEW_POPUP = "TestTreeViewPopup"; public static final String TESTTREE_VIEW_TOOLBAR = "TestTreeViewToolbar"; @@ -127,6 +131,10 @@ public abstract class ActionPlaces { return ArrayUtil.find(ourToolbarPlaces, place) != -1; } + public static boolean isMainMenuOrActionSearch(String place) { + return MAIN_MENU.equals(place) || ACTION_SEARCH.equals(place); + } + private static final String[] ourPopupPlaces = {EDITOR_POPUP, EDITOR_TAB_POPUP, COMMANDER_POPUP, PROJECT_VIEW_POPUP, FAVORITES_VIEW_POPUP, SCOPE_VIEW_POPUP, TESTTREE_VIEW_POPUP, TESTSTATISTICS_VIEW_POPUP, TYPE_HIERARCHY_VIEW_POPUP, METHOD_HIERARCHY_VIEW_POPUP, CALL_HIERARCHY_VIEW_POPUP, J2EE_ATTRIBUTES_VIEW_POPUP, J2EE_VIEW_POPUP, USAGE_VIEW_POPUP, diff --git a/platform/platform-api/src/com/intellij/openapi/actionSystem/Separator.java b/platform/platform-api/src/com/intellij/openapi/actionSystem/Separator.java index 2dd2ee50d120..191c8c01ce32 100644 --- a/platform/platform-api/src/com/intellij/openapi/actionSystem/Separator.java +++ b/platform/platform-api/src/com/intellij/openapi/actionSystem/Separator.java @@ -42,6 +42,11 @@ public final class Separator extends AnAction implements DumbAware { } @Override + public String toString() { + return "Separator (" + myText + ")"; + } + + @Override public void actionPerformed(AnActionEvent e){ throw new UnsupportedOperationException(); } diff --git a/platform/platform-api/src/com/intellij/openapi/actionSystem/ex/CheckboxAction.java b/platform/platform-api/src/com/intellij/openapi/actionSystem/ex/CheckboxAction.java index 5f179baad831..3e52f26d0b87 100644 --- a/platform/platform-api/src/com/intellij/openapi/actionSystem/ex/CheckboxAction.java +++ b/platform/platform-api/src/com/intellij/openapi/actionSystem/ex/CheckboxAction.java @@ -43,12 +43,8 @@ public abstract class CheckboxAction extends ToggleAction implements CustomCompo public JComponent createCustomComponent(Presentation presentation) { // this component cannot be stored right here because of action system architecture: // one action can be shown on multiple toolbars simultaneously - JCheckBox checkBox = new JCheckBox(presentation.getText()); + JCheckBox checkBox = new JCheckBox(); checkBox.setOpaque(false); - checkBox.setToolTipText(presentation.getDescription()); - checkBox.setMnemonic(presentation.getMnemonic()); - checkBox.setDisplayedMnemonicIndex(presentation.getDisplayedMnemonicIndex()); - checkBox.setSelected(Boolean.TRUE.equals(presentation.getClientProperty(SELECTED_PROPERTY))); checkBox.addActionListener(new ActionListener() { @Override @@ -69,13 +65,19 @@ public abstract class CheckboxAction extends ToggleAction implements CustomCompo @Override public void update(final AnActionEvent e) { super.update(e); - Object property = e.getPresentation().getClientProperty(CUSTOM_COMPONENT_PROPERTY); + Presentation presentation = e.getPresentation(); + Object property = presentation.getClientProperty(CUSTOM_COMPONENT_PROPERTY); if (property instanceof JCheckBox) { JCheckBox checkBox = (JCheckBox)property; - checkBox.setSelected(Boolean.TRUE.equals(e.getPresentation().getClientProperty(SELECTED_PROPERTY))); - checkBox.setEnabled(e.getPresentation().isEnabled()); - checkBox.setVisible(e.getPresentation().isVisible()); + checkBox.setText(presentation.getText()); + checkBox.setToolTipText(presentation.getDescription()); + checkBox.setMnemonic(presentation.getMnemonic()); + checkBox.setDisplayedMnemonicIndex(presentation.getDisplayedMnemonicIndex()); + checkBox.setSelected(Boolean.TRUE.equals(presentation.getClientProperty(SELECTED_PROPERTY))); + + checkBox.setEnabled(presentation.isEnabled()); + checkBox.setVisible(presentation.isVisible()); } } } diff --git a/platform/platform-api/src/com/intellij/openapi/actionSystem/ex/ComboBoxAction.java b/platform/platform-api/src/com/intellij/openapi/actionSystem/ex/ComboBoxAction.java index 7398bf706c78..6ce522141f16 100644 --- a/platform/platform-api/src/com/intellij/openapi/actionSystem/ex/ComboBoxAction.java +++ b/platform/platform-api/src/com/intellij/openapi/actionSystem/ex/ComboBoxAction.java @@ -26,10 +26,7 @@ import com.intellij.openapi.util.IconLoader; import com.intellij.openapi.util.SystemInfo; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.wm.IdeFocusManager; -import com.intellij.ui.ColorUtil; -import com.intellij.ui.Gray; -import com.intellij.ui.IdeBorderFactory; -import com.intellij.ui.JBColor; +import com.intellij.ui.*; import com.intellij.ui.awt.RelativePoint; import com.intellij.util.ui.GraphicsUtil; import com.intellij.util.ui.UIUtil; @@ -103,7 +100,7 @@ public abstract class ComboBoxAction extends AnAction implements CustomComponent return 1; } - protected class ComboBoxButton extends JButton { + protected class ComboBoxButton extends JButton implements UserActivityProviderComponent { private final Presentation myPresentation; private boolean myForcePressed = false; private PropertyChangeListener myButtonSynchronizer; @@ -227,6 +224,7 @@ public abstract class ComboBoxAction extends AnAction implements CustomComponent } }); repaint(); + fireStateChanged(); } }; diff --git a/platform/platform-api/src/com/intellij/openapi/application/ApplicationStarterEx.java b/platform/platform-api/src/com/intellij/openapi/application/ApplicationStarterEx.java index c4b3a6384f56..86e322f6e0e3 100644 --- a/platform/platform-api/src/com/intellij/openapi/application/ApplicationStarterEx.java +++ b/platform/platform-api/src/com/intellij/openapi/application/ApplicationStarterEx.java @@ -15,6 +15,8 @@ */ package com.intellij.openapi.application; +import org.jetbrains.annotations.Nullable; + /** * Implementers of the interface declared via {@link com.intellij.ExtensionPoints#APPLICATION_STARTER} * may be capable of processing an external command line within a running IntelliJ Platform instance. @@ -28,5 +30,10 @@ public abstract class ApplicationStarterEx implements ApplicationStarter { return false; } + @Deprecated public void processExternalCommandLine(String[] args) { } + + public void processExternalCommandLine(String[] args, @Nullable String currentDirectory) { + processExternalCommandLine(args); + } } diff --git a/platform/platform-api/src/com/intellij/openapi/diagnostic/ErrorReportSubmitter.java b/platform/platform-api/src/com/intellij/openapi/diagnostic/ErrorReportSubmitter.java index 9f1b8e06b39e..c68e45189a95 100644 --- a/platform/platform-api/src/com/intellij/openapi/diagnostic/ErrorReportSubmitter.java +++ b/platform/platform-api/src/com/intellij/openapi/diagnostic/ErrorReportSubmitter.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 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. @@ -18,6 +18,8 @@ package com.intellij.openapi.diagnostic; import com.intellij.openapi.extensions.PluginAware; import com.intellij.openapi.extensions.PluginDescriptor; import com.intellij.util.Consumer; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import java.awt.*; @@ -44,33 +46,43 @@ public abstract class ErrorReportSubmitter implements PluginAware { } /** - * @return "Report to vendor" action text to be used in Error Reporter user interface. For example: "Report to JetBrains". + * @return an action text to be used in Error Reporter user interface, e.g. "Report to JetBrains". */ public abstract String getReportActionText(); /** - * This method is called whenever fatal error (aka exception) in plugin code had happened and user decided to report this problem to - * plugin vendor. - * @param events sequence of the fatal error descriptors. Fatal errors that happened immediately one after another most probably caused - * by first one that happened so it's a common practice to submit only first one. Array passed is guaranteed to have at least one element. - * @param parentComponent one usually wants to show up a dialog asking user for additional details and probably authentication info. - * parentComponent parameter is passed so dialog that would come up would be properly aligned with its parent dialog (IDE Fatal Errors). - * @return submission result status. + * This method is called whenever an exception in a plugin code had happened and a user decided to report a problem to the plugin vendor. + * + * @param events a non-empty sequence of error descriptors. + * @param additionalInfo additional information provided by a user. + * @param parentComponent UI component to use as a parent in any UI activity from a submitter. + * @param consumer a callback to be called after sending is finished (or failed). + * @return {@code true} if reporting was started, {@code false} if a report can't be sent at the moment. */ - public abstract SubmittedReportInfo submit(IdeaLoggingEvent[] events, Component parentComponent); - - public void submitAsync(IdeaLoggingEvent[] events, - String additionalInfo, - Component parentComponent, - Consumer<SubmittedReportInfo> consumer) { - consumer.consume(submit(events, parentComponent)); + @SuppressWarnings("deprecation") + public boolean submit(@NotNull IdeaLoggingEvent[] events, + @Nullable String additionalInfo, + @NotNull Component parentComponent, + @NotNull Consumer<SubmittedReportInfo> consumer) { + return trySubmitAsync(events, additionalInfo, parentComponent, consumer); } - public boolean trySubmitAsync(IdeaLoggingEvent[] events, - String additionalInfo, - Component parentComponent, - Consumer<SubmittedReportInfo> consumer) { - submitAsync(events, additionalInfo, parentComponent, consumer); + /** @deprecated implement {@link #submit(IdeaLoggingEvent[], String, Component, Consumer)} (to be removed in IDEA 16) */ + @SuppressWarnings({"deprecation", "unused"}) + public boolean trySubmitAsync(IdeaLoggingEvent[] events, String info, Component parent, Consumer<SubmittedReportInfo> consumer) { + submitAsync(events, info, parent, consumer); return true; } + + /** @deprecated implement {@link #submit(IdeaLoggingEvent[], String, Component, Consumer)} (to be removed in IDEA 16) */ + @SuppressWarnings({"deprecation", "unused"}) + public void submitAsync(IdeaLoggingEvent[] events, String info, Component parent, Consumer<SubmittedReportInfo> consumer) { + consumer.consume(submit(events, parent)); + } + + /** @deprecated implement {@link #submit(IdeaLoggingEvent[], String, Component, Consumer)} (to be removed in IDEA 16) */ + @SuppressWarnings({"deprecation", "unused"}) + public SubmittedReportInfo submit(IdeaLoggingEvent[] events, Component parent) { + throw new UnsupportedOperationException("Deprecated API called"); + } } diff --git a/platform/platform-api/src/com/intellij/openapi/diagnostic/SubmittedReportInfo.java b/platform/platform-api/src/com/intellij/openapi/diagnostic/SubmittedReportInfo.java index 6bad8c45df93..8ead30567681 100644 --- a/platform/platform-api/src/com/intellij/openapi/diagnostic/SubmittedReportInfo.java +++ b/platform/platform-api/src/com/intellij/openapi/diagnostic/SubmittedReportInfo.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 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. @@ -15,6 +15,9 @@ */ package com.intellij.openapi.diagnostic; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + /** * Simple bean representing error submission status. */ @@ -31,29 +34,27 @@ public class SubmittedReportInfo { DUPLICATE, /** - * Submission failed. (For network connection reasons for example) + * Submission failed (e.g. because of network problem) */ FAILED } - private final String myURL; + private final String myUrl; private final String myLinkText; private final SubmissionStatus myStatus; - /** - * Create new submission status bean - * @param URL url that points to newly created issue. Optional. Pass <code>null</code> value if N/A or failed - * @param linkText short text that UI interface pointing to the issue should have. - * @param status submission success/failure - */ - public SubmittedReportInfo(final String URL, final String linkText, final SubmissionStatus status) { - myURL = URL; + public SubmittedReportInfo(SubmissionStatus status) { + this(null, null, status); + } + + public SubmittedReportInfo(@Nullable String url, @Nullable String linkText, @NotNull SubmissionStatus status) { + myUrl = url; myLinkText = linkText; myStatus = status; } public String getURL() { - return myURL; + return myUrl; } public String getLinkText() { diff --git a/platform/platform-api/src/com/intellij/openapi/fileChooser/FileChooser.java b/platform/platform-api/src/com/intellij/openapi/fileChooser/FileChooser.java index 9e0bf738a7cf..fee268813d14 100644 --- a/platform/platform-api/src/com/intellij/openapi/fileChooser/FileChooser.java +++ b/platform/platform-api/src/com/intellij/openapi/fileChooser/FileChooser.java @@ -52,7 +52,7 @@ public class FileChooser { @Nullable final Project project, @Nullable final VirtualFile toSelect) { final FileChooserDialog chooser = FileChooserFactory.getInstance().createFileChooser(descriptor, project, parent); - return chooser.choose(toSelect, project); + return chooser.choose(project, toSelect); } @Nullable diff --git a/platform/platform-api/src/com/intellij/openapi/fileChooser/FileChooserDialog.java b/platform/platform-api/src/com/intellij/openapi/fileChooser/FileChooserDialog.java index c12ab422a942..324979dff228 100644 --- a/platform/platform-api/src/com/intellij/openapi/fileChooser/FileChooserDialog.java +++ b/platform/platform-api/src/com/intellij/openapi/fileChooser/FileChooserDialog.java @@ -23,7 +23,22 @@ import org.jetbrains.annotations.Nullable; public interface FileChooserDialog { DataKey<Boolean> PREFER_LAST_OVER_TO_SELECT = PathChooserDialog.PREFER_LAST_OVER_EXPLICIT; - + + /** + * @deprecated Please use {@link #choose(com.intellij.openapi.project.Project, com.intellij.openapi.vfs.VirtualFile...)} because + * it supports several selections + */ + @Deprecated @NotNull VirtualFile[] choose(@Nullable VirtualFile toSelect, @Nullable Project project); + + /** + * Choose one or more files + * + * @param project use this project (you may pass null if you already set project in ctor) + * @param toSelect files to be selected automatically. + * @return files chosen by user + */ + @NotNull + VirtualFile[] choose(@Nullable Project project, @NotNull VirtualFile... toSelect); }
\ No newline at end of file diff --git a/platform/platform-api/src/com/intellij/openapi/fileEditor/FileEditorManager.java b/platform/platform-api/src/com/intellij/openapi/fileEditor/FileEditorManager.java index 86e719eef48d..dcb1327f1a10 100644 --- a/platform/platform-api/src/com/intellij/openapi/fileEditor/FileEditorManager.java +++ b/platform/platform-api/src/com/intellij/openapi/fileEditor/FileEditorManager.java @@ -197,5 +197,5 @@ public abstract class FileEditorManager { * @param fileEditorProviderId the ID of the file editor to open; matches the return value of * {@link com.intellij.openapi.fileEditor.FileEditorProvider#getEditorTypeId()} */ - public abstract void setSelectedEditor(@NotNull VirtualFile file, String fileEditorProviderId); + public abstract void setSelectedEditor(@NotNull VirtualFile file, @NotNull String fileEditorProviderId); } diff --git a/platform/platform-api/src/com/intellij/openapi/options/ConfigurableEP.java b/platform/platform-api/src/com/intellij/openapi/options/ConfigurableEP.java index 78a4c1ece130..828907c13cfb 100644 --- a/platform/platform-api/src/com/intellij/openapi/options/ConfigurableEP.java +++ b/platform/platform-api/src/com/intellij/openapi/options/ConfigurableEP.java @@ -175,9 +175,25 @@ public class ConfigurableEP<T extends UnnamedConfigurable> extends AbstractExten return getDisplayName(); } + public boolean canCreateConfigurable() { + if (providerClass == null) { + return implementationClass != null || instanceClass != null; + } + try { + ConfigurableProvider provider = instantiate(providerClass, myPicoContainer); + return provider.canCreateConfigurable(); // do not load heavy configurables + } + catch (Exception ignored) { + return true; // see InstanceFromProviderFactory#compute + } + } + private class InstanceFromProviderFactory extends AtomicNotNullLazyValue<ConfigurableProvider> implements NullableFactory<T> { public T create() { - return (T)getValue().createConfigurable(); + ConfigurableProvider provider = getValue(); + return provider.canCreateConfigurable() + ? (T)provider.createConfigurable() + : null; } @NotNull diff --git a/platform/platform-api/src/com/intellij/openapi/options/ConfigurableProvider.java b/platform/platform-api/src/com/intellij/openapi/options/ConfigurableProvider.java index 5a71ffa73050..cf2bc0390c5a 100644 --- a/platform/platform-api/src/com/intellij/openapi/options/ConfigurableProvider.java +++ b/platform/platform-api/src/com/intellij/openapi/options/ConfigurableProvider.java @@ -29,4 +29,15 @@ public abstract class ConfigurableProvider { @Nullable public abstract Configurable createConfigurable(); + /** + * Defines whether this provider creates a configurable or not. + * Note that the {@code createConfigurable} method will be called + * if this method returns {@code true}. + * + * @return {@code true} if this provider creates configurable, + * {@code false} otherwise + */ + public boolean canCreateConfigurable() { + return true; + } } diff --git a/platform/platform-api/src/com/intellij/openapi/options/CurrentUserHolder.java b/platform/platform-api/src/com/intellij/openapi/options/CurrentUserHolder.java index 473dce3dda6c..2395fa27f4c1 100644 --- a/platform/platform-api/src/com/intellij/openapi/options/CurrentUserHolder.java +++ b/platform/platform-api/src/com/intellij/openapi/options/CurrentUserHolder.java @@ -15,6 +15,7 @@ */ package com.intellij.openapi.options; +@Deprecated public interface CurrentUserHolder { String getCurrentUserName(); } diff --git a/platform/platform-api/src/com/intellij/openapi/options/SearchableConfigurable.java b/platform/platform-api/src/com/intellij/openapi/options/SearchableConfigurable.java index e98bb05aba99..b426e35d77a8 100644 --- a/platform/platform-api/src/com/intellij/openapi/options/SearchableConfigurable.java +++ b/platform/platform-api/src/com/intellij/openapi/options/SearchableConfigurable.java @@ -34,6 +34,12 @@ public interface SearchableConfigurable extends Configurable { interface Parent extends SearchableConfigurable, Composite { boolean hasOwnContent(); + + /** + * @deprecated use {@link ConfigurableProvider#canCreateConfigurable()} instead + * to specify configurables which should not be visible + */ + @Deprecated boolean isVisible(); abstract class Abstract implements Parent { 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); } diff --git a/platform/platform-api/src/com/intellij/openapi/vfs/newvfs/FileAttribute.java b/platform/platform-api/src/com/intellij/openapi/vfs/newvfs/FileAttribute.java index 965b3c0de9bf..3c775f5b2e8c 100644 --- a/platform/platform-api/src/com/intellij/openapi/vfs/newvfs/FileAttribute.java +++ b/platform/platform-api/src/com/intellij/openapi/vfs/newvfs/FileAttribute.java @@ -21,7 +21,6 @@ package com.intellij.openapi.vfs.newvfs; import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.vfs.VirtualFile; -import com.intellij.util.io.DataInputOutputUtil; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -60,33 +59,12 @@ public class FileAttribute { @Nullable public DataInputStream readAttribute(@NotNull VirtualFile file) { - DataInputStream stream = ManagingFS.getInstance().readAttribute(file, this); - if (stream != null) { - try { - int actualVersion = DataInputOutputUtil.readINT(stream); - if (actualVersion != myVersion) { - stream.close(); - return null; - } - } - catch (IOException e) { - return null; - } - } - return stream; + return ManagingFS.getInstance().readAttribute(file, this); } @NotNull public DataOutputStream writeAttribute(@NotNull VirtualFile file) { - final DataOutputStream stream = ManagingFS.getInstance().writeAttribute(file, this); - try { - DataInputOutputUtil.writeINT(stream, myVersion); - } - catch (IOException e) { - throw new RuntimeException(e); - } - - return stream; + return ManagingFS.getInstance().writeAttribute(file, this); } @Nullable @@ -131,4 +109,8 @@ public class FileAttribute { public FileAttribute newVersion(int newVersion) { return new FileAttribute(newVersion, myFixedSize, myId); } + + public int getVersion() { + return myVersion; + } } |