001/*
002 * $Id: ColumnControlPopup.java 4065 2011-08-19 13:28:26Z kleopatra $
003 *
004 * Copyright 2008 Sun Microsystems, Inc., 4150 Network Circle,
005 * Santa Clara, California 95054, U.S.A. All rights reserved.
006 *
007 * This library is free software; you can redistribute it and/or
008 * modify it under the terms of the GNU Lesser General Public
009 * License as published by the Free Software Foundation; either
010 * version 2.1 of the License, or (at your option) any later version.
011 *
012 * This library is distributed in the hope that it will be useful,
013 * but WITHOUT ANY WARRANTY; without even the implied warranty of
014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
015 * Lesser General Public License for more details.
016 *
017 * You should have received a copy of the GNU Lesser General Public
018 * License along with this library; if not, write to the Free Software
019 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
020 */
021package org.jdesktop.swingx.table;
022
023import java.awt.ComponentOrientation;
024import java.util.List;
025
026import javax.swing.Action;
027import javax.swing.JComponent;
028
029import org.jdesktop.swingx.action.AbstractActionExt;
030import org.jdesktop.swingx.plaf.UIDependent;
031
032/**
033 * Encapsulates the popup component which is the delegate for
034 * all popup visuals, used by a ColumnControlButton.
035 * <p>
036 * For now, this class a simple extraction of what a ColumnControl needs. 
037 * Usage will drive further evolution.
038 * 
039 */
040public interface ColumnControlPopup extends UIDependent {
041    /**
042     * Toggles the popup's visibility. This method is responsible for
043     * placing itself relative to the given owner if toggled to visible.
044     * 
045     * @param owner the JComponent which triggered the visibility change, typically
046     *   a ColumnControlButton.
047     */
048    void toggleVisibility(JComponent owner);
049
050    /**
051     * Applies the specified component orientation to all internal widgets.
052     * This method must be called by the owner if its component orientation 
053     * changes. 
054     * 
055     * @param o the componentOrientation to apply to all internal widgets.
056     * @see javax.swing.JComponent#applyComponentOrientation(ComponentOrientation).
057     */
058    void applyComponentOrientation(ComponentOrientation o);
059
060    /**
061     * Removes all items from the popup. 
062     */
063    void removeAll();
064
065    /**
066     * Adds items corresponding to the column's visibility actions.
067     * <p>
068     * Each <code>Action</code> in the list is a <code>stateAction</code>,
069     * its <code>selected</code> property bound to a column's
070     * <code>visible</code> property, that is toggling the selected will
071     * toggle the column's visibility (if the action is enabled).
072     * 
073     * The  <code>Action</code>s <code>name</code> property is bound to 
074     * the column's <code>title</code>.
075     * 
076     * @param actions List of AbstractActionExt to add.
077     */
078    void addVisibilityActionItems(List<? extends AbstractActionExt> actions);
079    // JW: dooohhh ... what a winding description ...
080    // sure need to have a better abstraction! 
081    // 
082    
083    /**
084     * Adds additional actions to the popup. 
085     * 
086     * @param actions List of <code>Action</code>s to add to the popup.
087     */
088    void addAdditionalActionItems(List<? extends Action> actions);
089    
090    /**
091     * Splits and returns a List of actions into sub-lists. 
092     */
093    public interface ActionGrouper {
094        <A extends Action> List<List<A>> group(List<A> actions);
095    }
096    
097    /**
098     * Interface indicating support for grouping of menu actions.
099     * Implementations of ColumnControlPopup may implement this 
100     * if they support grouping of additional action.
101     */
102    public interface ActionGroupable {
103        public void setActionGrouper(ActionGrouper grouper);
104    }
105    
106
107}