All Downloads are FREE. Search and download functionalities are using the official Maven repository.

bibliothek.gui.dock.util.PropertyKey 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) 2007 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.util;

import javax.swing.Icon;

import bibliothek.gui.DockStation;
import bibliothek.gui.Dockable;
import bibliothek.gui.dock.util.property.PropertyFactory;

/**
 * The key for an entry in a map of {@link DockProperties properties}.
 * @author Benjamin Sigg
 *
 * @param  the type of entry
 */
public class PropertyKey {
	/**
	 * The Icon used for a {@link Dockable} if it has no icon.
* This key should only be used for writing the icon, reading the icon should be done throught the {@link IconManager} * using the key "dockable.default". */ public static final PropertyKey DOCKABLE_ICON = new PropertyKey( "javax.swing.Icon_dockable_icon" ); /** * The Icon used for a {@link DockStation} if it has no icon.
* This key should only be used for writing the icon, reading the icon should be done throught the {@link IconManager} * using the key "dockStation.default". */ public static final PropertyKey DOCK_STATION_ICON = new PropertyKey( "javax.swing.Icon_dock_station_icon" ); /** * The title of a {@link Dockable} if it has no title. */ public static final PropertyKey DOCKABLE_TITLE = new PropertyKey( "java.lang.String_dockable_title" ); /** * The title of a {@link DockStation} if it has no title. */ public static final PropertyKey DOCK_STATION_TITLE = new PropertyKey( "java.lang.String_dock_station_title" ); /** * The tooltip used for a {@link Dockable} that has no tooltip set */ public static final PropertyKey DOCKABLE_TOOLTIP = new PropertyKey( "java.lang.String_dockable_tooltip" ); /** * The tooltip used for a {@link DockStation} that has no tooltip set */ public static final PropertyKey DOCK_STATION_TOOLTIP = new PropertyKey( "java.lang.String_dock_station_tooltip" ); /** a unique identifier */ private String id; /** default value */ private PropertyFactory
value; /** if set, then the null value gets replaced by the default specified in this key */ private boolean nullValueReplacedByDefault = false; /** * Creates a new key. * @param id a unique identifier, should contain the name of the * type of property, represented by this key. */ public PropertyKey( String id ){ this( id, null, false ); } /** * Creates a new key. * @param id a unique identifier, should contain the name of the * type of property, represented by this key. * @param value the value that will be used when no value is set * in the properties * @deprecated replaced by {@link #PropertyKey(String, PropertyFactory, boolean)} */ @Deprecated public PropertyKey( String id, PropertyFactory value ){ this( id, value, false ); } /** * Creates a new key. * @param id a unique identifier, should contain the name of the * type of property, represented by this key. * @param value the value that will be used when no value is set * in the properties * @param nullValueReplacedByDefault if set, then the null value * in {@link DockProperties} gets replaced by the default value of this key even if * the null value was set explicitely. */ public PropertyKey( String id, PropertyFactory value, boolean nullValueReplacedByDefault ){ if( id == null ) throw new IllegalArgumentException( "id must not be null" ); this.value = value; this.id = id; this.nullValueReplacedByDefault = nullValueReplacedByDefault; } /** * Gets a default-value that should be used when no value is set * in the {@link DockProperties}.
* Note: this method should not be called by clients. * @param properties the properties for which the default value will be used * @return the default-value */ public final A getDefault( DockProperties properties ){ if( value == null ) return null; if( properties == null ) return value.getDefault( this ); else return value.getDefault( this, properties ); } /** * If set, then the null value should be replaced by the * default value specified by this key. * @return true if null means default */ public boolean isNullValueReplacedByDefault() { return nullValueReplacedByDefault; } @Override public final int hashCode(){ return id.hashCode(); } @Override public final boolean equals( Object obj ){ return this == obj; } @Override public String toString(){ return id; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy