bibliothek.gui.dock.support.mode.Mode 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.support.mode;
import bibliothek.gui.Dockable;
import bibliothek.gui.dock.accept.DockAcceptance;
import bibliothek.gui.dock.action.DockActionSource;
import bibliothek.util.Path;
/**
* A mode describes a state in which a {@link Dockable} can be. A Dockable
* can be in exactly one {@link Mode} at a time. Notice that the mode may
* change through events that are not registered or influenced by this
* mode.
* @author Benjamin Sigg
* @param class storing history information
*/
public interface Mode {
/**
* Gets a {@link DockActionSource} which should be shown on dockable
* which is currently in mode
. This method will be called
* every time when dockable
changes its mode.
* @param dockable some element, not null
* @param mode the mode of dockable
, not null
* @return the actions for dockable
, can be null
*/
public DockActionSource getActionsFor( Dockable dockable, Mode mode );
/**
* Gets a unique identifier, only this {@link Mode} must have this
* identifier. Identifiers with the first segment being "dock" are
* reserved for this framework, clients may choose any other identifiers.
* @return the identifier, not null
, should contain at least
* one segment.
*/
public Path getUniqueIdentifier();
/**
* Applies this mode to dockable
. This method may fail for example because a {@link DockAcceptance}
* does prevent dockable
from being moved.
* @param dockable the element whose mode becomes this
* @param history history information that was returned by this mode
* on its last call to {@link #current(Dockable)}. May be null
* if this mode was never applied or returns null
on {@link #current(Dockable)}.
* @param set this method has to store all {@link Dockable}s which might have changed their
* mode in the set.
* @return true
if dockable
was successfully moved on its parent or to a new parent,
* or false
if dockable
did not change its location
*/
public boolean apply( Dockable dockable, H history, AffectedSet set );
/**
* Provides history information about the current state of dockable
* in respect to this mode.
* @param dockable the element
* @return history information that is needed when calling {@link #apply(Dockable, Object, AffectedSet)}
*/
public H current( Dockable dockable );
/**
* Checks whether this mode is a default mode of dockable
. A
* default mode is a mode that is chosen per default, if no other mode
* is selected. There should be only one default-mode per {@link Dockable}.
* @param dockable some dockable, not null
* @return whether this is a default mode
*/
public boolean isDefaultMode( Dockable dockable );
/**
* Tells whether dockable
fulfills the requirements of
* this mode, meaning whether dockable
has this mode. There
* should be only at most one mode which returns true
for this
* question. Please note, the mode selected in the {@link ModeManager} may
* be out of date, and should not be considered when checking the
* current mode.
* @param dockable some dockable, not null
* @return whether dockable
is in this
mode
*/
public boolean isCurrentMode( Dockable dockable );
/**
* Gets the current properties of this mode in an independent way.
* @param setting a {@link ModeSetting} with the same id as this {@link Mode}. This setting
* was created by a {@link ModeSettingFactory} with the same id as this {@link Mode}.
*/
public void writeSetting( ModeSetting setting );
/**
* Sets the properties of this mode. This method will only be called
* with a {@link ModeSetting} that has been created by the current
* {@link #getSettingFactory() ModeSettingFactory}
* @param setting the new set of properties, not null
*/
public void readSetting( ModeSetting setting );
/**
* Gets a factory for creating new {@link ModeSetting}s.
* @return the factory, can be null
*/
public ModeSettingFactory getSettingFactory();
}