bibliothek.gui.dock.station.toolbar.ToolbarStrategy Maven / Gradle / Ivy
The newest version!
/*
* Bibliothek - DockingFrames
* Library built on Java/Swing, allows the user to "drag and drop"
* panels containing any Swing-Component the developer likes to add.
*
* Copyright (C) 2012 Herve Guillaume, Benjamin Sigg
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* Herve Guillaume
* [email protected]
* FR - France
*
* Benjamin Sigg
* [email protected]
* CH - Switzerland
*/
package bibliothek.gui.dock.station.toolbar;
import bibliothek.gui.DockStation;
import bibliothek.gui.Dockable;
import bibliothek.gui.dock.util.PropertyKey;
import bibliothek.gui.dock.util.property.ConstantPropertyFactory;
/**
* A {@link ToolbarStrategy} defines how different parts of a toolbar interact
* with each other.
*
* @author Benjamin Sigg
*/
public interface ToolbarStrategy {
/**
* {@link PropertyKey} for the current {@link ToolbarStrategy} to use.
*/
public static final PropertyKey STRATEGY = new PropertyKey( "dock.toolbarStrategy", new ConstantPropertyFactory( new DefaultToolbarStrategy() ), true );
/**
* As toolbars have constraints on which {@link Dockable} can be a child of
* which {@link DockStation} often additional layers between a specific
* {@link DockStation} and a {@link Dockable} are required. This method
* defines what these layers are.
* This method must not add child
to any {@link DockStation}.
* @param parent some {@link DockStation} which is going to become a direct or indirect parent of child
* @param child some {@link Dockable} that is going to be a direct or indirect child of parent
* @return the element that is actually added to parent
as
* direct child. This can either be child
, or a new
* empty dockable {@link DockStation}. A
* value of null
indicates that child
can
* never be any kind of child of parent
. The other
* methods of this {@link ToolbarStrategy} should however be
* implemented such that this case never happens during a drag and
* drop operation.
*/
public Dockable ensureToolbarLayer( DockStation parent, Dockable child );
/**
* Tells whether the station parent
is a valid choice for the
* dockable child
, assuming that child represents a component
* of a toolbar, e.g. a button.
* @param parent a potential parent for child
. It might be that an
* additional layer between parent
and child
will be created.
* @param child the potential new child of parent
* @param strongRelation if true
, then it must be possible to add
* child
directly to parent
, if false
the relation
* must be valid after calling {@link #ensureToolbarLayer(DockStation, Dockable)}.
* @return true
if a combination between child
and parent
is possible
*/
public boolean isToolbarGroupPartParent( DockStation parent, Dockable child, boolean strongRelation );
/**
* Tells whether dockable
represents a group of toolbar
* components, e.g. a group of buttons. Also a single toolbar component can
* be understood to be a group of components.
* @param dockable some dockable that is drag and dropped
* @return true
if dockable
represents a group of toolbar components
*/
public boolean isToolbarGroupPart( Dockable dockable );
/**
* Tells whether dockable
represents a toolbar. A toolbar can
* either be a single item like a button, a
* {@link #isToolbarGroupPart(Dockable) group of such items}, or a real
* toolbar.
* @param dockable the element to test
* @return true
if dockable
represents a toolbar or a part of a toolbar
*/
public boolean isToolbarPart( Dockable dockable );
}