View Javadoc

1   /*
2    *  Copyright (C) 2003-2005 SINTEF
3    *  Author:  Fredrik Vraalsen (fredrik dot vraalsen at sintef dot no)
4    *  Webpage: http://coras.sourceforge.net/
5    *
6    *  This program is free software; you can redistribute it and/or
7    *  modify it under the terms of the GNU Lesser General Public License
8    *  as published by the Free Software Foundation; either version 2.1
9    *  of the License, or (at your option) any later version.
10   *
11   *  This program is distributed in the hope that it will be useful,
12   *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13   *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14   *  Lesser General Public License for more details.
15   *
16   *  You should have received a copy of the GNU Lesser General Public
17   *  License along with this program; if not, write to the Free
18   *  Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
19   *  02111-1307 USA
20   */
21  package coras.client.ui;
22  
23  import java.awt.Frame;
24  import java.util.HashMap;
25  import java.util.Map;
26  
27  import javax.swing.JFrame;
28  import javax.swing.JMenuBar;
29  import javax.swing.JPopupMenu;
30  import javax.swing.JTabbedPane;
31  import javax.swing.ToolTipManager;
32  import javax.swing.UIManager;
33  
34  /***
35   * @author fvr
36   *
37   * TODO To change the template for this generated type comment go to
38   * Window - Preferences - Java - Code Style - Code Templates
39   */
40  public class CorasFrame extends JFrame {
41  
42  	private javax.swing.JPanel contentPane = null;
43  	private JTabbedPane tabbedPane = null;
44  	private HtmlPanel methodologyPanel = null;
45  	private PackagePanel projectPanel = null;
46  	private PackagePanel libraryPanel = null;
47  
48      private JMenuBar menuBar = null;
49  
50  	/***
51  	 * This is the default constructor
52  	 */
53  	public CorasFrame() {
54  		super();
55  		initialize();
56  	}
57  
58  	public void showProjectPanel() {
59  	    getTabbedPane().setSelectedComponent(getProjectPanel());
60  	}
61  
62  	public void showLibraryPanel() {
63  		getTabbedPane().setSelectedComponent(getLibraryPanel());
64  	}
65  
66      public void showMethodologyPanel() {
67      	getTabbedPane().setSelectedComponent(getMethodologyPanel());
68      }
69  
70      /***
71  	 * This method initializes methodologyPanel	
72  	 * 	
73  	 * @return coras.client.ui.MethodologyPanel	
74  	 */    
75  	public HtmlPanel getMethodologyPanel() {
76  		if (methodologyPanel == null) {
77  			Map idMap = new HashMap();
78  			idMap.put("top", "top.html");
79  			idMap.put("methodology", "help/index.html");
80  			idMap.put("about", "about.html");
81  			idMap.put("getting_started", "gettingStarted/CORAS_Getting_Started.html");
82  			methodologyPanel = new HtmlPanel(idMap, "top");
83  		}
84  		return methodologyPanel;
85  	}
86  	
87  	/***
88  	 * This method initializes packagePanel	
89  	 * 	
90  	 * @return coras.client.ui.PackagePanel	
91  	 */    
92  	public PackagePanel getProjectPanel() {
93  		if (projectPanel == null) {
94  			projectPanel = new PackagePanel();
95  			projectPanel.setCategoryEnabled(false);
96  			projectPanel.setDomainEnabled(false);
97  		}
98  		return projectPanel;
99  	}
100 	
101     /***
102 	 * This method initializes packagePanel	
103 	 * 	
104 	 * @return coras.client.ui.PackagePanel	
105 	 */    
106 	public PackagePanel getLibraryPanel() {
107 		if (libraryPanel == null) {
108 			libraryPanel = new PackagePanel();
109 		}
110 		return libraryPanel;
111 	}
112 
113 	/***
114 	 * This method initializes jTabbedPane	
115 	 * 	
116 	 * @return javax.swing.JTabbedPane	
117 	 */    
118 	public JTabbedPane getTabbedPane() {
119 		if (tabbedPane == null) {
120 			tabbedPane = new JTabbedPane();
121 			tabbedPane.setFont(new java.awt.Font("Dialog", java.awt.Font.BOLD, 14));
122 			tabbedPane.addTab("Risk Analysis Project", null, getProjectPanel(), null);
123 			tabbedPane.addTab("Experience Library", null, getLibraryPanel(), null);
124 			tabbedPane.addTab("CORAS Methodology", null, getMethodologyPanel(), null);
125 		}
126 		return tabbedPane;
127 	}
128 	
129 	/***
130 	 * This method initializes jJMenuBar	
131 	 * 	
132 	 * @return javax.swing.JMenuBar	
133 	 */    
134 	private JMenuBar getJJMenuBar() {
135 		if (menuBar == null) {
136 			menuBar = new JMenuBar();
137 		}
138 		return menuBar;
139 	}
140 
141 	/***
142 	 * This method initializes jContentPane
143 	 * 
144 	 * @return javax.swing.JPanel
145 	 */
146 	private javax.swing.JPanel getJContentPane() {
147 		if(contentPane == null) {
148 			contentPane = new javax.swing.JPanel();
149 			contentPane.setLayout(new java.awt.BorderLayout());
150 			contentPane.add(getTabbedPane(), java.awt.BorderLayout.CENTER);
151 		}
152 		return contentPane;
153 	}
154 
155 	/***
156 	 * This method initializes this
157 	 * 
158 	 * @return void
159 	 */
160 	private void initialize() {
161 		try {
162 			// String gtkLaF = "com.sun.java.swing.plaf.gtk.GTKLookAndFeel";
163 			String systemLaF = UIManager.getSystemLookAndFeelClassName();
164 			UIManager.setLookAndFeel(systemLaF);
165 		} catch (Exception e) {
166 		    // LOGGER.info("Unable to set system look and feel, using default");
167 		}
168 		
169 		this.setBounds(0, 0, 800, 600);
170 		JPopupMenu.setDefaultLightWeightPopupEnabled(false);
171 		ToolTipManager.sharedInstance().setLightWeightPopupEnabled(false);
172 		this.setJMenuBar(getJJMenuBar());
173 		this.setContentPane(getJContentPane());
174 		this.setTitle("CORAS Risk Analysis Tool");
175 		this.setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
176 		this.setExtendedState(Frame.MAXIMIZED_BOTH);
177 	}
178 	
179 }