Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: com/robrohan/treebeard/XMLSetup.java


1   /*
2    * Treebeard: an xml xslt transfomer
3    * Copyright (C) 2002 Rob Rohan
4    * This program is free software; you can redistribute it and/or modify it
5    * under the terms of the GNU General Public License as published by the
6    * Free Software Foundation; either version 2 of the License, or (at your
7    * option) any later version.
8    * 
9    * This program is distributed in the hope that it will be useful, but 
10   * WITHOUT ANY WARRANTY; without even the implied warranty of 
11   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 
12   * General Public License for more details.
13   * 
14   * You should have received a copy of the GNU General Public License along 
15   * with this program; if not, write to the Free Software Foundation, Inc.,
16   * 675 Mass Ave, Cambridge, MA 02139, USA.
17   *
18   * Email: me@robrohan.com
19   * 
20   * XMLSetup.java
21   *
22   * Created on August 2, 2002, 11:48 PM
23   */
24  
25  package com.robrohan.treebeard;
26  
27  /**
28   * The dialog box to setup the XML and XSLT parsers
29   * @author  rob
30   */
31  public class XMLSetup extends javax.swing.JInternalFrame{ //javax.swing.JDialog {
32      
33      Settings settings_hndl;
34      
35      /** Creates new form XMLSetup
36       * @param parent to whom does this belong
37       * @param modal modal?
38       */
39      public XMLSetup(java.awt.Frame parent, boolean modal) {
40          //super(parent, modal);
41          super("XML Setup",false,false,false,false);
42          initComponents();
43          addDefaultItems();
44      }
45      
46      /** set the setting object this should be changing
47       * @param settings the global settings object
48       */    
49      public void setSettings(Settings settings){
50          this.settings_hndl = settings;
51          this.comboSAX.setSelectedItem(settings_hndl.SAXFactory);
52          this.comboDOM.setSelectedItem(settings_hndl.DOMFactory);
53          this.comboXSLT.setSelectedItem(settings_hndl.XSLTFactory);
54      }
55      
56      /** get the setting object handle this was / is changing
57       * @return the settings object
58       */    
59      public Settings getSettings(){
60          return this.settings_hndl;
61      }
62      
63      private void addDefaultItems(){
64          //this should be in a file...
65          this.comboSAX.addItem("org.apache.xerces.jaxp.SAXParserFactoryImpl");
66          this.comboSAX.addItem("com.icl.saxon.aelfred.SAXParserFactoryImpl");
67          
68          this.comboDOM.addItem("org.apache.xerces.jaxp.DocumentBuilderFactoryImpl");
69          this.comboDOM.addItem("com.icl.saxon.om.DocumentBuilderFactoryImpl");
70                  
71          this.comboXSLT.addItem("org.apache.xalan.processor.TransformerFactoryImpl");
72          this.comboXSLT.addItem("com.icl.saxon.TransformerFactoryImpl");
73          this.comboXSLT.addItem("oracle.xml.jaxp.JXSAXTransformerFactory");
74          this.comboXSLT.addItem("jd.xml.xslt.trax.TransformerFactoryImpl");
75          //this.comboXSLT.addItem("msxsl $1 $2");
76      }
77      
78      /** This method is called from within the constructor to
79       * initialize the form.
80       * WARNING: Do NOT modify this code. The content of this method is
81       * always regenerated by the Form Editor.
82       */
83      private void initComponents() {//GEN-BEGIN:initComponents
84          panCenter = new javax.swing.JPanel();
85          jPanel1 = new javax.swing.JPanel();
86          jPanel9 = new javax.swing.JPanel();
87          jLabel1 = new javax.swing.JLabel();
88          comboSAX = new javax.swing.JComboBox();
89          jPanel10 = new javax.swing.JPanel();
90          jLabel2 = new javax.swing.JLabel();
91          comboDOM = new javax.swing.JComboBox();
92          jPanel6 = new javax.swing.JPanel();
93          jPanel8 = new javax.swing.JPanel();
94          jLabel3 = new javax.swing.JLabel();
95          comboXSLT = new javax.swing.JComboBox();
96          jPanel2 = new javax.swing.JPanel();
97          panBottom = new javax.swing.JPanel();
98          cmdOk = new javax.swing.JButton();
99          cmdApply = new javax.swing.JButton();
100         cmdClose = new javax.swing.JButton();
101         jPanel4 = new javax.swing.JPanel();
102         jPanel5 = new javax.swing.JPanel();
103 
104         setTitle("XML Setup");
105         setDefaultCloseOperation(javax.swing.WindowConstants.HIDE_ON_CLOSE);
106         panCenter.setLayout(new javax.swing.BoxLayout(panCenter, javax.swing.BoxLayout.Y_AXIS));
107 
108         jPanel1.setLayout(new javax.swing.BoxLayout(jPanel1, javax.swing.BoxLayout.Y_AXIS));
109 
110         jPanel9.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.RIGHT));
111 
112         jLabel1.setText("SAX:");
113         jPanel9.add(jLabel1);
114 
115         comboSAX.setEditable(true);
116         comboSAX.setPreferredSize(new java.awt.Dimension(295, 25));
117         jPanel9.add(comboSAX);
118 
119         jPanel1.add(jPanel9);
120 
121         jPanel10.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.RIGHT));
122 
123         jLabel2.setText("DOM:");
124         jPanel10.add(jLabel2);
125 
126         comboDOM.setEditable(true);
127         comboDOM.setPreferredSize(new java.awt.Dimension(295, 25));
128         jPanel10.add(comboDOM);
129 
130         jPanel1.add(jPanel10);
131 
132         panCenter.add(jPanel1);
133 
134         jPanel6.setLayout(new javax.swing.BoxLayout(jPanel6, javax.swing.BoxLayout.Y_AXIS));
135 
136         jPanel8.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.RIGHT));
137 
138         jLabel3.setText("XSLT Parser:");
139         jPanel8.add(jLabel3);
140 
141         comboXSLT.setEditable(true);
142         comboXSLT.setPreferredSize(new java.awt.Dimension(295, 25));
143         jPanel8.add(comboXSLT);
144 
145         jPanel6.add(jPanel8);
146 
147         panCenter.add(jPanel6);
148 
149         getContentPane().add(panCenter, java.awt.BorderLayout.CENTER);
150 
151         getContentPane().add(jPanel2, java.awt.BorderLayout.NORTH);
152 
153         panBottom.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.RIGHT));
154 
155         cmdOk.setText("Okay");
156         cmdOk.addActionListener(new java.awt.event.ActionListener() {
157             public void actionPerformed(java.awt.event.ActionEvent evt) {
158                 cmdOkActionPerformed(evt);
159             }
160         });
161 
162         panBottom.add(cmdOk);
163 
164         cmdApply.setText("Apply");
165         cmdApply.addActionListener(new java.awt.event.ActionListener() {
166             public void actionPerformed(java.awt.event.ActionEvent evt) {
167                 cmdApplyActionPerformed(evt);
168             }
169         });
170 
171         panBottom.add(cmdApply);
172 
173         cmdClose.setText("Close");
174         cmdClose.addActionListener(new java.awt.event.ActionListener() {
175             public void actionPerformed(java.awt.event.ActionEvent evt) {
176                 cmdCloseActionPerformed(evt);
177             }
178         });
179 
180         panBottom.add(cmdClose);
181 
182         getContentPane().add(panBottom, java.awt.BorderLayout.SOUTH);
183 
184         getContentPane().add(jPanel4, java.awt.BorderLayout.EAST);
185 
186         getContentPane().add(jPanel5, java.awt.BorderLayout.WEST);
187 
188         pack();
189     }//GEN-END:initComponents
190 
191     private void cmdApplyActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmdApplyActionPerformed
192         setSettings();
193     }//GEN-LAST:event_cmdApplyActionPerformed
194 
195     private void cmdCloseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmdCloseActionPerformed
196         //this.settings_hndl = null;
197         killWindow();
198     }//GEN-LAST:event_cmdCloseActionPerformed
199 
200     private void cmdOkActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmdOkActionPerformed
201         setSettings();
202         killWindow();
203     }//GEN-LAST:event_cmdOkActionPerformed
204     
205     private void setSettings(){
206         settings_hndl.DOMFactory = this.comboDOM.getSelectedItem().toString();
207         settings_hndl.SAXFactory = this.comboSAX.getSelectedItem().toString();
208         settings_hndl.XSLTFactory = this.comboXSLT.getSelectedItem().toString();   
209     }
210     
211     private void killWindow(){
212         setVisible(false);
213         //dispose();   
214     }
215     /** Closes the dialog */
216     private void closeDialog(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_closeDialog
217         killWindow();
218     }//GEN-LAST:event_closeDialog
219     
220     /**
221      * @param args the command line arguments
222      
223     public static void main(String args[]) {
224         new XMLSetup(new javax.swing.JFrame(), true).show();
225     } */
226     
227     
228     // Variables declaration - do not modify//GEN-BEGIN:variables
229     private javax.swing.JPanel jPanel4;
230     private javax.swing.JButton cmdOk;
231     private javax.swing.JLabel jLabel1;
232     private javax.swing.JLabel jLabel3;
233     private javax.swing.JComboBox comboDOM;
234     private javax.swing.JPanel jPanel10;
235     private javax.swing.JLabel jLabel2;
236     private javax.swing.JComboBox comboSAX;
237     private javax.swing.JPanel jPanel2;
238     private javax.swing.JPanel jPanel5;
239     private javax.swing.JButton cmdClose;
240     private javax.swing.JPanel panBottom;
241     private javax.swing.JPanel jPanel8;
242     private javax.swing.JPanel jPanel1;
243     private javax.swing.JButton cmdApply;
244     private javax.swing.JPanel jPanel6;
245     private javax.swing.JComboBox comboXSLT;
246     private javax.swing.JPanel panCenter;
247     private javax.swing.JPanel jPanel9;
248     // End of variables declaration//GEN-END:variables
249     
250 }