/* Research Project: Graphical Database for Category Theory J. Bradbury, Dr. R. Rosebrugh, I. Rutherford Mount Allison University 2001 File: SettingServer.java Description: This class displays a frame which allows the user to change the default server, default server category directory, and the default server functor directory, which are used in the loading of files. */ //import statements import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.beans.*; public class SettingsServer extends JInternalFrame { private IniSettings ini; private JButton okButton; private JButton defaultButton; private JLabel serverLabel; private JLabel catLabel; private JLabel cglLabel; private JLabel funLabel; private JLabel fglLabel; private JTextField serverField; private JTextField catField; private JTextField cglField; private JTextField funField; private JTextField fglField; public SettingsServer(IniSettings newIni) //Default Constructor with the parent frame as a parameter { super("GDCT: Server Settings", true, true, false, false); ini = newIni; okButton = new JButton("OK"); okButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { okButton_actionPerformed(e); } }); defaultButton = new JButton("Default"); defaultButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { defaultButton_action(e); } }); serverLabel = new JLabel("Server Address:"); catLabel = new JLabel("CAT File Directory: "); funLabel = new JLabel("FUN File Directory:"); cglLabel = new JLabel("CGL File Directory: "); fglLabel = new JLabel("FGL File Directory: "); serverField = new JTextField(ini.getServer()); catField = new JTextField(ini.getCatDir()); cglField = new JTextField(ini.getCglDir()); funField = new JTextField(ini.getFunDir()); fglField = new JTextField(ini.getFglDir()); Container contentPane = getContentPane(); contentPane.setLayout(new GridBagLayout()); contentPane.add(serverLabel, new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0 ,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(10, 10, 10, 10), 0, 0)); contentPane.add(catLabel, new GridBagConstraints(0, 1, 1, 1, 1.0, 1.0 ,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(10, 10, 10, 10), 0, 0)); contentPane.add(cglLabel, new GridBagConstraints(0, 2, 1, 1, 1.0, 1.0 ,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(10, 10, 10, 10), 0, 0)); contentPane.add(funLabel, new GridBagConstraints(0, 3, 1, 1, 1.0, 1.0 ,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(10, 10, 10, 10), 0, 0)); contentPane.add(fglLabel, new GridBagConstraints(0, 4, 1, 1, 1.0, 1.0 ,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(10, 10, 10, 10), 0, 0)); contentPane.add(serverField, new GridBagConstraints(1, 0, 1, 1, 1.0, 1.0 ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0)); contentPane.add(catField, new GridBagConstraints(1, 1, 1, 1, 1.0, 1.0 ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0)); contentPane.add(cglField, new GridBagConstraints(1, 2, 1, 1, 1.0, 1.0 ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0)); contentPane.add(funField, new GridBagConstraints(1, 3, 1, 1, 1.0, 1.0 ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0)); contentPane.add(fglField, new GridBagConstraints(1, 4, 1, 1, 1.0, 1.0 ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0)); contentPane.add(defaultButton, new GridBagConstraints(0, 5, 1, 1, 1.0, 1.0 ,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(5, 5, 5, 5), 0, 0)); contentPane.add(okButton, new GridBagConstraints(1, 5, 1, 1, 1.0, 1.0 ,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(5, 5, 5, 5), 0, 0)); } private void okButton_actionPerformed(ActionEvent e) { ini.setServer(serverField.getText()); ini.setCatDir(catField.getText()); ini.setCglDir(cglField.getText()); ini.setFunDir(funField.getText()); ini.setFglDir(fglField.getText()); try {this.setClosed(true);} catch (PropertyVetoException pve) {} } private void defaultButton_action(ActionEvent e) { serverField.setText("http://mathcs.mta.ca/research/rosebrugh/gdct/"); catField.setText("cat/"); cglField.setText("cgl/"); funField.setText("fun/"); fglField.setText("fgl/"); } }