From fee3e5251d21bedd45bd95059f36a43befd4db1b Mon Sep 17 00:00:00 2001 From: huangyuhui Date: Tue, 26 Jan 2016 20:17:05 +0800 Subject: [PATCH] Try to fix warnings by NetBeans --- .../launcher/views/modpack/ModpackWizard.java | 2 +- .../views/wizard/api/WizardDisplayer.java | 10 +- .../api/displayer/NavButtonManager.java | 13 +- .../wizard/api/displayer/NavProgress.java | 12 +- .../api/displayer/WizardDisplayerImpl.java | 30 +- .../wizard/modules/InstructionsPanelImpl.java | 82 ++- .../utils/views/wizard/modules/MergeMap.java | 175 +++-- .../views/wizard/spi/BranchingWizard.java | 169 ++--- .../views/wizard/spi/GenericListener.java | 256 +++---- .../views/wizard/spi/SimpleWizardInfo.java | 18 +- .../utils/views/wizard/spi/Summary.java | 165 +++-- .../utils/views/wizard/spi/Util.java | 100 ++- .../utils/views/wizard/spi/Wizard.java | 230 ++++--- .../utils/views/wizard/spi/WizardPage.java | 622 +++++++++--------- .../utils/views/wizard/spi/WizardPanel.java | 86 +-- 15 files changed, 907 insertions(+), 1063 deletions(-) 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. *

* Wizards with arbitrary numbers of branches can be handled by a @@ -38,8 +37,9 @@ import java.util.Map; * @author Tim Boudreau */ final class BranchingWizard implements WizardImplementation { - private final List listenerList = Collections.synchronizedList ( - new LinkedList()); + + private final List listenerList = Collections.synchronizedList( + new LinkedList()); private final WizardBranchController brancher; final WizardImplementation initialSteps; @@ -63,70 +63,63 @@ final class BranchingWizard implements WizardImplementation { } private void checkForSecondary() { - if (wizardData == null) { + if (wizardData == null) return; - } WizardImplementation newSecondary = createSecondary(wizardData); - /* + /* * johnflournoy 7/20/07 * check for secondary should be adding the secondary to the activeWizard * not the initial wizard. Adding it to the initial wizard was breaking * multiple branching - to accomplish this created a new method: * setSecondary() */ - if (activeWizard instanceof BranchingWizard) { + if (activeWizard instanceof BranchingWizard) ((BranchingWizard) activeWizard).setSecondary(newSecondary); - } else { - this.setSecondary(newSecondary); - } + else + this.setSecondary(newSecondary); } - + /** - * Set the secondary for this 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 /* */ used) { + + static String uniquify(String s, Set /* */ used) { String test = s; if (test != null) { int ix = 0; - while (used.contains(test)) { + while (used.contains(test)) test = s + "_" + ix++; - } } return test; } @@ -56,24 +56,22 @@ final class Util { for (int i = 0; i < pages.length; i++) { result[i] = pages[i].description(); - if (result[i] == null) { - result[i] = getDescriptionFromStaticMethod (pages[i].getClass()); - } + if (result[i] == null) + result[i] = getDescriptionFromStaticMethod(pages[i].getClass()); } return result; } - static String getIDFromStaticMethod (Class clazz) { + static String getIDFromStaticMethod(Class clazz) { // System.err.println("GetID by method for " + clazz); String result = null; try { Method m = clazz.getDeclaredMethod("getStep", new Class[] {}); // assert m.getReturnType() == String.class; result = (String) m.invoke(clazz, (Object[]) null); - if (result == null) { - throw new NullPointerException ("getStep may not return null"); - } + if (result == null) + throw new NullPointerException("getStep may not return null"); } catch (Exception ex) { //do nothing } @@ -85,27 +83,23 @@ final class Util { * class object passed */ static String[] getSteps(Class[] pages) { - if (pages == null) { - throw new NullPointerException("Null array of classes"); //NOI18N - } + if (pages == null) + throw new NullPointerException("Null array of classes"); String[] result = new String[pages.length]; - Set used = new HashSet (pages.length); + Set used = new HashSet(pages.length); for (int i = 0; i < pages.length; i++) { - if (pages[i] == null) { - throw new NullPointerException("Null at " + i + " in array " + //NOI18N - "of panel classes"); //NOI18N - } + if (pages[i] == null) + throw new NullPointerException("Null at " + i + " in array " + + "of panel classes"); - if (!WizardPage.class.isAssignableFrom(pages[i])) { - throw new IllegalArgumentException(pages[i] + - " is not a subclass of WizardPage"); //NOI18N - } - result[i] = uniquify (getIDFromStaticMethod (pages[i]), used); - if (result[i] == null) { + if (!WizardPage.class.isAssignableFrom(pages[i])) + throw new IllegalArgumentException(pages[i] + + " is not a subclass of WizardPage"); + result[i] = uniquify(getIDFromStaticMethod(pages[i]), used); + if (result[i] == null) result[i] = pages[i].getName(); - } } // System.err.println("Returning " + Arrays.asList(result)); return result; @@ -120,7 +114,6 @@ final class Util { // return false; // } // } - /** * Get an array of descriptions by looking for the static method * getDescription() on each passed class object @@ -128,9 +121,8 @@ final class Util { static String[] getDescriptions(Class[] pages) { String[] result = new String[pages.length]; - for (int i = 0; i < pages.length; i++) { + for (int i = 0; i < pages.length; i++) result[i] = getDescriptionFromStaticMethod(pages[i]); - } return result; } @@ -139,35 +131,33 @@ final class Util { String result = null; Method m; try { - m = clazz.getDeclaredMethod("getDescription", (Class[]) null); //NOI18N + m = clazz.getDeclaredMethod("getDescription", (Class[]) null); } catch (Exception e) { - throw new IllegalArgumentException("Could not find or access " + //NOI18N - "public static String " + clazz.getName() + //NOI18N - ".getDescription() - make sure it exists"); //NOI18N + throw new IllegalArgumentException("Could not find or access " + + "public static String " + clazz.getName() + + ".getDescription() - make sure it exists"); } - if (m.getReturnType() != String.class) { - throw new IllegalArgumentException("getStep has wrong " //NOI18N - + " return type: " + m.getReturnType() + " on " + //NOI18N - clazz); - } + if (m.getReturnType() != String.class) + throw new IllegalArgumentException("getStep has wrong " + + " return type: " + m.getReturnType() + " on " + + clazz); - if (!Modifier.isStatic(m.getModifiers())) { - throw new IllegalArgumentException("getStep is not " + //NOI18N - "static on " + clazz); //NOI18N - } + if (!Modifier.isStatic(m.getModifiers())) + throw new IllegalArgumentException("getStep is not " + + "static on " + clazz); try { m.setAccessible(true); - result= (String) m.invoke(null, (Object[]) null); + result = (String) m.invoke(null, (Object[]) null); } catch (InvocationTargetException ite) { - throw new IllegalArgumentException("Could not invoke " + //NOI18N - "public static String " + clazz.getName() + //NOI18N - ".getDescription() - make sure it exists."); //NOI18N + throw new IllegalArgumentException("Could not invoke " + + "public static String " + clazz.getName() + + ".getDescription() - make sure it exists."); } catch (IllegalAccessException iae) { - throw new IllegalArgumentException("Could not invoke " + //NOI18N - "public static String " + clazz.getName() + //NOI18N - ".getDescription() - make sure it exists."); //NOI18N + throw new IllegalArgumentException("Could not invoke " + + "public static String " + clazz.getName() + + ".getDescription() - make sure it exists."); } return result; } diff --git a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/views/wizard/spi/Wizard.java b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/views/wizard/spi/Wizard.java index bf735b8fb..be25251e2 100644 --- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/views/wizard/spi/Wizard.java +++ b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/utils/views/wizard/spi/Wizard.java @@ -8,7 +8,6 @@ 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]" */ - package org.jackhuang.hellominecraft.utils.views.wizard.spi; import java.awt.Rectangle; @@ -21,33 +20,35 @@ import javax.swing.JComponent; import org.jackhuang.hellominecraft.utils.views.wizard.api.WizardDisplayer; /** - * Encapsulates the logic and state of a Wizard. A Wizard gathers information + * Encapsulates the logic and state of a Wizard. A Wizard gathers information * into a Map, and then performs some action with that information when the - * user clicks Finish. To display a wizard, pass it to one of the methods + * user clicks Finish. To display a wizard, pass it to one of the methods * on 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: *