Gridarta Editor
net.sf.gridarta.gui.utils.GSplitPane Class Reference

A JSplitPane that keeps its size even upon ancestor layout changes and is restored upon editor restarts. More...

+ Inheritance diagram for net.sf.gridarta.gui.utils.GSplitPane:
+ Collaboration diagram for net.sf.gridarta.gui.utils.GSplitPane:

Public Member Functions

 GSplitPane (final int newOrientation, @NotNull final Component newLeftComponent, @NotNull final Component newRightComponent, @NotNull final String preferencesKey, final int defaultDividerLocation)
 Create a new GSplitPane. More...
 
void saveLocation ()
 Saves the current divider location into the preferences. More...
 
void setDividerLocation (final int location)
 

Private Member Functions

int getState (final int dividerLocation)
 Returns the minimized/maximized state for a given divider location. More...
 

Private Attributes

final List< ActionListener > actionListeners = new ArrayList<>()
 The ActionListeners attached to the "oneTouchExpandable" buttons of the JSplitPane. More...
 
final String defaultDividerLocation
 The default divider location. More...
 
final HierarchyListener hierarchyListener
 The HierarchyListener for updating the initial divider location. More...
 
final String preferencesKey
 The preferences key for restoring the divider location. More...
 

Static Private Attributes

static final String MAX = "max"
 The preferences value for a maximized divider. More...
 
static final String MIN = "min"
 The preferences value for a minimized divider. More...
 
static final Preferences PREFERENCES = Preferences.userNodeForPackage(MainControl.class)
 The preferences. More...
 
static final long serialVersionUID = 1L
 Serial Version UID. More...
 

Detailed Description

A JSplitPane that keeps its size even upon ancestor layout changes and is restored upon editor restarts.

The minimized or maximized state of the oneTouchExpandable buttons cannot be set programatically. Therefore calling JSplitPane#setDividerLocation(int) does not work reliably. This class attempts to set the minimized/maximized state by calling the ActionListeners attached to these buttons.

Author
Andreas Kirschbaum

Definition at line 50 of file GSplitPane.java.

Constructor & Destructor Documentation

◆ GSplitPane()

net.sf.gridarta.gui.utils.GSplitPane.GSplitPane ( final int  newOrientation,
@NotNull final Component  newLeftComponent,
@NotNull final Component  newRightComponent,
@NotNull final String  preferencesKey,
final int  defaultDividerLocation 
)

Create a new GSplitPane.

Parameters
newOrientationJSplitPane#HORIZONTAL_SPLIT or JSplitPane#VERTICAL_SPLIT.
newLeftComponentthe Component that will appear on the left of a horizontally-split pane, or at the top of a vertically-split pane
newRightComponentthe Component that will appear on the right of a horizontally-split pane, or at the bottom of a vertically-split pane
preferencesKeythe preferences key for restoring the divider location
defaultDividerLocationthe default divider location in case none has been saved;
-1
to not set the divider location if no default divider location has been saved

Definition at line 143 of file GSplitPane.java.

References net.sf.gridarta.gui.utils.GSplitPane.preferencesKey.

Member Function Documentation

◆ getState()

int net.sf.gridarta.gui.utils.GSplitPane.getState ( final int  dividerLocation)
private

Returns the minimized/maximized state for a given divider location.

Parameters
dividerLocationthe divider location to get the state of
Returns
the state:
-1
=minimized,
0
=normal,
+1
=maximized

Definition at line 246 of file GSplitPane.java.

Referenced by net.sf.gridarta.gui.utils.GSplitPane.saveLocation(), and net.sf.gridarta.gui.utils.GSplitPane.setDividerLocation().

+ Here is the caller graph for this function:

◆ saveLocation()

void net.sf.gridarta.gui.utils.GSplitPane.saveLocation ( )

Saves the current divider location into the preferences.

Definition at line 211 of file GSplitPane.java.

References net.sf.gridarta.gui.utils.GSplitPane.getState(), net.sf.gridarta.gui.utils.GSplitPane.MAX, and net.sf.gridarta.gui.utils.GSplitPane.MIN.

Referenced by net.sf.gridarta.gui.utils.GSplitPaneTestApplication.main().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setDividerLocation()

void net.sf.gridarta.gui.utils.GSplitPane.setDividerLocation ( final int  location)

Definition at line 233 of file GSplitPane.java.

References net.sf.gridarta.gui.utils.GSplitPane.getState().

+ Here is the call graph for this function:

Member Data Documentation

◆ actionListeners

final List<ActionListener> net.sf.gridarta.gui.utils.GSplitPane.actionListeners = new ArrayList<>()
private

The ActionListeners attached to the "oneTouchExpandable" buttons of the JSplitPane.

The size if either two or zero; zero if no action listeners could be found. If action listener have been found, index

0

is the minimize button, index

1

is the maximize button.

Definition at line 89 of file GSplitPane.java.

◆ defaultDividerLocation

final String net.sf.gridarta.gui.utils.GSplitPane.defaultDividerLocation
private

The default divider location.

Set to

null

to not change the divider location.

Definition at line 96 of file GSplitPane.java.

◆ hierarchyListener

final HierarchyListener net.sf.gridarta.gui.utils.GSplitPane.hierarchyListener
private
Initial value:
= new HierarchyListener() {
@Override
public void hierarchyChanged(final HierarchyEvent e) {
if ((e.getChangeFlags() & (long) HierarchyEvent.SHOWING_CHANGED) != 0L && isShowing()) {
removeHierarchyListener(hierarchyListener);
if (defaultDividerLocation == null) {
} else if (defaultDividerLocation.equals(MIN)) {
if (!actionListeners.isEmpty()) {
actionListeners.get(0).actionPerformed(new ActionEvent(GSplitPane.this, 0, ""));
}
} else if (defaultDividerLocation.equals(MAX)) {
if (!actionListeners.isEmpty()) {
actionListeners.get(1).actionPerformed(new ActionEvent(GSplitPane.this, 0, ""));
}
} else {
try {
} catch (final NumberFormatException ignored) {
}
}
}
}
}

The HierarchyListener for updating the initial divider location.

Definition at line 102 of file GSplitPane.java.

◆ MAX

final String net.sf.gridarta.gui.utils.GSplitPane.MAX = "max"
staticprivate

The preferences value for a maximized divider.

Definition at line 62 of file GSplitPane.java.

Referenced by net.sf.gridarta.gui.utils.GSplitPane.saveLocation().

◆ MIN

final String net.sf.gridarta.gui.utils.GSplitPane.MIN = "min"
staticprivate

The preferences value for a minimized divider.

Definition at line 56 of file GSplitPane.java.

Referenced by net.sf.gridarta.gui.utils.GSplitPane.saveLocation().

◆ PREFERENCES

final Preferences net.sf.gridarta.gui.utils.GSplitPane.PREFERENCES = Preferences.userNodeForPackage(MainControl.class)
staticprivate

The preferences.

Definition at line 73 of file GSplitPane.java.

◆ preferencesKey

final String net.sf.gridarta.gui.utils.GSplitPane.preferencesKey
private

The preferences key for restoring the divider location.

Definition at line 79 of file GSplitPane.java.

Referenced by net.sf.gridarta.gui.utils.GSplitPane.GSplitPane().

◆ serialVersionUID

final long net.sf.gridarta.gui.utils.GSplitPane.serialVersionUID = 1L
staticprivate

Serial Version UID.

Definition at line 67 of file GSplitPane.java.


The documentation for this class was generated from the following file: