KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > antlr > works > project > ProjectSettingsDialog


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

47
48 public class ProjectSettingsDialog extends XJDialog {
49
50     public ProjectSettingsDialog(Container parent) {
51         super(parent, true);
52
53         initComponents();
54         setSize(600, 160);
55
56         if(XJSystem.isMacOS()) {
57             CellConstraints cc = new CellConstraints();
58
59             buttonBar.remove(cancelButton);
60             buttonBar.remove(okButton);
61
62             buttonBar.add(cancelButton, cc.xy(2, 1));
63             buttonBar.add(okButton, cc.xy(4, 1));
64         }
65
66         setDefaultButton(okButton);
67         setOKButton(okButton);
68         setCancelButton(cancelButton);
69
70         sourceChooseButton.addActionListener(new ActionListener JavaDoc() {
71             public void actionPerformed(ActionEvent JavaDoc e) {
72                 if(XJFileChooser.shared().displayChooseDirectory(ProjectSettingsDialog.this.getJavaComponent())) {
73                     sourceField.setText(XJFileChooser.shared().getSelectedFilePath());
74                 }
75             }
76         });
77     }
78
79     public void dialogWillCloseOK() {
80     }
81
82     public void setSourcePath(String JavaDoc path) {
83         sourceField.setText(path);
84     }
85
86     public String JavaDoc getSourcePath() {
87         return sourceField.getText();
88     }
89
90     private void initComponents() {
91         // JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents
92
// Generated using JFormDesigner Open Source Project license - ANTLR (www.antlr.org)
93
dialogPane = new JPanel();
94         contentPane = new JPanel();
95         label1 = new JLabel();
96         sourceField = new JTextField();
97         sourceChooseButton = new JButton();
98         label2 = new JLabel();
99         buttonBar = new JPanel();
100         okButton = new JButton();
101         cancelButton = new JButton();
102         CellConstraints cc = new CellConstraints();
103
104         //======== this ========
105
setTitle("Project Settings");
106         Container contentPane2 = getContentPane();
107         contentPane2.setLayout(new BorderLayout());
108
109         //======== dialogPane ========
110
{
111             dialogPane.setBorder(Borders.DIALOG_BORDER);
112             dialogPane.setLayout(new BorderLayout());
113
114             //======== contentPane ========
115
{
116                 contentPane.setLayout(new FormLayout(
117                     new ColumnSpec[] {
118                         FormFactory.DEFAULT_COLSPEC,
119                         FormFactory.LABEL_COMPONENT_GAP_COLSPEC,
120                         new ColumnSpec("max(min;200dlu):grow"),
121                         FormFactory.LABEL_COMPONENT_GAP_COLSPEC,
122                         FormFactory.DEFAULT_COLSPEC
123                     },
124                     new RowSpec[] {
125                         FormFactory.DEFAULT_ROWSPEC,
126                         FormFactory.LINE_GAP_ROWSPEC,
127                         FormFactory.DEFAULT_ROWSPEC,
128                         FormFactory.LINE_GAP_ROWSPEC,
129                         FormFactory.DEFAULT_ROWSPEC,
130                         FormFactory.LINE_GAP_ROWSPEC,
131                         FormFactory.DEFAULT_ROWSPEC
132                     }));
133
134                 //---- label1 ----
135
label1.setText("Source:");
136                 contentPane.add(label1, cc.xy(1, 3));
137                 contentPane.add(sourceField, cc.xy(3, 3));
138
139                 //---- sourceChooseButton ----
140
sourceChooseButton.setText("Choose...");
141                 contentPane.add(sourceChooseButton, cc.xy(5, 3));
142
143                 //---- label2 ----
144
label2.setText("Specify the source directory of the project");
145                 label2.setFont(new Font("Lucida Grande", Font.PLAIN, 10));
146                 contentPane.add(label2, cc.xy(3, 5));
147             }
148             dialogPane.add(contentPane, BorderLayout.CENTER);
149
150             //======== buttonBar ========
151
{
152                 buttonBar.setBorder(Borders.BUTTON_BAR_GAP_BORDER);
153                 buttonBar.setLayout(new FormLayout(
154                     new ColumnSpec[] {
155                         FormFactory.GLUE_COLSPEC,
156                         FormFactory.BUTTON_COLSPEC,
157                         FormFactory.RELATED_GAP_COLSPEC,
158                         FormFactory.BUTTON_COLSPEC
159                     },
160                     RowSpec.decodeSpecs("pref")));
161
162                 //---- okButton ----
163
okButton.setText("OK");
164                 buttonBar.add(okButton, cc.xy(2, 1));
165
166                 //---- cancelButton ----
167
cancelButton.setText("Cancel");
168                 buttonBar.add(cancelButton, cc.xy(4, 1));
169             }
170             dialogPane.add(buttonBar, BorderLayout.SOUTH);
171         }
172         contentPane2.add(dialogPane, BorderLayout.CENTER);
173         pack();
174         // JFormDesigner - End of component initialization //GEN-END:initComponents
175
}
176
177     // JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables
178
// Generated using JFormDesigner Open Source Project license - ANTLR (www.antlr.org)
179
private JPanel dialogPane;
180     private JPanel contentPane;
181     private JLabel label1;
182     private JTextField sourceField;
183     private JButton sourceChooseButton;
184     private JLabel label2;
185     private JPanel buttonBar;
186     private JButton okButton;
187     private JButton cancelButton;
188     // JFormDesigner - End of variables declaration //GEN-END:variables
189

190 }
191
Popular Tags