KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > antlr > works > plugin > PluginTester


1 package org.antlr.works.plugin;
2
3 import org.antlr.works.components.grammar.CEditorGrammarDefaultDelegate;
4 import org.antlr.works.plugin.container.PluginContainer;
5
6 import javax.swing.*;
7 import java.awt.*;
8 /*
9
10 [The "BSD licence"]
11 Copyright (c) 2005-2006 Jean Bovet
12 All rights reserved.
13
14 Redistribution and use in source and binary forms, with or without
15 modification, are permitted provided that the following conditions
16 are met:
17
18 1. Redistributions of source code must retain the above copyright
19 notice, this list of conditions and the following disclaimer.
20 2. Redistributions in binary form must reproduce the above copyright
21 notice, this list of conditions and the following disclaimer in the
22 documentation and/or other materials provided with the distribution.
23 3. The name of the author may not be used to endorse or promote products
24 derived from this software without specific prior written permission.
25
26 THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
27 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
28 OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
29 IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
30 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
31 NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
35 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36
37 */

38
39 public class PluginTester {
40
41     public PluginContainer container;
42     protected JSplitPane vertical;
43
44     private void createAndShowGUI() {
45         container = new PluginContainer();
46         //container.load("/Users/bovet/Desktop/Java/java.g");
47
container.load("/Users/bovet/Desktop/TestAW.g");
48         assemble();
49
50         JFrame.setDefaultLookAndFeelDecorated(true);
51
52         JFrame frame = new JFrame("Plugin Tester");
53         frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
54         frame.setSize(900, 600);
55
56         frame.add(container.getRootPane());
57
58         frame.pack();
59         frame.setVisible(true);
60         container.becomingVisibleForTheFirstTime();
61         vertical.setDividerLocation((int)(container.getContentPane().getHeight()*0.5));
62     }
63
64     public void assemble() {
65         JSplitPane horizontal = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
66         horizontal.setLeftComponent(container.getRulesComponent());
67         horizontal.setRightComponent(container.getEditorComponent());
68         horizontal.setBorder(null);
69         horizontal.setContinuousLayout(true);
70         horizontal.setOneTouchExpandable(true);
71
72         vertical = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
73         vertical.setTopComponent(horizontal);
74         vertical.setBottomComponent(container.getTabbedComponent());
75         vertical.setBorder(null);
76         vertical.setContinuousLayout(true);
77         vertical.setOneTouchExpandable(true);
78
79         JPanel upperPanel = new JPanel(new BorderLayout());
80         upperPanel.add(container.getMenubarComponent(), BorderLayout.NORTH);
81         upperPanel.add(container.getToolbarComponent(), BorderLayout.CENTER);
82
83         JPanel panel = new JPanel(new BorderLayout());
84         panel.add(upperPanel, BorderLayout.NORTH);
85         panel.add(vertical, BorderLayout.CENTER);
86         panel.add(container.getStatusComponent(), BorderLayout.SOUTH);
87
88         container.setEditorGrammarDelegate(new CEditorGrammarDefaultDelegate(vertical));
89
90         container.getContentPane().add(panel);
91     }
92
93     public static void main(String JavaDoc[] args) {
94         javax.swing.SwingUtilities.invokeLater(new Runnable JavaDoc() {
95             public void run() {
96                 new PluginTester().createAndShowGUI();
97             }
98         });
99     }
100
101 }
102
Popular Tags