Skip to content

Commit

Permalink
[prmr#508] Updated handler spawning method to support polymorphism
Browse files Browse the repository at this point in the history
  • Loading branch information
ArthusWQZ committed Oct 17, 2023
1 parent c35eaf2 commit b6989d9
Showing 1 changed file with 22 additions and 8 deletions.
30 changes: 22 additions & 8 deletions src/org/jetuml/gui/NotificationHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,12 @@ public void updatePosition()
}

/**
* Spawns a new toast notification.
* Spawns a notification (it should be instantiated first).
*
* @param pText The text to show on the toast
* @param pNotification The notification object to spawn
*/
public void spawn(String pText)
public void spawn(Notification pNotification)
{

if (this.aMainStage == null)
{
return;
Expand All @@ -97,12 +96,27 @@ public void spawn(String pText)
double x = this.aMainStage.getX() + NOTIFICATION_STACK_X_MARGIN;
double y = this.aMainStage.getY() + this.aMainStage.getHeight() - NOTIFICATION_STACK_Y_MARGIN;

ToastNotification toast = new ToastNotification(pText, this.aMainStage);

aNotificationList.add(toast);
aNotificationList.add(pNotification);

toast.show(x, y, new CleanUpCallback());
pNotification.show(x, y, new CleanUpCallback());
this.updatePosition();
}

/**
* Spawns a new toast notification.
*
* @param pText The text to show on the toast
*/
public void spawn(String pText)
{

if (this.aMainStage == null)
{
return;
}

ToastNotification toast = new ToastNotification(pText, this.aMainStage);
spawn(toast);

}

Expand Down

0 comments on commit b6989d9

Please sign in to comment.