View Javadoc

1   /*
2    * $Id: OutputPanel.java,v 1.10 2007/10/01 12:48:49 edankert Exp $
3    *
4    * The contents of this file are subject to the Mozilla Public License 
5    * Version 1.1 (the "License"); you may not use this file except in 
6    * compliance with the License. You may obtain a copy of the License at 
7    * http://www.mozilla.org/MPL/ 
8    *
9    * Software distributed under the License is distributed on an "AS IS" basis, 
10   * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 
11   * for the specific language governing rights and limitations under the License.
12   *
13   * The Original Code is XML Hammer code. (org.xmlhammer.*)
14   *
15   * The Initial Developer of the Original Code is Edwin Dankert. Portions created 
16   * by the Initial Developer are Copyright (C) 2005 - 2006 the Initial Developer. 
17   * All Rights Reserved.
18   *
19   * Contributor(s): Edwin Dankert <edankert@gmail.com>
20   */
21  
22  package org.xmlhammer.gui.output;
23  
24  import java.awt.BorderLayout;
25  import java.awt.Font;
26  
27  import javax.swing.ImageIcon;
28  import javax.swing.JTabbedPane;
29  
30  import org.bounce.CardPanel;
31  import org.bounce.image.ImageLoader;
32  import org.xmlhammer.gui.ProjectView;
33  import org.xmlhammer.gui.util.SelectablePanel;
34  
35  /***
36   * Output Panel.
37   * 
38   * @version $Revision: 1.10 $, $Date: 2007/10/01 12:48:49 $
39   * @author Edwin Dankert <edankert@gmail.com>
40   */
41  
42  public class OutputPanel extends SelectablePanel {
43  	private static final long serialVersionUID = 3845828241074593653L;
44      
45      private static final ImageIcon LOG_ICON = ImageLoader.get().getImage( "/org/xmlhammer/gui/icons/view16/error_log.gif");
46  	private static final ImageIcon RESULT_ICON = ImageLoader.get().getImage( "/org/xmlhammer/gui/icons/eview16/prop_ps.gif");
47      private static final ImageIcon JAVA_ICON = ImageLoader.get().getImage( "/org/xmlhammer/gui/icons/obj16/jcu_obj.gif");
48      private static final ImageIcon CONSOLE_ICON = ImageLoader.get().getImage( "/org/xmlhammer/gui/icons/obj16/monitor_obj.gif");
49  
50  	private CardPanel<LogPanel> logPanel = null;
51      private CardPanel<ConsolePanel> consolePanel = null;
52  	private CardPanel<ResultPanel> resultPanel = null;
53      private CardPanel<JavaPanel> javaPanel = null;
54  
55  	private JTabbedPane tabs = null;
56  
57  	/***
58  	 * Constructs a new Input Panel.
59  	 */
60  	public OutputPanel() {		
61  		super( new BorderLayout());
62  
63  		tabs = new JTabbedPane();
64  		tabs.setFont( tabs.getFont().deriveFont(Font.PLAIN));
65  		
66  		logPanel = new CardPanel<LogPanel>();
67          consolePanel = new CardPanel<ConsolePanel>();
68  		resultPanel = new CardPanel<ResultPanel>();
69          javaPanel = new CardPanel<JavaPanel>();
70  		
71  		tabs.addTab( "Result", RESULT_ICON, resultPanel);
72  		tabs.addTab( "Log", LOG_ICON, logPanel);
73          tabs.addTab( "Console", CONSOLE_ICON, consolePanel);
74          tabs.addTab( "Java", JAVA_ICON, javaPanel);
75  
76  		add( tabs, BorderLayout.CENTER);
77  	}
78  	
79  	public void showView( ProjectView view) {
80  		logPanel.show( view.getLogPanel());
81          
82  //        if (consolePanel.selected() != null) {
83  //            consolePanel.selected().stop();
84  //            view.getConsolePanel().start();
85  //        }
86  //
87          consolePanel.show( view.getConsolePanel());
88  		resultPanel.show( view.getResultPanel());
89          javaPanel.show( view.getJavaPanel());
90  	}
91  	
92  	public void addView( ProjectView view){
93  		logPanel.add( view.getLogPanel());
94          consolePanel.add( view.getConsolePanel());
95  		resultPanel.add( view.getResultPanel());
96          javaPanel.add( view.getJavaPanel());
97  	}
98  
99  	public void removeView( ProjectView view){
100 //        view.getConsolePanel().stop();
101 
102         logPanel.remove( view.getLogPanel());
103         consolePanel.remove( view.getConsolePanel());
104 		resultPanel.remove( view.getResultPanel());
105         javaPanel.remove( view.getJavaPanel());
106 	}
107 }