~ubuntu-branches/ubuntu/natty/libswingx-java/natty

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
/*
 * $Id: JXTaskPaneContainer.java 3569 2009-12-21 16:25:42Z kleopatra $
 *
 * Copyright 2004 Sun Microsystems, Inc., 4150 Network Circle,
 * Santa Clara, California 95054, U.S.A. All rights reserved.
 *
 * 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 St, Fifth Floor, Boston, MA  02110-1301  USA
 */
package org.jdesktop.swingx;

import java.awt.event.ContainerAdapter;
import java.awt.event.ContainerEvent;

import org.jdesktop.swingx.plaf.LookAndFeelAddons;
import org.jdesktop.swingx.plaf.TaskPaneContainerAddon;
import org.jdesktop.swingx.plaf.TaskPaneContainerUI;

/**
 * <code>JXTaskPaneContainer</code> provides an elegant view
 * to display a list of tasks ordered by groups ({@link org.jdesktop.swingx.JXTaskPane}s).
 * 
 * <p>
 * Although {@link org.jdesktop.swingx.JXTaskPane} can be added to any other
 * container, the <code>JXTaskPaneContainer</code> will provide better
 * fidelity when it comes to matching the look and feel of the host operating
 * system than any other panel. As example, when using on a Windows platform,
 * the <code>JXTaskPaneContainer</code> will be painted with a light gradient
 * background. Also <code>JXTaskPaneContainer</code> takes care of using the
 * right {@link java.awt.LayoutManager} (as required by
 * {@link org.jdesktop.swingx.JXCollapsiblePane}) so that
 * {@link org.jdesktop.swingx.JXTaskPane} behaves correctly when collapsing and
 * expanding its content.
 *  
 * <p>
 * <code>JXTaskPaneContainer<code> can be added to a JScrollPane.
 * 
 * <p>
 * Example:
 * <pre>
 * <code>
 * JXFrame frame = new JXFrame();
 * 
 * // a container to put all JXTaskPane together
 * JXTaskPaneContainer taskPaneContainer = new JXTaskPaneContainer();
 * 
 * // add JXTaskPanes to the container
 * JXTaskPane actionPane = createActionPane();
 * JXTaskPane miscActionPane = createMiscActionPane();
 * JXTaskPane detailsPane = createDetailsPane();
 * taskPaneContainer.add(actionPane);
 * taskPaneContainer.add(miscActionPane);
 * taskPaneContainer.add(detailsPane);
 *
 * // put the action list on the left in a JScrollPane
 * // as we have several taskPane and we want to make sure they
 * // all get visible.   
 * frame.add(new JScrollPane(taskPaneContainer), BorderLayout.EAST);
 * 
 * // and a file browser in the middle
 * frame.add(fileBrowser, BorderLayout.CENTER);
 * 
 * frame.pack().
 * frame.setVisible(true);
 * </code>
 * </pre>
 *
 * @author <a href="mailto:fred@L2FProd.com">Frederic Lavigne</a>
 * 
 * @javabean.attribute
 *          name="isContainer"
 *          value="Boolean.TRUE"
 *          rtexpr="true"
 * 
 * @javabean.class
 *          name="JXTaskPaneContainer"
 *          shortDescription="A component that contains JTaskPaneGroups."
 *          stopClass="java.awt.Component"
 * 
 * @javabean.icons
 *          mono16="JXTaskPaneContainer16-mono.gif"
 *          color16="JXTaskPaneContainer16.gif"
 *          mono32="JXTaskPaneContainer32-mono.gif"
 *          color32="JXTaskPaneContainer32.gif"
 */
public class JXTaskPaneContainer extends JXPanel {

  public final static String uiClassID = "swingx/TaskPaneContainerUI";
  
    // ensure at least the default ui is registered
    static {
        LookAndFeelAddons.contribute(new TaskPaneContainerAddon());
    }

    /**
     * Creates a new empty taskpane.
     */
    public JXTaskPaneContainer() {
        super(null);
        updateUI();

        addContainerListener(new ContainerAdapter() {
            @Override
            public void componentRemoved(ContainerEvent e) {
                repaint();
            }
        });
        setScrollableHeightHint(ScrollableSizeHint.VERTICAL_STRETCH);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public TaskPaneContainerUI getUI() {
        return (TaskPaneContainerUI) super.getUI();
    }
  
    /**
     * Notification from the <code>UIManager</code> that the L&F has changed.
     * Replaces the current UI object with the latest version from the
     * <code>UIManager</code>.
     * 
     * @see javax.swing.JComponent#updateUI
     */
    @Override
    public void updateUI() {
        setUI((TaskPaneContainerUI) LookAndFeelAddons.getUI(this,
                TaskPaneContainerUI.class));
    }

    /**
     * Sets the L&F object that renders this component.
     * 
     * @param ui the <code>TaskPaneContainerUI</code> L&F object
     * @see javax.swing.UIDefaults#getUI
     * 
     * @beaninfo bound: true hidden: true description: The UI object that
     *           implements the taskpane's LookAndFeel.
     */
    public void setUI(TaskPaneContainerUI ui) {
        super.setUI(ui);
    }

    /**
     * Returns the name of the L&F class that renders this component.
     * 
     * @return the string {@link #uiClassID}
     * @see javax.swing.JComponent#getUIClassID
     * @see javax.swing.UIDefaults#getUI
     */
    @Override
    public String getUIClassID() {
        return uiClassID;
    }

    /**
     * Adds a <code>JXTaskPane</code> to this JXTaskPaneContainer.
     * 
     * @param group
     */
    public void add(JXTaskPane group) {
        super.add(group);
    }

    /**
     * Removes a <code>JXTaskPane</code> from this JXTaskPaneContainer.
     * 
     * @param group
     */
    public void remove(JXTaskPane group) {
        super.remove(group);
    }

//    /**
//     * @see Scrollable#getScrollableTracksViewportHeight()
//     */
//    @Override
//    public boolean getScrollableTracksViewportHeight() {
//        if (getParent() instanceof JViewport) {
//            return (((JViewport) getParent()).getHeight() > getPreferredSize().height);
//        } else {
//            return false;
//        }
//    }
//  
//    /**
//     * @see Scrollable#getScrollableTracksViewportWidth()
//     */
//    @Override
//    public boolean getScrollableTracksViewportWidth() {
//        return true;
//    }
}