summaryrefslogtreecommitdiffstats
path: root/pki/base/console/src/com/netscape/admin/certsrv/wizard
diff options
context:
space:
mode:
Diffstat (limited to 'pki/base/console/src/com/netscape/admin/certsrv/wizard')
-rw-r--r--pki/base/console/src/com/netscape/admin/certsrv/wizard/ConfigServlet.java24
-rw-r--r--pki/base/console/src/com/netscape/admin/certsrv/wizard/IWizardDone.java28
-rw-r--r--pki/base/console/src/com/netscape/admin/certsrv/wizard/IWizardPanel.java98
-rw-r--r--pki/base/console/src/com/netscape/admin/certsrv/wizard/WizardBasePanel.java290
-rw-r--r--pki/base/console/src/com/netscape/admin/certsrv/wizard/WizardInfo.java88
-rw-r--r--pki/base/console/src/com/netscape/admin/certsrv/wizard/WizardWidget.java427
6 files changed, 955 insertions, 0 deletions
diff --git a/pki/base/console/src/com/netscape/admin/certsrv/wizard/ConfigServlet.java b/pki/base/console/src/com/netscape/admin/certsrv/wizard/ConfigServlet.java
new file mode 100644
index 000000000..5ed3195b9
--- /dev/null
+++ b/pki/base/console/src/com/netscape/admin/certsrv/wizard/ConfigServlet.java
@@ -0,0 +1,24 @@
+// --- BEGIN COPYRIGHT BLOCK ---
+// 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; version 2 of the License.
+//
+// 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.
+//
+// You should have received a copy of the GNU General Public License along
+// with this program; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+//
+// (C) 2007 Red Hat, Inc.
+// All rights reserved.
+// --- END COPYRIGHT BLOCK ---
+package com.netscape.admin.certsrv.wizard;
+
+import java.net.*;
+
+public interface ConfigServlet {
+ public boolean send(String s, WizardInfo wizardInfo);
+}
diff --git a/pki/base/console/src/com/netscape/admin/certsrv/wizard/IWizardDone.java b/pki/base/console/src/com/netscape/admin/certsrv/wizard/IWizardDone.java
new file mode 100644
index 000000000..5576278c4
--- /dev/null
+++ b/pki/base/console/src/com/netscape/admin/certsrv/wizard/IWizardDone.java
@@ -0,0 +1,28 @@
+// --- BEGIN COPYRIGHT BLOCK ---
+// 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; version 2 of the License.
+//
+// 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.
+//
+// You should have received a copy of the GNU General Public License along
+// with this program; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+//
+// (C) 2007 Red Hat, Inc.
+// All rights reserved.
+// --- END COPYRIGHT BLOCK ---
+package com.netscape.admin.certsrv.wizard;
+
+import javax.swing.*;
+
+public interface IWizardDone {
+
+ /**
+ * Called by WizardWidget when all panels are executed.
+ */
+ public void notify(WizardWidget w);
+}
diff --git a/pki/base/console/src/com/netscape/admin/certsrv/wizard/IWizardPanel.java b/pki/base/console/src/com/netscape/admin/certsrv/wizard/IWizardPanel.java
new file mode 100644
index 000000000..1b729b70f
--- /dev/null
+++ b/pki/base/console/src/com/netscape/admin/certsrv/wizard/IWizardPanel.java
@@ -0,0 +1,98 @@
+// --- BEGIN COPYRIGHT BLOCK ---
+// 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; version 2 of the License.
+//
+// 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.
+//
+// You should have received a copy of the GNU General Public License along
+// with this program; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+//
+// (C) 2007 Red Hat, Inc.
+// All rights reserved.
+// --- END COPYRIGHT BLOCK ---
+package com.netscape.admin.certsrv.wizard;
+
+import javax.swing.*;
+
+/**
+ * Interface for WizardWidget delegation.<p>
+ * The methods will be call in the following order: <br>
+ * <pre>
+ * initialize(WizardInfo);
+ * validate();
+ * conclude(WizardInfo);
+ * getUpdateInfo(WizardInfo);
+ * </pre>
+ * For example, you can assume the WizardPanel is validated already
+ * when getUpdateInfo() is called.<p>
+ * REMEMBER TO SET THE ERROR WHEN ERROR OCCURRED!<p>
+ *
+ * @author jpanchen
+ * @version %I%, %G%
+ * @date 12/02/97
+ * @see com.netscape.admin.certsrv.wizard
+ */
+public interface IWizardPanel {
+
+ /**
+ * Initialize the panel. Data are passed in
+ * as WinzardInfo. Class implements this interface is responsible
+ * for maintaining the state information. Usually, you just
+ * need to have a dummy function if you are not using
+ * information provided by the previous screen to config/generate
+ * this screen. If error occurred, return false and set error
+ * message to be retrieved by getErrorMessage().
+ * @return true if ok; otherwise, false.
+ */
+ public abstract boolean initializePanel(WizardInfo info);
+
+ /**
+ * Verify the panel. The implementation should check for
+ * errors at this time. If error found, return false, and
+ * set error message to be retrieved by getErrorMessage().
+ * @return true if ok; otherwise, false.
+ */
+ public abstract boolean validatePanel();
+
+ /**
+ * Performs post processing. This function is call after
+ * the panel is verified.
+ * Ususally the LAST IWizardPanel use this method to perform
+ * save/update operation on the server via cgi/rmi/ldap.
+ * Similar to validate(), if error found, return false and
+ * set error message to be retrieved by getErrorMessage().
+ * @return true if ok; otherwise, false.
+ */
+ public abstract boolean concludePanel(WizardInfo info);
+
+ /**
+ * Save panel information into the WizardInfo to be passed
+ * on to the next screen.
+ */
+ public abstract void getUpdateInfo(WizardInfo info);
+
+ /**
+ * Error Message delegation. This method should return
+ * an I18N supported string detailing the error.
+ * @return string represenation of error
+ */
+ public abstract String getErrorMessage();
+
+ /**
+ * Display Help for this page
+ */
+ public abstract void callHelp();
+
+ /**
+ * Get title for this page
+ */
+ public abstract String getTitle();
+
+ public boolean isLastPage();
+
+}
diff --git a/pki/base/console/src/com/netscape/admin/certsrv/wizard/WizardBasePanel.java b/pki/base/console/src/com/netscape/admin/certsrv/wizard/WizardBasePanel.java
new file mode 100644
index 000000000..c31767d99
--- /dev/null
+++ b/pki/base/console/src/com/netscape/admin/certsrv/wizard/WizardBasePanel.java
@@ -0,0 +1,290 @@
+// --- BEGIN COPYRIGHT BLOCK ---
+// 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; version 2 of the License.
+//
+// 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.
+//
+// You should have received a copy of the GNU General Public License along
+// with this program; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+//
+// (C) 2007 Red Hat, Inc.
+// All rights reserved.
+// --- END COPYRIGHT BLOCK ---
+package com.netscape.admin.certsrv.wizard;
+
+import java.awt.*;
+import java.awt.event.MouseEvent;
+import java.awt.event.MouseMotionListener;
+import java.util.*;
+import javax.swing.*;
+import com.netscape.admin.certsrv.*;
+import com.netscape.management.client.util.*;
+import javax.swing.border.*;
+import java.net.*;
+import java.io.*;
+
+/**
+ * Wizard Base Panel
+ *
+ * @author Jack Pan-Chen
+ * @version $Revision$, $Date$
+ * @see com.netscape.admin.certsrv.config
+ */
+public class WizardBasePanel extends CMSBasePanel implements MouseMotionListener,
+ ConfigServlet {
+
+ /*==========================================================
+ * variables
+ *==========================================================*/
+ protected String mTitle;
+ protected String mErrorString;
+ protected String mNextString =
+ mResource.getString("GENERALWIZARD_LABEL_NEXT_LABEL");
+ protected String mPanelName;
+ public static long mSeed;
+
+ /*==========================================================
+ * constructors
+ *==========================================================*/
+ public WizardBasePanel(String name) {
+ super(name);
+ mTitle = mResource.getString(name+"_TITLE");
+ mPanelName = name;
+ addMouseMotionListener(this);
+ }
+
+ public WizardBasePanel(String name, ResourceBundle rb) {
+ super(name, rb);
+ mPanelName = name;
+ try {
+ mTitle = mResource.getString(name+"_TITLE");
+ } catch (MissingResourceException e) {
+ mTitle = "Missing Title";
+ }
+ addMouseMotionListener(this);
+ }
+
+ protected void init() {
+
+/*
+ GridBagConstraints gbc = new GridBagConstraints();
+
+ CMSAdminUtil.resetGBC(gbc);
+ gbc.anchor = gbc.SOUTHWEST;
+ gbc.weightx = 1.0;
+ gbc.weighty = 0.0;
+ gbc.gridheight = gbc.REMAINDER;
+ gbc.insets = new Insets(COMPONENT_SPACE,COMPONENT_SPACE,
+ COMPONENT_SPACE,COMPONENT_SPACE);
+ JLabel nextLabel = new JLabel(mNextString);
+ add(nextLabel, gbc);
+
+ setBorder(makeTitledBorder(mPanelName));
+*/
+ }
+
+ protected JTextArea createTextArea(String str, int row, int col) {
+ JTextArea desc = new JTextArea(str, row, col);
+ desc.setBackground(getBackground());
+ desc.setEditable(false);
+ desc.setCaretColor(getBackground());
+
+ return desc;
+ }
+
+ protected JTextArea createTextArea(String str) {
+ JTextArea desc = new JTextArea(str);
+ desc.setBackground(getBackground());
+ desc.setEditable(false);
+ desc.setCaretColor(getBackground());
+ desc.setLineWrap(true);
+ desc.setWrapStyleWord(true);
+
+ return desc;
+ }
+
+ /*==========================================================
+ * public methods
+ *==========================================================*/
+ /**
+ * Returns the title of the tab
+ * @return string representation of the title
+ */
+ public String getTitle() {
+ return mTitle;
+ }
+
+ /**
+ * Returns the error string
+ */
+ public String getErrorMessage() {
+ return mErrorString;
+ }
+
+ /**
+ * Set error string
+ */
+ public void setErrorMessage(String keyword) {
+ try {
+ String err = mResource.getString(mPanelName+"_DIALOG_"+keyword+"_MESSAGE");
+ mErrorString = err;
+ } catch (MissingResourceException e) {
+ mErrorString = keyword;
+ }
+ }
+
+ public void cleanUpWizardInfo(WizardInfo wizardInfo) {
+ wizardInfo.remove("NMC_WARNINFO");
+ wizardInfo.remove("NMC_ERRINFO");
+ wizardInfo.remove("NMC_STATUS");
+ }
+
+ public String getErrorMessage(WizardInfo wizardInfo) {
+ String value = (String)wizardInfo.get("NMC_ERRINFO");
+ if (value != null || value.trim().length() == 0)
+ return value;
+ value = (String)wizardInfo.get("NMC_WARNINFO");
+ if (value != null || value.trim().length() == 0)
+ return value;
+
+ return null;
+ }
+
+ public boolean send(String host, int port, String servlet, String rawData,
+ WizardInfo wizardInfo) {
+ try {
+ Socket socket = new Socket(host, port);
+ DataOutputStream dos = new DataOutputStream(socket.getOutputStream());
+ InputStream is = socket.getInputStream();
+ String spost = "POST "+servlet+" HTTP/1.0\r\n";
+ byte[] b = rawData.getBytes();
+ dos.writeBytes(spost);
+ dos.writeBytes("User-Agent: HTTPTool/1.0\r\n");
+ dos.writeBytes("Content-length: " + b.length + "\r\n");
+ dos.writeBytes("Content-Type: application/x-www-form-urlencoded\r\n");
+ dos.writeBytes("\r\n");
+ dos.write(b);
+ dos.writeBytes("\r\n");
+ dos.flush();
+
+ ByteArrayOutputStream bstream = new ByteArrayOutputStream(10000);
+ while (true)
+ {
+ int r = is.read();
+ if (r == -1)
+ break;
+ bstream.write(r);
+ }
+
+ socket.close();
+ String test = bstream.toString();
+
+ StringTokenizer tokenizer = new StringTokenizer(test, "\r\n");
+ while (tokenizer.hasMoreTokens()) {
+ String nvalue = tokenizer.nextToken();
+ System.out.println("tokenizer="+nvalue);
+ StringTokenizer tokenizer1 = new StringTokenizer(nvalue, ":");
+ int numTokens = tokenizer1.countTokens();
+ if (numTokens == 2) {
+ String name = tokenizer1.nextToken().trim();
+ String value = tokenizer1.nextToken().trim();
+ wizardInfo.put(name, value);
+ }
+ }
+ bstream.close();
+ String sendStatus = (String)wizardInfo.get("NMC_STATUS");
+ if (sendStatus.equals("0")) {
+ return true;
+ } else {
+ return false;
+ }
+ } catch (Exception e) {
+ }
+
+ return false;
+ }
+
+ public boolean send(String rawData, WizardInfo wizardInfo) {
+ try {
+ Socket socket = new Socket("droopy-linux.sfbay.redhat.com", 1924);
+ DataOutputStream dos = new DataOutputStream(socket.getOutputStream());
+ InputStream is = socket.getInputStream();
+ String servlet = "/config/configSubsystem";
+ String spost = "POST "+servlet+" HTTP/1.0\r\n";
+ byte[] b = rawData.getBytes();
+ dos.writeBytes(spost);
+ dos.writeBytes("User-Agent: HTTPTool/1.0\r\n");
+ dos.writeBytes("Content-length: " + b.length + "\r\n");
+ dos.writeBytes("Content-Type: application/x-www-form-urlencoded\r\n");
+ dos.writeBytes("\r\n");
+ dos.write(b);
+ dos.writeBytes("\r\n");
+ dos.flush();
+
+ ByteArrayOutputStream bstream = new ByteArrayOutputStream(10000);
+ while (true)
+ {
+ int r = is.read();
+ if (r == -1)
+ break;
+ bstream.write(r);
+ }
+
+ socket.close();
+ String test = bstream.toString();
+
+ StringTokenizer tokenizer = new StringTokenizer(test, "\r\n");
+ while (tokenizer.hasMoreTokens()) {
+ String nvalue = tokenizer.nextToken();
+ System.out.println("tokenizer="+nvalue);
+ StringTokenizer tokenizer1 = new StringTokenizer(nvalue, ":");
+ int numTokens = tokenizer1.countTokens();
+ if (numTokens == 2) {
+ String name = tokenizer1.nextToken().trim();
+ String value = tokenizer1.nextToken().trim();
+ wizardInfo.put(name, value);
+ }
+ }
+ bstream.close();
+ String sendStatus = (String)wizardInfo.get("NMC_STATUS");
+ if (sendStatus.equals("0")) {
+ return true;
+ } else {
+ return false;
+ }
+ } catch (Exception e) {
+ }
+
+ return false;
+ }
+
+ /*==========================================================
+ * EVENT HANDLER METHODS
+ *==========================================================*/
+
+ /*
+ * mouselistener events - for JPanel
+ */
+
+ /**
+ * This lets us know when someone move the mouse, so we can
+ * keep coordidate of mouse posion and use this value as a random seed
+ */
+ public void mouseDragged(MouseEvent e) {
+ // Do nothing for this
+ }
+
+ public void mouseMoved(MouseEvent e) {
+ // Keep tracking coordinate values
+ long x = e.getX();
+ long y = e.getY();
+
+ long top = mSeed >> 62;
+ mSeed = ((mSeed << 2) ^ top ^ (x<<8) ^ (y)) % Long.MAX_VALUE;
+ }
+}
diff --git a/pki/base/console/src/com/netscape/admin/certsrv/wizard/WizardInfo.java b/pki/base/console/src/com/netscape/admin/certsrv/wizard/WizardInfo.java
new file mode 100644
index 000000000..5085d43b4
--- /dev/null
+++ b/pki/base/console/src/com/netscape/admin/certsrv/wizard/WizardInfo.java
@@ -0,0 +1,88 @@
+// --- BEGIN COPYRIGHT BLOCK ---
+// 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; version 2 of the License.
+//
+// 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.
+//
+// You should have received a copy of the GNU General Public License along
+// with this program; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+//
+// (C) 2007 Red Hat, Inc.
+// All rights reserved.
+// --- END COPYRIGHT BLOCK ---
+package com.netscape.admin.certsrv.wizard;
+
+import javax.swing.*;
+import java.util.Properties;
+
+/**
+ * Wizard Data Container
+ */
+public class WizardInfo extends Properties {
+
+ /*==========================================================
+ * variables
+ *==========================================================*/
+ protected JButton mBNext_Done, mBCancel, mBBack;
+
+ /*==========================================================
+ * constructors
+ *==========================================================*/
+ public WizardInfo() {
+ super();
+ }
+
+ /*==========================================================
+ * public methods
+ *==========================================================*/
+ public void addEntry(String name, Object entry) {
+ put(name, entry);
+ }
+
+ public Object getEntry(String name) {
+ return get(name);
+ }
+
+ /**
+ * access method to NEXT-DONE function buttons
+ */
+ public JButton getNextDoneButton() {
+ return mBNext_Done;
+ }
+
+ /**
+ * access method to CANCEL function buttons
+ */
+ public JButton getCancelButton() {
+ return mBCancel;
+ }
+
+ /**
+ * access method to BACK function buttons
+ */
+ public JButton getBackButton() {
+ return mBBack;
+ }
+
+ /*==========================================================
+ * package methods
+ *==========================================================*/
+
+ /**
+ * set function buttons. Called by the WizardWidget to set the
+ * button reference.
+ */
+ void setButtons(JButton next, JButton cancel, JButton back ) {
+ mBNext_Done = next;
+ mBCancel = cancel;
+ mBBack = back;
+ }
+}
+
+
+
diff --git a/pki/base/console/src/com/netscape/admin/certsrv/wizard/WizardWidget.java b/pki/base/console/src/com/netscape/admin/certsrv/wizard/WizardWidget.java
new file mode 100644
index 000000000..92bed2895
--- /dev/null
+++ b/pki/base/console/src/com/netscape/admin/certsrv/wizard/WizardWidget.java
@@ -0,0 +1,427 @@
+// --- BEGIN COPYRIGHT BLOCK ---
+// 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; version 2 of the License.
+//
+// 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.
+//
+// You should have received a copy of the GNU General Public License along
+// with this program; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+//
+// (C) 2007 Red Hat, Inc.
+// All rights reserved.
+// --- END COPYRIGHT BLOCK ---
+package com.netscape.admin.certsrv.wizard;
+
+import java.util.*;
+import java.awt.*;
+import java.awt.event.*;
+import javax.swing.*;
+import javax.swing.border.*;
+import com.netscape.admin.certsrv.*;
+import com.netscape.certsrv.common.*;
+import com.netscape.management.client.util.*;
+import com.netscape.admin.certsrv.config.install.*;
+import com.netscape.admin.certsrv.task.*;
+import com.netscape.management.client.console.*;
+
+/**
+ * WizardWidget provides the most fundamental functionalities
+ * of an wizard widget.
+ *
+ * @author jpanchen
+ * @version %I%, %G%
+ * @date 12/02/97
+ * @see com.netscape.admin.certsrv.wizard
+ */
+public class WizardWidget extends JDialog implements ActionListener
+{
+
+ /*==========================================================
+ * variables
+ *==========================================================*/
+ private static final String PANELNAME = "WIZARD";
+ //static final Dimension DEFAULT_SIZE = new Dimension(460,520);
+ static final Dimension DEFAULT_SIZE = new Dimension(480,600);
+ static final Dimension BUTTON_MIN_SIZE = new Dimension(100,30);
+ static final int STRUT_SIZE = 10;
+
+ //private variables
+ private JButton mBNext_Done, mBCancel, mBBack, mBHelp;
+ private Stack mPrevScreen = new Stack();
+ private Stack mNextScreen = new Stack();
+ protected JPanel mCurrent = null;
+ protected JPanel mDisplay;
+ private String mDoneLabel, mNextLabel;
+
+ protected ResourceBundle mResource;
+ private WizardInfo mInfo;
+ private JFrame mParent;
+ private Dimension mSize;
+ private IWizardDone mWizDone;
+
+ /*==========================================================
+ * constructors
+ *==========================================================*/
+
+ /**
+ * Construct Wizard with specified title and parent frame.
+ * @param parent parent frame
+ * @param title string to be displayed on the dialog box title bar
+ * @param size specify wizard size
+ */
+ public WizardWidget(JFrame parent, Dimension size, IWizardDone wizDone) {
+ this(parent, wizDone);
+ mSize = size;
+ setSize(size.width, size.height);
+ }
+
+ /**
+ * Construct Wizard with specified title and parent frame.
+ * @param parent parent frame
+ * @title string to be displayed on the dialog box title bar
+ */
+ public WizardWidget(JFrame parent) {
+ this(parent, null);
+ }
+
+ public WizardWidget(JFrame parent, IWizardDone wizDone) {
+ //super(parent, title, true); XXX JDK 1.1.4 Bug
+ super(parent, true);
+ mSize = DEFAULT_SIZE;
+ mParent = parent;
+ getContentPane().setLayout(new BorderLayout());
+ setSize(mSize.width, mSize.height);
+ getRootPane().setDoubleBuffered(true);
+ setLocationRelativeTo(parent);
+ mInfo = new WizardInfo();
+ mWizDone = wizDone;
+ mResource = ResourceBundle.getBundle(CMSAdminResources.class.getName());
+
+ mNextLabel = mResource.getString(CMSAdminResources.GENERAL_NEXT);
+ mDoneLabel = mResource.getString(CMSAdminResources.GENERAL_DONE);
+
+ //create display panel
+ mDisplay = new JPanel();
+ mDisplay.setLayout(new BorderLayout());
+ mDisplay.setBorder(new EmptyBorder(CMSAdminUtil.DIFFERENT_COMPONENT_SPACE,
+ CMSAdminUtil.DIFFERENT_COMPONENT_SPACE,
+ 0,CMSAdminUtil.DIFFERENT_COMPONENT_SPACE));
+/*
+ mDisplay.setBorder(new CompoundBorder(
+ new EmptyBorder(CMSAdminUtil.DIFFERENT_COMPONENT_SPACE,
+ CMSAdminUtil.DIFFERENT_COMPONENT_SPACE,
+ 0,CMSAdminUtil.DIFFERENT_COMPONENT_SPACE),
+ BorderFactory.createEtchedBorder()));
+*/
+ getContentPane().add("Center",mDisplay);
+
+ //create button panel
+
+ //buttonPanel.add(Box.createGlue());
+ getContentPane().add("South", createActionPanel());
+ }
+
+ /*==========================================================
+ * public methods
+ *==========================================================*/
+
+ /**
+ * get parent frame
+ * @return parent frame
+ */
+ public JFrame getFrame() {
+ return mParent;
+ }
+
+ /**
+ * Add a IWizardPanel into wizard. Note the sequence you add
+ * will the be the sequence it will appear.
+ * @param page IWizardPanel to be displayed
+ */
+ public void addPage(JPanel page) {
+ if (mCurrent == null) {
+ mCurrent = page;
+ mDisplay.add("Center",page);
+ initializeWizardPanel();
+ } else {
+ mNextScreen.insertElementAt(page, 0);
+ }
+ }
+
+ /**
+ * Action Performed when button pressed. ActionListener implementation.
+ * @param event
+ */
+ public void actionPerformed(ActionEvent e) {
+
+ //DONE or NEXT Pressed
+ if (e.getSource().equals(mBNext_Done)) {
+
+ if (!validateWizardPanel()) {
+ return;
+ }
+
+ if (concludeWizardPanel()) {
+
+ if (mNextScreen.empty() || mBNext_Done.getText().equals("Done")) {
+ //killDaemon();
+ this.dispose();
+ if (mWizDone != null) {
+ mWizDone.notify(this);
+ }
+ return;
+ } else {
+ updateWizardInfo();
+ mPrevScreen.push(mCurrent);
+ mDisplay.remove(mCurrent);
+ mCurrent = (JPanel)(mNextScreen.pop());
+ while (!initializeWizardPanel()) {
+ //move to next
+ if (mNextScreen.empty()) {
+ this.dispose();
+ return;
+ }
+ mPrevScreen.push(mCurrent);
+ mCurrent = (JPanel)(mNextScreen.pop());
+ }
+ mDisplay.add("Center",mCurrent);
+ mDisplay.invalidate();
+ mDisplay.validate();
+ mDisplay.repaint(1);
+ getRootPane().paintImmediately(getRootPane().getVisibleRect());
+ }
+
+ } else {
+ return;
+ }
+ }
+
+ //Cancel Pressed
+ if (e.getSource().equals(mBCancel)) {
+ //prompt for confirm
+ int option = CMSAdminUtil.showConfirmDialog(mParent, mResource,
+ PANELNAME, "EXIT",
+ JOptionPane.YES_NO_OPTION);
+ if (option == JOptionPane.YES_OPTION) {
+ //killDaemon();
+ this.dispose();
+ }
+ }
+
+ //Back Pressed
+ if (e.getSource().equals(mBBack)) {
+ back_cb(mInfo);
+ //move back to previous page
+ if (!(mPrevScreen.empty())) {
+ mNextScreen.push(mCurrent);
+ mDisplay.remove(mCurrent);
+ mCurrent = (JPanel)(mPrevScreen.pop());
+ while (!initializeWizardPanel()) {
+ //move to prev
+ if (mPrevScreen.empty()) {
+ return;
+ }
+ mNextScreen.push(mCurrent);
+ mCurrent = (JPanel)(mPrevScreen.pop());
+ }
+ mDisplay.add("Center",mCurrent);
+ mDisplay.invalidate();
+ mDisplay.validate();
+ mDisplay.repaint(1);
+ getRootPane().paintImmediately(getRootPane().getVisibleRect());
+ }
+ }
+
+ //Help Pressed
+ if (e.getSource().equals(mBHelp)) {
+ callHelp();
+ }
+
+ changeButton();
+ }
+
+ /**
+ * This method is only for installation wizard.
+ */
+/*
+ private void killDaemon() {
+ if (mInfo instanceof InstallWizardInfo) {
+ InstallWizardInfo wizardInfo = (InstallWizardInfo)mInfo;
+ ConsoleInfo consoleInfo = wizardInfo.getAdminConsoleInfo();
+ CMSConfigCert configCertCgi = new CMSConfigCert();
+ configCertCgi.initialize(wizardInfo);
+ Hashtable data = new Hashtable();
+ data.put(ConfigConstants.TASKID, TaskId.TASK_EXIT);
+ data.put(ConfigConstants.OPTYPE, OpDef.OP_MODIFY);
+ data.put(ConfigConstants.PR_CERT_INSTANCE_NAME,
+ consoleInfo.get(ConfigConstants.PR_CERT_INSTANCE_NAME));
+ data.put(ConfigConstants.PR_SERVER_ROOT,
+ consoleInfo.get(ConfigConstants.PR_SERVER_ROOT));
+ boolean ready = configCertCgi.configCert(data);
+ data.clear();
+ data = null;
+ }
+ }
+*/
+
+ /*==========================================================
+ * protected methods
+ *==========================================================*/
+
+ protected JPanel createActionPanel() {
+ //edit, add, delete, help buttons required
+ //actionlister to this object
+
+ mBBack = new JButton();
+ mBBack.setText(mResource.getString(CMSAdminResources.GENERAL_BACK));
+ mBBack.addActionListener(this);
+ mBBack.setEnabled(false);
+
+ mBNext_Done = new JButton();
+ mBNext_Done.setText(mNextLabel);
+ mBNext_Done.addActionListener(this);
+
+ mBCancel = new JButton();
+ mBCancel.setText(mResource.getString(CMSAdminResources.GENERAL_CANCEL));
+ mBCancel.addActionListener(this);
+
+ mBHelp = new JButton();
+ mBHelp.setText(mResource.getString(CMSAdminResources.GENERAL_HELP));
+ mBHelp.addActionListener(this);
+
+ JButton[] buttons = {mBBack, mBNext_Done, mBCancel, mBHelp };
+
+ //pass the buttons reference to wizardinfo
+ mInfo.setButtons(mBNext_Done, mBCancel, mBBack);
+
+ return CMSAdminUtil.makeJButtonPanel( buttons, true);
+ }
+
+
+ /**
+ * Returns wizard data container
+ */
+ protected WizardInfo getWizardInfo() {
+ return mInfo;
+ }
+
+ /**
+ * set wizard data container
+ */
+ protected void setWizardInfo(WizardInfo info) {
+ mInfo = info;
+ }
+
+ /**
+ * Initialize currently displayed panel
+ * Implemetation is delegated to initialize() method
+ * of IWizardPanel. It retruns false, if the panel is
+ * to be skipped.
+ */
+ protected boolean initializeWizardPanel() {
+
+ if (mCurrent instanceof IWizardPanel) {
+ boolean status = ((IWizardPanel)mCurrent).initializePanel(mInfo);
+ setTitle( ((IWizardPanel)mCurrent).getTitle() );
+ return status;
+ }
+ return true;
+ }
+
+ /**
+ * Verify if a page is complete. It means all the
+ * require fields are fill out. It delegates implementation
+ * details to validate() method of the IWizardPanel obejct.
+ * If failed, error dialog is displayed but not terminated.
+ */
+ boolean validateWizardPanel() {
+ boolean complete = true;
+
+ if (mCurrent instanceof IWizardPanel) {
+ if (!( (IWizardPanel)mCurrent ).validatePanel()) {
+ String msg = ((IWizardPanel)mCurrent).getErrorMessage();
+ if (msg != null && !msg.equals(""))
+ CMSAdminUtil.showErrorDialog(mParent, mResource, msg,
+ JOptionPane.ERROR_MESSAGE);
+ complete = false;
+ }
+ }
+
+ return complete;
+ }
+
+ /**
+ * Some panel may require post-processing before moving to next stage.
+ * Ususally the last IWizardPanel use this method to perform
+ * save/update operation on the server via cgi/rmi/ldap.
+ * If error occurred, wizard will be terminated.
+ */
+ boolean concludeWizardPanel() {
+ boolean complete = true;
+ if(mCurrent instanceof IWizardPanel) {
+ if (!((IWizardPanel)mCurrent).concludePanel(mInfo)) {
+ CMSAdminUtil.showErrorDialog(mParent, mResource,
+ ((IWizardPanel)mCurrent).getErrorMessage(),
+ JOptionPane.ERROR_MESSAGE);
+ complete = false;
+ }
+ }
+ return complete;
+ }
+
+ /**
+ * Retrieve the update information from the
+ * IWizardPanel into WizardInfo.
+ */
+ void updateWizardInfo() {
+ if(mCurrent instanceof IWizardPanel) {
+ ((IWizardPanel)mCurrent).getUpdateInfo(mInfo);
+ }
+ }
+
+ protected void callHelp() {
+ Debug.println("Overwrite this method");
+ }
+
+ protected void back_cb(WizardInfo info) {
+ Debug.println("Overwrite this method");
+ }
+
+ /*==========================================================
+ * private methods
+ *==========================================================*/
+
+ /**
+ * Button enable/disable and label changes
+ */
+ private void changeButton() {
+
+ if (mPrevScreen.size()==0) {
+ mBBack.setEnabled(false);
+ mBBack.repaint();
+ } else {
+ mBBack.setEnabled(true);
+ mBBack.repaint();
+ }
+
+ boolean lastPage = ((IWizardPanel)mCurrent).isLastPage();
+ if ((mNextScreen.size()==0) || (lastPage)) {
+ mBNext_Done.setText(mDoneLabel);
+ mBCancel.setEnabled(false);
+ mBBack.setEnabled(false);
+ } else {
+ mBNext_Done.setText(mNextLabel);
+ mBCancel.setEnabled(true);
+ }
+ mBNext_Done.repaint();
+ mBCancel.repaint();
+ mBBack.repaint();
+ }
+}
+
+