Skip to content

Commit

Permalink
Work around deprecations of API
Browse files Browse the repository at this point in the history
  • Loading branch information
halirutan committed Jul 19, 2024
1 parent 051c6c3 commit 0d18a3b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
5 changes: 3 additions & 2 deletions src/de/halirutan/keypromoterx/KeyPromoter.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@

package de.halirutan.keypromoterx;

import com.intellij.application.Topics;
import com.intellij.ide.ui.UISettings;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.actionSystem.AnAction;
Expand All @@ -32,6 +31,7 @@
import com.intellij.openapi.util.registry.Registry;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.toolWindow.StripeButton;
import com.intellij.util.messages.MessageBus;
import de.halirutan.keypromoterx.statistic.KeyPromoterStatistics;
import org.jetbrains.annotations.NotNull;

Expand Down Expand Up @@ -63,7 +63,8 @@ public class KeyPromoter implements AWTEventListener, AnActionListener, Disposab
private boolean mouseDrag = false;

public KeyPromoter() {
Topics.subscribe(AnActionListener.TOPIC, this, this);
MessageBus messageBus = ApplicationManager.getApplication().getMessageBus();
messageBus.connect(this).subscribe(AnActionListener.TOPIC, this);
long eventMask = AWTEvent.MOUSE_EVENT_MASK | AWTEvent.MOUSE_MOTION_EVENT_MASK | AWTEvent.WINDOW_EVENT_MASK | AWTEvent.WINDOW_STATE_EVENT_MASK;
Toolkit.getDefaultToolkit().addAWTEventListener(this, eventMask);
}
Expand Down
6 changes: 3 additions & 3 deletions src/de/halirutan/keypromoterx/KeyPromoterAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ private void analyzeStripeButton(StripeButton stripeButton) {
mySource = ActionSource.TOOL_WINDOW_BUTTON;
myDescription = stripeButton.getText();
myMnemonic = stripeButton.getMnemonic2();
myIdeaActionID = ActivateToolWindowAction.getActionIdForToolWindow(stripeButton.getId());
myIdeaActionID = ActivateToolWindowAction.Manager.getActionIdForToolWindow(stripeButton.getId());
myShortcut = KeyPromoterUtils.getKeyboardShortcutsText(myIdeaActionID);
}

Expand Down Expand Up @@ -186,7 +186,7 @@ private void fixValuesFromAction(AnAction anAction) {
* Used to adjust Run and Debug descriptions so that the don't contain the name of the run-configuration
*/
private void fixDescription() {
if (myDescription == null || myDescription.length() == 0) {
if (myDescription == null || myDescription.isEmpty()) {
return;
}
if ("Debug".equals(myIdeaActionID) || "DebugClass".equals(myIdeaActionID)) {
Expand All @@ -198,7 +198,7 @@ private void fixDescription() {
}

public String getShortcut() {
if (myShortcut != null && myShortcut.length() > 0) {
if (myShortcut != null && !myShortcut.isEmpty()) {
return myShortcut;
}
if (mySource.equals(ActionSource.TOOL_WINDOW_BUTTON) && myMnemonic > 0) {
Expand Down

0 comments on commit 0d18a3b

Please sign in to comment.