package ir.ac.iust.nlp.dependencyparser.utility.parsing;
import ir.ac.iust.nlp.dependencyparser.BasePanel;
import ir.ac.iust.nlp.dependencyparser.utility.enumeration.Flowchart;
import java.io.File;
import javax.swing.SpinnerNumberModel;
/**
*
* @author Mojtaba Khallash
*/
public class ClearSettingsPanel extends javax.swing.JPanel {
/**
* Creates new form ClearSettingsPanel
*/
public ClearSettingsPanel() {
this("", Flowchart.Train);
}
public ClearSettingsPanel(String dir, Flowchart chart) {
initComponents();
txtConfigFile.setText(dir + File.separator +
"Treebank" + File.separator +
"clearParser" + File.separator +
"config_dep_en.xml");
txtFeatureTemplateFile.setText(dir + File.separator +
"Treebank" + File.separator +
"clearParser" + File.separator +
"feature_dep_en_conll09.xml");
SpinnerNumberModel num_model = new SpinnerNumberModel(2, 0, 10000, 1);
spBootstrapLevel.setModel(num_model);
if (chart == Flowchart.Parse) {
lblFeatureTemplateFile.setVisible(false);
txtFeatureTemplateFile.setVisible(false);
btnFeatureTemplateFileBrowse.setVisible(false);
lblBootstrapLevel.setVisible(false);
spBootstrapLevel.setVisible(false);
}
setDrop();
}
private void setDrop() {
BasePanel.initDrop(txtConfigFile, false);
BasePanel.initDrop(txtFeatureTemplateFile, false);
}
public String getOptionsFile() {
return txtConfigFile.getText();
}
public String getGuidesFile() {
return txtFeatureTemplateFile.getText();
}
public int getBootstrapLevel() {
return Integer.parseInt(spBootstrapLevel.getValue().toString());
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
lblConfigFile = new javax.swing.JLabel();
lblFeatureTemplateFile = new javax.swing.JLabel();
lblBootstrapLevel = new javax.swing.JLabel();
txtConfigFile = new javax.swing.JTextField();
txtFeatureTemplateFile = new javax.swing.JTextField();
spBootstrapLevel = new javax.swing.JSpinner();
btnConfigFileBrowse = new javax.swing.JButton();
btnFeatureTemplateFileBrowse = new javax.swing.JButton();
lblConfigFile.setText("Configs File:");
lblFeatureTemplateFile.setText("Feature Template File:");
lblBootstrapLevel.setText("Bootstrapping Level:");
txtConfigFile.setEditable(false);
txtFeatureTemplateFile.setEditable(false);
btnConfigFileBrowse.setText("...");
btnConfigFileBrowse.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnConfigFileBrowseActionPerformed(evt);
}
});
btnFeatureTemplateFileBrowse.setText("...");
btnFeatureTemplateFileBrowse.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnFeatureTemplateFileBrowseActionPerformed(evt);
}
});
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(lblConfigFile)
.addComponent(lblFeatureTemplateFile)
.addComponent(lblBootstrapLevel))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(txtFeatureTemplateFile, javax.swing.GroupLayout.DEFAULT_SIZE, 377, Short.MAX_VALUE)
.addGroup(layout.createSequentialGroup()
.addComponent(spBootstrapLevel, javax.swing.GroupLayout.PREFERRED_SIZE, 57, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(0, 0, Short.MAX_VALUE))
.addComponent(txtConfigFile))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(btnConfigFileBrowse, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(btnFeatureTemplateFileBrowse, javax.swing.GroupLayout.PREFERRED_SIZE, 1, Short.MAX_VALUE))
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(lblConfigFile)
.addComponent(txtConfigFile, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(btnConfigFileBrowse))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(lblFeatureTemplateFile)
.addComponent(txtFeatureTemplateFile, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(btnFeatureTemplateFileBrowse))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(lblBootstrapLevel)
.addComponent(spBootstrapLevel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
}// </editor-fold>//GEN-END:initComponents
private void btnConfigFileBrowseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnConfigFileBrowseActionPerformed
txtConfigFile.setText(BasePanel.showFileDialog(txtConfigFile.getText(), false));
}//GEN-LAST:event_btnConfigFileBrowseActionPerformed
private void btnFeatureTemplateFileBrowseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnFeatureTemplateFileBrowseActionPerformed
txtFeatureTemplateFile.setText(BasePanel.showFileDialog(txtFeatureTemplateFile.getText(), false));
}//GEN-LAST:event_btnFeatureTemplateFileBrowseActionPerformed
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton btnConfigFileBrowse;
private javax.swing.JButton btnFeatureTemplateFileBrowse;
private javax.swing.JLabel lblBootstrapLevel;
private javax.swing.JLabel lblConfigFile;
private javax.swing.JLabel lblFeatureTemplateFile;
private javax.swing.JSpinner spBootstrapLevel;
private javax.swing.JTextField txtConfigFile;
private javax.swing.JTextField txtFeatureTemplateFile;
// End of variables declaration//GEN-END:variables
}