| 1 31 32 package org.antlr.works.generate; 33 34 import com.jgoodies.forms.factories.Borders; 35 import com.jgoodies.forms.factories.FormFactory; 36 import com.jgoodies.forms.layout.CellConstraints; 37 import com.jgoodies.forms.layout.ColumnSpec; 38 import com.jgoodies.forms.layout.FormLayout; 39 import com.jgoodies.forms.layout.RowSpec; 40 import org.antlr.xjlib.appkit.frame.XJDialog; 41 import org.antlr.xjlib.appkit.utils.XJFileChooser; 42 import org.antlr.xjlib.foundation.XJSystem; 43 import org.antlr.works.prefs.AWPrefs; 44 45 import javax.swing.*; 46 import java.awt.*; 47 import java.awt.event.ActionEvent ; 48 import java.awt.event.ActionListener ; 49 50 public class DialogGenerate extends XJDialog { 51 52 public DialogGenerate(Container parent) { 53 super(parent, true); 54 55 initComponents(); 56 setSize(612, 145); 57 58 if(XJSystem.isMacOS()) { 59 CellConstraints cc = new CellConstraints(); 60 61 buttonBar.remove(cancelButton); 62 buttonBar.remove(okButton); 63 64 buttonBar.add(cancelButton, cc.xy(2, 1)); 65 buttonBar.add(okButton, cc.xy(4, 1)); 66 } 67 68 setDefaultButton(okButton); 69 setOKButton(okButton); 70 setCancelButton(cancelButton); 71 72 outputPathField.setText(AWPrefs.getOutputPath()); 73 74 browseButton.addActionListener(new ActionListener () { 75 public void actionPerformed(ActionEvent event) { 76 if(XJFileChooser.shared().displayChooseDirectory(DialogGenerate.this.getJavaComponent())) { 77 outputPathField.setText(XJFileChooser.shared().getSelectedFilePath()); 78 } 79 } 80 }); 81 } 82 83 public void dialogWillCloseOK() { 84 AWPrefs.setOutputPath(getOutputPath()); 85 } 86 87 public void setDebugOnly() { 88 debugInfoButton.setSelected(true); 89 debugInfoButton.setVisible(false); 90 } 91 92 public boolean generateDebugInformation() { 93 return debugInfoButton.isSelected(); 94 } 95 96 public String getOutputPath() { 97 return outputPathField.getText(); 98 } 99 100 private void initComponents() { 101 dialogPane = new JPanel(); 104 contentPane = new JPanel(); 105 label1 = new JLabel(); 106 outputPathField = new JTextField(); 107 browseButton = new JButton(); 108 debugInfoButton = new JCheckBox(); 109 buttonBar = new JPanel(); 110 okButton = new JButton(); 111 cancelButton = new JButton(); 112 CellConstraints cc = new CellConstraints(); 113 114 setTitle("Generate"); 116 Container contentPane2 = getContentPane(); 117 contentPane2.setLayout(new BorderLayout()); 118 119 { 121 dialogPane.setBorder(Borders.DIALOG_BORDER); 122 dialogPane.setLayout(new BorderLayout()); 123 124 { 126 contentPane.setLayout(new FormLayout( 127 new ColumnSpec[] { 128 FormFactory.DEFAULT_COLSPEC, 129 FormFactory.LABEL_COMPONENT_GAP_COLSPEC, 130 new ColumnSpec("max(min;200dlu):grow"), 131 FormFactory.LABEL_COMPONENT_GAP_COLSPEC, 132 FormFactory.DEFAULT_COLSPEC 133 }, 134 new RowSpec[] { 135 FormFactory.DEFAULT_ROWSPEC, 136 FormFactory.LINE_GAP_ROWSPEC, 137 FormFactory.DEFAULT_ROWSPEC 138 })); 139 140 label1.setText("Output path:"); 142 label1.setHorizontalAlignment(SwingConstants.RIGHT); 143 contentPane.add(label1, cc.xy(1, 1)); 144 contentPane.add(outputPathField, cc.xy(3, 1)); 145 146 browseButton.setText("Browse..."); 148 contentPane.add(browseButton, cc.xy(5, 1)); 149 150 debugInfoButton.setText("Debug information"); 152 contentPane.add(debugInfoButton, cc.xy(3, 3)); 153 } 154 dialogPane.add(contentPane, BorderLayout.CENTER); 155 156 { 158 buttonBar.setBorder(Borders.BUTTON_BAR_GAP_BORDER); 159 buttonBar.setLayout(new FormLayout( 160 new ColumnSpec[] { 161 FormFactory.GLUE_COLSPEC, 162 FormFactory.BUTTON_COLSPEC, 163 FormFactory.RELATED_GAP_COLSPEC, 164 FormFactory.BUTTON_COLSPEC 165 }, 166 RowSpec.decodeSpecs("pref"))); 167 168 okButton.setText("OK"); 170 buttonBar.add(okButton, cc.xy(2, 1)); 171 172 cancelButton.setText("Cancel"); 174 buttonBar.add(cancelButton, cc.xy(4, 1)); 175 } 176 dialogPane.add(buttonBar, BorderLayout.SOUTH); 177 } 178 contentPane2.add(dialogPane, BorderLayout.CENTER); 179 pack(); 180 } 182 183 private JPanel dialogPane; 186 private JPanel contentPane; 187 private JLabel label1; 188 private JTextField outputPathField; 189 private JButton browseButton; 190 private JCheckBox debugInfoButton; 191 private JPanel buttonBar; 192 private JButton okButton; 193 private JButton cancelButton; 194 196 } 197 | Popular Tags |