Skip to content

Commit

Permalink
Add a 'methodCalled' event that can be fired with varargs for listene…
Browse files Browse the repository at this point in the history
…rs to see the call stack at the time of firing
  • Loading branch information
daykin committed Jun 19, 2024
1 parent fa44289 commit 01a260c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,7 @@ public interface ToolkitListener
* @param value The value
*/
default public void handleWrite(Widget widget, Object value) {};

default public void handleMethodCalled(Object... user_args) {};

}
Original file line number Diff line number Diff line change
Expand Up @@ -689,6 +689,20 @@ public void fireWrite(final Widget widget, final Object value)
}
}

public void fireMethodCall(Object... user_args) {
for (final ToolkitListener listener : listeners)
{
try
{
listener.handleMethodCalled(user_args);
}
catch (final Throwable ex)
{
logger.log(Level.WARNING, "Failure when firing method-call event for " + Thread.currentThread().getStackTrace()[1].getMethodName(), ex);
}
}
};

/** Close the toolkit's "window" that displays a model
* @param model Model that has been represented in this toolkit
* @throws Exception on error
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,8 @@ public void loadDisplayFile(final DisplayInfo info)
// another instance
dock_item.setInput(info.toURI());

representation.fireMethodCall((Object)display_info);

// Now that old model is no longer represented,
// show info.
// Showing this info before disposeModel()
Expand Down

0 comments on commit 01a260c

Please sign in to comment.