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 ; 16 import java.awt.event.ActionListener ; 17 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 () { 71 public void actionPerformed(ActionEvent 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 path) { 83 sourceField.setText(path); 84 } 85 86 public String getSourcePath() { 87 return sourceField.getText(); 88 } 89 90 private void initComponents() { 91 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 setTitle("Project Settings"); 106 Container contentPane2 = getContentPane(); 107 contentPane2.setLayout(new BorderLayout()); 108 109 { 111 dialogPane.setBorder(Borders.DIALOG_BORDER); 112 dialogPane.setLayout(new BorderLayout()); 113 114 { 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.setText("Source:"); 136 contentPane.add(label1, cc.xy(1, 3)); 137 contentPane.add(sourceField, cc.xy(3, 3)); 138 139 sourceChooseButton.setText("Choose..."); 141 contentPane.add(sourceChooseButton, cc.xy(5, 3)); 142 143 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 { 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.setText("OK"); 164 buttonBar.add(okButton, cc.xy(2, 1)); 165 166 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 } 176 177 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 190 } 191 | Popular Tags |