KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > antlr > works > scm > p4 > P4SubmitDialog


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
33 package org.antlr.works.scm.p4;
34
35 import com.jgoodies.forms.factories.Borders;
36 import com.jgoodies.forms.factories.FormFactory;
37 import com.jgoodies.forms.layout.*;
38 import org.antlr.xjlib.appkit.frame.XJDialog;
39 import org.antlr.xjlib.appkit.utils.XJAlert;
40 import org.antlr.xjlib.foundation.XJSystem;
41
42 import javax.swing.*;
43 import javax.swing.border.LineBorder JavaDoc;
44 import java.awt.*;
45
46 public class P4SubmitDialog extends XJDialog {
47
48     public P4SubmitDialog(Container parent) {
49         super(parent, true);
50
51         initComponents();
52         setSize(550, 500);
53
54         if(XJSystem.isMacOS()) {
55             CellConstraints cc = new CellConstraints();
56
57             buttonBar.remove(cancelButton);
58             buttonBar.remove(submitButton);
59
60             buttonBar.add(cancelButton, cc.xy(2, 1));
61             buttonBar.add(submitButton, cc.xy(4, 1));
62         }
63
64         setDefaultButton(submitButton);
65         setOKButton(submitButton);
66         setCancelButton(cancelButton);
67     }
68
69     public String JavaDoc getDescription() {
70         return description.getText();
71     }
72
73     public boolean getRemainOpen() {
74         return keepOpenButton.isSelected();
75     }
76
77     public void dialogWillDisplay() {
78         description.setText("");
79     }
80
81     public boolean dialogCanCloseOK() {
82         String JavaDoc text = description.getText();
83         if(text.length() == 0) {
84             XJAlert.display(getJavaComponent(), "Cannot Submit", "You must provide a description in order to submit.");
85             return false;
86         } else
87             return true;
88     }
89
90     public void dialogWillCloseOK() {
91         String JavaDoc text = description.getText();
92         if(text.length() == 0) {
93             XJAlert.display(getJavaComponent(), "Cannot Submit", "You must provide a description in order to submit.");
94         }
95     }
96
97     private void initComponents() {
98         // JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents
99
// Generated using JFormDesigner Open Source Project license - ANTLR (www.antlr.org)
100
dialogPane = new JPanel();
101         contentPane = new JPanel();
102         label1 = new JLabel();
103         description = new JTextArea();
104         keepOpenButton = new JCheckBox();
105         buttonBar = new JPanel();
106         submitButton = new JButton();
107         cancelButton = new JButton();
108         CellConstraints cc = new CellConstraints();
109
110         //======== this ========
111
setTitle("Submit File");
112         Container contentPane2 = getContentPane();
113         contentPane2.setLayout(new BorderLayout());
114
115         //======== dialogPane ========
116
{
117             dialogPane.setBorder(Borders.DIALOG_BORDER);
118             dialogPane.setPreferredSize(new Dimension(500, 300));
119             dialogPane.setMinimumSize(new Dimension(300, 300));
120             dialogPane.setLayout(new BorderLayout());
121
122             //======== contentPane ========
123
{
124                 contentPane.setLayout(new FormLayout(
125                     new ColumnSpec[] {
126                         new ColumnSpec(ColumnSpec.FILL, Sizes.DEFAULT, FormSpec.DEFAULT_GROW),
127                         FormFactory.LABEL_COMPONENT_GAP_COLSPEC,
128                         FormFactory.DEFAULT_COLSPEC
129                     },
130                     new RowSpec[] {
131                         FormFactory.DEFAULT_ROWSPEC,
132                         FormFactory.LINE_GAP_ROWSPEC,
133                         new RowSpec(RowSpec.FILL, Sizes.DEFAULT, FormSpec.DEFAULT_GROW),
134                         FormFactory.LINE_GAP_ROWSPEC,
135                         FormFactory.DEFAULT_ROWSPEC
136                     }));
137
138                 //---- label1 ----
139
label1.setText("Enter a description:");
140                 contentPane.add(label1, cc.xy(1, 1));
141
142                 //---- description ----
143
description.setBorder(LineBorder.createBlackLineBorder());
144                 contentPane.add(description, cc.xywh(1, 3, 3, 1));
145
146                 //---- keepOpenButton ----
147
keepOpenButton.setText("Keep file open after submit");
148                 contentPane.add(keepOpenButton, cc.xy(1, 5));
149             }
150             dialogPane.add(contentPane, BorderLayout.CENTER);
151
152             //======== buttonBar ========
153
{
154                 buttonBar.setBorder(Borders.BUTTON_BAR_GAP_BORDER);
155                 buttonBar.setLayout(new FormLayout(
156                     new ColumnSpec[] {
157                         FormFactory.GLUE_COLSPEC,
158                         FormFactory.BUTTON_COLSPEC,
159                         FormFactory.RELATED_GAP_COLSPEC,
160                         FormFactory.BUTTON_COLSPEC
161                     },
162                     RowSpec.decodeSpecs("pref")));
163
164                 //---- submitButton ----
165
submitButton.setText("Submit");
166                 buttonBar.add(submitButton, cc.xy(2, 1));
167
168                 //---- cancelButton ----
169
cancelButton.setText("Cancel");
170                 buttonBar.add(cancelButton, cc.xy(4, 1));
171             }
172             dialogPane.add(buttonBar, BorderLayout.SOUTH);
173         }
174         contentPane2.add(dialogPane, BorderLayout.CENTER);
175         pack();
176         // JFormDesigner - End of component initialization //GEN-END:initComponents
177
}
178
179     // JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables
180
// Generated using JFormDesigner Open Source Project license - ANTLR (www.antlr.org)
181
private JPanel dialogPane;
182     private JPanel contentPane;
183     private JLabel label1;
184     private JTextArea description;
185     private JCheckBox keepOpenButton;
186     private JPanel buttonBar;
187     private JButton submitButton;
188     private JButton cancelButton;
189     // JFormDesigner - End of variables declaration //GEN-END:variables
190

191 }
192
Popular Tags