KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > edu > umd > cs > findbugs > gui2 > TabbedLayout


1 /*
2  * FindBugs - Find Bugs in Java programs
3  * Copyright (C) 2006, University of Maryland
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  */

19
20 package edu.umd.cs.findbugs.gui2;
21
22 import java.awt.BorderLayout JavaDoc;
23 import java.awt.event.KeyEvent JavaDoc;
24
25 import javax.swing.JMenu JavaDoc;
26 import javax.swing.JSplitPane JavaDoc;
27 import javax.swing.JTabbedPane JavaDoc;
28 import javax.swing.UIManager JavaDoc;
29
30 /**
31  * @author pugh
32  */

33 public class TabbedLayout implements FindBugsLayoutManager {
34
35     final MainFrame frame;
36     
37     private JTabbedPane JavaDoc mainTabs = null;
38     /**
39      * @param frame
40      */

41     public TabbedLayout(MainFrame frame) {
42         this.frame = frame;
43     }
44
45     /* (non-Javadoc)
46      * @see edu.umd.cs.findbugs.gui2.FindBugsLayoutManager#createWindowMenu()
47      */

48     public JMenu JavaDoc createWindowMenu() {
49         return null;
50     }
51
52     /* (non-Javadoc)
53      * @see edu.umd.cs.findbugs.gui2.FindBugsLayoutManager#initialize()
54      */

55     public void initialize() {
56         //This will change the look of the tabs and filechoosr if the font size is set to greater than 15.
57
if(Driver.getFontSize() > 15 && System.getProperty("os.name").startsWith("Mac")){
58             UIManager.put("TabbedPaneUI", "javax.swing.plaf.basic.BasicTabbedPaneUI");
59             UIManager.put("FileChooserUI", "javax.swing.plaf.metal.MetalFileChooserUI");
60         }
61         
62         mainTabs = bottomTabs();
63         
64         JSplitPane JavaDoc split = new JSplitPane JavaDoc(JSplitPane.VERTICAL_SPLIT,
65                 frame.bugListPanel(), mainTabs);
66         split.setOneTouchExpandable(true);
67         split.setDividerLocation(275);
68
69         frame.setLayout(new BorderLayout JavaDoc());
70         frame.add(split, BorderLayout.CENTER);
71         frame.add(frame.statusBar(), BorderLayout.SOUTH);
72
73     }
74
75     /* (non-Javadoc)
76      * @see edu.umd.cs.findbugs.gui2.FindBugsLayoutManager#makeCommentsVisible()
77      */

78     public void makeCommentsVisible() {
79         mainTabs.setSelectedIndex(1);
80
81     }
82
83     /* (non-Javadoc)
84      * @see edu.umd.cs.findbugs.gui2.FindBugsLayoutManager#makeSourceVisible()
85      */

86     public void makeSourceVisible() {
87         mainTabs.setSelectedIndex(2);
88
89     }
90
91     /* (non-Javadoc)
92      * @see edu.umd.cs.findbugs.gui2.FindBugsLayoutManager#saveState()
93      */

94     public void saveState() {
95         // TODO Auto-generated method stub
96

97     }
98
99     /* (non-Javadoc)
100      * @see edu.umd.cs.findbugs.gui2.FindBugsLayoutManager#setSourceTitle(java.lang.String)
101      */

102     public void setSourceTitle(String JavaDoc title) {
103         mainTabs.setTitleAt(2, title);
104
105     }
106     /**
107      * Creates the bottom tabs of the GUI.
108      * @return
109      */

110     JTabbedPane JavaDoc bottomTabs()
111     {
112         JTabbedPane JavaDoc bottomTabs = new JTabbedPane JavaDoc();
113         
114         bottomTabs.addTab("Bug Summary", frame.summaryTab());
115         bottomTabs.addTab("Comments", null, frame.createCommentsInputPanel(),
116                 "User defined comments of current bug.");
117         bottomTabs.addTab("Source", null, frame.createSourceCodePanel(),
118                 "Source code of current bug if available.");
119         
120         //Set keyboard mnemonic for tabs.
121
bottomTabs.setMnemonicAt(0, KeyEvent.VK_B);
122         bottomTabs.setMnemonicAt(1, KeyEvent.VK_C);
123         bottomTabs.setMnemonicAt(2, KeyEvent.VK_S);
124         
125         return bottomTabs;
126     }
127 }
128
Popular Tags