-
Notifications
You must be signed in to change notification settings - Fork 332
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
Conversation
There was a problem hiding this 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; }
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. |
Codecov ReportAttention: Patch coverage is
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. 🚀 New features to boost your workflow:
|
* @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
* @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
* @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
* @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
* @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
/** | ||
* 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
There was a problem hiding this 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
* @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
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 |
/** | ||
* @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> | ||
*/ |
There was a problem hiding this comment.
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( |
There was a problem hiding this comment.
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)
There was a problem hiding this 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 = ";";
This PR moves the EnhancedTabbedPane from MML to MM common.
This PR will allow to use the new tabs in MM and MHQ
This PR is required for #1867