home *** CD-ROM | disk | FTP | other *** search
- package javax.swing.plaf.basic;
-
- import java.awt.Component;
- import java.awt.Container;
- import java.awt.Cursor;
- import java.awt.Dimension;
- import java.awt.Graphics;
- import java.awt.Insets;
- import java.beans.PropertyChangeEvent;
- import java.beans.PropertyChangeListener;
- import java.util.EventObject;
- import javax.swing.AbstractButton;
- import javax.swing.JButton;
- import javax.swing.JSplitPane;
- import javax.swing.UIManager;
- import javax.swing.border.Border;
-
- public class BasicSplitPaneDivider extends Container implements PropertyChangeListener {
- protected static final int ONE_TOUCH_SIZE = 6;
- protected static final int ONE_TOUCH_OFFSET = 2;
- protected DragController dragger;
- protected BasicSplitPaneUI splitPaneUI;
- protected int dividerSize = 0;
- protected Component hiddenDivider;
- protected JSplitPane splitPane;
- protected MouseHandler mouseHandler;
- protected int orientation;
- protected JButton leftButton;
- protected JButton rightButton;
- static final Cursor horizontalCursor = Cursor.getPredefinedCursor(11);
- static final Cursor verticalCursor = Cursor.getPredefinedCursor(9);
- static final Cursor defaultCursor = Cursor.getPredefinedCursor(0);
- private Border border;
-
- public BasicSplitPaneDivider(BasicSplitPaneUI var1) {
- ((Container)this).setLayout(new DividerLayout(this));
- this.setBasicSplitPaneUI(var1);
- this.orientation = this.splitPane.getOrientation();
- ((Component)this).setBackground(UIManager.getColor("SplitPane.background"));
- }
-
- public void setBasicSplitPaneUI(BasicSplitPaneUI var1) {
- if (this.splitPane != null) {
- this.splitPane.removePropertyChangeListener(this);
- if (this.mouseHandler != null) {
- this.splitPane.removeMouseListener(this.mouseHandler);
- this.splitPane.removeMouseMotionListener(this.mouseHandler);
- ((Component)this).removeMouseListener(this.mouseHandler);
- ((Component)this).removeMouseMotionListener(this.mouseHandler);
- this.mouseHandler = null;
- }
- }
-
- this.splitPaneUI = var1;
- if (var1 != null) {
- this.splitPane = var1.getSplitPane();
- if (this.splitPane != null) {
- if (this.mouseHandler == null) {
- this.mouseHandler = new MouseHandler(this);
- }
-
- this.splitPane.addMouseListener(this.mouseHandler);
- this.splitPane.addMouseMotionListener(this.mouseHandler);
- ((Component)this).addMouseListener(this.mouseHandler);
- ((Component)this).addMouseMotionListener(this.mouseHandler);
- this.splitPane.addPropertyChangeListener(this);
- if (this.splitPane.isOneTouchExpandable()) {
- this.oneTouchExpandableChanged();
- }
- }
- } else {
- this.splitPane = null;
- }
-
- }
-
- public BasicSplitPaneUI getBasicSplitPaneUI() {
- return this.splitPaneUI;
- }
-
- public void setDividerSize(int var1) {
- this.dividerSize = var1;
- }
-
- public int getDividerSize() {
- return this.dividerSize;
- }
-
- public void setBorder(Border var1) {
- Border var2 = this.border;
- this.border = var1;
- }
-
- public Border getBorder() {
- return this.border;
- }
-
- public Insets getInsets() {
- Border var1 = this.getBorder();
- return var1 != null ? var1.getBorderInsets(this) : super.getInsets();
- }
-
- public Dimension getPreferredSize() {
- return new Dimension(this.getDividerSize(), this.getDividerSize());
- }
-
- public Dimension getMinimumSize() {
- return this.getPreferredSize();
- }
-
- public void propertyChange(PropertyChangeEvent var1) {
- if (((EventObject)var1).getSource() == this.splitPane) {
- if (var1.getPropertyName().equals("orientation")) {
- this.orientation = this.splitPane.getOrientation();
- ((Container)this).invalidate();
- ((Container)this).validate();
- } else if (var1.getPropertyName().equals("oneTouchExpandable")) {
- this.oneTouchExpandableChanged();
- }
- }
-
- }
-
- public void paint(Graphics var1) {
- super.paint(var1);
- Border var2 = this.getBorder();
- if (var2 != null) {
- Dimension var3 = ((Component)this).getSize();
- var2.paintBorder(this, var1, 0, 0, var3.width, var3.height);
- }
-
- }
-
- protected void oneTouchExpandableChanged() {
- if (this.splitPane.isOneTouchExpandable() && this.leftButton == null && this.rightButton == null) {
- this.leftButton = this.createLeftOneTouchButton();
- if (this.leftButton != null) {
- this.leftButton.addActionListener(new OneTouchActionHandler(this, true));
- }
-
- this.rightButton = this.createRightOneTouchButton();
- if (this.rightButton != null) {
- this.rightButton.addActionListener(new OneTouchActionHandler(this, false));
- }
-
- if (this.leftButton != null && this.rightButton != null) {
- ((Container)this).add(this.leftButton);
- ((Container)this).add(this.rightButton);
- }
- }
-
- ((Container)this).invalidate();
- ((Container)this).validate();
- }
-
- protected JButton createLeftOneTouchButton() {
- 1 var1 = new 1(this);
- ((Component)var1).setCursor(defaultCursor);
- ((AbstractButton)var1).setFocusPainted(false);
- ((AbstractButton)var1).setBorderPainted(false);
- return var1;
- }
-
- protected JButton createRightOneTouchButton() {
- 2 var1 = new 2(this);
- ((Component)var1).setCursor(defaultCursor);
- ((AbstractButton)var1).setFocusPainted(false);
- ((AbstractButton)var1).setBorderPainted(false);
- return var1;
- }
-
- protected void prepareForDragging() {
- this.splitPaneUI.startDragging();
- }
-
- protected void dragDividerTo(int var1) {
- this.splitPaneUI.dragDividerTo(var1);
- }
-
- protected void finishDraggingTo(int var1) {
- this.splitPaneUI.finishDraggingTo(var1);
- }
- }
-