Skip to content

enhancedtabs moved to common #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

Merged
merged 16 commits into from
May 11, 2025
Merged

enhancedtabs moved to common #6960

merged 16 commits into from
May 11, 2025

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 of the detached windows
  • add a new event when a tab is moved
  • Implements saving the tabs sorting order (this is, on purpose, not automatic. Loading and saving is implemented by calling the dedicated methods, see the implementation in the linked PR on MML)

This PR will allow to use the new tabs in MM and MHQ

This PR is required for #1867

@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 1034 lines in your changes missing coverage. Please review.

Project coverage is 30.21%. Comparing base (7d2f4ab) to head (f660e35).
Report is 17 commits behind head on master.

Files with missing lines Patch % Lines
megamek/src/megamek/common/EnhancedTabbedPane.java 0.00% 1009 Missing ⚠️
...ek/src/megamek/client/ui/swing/GUIPreferences.java 0.00% 25 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #6960      +/-   ##
============================================
- Coverage     30.21%   30.21%   -0.01%     
+ Complexity    15864    15857       -7     
============================================
  Files          2892     2892              
  Lines        284474   284518      +44     
  Branches      49517    49532      +15     
============================================
- Hits          85966    85956      -10     
- Misses       192883   192937      +54     
  Partials       5625     5625              

☔ 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.

* @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.
@exeea exeea changed the title enhancedtabs moved to common, implemented in UnitDisplay enhancedtabs moved to common May 9, 2025
@exeea exeea requested a review from Copilot May 9, 2025 11:14
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 to the common module and enhances window position/size persistence by storing x, y, width, and height as well as implementing tab sorting persistence.

  • Updated license header information.
  • Added methods to get and set window geometry with coordinate data.
  • Introduced usage of Optional to safely handle persistence values.

* @param tabIndex The new index of the tab that was moved
* @param component The component that was moved
*/
default void onTabMoved(int oldIndex, int tabIndex, Component component) {

Check notice

Code scanning / CodeQL

Useless parameter Note

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

Check notice

Code scanning / CodeQL

Useless parameter Note

The parameter 'component' is never used.
@exeea exeea marked this pull request as ready for review May 9, 2025 16:07
@exeea exeea requested a review from a team as a code owner May 9, 2025 16:07
@exeea exeea requested a review from pavelbraginskiy May 9, 2025 16:07
@exeea exeea requested a review from rjhancock May 9, 2025 16:23
@Sleet01
Copy link
Collaborator

Sleet01 commented May 9, 2025

Is this in service of a bug fix? If not, this might be better-suited for inclusion in the release after the upcoming one.

@Scoppio
Copy link
Collaborator

Scoppio commented May 9, 2025

Is this in service of a bug fix? If not, this might be better-suited for inclusion in the release after the upcoming one.

I get that, but its just moving a feature from MML to MM so its available to MM and MHQ, it only adds stuff and dont change other behaviors, so it is safe to get in

Comment on lines +56 to +70
/**
* @author Drake
* <p>
* Enhanced tabbed pane with closable, draggable tabs and additional
* action buttons. This component extends
* JTabbedPane to add the following features:
* <ul>
* <li>Closable tabs with an X button on each tab</li>
* <li>Ability to drag and reorder tabs</li>
* <li>Action buttons on the right side of the tab area (sticky and
* not)</li>
* <li>Detachable tabs that can be dragged out (or right-click) into
* floating windows</li>
* </ul>
*/
Copy link
Collaborator

Choose a reason for hiding this comment

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

we are not limiting javadoc to 80 columns, you can go wild (120 columns or 160... dont remember)

*/
public class EnhancedTabbedPane extends JTabbedPane {

private static record TabRestorationInfo(
Copy link
Collaborator

Choose a reason for hiding this comment

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

record dont need to be static (I dont know why)

@exeea exeea requested review from Copilot and Scoppio May 9, 2025 21:19
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 is focused on migrating the EnhancedTabbedPane functionality from MML to MM common, enhancing the tab and window state persistence features.

  • Improved window state persistence by saving x, y, width, and height.
  • Added methods to save and retrieve the tabs order and associated window properties.
  • Updated internationalization files with new messages for the EnhancedTabbedPane.

Reviewed Changes

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

Show a summary per file
File Description
megamek/src/megamek/client/ui/swing/GUIPreferences.java Added new methods for saving/restoring window size/position and tab order, and updated header comments.
megamek/i18n/megamek/common/messages_ru.properties Added new messages for EnhancedTabbedPane functionality.
megamek/i18n/megamek/common/messages_es.properties Added new messages for EnhancedTabbedPane functionality.
megamek/i18n/megamek/common/messages_de.properties Added new messages for EnhancedTabbedPane functionality.
megamek/i18n/megamek/common/messages.properties Added new messages for EnhancedTabbedPane functionality.
Comments suppressed due to low confidence (1)

megamek/src/megamek/client/ui/swing/GUIPreferences.java:469

  • [nitpick] The constant names _TABORDER and _WINDOW could be more descriptive. Consider renaming them to TAB_ORDER_KEY and WINDOW_KEY for better readability.
private static final String DELIMITER = ";";

@Scoppio Scoppio merged commit 1ce4803 into MegaMek:master May 11, 2025
6 checks passed
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.

4 participants