View Javadoc

1   /*
2    * $Id: Page.java,v 1.11 2007/05/29 21:02:55 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  
23  package org.xmlhammer.gui;
24  
25  import java.awt.BorderLayout;
26  import java.util.ArrayList;
27  
28  import javax.swing.Icon;
29  import javax.swing.ImageIcon;
30  import javax.swing.JPanel;
31  import javax.swing.JScrollPane;
32  import javax.swing.JToolBar;
33  import javax.swing.border.EmptyBorder;
34  
35  import org.bounce.image.ImageLoader;
36  import org.xmlhammer.gui.actions.PageHelpAction;
37  import org.xmlhammer.gui.overview.OverviewNode;
38  import org.xmlhammer.gui.util.TitleBar;
39  
40  /***
41   * Put comment...
42   * 
43   * @version $Revision: 1.11 $, $Date: 2007/05/29 21:02:55 $
44   * @author Edwin Dankert <edankert@gmail.com>
45   */
46  
47  public abstract class Page extends JPanel implements OverviewNode {
48  	private static final ImageIcon PAGE_ICON = ImageLoader.get().getImage( "/org/xmlhammer/gui/icons/obj16/page_obj.gif");
49  
50  	private ProjectView view = null;
51      private JPanel centerPanel = null;
52      private JPanel main = null;
53      
54  	/***
55  	 * 
56  	 */
57  	public Page( ProjectView view) {
58  		this( view, true);
59  	}
60  
61  	/***
62  	 * @param layout
63  	 * @param isDoubleBuffered
64  	 */
65  	public Page( ProjectView view, boolean isDoubleBuffered) {
66  		super(new BorderLayout(), isDoubleBuffered);
67  		
68  		this.view = view;
69          
70          centerPanel = new JPanel( new BorderLayout());
71          centerPanel.setBorder( new EmptyBorder( 2, 2, 0, 0));
72  
73          JScrollPane centerScrollPane = new JScrollPane( centerPanel,
74                  JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
75                  JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
76          
77          centerScrollPane.getVerticalScrollBar().setUnitIncrement(10);
78          centerScrollPane.getHorizontalScrollBar().setUnitIncrement(10);
79  
80          main = new JPanel( new BorderLayout());
81          main.setBorder( new EmptyBorder( 2, 5, 0, 5));
82          main.add( centerScrollPane, BorderLayout.CENTER);
83          add( main, BorderLayout.CENTER);
84  	}
85      
86      protected void setCenterPanel( JPanel center) {
87          centerPanel.add( center, BorderLayout.CENTER);
88      }
89  	
90      protected void setTitleBar( TitleBar titleBar) {
91          titleBar.add(new JToolBar.Separator());
92          titleBar.add(new PageHelpAction(view.getProjectsView().getRoot()));
93          
94          main.add( titleBar, BorderLayout.NORTH);
95      }
96  
97      public void showPropertiesDialog() {
98  	}
99  	
100 	public ProjectView getProjectView() {
101 		return view;
102 	}
103 
104     public abstract String getShortName();
105 
106     /***
107      * @return an help ID for the page
108      */
109     public abstract String getHelpID();
110 
111     /* (non-Javadoc)
112 	 * @see org.xmlhammer.gui.overview.OverviewNode#getNodeName()
113 	 */
114 	public abstract String getNodeName();
115 
116 	/* (non-Javadoc)
117 	 * @see org.xmlhammer.gui.overview.OverviewNode#getChildNodes()
118 	 */
119 	public abstract ArrayList<OverviewNode> getChildNodes();
120 	
121 	/* (non-Javadoc)
122 	 * @see org.xmlhammer.gui.overview.OverviewNode#getParentNode()
123 	 */
124 	public OverviewNode getParentNode() {
125 		return getProjectView().getOverviewPanel().getModel().getRoot();
126 	}
127 
128 	/* (non-Javadoc)
129 	 * @see org.xmlhammer.gui.overview.OverviewNode#getNodeIcon()
130 	 */
131 	public Icon getNodeIcon() {
132 		return PAGE_ICON;
133 	}
134     
135     public abstract void dispose();
136 }