/*
* File : ReportServerSettingsDlg.java
* Created : 21-feb-2003 09:57
* By : fbusquets
*
* JClic - Authoring and playing system for educational activities
*
* Copyright (C) 2000 - 2018 Francesc Busquets & Departament
* d'Educacio de la Generalitat de Catalunya
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details (see the LICENSE file).
*/
import edu.xtec.jclic.ReportServerConstants;
import edu.xtec.jclic.report.BasicJDBCBridge;
import edu.xtec.util.BrowserLauncher;
import edu.xtec.util.LFUtil;
import edu.xtec.util.Messages;
import edu.xtec.util.Options;
import edu.xtec.util.db.ConnectionBeanProvider;
import java.awt.Frame;
import java.awt.Point;
import java.io.File;
import javax.swing.JDialog;
import javax.swing.JFileChooser;
/**
* @author Francesc Busquets (fbusquets@xtec.cat)
* @version 13.09.09
*/
public class ReportServerSettingsDlg extends JDialog implements ReportServerConstants {
Options options;
Messages msg;
public boolean result;
/** Creates new form ReportServerSettingsDlg */
public ReportServerSettingsDlg(Frame parent, boolean modal, Options options) {
super(parent, modal);
this.options = options;
msg = options.getMessages();
initComponents();
result = false;
Point p = parent.getLocationOnScreen();
setLocation(p.x + 80, p.y + 30);
}
/**
* 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.
*/
// //GEN-BEGIN:initComponents
private void initComponents() {
java.awt.GridBagConstraints gridBagConstraints;
javax.swing.JTabbedPane mainPanel = new javax.swing.JTabbedPane();
javax.swing.JPanel optionsPanel = new javax.swing.JPanel();
langLb = new javax.swing.JLabel();
langCombo = new javax.swing.JComboBox//GEN-END:initComponents
private void logFileWebBtnActionPerformed(java.awt.event.ActionEvent evt) { // GEN-FIRST:event_logFileWebBtnActionPerformed
JFileChooser chooser;
String s = webLogField.getText();
if (s != null && s.length() > 0) {
File f = new File(s);
chooser = new JFileChooser(f.getParent());
chooser.setSelectedFile(f);
} else {
chooser = new JFileChooser();
chooser.setSelectedFile(new File("jclic_webserver.log"));
}
int b = chooser.showSaveDialog(this);
if (b == JFileChooser.APPROVE_OPTION) {
webLogField.setText(chooser.getSelectedFile().getAbsolutePath());
}
} // GEN-LAST:event_logFileWebBtnActionPerformed
private void tooltipChkActionPerformed(java.awt.event.ActionEvent evt) { // GEN-FIRST:event_tooltipChkActionPerformed
// Add your handling code here:
} // GEN-LAST:event_tooltipChkActionPerformed
private void btCancelActionPerformed(java.awt.event.ActionEvent evt) { // GEN-FIRST:event_btCancelActionPerformed
closeDialog(null);
} // GEN-LAST:event_btCancelActionPerformed
private void btOkActionPerformed(java.awt.event.ActionEvent evt) { // GEN-FIRST:event_btOkActionPerformed
readValues();
result = true;
closeDialog(null);
} // GEN-LAST:event_btOkActionPerformed
/** Closes the dialog */
private void closeDialog(java.awt.event.WindowEvent evt) { // GEN-FIRST:event_closeDialog
setVisible(false);
dispose();
} // GEN-LAST:event_closeDialog
protected void readValues() {
options.put(Messages.LANGUAGE, Messages.getLanguageFromDescriptive(langCombo.getSelectedItem().toString()));
options.put(LOOK, lookCombo.getSelectedItem().toString());
options.put(TOOLTIPS, tooltipChk.isSelected() ? TRUE : FALSE);
options.put(ConnectionBeanProvider.DB_DRIVER, driverField.getText());
options.put(ConnectionBeanProvider.DB_SERVER, urlField.getText());
options.put(ConnectionBeanProvider.DB_LOGIN, usrField.getText());
options.put(ConnectionBeanProvider.DB_PASSWORD, new String(pwdField.getPassword()));
options.put(BasicJDBCBridge.TABLE_PREFIX_KEY, prefixFld.getText());
options.put(BasicJDBCBridge.CREATE_TABLES_KEY, createChk.isSelected() ? "true" : "false");
options.put(HTTP_PORT, webPortField.getText());
options.put(HTTP_TIMEOUT, webTimeoutField.getText());
options.put(SESSION_LIFETIME, sessionLifetimeField.getText());
options.put(HTTP_AUTOSTART, webAutostartChk.isSelected() ? TRUE : FALSE);
options.put(HTTP_LOGFILE, webLogField.getText());
options.put(BrowserLauncher.BROWSER, browserField.getText());
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JTextField browserField;
private javax.swing.JCheckBox createChk;
private javax.swing.JPanel dbPanel;
private javax.swing.JTextField driverField;
private javax.swing.JLabel driverLb;
private javax.swing.JComboBox langCombo;
private javax.swing.JLabel langLb;
private javax.swing.JButton logFileWebBtn;
private javax.swing.JComboBox lookCombo;
private javax.swing.JTextField prefixFld;
private javax.swing.JLabel prefixLb;
private javax.swing.JPasswordField pwdField;
private javax.swing.JLabel pwdLb;
private javax.swing.JTextField sessionLifetimeField;
private javax.swing.JLabel sessionLifetimeLb;
private javax.swing.JCheckBox tooltipChk;
private javax.swing.JTextField urlField;
private javax.swing.JLabel urlLb;
private javax.swing.JTextField usrField;
private javax.swing.JLabel usrLb;
private javax.swing.JCheckBox webAutostartChk;
private javax.swing.JTextField webLogField;
private javax.swing.JLabel webLogLb;
private javax.swing.JPanel webPanel;
private javax.swing.JTextField webPortField;
private javax.swing.JLabel webPortLb;
private javax.swing.JTextField webTimeoutField;
private javax.swing.JLabel webTimeoutLb;
// End of variables declaration//GEN-END:variables
}