001: /*
002: * (C) Copyright SimulacraMedia 2003. All rights reserved.
003: *
004: * Created on 23-Nov-2003
005: *
006: */
007: package org.openharmonise.him.displaycomponents.table.title;
008:
009: import java.awt.Component;
010: import java.awt.event.ComponentAdapter;
011: import java.awt.event.ComponentEvent;
012: import java.beans.PropertyChangeEvent;
013: import java.beans.PropertyChangeListener;
014:
015: import javax.swing.JSplitPane;
016:
017: /**
018: * Spacialisation of JSplitPane that will not allow the user to move it.
019: * This enables us to place the {@link com.simulacramedia.contentmanager.displaycomponents.table.title.TitleBar}
020: * at the top of the table view.
021: *
022: * @author Matthew Large
023: * @version $Revision: 1.1 $
024: *
025: */
026: public class TitleBarSplitPane extends JSplitPane {
027:
028: private static int HEIGHT = 30;
029:
030: /**
031: *
032: */
033: public TitleBarSplitPane() {
034: super ();
035: this .setup();
036: }
037:
038: /**
039: * @param newOrientation
040: */
041: public TitleBarSplitPane(int newOrientation) {
042: super (newOrientation);
043: this .setup();
044: }
045:
046: /**
047: * @param newOrientation
048: * @param newContinuousLayout
049: */
050: public TitleBarSplitPane(int newOrientation,
051: boolean newContinuousLayout) {
052: super (newOrientation, newContinuousLayout);
053: this .setup();
054: }
055:
056: /**
057: * @param newOrientation
058: * @param newLeftComponent
059: * @param newRightComponent
060: */
061: public TitleBarSplitPane(int newOrientation,
062: Component newLeftComponent, Component newRightComponent) {
063: super (newOrientation, newLeftComponent, newRightComponent);
064: this .setup();
065: }
066:
067: /**
068: * @param newOrientation
069: * @param newContinuousLayout
070: * @param newLeftComponent
071: * @param newRightComponent
072: */
073: public TitleBarSplitPane(int newOrientation,
074: boolean newContinuousLayout, Component newLeftComponent,
075: Component newRightComponent) {
076: super (newOrientation, newContinuousLayout, newLeftComponent,
077: newRightComponent);
078: this .setup();
079: }
080:
081: /* (non-Javadoc)
082: * @see javax.swing.JSplitPane#setDividerLocation(double)
083: */
084: public void setDividerLocation(double loc) {
085: super .setDividerLocation(new Integer(HEIGHT).intValue());
086: }
087:
088: /* (non-Javadoc)
089: * @see com.simulacramedia.contentmanager.window.swing.ExtendedSplitPane#setExtDividerLocation(int)
090: */
091: public void setExtDividerLocation(int loc) {
092: super .setDividerLocation(new Integer(HEIGHT).intValue());
093: }
094:
095: private void setup() {
096: this .setOneTouchExpandable(true);
097: this .setContinuousLayout(true);
098: this .setDividerSize(0);
099: this .setExtDividerLocation(HEIGHT);
100: }
101:
102: public class DividerListener extends ComponentAdapter implements
103: PropertyChangeListener {
104: double percentage = 1.0;
105: boolean ignore = false;
106:
107: public void propertyChange(PropertyChangeEvent event) {
108: String prop = event.getPropertyName();
109: JSplitPane split = (JSplitPane) event.getSource();
110: if (prop.equals("lastDividerLocation")) {
111: if (ignore) {
112: ignore = false;
113: } else {
114: setExtDividerLocation(new Integer(HEIGHT)
115: .intValue());
116: }
117: }
118: }
119:
120: public void componentResized(ComponentEvent event) {
121: ignore = true;
122: setExtDividerLocation(new Integer(HEIGHT).intValue());
123: repaint();
124: }
125: }
126:
127: }
|