home *** CD-ROM | disk | FTP | other *** search
- package javax.swing.plaf.basic;
-
- import java.awt.Color;
- import java.awt.Component;
- import java.awt.Dimension;
- import java.awt.Graphics;
- import java.awt.Insets;
- import java.awt.LayoutManager;
- import java.awt.Rectangle;
- import java.awt.event.ActionListener;
- import java.awt.event.FocusListener;
- import java.awt.peer.ComponentPeer;
- import java.awt.peer.LightweightPeer;
- import java.beans.PropertyChangeListener;
- import javax.swing.ActionMap;
- import javax.swing.InputMap;
- import javax.swing.JComponent;
- import javax.swing.JSplitPane;
- import javax.swing.KeyStroke;
- import javax.swing.LookAndFeel;
- import javax.swing.RepaintManager;
- import javax.swing.SwingUtilities;
- import javax.swing.UIManager;
- import javax.swing.border.Border;
- import javax.swing.plaf.ActionMapUIResource;
- import javax.swing.plaf.ComponentUI;
- import javax.swing.plaf.SplitPaneUI;
- import javax.swing.plaf.UIResource;
-
- public class BasicSplitPaneUI extends SplitPaneUI {
- protected static final String NON_CONTINUOUS_DIVIDER = "nonContinuousDivider";
- protected static int KEYBOARD_DIVIDER_MOVE_OFFSET = 3;
- protected JSplitPane splitPane;
- protected BasicHorizontalLayoutManager layoutManager;
- protected BasicSplitPaneDivider divider;
- protected PropertyChangeListener propertyChangeListener;
- protected FocusListener focusListener;
- protected int dividerSize;
- protected Component nonContinuousLayoutDivider;
- protected boolean draggingHW;
- protected int beginDragDividerLocation;
- protected KeyStroke upKey;
- protected KeyStroke downKey;
- protected KeyStroke leftKey;
- protected KeyStroke rightKey;
- protected KeyStroke homeKey;
- protected KeyStroke endKey;
- protected KeyStroke dividerResizeToggleKey;
- protected ActionListener keyboardUpLeftListener;
- protected ActionListener keyboardDownRightListener;
- protected ActionListener keyboardHomeListener;
- protected ActionListener keyboardEndListener;
- protected ActionListener keyboardResizeToggleListener;
- private int orientation;
- private int lastDragLocation;
- private boolean continuousLayout;
- private boolean dividerKeyboardResize;
- private boolean dividerLocationIsSet;
- boolean painted;
- boolean ignoreDividerLocationChange;
-
- public static ComponentUI createUI(JComponent var0) {
- return new BasicSplitPaneUI();
- }
-
- public void installUI(JComponent var1) {
- this.splitPane = (JSplitPane)var1;
- this.dividerLocationIsSet = false;
- this.dividerKeyboardResize = false;
- this.installDefaults();
- this.installListeners();
- this.installKeyboardActions();
- this.setLastDragLocation(-1);
- }
-
- protected void installDefaults() {
- LookAndFeel.installBorder(this.splitPane, "SplitPane.border");
- if (this.divider == null) {
- this.divider = this.createDefaultDivider();
- }
-
- this.divider.setBasicSplitPaneUI(this);
- Border var1 = this.divider.getBorder();
- if (var1 == null || !(var1 instanceof UIResource)) {
- this.divider.setBorder(UIManager.getBorder("SplitPaneDivider.border"));
- }
-
- this.setOrientation(this.splitPane.getOrientation());
- this.splitPane.setDividerSize((Integer)UIManager.get("SplitPane.dividerSize"));
- this.divider.setDividerSize(this.splitPane.getDividerSize());
- this.dividerSize = this.divider.getDividerSize();
- this.splitPane.add(this.divider, "divider");
- this.setContinuousLayout(this.splitPane.isContinuousLayout());
- this.resetLayoutManager();
- if (this.nonContinuousLayoutDivider == null) {
- this.setNonContinuousLayoutDivider(this.createDefaultNonContinuousLayoutDivider(), true);
- } else {
- this.setNonContinuousLayoutDivider(this.nonContinuousLayoutDivider, true);
- }
-
- }
-
- protected void installListeners() {
- if ((this.propertyChangeListener = this.createPropertyChangeListener()) != null) {
- this.splitPane.addPropertyChangeListener(this.propertyChangeListener);
- }
-
- if ((this.focusListener = this.createFocusListener()) != null) {
- this.splitPane.addFocusListener(this.focusListener);
- }
-
- }
-
- protected void installKeyboardActions() {
- InputMap var1 = this.getInputMap(1);
- SwingUtilities.replaceUIInputMap(this.splitPane, 1, var1);
- ActionMap var2 = this.getActionMap();
- SwingUtilities.replaceUIActionMap(this.splitPane, var2);
- }
-
- InputMap getInputMap(int var1) {
- return var1 == 1 ? (InputMap)UIManager.get("SplitPane.ancestorInputMap") : null;
- }
-
- ActionMap getActionMap() {
- ActionMap var1 = (ActionMap)UIManager.get("SplitPane.actionMap");
- if (var1 == null) {
- var1 = this.createActionMap();
- if (var1 != null) {
- UIManager.put("SplitPane.actionMap", var1);
- }
- }
-
- return var1;
- }
-
- ActionMap createActionMap() {
- ActionMapUIResource var1 = new ActionMapUIResource();
- ((ActionMap)var1).put("negativeIncrement", new KeyboardUpLeftAction());
- ((ActionMap)var1).put("positiveIncrement", new KeyboardDownRightAction());
- ((ActionMap)var1).put("selectMin", new KeyboardHomeAction());
- ((ActionMap)var1).put("selectMax", new KeyboardEndAction());
- ((ActionMap)var1).put("startResize", new KeyboardResizeToggleAction());
- ((ActionMap)var1).put("toggleFocus", new ToggleSideFocusAction());
- return var1;
- }
-
- public void uninstallUI(JComponent var1) {
- this.uninstallKeyboardActions();
- this.uninstallListeners();
- this.uninstallDefaults();
- this.dividerLocationIsSet = false;
- this.dividerKeyboardResize = false;
- this.splitPane = null;
- }
-
- protected void uninstallDefaults() {
- if (this.splitPane.getLayout() == this.layoutManager) {
- this.splitPane.setLayout((LayoutManager)null);
- }
-
- if (this.nonContinuousLayoutDivider != null) {
- this.splitPane.remove(this.nonContinuousLayoutDivider);
- }
-
- LookAndFeel.uninstallBorder(this.splitPane);
- Border var1 = this.divider.getBorder();
- if (var1 instanceof UIResource) {
- this.divider.setBorder((Border)null);
- }
-
- this.splitPane.remove(this.divider);
- this.divider.setBasicSplitPaneUI((BasicSplitPaneUI)null);
- this.layoutManager = null;
- this.divider = null;
- this.nonContinuousLayoutDivider = null;
- this.setNonContinuousLayoutDivider((Component)null);
- }
-
- protected void uninstallListeners() {
- if (this.propertyChangeListener != null) {
- this.splitPane.removePropertyChangeListener(this.propertyChangeListener);
- this.propertyChangeListener = null;
- }
-
- if (this.focusListener != null) {
- this.splitPane.removeFocusListener(this.focusListener);
- this.focusListener = null;
- }
-
- this.keyboardUpLeftListener = null;
- this.keyboardDownRightListener = null;
- this.keyboardHomeListener = null;
- this.keyboardEndListener = null;
- this.keyboardResizeToggleListener = null;
- }
-
- protected void uninstallKeyboardActions() {
- SwingUtilities.replaceUIActionMap(this.splitPane, (ActionMap)null);
- SwingUtilities.replaceUIInputMap(this.splitPane, 1, (InputMap)null);
- }
-
- protected PropertyChangeListener createPropertyChangeListener() {
- return new PropertyHandler(this);
- }
-
- protected FocusListener createFocusListener() {
- return new FocusHandler(this);
- }
-
- protected ActionListener createKeyboardUpLeftListener() {
- return new KeyboardUpLeftHandler(this);
- }
-
- protected ActionListener createKeyboardDownRightListener() {
- return new KeyboardDownRightHandler(this);
- }
-
- protected ActionListener createKeyboardHomeListener() {
- return new KeyboardHomeHandler(this);
- }
-
- protected ActionListener createKeyboardEndListener() {
- return new KeyboardEndHandler(this);
- }
-
- protected ActionListener createKeyboardResizeToggleListener() {
- return new KeyboardResizeToggleHandler(this);
- }
-
- public int getOrientation() {
- return this.orientation;
- }
-
- public void setOrientation(int var1) {
- this.orientation = var1;
- }
-
- public boolean isContinuousLayout() {
- return this.continuousLayout;
- }
-
- public void setContinuousLayout(boolean var1) {
- this.continuousLayout = var1;
- }
-
- public int getLastDragLocation() {
- return this.lastDragLocation;
- }
-
- public void setLastDragLocation(int var1) {
- this.lastDragLocation = var1;
- }
-
- int getKeyboardMoveIncrement() {
- return KEYBOARD_DIVIDER_MOVE_OFFSET;
- }
-
- public BasicSplitPaneDivider getDivider() {
- return this.divider;
- }
-
- protected Component createDefaultNonContinuousLayoutDivider() {
- return new 1(this);
- }
-
- protected void setNonContinuousLayoutDivider(Component var1) {
- this.setNonContinuousLayoutDivider(var1, true);
- }
-
- protected void setNonContinuousLayoutDivider(Component var1, boolean var2) {
- if (this.nonContinuousLayoutDivider != null && this.splitPane != null) {
- this.splitPane.remove(this.nonContinuousLayoutDivider);
- }
-
- this.nonContinuousLayoutDivider = var1;
- if (this.nonContinuousLayoutDivider != null && this.splitPane != null) {
- this.nonContinuousLayoutDivider.setLocation(-1000, -1000);
- Component var3 = this.splitPane.getLeftComponent();
- Component var4 = this.splitPane.getRightComponent();
- int var5 = this.splitPane.getDividerLocation();
- if (var3 != null) {
- this.splitPane.setLeftComponent((Component)null);
- }
-
- if (var4 != null) {
- this.splitPane.setRightComponent((Component)null);
- }
-
- this.splitPane.remove(this.divider);
- this.splitPane.add(this.nonContinuousLayoutDivider, "nonContinuousDivider", this.splitPane.getComponentCount());
- this.splitPane.setLeftComponent(var3);
- this.splitPane.setRightComponent(var4);
- this.splitPane.add(this.divider, "divider");
- if (var2) {
- this.splitPane.setDividerLocation(var5);
- }
-
- this.splitPane.revalidate();
- this.splitPane.paintImmediately(this.splitPane.getX(), this.splitPane.getY(), this.splitPane.getWidth(), this.splitPane.getHeight());
- }
-
- }
-
- public Component getNonContinuousLayoutDivider() {
- return this.nonContinuousLayoutDivider;
- }
-
- public JSplitPane getSplitPane() {
- return this.splitPane;
- }
-
- public BasicSplitPaneDivider createDefaultDivider() {
- return new BasicSplitPaneDivider(this);
- }
-
- public void resetToPreferredSizes(JSplitPane var1) {
- if (this.splitPane != null) {
- this.layoutManager.resetToPreferredSizes();
- this.splitPane.revalidate();
- this.layoutManager.layoutContainer(this.splitPane);
- this.splitPane.repaint();
- }
-
- }
-
- public void setDividerLocation(JSplitPane var1, int var2) {
- if (!this.ignoreDividerLocationChange) {
- this.dividerLocationIsSet = true;
- this.splitPane.revalidate();
- this.splitPane.repaint();
- } else {
- this.ignoreDividerLocationChange = false;
- }
-
- }
-
- public int getDividerLocation(JSplitPane var1) {
- return this.orientation == 1 ? this.divider.getLocation().x : this.divider.getLocation().y;
- }
-
- public int getMinimumDividerLocation(JSplitPane var1) {
- int var2 = 0;
- Component var3 = this.splitPane.getLeftComponent();
- if (var3 != null && var3.isVisible()) {
- Insets var4 = this.splitPane.getInsets();
- Dimension var5 = var3.getMinimumSize();
- if (this.orientation == 1) {
- var2 = var5.width;
- } else {
- var2 = var5.height;
- }
-
- if (var4 != null) {
- if (this.orientation == 1) {
- var2 += var4.left;
- } else {
- var2 += var4.top;
- }
- }
- }
-
- return var2;
- }
-
- public int getMaximumDividerLocation(JSplitPane var1) {
- Dimension var2 = this.splitPane.getSize();
- int var3 = 0;
- Component var4 = this.splitPane.getRightComponent();
- if (var4 != null) {
- Insets var5 = this.splitPane.getInsets();
- Dimension var6 = new Dimension(0, 0);
- if (var4.isVisible()) {
- var6 = var4.getMinimumSize();
- }
-
- if (this.orientation == 1) {
- var3 = var2.width - var6.width;
- } else {
- var3 = var2.height - var6.height;
- }
-
- var3 -= this.dividerSize;
- if (var5 != null) {
- if (this.orientation == 1) {
- var3 -= var5.right;
- } else {
- var3 -= var5.top;
- }
- }
- }
-
- return Math.max(this.getMinimumDividerLocation(this.splitPane), var3);
- }
-
- public void finishedPaintingChildren(JSplitPane var1, Graphics var2) {
- if (var1 == this.splitPane && this.getLastDragLocation() != -1 && !this.isContinuousLayout() && !this.draggingHW) {
- Dimension var3 = this.splitPane.getSize();
- var2.setColor(Color.darkGray);
- if (this.orientation == 1) {
- var2.fillRect(this.getLastDragLocation(), 0, this.dividerSize - 1, var3.height - 1);
- } else {
- var2.fillRect(0, this.lastDragLocation, var3.width - 1, this.dividerSize - 1);
- }
- }
-
- }
-
- public void paint(Graphics var1, JComponent var2) {
- this.painted = true;
- }
-
- public Dimension getPreferredSize(JComponent var1) {
- return this.splitPane != null ? this.layoutManager.preferredLayoutSize(this.splitPane) : new Dimension(0, 0);
- }
-
- public Dimension getMinimumSize(JComponent var1) {
- return this.splitPane != null ? this.layoutManager.minimumLayoutSize(this.splitPane) : new Dimension(0, 0);
- }
-
- public Dimension getMaximumSize(JComponent var1) {
- return this.splitPane != null ? this.layoutManager.maximumLayoutSize(this.splitPane) : new Dimension(0, 0);
- }
-
- public Insets getInsets(JComponent var1) {
- return null;
- }
-
- protected void resetLayoutManager() {
- if (this.orientation == 1) {
- this.layoutManager = new BasicHorizontalLayoutManager(this);
- } else {
- this.layoutManager = new BasicVerticalLayoutManager(this);
- }
-
- this.splitPane.setLayout(this.layoutManager);
- this.layoutManager.updateComponents();
- this.splitPane.revalidate();
- this.splitPane.repaint();
- }
-
- protected void startDragging() {
- Component var1 = this.splitPane.getLeftComponent();
- Component var2 = this.splitPane.getRightComponent();
- this.beginDragDividerLocation = this.getDividerLocation(this.splitPane);
- this.draggingHW = false;
- ComponentPeer var3;
- if (var1 != null && (var3 = var1.getPeer()) != null && !(var3 instanceof LightweightPeer)) {
- this.draggingHW = true;
- } else if (var2 != null && (var3 = var2.getPeer()) != null && !(var3 instanceof LightweightPeer)) {
- this.draggingHW = true;
- }
-
- if (this.orientation == 1) {
- this.setLastDragLocation(this.divider.getBounds().x);
- this.dividerSize = this.divider.getSize().width;
- if (!this.isContinuousLayout() && this.draggingHW) {
- this.nonContinuousLayoutDivider.setBounds(this.getLastDragLocation(), 0, this.dividerSize, this.splitPane.getHeight());
- }
- } else {
- this.setLastDragLocation(this.divider.getBounds().y);
- this.dividerSize = this.divider.getSize().height;
- if (!this.isContinuousLayout() && this.draggingHW) {
- this.nonContinuousLayoutDivider.setBounds(0, this.getLastDragLocation(), this.splitPane.getWidth(), this.dividerSize);
- }
- }
-
- }
-
- protected void dragDividerTo(int var1) {
- if (this.getLastDragLocation() != var1) {
- if (this.isContinuousLayout()) {
- this.splitPane.setDividerLocation(var1);
- this.setLastDragLocation(var1);
- } else {
- int var2 = this.getLastDragLocation();
- this.setLastDragLocation(var1);
- if (this.orientation == 1) {
- if (this.draggingHW) {
- this.nonContinuousLayoutDivider.setLocation(this.getLastDragLocation(), 0);
- } else {
- int var3 = this.splitPane.getHeight();
- this.splitPane.repaint(var2, 0, this.dividerSize, var3);
- this.splitPane.repaint(var1, 0, this.dividerSize, var3);
- }
- } else if (this.draggingHW) {
- this.nonContinuousLayoutDivider.setLocation(0, this.getLastDragLocation());
- } else {
- int var4 = this.splitPane.getWidth();
- this.splitPane.repaint(0, var2, var4, this.dividerSize);
- this.splitPane.repaint(0, var1, var4, this.dividerSize);
- }
- }
- }
-
- }
-
- protected void finishDraggingTo(int var1) {
- this.dragDividerTo(var1);
- this.setLastDragLocation(-1);
- if (!this.isContinuousLayout()) {
- Component var2 = this.splitPane.getLeftComponent();
- Rectangle var3 = var2.getBounds();
- if (this.draggingHW) {
- if (this.orientation == 1) {
- this.nonContinuousLayoutDivider.setLocation(-this.dividerSize, 0);
- } else {
- this.nonContinuousLayoutDivider.setLocation(0, -this.dividerSize);
- }
- }
-
- this.splitPane.setDividerLocation(var1);
- RepaintManager.currentManager(this.splitPane).validateInvalidComponents();
- this.splitPane.repaint();
- }
-
- }
-
- protected int getDividerBorderSize() {
- return 1;
- }
-
- // $FF: synthetic method
- static int access$002(BasicSplitPaneUI var0, int var1) {
- return var0.orientation = var1;
- }
-
- // $FF: synthetic method
- static boolean access$102(BasicSplitPaneUI var0, boolean var1) {
- return var0.dividerKeyboardResize = var1;
- }
-
- // $FF: synthetic method
- static boolean access$100(BasicSplitPaneUI var0) {
- return var0.dividerKeyboardResize;
- }
-
- // $FF: synthetic method
- static int access$000(BasicSplitPaneUI var0) {
- return var0.orientation;
- }
-
- // $FF: synthetic method
- static boolean access$200(BasicSplitPaneUI var0) {
- return var0.dividerLocationIsSet;
- }
-
- // $FF: synthetic method
- static boolean access$202(BasicSplitPaneUI var0, boolean var1) {
- return var0.dividerLocationIsSet = var1;
- }
- }
-