diff --git a/platform/editor-ui-api/src/com/intellij/openapi/actionSystem/KeyboardShortcut.java b/platform/editor-ui-api/src/com/intellij/openapi/actionSystem/KeyboardShortcut.java index a9555be753be..2ef071841973 100644 --- a/platform/editor-ui-api/src/com/intellij/openapi/actionSystem/KeyboardShortcut.java +++ b/platform/editor-ui-api/src/com/intellij/openapi/actionSystem/KeyboardShortcut.java @@ -47,6 +47,7 @@ public final class KeyboardShortcut extends Shortcut { return mySecondKeyStroke; } + @Override public int hashCode() { int hashCode = myFirstKeyStroke.hashCode(); if (mySecondKeyStroke != null) { @@ -55,6 +56,7 @@ public final class KeyboardShortcut extends Shortcut { return hashCode; } + @Override public boolean equals(Object obj) { if (!(obj instanceof KeyboardShortcut)) { return false; diff --git a/platform/platform-impl/src/com/intellij/openapi/progress/util/ProgressDialog.java b/platform/platform-impl/src/com/intellij/openapi/progress/util/ProgressDialog.java index d6c7a6e6aa0f..dc196f4b100c 100644 --- a/platform/platform-impl/src/com/intellij/openapi/progress/util/ProgressDialog.java +++ b/platform/platform-impl/src/com/intellij/openapi/progress/util/ProgressDialog.java @@ -65,6 +65,45 @@ class ProgressDialog implements Disposable { } }; + private final Runnable myUpdateRequest = () -> update(); + + JPanel myPanel; + private JLabel myTextLabel; + + private JBLabel myText2Label; + private JButton myCancelButton; + + private JButton myBackgroundButton; + private JProgressBar myProgressBar; + + private boolean myRepaintedFlag = true; // guarded by this + private TitlePanel myTitlePanel; + private JPanel myInnerPanel; + DialogWrapper myPopup; + private final Window myParentWindow; + + private final SingleAlarm myDisableCancelAlarm = new SingleAlarm(this::setCancelButtonDisabledInEDT, 500,this); + private final SingleAlarm myEnableCancelAlarm = new SingleAlarm(this::setCancelButtonEnabledInEDT, 500,this); + + ProgressDialog(@NotNull ProgressWindow progressWindow, + boolean shouldShowBackground, + @Nullable Component parent, + @Nullable Project project, + String cancelText) { + myProgressWindow = progressWindow; + if (parent != null) { + myParentWindow = UIUtil.getWindow(parent); + } + else { + Window parentWindow = WindowManager.getInstance().suggestParentWindow(project); + if (parentWindow == null) { + parentWindow = WindowManagerEx.getInstanceEx().getMostRecentFocusedWindow(); + } + myParentWindow = parentWindow; + } + initDialog(shouldShowBackground, cancelText); + } + @NotNull private static String fitTextToLabel(@Nullable String fullText, @NotNull JLabel label) { if (fullText == null || fullText.isEmpty()) return " "; @@ -76,39 +115,6 @@ class ProgressDialog implements Disposable { return fullText; } - private final Runnable myUpdateRequest = () -> update(); - JPanel myPanel; - - private JLabel myTextLabel; - private JBLabel myText2Label; - - private JButton myCancelButton; - private JButton myBackgroundButton; - - private JProgressBar myProgressBar; - private boolean myRepaintedFlag = true; // guarded by this - private TitlePanel myTitlePanel; - private JPanel myInnerPanel; - DialogWrapper myPopup; - private final Window myParentWindow; - - ProgressDialog(ProgressWindow progressWindow, boolean shouldShowBackground, Project project, String cancelText) { - myProgressWindow = progressWindow; - Window parentWindow = WindowManager.getInstance().suggestParentWindow(project); - if (parentWindow == null) { - parentWindow = WindowManagerEx.getInstanceEx().getMostRecentFocusedWindow(); - } - myParentWindow = parentWindow; - - initDialog(shouldShowBackground, cancelText); - } - - ProgressDialog(ProgressWindow progressWindow, boolean shouldShowBackground, Component parent, String cancelText) { - myProgressWindow = progressWindow; - myParentWindow = UIUtil.getWindow(parent); - initDialog(shouldShowBackground, cancelText); - } - private void initDialog(boolean shouldShowBackground, String cancelText) { if (SystemInfo.isMac) { UIUtil.applyStyle(UIUtil.ComponentStyle.SMALL, myText2Label); @@ -149,11 +155,12 @@ class ProgressDialog implements Disposable { UIUtil.dispose(myCancelButton); } + @NotNull JPanel getPanel() { return myPanel; } - void changeCancelButtonText(String text) { + void changeCancelButtonText(@NotNull String text) { myCancelButton.setText(text); } @@ -180,9 +187,6 @@ class ProgressDialog implements Disposable { (enable ? myEnableCancelAlarm : myDisableCancelAlarm).request(); } - private final SingleAlarm myDisableCancelAlarm = new SingleAlarm(this::setCancelButtonDisabledInEDT, 500,this); - private final SingleAlarm myEnableCancelAlarm = new SingleAlarm(this::setCancelButtonEnabledInEDT, 500,this); - private void createCenterPanel() { // Cancel button (if any) @@ -289,7 +293,7 @@ class ProgressDialog implements Disposable { myIsCancellable = cancellable; } - MyDialogWrapper(Component parent, final boolean cancellable) { + MyDialogWrapper(@NotNull Component parent, final boolean cancellable) { super(parent, false); init(); myIsCancellable = cancellable; diff --git a/platform/platform-impl/src/com/intellij/openapi/progress/util/ProgressWindow.java b/platform/platform-impl/src/com/intellij/openapi/progress/util/ProgressWindow.java index 14fd21212aa1..76d44e7b8da3 100644 --- a/platform/platform-impl/src/com/intellij/openapi/progress/util/ProgressWindow.java +++ b/platform/platform-impl/src/com/intellij/openapi/progress/util/ProgressWindow.java @@ -41,7 +41,6 @@ import javax.swing.*; import java.awt.*; import java.awt.event.KeyEvent; -@SuppressWarnings("NonStaticInitializer") public class ProgressWindow extends ProgressIndicatorBase implements BlockingProgressIndicator, Disposable { private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.progress.util.ProgressWindow"); @@ -100,9 +99,7 @@ public class ProgressWindow extends ProgressIndicatorBase implements BlockingPro parent = JOptionPane.getRootFrame(); } - myDialog = parent == null - ? new ProgressDialog(this, shouldShowBackground, myProject, myCancelText) - : new ProgressDialog(this, shouldShowBackground, parent, myCancelText); + myDialog = new ProgressDialog(this, shouldShowBackground, parent, myProject, myCancelText); Disposer.register(this, myDialog); @@ -320,7 +317,7 @@ public class ProgressWindow extends ProgressIndicatorBase implements BlockingPro return myTitle; } - public void setCancelButtonText(String text) { + public void setCancelButtonText(@NotNull String text) { if (myDialog != null) { myDialog.changeCancelButtonText(text); } diff --git a/platform/util/src/com/intellij/util/containers/UnmodifiableTHashMap.java b/platform/util/src/com/intellij/util/containers/UnmodifiableTHashMap.java index 60a5ddc9969f..5be2d1fed8b9 100644 --- a/platform/util/src/com/intellij/util/containers/UnmodifiableTHashMap.java +++ b/platform/util/src/com/intellij/util/containers/UnmodifiableTHashMap.java @@ -13,7 +13,7 @@ import java.util.Map; import java.util.Set; public class UnmodifiableTHashMap extends THashMap { - public UnmodifiableTHashMap(@NotNull TObjectHashingStrategy strategy, K k, V v) { + public UnmodifiableTHashMap(@NotNull TObjectHashingStrategy strategy, @NotNull K k, V v) { super(strategy); super.put(k, v); } @@ -26,13 +26,13 @@ public class UnmodifiableTHashMap extends THashMap { } } public UnmodifiableTHashMap(@NotNull TObjectHashingStrategy strategy, - @NotNull Map map, K additionalKey, V additionalValue) { + @NotNull Map map, @NotNull K additionalKey, V additionalValue) { this(strategy, map); super.put(additionalKey, additionalValue); } @Override - public V put(K key, V value) { + public V put(@NotNull K key, V value) { throw new UnsupportedOperationException(); }