Go to the documentation of this file.00001 package instruction.gui.tab;
00002
00003 import instruction.disambiguator.Disambiguator;
00004 import instruction.configuration.ConfigurationManager;
00005
00006 import java.awt.GridBagLayout;
00007 import javax.swing.JPanel;
00008 import javax.swing.JTextField;
00009 import java.awt.GridBagConstraints;
00010 import javax.swing.ButtonGroup;
00011 import javax.swing.JButton;
00012 import javax.swing.JFileChooser;
00013 import javax.swing.JLabel;
00014 import javax.swing.JRadioButton;
00015 import java.awt.Insets;
00016
00017 public class ConfigurationTab extends JPanel implements DialogTab {
00018
00019 private static final long serialVersionUID = 1L;
00020 private JTextField txtDisambiguator = null;
00021 private JButton btnBrowse2 = null;
00022 private JLabel jLabel3 = null;
00023 private JLabel jLabel31 = null;
00024 private JLabel jLabel6 = null;
00025 private JRadioButton jRadioButtonApply = null;
00026 private JRadioButton jRadioButtonTrain = null;
00027 private JLabel jLabel5 = null;
00028 private JTextField txtCycCache = null;
00029 private JButton btnBrowse3 = null;
00030 private JButton jButton = null;
00031 private JTextField jTextField = null;
00032 private JLabel jLabel = null;
00033
00034 private ButtonGroup disambMode = new ButtonGroup();
00035
00039 public ConfigurationTab() {
00040
00041 super();
00042 initialize();
00043 }
00044
00050 private void initialize() {
00051
00052 GridBagConstraints gridBagConstraints11 = new GridBagConstraints();
00053 gridBagConstraints11.gridx = 0;
00054 gridBagConstraints11.anchor = GridBagConstraints.WEST;
00055 gridBagConstraints11.insets = new Insets(5, 5, 5, 5);
00056 gridBagConstraints11.fill = GridBagConstraints.HORIZONTAL;
00057 gridBagConstraints11.gridy = 0;
00058 jLabel = new JLabel();
00059 jLabel.setText("Path to local Howtos:");
00060 GridBagConstraints gridBagConstraints10 = new GridBagConstraints();
00061 gridBagConstraints10.fill = GridBagConstraints.HORIZONTAL;
00062 gridBagConstraints10.gridy = 0;
00063 gridBagConstraints10.weightx = 1.0;
00064 gridBagConstraints10.insets = new Insets(5, 5, 5, 5);
00065 gridBagConstraints10.gridx = 1;
00066 GridBagConstraints gridBagConstraints91 = new GridBagConstraints();
00067 gridBagConstraints91.gridx = 2;
00068 gridBagConstraints91.insets = new Insets(5, 5, 5, 5);
00069 gridBagConstraints91.gridy = 0;
00070 GridBagConstraints gridBagConstraints9 = new GridBagConstraints();
00071 gridBagConstraints9.gridx = 2;
00072 gridBagConstraints9.insets = new Insets(5, 5, 5, 5);
00073 gridBagConstraints9.gridy = 5;
00074 GridBagConstraints gridBagConstraints8 = new GridBagConstraints();
00075 gridBagConstraints8.fill = GridBagConstraints.HORIZONTAL;
00076 gridBagConstraints8.gridy = 5;
00077 gridBagConstraints8.weightx = 1.0;
00078 gridBagConstraints8.insets = new Insets(5, 5, 5, 5);
00079 gridBagConstraints8.gridx = 1;
00080 GridBagConstraints gridBagConstraints7 = new GridBagConstraints();
00081 gridBagConstraints7.gridx = 0;
00082 gridBagConstraints7.anchor = GridBagConstraints.WEST;
00083 gridBagConstraints7.insets = new Insets(5, 5, 5, 5);
00084 gridBagConstraints7.fill = GridBagConstraints.HORIZONTAL;
00085 gridBagConstraints7.gridy = 5;
00086 jLabel5 = new JLabel();
00087 jLabel5.setText("Cyc Cache (optional):");
00088 GridBagConstraints gridBagConstraints6 = new GridBagConstraints();
00089 gridBagConstraints6.gridx = 1;
00090 gridBagConstraints6.anchor = GridBagConstraints.WEST;
00091 gridBagConstraints6.gridy = 4;
00092 GridBagConstraints gridBagConstraints5 = new GridBagConstraints();
00093 gridBagConstraints5.gridx = 1;
00094 gridBagConstraints5.anchor = GridBagConstraints.WEST;
00095 gridBagConstraints5.gridy = 3;
00096 GridBagConstraints gridBagConstraints4 = new GridBagConstraints();
00097 gridBagConstraints4.gridx = 0;
00098 gridBagConstraints4.anchor = GridBagConstraints.WEST;
00099 gridBagConstraints4.insets = new Insets(5, 5, 5, 5);
00100 gridBagConstraints4.fill = GridBagConstraints.HORIZONTAL;
00101 gridBagConstraints4.gridy = 3;
00102 jLabel6 = new JLabel();
00103 jLabel6.setText("Disambiguator Mode:");
00104 GridBagConstraints gridBagConstraints3 = new GridBagConstraints();
00105 gridBagConstraints3.gridx = 1;
00106 gridBagConstraints3.gridy = 2;
00107 jLabel31 = new JLabel();
00108 jLabel31.setText("");
00109 GridBagConstraints gridBagConstraints2 = new GridBagConstraints();
00110 gridBagConstraints2.gridx = 0;
00111 gridBagConstraints2.anchor = GridBagConstraints.WEST;
00112 gridBagConstraints2.insets = new Insets(5, 5, 5, 5);
00113 gridBagConstraints2.fill = GridBagConstraints.HORIZONTAL;
00114 gridBagConstraints2.gridy = 1;
00115 jLabel3 = new JLabel();
00116 jLabel3.setText("Disambiguator:");
00117 GridBagConstraints gridBagConstraints1 = new GridBagConstraints();
00118 gridBagConstraints1.gridx = 2;
00119 gridBagConstraints1.insets = new Insets(5, 5, 5, 5);
00120 gridBagConstraints1.gridy = 1;
00121 GridBagConstraints gridBagConstraints = new GridBagConstraints();
00122 gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
00123 gridBagConstraints.gridy = 1;
00124 gridBagConstraints.weightx = 1.0;
00125 gridBagConstraints.insets = new Insets(5, 5, 5, 5);
00126 gridBagConstraints.gridx = 1;
00127 this.setSize(693, 295);
00128 this.setLayout(new GridBagLayout());
00129 this.add(getTxtDisambiguator(), gridBagConstraints);
00130 this.add(getBtnBrowse2(), gridBagConstraints1);
00131 this.add(jLabel3, gridBagConstraints2);
00132 this.add(jLabel31, gridBagConstraints3);
00133 this.add(jLabel6, gridBagConstraints4);
00134 this.add(getJRadioButton(), gridBagConstraints5);
00135 this.add(getJRadioButton1(), gridBagConstraints6);
00136 disambMode.add(getJRadioButton());
00137 disambMode.add(getJRadioButton1());
00138 if (ConfigurationManager.getDisambiguatorMode() == Disambiguator.MODE_APPLY)
00139 getJRadioButton().setSelected(true);
00140 else
00141 getJRadioButton1().setSelected(true);
00142 this.add(jLabel5, gridBagConstraints7);
00143 this.add(getTxtCycCache(), gridBagConstraints8);
00144 this.add(getBtnBrowse3(), gridBagConstraints9);
00145 this.add(getJButton(), gridBagConstraints91);
00146 this.add(getJTextField(), gridBagConstraints10);
00147 this.add(jLabel, gridBagConstraints11);
00148 }
00149
00155 private JTextField getTxtDisambiguator() {
00156
00157 if (txtDisambiguator == null) {
00158 txtDisambiguator = new JTextField();
00159 txtDisambiguator.setText(ConfigurationManager
00160 .getPathDisambiguator() == null ? "" : ConfigurationManager
00161 .getPathDisambiguator());
00162 }
00163 return txtDisambiguator;
00164 }
00165
00171 private JButton getBtnBrowse2() {
00172
00173 if (btnBrowse2 == null) {
00174 btnBrowse2 = new JButton();
00175 btnBrowse2.setText("Browse...");
00176 btnBrowse2.addActionListener(new java.awt.event.ActionListener() {
00177 public void actionPerformed(java.awt.event.ActionEvent e) {
00178 JFileChooser dlg = new JFileChooser();
00179 if (dlg.showOpenDialog(ConfigurationTab.this) == JFileChooser.APPROVE_OPTION) {
00180 getTxtDisambiguator().setText(
00181 dlg.getSelectedFile().getAbsolutePath());
00182 }
00183 }
00184 });
00185 }
00186 return btnBrowse2;
00187 }
00188
00194 private JRadioButton getJRadioButton() {
00195
00196 if (jRadioButtonApply == null) {
00197 jRadioButtonApply = new JRadioButton();
00198 jRadioButtonApply.setText("Apply");
00199 }
00200 return jRadioButtonApply;
00201 }
00202
00208 private JRadioButton getJRadioButton1() {
00209
00210 if (jRadioButtonTrain == null) {
00211 jRadioButtonTrain = new JRadioButton();
00212 jRadioButtonTrain.setText("Train");
00213 }
00214 return jRadioButtonTrain;
00215 }
00216
00222 private JTextField getTxtCycCache() {
00223
00224 if (txtCycCache == null) {
00225 txtCycCache = new JTextField();
00226 txtCycCache
00227 .setText(ConfigurationManager.getPathCycCache() == null ? ""
00228 : ConfigurationManager.getPathCycCache());
00229 }
00230 return txtCycCache;
00231 }
00232
00238 private JButton getBtnBrowse3() {
00239
00240 if (btnBrowse3 == null) {
00241 btnBrowse3 = new JButton();
00242 btnBrowse3.setText("Browse...");
00243 }
00244 return btnBrowse3;
00245 }
00246
00247 public void onCancel() {
00248
00249
00250
00251 }
00252
00253 public void onOK() {
00254
00255 ConfigurationManager.setPathDisambiguator(txtDisambiguator.getText());
00256 ConfigurationManager.setPathCycCache(txtCycCache.getText());
00257 ConfigurationManager.setPathHowtos(jTextField.getText());
00258 ConfigurationManager.setDisambiguatorMode(getJRadioButton()
00259 .isSelected() ? Disambiguator.MODE_APPLY
00260 : Disambiguator.MODE_TRAIN);
00261 }
00262
00268 private JButton getJButton() {
00269
00270 if (jButton == null) {
00271 jButton = new JButton();
00272 jButton.setText("Browse...");
00273 jButton.addActionListener(new java.awt.event.ActionListener() {
00274 public void actionPerformed(java.awt.event.ActionEvent e) {
00275 JFileChooser dlg = new JFileChooser();
00276 dlg.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
00277 if (dlg.showOpenDialog(ConfigurationTab.this) == JFileChooser.APPROVE_OPTION) {
00278 getJTextField().setText(
00279 dlg.getSelectedFile().getAbsolutePath());
00280 }
00281 }
00282 });
00283
00284 }
00285 return jButton;
00286 }
00287
00293 private JTextField getJTextField() {
00294
00295 if (jTextField == null) {
00296 jTextField = new JTextField();
00297 jTextField
00298 .setText(ConfigurationManager.getPathHowtos() == null ? ""
00299 : ConfigurationManager.getPathHowtos());
00300 }
00301 return jTextField;
00302 }
00303
00304 }