ImportWizard.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 2001-2002 by Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/**
* ImportWizard provides an easy-to-use interface for importing configuration
* data from one DHCP server to another.
*
* @see ExportWizard
*/
public class ImportWizard extends Wizard {
// Step to get the location of the export file
class LocationStep implements WizardStep {
public LocationStep() {
l.setLabelFor(pathField);
c = Wizard.createTextArea(
overrideBox = new JCheckBox(
c = Box.createVerticalGlue();
// Enable forward only if something is entered in the file field
public void insertUpdate(DocumentEvent e) {
}
public void changedUpdate(DocumentEvent e) {
insertUpdate(e);
}
public void removeUpdate(DocumentEvent e) {
insertUpdate(e);
}
});
}
public String getDescription() {
}
public Component getComponent() {
return stepPanel;
}
}
public boolean setInactive(int direction) {
/*
* Read the file header for display in next step; if we can't read
* it, display the errors and veto the forward step.
*/
try {
// Something wrong, but controller already displayed err
return false;
}
} catch (FileNotFoundException e) {
return false;
} catch (Exception e) {
e.getMessage()
};
return false;
}
}
return true;
}
}
// Allow user to review summary of file contents before proceeding.
class ReviewStep implements WizardStep {
private MessageFormat infoFormat =
public ReviewStep() {
l = new JLabel(
overrideLabel = new JLabel();
l = new JLabel(
l.setLabelFor(srcLabel);
l = new JLabel(
l.setLabelFor(userLabel);
l = new JLabel(
l.setLabelFor(dateLabel);
}
public String getDescription() {
}
public Component getComponent() {
return stepBox;
}
if (conflictImport) {
} else {
}
// Set values from file header
setFinishEnabled(true);
}
public boolean setInactive(int direction) {
return true;
}
}
/*
* Display an error message inside a separate thread so that background
* threads may interact with the user via SwingUtilities.invoke*
*/
class ErrorDisplay implements Runnable {
}
public void run() {
}
}
private boolean conflictImport = false;
private ImportController importController;
private ExportHeader header;
/*
* The Importer allows the ImportController, which contains all of the
* actual import logic, to interact with the user as the import proceeds.
* Since we run the import in a background thread to keep the GUI live,
* the interactions must use SwingUtilities.invoke* to control the GUI.
* Progress updates via ProgressManager don't need special logic here as
* ProgressManager already handles the threading work for us.
*/
};
// Create progress display
public void initializeProgress(int length) {
length);
}
// Update progress display with current completion level and message
throws InterruptedException {
}
// Display a single error message
}
// Display a group of error messages using a table.
ActionError [] errors) {
}
// Display an error in the GUI
// If we're on the event dispatch thread already then display now
if (SwingUtilities.isEventDispatchThread()) {
} else {
try {
} catch (Exception e) {
// Errors here are fairly serious; dump the stack
e.printStackTrace();
}
}
}
};
super(owner, "");
addStep(new LocationStep());
addStep(new ReviewStep());
}
public void doFinish() {
/*
* Runnable which the importThread can call to tear down the display
* when it's completed.
*/
public void run() {
reallyFinish();
}
};
// Create the thread in which to execute the import
public void run() {
// Only exit if import successful
}
}
};
// Run the import thread
}
public void doCancel() {
// Close file if there is one open
super.doCancel();
}
protected void reallyFinish() {
super.doFinish();
}
public void doHelp() {
}
}