20 package net.sf.gridarta.gui.utils;
22 import java.awt.Component;
23 import java.awt.Container;
24 import java.awt.Dimension;
25 import java.awt.event.ActionEvent;
26 import java.awt.event.ActionListener;
27 import java.awt.event.HierarchyEvent;
28 import java.awt.event.HierarchyListener;
29 import java.util.ArrayList;
30 import java.util.List;
31 import java.util.prefs.Preferences;
32 import javax.swing.AbstractButton;
33 import javax.swing.JSplitPane;
34 import javax.swing.border.EmptyBorder;
36 import org.jetbrains.annotations.NotNull;
37 import org.jetbrains.annotations.Nullable;
56 private static final String
MIN =
"min";
62 private static final String
MAX =
"max";
105 public void hierarchyChanged(
final HierarchyEvent e) {
106 if ((e.getChangeFlags() & HierarchyEvent.SHOWING_CHANGED) != 0L && isShowing()) {
121 }
catch (
final NumberFormatException ignored) {
144 super(newOrientation, newLeftComponent, newRightComponent);
146 setOneTouchExpandable(
true);
158 setBorder(
new EmptyBorder(0, 0, 0, 0));
159 for (
final Component component : getComponents()) {
160 if (component != newLeftComponent && component != newRightComponent) {
161 if (component instanceof Container) {
162 final Container container = (Container) component;
163 for (
final Component component2 : container.getComponents()) {
164 if (component2 instanceof AbstractButton) {
165 final AbstractButton button = (AbstractButton) component2;
166 for (
final ActionListener actionListener : button.getActionListeners()) {
167 if (actionListener.getClass().getName().endsWith(
"$OneTouchActionHandler")) {
169 button.removeActionListener(actionListener);
171 button.addActionListener(e -> {
172 getRightComponent().setVisible(
true);
173 actionListener.actionPerformed(e);
176 button.addActionListener(e -> {
177 getLeftComponent().setVisible(
true);
178 actionListener.actionPerformed(e);
193 if (this.defaultDividerLocation !=
null) {
202 final int dividerLocation = getDividerLocation();
203 if (dividerLocation != -1) {
205 switch (
getState(dividerLocation)) {
211 value = Integer.toString(dividerLocation);
224 super.setDividerLocation(location);
225 final int state =
getState(location);
226 getLeftComponent().setVisible(state != -1);
227 getRightComponent().setVisible(state != +1);
237 final Dimension leftSize = leftComponent.getMinimumSize();
238 final Dimension rightSize = rightComponent.getMinimumSize();
239 final int minLimit = getOrientation() == HORIZONTAL_SPLIT ? leftSize.width : leftSize.height;
240 final int maxLimit = getOrientation() == HORIZONTAL_SPLIT ? getWidth() - rightSize.width - getDividerSize() : getHeight() - rightSize.height - getDividerSize();
241 if (dividerLocation < minLimit) {
244 if (dividerLocation > maxLimit) {