Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix tab name updating
Browse files Browse the repository at this point in the history
pavelbraginskiy committed Jan 12, 2025
1 parent 3062c09 commit 84b0936
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion megameklab/src/megameklab/ui/MegaMekLabMainUI.java
Original file line number Diff line number Diff line change
@@ -148,7 +148,7 @@ public void refreshHeader() {
setTitle(getEntity().getFullChassis() + " " + getEntity().getModel() + fileInfo);
if (owner != null) {
getEntity().generateDisplayName();
owner.setTabName(getEntity().getDisplayName());
owner.setTabName(getEntity().getDisplayName(), this);
}
}

10 changes: 5 additions & 5 deletions megameklab/src/megameklab/ui/MegaMekLabTabbedUI.java
Original file line number Diff line number Diff line change
@@ -128,11 +128,10 @@ public MegaMekLabMainUI currentEditor() {
*
* @param tabName The new name to be set for the currently selected tab.
*/
public void setTabName(String tabName) {
// ClosableTab is a label with the unit name, and a close button.
// If we didn't need that close button, this could be tabs.setTitleAt
tabs.setTabComponentAt(tabs.getSelectedIndex(), new EditorTab(tabName, currentEditor()) );
checkChanged(tabs.getSelectedIndex());
public void setTabName(String tabName, MegaMekLabMainUI editor) {
var idx = editors.indexOf(editor);
tabs.setTabComponentAt(idx, new EditorTab(tabName, currentEditor()) );
checkChanged(idx);
}

/**
@@ -199,6 +198,7 @@ private void addNewTabButton() {
private void newUnit(long type, boolean primitive, boolean industrial) {
var oldUi = editors.get(tabs.getSelectedIndex());
var newUi = UiLoader.getUI(type, primitive, industrial);
newUi.setOwner(this);
editors.set(tabs.getSelectedIndex(), newUi);
tabs.setComponentAt(tabs.getSelectedIndex(), newUi.getContentPane());
tabs.setTabComponentAt(tabs.getSelectedIndex(), new EditorTab(newUi.getEntity().getDisplayName(), newUi));

0 comments on commit 84b0936

Please sign in to comment.