KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > antlr > works > dialog > DialogAbout


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

31
32 package org.antlr.works.dialog;
33
34 import com.jgoodies.forms.factories.FormFactory;
35 import com.jgoodies.forms.layout.*;
36 import org.antlr.Tool;
37 import org.antlr.stringtemplate.StringTemplate;
38 import org.antlr.works.IDE;
39 import org.antlr.works.utils.IconManager;
40 import org.antlr.xjlib.appkit.app.XJApplication;
41 import org.antlr.xjlib.appkit.frame.XJPanel;
42 import org.antlr.xjlib.foundation.XJLib;
43
44 import javax.swing.*;
45 import javax.swing.table.DefaultTableModel JavaDoc;
46 import java.awt.*;
47 import java.util.ArrayList JavaDoc;
48 import java.util.List JavaDoc;
49
50 public class DialogAbout extends XJPanel {
51
52     public InfoTableModel tableModel = new InfoTableModel();
53
54     public DialogAbout() {
55         initComponents();
56
57         appIconButton.setIcon(IconManager.shared().getIconApplication());
58         copyrightLabel.setText("Copyright (c) 2005-2007 Jean Bovet & Terence Parr");
59
60         versionLabel.setText("Version "+XJApplication.getAppVersionLong());
61
62         infoTable.setModel(tableModel);
63         infoTable.getParent().setBackground(Color.white);
64         
65         tableModel.addInfo("ANTLRWorks", XJApplication.getAppVersionShort());
66         if(IDE.isPlugin()) {
67             tableModel.addInfo("ANTLRWorks Plugin", IDE.getPluginVersionShort());
68         }
69         tableModel.addInfo("ANTLR", Tool.VERSION);
70         tableModel.addInfo("StringTemplate", StringTemplate.VERSION);
71         tableModel.addInfo("XJLibrary", XJLib.stringVersion());
72         tableModel.addInfo("Java", System.getProperty("java.version")+" ("+System.getProperty("java.vendor")+")");
73         tableModel.fireTableDataChanged();
74
75         resetAcknowledge();
76         addAcknowledge("ANTLR and StringTemplate are (c) 1989-2007 Terence Parr");
77         addAcknowledge("XJLibrary is (c) 2004-2007 Jean Bovet");
78         addAcknowledge("Application & Mac OS X document icons are (c) Simon Bovet");
79         addAcknowledge("Portion of the GUI uses JGoodies, (c) 2002-2004 Karsten Lentzsch");
80         addAcknowledge("Portion of the GUI was created using JFormDesigner, (c) 2004-2005 Karl Tauber");
81         addAcknowledge("B-spline algorithm is (c) Leen Ammeraal <http://home.wxs.nl/~ammeraal/grjava.html>");
82         addAcknowledge("BrowserLauncher is (c) 2001 Eric Albert <ejalbert@cs.stanford.edu>");
83         addAcknowledge("Contributions by Matthew J. Diehl <good.mdiehl@comcast.net>");
84
85         setResizable(false);
86         setSize(800, 500);
87         center();
88     }
89
90     public void resetAcknowledge() {
91         acknowledgeTextArea.setText("");
92         //acknowledgeTextArea.setBackground(jFrame.getBackground());
93
acknowledgeTextArea.setBackground(null);
94     }
95
96     public void addAcknowledge(String JavaDoc ack) {
97         acknowledgeTextArea.setText(acknowledgeTextArea.getText()+"\n"+ack);
98     }
99
100     public boolean isAuxiliaryWindow() {
101         return true;
102     }
103
104     public class InfoTableModel extends DefaultTableModel JavaDoc {
105
106         public List JavaDoc<Object JavaDoc[]> info = new ArrayList JavaDoc<Object JavaDoc[]>();
107
108         public Object JavaDoc getValueAt(int row, int column) {
109             return (info.get(row))[column];
110         }
111
112         public boolean isCellEditable(int row, int column) {
113             return false;
114         }
115
116         public int getRowCount() {
117             if(info == null)
118                 return 0;
119             else
120                 return info.size();
121         }
122
123         public int getColumnCount() {
124             return 2;
125         }
126
127         public String JavaDoc getColumnName(int column) {
128             if(column == 0)
129                 return "Name";
130             else
131                 return "Version";
132         }
133
134         public void addInfo(String JavaDoc name, String JavaDoc version) {
135             info.add(new Object JavaDoc[] { name, version });
136         }
137     }
138
139     private void initComponents() {
140         // JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents
141
// Generated using JFormDesigner Open Source Project license - ANTLR (www.antlr.org)
142
appIconButton = new JButton();
143         descriptionLabel = new JLabel();
144         titleLabel = new JLabel();
145         versionLabel = new JLabel();
146         copyrightLabel = new JLabel();
147         tabbedPane1 = new JTabbedPane();
148         panel2 = new JPanel();
149         acknowledgeTextArea = new JTextArea();
150         panel1 = new JPanel();
151         scrollPane1 = new JScrollPane();
152         infoTable = new JTable();
153         CellConstraints cc = new CellConstraints();
154
155         //======== this ========
156
setResizable(false);
157         setTitle("About");
158         Container contentPane = getContentPane();
159         contentPane.setLayout(new FormLayout(
160             new ColumnSpec[] {
161                 new ColumnSpec(Sizes.dluX(10)),
162                 FormFactory.LABEL_COMPONENT_GAP_COLSPEC,
163                 FormFactory.DEFAULT_COLSPEC,
164                 FormFactory.LABEL_COMPONENT_GAP_COLSPEC,
165                 new ColumnSpec(ColumnSpec.FILL, Sizes.DEFAULT, FormSpec.DEFAULT_GROW),
166                 FormFactory.LABEL_COMPONENT_GAP_COLSPEC,
167                 new ColumnSpec(Sizes.dluX(10))
168             },
169             new RowSpec[] {
170                 new RowSpec(Sizes.dluY(10)),
171                 FormFactory.LINE_GAP_ROWSPEC,
172                 new RowSpec(RowSpec.BOTTOM, Sizes.DEFAULT, FormSpec.NO_GROW),
173                 FormFactory.LINE_GAP_ROWSPEC,
174                 new RowSpec("top:max(default;15dlu)"),
175                 FormFactory.LINE_GAP_ROWSPEC,
176                 new RowSpec("bottom:max(default;10dlu)"),
177                 FormFactory.LINE_GAP_ROWSPEC,
178                 new RowSpec("top:max(default;10dlu)"),
179                 FormFactory.LINE_GAP_ROWSPEC,
180                 new RowSpec("fill:max(default;60dlu):grow"),
181                 FormFactory.LINE_GAP_ROWSPEC,
182                 new RowSpec(Sizes.dluY(10))
183             }));
184
185         //---- appIconButton ----
186
appIconButton.setIcon(null);
187         appIconButton.setBorderPainted(false);
188         appIconButton.setContentAreaFilled(false);
189         appIconButton.setDefaultCapable(false);
190         appIconButton.setEnabled(true);
191         appIconButton.setFocusable(false);
192         appIconButton.setFocusPainted(false);
193         appIconButton.setPreferredSize(new Dimension(124, 144));
194         appIconButton.setMaximumSize(new Dimension(136, 144));
195         appIconButton.setMinimumSize(new Dimension(136, 144));
196         contentPane.add(appIconButton, cc.xywh(3, 3, 1, 8));
197
198         //---- descriptionLabel ----
199
descriptionLabel.setText("A graphical development environment for developing and debugging ANTLR v3 grammars");
200         descriptionLabel.setHorizontalAlignment(SwingConstants.LEFT);
201         descriptionLabel.setHorizontalTextPosition(SwingConstants.LEFT);
202         descriptionLabel.setVerticalTextPosition(SwingConstants.TOP);
203         descriptionLabel.setVerticalAlignment(SwingConstants.TOP);
204         contentPane.add(descriptionLabel, cc.xywh(5, 7, 1, 2));
205
206         //---- titleLabel ----
207
titleLabel.setText("ANTLRWorks");
208         titleLabel.setFont(new Font("Lucida Grande", Font.BOLD, 36));
209         contentPane.add(titleLabel, cc.xy(5, 3));
210
211         //---- versionLabel ----
212
versionLabel.setText("Version 1.0 early access 1");
213         contentPane.add(versionLabel, cc.xy(5, 5));
214
215         //---- copyrightLabel ----
216
copyrightLabel.setText("Copyright (c) 2005 Jean Bovet & Terence Parr");
217         contentPane.add(copyrightLabel, cc.xy(5, 9));
218
219         //======== tabbedPane1 ========
220
{
221
222             //======== panel2 ========
223
{
224                 panel2.setLayout(new FormLayout(
225                     new ColumnSpec[] {
226                         new ColumnSpec(Sizes.dluX(10)),
227                         FormFactory.LABEL_COMPONENT_GAP_COLSPEC,
228                         new ColumnSpec(ColumnSpec.FILL, Sizes.DEFAULT, FormSpec.DEFAULT_GROW),
229                         FormFactory.LABEL_COMPONENT_GAP_COLSPEC,
230                         new ColumnSpec(Sizes.dluX(10))
231                     },
232                     new RowSpec[] {
233                         new RowSpec(Sizes.dluY(10)),
234                         FormFactory.LINE_GAP_ROWSPEC,
235                         new RowSpec(RowSpec.FILL, Sizes.DEFAULT, FormSpec.NO_GROW),
236                         FormFactory.LINE_GAP_ROWSPEC,
237                         new RowSpec(Sizes.dluY(10))
238                     }));
239
240                 //---- acknowledgeTextArea ----
241
acknowledgeTextArea.setText("ANTLR and StringTemplate are (c) 1989-2005 Terence Parr\nXJLibrary is (c) 2004-2005 Jean Bovet\nPortion of the GUI uses JGoodies, (c) 2002-2004 Karsten Lentzsch\nPortion of the GUI was created using JFormDesigner, (c) 2004-2005 Karl Tauber\nBrowserLauncher is (c) 2001 Eric Albert <ejalbert@cs.stanford.edu>\nApplication icon is (c) Matthew McClintock <matthew@mc.clintock.com>\n");
242                 acknowledgeTextArea.setEditable(false);
243                 acknowledgeTextArea.setBackground(SystemColor.window);
244                 panel2.add(acknowledgeTextArea, cc.xy(3, 3));
245             }
246             tabbedPane1.addTab("Acknowledgment", panel2);
247
248
249             //======== panel1 ========
250
{
251                 panel1.setLayout(new FormLayout(
252                     new ColumnSpec[] {
253                         new ColumnSpec(Sizes.dluX(10)),
254                         FormFactory.LABEL_COMPONENT_GAP_COLSPEC,
255                         new ColumnSpec(ColumnSpec.FILL, Sizes.DEFAULT, FormSpec.DEFAULT_GROW),
256                         FormFactory.LABEL_COMPONENT_GAP_COLSPEC,
257                         new ColumnSpec(Sizes.dluX(10))
258                     },
259                     new RowSpec[] {
260                         new RowSpec(Sizes.dluY(10)),
261                         FormFactory.LINE_GAP_ROWSPEC,
262                         new RowSpec(RowSpec.FILL, Sizes.dluY(10), FormSpec.DEFAULT_GROW),
263                         FormFactory.LINE_GAP_ROWSPEC,
264                         new RowSpec(Sizes.dluY(10))
265                     }));
266
267                 //======== scrollPane1 ========
268
{
269
270                     //---- infoTable ----
271
infoTable.setModel(new DefaultTableModel JavaDoc(
272                         new Object JavaDoc[][] {
273                             {null, null},
274                             {null, null},
275                             {null, null},
276                             {null, null},
277                         },
278                         new String JavaDoc[] {
279                             "Name", "Version"
280                         }
281                     ) {
282                         boolean[] columnEditable = new boolean[] {
283                             false, false
284                         };
285                         @Override JavaDoc
286                         public boolean isCellEditable(int rowIndex, int columnIndex) {
287                             return columnEditable[columnIndex];
288                         }
289                     });
290                     infoTable.setShowVerticalLines(true);
291                     scrollPane1.setViewportView(infoTable);
292                 }
293                 panel1.add(scrollPane1, cc.xy(3, 3));
294             }
295             tabbedPane1.addTab("Information", panel1);
296
297         }
298         contentPane.add(tabbedPane1, cc.xywh(3, 11, 3, 1));
299         pack();
300         // JFormDesigner - End of component initialization //GEN-END:initComponents
301
}
302
303     // JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables
304
// Generated using JFormDesigner Open Source Project license - ANTLR (www.antlr.org)
305
private JButton appIconButton;
306     private JLabel descriptionLabel;
307     private JLabel titleLabel;
308     private JLabel versionLabel;
309     private JLabel copyrightLabel;
310     private JTabbedPane tabbedPane1;
311     private JPanel panel2;
312     private JTextArea acknowledgeTextArea;
313     private JPanel panel1;
314     private JScrollPane scrollPane1;
315     private JTable infoTable;
316     // JFormDesigner - End of variables declaration //GEN-END:variables
317

318
319 }
320
Popular Tags