View Javadoc

1   /*
2    * $Id$
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.xslt;
23  
24  import java.awt.BorderLayout;
25  import java.net.URI;
26  import java.util.ArrayList;
27  import java.util.List;
28  
29  import javax.swing.Icon;
30  import javax.swing.ImageIcon;
31  import javax.swing.JPanel;
32  import javax.swing.border.EmptyBorder;
33  
34  import org.bounce.image.ImageLoader;
35  import org.xmlhammer.gui.history.HistoryUtilities;
36  import org.xmlhammer.gui.overview.OverviewNode;
37  import org.xmlhammer.gui.util.URIsPanel;
38  import org.xmlhammer.model.project.Document;
39  
40  /***
41   * Input Panel.
42   * 
43   * Allows to select either one URI, multiple URIs or 
44   * a range of files.
45   * 
46   * @version $Revision$, $Date$
47   * @author Edwin Dankert <edankert@gmail.com>
48   */
49  
50  public class StylesheetURIsPanel extends JPanel implements OverviewNode {
51  	private static final long serialVersionUID = 3689910673756729653L;
52  	private static final String NO_LANGUAGE = "<No Language Specified>";
53  
54      private static final ImageIcon COMBO_ICON = ImageLoader.get().getImage( "/org/xmlhammer/gui/icons/elcl16/view_menu.gif");
55      
56      private StylesheetsPage parent 		= null;
57  	private URIsPanel urisPanel		= null;
58  
59  	/***
60  	 * Constructs a new Input Panel.
61  	 */
62  	public StylesheetURIsPanel(StylesheetsPage parent) {
63  		super( new BorderLayout());
64  		
65  		this.parent = parent;
66  		
67  		setBorder( new EmptyBorder( 10, 10, 0, 10));
68  
69          urisPanel = new URIsPanel(parent, HistoryUtilities.getInstance().getStylesheets(), false, true);
70  
71  		JPanel mainPanel = new JPanel( new BorderLayout( 0, 5));
72  		mainPanel.add(urisPanel, BorderLayout.CENTER);
73  		
74  		add(mainPanel, BorderLayout.NORTH);
75  	}
76  	
77      public void setURIs(URI base, List uris) {
78          urisPanel.reset();
79          urisPanel.setURIs(base, uris);
80  	}
81      
82      public List<Document> getURIs(URI base) { 
83          return urisPanel.getURIs(base);
84      }
85  
86      public void setEnabled(boolean enabled) {
87          urisPanel.setEnabled(enabled);
88      }
89      
90      public boolean isEnabled() {
91          return urisPanel.isEnabled();
92      }
93  
94      public String getError() {
95          return null;
96      }
97  
98      public String getNodeName() {
99  //        String name = (String)schemaLanguageField.getSelectedItem();
100 //
101 //        if ( NO_LANGUAGE.equals( name)) {
102 //            return name;
103 //        }
104         return "test";//name + " (schemaLanguage)";
105     }
106 
107     public ArrayList<OverviewNode> getChildNodes() {
108     	if ( NO_LANGUAGE.equals( getNodeName())) {
109     		return new ArrayList<OverviewNode>();
110     	}
111 
112         return urisPanel.getNodes();
113     }
114 
115     public OverviewNode getParentNode() {
116         return parent;
117     }
118 
119     public Icon getNodeIcon() {
120     	return COMBO_ICON;
121     }
122     
123     public void dispose() {
124         urisPanel.dispose();
125     }
126 }