From: <th...@us...> - 2009-01-03 17:08:00
|
Revision: 8864 http://pcgen.svn.sourceforge.net/pcgen/?rev=8864&view=rev Author: thpr Date: 2009-01-03 17:07:56 +0000 (Sat, 03 Jan 2009) Log Message: ----------- [ 2483203 ] Pull Down Menus not listing entries in alphabetical order Modified Paths: -------------- Trunk/pcgen/code/src/java/pcgen/base/util/KeyMap.java Trunk/pcgen/code/src/java/pcgen/base/util/ListSet.java Trunk/pcgen/code/src/java/pcgen/cdom/reference/AbstractReferenceManufacturer.java Modified: Trunk/pcgen/code/src/java/pcgen/base/util/KeyMap.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/base/util/KeyMap.java 2009-01-03 16:56:17 UTC (rev 8863) +++ Trunk/pcgen/code/src/java/pcgen/base/util/KeyMap.java 2009-01-03 17:07:56 UTC (rev 8864) @@ -232,7 +232,7 @@ */ public Collection<V> values() { - return new ListSet<V>(reverseMap.keySet()); + return new ListSet<V>(forwardMap.values()); } /** Modified: Trunk/pcgen/code/src/java/pcgen/base/util/ListSet.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/base/util/ListSet.java 2009-01-03 16:56:17 UTC (rev 8863) +++ Trunk/pcgen/code/src/java/pcgen/base/util/ListSet.java 2009-01-03 17:07:56 UTC (rev 8864) @@ -21,6 +21,7 @@ import java.util.AbstractSet; import java.util.ArrayList; +import java.util.Collection; import java.util.Comparator; import java.util.Iterator; import java.util.Set; @@ -119,7 +120,7 @@ * @throws NullPointerException * if the given Set is null */ - public ListSet(Set<T> otherSet) + public ListSet(Collection<T> otherSet) { list = new ArrayList<T>(otherSet); comparator = null; Modified: Trunk/pcgen/code/src/java/pcgen/cdom/reference/AbstractReferenceManufacturer.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/cdom/reference/AbstractReferenceManufacturer.java 2009-01-03 16:56:17 UTC (rev 8863) +++ Trunk/pcgen/code/src/java/pcgen/cdom/reference/AbstractReferenceManufacturer.java 2009-01-03 17:07:56 UTC (rev 8864) @@ -887,9 +887,7 @@ */ public Collection<T> getAllObjects() { - List<T> list = new ArrayList<T>(active.size()); - list.addAll(active.values()); - return list; + return active.values(); } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jde...@us...> - 2009-01-06 09:31:05
|
Revision: 8893 http://pcgen.svn.sourceforge.net/pcgen/?rev=8893&view=rev Author: jdempsey Date: 2009-01-06 09:31:00 +0000 (Tue, 06 Jan 2009) Log Message: ----------- Fixes for errors encountered when first converting Modified Paths: -------------- Trunk/pcgen/code/src/java/pcgen/gui/converter/AbstractLoader.java Trunk/pcgen/code/src/java/pcgen/gui/converter/AbstractTokenLoader.java Trunk/pcgen/code/src/java/pcgen/rules/persistence/token/AbstractSpellListToken.java Modified: Trunk/pcgen/code/src/java/pcgen/gui/converter/AbstractLoader.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/gui/converter/AbstractLoader.java 2009-01-05 21:42:31 UTC (rev 8892) +++ Trunk/pcgen/code/src/java/pcgen/gui/converter/AbstractLoader.java 2009-01-06 09:31:00 UTC (rev 8893) @@ -160,8 +160,12 @@ private File findSubRoot(File root, File in) { - if (in.getParentFile().equals(root)) + if (in.getParentFile() == null) { + return null; + } + if (in.getParentFile().getAbsolutePath().equals(root.getAbsolutePath())) + { return in; } return findSubRoot(root, in.getParentFile()); Modified: Trunk/pcgen/code/src/java/pcgen/gui/converter/AbstractTokenLoader.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/gui/converter/AbstractTokenLoader.java 2009-01-05 21:42:31 UTC (rev 8892) +++ Trunk/pcgen/code/src/java/pcgen/gui/converter/AbstractTokenLoader.java 2009-01-06 09:31:00 UTC (rev 8893) @@ -39,6 +39,10 @@ throws PersistenceLayerException { String[] tokens = lineString.split(FIELD_SEPARATOR); + if (tokens.length == 0) + { + return; + } result.append(tokens[0]); for (int tok = 1; tok < tokens.length; tok++) { Modified: Trunk/pcgen/code/src/java/pcgen/rules/persistence/token/AbstractSpellListToken.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/rules/persistence/token/AbstractSpellListToken.java 2009-01-05 21:42:31 UTC (rev 8892) +++ Trunk/pcgen/code/src/java/pcgen/rules/persistence/token/AbstractSpellListToken.java 2009-01-06 09:31:00 UTC (rev 8893) @@ -84,7 +84,7 @@ { // Zero indicates no Token // TODO Error message - unexpected? - return null; + continue; } for (CDOMReference<Spell> added : mtl.getKeySet()) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <th...@us...> - 2009-01-07 02:15:33
|
Revision: 8914 http://pcgen.svn.sourceforge.net/pcgen/?rev=8914&view=rev Author: thpr Date: 2009-01-07 02:15:29 +0000 (Wed, 07 Jan 2009) Log Message: ----------- fix FORWARDREF for FEAT/ABILITY Modified Paths: -------------- Trunk/pcgen/code/src/java/pcgen/core/Campaign.java Trunk/pcgen/code/src/java/pcgen/rules/context/GameReferenceContext.java Trunk/pcgen/code/src/java/pcgen/rules/context/ReferenceContext.java Added Paths: ----------- Trunk/pcgen/code/src/java/pcgen/cdom/reference/CDOMTransparentCategorizedSingleRef.java Trunk/pcgen/code/src/java/pcgen/cdom/reference/TransparentCategorizedReferenceManufacturer.java Added: Trunk/pcgen/code/src/java/pcgen/cdom/reference/CDOMTransparentCategorizedSingleRef.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/cdom/reference/CDOMTransparentCategorizedSingleRef.java (rev 0) +++ Trunk/pcgen/code/src/java/pcgen/cdom/reference/CDOMTransparentCategorizedSingleRef.java 2009-01-07 02:15:29 UTC (rev 8914) @@ -0,0 +1,107 @@ +/* + * Copyright (c) 2007 Tom Parker <th...@us...> + * + * This program is free software; you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License as published by the Free + * Software Foundation; either version 2.1 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more + * details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ +package pcgen.cdom.reference; + +import pcgen.cdom.base.CategorizedCDOMObject; +import pcgen.cdom.base.Category; + +/** + * A CDOMTransparentCategorizedSingleRef is a CDOMReference which is intended to + * contain a another CDOMSingleRef, to which the + * CDOMTransparentCategorizedSingleRef will delegate behavior. + * + * A CDOMTransparentCategorizedSingleRef, unlike many CDOMReference objects, can + * be cleared, and the underlying CDOMSingleRef can be changed. + * + * @see TransparentReference for a description of cases in which + * TransparentReferences like CDOMTransparentCategorizedSingleRef are + * typically used + * + * @param <T> + * The Class of the underlying object contained by this + * CDOMTransparentCategorizedSingleRef + */ +public class CDOMTransparentCategorizedSingleRef<T extends CategorizedCDOMObject<T>> + extends CDOMTransparentSingleRef<T> implements TransparentReference<T>, + CategorizedCDOMReference<T> +{ + /** + * The Category of the object of the Class this CDOMCategorizedSingleRef + * represents + */ + private final Category<T> category; + + /** + * Constructs a new CDOMTransparentCategorizedSingleRef for the given Class + * and name. + * + * @param cl + * The Class of the underlying object contained by this + * CDOMTransparentCategorizedSingleRef. + * @param nm + * An identifier of the object this + * CDOMTransparentCategorizedSingleRef contains. + */ + public CDOMTransparentCategorizedSingleRef(Class<T> cl, Category<T> cat, + String nm) + { + super(cl, nm); + if (cat == null) + { + throw new IllegalArgumentException( + "Cannot built CDOMTransparentCategorizedSingleRef with null category"); + } + category = cat; + } + + /** + * Returns true if this CDOMTransparentCategorizedSingleRef is equal to the + * given Object. Equality is defined as being another + * CDOMTransparentCategorizedSingleRef object with equal Class represented + * by the reference and equal name of the underlying reference. This is NOT + * a deep .equals, in that neither the actual contents of this + * CDOMTransparentCategorizedSingleRef nor the underlying CDOMSingleRef are + * tested. + * + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object o) + { + if (o instanceof CDOMTransparentCategorizedSingleRef) + { + CDOMTransparentCategorizedSingleRef<?> ref = (CDOMTransparentCategorizedSingleRef<?>) o; + return getReferenceClass().equals(ref.getReferenceClass()) + && category.equals(ref.getCDOMCategory()) + && getName().equals(ref.getName()); + } + return false; + } + + /** + * Returns the Category of the object this + * CDOMTransparentCategorizedSingleRef contains + * + * @return the Category of the object this + * CDOMTransparentCategorizedSingleRef contains + */ + public Category<T> getCDOMCategory() + { + return category; + } +} Added: Trunk/pcgen/code/src/java/pcgen/cdom/reference/TransparentCategorizedReferenceManufacturer.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/cdom/reference/TransparentCategorizedReferenceManufacturer.java (rev 0) +++ Trunk/pcgen/code/src/java/pcgen/cdom/reference/TransparentCategorizedReferenceManufacturer.java 2009-01-07 02:15:29 UTC (rev 8914) @@ -0,0 +1,189 @@ +/* + * Copyright 2007, 2008 (C) Tom Parker <th...@us...> + * + * This library is free software; you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License as published by the Free + * Software Foundation; either version 2.1 of the License, or (at your option) + * any later version. + * + * This library is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more + * details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package pcgen.cdom.reference; + +import pcgen.cdom.base.CDOMObject; +import pcgen.cdom.base.CategorizedCDOMObject; +import pcgen.cdom.base.Category; + +/** + * A TransparentCategorizedReferenceManufacturer is a ReferenceManufacturer + * capable of creating TransparentReferences of a given "form". That "form" + * includes a specific Class of CDOMObject, or a specific Class/Category for + * Categorized CDOMObjects (this class does not make distinction between the + * Class and Class/Categorized cases) + * + * @param <T> + * The Class of object this + * TransparentCategorizedReferenceManufacturer can reference + */ +public class TransparentCategorizedReferenceManufacturer<T extends CDOMObject & CategorizedCDOMObject<T>> + extends TransparentReferenceManufacturer<T> implements + ReferenceManufacturer<T, CDOMTransparentSingleRef<T>> +{ + /** + * Stores the Category of the CategorizedCDOMObjects that this + * TransparentCategorizedReferenceManufacturer constructs and references. + */ + private final Category<T> category; + + /** + * Constructs a new TransparentCategorizedReferenceManufacturer for the + * given Class. + * + * @param cl + * The Class of object this + * TransparentCategorizedReferenceManufacturer will construct and + * reference. + */ + public TransparentCategorizedReferenceManufacturer(Class<T> cl, + Category<T> cat) + { + super(cl); + if (cat == null) + { + throw new IllegalArgumentException( + "Cannot built TransparentCategorizedReferenceManufacturer with null category"); + } + category = cat; + } + + /** + * Returns a CDOMTransparentSingleRef for the given identifier as defined by + * the Class provided when this TransparentCategorizedReferenceManufacturer + * was constructed. This is designed to be used ONLY by the + * AbstractReferenceManufacturer template Class and should not be called by + * other objects. + * + * @param ident + * The identifier for which a CDOMTransparentSingleRef should be + * returned. + * @return a CDOMTransparentSingleRef for the given identifier as defined by + * the Class provided when this + * TransparentCategorizedReferenceManufacturer was constructed. + */ + @Override + protected CDOMTransparentCategorizedSingleRef<T> getLocalReference( + String ident) + { + return new CDOMTransparentCategorizedSingleRef<T>(getReferenceClass(), + category, ident); + } + + /** + * Returns a CDOMTransparentTypeRef for the given types as defined by the + * Class provided when this TransparentCategorizedReferenceManufacturer was + * constructed. This is designed to be used ONLY by the + * AbstractReferenceManufacturer template Class and should not be called by + * other objects. + * + * @param types + * An array of the types of objects to which the returned + * CDOMReference will refer. + * @return A CDOMTransparentTypeRef for the given types as defined by the + * Class provided when this + * TransparentCategorizedReferenceManufacturer was constructed. + */ + @Override + protected CDOMTransparentTypeRef<T> getLocalTypeReference(String[] types) + { + return new CDOMTransparentTypeRef<T>(getReferenceClass(), types); + } + + /** + * Returns a CDOMTransparentAllRef for all objects of the Class provided + * when this TransparentCategorizedReferenceManufacturer was constructed. + * This is designed to be used ONLY by the AbstractReferenceManufacturer + * template Class and should not be called by other objects. + * + * @return A CDOMTransparentAllRef for all objects of the Class provided + * when this TransparentCategorizedReferenceManufacturer was + * constructed. + */ + @Override + protected CDOMTransparentAllRef<T> getLocalAllReference() + { + return new CDOMTransparentAllRef<T>(getReferenceClass()); + } + + /** + * Resolves the TransparentReferences in this + * TransparentCategorizedReferenceManufacturer using the given + * ReferenceManufacturer. + * + * This method may be called more than once; each time it is called it will + * overwrite the existing resolution of the TransparentReferences contained + * within this TransparentCategorizedReferenceManufacturer. + * + * @param rm + * The ReferenceManufacturer to be used to resolve the + * TransparentReferences produced in this + * TransparentCategorizedReferenceManufacturer + * @throws IllegalArgumentException + * if the given ReferenceManufacturer is null + */ + public void resolveUsing(ReferenceManufacturer<T, ?> rm) + { + if (rm == null) + { + throw new IllegalArgumentException( + "Reference Manufacturer for resolveUsing cannot be null"); + } + CDOMTransparentAllRef<T> all = getAllRef(); + if (all != null) + { + all.resolve(rm); + } + for (CDOMTransparentTypeRef<T> ref : getTypeReferences()) + { + ref.resolve(rm); + } + for (CDOMTransparentSingleRef<T> ref : getReferenced()) + { + ref.resolve(rm); + } + injectConstructed(rm); + } + + /** + * Returns a description of the type of Class this + * TransparentCategorizedReferenceManufacturer constructs or references. + * This is designed to be used ONLY by the AbstractReferenceManufacturer + * template Class and should not be called by other objects. + * + * @return A String description of the Class that this + * TransparentCategorizedReferenceManufacturer constructs or + * references. + */ + @Override + protected String getReferenceDescription() + { + return getReferenceClass().getSimpleName() + " " + category; + } + + @Override + protected boolean validate(UnconstructedValidator validator, String s) + { + return validator != null && validator.allow(getReferenceClass(), s); + } + + public Category<T> getCDOMCategory() + { + return category; + } +} \ No newline at end of file Modified: Trunk/pcgen/code/src/java/pcgen/core/Campaign.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/Campaign.java 2009-01-07 02:13:46 UTC (rev 8913) +++ Trunk/pcgen/code/src/java/pcgen/core/Campaign.java 2009-01-07 02:15:29 UTC (rev 8914) @@ -28,8 +28,12 @@ import java.util.List; import pcgen.cdom.base.CDOMObject; +import pcgen.cdom.base.CategorizedCDOMObject; +import pcgen.cdom.base.Category; import pcgen.cdom.base.Constants; import pcgen.cdom.enumeration.ListKey; +import pcgen.cdom.reference.ReferenceManufacturer; +import pcgen.cdom.reference.TransparentCategorizedReferenceManufacturer; import pcgen.cdom.reference.TransparentReferenceManufacturer; import pcgen.core.utils.MessageType; import pcgen.core.utils.ShowMessageDelegate; @@ -179,7 +183,19 @@ private <T extends CDOMObject> void resolveReferenceManufacturer( AbstractReferenceContext rc, TransparentReferenceManufacturer<T> rm) { - rm.resolveUsing(rc.getManufacturer(rm.getReferenceClass())); + Class<T> c = rm.getReferenceClass(); + ReferenceManufacturer<T, ?> mfg; + if (CategorizedCDOMObject.class.isAssignableFrom(c)) + { + Category category = ((TransparentCategorizedReferenceManufacturer) rm) + .getCDOMCategory(); + mfg = rc.getManufacturer((Class) c, category); + } + else + { + mfg = rc.getManufacturer(c); + } + rm.resolveUsing(mfg); } } Modified: Trunk/pcgen/code/src/java/pcgen/rules/context/GameReferenceContext.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/rules/context/GameReferenceContext.java 2009-01-07 02:13:46 UTC (rev 8913) +++ Trunk/pcgen/code/src/java/pcgen/rules/context/GameReferenceContext.java 2009-01-07 02:15:29 UTC (rev 8914) @@ -28,18 +28,24 @@ import pcgen.cdom.base.Category; import pcgen.cdom.reference.CDOMSingleRef; import pcgen.cdom.reference.ReferenceManufacturer; +import pcgen.cdom.reference.TransparentCategorizedReferenceManufacturer; import pcgen.cdom.reference.TransparentReferenceManufacturer; public class GameReferenceContext extends AbstractReferenceContext { private final Map<Class<?>, TransparentReferenceManufacturer<? extends CDOMObject>> map = new HashMap<Class<?>, TransparentReferenceManufacturer<? extends CDOMObject>>(); - private final DoubleKeyMap<Class<?>, Category<?>, TransparentReferenceManufacturer<? extends CDOMObject>> catmap = new DoubleKeyMap<Class<?>, Category<?>, TransparentReferenceManufacturer<? extends CDOMObject>>(); + private final DoubleKeyMap<Class<?>, Category<?>, TransparentCategorizedReferenceManufacturer<? extends CDOMObject>> catmap = new DoubleKeyMap<Class<?>, Category<?>, TransparentCategorizedReferenceManufacturer<? extends CDOMObject>>(); @Override public <T extends CDOMObject> ReferenceManufacturer<T, ? extends CDOMSingleRef<T>> getManufacturer( Class<T> cl) { + if (CategorizedCDOMObject.class.isAssignableFrom(cl)) + { + throw new InternalError(cl + + " is categorized but was fetched without a category"); + } TransparentReferenceManufacturer<T> mfg = (TransparentReferenceManufacturer<T>) map .get(cl); if (mfg == null) @@ -66,11 +72,11 @@ public <T extends CDOMObject & CategorizedCDOMObject<T>> ReferenceManufacturer<T, ? extends CDOMSingleRef<T>> getManufacturer( Class<T> cl, Category<T> cat) { - TransparentReferenceManufacturer<T> mfg = (TransparentReferenceManufacturer<T>) catmap + TransparentCategorizedReferenceManufacturer<T> mfg = (TransparentCategorizedReferenceManufacturer<T>) catmap .get(cl, cat); if (mfg == null) { - mfg = new TransparentReferenceManufacturer<T>(cl); + mfg = new TransparentCategorizedReferenceManufacturer<T>(cl, cat); catmap.put(cl, cat, mfg); } return mfg; Modified: Trunk/pcgen/code/src/java/pcgen/rules/context/ReferenceContext.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/rules/context/ReferenceContext.java 2009-01-07 02:13:46 UTC (rev 8913) +++ Trunk/pcgen/code/src/java/pcgen/rules/context/ReferenceContext.java 2009-01-07 02:15:29 UTC (rev 8914) @@ -41,6 +41,11 @@ public <T extends CDOMObject> ReferenceManufacturer<T, ? extends CDOMSingleRef<T>> getManufacturer( Class<T> cl) { + if (CategorizedCDOMObject.class.isAssignableFrom(cl)) + { + throw new InternalError(cl + + " is categorized but was fetched without a category"); + } ReferenceManufacturer<T, ?> mfg = (ReferenceManufacturer<T, ?>) map .get(cl); if (mfg == null) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jde...@us...> - 2009-01-10 13:15:24
|
Revision: 8963 http://pcgen.svn.sourceforge.net/pcgen/?rev=8963&view=rev Author: jdempsey Date: 2009-01-10 13:15:12 +0000 (Sat, 10 Jan 2009) Log Message: ----------- FReq: Add Quick Search and filtering to the Kit window Issue#: 2016157 Modified Paths: -------------- Trunk/pcgen/code/src/java/pcgen/core/SettingsHandler.java Trunk/pcgen/code/src/java/pcgen/gui/KitSelector.java Trunk/pcgen/code/src/java/pcgen/gui/tabs/InfoSkills.java Modified: Trunk/pcgen/code/src/java/pcgen/core/SettingsHandler.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/SettingsHandler.java 2009-01-10 05:03:36 UTC (rev 8962) +++ Trunk/pcgen/code/src/java/pcgen/core/SettingsHandler.java 2009-01-10 13:15:12 UTC (rev 8963) @@ -112,6 +112,8 @@ private static GameMode game = new GameMode("default"); private static boolean grimHPMode = false; private static boolean grittyACMode = false; + private static Dimension kitSelectorDimension = null; + private static Point kitSelectorLeftUpperCorner = null; private static boolean useWaitCursor = true; private static boolean showD20InfoAtStart = true; private static boolean loadURLs = false; @@ -945,6 +947,26 @@ isGMGen = GMGen; } + public static void setKitSelectorDimension(final Dimension d) + { + kitSelectorDimension = d; + } + + public static Dimension getKitSelectorDimension() + { + return kitSelectorDimension; + } + + public static void setKitSelectorLeftUpperCorner(final Point argLeftUpperCorner) + { + kitSelectorLeftUpperCorner = argLeftUpperCorner; + } + + public static Point getKitSelectorLeftUpperCorner() + { + return kitSelectorLeftUpperCorner; + } + public static void setLastTipShown(final int argLastTipShown) { lastTipShown = argLastTipShown; @@ -1110,6 +1132,17 @@ setCustomizerDimension(new Dimension(dw.intValue(), dh.intValue())); } + + setKitSelectorLeftUpperCorner(new Point(getPCGenOption("kitSelector.windowLeftUpperCorner.X", -1.0).intValue(), //$NON-NLS-1$ + getPCGenOption("kitSelector.windowLeftUpperCorner.Y", -1.0).intValue())); //$NON-NLS-1$ + dw = getPCGenOption("kitSelector.windowWidth", 0.0); //$NON-NLS-1$ + dh = getPCGenOption("kitSelector.windowHeight", 0.0); //$NON-NLS-1$ + + if (!CoreUtility.doublesEqual(dw.doubleValue(), 0.0) && !CoreUtility.doublesEqual(dh.doubleValue(), 0.0)) + { + setKitSelectorDimension(new Dimension(dw.intValue(), dh.intValue())); + } + // // Read in the buy/sell percentages for the gear tab // If not in the .ini file and ignoreCost is set, then use 0% @@ -1521,6 +1554,18 @@ setPCGenOption("customizer.windowHeight", getCustomizerDimension().getHeight()); //$NON-NLS-1$ } + if (getKitSelectorLeftUpperCorner() != null) + { + setPCGenOption("kitSelector.windowLeftUpperCorner.X", getKitSelectorLeftUpperCorner().getX()); //$NON-NLS-1$ + setPCGenOption("kitSelector.windowLeftUpperCorner.Y", getKitSelectorLeftUpperCorner().getY()); //$NON-NLS-1$ + } + + if (getKitSelectorDimension() != null) + { + setPCGenOption("kitSelector.windowWidth", getKitSelectorDimension().getWidth()); //$NON-NLS-1$ + setPCGenOption("kitSelector.windowHeight", getKitSelectorDimension().getHeight()); //$NON-NLS-1$ + } + final String paperName = Globals.getPaperInfo(Constants.PAPERINFO_NAME); if (paperName != null) Modified: Trunk/pcgen/code/src/java/pcgen/gui/KitSelector.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/gui/KitSelector.java 2009-01-10 05:03:36 UTC (rev 8962) +++ Trunk/pcgen/code/src/java/pcgen/gui/KitSelector.java 2009-01-10 13:15:12 UTC (rev 8963) @@ -40,6 +40,7 @@ import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import java.awt.Insets; +import java.awt.Point; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.MouseAdapter; @@ -63,9 +64,12 @@ import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JSplitPane; +import javax.swing.JTextField; import javax.swing.ListSelectionModel; import javax.swing.border.EmptyBorder; import javax.swing.border.TitledBorder; +import javax.swing.event.DocumentEvent; +import javax.swing.event.DocumentListener; import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; @@ -78,9 +82,11 @@ import pcgen.core.kit.BaseKit; import pcgen.core.prereq.PrereqHandler; import pcgen.gui.panes.FlippingSplitPane; +import pcgen.gui.tabs.InfoTabUtils; import pcgen.gui.utils.IconUtilitities; import pcgen.gui.utils.JLabelPane; import pcgen.gui.utils.Utility; +import pcgen.util.PropertyFactory; final class KitSelector extends JFrame { @@ -110,6 +116,15 @@ private PlayerCharacter aPC = null; private int userResponse = 0; + private final JLabel lblAvailableQFilter = new JLabel(PropertyFactory.getString("in_filter") + ":"); + private final JLabel lblSelectedQFilter = new JLabel(PropertyFactory.getString("in_filter") + ":"); + private JTextField textAvailableQFilter = new JTextField(); + private JTextField textSelectedQFilter = new JTextField(); + private JButton clearAvailableQFilterButton = new JButton(PropertyFactory.getString("in_clear")); + private JButton clearSelectedQFilterButton = new JButton(PropertyFactory.getString("in_clear")); + private KitListModel availableModel; + private KitListModel selectedModel; + /** * Creates new form KitSelector * @param argPC the PlayerCharacter the kit will be applied to @@ -123,8 +138,46 @@ initComponents(); initComponentContents(); - this.setSize(new Dimension(640, 460)); - Utility.centerFrame(this, false); + int t = spChoices.getDividerLocation(); + int u = spMain.getDividerLocation(); + + t = SettingsHandler.getPCGenOption("kitSelector.spChoices", t); //$NON-NLS-1$ + u = SettingsHandler.getPCGenOption("kitSelector.spMain", u); //$NON-NLS-1$ + + if (t > 0) + { + spChoices.setDividerLocation(t); + SettingsHandler.setPCGenOption("InfoSkills.bsplit", t); //$NON-NLS-1$ + } + + if (u > 0) + { + spMain.setDividerLocation(u); + SettingsHandler.setPCGenOption("InfoSkills.asplit", u); //$NON-NLS-1$ + } + + final Dimension kitSelDim = SettingsHandler.getKitSelectorDimension(); + final Point kitSelLoc = SettingsHandler.getKitSelectorLeftUpperCorner(); + int x = -11; + int y = -11; + + if (kitSelLoc != null) + { + x = (int) kitSelLoc.getX(); + y = (int) kitSelLoc.getY(); + } + + if ((x < -10) || (y < -10) || (kitSelDim == null) || (kitSelDim.height == 0) + || (kitSelDim.width == 0)) + { + setSize(new Dimension(640, 460)); + Utility.centerFrame(this, false); + } + else + { + setLocation(kitSelLoc); + setSize(kitSelDim); + } } /** @@ -132,9 +185,14 @@ */ public void closeDialog() { - // - // TODO: save window size and position of scroll pane dividers - // + // Save window size and position of scroll pane dividers + SettingsHandler.setKitSelectorLeftUpperCorner(getLocationOnScreen()); + SettingsHandler.setKitSelectorDimension(getSize()); + SettingsHandler.setPCGenOption( + "kitSelector.spChoices", spChoices.getDividerLocation()); //$NON-NLS-1$ + SettingsHandler.setPCGenOption( + "kitSelector.spMain", spMain.getDividerLocation()); //$NON-NLS-1$ + setVisible(false); dispose(); } @@ -245,12 +303,15 @@ { IconUtilitities.maybeSetIcon(this, IconUtilitities.RESOURCE_APP_ICON); - lstAvailable = new JList(new KitListModel(new ArrayList<Kit>())); + + availableModel = new KitListModel(new ArrayList<Kit>()); + lstAvailable = new JList(availableModel); lstAvailable.setCellRenderer(new MyCellRenderer()); lstAvailable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); scpAvailable.setViewportView(lstAvailable); - lstSelected = new JList(new KitListModel(new ArrayList<Kit>())); + selectedModel = new KitListModel(new ArrayList<Kit>()); + lstSelected = new JList(selectedModel); lstSelected.setCellRenderer(new MyCellRenderer()); lstSelected.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); scpSelected.setViewportView(lstSelected); @@ -345,36 +406,60 @@ pnlAvailable.setLayout(new GridBagLayout()); pnlAvailable.setBorder(new EmptyBorder(new Insets(1, 3, 1, 3))); - btnAdd.setEnabled(false); - btnAdd.addActionListener(new ActionListener() - { - public void actionPerformed(ActionEvent evt) - { - btnAddActionPerformed(); - } - }); - pnlAvailable.add(btnAdd, new GridBagConstraints()); + gridBagConstraints = new GridBagConstraints(); + Utility.buildRelativeConstraints(gridBagConstraints, + GridBagConstraints.REMAINDER, 1, 0.0, 0.0, + GridBagConstraints.HORIZONTAL, GridBagConstraints.WEST); + pnlAvailable.add(InfoTabUtils.createFilterPane(null, null, lblAvailableQFilter, + textAvailableQFilter, clearAvailableQFilterButton), gridBagConstraints); lblAvailable.setText("Available"); - gridBagConstraints = new GridBagConstraints(); - gridBagConstraints.gridy = 1; - gridBagConstraints.fill = GridBagConstraints.HORIZONTAL; - gridBagConstraints.anchor = GridBagConstraints.WEST; + Utility.buildRelativeConstraints(gridBagConstraints, + GridBagConstraints.REMAINDER, 1, 0.0, 0.0, + GridBagConstraints.HORIZONTAL, GridBagConstraints.WEST); pnlAvailable.add(lblAvailable, gridBagConstraints); - gridBagConstraints = new GridBagConstraints(); - gridBagConstraints.gridy = 2; - gridBagConstraints.fill = GridBagConstraints.BOTH; - gridBagConstraints.weightx = 1.0; - gridBagConstraints.weighty = 1.0; + Utility.buildRelativeConstraints(gridBagConstraints, + GridBagConstraints.REMAINDER, 1, 1.0, 1.0, GridBagConstraints.BOTH, + GridBagConstraints.WEST); pnlAvailable.add(scpAvailable, gridBagConstraints); + btnAdd.setEnabled(false); + btnAdd.addActionListener(new ActionListener() + { + public void actionPerformed(ActionEvent evt) + { + btnAddActionPerformed(); + } + }); + Utility.buildRelativeConstraints(gridBagConstraints, + GridBagConstraints.REMAINDER, 1, 1.0, 1.0, GridBagConstraints.NONE, + GridBagConstraints.CENTER); + pnlAvailable.add(btnAdd, new GridBagConstraints()); + spChoices.setLeftComponent(pnlAvailable); pnlSelected.setLayout(new GridBagLayout()); pnlSelected.setBorder(new EmptyBorder(new Insets(1, 3, 1, 3))); + Utility.buildRelativeConstraints(gridBagConstraints, + GridBagConstraints.REMAINDER, 1, 0.0, 0.0, + GridBagConstraints.HORIZONTAL, GridBagConstraints.WEST); + pnlSelected.add(InfoTabUtils.createFilterPane(null, null, lblSelectedQFilter, + textSelectedQFilter, clearSelectedQFilterButton), gridBagConstraints); + + lblSelected.setText("Selected"); + Utility.buildRelativeConstraints(gridBagConstraints, + GridBagConstraints.REMAINDER, 1, 0.0, 0.0, + GridBagConstraints.HORIZONTAL, GridBagConstraints.WEST); + pnlSelected.add(lblSelected, gridBagConstraints); + + Utility.buildRelativeConstraints(gridBagConstraints, + GridBagConstraints.REMAINDER, 1, 1.0, 1.0, GridBagConstraints.BOTH, + GridBagConstraints.WEST); + pnlSelected.add(scpSelected, gridBagConstraints); + btnRemove.setEnabled(false); btnRemove.addActionListener(new ActionListener() { @@ -383,23 +468,12 @@ btnRemoveActionPerformed(); } }); - - pnlSelected.add(btnRemove, new GridBagConstraints()); - - lblSelected.setText("Selected"); gridBagConstraints = new GridBagConstraints(); - gridBagConstraints.gridy = 1; - gridBagConstraints.fill = GridBagConstraints.HORIZONTAL; - gridBagConstraints.anchor = GridBagConstraints.WEST; - pnlSelected.add(lblSelected, gridBagConstraints); - - gridBagConstraints = new GridBagConstraints(); - gridBagConstraints.gridy = 2; - gridBagConstraints.fill = GridBagConstraints.BOTH; - gridBagConstraints.weightx = 1.0; - gridBagConstraints.weighty = 1.0; - pnlSelected.add(scpSelected, gridBagConstraints); - + Utility.buildRelativeConstraints(gridBagConstraints, + GridBagConstraints.REMAINDER, 1, 0.0, 0.0, GridBagConstraints.NONE, + GridBagConstraints.CENTER); + pnlSelected.add(btnRemove, gridBagConstraints); + spChoices.setRightComponent(pnlSelected); spMain.setLeftComponent(spChoices); @@ -439,6 +513,57 @@ pnlFrame.add(spMain, BorderLayout.CENTER); getContentPane().add(pnlFrame, BorderLayout.CENTER); + + textAvailableQFilter.getDocument().addDocumentListener(new DocumentListener() + { + public void changedUpdate(DocumentEvent evt) + { + setQFilter(availableModel); + } + + public void insertUpdate(DocumentEvent evt) + { + setQFilter(availableModel); + } + + public void removeUpdate(DocumentEvent evt) + { + setQFilter(availableModel); + } + }); + clearAvailableQFilterButton.addActionListener(new ActionListener() + { + public void actionPerformed(ActionEvent evt) + { + clearQFilter(availableModel); + } + }); + + textSelectedQFilter.getDocument().addDocumentListener(new DocumentListener() + { + public void changedUpdate(DocumentEvent evt) + { + setQFilter(selectedModel); + } + + public void insertUpdate(DocumentEvent evt) + { + setQFilter(selectedModel); + } + + public void removeUpdate(DocumentEvent evt) + { + setQFilter(selectedModel); + } + }); + clearSelectedQFilterButton.addActionListener(new ActionListener() + { + public void actionPerformed(ActionEvent evt) + { + clearQFilter(selectedModel); + } + }); + } private boolean kitPassesPrereqs(Kit theKit) @@ -579,9 +704,57 @@ return userResponse; } + private void clearQFilter(KitListModel model) + { + model.clearQFilter(); + model.resetModel(); + if (model == availableModel) + { + textAvailableQFilter.setText(""); + clearAvailableQFilterButton.setEnabled(false); + lstAvailable.updateUI(); + } + else + { + textSelectedQFilter.setText(""); + clearSelectedQFilterButton.setEnabled(false); + lstSelected.updateUI(); + } + //forceRefresh(); + } + + private void setQFilter(KitListModel model) + { + String aString = + model == availableModel ? textAvailableQFilter.getText() + : textSelectedQFilter.getText(); + + if (aString.length() == 0) + { + clearQFilter(model); + return; + } + model.setQFilter(aString); + + model.resetModel(); + if (model == availableModel) + { + clearAvailableQFilterButton.setEnabled(true); + lstAvailable.updateUI(); + } + else + { + clearSelectedQFilterButton.setEnabled(true); + lstSelected.updateUI(); + } + //forceRefresh(); + } + private class KitListModel extends AbstractListModel { private List<Kit> theList = null; + private List<Kit> theVisibleList = null; + private String qFilter = null; /** * Constructor @@ -590,16 +763,33 @@ public KitListModel(final List<Kit> aList) { theList = new ArrayList<Kit>(aList); + theVisibleList = new ArrayList<Kit>(); + resetModel(); } + public void resetModel() + { + theVisibleList.clear(); + for (Kit aKit : theList) + { + if (qFilter == null + || (aKit.getDisplayName().toLowerCase().indexOf( + qFilter) >= 0 || aKit.getType().toLowerCase() + .indexOf(qFilter) >= 0)) + { + theVisibleList.add(aKit); + } + } + } + public Object getElementAt(int index) { - return theList.get(index); + return theVisibleList.get(index); } public int getSize() { - return theList.size(); + return theVisibleList.size(); } /** @@ -609,6 +799,14 @@ public void addItem(Kit aKit) { theList.add(aKit); + if (qFilter == null + || (aKit.getDisplayName().toLowerCase().indexOf( + qFilter) >= 0 || aKit.getType().toLowerCase() + .indexOf(qFilter) >= 0)) + { + theVisibleList.add(aKit); + Collections.sort(theVisibleList); + } Collections.sort(theList); } @@ -619,7 +817,42 @@ public void removeItem(Object item) { theList.remove(item); + theVisibleList.remove(item); } + + /** + * Get the QuickFilter + * @return QuickFilter + */ + public String getQFilter() + { + return qFilter; + } + + /** + * Set theQuickFilter + * @param quickFilter + */ + public void setQFilter(String quickFilter) + { + if (quickFilter != null) + { + this.qFilter = quickFilter.toLowerCase(); + } + else + { + this.qFilter = null; + } + } + + /** + * Clear the QuickFilter + */ + public void clearQFilter() + { + this.qFilter = null; + } + } private class MyCellRenderer extends DefaultListCellRenderer Modified: Trunk/pcgen/code/src/java/pcgen/gui/tabs/InfoSkills.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/gui/tabs/InfoSkills.java 2009-01-10 05:03:36 UTC (rev 8962) +++ Trunk/pcgen/code/src/java/pcgen/gui/tabs/InfoSkills.java 2009-01-10 13:15:12 UTC (rev 8963) @@ -206,8 +206,8 @@ private FlippingSplitPane splitPane; private JButton addButton; private JButton removeButton; - private JButton clearAvailableQFilterButton = new JButton("Clear"); - private JButton clearSelectedQFilterButton = new JButton("Clear"); + private JButton clearAvailableQFilterButton = new JButton(PropertyFactory.getString("in_clear")); + private JButton clearSelectedQFilterButton = new JButton(PropertyFactory.getString("in_clear")); private JComboBoxEx currCharacterClass = null; // now contains Strings of Class/lvl /** The output order selection drop-down */ @@ -217,8 +217,8 @@ private JComboBoxEx viewSelectComboBox = new JComboBoxEx(); private JLabel exclusiveLabel = new JLabel(); private JLabel includeLabel = new JLabel(); - private final JLabel lblAvailableQFilter = new JLabel("Filter:"); - private final JLabel lblSelectedQFilter = new JLabel("Filter:"); + private final JLabel lblAvailableQFilter = new JLabel(PropertyFactory.getString("in_filter") + ":"); + private final JLabel lblSelectedQFilter = new JLabel(PropertyFactory.getString("in_filter") + ":"); private JLabel jLbClassSkillPoints = null; private JLabel jLbMaxCrossSkill = new JLabel(); private JLabel jLbMaxSkill = new JLabel(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jde...@us...> - 2009-01-12 10:50:20
|
Revision: 8973 http://pcgen.svn.sourceforge.net/pcgen/?rev=8973&view=rev Author: jdempsey Date: 2009-01-12 10:50:13 +0000 (Mon, 12 Jan 2009) Log Message: ----------- Correct issue with saving and loading bonus known spells. Modified Paths: -------------- Trunk/pcgen/code/src/java/pcgen/core/PlayerCharacter.java Trunk/pcgen/code/src/java/pcgen/io/PCGVer2Creator.java Modified: Trunk/pcgen/code/src/java/pcgen/core/PlayerCharacter.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/PlayerCharacter.java 2009-01-12 04:10:29 UTC (rev 8972) +++ Trunk/pcgen/code/src/java/pcgen/core/PlayerCharacter.java 2009-01-12 10:50:13 UTC (rev 8973) @@ -17831,6 +17831,10 @@ { List<CharacterSpell> cspells = getAssocList(po, AssociationListKey.CHARACTER_SPELLS); + if (cspells == null) + { + cspells = new ArrayList<CharacterSpell>(); + } // Add in the spells granted by objects SpellLevel.addBonusKnowSpellsToList(this, po, cspells); @@ -17891,4 +17895,45 @@ return aList; } + /** + * Get a list of CharacterSpells from the character spell list + * @param fList + * @param spellSource TODO + * @param aSpell + * @param book + * @param level + * @return list of CharacterSpells from the character spell list + */ + public final List<CharacterSpell> getCharacterSpellsNoBonus(PObject spellSource, + final Spell aSpell, final String book, final int level) + { + List<CharacterSpell> csList = + getAssocList(spellSource, AssociationListKey.CHARACTER_SPELLS); + if (csList == null) + { + csList = new ArrayList<CharacterSpell>(); + } + + final ArrayList<CharacterSpell> aList = new ArrayList<CharacterSpell>(); + if (csList == null || csList.size() == 0) + { + return aList; + } + + for (CharacterSpell cs : csList) + { + if ((aSpell == null) || cs.getSpell().equals(aSpell)) + { + final SpellInfo si = cs.getSpellInfoFor(book, level, -1, null); + + if (si != null) + { + aList.add(cs); + } + } + } + + return aList; + } + } Modified: Trunk/pcgen/code/src/java/pcgen/io/PCGVer2Creator.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/io/PCGVer2Creator.java 2009-01-12 04:10:29 UTC (rev 8972) +++ Trunk/pcgen/code/src/java/pcgen/io/PCGVer2Creator.java 2009-01-12 10:50:13 UTC (rev 8973) @@ -2022,7 +2022,7 @@ for (PCClass pcClass : thePC.getClassList()) { - for (CharacterSpell cSpell : thePC.getCharacterSpells(pcClass, + for (CharacterSpell cSpell : thePC.getCharacterSpellsNoBonus(pcClass, null, Constants.EMPTY_STRING, -1)) { for (SpellInfo spellInfo : cSpell.getInfoList()) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <th...@us...> - 2009-01-16 22:54:14
|
Revision: 9024 http://pcgen.svn.sourceforge.net/pcgen/?rev=9024&view=rev Author: thpr Date: 2009-01-16 22:54:11 +0000 (Fri, 16 Jan 2009) Log Message: ----------- UI framework for Converter Modified Paths: -------------- Trunk/pcgen/code/src/java/pcgen/cdom/enumeration/ObjectKey.java Trunk/pcgen/code/src/java/pcgen/persistence/lst/LstSystemLoader.java Added Paths: ----------- Trunk/pcgen/code/src/java/pcgen/gui/converter/ConvertPanel.java Trunk/pcgen/code/src/java/pcgen/gui/converter/PCGenDataConvert.java Trunk/pcgen/code/src/java/pcgen/gui/converter/UnstretchingGridLayout.java Trunk/pcgen/code/src/java/pcgen/gui/converter/event/ProgressEvent.java Trunk/pcgen/code/src/java/pcgen/gui/converter/event/ProgressListener.java Trunk/pcgen/code/src/java/pcgen/gui/converter/event/ProgressMonitor.java Trunk/pcgen/code/src/java/pcgen/gui/converter/event/TaskStrategyListener.java Trunk/pcgen/code/src/java/pcgen/gui/converter/event/TaskStrategyMessage.java Trunk/pcgen/code/src/java/pcgen/gui/converter/panel/ Trunk/pcgen/code/src/java/pcgen/gui/converter/panel/ConvertSubPanel.java Trunk/pcgen/code/src/java/pcgen/gui/converter/panel/GameModePanel.java Trunk/pcgen/code/src/java/pcgen/gui/converter/panel/MessagePanel.java Trunk/pcgen/code/src/java/pcgen/gui/converter/panel/SourceSelectionPanel.java Trunk/pcgen/code/src/java/pcgen/gui/converter/panel/StartupPanel.java Trunk/pcgen/code/src/java/pcgen/gui/converter/panel/WriteDirectoryPanel.java Trunk/pcgen/code/src/java/pcgen/gui/utils/AWTUtilities.java Trunk/pcgen/code/src/java/pcgen/gui/utils/CursorControlUtilities.java Modified: Trunk/pcgen/code/src/java/pcgen/cdom/enumeration/ObjectKey.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/cdom/enumeration/ObjectKey.java 2009-01-16 21:39:52 UTC (rev 9023) +++ Trunk/pcgen/code/src/java/pcgen/cdom/enumeration/ObjectKey.java 2009-01-16 22:54:11 UTC (rev 9024) @@ -23,6 +23,7 @@ */ package pcgen.cdom.enumeration; +import java.io.File; import java.lang.reflect.Field; import java.math.BigDecimal; import java.net.URI; @@ -52,6 +53,7 @@ import pcgen.core.ArmorProf; import pcgen.core.Campaign; import pcgen.core.Equipment; +import pcgen.core.GameMode; import pcgen.core.Language; import pcgen.core.PCAlignment; import pcgen.core.PCClass; @@ -280,6 +282,12 @@ public static final ObjectKey<QualifiedObject<Boolean>> HAS_ALL_WEAPONPROF = new ObjectKey<QualifiedObject<Boolean>>(new QualifiedObject<Boolean>(Boolean.FALSE)); + public static final ObjectKey<File> DIRECTORY = new ObjectKey<File>(null); + + public static final ObjectKey<File> WRITE_DIRECTORY = new ObjectKey<File>(null); + + public static final ObjectKey<GameMode> GAME_MODE = new ObjectKey<GameMode>(null); + /* * TODO Okay, this is a hack. */ Added: Trunk/pcgen/code/src/java/pcgen/gui/converter/ConvertPanel.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/gui/converter/ConvertPanel.java (rev 0) +++ Trunk/pcgen/code/src/java/pcgen/gui/converter/ConvertPanel.java 2009-01-16 22:54:11 UTC (rev 9024) @@ -0,0 +1,215 @@ +/* + * Copyright (c) 2006, 2009. + * + * This program is free software; you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by the Free Software + * Foundation; either version 2.0 of the License, or (at your option) any later + * version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License along with + * this library; if not, write to the Free Software Foundation, Inc., 51 + * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + * + * Created on Mar 10, 2006 + */ +package pcgen.gui.converter; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.concurrent.BlockingQueue; + +import javax.swing.Box; +import javax.swing.JButton; +import javax.swing.JLabel; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.ScrollPaneConstants; + +import pcgen.cdom.base.CDOMObject; +import pcgen.cdom.inst.ObjectCache; +import pcgen.gui.converter.event.ProgressEvent; +import pcgen.gui.converter.event.ProgressListener; +import pcgen.gui.converter.event.TaskStrategyListener; +import pcgen.gui.converter.event.TaskStrategyMessage; +import pcgen.gui.converter.panel.ConvertSubPanel; +import pcgen.gui.utils.CursorControlUtilities; + +public class ConvertPanel extends JPanel +{ + + private final JPanel basePanel = new JPanel(); + + private final JButton finishButton; + + private final JButton nextButton; + + private final JButton cancelButton; + + private final CDOMObject properties; + + private final ProgressListener pl; + + private final BlockingQueue<ConvertSubPanel> queue; + + public ConvertPanel(BlockingQueue<ConvertSubPanel> bq) + { + super(new BorderLayout()); + final JLabel statusLabel = new JLabel(); + TaskStrategyListener tsl = new TaskStrategyListener() + { + private String status; + + private long time; + + public void processMessage(Object owner, String string) + { + JOptionPane.showMessageDialog(null, string); + } + + public void processStatus(Object source, String string) + { + status = string; + statusLabel.setText(string); + } + + public void processActiveItem(Object source, String string) + { + long currentTime = System.currentTimeMillis(); + if ((currentTime - time) > 100) + { + statusLabel.setText(status + " [" + string + "]"); + time = currentTime; + } + } + }; + TaskStrategyMessage.addTaskStrategyListener(tsl); + + properties = new ObjectCache(); + Box buttonBox = Box.createHorizontalBox(); + // prevButton = new JButton("< Previous"); + // prevButton.setMnemonic('P'); + // prevButton.addActionListener(new PreviousButtonListener()); + // prevButton.setEnabled(false); // FUTURE Need to reenable this + // buttonBox.add(prevButton); + nextButton = new JButton("Next >"); + nextButton.setMnemonic('N'); + pl = new ProgressListener() + { + public void progressAllowed(ProgressEvent pe) + { + nextButton.setEnabled(true); + } + + public void progressNotAllowed(ProgressEvent pe) + { + nextButton.setEnabled(false); + } + }; + nextButton.addActionListener(new ActionListener() + { + public void actionPerformed(ActionEvent arg0) + { + Thread t = new Thread(new Runnable() + { + public void run() + { + CursorControlUtilities.startWaitCursor(basePanel); + runNextPanel(); + CursorControlUtilities.stopWaitCursor(basePanel); + } + }); + t.start(); + } + }); + buttonBox.add(nextButton); + cancelButton = new JButton("Cancel"); + cancelButton.addActionListener(new ActionListener() + { + public void actionPerformed(ActionEvent arg0) + { + checkExit(); + } + }); + buttonBox.add(cancelButton); + finishButton = new JButton("Finish"); + finishButton.addActionListener(new ActionListener() + { + public void actionPerformed(ActionEvent arg0) + { + System.exit(0); + } + }); + finishButton.setVisible(false); + buttonBox.add(finishButton); + basePanel.setPreferredSize(new Dimension(800, 500)); + JScrollPane jsp = new JScrollPane(basePanel); + jsp + .setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); + jsp + .setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED); + add(jsp); + JPanel buttonLayout = new JPanel(new BorderLayout()); + buttonLayout.add(buttonBox, BorderLayout.EAST); + buttonLayout.add(statusLabel, BorderLayout.WEST); + add(buttonLayout, BorderLayout.SOUTH); + queue = bq; + runNextPanel(); + } + + public void prepare(ConvertSubPanel panel) + { + setButtonVisibility(panel.isLast()); + panel.addProgressListener(pl); + panel.performAnalysis(properties); + } + + private void setButtonVisibility(boolean displayingLast) + { + nextButton.setEnabled(false); + finishButton.setVisible(displayingLast); + cancelButton.setVisible(!displayingLast); + } + + public void checkExit() + { + // FINALCLEAN this is temporary, so it doesn't annoy me + System.exit(0); + + int response = JOptionPane.showConfirmDialog(this, + "Are you sure you wish to cancel and exit?", "Confirm Exit", + JOptionPane.OK_CANCEL_OPTION); + if (response == JOptionPane.OK_OPTION) + { + System.exit(0); + } + } + + private void runNextPanel() + { + ConvertSubPanel nextpanel = null; + do + { + try + { + nextpanel = queue.take(); + prepare(nextpanel); + basePanel.removeAll(); + nextpanel.setupDisplay(basePanel, properties); + basePanel.repaint(); + } + catch (InterruptedException e) + { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } while (nextpanel != null && nextpanel.autoAdvance(properties)); + } +} Added: Trunk/pcgen/code/src/java/pcgen/gui/converter/PCGenDataConvert.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/gui/converter/PCGenDataConvert.java (rev 0) +++ Trunk/pcgen/code/src/java/pcgen/gui/converter/PCGenDataConvert.java 2009-01-16 22:54:11 UTC (rev 9024) @@ -0,0 +1,100 @@ +/* + * Copyright (c) 2006, 2009. + * + * This program is free software; you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by the Free Software + * Foundation; either version 2.0 of the License, or (at your option) any later + * version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License along with + * this library; if not, write to the Free Software Foundation, Inc., 51 + * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + * + * Created on Mar 10, 2006 + */ +package pcgen.gui.converter; + +import java.awt.CardLayout; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.util.concurrent.BlockingQueue; +import java.util.concurrent.LinkedBlockingQueue; + +import javax.swing.JFrame; +import javax.swing.JPanel; +import javax.swing.WindowConstants; + +import pcgen.cdom.base.CDOMObject; +import pcgen.cdom.inst.ObjectCache; +import pcgen.gui.converter.event.ProgressEvent; +import pcgen.gui.converter.panel.ConvertSubPanel; +import pcgen.gui.converter.panel.GameModePanel; +import pcgen.gui.converter.panel.MessagePanel; +import pcgen.gui.converter.panel.SourceSelectionPanel; +import pcgen.gui.converter.panel.StartupPanel; +import pcgen.gui.converter.panel.WriteDirectoryPanel; +import pcgen.gui.utils.AWTUtilities; +import pcgen.persistence.lst.LstSystemLoader; + +public final class PCGenDataConvert extends JFrame +{ + + private final JPanel contentPanel = new JPanel(new CardLayout()); + + public void addNamedPanel(String name, JPanel panel) + { + contentPanel.add(panel, name); + } + + private PCGenDataConvert() + { + super("PCGenDataConvert"); + } + + public static PCGenDataConvert getConverter(CDOMObject pc) + throws InterruptedException + { + PCGenDataConvert frame = new PCGenDataConvert(); + frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); + BlockingQueue<ConvertSubPanel> panels = new LinkedBlockingQueue<ConvertSubPanel>(); + LstSystemLoader loader = new LstSystemLoader(); + panels.put(new StartupPanel(loader)); + + final ConvertPanel installPanel = new ConvertPanel(panels); + frame.addWindowListener(new WindowAdapter() + { + @Override + public void windowClosing(WindowEvent wEvent) + { + installPanel.checkExit(); + } + }); + + panels.put(new SourceSelectionPanel()); + panels.put(new GameModePanel(loader)); + + /* + * TODO Need to select Campaigns here... + */ + + panels.put(new WriteDirectoryPanel()); + + panels.put(new MessagePanel("PCGen Data Conversion Complete!", + ProgressEvent.NOT_ALLOWED)); + + frame.getContentPane().add(installPanel); + frame.pack(); + frame.setLocation(AWTUtilities.computeWindowLocation(frame)); + return frame; + } + + public static void main(String[] args) throws InterruptedException + { + getConverter(new ObjectCache()).setVisible(true); + } +} Added: Trunk/pcgen/code/src/java/pcgen/gui/converter/UnstretchingGridLayout.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/gui/converter/UnstretchingGridLayout.java (rev 0) +++ Trunk/pcgen/code/src/java/pcgen/gui/converter/UnstretchingGridLayout.java 2009-01-16 22:54:11 UTC (rev 9024) @@ -0,0 +1,125 @@ +/* + * Copyright (c) 2004-2009. + * + * This program is free software; you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by the Free Software + * Foundation; either version 2.0 of the License, or (at your option) any later + * version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License along with + * this library; if not, write to the Free Software Foundation, Inc., 51 + * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + * + * Created on Oct 16, 2004 + */ +package pcgen.gui.converter; + +import java.awt.Component; +import java.awt.Container; +import java.awt.Dimension; +import java.awt.GridLayout; +import java.awt.Insets; + +public class UnstretchingGridLayout extends GridLayout +{ + + public UnstretchingGridLayout() + { + super(); + } + + public UnstretchingGridLayout(int arg0, int arg1) + { + super(arg0, arg1); + } + + public UnstretchingGridLayout(int arg0, int arg1, int arg2, int arg3) + { + super(arg0, arg1, arg2, arg3); + } + + @Override + public void layoutContainer(Container parent) + { + synchronized (parent.getTreeLock()) + { + int componentCount = parent.getComponentCount(); + if (componentCount == 0) + { + return; + } + + int rowCount = getRows(); + int columnCount = getColumns(); + if (rowCount > 0) + { + columnCount = (componentCount + rowCount - 1) / rowCount; + } + else + { + rowCount = (componentCount + columnCount - 1) / columnCount; + } + + /* + * First loop is to determine the maximum row height and column + * width necessary for proper layout. + */ + int[] rowHeight = new int[rowCount]; + int[] columnWidth = new int[columnCount]; + for (int i = 0; i < componentCount; i++) + { + int row = i / columnCount; + int column = i % columnCount; + Component component = parent.getComponent(i); + Dimension d = component.getPreferredSize(); + rowHeight[row] = Math.max(rowHeight[row], d.height); + columnWidth[column] = Math.max(columnWidth[column], d.width); + } + // Avoid fetching the orientation & gaps/gutters in the loop + boolean leftToRight = parent.getComponentOrientation() + .isLeftToRight(); + int xGutter = getHgap(); + int yGutter = getVgap(); + + Insets insets = parent.getInsets(); + int yLoc = insets.top; + /* + * This loop actually does the placement. Note that it seems easier + * to do this with two loops (one for rows and one for columns) in + * order to simplify the calculation of the x and y location of the + * component. Is there an algorithm that would obliviate the need + * for the gate on componentCount and can avoid having to sum + * multiple values from the row* and column* arrays? + */ + for (int row = 0; row < rowHeight.length; row++) + { + int xLoc = insets.left; + for (int column = 0; column < columnCount; column++) + { + int i = row * columnCount + column; + if (i < componentCount) + { + Component component = parent.getComponent(i); + Dimension d = component.getPreferredSize(); + int x = leftToRight ? xLoc : xLoc - d.width; + component.setBounds(x, yLoc, d.width, d.height); + } + if (leftToRight) + { + xLoc += columnWidth[column] + xGutter; + } + else + { + xLoc -= columnWidth[column] + xGutter; + } + } + yLoc += rowHeight[row] + yGutter; + } + } + } +} \ No newline at end of file Added: Trunk/pcgen/code/src/java/pcgen/gui/converter/event/ProgressEvent.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/gui/converter/event/ProgressEvent.java (rev 0) +++ Trunk/pcgen/code/src/java/pcgen/gui/converter/event/ProgressEvent.java 2009-01-16 22:54:11 UTC (rev 9024) @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2006, 2009. + * + * This program is free software; you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by the Free Software + * Foundation; either version 2.0 of the License, or (at your option) any later + * version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License along with + * this library; if not, write to the Free Software Foundation, Inc., 51 + * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + * + * Created on Mar 10, 2006 + */ +package pcgen.gui.converter.event; + +import java.util.EventObject; + +public class ProgressEvent extends EventObject +{ + + public static final int NOT_ALLOWED = 1; + + public static final int ALLOWED = 0; + + private int ident; + + public ProgressEvent(Object arg0, int id) + { + super(arg0); + ident = id; + } + + public int getID() + { + return ident; + } +} Added: Trunk/pcgen/code/src/java/pcgen/gui/converter/event/ProgressListener.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/gui/converter/event/ProgressListener.java (rev 0) +++ Trunk/pcgen/code/src/java/pcgen/gui/converter/event/ProgressListener.java 2009-01-16 22:54:11 UTC (rev 9024) @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2006, 2009. + * + * This program is free software; you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by the Free Software + * Foundation; either version 2.0 of the License, or (at your option) any later + * version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License along with + * this library; if not, write to the Free Software Foundation, Inc., 51 + * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + * + * Created on Mar 10, 2006 + */ +package pcgen.gui.converter.event; + +import java.util.EventListener; + +public interface ProgressListener extends EventListener +{ + + public void progressAllowed(ProgressEvent pe); + + public void progressNotAllowed(ProgressEvent pe); +} Added: Trunk/pcgen/code/src/java/pcgen/gui/converter/event/ProgressMonitor.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/gui/converter/event/ProgressMonitor.java (rev 0) +++ Trunk/pcgen/code/src/java/pcgen/gui/converter/event/ProgressMonitor.java 2009-01-16 22:54:11 UTC (rev 9024) @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2006, 2009. + * + * This program is free software; you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by the Free Software + * Foundation; either version 2.0 of the License, or (at your option) any later + * version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License along with + * this library; if not, write to the Free Software Foundation, Inc., 51 + * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + * + * Created on Sep 23, 2006 + */ +package pcgen.gui.converter.event; + +public interface ProgressMonitor +{ + public void fireProgressEvent(int i); +} Added: Trunk/pcgen/code/src/java/pcgen/gui/converter/event/TaskStrategyListener.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/gui/converter/event/TaskStrategyListener.java (rev 0) +++ Trunk/pcgen/code/src/java/pcgen/gui/converter/event/TaskStrategyListener.java 2009-01-16 22:54:11 UTC (rev 9024) @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2006, 2009. + * + * This program is free software; you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License as published by the Free + * Software Foundation; either version 2.1 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more + * details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + * + * Created on Apr 9, 2006 + */ +package pcgen.gui.converter.event; + +import java.util.EventListener; + +public interface TaskStrategyListener extends EventListener +{ + + void processMessage(Object owner, String string); + + void processStatus(Object source, String string); + + void processActiveItem(Object source, String string); + +} Added: Trunk/pcgen/code/src/java/pcgen/gui/converter/event/TaskStrategyMessage.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/gui/converter/event/TaskStrategyMessage.java (rev 0) +++ Trunk/pcgen/code/src/java/pcgen/gui/converter/event/TaskStrategyMessage.java 2009-01-16 22:54:11 UTC (rev 9024) @@ -0,0 +1,88 @@ +/* + * Copyright (c) 2006, 2009. + * + * This program is free software; you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License as published by the Free + * Software Foundation; either version 2.1 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more + * details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + * + * Created on Apr 9, 2006 + */ +package pcgen.gui.converter.event; + +import javax.swing.event.EventListenerList; + +public final class TaskStrategyMessage +{ + + private TaskStrategyMessage() + { + super(); + } + + public static void sendMessage(Object owner, String string) + { + Object[] listeners = LISTENER_LIST.getListenerList(); + for (int i = listeners.length - 2; i >= 0; i -= 2) + { + if (listeners[i] == TaskStrategyListener.class) + { + ((TaskStrategyListener) listeners[i + 1]).processMessage(owner, + string); + } + } + } + + public static void sendStatus(Object source, String string) + { + Object[] listeners = LISTENER_LIST.getListenerList(); + for (int i = listeners.length - 2; i >= 0; i -= 2) + { + if (listeners[i] == TaskStrategyListener.class) + { + ((TaskStrategyListener) listeners[i + 1]).processStatus(source, + string); + } + } + } + + public static void sendActiveItem(Object source, String string) + { + Object[] listeners = LISTENER_LIST.getListenerList(); + for (int i = listeners.length - 2; i >= 0; i -= 2) + { + if (listeners[i] == TaskStrategyListener.class) + { + ((TaskStrategyListener) listeners[i + 1]).processActiveItem( + source, string); + } + } + } + + private static final EventListenerList LISTENER_LIST = new EventListenerList(); + + public static void addTaskStrategyListener(TaskStrategyListener listener) + { + LISTENER_LIST.add(TaskStrategyListener.class, listener); + } + + public static synchronized TaskStrategyListener[] getTaskStrategyListeners() + { + return LISTENER_LIST.getListeners(TaskStrategyListener.class); + } + + public static void removeTaskStrategyListener(TaskStrategyListener listener) + { + LISTENER_LIST.remove(TaskStrategyListener.class, listener); + } + +} Added: Trunk/pcgen/code/src/java/pcgen/gui/converter/panel/ConvertSubPanel.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/gui/converter/panel/ConvertSubPanel.java (rev 0) +++ Trunk/pcgen/code/src/java/pcgen/gui/converter/panel/ConvertSubPanel.java 2009-01-16 22:54:11 UTC (rev 9024) @@ -0,0 +1,142 @@ +/* + * Copyright (c) 2006, 2009. + * + * This program is free software; you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by the Free Software + * Foundation; either version 2.0 of the License, or (at your option) any later + * version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License along with + * this library; if not, write to the Free Software Foundation, Inc., 51 + * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + * + * Created on Mar 10, 2006 + */ +package pcgen.gui.converter.panel; + +import javax.swing.JPanel; +import javax.swing.event.EventListenerList; + +import pcgen.cdom.base.CDOMObject; +import pcgen.gui.converter.event.ProgressEvent; +import pcgen.gui.converter.event.ProgressListener; +import pcgen.gui.converter.event.ProgressMonitor; + +public abstract class ConvertSubPanel implements ProgressMonitor +{ + private ProgressSupport support; + + public boolean isLast() + { + return false; + } + + public ConvertSubPanel() + { + super(); + support = new ProgressSupport(this); + } + + public void addProgressListener(ProgressListener listener) + { + support.addProgressListener(listener); + } + + public ProgressListener[] getProgressListeners() + { + return support.getProgressListeners(); + } + + public void removeProgressListener(ProgressListener listener) + { + support.removeProgressListener(listener); + } + + public void fireProgressEvent(int id) + { + support.fireProgressEvent(id); + } + + public abstract boolean performAnalysis(CDOMObject pc); + + public abstract boolean autoAdvance(CDOMObject pc); + + public abstract void setupDisplay(JPanel panel, CDOMObject pc); + + public class ProgressSupport implements ProgressMonitor + { + + private final EventListenerList listenerList; + + private final Object source; + + public ProgressSupport(Object sourceObject) + { + super(); + if (sourceObject == null) + { + throw new IllegalArgumentException( + "Source for ProgressSupport cannot be null"); + } + source = sourceObject; + listenerList = new EventListenerList(); + } + + public void addProgressListener(ProgressListener listener) + { + listenerList.add(ProgressListener.class, listener); + } + + public synchronized ProgressListener[] getProgressListeners() + { + return listenerList.getListeners(ProgressListener.class); + } + + public void removeProgressListener(ProgressListener listener) + { + listenerList.remove(ProgressListener.class, listener); + } + + public void fireProgressEvent(int id) + { + Object[] listeners = listenerList.getListenerList(); + /* + * This list is decremented from the end of the list to the + * beginning in order to maintain consistent operation with how Java + * AWT and Swing listeners are notified of Events (they are in + * reverse order to how they were added to the Event-owning object). + */ + ProgressEvent ccEvent = null; + for (int i = listeners.length - 2; i >= 0; i -= 2) + { + if (listeners[i] == ProgressListener.class) + { + // Lazily create event + if (ccEvent == null) + { + ccEvent = new ProgressEvent(source, id); + } + switch (ccEvent.getID()) + { + case ProgressEvent.ALLOWED: + ((ProgressListener) listeners[i + 1]) + .progressAllowed(ccEvent); + break; + case ProgressEvent.NOT_ALLOWED: + ((ProgressListener) listeners[i + 1]) + .progressNotAllowed(ccEvent); + break; + default: + break; + } + } + } + } + } + +} Added: Trunk/pcgen/code/src/java/pcgen/gui/converter/panel/GameModePanel.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/gui/converter/panel/GameModePanel.java (rev 0) +++ Trunk/pcgen/code/src/java/pcgen/gui/converter/panel/GameModePanel.java 2009-01-16 22:54:11 UTC (rev 9024) @@ -0,0 +1,107 @@ +package pcgen.gui.converter.panel; + +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.List; + +import javax.swing.JLabel; +import javax.swing.JPanel; + +import pcgen.cdom.base.CDOMObject; +import pcgen.cdom.enumeration.ObjectKey; +import pcgen.core.GameMode; +import pcgen.core.Globals; +import pcgen.core.SettingsHandler; +import pcgen.core.SystemCollections; +import pcgen.gui.converter.event.ProgressEvent; +import pcgen.gui.utils.JComboBoxEx; +import pcgen.persistence.PersistenceLayerException; +import pcgen.persistence.lst.LstSystemLoader; +import pcgen.util.PropertyFactory; + +public class GameModePanel extends ConvertSubPanel +{ + + JComboBoxEx gameModeCombo; + + private final LstSystemLoader loader; + + public GameModePanel(LstSystemLoader sl) + { + loader = sl; + } + + @Override + public boolean autoAdvance(CDOMObject pc) + { + return false; + } + + @Override + public boolean performAnalysis(CDOMObject pc) + { + loader.loadPCCFilesInDirectory(pc.get(ObjectKey.DIRECTORY)); + try + { + loader.initRecursivePccFiles(); + } + catch (PersistenceLayerException e) + { + e.printStackTrace(); + return false; + } + Globals.sortPObjectListByName(Globals.getCampaignList()); + + Globals.createEmptyRace(); + + SettingsHandler.initGameModes(); + return saveGameMode(pc); + } + + private boolean saveGameMode(CDOMObject pc) + { + boolean advance = pc.get(ObjectKey.GAME_MODE) != null; + if (advance) + { + fireProgressEvent(ProgressEvent.ALLOWED); + } + return advance; + } + + private void getSelection(CDOMObject pc) + { + String gameModeKey = (String) gameModeCombo.getSelectedItem(); + if (gameModeKey != null) + { + GameMode gamemode = SystemCollections.getGameModeNamed(gameModeKey); + pc.put(ObjectKey.GAME_MODE, gamemode); + } + } + + @Override + public void setupDisplay(JPanel panel, final CDOMObject pc) + { + JLabel introLabel = new JLabel(PropertyFactory + .getString("in_qsrc_gameModeIntro")); + panel.add(introLabel); + + List<GameMode> games = SystemCollections.getUnmodifiableGameModeList(); + String gameModeNames[] = new String[games.size()]; + for (int i = 0; i < gameModeNames.length; i++) + { + gameModeNames[i] = games.get(i).getName(); + } + gameModeCombo = new JComboBoxEx(gameModeNames); + gameModeCombo.addActionListener(new ActionListener() + { + public void actionPerformed(ActionEvent arg0) + { + getSelection(pc); + saveGameMode(pc); + } + }); + gameModeCombo.setSelectedItem(SettingsHandler.getGame().getName()); + + panel.add(gameModeCombo); + } +} Added: Trunk/pcgen/code/src/java/pcgen/gui/converter/panel/MessagePanel.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/gui/converter/panel/MessagePanel.java (rev 0) +++ Trunk/pcgen/code/src/java/pcgen/gui/converter/panel/MessagePanel.java 2009-01-16 22:54:11 UTC (rev 9024) @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2006, 2009. + * + * This program is free software; you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by the Free Software + * Foundation; either version 2.0 of the License, or (at your option) any later + * version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License along with + * this library; if not, write to the Free Software Foundation, Inc., 51 + * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + * + * Created on Mar 10, 2006 + */ +package pcgen.gui.converter.panel; + +import java.awt.Dimension; +import java.util.StringTokenizer; + +import javax.swing.JLabel; +import javax.swing.JPanel; + +import pcgen.cdom.base.CDOMObject; +import pcgen.gui.converter.UnstretchingGridLayout; +import pcgen.gui.converter.event.ProgressEvent; + +public class MessagePanel extends ConvertSubPanel +{ + + private int progress; + private final JPanel message; + + public MessagePanel(String s, int i) + { + message = new JPanel(); + message.setLayout(new UnstretchingGridLayout(0, 1)); + StringTokenizer st = new StringTokenizer(s, "\n\r\f"); + while (st.hasMoreElements()) + { + message.add(new JLabel(st.nextToken())); + } + progress = i; + } + + @Override + public boolean performAnalysis(CDOMObject pc) + { + fireProgressEvent(progress); + return true; + } + + @Override + public boolean autoAdvance(CDOMObject pc) + { + return false; + } + + @Override + public void setupDisplay(JPanel panel, CDOMObject pc) + { + panel.add(message); + panel.setPreferredSize(new Dimension(800, 500)); + } + + @Override + public boolean isLast() + { + return ProgressEvent.NOT_ALLOWED == progress; + } + +} Added: Trunk/pcgen/code/src/java/pcgen/gui/converter/panel/SourceSelectionPanel.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/gui/converter/panel/SourceSelectionPanel.java (rev 0) +++ Trunk/pcgen/code/src/java/pcgen/gui/converter/panel/SourceSelectionPanel.java 2009-01-16 22:54:11 UTC (rev 9024) @@ -0,0 +1,139 @@ +/* + * Copyright (c) 2006, 2009. + * + * This program is free software; you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by the Free Software + * Foundation; either version 2.0 of the License, or (at your option) any later + * version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License along with + * this library; if not, write to the Free Software Foundation, Inc., 51 + * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + * + * Created on Mar 10, 2006 + */ +package pcgen.gui.converter.panel; + +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.io.File; + +import javax.swing.JButton; +import javax.swing.JFileChooser; +import javax.swing.JLabel; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.SpringLayout; + +import pcgen.cdom.base.CDOMObject; +import pcgen.cdom.enumeration.ObjectKey; +import pcgen.gui.converter.event.ProgressEvent; +import pcgen.gui.converter.event.TaskStrategyMessage; + +public class SourceSelectionPanel extends ConvertSubPanel +{ + + private File path = null; + + private SpringLayout layout = new SpringLayout(); + + private final JLabel fileLabel; + + public SourceSelectionPanel() + { + fileLabel = new JLabel(); + } + + public String getPath() + { + return path.getAbsolutePath(); + } + + @Override + public boolean performAnalysis(CDOMObject pc) + { + TaskStrategyMessage.sendStatus(this, "Finding Data Directories"); + path = pc.get(ObjectKey.DIRECTORY); + if (path != null) + { + fileLabel.setText(path.getAbsolutePath()); + } + else + { + path = new File("."); + } + pc.put(ObjectKey.DIRECTORY, path); + fireProgressEvent(ProgressEvent.ALLOWED); + return true; + } + + @Override + public boolean autoAdvance(CDOMObject pc) + { + return false; + } + + @Override + public void setupDisplay(JPanel panel, final CDOMObject pc) + { + panel.setLayout(layout); + JLabel label = new JLabel( + "Please select the Source Directory to Convert: "); + + JButton button = new JButton("Browse..."); + button.setMnemonic('r'); + button.addActionListener(new ActionListener() + { + public void actionPerformed(ActionEvent arg0) + { + JFileChooser chooser = new JFileChooser(); + chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); + chooser.setDialogType(JFileChooser.OPEN_DIALOG); + chooser.setSelectedFile(path); + while (true) + { + int open = chooser.showOpenDialog(null); + if (open == JFileChooser.APPROVE_OPTION) + { + File fileToOpen = chooser.getSelectedFile(); + if (fileToOpen.isDirectory()) + { + path = fileToOpen; + pc.put(ObjectKey.DIRECTORY, path); + fileLabel.setText(path.getAbsolutePath()); + break; + } + JOptionPane.showMessageDialog(null, + "Selection must be a valid Directory"); + chooser.setSelectedFile(path); + } + else if (open == JFileChooser.CANCEL_OPTION) + { + break; + } + } + } + }); + panel.add(label); + panel.add(fileLabel); + panel.add(button); + layout.putConstraint(SpringLayout.NORTH, label, 50, SpringLayout.NORTH, + panel); + layout.putConstraint(SpringLayout.NORTH, fileLabel, 75 + label + .getPreferredSize().height, SpringLayout.NORTH, panel); + layout.putConstraint(SpringLayout.NORTH, button, 75 + label + .getPreferredSize().height, SpringLayout.NORTH, panel); + layout.putConstraint(SpringLayout.WEST, label, 25, SpringLayout.WEST, + panel); + layout.putConstraint(SpringLayout.WEST, fileLabel, 25, + SpringLayout.WEST, panel); + layout.putConstraint(SpringLayout.EAST, button, -50, SpringLayout.EAST, + panel); + fileLabel.setText(path.getAbsolutePath()); + } +} Added: Trunk/pcgen/code/src/java/pcgen/gui/converter/panel/StartupPanel.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/gui/converter/panel/StartupPanel.java (rev 0) +++ Trunk/pcgen/code/src/java/pcgen/gui/converter/panel/StartupPanel.java 2009-01-16 22:54:11 UTC (rev 9024) @@ -0,0 +1,91 @@ +/* + * Copyright (c) 2006, 2009. + * + * This program is free software; you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by the Free Software + * Foundation; either version 2.0 of the License, or (at your option) any later + * version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License along with + * this library; if not, write to the Free Software Foundation, Inc., 51 + * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + * + * Created on Mar 10, 2006 + */ +package pcgen.gui.converter.panel; + +import gmgen.pluginmgr.PluginLoader; + +import java.awt.Dimension; + +import javax.swing.JLabel; +import javax.swing.JPanel; + +import pcgen.cdom.base.CDOMObject; +import pcgen.cdom.base.Constants; +import pcgen.core.SettingsHandler; +import pcgen.gui.converter.UnstretchingGridLayout; +import pcgen.gui.converter.event.ProgressEvent; +import pcgen.persistence.lst.LstSystemLoader; + +public class StartupPanel extends ConvertSubPanel +{ + + private final JPanel message; + + private final LstSystemLoader loader; + + public StartupPanel(LstSystemLoader sl) + { + loader = sl; + message = new JPanel(); + message.setLayout(new UnstretchingGridLayout(0, 1)); + message.add(new JLabel("Welcome to the PCGen 5.16 Data Converter...")); + message.add(new JLabel("Loading Game Modes and Campaign Information.")); + message.add(new JLabel("Next button will become active " + + "when initialization is complete.")); + } + + @Override + public boolean performAnalysis(CDOMObject pc) + { + new Thread(new Runnable() + { + public void run() + { + SettingsHandler.readOptionsProperties(); + SettingsHandler.getOptionsFromProperties(null); + PluginLoader ploader = PluginLoader.inst(); + ploader.startSystemPlugins(Constants.s_SYSTEM_TOKENS); + loader.loadGameModes(); + fireProgressEvent(ProgressEvent.ALLOWED); + } + }).start(); + return true; + } + + @Override + public boolean autoAdvance(CDOMObject pc) + { + return false; + } + + @Override + public void setupDisplay(JPanel panel, CDOMObject pc) + { + panel.add(message); + panel.setPreferredSize(new Dimension(800, 500)); + } + + @Override + public boolean isLast() + { + return false; + } + +} Added: Trunk/pcgen/code/src/java/pcgen/gui/converter/panel/WriteDirectoryPanel.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/gui/converter/panel/WriteDirectoryPanel.java (rev 0) +++ Trunk/pcgen/code/src/java/pcgen/gui/converter/panel/WriteDirectoryPanel.java 2009-01-16 22:54:11 UTC (rev 9024) @@ -0,0 +1,140 @@ +/* + * Copyright (c) 2006, 2009. + * + * This program is free software; you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by the Free Software + * Foundation; either version 2.0 of the License, or (at your option) any later + * version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License along with + * this library; if not, write to the Free Software Foundation, Inc., 51 + * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + * + * Created on Mar 10, 2006 + */ +package pcgen.gui.converter.panel; + +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.io.File; + +import javax.swing.JButton; +import javax.swing.JFileChooser; +import javax.swing.JLabel; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.SpringLayout; + +import pcgen.cdom.base.CDOMObject; +import pcgen.cdom.enumeration.ObjectKey; +import pcgen.gui.converter.event.ProgressEvent; +import pcgen.gui.converter.event.TaskStrategyMessage; + +public class WriteDirectoryPanel extends ConvertSubPanel +{ + + private File path = null; + + private SpringLayout layout = new SpringLayout(); + + private final JLabel fileLabel; + + public WriteDirectoryPanel() + { + fileLabel = new JLabel(); + } + + public String getPath() + { + return path.getAbsolutePath(); + } + + @Override + public boolean performAnalysis(CDOMObject pc) + { + TaskStrategyMessage.sendStatus(this, "Finding Data Directories"); + path = pc.get(ObjectKey.WRITE_DIRECTORY); + if (path != null) + { + fileLabel.setText(path.getAbsolutePath()); + } + else + { + path = new File("."); + } + pc.put(ObjectKey.WRITE_DIRECTORY, path); + fireProgressEvent(ProgressEvent.ALLOWED); + return true; + } + + @Override + public boolean autoAdvance(CDOMObject pc) + { + return false; + } + + @Override + public void setupDisplay(JPanel panel, final CDOMObject pc) + { + panel.setLayout(layout); + JLabel label = new JLabel( + "Please select the Directory where Converted files should be written: "); + JButton button = new JButton("Browse..."); + button.setMnemonic('r'); + button.addActionListener(new ActionListener() + { + public void actionPerformed(ActionEvent arg0) + { + JFileChooser chooser = new JFileChooser(); + chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); + chooser.setDialogType(JFileChooser.OPEN_DIALOG); + chooser.setSelectedFile(path); + while (true) + { + int open = chooser.showOpenDialog(null); + if (open == JFileChooser.APPROVE_OPTION) + { + File fileToOpen = chooser.getSelectedFile(); + if (fileToOpen.isDirectory() && fileToOpen.canRead() + && fileToOpen.canWrite()) + { + path = fileToOpen; + pc.put(ObjectKey.WRITE_DIRECTORY, path); + fileLabel.setText(path.getAbsolutePath()); + break; + } + JOptionPane.showMessageDialog(null, + "Selection must be a valid " + + "(readable & writeable) Directory"); + chooser.setSelectedFile(path); + } + else if (open == JFileChooser.CANCEL_OPTION) + { + break; + } + } + } + }); + panel.add(label); + panel.add(fileLabel); + panel.add(button); + layout.putConstraint(SpringLayout.NORTH, label, 50, SpringLayout.NORTH, + panel); + layout.putConstraint(SpringLayout.NORTH, fileLabel, 75 + label + .getPreferredSize().height, SpringLayout.NORTH, panel); + layout.putConstraint(SpringLayout.NORTH, button, 75 + label + .getPreferredSize().height, SpringLayout.NORTH, panel); + layout.putConstraint(SpringLayout.WEST, label, 25, SpringLayout.WEST, + panel); + layout.putConstraint(SpringLayout.WEST, fileLabel, 25, + SpringLayout.WEST, panel); + layout.putConstraint(SpringLayout.EAST, button, -50, SpringLayout.EAST, + panel); + fileLabel.setText(path.getAbsolutePath()); + } +} Added: Trunk/pcgen/code/src/java/pcgen/gui/utils/AWTUtilities.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/gui/utils/AWTUtilities.java (rev 0) +++ Trunk/pcgen/code/src/java/pcgen/gui/utils/AWTUtilities.java 2009-01-16 22:54:11 UTC (rev 9024) @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2006, 2009 + * + * This program is free software; you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by the Free Software + * Foundation; either version 2.0 of the License, or (at your option) any later + * version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License along with + * this library; if not, write to the Free Software Foundation, Inc., 51 + * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + * + * Created on Mar 10, 2006 + */ +package pcgen.gui.utils; + +import java.awt.Dimension; +import java.awt.Point; +import java.awt.Window; + +public final class AWTUtilities +{ + + private AWTUtilities() + { + // Can't instantiate + } + + public static Point computeWindowLocation(Window window) + { + Dimension scrnSz = window.getToolkit().getScreenSize(); + Dimension windowSize = window.getPreferredSize(); + + int x = (scrnSz.width - windowSize.width) / 2; + int y = (scrnSz.height - windowSize.height) / 2; + + return new Point(x, y); + } + +} Added: Trunk/pcgen/code/src/java/pcgen/gui/utils/CursorControlUtilities.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/gui/utils/CursorControlUtilities.java (rev 0) +++ Trunk/pcgen/code/src/java/pcgen/gui/utils/CursorControlUtilities.java 2009-01-16 22:54:11 UTC (rev 9024) @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2006, 2009. + * + * This program is free software; you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License as published by the Free + * Software Foundation; either version 2.1 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more + * details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + * + * Created on Apr 19, 2006 + */ +package pcgen.gui.utils; + +import java.awt.Cursor; +import java.awt.event.MouseAdapter; + +import javax.swing.JComponent; +import javax.swing.RootPaneContainer; + +public final class CursorControlUtilities +{ + + private static final Cursor WAIT_CURSOR = Cursor + .getPredefinedCursor(Cursor.WAIT_CURSOR); + + private static final Cursor DEFAULT_CURSOR = Cursor + .getPredefinedCursor(Cursor.DEFAULT_CURSOR); + + private static final MouseAdapter CLICK_CONSUMER = new MouseAdapter() + { + // Empty class (designed to consume all clicks with no effect) + }; + + private CursorControlUtilities() + { + // Utility class cannot be instantiated + } + + public static void startWaitCursor(JComponent component) + { + RootPaneContainer root = ((RootPaneContainer) component + .getTopLevelAncestor()); + root.getGlassPane().setCursor(WAIT_CURSOR); + root.getGlassPane().addMouseListener(CLICK_CONSUMER); + root.getGlassPane().setVisible(true); + root.getRootPane().validate(); + } + + public static void stopWaitCursor(JComponent component) + { + RootPaneContainer root = ((RootPaneContainer) component + .getTopLevelAncestor()); + root.getGlassPane().setCursor(DEFAULT_CURSOR); + root.getGlassPane().removeMouseListener(CLICK_CONSUMER); + root.getGlassPane().setVisible(false); + root.getRootPane().validate(); + } +} \ No newline at end of file Modified: Trunk/pcgen/code/src/java/pcgen/persistence/lst/LstSystemLoader.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/persistence/lst/LstSystemLoader.java 2009-01-16 21:39:52 UTC (rev 9023) +++ Trunk/pcgen/code/src/java/pcgen/persistence/lst/LstSystemLoader.java 2009-01-16 22:54:11 UTC (rev 9024) @@ -398,7 +398,7 @@ .getAbsolutePath()); // Now that those are loaded, make sure to initialize the recursive campaigns - campaignLoader.initRecursivePccFiles(); + initRecursivePccFiles(); Globals.sortPObjectListByName(Globals.getCampaignList()); } @@ -1110,7 +1110,7 @@ new File(aDirectory).list(pccFileFilter); } - private void loadPCCFilesInDirectory(File aDirectory) + public void loadPCCFilesInDirectory(File aDirectory) { aDirectory.list(pccFileFilter); } @@ -1179,7 +1179,7 @@ } } - private void loadGameModes() + public void loadGameModes() { final String[] gameFiles = getGameFilesList(); @@ -1621,4 +1621,9 @@ setChanged(); } + public void initRecursivePccFiles() throws PersistenceLayerException + { + campaignLoader.initRecursivePccFiles(); + } + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jde...@us...> - 2009-01-17 12:41:38
|
Revision: 9034 http://pcgen.svn.sourceforge.net/pcgen/?rev=9034&view=rev Author: jdempsey Date: 2009-01-17 12:41:28 +0000 (Sat, 17 Jan 2009) Log Message: ----------- Data converter UI - Add campaign selection panel and beginnings of a confirm info panel Modified Paths: -------------- Trunk/pcgen/code/src/java/pcgen/cdom/enumeration/ListKey.java Trunk/pcgen/code/src/java/pcgen/gui/converter/PCGenDataConvert.java Added Paths: ----------- Trunk/pcgen/code/src/java/pcgen/gui/converter/panel/CampaignPanel.java Modified: Trunk/pcgen/code/src/java/pcgen/cdom/enumeration/ListKey.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/cdom/enumeration/ListKey.java 2009-01-17 10:45:05 UTC (rev 9033) +++ Trunk/pcgen/code/src/java/pcgen/cdom/enumeration/ListKey.java 2009-01-17 12:41:28 UTC (rev 9034) @@ -55,6 +55,7 @@ import pcgen.cdom.reference.CDOMSingleRef; import pcgen.core.Ability; import pcgen.core.ArmorProf; +import pcgen.core.Campaign; import pcgen.core.DamageReduction; import pcgen.core.Deity; import pcgen.core.Description; @@ -253,6 +254,7 @@ public static final ListKey<EqModRef> EQMOD_INFO = new ListKey<EqModRef>(); public static final ListKey<CampaignURL> CAMPAIGN_URL = new ListKey<CampaignURL>(); public static final ListKey<Qualifier> FORWARDREF = new ListKey<Qualifier>(); + public static final ListKey<Campaign> CAMPAIGN = new ListKey<Campaign>(); //These are case sensitive, please do not change them to upper case public static final ListKey<String> HIDDEN_Equipment = new ListKey<String>(); Modified: Trunk/pcgen/code/src/java/pcgen/gui/converter/PCGenDataConvert.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/gui/converter/PCGenDataConvert.java 2009-01-17 10:45:05 UTC (rev 9033) +++ Trunk/pcgen/code/src/java/pcgen/gui/converter/PCGenDataConvert.java 2009-01-17 12:41:28 UTC (rev 9034) @@ -28,8 +28,10 @@ import javax.swing.WindowConstants; import pcgen.cdom.base.CDOMObject; +import pcgen.cdom.enumeration.ListKey; import pcgen.cdom.inst.ObjectCache; import pcgen.gui.converter.event.ProgressEvent; +import pcgen.gui.converter.panel.CampaignPanel; import pcgen.gui.converter.panel.ConvertSubPanel; import pcgen.gui.converter.panel.GameModePanel; import pcgen.gui.converter.panel.MessagePanel; @@ -75,12 +77,11 @@ panels.put(new SourceSelectionPanel()); panels.put(new GameModePanel(loader)); + panels.put(new CampaignPanel()); - /* - * TODO Need to select Campaigns here... - */ - panels.put(new WriteDirectoryPanel()); + panels.put(new MessagePanel(buildReadyToConvertMessage(pc), + ProgressEvent.ALLOWED)); panels.put(new MessagePanel("PCGen Data Conversion Complete!", ProgressEvent.NOT_ALLOWED)); @@ -91,6 +92,13 @@ return frame; } + private static String buildReadyToConvertMessage(CDOMObject pc) + { + StringBuffer result = new StringBuffer("Ready to convert.\n"); + result.append("Press Next to beign converting using the following settings:\n"); + return result.toString(); + } + public static void main(String[] args) throws InterruptedException { getConverter(new ObjectCache()).setVisible(true); Added: Trunk/pcgen/code/src/java/pcgen/gui/converter/panel/CampaignPanel.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/gui/converter/panel/CampaignPanel.java (rev 0) +++ Trunk/pcgen/code/src/java/pcgen/gui/converter/panel/CampaignPanel.java 2009-01-17 12:41:28 UTC (rev 9034) @@ -0,0 +1,261 @@ +/* + * CampaignPanel.java + * Copyright 2008 (C) James Dempsey + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Created on 17/01/2009 10:59:55 PM + * + * $Id: $ + */ +package pcgen.gui.converter.panel; + +import java.awt.event.MouseEvent; +import java.io.File; +import java.util.ArrayList; +import java.util.List; + +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.ListSelectionModel; +import javax.swing.SpringLayout; +import javax.swing.event.ListSelectionEvent; +import javax.swing.event.ListSelectionListener; +import javax.swing.table.AbstractTableModel; + +import pcgen.cdom.base.CDOMObject; +import pcgen.cdom.enumeration.ListKey; +import pcgen.cdom.enumeration.ObjectKey; +import pcgen.core.Campaign; +import pcgen.core.GameMode; +import pcgen.core.Globals; +import pcgen.gui.converter.event.ProgressEvent; + +/** + * The Class <code>CampaignPanel</code> displays a panel allowing + * the user to select the campaigns to be converted. + * + * Last Editor: $Author: $ + * Last Edited: $Date: $ + * + * @author James Dempsey <jde...@us...> + * @version $Revision: $ + */ +public class CampaignPanel extends ConvertSubPanel +{ + + private SpringLayout layout = new SpringLayout(); + + private List<Campaign> gameModeCampaigns; + private String folderName; + + /* (non-Javadoc) + * @see pcgen.gui.converter.panel.ConvertSubPanel#autoAdvance(pcgen.cdom.base.CDOMObject) + */ + @Override + public boolean autoAdvance(CDOMObject pc) + { + return false; + } + + /* (non-Javadoc) + * @see pcgen.gui.converter.panel.ConvertSubPanel#performAnalysis(pcgen.cdom.base.CDOMObject) + */ + @Override + public boolean performAnalysis(CDOMObject pc) + { + GameMode game = pc.get(ObjectKey.GAME_MODE); + List<String> gameModeList = new ArrayList<String>(); + gameModeList.add(game.getName()); + + File sourceFolder = pc.get(ObjectKey.DIRECTORY); + folderName = sourceFolder.toURI().toString(); + + // Only add those campaigns in the user's chosen folder and game mode + List<Campaign> allCampaigns = Globals.getCampaignList(); + gameModeCampaigns = new ArrayList<Campaign>(); + for (Campaign campaign : allCampaigns) + { + if (campaign.isGameMode(gameModeList)) + { + if (campaign.getSourceURI().toString().startsWith(folderName)) + { + gameModeCampaigns.add(campaign); + } + } + } + return false; + } + + /* (non-Javadoc) + * @see pcgen.gui.converter.panel.ConvertSubPanel#setupDisplay(javax.swing.JPanel, pcgen.cdom.base.CDOMObject) + */ + @Override + public void setupDisplay(JPanel panel, final CDOMObject pc) + { + panel.setLayout(layout); + JLabel introLabel = + new JLabel("Please select the Campaign(s) to Convert:"); + panel.add(introLabel); + layout.putConstraint(SpringLayout.NORTH, introLabel, 20, + SpringLayout.NORTH, panel); + layout.putConstraint(SpringLayout.WEST, introLabel, 25, + SpringLayout.WEST, panel); + + final CampaignTableModel model = new CampaignTableModel(gameModeCampaigns, folderName); + final JTable table = new JTable(model){ + //Implement table cell tool tips. + public String getToolTipText(MouseEvent e) { + java.awt.Point p = e.getPoint(); + int rowIndex = rowAtPoint(p); + int colIndex = columnAtPoint(p); + String tip = String.valueOf(getValueAt(rowIndex, colIndex)); + return tip; + } + }; + table.getSelectionModel().addListSelectionListener( + new ListSelectionListener() + { + public void valueChanged(ListSelectionEvent event) + { + ListSelectionModel lsm = + (ListSelectionModel) event.getSource(); + + //int viewRow = table.getSelectedRow(); + pc.removeListFor(ListKey.CAMPAIGN); + if (lsm.isSelectionEmpty()) + { + fireProgressEvent(ProgressEvent.NOT_ALLOWED); + } + else + { + // Find out which indexes are selected. + int minIndex = lsm.getMinSelectionIndex(); + int maxIndex = lsm.getMaxSelectionIndex(); + for (int i = minIndex; i <= maxIndex; i++) + { + if (lsm.isSelectedIndex(i)) + { + int modelRow = table.convertRowIndexToModel(i); + Campaign selCampaign = + (Campaign) model + .getValueAt(modelRow, 0); + pc.addToListFor(ListKey.CAMPAIGN, selCampaign); + } + } + fireProgressEvent(ProgressEvent.ALLOWED); + } + } + } + ); + + JScrollPane listScroller = new JScrollPane(table); + panel.add(listScroller); + layout.putConstraint(SpringLayout.NORTH, listScroller, 20, + SpringLayout.SOUTH, introLabel); + layout.putConstraint(SpringLayout.WEST, listScroller, 25, + SpringLayout.WEST, panel); + layout.putConstraint(SpringLayout.SOUTH, listScroller, -50, + SpringLayout.SOUTH, panel); + layout.putConstraint(SpringLayout.EAST, listScroller, -25, + SpringLayout.EAST, panel); + + } + + /** + * The model of the campaign table. + */ + @SuppressWarnings("serial") + public class CampaignTableModel extends AbstractTableModel + { + + /** The column names. */ + private String[] columnNames = {"Campaign", "Location"}; + + /** The row data. */ + private Object[][] rowData; + + /** + * Instantiates a new campaign table model. + * + * @param campList the list of campaigns to be displayed + * @param prefix the prefix to be removed from each campaign location. + */ + public CampaignTableModel(List<Campaign> campList, String prefix) + { + rowData = new Object[campList.size()][2]; + int i = 0; + for (Campaign campaign : campList) + { + rowData[i++] = + new Object[]{ + campaign, + campaign.getSourceURI().toString().substring( + prefix.length())}; + } + } + + /* (non-Javadoc) + * @see javax.swing.table.AbstractTableModel#getColumnName(int) + */ + public String getColumnName(int col) + { + return columnNames[col].toString(); + } + + /* (non-Javadoc) + * @see javax.swing.table.TableModel#getRowCount() + */ + public int getRowCount() + { + return rowData.length; + } + + /* (non-Javadoc) + * @see javax.swing.table.TableModel#getColumnCount() + */ + public int getColumnCount() + { + return columnNames.length; + } + + /* (non-Javadoc) + * @see javax.swing.table.TableModel#getValueAt(int, int) + */ + public Object getValueAt(int row, int col) + { + return rowData[row][col]; + } + + /* (non-Javadoc) + * @see javax.swing.table.AbstractTableModel#isCellEditable(int, int) + */ + public boolean isCellEditable(int row, int col) + { + return false; + } + + /* (non-Javadoc) + * @see javax.swing.table.AbstractTableModel#setValueAt(java.lang.Object, int, int) + */ + public void setValueAt(Object value, int row, int col) + { + // read only + } + } + +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jay...@us...> - 2009-01-23 07:36:39
|
Revision: 9064 http://pcgen.svn.sourceforge.net/pcgen/?rev=9064&view=rev Author: jaymecox Date: 2009-01-23 07:36:34 +0000 (Fri, 23 Jan 2009) Log Message: ----------- Fixes for [ pcgen-Bugs-2387797 ] TEMPBONUS:FEAT= broken for abilities Modified Paths: -------------- Trunk/pcgen/code/src/java/pcgen/gui/tabs/InfoTempMod.java Trunk/pcgen/code/src/java/pcgen/io/PCGVer2Creator.java Trunk/pcgen/code/src/java/pcgen/io/PCGVer2Parser.java Modified: Trunk/pcgen/code/src/java/pcgen/gui/tabs/InfoTempMod.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/gui/tabs/InfoTempMod.java 2009-01-23 04:46:42 UTC (rev 9063) +++ Trunk/pcgen/code/src/java/pcgen/gui/tabs/InfoTempMod.java 2009-01-23 07:36:34 UTC (rev 9064) @@ -2570,6 +2570,9 @@ } // + // Do we also need to Iterate Globals.getAbilityKeyIterator(Constants.ALL_CATEGORIES); ? + // or will they be covered by getClassList()? + // // iterate thru all PC's Classes for (PCClass aClass : pc.getClassList()) { Modified: Trunk/pcgen/code/src/java/pcgen/io/PCGVer2Creator.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/io/PCGVer2Creator.java 2009-01-23 04:46:42 UTC (rev 9063) +++ Trunk/pcgen/code/src/java/pcgen/io/PCGVer2Creator.java 2009-01-23 07:36:34 UTC (rev 9064) @@ -2181,7 +2181,7 @@ // TODO Isn't this the same as outString? Hmm, yes it is, why was it coded this way? final String tarString = tempBonusName(creObj, tarObj); buffer.append(tarString); - + // TODO Why do we loop through the bonuses again? Are there sub bonuses for each bouns? for (BonusObj subBonus : thePC.getTempBonusList()) { @@ -2508,7 +2508,6 @@ final StringBuffer cb = new StringBuffer(); cb.append(TAG_TEMPBONUS).append(':'); - if (creator instanceof PObject) { final PObject oCreator = (PObject) creator; @@ -2543,12 +2542,13 @@ } cb.append(EntityEncoder.encode(oCreator.getKeyName())); + // Hmm, need to get the Type of oCreater also? + // Might be required so the PCGVer2Parser can search correct type to re-create } else { return Constants.EMPTY_STRING; } - cb.append('|'); cb.append(TAG_TEMPBONUSTARGET).append(':'); Modified: Trunk/pcgen/code/src/java/pcgen/io/PCGVer2Parser.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/io/PCGVer2Parser.java 2009-01-23 04:46:42 UTC (rev 9063) +++ Trunk/pcgen/code/src/java/pcgen/io/PCGVer2Parser.java 2009-01-23 07:36:34 UTC (rev 9064) @@ -209,7 +209,7 @@ */ private List<BonusObj> getBonusFromName(String sName, String tName) { - //sName = SPELL=Haste + //sName = NAME=Haste //tName = PC String sourceStr = sName.substring(TAG_TEMPBONUS.length() + 1); String targetStr = tName.substring(TAG_TEMPBONUSTARGET.length() + 1); @@ -222,7 +222,15 @@ oSource = thePC.getFeatKeyed(sourceStr); if (oSource == null) { - oSource = Globals.getAbilityKeyed("Special Ability", sourceStr); + for (final AbilityCategory cat : SettingsHandler.getGame().getAllAbilityCategories()) + { + Object abilSourceObj = null; + abilSourceObj = Globals.getAbilityKeyed(cat, sourceStr); + if (abilSourceObj != null) + { + oSource = abilSourceObj; + } + } } } else if (sourceStr.startsWith(TAG_SPELL + '=')) @@ -2261,7 +2269,7 @@ } //# EquipSet Temp Bonuses - //EQSETBONUS:0.2|TEMPBONUS:SPELL=Haste|TBTARGET:PC|TEMPBONUS:SPELL=Shield of Faith|TBTARGET:PC + //EQSETBONUS:0.2|TEMPBONUS:NAME=Haste|TBTARGET:PC|TEMPBONUS:SPELL=Shield of Faith|TBTARGET:PC final List<BonusObj> aList = new ArrayList<BonusObj>(); for (final PCGElement element : tokens.getElements()) @@ -5280,11 +5288,6 @@ aFeat = Globals.getAbilityKeyed("Special Ability", cKey); } - // if (aFeat == null) - // { - // aFeat = Globals.getAbilityNamed("FEAT", cKey); - // } - if (aFeat != null) { newB = Bonus.newBonus(bonus); @@ -5368,6 +5371,11 @@ newB.setCreatorObject(aSpell); } } + else if (cType.equals(TAG_NAME)) + { + newB = Bonus.newBonus(bonus); + //newB.setCreatorObject(thePC); + } if (newB == null) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <th...@us...> - 2009-01-28 00:42:29
|
Revision: 9122 http://pcgen.svn.sourceforge.net/pcgen/?rev=9122&view=rev Author: thpr Date: 2009-01-28 00:42:24 +0000 (Wed, 28 Jan 2009) Log Message: ----------- [ 2534389 ] CHOOSE:SPELLS bug Issue#: 2534389 Modified Paths: -------------- Trunk/pcgen/code/src/java/pcgen/cdom/base/CDOMList.java Trunk/pcgen/code/src/java/pcgen/cdom/enumeration/Type.java Trunk/pcgen/code/src/java/pcgen/core/chooser/SpellsChoiceManager.java Trunk/pcgen/code/src/java/pcgen/rules/context/AbstractReferenceContext.java Modified: Trunk/pcgen/code/src/java/pcgen/cdom/base/CDOMList.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/cdom/base/CDOMList.java 2009-01-28 00:34:07 UTC (rev 9121) +++ Trunk/pcgen/code/src/java/pcgen/cdom/base/CDOMList.java 2009-01-28 00:42:24 UTC (rev 9122) @@ -40,4 +40,6 @@ public Class<T> getListClass(); public String getKeyName(); + + public boolean isType(String type); } Modified: Trunk/pcgen/code/src/java/pcgen/cdom/enumeration/Type.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/cdom/enumeration/Type.java 2009-01-28 00:34:07 UTC (rev 9121) +++ Trunk/pcgen/code/src/java/pcgen/cdom/enumeration/Type.java 2009-01-28 00:42:24 UTC (rev 9122) @@ -78,6 +78,8 @@ public static final Type TEMPORARY = getConstant("TEMPORARY"); + public static final Type DIVINE = getConstant("Divine"); + /** * This is used to provide a unique ordinal to each constant in this class */ Modified: Trunk/pcgen/code/src/java/pcgen/core/chooser/SpellsChoiceManager.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/chooser/SpellsChoiceManager.java 2009-01-28 00:34:07 UTC (rev 9121) +++ Trunk/pcgen/code/src/java/pcgen/core/chooser/SpellsChoiceManager.java 2009-01-28 00:42:24 UTC (rev 9122) @@ -426,15 +426,12 @@ public void conditionallyAdd(Spell spell, PlayerCharacter pc, List<Spell> availableList) { - if (!spell.isType(listname)) - { - return; - } - HashMapToList<CDOMList<Spell>, Integer> levelInfo = pc.getLevelInfo(spell); - boolean useDomain = "DIVINE".equalsIgnoreCase(listname); + HashMapToList<CDOMList<Spell>, Integer> levelInfo = SpellLevel + .getMasterLevelInfo(null, spell); + levelInfo.addAllLists(pc.getPCBasedLevelInfo(spell)); for (CDOMList<Spell> spellList : levelInfo.getKeySet()) { - if (useDomain && spellList instanceof DomainSpellList) + if (spellList.isType(listname)) { for (Integer level : levelInfo.getListFor(spellList)) { @@ -445,28 +442,6 @@ } } } - else - { - for (PCClass cl : pc.getClassList()) - { - if (!listname.equalsIgnoreCase(cl.getSpellType())) - { - continue; - } - if (cl.getSpellLists(pc).contains(spellList)) - { - for (Integer level : levelInfo - .getListFor(spellList)) - { - if (passesRestriction(spell, pc, level)) - { - availableList.add(spell); - return; - } - } - } - } - } } } @@ -518,7 +493,9 @@ public void conditionallyAdd(Spell spell, PlayerCharacter pc, List<Spell> availableList) { - HashMapToList<CDOMList<Spell>, Integer> levelInfo = pc.getLevelInfo(spell); + HashMapToList<CDOMList<Spell>, Integer> levelInfo = SpellLevel + .getMasterLevelInfo(null, spell); + levelInfo.addAllLists(pc.getPCBasedLevelInfo(spell)); for (CDOMList<Spell> spellList : levelInfo.getKeySet()) { for (Integer level : levelInfo.getListFor(spellList)) Modified: Trunk/pcgen/code/src/java/pcgen/rules/context/AbstractReferenceContext.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/rules/context/AbstractReferenceContext.java 2009-01-28 00:34:07 UTC (rev 9121) +++ Trunk/pcgen/code/src/java/pcgen/rules/context/AbstractReferenceContext.java 2009-01-28 00:42:24 UTC (rev 9122) @@ -329,6 +329,7 @@ for (Domain d : domains) { DomainSpellList dsl = constructCDOMObject(DOMAINSPELLLIST_CLASS, d.getKeyName()); + dsl.addToListFor(ListKey.TYPE, Type.DIVINE); d.put(ObjectKey.DOMAIN_SPELLLIST, dsl); } Collection<PCClass> classes = getConstructedCDOMObjects(PCClass.class); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <th...@us...> - 2009-02-01 20:43:45
|
Revision: 9206 http://pcgen.svn.sourceforge.net/pcgen/?rev=9206&view=rev Author: thpr Date: 2009-02-01 20:43:40 +0000 (Sun, 01 Feb 2009) Log Message: ----------- docs Modified Paths: -------------- Trunk/pcgen/code/src/java/pcgen/base/formula/Formula.java Trunk/pcgen/code/src/java/pcgen/base/lang/StringUtil.java Trunk/pcgen/code/src/java/pcgen/cdom/base/CDOMList.java Trunk/pcgen/code/src/java/pcgen/cdom/base/ChoiceSet.java Trunk/pcgen/code/src/java/pcgen/cdom/base/ChooseResultActor.java Trunk/pcgen/code/src/java/pcgen/cdom/base/FormulaFactory.java Trunk/pcgen/code/src/java/pcgen/cdom/base/PersistentChoiceActor.java Trunk/pcgen/code/src/java/pcgen/cdom/base/PersistentTransitionChoice.java Trunk/pcgen/code/src/java/pcgen/cdom/base/TransitionChoice.java Modified: Trunk/pcgen/code/src/java/pcgen/base/formula/Formula.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/base/formula/Formula.java 2009-02-01 11:34:51 UTC (rev 9205) +++ Trunk/pcgen/code/src/java/pcgen/base/formula/Formula.java 2009-02-01 20:43:40 UTC (rev 9206) @@ -27,10 +27,57 @@ */ public interface Formula { + /** + * Resolves the formula relative to the given PlayerCharacter and source + * object. Variables are taken from the active objects on the + * PlayerCharacter, and any required context beyond the PlayerCharacter is + * taken from the source object. Formatting of the source String may vary. + * + * @param pc + * The PlayerCharacter relative to which the Formula should be + * resolved. + * @param source + * The source object of the Formula, for purposes of resolution. + * @return The Number indicating the result of the Formula when resolved in + * the given context. + */ public Number resolve(PlayerCharacter pc, String source); + /** + * Resolves the formula relative to the given Equipment, EquipmentHead, + * PlayerCharacter and source object. Variables are taken from the active + * objects on the Equipment and PlayerCharacter, and any required context + * beyond the PlayerCharacter is taken from the source object. Formatting of + * the source String may vary. + * + * @param equipment + * The Equipment relative to which the Formula should be + * resolved. + * @param primary + * True if the primary head of the given Equipment should be used + * for resolution, false if the secondary head should be used for + * resolution. + * @param apc + * The PlayerCharacter relative to which the Formula should be + * resolved. + * @param string + * The source object of the Formula, for purposes of resolution. + * @return The Number indicating the result of the Formula when resolved in + * the given context. + */ + public Number resolve(Equipment equipment, boolean primary, + PlayerCharacter apc, String string); + + /** + * Returns true if the underlying Formula is known to be static. + * + * Implementation of this method may vary, and a static Formula may return + * true or false to this method. The only requirement is that if true is + * returned, then the Formula must be static. + * + * @return true if the underlying Formula is known to be static; false + * otherwise + */ public boolean isStatic(); - public Number resolve(Equipment equipment, boolean primary, - PlayerCharacter apc, String string); } Modified: Trunk/pcgen/code/src/java/pcgen/base/lang/StringUtil.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/base/lang/StringUtil.java 2009-02-01 11:34:51 UTC (rev 9205) +++ Trunk/pcgen/code/src/java/pcgen/base/lang/StringUtil.java 2009-02-01 20:43:40 UTC (rev 9206) @@ -176,6 +176,17 @@ return sb.toString(); } + /** + * Tests to see if the given String has balanced parenthesis. Balanced means + * that it has an equal number of open and close parenthesis, and also that + * the parenthesis are in a "sensible" format. "Sensible" means that a close + * parenthesis cannot appear before an open parenthesis. + * + * @param ds + * The String to be tested to see if it has balanced parenthesis + * @return true if the given String has balanced parenthesis; false + * otherwise + */ public static boolean hasBalancedParens(String ds) { int level = 0; Modified: Trunk/pcgen/code/src/java/pcgen/cdom/base/CDOMList.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/cdom/base/CDOMList.java 2009-02-01 11:34:51 UTC (rev 9205) +++ Trunk/pcgen/code/src/java/pcgen/cdom/base/CDOMList.java 2009-02-01 20:43:40 UTC (rev 9206) @@ -38,8 +38,27 @@ * @return the Class of Object this CDOMList will identify */ public Class<T> getListClass(); - + + /** + * Returns the key name for this CDOMList. This is the unique identifer of + * the CDOMList. Theoretically, this is unique relative to the ListClass + * (from getListClass()), not globally unique. However, this "uniqueness" is + * not enforced (since this is merely an interface). + * + * @return The key name for this CDOMList + */ public String getKeyName(); + /** + * Returns true if this CDOMList has the given Type. This test the CDOMList + * itself, not the contents of the CDOMList. A CDOMList can have a type, for + * example, because a ClassSpellList (A form of CDOMList) can be "Arcane" or + * "Divine". + * + * @param type + * The String representation of the Type that this CDOMList + * should be tested for. + * @return true if this CDOMList has the given type; false otherwise. + */ public boolean isType(String type); } Modified: Trunk/pcgen/code/src/java/pcgen/cdom/base/ChoiceSet.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/cdom/base/ChoiceSet.java 2009-02-01 11:34:51 UTC (rev 9205) +++ Trunk/pcgen/code/src/java/pcgen/cdom/base/ChoiceSet.java 2009-02-01 20:43:40 UTC (rev 9206) @@ -58,6 +58,11 @@ */ private final String setName; + /** + * An identifier to check if the ChoiceSet (and the underlying + * PrimitiveChoiceSet) should use the "ANY" identifier (vs. "ALL") when + * referring to the global collection of objects of a certain type. + */ private final boolean useAny; /** Modified: Trunk/pcgen/code/src/java/pcgen/cdom/base/ChooseResultActor.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/cdom/base/ChooseResultActor.java 2009-02-01 11:34:51 UTC (rev 9205) +++ Trunk/pcgen/code/src/java/pcgen/cdom/base/ChooseResultActor.java 2009-02-01 20:43:40 UTC (rev 9206) @@ -21,15 +21,57 @@ import pcgen.core.PlayerCharacter; import pcgen.persistence.PersistenceLayerException; +/** + * A ChooseResultActor is an object that can apply and remove choices (based on + * the CHOOSE token) to a PlayerCharacter. This is an object that will act after + * a selection has been made by a user through through the chooser system. + */ public interface ChooseResultActor { - void apply(PlayerCharacter pc, CDOMObject obj, String o); + /** + * Applies the given choice to the given PlayerCharacter. + * + * @param pc + * The PlayerCharacter to which the given choice should be + * applied. + * @param obj + * The CDOMObject to which the choice was applied (the CDOMObject + * on which the CHOOSE token was present) + * @param choice + * The choice being applied to the given PlayerCharacter + */ + void apply(PlayerCharacter pc, CDOMObject obj, String choice); - void remove(PlayerCharacter pc, CDOMObject obj, String o); + /** + * Applies the given choice to the given PlayerCharacter. + * + * @param pc + * The PlayerCharacter to which the given choice should be + * applied. + * @param obj + * The CDOMObject to which the choice was applied (the CDOMObject + * on which the CHOOSE token was present) + * @param choice + * The choice being applied to the given PlayerCharacter + */ + void remove(PlayerCharacter pc, CDOMObject obj, String choice); + /** + * Returns the source of this ChooseResultActor. Provided primarily to allow + * the Token/Loader system to properly identify the source of + * ChooseResultActors for purposes of unparsing. + * + * @return The source of this ChooseResultActor + */ String getSource(); + /** + * Returns the LST format for this ChooseResultActor. Provided primarily to + * allow the Token/Loader system to properly unparse the ChooseResultActor. + * + * @return The LST format of this ChooseResultActor + */ String getLstFormat() throws PersistenceLayerException; } Modified: Trunk/pcgen/code/src/java/pcgen/cdom/base/FormulaFactory.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/cdom/base/FormulaFactory.java 2009-02-01 11:34:51 UTC (rev 9205) +++ Trunk/pcgen/code/src/java/pcgen/cdom/base/FormulaFactory.java 2009-02-01 20:43:40 UTC (rev 9206) @@ -149,6 +149,12 @@ return i; } + /** + * Resolves this IntegerFormula, returning the Integer in this + * IntegerFormula. + * + * @return the Integer in this IntegerFormula. + */ public Integer resolve(Equipment equipment, boolean primary, PlayerCharacter apc, String string) { @@ -189,6 +195,10 @@ && ((IntegerFormula) o).i.equals(i); } + /** + * Returns true as an IntegerFormula has an underlying integer (static) + * value + */ public boolean isStatic() { return true; @@ -235,6 +245,12 @@ return i; } + /** + * Resolves this DoubleFormula, returning the Double in this + * DoubleFormula. + * + * @return the Double in this DoubleFormula. + */ public Double resolve(Equipment equipment, boolean primary, PlayerCharacter apc, String string) { @@ -275,6 +291,10 @@ && ((DoubleFormula) o).i.equals(i); } + /** + * Returns true as an DoubleFormula has an underlying double (static) + * value + */ public boolean isStatic() { return true; Modified: Trunk/pcgen/code/src/java/pcgen/cdom/base/PersistentChoiceActor.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/cdom/base/PersistentChoiceActor.java 2009-02-01 11:34:51 UTC (rev 9205) +++ Trunk/pcgen/code/src/java/pcgen/cdom/base/PersistentChoiceActor.java 2009-02-01 20:43:40 UTC (rev 9206) @@ -80,6 +80,16 @@ * The choice being restored to the given PlayerCharacter. */ public void restoreChoice(PlayerCharacter pc, CDOMObject owner, T choice); - + + /** + * Removes a choice from a PlayerCharacter. + * + * @param pc + * The PlayerCharacter from which the choice should be removed. + * @param owner + * The owning object of the choice being removed. + * @param choice + * The choice being removed from the given PlayerCharacter. + */ public void removeChoice(PlayerCharacter pc, CDOMObject owner, T choice); } Modified: Trunk/pcgen/code/src/java/pcgen/cdom/base/PersistentTransitionChoice.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/cdom/base/PersistentTransitionChoice.java 2009-02-01 11:34:51 UTC (rev 9205) +++ Trunk/pcgen/code/src/java/pcgen/cdom/base/PersistentTransitionChoice.java 2009-02-01 20:43:40 UTC (rev 9206) @@ -26,20 +26,52 @@ /** * This is a transitional class from PCGen 5.15+ to the final CDOM core. It is * provided as convenience to hold a set of choices and the number of choices - * allowed, prior to final implementation of the new choice system + * allowed, prior to final implementation of the new choice system. * + * This is a TransitionChoice that is designed to be stored in a PlayerCharacter + * file when saved. Thus, encoding and decoding (to a 'persistent' string) + * methods are provided. + * * @param <T> */ public class PersistentTransitionChoice<T> extends TransitionChoice<T> { + /** + * The PersistentChoiceActor (optional) which will act upon any choices made + * from this PersistentTransitionChoice. + */ private PersistentChoiceActor<T> choiceActor; + /** + * Constructs a new PersistentChoiceActor with the given ChoiceSet (of + * possible choices) and Formula (indicating the number of choices that may + * be taken) + * + * @param cs + * The ChoiceSet indicating the choices available in this + * PersistentChoiceActor. + * @param count + * The Formula indicating the number of choices that may be + * selected when selections are made in this + * PersistentChoiceActor. + */ public PersistentTransitionChoice(ChoiceSet<? extends T> cs, Formula count) { super(cs, count); } + /** + * Sets the (optional) ChoiceActor for this TransitionChoice. The + * ChoiceActor will be called when the act method of TransitionChoice is + * called. If the ChoiceActor is not set, then the set method may not be + * used without triggering an exception. + * + * @param ca + * The ChoiceActor for this TransitionChoice. + * @throws ClassCastException + * if the given ChoiceActor is not a PersistentChoiceActor + */ @Override public void setChoiceActor(ChoiceActor<T> ca) { @@ -47,21 +79,74 @@ super.setChoiceActor(ca); } + /** + * Encodes the given choice into a String sufficient to uniquely identify + * the choice. This may not sufficiently encode to be stored into a file or + * format which restricts certain characters (such as URLs), it simply + * encodes into an identifying String. There is no guarantee that this + * encoding is human readable, simply that the encoding is uniquely + * identifing such that the decodeChoice method of the + * PersistentTransitionChoice is capable of decoding the String into the + * choice object. + * + * @param choice + * The choice which should be encoded into a String sufficient to + * identify the choice. + * + * @return A String sufficient to uniquely identify the choice. + */ public String encodeChoice(Object choice) { return choiceActor.encodeChoice(choice); } + /** + * Decodes a given String into a choice of the appropriate type. The String + * format to be passed into this method is defined solely by the return + * result of the encodeChoice method. There is no guarantee that the + * encoding is human readable, simply that the encoding is uniquely + * identifing such that this method is capable of decoding the String into + * the choice object. + * + * @param s + * The String which should be decoded to provide the choice of + * the appropriate type. + * + * @return A choice object of the appropriate type that was encoded in the + * given String. + */ public T decodeChoice(String persistenceFormat) { return choiceActor.decodeChoice(persistenceFormat); } + /** + * Restores a choice to a PlayerCharacter. This method re-applies a choice + * when a PlayerCharacter is restored from a persistent state (the act + * method of TransitionChoice having been used to first apply the choice to + * a PlayerCharacter). + * + * @param pc + * The PlayerCharacter to which the choice should be restored. + * @param owner + * The owning object of the choice being restored. + * @param choice + * The choice being restored to the given PlayerCharacter. + */ public void restoreChoice(PlayerCharacter pc, CDOMObject owner, T choice) { choiceActor.restoreChoice(pc, owner, choice); } + /** + * Removes all choices made by this TransitionChoice from the given + * PlayerCharacter. + * + * @param owner + * The owning object of the choice being removed. + * @param pc + * The PlayerCharacter from which the choice should be removed. + */ public void remove(CDOMObject owner, PlayerCharacter apc) { List<Object> ch = apc.removeAllAssocs(this, AssociationListKey.ADD); Modified: Trunk/pcgen/code/src/java/pcgen/cdom/base/TransitionChoice.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/cdom/base/TransitionChoice.java 2009-02-01 11:34:51 UTC (rev 9205) +++ Trunk/pcgen/code/src/java/pcgen/cdom/base/TransitionChoice.java 2009-02-01 20:43:40 UTC (rev 9206) @@ -40,30 +40,103 @@ public class TransitionChoice<T> { + /** + * The underlying ChoiceSet used to determine the choices available when + * selections are to be made in this TransitionChoice. + */ private final ChoiceSet<? extends T> choices; + + /** + * The Formula indicating the number of choices to be made when selections + * are made in this TransitionChoice. + */ private final Formula choiceCount; + + /** + * The title of this choice - presented to the user as the title of the + * dialog box from which selections are made. + */ private String title; + + /** + * IDentifies if this TransitionChoice selection is required - if it is + * required, then the user cannot dismiss the dialog box without making a + * choice (or the dialog box reappears, etc.) + */ private boolean required = true; + + /** + * The ChoiceActor (optional) which will act upon any choices made from this + * TransitionChoice. + */ private ChoiceActor<T> choiceActor; + + /** + * Identifies if this TransitionChoice allows stacking of the same object. + * + * This is typically done with Abilities, which has the STACKS: token in + * order to identify stackable Abilities. Note that this field only allows + * stacking, it does not enable stacking of objects which are not generally + * stackable. + */ private boolean allowStack = false; + + /** + * Identifies any limit to stacking in this TransitionChoice. This is only + * enabled if allowStack is true, and limits the number of times a single + * object may be stacked in this selection. + */ private Integer stackLimit = null; + /** + * Constructs a new TransitionChoice with the given ChoiceSet (of possible + * choices) and Formula (indicating the number of choices that may be taken) + * + * @param cs + * The ChoiceSet indicating the choices available in this + * TransitionChoice. + * @param count + * The Formula indicating the number of choices that may be + * selected when selections are made in this TransitionChoice. + */ public TransitionChoice(ChoiceSet<? extends T> cs, Formula count) { choices = cs; choiceCount = count; } + /** + * Returns the ChoiceSet for this TransitionChoice. + * + * TODO Should determine if this should be exposed. It seems this is + * primarily used to get access to getLSTformat and getChoiceClass, so + * perhaps the TransitionChoice should delegate those instead in order to + * protect the ChoiceSet? + * + * @return The ChoiceSet for this TransitionChoice. + */ public ChoiceSet<? extends T> getChoices() { return choices; } + /** + * Returns the Formula indicating the number of selections available when + * selections are made in this TransitionChoice. + * + * @return The Formula indicating the number of selections available + */ public Formula getCount() { return choiceCount; } + /** + * Returns true if the given Object is a TransitionChoice and has identical + * underlying choices and choiceCount + * + * @see java.lang.Object#equals(java.lang.Object) + */ @Override public boolean equals(Object obj) { @@ -76,12 +149,27 @@ return false; } + /** + * Returns a consistent-with-equals hashCode for this TransitionChoice. + * + * @see java.lang.Object#hashCode() + */ @Override public int hashCode() { return choiceCount.hashCode() * 29 + choices.hashCode(); } + /** + * Drives a selection for this TransitionChoice on the given + * PlayerCharacter. + * + * @param pc + * The PlayerCharacter for which this TransitionChoice should + * drive a choice. + * @return A Collection of objects of the type that this TransitionChoice + * selects. + */ public Collection<? extends T> driveChoice(PlayerCharacter pc) { ChooserInterface c = ChooserFactory.getChooserInstance(); @@ -139,22 +227,57 @@ } } + /** + * Sets the title of this TransitionChoice (displayed to the user as the + * title of the dialog box used to make the selections). + * + * @param string + * The title of this TransitionChoice. + */ public void setTitle(String string) { title = string; } + /** + * Sets whether a selection from this TransitionChoice is required. If + * required, a TransitionChoice will not exit the driveChoice method until + * the user has made a selection. + * + * @param b + * true if a selection from this TransitionChoice should be + * required. + */ public void setRequired(boolean b) { required = b; } + /** + * Sets the (optional) ChoiceActor for this TransitionChoice. The + * ChoiceActor will be called when the act method of TransitionChoice is + * called. If the ChoiceActor is not set, then the set method may not be + * used without triggering an exception. + * + * @param ca + * The ChoiceActor for this TransitionChoice. + */ public void setChoiceActor(ChoiceActor<T> ca) { choiceActor = ca; } - public void act(Collection<? extends T> driveChoice, CDOMObject owner, + /** + * Acts upon choices made in this TransitionChoice. + * + * @param choices + * The choices on which this TransitionChoice should act. + * @param owner + * The owning object for this TransitionChoice + * @param apc + * The PlayerCharacter to which the choices should be applied. + */ + public void act(Collection<? extends T> choicesMade, CDOMObject owner, PlayerCharacter apc) { if (choiceActor == null) @@ -162,38 +285,84 @@ throw new IllegalStateException( "Cannot act without a defined ChoiceActor"); } - for (T choice : driveChoice) + for (T choice : choicesMade) { choiceActor.applyChoice(owner, choice, apc); apc.addAssoc(this, AssociationListKey.ADD, choice); } } + /** + * Casts an object to the (Generic) Type of this TransitionChoice. + * + * @param o + * The incoming object + * @return The incoming object, cast to the (Generic) type of this + * TransitionChoice. + */ public T castChoice(Object o) { return (T) o; } + /** + * Sets whether this TransitionChoice should allow stacking. + * + * @param allow + * true if this TransitionChoice should allow stacking; false + * otherwise. + */ public void allowStack(boolean allow) { allowStack = allow; } + /** + * Sets the stacking limit of this TransitionChoice. This is only enabled if + * allowStack is set to true. This limits the number of times an individual + * item can stack in a given TransitionChoice. + * + * @param limit + * The limit (number of times a stackable item may be selected in + * this TransitionChoice) + */ public void setStackLimit(int limit) { stackLimit = limit; } + /** + * Identifies if this TransitionChoice allows stacking. + * + * @return true if this TransitionChoice should allow stacking; false + * otherwise. + */ public boolean allowsStacking() { return allowStack; } + /** + * Returns the Stacking Limit of this TransitionChoice. This is only enabled + * if allowStack is set to true. This limits the number of times an + * individual item can stack in a given TransitionChoice. + * + * @return The limit (number of times a stackable item may be selected in + * this TransitionChoice) + */ public int getStackLimit() { return stackLimit == null ? 0 : stackLimit; } + /** + * Returns the ChoiceActor for this TransitionChoice. + * + * CONSIDER Should look at another method to get rid of this - do the users + * of this method require their own sub-class to TransitionChoice? + * + * @return The ChoiceActor for this TransitionChoice. + */ public ChoiceActor<T> getChoiceActor() { return choiceActor; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <th...@us...> - 2009-02-02 22:16:13
|
Revision: 9221 http://pcgen.svn.sourceforge.net/pcgen/?rev=9221&view=rev Author: thpr Date: 2009-02-02 22:12:52 +0000 (Mon, 02 Feb 2009) Log Message: ----------- attempted fix for [ 2556253 ] Converter Non-functional on Macs Issue#: 2556253 Modified Paths: -------------- Trunk/pcgen/code/src/java/pcgen/gui/converter/LSTConverter.java Trunk/pcgen/code/src/java/pcgen/gui/converter/ObjectInjector.java Trunk/pcgen/code/src/java/pcgen/rules/persistence/CDOMKitLoader.java Modified: Trunk/pcgen/code/src/java/pcgen/gui/converter/LSTConverter.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/gui/converter/LSTConverter.java 2009-02-02 21:49:28 UTC (rev 9220) +++ Trunk/pcgen/code/src/java/pcgen/gui/converter/LSTConverter.java 2009-02-02 22:12:52 UTC (rev 9221) @@ -136,7 +136,7 @@ continue; } written.add(uri); - File in = new File(uri.getPath().substring(1)); + File in = new File(uri); File base = findSubRoot(rootDir, in); String relative = in.toString().substring( base.toString().length() + 1); Modified: Trunk/pcgen/code/src/java/pcgen/gui/converter/ObjectInjector.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/gui/converter/ObjectInjector.java 2009-02-02 21:49:28 UTC (rev 9220) +++ Trunk/pcgen/code/src/java/pcgen/gui/converter/ObjectInjector.java 2009-02-02 22:12:52 UTC (rev 9221) @@ -98,7 +98,7 @@ private File getNewOutputName(URI uri) { - File in = new File(uri.getPath().substring(1)); + File in = new File(uri); File base = findSubRoot(rootDir, in); String relative = in.toString().substring(base.toString().length() + 1); File actualRoot = generateCommonRoot(rootDir, outDir); Modified: Trunk/pcgen/code/src/java/pcgen/rules/persistence/CDOMKitLoader.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/rules/persistence/CDOMKitLoader.java 2009-02-02 21:49:28 UTC (rev 9220) +++ Trunk/pcgen/code/src/java/pcgen/rules/persistence/CDOMKitLoader.java 2009-02-02 22:12:52 UTC (rev 9221) @@ -166,8 +166,7 @@ { lc.setExtractURI(cse.getURI()); URI writeURI = cse.getWriteURI(); - String path = writeURI.getPath().substring(1); - File f = new File(path); + File f = new File(writeURI); ensureCreated(f.getParentFile()); try { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <th...@us...> - 2009-02-04 22:32:06
|
Revision: 9261 http://pcgen.svn.sourceforge.net/pcgen/?rev=9261&view=rev Author: thpr Date: 2009-02-04 22:32:03 +0000 (Wed, 04 Feb 2009) Log Message: ----------- fix REGION: token in Kits Modified Paths: -------------- Trunk/pcgen/code/src/java/pcgen/cdom/base/CDOMObject.java Trunk/pcgen/code/src/java/pcgen/persistence/lst/KitLoader.java Trunk/pcgen/code/src/java/pcgen/rules/persistence/CDOMKitLoader.java Modified: Trunk/pcgen/code/src/java/pcgen/cdom/base/CDOMObject.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/cdom/base/CDOMObject.java 2009-02-04 04:04:40 UTC (rev 9260) +++ Trunk/pcgen/code/src/java/pcgen/cdom/base/CDOMObject.java 2009-02-04 22:32:03 UTC (rev 9261) @@ -568,6 +568,7 @@ public final void overlayCDOMObject(CDOMObject cdo) { + addAllPrerequisites(cdo.getPrerequisiteList()); integerChar.putAll(cdo.integerChar); stringChar.putAll(cdo.stringChar); formulaChar.putAll(cdo.formulaChar); Modified: Trunk/pcgen/code/src/java/pcgen/persistence/lst/KitLoader.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/persistence/lst/KitLoader.java 2009-02-04 04:04:40 UTC (rev 9260) +++ Trunk/pcgen/code/src/java/pcgen/persistence/lst/KitLoader.java 2009-02-04 22:32:03 UTC (rev 9261) @@ -24,6 +24,7 @@ import java.util.StringTokenizer; +import pcgen.cdom.base.Constants; import pcgen.core.Kit; import pcgen.core.kit.KitAbilities; import pcgen.core.kit.KitAlignment; @@ -64,41 +65,41 @@ public KitLoader() { kitLoader.addLineLoader(new CDOMSubLineLoader<KitAlignment>( - "*KITTOKEN", "ALIGN", KitAlignment.class)); + "*KITTOKEN", "ALIGN", KitAlignment.class)); kitLoader.addLineLoader(new CDOMSubLineLoader<KitRace>("*KITTOKEN", - "RACE", KitRace.class)); + "RACE", KitRace.class)); kitLoader.addLineLoader(new CDOMSubLineLoader<KitSkill>("*KITTOKEN", - "SKILL", KitSkill.class)); + "SKILL", KitSkill.class)); kitLoader.addLineLoader(new CDOMSubLineLoader<KitGear>("*KITTOKEN", - "GEAR", KitGear.class)); + "GEAR", KitGear.class)); kitLoader.addLineLoader(new CDOMSubLineLoader<KitSpells>("*KITTOKEN", - "SPELLS", KitSpells.class)); + "SPELLS", KitSpells.class)); kitLoader.addLineLoader(new CDOMSubLineLoader<KitStat>("*KITTOKEN", - "STAT", KitStat.class)); + "STAT", KitStat.class)); kitLoader.addLineLoader(new CDOMSubLineLoader<KitProf>("*KITTOKEN", - "PROF", KitProf.class)); + "PROF", KitProf.class)); kitLoader.addLineLoader(new CDOMSubLineLoader<KitAbilities>( - "*KITTOKEN", "FEAT", KitAbilities.class)); + "*KITTOKEN", "FEAT", KitAbilities.class)); kitLoader.addLineLoader(new CDOMSubLineLoader<KitAbilities>( - "*KITTOKEN", "ABILITY", KitAbilities.class)); + "*KITTOKEN", "ABILITY", KitAbilities.class)); kitLoader.addLineLoader(new CDOMSubLineLoader<KitBio>("*KITTOKEN", - "NAME", KitBio.class)); + "NAME", KitBio.class)); kitLoader.addLineLoader(new CDOMSubLineLoader<KitLevelAbility>( - "*KITTOKEN", "LEVELABILITY", KitLevelAbility.class)); + "*KITTOKEN", "LEVELABILITY", KitLevelAbility.class)); kitLoader.addLineLoader(new CDOMSubLineLoader<KitClass>("*KITTOKEN", - "CLASS", KitClass.class)); + "CLASS", KitClass.class)); kitLoader.addLineLoader(new CDOMSubLineLoader<KitTemplate>("*KITTOKEN", - "TEMPLATE", KitTemplate.class)); + "TEMPLATE", KitTemplate.class)); kitLoader.addLineLoader(new CDOMSubLineLoader<KitDeity>("*KITTOKEN", - "DEITY", KitDeity.class)); + "DEITY", KitDeity.class)); kitLoader.addLineLoader(new CDOMSubLineLoader<KitKit>("*KITTOKEN", - "KIT", KitKit.class)); + "KIT", KitKit.class)); kitLoader.addLineLoader(new CDOMSubLineLoader<KitTable>("*KITTOKEN", - "TABLE", KitTable.class)); + "TABLE", KitTable.class)); kitLoader.addLineLoader(new CDOMSubLineLoader<KitSelect>("*KITTOKEN", - "SELECT", KitSelect.class)); + "SELECT", KitSelect.class)); kitLoader.addLineLoader(new CDOMSubLineLoader<KitBio>("*KITTOKEN", - "GENDER", KitBio.class)); + "GENDER", KitBio.class)); kitLoader.addLineLoader(new CDOMSubLineLoader<KitFunds>("*KITTOKEN", "FUNDS", KitFunds.class)); kitLoader.addLineLoader(new CDOMSubLineLoader<KitLangBonus>( @@ -108,13 +109,12 @@ @Override protected Kit getObjectKeyed(LoadContext context, String aKey) { - return context.ref.silentlyGetConstructedCDOMObject( - Kit.class, aKey); + return context.ref.silentlyGetConstructedCDOMObject(Kit.class, aKey); } @Override public Kit parseLine(LoadContext context, Kit target, String inputLine, - CampaignSourceEntry source) throws PersistenceLayerException + CampaignSourceEntry source) throws PersistenceLayerException { if (inputLine.startsWith("STARTPACK:")) { @@ -125,9 +125,8 @@ StringTokenizer st = new StringTokenizer(inputLine, "\t"); String firstToken = st.nextToken(); int colonLoc = firstToken.indexOf(':'); - target = - context.ref.constructCDOMObject(Kit.class, firstToken - .substring(colonLoc + 1)); + target = context.ref.constructCDOMObject(Kit.class, firstToken + .substring(colonLoc + 1)); target.setSourceCampaign(source.getCampaign()); target.setSourceURI(source.getURI()); context.addStatefulInformation(target); @@ -138,34 +137,74 @@ if (cLoc == -1) { Logging - .errorPrint("Invalid Token - does not contain a colon: " - + token); + .errorPrint("Invalid Token - does not contain a colon: " + + token); continue; } else if (cLoc == 0) { Logging.errorPrint("Invalid Token - starts with a colon: " - + token); + + token); continue; } String key = token.substring(0, cLoc); - String value = - (cLoc == token.length() - 1) ? null : token - .substring(cLoc + 1); + String value = (cLoc == token.length() - 1) ? null : token + .substring(cLoc + 1); context.processToken(target, key, value); } } - else if (kitLoader.parseSubLine(context, target, inputLine, source - .getURI())) + else if (inputLine.startsWith("REGION:")) { - Logging.clearParseMessages(); - context.commit(); + String value = inputLine.substring(7); + context.clearStatefulInformation(); + if (value != null && value.length() > 0) + { + StringTokenizer st = new StringTokenizer(value, "\t"); + + String region = st.nextToken(); + if (!region.equalsIgnoreCase(Constants.LST_NONE)) + { + // Add a real prereq for the REGION: tag + if (context.addStatefulToken("PREREGION:" + region)) + { + context.commit(); + } + else + { + context.rollback(); + Logging.errorPrint("Invalid Stateful Token" + + " from Region NONE: PREREGION:" + region); + Logging.replayParsedMessages(); + } + Logging.clearParseMessages(); + } + + while (st.hasMoreTokens()) + { + String gt = st.nextToken(); + if (!context.addStatefulToken(gt)) + { + Logging.errorPrint("Invalid Stateful Token: " + gt); + } + } + } } else { - Logging.replayParsedMessages(); - Logging.clearParseMessages(); + context.rollback(); + if (kitLoader.parseSubLine(context, target, inputLine, source + .getURI())) + { + Logging.clearParseMessages(); + context.commit(); + } + else + { + context.rollback(); + Logging.replayParsedMessages(); + Logging.clearParseMessages(); + } } return target; } Modified: Trunk/pcgen/code/src/java/pcgen/rules/persistence/CDOMKitLoader.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/rules/persistence/CDOMKitLoader.java 2009-02-04 04:04:40 UTC (rev 9260) +++ Trunk/pcgen/code/src/java/pcgen/rules/persistence/CDOMKitLoader.java 2009-02-04 22:32:03 UTC (rev 9261) @@ -8,7 +8,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.StringTokenizer; import java.util.TreeSet; import pcgen.base.lang.StringUtil; @@ -25,8 +24,7 @@ public class CDOMKitLoader implements CDOMLoader<Kit> { - private final Map<String, CDOMSubLineLoader<? extends BaseKit>> loadMap = - new HashMap<String, CDOMSubLineLoader<? extends BaseKit>>(); + private final Map<String, CDOMSubLineLoader<? extends BaseKit>> loadMap = new HashMap<String, CDOMSubLineLoader<? extends BaseKit>>(); private final Class<Kit> targetClass = Kit.class; @@ -38,15 +36,17 @@ } public boolean parseSubLine(LoadContext context, Kit obj, String val, - URI source) + URI source) { int sepLoc = val.indexOf('\t'); String firstToken = (sepLoc == -1) ? val : val.substring(0, sepLoc); int colonLoc = firstToken.indexOf(':'); if (colonLoc == -1) { - Logging.addParseMessage(Logging.LST_ERROR, "Unsure what to do with line without " - + "a colon in first token: " + val + " in file: " + source); + Logging.addParseMessage(Logging.LST_ERROR, + "Unsure what to do with line without " + + "a colon in first token: " + val + " in file: " + + source); return false; } @@ -54,8 +54,9 @@ CDOMSubLineLoader<? extends BaseKit> loader = loadMap.get(prefix); if (loader == null) { - Logging.addParseMessage(Logging.LST_ERROR, "Unsure what to do with line with prefix: " - + prefix + ". Line was: " + val + " in file: " + source); + Logging.addParseMessage(Logging.LST_ERROR, + "Unsure what to do with line with prefix: " + prefix + + ". Line was: " + val + " in file: " + source); return false; } try @@ -74,51 +75,15 @@ return true; } - public boolean parseLine(LoadContext context, Kit obj, String val, URI source) - throws PersistenceLayerException + public boolean parseLine(LoadContext context, Kit obj, String val, + URI source) throws PersistenceLayerException { - StringTokenizer st = new StringTokenizer(val, "\t"); - boolean returnValue = true; - while (st.hasMoreTokens()) - { - String token = st.nextToken().trim(); - int colonLoc = token.indexOf(':'); - if (colonLoc == -1) - { - Logging.errorPrint("Invalid Token - does not contain a colon: " - + token); - returnValue &= false; - continue; - } - else if (colonLoc == 0) - { - Logging.errorPrint("Invalid Token - starts with a colon: " - + token); - returnValue &= false; - continue; - } - String key = token.substring(0, colonLoc); - String value = - (colonLoc == token.length() - 1) ? null : token - .substring(colonLoc + 1); - if (context.processSubToken(obj, "*KITTOKEN", key, value)) - { - Logging.clearParseMessages(); - context.commit(); - } - else - { - context.rollback(); - Logging.rewindParseMessages(); - Logging.replayParsedMessages(); - returnValue &= false; - } - } - return returnValue; + //TODO shell + return false; } public void loadLstFiles(LoadContext context, - Collection<CampaignSourceEntry> sources) + Collection<CampaignSourceEntry> sources) { throw new IllegalStateException("Can't do this yet"); } @@ -128,9 +93,9 @@ throw new IllegalStateException("Can't do this yet"); } - private <CC extends BaseKit> boolean subParse( - LoadContext context, Kit kit, CDOMSubLineLoader<CC> loader, String line, URI uri) - throws PersistenceLayerException + private <CC extends BaseKit> boolean subParse(LoadContext context, Kit kit, + CDOMSubLineLoader<CC> loader, String line, URI uri) + throws PersistenceLayerException { CC obj = loader.getCDOMObject(context); Class cl = obj.getClass(); @@ -140,8 +105,8 @@ protected Kit getCDOMObject(LoadContext context, String name) { - Kit obj = - context.ref.silentlyGetConstructedCDOMObject(targetClass, name); + Kit obj = context.ref.silentlyGetConstructedCDOMObject(targetClass, + name); if (obj == null) { obj = context.ref.constructCDOMObject(targetClass, name); @@ -155,10 +120,9 @@ } public void unloadLstFiles(LoadContext lc, - Collection<CampaignSourceEntry> files) + Collection<CampaignSourceEntry> files) { - HashMapToList<Class<?>, CDOMSubLineLoader<?>> loaderMap = - new HashMapToList<Class<?>, CDOMSubLineLoader<?>>(); + HashMapToList<Class<?>, CDOMSubLineLoader<?>> loaderMap = new HashMapToList<Class<?>, CDOMSubLineLoader<?>>(); for (CDOMSubLineLoader<?> loader : loadMap.values()) { loaderMap.addToListFor(loader.getLoadedClass(), loader); @@ -183,13 +147,12 @@ if (unparse != null) { sb.append("\t").append( - StringUtil.join(unparse, "\t")); + StringUtil.join(unparse, "\t")); } sb.append("\n"); - Changes<BaseKit> changes = - lc.getObjectContext().getListChanges(k, - ListKey.KIT_TASKS); + Changes<BaseKit> changes = lc.getObjectContext() + .getListChanges(k, ListKey.KIT_TASKS); Collection<BaseKit> tasks = changes.getAdded(); if (tasks == null) { @@ -197,8 +160,8 @@ } for (BaseKit kt : tasks) { - List<CDOMSubLineLoader<?>> loaders = - loaderMap.getListFor(kt.getClass()); + List<CDOMSubLineLoader<?>> loaders = loaderMap + .getListFor(kt.getClass()); for (CDOMSubLineLoader loader : loaders) { processTask(lc, kt, loader, sb); @@ -224,8 +187,8 @@ } } - private <T extends BaseKit> void processTask(LoadContext lc, - T kt, CDOMSubLineLoader<T> loader, StringBuilder pw) + private <T extends BaseKit> void processTask(LoadContext lc, T kt, + CDOMSubLineLoader<T> loader, StringBuilder pw) { loader.unloadObject(lc, kt, pw); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jde...@us...> - 2009-02-06 12:34:57
|
Revision: 9291 http://pcgen.svn.sourceforge.net/pcgen/?rev=9291&view=rev Author: jdempsey Date: 2009-02-06 12:34:53 +0000 (Fri, 06 Feb 2009) Log Message: ----------- Fix bug: Natures should not stack together Issue#: 2444695 Modified Paths: -------------- Trunk/pcgen/code/src/java/pcgen/core/PlayerCharacter.java Trunk/pcgen/code/src/java/pcgen/gui/tabs/ability/SelectedAbilityPanel.java Modified: Trunk/pcgen/code/src/java/pcgen/core/PlayerCharacter.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/PlayerCharacter.java 2009-02-06 05:52:18 UTC (rev 9290) +++ Trunk/pcgen/code/src/java/pcgen/core/PlayerCharacter.java 2009-02-06 12:34:53 UTC (rev 9291) @@ -16240,12 +16240,27 @@ return abilities; } - private List<Ability> rebuildFeatAggreagateList() + + /** + * Retrieve a list of all abilities held by the character in the specified + * category. <br> + * NB: Abilities are only returned in the category they are taken + * in, so if parent catgeory is supplied only those taken directly in the + * parent category will be returned. e.g. If asking for feats, Power Attack + * taken as a fighter feat will nto be returned. You would need to query + * fighter feats to get that. <br> + * NB: Duplicate abilities will not be retruned by this method. The order + * of priorty is normla, virtual then automatic. + * + * @param aCategory The ability category to be queried. + * @return The list of abilities of the category regardless of nature. + */ + public List<Ability> getAggregateAbilityListNoDuplicates(final AbilityCategory aCategory) { List<Ability> aggregate = new ArrayList<Ability>(); final Map<String, Ability> aHashMap = new HashMap<String, Ability>(); - for (Ability aFeat : getRealAbilitiesList(AbilityCategory.FEAT)) + for (Ability aFeat : getRealAbilitiesList(aCategory)) { if (aFeat != null) { @@ -16253,46 +16268,57 @@ } } - for (Ability vFeat : getVirtualFeatList()) + addUniqueAbilitiesToMap(aHashMap, getVirtualAbilityList(aCategory)); + addUniqueAbilitiesToMap(aHashMap, getAutomaticAbilityList(aCategory)); + + aggregate.addAll(aHashMap.values()); + return aggregate; + } + + private List<Ability> rebuildFeatAggreagateList() + { + List<Ability> aggregate = new ArrayList<Ability>(); + final Map<String, Ability> aHashMap = new HashMap<String, Ability>(); + + for (Ability aFeat : getRealAbilitiesList(AbilityCategory.FEAT)) { - if (!aHashMap.containsKey(vFeat.getKeyName())) + if (aFeat != null) { - aHashMap.put(vFeat.getKeyName(), vFeat); + aHashMap.put(aFeat.getKeyName(), aFeat); } - else if (vFeat.getSafe(ObjectKey.MULTIPLE_ALLOWED)) - { - Ability aggregateFeat = aHashMap.get(vFeat.getKeyName()); - aggregateFeat = aggregateFeat.clone(); + } - for (String aString : getAssociationList(vFeat)) - { - if (aggregateFeat.getSafe(ObjectKey.STACKS) - || !containsAssociated(aggregateFeat, aString)) - { - addAssociation(aggregateFeat, aString); - } - } + addUniqueAbilitiesToMap(aHashMap, getVirtualFeatList()); - aHashMap.put(vFeat.getKeyName(), aggregateFeat); - } - } + aggregate.addAll(aHashMap.values()); + setStableAggregateFeatList(aggregate); + addUniqueAbilitiesToMap(aHashMap, featAutoList()); + + aggregate = new ArrayList<Ability>(); aggregate.addAll(aHashMap.values()); setStableAggregateFeatList(aggregate); + return aggregate; + } - for (Ability autoFeat : featAutoList()) + /** + * @param aHashMap + * @param abilityList TODO + */ + private void addUniqueAbilitiesToMap(final Map<String, Ability> aHashMap, List<Ability> abilityList) + { + for (Ability vFeat : abilityList) { - if (!aHashMap.containsKey(autoFeat.getKeyName())) + if (!aHashMap.containsKey(vFeat.getKeyName())) { - aHashMap.put(autoFeat.getKeyName(), autoFeat); + aHashMap.put(vFeat.getKeyName(), vFeat); } - - else if (autoFeat.getSafe(ObjectKey.MULTIPLE_ALLOWED)) + else if (vFeat.getSafe(ObjectKey.MULTIPLE_ALLOWED)) { - Ability aggregateFeat = aHashMap.get(autoFeat.getKeyName()); + Ability aggregateFeat = aHashMap.get(vFeat.getKeyName()); aggregateFeat = aggregateFeat.clone(); - for (String aString : getAssociationList(autoFeat)) + for (String aString : getAssociationList(vFeat)) { if (aggregateFeat.getSafe(ObjectKey.STACKS) || !containsAssociated(aggregateFeat, aString)) @@ -16301,14 +16327,9 @@ } } - aHashMap.put(autoFeat.getKeyName(), aggregateFeat); + aHashMap.put(vFeat.getKeyName(), aggregateFeat); } } - - aggregate = new ArrayList<Ability>(); - aggregate.addAll(aHashMap.values()); - setStableAggregateFeatList(aggregate); - return aggregate; } public List<Ability> aggregateVisibleFeatList() @@ -16415,7 +16436,7 @@ for (AbilityCategory cat : catSet) { - abilityList.addAll(this.getAggregateAbilityList(cat)); + abilityList.addAll(this.getAggregateAbilityListNoDuplicates(cat)); } return abilityList; Modified: Trunk/pcgen/code/src/java/pcgen/gui/tabs/ability/SelectedAbilityPanel.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/gui/tabs/ability/SelectedAbilityPanel.java 2009-02-06 05:52:18 UTC (rev 9290) +++ Trunk/pcgen/code/src/java/pcgen/gui/tabs/ability/SelectedAbilityPanel.java 2009-02-06 12:34:53 UTC (rev 9291) @@ -230,7 +230,7 @@ new HashMap<AbilityCategory, List<Ability>>(); for (AbilityCategory abilityCategory : catList) { - abilityList.put(abilityCategory, getPC().getAggregateAbilityList( + abilityList.put(abilityCategory, getPC().getAggregateAbilityListNoDuplicates( abilityCategory)); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <th...@us...> - 2009-02-14 23:22:12
|
Revision: 9398 http://pcgen.svn.sourceforge.net/pcgen/?rev=9398&view=rev Author: thpr Date: 2009-02-14 22:48:04 +0000 (Sat, 14 Feb 2009) Log Message: ----------- cleanup from PMD, Checkstyle Modified Paths: -------------- Trunk/pcgen/code/src/java/pcgen/core/prereq/PrerequisiteUtilities.java Trunk/pcgen/code/src/java/pcgen/core/spell/Spell.java Trunk/pcgen/code/src/java/pcgen/rules/context/AbstractReferenceContext.java Trunk/pcgen/code/src/java/pcgen/rules/context/LoadContext.java Trunk/pcgen/code/src/java/pcgen/rules/context/TrackingReferenceContext.java Trunk/pcgen/code/src/java/pcgen/rules/persistence/CDOMSubLineLoader.java Trunk/pcgen/code/src/java/pcgen/rules/persistence/TokenSupport.java Modified: Trunk/pcgen/code/src/java/pcgen/core/prereq/PrerequisiteUtilities.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/prereq/PrerequisiteUtilities.java 2009-02-14 22:45:52 UTC (rev 9397) +++ Trunk/pcgen/code/src/java/pcgen/core/prereq/PrerequisiteUtilities.java 2009-02-14 22:48:04 UTC (rev 9398) @@ -45,7 +45,6 @@ import pcgen.core.SettingsHandler; import pcgen.core.Skill; import pcgen.core.WeaponProf; -import pcgen.core.chooser.ChooserUtilities; import pcgen.core.spell.Spell; import pcgen.persistence.PersistenceLayerException; import pcgen.persistence.lst.output.prereq.PrerequisiteWriter; Modified: Trunk/pcgen/code/src/java/pcgen/core/spell/Spell.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/spell/Spell.java 2009-02-14 22:45:52 UTC (rev 9397) +++ Trunk/pcgen/code/src/java/pcgen/core/spell/Spell.java 2009-02-14 22:48:04 UTC (rev 9398) @@ -28,7 +28,6 @@ import pcgen.cdom.enumeration.IntegerKey; import pcgen.cdom.enumeration.ListKey; import pcgen.cdom.enumeration.ObjectKey; -import pcgen.cdom.enumeration.StringKey; import pcgen.cdom.enumeration.Type; import pcgen.cdom.list.SpellList; import pcgen.cdom.reference.CDOMDirectSingleRef; Modified: Trunk/pcgen/code/src/java/pcgen/rules/context/AbstractReferenceContext.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/rules/context/AbstractReferenceContext.java 2009-02-14 22:45:52 UTC (rev 9397) +++ Trunk/pcgen/code/src/java/pcgen/rules/context/AbstractReferenceContext.java 2009-02-14 22:48:04 UTC (rev 9398) @@ -41,7 +41,6 @@ import pcgen.cdom.reference.CDOMSingleRef; import pcgen.cdom.reference.ReferenceManufacturer; import pcgen.cdom.reference.UnconstructedValidator; -import pcgen.core.AbilityCategory; import pcgen.core.Domain; import pcgen.core.PCClass; import pcgen.core.SubClass; Modified: Trunk/pcgen/code/src/java/pcgen/rules/context/LoadContext.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/rules/context/LoadContext.java 2009-02-14 22:45:52 UTC (rev 9397) +++ Trunk/pcgen/code/src/java/pcgen/rules/context/LoadContext.java 2009-02-14 22:48:04 UTC (rev 9398) @@ -55,7 +55,7 @@ public final ReferenceContext ref; - private List<Campaign> campaignList = new ArrayList<Campaign>(); + private final List<Campaign> campaignList = new ArrayList<Campaign>(); public LoadContext(ReferenceContext rc, ListContext lc, ObjectContext oc) { @@ -321,7 +321,7 @@ return CampaignSourceEntry.getNewCSE(source, sourceURI, value); } - CDOMObject stateful; + private CDOMObject stateful; public void clearStatefulInformation() { @@ -352,10 +352,10 @@ } } - public void setLoaded(List<Campaign> selectedCampaignsList) + public void setLoaded(List<Campaign> campaigns) { campaignList.clear(); - campaignList.addAll(selectedCampaignsList); + campaignList.addAll(campaigns); } public boolean isTypeHidden(Class<?> cl, String type) @@ -397,7 +397,7 @@ + StringPClassUtil.getValidStrings()); return null; } - else if (firstToken.equals("FEAT")) + else if ("FEAT".equals(firstToken)) { className = "ABILITY"; categoryName = "FEAT"; Modified: Trunk/pcgen/code/src/java/pcgen/rules/context/TrackingReferenceContext.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/rules/context/TrackingReferenceContext.java 2009-02-14 22:45:52 UTC (rev 9397) +++ Trunk/pcgen/code/src/java/pcgen/rules/context/TrackingReferenceContext.java 2009-02-14 22:48:04 UTC (rev 9398) @@ -41,7 +41,7 @@ UnconstructedListener { - private DoubleKeyMapToList<CDOMReference<?>, URI, String> track = new DoubleKeyMapToList<CDOMReference<?>, URI, String>(WeakHashMap.class, HashMap.class); + private final DoubleKeyMapToList<CDOMReference<?>, URI, String> track = new DoubleKeyMapToList<CDOMReference<?>, URI, String>(WeakHashMap.class, HashMap.class); @Override public <T extends CDOMObject & CategorizedCDOMObject<T>> CDOMSingleRef<T> getCDOMReference( @@ -96,7 +96,7 @@ return ref; } - private Set<ReferenceManufacturer<?, ?>> listening = new HashSet<ReferenceManufacturer<?, ?>>(); + private final Set<ReferenceManufacturer<?, ?>> listening = new HashSet<ReferenceManufacturer<?, ?>>(); @Override protected <T extends CDOMObject & CategorizedCDOMObject<T>> ReferenceManufacturer<T, ? extends CDOMSingleRef<T>> getManufacturer( Modified: Trunk/pcgen/code/src/java/pcgen/rules/persistence/CDOMSubLineLoader.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/rules/persistence/CDOMSubLineLoader.java 2009-02-14 22:45:52 UTC (rev 9397) +++ Trunk/pcgen/code/src/java/pcgen/rules/persistence/CDOMSubLineLoader.java 2009-02-14 22:48:04 UTC (rev 9398) @@ -76,8 +76,7 @@ { try { - T obj = targetClass.newInstance(); - return obj; + return targetClass.newInstance(); } catch (InstantiationException e) { Modified: Trunk/pcgen/code/src/java/pcgen/rules/persistence/TokenSupport.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/rules/persistence/TokenSupport.java 2009-02-14 22:45:52 UTC (rev 9397) +++ Trunk/pcgen/code/src/java/pcgen/rules/persistence/TokenSupport.java 2009-02-14 22:48:04 UTC (rev 9398) @@ -113,12 +113,14 @@ if (tokenList != null) { for (CDOMToken<T> token : tokenList) - if (token.parse(context, cdo, value)) { - return true; + if (token.parse(context, cdo, value)) + { + return true; + } + Logging.addParseMessage(Logging.LST_ERROR, + "Failed in parsing subtoken: " + key + " of " + value); } - Logging.addParseMessage(Logging.LST_ERROR, - "Failed in parsing subtoken: " + key + " of " + value); } /* * CONSIDER Better option than toString, given that T != CDOMObject This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <th...@us...> - 2009-02-15 00:12:53
|
Revision: 9399 http://pcgen.svn.sourceforge.net/pcgen/?rev=9399&view=rev Author: thpr Date: 2009-02-15 00:12:49 +0000 (Sun, 15 Feb 2009) Log Message: ----------- [ 2185915 ] ADD: tokens don't do proper sorting Issue#: 2185915 Modified Paths: -------------- Trunk/pcgen/code/src/java/pcgen/cdom/helper/AbilitySelection.java Trunk/pcgen/code/src/java/pcgen/core/kit/KitAbilities.java Trunk/pcgen/code/src/java/pcgen/gui/utils/SwingChooser.java Modified: Trunk/pcgen/code/src/java/pcgen/cdom/helper/AbilitySelection.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/cdom/helper/AbilitySelection.java 2009-02-14 22:48:04 UTC (rev 9398) +++ Trunk/pcgen/code/src/java/pcgen/cdom/helper/AbilitySelection.java 2009-02-15 00:12:49 UTC (rev 9399) @@ -35,7 +35,7 @@ * This is generally used as the storage container when a selection has been * made from a token like ADD:FEAT */ -public class AbilitySelection +public class AbilitySelection implements Comparable<AbilitySelection> { /** @@ -324,4 +324,19 @@ { return ability; } + + public int compareTo(AbilitySelection o) + { + int base = ability.compareTo(o.ability); + if (base != 0) + { + return base; + } + if (selection == null) + { + return o.selection == null ? 0 : -1; + } + return o.selection == null ? 1 : selection + .compareToIgnoreCase(o.selection); + } } Modified: Trunk/pcgen/code/src/java/pcgen/core/kit/KitAbilities.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/kit/KitAbilities.java 2009-02-14 22:48:04 UTC (rev 9398) +++ Trunk/pcgen/code/src/java/pcgen/core/kit/KitAbilities.java 2009-02-15 00:12:49 UTC (rev 9399) @@ -294,7 +294,7 @@ return wc; } - private class AbilitySelection + private class AbilitySelection implements Comparable<AbilitySelection> { public final Ability ability; public final String selection; @@ -316,6 +316,21 @@ } return sb.toString(); } + + public int compareTo(AbilitySelection o) + { + int base = ability.compareTo(o.ability); + if (base != 0) + { + return base; + } + if (selection == null) + { + return o.selection == null ? 0 : -1; + } + return o.selection == null ? 1 : selection + .compareToIgnoreCase(o.selection); + } } public void setCategory(AbilityCategory ac) Modified: Trunk/pcgen/code/src/java/pcgen/gui/utils/SwingChooser.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/gui/utils/SwingChooser.java 2009-02-14 22:48:04 UTC (rev 9398) +++ Trunk/pcgen/code/src/java/pcgen/gui/utils/SwingChooser.java 2009-02-15 00:12:49 UTC (rev 9399) @@ -34,6 +34,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; +import java.util.Collections; import java.util.Iterator; import java.util.List; import java.util.StringTokenizer; @@ -1054,6 +1055,10 @@ setAvailableColumnNames(AVAILABLE_COLUMN_NAMES); } + if (mAvailableList.get(0) instanceof Comparable) + { + Collections.sort(mAvailableList); + } updateTable(mAvailableTable, mAvailableModel, mAvailableList, ""); // mAvailableData = updateTable(mAvailableTable, mAvailableModel, mAvailableData, // mAvailableList, ""); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <th...@us...> - 2009-02-25 23:33:30
|
Revision: 9492 http://pcgen.svn.sourceforge.net/pcgen/?rev=9492&view=rev Author: thpr Date: 2009-02-25 22:28:45 +0000 (Wed, 25 Feb 2009) Log Message: ----------- minor cleanup Modified Paths: -------------- Trunk/pcgen/code/src/java/pcgen/cdom/base/CDOMObject.java Trunk/pcgen/code/src/java/pcgen/core/PlayerCharacter.java Modified: Trunk/pcgen/code/src/java/pcgen/cdom/base/CDOMObject.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/cdom/base/CDOMObject.java 2009-02-25 22:28:20 UTC (rev 9491) +++ Trunk/pcgen/code/src/java/pcgen/cdom/base/CDOMObject.java 2009-02-25 22:28:45 UTC (rev 9492) @@ -419,7 +419,6 @@ public String getDisplayName() { return this.get(StringKey.NAME); - // TODO Auto-generated method stub } public void setName(String name) @@ -437,11 +436,6 @@ { return false; } - /* - * FIXME Test source here - * - * private final SourceEntry source = new SourceEntry(); - */ if (!integerChar.equals(cdo.integerChar)) { // System.err.println("CDOM Inequality Integer"); Modified: Trunk/pcgen/code/src/java/pcgen/core/PlayerCharacter.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/PlayerCharacter.java 2009-02-25 22:28:20 UTC (rev 9491) +++ Trunk/pcgen/code/src/java/pcgen/core/PlayerCharacter.java 2009-02-25 22:28:45 UTC (rev 9492) @@ -16791,7 +16791,6 @@ { for (String aString : getAssociationList(aDomain)) { -System.err.println("DA: " + aString); if (aString.startsWith("FEAT")) { final int idx = aString.indexOf('?'); @@ -16804,7 +16803,6 @@ this, abilities, Constants.FEAT_CATEGORY, aString.substring(idx + 1)); -System.err.println(added); if (added != null) { added This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <th...@us...> - 2009-02-26 00:23:16
|
Revision: 9493 http://pcgen.svn.sourceforge.net/pcgen/?rev=9493&view=rev Author: thpr Date: 2009-02-25 22:53:02 +0000 (Wed, 25 Feb 2009) Log Message: ----------- [ 2601269 ] mapChar not cloned in CDOMObject [ 2601283 ] CDOMListMods is not copied in overlay Issue#: 2601269 Modified Paths: -------------- Trunk/pcgen/code/src/java/pcgen/base/util/DoubleKeyMapToList.java Trunk/pcgen/code/src/java/pcgen/cdom/base/CDOMObject.java Modified: Trunk/pcgen/code/src/java/pcgen/base/util/DoubleKeyMapToList.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/base/util/DoubleKeyMapToList.java 2009-02-25 22:28:45 UTC (rev 9492) +++ Trunk/pcgen/code/src/java/pcgen/base/util/DoubleKeyMapToList.java 2009-02-25 22:53:02 UTC (rev 9493) @@ -26,6 +26,7 @@ import java.util.List; import java.util.Map; import java.util.Set; +import java.util.Map.Entry; /** * @author Thomas Parker (thpr [at] yahoo.com) @@ -149,13 +150,7 @@ */ public void addToListFor(K1 key1, K2 key2, V value) { - MapToList<K2, V> localMap = mtmtl.get(key1); - if (localMap == null) - { - localMap = GenericMapToList.getMapToList(secondClass); - mtmtl.put(key1, localMap); - } - localMap.addToListFor(key2, value); + getMapToListFor(key1).addToListFor(key2, value); } /** @@ -181,13 +176,33 @@ */ public void addAllToListFor(K1 key1, K2 key2, Collection<V> values) { - MapToList<K2, V> localMap = mtmtl.get(key1); - if (localMap == null) + getMapToListFor(key1).addAllToListFor(key2, values); + } + + /** + * Adds all of the contents of the given DoubleKeyMapToList to this + * DoubleKeyMapToList. + * + * No reference is maintained to the internal structure of the given + * DoubleKeyMapToList, so modifications to this DoubleKeyMapToList are not + * reflected in the given DoubleKeyMapToList (and vice versa). However, the + * Keys and Value objects from the given DoubleKeyMapToList are maintained + * by reference, so modification to the Keys or Values of either this + * DoubleKeyMapToList or the given DoubleKeyMapToList will be reflected in + * the other DoubleKeyMapToList (this is consistent behavior with the + * analogous classes in the java.util.Map implementations) + * + * @param dkmtl + * The DoubleKeyMapToList from which the contents should be + * copied into this DoubleKeyMapToList. + */ + public void addAll(DoubleKeyMapToList<K1, K2, V> dkmtl) + { + for (Entry<K1, MapToList<K2, V>> me : dkmtl.mtmtl.entrySet()) { - localMap = GenericMapToList.getMapToList(secondClass); - mtmtl.put(key1, localMap); + MapToList<K2, V> localMap = getMapToListFor(me.getKey()); + localMap.addAllLists(me.getValue()); } - localMap.addAllToListFor(key2, values); } /** @@ -560,4 +575,25 @@ e); } } + + /** + * This should remain PRIVATE as it exposes the internal structure of the + * DoubleKeyMapToList. It is used as an internal convenience method. + * + * @param key1 + * The Key for which an internal MapToList should be fetched, or + * created if it does not exist + * @return The (internal use only) MapToList for the given key + */ + private MapToList<K2, V> getMapToListFor(K1 key1) + { + MapToList<K2, V> localMap = mtmtl.get(key1); + if (localMap == null) + { + localMap = GenericMapToList.getMapToList(secondClass); + mtmtl.put(key1, localMap); + } + return localMap; + } + } Modified: Trunk/pcgen/code/src/java/pcgen/cdom/base/CDOMObject.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/cdom/base/CDOMObject.java 2009-02-25 22:28:45 UTC (rev 9492) +++ Trunk/pcgen/code/src/java/pcgen/cdom/base/CDOMObject.java 2009-02-25 22:53:02 UTC (rev 9493) @@ -474,6 +474,10 @@ // + cdo.listChar.getKeySet()); return false; } + if (!mapChar.equals(cdo.mapChar)) + { + return false; + } if (!cdomListMods.equals(cdo.cdomListMods)) { // System.err.println("CDOM Inequality ListMods"); @@ -569,9 +573,8 @@ objectChar.putAll(cdo.objectChar); variableChar.putAll(cdo.variableChar); listChar.addAllLists(cdo.listChar); - /* - * TODO Need to do CDOMListMods - */ + mapChar.putAll(cdo.mapChar); + cdomListMods.addAll(cdo.cdomListMods); } @Override @@ -585,6 +588,8 @@ clone.objectChar = new HashMap<ObjectKey<?>, Object>(objectChar); clone.listChar = new ListKeyMapToList(); clone.listChar.addAllLists(listChar); + clone.mapChar = new MapKeyMap(); + clone.mapChar.putAll(mapChar); clone.cdomListMods = cdomListMods.clone(); clone.ownBonuses(); return clone; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <th...@us...> - 2009-03-02 22:58:04
|
Revision: 9553 http://pcgen.svn.sourceforge.net/pcgen/?rev=9553&view=rev Author: thpr Date: 2009-03-02 22:57:54 +0000 (Mon, 02 Mar 2009) Log Message: ----------- [ 2655742 ] War Domain CHOOSE doesn't add Prof or Feat Issue#: 2655742 Modified Paths: -------------- Trunk/pcgen/code/src/java/pcgen/core/PCClass.java Trunk/pcgen/code/src/java/pcgen/core/kit/KitDeity.java Trunk/pcgen/code/src/java/pcgen/core/npcgen/NPCGenerator.java Trunk/pcgen/code/src/java/pcgen/gui/tabs/InfoDomain.java Trunk/pcgen/code/src/java/pcgen/io/PCGVer2Parser.java Modified: Trunk/pcgen/code/src/java/pcgen/core/PCClass.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/PCClass.java 2009-03-02 18:57:53 UTC (rev 9552) +++ Trunk/pcgen/code/src/java/pcgen/core/PCClass.java 2009-03-02 22:57:54 UTC (rev 9553) @@ -4119,10 +4119,9 @@ final CharacterDomain aCD = aPC.getNewCharacterDomain(getKeyName()); - aCD.setDomain(aDomain, aPC); + Domain newDomain = aCD.setDomain(aDomain, aPC); aPC.addCharacterDomain(aCD); - aDomain = aCD.getDomain(); - DomainApplication.applyDomain(aPC, aDomain); + DomainApplication.applyDomain(aPC, newDomain); } } else Modified: Trunk/pcgen/code/src/java/pcgen/core/kit/KitDeity.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/kit/KitDeity.java 2009-03-02 18:57:53 UTC (rev 9552) +++ Trunk/pcgen/code/src/java/pcgen/core/kit/KitDeity.java 2009-03-02 22:57:54 UTC (rev 9553) @@ -223,8 +223,8 @@ } domainsToAdd.add(domain); - DomainApplication.applyDomain(aPC, domain); - aCD.setDomain(domain, aPC); + Domain newDomain = aCD.setDomain(domain, aPC); + DomainApplication.applyDomain(aPC, newDomain); aPC.addCharacterDomain(aCD); } aPC.calcActiveBonuses(); @@ -259,8 +259,8 @@ // Shouldn't happen continue; } - DomainApplication.applyDomain(aPC, domain); - aCD.setDomain(domain, aPC); + Domain newDomain = aCD.setDomain(domain, aPC); + DomainApplication.applyDomain(aPC, newDomain); aPC.addCharacterDomain(aCD); } aPC.calcActiveBonuses(); Modified: Trunk/pcgen/code/src/java/pcgen/core/npcgen/NPCGenerator.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/npcgen/NPCGenerator.java 2009-03-02 18:57:53 UTC (rev 9552) +++ Trunk/pcgen/code/src/java/pcgen/core/npcgen/NPCGenerator.java 2009-03-02 22:57:54 UTC (rev 9553) @@ -446,8 +446,8 @@ // space remains for another domain, so add it if (existingDomain == null) { - DomainApplication.applyDomain(aPC, domain); - aCD.setDomain(domain, aPC); + Domain newDomain = aCD.setDomain(domain, aPC); + DomainApplication.applyDomain(aPC, newDomain); aPC.addCharacterDomain(aCD); aPC.calcActiveBonuses(); Modified: Trunk/pcgen/code/src/java/pcgen/gui/tabs/InfoDomain.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/gui/tabs/InfoDomain.java 2009-03-02 18:57:53 UTC (rev 9552) +++ Trunk/pcgen/code/src/java/pcgen/gui/tabs/InfoDomain.java 2009-03-02 22:57:54 UTC (rev 9553) @@ -1410,9 +1410,9 @@ // space remains for another domain, so add it if (existingDomain == null) { - aCD.setDomain(addedDomain, pc); + Domain newDomain = aCD.setDomain(addedDomain, pc); pc.addCharacterDomain(aCD); - DomainApplication.applyDomain(pc, addedDomain); + DomainApplication.applyDomain(pc, newDomain); if (!selectedDomainList.contains(addedDomain)) { Modified: Trunk/pcgen/code/src/java/pcgen/io/PCGVer2Parser.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/io/PCGVer2Parser.java 2009-03-02 18:57:53 UTC (rev 9552) +++ Trunk/pcgen/code/src/java/pcgen/io/PCGVer2Parser.java 2009-03-02 22:57:54 UTC (rev 9553) @@ -2169,7 +2169,7 @@ // PC doesn't have the domain, so create a new // one and add it to the PC domain list CharacterDomain aCharacterDomain = new CharacterDomain(); - aCharacterDomain.setDomain(aDomain, thePC); + Domain newDomain = aCharacterDomain.setDomain(aDomain, thePC); while (it.hasNext()) { @@ -2185,13 +2185,13 @@ } else if (TAG_ASSOCIATEDDATA.equals(tag)) { - thePC.addAssociation(aCharacterDomain.getDomain(), + thePC.addAssociation(newDomain, EntityEncoder.decode(element.getText())); } } thePC.addCharacterDomain(aCharacterDomain); - DomainApplication.applyDomain(thePC, aDomain); + DomainApplication.applyDomain(thePC, newDomain); // TODO // set associated list This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <th...@us...> - 2009-03-14 17:28:53
|
Revision: 9643 http://pcgen.svn.sourceforge.net/pcgen/?rev=9643&view=rev Author: thpr Date: 2009-03-14 17:28:42 +0000 (Sat, 14 Mar 2009) Log Message: ----------- eliminate effectively useless method getActiveEquivalent from PObject Modified Paths: -------------- Trunk/pcgen/code/src/java/pcgen/cdom/choiceset/AbilityFromClassChoiceSet.java Trunk/pcgen/code/src/java/pcgen/core/Ability.java Trunk/pcgen/code/src/java/pcgen/core/PCClass.java Trunk/pcgen/code/src/java/pcgen/core/PCStat.java Trunk/pcgen/code/src/java/pcgen/core/PCTemplate.java Trunk/pcgen/code/src/java/pcgen/core/PObject.java Trunk/pcgen/code/src/java/pcgen/core/Race.java Trunk/pcgen/code/src/java/pcgen/core/Skill.java Modified: Trunk/pcgen/code/src/java/pcgen/cdom/choiceset/AbilityFromClassChoiceSet.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/cdom/choiceset/AbilityFromClassChoiceSet.java 2009-03-14 17:27:32 UTC (rev 9642) +++ Trunk/pcgen/code/src/java/pcgen/cdom/choiceset/AbilityFromClassChoiceSet.java 2009-03-14 17:28:42 UTC (rev 9643) @@ -137,7 +137,7 @@ */ public Set<AbilitySelection> getSet(PlayerCharacter pc) { - PCClass aClass = cl.resolvesTo().getActiveEquivalent(pc); + PCClass aClass = pc.getClassKeyed(cl.resolvesTo().getKeyName()); Set<AbilitySelection> set = new HashSet<AbilitySelection>(); if (aClass != null) { Modified: Trunk/pcgen/code/src/java/pcgen/core/Ability.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/Ability.java 2009-03-14 17:27:32 UTC (rev 9642) +++ Trunk/pcgen/code/src/java/pcgen/core/Ability.java 2009-03-14 17:28:42 UTC (rev 9643) @@ -307,16 +307,4 @@ } return ListKey.DESCRIPTION; } - - @Override - public PObject getActiveEquivalent(PlayerCharacter pc) - { - AbilityCategory cat = SettingsHandler.getGame() - .silentlyGetAbilityCategory(getCategory()); - PObject ability = pc.getAbilityKeyed(cat, getAbilityNature(), - getKeyName()); - return ability == null ? this : ability; - } - - } Modified: Trunk/pcgen/code/src/java/pcgen/core/PCClass.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/PCClass.java 2009-03-14 17:27:32 UTC (rev 9642) +++ Trunk/pcgen/code/src/java/pcgen/core/PCClass.java 2009-03-14 17:28:42 UTC (rev 9643) @@ -4377,12 +4377,6 @@ } @Override - public PCClass getActiveEquivalent(PlayerCharacter pc) - { - return pc.getClassKeyed(getKeyName()); - } - - @Override public List<BonusObj> getRawBonusList(PlayerCharacter pc) { List<BonusObj> list = super.getRawBonusList(pc); Modified: Trunk/pcgen/code/src/java/pcgen/core/PCStat.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/PCStat.java 2009-03-14 17:27:32 UTC (rev 9642) +++ Trunk/pcgen/code/src/java/pcgen/core/PCStat.java 2009-03-14 17:28:42 UTC (rev 9643) @@ -158,11 +158,4 @@ { return statMod; } - - @Override - public PObject getActiveEquivalent(PlayerCharacter pc) - { - int index = SettingsHandler.getGame().getStatFromAbbrev(getKeyName()); - return pc.getStatList().getStatAt(index); - } } Modified: Trunk/pcgen/code/src/java/pcgen/core/PCTemplate.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/PCTemplate.java 2009-03-14 17:27:32 UTC (rev 9642) +++ Trunk/pcgen/code/src/java/pcgen/core/PCTemplate.java 2009-03-14 17:28:42 UTC (rev 9643) @@ -267,11 +267,4 @@ // end potential TO-DO change return list; } - - @Override - public PObject getActiveEquivalent(PlayerCharacter pc) - { - return pc.getTemplateKeyed(getKeyName()); - } - } Modified: Trunk/pcgen/code/src/java/pcgen/core/PObject.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/PObject.java 2009-03-14 17:27:32 UTC (rev 9642) +++ Trunk/pcgen/code/src/java/pcgen/core/PObject.java 2009-03-14 17:28:42 UTC (rev 9643) @@ -973,14 +973,6 @@ return bonus * iTimes; } - /* - * Any PObject which is cloned before it is added to a PC must override this - */ - public PObject getActiveEquivalent(PlayerCharacter as) - { - return this; - } - public List<BonusObj> getBonusList(AssociationStore as) { if (as instanceof PlayerCharacter) Modified: Trunk/pcgen/code/src/java/pcgen/core/Race.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/Race.java 2009-03-14 17:27:32 UTC (rev 9642) +++ Trunk/pcgen/code/src/java/pcgen/core/Race.java 2009-03-14 17:28:42 UTC (rev 9643) @@ -141,15 +141,4 @@ return steps; } } - - @Override - public PObject getActiveEquivalent(PlayerCharacter pc) - { - if (pc.getRace().getKeyName().equals(getKeyName())) - { - return pc.getRace(); - } - return this; - } - } Modified: Trunk/pcgen/code/src/java/pcgen/core/Skill.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/Skill.java 2009-03-14 17:27:32 UTC (rev 9642) +++ Trunk/pcgen/code/src/java/pcgen/core/Skill.java 2009-03-14 17:28:42 UTC (rev 9643) @@ -304,12 +304,4 @@ PCStat keyStat = get(ObjectKey.KEY_STAT); return keyStat == null ? "" : keyStat.getAbb(); } - - @Override - public PObject getActiveEquivalent(PlayerCharacter pc) - { - return pc.getSkillKeyed(getKeyName()); - } - - } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <th...@us...> - 2009-03-14 18:20:21
|
Revision: 9646 http://pcgen.svn.sourceforge.net/pcgen/?rev=9646&view=rev Author: thpr Date: 2009-03-14 18:20:19 +0000 (Sat, 14 Mar 2009) Log Message: ----------- [ 877582 ] Separate Meta data from implementation data in code Specifically moves field isNewItem into the editor system (only place it was used) Issue#: 877582 Modified Paths: -------------- Trunk/pcgen/code/src/java/pcgen/core/Domain.java Trunk/pcgen/code/src/java/pcgen/gui/editor/EditorMainForm.java Modified: Trunk/pcgen/code/src/java/pcgen/core/Domain.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/Domain.java 2009-03-14 17:33:05 UTC (rev 9645) +++ Trunk/pcgen/code/src/java/pcgen/core/Domain.java 2009-03-14 18:20:19 UTC (rev 9646) @@ -43,30 +43,6 @@ */ public final class Domain extends PObject { - /* - * Honestly, as Editor information, this doesn't belong here, but it works - * for now. TODO Should be removed in 5.17 editor rebuild - */ - private boolean isNewItem = true; - - /** - * Set the item as new flag - * @param newItem - */ - public final void setNewItem(final boolean newItem) - { - this.isNewItem = newItem; - } - - /** - * Returns true if the item is new - * @return true if the item is new - */ - public final boolean isNewItem() - { - return isNewItem; - } - @Override public Domain clone() { Modified: Trunk/pcgen/code/src/java/pcgen/gui/editor/EditorMainForm.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/gui/editor/EditorMainForm.java 2009-03-14 17:33:05 UTC (rev 9645) +++ Trunk/pcgen/code/src/java/pcgen/gui/editor/EditorMainForm.java 2009-03-14 18:20:19 UTC (rev 9646) @@ -315,6 +315,7 @@ private VisionPanel pnlVision; private boolean wasCancelled = true; private int editType = EditorConstants.EDIT_NONE; + private Set<PObject> oldItems = new HashSet<PObject>(); /** Creates new form EditorMainForm * @param parent @@ -683,9 +684,7 @@ context.unconditionallyProcess(thisPObject, "FEAT", aString); sel = pnlQSpells.getSelectedList(); - Domain thisDomain = (Domain) thisPObject; - if (thisDomain.isNewItem()) - thisDomain.setNewItem(false); + oldItems.add(thisPObject); thisPObject.clearSpellListInfo(); for (int i = 0; i < sel.length; ++i) @@ -1389,8 +1388,7 @@ List<Spell> availableSpellList = new ArrayList<Spell>(); List<String> selectedSpellList = new ArrayList<String>(); - Domain thisDomain = (Domain) thisPObject; - if (thisDomain.isNewItem()) + if (!oldItems.contains(thisPObject)) { thisPObject.clearSpellListInfo(); for (Iterator<?> e = Globals.getSpellMap().values().iterator(); e.hasNext();) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <th...@us...> - 2009-03-14 22:26:07
|
Revision: 9652 http://pcgen.svn.sourceforge.net/pcgen/?rev=9652&view=rev Author: thpr Date: 2009-03-14 22:26:05 +0000 (Sat, 14 Mar 2009) Log Message: ----------- [ 877582 ] Separate Meta data from implementation data in code Specifically remove saSource in SpecialAbility to simplify data structure & recursive changes required (on things like name changes) Modified Paths: -------------- Trunk/pcgen/code/src/java/pcgen/core/PCClass.java Trunk/pcgen/code/src/java/pcgen/core/PObject.java Trunk/pcgen/code/src/java/pcgen/core/SpecialAbility.java Trunk/pcgen/code/src/java/pcgen/core/analysis/SpecialAbilityResolution.java Trunk/pcgen/code/src/java/pcgen/gui/AddSpecialAbility.java Trunk/pcgen/code/src/java/pcgen/gui/editor/EditorMainForm.java Trunk/pcgen/code/src/java/pcgen/gui/tabs/InfoSpecialAbilities.java Trunk/pcgen/code/src/java/pcgen/io/PCGVer0Parser.java Trunk/pcgen/code/src/java/pcgen/io/PCGVer2Creator.java Trunk/pcgen/code/src/java/pcgen/io/PCGVer2Parser.java Modified: Trunk/pcgen/code/src/java/pcgen/core/PCClass.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/PCClass.java 2009-03-14 22:16:51 UTC (rev 9651) +++ Trunk/pcgen/code/src/java/pcgen/core/PCClass.java 2009-03-14 22:26:05 UTC (rev 9652) @@ -3020,33 +3020,6 @@ } // - // Go through the specialty list (SA) and adjust the class to the new - // name - // - for (SpecialAbility sa : getSafeListFor(ListKey.SAB)) - { - removeFromListFor(ListKey.SAB, sa); - sa = new SpecialAbility(sa.getKeyName(), sa.getSASource(), sa - .getSADesc()); - sa.setQualificationClass(oldClass, newClass); - addToListFor(ListKey.SAB, sa); - } - for (PCClassLevel pcl : getClassLevelCollection()) - { - for (SpecialAbility sa : pcl.getSafeListFor(ListKey.SAB)) - { - if (sa.getSASource().length() != 0) - { - pcl.removeFromListFor(ListKey.SAB, sa); - sa = new SpecialAbility(sa.getKeyName(), sa.getSASource(), - sa.getSADesc()); - sa.setQualificationClass(oldClass, newClass); - pcl.addToListFor(ListKey.SAB, sa); - } - } - } - - // // Go through the variable list (DEFINE) and adjust the class to the new // name // Modified: Trunk/pcgen/code/src/java/pcgen/core/PObject.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/PObject.java 2009-03-14 22:16:51 UTC (rev 9651) +++ Trunk/pcgen/code/src/java/pcgen/core/PObject.java 2009-03-14 22:26:05 UTC (rev 9652) @@ -51,6 +51,7 @@ import pcgen.cdom.inst.PCClassLevel; import pcgen.cdom.list.ClassSpellList; import pcgen.cdom.list.DomainSpellList; +import pcgen.core.analysis.SpecialAbilityResolution; import pcgen.core.bonus.BonusObj; import pcgen.core.bonus.BonusUtilities; import pcgen.core.chooser.ChooserUtilities; @@ -451,38 +452,7 @@ public List<SpecialAbility> addSpecialAbilitiesToList(final List<SpecialAbility> aList, final PlayerCharacter aPC) { - for ( SpecialAbility sa : getSafeListFor(ListKey.SPECIAL_ABILITY) ) - { - if (sa.pcQualifiesFor(aPC)) - { - final String key = sa.getKeyName(); - final int idx = key.indexOf("%CHOICE"); - - if (idx >= 0) - { - StringBuilder sb = new StringBuilder(); - sb.append(key.substring(0, idx)); - - if (aPC.hasAssociations(this)) - { - sb.append(StringUtil.joinToStringBuffer(aPC.getAssociationList(this), ", ")); - } - else - { - sb.append("<undefined>"); - } - - sb.append(key.substring(idx + 7)); - sa = - new SpecialAbility(sb.toString(), sa.getSASource(), - sa.getSADesc()); - } - - aList.add(sa); - } - } - - return aList; + return SpecialAbilityResolution.addSABToList(aList, aPC, this); } public void globalChecks(final PlayerCharacter aPC) Modified: Trunk/pcgen/code/src/java/pcgen/core/SpecialAbility.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/SpecialAbility.java 2009-03-14 22:16:51 UTC (rev 9651) +++ Trunk/pcgen/code/src/java/pcgen/core/SpecialAbility.java 2009-03-14 22:26:05 UTC (rev 9652) @@ -20,11 +20,7 @@ */ package pcgen.core; -import java.util.StringTokenizer; -import pcgen.core.prereq.PrereqHandler; -import pcgen.util.Logging; - /** * <code>SpecialAbility</code>. * @@ -33,7 +29,6 @@ */ public final class SpecialAbility extends TextProperty { - protected String saSource = ""; //$NON-NLS-1$ private String propDesc = ""; /** Default constructor */ @@ -53,77 +48,22 @@ } /** - * Constructor, with name and source - * - * @param name - * @param saSource - */ - public SpecialAbility(final String name, final String saSource) - { - super(name); - this.saSource = saSource; - } - - /** * Constructor * * @param name * The name of the Special Ability - * @param saSource - * The source of the Special Ability * @param propDesc * NEEDDOC * */ - public SpecialAbility(final String name, final String saSource, + public SpecialAbility(final String name, final String propDesc) { super(name); - this.saSource = saSource; this.propDesc = propDesc; } /** - * Set the class that is used to determine if a character should have this - * special ability - * - * @param oldClass - * The name of the original class - * @param newClass - * The name of the new class that is to be used for this special - * ability - */ - public void setQualificationClass(final String oldClass, - final String newClass) - { - if ("".equals(saSource)) //$NON-NLS-1$ - { - return; - } - - try - { - final StringTokenizer aTok = - new StringTokenizer(saSource, "|=", false); - final String typeString = aTok.nextToken(); - final String classKey = aTok.nextToken(); - final String levelString = aTok.nextToken(); - - if (classKey.equals(oldClass)) - { - Logging.errorPrint("Source class changed from " + oldClass //$NON-NLS-1$ - + " to " + newClass + " for " + getDisplayName()); //$NON-NLS-1$ //$NON-NLS-2$ - - setSASource(typeString + "=" + newClass + "|" + levelString); - } - } - catch (Exception exc) - { - Logging.errorPrint("setQualificationClass:" + saSource, exc); //$NON-NLS-1$ - } - } - - /** * Set the description of the Special Ability * * @param saDesc @@ -144,44 +84,11 @@ } /** - * Set the source of the special ability - * - * @param saSource - */ - public void setSASource(final String saSource) - { - this.saSource = saSource; - } - - /** - * Get the source of the Special Ability - * - * @return source of the Special Ability - */ - public String getSASource() - { - return saSource; - } - - /** * @see pcgen.core.TextProperty#compareTo(java.lang.Object) */ @Override public int compareTo(final Object obj) { - if (obj instanceof SpecialAbility) - { - SpecialAbility sa = (SpecialAbility) obj; - if (getKeyName().equals(sa.getKeyName())) - { -// if (keyName.equalsIgnoreCase(tp.getKeyName())) -// { -// return propDesc.compareToIgnoreCase(((TextProperty) obj).propDesc); -// } - return saSource.compareToIgnoreCase(sa.saSource); - } - } - return getKeyName().compareToIgnoreCase(obj.toString()); } @@ -195,65 +102,6 @@ } /** - * Check if the PC qualifies for the Special Ability. - */ - @Override - public boolean pcQualifiesFor(final PlayerCharacter aPC) - { - - // If the PC doesn't meet all of pre-reqs then return false - if (!PrereqHandler.passesAll(getPrerequisiteList(), aPC, null)) - { - return false; - } - - // If there is an empty or '0' qualification, then return true - if ("".equals(saSource) || saSource.endsWith("|0")) //$NON-NLS-1$ - { - return true; - } - - // currently source is either empty or - // PCCLASS|classKey|classlevel (means it's a chosen special ability) - // PCCLASS=classKey|classlevel (means it's a defined special ability) - // DEITY=deityKey|totallevels - final StringTokenizer aTok = new StringTokenizer(saSource, "|=", false); - final String aString = aTok.nextToken(); - final String aKey = aTok.nextToken(); - final PCClass aClass; - final int level; - - // Get the level, if not a valid number then return false - try - { - level = Integer.parseInt(aTok.nextToken()); - } - catch (NumberFormatException exc) - { - Logging.errorPrint("pcQualifiesFor:" + saSource, exc); //$NON-NLS-1$ - return false; - } - - // If we're reading in PCCLASS then check the PC's level (for that - // class) versus the level that we need to qualify for - if ("PCCLASS".equals(aString)) - { - aClass = aPC.getClassKeyed(aKey); - - // If the PC doesn't have that class then return false - if (aClass == null) - { - return false; - } - - return (aClass.getLevel() >= level); - } - - // Otherwise by default we check against the total level - return aPC.getTotalLevels() >= level; - } - - /** * Set the property description * @param propDesc */ Modified: Trunk/pcgen/code/src/java/pcgen/core/analysis/SpecialAbilityResolution.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/analysis/SpecialAbilityResolution.java 2009-03-14 22:16:51 UTC (rev 9651) +++ Trunk/pcgen/code/src/java/pcgen/core/analysis/SpecialAbilityResolution.java 2009-03-14 22:26:05 UTC (rev 9652) @@ -29,7 +29,7 @@ public class SpecialAbilityResolution { - public static void addSABToList(List<SpecialAbility> saList, PlayerCharacter pc, CDOMObject cdo) + public static List<SpecialAbility> addSABToList(List<SpecialAbility> saList, PlayerCharacter pc, CDOMObject cdo) { for (SpecialAbility sa : cdo.getSafeListFor(ListKey.SAB)) { @@ -54,8 +54,7 @@ } sb.append(key.substring(idx + 7)); - sa = new SpecialAbility(sb.toString(), sa.getSASource(), sa - .getSADesc()); + sa = new SpecialAbility(sb.toString(), sa.getSADesc()); saList.add(sa); } else @@ -64,6 +63,7 @@ } } } + return saList; } } Modified: Trunk/pcgen/code/src/java/pcgen/gui/AddSpecialAbility.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/gui/AddSpecialAbility.java 2009-03-14 22:16:51 UTC (rev 9651) +++ Trunk/pcgen/code/src/java/pcgen/gui/AddSpecialAbility.java 2009-03-14 22:26:05 UTC (rev 9652) @@ -302,7 +302,7 @@ return sa.getDisplayName(); case 1: // Source - return sa.getSASource(); + return ""; default: break; Modified: Trunk/pcgen/code/src/java/pcgen/gui/editor/EditorMainForm.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/gui/editor/EditorMainForm.java 2009-03-14 22:16:51 UTC (rev 9651) +++ Trunk/pcgen/code/src/java/pcgen/gui/editor/EditorMainForm.java 2009-03-14 22:26:05 UTC (rev 9652) @@ -3175,17 +3175,7 @@ { for (Iterator<SpecialAbility> e = saList.iterator(); e.hasNext();) { - SpecialAbility specialAbility = e.next(); - String saSource = specialAbility.getSASource(); - String saLevel = saSource.substring(saSource.indexOf("|") + 1); - String saTxt = specialAbility.toString(); - - if (saLevel.length() > 0) - { - saLevel += "|"; - } - - selectedList.add("SAB:" + saLevel + saTxt); + selectedList.add("SAB:" + e.next().toString()); } } Modified: Trunk/pcgen/code/src/java/pcgen/gui/tabs/InfoSpecialAbilities.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/gui/tabs/InfoSpecialAbilities.java 2009-03-14 22:16:51 UTC (rev 9651) +++ Trunk/pcgen/code/src/java/pcgen/gui/tabs/InfoSpecialAbilities.java 2009-03-14 22:26:05 UTC (rev 9652) @@ -519,11 +519,8 @@ for (SpecialAbility sa : aClass .getSafeListFor(ListKey.SPECIAL_ABILITY)) { - if (sa.getSASource().endsWith("|0")) - { - aList.add(sa.getKeyName()); - cList.add(sa); - } + aList.add(sa.getKeyName()); + cList.add(sa); } } @@ -547,10 +544,7 @@ } SpecialAbility sa = cList.get(ix); - final String bString = sa.getSASource(); - PCClass aClass = - pc.getClassKeyed(bString.substring( - bString.indexOf("|") + 1, bString.lastIndexOf("|"))); + PCClass aClass = pc.getClassList().get(0); if (aClass == null) { Modified: Trunk/pcgen/code/src/java/pcgen/io/PCGVer0Parser.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/io/PCGVer0Parser.java 2009-03-14 22:16:51 UTC (rev 9651) +++ Trunk/pcgen/code/src/java/pcgen/io/PCGVer0Parser.java 2009-03-14 22:26:05 UTC (rev 9652) @@ -32,6 +32,7 @@ import java.util.Map; import java.util.StringTokenizer; +import pcgen.cdom.base.CDOMObject; import pcgen.cdom.base.Constants; import pcgen.cdom.enumeration.AssociationKey; import pcgen.cdom.enumeration.AssociationListKey; @@ -480,15 +481,27 @@ "Bonus Caster Level for " + cTok.nextToken()); + CDOMObject target = aClass; if ((pcgVersion > 270) && cTok.hasMoreTokens()) { - sa.setSASource("PCCLASS|" - + aClass.getKeyName() + "|" - + cTok.nextToken()); + String tok = cTok.nextToken(); + try + { + int level = Integer.parseInt(tok); + if (level > 0) + { + target = aClass.getClassLevel(level); + } + } + catch (NumberFormatException e) + { + Logging.errorPrint("Expected a level number for SA Source, found: " + + tok); + } } - aClass.addToListFor(ListKey.SPECIAL_ABILITY, sa); + target.addToListFor(ListKey.SPECIAL_ABILITY, sa); } } } Modified: Trunk/pcgen/code/src/java/pcgen/io/PCGVer2Creator.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/io/PCGVer2Creator.java 2009-03-14 22:16:51 UTC (rev 9651) +++ Trunk/pcgen/code/src/java/pcgen/io/PCGVer2Creator.java 2009-03-14 22:26:05 UTC (rev 9652) @@ -48,9 +48,11 @@ import pcgen.cdom.base.PersistentTransitionChoice; import pcgen.cdom.enumeration.AssociationKey; import pcgen.cdom.enumeration.AssociationListKey; +import pcgen.cdom.enumeration.IntegerKey; import pcgen.cdom.enumeration.ListKey; import pcgen.cdom.enumeration.ObjectKey; import pcgen.cdom.enumeration.StringKey; +import pcgen.cdom.inst.PCClassLevel; import pcgen.cdom.list.ClassSpellList; import pcgen.core.Ability; import pcgen.core.AbilityCategory; @@ -87,7 +89,6 @@ import pcgen.core.pclevelinfo.PCLevelInfo; import pcgen.core.pclevelinfo.PCLevelInfoStat; import pcgen.core.spell.Spell; -import pcgen.util.Logging; /** * <code>PCGVer2Creator</code><br> @@ -757,32 +758,23 @@ { if (sa.getKeyName().equalsIgnoreCase(save)) { - found = true; - int relevantLevel = 1; - final String source = sa.getSASource(); - - try + specials.put(pcClass.getKeyName() + TAG_SA + 0, sa + .getKeyName()); + break; + } + } + for (PCClassLevel pcl : pcClass.getClassLevelCollection()) + { + Integer level = pcl.get(IntegerKey.LEVEL); + for (SpecialAbility sa : pcl + .getListFor(ListKey.SPECIAL_ABILITY)) + { + if (sa.getKeyName().equalsIgnoreCase(save)) { - relevantLevel = - Integer.parseInt(source.substring(source - .lastIndexOf('|') + 1)); - - if (relevantLevel < 0) - { - relevantLevel = 1; - } + specials.put(pcClass.getKeyName() + TAG_SA + level, + sa.getKeyName()); + break; } - catch (NumberFormatException nfe) - { - Logging - .errorPrint("Error parsing SA relevant level: " //$NON-NLS-1$ - + source - .substring(source.lastIndexOf('|') + 1)); - } - - specials.put(pcClass.getKeyName() + TAG_SA - + (relevantLevel - 1), sa.getKeyName()); - break; } } Modified: Trunk/pcgen/code/src/java/pcgen/io/PCGVer2Parser.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/io/PCGVer2Parser.java 2009-03-14 22:16:51 UTC (rev 9651) +++ Trunk/pcgen/code/src/java/pcgen/io/PCGVer2Parser.java 2009-03-14 22:26:05 UTC (rev 9652) @@ -1699,10 +1699,6 @@ { for (PCGElement child : element.getChildren()) { - // TODO - This looks like a bug. Looks like it should - // be child.getText(). I am not sure how to test this - // though. - // specialAbilityName = EntityEncoder.decode(element.getText()); specialAbilityName = EntityEncoder.decode(child.getText()); if (pcgenVersion[0] <= 5 && pcgenVersion[1] <= 5 && pcgenVersion[2] < 6) @@ -1719,28 +1715,15 @@ } } specialAbility = new SpecialAbility(specialAbilityName); - - // TODO This looks bogus. PCClass should probably be the - // same case in both instances below. - if (specialAbilityName.endsWith(":-1")) //$NON-NLS-1$ + CDOMObject target = aPCClass; + if (level > 0) { - specialAbilityName = - specialAbilityName.substring(0, - specialAbilityName.length() - 3); - specialAbility = new SpecialAbility(specialAbilityName); - specialAbility - .setSASource("PCClass|" + aPCClass.getKeyName() + '|' + 0); //$NON-NLS-1$ + target = aPCClass.getClassLevel(level); } - else - { - specialAbility = new SpecialAbility(specialAbilityName); - specialAbility - .setSASource("PCCLASS|" + aPCClass.getKeyName() + '|' + level); //$NON-NLS-1$ - } if (!thePC.hasSpecialAbility(specialAbilityName)) { - aPCClass.addToListFor(ListKey.SPECIAL_ABILITY, + target.addToListFor(ListKey.SPECIAL_ABILITY, specialAbility); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <th...@us...> - 2009-03-15 00:33:47
|
Revision: 9656 http://pcgen.svn.sourceforge.net/pcgen/?rev=9656&view=rev Author: thpr Date: 2009-03-15 00:33:43 +0000 (Sun, 15 Mar 2009) Log Message: ----------- [ 877582 ] Separate Meta data from implementation data in code Specifically remove the Field substitutionclasskey from PCClass and make it an association on the PlayerCharacter Modified Paths: -------------- Trunk/pcgen/code/src/java/pcgen/cdom/enumeration/AssociationKey.java Trunk/pcgen/code/src/java/pcgen/core/PCClass.java Trunk/pcgen/code/src/java/pcgen/io/PCGVer2Creator.java Trunk/pcgen/code/src/java/pcgen/io/PCGVer2Parser.java Modified: Trunk/pcgen/code/src/java/pcgen/cdom/enumeration/AssociationKey.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/cdom/enumeration/AssociationKey.java 2009-03-15 00:24:42 UTC (rev 9655) +++ Trunk/pcgen/code/src/java/pcgen/cdom/enumeration/AssociationKey.java 2009-03-15 00:33:43 UTC (rev 9656) @@ -95,6 +95,8 @@ public static final AssociationKey<String> SUBCLASS_KEY = new AssociationKey<String>(); + public static final AssociationKey<String> SUBSTITUTIONCLASS_KEY = new AssociationKey<String>(); + private static CaseInsensitiveMap<AssociationKey<?>> map = null; private AssociationKey() Modified: Trunk/pcgen/code/src/java/pcgen/core/PCClass.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/PCClass.java 2009-03-15 00:24:42 UTC (rev 9655) +++ Trunk/pcgen/code/src/java/pcgen/core/PCClass.java 2009-03-15 00:33:43 UTC (rev 9656) @@ -140,13 +140,6 @@ private int skillPool = 0; /* - * FINALALLCLASSLEVELS This goes into each PCClassLevel from PCClass in order to - * store what the substitution level actually is. This is NOT set by a tag, so it is - * PCCLASSLEVELONLY - */ - private Map<Integer, String> substitutionClassKey = null; - - /* * TYPESAFETY This is definitely something that needs to NOT be a String, * but it gets VERY complicated to do that, since the keys are widely used * in the variable processor. @@ -710,7 +703,8 @@ */ public String getDisplayClassName(PlayerCharacter pc, final int aLevel) { - String aKey = getSubstitutionClassKey(aLevel); + PCClassLevel lvl = getClassLevel(aLevel); + String aKey = pc.getAssoc(lvl, AssociationKey.SUBSTITUTIONCLASS_KEY); if (aKey == null) { return getDisplayClassName(pc); @@ -1114,34 +1108,6 @@ } /* - * FINALPCCLASSLEVELONLY Since this is setting the key that will appear in - * the PCClassLevel (called during construction) this is only required - * in the level objects, not PCClass - */ - public void setSubstitutionClassKey(final String aKey, final Integer aLevel) - { - if (substitutionClassKey == null) - { - substitutionClassKey = new HashMap<Integer, String>(); - } - substitutionClassKey.put(aLevel, aKey); - } - - /* - * FINALPCCLASSLEVELONLY Since this is getting the key that will appear in - * the PCClassLevel (was set during construction) this is only required - * in the level objects, not PCClass - */ - public String getSubstitutionClassKey(final Integer aLevel) - { - if (substitutionClassKey == null) - { - return null; - } - return substitutionClassKey.get(aLevel); - } - - /* * PCCLASSLEVELONLY Since this is setting the key that will appear in * the PCClassLevel (called during construction) this is only required * in the level objects, not PCClass @@ -3755,10 +3721,11 @@ selected = selectedList.get(0); } + PCClassLevel lvl = this.getClassLevel(aLevel); if ((!selectedList.isEmpty()) && selected instanceof SubstitutionClass) { SubstitutionClass sc = (SubstitutionClass) selected; - setSubstitutionClassKey(sc.getKeyName(), aLevel); + aPC.setAssoc(lvl, AssociationKey.SUBSTITUTIONCLASS_KEY, sc.getKeyName()); SubstitutionLevelSupport.applyLevelArrayModsToLevel(sc, this, aLevel, aPC); return; } @@ -3771,7 +3738,7 @@ * method returned an empty list, it returned right away without * calling this method. */ - setSubstitutionClassKey(null, aLevel); + aPC.removeAssoc(lvl, AssociationKey.SUBSTITUTIONCLASS_KEY); return; } Modified: Trunk/pcgen/code/src/java/pcgen/io/PCGVer2Creator.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/io/PCGVer2Creator.java 2009-03-15 00:24:42 UTC (rev 9655) +++ Trunk/pcgen/code/src/java/pcgen/io/PCGVer2Creator.java 2009-03-15 00:33:43 UTC (rev 9656) @@ -852,7 +852,8 @@ if (pcClass != null) { - String aKey = pcClass.getSubstitutionClassKey(lvl + 1); + String aKey = thePC.getAssoc(pcClass.getClassLevel(lvl + 1), + AssociationKey.SUBSTITUTIONCLASS_KEY); if (aKey != null) { buffer.append('|'); Modified: Trunk/pcgen/code/src/java/pcgen/io/PCGVer2Parser.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/io/PCGVer2Parser.java 2009-03-15 00:24:42 UTC (rev 9655) +++ Trunk/pcgen/code/src/java/pcgen/io/PCGVer2Parser.java 2009-03-15 00:33:43 UTC (rev 9656) @@ -1639,10 +1639,11 @@ return; } - aPCClass.setSubstitutionClassKey(substitutionClassKeyName, - level); SubstitutionLevelSupport.applyLevelArrayModsToLevel( aSubstitutionClass, aPCClass, level, thePC); + thePC.setAssoc(aPCClass.getClassLevel(level), + AssociationKey.SUBSTITUTIONCLASS_KEY, + substitutionClassKeyName); } else if (TAG_HITPOINTS.equals(tag)) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <th...@us...> - 2009-03-15 00:51:01
|
Revision: 9657 http://pcgen.svn.sourceforge.net/pcgen/?rev=9657&view=rev Author: thpr Date: 2009-03-15 00:50:41 +0000 (Sun, 15 Mar 2009) Log Message: ----------- [ 877582 ] Separate Meta data from implementation data in code Specifically remove the Field skillPool from PCClass and make it an association on the PlayerCharacter Modified Paths: -------------- Trunk/pcgen/code/src/java/pcgen/cdom/enumeration/AssociationKey.java Trunk/pcgen/code/src/java/pcgen/core/PCClass.java Trunk/pcgen/code/src/java/pcgen/core/PlayerCharacter.java Trunk/pcgen/code/src/java/pcgen/core/analysis/SkillRankControl.java Trunk/pcgen/code/src/java/pcgen/core/kit/KitStat.java Trunk/pcgen/code/src/java/pcgen/gui/tabs/InfoSkills.java Trunk/pcgen/code/src/java/pcgen/io/PCGVer0Parser.java Trunk/pcgen/code/src/java/pcgen/io/PCGVer2Creator.java Trunk/pcgen/code/src/java/pcgen/io/PCGVer2Parser.java Modified: Trunk/pcgen/code/src/java/pcgen/cdom/enumeration/AssociationKey.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/cdom/enumeration/AssociationKey.java 2009-03-15 00:33:43 UTC (rev 9656) +++ Trunk/pcgen/code/src/java/pcgen/cdom/enumeration/AssociationKey.java 2009-03-15 00:50:41 UTC (rev 9657) @@ -97,6 +97,8 @@ public static final AssociationKey<String> SUBSTITUTIONCLASS_KEY = new AssociationKey<String>(); + public static final AssociationKey<Integer> SKILL_POOL = new AssociationKey<Integer>(); + private static CaseInsensitiveMap<AssociationKey<?>> map = null; private AssociationKey() Modified: Trunk/pcgen/code/src/java/pcgen/core/PCClass.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/PCClass.java 2009-03-15 00:33:43 UTC (rev 9656) +++ Trunk/pcgen/code/src/java/pcgen/core/PCClass.java 2009-03-15 00:50:41 UTC (rev 9657) @@ -133,13 +133,6 @@ // PCLevelInfo /* - * ALLCLASSLEVELS skillPool is part each PCClassLevel and what that level - * grants to each PlayerCharacter (added by the PCClassLevel Factory, not - * by a tag) - */ - private int skillPool = 0; - - /* * TYPESAFETY This is definitely something that needs to NOT be a String, * but it gets VERY complicated to do that, since the keys are widely used * in the variable processor. @@ -2114,24 +2107,6 @@ } /* - * PCCLASSLEVELONLY This is only part of the level, as the skill pool is - * calculated based on other factors, it is not a Tag - */ - public final int skillPool() - { - return skillPool; - } - - /* - * PCCLASSLEVELONLY This is only part of the level, as the skill pool is - * calculated based on other factors, it is not a Tag - */ - public void setSkillPool(final int i) - { - skillPool = i; - } - - /* * REFACTOR TO DELETEMETHOD I would really like to get rid of this, since it * it used as a "funky spells" test - which should be more explicit than * implicit in zero cast spells. @@ -2704,7 +2679,9 @@ } } - skillPool = skillPool() + spMod; + Integer currentPool = aPC.getAssoc(this, AssociationKey.SKILL_POOL); + int newSkillPool = spMod + (currentPool == null ? 0 : currentPool); + aPC.setAssoc(this, AssociationKey.SKILL_POOL, newSkillPool); aPC.setSkillPoints(spMod + aPC.getSkillPoints()); @@ -3093,7 +3070,8 @@ SkillRankControl.setZeroRanks(this, aPC, skill); } - spMod = skillPool(); + Integer currentPool = aPC.getAssoc(this, AssociationKey.SKILL_POOL); + spMod = currentPool == null ? 0 : currentPool; } if (!isMonster() && (total > aPC.getTotalLevels())) @@ -3147,7 +3125,9 @@ else { aPC.setSkillPoints(aPC.getSkillPoints() - spMod); - skillPool = skillPool() - spMod; + Integer currentPool = aPC.getAssoc(this, AssociationKey.SKILL_POOL); + int newSkillPool = (currentPool == null ? 0 : currentPool) - spMod; + aPC.setAssoc(this, AssociationKey.SKILL_POOL, newSkillPool); } if (getLevel() == 0) Modified: Trunk/pcgen/code/src/java/pcgen/core/PlayerCharacter.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/PlayerCharacter.java 2009-03-15 00:33:43 UTC (rev 9656) +++ Trunk/pcgen/code/src/java/pcgen/core/PlayerCharacter.java 2009-03-15 00:50:41 UTC (rev 9657) @@ -6466,8 +6466,7 @@ final int cLevels = pcClass.getLevel(); - // aClass.setLevel(0); - pcClass.setSkillPool(0); + setAssoc(pcClass, AssociationKey.SKILL_POOL, 0); int cMod = 0; @@ -6478,7 +6477,7 @@ ++totalLevels); } - pcClass.setSkillPool(cMod); + setAssoc(pcClass, AssociationKey.SKILL_POOL, cMod); } } } @@ -8259,7 +8258,7 @@ pi.setSkillPointsRemaining(pi .getSkillPointsRemaining() + newSkillPointsGained - formerGained); - pcClass.setSkillPool(pcClass.getSkillPool(this) + setAssoc(pcClass, AssociationKey.SKILL_POOL, pcClass.getSkillPool(this) + newSkillPointsGained - formerGained); setSkillPoints(getSkillPoints() + newSkillPointsGained - formerGained); @@ -10009,7 +10008,7 @@ .getKeyName(), cl.getKeyName()); } - bClass.setSkillPool(aClass.getSkillPool(this)); + setAssoc(bClass, AssociationKey.SKILL_POOL, aClass.getSkillPool(this)); } catch (NumberFormatException nfe) { Modified: Trunk/pcgen/code/src/java/pcgen/core/analysis/SkillRankControl.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/analysis/SkillRankControl.java 2009-03-15 00:33:43 UTC (rev 9656) +++ Trunk/pcgen/code/src/java/pcgen/core/analysis/SkillRankControl.java 2009-03-15 00:50:41 UTC (rev 9657) @@ -23,6 +23,7 @@ import pcgen.base.lang.StringUtil; import pcgen.base.util.NamedValue; +import pcgen.cdom.enumeration.AssociationKey; import pcgen.cdom.enumeration.AssociationListKey; import pcgen.cdom.enumeration.SkillCost; import pcgen.cdom.enumeration.StringKey; @@ -233,7 +234,8 @@ { if (aClass != null) { - aClass.setSkillPool(aClass.getSkillPool(aPC) + aPC.setAssoc(aClass, AssociationKey.SKILL_POOL, aClass + .getSkillPool(aPC) - (int) (i * rankMod)); } Modified: Trunk/pcgen/code/src/java/pcgen/core/kit/KitStat.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/kit/KitStat.java 2009-03-15 00:33:43 UTC (rev 9656) +++ Trunk/pcgen/code/src/java/pcgen/core/kit/KitStat.java 2009-03-15 00:50:41 UTC (rev 9657) @@ -34,7 +34,6 @@ import pcgen.base.lang.StringUtil; import pcgen.cdom.base.Constants; import pcgen.cdom.enumeration.AssociationKey; -import pcgen.cdom.enumeration.ObjectKey; import pcgen.core.Kit; import pcgen.core.PCClass; import pcgen.core.PCStat; @@ -129,7 +128,7 @@ aPC.setSkillPoints(0); for (PCClass pcClass : classes) { - pcClass.setSkillPool(0); + aPC.setAssoc(pcClass, AssociationKey.SKILL_POOL, 0); // We don't limit this to MOD_TO_SKILLS classes as they may manually include the INT bonus in the skills. if (aPC.getLevelInfoSize() > 0) { @@ -145,7 +144,9 @@ pcl.setSkillPointsGained(spMod); pcl.setSkillPointsRemaining(pcl .getSkillPointsGained()); - pcClass.setSkillPool(pcClass.skillPool() + spMod); + Integer currentPool = aPC.getAssoc(pcClass, AssociationKey.SKILL_POOL); + int newSkillPool = (currentPool == null ? 0 : currentPool) + spMod; + aPC.setAssoc(pcClass, AssociationKey.SKILL_POOL, newSkillPool); aPC.setSkillPoints(spMod + aPC.getSkillPoints()); } Modified: Trunk/pcgen/code/src/java/pcgen/gui/tabs/InfoSkills.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/gui/tabs/InfoSkills.java 2009-03-15 00:33:43 UTC (rev 9656) +++ Trunk/pcgen/code/src/java/pcgen/gui/tabs/InfoSkills.java 2009-03-15 00:50:41 UTC (rev 9657) @@ -1137,7 +1137,7 @@ final int i = skillPool - anInt; pcl.setSkillPointsRemaining(anInt); - aClass.setSkillPool(Math.max(0, aClass.getSkillPool(pc) - i)); + pc.setAssoc(aClass, AssociationKey.SKILL_POOL, Math.max(0, aClass.getSkillPool(pc) - i)); currentPC.setSkillPoints(Math .max(0, currentPC.getSkillPoints() - i)); } @@ -2149,7 +2149,7 @@ for (PCClass aClass : currentPC.getClassList()) { - aClass.setSkillPool(Math.max(0, y)); + currentPC.setAssoc(aClass, AssociationKey.SKILL_POOL, Math.max(0, y)); } PCLevelInfo pcl = getSelectedLevelInfo(currentPC); Modified: Trunk/pcgen/code/src/java/pcgen/io/PCGVer0Parser.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/io/PCGVer0Parser.java 2009-03-15 00:33:43 UTC (rev 9656) +++ Trunk/pcgen/code/src/java/pcgen/io/PCGVer0Parser.java 2009-03-15 00:50:41 UTC (rev 9657) @@ -639,7 +639,7 @@ if (aClass != null) { - aClass.setSkillPool(skillPool); + aPC.setAssoc(aClass, AssociationKey.SKILL_POOL, skillPool); } if (aTok.hasMoreTokens()) Modified: Trunk/pcgen/code/src/java/pcgen/io/PCGVer2Creator.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/io/PCGVer2Creator.java 2009-03-15 00:33:43 UTC (rev 9656) +++ Trunk/pcgen/code/src/java/pcgen/io/PCGVer2Creator.java 2009-03-15 00:50:41 UTC (rev 9657) @@ -694,7 +694,8 @@ buffer.append(classLevel); buffer.append('|'); buffer.append(TAG_SKILLPOOL).append(':'); - buffer.append(pcClass.skillPool()); + Integer currentPool = thePC.getAssoc(pcClass, AssociationKey.SKILL_POOL); + buffer.append(currentPool == null ? 0 : currentPool); // determine if this class can cast spells boolean isCaster = false; Modified: Trunk/pcgen/code/src/java/pcgen/io/PCGVer2Parser.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/io/PCGVer2Parser.java 2009-03-15 00:33:43 UTC (rev 9656) +++ Trunk/pcgen/code/src/java/pcgen/io/PCGVer2Parser.java 2009-03-15 00:50:41 UTC (rev 9657) @@ -2049,7 +2049,7 @@ if (skillPool > -1) { - aPCClass.setSkillPool(skillPool); + thePC.setAssoc(aPCClass, AssociationKey.SKILL_POOL, skillPool); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <th...@us...> - 2009-03-15 02:22:31
|
Revision: 9659 http://pcgen.svn.sourceforge.net/pcgen/?rev=9659&view=rev Author: thpr Date: 2009-03-15 01:37:09 +0000 (Sun, 15 Mar 2009) Log Message: ----------- [ 877582 ] Separate Meta data from implementation data in code Specifically eliminate the use of SELECTED_WEAPON_PROF_BONUS (related to CHOOSE:WEAPONPROF among other things) as a ListKey (which modifies the global object) and moves this data into an Association on the PlayerCharacter Modified Paths: -------------- Trunk/pcgen/code/src/java/pcgen/cdom/enumeration/AssociationListKey.java Trunk/pcgen/code/src/java/pcgen/cdom/enumeration/ListKey.java Trunk/pcgen/code/src/java/pcgen/core/PObject.java Trunk/pcgen/code/src/java/pcgen/core/PlayerCharacter.java Trunk/pcgen/code/src/java/pcgen/core/chooser/SimpleWeaponProfChoiceManager.java Trunk/pcgen/code/src/java/pcgen/core/kit/KitProf.java Trunk/pcgen/code/src/java/pcgen/io/PCGVer0Parser.java Trunk/pcgen/code/src/java/pcgen/io/PCGVer2Creator.java Trunk/pcgen/code/src/java/pcgen/io/PCGVer2Parser.java Modified: Trunk/pcgen/code/src/java/pcgen/cdom/enumeration/AssociationListKey.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/cdom/enumeration/AssociationListKey.java 2009-03-15 01:21:16 UTC (rev 9658) +++ Trunk/pcgen/code/src/java/pcgen/cdom/enumeration/AssociationListKey.java 2009-03-15 01:37:09 UTC (rev 9659) @@ -107,6 +107,8 @@ public static final AssociationListKey<String> TEMPLATE_FEAT = new AssociationListKey<String>(); + public static final AssociationListKey<String> SELECTED_WEAPON_PROF_BONUS = new AssociationListKey<String>(); + private static CaseInsensitiveMap<AssociationListKey<?>> map = null; private AssociationListKey() Modified: Trunk/pcgen/code/src/java/pcgen/cdom/enumeration/ListKey.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/cdom/enumeration/ListKey.java 2009-03-15 01:21:16 UTC (rev 9658) +++ Trunk/pcgen/code/src/java/pcgen/cdom/enumeration/ListKey.java 2009-03-15 01:37:09 UTC (rev 9659) @@ -155,8 +155,6 @@ public static final ListKey<String> SAVE = new ListKey<String>(); /** SECTION 15 - a ListKey */ public static final ListKey<String> SECTION_15 = new ListKey<String>(); - /** SELECTED_WEAPON_PROF_BONUS - a ListKey */ - public static final ListKey<String> SELECTED_WEAPON_PROF_BONUS = new ListKey<String>(); /** SPECIAL_ABILITY - a ListKey */ public static final ListKey<SpecialAbility> SPECIAL_ABILITY = new ListKey<SpecialAbility>(); /** TEMP_BONUS - a ListKey */ Modified: Trunk/pcgen/code/src/java/pcgen/core/PObject.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/PObject.java 2009-03-15 01:21:16 UTC (rev 9658) +++ Trunk/pcgen/code/src/java/pcgen/core/PObject.java 2009-03-15 01:37:09 UTC (rev 9659) @@ -51,7 +51,6 @@ import pcgen.cdom.inst.PCClassLevel; import pcgen.cdom.list.ClassSpellList; import pcgen.cdom.list.DomainSpellList; -import pcgen.core.analysis.SpecialAbilityResolution; import pcgen.core.bonus.BonusObj; import pcgen.core.bonus.BonusUtilities; import pcgen.core.chooser.ChooserUtilities; @@ -104,15 +103,6 @@ } /** - * Add the selected wepaon prof bonus to the character list - * @param entry - */ - public final void addSelectedWeaponProfBonus(final String entry) - { - addToListFor(ListKey.SELECTED_WEAPON_PROF_BONUS, entry); - } - - /** * if a class implements the Cloneable interface then it should have a * public" 'clone ()' method It should be declared to throw * CloneNotSupportedException', but subclasses do not need the "throws" @@ -568,15 +558,6 @@ } /** - * Clear the selected weapon proficiency bonuses - * - */ - public void clearSelectedWeaponProfBonus() - { - removeListFor(ListKey.SELECTED_WEAPON_PROF_BONUS); - } - - /** * Get the list of bonuses for this object * @param as TODO * @return the list of bonuses for this object Modified: Trunk/pcgen/code/src/java/pcgen/core/PlayerCharacter.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/PlayerCharacter.java 2009-03-15 01:21:16 UTC (rev 9658) +++ Trunk/pcgen/code/src/java/pcgen/core/PlayerCharacter.java 2009-03-15 01:37:09 UTC (rev 9659) @@ -4034,18 +4034,22 @@ // Try all possible CDOMObjects for (CDOMObject pobj : getCDOMObjectList()) { - Set<String> profKeyList = - new TreeSet<String>(pobj - .getSafeListFor(ListKey.SELECTED_WEAPON_PROF_BONUS)); - for (String profKey : profKeyList) + List<String> profKeys = getAssocList(pobj, + AssociationListKey.SELECTED_WEAPON_PROF_BONUS); + if (profKeys != null) { - WeaponProf prof = - Globals.getContext().ref - .silentlyGetConstructedCDOMObject(WeaponProf.class, - profKey); - if (prof != null) + Set<String> profKeyList = new TreeSet<String>(); + profKeyList.addAll(profKeys); + for (String profKey : profKeyList) { - ret.put(prof.getKeyName(), prof); + WeaponProf prof = + Globals.getContext().ref + .silentlyGetConstructedCDOMObject(WeaponProf.class, + profKey); + if (prof != null) + { + ret.put(prof.getKeyName(), prof); + } } } //Natural Weapon Proficiencies @@ -12158,7 +12162,8 @@ if (anAbility != null) { // TheForken 20050124 adds bonus to feat - anAbility.addSelectedWeaponProfBonus(aString); + addAssoc(anAbility, + AssociationListKey.SELECTED_WEAPON_PROF_BONUS, aString); } featKey = ""; @@ -16744,14 +16749,22 @@ // if (getRace() != null) { - addAutoProfsToList(getRace().getSafeListFor( - ListKey.SELECTED_WEAPON_PROF_BONUS), abilities); + List<String> profKeys = getAssocList(getRace(), + AssociationListKey.SELECTED_WEAPON_PROF_BONUS); + if (profKeys != null) + { + addAutoProfsToList(profKeys, abilities); + } } for (final PCClass aClass : getClassList()) { - addAutoProfsToList(aClass - .getSafeListFor(ListKey.SELECTED_WEAPON_PROF_BONUS), abilities); + List<String> profKeys = getAssocList(aClass, + AssociationListKey.SELECTED_WEAPON_PROF_BONUS); + if (profKeys != null) + { + addAutoProfsToList(profKeys, abilities); + } } if (!getTemplateList().isEmpty()) @@ -16787,10 +16800,12 @@ } } } - addAutoProfsToList(aTemplate - .getSafeListFor(ListKey.SELECTED_WEAPON_PROF_BONUS), - abilities); - + List<String> profKeys = getAssocList(aTemplate, + AssociationListKey.SELECTED_WEAPON_PROF_BONUS); + if (profKeys != null) + { + addAutoProfsToList(profKeys, abilities); + } } } @@ -16861,10 +16876,12 @@ } } - addAutoProfsToList(aDomain - .getSafeListFor(ListKey.SELECTED_WEAPON_PROF_BONUS), - abilities); - + List<String> profKeys = getAssocList(aDomain, + AssociationListKey.SELECTED_WEAPON_PROF_BONUS); + if (profKeys != null) + { + addAutoProfsToList(profKeys, abilities); + } } } } Modified: Trunk/pcgen/code/src/java/pcgen/core/chooser/SimpleWeaponProfChoiceManager.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/chooser/SimpleWeaponProfChoiceManager.java 2009-03-15 01:21:16 UTC (rev 9658) +++ Trunk/pcgen/code/src/java/pcgen/core/chooser/SimpleWeaponProfChoiceManager.java 2009-03-15 01:37:09 UTC (rev 9659) @@ -29,6 +29,7 @@ import java.util.StringTokenizer; import pcgen.cdom.base.CDOMReference; +import pcgen.cdom.enumeration.AssociationListKey; import pcgen.cdom.enumeration.ListKey; import pcgen.cdom.enumeration.ObjectKey; import pcgen.cdom.reference.CDOMSingleRef; @@ -130,7 +131,11 @@ { weaponToProfMap.clear(); - selectedList.addAll(pobject.getSafeListFor(ListKey.SELECTED_WEAPON_PROF_BONUS)); + List<String> list = aPc.getAssocList(pobject, AssociationListKey.SELECTED_WEAPON_PROF_BONUS); + if (list != null) + { + selectedList.addAll(list); + } for ( String raw : getChoiceList()) { @@ -406,7 +411,7 @@ final PlayerCharacter aPC, final List<String> selected) { - pobject.clearSelectedWeaponProfBonus(); + aPC.removeAllAssocs(pobject, AssociationListKey.SELECTED_WEAPON_PROF_BONUS); aPC.setAutomaticAbilitiesStable(null, false); // aPC.setAutomaticFeatsStable(false); @@ -426,7 +431,9 @@ if (featOrProf.startsWith("WEAPONPROF")) { - pobject.addSelectedWeaponProfBonus(aChoice); + aPC.addAssoc(pobject, + AssociationListKey.SELECTED_WEAPON_PROF_BONUS, + aChoice); } // Modified: Trunk/pcgen/code/src/java/pcgen/core/kit/KitProf.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/kit/KitProf.java 2009-03-15 01:21:16 UTC (rev 9658) +++ Trunk/pcgen/code/src/java/pcgen/core/kit/KitProf.java 2009-03-15 01:37:09 UTC (rev 9659) @@ -29,7 +29,7 @@ import pcgen.base.lang.StringUtil; import pcgen.cdom.base.CDOMReference; -import pcgen.cdom.enumeration.ListKey; +import pcgen.cdom.enumeration.AssociationListKey; import pcgen.cdom.reference.CDOMSingleRef; import pcgen.core.Globals; import pcgen.core.Kit; @@ -99,8 +99,6 @@ thePObject = null; weaponProfs = null; - ListKey<String> weaponProfKey = ListKey.SELECTED_WEAPON_PROF_BONUS; - Collection<CDOMReference<WeaponProf>> wpBonus = null; if (isRacial()) { @@ -112,7 +110,8 @@ return false; } - if (pcRace.getSafeSizeOfListFor(weaponProfKey) != 0) + if (aPC.getAssocCount(pcRace, + AssociationListKey.SELECTED_WEAPON_PROF_BONUS) != 0) { warnings .add("PROF: Race has already selected bonus weapon proficiency"); @@ -144,7 +143,8 @@ } } thePObject = pcClass; - if (pcClass.getSafeSizeOfListFor(weaponProfKey) != 0) + if (aPC.getAssocCount(pcClass, + AssociationListKey.SELECTED_WEAPON_PROF_BONUS) != 0) { warnings .add("PROF: Class has already selected bonus weapon proficiency"); @@ -249,7 +249,8 @@ { for (WeaponProf prof : weaponProfs) { - thePObject.addSelectedWeaponProfBonus(prof.getKeyName()); + aPC.addAssoc(thePObject, + AssociationListKey.SELECTED_WEAPON_PROF_BONUS, prof.getKeyName()); } } Modified: Trunk/pcgen/code/src/java/pcgen/io/PCGVer0Parser.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/io/PCGVer0Parser.java 2009-03-15 01:21:16 UTC (rev 9658) +++ Trunk/pcgen/code/src/java/pcgen/io/PCGVer0Parser.java 2009-03-15 01:37:09 UTC (rev 9659) @@ -2293,92 +2293,50 @@ // { // aPC.addWeaponProf(aTok.nextToken()); // } - int iState = 0; final StringTokenizer aTok = new StringTokenizer(line, ":", false); - Race aRace = null; - PCClass aClass = null; - Domain aDomain = null; - Ability aFeat = null; final List<String> myProfs = new ArrayList<String>(); while (aTok.hasMoreTokens()) { String aString = aTok.nextToken(); + PObject target = null; if (aString.startsWith("RACE=")) { - iState = 1; - aRace = aPC.getRace(); + target = aPC.getRace(); continue; } else if (aString.startsWith("CLASS=")) { - iState = 2; aString = aString.substring(6); - aClass = aPC.getClassKeyed(aString); + target = aPC.getClassKeyed(aString); continue; } else if (aString.startsWith("DOMAIN=")) { - iState = 3; aString = aString.substring(7); - aDomain = aPC.getCharacterDomainKeyed(aString); + target = aPC.getCharacterDomainKeyed(aString); continue; } else if (aString.startsWith("FEAT=")) { - iState = 4; aString = aString.substring(5); - aFeat = aPC.getFeatNamed(aString); + target = aPC.getFeatNamed(aString); continue; } - - switch (iState) + else { - case 1: + myProfs.add(aString); + } - if (aRace != null) - { - aRace.addSelectedWeaponProfBonus(aString); - } - - break; - - case 2: - - if (aClass != null) - { - aClass.addSelectedWeaponProfBonus(aString); - } - - break; - - case 3: - - if (aDomain != null) - { - aDomain.addSelectedWeaponProfBonus(aString); - } - - break; - - case 4: - - if (aFeat != null) - { - aFeat.addSelectedWeaponProfBonus(aString); - } - - break; - - default: - myProfs.add(aString); - - break; + if (target != null) + { + aPC.addAssoc(target, + AssociationListKey.SELECTED_WEAPON_PROF_BONUS, aString); } } Modified: Trunk/pcgen/code/src/java/pcgen/io/PCGVer2Creator.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/io/PCGVer2Creator.java 2009-03-15 01:21:16 UTC (rev 9658) +++ Trunk/pcgen/code/src/java/pcgen/io/PCGVer2Creator.java 2009-03-15 01:37:09 UTC (rev 9659) @@ -2353,15 +2353,15 @@ } } - private static void appendWeaponProficiencyLines(StringBuffer buffer, + private void appendWeaponProficiencyLines(StringBuffer buffer, PObject source) { if (source == null) { return; } - final List<String> profs = - source.getListFor(ListKey.SELECTED_WEAPON_PROF_BONUS); + final List<String> profs = thePC.getAssocList(source, + AssociationListKey.SELECTED_WEAPON_PROF_BONUS); if (profs == null || profs.isEmpty()) { return; Modified: Trunk/pcgen/code/src/java/pcgen/io/PCGVer2Parser.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/io/PCGVer2Parser.java 2009-03-15 01:21:16 UTC (rev 9658) +++ Trunk/pcgen/code/src/java/pcgen/io/PCGVer2Parser.java 2009-03-15 01:37:09 UTC (rev 9659) @@ -4664,8 +4664,9 @@ { for (PCGElement child : element.getChildren()) { - source.addSelectedWeaponProfBonus(updateProficiencyName(child - .getText(), true)); + thePC.addAssoc(source, + AssociationListKey.SELECTED_WEAPON_PROF_BONUS, + updateProficiencyName(child.getText(), true)); } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <th...@us...> - 2009-03-15 19:55:57
|
Revision: 9663 http://pcgen.svn.sourceforge.net/pcgen/?rev=9663&view=rev Author: thpr Date: 2009-03-15 19:55:49 +0000 (Sun, 15 Mar 2009) Log Message: ----------- [ 877582 ] Separate Meta data from implementation data in code Specifically, pcgen.gui.AddSpecialAbility has a new moethod of storing Special Abilities that does not use ListKey.SAVE and ListKey.SPECIAL_ABILITY is not stored in PCClass Note that ListKey.SAVE was effectively useless as it was redundant to ListKey.SPECIAL_ABILITY. Therefore any useless information (otherwise left in a PCC file unprocessed) is now discarded with a Logging.debugPrint Modified Paths: -------------- Trunk/pcgen/code/src/java/pcgen/cdom/enumeration/AssociationListKey.java Trunk/pcgen/code/src/java/pcgen/cdom/enumeration/ListKey.java Trunk/pcgen/code/src/java/pcgen/core/PObject.java Trunk/pcgen/code/src/java/pcgen/gui/AddSpecialAbility.java Trunk/pcgen/code/src/java/pcgen/gui/tabs/InfoSpecialAbilities.java Trunk/pcgen/code/src/java/pcgen/io/PCGVer0Parser.java Trunk/pcgen/code/src/java/pcgen/io/PCGVer2Creator.java Trunk/pcgen/code/src/java/pcgen/io/PCGVer2Parser.java Modified: Trunk/pcgen/code/src/java/pcgen/cdom/enumeration/AssociationListKey.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/cdom/enumeration/AssociationListKey.java 2009-03-15 18:52:40 UTC (rev 9662) +++ Trunk/pcgen/code/src/java/pcgen/cdom/enumeration/AssociationListKey.java 2009-03-15 19:55:49 UTC (rev 9663) @@ -40,6 +40,7 @@ import pcgen.core.PCClass; import pcgen.core.ShieldProf; import pcgen.core.Skill; +import pcgen.core.SpecialAbility; import pcgen.core.SpellProhibitor; import pcgen.core.WeaponProf; import pcgen.core.bonus.BonusObj; @@ -109,6 +110,8 @@ public static final AssociationListKey<String> SELECTED_WEAPON_PROF_BONUS = new AssociationListKey<String>(); + public static final AssociationListKey<SpecialAbility> SPECIAL_ABILITY = new AssociationListKey<SpecialAbility>(); + private static CaseInsensitiveMap<AssociationListKey<?>> map = null; private AssociationListKey() Modified: Trunk/pcgen/code/src/java/pcgen/cdom/enumeration/ListKey.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/cdom/enumeration/ListKey.java 2009-03-15 18:52:40 UTC (rev 9662) +++ Trunk/pcgen/code/src/java/pcgen/cdom/enumeration/ListKey.java 2009-03-15 19:55:49 UTC (rev 9663) @@ -151,12 +151,8 @@ public static final ListKey<Pantheon> PANTHEON = new ListKey<Pantheon>(); /** RACE_PANTHEON - a ListKey */ public static final ListKey<String> RACEPANTHEON = new ListKey<String>(); - /** SAVE - a ListKey */ - public static final ListKey<String> SAVE = new ListKey<String>(); /** SECTION 15 - a ListKey */ public static final ListKey<String> SECTION_15 = new ListKey<String>(); - /** SPECIAL_ABILITY - a ListKey */ - public static final ListKey<SpecialAbility> SPECIAL_ABILITY = new ListKey<SpecialAbility>(); /** TEMP_BONUS - a ListKey */ public static final ListKey<BonusObj> TEMP_BONUS = new ListKey<BonusObj>(); // /** Key for a list of weapon proficiencies */ Modified: Trunk/pcgen/code/src/java/pcgen/core/PObject.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/PObject.java 2009-03-15 18:52:40 UTC (rev 9662) +++ Trunk/pcgen/code/src/java/pcgen/core/PObject.java 2009-03-15 19:55:49 UTC (rev 9663) @@ -94,15 +94,6 @@ * ************/ /** - * Add to the 'save' for the character list - * @param aString - */ - public final void addSave(final String aString) - { - addToListFor(ListKey.SAVE, aString); - } - - /** * if a class implements the Cloneable interface then it should have a * public" 'clone ()' method It should be declared to throw * CloneNotSupportedException', but subclasses do not need the "throws" @@ -348,18 +339,6 @@ } /** - * Remove the save - * @param bonusString - */ - public final void removeSave(final String bonusString) - { - boolean b = removeFromListFor(ListKey.SAVE, bonusString); - if (!b) { - Logging.errorPrint("removeSave: Could not find: " + bonusString + " in saveList."); - } - } - - /** * Set the campaign source * @param arg */ @@ -442,8 +421,14 @@ public List<SpecialAbility> addSpecialAbilitiesToList(final List<SpecialAbility> aList, final PlayerCharacter aPC) { - for ( SpecialAbility sa : getSafeListFor(ListKey.SPECIAL_ABILITY) ) + List<SpecialAbility> salist = aPC.getAssocList(this, + AssociationListKey.SPECIAL_ABILITY); + if (salist == null) { + return aList; + } + for ( SpecialAbility sa : salist ) + { if (sa.pcQualifiesFor(aPC)) { final String key = sa.getKeyName(); Modified: Trunk/pcgen/code/src/java/pcgen/gui/AddSpecialAbility.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/gui/AddSpecialAbility.java 2009-03-15 18:52:40 UTC (rev 9662) +++ Trunk/pcgen/code/src/java/pcgen/gui/AddSpecialAbility.java 2009-03-15 19:55:49 UTC (rev 9663) @@ -25,7 +25,30 @@ **/ package pcgen.gui; -import pcgen.cdom.enumeration.ListKey; +import java.awt.BorderLayout; +import java.awt.Container; +import java.awt.Dimension; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.HeadlessException; +import java.awt.Insets; +import java.awt.Toolkit; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; + +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTextField; +import javax.swing.ListSelectionModel; +import javax.swing.WindowConstants; +import javax.swing.table.AbstractTableModel; + +import pcgen.cdom.enumeration.AssociationListKey; import pcgen.core.Globals; import pcgen.core.PCClass; import pcgen.core.PlayerCharacter; @@ -38,14 +61,6 @@ import pcgen.util.Logging; import pcgen.util.PropertyFactory; -import javax.swing.*; -import javax.swing.table.AbstractTableModel; -import java.awt.*; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; - /** * Title: AddSpecialAbility.java * Description: New GUI implementation for panel to add special abilities @@ -155,8 +170,7 @@ PCClass aClass = aPC.getClassList().get(0); String aString = (selectedValue).trim(); SpecialAbility sa = new SpecialAbility(aString); - aClass.addToListFor(ListKey.SPECIAL_ABILITY, sa); - aClass.addSave(aString); + aPC.addAssoc(aClass, AssociationListKey.SPECIAL_ABILITY, sa); if (owner != null) { Modified: Trunk/pcgen/code/src/java/pcgen/gui/tabs/InfoSpecialAbilities.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/gui/tabs/InfoSpecialAbilities.java 2009-03-15 18:52:40 UTC (rev 9662) +++ Trunk/pcgen/code/src/java/pcgen/gui/tabs/InfoSpecialAbilities.java 2009-03-15 19:55:49 UTC (rev 9663) @@ -52,7 +52,7 @@ import pcgen.base.lang.StringUtil; import pcgen.cdom.base.CDOMReference; import pcgen.cdom.base.Constants; -import pcgen.cdom.enumeration.ListKey; +import pcgen.cdom.enumeration.AssociationListKey; import pcgen.cdom.enumeration.StringKey; import pcgen.cdom.reference.ReferenceUtilities; import pcgen.core.CharacterDomain; @@ -515,12 +515,15 @@ for (PCClass aClass : pc.getClassList()) { - - for (SpecialAbility sa : aClass - .getSafeListFor(ListKey.SPECIAL_ABILITY)) + List<SpecialAbility> salist = pc.getAssocList(aClass, + AssociationListKey.SPECIAL_ABILITY); + if (salist != null) { - aList.add(sa.getKeyName()); - cList.add(sa); + for (SpecialAbility sa : salist) + { + aList.add(sa.getKeyName()); + cList.add(sa); + } } } @@ -551,8 +554,7 @@ continue; } - aClass.removeSave(sa.getKeyName()); - aClass.removeFromListFor(ListKey.SPECIAL_ABILITY, sa); + pc.removeAssoc(aClass, AssociationListKey.SPECIAL_ABILITY, sa); } // pc = null; // forces everything to re-display it's broken Modified: Trunk/pcgen/code/src/java/pcgen/io/PCGVer0Parser.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/io/PCGVer0Parser.java 2009-03-15 18:52:40 UTC (rev 9662) +++ Trunk/pcgen/code/src/java/pcgen/io/PCGVer0Parser.java 2009-03-15 19:55:49 UTC (rev 9663) @@ -414,8 +414,6 @@ String token; StringTokenizer aTok; - ListKey<String> saveKey = ListKey.SAVE; - for (int i = 0; i < aPC.getClassList().size(); i++) { line = lines[current++]; @@ -502,7 +500,9 @@ } } - target.addToListFor(ListKey.SPECIAL_ABILITY, sa); + aPC.addAssoc(target, + AssociationListKey.SPECIAL_ABILITY, + sa); } } } @@ -521,14 +521,10 @@ src = ""; } - //sa.setSource(src); - aClass.addToListFor(ListKey.SPECIAL_ABILITY, sa); + aPC.addAssoc(aClass, + AssociationListKey.SPECIAL_ABILITY, + sa); } - - if (!aClass.containsInList(saveKey, token)) - { - aClass.addSave(token); - } } } } @@ -1249,7 +1245,7 @@ } else { - anAbility.addSave(aString); + Logging.debugPrint("Ignoring SAVE:" + aString); } } } Modified: Trunk/pcgen/code/src/java/pcgen/io/PCGVer2Creator.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/io/PCGVer2Creator.java 2009-03-15 18:52:40 UTC (rev 9662) +++ Trunk/pcgen/code/src/java/pcgen/io/PCGVer2Creator.java 2009-03-15 19:55:49 UTC (rev 9663) @@ -48,11 +48,9 @@ import pcgen.cdom.base.PersistentTransitionChoice; import pcgen.cdom.enumeration.AssociationKey; import pcgen.cdom.enumeration.AssociationListKey; -import pcgen.cdom.enumeration.IntegerKey; import pcgen.cdom.enumeration.ListKey; import pcgen.cdom.enumeration.ObjectKey; import pcgen.cdom.enumeration.StringKey; -import pcgen.cdom.inst.PCClassLevel; import pcgen.cdom.list.ClassSpellList; import pcgen.core.Ability; import pcgen.core.AbilityCategory; @@ -751,38 +749,16 @@ String key; key = pcClass.getKeyName() + TAG_SAVE + '0'; - for (String save : pcClass.getSafeListFor(ListKey.SAVE)) + List<SpecialAbility> salist = thePC.getAssocList(pcClass, + AssociationListKey.SPECIAL_ABILITY); + if (salist != null) { - boolean found = false; - for (SpecialAbility sa : pcClass - .getListFor(ListKey.SPECIAL_ABILITY)) + for (SpecialAbility sa : salist) { - if (sa.getKeyName().equalsIgnoreCase(save)) - { - specials.put(pcClass.getKeyName() + TAG_SA + 0, sa - .getKeyName()); - break; - } + specials.put(pcClass.getKeyName() + TAG_SA + 0, sa + .getKeyName()); + break; } - for (PCClassLevel pcl : pcClass.getClassLevelCollection()) - { - Integer level = pcl.get(IntegerKey.LEVEL); - for (SpecialAbility sa : pcl - .getListFor(ListKey.SPECIAL_ABILITY)) - { - if (sa.getKeyName().equalsIgnoreCase(save)) - { - specials.put(pcClass.getKeyName() + TAG_SA + level, - sa.getKeyName()); - break; - } - } - } - - if (!found) - { - specials.put(key, save); - } } List<BonusObj> list = @@ -1334,13 +1310,6 @@ buffer.append(TAG_TYPE).append(TAG_END); buffer.append(EntityEncoder.encode(ability.getType())); - for (final String save : ability.getSafeListFor(ListKey.SAVE)) - { - buffer.append('|'); - buffer.append(TAG_SAVE).append(':'); - buffer.append(EntityEncoder.encode(save)); - } - List<BonusObj> list = thePC.getAssocList(ability, AssociationListKey.BONUS); if (list != null) Modified: Trunk/pcgen/code/src/java/pcgen/io/PCGVer2Parser.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/io/PCGVer2Parser.java 2009-03-15 18:52:40 UTC (rev 9662) +++ Trunk/pcgen/code/src/java/pcgen/io/PCGVer2Parser.java 2009-03-15 19:55:49 UTC (rev 9663) @@ -1724,15 +1724,10 @@ if (!thePC.hasSpecialAbility(specialAbilityName)) { - target.addToListFor(ListKey.SPECIAL_ABILITY, - specialAbility); + thePC.addAssoc(target, + AssociationListKey.SPECIAL_ABILITY, + specialAbility); } - - if (!aPCClass.containsInList(ListKey.SAVE, - specialAbilityName)) - { - aPCClass.addSave(specialAbilityName); - } } } else if (tag.equals(TAG_LEVELABILITY)) @@ -2478,7 +2473,7 @@ } else { - ability.addSave(saveKey); + Logging.debugPrint("Ignoring SAVE:" + saveKey); } } } @@ -2755,7 +2750,7 @@ } else { - aFeat.addSave(saveKey); + Logging.debugPrint("Ignoring SAVE:" + saveKey); } } else if (tag.equals(TAG_LEVELABILITY)) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |