This commit is contained in:
Alexey Kudravtsev
2018-09-19 13:29:03 +03:00
parent ea0dab662b
commit 79c1a1155f
4 changed files with 49 additions and 46 deletions
@@ -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;
@@ -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;
@@ -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);
}
@@ -13,7 +13,7 @@ import java.util.Map;
import java.util.Set;
public class UnmodifiableTHashMap<K,V> extends THashMap<K,V> {
public UnmodifiableTHashMap(@NotNull TObjectHashingStrategy<K> strategy, K k, V v) {
public UnmodifiableTHashMap(@NotNull TObjectHashingStrategy<K> strategy, @NotNull K k, V v) {
super(strategy);
super.put(k, v);
}
@@ -26,13 +26,13 @@ public class UnmodifiableTHashMap<K,V> extends THashMap<K,V> {
}
}
public UnmodifiableTHashMap(@NotNull TObjectHashingStrategy<K> strategy,
@NotNull Map<? extends K, ? extends V> map, K additionalKey, V additionalValue) {
@NotNull Map<? extends K, ? extends V> 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();
}