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

bibliothek.gui.dock.frontend.MissingDockableStrategy Maven / Gradle / Ivy

There is a newer version: 1.1.2p6a
Show 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.frontend;

import bibliothek.gui.DockFrontend;
import bibliothek.gui.Dockable;
import bibliothek.gui.dock.DockFactory;

/**
 * Used by the {@link DockFrontend} to handle missing {@link Dockable}s. The
 * methods of this interface are called to find out, for which missing {@link Dockable}
 * information should be stored, and for which not.
 * @author Benjamin Sigg
 */
public interface MissingDockableStrategy {
    /**
     * This strategy throws away all information.
     */
    public static MissingDockableStrategy DISCARD_ALL = new MissingDockableStrategy(){
        public boolean shouldStoreHidden( String key ) {
            return false;
        }
        public boolean shouldStoreShown( String key ) {
            return false;
        }
        public  boolean shouldCreate( DockFactory factory, L data ) {
            return false;
        }
    };
    
    /**
     * This strategy stores all information.
     */
    public static MissingDockableStrategy STORE_ALL = new MissingDockableStrategy(){
        public boolean shouldStoreHidden( String key ) {
            return true;
        }
        public boolean shouldStoreShown( String key ) {
            return true;
        }
        public  boolean shouldCreate( DockFactory factory, L data ) {
            return true;
        }
    };
    
    /**
     * Tells whether the location of the hidden and missing {@link Dockable}
     * key should be stored anyway. A {@link DockFrontend} will
     * create an {@link DockFrontend#addEmpty(String) empty info} for all
     * keys which pass this method.
     * @param key the name of a missing element
     * @return true if its location should be stored for the
     * case that it becomes known later, or false if its location
     * should be discarded
     */
    public boolean shouldStoreHidden( String key );
    
    /**
     * Tells whether the location of the shown but missing {@link Dockable}
     * key should be stored anyway. A {@link DockFrontend} will
     * create an {@link DockFrontend#addEmpty(String) empty info} for all
     * keys which pass this method.
     * @param key the name of a missing element
     * @return true if its location should be stored for the
     * case that it becomes known later, or false if its location
     * should be discarded
     */
    public boolean shouldStoreShown( String key );
        
    /**
     * Tells whether factory should be used to create a new
     * {@link Dockable} using data. This method is only called
     * when the element would be created outside the normal setup phase, i.e.
     * when a new factory has become known and old data is revisited.
     * @param  the kind of data to use for factory
     * @param factory the factory which might create new elements
     * @param data the information factory would convert
     * @return true if factory is allowed to convert
     * data
     */
    public  boolean shouldCreate( DockFactory factory, L data );
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy