CreateAddressDialog.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 1998-2002 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/**
*/
public class CreateAddressDialog extends JDialog
implements ButtonPanelListener {
// Model class for the drop-down list of macros user may select from
private Object currentValue;
public MacroListModel() {
try {
} catch (NoTableException e) {
// can function without table
} catch (Throwable e) {
e.printStackTrace();
}
}
public int getSize() {
return 1;
else
}
if (index == 0) {
return noMacro;
} else {
}
}
}
public Object getSelectedItem() {
return currentValue;
}
}
public static final int CREATE = 0;
public static final int EDIT = 1;
public static final int DUPLICATE = 2;
private IPAddressField address;
private HostnameField name;
private JTextField server;
private JTextField clientId;
private JTextField comment;
private JTextField expirationDate;
private JRadioButton temporary;
private JRadioButton permanent;
private ButtonGroup buttonGroup;
private ButtonPanel buttonPanel;
private DateFormat dateFormat =
super(f);
switch (mode) {
case CREATE:
break;
case EDIT:
break;
case DUPLICATE:
break;
default:
break;
}
GridBagConstraints c = new GridBagConstraints();
// Label and text field for address
bag.setConstraints(l, c);
address = new IPAddressField();
l.setLabelFor(address);
address.setEditable(false);
}
++c.gridx;
// Label and text field for name
++c.gridy;
c.gridx = 0;
bag.setConstraints(l, c);
name = new HostnameField();
l.setLabelFor(name);
++c.gridx;
name.setEditable(true);
try {
name.setEditable(false);
}
} catch (BridgeException e) {
// Assume set
}
// label and field for owning server
++c.gridy;
c.gridx = 0;
bag.setConstraints(l, c);
l.setLabelFor(server);
++c.gridx;
// label and combo box for macro
++c.gridy;
c.gridx = 0;
bag.setConstraints(l, c);
l.setLabelFor(macro);
macro.setEditable(false);
++c.gridx;
// Comment
++c.gridy;
c.gridx = 0;
bag.setConstraints(l, c);
l.setLabelFor(comment);
++c.gridx;
// Create first panel of tabs
// Client ID
l.setLabelFor(clientId);
// radio buttons for lease state
bag = new GridBagLayout();
/*
* Create a compound border with empty space on the outside and line
* border on the inside, then title it.
*/
// Reset constraints
c.gridwidth = 1;
buttonGroup = new ButtonGroup();
temporary = new JRadioButton();
c.weightx = 0.0;
++c.gridx;
c.weightx = 1.0;
bag.setConstraints(l, c);
leasePanel.add(l);
++c.gridy;
permanent = new JRadioButton();
++c.gridy;
c.gridx = 0;
c.weightx = 0.0;
++c.gridx;
c.weightx = 1.0;
bag.setConstraints(l, c);
leasePanel.add(l);
// Flag checkboxes
buttonPanel = new ButtonPanel(true);
public void insertUpdate(DocumentEvent e) {
}
public void changedUpdate(DocumentEvent e) {
insertUpdate(e);
}
public void removeUpdate(DocumentEvent e) {
insertUpdate(e);
}
};
buttonPanel.setOkEnabled(true);
}
}
public void setClient(DhcpClientRecord c) {
client = c;
resetValues();
}
private void resetValues() {
} else {
if (a.equals(n)) {
// If name == address, there is no name, so leave it blank
} else {
}
}
} else {
}
} else {
}
if (client.isPermanent()) {
permanent.setSelected(true);
} else {
temporary.setSelected(true);
}
} else {
}
}
public void buttonPressed(int buttonId) {
switch (buttonId) {
case OK:
// Bad IP address
return;
}
// Address is not on the network we're editing
};
return;
}
try {
} catch (ValidationException e) {
// This shouldn't happen, should have caught any problem already
}
// This logic is needed because if the original client name
// was equal to its IP address, then this really means that
// that the name was not set. If this is the case and the
// name field is empty, then no change was made. In all other
// cases we can be assured that the client name was changed
// or is valid.
//
originalClient.getClientName()))) {
}
try {
// Don't bother resetting if it hasn't changed
}
} catch (ValidationException e) {
// Bad server name
return;
}
int i = macro.getSelectedIndex();
if (i == 0) {
} else {
}
try {
} catch (ValidationException e) {
// Bad client ID
return;
}
try {
} else {
client.setExpiration(d);
}
} catch (ParseException e) {
};
return;
}
// Got all the data, now update the data store
try {
} else {
}
setVisible(false);
dispose();
} catch (Exception e) {
/*
* Display an error message dialog. However, if the error
* related to editing the hosts table, we merely consider it
* a warning as the network table stuff actually was done.
*/
if (e instanceof ExistsException) {
} else if (e instanceof NoEntryException) {
} else if (e instanceof HostExistsException) {
} else if (e instanceof NoHostsEntryException) {
}
setVisible(false);
dispose();
}
}
break;
case CANCEL:
setVisible(false);
dispose();
break;
case HELP:
switch (mode) {
case CREATE:
helpTag = "create_address";
break;
case DUPLICATE:
helpTag = "duplicate_address";
break;
case EDIT:
helpTag = "modify_address";
break;
}
break;
case RESET:
break;
}
}
public void addActionListener(ActionListener l) {
listeners.addElement(l);
}
public void removeActionListener(ActionListener l) {
}
protected void fireActionPerformed() {
switch (mode) {
case CREATE:
break;
case DUPLICATE:
break;
case EDIT:
break;
}
command);
while (en.hasMoreElements()) {
l.actionPerformed(e);
}
}
}