Package megameklab.ui
Class MegaMekLabTabbedUI
java.lang.Object
java.awt.Component
java.awt.Container
java.awt.Window
java.awt.Frame
javax.swing.JFrame
megameklab.ui.MegaMekLabTabbedUI
- All Implemented Interfaces:
ImageObserver,MenuContainer,Serializable,EventListener,Accessible,ChangeListener,RootPaneContainer,WindowConstants,MenuBarOwner,AppCloser
Replaces
MegaMekLabMainUI as the top-level window for MML. Holds several MegaMekLabMainUIs as tabs,
allowing many units to be open at once.- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class javax.swing.JFrame
JFrame.AccessibleJFrameNested classes/interfaces inherited from class java.awt.Frame
Frame.AccessibleAWTFrameNested classes/interfaces inherited from class java.awt.Window
Window.AccessibleAWTWindow, Window.TypeNested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainerNested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy -
Field Summary
Fields inherited from class javax.swing.JFrame
accessibleContext, rootPane, rootPaneCheckingEnabledFields inherited from class java.awt.Frame
CROSSHAIR_CURSOR, DEFAULT_CURSOR, E_RESIZE_CURSOR, HAND_CURSOR, ICONIFIED, MAXIMIZED_BOTH, MAXIMIZED_HORIZ, MAXIMIZED_VERT, MOVE_CURSOR, N_RESIZE_CURSOR, NE_RESIZE_CURSOR, NORMAL, NW_RESIZE_CURSOR, S_RESIZE_CURSOR, SE_RESIZE_CURSOR, SW_RESIZE_CURSOR, TEXT_CURSOR, W_RESIZE_CURSOR, WAIT_CURSORFields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENTFields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTHFields inherited from interface javax.swing.WindowConstants
DISPOSE_ON_CLOSE, DO_NOTHING_ON_CLOSE, EXIT_ON_CLOSE, HIDE_ON_CLOSE -
Constructor Summary
ConstructorsConstructorDescriptionMegaMekLabTabbedUI(MegaMekLabMainUI... entities) Constructs a new MegaMekLabTabbedUI instance, which serves as the main tabbed UI for managing multiple MegaMekLabMainUI editors. -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds a new tab with the given unit to the tabbed user interface.voidDeletes the current tab.voidcreateNewUnit(long type, boolean primitive, boolean industrial) Create a new blank editor of the given unit type.booleanexit()Override to provide specific exit handling.Retrieves the currently selected editor from the tabbed user interface.List<megamek.common.units.Entity>static MegaMekLabMainUIgetEditorForEntity(megamek.common.units.Entity entityToFind) Finds an open editor tab for the given entitymegamek.common.units.EntitygetFrame()booleanbooleanstatic booleanisOpen()booleanisTabEditorSelected(MegaMekLabMainUI editor) Checks if the given editor is the currently selected tab in the tabbed UI.voidnewTab()voidThis method is called when this menubar owner should refresh all displayed content (all tabs in the unit main UIs).static voidrefreshEntity(megamek.common.units.Entity entityToFind) Refreshes the display of the given entity.voidRefreshes the menu bar.voidvoidsetTabName(MegaMekLabMainUI editor, String tabName) Updates the name of the currently selected tab in the tabbed user interface.static voidshowEditorForEntity(megamek.common.units.Entity entityToFind) Finds an open editor tab for the given entity, brings its window to the front, and selects the tab.voidvoidswitchUnit(long type, boolean primitive) Replaces the current editor with a new blank one of the given unit type.Methods inherited from class javax.swing.JFrame
addImpl, createRootPane, frameInit, getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getGraphics, getJMenuBar, getLayeredPane, getRootPane, getTransferHandler, isDefaultLookAndFeelDecorated, isRootPaneCheckingEnabled, paramString, processWindowEvent, remove, repaint, setContentPane, setDefaultCloseOperation, setDefaultLookAndFeelDecorated, setGlassPane, setIconImage, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, setTransferHandler, updateMethods inherited from class java.awt.Frame
addNotify, getCursorType, getExtendedState, getFrames, getIconImage, getMaximizedBounds, getMenuBar, getState, getTitle, isResizable, isUndecorated, remove, removeNotify, setBackground, setCursor, setExtendedState, setMaximizedBounds, setMenuBar, setOpacity, setResizable, setShape, setState, setTitle, setUndecoratedMethods inherited from class java.awt.Window
addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, dispose, getBackground, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getIconImages, getInputContext, getListeners, getLocale, getModalExclusionType, getMostRecentFocusOwner, getOpacity, getOwnedWindows, getOwner, getOwnerlessWindows, getShape, getToolkit, getType, getWarningString, getWindowFocusListeners, getWindowListeners, getWindows, getWindowStateListeners, hide, isActive, isAlwaysOnTop, isAlwaysOnTopSupported, isAutoRequestFocus, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isOpaque, isShowing, isValidateRoot, pack, paint, postEvent, processEvent, processWindowFocusEvent, processWindowStateEvent, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, reshape, setAlwaysOnTop, setAutoRequestFocus, setBounds, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setIconImages, setLocation, setLocation, setLocationByPlatform, setLocationRelativeTo, setMinimumSize, setModalExclusionType, setSize, setSize, setType, setVisible, show, toBack, toFrontMethods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, transferFocusDownCycle, validate, validateTreeMethods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, requestFocusInWindow, resize, resize, revalidate, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setMaximumSize, setMixingCutoutShape, setName, setPreferredSize, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycleMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface megameklab.ui.MenuBarOwner
changeTheme, changeTheme, safetyPromptMethods inherited from interface java.awt.MenuContainer
getFont, postEvent
-
Constructor Details
-
MegaMekLabTabbedUI
Constructs a new MegaMekLabTabbedUI instance, which serves as the main tabbed UI for managing multiple MegaMekLabMainUI editors. Automatically initializes a default BMMainUI instance if no entities are provided.- Parameters:
entities- A variable number of MegaMekLabMainUI instances that will be added as tabs to the UI. If no entities are provided, a default BMMainUI instance will be created and added.
-
-
Method Details
-
isOpen
public static boolean isOpen() -
isTabEditorSelected
Checks if the given editor is the currently selected tab in the tabbed UI.- Parameters:
editor- The MegaMekLabMainUI instance to check against the currently selected- Returns:
- True if the given editor is the currently selected tab, false otherwise.
-
refreshEntity
public static void refreshEntity(megamek.common.units.Entity entityToFind) Refreshes the display of the given entity. This method is called when the entity is modified externally.- Parameters:
entityToFind-Entityto be refreshed.
-
getEditorForEntity
Finds an open editor tab for the given entity- Parameters:
entityToFind- The entity
-
showEditorForEntity
public static void showEditorForEntity(megamek.common.units.Entity entityToFind) Finds an open editor tab for the given entity, brings its window to the front, and selects the tab. If no editor is found, creates a new tab in the first available window.- Parameters:
entityToFind- The entity to show the editor for.
-
getActiveEditor
Retrieves the currently selected editor from the tabbed user interface.- Returns:
- The currently selected MegaMekLabMainUI instance, which represents the active editor in the tabbed UI, or null if no tab is selected.
-
setTabName
Updates the name of the currently selected tab in the tabbed user interface. Should typically be called when the name of the unit being edited changes.- Parameters:
editor- The editor for which the tab name needs to be settabName- The new name to be set for the currently selected tab.
-
createNewUnit
public void createNewUnit(long type, boolean primitive, boolean industrial) Create a new blank editor of the given unit type.- Parameters:
type- the type of unit to load for the new editor UIprimitive- whether the unit is primitiveindustrial- whether the unit is an IndustrialMek
-
switchUnit
public void switchUnit(long type, boolean primitive) Replaces the current editor with a new blank one of the given unit type. Disposes of the old editor UI after the new one is initialized.- Parameters:
type- the type of unit to load for the new editor UIprimitive- whether the unit is primitive
-
addUnit
Adds a new tab with the given unit to the tabbed user interface.- Parameters:
entity- The Entity object representing the unit to be added.filename- The name of the file associated with the unit being added.setSelected- Whether to set the new tab as the currently selected tab.
-
exit
public boolean exit()Description copied from interface:AppCloserOverride to provide specific exit handling. Return false to prevent exiting the application, true to confirm it. By default, this method does nothing and returns true. -
refreshAll
public void refreshAll()Description copied from interface:MenuBarOwnerThis method is called when this menubar owner should refresh all displayed content (all tabs in the unit main UIs). By default, this method does nothing.- Specified by:
refreshAllin interfaceMenuBarOwner
-
newTab
public void newTab() -
closeCurrentTab
public void closeCurrentTab()Deletes the current tab. This does not issue the safety prompt, it is up to the caller to do so! -
reopenTab
public void reopenTab() -
hasClosedTabs
public boolean hasClosedTabs() -
getFrame
- Specified by:
getFramein interfaceMenuBarOwner- Returns:
- A frame of this menubar owner to use as a parent for dialogs.
-
getEntity
public megamek.common.units.Entity getEntity()- Specified by:
getEntityin interfaceMenuBarOwner- Returns:
- The entity currently worked on or null.
-
getFileName
- Specified by:
getFileNamein interfaceMenuBarOwner- Returns:
- The file name of the currently worked on unit or an empty String.
-
hasEntityNameChanged
public boolean hasEntityNameChanged()- Specified by:
hasEntityNameChangedin interfaceMenuBarOwner- Returns:
- True if the entity's name has changed since load.
-
refreshMenuBar
public void refreshMenuBar()Description copied from interface:MenuBarOwnerRefreshes the menu bar. Updates the recent units in the File menu.- Specified by:
refreshMenuBarin interfaceMenuBarOwner
-
getMMLMenuBar
- Specified by:
getMMLMenuBarin interfaceMenuBarOwner
-
stateChanged
- Specified by:
stateChangedin interfaceChangeListener
-
getAllEntities
-