bibliothek.gui.dock.facile.mode.LocationModeEvent 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;
import java.util.HashMap;
import java.util.Map;
import bibliothek.gui.Dockable;
import bibliothek.gui.dock.support.mode.AffectedSet;
import bibliothek.gui.dock.support.mode.Mode;
/**
* Information given to a {@link LocationModeListener}.
* @author Benjamin Sigg
*/
public class LocationModeEvent {
/** the source of the event */
private LocationMode mode;
/** the element which got the new mode */
private Dockable dockable;
/** the new location of {@link #dockable} */
private Location location;
/** the set of affected elements */
private AffectedSet affected;
/** the objects that are stored for some listeners */
private Map map = new HashMap();
/** flag indicating that the mode transition has been done */
private boolean done = false;
/** flag telling whether the operation was a success */
private boolean success;
/**
* Creates a new event.
* @param mode the source of the event
* @param location the new location of dockable
, may be null
* @param dockable the element with the new mode
* @param affected the affected elements
*/
public LocationModeEvent( LocationMode mode, Location location, Dockable dockable, AffectedSet affected ){
this.mode = mode;
this.location = location;
this.dockable = dockable;
this.affected = affected;
}
/**
* Marks the mode transition as over. This method is normally called after
* {@link Mode#apply(Dockable, Object, AffectedSet) apply} has finished its job.
* {@link LocationModeListener}s might however prematurely call this method. In this case
* apply
is not executed, but all remaining events are sent anyway.
* @param success whether the operation was a success
*/
public void done(boolean success){
done = true;
this.success = success;
}
/**
* Tells whether the mode transition has been done or not.
* @return true
if the transition is over
*/
public boolean isDone(){
return done;
}
/**
* Assuming {@link #isDone()} is true
, then this flag tells whether the operation was a success or not.
* If the operation was not a success, then the {@link #getDockable() dockable} was not moved at all, or was not
* moved to the correct location.
* @return whether the operation was a success
*/
public boolean isSuccess(){
return success;
}
/**
* Gets the source of the event, the mode whose apply
method was called.
* @return the source of the event
*/
public LocationMode getMode(){
return mode;
}
/**
* Gets the location which {@link #getDockable() dockable} should have after
* apply
. Note: this might not be the actual location the element gets.
* @return the expected location, not null
*/
public Location getLocation(){
return location;
}
/**
* Gets the {@link Dockable} whose mode was, or is going to be, changed.
* @return the element
*/
public Dockable getDockable(){
return dockable;
}
/**
* The set of elements that is affected.
* @return the elements
*/
public AffectedSet getAffected(){
return affected;
}
/**
* Stores object
in a map using listener
as key. If this
* method is called by {@link LocationModeListener#applyStarting(LocationModeEvent)},
* then the object is available when {@link LocationModeListener#applyDone(LocationModeEvent)}
* is called.
* @param key the key, not null
* @param value the value, may be null
*/
public void setClientObject( LocationModeListener key, Object value ){
map.put( key, value );
}
/**
* Gets some object that was stored earlier using key key
.
* @param key the key
* @return the value, may be null
*/
public Object getClientObject( LocationModeListener key ){
return map.get( key );
}
}