diff --git a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/views/modpack/ModpackWizard.java b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/views/modpack/ModpackWizard.java index efde0b662..032b0133e 100644 --- a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/views/modpack/ModpackWizard.java +++ b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/views/modpack/ModpackWizard.java @@ -77,7 +77,7 @@ public class ModpackWizard extends WizardBranchController { service.version(), (String) settings.get(ModpackInitializationPanel.KEY_GAME_VERSION), blackList); - progress.finished(Summary.create(C.i18n("modpack.export_finished") + ": " + loc.getAbsolutePath(), null)); + progress.finished(new Summary(C.i18n("modpack.export_finished") + ": " + loc.getAbsolutePath(), null)); } catch (IOException | GameException ex) { HMCLog.err("Failed to export modpack", ex); progress.failed(C.i18n("modpack.export_error") + ": " + ex.getClass().getName() + ", " + ex.getLocalizedMessage(), true); diff --git a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/views/wizard/api/WizardDisplayer.java b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/views/wizard/api/WizardDisplayer.java index 2820cf14d..a76912adf 100644 --- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/views/wizard/api/WizardDisplayer.java +++ b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/views/wizard/api/WizardDisplayer.java @@ -207,15 +207,13 @@ public abstract class WizardDisplayer { if (new HashSet(Arrays.asList(s)).size() != s.length) throw new RuntimeException("steps are duplicated: " + Arrays.asList(s)); if (s.length == 1 && Wizard.UNDETERMINED_STEP.equals(s[0])) - // assert false : "Only ID may not be UNDETERMINED_ID"; //NOI18N + // assert false : "Only ID may not be UNDETERMINED_ID"; throw new RuntimeException("Only ID may not be UNDETERMINED_ID"); for (int i = 0; i < s.length; i++) if (Wizard.UNDETERMINED_STEP.equals(s[i]) && i != s.length - 1) - // assert false : "UNDETERMINED_ID may only be last element in" + //NOI18N - // " ids array " + Arrays.asList(s); //NOI18N - throw new RuntimeException("UNDETERMINED_ID may only be last element in" - + //NOI18N - " ids array " + Arrays.asList(s)); //NOI18N) + // assert false : "UNDETERMINED_ID may only be last element in" + + // " ids array " + Arrays.asList(s); + throw new RuntimeException("UNDETERMINED_ID may only be last element in ids array " + Arrays.asList(s)); return true; } diff --git a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/views/wizard/api/displayer/NavButtonManager.java b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/views/wizard/api/displayer/NavButtonManager.java index 322f44931..349a59ae0 100644 --- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/views/wizard/api/displayer/NavButtonManager.java +++ b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/views/wizard/api/displayer/NavButtonManager.java @@ -12,7 +12,6 @@ import java.awt.Window; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.NoSuchElementException; -import java.util.logging.Logger; import javax.swing.Action; import javax.swing.BorderFactory; @@ -62,9 +61,6 @@ public class NavButtonManager implements ActionListener { */ static final String DEFERRED_FAILED = "FAILED_"; - private static final Logger logger - = Logger.getLogger(NavButtonManager.class.getName()); - JButton next = null; JButton prev = null; @@ -105,7 +101,7 @@ public class NavButtonManager implements ActionListener { prev.setName(NAME_PREV); prev.setMnemonic(C.i18n("wizard.prev_mnemonic").charAt(0)); - finish = new JButton(C.i18n("wizard.finish")); // NOI18N + finish = new JButton(C.i18n("wizard.finish")); finish.setName(NAME_FINISH); finish.setMnemonic(C.i18n("wizard.finish_mnemonic").charAt(0)); @@ -127,7 +123,7 @@ public class NavButtonManager implements ActionListener { help.setVisible(helpAction != null); // Use standard default-button-last order on Aqua L&F - final boolean aqua = "Aqua".equals(UIManager.getLookAndFeel().getID()); // NOI18N + final boolean aqua = "Aqua".equals(UIManager.getLookAndFeel().getID()); buttons = new JPanel() { public void doLayout() { @@ -163,7 +159,7 @@ public class NavButtonManager implements ActionListener { } }; buttons.setBorder(BorderFactory.createMatteBorder(1, 0, 0, 0, UIManager - .getColor("textText"))); // NOI18N + .getColor("textText"))); buttons.add(prev); buttons.add(next); @@ -494,7 +490,6 @@ public class NavButtonManager implements ActionListener { boolean closeWindow; if (reallyCancel && parent.cancel()) { - logger.fine("calling wizard cancel method on " + wizard); wizard.cancel(settings); return; } @@ -530,7 +525,7 @@ public class NavButtonManager implements ActionListener { if (window != null && parent.receiver == null && window instanceof JDialog) ((JDialog) window).getRootPane().setDefaultButton(cancel); - cancel.setText(getCloseString()); // NOI18N + cancel.setText(getCloseString()); cancel.setMnemonic(C.i18n("wizard.close_mnemonic").charAt(0)); cancel.setName(NAME_CLOSE); deferredStatus = null; // ?? should summary be different diff --git a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/views/wizard/api/displayer/NavProgress.java b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/views/wizard/api/displayer/NavProgress.java index 0defbac20..b4f9869e8 100644 --- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/views/wizard/api/displayer/NavProgress.java +++ b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/views/wizard/api/displayer/NavProgress.java @@ -3,12 +3,12 @@ package org.jackhuang.hellominecraft.utils.views.wizard.api.displayer; import java.awt.Container; import java.awt.EventQueue; import java.lang.reflect.InvocationTargetException; -import java.util.logging.Logger; import javax.swing.JLabel; import javax.swing.JProgressBar; import javax.swing.border.EmptyBorder; import org.jackhuang.hellominecraft.utils.C; +import org.jackhuang.hellominecraft.utils.logging.HMCLog; import org.jackhuang.hellominecraft.utils.views.wizard.spi.ResultProgressHandle; import org.jackhuang.hellominecraft.utils.views.wizard.spi.Summary; @@ -28,9 +28,6 @@ import org.jackhuang.hellominecraft.utils.views.wizard.spi.Summary; */ public class NavProgress implements ResultProgressHandle { - private static final Logger logger - = Logger.getLogger(NavProgress.class.getName()); - JProgressBar progressBar = new JProgressBar(); JLabel lbl = new JLabel(); @@ -61,7 +58,7 @@ public class NavProgress implements ResultProgressHandle { public void setProgress(final String description, final int currentStep, final int totalSteps) { invoke(() -> { - lbl.setText(description == null ? " " : description); // NOI18N + lbl.setText(description == null ? " " : description); setProgress(currentStep, totalSteps); }); } @@ -99,8 +96,7 @@ public class NavProgress implements ResultProgressHandle { try { EventQueue.invokeAndWait(r); } catch (InvocationTargetException | InterruptedException ex) { - ex.printStackTrace(); - logger.severe("Error invoking operation " + ex.getClass().getName() + " " + ex.getMessage()); + HMCLog.err("NavProgress: Error invoking operation", ex); } } @@ -127,7 +123,7 @@ public class NavProgress implements ResultProgressHandle { Runnable r = () -> { // cheap word wrap - JLabel comp = new JLabel("
" + message); // NOI18N + JLabel comp = new JLabel("" + message); comp.setBorder(new EmptyBorder(5, 5, 5, 5)); parent.setCurrentWizardPanel(comp); parent.getTtlLabel().setText(C.i18n("wizard.failed")); diff --git a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/views/wizard/api/displayer/WizardDisplayerImpl.java b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/views/wizard/api/displayer/WizardDisplayerImpl.java index 7b3edc339..21b741922 100644 --- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/views/wizard/api/displayer/WizardDisplayerImpl.java +++ b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/views/wizard/api/displayer/WizardDisplayerImpl.java @@ -34,8 +34,6 @@ import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import java.lang.reflect.InvocationTargetException; import java.util.Map; -import java.util.logging.Level; -import java.util.logging.Logger; import javax.swing.AbstractAction; import javax.swing.Action; import javax.swing.BorderFactory; @@ -125,7 +123,7 @@ public class WizardDisplayerImpl extends WizardDisplayer { ttlLabel = new JLabel(wizard.getStepDescription(wizard.getAllSteps()[0])); ttlLabel.setBorder(BorderFactory.createCompoundBorder(BorderFactory .createEmptyBorder(5, 5, 12, 5), BorderFactory.createMatteBorder(0, 0, 1, 0, UIManager - .getColor("textText")))); // NOI18N + .getColor("textText")))); ttlPanel = new JPanel() { public void doLayout() { Dimension d = ttlLabel.getPreferredSize(); @@ -142,7 +140,7 @@ public class WizardDisplayerImpl extends WizardDisplayer { ttlPanel.add(ttlLabel); Font f = ttlLabel.getFont(); if (f == null) - f = UIManager.getFont("controlFont"); // NOI18N + f = UIManager.getFont("controlFont"); if (f != null) { f = f.deriveFont(Font.BOLD); ttlLabel.setFont(f); @@ -173,7 +171,7 @@ public class WizardDisplayerImpl extends WizardDisplayer { outerPanel = new JPanel(); if (wizard.getAllSteps().length == 0) - throw new IllegalArgumentException("Wizard has no steps"); // NOI18N + throw new IllegalArgumentException("Wizard has no steps"); // initialize the ttl* stuff buildStepTitle(); @@ -190,8 +188,8 @@ public class WizardDisplayerImpl extends WizardDisplayer { } }; outerPanel.getInputMap(JPanel.WHEN_IN_FOCUSED_WINDOW).put( - KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "cancel"); //NOI18N - outerPanel.getActionMap().put("cancel", kbdCancel); //NOI18N + KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "cancel"); + outerPanel.getActionMap().put("cancel", kbdCancel); instructions = createInstructionsPanel(); @@ -202,7 +200,7 @@ public class WizardDisplayerImpl extends WizardDisplayer { inner.add(ttlPanel, BorderLayout.NORTH); problem = new JLabel(" "); - Color fg = UIManager.getColor("nb.errorColor"); // NOI18N + Color fg = UIManager.getColor("nb.errorColor"); problem.setForeground(fg == null ? Color.BLUE : fg); inner.add(problem, BorderLayout.SOUTH); problem.setPreferredSize(new Dimension(20, 20)); @@ -254,10 +252,9 @@ public class WizardDisplayerImpl extends WizardDisplayer { public Object show(final Wizard awizard, Rectangle bounds, Action helpAction, Map initialProperties) { if (!EventQueue.isDispatchThread() && !warned) { - Logger.getLogger(WizardDisplayerImpl.class.getName()).log(Level.WARNING, - "show() should be called from the AWT Event Thread. This " - + "call may deadlock - c.f. " - + "http://java.net/jira/browse/WIZARD-33", new Throwable()); + HMCLog.warn("WizardDisplayerImpl: show() should be called from the AWT Event Thread. This " + + "call may deadlock - c.f. " + + "http://java.net/jira/browse/WIZARD-33", new Throwable()); warned = true; } createOuterPanel(awizard, bounds, helpAction, initialProperties); @@ -364,8 +361,7 @@ public class WizardDisplayerImpl extends WizardDisplayer { return; default: throw new IllegalArgumentException("Illegal forward " - + // NOI18N - "navigation mode: " + i); // NOI18N + + "navigation mode: " + i); } } @@ -450,7 +446,7 @@ public class WizardDisplayerImpl extends WizardDisplayer { } } else { - synchronized (this) { + synchronized (WizardDisplayerImpl.this) { deferredResult = null; } buttonManager.getCancel().setEnabled(true); @@ -463,7 +459,7 @@ public class WizardDisplayerImpl extends WizardDisplayer { } } }; - Thread runner = new Thread(run, "Wizard Background Result Thread " + r); // NOI18N + Thread runner = new Thread(run, "Wizard Background Result Thread " + r); runner.start(); } @@ -553,7 +549,7 @@ public class WizardDisplayerImpl extends WizardDisplayer { void updateProblem() { String prob = wizard.getProblem(); - problem.setText(prob == null ? " " : prob); // NOI18N + problem.setText(prob == null ? " " : prob); if (prob != null && prob.trim().length() == 0) // Issue 3 - provide ability to disable next w/o // showing the error line diff --git a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/views/wizard/modules/InstructionsPanelImpl.java b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/views/wizard/modules/InstructionsPanelImpl.java index cdf0fa044..43bb3bd20 100644 --- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/views/wizard/modules/InstructionsPanelImpl.java +++ b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/views/wizard/modules/InstructionsPanelImpl.java @@ -72,7 +72,7 @@ public class InstructionsPanelImpl extends JComponent implements WizardObserver, public InstructionsPanelImpl(Wizard wiz) { this(null, wiz); - Font f = UIManager.getFont("Tree.font"); //NOI18N + Font f = UIManager.getFont("Tree.font"); if (f != null) setFont(f); } @@ -123,9 +123,9 @@ public class InstructionsPanelImpl extends JComponent implements WizardObserver, //In the event of classloader issues, also have a way to get //the image from UIManager - slightly more portable for large //apps - img = (BufferedImage) UIManager.get("wizard.sidebar.image"); //NOI18N + img = (BufferedImage) UIManager.get("wizard.sidebar.image"); - String imgStr = System.getProperty("wizard.sidebar.image"); //NOI18N + String imgStr = System.getProperty("wizard.sidebar.image"); //image has not been loaded and user wishes to supply their own image if (img == null && imgStr != null) { //get an URL, works for jars @@ -137,21 +137,20 @@ public class InstructionsPanelImpl extends JComponent implements WizardObserver, img = ImageIO.read(url); } catch (IOException ioe) { System.err.println("Could not load wizard image " - + //NOI18N - ioe.getMessage()); - System.setProperty("wizard.sidebar.image", null); //NOI18N + + ioe.getMessage()); + System.setProperty("wizard.sidebar.image", null); img = null; //error loading img, set to null to use default } else { //URL was not successfully parsed, set img to null to use default - System.err.println("Bad URL for wizard image " + imgStr); //NOI18N - System.setProperty("wizard.sidebar.image", null); //NOI18N + System.err.println("Bad URL for wizard image " + imgStr); + System.setProperty("wizard.sidebar.image", null); img = null; } } if (img == null) try { img = ImageIO.read(InstructionsPanelImpl.class.getResourceAsStream( - "/org/jackhuang/hellominecraft/wizard.jpg")); //NOI18N + "/org/jackhuang/hellominecraft/wizard.jpg")); } catch (IOException ioe) { HMCLog.err("Failed to load wizard.jpg, maybe you fucking modified the launcher", ioe); } @@ -189,7 +188,7 @@ public class InstructionsPanelImpl extends JComponent implements WizardObserver, public final void paintComponent(Graphics g) { Graphics2D g2d = (Graphics2D) g; - Font f = getFont() != null ? getFont() : UIManager.getFont("controlFont"); //NOI18N + Font f = getFont() != null ? getFont() : UIManager.getFont("controlFont"); FontMetrics fm = g.getFontMetrics(f); Insets ins = getInsets(); int dx = ins.left; @@ -202,13 +201,13 @@ public class InstructionsPanelImpl extends JComponent implements WizardObserver, //Don't fetch step list if in summary page, there will //only be the base ones steps = wizard.getAllSteps(); - String steps[] = this.steps; + String[] steps2 = this.steps; if (inSummaryPage) { String summaryStep = C.i18n("wizard.summary"); - String[] nue = new String[steps.length + 1]; - System.arraycopy(steps, 0, nue, 0, steps.length); + String[] nue = new String[steps2.length + 1]; + System.arraycopy(steps2, 0, nue, 0, steps2.length); nue[nue.length - 1] = summaryStep; - steps = nue; + steps2 = nue; } int y = fm.getMaxAscent() + ins.top + MARGIN; int x = ins.left + MARGIN; @@ -228,27 +227,27 @@ public class InstructionsPanelImpl extends JComponent implements WizardObserver, y += h + 10; int first = 0; - int stop = steps.length; - boolean wontFit = y + (h * (steps.length)) > getHeight(); + int stop = steps2.length; + boolean wontFit = y + (h * (steps2.length)) > getHeight(); if (wontFit) { //try to center the current step int availHeight = bottom - y; int willFit = availHeight / h; - int currStepIndex = Arrays.asList(steps).indexOf(currentStep); + int currStepIndex = Arrays.asList(steps2).indexOf(currentStep); int rangeStart = Math.max(0, currStepIndex - (willFit / 2)); - int rangeEnd = Math.min(rangeStart + willFit, steps.length); - if (rangeStart + willFit > steps.length) { + int rangeEnd = Math.min(rangeStart + willFit, steps2.length); + if (rangeStart + willFit > steps2.length) { //Don't scroll off if there's room - rangeStart = steps.length - willFit; - rangeEnd = steps.length; + rangeStart = steps2.length - willFit; + rangeEnd = steps2.length; } - steps = (String[]) steps.clone(); + steps2 = (String[]) steps2.clone(); if (rangeStart != 0) { - steps[rangeStart] = elipsis; + steps2[rangeStart] = elipsis; first = rangeStart; } - if (rangeEnd != steps.length && rangeEnd > 0) { - steps[rangeEnd - 1] = elipsis; + if (rangeEnd != steps2.length && rangeEnd > 0) { + steps2[rangeEnd - 1] = elipsis; stop = rangeEnd; } } @@ -257,25 +256,25 @@ public class InstructionsPanelImpl extends JComponent implements WizardObserver, g.setColor(getForeground()); for (int i = first; i < stop; i++) { - boolean isUndetermined = Wizard.UNDETERMINED_STEP.equals(steps[i]); + boolean isUndetermined = Wizard.UNDETERMINED_STEP.equals(steps2[i]); boolean canOnlyFinish = wizard.getForwardNavigationMode() == Wizard.MODE_CAN_FINISH; if (isUndetermined && canOnlyFinish) break; String curr; - if (!elipsis.equals(steps[i])) + if (!elipsis.equals(steps2[i])) if (inSummaryPage && i == this.steps.length) - curr = (i + 1) + ". " + steps[i]; + curr = (i + 1) + ". " + steps2[i]; else curr = (i + 1) + ". " + (isUndetermined ? elipsis - : steps[i].equals(elipsis) ? elipsis - : wizard.getStepDescription(steps[i])); + : steps2[i].equals(elipsis) ? elipsis + : wizard.getStepDescription(steps2[i])); else curr = elipsis; if (curr != null) { - boolean selected = (steps[i].equals(currentStep) && !inSummaryPage) - || (inSummaryPage && i == steps.length - 1); + boolean selected = (steps2[i].equals(currentStep) && !inSummaryPage) + || (inSummaryPage && i == steps2.length - 1); if (selected) g.setFont(boldFont); @@ -297,7 +296,7 @@ public class InstructionsPanelImpl extends JComponent implements WizardObserver, public final Dimension getPreferredSize() { Font f = getFont() != null ? getFont() - : UIManager.getFont("controlFont"); //NOI18N + : UIManager.getFont("controlFont"); Graphics g = getGraphics(); if (g == null) @@ -307,25 +306,24 @@ public class InstructionsPanelImpl extends JComponent implements WizardObserver, Insets ins = getInsets(); int h = fm.getHeight(); - String[] steps = wizard.getAllSteps(); + String[] steps2 = wizard.getAllSteps(); int w = Integer.MIN_VALUE; - for (int i = 0; i < steps.length; i++) { - String desc = i + ". " + (Wizard.UNDETERMINED_STEP.equals(steps[i]) + for (int i = 0; i < steps2.length; i++) { + String desc = i + ". " + (Wizard.UNDETERMINED_STEP.equals(steps2[i]) ? elipsis - : //NOI18N - wizard.getStepDescription(steps[i])); + : wizard.getStepDescription(steps2[i])); if (desc != null) w = Math.max(w, fm.stringWidth(desc) + MARGIN); } if (Integer.MIN_VALUE == w) w = 250; - BufferedImage img = getImage(); - if (img != null) - w = Math.max(w, img.getWidth()); + BufferedImage image = getImage(); + if (image != null) + w = Math.max(w, image.getWidth()); //Make sure we can grow but not shrink w = Math.max(w, historicWidth); historicWidth = w; - return new Dimension(w, ins.top + ins.bottom + ((h + 3) * steps.length)); + return new Dimension(w, ins.top + ins.bottom + ((h + 3) * steps2.length)); } private boolean inSummaryPage; diff --git a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/views/wizard/modules/MergeMap.java b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/views/wizard/modules/MergeMap.java index d11b6fec1..0eb677751 100644 --- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/views/wizard/modules/MergeMap.java +++ b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/views/wizard/modules/MergeMap.java @@ -8,12 +8,11 @@ and include the License file at http://www.netbeans.org/cddl.txt. If applicable, add the following below the CDDL Header, with the fields enclosed by brackets [] replaced by your own identifying information: "Portions Copyrighted [year] [name of copyright owner]" */ -/* + /* * MergeMap.java * * Created on February 22, 2005, 4:06 PM */ - package org.jackhuang.hellominecraft.utils.views.wizard.modules; import java.util.ArrayList; @@ -28,38 +27,43 @@ import java.util.Set; import java.util.Stack; /** - * A map which proxies a collection of sub-maps each of which has a - * unique id. Submaps can be added or removed en banc. Values from - * removed maps are retained; if push ("someKnownId") happens, the + * A map which proxies a collection of sub-maps each of which has a + * unique id. Submaps can be added or removed en banc. Values from + * removed maps are retained; if push ("someKnownId") happens, the * values previously added to the map while that ID was active reappear. ** This allows us to implement backward/forward semantics for wizards, * in which each pane (identified with a unique ID) can add its own - * settings to the settings map, but if the user presses the Back - * button, the settings from the formerly active pane can disappear - + * settings to the settings map, but if the user presses the Back + * button, the settings from the formerly active pane can disappear - * but if the user moves forward again, they are not lost. *
* Calling remove("someKeyBelongingToAnEarlierId") will completely - * remove that value; calling put ("someKeyBelongingToAnEarlierId", "newValue") + * remove that value; calling put ("someKeyBelongingToAnEarlierId", "newValue") * replaces the earler value permanently. *
- * This class is NOT AN API CLASS. There is no
+ * This class is NOT AN API CLASS. There is no
* commitment that it will remain backward compatible or even exist in the
- * future. The API of this library is in the packages org.netbeans.api.wizard
- * and org.netbeans.spi.wizard.
+ * future. The API of this library is in the packages
+ * org.netbeans.api.wizard
+ * and org.netbeans.spi.wizard.
*
* @author Tim Boudreau
*/
public class MergeMap implements Map {
- private Stack order = new Stack();
- private Map id2map = new HashMap();
-
- /** Creates a new instance of MergeMap */
+
+ private final Stack order = new Stack();
+ private final Map id2map = new HashMap();
+
+ /**
+ * Creates a new instance of MergeMap
+ */
public MergeMap(String currID) {
- push (currID);
+ push(currID);
}
-
- private static final String BASE = "__BASE"; //NOI18N
+
+ private static final String BASE = "__BASE";
+
/**
* Creates a MergeMap with a set of key/value pairs that are
* always there (they came from a legacy wizard - used for bridging the
@@ -69,69 +73,64 @@ public class MergeMap implements Map {
*/
public MergeMap(String currId, Map everpresent) {
order.push(BASE);
- id2map.put (BASE, everpresent);
- push (currId);
+ id2map.put(BASE, everpresent);
+ push(currId);
}
-
+
/**
* Move to a different ID (meaning add a new named map to proxy which can be
* calved off if necessary).
*/
- public Map push (String id) {
- // assert !order.contains(id) : id + " already present"; //NOI18N
- if (order.contains(id)) {
- throw new RuntimeException (id + " already present"); //NOI18N
- }
-// assert !order.contains(id) : id + " already present"; //NOI18N
- if (!order.isEmpty() && id.equals(order.peek())) {
+ public Map push(String id) {
+ // assert !order.contains(id) : id + " already present";
+ if (order.contains(id))
+ throw new RuntimeException(id + " already present");
+// assert !order.contains(id) : id + " already present";
+ if (!order.isEmpty() && id.equals(order.peek()))
return (Map) id2map.get(id);
- }
Map result = (Map) id2map.get(id);
if (result == null) {
result = new HashMap();
- id2map.put (id, result);
+ id2map.put(id, result);
}
- order.push (id);
+ order.push(id);
return result;
}
-
+
/**
* Get the ID of the current sub-map being written into.
*/
public String currID() {
return (String) order.peek();
}
-
+
/**
- * Remove the current sub-map. Removes all of its settings from the
+ * Remove the current sub-map. Removes all of its settings from the
* MergedMap, but if push() is called with the returned value, the
* values associated with the ID being removed will be restored.
*/
public String popAndCalve() {
- if (order.size() == 0) {
- throw new NoSuchElementException ("Cannot back out past first " + //NOI18N
- "entry"); //NOI18N
- }
+ if (order.isEmpty())
+ throw new NoSuchElementException("Cannot back out past first "
+ + "entry");
//Get the current map
String result = (String) order.peek();
- Map curr = (Map) id2map.get (result);
+ Map curr = (Map) id2map.get(result);
order.pop();
-
+
//Though unlikely, it is possible that a later step in a wizard
//overwrote a key/value pair from a previous step of the wizard.
//We do not want to revert that write, so iterate all the keys
- //we're removing, and if any of them are in steps lower on the
+ //we're removing, and if any of them are in steps lower on the
//stack, change those lower steps values to whatever was written
//into the map we're calving off
-
Set keysForCurr = curr.keySet();
- for (Iterator i=orderIterator(); i.hasNext();) {
+ for (Iterator i = orderIterator(); i.hasNext();) {
Map other = (Map) id2map.get(i.next());
- for (Iterator j=curr.keySet().iterator(); j.hasNext();) {
+ for (Iterator j = curr.keySet().iterator(); j.hasNext();) {
Object key = j.next();
- if (other.containsKey(key)) {
- other.put (key, curr.get(key));
- }
+ if (other.containsKey(key))
+ other.put(key, curr.get(key));
}
}
return result;
@@ -144,9 +143,8 @@ public class MergeMap implements Map {
public boolean containsKey(Object obj) {
for (Iterator i = orderIterator(); i.hasNext();) {
Map curr = (Map) id2map.get(i.next());
- if (curr.containsKey(obj)) {
+ if (curr.containsKey(obj))
return true;
- }
}
return false;
}
@@ -154,9 +152,8 @@ public class MergeMap implements Map {
public boolean containsValue(Object obj) {
for (Iterator i = orderIterator(); i.hasNext();) {
Map curr = (Map) id2map.get(i.next());
- if (curr.containsValue(obj)) {
+ if (curr.containsValue(obj))
return true;
- }
}
return false;
}
@@ -165,7 +162,7 @@ public class MergeMap implements Map {
HashSet result = new HashSet();
for (Iterator i = orderIterator(); i.hasNext();) {
Map curr = (Map) id2map.get(i.next());
- result.addAll (curr.entrySet());
+ result.addAll(curr.entrySet());
}
return result;
}
@@ -175,9 +172,8 @@ public class MergeMap implements Map {
String id = (String) i.next();
Map curr = (Map) id2map.get(id);
Object result = curr.get(obj);
- if (result != null) {
+ if (result != null)
return result;
- }
}
return null;
}
@@ -190,42 +186,39 @@ public class MergeMap implements Map {
HashSet result = new HashSet();
for (Iterator i = orderIterator(); i.hasNext();) {
Map curr = (Map) id2map.get(i.next());
- result.addAll (curr.keySet());
+ result.addAll(curr.keySet());
}
return result;
}
public Object put(Object obj, Object obj1) {
- Map curr = (Map) id2map.get (order.peek());
- return curr.put (obj, obj1);
+ Map curr = (Map) id2map.get(order.peek());
+ return curr.put(obj, obj1);
}
public void putAll(Map map) {
- Map curr = (Map) id2map.get (order.peek());
- curr.putAll (map);
+ Map curr = (Map) id2map.get(order.peek());
+ curr.putAll(map);
}
private Object doRemove(Object obj) {
- Map curr = (Map) id2map.get (order.peek());
- Object result = curr.remove (obj);
- if (result == null) {
+ Map curr = (Map) id2map.get(order.peek());
+ Object result = curr.remove(obj);
+ if (result == null)
for (Iterator i = orderIterator(); i.hasNext();) {
curr = (Map) id2map.get(i.next());
- result = curr.remove (obj);
- if (result != null) {
+ result = curr.remove(obj);
+ if (result != null)
break;
- }
}
- }
return result;
}
-
+
public Object remove(Object obj) {
//Ensure we remove any duplicates in upper arrays
Object result = get(obj);
- while (get(obj) != null) {
- doRemove (obj);
- }
+ while (get(obj) != null)
+ doRemove(obj);
return result;
}
@@ -237,54 +230,40 @@ public class MergeMap implements Map {
public Collection values() {
HashSet result = new HashSet();
Set keys = keySet();
- for (Iterator i = keys.iterator(); i.hasNext();) {
- result.add (get(i.next()));
- }
+ for (Iterator i = keys.iterator(); i.hasNext();)
+ result.add(get(i.next()));
return result;
}
-
+
private Iterator orderIterator() {
return new ReverseIterator(order);
}
-
+
private static final class ReverseIterator implements Iterator {
+
private int pos;
- private List l;
- public ReverseIterator (Stack s) {
- pos = s.size()-1;
+ private final List l;
+
+ public ReverseIterator(Stack s) {
+ pos = s.size() - 1;
l = new ArrayList(s);
}
-
+
public boolean hasNext() {
return pos != -1;
}
-
+
public Object next() {
- if (pos < 0) {
+ if (pos < 0)
throw new NoSuchElementException();
- }
Object result = l.get(pos);
pos--;
return result;
- }
-
+ }
+
public void remove() {
throw new UnsupportedOperationException();
}
}
- public String toString() {
- StringBuffer sb = new StringBuffer();
- for (Iterator i = keySet().iterator(); i.hasNext();) {
- Object key = (Object) i.next();
- sb.append ('[');
- sb.append (key);
- sb.append('=');
- sb.append(get(key));
- sb.append(']');
- if (i.hasNext()) sb.append (',');
- }
- return sb.toString();
- }
-
}
diff --git a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/views/wizard/spi/BranchingWizard.java b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/views/wizard/spi/BranchingWizard.java
index be142b175..27e5c2ee2 100644
--- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/views/wizard/spi/BranchingWizard.java
+++ b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/views/wizard/spi/BranchingWizard.java
@@ -9,12 +9,11 @@ If applicable, add the following below the CDDL Header, with the fields
enclosed by brackets [] replaced by your own identifying information:
"Portions Copyrighted [year] [name of copyright owner]" */
-/*
+ /*
* BranchingWizard.java
*
* Created on March 4, 2005, 10:56 PM
*/
-
package org.jackhuang.hellominecraft.utils.views.wizard.spi;
import javax.swing.*;
@@ -25,7 +24,7 @@ import java.util.List;
import java.util.Map;
/**
- * A Wizard with indeterminate branches. The actual branch decision-making
+ * A Wizard with indeterminate branches. The actual branch decision-making
* is done by the WizardBranchController passed to the constructor.
*
BranchingWizard.
+ * Set the secondary for this BranchingWizard.
+ *
* @param newSecondary is a WizardImplementation.
*/
private void setSecondary(WizardImplementation newSecondary) {
/* johnflournoy added additional condition: secondary != this */
- if ((((subsequentSteps == null) != (newSecondary == null))
- || (subsequentSteps != null && !subsequentSteps.equals(newSecondary)))
- && !this.equals(newSecondary)) {
-
- /*
- * johnflournoy: only set the subsequent steps if it
+ if ((((subsequentSteps == null) != (newSecondary == null))
+ || (subsequentSteps != null && !subsequentSteps.equals(newSecondary)))
+ && !this.equals(newSecondary))
+
+ /*
+ * johnflournoy: only set the subsequent steps if it
* this wizard owns the current step.
- */
- if (Arrays.asList(initialSteps.getAllSteps()).contains(currStep)) {
+ */
+ if (Arrays.asList(initialSteps.getAllSteps()).contains(currStep)) {
subsequentSteps = newSecondary;
fireStepsChanged();
}
- }
}
-
public int getForwardNavigationMode() {
return activeWizard.getForwardNavigationMode();
}
private void setCurrent(WizardImplementation wizard) {
- if (activeWizard == wizard) {
+ if (activeWizard == wizard)
return;
- }
- if (wizard == null) {
+ if (wizard == null)
throw new NullPointerException("Can't set current wizard to null");
- }
- if ((activeWizard != null) && (wl != null)) {
+ if ((activeWizard != null) && (wl != null))
activeWizard.removeWizardObserver(wl);
- }
activeWizard = wizard;
- if (wl == null) {
+ if (wl == null)
wl = new WL();
- }
activeWizard.addWizardObserver(wl);
}
@@ -140,17 +133,15 @@ final class BranchingWizard implements WizardImplementation {
Object result = activeWizard.finish(settings);
initialSteps.removeWizardObserver(wl);
//Can be null, we allow bail-out with finish mid-wizard now
- if (subsequentSteps != null) {
+ if (subsequentSteps != null)
subsequentSteps.removeWizardObserver(wl);
- }
return result;
} catch (WizardException we) {
if (we.getStepToReturnTo() != null) {
initialSteps.addWizardObserver(wl);
//Can be null, we allow bail-out with finish mid-wizard now
- if (subsequentSteps != null) {
+ if (subsequentSteps != null)
subsequentSteps.addWizardObserver(wl);
- }
}
throw we;
}
@@ -179,46 +170,40 @@ final class BranchingWizard implements WizardImplementation {
public final String getNextStep() {
String result;
- if (currStep == null) {
+ if (currStep == null)
result = getAllSteps()[0];
- } else {
+ else {
String[] steps = getAllSteps();
int idx = Arrays.asList(steps).indexOf(currStep);
- if (idx == -1) {
- throw new IllegalStateException("Current step not in" + //NOI18N
- " available steps: " + currStep + " not in " + //NOI18N
- Arrays.asList(steps));
- } else {
- if (idx == steps.length - 1) {
- if (subsequentSteps == null) {
+ if (idx == -1)
+ throw new IllegalStateException("Current step not in"
+ + " available steps: " + currStep + " not in "
+ + Arrays.asList(steps));
+ else if (idx == steps.length - 1)
+ if (subsequentSteps == null)
+ result = UNDETERMINED_STEP;
+ else
+ result = subsequentSteps.getNextStep();
+ else {
+ WizardImplementation w = ownerOf(currStep);
+ if (w == initialSteps && idx == initialSteps.getAllSteps().length - 1) {
+ checkForSecondary();
+ if (subsequentSteps != null)
+ result = subsequentSteps.getAllSteps()[0];
+ else
result = UNDETERMINED_STEP;
- } else {
- result = subsequentSteps.getNextStep();
- }
- } else {
- WizardImplementation w = ownerOf(currStep);
- if (w == initialSteps && idx == initialSteps.getAllSteps().length - 1) {
- checkForSecondary();
- if (subsequentSteps != null) {
- result = subsequentSteps.getAllSteps()[0];
- } else {
- result = UNDETERMINED_STEP;
- }
- } else {
- result = w.getNextStep();
- }
- }
+ } else
+ result = w.getNextStep();
}
}
return getProblem() == null ? result : UNDETERMINED_STEP.equals(result) ? result : null;
}
public final String getPreviousStep() {
- if (activeWizard == subsequentSteps && subsequentSteps.getAllSteps()[0].equals(currStep)) {
+ if (activeWizard == subsequentSteps && subsequentSteps.getAllSteps()[0].equals(currStep))
return initialSteps.getAllSteps()[initialSteps.getAllSteps().length - 1];
- } else {
+ else
return activeWizard.getPreviousStep();
- }
}
public final String getProblem() {
@@ -227,17 +212,15 @@ final class BranchingWizard implements WizardImplementation {
public final String getStepDescription(String id) {
WizardImplementation w = ownerOf(id);
- if (w == null) {
+ if (w == null)
return null;
- }
return w.getStepDescription(id);
}
-
+
public final String getLongDescription(String id) {
WizardImplementation w = ownerOf(id);
- if (w == null) {
+ if (w == null)
return null;
- }
return w.getLongDescription(id);
}
@@ -246,24 +229,22 @@ final class BranchingWizard implements WizardImplementation {
checkForSecondary();
return subsequentSteps;
}
- if (Arrays.asList(initialSteps.getAllSteps()).contains(id)) {
+ if (Arrays.asList(initialSteps.getAllSteps()).contains(id))
return initialSteps;
- } else {
+ else {
/*
- * johnflournoy
+ * johnflournoy
* need to check an existing subsequentsteps to see if
* we can find the owner of "id", otherwise we were losing
- * a wizard if we had multiple branches and we backed up to an
+ * a wizard if we had multiple branches and we backed up to an
* earlier wizard and then went down the same path again.
*/
if (subsequentSteps != null) {
- if (!Arrays.asList(subsequentSteps.getAllSteps()).contains(id)) {
+ if (!Arrays.asList(subsequentSteps.getAllSteps()).contains(id))
checkForSecondary();
- }
- } else {
+ } else
checkForSecondary();
- }
-
+
return subsequentSteps;
}
}
@@ -273,35 +254,32 @@ final class BranchingWizard implements WizardImplementation {
}
public final JComponent navigatingTo(String id, Map settings) {
- if (id == null) {
+ if (id == null)
throw new NullPointerException();
- }
currStep = id;
wizardData = settings;
- WizardImplementation impl = ownerOf (id);
- if (impl == null) {
- throw new NullPointerException ("No owning WizardImplementation for" +
- " id " + id);
- }
+ WizardImplementation impl = ownerOf(id);
+ if (impl == null)
+ throw new NullPointerException("No owning WizardImplementation for"
+ + " id " + id);
setCurrent(impl);
return activeWizard.navigatingTo(id, settings);
}
- public final void removeWizardObserver (WizardObserver observer) {
+ public final void removeWizardObserver(WizardObserver observer) {
listenerList.remove(observer);
}
- public final void addWizardObserver (WizardObserver observer) {
+ public final void addWizardObserver(WizardObserver observer) {
listenerList.add(observer);
}
private void fireStepsChanged() {
- WizardObserver[] listeners = (WizardObserver[])
- listenerList.toArray (new WizardObserver[0]);
+ WizardObserver[] listeners = (WizardObserver[]) listenerList.toArray(new WizardObserver[0]);
- for (int i = listeners.length - 1; i >= 0; i --) {
+ for (int i = listeners.length - 1; i >= 0; i--) {
WizardObserver l = (WizardObserver) listeners[i];
l.stepsChanged(null);
}
@@ -310,20 +288,18 @@ final class BranchingWizard implements WizardImplementation {
private void fireNavigabilityChanged() {
checkForSecondary();
- WizardObserver[] listeners = (WizardObserver[])
- listenerList.toArray (new WizardObserver[0]);
+ WizardObserver[] listeners = (WizardObserver[]) listenerList.toArray(new WizardObserver[0]);
- for (int i = listeners.length - 1; i >= 0; i --) {
+ for (int i = listeners.length - 1; i >= 0; i--) {
WizardObserver l = (WizardObserver) listeners[i];
l.navigabilityChanged(null);
}
}
private void fireSelectionChanged() {
- WizardObserver[] listeners = (WizardObserver[])
- listenerList.toArray (new WizardObserver[0]);
+ WizardObserver[] listeners = (WizardObserver[]) listenerList.toArray(new WizardObserver[0]);
- for (int i = listeners.length - 1; i >= 0; i --) {
+ for (int i = listeners.length - 1; i >= 0; i--) {
WizardObserver l = (WizardObserver) listeners[i];
l.selectionChanged(null);
}
@@ -334,6 +310,7 @@ final class BranchingWizard implements WizardImplementation {
}
private class WL implements WizardObserver {
+
public void stepsChanged(Wizard wizard) {
fireStepsChanged();
}
diff --git a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/views/wizard/spi/GenericListener.java b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/views/wizard/spi/GenericListener.java
index 292475df4..a120fcb4b 100644
--- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/views/wizard/spi/GenericListener.java
+++ b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/views/wizard/spi/GenericListener.java
@@ -9,12 +9,11 @@ If applicable, add the following below the CDDL Header, with the fields
enclosed by brackets [] replaced by your own identifying information:
"Portions Copyrighted [year] [name of copyright owner]" */
-/*
+ /*
* GenericListener.java
*
* Created on October 5, 2004, 12:36 AM
*/
-
package org.jackhuang.hellominecraft.utils.views.wizard.spi;
import java.awt.Component;
@@ -30,8 +29,6 @@ import java.util.EventObject;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
-import java.util.logging.Logger;
-import java.util.logging.Level;
import javax.swing.*;
import javax.swing.table.*;
import javax.swing.tree.*;
@@ -56,17 +53,15 @@ import javax.swing.tree.TreeSelectionModel;
* validate its contents.
*
* If you use subclasses of the swing components, you will also need to subclass
- * this listener and override at least the methods isProbablyContainer, attachTo and detachFrom.
+ * this listener and override at least the methods isProbablyContainer, attachTo
+ * and detachFrom.
*
* @author Tim Boudreau
*/
final class GenericListener
- implements ActionListener, PropertyChangeListener, ItemListener,
- ContainerListener, DocumentListener, ChangeListener,
- ListSelectionListener, TreeSelectionListener, TableModelListener {
-
- private static final Logger logger =
- Logger.getLogger(GenericListener.class.getName());
+ implements ActionListener, PropertyChangeListener, ItemListener,
+ ContainerListener, DocumentListener, ChangeListener,
+ ListSelectionListener, TreeSelectionListener, TableModelListener {
private final WizardPage wizardPage;
@@ -76,218 +71,191 @@ final class GenericListener
* Set of components that we're listening to models of, so we can look
* up the component from the model as needed
*/
- private Set listenedTo = new HashSet();
+ private final Set listenedTo = new HashSet();
private final WizardPage.CustomComponentListener extListener;
private final WizardPage.CustomComponentNotifier extNotifier;
+
public GenericListener(WizardPage wizardPage, WizardPage.CustomComponentListener l,
- WizardPage.CustomComponentNotifier n) {
+ WizardPage.CustomComponentNotifier n) {
this.extListener = l;
this.extNotifier = n;
- if ((extListener == null) != (extNotifier == null)) {
+ if ((extListener == null) != (extNotifier == null))
throw new RuntimeException();
- }
- // assert wizardPage != null : "WizardPage may not be null"; // NOI18N
- if (wizardPage == null) {
- throw new IllegalArgumentException("WizardPage may not be null"); // NOI18N)
- }
+ // assert wizardPage != null : "WizardPage may not be null";
+ if (wizardPage == null)
+ throw new IllegalArgumentException("WizardPage may not be null");
this.wizardPage = wizardPage;
wizardPage.addContainerListener(this);
}
-
- public GenericListener (WizardPage page) {
- this (page, null, null);
+
+ public GenericListener(WizardPage page) {
+ this(page, null, null);
}
/**
- * Return true if the given component is likely to be a container such the each
+ * Return true if the given component is likely to be a container such the
+ * each
* component within the container should be be considered as a user input.
- *
+ *
* @param c
+ *
* @return true if the component children should have this listener added.
*/
- protected boolean isProbablyAContainer (Component c) {
+ protected boolean isProbablyAContainer(Component c) {
boolean result = extListener != null ? extListener.isContainer(c) : false;
if (!result) {
boolean isSwing = isSwingClass(c);
- if (isSwing) {
- result = c instanceof JPanel || c instanceof JSplitPane || c instanceof
- JToolBar || c instanceof JViewport || c instanceof JScrollPane ||
- c instanceof JFrame || c instanceof JRootPane || c instanceof
- Window || c instanceof Frame || c instanceof Dialog ||
- c instanceof JTabbedPane || c instanceof JInternalFrame ||
- c instanceof JDesktopPane || c instanceof JLayeredPane ||
- c instanceof Box;
- } else {
+ if (isSwing)
+ result = c instanceof JPanel || c instanceof JSplitPane || c instanceof JToolBar || c instanceof JViewport || c instanceof JScrollPane
+ || c instanceof JFrame || c instanceof JRootPane || c instanceof Window || c instanceof Frame || c instanceof Dialog
+ || c instanceof JTabbedPane || c instanceof JInternalFrame
+ || c instanceof JDesktopPane || c instanceof JLayeredPane
+ || c instanceof Box;
+ else
result = c instanceof Container;
- }
}
return result;
}
-
+
/**
- * Return true if the given component is likely to be a swing primitive or a subclass.
- * The default implmentation here just checks for the package of the component to be "javax.swing"
- * If you use subclasses of swing components, you will need to override this method
+ * Return true if the given component is likely to be a swing primitive or a
+ * subclass.
+ * The default implmentation here just checks for the package of the
+ * component to be "javax.swing"
+ * If you use subclasses of swing components, you will need to override this
+ * method
* to get proper behavior.
*
* @param c
- * @return true if the component should be examined more closely (see isProbablyAContainer)
+ *
+ * @return true if the component should be examined more closely (see
+ * isProbablyAContainer)
*/
- protected boolean isSwingClass (Component c)
- {
+ protected boolean isSwingClass(Component c) {
String packageName = c.getClass().getPackage().getName();
- boolean swing = packageName.equals ("javax.swing"); //NOI18N
+ boolean swing = packageName.equals("javax.swing");
return swing;
}
protected void attachTo(Component jc) {
- if (extListener != null && extListener.accept (jc)) {
+ if (extListener != null && extListener.accept(jc)) {
extListener.startListeningTo(jc, extNotifier);
- listenedTo.add (jc);
- if (wizardPage.getMapKeyFor(jc) != null) {
+ listenedTo.add(jc);
+ if (wizardPage.getMapKeyFor(jc) != null)
wizardPage.maybeUpdateMap(jc);
- }
return;
}
- if (isProbablyAContainer(jc)) {
+ if (isProbablyAContainer(jc))
attachToHierarchyOf((Container) jc);
- } else if (jc instanceof JList) {
+ else if (jc instanceof JList) {
listenedTo.add(jc);
((JList) jc).addListSelectionListener(this);
- } else if (jc instanceof JComboBox) {
+ } else if (jc instanceof JComboBox)
((JComboBox) jc).addActionListener(this);
- } else if (jc instanceof JTree) {
+ else if (jc instanceof JTree) {
listenedTo.add(jc);
((JTree) jc).getSelectionModel().addTreeSelectionListener(this);
- } else if (jc instanceof JToggleButton) {
+ } else if (jc instanceof JToggleButton)
((AbstractButton) jc).addItemListener(this);
- } else if (jc instanceof JFormattedTextField) { //JFormattedTextField must be tested before JTextCompoent
+ else if (jc instanceof JFormattedTextField) //JFormattedTextField must be tested before JTextCompoent
jc.addPropertyChangeListener("value", this);
- } else if (jc instanceof JTextComponent) {
+ else if (jc instanceof JTextComponent) {
listenedTo.add(jc);
((JTextComponent) jc).getDocument().addDocumentListener(this);
} else if (jc instanceof JColorChooser) {
listenedTo.add(jc);
((JColorChooser) jc).getSelectionModel().addChangeListener(this);
- } else if (jc instanceof JSpinner) {
+ } else if (jc instanceof JSpinner)
((JSpinner) jc).addChangeListener(this);
- } else if (jc instanceof JSlider) {
+ else if (jc instanceof JSlider)
((JSlider) jc).addChangeListener(this);
- } else if (jc instanceof JTable) {
+ else if (jc instanceof JTable) {
listenedTo.add(jc);
((JTable) jc).getSelectionModel().addListSelectionListener(this);
- } else {
- if (logger.isLoggable(Level.FINE)) {
- logger.fine("Don't know how to listen to a " + // NOI18N
- jc.getClass().getName());
- }
}
if (accept(jc) && !(jc instanceof JPanel)) {
jc.addPropertyChangeListener("name", this);
- if (wizardPage.getMapKeyFor(jc) != null) {
+ if (wizardPage.getMapKeyFor(jc) != null)
wizardPage.maybeUpdateMap(jc);
- }
- }
-
- if (logger.isLoggable(Level.FINE) && accept(jc)) {
- logger.fine("Begin listening to " + jc); // NOI18N
}
}
protected void detachFrom(Component jc) {
listenedTo.remove(jc);
- if (extListener != null && extListener.accept (jc)) {
+ if (extListener != null && extListener.accept(jc))
extListener.stopListeningTo(jc);
- }
- if (isProbablyAContainer(jc)) {
+ if (isProbablyAContainer(jc))
detachFromHierarchyOf((Container) jc);
- } else if (jc instanceof JList) {
+ else if (jc instanceof JList)
((JList) jc).removeListSelectionListener(this);
- } else if (jc instanceof JComboBox) {
+ else if (jc instanceof JComboBox)
((JComboBox) jc).removeActionListener(this);
- } else if (jc instanceof JTree) {
+ else if (jc instanceof JTree)
((JTree) jc).getSelectionModel().removeTreeSelectionListener(this);
- } else if (jc instanceof JToggleButton) {
+ else if (jc instanceof JToggleButton)
((AbstractButton) jc).removeActionListener(this);
- } else if (jc instanceof JTextComponent) {
+ else if (jc instanceof JTextComponent) {
} else if (jc instanceof JFormattedTextField) { //JFormattedTextField must be tested before JTextCompoent
jc.removePropertyChangeListener("value", this);
((JTextComponent) jc).getDocument().removeDocumentListener(this);
- } else if (jc instanceof JColorChooser) {
+ } else if (jc instanceof JColorChooser)
((JColorChooser) jc).getSelectionModel().removeChangeListener(this);
- } else if (jc instanceof JSpinner) {
+ else if (jc instanceof JSpinner)
((JSpinner) jc).removeChangeListener(this);
- } else if (jc instanceof JSlider) {
+ else if (jc instanceof JSlider)
((JSlider) jc).removeChangeListener(this);
- } else if (jc instanceof JTable) {
+ else if (jc instanceof JTable)
((JTable) jc).getSelectionModel().removeListSelectionListener(this);
- }
if (accept(jc) && !(jc instanceof JPanel)) {
jc.removePropertyChangeListener("name", this);
Object key = wizardPage.getMapKeyFor(jc);
- if (key != null) {
- if (logger.isLoggable(Level.FINE)) {
- logger.fine("Named component removed from hierarchy: " + // NOI18N
- key + ". Removing any corresponding " + // NOI18N
- "value from the wizard settings map."); // NOI18N
- }
-
+ if (key != null)
wizardPage.removeFromMap(key);
- }
- }
-
- if (logger.isLoggable(Level.FINE) && accept(jc)) {
- logger.fine("Stop listening to " + jc); // NOI18N
}
}
private void detachFromHierarchyOf(Container container) {
container.removeContainerListener(this);
Component[] components = container.getComponents();
- for (int i = 0; i < components.length; i++) {
- detachFrom(components[i]); // Will callback recursively any nested JPanels
- }
+ for (Component component : components)
+ detachFrom(component); // Will callback recursively any nested JPanels
}
void attachToHierarchyOf(Container container) {
- if (!Arrays.asList (container.getContainerListeners()).contains(this)) {
+ if (!Arrays.asList(container.getContainerListeners()).contains(this))
container.addContainerListener(this);
- }
Component[] components = container.getComponents();
- for (int i = 0; i < components.length; i++) {
- attachTo(components[i]); // Will recursively add any child components in
- }
+ for (Component component : components)
+ attachTo(component); // Will recursively add any child components in
}
protected boolean accept(Component jc) {
- if (extListener != null && extListener.accept(jc)) {
+ if (extListener != null && extListener.accept(jc))
return true;
- }
- if (!(jc instanceof JComponent)) {
+ if (!(jc instanceof JComponent))
return false;
- }
- if (jc instanceof TableCellEditor || jc instanceof TreeCellEditor ||
- SwingUtilities.getAncestorOfClass(JTable.class, jc) != null ||
- SwingUtilities.getAncestorOfClass(JTree.class, jc) != null ||
- SwingUtilities.getAncestorOfClass(JList.class, jc) != null){
+ if (jc instanceof TableCellEditor || jc instanceof TreeCellEditor
+ || SwingUtilities.getAncestorOfClass(JTable.class, jc) != null
+ || SwingUtilities.getAncestorOfClass(JTree.class, jc) != null
+ || SwingUtilities.getAncestorOfClass(JList.class, jc) != null)
//Don't listen to cell editors, we can end up listening to them
//multiple times, and the tree/table model will give us the event
//we need
return false;
- }
- return isProbablyAContainer (jc) ||
- jc instanceof JList ||
- jc instanceof JComboBox ||
- jc instanceof JTree ||
- jc instanceof JToggleButton || //covers toggle, radio, checkbox
- jc instanceof JTextComponent ||
- jc instanceof JColorChooser ||
- jc instanceof JSpinner ||
- jc instanceof JSlider;
+ return isProbablyAContainer(jc)
+ || jc instanceof JList
+ || jc instanceof JComboBox
+ || jc instanceof JTree
+ || jc instanceof JToggleButton
+ || //covers toggle, radio, checkbox
+ jc instanceof JTextComponent
+ || jc instanceof JColorChooser
+ || jc instanceof JSpinner
+ || jc instanceof JSlider;
}
void setIgnoreEvents(boolean val) {
@@ -299,59 +267,40 @@ final class GenericListener
setIgnoreEvents(true);
try {
//XXX this could be prettier...
- if (logger.isLoggable(Level.FINE)) {
- logger.fine("Event received: " + e); // NOI18N
- }
- if (e instanceof EventObject && ((EventObject) e).getSource() instanceof Component) {
+ if (e instanceof EventObject && ((EventObject) e).getSource() instanceof Component)
wizardPage.userInputReceived((Component) ((EventObject) e).getSource(), e);
- } else if (e instanceof TreeSelectionEvent) {
- logger.fine("Looking for a tree for a tree selection event"); // NOI18N
+ else if (e instanceof TreeSelectionEvent) {
TreeSelectionModel mdl = (TreeSelectionModel) ((TreeSelectionEvent) e).getSource();
for (Iterator i = listenedTo.iterator(); i.hasNext();) {
Object o = i.next();
if (o instanceof JTree && ((JTree) o).getSelectionModel() == mdl) {
- if (logger.isLoggable(Level.FINE)) {
- logger.fine(" found it: " + o); // NOI18N
- }
wizardPage.userInputReceived((Component) o, e);
break;
}
}
} else if (e instanceof DocumentEvent) {
- logger.fine("Looking for a JTextComponent for a DocumentEvent"); // NOI18N
Document document = ((DocumentEvent) e).getDocument();
for (Iterator i = listenedTo.iterator(); i.hasNext();) {
Object o = i.next();
if (o instanceof JTextComponent && ((JTextComponent) o).getDocument() == document) {
- if (logger.isLoggable(Level.FINE)) {
- logger.fine(" found it: " + o); // NOI18N
- }
wizardPage.userInputReceived((Component) o, e);
break;
}
}
} else if (e instanceof ListSelectionEvent) {
- logger.fine("Looking for a JList or JTable for a ListSelectionEvent"); // NOI18N
ListSelectionModel model = (ListSelectionModel) ((ListSelectionEvent) e).getSource();
for (Iterator i = listenedTo.iterator(); i.hasNext();) {
Object o = i.next();
if (o instanceof JList && ((JList) o).getSelectionModel() == model) {
- if (logger.isLoggable(Level.FINE)) {
- logger.fine(" found it: " + o); // NOI18N
- }
wizardPage.userInputReceived((Component) o, e);
break;
} else if (o instanceof JTable && ((JTable) o).getSelectionModel() == model) {
- if (logger.isLoggable(Level.FINE)) {
- logger.fine(" found it: " + o); // NOI18N
- }
wizardPage.userInputReceived((Component) o, e);
break;
}
}
- } else {
+ } else
wizardPage.userInputReceived(null, e);
- }
} finally {
setIgnoreEvents(false);
}
@@ -366,19 +315,8 @@ final class GenericListener
if (e.getSource() instanceof JComponent && "name".equals(e.getPropertyName())) {
// Note - most components do NOT fire a property change on
// setName(), but it is possible for this to be done intentionally
- if (e.getOldValue() instanceof String) {
- if (logger.isLoggable(Level.FINE)) {
- logger.fine("Name of component changed from " + e.getOldValue() + // NOI18N
- " to " + e.getNewValue() + ". Removing any values for " + // NOI18N
- e.getOldValue() + " from the wizard data map"); // NOI18N
- }
+ if (e.getOldValue() instanceof String)
wizardPage.removeFromMap(e.getOldValue());
- }
-
- if (logger.isLoggable(Level.FINE)) {
- logger.fine("Possibly update map for renamed component " + // NOI18N
- e.getSource());
- }
} else if (e.getSource() instanceof JFormattedTextField && "value".equals(e.getPropertyName())) {
fire(e);
@@ -395,18 +333,16 @@ final class GenericListener
// extListener.startListeningTo(e.getChild(), extNotifier);
// listenedTo.add (e.getChild());
// } else if (accept(e.getChild())) {
- if (accept (e.getChild())) {
+ if (accept(e.getChild()))
attachTo(e.getChild());
- }
}
public void componentRemoved(ContainerEvent e) {
- if (extListener != null && extListener.accept (e.getChild())) {
- extListener.stopListeningTo (e.getChild());
- listenedTo.remove (e.getChild());
- } else if (accept(e.getChild())) {
+ if (extListener != null && extListener.accept(e.getChild())) {
+ extListener.stopListeningTo(e.getChild());
+ listenedTo.remove(e.getChild());
+ } else if (accept(e.getChild()))
detachFrom(e.getChild());
- }
}
public void insertUpdate(DocumentEvent e) {
diff --git a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/views/wizard/spi/SimpleWizardInfo.java b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/views/wizard/spi/SimpleWizardInfo.java
index 9654607ed..6a2d39584 100644
--- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/views/wizard/spi/SimpleWizardInfo.java
+++ b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/views/wizard/spi/SimpleWizardInfo.java
@@ -172,11 +172,8 @@ final class SimpleWizardInfo implements WizardControllerImplementation {
}
private int index() {
- SimpleWizard wizard = getWizard();
- if (wizard != null)
- return wizard.currentStepIndex();
- else
- return 0;
+ SimpleWizard a = getWizard();
+ return a == null ? 0 : a.currentStepIndex();
}
public final void setBusy(boolean value) {
@@ -281,11 +278,9 @@ final class SimpleWizardInfo implements WizardControllerImplementation {
// lookup the step by name
boolean containsStep(String name) {
- for (int i = 0; i < steps.length; i++) {
- String step = steps[i];
+ for (String step : steps)
if (name.equals(step))
return true;
- }
return false;
}
@@ -308,7 +303,7 @@ final class SimpleWizardInfo implements WizardControllerImplementation {
return Arrays.equals(info.descriptions, descriptions)
&& Arrays.equals(info.steps, steps)
- && info.title == title;
+ && (info.title == null ? title == null : info.title.equals(title));
} else
return false;
}
@@ -323,9 +318,4 @@ final class SimpleWizardInfo implements WizardControllerImplementation {
boolean cancel(Map settings) {
return provider.cancel(settings);
}
-
- public String toString() {
- return "SimpleWizardInfo@" + System.identityHashCode(this) + " for "
- + provider;
- }
}
diff --git a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/views/wizard/spi/Summary.java b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/views/wizard/spi/Summary.java
index 6e35464ed..0106ca346 100644
--- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/views/wizard/spi/Summary.java
+++ b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/views/wizard/spi/Summary.java
@@ -8,7 +8,7 @@ and include the License file at http://www.netbeans.org/cddl.txt.
If applicable, add the following below the CDDL Header, with the fields
enclosed by brackets [] replaced by your own identifying information:
"Portions Copyrighted [year] [name of copyright owner]" */
-/*
+ /*
* Summary.java
*
* Created on September 24, 2006, 4:05 AM
@@ -16,7 +16,6 @@ enclosed by brackets [] replaced by your own identifying information:
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
-
package org.jackhuang.hellominecraft.utils.views.wizard.spi;
import java.awt.Component;
@@ -27,122 +26,114 @@ import javax.swing.JTextArea;
import javax.swing.UIManager;
/**
- * Object which may be returned from WizardPage.WizardResultProducer.finish()
- * or WizardPanelProvider.finish(), or passed to
- * DeferredWizardResult.ResultProgressHandle.finish(). If an
- * instance of Summary is used, then the UI should, rather
- * than disappearing, show the component provided by the Summary
- * object. Convenience constructors are provided for plain text and list style
+ * Object which may be returned from
+ * WizardPage.WizardResultProducer.finish()
+ * or WizardPanelProvider.finish(), or passed to
+ * DeferredWizardResult.ResultProgressHandle.finish(). If an
+ * instance of Summary is used, then the UI should, rather
+ * than disappearing, show the component provided by the Summary
+ * object. Convenience constructors are provided for plain text and list style
* views.
*
* @author Tim Boudreau
*/
public class Summary {
+
private final Component comp;
private Object result;
-
- //constructors package private - only unit tests should be able to subclass
- //Summary
-
- Summary(String text, Object result) {
+
+ /**
+ * Create a Summary object which will display the
+ * passed String in a text component of some sort.
+ *
+ * @param text The text to display - must be non-null, greater than zero
+ * length and not completely whitespace
+ * @param result The result that should be returned when the Wizard is
+ * closed
+ *
+ * @return the requested Summary object
+ */
+ public Summary(String text, Object result) {
//XXX this is creating components off the AWT thread - needs to change
//to use invokeAndWait where appropriate
- if (text == null) {
- throw new NullPointerException ("Text is null"); //NOI18N
- }
- if (text.trim().length() == 0) {
- throw new IllegalArgumentException ("Text is empty or all " + //NOI18N
- "whitespace"); //NOI18N
- }
+ if (text == null)
+ throw new NullPointerException("Text is null");
+ if (text.trim().length() == 0)
+ throw new IllegalArgumentException("Text is empty or all whitespace");
this.result = result;
JTextArea jta = new JTextArea();
- jta.setText (text);
+ jta.setText(text);
jta.setWrapStyleWord(true);
jta.setLineWrap(true);
jta.getCaret().setBlinkRate(0);
jta.setEditable(false);
jta.getCaret().setVisible(true);
- Font f = UIManager.getFont ("Label.font");
- if (f != null) { //may be on old GTK L&F, etc.
- jta.setFont (f);
- }
- comp = new JScrollPane (jta);
+ Font f = UIManager.getFont("Label.font");
+ if (f != null) //may be on old GTK L&F, etc.
+ jta.setFont(f);
+ comp = new JScrollPane(jta);
}
-
- Summary(String[] items, Object result) {
- if (items == null) {
- throw new NullPointerException ("Items array null"); //NOI18N
- }
- if (items.length == 0) {
- throw new IllegalArgumentException ("Items array empty"); //NOI18N
- }
+
+ /**
+ * Create a Summary object that will display the passed
+ * Strings in a JList or similar.
+ *
+ * @param items A non-null list of one or more Strings to be displayed
+ * @param result The result that should be returned when the Wizard is
+ * closed
+ *
+ * @return the requested Summary object
+ */
+ public Summary(String[] items, Object result) {
+ if (items == null)
+ throw new NullPointerException("Items array null");
+ if (items.length == 0)
+ throw new IllegalArgumentException("Items array empty");
this.result = result;
JList list = new JList(items);
- comp = new JScrollPane (list);
+ comp = new JScrollPane(list);
}
-
- Summary(Component comp, Object result) {
+
+ /**
+ * Create a Summary object that will display the passed
+ * component.
+ *
+ * @param comp A custom component to show on the summary page after the
+ * Wizard has been completed
+ * @param result The result that should be returned when the
+ * Wizard is
+ * closed
+ *
+ * @return the requested Summary object
+ */
+ public Summary(Component comp, Object result) {
this.result = result;
this.comp = comp;
- if (comp == null) {
- throw new NullPointerException ("Null component"); //NOI18N
- }
+ if (comp == null)
+ throw new NullPointerException("Null component");
}
-
- /**
- * Create a Summary object that will display the passed
- * Strings in a JList or similar.
- * @param items A non-null list of one or more Strings to be displayed
- * @param result The result that should be returned when the Wizard is
- * closed
- * @return the requested Summary object
- */
- public static Summary create (String[] items, Object result) {
- return new Summary (items, result);
- }
-
- /**
- * Create a Summary object that will display the passed component.
- * @param comp A custom component to show on the summary page after the
- * Wizard has been completed
- * @param result The result that should be returned when the Wizard is
- * closed
- * @return the requested Summary object
- */
- public static Summary create (Component comp, Object result) {
- return new Summary (comp, result);
- }
-
- /**
- * Create a Summary object which will display the
- * passed String in a text component of some sort.
- * @param text The text to display - must be non-null, greater than zero
- * length and not completely whitespace
- * @param result The result that should be returned when the Wizard is
- * closed
- * @return the requested Summary object
- */
- public static Summary create (String text, Object result) {
- return new Summary (text, result);
- }
-
+
/**
* Get the component that will display the summary information.
+ *
* @return an appropriate component, the type of which may differ depending
- * on the factory method used to create this component
- */
+ * on the factory method used to create this component
+ */
public Component getSummaryComponent() {
return comp;
}
-
+
/**
- * Get the object that represents the actual result of whatever the Wizard
- * that created this Summary object computes. Note this method may not
- * return another instance of Summary or an instance of
+ * Get the object that represents the actual result of whatever the
+ * Wizard
+ * that created this Summary object computes. Note this method
+ * may not
+ * return another instance of Summary or an instance of
* DeferredWizardResult.
- * @return the object passed to the factory method that created this
- * Summary object, or null.
- */
+ *
+ * @return the object passed to the factory method that created this
+ * Summary object, or null.
+ */
public Object getResult() {
return result;
}
diff --git a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/views/wizard/spi/Util.java b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/views/wizard/spi/Util.java
index 58229cd58..22761d4a7 100644
--- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/views/wizard/spi/Util.java
+++ b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/views/wizard/spi/Util.java
@@ -2,7 +2,6 @@
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
-
package org.jackhuang.hellominecraft.utils.views.wizard.spi;
import java.lang.reflect.InvocationTargetException;
@@ -16,8 +15,10 @@ import java.util.Set;
* @author Tim Boudreau
*/
final class Util {
- private Util(){}
-
+
+ private Util() {
+ }
+
/**
* Get an array of step ids from an array of WizardPages
*/
@@ -28,22 +29,21 @@ final class Util {
for (int i = 0; i < pages.length; i++) {
result[i] = pages[i].id();
if (result[i] == null || uniqueNames.contains(result[i])) {
- result[i] = uniquify (getIDFromStaticMethod(pages[i].getClass()),
- uniqueNames);
+ result[i] = uniquify(getIDFromStaticMethod(pages[i].getClass()),
+ uniqueNames);
pages[i].id = result[i];
}
- uniqueNames.add (result[i]);
+ uniqueNames.add(result[i]);
}
return result;
}
-
- static String uniquify (String s, Set /* WizardDisplayer.getDefault().
* * A Wizard is a series of one or more steps represented - * by panels in the user interface. Each step is identified by a unique String ID. + * by panels in the user interface. Each step is identified by a unique String + * ID. * Panels are created, usually on-demand, as the user navigates through - * the UI of the wizard. Panels typically listen on components they contain - * and put values into the Map where the wizard gathers data. Note that if the + * the UI of the wizard. Panels typically listen on components they contain + * and put values into the Map where the wizard gathers data. Note that if the * user navigates backward, data entered on pages after the current one * disappears from the Map. *
* To create a Wizard, you do not implement or instantiate this class directly, - * but rather, use one of the convenience classes in this package. There are + * but rather, use one of the convenience classes in this package. There are * three: *
WizardPage - use or subclass WizardPage, and pass an array
- * of instances, or an array of the Class objects of your subclasses
- * to WizardPage.createWizard(). This class offers the added
+ * of instances, or an array of the Class objects of your
+ * subclasses
+ * to WizardPage.createWizard(). This class offers the added
* convenience that standard Swing components will be listened to automatically,
* and if their Name property is set, the value from the component will be
- * automatically put into the settings map.
+ * automatically put into the settings map.
* WizardPanelProvider - subclass this to create a Wizard
- * with a fixed set of steps. You provide a set of unique ID strings to the
+ * with a fixed set of steps. You provide a set of unique ID strings to the
* constructor, for all of the steps in the wizard, and override
* createPanel() to create the GUI component that should be displayed for
* each step - it will be called on demand as the user moves through the
@@ -55,12 +56,12 @@ import org.jackhuang.hellominecraft.utils.views.wizard.api.WizardDisplayer;
*
* WizardBranchController - this is for creating complex
* wizards with decision points after which the future steps change, depending
- * on what the user chooses. Create a simple wizard using WizardPage or
+ * on what the user chooses. Create a simple wizard using WizardPage or
* WizardPanelProvider to represent the initial steps.
* Then override getWizardForStep() or
* getPanelProviderForStep() to return a different Wizard to
* represent the remaining steps at any point where the set of future steps
- * changes. You can have as many branch points as you want, simply by
+ * changes. You can have as many branch points as you want, simply by
* using WizardBranchController to create the wizards for different decision
* points.
*
@@ -81,58 +82,63 @@ import org.jackhuang.hellominecraft.utils.views.wizard.api.WizardDisplayer;
* @author Timothy Boudreau
*/
public final class Wizard {
+
/**
* Constant that can be returned by
@@ -247,101 +241,122 @@ public class WizardPage extends JPanel implements WizardPanel {
* Important: The return value from this method should always
* be the same for any given component, for the lifetime of the
* WizardPage.
- *
+ *
* @param c A component
+ *
* @return Whether or not this CustomComponentListener will listen
- * on the passed component. If true, the component will later be
- * passed to
* Important: The return value from this method should always
* be the same for any given component, for the lifetime of the
* WizardPage.
+ *
* @param c the component, which the accept method earlier returned
- * true for
+ * true for
+ *
* @return A string key that should be used in the Wizard's settings
- * map for the name of this component's value
- */
- public String keyFor (Component c) {
+ * map for the name of this component's value
+ */
+ public String keyFor(Component c) {
return c.getName();
}
+
/**
- * Get the value currently set on the passed component. Will only
- * be passed components which the
- * If an instance of
- * If an instance of getForwardNavigationMode()
* to indicate that the Next button can be enabled (or the Finish button
* if the current panel is the last one in the wizard).
- */
- public static final int MODE_CAN_CONTINUE =
- WizardController.MODE_CAN_CONTINUE;
+ */
+ public static final int MODE_CAN_CONTINUE
+ = WizardController.MODE_CAN_CONTINUE;
/**
- * Constant that can be returned by getForwardNavigationMode to indicate
+ * Constant that can be returned by getForwardNavigationMode to
+ * indicate
* that the Finish button can be enabled if the problem string is null.
*/
- public static final int MODE_CAN_FINISH =
- WizardController.MODE_CAN_FINISH;
+ public static final int MODE_CAN_FINISH
+ = WizardController.MODE_CAN_FINISH;
/**
- * Constant that can be returned by getForwardNavigationMode to indicate
- * that both the Finish and Next buttons can be enabled if the problem
- * string is null. This value is a bitmask - i.e.
- * MODE_CAN_CONTINUE_OR_FINISH == MODE_CAN_CONTINUE |
+ * Constant that can be returned by getForwardNavigationMode to
+ * indicate
+ * that both the Finish and Next buttons can be enabled if the problem
+ * string is null. This value is a bitmask - i.e.
+ * MODE_CAN_CONTINUE_OR_FINISH == MODE_CAN_CONTINUE |
* MODE_CAN_FINISH
*/
- public static final int MODE_CAN_CONTINUE_OR_FINISH =
- WizardController.MODE_CAN_CONTINUE_OR_FINISH;
-
+ public static final int MODE_CAN_CONTINUE_OR_FINISH
+ = WizardController.MODE_CAN_CONTINUE_OR_FINISH;
+
/**
* Special panel ID key indicating a branch point in the wizard,
* after which the next step(s) are unknown.
*/
public static final String UNDETERMINED_STEP = "_#UndeterminedStep";
-
final WizardImplementation impl; //package private for unit tests
-
- /** Creates a new instance of Wizard */
+
+ /**
+ * Creates a new instance of Wizard
+ */
Wizard(WizardImplementation impl) {
this.impl = impl;
- if (impl == null) {
+ if (impl == null)
throw new NullPointerException();
- }
}
/**
* Notify the wizard that the user is navigating to a different panel,
* as identified by the passed id.
- * @param id The id of the panel being navigated to
+ *
+ * @param id The id of the panel being navigated to
* @param wizardData The data gathered thus far as the user has progressed
- * through the wizard. The contents of this map should not contain any
- * key/values that were assigned on future panels, if the user is
- * navigating backward.
+ * through the wizard. The contents of this map should not contain any
+ * key/values that were assigned on future panels, if the user is
+ * navigating backward.
+ *
* @return The component that should be shown for step id
- * of the Wizard
- */
+ * of the Wizard
+ */
public JComponent navigatingTo(String id, Map wizardData) {
return impl.navigatingTo(id, wizardData);
}
@@ -140,7 +146,7 @@ public final class Wizard {
/**
* Get the current step the wizard is on, as determined by the most recent
* call to navigatingTo().
- */
+ */
public String getCurrentStep() {
return impl.getCurrentStep();
}
@@ -148,31 +154,34 @@ public final class Wizard {
/**
* Get the id of the step that comes after current step returned by
* getCurrentStep().
- * @return Null if this is the last step of the wizard;
- * UNDETERMINED_STEP if this is a branch point and the
- * user yet needs to do some interaction with the UI of the current
- * panel to trigger computation of the id of the next step; otherwise,
- * the unique id of the next step.
- */
+ *
+ * @return Null if this is the last step of the wizard;
+ * UNDETERMINED_STEP if this is a branch point and the
+ * user yet needs to do some interaction with the UI of the current
+ * panel to trigger computation of the id of the next step; otherwise,
+ * the unique id of the next step.
+ */
public String getNextStep() {
return impl.getNextStep();
}
/**
* Get the id of the preceding step to the current one as returned by
- * getCurrentStep(), or null if the current step is the
+ * getCurrentStep(), or null if the current step is the
* first page of the wizard.
+ *
* @return the id of the previous step or null
- */
+ */
public String getPreviousStep() {
return impl.getPreviousStep();
}
/**
* Get the problem string that should be displayed to the user.
+ *
* @return A string describing what the user needs to do to enable
- * the Next or Finish buttons, or null if the buttons may be enabled
- */
+ * the Next or Finish buttons, or null if the buttons may be enabled
+ */
public String getProblem() {
return impl.getProblem();
}
@@ -181,43 +190,49 @@ public final class Wizard {
* Get the string IDs of all known steps in this wizard, terminating
* with UNDETERMINED_STEP if subsequent steps of the
* wizard depend on the user's interaction beyond that point.
+ *
* @return an array of strings which may individually be passed to
- * navigatingTo to change the current step of the wizard
- */
+ * navigatingTo to change the current step of the wizard
+ */
public String[] getAllSteps() {
return impl.getAllSteps();
}
-
+
/**
- * Get a long description for this panel. The long description should be
+ * Get a long description for this panel. The long description should be
* used in preference to the short description in the top of a wizard
* panel in the UI, if it returns non-null.
+ *
* @param stepId The ID of the step for which a description is requested
+ *
* @return A more detailed localized description or null
- */
+ */
public String getLongDescription(String stepId) {
- return impl.getLongDescription (stepId);
+ return impl.getLongDescription(stepId);
}
/**
* Get a localized String description of the step for the passed id,
* which may be displayed in the UI of the wizard.
+ *
* @param id A step id among those returned by getAllSteps()
- */
+ */
public String getStepDescription(String id) {
return impl.getStepDescription(id);
}
/**
- * Called when the user has clicked the finish button. This method
+ * Called when the user has clicked the finish button. This method
* computes whatever the result of the wizard is.
+ *
* @param settings The complete set of key-value pairs gathered by the
- * various panels as the user proceeded through the wizard
+ * various panels as the user proceeded through the wizard
+ *
* @return An implementation-dependent object that is the outcome of
- * the wizard. May be null. Special return values are instances of
- * DeferredWizardResult and Summary which will affect the behavior of
- * the UI.
- */
+ * the wizard. May be null. Special return values are instances of
+ * DeferredWizardResult and Summary which will affect the behavior of
+ * the UI.
+ */
public Object finish(Map settings) throws WizardException {
return impl.finish(settings);
}
@@ -225,20 +240,24 @@ public final class Wizard {
/**
* Called when the user has clicked the Cancel button in the wizard UI
* or otherwise closed the UI component without completing the wizard.
- * @param settings The (possibly incomplete) set of key-value pairs gathered by the
- * various panels as the user proceeded through the wizard
+ *
+ * @param settings The (possibly incomplete) set of key-value pairs gathered
+ * by the
+ * various panels as the user proceeded through the wizard
+ *
* @return true if the UI may indeed be closed, false if closing should
- * not be permitted
- */
- public boolean cancel (Map settings) {
+ * not be permitted
+ */
+ public boolean cancel(Map settings) {
return impl.cancel(settings);
}
/**
* Get the title of the Wizard that should be displayed in its dialog
* titlebar (if any).
+ *
* @return A localized string
- */
+ */
public String getTitle() {
return impl.getTitle();
}
@@ -246,8 +265,9 @@ public final class Wizard {
/**
* Determine if the wizard is busy doing work in a background thread and
* all navigation controls should be disabled.
+ *
* @return whether or not the wizard is busy
- */
+ */
public boolean isBusy() {
return impl.isBusy();
}
@@ -255,23 +275,27 @@ public final class Wizard {
/**
* Get the navigation mode, which determines the enablement state of
* the Next and Finish buttons.
+ *
* @return one of the constants MODE_CAN_CONTINUE,
- * MODE_CAN_FINISH, or MODE_CAN_CONTINUE_OR_FINISH.
- */
+ * MODE_CAN_FINISH, or
+ * MODE_CAN_CONTINUE_OR_FINISH.
+ */
public int getForwardNavigationMode() {
return impl.getForwardNavigationMode();
}
private volatile boolean listeningToImpl = false;
- private final List listeners = Collections.synchronizedList (
- new LinkedList());
+ private final List listeners = Collections.synchronizedList(
+ new LinkedList());
private WizardObserver l = null;
+
/**
* Add a WizardObserver that will be notified of navigability and step
* changes.
+ *
* @param observer A WizardObserver
- */
+ */
public void addWizardObserver(WizardObserver observer) {
listeners.add(observer);
if (!listeningToImpl) {
@@ -283,11 +307,12 @@ public final class Wizard {
/**
* Remove a WizardObserver.
+ *
* @param observer A WizardObserver
- */
+ */
public void removeWizardObserver(WizardObserver observer) {
listeners.remove(observer);
- if (listeningToImpl && listeners.size() == 0) {
+ if (listeningToImpl && listeners.isEmpty()) {
impl.removeWizardObserver(l);
l = null;
listeningToImpl = false;
@@ -295,28 +320,26 @@ public final class Wizard {
}
private class ImplL implements WizardObserver {
+
public void stepsChanged(Wizard wizard) {
WizardObserver[] l = (WizardObserver[]) listeners.toArray(
- new WizardObserver[listeners.size()]);
- for (int i = 0; i < l.length; i++) {
- l[i].stepsChanged(Wizard.this);
- }
+ new WizardObserver[listeners.size()]);
+ for (WizardObserver l1 : l)
+ l1.stepsChanged(Wizard.this);
}
public void navigabilityChanged(Wizard wizard) {
WizardObserver[] l = (WizardObserver[]) listeners.toArray(
- new WizardObserver[listeners.size()]);
- for (int i = 0; i < l.length; i++) {
- l[i].navigabilityChanged(Wizard.this);
- }
+ new WizardObserver[listeners.size()]);
+ for (WizardObserver l1 : l)
+ l1.navigabilityChanged(Wizard.this);
}
public void selectionChanged(Wizard wizard) {
WizardObserver[] l = (WizardObserver[]) listeners.toArray(
- new WizardObserver[listeners.size()]);
- for (int i = 0; i < l.length; i++) {
- l[i].selectionChanged(Wizard.this);
- }
+ new WizardObserver[listeners.size()]);
+ for (WizardObserver l1 : l)
+ l1.selectionChanged(Wizard.this);
}
}
@@ -324,41 +347,40 @@ public final class Wizard {
return impl.hashCode() * 17;
}
- public boolean equals (Object o) {
- if (o == this) {
+ public boolean equals(Object o) {
+ if (o == this)
return true;
- } else if (o instanceof Wizard) {
- return impl.equals (((Wizard)o).impl);
- } else {
+ else if (o instanceof Wizard)
+ return impl.equals(((Wizard) o).impl);
+ else
return false;
- }
}
/**
* Delegates to WizardDisplayer.showWizard()
- */
- public void show () {
+ */
+ public void show() {
WizardDisplayer.showWizard(this);
}
/**
* Delegates to WizardDisplayer.showWizard()
- */
- public Object show (Wizard wizard, Action help) {
- return WizardDisplayer.showWizard (wizard, help);
+ */
+ public Object show(Wizard wizard, Action help) {
+ return WizardDisplayer.showWizard(wizard, help);
}
/**
* Delegates to WizardDisplayer.showWizard()
- */
- public Object show (Wizard wizard, Rectangle r) {
- return WizardDisplayer.showWizard (wizard, r);
+ */
+ public Object show(Wizard wizard, Rectangle r) {
+ return WizardDisplayer.showWizard(wizard, r);
}
/**
* Delegates to WizardDisplayer.showWizard()
- */
- public Object show (Wizard wizard, Rectangle r, Action help) {
- return WizardDisplayer.showWizard (wizard, r, help, null);
+ */
+ public Object show(Wizard wizard, Rectangle r, Action help) {
+ return WizardDisplayer.showWizard(wizard, r, help, null);
}
}
diff --git a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/views/wizard/spi/WizardPage.java b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/views/wizard/spi/WizardPage.java
index d5a9f286c..179417d34 100644
--- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/views/wizard/spi/WizardPage.java
+++ b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/views/wizard/spi/WizardPage.java
@@ -8,12 +8,11 @@ and include the License file at http://www.netbeans.org/cddl.txt.
If applicable, add the following below the CDDL Header, with the fields
enclosed by brackets [] replaced by your own identifying information:
"Portions Copyrighted [year] [name of copyright owner]" */
-/*
+ /*
* FixedWizard.java
*
* Created on August 19, 2005, 9:11 PM
*/
-
package org.jackhuang.hellominecraft.utils.views.wizard.spi;
import java.beans.Beans;
@@ -22,18 +21,11 @@ import javax.swing.text.JTextComponent;
import javax.swing.tree.TreePath;
import java.awt.Color;
import java.awt.Component;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
-import java.util.Set;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
/**
* A convenience JPanel subclass that makes it easy to create wizard panels.
@@ -42,7 +34,7 @@ import java.util.logging.Logger;
* Automatic listening to child components
* If you add an editable component (all standard Swing controls are supported)
* to a WizardPage or a child JPanel inside it,
- * a listener is automatically attached to it. If user input occurs, the
+ * a listener is automatically attached to it. If user input occurs, the
* following things happen, in order:
*
*
*
* The above behavior can be disabled by passing name property of the component has been set, then
@@ -50,13 +42,13 @@ import java.util.logging.Logger;
* for lists/combo boxes/trees, etc.) will automatically be added to the
* wizard settings map, with the component name as the key.name property is set,
- * validateContents() will be called. You can override that method
+ * validateContents() will be called. You can override that method
* to enable/disable the finish button, call setProblem() to
* disable navigation and display a string to the user, etc.
* false to the
- * appropriate constructor. In that case, validateContents will
+ * appropriate constructor. In that case, validateContents will
* never be called automatically.
*
* If you have custom components that WizardPage will not know how to listen
@@ -68,14 +60,14 @@ import java.util.logging.Logger;
* the WizardController and the settings map for the wizard that
* the panel is a part of.
*
- * Instances of WizardPage can be returned from a WizardPanelProvider; this
+ * Instances of WizardPage can be returned from a WizardPanelProvider; this
* class also offers two methods for conveniently assembling a wizard:
*
*
createWizard(). Note that for large wizards, it is preferable
+ * createWizard(). Note that for large wizards, it is preferable
* to construct the panels on demand rather than at construction time.
*
*
* Note that during development of a wizard, it is worthwhile to test/run with
- * assertions enabled, as there is quite a bit of validity checking via assertions
+ * assertions enabled, as there is quite a bit of validity checking via
+ * assertions
* that can help find problems early.
* Using Custom Components
* If the autoListen constructor argument is true, a WizardPage
* will automatically listen to components which have a name, if they are
- * standard Swing components it knows how to listen to. If you are using
+ * standard Swing components it knows how to listen to. If you are using
* custom components, implement WizardPage.CustomComponentListener and return
* it from createCustomComponentListener() to add supplementary
* listening code for custom components.
@@ -109,9 +102,6 @@ import java.util.logging.Logger;
*/
public class WizardPage extends JPanel implements WizardPanel {
- private static final Logger logger =
- Logger.getLogger(WizardPage.class.getName());
-
private final String description;
String id;
@@ -135,70 +125,72 @@ public class WizardPage extends JPanel implements WizardPanel {
/**
* Create a WizardPage with the passed description and auto-listening
* behavior.
- *
+ *
* @param stepDescription the localized description of this step
* @param autoListen if true, components added will automatically be
* listened to for user input
- */
+ */
public WizardPage(String stepDescription, boolean autoListen) {
- this (null, stepDescription, autoListen);
+ this(null, stepDescription, autoListen);
}
+
/**
* Construct a new WizardPage with the passed step id and description.
* Use this constructor for WizardPages which will be constructed ahead
* of time and passed in an array to createWizard.
*
- * @param stepId the unique ID for the step represented. If null,
+ * @param stepId the unique ID for the step represented. If null,
* the class name or a variant of it will be used
* @param stepDescription the localized description of this step
* @param autoListen if true, components added will automatically be
* listened to for user input
+ *
* @see #validateContents
*/
public WizardPage(String stepId, String stepDescription, boolean autoListen) {
id = stepId == null ? getClass().getName() : stepId;
this.autoListen = autoListen;
description = stepDescription;
-
+
}
private boolean listening;
+
private void startListening() {
listening = true;
if (autoListen) {
//It will attach itself
GenericListener gl = new GenericListener(this, ccl = createCustomComponentListener(),
- ccl == null ? null : new CustomComponentNotifierImpl(this));
+ ccl == null ? null : new CustomComponentNotifierImpl(this));
gl.attachToHierarchyOf(this);
- } else {
- if ((ccl = createCustomComponentListener()) != null) {
- throw new IllegalStateException ("CustomComponentListener " +
- "will never be called if the autoListen parameter is " +
- "false");
- }
- }
+ } else if ((ccl = createCustomComponentListener()) != null)
+ throw new IllegalStateException("CustomComponentListener "
+ + "will never be called if the autoListen parameter is "
+ + "false");
// if (getClass() == WizardPage.class && stepId == null ||
// description == null) {
-// throw new NullPointerException ("Step or ID is null"); //NOI18N
+// throw new NullPointerException ("Step or ID is null");
// }
setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); //XXX
}
-
- /**
- * Create an auto-listening WizardPage with the passed description
- * @param stepDescription the localized description of this step
- */
- public WizardPage (String stepDescription) {
- this (null, stepDescription);
- }
/**
* Create an auto-listening WizardPage with the passed description
- * @param stepId The unique id for the step. If null, an id will be
- * generated
+ *
* @param stepDescription the localized description of this step
- *
- */
+ */
+ public WizardPage(String stepDescription) {
+ this(null, stepDescription);
+ }
+
+ /**
+ * Create an auto-listening WizardPage with the passed description
+ *
+ * @param stepId The unique id for the step. If null, an id will be
+ * generated
+ * @param stepDescription the localized description of this step
+ *
+ */
public WizardPage(String stepId, String stepDescription) {
this(stepId, stepDescription, true);
}
@@ -212,32 +204,34 @@ public class WizardPage extends JPanel implements WizardPanel {
}
/**
- * Default constructor. AutoListening will be on by default.
+ * Default constructor. AutoListening will be on by default.
*/
protected WizardPage() {
this(true);
}
-
+
/**
- * If you are using custom Swing or AWT components which the
+ * If you are using custom Swing or AWT components which the
* WizardPage will not know how to automatically listen to, you
* may want to override this method, implement CustomComponentListener
- * and return an instance of it.
+ * and return an instance of it.
+ *
* @return A CustomComponentListener implementation, or null (the default).
- */
+ */
protected CustomComponentListener createCustomComponentListener() {
return null;
}
-
+
/**
* Implement this class if you are using custom Swing or AWT components,
- * and return an instance of it from
+ * and return an instance of it from
* WizardPage.createCustomComponentListener().
- */
+ */
public static abstract class CustomComponentListener {
+
/**
* Indicates that this CustomComponentListener will take responsibility
- * for noticing events from the passed component, and that the
+ * for noticing events from the passed component, and that the
* WizardPage should not try to automatically listen on it (which it
* can only do for standard Swing components and their children).
* startListeningTo()
- */
- public abstract boolean accept (Component c);
+ * on the passed component. If true, the component will later be
+ * passed to startListeningTo()
+ */
+ public abstract boolean accept(Component c);
+
/**
- * Begin listening for events on the component. When an event occurs,
+ * Begin listening for events on the component. When an event occurs,
* call the eventOccurred() method on the passed
* CustomComponentNotifier.
+ *
* @param c The component to start listening to
* @param n An object that can be called to update the settings map
- * when an interesting event occurs on the component
- */
- public abstract void startListeningTo (Component c, CustomComponentNotifier n);
+ * when an interesting event occurs on the component
+ */
+ public abstract void startListeningTo(Component c, CustomComponentNotifier n);
+
/**
* Stop listening for events on a component.
+ *
* @param c The component to stop listening to
- */
- public abstract void stopListeningTo (Component c);
+ */
+ public abstract void stopListeningTo(Component c);
+
/**
* Determine if the passed component is a container whose children
- * may need to be listened on. Returns false by default.
- *
+ * may need to be listened on. Returns false by default.
+ *
* @param c A component which might be a container
- */
+ */
public boolean isContainer(Component c) {
return false;
}
+
/**
- * Get the map key for this component's value. By default, returns
- * the component's name. Will only
- * be passed components which the accept() method
+ * Get the map key for this component's value. By default, returns
+ * the component's name. Will only
+ * be passed components which the accept() method
* returned true for.
* accept() method
+ * Get the value currently set on the passed component. Will only
+ * be passed components which the accept() method
* returned true for, and which keyFor() returned non-null.
+ *
* @param c the component
+ *
* @return An object representing the current value of this component.
- * For example, if it were a JTextComponent, the value would likely
- * be the return value of JTextComponent.getText()
- */
- public abstract Object valueFor (Component c);
+ * For example, if it were a JTextComponent, the value
+ * would likely
+ * be the return value of JTextComponent.getText()
+ */
+ public abstract Object valueFor(Component c);
}
-
+
/**
- * Object which is passed to CustomComponentListener.startListeningTo(),
+ * Object which is passed to
+ * CustomComponentListener.startListeningTo(),
* which can be called when an event has occurred on a custom component the
- * CustomComponentListener has claimed (by returning true
+ * CustomComponentListener has claimed (by returning
+ * true
* from its accept() method).
- */
+ */
public static abstract class CustomComponentNotifier {
- private CustomComponentNotifier() {}
+
+ private CustomComponentNotifier() {
+ }
+
/**
- * Method which may be called when an event occurred on a custom component.
- * @param c the component
+ * Method which may be called when an event occurred on a custom
+ * component.
+ *
+ * @param c the component
* @param eventObject the event object from the component, or null (with
- * the exception of javax.swing.text.DocumentEvent, it
- * will likely be a subclass of java.util.EventObject).
- */
- public abstract void userInputReceived (Component c, Object eventObject);
+ * the exception of javax.swing.text.DocumentEvent, it
+ * will likely be a subclass of java.util.EventObject).
+ */
+ public abstract void userInputReceived(Component c, Object eventObject);
}
-
+
private static final class CustomComponentNotifierImpl extends CustomComponentNotifier {
+
private final WizardPage page;
- private CustomComponentNotifierImpl (WizardPage page) {
+
+ private CustomComponentNotifierImpl(WizardPage page) {
this.page = page; //Slightly smaller footprint a nested, not inner class
}
-
+
public void userInputReceived(Component c, Object event) {
- if (!page.ccl.accept(c)) {
+ if (!page.ccl.accept(c))
return;
- }
- page.userInputReceived (c, event);
+ page.userInputReceived(c, event);
}
}
-
+
String id() {
return getID();
}
-
+
String description() {
return getDescription();
}
@@ -356,9 +371,8 @@ public class WizardPage extends JPanel implements WizardPanel {
public void addNotify() {
super.addNotify();
- if (!listening) {
+ if (!listening)
startListening();
- }
renderingPage();
inValidateContents = true;
@@ -438,9 +452,10 @@ public class WizardPage extends JPanel implements WizardPanel {
* unique subclass of WizardPage.
*/
public static Wizard createWizard(String title, Class[] wizardPageClasses) {
- return new CWPP(title, wizardPageClasses,
- WizardResultProducer.NO_OP).createWizard();
+ return new CWPP(title, wizardPageClasses,
+ WizardResultProducer.NO_OP).createWizard();
}
+
/**
* Create a simple Wizard from an array of classes, each of which is a
* unique subclass of WizardPage, with a
@@ -451,48 +466,44 @@ public class WizardPage extends JPanel implements WizardPanel {
}
/**
- * Called by createPanelForStep, with whatever map is passed. In the
+ * Called by createPanelForStep, with whatever map is passed. In the
* current impl this is always the same Map, but that is not guaranteed.
* If any content was added by calls to putWizardData() during the
* constructor, etc., such data is copied to the settings map the first
* time this method is called.
*
- * Subclasses do NOT need to override this method,
- * they can override renderPage which is always called AFTER the map has been made valid.
+ * Subclasses do NOT need to override this method,
+ * they can override renderPage which is always called AFTER the map has
+ * been made valid.
*/
void setWizardDataMap(Map m) {
- if (m == null) {
+ if (m == null)
wizardData = new HashMap();
- } else {
- if (wizardData instanceof HashMap) {
+ else {
+ if (wizardData instanceof HashMap)
// our initial map has keys for all of our components
// but with dummy empty values
// So make sure we don't override data that was put in as part of the initialProperties
- for (Iterator iter = wizardData.entrySet().iterator(); iter.hasNext();)
- {
+ for (Iterator iter = wizardData.entrySet().iterator(); iter.hasNext();) {
Map.Entry entry = (Map.Entry) iter.next();
Object key = entry.getKey();
- if ( ! m.containsKey(key))
- {
+ if (!m.containsKey(key))
m.put(key, entry.getValue());
- }
}
- }
wizardData = m;
}
}
/**
- * Set the WizardController. In the current impl, this is always the same
- * object, but the API does not guarantee that. The first time this is
- * called, it will update the state of the passed controller to match
+ * Set the WizardController. In the current impl, this is always the same
+ * object, but the API does not guarantee that. The first time this is
+ * called, it will update the state of the passed controller to match
* any state that was set by components during the construction of this
* component
*/
void setController(WizardController controller) {
- if (controller.getImpl() instanceof WC) {
+ if (controller.getImpl() instanceof WC)
((WC) controller.getImpl()).configure(controller);
- }
this.controller = controller;
}
@@ -506,10 +517,9 @@ public class WizardPage extends JPanel implements WizardPanel {
return controller;
}
-
/**
- * Set the problem string. Call this method if next/finish should be
- * disabled. The passed string will be visible to the user, and should
+ * Set the problem string. Call this method if next/finish should be
+ * disabled. The passed string will be visible to the user, and should
* be a short, localized description of what is wrong.
*/
protected final void setProblem(String value) {
@@ -529,8 +539,8 @@ public class WizardPage extends JPanel implements WizardPanel {
}
/**
- * Disable all navigation. Useful if some background task is being
- * completed during which no navigation should be allowed. Use with care,
+ * Disable all navigation. Useful if some background task is being
+ * completed during which no navigation should be allowed. Use with care,
* as it disables the cancel button as well.
*/
protected final void setBusy(boolean busy) {
@@ -541,7 +551,6 @@ public class WizardPage extends JPanel implements WizardPanel {
* Store a value in response to user interaction with a GUI component.
*/
protected final void putWizardData(Object key, Object value) {
- logger.fine("putWizardData " + key + "=" + value); //NOI18N
getWizardDataMap().put(key, value);
if (!inBeginUIChanged && !inValidateContents) {
inValidateContents = true;
@@ -562,7 +571,8 @@ public class WizardPage extends JPanel implements WizardPanel {
/**
* Retrieve a value stored in the wizard map, which may have been
- * putWizardData there by this panel or any previous panel in the wizard which
+ * putWizardData there by this panel or any previous panel in the wizard
+ * which
* contains this panel.
*/
protected final Object getWizardData(Object key) {
@@ -578,12 +588,12 @@ public class WizardPage extends JPanel implements WizardPanel {
/**
* Called when an event is received from one of the components in the
- * panel that indicates user input. Typically you won't need to touch this
+ * panel that indicates user input. Typically you won't need to touch this
* method, unless your panel contains custom components which are not
* subclasses of any standard Swing component, which the framework won't
- * know how to listen for changes on. For such cases, attach a listener
+ * know how to listen for changes on. For such cases, attach a listener
* to the custom component, and call this method with the event if you want
- * validation to run when input happens. Automatic updating of the
+ * validation to run when input happens. Automatic updating of the
* settings map will not work for such custom components, for obvious
* reasons, so update the settings map, if needed, in validateContents
* for this case.
@@ -594,28 +604,23 @@ public class WizardPage extends JPanel implements WizardPanel {
* DocumentEvent.
*/
protected final void userInputReceived(Component source, Object event) {
- if (inBeginUIChanged) {
- logger.fine("Ignoring recursive entry to userInputReceived while updating map");
+ if (inBeginUIChanged)
return;
- }
//Update the map no matter what
inBeginUIChanged = true;
- if (source != null) {
+ if (source != null)
try {
maybeUpdateMap(source);
} finally {
inBeginUIChanged = false;
}
- }
//Possibly some programmatic change from checkState could cause
//a recursive call
- if (inUiChanged) {
- logger.fine("Ignoring recursive entry to userInputReceieved from validateContents");
+ if (inUiChanged)
return;
- }
inUiChanged = true;
inValidateContents = true;
@@ -632,19 +637,10 @@ public class WizardPage extends JPanel implements WizardPanel {
* component's name property is not null
*/
void maybeUpdateMap(Component comp) {
- if (logger.isLoggable(Level.FINE)) {
- logger.fine("Maybe update map for " + comp.getClass().getName() + //NOI18N
- " named " + comp.getName()); //NOI18N
- }
-
Object mapKey = getMapKeyFor(comp);
// debug: System.err.println("MaybeUpdateMap " + mapKey + " from " + comp);
if (mapKey != null) {
Object value = valueFrom(comp);
- if (logger.isLoggable(Level.FINE)) {
- logger.fine("maybeUpdateMap putting " + mapKey + "," + value +
- " into settings"); //NOI18N
- }
putWizardData(mapKey, value);
}
}
@@ -654,57 +650,52 @@ public class WizardPage extends JPanel implements WizardPanel {
* changes or it is removed from the panel.
*/
void removeFromMap(Object key) {
- logger.fine("removeFromMap: " + key); //NOI18N
getWizardDataMap().remove(key);
}
/**
* Given an ad-hoc swing component, fetch the likely value based on its
- * state. The default implementation handles most common swing components.
+ * state. The default implementation handles most common swing components.
* If you are using custom components and have assigned them names, override
* this method to handle getting an appropriate value out of your
* custom component and call super for the others.
*/
protected Object valueFrom(Component comp) {
- if (ccl != null && ccl.accept(comp)) {
+ if (ccl != null && ccl.accept(comp))
return ccl.valueFor(comp);
- }
- if (comp instanceof JRadioButton || comp instanceof JCheckBox || comp instanceof JToggleButton) {
+ if (comp instanceof JRadioButton || comp instanceof JCheckBox || comp instanceof JToggleButton)
return ((AbstractButton) comp).getModel().isSelected() ? Boolean.TRUE : Boolean.FALSE;
- } else if (comp instanceof JTree) {
+ else if (comp instanceof JTree) {
TreePath path = ((JTree) comp).getSelectionPath();
- if (path != null) {
+ if (path != null)
return path.getLastPathComponent();
- }
- } else if (comp instanceof JFormattedTextField) {
+ } else if (comp instanceof JFormattedTextField)
return ((JFormattedTextField) comp).getValue();
- } else if (comp instanceof JList) {
+ else if (comp instanceof JList) {
Object[] o = ((JList) comp).getSelectedValues();
- if (o != null) {
- if (o.length > 1) {
+ if (o != null)
+ if (o.length > 1)
return o;
- } else if (o.length == 1) {
+ else if (o.length == 1)
return o[0];
- }
- }
- } else if (comp instanceof JTextComponent) {
+ } else if (comp instanceof JTextComponent)
return ((JTextComponent) comp).getText();
- } else if (comp instanceof JComboBox) {
+ else if (comp instanceof JComboBox)
return ((JComboBox) comp).getSelectedItem();
- } else if (comp instanceof JColorChooser) {
+ else if (comp instanceof JColorChooser)
return ((JColorChooser) comp).getSelectionModel().getSelectedColor();
- } else if (comp instanceof JSpinner) {
+ else if (comp instanceof JSpinner)
return ((JSpinner) comp).getValue();
- } else if (comp instanceof JSlider) {
- return new Integer(((JSlider) comp).getValue());
- }
+ else if (comp instanceof JSlider)
+ return ((JSlider) comp).getValue();
return null;
}
/**
- * Given an ad-hoc swing component, set the value as the property
- * from the settings. The default implementation handles most common swing components.
+ * Given an ad-hoc swing component, set the value as the property
+ * from the settings. The default implementation handles most common swing
+ * components.
* If you are using custom components and have assigned them names, override
* this method to handle getting an appropriate value out of your
* custom component and call super for the others.
@@ -714,60 +705,55 @@ public class WizardPage extends JPanel implements WizardPanel {
Object value = settings.get(name);
if (comp instanceof JRadioButton || comp instanceof JCheckBox || comp instanceof JToggleButton) {
if (value instanceof Boolean)
- {
- ((AbstractButton) comp).getModel().setSelected(((Boolean) value).booleanValue());
- }
+ ((AbstractButton) comp).getModel().setSelected(((Boolean) value));
// TOFIX: JTree
- } else if (comp instanceof JFormattedTextField) {
- ((JFormattedTextField) comp).setValue(value);
-// } else if (comp instanceof JTree) {
-// TreePath path = ((JTree) comp).getSelectionPath();
-// if (path != null) {
-// return path.getLastPathComponent();
-// }
- } else if (comp instanceof JList) {
+ } else if (comp instanceof JFormattedTextField)
+ ((JFormattedTextField) comp).setValue(value); // } else if (comp instanceof JTree) {
+ // TreePath path = ((JTree) comp).getSelectionPath();
+ // if (path != null) {
+ // return path.getLastPathComponent();
+ // }
+ else if (comp instanceof JList) {
if (value instanceof Object[])
- {
- throw new IllegalArgumentException ("can't handle multi-select lists");
- }
+ throw new IllegalArgumentException("can't handle multi-select lists");
((JList) comp).setSelectedValue(value, true);
- } else if (comp instanceof JTextComponent) {
+ } else if (comp instanceof JTextComponent)
((JTextComponent) comp).setText((String) value);
- } else if (comp instanceof JComboBox) {
+ else if (comp instanceof JComboBox)
((JComboBox) comp).setSelectedItem(value);
- } else if (comp instanceof JColorChooser) {
- ((JColorChooser) comp).getSelectionModel().setSelectedColor((Color)value);
- } else if (comp instanceof JSpinner) {
+ else if (comp instanceof JColorChooser)
+ ((JColorChooser) comp).getSelectionModel().setSelectedColor((Color) value);
+ else if (comp instanceof JSpinner)
((JSpinner) comp).setValue(value);
- } else if (comp instanceof JSlider) {
- ((JSlider) comp).setValue(((Integer)value).intValue());
- }
+ else if (comp instanceof JSlider)
+ ((JSlider) comp).setValue(((Integer) value));
}
/**
* Get the map key that should be used to automatically put the value
* represented by this component into the wizard data map.
* c.getName(),
+ * The default implementation returns the result of
+ * c.getName(),
* which is almost always sufficient and convenient - just set the
* component names in a GUI builder and everything will be handled.
*
* @return null if the component's value should not be automatically
* written to the wizard data map, or an object which is the key that
- * later code will use to find this value. By default, it returns the
+ * later code will use to find this value. By default, it returns the
* component's name.
*/
protected Object getMapKeyFor(Component c) {
- if (ccl != null && ccl.accept(c)) {
+ if (ccl != null && ccl.accept(c))
return ccl.keyFor(c);
- } else {
+ else
return c.getName();
- }
}
/**
- * Called when user interaction has occurred on a component contained by this
- * panel or one of its children. Override this method to check if all of
+ * Called when user interaction has occurred on a component contained by
+ * this
+ * panel or one of its children. Override this method to check if all of
* the values are legal, such that the Next/Finish button should be enabled,
* optionally calling setForwardNavigationMode() if warranted.
*
@@ -776,8 +762,10 @@ public class WizardPage extends JPanel implements WizardPanel {
* this method.
*
* Note that this method may be called very frequently, so it is important
- * that validation code be fast. For cases such as DocumentEvents,
- * it may be desirable to delay validation with a timer, if the implementation
+ * that validation code be fast. For cases such as
+ * DocumentEvents,
+ * it may be desirable to delay validation with a timer, if the
+ * implementation
* of this method is too expensive to call on each keystroke.
*
* Either the component, or the event, or both may be null on some calls
@@ -787,15 +775,16 @@ public class WizardPage extends JPanel implements WizardPanel {
* The default implementation returns null.
*
* @param component The component the user interacted with, if it can be
- * determined. The infrastructure does track the owners of list models
+ * determined. The infrastructure does track the owners of list models
* and such, and can find the associated component, so this will usually
* (but not necessarily) be non-null.
* @param event The event object (if any) that triggered this call to
- * validateContents. For most cases this will be an instance of
+ * validateContents. For most cases this will be an instance of
* EventObject, and can be used to directly detect what component
- * the user interacted with. Since javax.swing.text.DocumentEvent is
+ * the user interacted with. Since javax.swing.text.DocumentEvent is
* not a subclass of EventObject, the type of the argument is Object,
* so these events may be passed.
+ *
* @return A localized string describing why navigation should be disabled,
* or null if the state of the components is valid and forward navigation
* should be enabled.
@@ -826,50 +815,50 @@ public class WizardPage extends JPanel implements WizardPanel {
*/
// the map is empty during construction, then later set to the map from the containing WizardController
protected Map getWizardDataMap() {
- if (wizardData == null) {
+ if (wizardData == null)
wizardData = new HashMap();
- }
return wizardData;
}
-
+
private String longDescription;
+
/**
- * Set the long description of this page. This method may be called
+ * Set the long description of this page. This method may be called
* only once and should be called from within the constructor.
+ *
* @param desc The long description for this step
- */
+ */
protected void setLongDescription(String desc) {
- if (!Beans.isDesignTime() && this.longDescription != null) {
- throw new IllegalStateException ("Long description already set to" +
- " " + desc);
- }
+ if (!Beans.isDesignTime() && this.longDescription != null)
+ throw new IllegalStateException("Long description already set to"
+ + " " + desc);
this.longDescription = desc;
}
-
+
/**
* Get the long description of this page, which should be used in the title
- * area of the wizard's UI if non-null. To use, call setLongDescription()
- * in your WizardPage's constructor. It may be set only once.
- *
+ * area of the wizard's UI if non-null. To use, call setLongDescription()
+ * in your WizardPage's constructor. It may be set only once.
+ *
* @return the description
- */
+ */
public final String getLongDescription() {
return longDescription;
}
- static WizardPanelProvider createWizardPanelProvider (WizardPage page) {
- return new WPP (new WizardPage[] { page }, WizardResultProducer.NO_OP);
+ static WizardPanelProvider createWizardPanelProvider(WizardPage page) {
+ return new WPP(new WizardPage[] { page }, WizardResultProducer.NO_OP);
}
- static WizardPanelProvider createWizardPanelProvider (WizardPage[] page) {
- return new WPP (page, WizardResultProducer.NO_OP);
+ static WizardPanelProvider createWizardPanelProvider(WizardPage[] page) {
+ return new WPP(page, WizardResultProducer.NO_OP);
}
-
/**
* WizardPanelProvider that takes an array of already created WizardPages
*/
static final class WPP extends WizardPanelProvider {
+
private final WizardPage[] pages;
private final WizardResultProducer finish;
@@ -882,14 +871,10 @@ public class WizardPage extends JPanel implements WizardPanel {
// assert finish != null;
String v = valid(pages);
if (v != null)
- {
- throw new RuntimeException (v);
- }
+ throw new RuntimeException(v);
if (finish == null)
- {
- throw new RuntimeException ("finish must not be null");
- }
-
+ throw new RuntimeException("finish must not be null");
+
this.pages = pages;
this.finish = finish;
}
@@ -903,14 +888,9 @@ public class WizardPage extends JPanel implements WizardPanel {
// assert finish != null;
String v = valid(pages);
if (v != null)
- {
- throw new RuntimeException (v);
- }
+ throw new RuntimeException(v);
if (finish == null)
- {
- throw new RuntimeException ("finish must not be null");
- }
-
+ throw new RuntimeException("finish must not be null");
this.pages = pages;
this.finish = finish;
@@ -920,11 +900,9 @@ public class WizardPage extends JPanel implements WizardPanel {
Map wizardData) {
int idx = indexOfStep(id);
- // assert idx != -1 : "Bad ID passed to createPanel: " + id; //NOI18N
+ // assert idx != -1 : "Bad ID passed to createPanel: " + id;
if (idx == -1)
- {
- throw new RuntimeException ("Bad ID passed to createPanel: " + id); //NOI18N
- }
+ throw new RuntimeException("Bad ID passed to createPanel: " + id);
pages[idx].setController(controller);
pages[idx].setWizardDataMap(wizardData);
@@ -935,16 +913,13 @@ public class WizardPage extends JPanel implements WizardPanel {
* Make sure we haven't been passed bogus data
*/
private String valid(WizardPage[] pages) {
- if (new HashSet(Arrays.asList(pages)).size() != pages.length) {
- return "Duplicate entry in array: " + //NOI18N
- Arrays.asList(pages);
- }
+ if (new HashSet(Arrays.asList(pages)).size() != pages.length)
+ return "Duplicate entry in array: "
+ + Arrays.asList(pages);
- for (int i = 0; i < pages.length; i++) {
- if (pages[i] == null) {
- return "Null entry at " + i + " in pages array"; //NOI18N
- }
- }
+ for (int i = 0; i < pages.length; i++)
+ if (pages[i] == null)
+ return "Null entry at " + i + " in pages array";
return null;
}
@@ -954,16 +929,13 @@ public class WizardPage extends JPanel implements WizardPanel {
}
public boolean cancel(Map settings) {
- return finish.cancel (settings);
+ return finish.cancel(settings);
}
-
+
public String getLongDescription(String stepId) {
- for (int i = 0; i < pages.length; i++) {
- WizardPage wizardPage = pages[i];
- if (stepId.equals(wizardPage.getID())) {
+ for (WizardPage wizardPage : pages)
+ if (stepId.equals(wizardPage.getID()))
return wizardPage.getLongDescription();
- }
- }
return null;
}
}
@@ -973,6 +945,7 @@ public class WizardPage extends JPanel implements WizardPanel {
* instantiates them on demand
*/
private static final class CWPP extends WizardPanelProvider {
+
private final Class[] classes;
private final WizardResultProducer finish;
private final String[] longDescriptions;
@@ -983,34 +956,27 @@ public class WizardPage extends JPanel implements WizardPanel {
// assert new HashSet(Arrays.asList(classes)).size() == classes.length :
// "Duplicate entries in class array";
// assert finish != null : "WizardResultProducer may not be null";
-
- _validateArgs (classes, finish);
+
+ _validateArgs(classes, finish);
this.finish = finish;
this.classes = classes;
- longDescriptions = new String [ classes.length ];
+ longDescriptions = new String[classes.length];
}
- private void _validateArgs (Class [] classes, WizardResultProducer finish)
- {
+ private void _validateArgs(Class[] classes, WizardResultProducer finish) {
// assert classes != null : "Class array may not be null";
// assert new HashSet(Arrays.asList(classes)).size() == classes.length :
// "Duplicate entries in class array";
// assert finish != null : "WizardResultProducer may not be null";
if (classes == null)
- {
- throw new RuntimeException ("Class array may not be null");
- }
- if ( new HashSet(Arrays.asList(classes)).size() != classes.length)
- {
- throw new RuntimeException ("Duplicate entries in class array");
- }
+ throw new RuntimeException("Class array may not be null");
+ if (new HashSet(Arrays.asList(classes)).size() != classes.length)
+ throw new RuntimeException("Duplicate entries in class array");
if (finish == null)
- {
- throw new RuntimeException ("WizardResultProducer may not be null");
- }
+ throw new RuntimeException("WizardResultProducer may not be null");
}
-
+
CWPP(Class[] classes, WizardResultProducer finish) {
super(Util.getSteps(classes), Util.getDescriptions(classes));
@@ -1018,67 +984,62 @@ public class WizardPage extends JPanel implements WizardPanel {
// assert new HashSet(Arrays.asList(classes)).size() == classes.length :
// "Duplicate entries in class array";
// assert finish != null : "WizardResultProducer may not be null";
-
- longDescriptions = new String [ classes.length ];
- _validateArgs (classes, finish);
+ longDescriptions = new String[classes.length];
+ _validateArgs(classes, finish);
this.classes = classes;
this.finish = finish;
}
-
protected JComponent createPanel(WizardController controller, String id, Map wizardData) {
int idx = indexOfStep(id);
- // assert idx != -1 : "Bad ID passed to createPanel: " + id; //NOI18N
+ // assert idx != -1 : "Bad ID passed to createPanel: " + id;
if (idx == -1)
- {
- throw new RuntimeException ( "Bad ID passed to createPanel: " + id); //NOI18N
- }
+ throw new RuntimeException("Bad ID passed to createPanel: " + id);
try {
WizardPage result = (WizardPage) classes[idx].newInstance();
longDescriptions[idx] = result.getLongDescription();
-
+
result.setController(controller);
result.setWizardDataMap(wizardData);
return result;
} catch (Exception e) {
- logger.log(Level.WARNING, "Could not instantiate " + classes[idx], e);
// really IllegalArgumentException, but we need to have the "cause" get shown in stack trace
- throw new RuntimeException("Could not instantiate " + //NOI18N
- classes[idx], e);
+ throw new RuntimeException("Could not instantiate "
+ + classes[idx], e);
}
}
protected Object finish(Map settings) throws WizardException {
return finish.finish(settings);
}
-
+
public boolean cancel(Map settings) {
return finish.cancel(settings);
}
-
+
public String toString() {
return super.toString() + " for " + finish;
}
-
+
public String getLongDescription(String stepId) {
- int idx = indexOfStep (stepId);
- if (idx != -1) {
- return longDescriptions[idx] == null ? descriptions [idx] :
- longDescriptions[idx];
- }
+ int idx = indexOfStep(stepId);
+ if (idx != -1)
+ return longDescriptions[idx] == null ? descriptions[idx]
+ : longDescriptions[idx];
return null;
}
}
/**
* A dummy wizard controller which is used until the panel has actually
- * been put into use; so state can be set during the constructor, etc.
+ * been put into use; so state can be set during the constructor, etc.
* Its state will be dumped into the real one once there is a real one.
*/
private static final class WC implements WizardControllerImplementation {
+
private String problem = null;
private int canFinish = -1;
private Boolean busy = null;
@@ -1089,12 +1050,12 @@ public class WizardPage extends JPanel implements WizardPanel {
public void setForwardNavigationMode(int value) {
switch (value) {
- case WizardController.MODE_CAN_CONTINUE :
- case WizardController.MODE_CAN_FINISH :
- case WizardController.MODE_CAN_CONTINUE_OR_FINISH :
- break;
- default :
- throw new IllegalArgumentException(Integer.toString(value));
+ case WizardController.MODE_CAN_CONTINUE:
+ case WizardController.MODE_CAN_FINISH:
+ case WizardController.MODE_CAN_CONTINUE_OR_FINISH:
+ break;
+ default:
+ throw new IllegalArgumentException(Integer.toString(value));
}
canFinish = value;
@@ -1105,55 +1066,62 @@ public class WizardPage extends JPanel implements WizardPanel {
}
void configure(WizardController other) {
- if (other == null) {
+ if (other == null)
return;
- }
- if (busy != null) {
- other.setBusy(busy.booleanValue());
- }
+ if (busy != null)
+ other.setBusy(busy);
- if (canFinish != -1) {
+ if (canFinish != -1)
other.setForwardNavigationMode(canFinish);
- }
- if (problem != null) {
+ if (problem != null)
other.setProblem(problem);
- }
}
}
/**
- * Interface that is passed to WizardPage.createWizard(). For wizards
+ * Interface that is passed to WizardPage.createWizard(). For wizards
* created from a set of WizardPages or WizardPage subclasses, this is
* the object that whose code will be run to create or do whatever the
* wizard does when the user clicks the Finish button.
*/
public static interface WizardResultProducer {
+
/**
* Conclude a wizard, doing whatever the wizard does with the data
* gathered into the map on the various panels.
* Summary is returned from this method, the
- * UI shall display it on a final page and disable all navigation buttons
+ * If an instance of Summary is returned from this method,
+ * the
+ * UI shall display it on a final page and disable all navigation
+ * buttons
* except the Close/Cancel button.
* DeferredWizardResult is returned from this
- * method, the UI shall display some sort of progress bar while the result
- * is computed in the background. If that DeferredWizardResult
- * produces a Summary object, that summary shall be displayed
+ * If an instance of DeferredWizardResult is returned from
+ * this
+ * method, the UI shall display some sort of progress bar while the
+ * result
+ * is computed in the background. If that
+ * DeferredWizardResult
+ * produces a Summary object, that summary shall be
+ * displayed
* as described above.
+ *
* @param wizardData the map with key-value pairs which has been
- * populated by the UI as the user progressed through the wizard
- * @return an object composed based on what the user entered in the wizard -
- * somethingmeaningful to whatever code invoked the wizard, or null. Note
- * special handling if an instance of DeferredWizardResult
- * or Summary is returned from this method.
+ * populated by the UI as the user progressed through the wizard
+ *
+ * @return an object composed based on what the user entered in the
+ * wizard -
+ * somethingmeaningful to whatever code invoked the wizard, or null.
+ * Note
+ * special handling if an instance of DeferredWizardResult
+ * or Summary is returned from this method.
*/
Object finish(Map wizardData) throws WizardException;
/**
- * Called when the user presses the cancel button. Almost all
+ * Called when the user presses the cancel button. Almost all
* implementations will want to return true.
*/
boolean cancel(Map settings);
@@ -1166,10 +1134,10 @@ public class WizardPage extends JPanel implements WizardPanel {
return wizardData;
}
- public boolean cancel (Map settings) {
+ public boolean cancel(Map settings) {
return true;
}
-
+
public String toString() {
return "NO_OP WizardResultProducer";
}
diff --git a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/views/wizard/spi/WizardPanel.java b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/views/wizard/spi/WizardPanel.java
index 875cfd586..d40a74058 100644
--- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/views/wizard/spi/WizardPanel.java
+++ b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/views/wizard/spi/WizardPanel.java
@@ -5,8 +5,7 @@ compliance with the License.
or http://www.netbeans.org/cddl.txt.
When distributing Covered Code, include this CDDL Header Notice in each file
and include the License file at http://www.netbeans.org/cddl.txt.
-*/
-
+ */
package org.jackhuang.hellominecraft.utils.views.wizard.spi;
import java.util.Map;
@@ -14,76 +13,85 @@ import java.util.Map;
/**
* This is an optional interface for panels that want to be notified when
* the next and back buttons are pressed.
- *
+ *
* The WizardPanelProvider is NOT required to create panels that implement
* this interface.
- *
+ *
* Each of these methods returns a WizardPanelNavResult that can be used to
* indicate PROCEED or REMAIN_ON_PAGE.
- *
+ *
* The result can also be an instance of a subclass of WizardPanelNavResult
* that implements the start method to use a background thread
- * to determine if the next page can be shown.
- *
+ * to determine if the next page can be shown.
+ *
* @author stanley@stanleyknutson.com
*/
-public interface WizardPanel
-{
+public interface WizardPanel {
+
/**
* This method is invoked when the "next" button has been pushed,
* to do a final validation of input (such as doing a database login).
- *
- * If this method return false, then the "next" button will not change the
- * displayed panel. Presumably some error will have been shown to the user.
- *
+ *
+ * If this method return false, then the "next" button will not change the
+ * displayed panel. Presumably some error will have been shown to the user.
+ *
* @param stepName
* @param settings
* @param wizard
+ *
* @return WizardPanelNavResult.PROCEED if the "next" button should proceed,
- * WizardPanelNavResult.REMAIN_ON_PAGE if "next" should not proceed,
- * or a instance of subclass of WizardPanelResult that will do some background computation
- * and call the progress.finished method with one of those constants
- * (or call progress.failed with the error message)
+ * WizardPanelNavResult.REMAIN_ON_PAGE if "next" should not proceed,
+ * or a instance of subclass of WizardPanelResult that will do some
+ * background computation
+ * and call the progress.finished method with one of those constants
+ * (or call progress.failed with the error message)
*/
- public WizardPanelNavResult allowNext (String stepName, Map settings, Wizard wizard);
+ public WizardPanelNavResult allowNext(String stepName, Map settings, Wizard wizard);
/**
* This method is invoked when the "back" button has been pushed,
- * to discard any data from the setings that will not been needed and for which the
+ * to discard any data from the setings that will not been needed and for
+ * which the
* normal "just hide that data" is not the desired behavior.
* (See MergeMap for discussion of the "hide the data" behavior)
- *
- * If this method return false, then the "next" button will not change the
- * displayed panel. Presumably some error will have been shown to the user.
- *
+ *
+ * If this method return false, then the "next" button will not change the
+ * displayed panel. Presumably some error will have been shown to the user.
+ *
* @param stepName
* @param settings
* @param wizard
+ *
* @return WizardPanelNavResult.PROCEED if the "back" button should proceed,
- * WizardPanelNavResult.REMAIN_ON_PAGE if "back" should not proceed,
- * or a instance of subclass of WizardPanelResult that will do some background computation
- * and call the progress.finished method with one of those constants.
- * (or call progress.failed with the error message)
+ * WizardPanelNavResult.REMAIN_ON_PAGE if "back" should not proceed,
+ * or a instance of subclass of WizardPanelResult that will do some
+ * background computation
+ * and call the progress.finished method with one of those constants.
+ * (or call progress.failed with the error message)
*/
- public WizardPanelNavResult allowBack (String stepName, Map settings, Wizard wizard);
+ public WizardPanelNavResult allowBack(String stepName, Map settings, Wizard wizard);
/**
* This method is invoked when the "finish" button has been pushed,
- * to allow veto of the finish action BEFORE the wizard finish method is invoked.
- *
- * If this method return false, then the "finish" button will have no effect.
+ * to allow veto of the finish action BEFORE the wizard finish method is
+ * invoked.
+ *
+ * If this method return false, then the "finish" button will have no
+ * effect.
* Presumably some error will have been shown to the user.
- *
+ *
* @param stepName
* @param settings
* @param wizard
- * @return WizardPanelNavResult.PROCEED if the "finish" button should proceed,
- * WizardPanelNavResult.REMAIN_ON_PAGE if "finish" should not proceed,
- * or a instance of subclass of WizardPanelResult that will do some background computation
- * and call the progress.finished method with one of those constants.
- * (or call progress.failed with the error message)
+ *
+ * @return WizardPanelNavResult.PROCEED if the "finish" button should
+ * proceed,
+ * WizardPanelNavResult.REMAIN_ON_PAGE if "finish" should not proceed,
+ * or a instance of subclass of WizardPanelResult that will do some
+ * background computation
+ * and call the progress.finished method with one of those constants.
+ * (or call progress.failed with the error message)
*/
- public WizardPanelNavResult allowFinish (String stepName, Map settings, Wizard wizard);
+ public WizardPanelNavResult allowFinish(String stepName, Map settings, Wizard wizard);
}
-