/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* A Basic L&F implementation of ToolBarUI. This implementation
* is a "combined" view/controller.
* <p>
*
* @author Georges Saab
* @author Jeff Shapiro
*/
{
private boolean floating;
private int floatingX;
private int floatingY;
// Rollover button implementation.
private boolean rolloverBorders = false;
private Hashtable<AbstractButton, Boolean> rolloverTable = new Hashtable<AbstractButton, Boolean>();
/**
* As of Java 2 platform v1.3 this previously undocumented field is no
* longer used.
* Key bindings are now defined by the LookAndFeel, please refer to
* the key bindings specification for further details.
*
* @deprecated As of Java 2 platform v1.3.
*/
/**
* As of Java 2 platform v1.3 this previously undocumented field is no
* longer used.
* Key bindings are now defined by the LookAndFeel, please refer to
* the key bindings specification for further details.
*
* @deprecated As of Java 2 platform v1.3.
*/
/**
* As of Java 2 platform v1.3 this previously undocumented field is no
* longer used.
* Key bindings are now defined by the LookAndFeel, please refer to
* the key bindings specification for further details.
*
* @deprecated As of Java 2 platform v1.3.
*/
/**
* As of Java 2 platform v1.3 this previously undocumented field is no
* longer used.
* Key bindings are now defined by the LookAndFeel, please refer to
* the key bindings specification for further details.
*
* @deprecated As of Java 2 platform v1.3.
*/
{
return new BasicToolBarUI();
}
{
// Set defaults
// Initialize instance vars
dockingSensitivity = 0;
floating = false;
{
}
}
{
// Clear defaults
// Clear instance vars
if (isFloating())
setFloating(false, null);
dragWindow = null;
}
protected void installDefaults( )
{
"ToolBar.background",
"ToolBar.foreground",
"ToolBar.font");
// Toolbar specific defaults
if ( dockingBorderColor == null ||
dockingBorderColor instanceof UIResource )
if ( floatingBorderColor == null ||
floatingBorderColor instanceof UIResource )
// ToolBar rollover button borders
if (rolloverProp == null) {
}
if ( rolloverProp != null ) {
}
if (rolloverBorder == null) {
}
if (nonRolloverBorder == null) {
}
if (nonRolloverToggleBorder == null) {
}
}
protected void uninstallDefaults( )
{
dockingColor = null;
}
protected void installComponents( )
{
}
protected void uninstallComponents( )
{
}
protected void installListeners( )
{
if ( dockingListener != null )
{
}
if (propertyListener != null) {
}
if ( toolBarContListener != null ) {
}
if ( toolBarFocusListener != null )
{
// Put focus listener on all components in toolbar
}
}
}
protected void uninstallListeners( )
{
if ( dockingListener != null )
{
}
if ( propertyListener != null )
{
}
if ( toolBarContListener != null )
{
}
if ( toolBarFocusListener != null )
{
// Remove focus listener from all components in toolbar
}
}
}
protected void installKeyboardActions( )
{
km);
"ToolBar.actionMap");
}
"ToolBar.ancestorInputMap");
}
return null;
}
}
protected void uninstallKeyboardActions( )
{
null);
}
{
int j;
switch ( direction )
{
case EAST:
case SOUTH:
j = focusedCompIndex + 1;
while ( j != focusedCompIndex )
{
if ( j >= nComp ) j = 0;
{
comp.requestFocus();
break;
}
}
break;
case WEST:
case NORTH:
j = focusedCompIndex - 1;
while ( j != focusedCompIndex )
{
{
comp.requestFocus();
break;
}
}
break;
default:
break;
}
}
/**
* Creates a rollover border for toolbar components. The
* rollover border will be installed if rollover borders are
* enabled.
* <p>
* Override this method to provide an alternate rollover border.
*
* @since 1.4
*/
}
new BasicBorders.RolloverMarginBorder());
}
/**
* Creates the non rollover border for toolbar components. This
* border will be installed as the border for components added
* to the toolbar if rollover borders are not enabled.
* <p>
* Override this method to provide an alternate rollover border.
*
* @since 1.4
*/
}
new BasicBorders.RolloverMarginBorder());
}
/**
* Creates a non rollover border for Toggle buttons in the toolbar.
*/
new BasicBorders.RolloverMarginBorder());
}
/**
* No longer used, use BasicToolBarUI.createFloatingWindow(JToolBar)
* @see #createFloatingWindow
*/
// Override createRootPane() to automatically resize
// the frame when contents change
protected JRootPane createRootPane() {
private boolean packing = false;
public void validate() {
super.validate();
if (!packing) {
packing = true;
pack();
packing = false;
}
}
};
return rootPane;
}
};
frame.setResizable(false);
return frame;
}
/**
* Creates a window which contains the toolbar after it has been
* dragged out from its container
* @return a <code>RootPaneContainer</code> object, containing the toolbar.
* @since 1.4
*/
class ToolBarDialog extends JDialog {
}
}
// Override createRootPane() to automatically resize
// the frame when contents change
protected JRootPane createRootPane() {
private boolean packing = false;
public void validate() {
super.validate();
if (!packing) {
packing = true;
pack();
packing = false;
}
}
};
return rootPane;
}
}
} else {
}
dialog.setResizable(false);
return dialog;
}
Container p;
p = p.getParent());
}
if(floatingToolBar == null) {
}
return dragWindow;
}
/**
* Returns a flag to determine whether rollover button borders
* are enabled.
*
* @return true if rollover borders are enabled; false otherwise
* @see #setRolloverBorders
* @since 1.4
*/
public boolean isRolloverBorders() {
return rolloverBorders;
}
/**
* Sets the flag for enabling rollover borders on the toolbar and it will
* also install the apropriate border depending on the state of the flag.
*
* @param rollover if true, rollover borders are installed.
* Otherwise non-rollover borders are installed
* @see #isRolloverBorders
* @since 1.4
*/
if ( rolloverBorders ) {
} else {
}
}
/**
* Installs rollover borders on all the child components of the JComponent.
* <p>
* This is a convenience method to call <code>setBorderToRollover</code>
* for each child component.
*
* @param c container which holds the child components (usally a JToolBar)
* @see #setBorderToRollover
* @since 1.4
*/
// Put rollover borders on buttons
if (component instanceof JComponent) {
}
}
}
/**
* Installs non-rollover borders on all the child components of the JComponent.
* A non-rollover border is the border that is installed on the child component
* while it is in the toolbar.
* <p>
* This is a convenience method to call <code>setBorderToNonRollover</code>
* for each child component.
*
* @param c container which holds the child components (usally a JToolBar)
* @see #setBorderToNonRollover
* @since 1.4
*/
// Put non-rollover borders on buttons. These borders reduce the margin.
if (component instanceof JComponent) {
}
}
}
/**
* Installs normal borders on all the child components of the JComponent.
* A normal border is the original border that was installed on the child
* component before it was added to the toolbar.
* <p>
* This is a convenience method to call <code>setBorderNormal</code>
* for each child component.
*
* @param c container which holds the child components (usally a JToolBar)
* @see #setBorderToNonRollover
* @since 1.4
*/
// Put back the normal borders on buttons
}
}
/**
* Sets the border of the component to have a rollover border which
* was created by the {@link #createRolloverBorder} method.
*
* @param c component which will have a rollover border installed
* @see #createRolloverBorder
* @since 1.4
*/
if (c instanceof AbstractButton) {
AbstractButton b = (AbstractButton)c;
}
// Only set the border if its the default border
if (b.getBorder() instanceof UIResource) {
b.setBorder(getRolloverBorder(b));
}
b.setRolloverEnabled(true);
}
}
/**
* Returns a rollover border for the button.
*
* @param b the button to calculate the rollover border for
* @return the rollover border
* @see #setBorderToRollover
* @since 1.6
*/
return rolloverBorder;
}
/**
* Sets the border of the component to have a non-rollover border which
* was created by the {@link #createNonRolloverBorder} method.
*
* @param c component which will have a non-rollover border installed
* @see #createNonRolloverBorder
* @since 1.4
*/
if (c instanceof AbstractButton) {
AbstractButton b = (AbstractButton)c;
}
// Only set the border if its the default border
if (b.getBorder() instanceof UIResource) {
b.setBorder(getNonRolloverBorder(b));
}
b.setRolloverEnabled(false);
}
}
/**
* Returns a non-rollover border for the button.
*
* @param b the button to calculate the non-rollover border for
* @return the non-rollover border
* @see #setBorderToNonRollover
* @since 1.6
*/
if (b instanceof JToggleButton) {
return nonRolloverToggleBorder;
} else {
return nonRolloverBorder;
}
}
/**
* Sets the border of the component to have a normal border.
* A normal border is the original border that was installed on the child
* component before it was added to the toolbar.
*
* @param c component which will have a normal border re-installed
* @see #createNonRolloverBorder
* @since 1.4
*/
if (c instanceof AbstractButton) {
AbstractButton b = (AbstractButton)c;
}
}
}
public void setFloatingLocation(int x, int y) {
floatingX = x;
floatingY = y;
}
public boolean isFloating() {
return floating;
}
if (toolBar.isFloatable()) {
boolean visible = false;
}
if (dragWindow != null)
dragWindow.setVisible(false);
this.floating = b;
if (floatingToolBar == null) {
}
if (b == true)
{
if (dockingSource == null)
{
}
if ( propertyListener != null )
if (floatingToolBar instanceof Window) {
if (visible) {
} else {
public void windowOpened(WindowEvent e) {
}
});
}
}
} else {
if (floatingToolBar == null)
p);
if (constraint == null) {
}
if (dockingSource== null)
if ( propertyListener != null )
}
if (dockingSourceParent != null)
}
}
{
if ( constraint != null )
{
}
return orientation;
}
{
if (dragWindow !=null)
}
/**
* Gets the color displayed when over a docking area
*/
return dockingColor;
}
/**
* Sets the color displayed when over a docking area
*/
this.dockingColor = c;
}
/**
* Gets the color displayed when over a floating area
*/
return floatingColor;
}
/**
* Sets the color displayed when over a floating area
*/
this.floatingColor = c;
}
if (lm instanceof BorderLayout) {
}
}
return false;
}
}
if (lm instanceof BorderLayout) {
}
}
if (p == null) return constraintBeforeFloating;
if (c.contains(p)) {
// North (Base distance on height for now!)
return BorderLayout.NORTH;
}
// East (Base distance on height for now!)
return BorderLayout.EAST;
}
// West (Base distance on height for now!)
return BorderLayout.WEST;
}
return BorderLayout.SOUTH;
}
}
return null;
}
{
if (toolBar.isFloatable())
{
try
{
if (dragWindow == null)
}
if (dockingSource == null)
global.y-dockingPosition.y);
} else {
}
if (dragWindow.isVisible() == false) {
dragWindow.show();
}
}
catch ( IllegalComponentStateException e )
{
}
}
}
{
if(toolBar.isFloatable())
{
try
{
}
if (dockingSource != null) {
global.y-dockingPosition.y);
setFloating(false, comparisonPoint);
} else {
setFloating(true, null);
}
} else {
setFloating(true, null);
}
}
catch ( IllegalComponentStateException e )
{
}
}
}
}
return handler;
}
{
return getHandler();
}
{
return getHandler();
}
{
return getHandler();
}
return getHandler();
}
return new FrameListener();
}
/**
* Paints the contents of the window used for dragging.
*
* @param g Graphics to paint to.
* @throws NullPointerException is <code>g</code> is null
* @since 1.5
*/
int w = dragWindow.getWidth();
int h = dragWindow.getHeight();
}
super(name);
}
if (NAVIGATE_RIGHT == key) {
} else if (NAVIGATE_LEFT == key) {
} else if (NAVIGATE_UP == key) {
} else if (NAVIGATE_DOWN == key) {
}
}
}
//
// ContainerListener
//
if (toolBarFocusListener != null) {
}
if (isRolloverBorders()) {
} else {
}
}
if (toolBarFocusListener != null) {
}
// Revert the button border
}
//
// FocusListener
//
}
//
// MouseInputListener (DockingListener)
//
boolean isDragging = false;
return;
}
isDragging = false;
}
return;
}
if (isDragging) {
}
isDragging = false;
}
return;
}
isDragging = true;
}
}
//
// PropertyChangeListener
//
if (propertyName == "lookAndFeel") {
} else if (propertyName == "orientation") {
// Search for JSeparator components and change it's orientation
// to match the toolbar and flip it's orientation.
} else {
}
// Flip the orientation.
}
}
}
} else if (propertyName == IS_ROLLOVER) {
}
}
}
if (toolBar.isFloatable()) {
if (dragWindow != null)
dragWindow.setVisible(false);
floating = false;
if (floatingToolBar == null)
constraint = "North";
}
} else {
constraint = "West";
}
}
if (dockingSource == null)
if (propertyListener != null)
if (dockingSourceParent != null)
}
}
}
// NOTE: This class exists only for backward compatability. All
// its functionality has been moved into Handler. If you need to add
// new functionality add it to the Handler, but make sure this
// class calls into the Handler.
getHandler().componentAdded(e);
}
getHandler().componentRemoved(e);
}
}
// NOTE: This class exists only for backward compatability. All
// its functionality has been moved into Handler. If you need to add
// new functionality add it to the Handler, but make sure this
// class calls into the Handler.
getHandler().focusGained(e);
}
getHandler().focusLost(e);
}
}
// NOTE: This class exists only for backward compatability. All
// its functionality has been moved into Handler. If you need to add
// new functionality add it to the Handler, but make sure this
// class calls into the Handler.
getHandler().propertyChange(e);
}
}
/**
* This class should be treated as a "protected" inner class.
* Instantiate it only within subclasses of BasicToolBarUI.
*/
// NOTE: This class exists only for backward compatability. All
// its functionality has been moved into Handler. If you need to add
// new functionality add it to the Handler, but make sure this
// class calls into the Handler.
protected boolean isDragging = false;
this.toolBar = t;
getHandler().tb = t;
}
getHandler().mouseClicked(e);
}
getHandler().mousePressed(e);
}
getHandler().mouseReleased(e);
}
getHandler().mouseEntered(e);
}
getHandler().mouseExited(e);
}
getHandler().mouseDragged(e);
}
getHandler().mouseMoved(e);
}
}
{
super(w);
}
/**
* Returns the orientation of the toolbar window when the toolbar is
* floating. The orientation is either one of <code>JToolBar.HORIZONTAL</code>
* or <code>JToolBar.VERTICAL</code>.
*
* @return the orientation of the toolbar window
* @since 1.6
*/
public int getOrientation() {
return orientation;
}
public void setOrientation(int o) {
if(isShowing()) {
if (o == this.orientation)
return;
this.orientation = o;
} else if( o == JToolBar.HORIZONTAL ) {
} else {
}
}
repaint();
}
}
return offset;
}
this.offset = p;
}
if (this.borderColor == c)
return;
this.borderColor = c;
repaint();
}
return this.borderColor;
}
paintDragWindow(g);
// Paint the children
super.paint(g);
}
}
}
}