generated from runelite/example-plugin
-
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: dismiss sticky overlays with notification
Fixes #117
- Loading branch information
1 parent
b65dcdf
commit 461a637
Showing
9 changed files
with
105 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
src/main/java/com/adamk33n3r/runelite/watchdog/notifications/DismissOverlay.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package com.adamk33n3r.runelite.watchdog.notifications; | ||
|
||
import com.adamk33n3r.runelite.watchdog.WatchdogPlugin; | ||
|
||
import lombok.Getter; | ||
import lombok.Setter; | ||
|
||
@Getter @Setter | ||
public class DismissOverlay extends Notification { | ||
private String dismissId; | ||
|
||
@Override | ||
protected void fireImpl(String[] triggerValues) { | ||
WatchdogPlugin.getInstance().getNotificationOverlay().clearById(this.dismissId); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
...adamk33n3r/runelite/watchdog/ui/notifications/panels/DismissOverlayNotificationPanel.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package com.adamk33n3r.runelite.watchdog.ui.notifications.panels; | ||
|
||
import com.adamk33n3r.runelite.watchdog.LengthLimitFilter; | ||
import com.adamk33n3r.runelite.watchdog.SimpleDocumentListener; | ||
import com.adamk33n3r.runelite.watchdog.notifications.DismissOverlay; | ||
import com.adamk33n3r.runelite.watchdog.notifications.Notification; | ||
import com.adamk33n3r.runelite.watchdog.ui.FlatTextArea; | ||
import com.adamk33n3r.runelite.watchdog.ui.panels.NotificationsPanel; | ||
import com.adamk33n3r.runelite.watchdog.ui.panels.PanelUtils; | ||
|
||
import javax.swing.text.AbstractDocument; | ||
import java.awt.event.FocusEvent; | ||
import java.awt.event.FocusListener; | ||
|
||
public class DismissOverlayNotificationPanel extends NotificationPanel { | ||
public DismissOverlayNotificationPanel(DismissOverlay notification, NotificationsPanel parentPanel, Runnable onChangeListener, PanelUtils.OnRemove onRemove) { | ||
super(notification, parentPanel, onChangeListener, onRemove); | ||
|
||
FlatTextArea flatTextArea = new FlatTextArea("Enter the ID of the overlay...", true); | ||
flatTextArea.setText(notification.getDismissId()); | ||
((AbstractDocument) flatTextArea.getDocument()).setDocumentFilter(new LengthLimitFilter(200)); | ||
flatTextArea.getDocument().addDocumentListener((SimpleDocumentListener) ev -> { | ||
notification.setDismissId(flatTextArea.getText()); | ||
}); | ||
flatTextArea.getTextArea().addFocusListener(new FocusListener() { | ||
@Override | ||
public void focusGained(FocusEvent e) { | ||
flatTextArea.getTextArea().selectAll(); | ||
} | ||
|
||
@Override | ||
public void focusLost(FocusEvent e) { | ||
onChangeListener.run(); | ||
} | ||
}); | ||
this.settings.add(flatTextArea); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
src/main/resources/com/adamk33n3r/runelite/watchdog/version.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters