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  
23  package org.xmlhammer.gui.xslt;
24  
25  import java.util.ArrayList;
26  import java.util.List;
27  
28  import javax.swing.JFrame;
29  import javax.swing.event.TreeSelectionListener;
30  
31  import org.xmlhammer.gui.preferences.JAXPPropertiesDialog;
32  import org.xmlhammer.gui.preferences.PropertiesPanel;
33  import org.xmlhammer.gui.util.preferences.HelpEnabledPreferencesPage;
34  import org.xmlhammer.model.jaxp.Property;
35  import org.xmlhammer.model.tools.xslt.OutputProperty;
36  
37  /***
38   * Put comment...
39   * 
40   * @version $Revision$, $Date$
41   * @author Edwin Dankert <edankert@gmail.com>
42   */
43  
44  public class XMLOutputPropertiesDialog extends JAXPPropertiesDialog implements TreeSelectionListener {
45      private static final long serialVersionUID = 2673193241652494262L;
46      
47      private PropertiesPanel propertiesPanel = null;
48  	
49  	/***
50  	 * @param parent the underlying frame
51  	 */
52  	public XMLOutputPropertiesDialog(JFrame parent) {
53  		super( parent, "Properties");
54  
55  		add((HelpEnabledPreferencesPage)null, getOutputPropertiesPanel());
56  	}
57  	
58  	protected PropertiesPanel getOutputPropertiesPanel() {
59  		if (propertiesPanel == null) {
60              propertiesPanel = new PropertiesPanel(null, "Output Properties", "project.trax.output", false);
61  		}
62  		
63  		return propertiesPanel;
64  	}
65  		
66  	/***
67  	 * @return the SAXParserfactory settings, 
68  	 * 		   null if global settings should be used.
69  	 */
70  	public List<OutputProperty> getOutputProperties( ) {
71          List<OutputProperty> properties = new ArrayList<OutputProperty>();
72          List<Property> props = getOutputPropertiesPanel().getProperties();
73  
74          for (Property prop : props) {
75              OutputProperty property = new OutputProperty();
76              property.setName(prop.getName());
77              property.setValue(prop.getValue());
78              property.setActive(prop.isActive());
79              properties.add(property);
80          }
81  
82  		return properties;
83  	}
84  	
85      /***
86       * @return the SAXParserfactory settings, 
87       *         null if global settings should be used.
88       */
89      public void setOutputProperties(List<OutputProperty> properties) {
90          List<Property> props = new ArrayList<Property>();
91  
92          for (OutputProperty property : properties) {
93              Property prop = new Property();
94              prop.setName(property.getName());
95              prop.setValue(property.getValue());
96              prop.setActive(property.isActive());
97              props.add(prop);
98          }
99          
100         getOutputPropertiesPanel().setProperties(props);
101     }
102 }