 |
Gridarta Editor
|
Go to the documentation of this file.
20 package net.sf.gridarta.gui.utils.tabbedpanel;
22 import java.awt.Component;
23 import java.awt.Dimension;
24 import java.awt.Insets;
25 import java.awt.event.MouseAdapter;
26 import java.awt.event.MouseEvent;
27 import java.awt.event.MouseListener;
28 import java.util.Collection;
29 import java.util.MissingResourceException;
30 import java.util.concurrent.CopyOnWriteArrayList;
31 import java.util.prefs.Preferences;
32 import javax.swing.AbstractButton;
33 import javax.swing.Action;
34 import javax.swing.JComponent;
35 import javax.swing.JMenu;
36 import javax.swing.JPopupMenu;
41 import net.
sf.japi.swing.action.ActionBuilder;
42 import net.
sf.japi.swing.action.ActionBuilderFactory;
43 import net.
sf.japi.swing.action.ToggleAction;
44 import org.jetbrains.annotations.NotNull;
45 import org.jetbrains.annotations.Nullable;
59 private static final int SPACE = 6;
83 private static final String
TAB_LOCATION =
"MainWindow.tab_location.";
95 private static final ActionBuilder
ACTION_BUILDER = ActionBuilderFactory.getInstance().getActionBuilder(
"net.sf.gridarta");
130 private final Collection<TabListener>
listeners =
new CopyOnWriteArrayList<>();
199 public void mousePressed(@NotNull
final MouseEvent e) {
204 public void mouseReleased(@NotNull
final MouseEvent e) {
212 private void checkPopup(@NotNull
final MouseEvent e) {
213 if (e.isPopupTrigger()) {
214 getPopupMenu().show(e.getComponent(), e.getX(), e.getY());
233 final Dimension preferredSize =
component.getPreferredSize();
236 final Dimension minimumSize =
component.getMinimumSize();
237 width = Math.max(defaultWidth, minimumSize.width);
238 height = Math.max(defaultHeight, minimumSize.height);
244 }
catch (
final IllegalArgumentException ignored) {
252 throw new MissingResourceException(
"missing action ",
MenuUtils.class.getName(),
"tabButtonMoveTo");
263 final int acceleratorIndex =
index < 10 ?
index : -1;
267 if (acceleratorIndex != -1) {
268 result.setMnemonic(
'0' +
index);
416 if (this.open ==
open) {
Severity severity
The tab's Severity.
static final String TAB_OPEN_PREFIX
The key used to store the open status of a tab.
Interface for listeners interested in Tab related events.
boolean alternativeLocation
Whether the tab is shown in the alternative location (.
final JComponent component
The JComponent that is shown when this tab is active.
final TabButtonAction action
The button's action.
boolean isAlternativeLocation()
Returns whether the button is shown in the alternative location.
Base package of all Gridarta classes.
final JPopupMenu popupMenu
The button's context menu.
AbstractButton getButton()
Returns the AbstractButton for showing or hiding the component.
final int index
The tab's index for ordering.
Component getComponent()
Returns the Component that is shown when this tab is active.
void removeTabListener(@NotNull final TabListener listener)
Removes a TabListener to be notified.
A tab in a TabbedPanel component.
static final String TAB_ALT_LOCATION
The key used to store the current location of a tab.
createButton
The location on the top side.
Graphical User Interface of Gridarta.
JMenu getMoveToMenu()
Returns the "Move To" menu within the button's context menu.
Severity getSeverity()
Returns the tab's Severity.
AbstractButton createButton()
Creates a button for this tab.
Severity levels for colors of tabs.
static final ActionBuilder ACTION_BUILDER
The ActionBuilder.
void setSize(final int size)
Sets the tab's size.
Location getLocation()
Returns the tab's location.
final String ident
The tab's identification string.
final Collection< TabListener > listeners
The registered TabListeners to notify.
int width
The tab's width when in locations Location#LEFT or {}.
void setAlternativeLocation(final boolean alternativeLocation)
Sets whether the button is shown in the alternative location.
JPopupMenu getPopupMenu()
Returns the button's context menu.
boolean open
The tab's open status.
abstract boolean isTopOrBottom()
Returns whether this location is TOP or BOTTOM.
int height
The tab's height when in locations Location#TOP or {}.
void addTabListener(@NotNull final TabListener listener)
Adds a TabListener to be notified.
boolean isOpen()
Returns the tab's open status.
Location location
The tab's location.
static final String TAB_HEIGHT_PREFIX
The key used to store the preferred height of a tab.
void setSplitModeAction(@Nullable final ToggleAction splitModeAction)
Sets the ToggleAction to update if the "split mode" state changes.
Tab(@NotNull final String ident, @NotNull final JComponent component, @NotNull final Location defaultLocation, final boolean alternativeLocation, final int index, final boolean defaultOpen)
Creates a new instance.
static final String TAB_WIDTH_PREFIX
The key used to store the preferred width of a tab.
void setLocation(@NotNull final Location location)
Sets the tab's location.
final MouseListener mouseListener
The MouseListener attached to button to open the context menu.
ToggleAction splitModeAction
The ToggleAction to update if the "split mode" state changes.
void setSeverity(@NotNull final Severity severity)
Sets the tab's Severity.
static final Preferences PREFERENCES
The Preferences.
void setOpen(final boolean open)
Sets the tab's open status.
AbstractButton button
The AbstractButton for showing or hiding the JComponent.
final JMenu moveToMenu
The "Move To" menu within popupMenu.
static final int SPACE
Additional space before and after the buttons' text.
DEFAULT
The tab contents are unchanged from defaults.
int getSize()
Returns the tab's size.
static final String TAB_LOCATION
The key used to store the current location of a tab.
Interface used as preferences location.