![JAR search and dependency download from the Maven repository](/logo.png)
bibliothek.gui.dock.facile.mode.status.ExtendedModeEnablement Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of docking-frames-common Show documentation
Show all versions of docking-frames-common Show documentation
DockingFrames is an open source Java Swing docking framework, licenced under LGPL 2.1.
This is the same distribution as the original distribution (http://www.docking-frames.org/), only reinstalled in maven
/*
* 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) 2009 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
*
* Benjamin Sigg
* [email protected]
* CH - Switzerland
*/
package bibliothek.gui.dock.facile.mode.status;
import bibliothek.gui.Dockable;
import bibliothek.gui.dock.common.mode.ExtendedMode;
import bibliothek.gui.dock.facile.mode.LocationModeManager;
/**
* Generic algorithm telling for {@link Dockable}s whether some {@link ExtendedMode} is
* available or not.
* @author Benjamin Sigg
*/
public interface ExtendedModeEnablement {
/**
* A measurement of how available a certain mode is. Is several {@link Availability}s are present,
* the first one of this list wins:
*
* - {@link Availability#STRONG_FORBIDDEN}
* - {@link Availability#STRONG_AVAILABLE}
* - {@link Availability#WEAK_FORBIDDEN}
* - {@link Availability#WEAK_AVAILABLE}
* - {@link Availability#UNCERTAIN}
*
* @author Benjamin Sigg
*/
public static enum Availability{
/** the mode is most certainly available */
STRONG_AVAILABLE( true ),
/** the mode is probably available */
WEAK_AVAILABLE( true ),
/** the strategy cannot decide, some other code will make the decision */
UNCERTAIN( true ),
/** the mode is probably not available */
WEAK_FORBIDDEN( false ),
/** the mode is not available */
STRONG_FORBIDDEN( false );
private boolean available;
private Availability( boolean available ){
this.available = available;
}
/**
* Tells whether this {@link Availability} means "available" or "forbidden".
* @return true
if this
means "available".
*/
public boolean isAvailable(){
return available;
}
/**
* Gets the strongest {@link Availability} of this
and other
.
* @param other some other {@link Availability}
* @return the stronger of this
and other
*/
public Availability strongest( Availability other ){
if( this == STRONG_FORBIDDEN || other == STRONG_FORBIDDEN ){
return STRONG_FORBIDDEN;
}
if( this == STRONG_AVAILABLE || other == STRONG_AVAILABLE ){
return STRONG_AVAILABLE;
}
if( this == WEAK_FORBIDDEN || other == WEAK_FORBIDDEN ){
return WEAK_FORBIDDEN;
}
if( this == WEAK_AVAILABLE || other == WEAK_AVAILABLE ){
return WEAK_AVAILABLE;
}
return UNCERTAIN;
}
}
/**
* A measurement of how hidden a certain mode is. Is several {@link Hidden}s are present,
* the first one of this list wins:
*
* - {@link Hidden#STRONG_HIDDEN}
* - {@link Hidden#STRONG_VISIBLE}
* - {@link Hidden#WEAK_HIDDEN}
* - {@link Hidden#WEAK_VISIBLE}
* - {@link Hidden#UNCERTAIN}
*
* @author Benjamin Sigg
*/
public static enum Hidden{
/** the mode is most certainly hidden */
STRONG_HIDDEN( true ),
/** the mode is probably hidden */
WEAK_HIDDEN( true ),
/** the strategy cannot decide, some other code will make the decision */
UNCERTAIN( true ),
/** the mode is probably visible */
WEAK_VISIBLE( false ),
/** the mode is visible */
STRONG_VISIBLE( false );
private boolean hidden;
private Hidden( boolean available ){
this.hidden = available;
}
/**
* Tells whether this {@link Hidden} means "hidden" or "visible".
* @return true
if this
means "hidden".
*/
public boolean isHidden(){
return hidden;
}
/**
* Gets the strongest {@link Hidden} of this
and other
.
* @param other some other {@link Hidden}
* @return the stronger of this
and other
*/
public Hidden strongest( Hidden other ){
if( this == STRONG_HIDDEN || other == STRONG_HIDDEN ){
return STRONG_HIDDEN;
}
if( this == STRONG_VISIBLE || other == STRONG_VISIBLE ){
return STRONG_VISIBLE;
}
if( this == WEAK_HIDDEN || other == WEAK_HIDDEN ){
return WEAK_HIDDEN;
}
if( this == WEAK_VISIBLE || other == WEAK_VISIBLE ){
return WEAK_VISIBLE;
}
return UNCERTAIN;
}
}
/**
* Tells whether mode
is available for dockable
.
* Note: for {@link ExtendedMode#NORMALIZED} the result should always be true
.
* @param dockable some element, not null
* @param mode some mode, not null
* @return whether the mode is available, most strategies should return {@link Availability#WEAK_AVAILABLE} if mode
equals {@link ExtendedMode#NORMALIZED}.
* Must never be null
, but a result of {@link Availability#UNCERTAIN} indicates that this enablement does not know
*/
public Availability isAvailable( Dockable dockable, ExtendedMode mode );
/**
* Tells whether mode
is hidden from the user for dockable
. If a mode
* is hidden it can still be available, the user will just not be informed (e.g. there is no button
* that will move the dockable).
* @param dockable some element, not null
* @param mode some mode, not null
* @return whether mode
is hidden from the user when looking at dockable
*/
public Hidden isHidden( Dockable dockable, ExtendedMode mode );
/**
* Adds a listener to this enablement, the listener has be informed if the availability state of
* a mode in respect to a dockable has changed. Only {@link Dockable}s that are registered
* at the {@link LocationModeManager} have to be observed.
* @param listener the new listener
*/
public void addListener( ExtendedModeEnablementListener listener );
/**
* Removes a listener from this enablement.
* @param listener the listener to remove
*/
public void removeListener( ExtendedModeEnablementListener listener );
/**
* Informs this enablement that it is no longer of any use. The enablement
* should remove any listeners it added to any other object.
*/
public void destroy();
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy