From dfc6e91321c4230c414937f026d647f1609b5b1c Mon Sep 17 00:00:00 2001 From: huangyuhui Date: Sun, 28 Feb 2016 14:47:31 +0800 Subject: [PATCH] Adds some suggested files to remove --- .../launcher/core/mod/ModpackManager.java | 4 +- .../launcher/ui/modpack/ModpackWizard.java | 3 +- .../hellominecraft/util/system/ZipEngine.java | 2 + .../ui/wizard/api/displayer/NavProgress.java | 14 ++- .../util/ui/wizard/spi/SimpleWizardInfo.java | 6 +- .../ui/wizard/spi/WizardBranchController.java | 118 ++++++++++-------- 6 files changed, 83 insertions(+), 64 deletions(-) diff --git a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/core/mod/ModpackManager.java b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/core/mod/ModpackManager.java index 592309ab4..186c14b48 100644 --- a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/core/mod/ModpackManager.java +++ b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/core/mod/ModpackManager.java @@ -202,8 +202,8 @@ public final class ModpackManager { } - public static final List MODPACK_BLACK_LIST = Arrays.asList(new String[] { "usernamecache.json", "asm", "logs", "backups", "versions", "assets", "usercache.json", "libraries", "crash-reports", "launcher_profiles.json", "NVIDIA", "AMD", "TCNodeTracker", "screenshots", "natives", "native", "$native", "pack.json", "launcher.jar", "launcher.pack.lzma", "hmclmc.log" }); - public static final List MODPACK_SUGGESTED_BLACK_LIST = Arrays.asList(new String[] { "saves", "servers.dat", "options.txt", "optionsshaders.txt", "mods/VoxelMods" }); + public static final List MODPACK_BLACK_LIST = Arrays.asList(new String[] { "usernamecache.json", "asm", "logs", "backups", "versions", "assets", "usercache.json", "libraries", "crash-reports", "launcher_profiles.json", "NVIDIA", "AMD", "TCNodeTracker", "screenshots", "natives", "native", "$native", "pack.json", "launcher.jar", "minetweaker.log", "launcher.pack.lzma", "hmclmc.log" }); + public static final List MODPACK_SUGGESTED_BLACK_LIST = Arrays.asList(new String[] { "fonts", "saves", "servers.dat", "options.txt", "optionsof.txt", "journeymap", "optionsshaders.txt", "mods/VoxelMods" }); /** * < String, Boolean, Boolean >: Folder/File name, Is Directory, diff --git a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/ui/modpack/ModpackWizard.java b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/ui/modpack/ModpackWizard.java index 86f8c1c26..10cebdaac 100644 --- a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/ui/modpack/ModpackWizard.java +++ b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/ui/modpack/ModpackWizard.java @@ -178,8 +178,7 @@ public class ModpackWizard extends WizardBranchController { throw new IllegalArgumentException(id); } } - } - ); + }); } @Override diff --git a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/util/system/ZipEngine.java b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/util/system/ZipEngine.java index 76d655cc6..7d85988ef 100644 --- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/util/system/ZipEngine.java +++ b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/util/system/ZipEngine.java @@ -100,6 +100,8 @@ public class ZipEngine { zos.putNextEntry(new ZipEntry(pathName)); putDirectoryImpl(file, basePath, pathNameCallback); } else { + if (".DS_Store".equals(file.getName())) // For mac computers. + continue; pathName = file.getPath().substring(basePath.length() + 1); if (pathNameCallback != null) pathName = pathNameCallback.apply(pathName, false); diff --git a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/util/ui/wizard/api/displayer/NavProgress.java b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/util/ui/wizard/api/displayer/NavProgress.java index 9fa51c750..df44ba0b8 100644 --- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/util/ui/wizard/api/displayer/NavProgress.java +++ b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/util/ui/wizard/api/displayer/NavProgress.java @@ -64,16 +64,18 @@ public class NavProgress implements ResultProgressHandle { public void setProgress(final int currentStep, final int totalSteps) { invoke(() -> { - if (totalSteps == -1) - progressBar.setIndeterminate(true); - else { + if (totalSteps == -1) { + if (!progressBar.isIndeterminate()) + progressBar.setIndeterminate(true); + } else { if (currentStep > totalSteps || currentStep < 0) { if (currentStep == -1 && totalSteps == -1) return; throw new IllegalArgumentException("Bad step values: " + currentStep + " out of " + totalSteps); } - progressBar.setIndeterminate(false); + if (progressBar.isIndeterminate()) + progressBar.setIndeterminate(false); progressBar.setMaximum(totalSteps); progressBar.setValue(currentStep); } @@ -83,8 +85,8 @@ public class NavProgress implements ResultProgressHandle { public void setBusy(final String description) { invoke(() -> { lbl.setText(description == null ? " " : description); - - progressBar.setIndeterminate(true); + if (!progressBar.isIndeterminate()) + progressBar.setIndeterminate(true); }); } diff --git a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/util/ui/wizard/spi/SimpleWizardInfo.java b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/util/ui/wizard/spi/SimpleWizardInfo.java index b02359885..507e150fa 100644 --- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/util/ui/wizard/spi/SimpleWizardInfo.java +++ b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/util/ui/wizard/spi/SimpleWizardInfo.java @@ -36,7 +36,7 @@ import javax.swing.JTextArea; * SimpleWizard created for it, acting as the WizardController for * calls to WizardPanelProvider.createPanel(). */ -final class SimpleWizardInfo implements WizardControllerImplementation { +public final class SimpleWizardInfo implements WizardControllerImplementation { private WeakReference wizard = null; private final String[] descriptions; @@ -318,4 +318,8 @@ final class SimpleWizardInfo implements WizardControllerImplementation { boolean cancel(Map settings) { return provider.cancel(settings); } + + public WizardPanelProvider getProvider() { + return provider; + } } diff --git a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/util/ui/wizard/spi/WizardBranchController.java b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/util/ui/wizard/spi/WizardBranchController.java index b6aff33c8..ebc1598a9 100644 --- a/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/util/ui/wizard/spi/WizardBranchController.java +++ b/HMCLAPI/src/main/java/org/jackhuang/hellominecraft/util/ui/wizard/spi/WizardBranchController.java @@ -8,113 +8,123 @@ 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]" */ -/* + /* * WizardBranchController.java * * Created on March 5, 2005, 6:33 PM */ - package org.jackhuang.hellominecraft.util.ui.wizard.spi; + import java.util.Map; /** - * Extend this class to create wizards which have branch points in them - - * either override getWizardForStep to return one or another a wizard which - * represents the subsequent steps after a decision point, or override - * getPanelProviderForStep to provide instances of WizardPanelProvider - * if there are no subsequent branch points and the continuation is a + * Extend this class to create wizards which have branch points in them - + * either override getWizardForStep to return one or another a + * wizard which + * represents the subsequent steps after a decision point, or override + * getPanelProviderForStep to provide instances of + * WizardPanelProvider + * if there are no subsequent branch points and the continuation is a * simple wizard. *

* The basic idea is to supply a base wizard for the initial steps, stopping - * at the branch point. The panel for the branch point should put enough - * information into the settings map that the WizardBranchController can + * at the branch point. The panel for the branch point should put enough + * information into the settings map that the WizardBranchController can * decide what to return as the remaining steps of the wizard. *

- * The result is a Wizard which embeds sub-wizards; when the + * The result is a Wizard which embeds sub-wizards; when the * PanelProvider passed to the constructor runs out of steps, * the master Wizard will try to find a sub-Wizard - * by calling getWizardForStep. If non-null, the user seamlessly - * continues in the returned wizard. To create Wizards with + * by calling getWizardForStep. If non-null, the user seamlessly + * continues in the returned wizard. To create Wizards with * multiple branches, simply override getWizardForStep to create * another WizardBranchController and return the result of its * createWizard method. *

- * Note that it is important to cache the instances of WizardPanelProvider + * Note that it is important to cache the instances of + * WizardPanelProvider * or Wizard which are returned here - this class's methods may * be called frequently to determine if the sequence of steps (the next wizard) * have changed. - * + * * @author Tim Boudreau */ public abstract class WizardBranchController { + private final SimpleWizardInfo base; /** - * Create a new WizardBranchController. The base argument + * Create a new WizardBranchController. The base argument * provides the initial step(s) of the wizard up; when the user comes to * the last step of the base wizard, this WizardBranchController will be - * asked for a wizard to provide subsequent panes. So the base wizard + * asked for a wizard to provide subsequent panes. So the base wizard * should put some token into the settings map based on what the user * selects on its final pane, which the WizardBranchController can use * to decide what the next steps should be. */ - protected WizardBranchController (WizardPanelProvider base) { - this (new SimpleWizardInfo (base)); + protected WizardBranchController(WizardPanelProvider base) { + this(new SimpleWizardInfo(base)); } /** * Create a new WizardBranchController using the passed WizardPage * instances as the initial pages of the wizard. + * * @param pages An array of WizardPage instances - */ - protected WizardBranchController (WizardPage[] pages) { - this (WizardPage.createWizardPanelProvider(pages)); + */ + protected WizardBranchController(WizardPage[] pages) { + this(WizardPage.createWizardPanelProvider(pages)); } /** * Create a new WizardBranchController using the passed WizardPage - * as the initial page of the wizard. The initial page should + * as the initial page of the wizard. The initial page should * determine the subsequent steps of the wizard. + * * @param onlyPage An instance of WizardPage - */ - protected WizardBranchController (WizardPage onlyPage) { - this (WizardPage.createWizardPanelProvider(onlyPage)); - } + */ + protected WizardBranchController(WizardPage onlyPage) { + this(WizardPage.createWizardPanelProvider(onlyPage)); + } + /** - * Create a new WizardBranchController, using the passed SimpleWizardInfo + * Create a new WizardBranchController, using the passed + * SimpleWizardInfo * for the initial panes of the wizard. */ - WizardBranchController (SimpleWizardInfo base) { - if (base == null) throw new NullPointerException ("No base"); + WizardBranchController(SimpleWizardInfo base) { + if (base == null) + throw new NullPointerException("No base"); this.base = base; } - + /** * Get the wizard which represents the subsequent panes after this step. * The UI for the current step should have put sufficient data into the - * settings map to decide what to return; return null if not. + * settings map to decide what to return; return null if not. *

- * The default implementation delegates to getPanelProviderForStep() + * The default implementation delegates to + * getPanelProviderForStep() * and returns a Wizard representing the result of that - * call. + * call. *

- * Note: This method can be called very frequently, to determine - * if the sequence of steps has changed - so it needs to run fast. - * Returning the same instance every time the same arguments are passed - * is highly recommended. It will typically be called whenever a change + * Note: This method can be called very frequently, to determine + * if the sequence of steps has changed - so it needs to run fast. + * Returning the same instance every time the same arguments are passed + * is highly recommended. It will typically be called whenever a change * is fired by the base wizard (i.e. every call setProblem() * should generate a check to see if the navigation has changed). *

* Note that the wizard for the subsequent steps will be instantiated - * as soon as it is known what the user's choice is, so the list of + * as soon as it is known what the user's choice is, so the list of * pending steps can be updated (this does not mean that all subsequent * panel UI components of the wizard will be instantiated, just the * Wizard object itself, which will create panels on demand if they * have not already been created). * - * @param step The current step the user is on in the wizard + * @param step The current step the user is on in the wizard * @param settings The settings map, which previous panes of the wizard - * have been writing information into + * have been writing information into */ protected Wizard getWizardForStep(String step, Map settings) { WizardPanelProvider provider = getPanelProviderForStep(step, settings); @@ -122,42 +132,44 @@ public abstract class WizardBranchController { } /** - * Override this method to return a WizardPanelProvider representing the + * Override this method to return a WizardPanelProvider + * representing the * steps from here to the final step of the wizard, varying the returned * object based on the contents of the map and the step in question. - * The default implementation of this method throws an Error - + * The default implementation of this method throws an Error - * either override this method, or override getWizardForStep() * (in which case this method will not be called). *

- * Note: This method can be called very frequently, to determine - * if the sequence of steps has changed - so it needs to run fast. + * Note: This method can be called very frequently, to determine + * if the sequence of steps has changed - so it needs to run fast. * Returning the same instance every time called with equivalent arguments * is highly recommended. - * - * @param step The string ID of the current step + * + * @param step The string ID of the current step * @param settings The settings map, which previous panes of the wizard - * will have written content into + * will have written content into */ protected WizardPanelProvider getPanelProviderForStep(String step, Map settings) { - throw new Error ("Override either createInfoForStep or " + - "createWizardForStep"); + throw new Error("Override either createInfoForStep or " + + "createWizardForStep"); } - + SimpleWizardInfo getBase() { return base; } private WizardImplementation wizard = null; private Wizard real = null; + /** - * Create a Wizard to represent this branch controller. The resulting + * Create a Wizard to represent this branch controller. The resulting * Wizard instance is cached; subsequent calls to this method will return * the same instance. */ public final Wizard createWizard() { if (wizard == null) { - wizard = new BranchingWizard (this); - real = new Wizard (wizard); + wizard = new BranchingWizard(this); + real = new Wizard(wizard); } return real; }