Skip to content

enhancedtabs moved to common, implemented in UnitDisplay #6960

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

exeea
Copy link
Collaborator

@exeea exeea commented Apr 29, 2025

This PR moves the EnhancedTabbedPane from MML to MM common.
Improves them using the saving of x;y;w;h instead of only w;h
Implements them in the UnitDisplay window

@Copilot Copilot AI review requested due to automatic review settings April 29, 2025 23:42
@exeea exeea requested a review from a team as a code owner April 29, 2025 23:42
@exeea exeea marked this pull request as draft April 29, 2025 23:42
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR moves the EnhancedTabbedPane component from MML to MM common, enhancing the tabbed UI in the UnitDisplay window and improving window state persistence by storing x, y, width, and height. Key changes include:

  • Updating MekPanelTabStrip constant naming to use capitalized strings.
  • Replacing the old tab strip with a new EnhancedTabbedPane in UnitDisplay.
  • Adding getters and setters in GUIPreferences for saving and retrieving window size and position.

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
megamek/src/megamek/client/ui/swing/widget/MekPanelTabStrip.java Updated constant string values for tab names.
megamek/src/megamek/client/ui/swing/unitDisplay/UnitDisplay.java Replaced MekPanelTabStrip with EnhancedTabbedPane and re-arranged layout using CardLayout for view switching.
megamek/src/megamek/client/ui/swing/GUIPreferences.java Added methods for persisting named window size and position.
Comments suppressed due to low confidence (1)

megamek/src/megamek/client/ui/swing/unitDisplay/UnitDisplay.java:505

  • In tabbed view mode the method showPanel() immediately returns without updating the tab selection. It is recommended to select the corresponding tab in tabbedPane based on the value of 's'.
if (GUIP.getUnitDisplayStartTabbed()) { return; }

@HammerGS
Copy link
Member

Can you add the screen shots? Also there is a long standing ask to include the sprite of the unit on the card so players can at a glance see the sprite outside of the map.

Copy link

codecov bot commented Apr 29, 2025

Codecov Report

Attention: Patch coverage is 0% with 1012 lines in your changes missing coverage. Please review.

Project coverage is 30.21%. Comparing base (bca68e9) to head (476aa7b).
Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
megamek/src/megamek/common/EnhancedTabbedPane.java 0.00% 943 Missing ⚠️
...gamek/client/ui/swing/unitDisplay/UnitDisplay.java 0.00% 54 Missing ⚠️
...ek/src/megamek/client/ui/swing/GUIPreferences.java 0.00% 15 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #6960      +/-   ##
============================================
- Coverage     30.31%   30.21%   -0.10%     
- Complexity    15807    15811       +4     
============================================
  Files          2886     2887       +1     
  Lines        283126   284084     +958     
  Branches      49326    49495     +169     
============================================
+ Hits          85833    85841       +8     
- Misses       191694   192642     +948     
- Partials       5599     5601       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

if (windowCoords.length < 4) {
return Optional.empty();
}
int x = Integer.parseInt(windowCoords[0]);

Check notice

Code scanning / CodeQL

Missing catch of NumberFormatException Note

Potential uncaught 'java.lang.NumberFormatException'.
return Optional.empty();
}
int x = Integer.parseInt(windowCoords[0]);
int y = Integer.parseInt(windowCoords[1]);

Check notice

Code scanning / CodeQL

Missing catch of NumberFormatException Note

Potential uncaught 'java.lang.NumberFormatException'.
}
int x = Integer.parseInt(windowCoords[0]);
int y = Integer.parseInt(windowCoords[1]);
int width = Integer.parseInt(windowCoords[2]);

Check notice

Code scanning / CodeQL

Missing catch of NumberFormatException Note

Potential uncaught 'java.lang.NumberFormatException'.
int x = Integer.parseInt(windowCoords[0]);
int y = Integer.parseInt(windowCoords[1]);
int width = Integer.parseInt(windowCoords[2]);
int height = Integer.parseInt(windowCoords[3]);

Check notice

Code scanning / CodeQL

Missing catch of NumberFormatException Note

Potential uncaught 'java.lang.NumberFormatException'.
* @param tabIndex The index of the tab being detached
* @param component The component in the tab
*/
default boolean onTabDetaching(int tabIndex, Component component) {

Check notice

Code scanning / CodeQL

Useless parameter Note

The parameter 'tabIndex' is never used.
* @param component The component in the tab
* @param event The event that triggered the close (may be null)
*/
default void onTabCloseRequest(int tabIndex, Component component, InputEvent event) {

Check notice

Code scanning / CodeQL

Useless parameter Note

The parameter 'component' is never used.
* @param component The component in the tab
* @param event The event that triggered the close (may be null)
*/
default void onTabCloseRequest(int tabIndex, Component component, InputEvent event) {

Check notice

Code scanning / CodeQL

Useless parameter Note

The parameter 'event' is never used.
* @param tabIndex The index of the tab that was removed
* @param component The component that was removed
*/
default void onTabRemoved(int tabIndex, Component component) {

Check notice

Code scanning / CodeQL

Useless parameter Note

The parameter 'tabIndex' is never used.
* @param tabIndex The index of the tab that was removed
* @param component The component that was removed
*/
default void onTabRemoved(int tabIndex, Component component) {

Check notice

Code scanning / CodeQL

Useless parameter Note

The parameter 'component' is never used.
/**
* Configures a JFrame for detached tab display
*/
private void setupFrame(JFrame frame, String title, Icon icon, Component component, Dimension size,

Check notice

Code scanning / CodeQL

Useless parameter Note

The parameter 'title' is never used.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants