KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > compiere > grid > VTabbedPane


1 /******************************************************************************
2  * The contents of this file are subject to the Compiere License Version 1.1
3  * ("License"); You may not use this file except in compliance with the License
4  * You may obtain a copy of the License at http://www.compiere.org/license.html
5  * Software distributed under the License is distributed on an "AS IS" basis,
6  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
7  * the specific language governing rights and limitations under the License.
8  * The Original Code is Compiere ERP & CRM Business Solution
9  * The Initial Developer of the Original Code is Jorg Janke and ComPiere, Inc.
10  * Portions created by Jorg Janke are Copyright (C) 1999-2001 Jorg Janke, parts
11  * created by ComPiere are Copyright (C) ComPiere, Inc.; All Rights Reserved.
12  * Contributor(s): ______________________________________.
13  *****************************************************************************/

14 package org.compiere.grid;
15
16 import java.awt.*;
17 import javax.swing.*;
18
19 import org.compiere.util.*;
20 import org.compiere.apps.*;
21 import org.compiere.swing.*;
22
23 /**
24  * Tabbed Pane - either Workbench or Window Tab
25  *
26  * @author Jorg Janke
27  * @version $Id: VTabbedPane.java,v 1.7 2002/10/08 04:28:56 jjanke Exp $
28  */

29 public class VTabbedPane extends CTabbedPane
30 {
31     /**
32      * Constructor
33      * @param isWorkbench is this a workbench tab (tabs on the left side)
34      */

35     public VTabbedPane (boolean isWorkbench)
36     {
37         super();
38         // bug in 1.4.1 - can't be SCROLL_TAB_LAYOUT - java.lang.NullPointerException
39
// at javax.swing.plaf.basic.BasicTabbedPaneUI$TabSelectionHandler.stateChanged(BasicTabbedPaneUI.java:3027)
40
// setTabLayoutPolicy (JTabbedPane.SCROLL_TAB_LAYOUT);
41
setWorkbench (isWorkbench);
42     } // workbenchTab
43

44     private boolean m_workbenchTab;
45
46     /**
47      * toString
48      * @return info
49      */

50     public String JavaDoc toString()
51     {
52         return (m_workbenchTab ? "WorkbenchTab" : "WindowTab")
53             + " - selected " + getSelectedIndex() + " of " + getTabCount();
54     } // toString
55

56     /**
57      * Set Workbench - or Window
58      * @param isWorkbench
59      */

60     public void setWorkbench (boolean isWorkbench)
61     {
62         m_workbenchTab = isWorkbench;
63         if (m_workbenchTab)
64             super.setTabPlacement(JTabbedPane.BOTTOM);
65         else
66             super.setTabPlacement(Language.getLanguage().isLeftToRight() ? JTabbedPane.LEFT : JTabbedPane.RIGHT);
67     } // setWorkbench
68

69     /**
70      * Tab is Workbench (not Window)
71      * @return true if Workbench
72      */

73     public boolean isWorkbench()
74     {
75         return m_workbenchTab;
76     } // toString
77

78     /**
79      * Set Tab Placement.
80      * Do not use - set via setWorkBench
81      * @param notUsed
82      */

83     public void setTabPlacement (int notUsed)
84     {
85         new java.lang.IllegalAccessError JavaDoc("Do not use VTabbedPane.setTabPlacement directly");
86     } // setTabPlacement
87

88     /**
89      * Dispose all contained VTabbedPanes and GridControllers
90      * @param aPanel
91      */

92     public void dispose (APanel aPanel)
93     {
94         Component[] comp = getComponents();
95         for (int i = 0; i < comp.length; i++)
96         {
97             if (comp[i] instanceof VTabbedPane)
98             {
99                 VTabbedPane tp = (VTabbedPane)comp[i];
100                 tp.removeChangeListener(aPanel);
101                 tp.dispose(aPanel);
102             }
103             else if (comp[i] instanceof GridController)
104             {
105                 GridController gc = (GridController)comp[i];
106                 gc.addDataStatusListener(aPanel);
107                 gc.dispose();
108             }
109         }
110         removeAll();
111     } // dispose
112

113 } // VTabbdPane
114
Popular Tags