 |
Gridarta Editor
|
Go to the documentation of this file.
20 package net.sf.gridarta.gui.utils.tabbedpanel;
22 import java.awt.BorderLayout;
23 import java.awt.Component;
24 import java.awt.Container;
25 import java.util.IdentityHashMap;
27 import java.util.prefs.Preferences;
28 import javax.swing.JMenu;
29 import javax.swing.JPopupMenu;
35 import net.
sf.japi.swing.action.ActionBuilder;
36 import net.
sf.japi.swing.action.ActionBuilderFactory;
37 import net.
sf.japi.swing.action.ToggleAction;
38 import org.jetbrains.annotations.NotNull;
39 import org.jetbrains.annotations.Nullable;
53 private static final String
TAB_PREFIX =
"MainWindow.tab";
64 private static final ActionBuilder
ACTION_BUILDER = ActionBuilderFactory.getInstance().getActionBuilder(
"net.sf.gridarta");
83 private final Map<Component, Tab>
openTabs =
new IdentityHashMap<>();
90 if (prevTab !=
null) {
112 public void sizeChanged(@NotNull
final Component component,
final int size) {
120 public void size2Changed(@NotNull
final Location location,
final int size2) {
125 public int getSize2(
final Location location) {
131 setLayout(
new BorderLayout());
142 tabAdded(tab, buttonList, tab.isOpen());
164 if (tab.getLocation() == location) {
168 final boolean open = tab.isOpen();
184 if (tab.isAlternativeLocation() == splitMode) {
188 final boolean open = tab.isOpen();
191 buttonList.
selectButton(tab.getButton(), tab.isAlternativeLocation());
203 if (buttonList.getButtonCount() == 1) {
204 add(buttonList.getButtons(), tab.getLocation().getBorderLocation());
209 buttonList.selectButton(tab.getButton(), tab.isAlternativeLocation());
219 if (buttonList.getButtonCount() == 0) {
220 remove(buttonList.getButtons());
233 final JPopupMenu popupMenu = tab.getPopupMenu();
234 final ToggleAction splitModeAction = (ToggleAction)
ACTION_BUILDER.createToggle(
false,
"tabSplitMode", moveToActions);
235 splitModeAction.setSelected(tab.isAlternativeLocation());
236 popupMenu.insert(splitModeAction.createCheckBoxMenuItem(), 0);
237 tab.setSplitModeAction(splitModeAction);
240 final JMenu moveToMenu = tab.getMoveToMenu();
242 final Location location = tab.getLocation();
244 if (thisLocation != location) {
245 moveToMenu.add(
ACTION_BUILDER.createAction(
true,
"tabButtonMoveTo" + thisLocation.getName(), moveToActions));
255 openTabs.put(tab.getComponent(), tab);
void setComponent(@NotNull final Location location, @NotNull final Component component, final boolean alternativeLocation, final int size)
Sets the optional Component for a location.
boolean isAlternativeLocation()
Returns whether the button is shown in the alternative location.
Base package of all Gridarta classes.
void unsetComponent(@NotNull final Location location, final boolean alternativeLocation)
Unsets the optional Component for a location.
void open(@NotNull final Tab tab)
Opens a Tab.
void tabAdded(@NotNull final Tab tab, @NotNull final DoubleButtonList buttonList, final boolean open)
Called whenever a Tab has been added to a ButtonList.
Component getComponent()
Returns the Component that is shown when this tab is active.
A tab in a TabbedPanel component.
void closeInt(final Tab tab)
Closes a Tab but does not update the tab's open status.
Graphical User Interface of Gridarta.
void setSize(final int size)
Sets the tab's size.
final BorderPanel borderPanel
The BorderPanel.
Location getLocation()
Returns the tab's location.
A Component that always displays another component and optionally a number of tabs around it.
TabbedPanel(@NotNull final Component centerComponent)
Creates a new instance.
static final long serialVersionUID
The serial version UID.
void fillContextMenu(@NotNull final Tab tab, final boolean initialize)
Fills in context popup menu entries for a tab in a given location.
Interface for listeners interested in BorderPanel related events.
final Map< Component, Tab > openTabs
The Tabs currently shown in borderPanel.
Tab getActiveTab(@NotNull final Location location, final boolean alternativeLocation)
Returns the active Tab on a given Location of the main view.
final ButtonLists buttonLists
The list of buttons for each Location.
abstract String getName()
Returns a name for building resource keys.
A Component that permanently displays another Component and optionally displays more components on th...
void tabRemoved(@NotNull final DoubleButtonList buttonList)
Called whenever a Tab has been added from a ButtonList.
static final String TAB_PREFIX
The key used to store the preferred height of a tab.
void setTabSplitMode(@NotNull final Tab tab, final boolean splitMode)
Toggles split mode for the given tab.
static final ActionBuilder ACTION_BUILDER
The ActionBuilder.
Defines ActionMethods to move tab locations.
void addTab(@NotNull final Tab tab)
Adds a tab.
void close(@NotNull final Tab tab)
Closes a Tab.
final ButtonListsListener buttonListsListener
The ButtonListsListener attached to buttonLists.
static final Preferences PREFERENCES
The Preferences.
void moveTab(@NotNull final Tab tab, @NotNull final Location location)
Moves the tab to the given location.
Interface used as preferences location.