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

Quick Search    Search Deep

Source code: com/robrohan/editorkit/XMLKitTest.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   * XMLKitTest.java
21   *
22   * Created on July 20, 2002, 11:43 AM
23   */
24  
25  package com.robrohan.editorkit;
26  
27  import javax.swing.*;
28  import java.awt.*;
29  import java.awt.event.*;
30  
31  /**
32   * Used to test out changes to the Jedit libraries - can remove from build
33   * if you want
34   * @author  rob
35   */
36  public class XMLKitTest {
37      
38      private javax.swing.Timer timer;
39      
40      /** Creates a new instance of XMLKitTest */
41      public XMLKitTest() {;}
42  
43      /** Simple wrapper around JEditorPane to browse xsl text
44       * using the JEdit plug-in.
45       *
46       * java JavaKitTest filename
47       * @param args arguments
48       */
49  
50      public void runTest(String filename){
51          try {
52              com.robrohan.editorkit.XMLEditorPaneDnD editor = new com.robrohan.editorkit.XMLEditorPaneDnD("text/xsl");
53              //final javax.swing.JTextArea editor = new javax.swing.JTextArea();
54              //editor.requestFocus();
55              java.io.File file = new java.io.File(filename);
56              editor.loadFile(file);
57              
58              javax.swing.JFrame f = new javax.swing.JFrame("XMLEditorKit: " + filename);
59              
60  //            final JPanel glass = (JPanel)f.getGlassPane();
61  //            glass.setVisible(true);
62  //            glass.setLayout(new GridBagLayout());
63  //            JButton glassButton = new JButton("Start");
64  //            glass.add(glassButton);
65  //            glassButton.setLocation(100,200);
66              
67              
68              f.addWindowListener(new java.awt.event.WindowAdapter() {
69                  public void windowClosing(java.awt.event.WindowEvent evt) {
70                       System.exit(0);
71                  }
72              });
73  
74              //f.getContentPane().setLayout(new java.awt.BorderLayout());
75              
76              //JPanel p = new JPanel(new BorderLayout());
77              
78              //final JPanel p = new JPanel();
79              //final OverlayLayout overlay = new OverlayLayout(p);
80              //p.setLayout(overlay);
81              
82              //final javax.swing.JButton jl = new javax.swing.JButton("TEST");
83              final JList jl = new JList(
84                  new String[]{ "One", "tWo", "Three", "Four", "Five", "Six" }
85              );
86              jl.setDoubleBuffered(true);
87              jl.setBorder(new javax.swing.border.BevelBorder(
88                  javax.swing.border.BevelBorder.RAISED
89              ));
90              jl.setVisibleRowCount(2);
91              jl.setAutoscrolls(true);
92              jl.validate();
93              final JScrollPane pane = new JScrollPane(jl);
94              
95              /* final javax.swing.JComboBox jl = new javax.swing.JComboBox(
96                  new String[]{ "One", "tWo", "Three", "Four", "Five", "Six" }
97              ); */
98              
99              
100             //System.out.println(editor.getLayout().getClass().toString());
101             //editor.setLayout(overlay);
102             JLayeredPane jlp = new JLayeredPane();
103             
104             jlp.add(editor,JLayeredPane.DEFAULT_LAYER);
105             //jlp.add(pane,JLayeredPane.POPUP_LAYER);
106             
107             
108             //p.add(editor);
109             //p.add(pane);
110             //overlay.invalidateLayout(p);
111             //pane.setAlignmentX(Float.valueOf("0.5").floatValue());
112             //pane.setAlignmentY(Float.valueOf("0.2").floatValue());
113             
114             
115             //p.doLayout();
116             
117             //get the top left corner of this component on screen
118             //Point = p.getLocationOnScreen()
119             //f.setContentPane(jlp);
120             f.getContentPane().add(jlp);
121             
122             f.pack();
123             f.setSize(600, 600);
124             f.setVisible(true);
125             
126             /* if(timer == null){
127                 timer = new javax.swing.Timer(2000, new java.awt.event.ActionListener() {
128                     public void actionPerformed(ActionEvent evt) {
129                         pane.requestFocus();
130                         jl.requestFocus();
131                         overlay.invalidateLayout(p);
132                         p.doLayout();
133                         //p.repaint();
134                     }    
135                 });
136                 timer.start();
137             } */
138            
139         } catch (Throwable e) {
140             e.printStackTrace();
141             System.exit(1);
142         }
143     }
144     
145     ///////////////////////////////////////////////////////////////////////////
146     public static void main(String[] args) {
147         
148       if (args.length != 1) {
149             System.err.println("Missing file name");
150             System.err.println("Usage: XMLKitTest <filename>");
151             System.exit(1);
152         }
153   
154         XMLKitTest xkt = new XMLKitTest();
155         xkt.runTest(args[0]);
156         
157     }
158 }