1 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 ; 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 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 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 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 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 setTitle("Submit File"); 112 Container contentPane2 = getContentPane(); 113 contentPane2.setLayout(new BorderLayout()); 114 115 { 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 { 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.setText("Enter a description:"); 140 contentPane.add(label1, cc.xy(1, 1)); 141 142 description.setBorder(LineBorder.createBlackLineBorder()); 144 contentPane.add(description, cc.xywh(1, 3, 3, 1)); 145 146 keepOpenButton.setText("Keep file open after submit"); 148 contentPane.add(keepOpenButton, cc.xy(1, 5)); 149 } 150 dialogPane.add(contentPane, BorderLayout.CENTER); 151 152 { 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.setText("Submit"); 166 buttonBar.add(submitButton, cc.xy(2, 1)); 167 168 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 } 178 179 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 191 } 192 | Popular Tags |