Skip to content

Commit

Permalink
Renaming members now reloads the tab (updates tables)
Browse files Browse the repository at this point in the history
  • Loading branch information
Col-E committed Jun 8, 2018
1 parent d59542d commit 86b3d32
Showing 1 changed file with 29 additions and 3 deletions.
32 changes: 29 additions & 3 deletions src/me/coley/recaf/ui/FxWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -182,12 +182,38 @@ private void onInputChange(NewInputEvent event) {

@Listener
private void onClassRename(ClassRenameEvent event) {
reloadTab(event.getOriginalName(), event.getNewName());
}

@Listener
private void onFieldRename(FieldRenameEvent rename) {
String name = rename.getOwner().name;
reloadTab(name, name);
Threads.runLater(30, () -> {
Tab tab = cache.get(name);
EditTabs edit = (EditTabs) ((BorderPane) tab.getContent()).getCenter();
edit.getSelectionModel().select(edit.getTabs().get(1));
});
}

@Listener
private void onMethodRename(MethodRenameEvent rename) {
String name = rename.getOwner().name;
reloadTab(name, name);
Threads.runLater(30, () -> {
Tab tab = cache.get(name);
EditTabs edit = (EditTabs) ((BorderPane) tab.getContent()).getCenter();
edit.getSelectionModel().select(edit.getTabs().get(2));
});
}

private void reloadTab(String originalName, String newName) {
// Close tab of edited class
Tab tab = cache.remove(event.getOriginalName());
Tab tab = cache.remove(originalName);
// reopen tab
if (getTabs().remove(tab)) {
Threads.runLaterFx(50, () -> {
Bus.post(new ClassOpenEvent(Input.get().getClass(event.getNewName())));
Threads.runLaterFx(20, () -> {
Bus.post(new ClassOpenEvent(Input.get().getClass(newName)));
});
}
}
Expand Down

0 comments on commit 86b3d32

Please sign in to comment.