ServerOptionsDialog.java revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* ident "%Z%%M% %I% %E% SMI"
*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/**
* Dialog to edit the options for the server as stored in the startup script.
*/
public class ServerOptionsDialog extends DhcpmgrDialog {
private static int DEFAULT_RESCAN_INTERVAL = 60;
private IPAddressList serverList;
private IPAddressList owneripList;
private JComboBox logFacility;
private LeftButton leftButton;
private RightButton rightButton;
/*
* Model for the tables which are used to edit the lists of
* interfaces which are monitored and ignored.
*/
class InterfaceTableModel extends AbstractTableModel {
private Vector interfaces;
public InterfaceTableModel() {
interfaces = new Vector();
}
// Initialize the list of interfaces
}
}
}
// Retrieve the interfacess as a comma-separated list
public String getInterfaceList() {
StringBuffer b = new StringBuffer();
while (e.hasMoreElements()) {
if (b.length() != 0) {
b.append(',');
}
}
return b.toString();
}
// Retrieve interface object for named interface
while (e.hasMoreElements()) {
return ipif;
}
}
return null;
}
// Retrieve the interface object at a particular row in the table
}
// Add an interface to the table
}
// Delete an interface from the table
}
// Return number of rows
public int getRowCount() {
return interfaces.size();
}
// Always two columns: interface name and network
public int getColumnCount() {
return 2;
}
// Return cell value at a particular coordinate
if (column == 0) {
} else {
}
}
// All data is strings from the display's point of view
return String.class;
}
// Get headings for each column
if (column == 0) {
} else {
}
}
}
super(f, true); // We want a reset button
resetValues();
}
/**
* Provide a title to be displayed for the dialog
*/
}
/**
* Construct and return the main display for this dialog.
*/
protected JPanel getMainPanel() {
/*
* Start with a tabbed view; the top tab is the options for the
* daemon, the lower tab is the interfaces to be monitored.
*/
// Use a gridbag with equal weights all around, cells anchored to west
// Add control for number of hops allowed
relayHops = new IntegerField();
// Add control for verbose logging
verboseLogging = new JCheckBox(
logTransactions = new JCheckBox(
false);
// Enable logging facility choices only when logging is turned on
public void actionPerformed(ActionEvent e) {
}
});
/*
* The main tab has two different displays depending on whether it's
* a relay or a full-fledged server.
*/
if (!DhcpmgrApplet.modeIsRelay) {
// Add control for duplicate detection using ICMP
detectDuplicates = new JCheckBox(
true);
// Add control for automatic reload of dhcptab and period
reloadEnabled = new JCheckBox(
"service_options_reload_dhcptab"));
reloadInterval = new IntegerField();
"service_options_reload_minutes"));
// Add control for DNS dynamic update and timeout value
dnsUpdateEnabled = new JCheckBox(
dnsTimeout = new IntegerField();
"service_options_timeout_dns"));
"service_options_seconds"));
// Add control for length of time to cache offers
"service_options_cache"));
cacheTime = new IntegerField();
"service_options_seconds"));
// Add choices for BOOTP compatibility behavior: none, auto, manual
noBootp = new JRadioButton(
autoBootp = new JRadioButton(
manualBootp = new JRadioButton(
false);
// Enable reload interval only when reload option is checked
public void actionPerformed(ActionEvent e) {
}
});
// Enable DNS timeout only when DNS update option is checked
public void actionPerformed(ActionEvent e) {
}
});
} else {
/*
* In relay mode the only other thing we can control is list of
* servers which we forward requests to.
*/
serverList = new IPAddressList();
}
// Panel for interfaces
// The list of interfaces we're monitoring goes on the left
"service_options_monitored"));
d.height = 100;
d.width = 210;
// The buttons to move items between the lists go in the middle
leftButton = new LeftButton();
rightButton = new RightButton();
rightButton.setEnabled(false);
leftButton.setEnabled(false);
// The list of interfaces to ignore is on the right
d.height = 100;
d.width = 210;
// Now create the tab for the interface manipulation
// tab for Addresses
if (!DhcpmgrApplet.modeIsRelay) {
// Add control for DHCP OWNER_IP option and values
owneripEnabled = new JCheckBox(
owneripList = new IPAddressList();
"service_options_owner_ip_addresses"));
// Enable OWNER_IP Addresses only when owner_ip option is checked
public void actionPerformed(ActionEvent e) {
}
});
// now add the tab for Addresses
}
/*
* Allow them to specify server should be restarted when these changes
* are applied
*/
restartServer = new JCheckBox(
buttonPanel.setOkEnabled(true);
// Handle enable and disable of buttons based on selection state
new ListSelectionListener() {
public void valueChanged(ListSelectionEvent e) {
rightButton.setEnabled(true);
} else {
rightButton.setEnabled(false);
}
}
});
new ListSelectionListener() {
public void valueChanged(ListSelectionEvent e) {
leftButton.setEnabled(true);
} else {
leftButton.setEnabled(false);
}
}
});
// Handle button presses
public void actionPerformed(ActionEvent e) {
return;
}
/*
* Now do the adds, then the removes; otherwise the row numbers
* we just got might be wrong
*/
}
while (en.hasMoreElements()) {
}
/*
* Clear the selection; this prevents exceptions from selection
* pointing at rows that are gone
*/
}
});
public void actionPerformed(ActionEvent e) {
return;
}
/*
* Now do the adds, then the removes; otherwise the row numbers
* we just got might be wrong
*/
}
while (en.hasMoreElements()) {
}
/*
* Clear the selection; this prevents exceptions from selection
* pointing at rows that are gone
*/
}
});
return mainPanel;
}
// Save a copy of the option settings so reset can work
private void setOptions(DhcpdOptions o) {
options = o;
}
// Reset all controls to initial values
private void resetValues() {
// Main tab parameters; first verbose logging
// Relay hops
if (options.isRelayHops()) {
} else {
}
// Set logging controls
} else {
}
if (!DhcpmgrApplet.modeIsRelay) {
// Set bootp compat. controls
if (options.isBootpCompatible()) {
}
// Set rescan interval to default if it's not specified
} else {
}
// Set owner_ip to default if it's not specified
}
// Set DNS timeout to default if it's not specified
if (options.isDnsUpdated()) {
} else {
}
if (options.isOfferTtl()) {
} else {
}
} else {
// In relay case only the server list is available
}
// Interfaces tab
try {
try {
} catch (BridgeException e) {
// we're not configured yet, apparently
interfaces = null;
}
if (options.isInterfaces()) {
while (st.hasMoreTokens()) {
}
}
} else {
}
} catch (Throwable e) {
e.printStackTrace();
}
// Default to restarting server
restartServer.setSelected(true);
}
/**
* User pressed OK, do what we think is necessary
*/
protected void doOk() {
try {
} else {
}
if (!DhcpmgrApplet.modeIsRelay) {
autoBootp.isSelected());
if (reloadEnabled.isSelected() &&
} else {
}
if (owneripEnabled.isSelected()) {
options.setOwnerip(true,
} else {
}
if (dnsUpdateEnabled.isSelected()) {
options.setDnsTimeout(true,
} else {
}
options.setOfferTtl(true,
} else {
}
} else {
}
// XXX Need to disable OK when this is the case
return;
}
/*
* If nothing is ignored then let server default to all
* interfaces
*/
} else {
}
if (restartServer.isSelected()) {
// Wait 5 secs for server to try to shutdown
}
setVisible(false);
dispose();
} catch (Exception e) {
form = new MessageFormat(
}
}
/**
* Return help system lookup key
*/
protected String getHelpKey() {
if (DhcpmgrApplet.modeIsRelay) {
return "modify_relay";
} else {
return "modify_server";
}
}
/**
* User pressed reset; go back to starting value
*/
protected void doReset() {
resetValues();
}
/**
* Notify our invoker that we're done
*/
protected void fireActionPerformed() {
}
}