From: <aki...@us...> - 2008-11-07 09:43:55
|
Revision: 5674 http://gridarta.svn.sourceforge.net/gridarta/?rev=5674&view=rev Author: akirschbaum Date: 2008-11-07 09:43:51 +0000 (Fri, 07 Nov 2008) Log Message: ----------- Remove redundant type parameters. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/daimonin/src/daieditor/CMainControl.java trunk/src/app/net/sf/gridarta/AbstractMainControl.java trunk/src/app/net/sf/gridarta/gameobject/GameObject.java trunk/src/app/net/sf/gridarta/gameobject/anim/AnimationObjects.java trunk/src/app/net/sf/gridarta/gameobject/anim/DefaultAnimationObjects.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-11-07 09:32:09 UTC (rev 5673) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-11-07 09:43:51 UTC (rev 5674) @@ -56,7 +56,6 @@ import net.sf.gridarta.gameobject.ArchetypeFactory; import net.sf.gridarta.gameobject.Collectable; import net.sf.gridarta.gameobject.GameObjectFactory; -import net.sf.gridarta.gameobject.anim.AnimationObject; import net.sf.gridarta.gameobject.anim.AnimationObjects; import net.sf.gridarta.gameobject.anim.DefaultAnimationObjects; import net.sf.gridarta.gameobject.face.DefaultFaceObjects; @@ -143,7 +142,7 @@ * @throws RuntimeException If the controller cannot be initialized. */ public CMainControl() { - super("cfeditor", new DefaultAnimationObjects<AnimationObject>(IGUIConstants.ANIMTREE_FILE), new DefaultFaceObjects(IGUIConstants.PNG_FILE, IGUIConstants.FACETREE_FILE, Pattern.compile("^.*\t\\.?(.*)"), "\\%1$05d\t./arch%2$s"), false, ConfigFileUtils.getHomeFile("thumbnails"), null, "CrossfireEditor.jar", pythonFileFilter, ".py", "Python", Archetype.TYPE_SPELL, null, Archetype.TYPE_EVENT_CONNECTOR, false, 0, new int[] { Archetype.TYPE_LOCKED_DOOR, Archetype.TYPE_SPECIAL_KEY, Archetype.TYPE_TRIGGER_ALTAR, Archetype.TYPE_DETECTOR, Archetype.TYPE_TRIGGER_MARKER, Archetype.TYPE_MARKER, Archetype.TYPE_INVENTORY_CHECKER, Archetype.TYPE_CONTAINER, }, PREFS_VALIDATOR_AUTO_DEFAULT, IGUIConstants.SCRIPTS_DIR); + super("cfeditor", new DefaultAnimationObjects(IGUIConstants.ANIMTREE_FILE), new DefaultFaceObjects(IGUIConstants.PNG_FILE, IGUIConstants.FACETREE_FILE, Pattern.compile("^.*\t\\.?(.*)"), "\\%1$05d\t./arch%2$s"), false, ConfigFileUtils.getHomeFile("thumbnails"), null, "CrossfireEditor.jar", pythonFileFilter, ".py", "Python", Archetype.TYPE_SPELL, null, Archetype.TYPE_EVENT_CONNECTOR, false, 0, new int[] { Archetype.TYPE_LOCKED_DOOR, Archetype.TYPE_SPECIAL_KEY, Archetype.TYPE_TRIGGER_ALTAR, Archetype.TYPE_DETECTOR, Archetype.TYPE_TRIGGER_MARKER, Archetype.TYPE_MARKER, Archetype.TYPE_INVENTORY_CHECKER, Archetype.TYPE_CONTAINER, }, PREFS_VALIDATOR_AUTO_DEFAULT, IGUIConstants.SCRIPTS_DIR); } /** {@inheritDoc} */ @@ -263,7 +262,7 @@ /** {@inheritDoc} */ @Override - protected AbstractArchetypeParser<GameObject, MapArchObject, Archetype> newArchetypeParser(final GameObjectParser<GameObject, MapArchObject, Archetype> gameObjectParser, final ArchetypeChooserControl<GameObject, MapArchObject, Archetype, CMapViewBasic> archetypeChooserControl, final AnimationObjects<? extends AnimationObject> animationObjects, final net.sf.gridarta.gameobject.ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final GameObjectFactory<GameObject, MapArchObject, Archetype> gameObjectFactory) { + protected AbstractArchetypeParser<GameObject, MapArchObject, Archetype> newArchetypeParser(final GameObjectParser<GameObject, MapArchObject, Archetype> gameObjectParser, final ArchetypeChooserControl<GameObject, MapArchObject, Archetype, CMapViewBasic> archetypeChooserControl, final AnimationObjects animationObjects, final net.sf.gridarta.gameobject.ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final GameObjectFactory<GameObject, MapArchObject, Archetype> gameObjectFactory) { return new ArchetypeParser(gameObjectParser, archetypeChooserControl, animationObjects, archetypeSet, gameObjectFactory, smoothFaces); } @@ -307,7 +306,7 @@ /** {@inheritDoc} */ @Override - protected void init4(@NotNull final GameObjectParser<GameObject, MapArchObject, Archetype> gameObjectParser, @NotNull final AbstractArchetypeParser<GameObject, MapArchObject, Archetype> archetypeParser, @NotNull final EditTypes editTypes, @NotNull final FaceObjects faceObjects, @NotNull final AnimationObjects<? extends AnimationObject> animationObjects, @NotNull final MainView<GameObject, MapArchObject, Archetype, CMapViewBasic> mainView, @NotNull final GlobalSettings globalSettings, @NotNull final net.sf.gridarta.gameobject.ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet) { + protected void init4(@NotNull final GameObjectParser<GameObject, MapArchObject, Archetype> gameObjectParser, @NotNull final AbstractArchetypeParser<GameObject, MapArchObject, Archetype> archetypeParser, @NotNull final EditTypes editTypes, @NotNull final FaceObjects faceObjects, @NotNull final AnimationObjects animationObjects, @NotNull final MainView<GameObject, MapArchObject, Archetype, CMapViewBasic> mainView, @NotNull final GlobalSettings globalSettings, @NotNull final net.sf.gridarta.gameobject.ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet) { new ArchetypeSetLoader(globalSettings, gameObjectParser, globalSettings.getCollectedDirectory(), archetypeSet, archetypeParser, editTypes, faceObjects, animationObjects, this).loadArchetypes(mainView); } Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-11-07 09:32:09 UTC (rev 5673) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-11-07 09:43:51 UTC (rev 5674) @@ -57,7 +57,6 @@ import net.sf.gridarta.gameobject.ArchetypeFactory; import net.sf.gridarta.gameobject.Collectable; import net.sf.gridarta.gameobject.GameObjectFactory; -import net.sf.gridarta.gameobject.anim.AnimationObject; import net.sf.gridarta.gameobject.anim.AnimationObjects; import net.sf.gridarta.gameobject.anim.DefaultAnimationObjects; import net.sf.gridarta.gameobject.face.DefaultFaceObjects; @@ -176,7 +175,7 @@ * @throws RuntimeException If the controller cannot be initialized. */ public CMainControl() { - super("daieditor", new DefaultAnimationObjects<AnimationObject>(IGUIConstants.ANIMTREE_FILE), new DefaultFaceObjects(IGUIConstants.PNG_FILE, IGUIConstants.FACETREE_FILE, Pattern.compile("^(.*)"), "%2$s"), true, null, GUIUtils.getSysIcon(IGUIConstants.TILE_NORTH), "DaimoninEditor.jar", luaFileFilter, ".lua", "Lua", 0, IGUIConstants.SPELL_FILE, 0, true, -1, new int[] { Archetype.TYPE_LOCKED_DOOR, Archetype.TYPE_SPECIAL_KEY, Archetype.TYPE_ALTAR_TRIGGER, Archetype.TYPE_MARKER, Archetype.TYPE_INVENTORY_CHECKER, Archetype.TYPE_SPAWN_POINT, Archetype.TYPE_CONTAINER, }, PREFS_VALIDATOR_AUTO_DEFAULT, IGUIConstants.SCRIPTS_DIR); + super("daieditor", new DefaultAnimationObjects(IGUIConstants.ANIMTREE_FILE), new DefaultFaceObjects(IGUIConstants.PNG_FILE, IGUIConstants.FACETREE_FILE, Pattern.compile("^(.*)"), "%2$s"), true, null, GUIUtils.getSysIcon(IGUIConstants.TILE_NORTH), "DaimoninEditor.jar", luaFileFilter, ".lua", "Lua", 0, IGUIConstants.SPELL_FILE, 0, true, -1, new int[] { Archetype.TYPE_LOCKED_DOOR, Archetype.TYPE_SPECIAL_KEY, Archetype.TYPE_ALTAR_TRIGGER, Archetype.TYPE_MARKER, Archetype.TYPE_INVENTORY_CHECKER, Archetype.TYPE_SPAWN_POINT, Archetype.TYPE_CONTAINER, }, PREFS_VALIDATOR_AUTO_DEFAULT, IGUIConstants.SCRIPTS_DIR); } /** {@inheritDoc} */ @@ -294,7 +293,7 @@ /** {@inheritDoc} */ @Override - protected AbstractArchetypeParser<GameObject, MapArchObject, Archetype> newArchetypeParser(final GameObjectParser<GameObject, MapArchObject, Archetype> gameObjectParser, final ArchetypeChooserControl<GameObject, MapArchObject, Archetype, CMapViewBasic> archetypeChooserControl, final AnimationObjects<? extends AnimationObject> animationObjects, final net.sf.gridarta.gameobject.ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final GameObjectFactory<GameObject, MapArchObject, Archetype> gameObjectFactory) { + protected AbstractArchetypeParser<GameObject, MapArchObject, Archetype> newArchetypeParser(final GameObjectParser<GameObject, MapArchObject, Archetype> gameObjectParser, final ArchetypeChooserControl<GameObject, MapArchObject, Archetype, CMapViewBasic> archetypeChooserControl, final AnimationObjects animationObjects, final net.sf.gridarta.gameobject.ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final GameObjectFactory<GameObject, MapArchObject, Archetype> gameObjectFactory) { return new ArchetypeParser(archetypeChooserControl, animationObjects, archetypeSet, gameObjectFactory); } @@ -340,7 +339,7 @@ /** {@inheritDoc} */ @Override - protected void init4(@NotNull final GameObjectParser<GameObject, MapArchObject, Archetype> gameObjectParser, @NotNull final AbstractArchetypeParser<GameObject, MapArchObject, Archetype> archetypeParser, @NotNull final EditTypes editTypes, @NotNull final FaceObjects faceObjects, @NotNull final AnimationObjects<? extends AnimationObject> animationObjects, @NotNull final MainView<GameObject, MapArchObject, Archetype, CMapViewBasic> mainView, @NotNull final GlobalSettings globalSettings, @NotNull final net.sf.gridarta.gameobject.ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet) { + protected void init4(@NotNull final GameObjectParser<GameObject, MapArchObject, Archetype> gameObjectParser, @NotNull final AbstractArchetypeParser<GameObject, MapArchObject, Archetype> archetypeParser, @NotNull final EditTypes editTypes, @NotNull final FaceObjects faceObjects, @NotNull final AnimationObjects animationObjects, @NotNull final MainView<GameObject, MapArchObject, Archetype, CMapViewBasic> mainView, @NotNull final GlobalSettings globalSettings, @NotNull final net.sf.gridarta.gameobject.ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet) { MultiPositionData.init(globalSettings.getConfigurationDirectory()); new ArchetypeSetLoader(globalSettings, gameObjectParser, globalSettings.getCollectedDirectory(), archetypeSet, archetypeParser, editTypes, faceObjects, animationObjects, this).loadArchetypes(mainView); } Modified: trunk/src/app/net/sf/gridarta/AbstractMainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2008-11-07 09:32:09 UTC (rev 5673) +++ trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2008-11-07 09:43:51 UTC (rev 5674) @@ -328,7 +328,7 @@ * default * @param scriptsDir the plugin scripts directory */ - protected AbstractMainControl(@NotNull final String key, @NotNull final AnimationObjects<? extends AnimationObject> animationObjects, @NotNull final FaceObjects faceObjects, final boolean createDirectionPane, @Nullable final File mapImageCacheDir, @Nullable final ImageIcon compassIcon, @NotNull final String gridartaJarFilename, @NotNull final FileFilter scriptFileFilter, @NotNull final String scriptExtension, @NotNull final String scriptName, final int spellType, @Nullable final String spellFile, final int typeNoEventConnector, final boolean includeFaceText, final int undefinedSpellIndex, @NotNull final int[] lockedItemsTypeNumbers, final boolean autoValidatorDefault, @NotNull final String scriptsDir) { + protected AbstractMainControl(@NotNull final String key, @NotNull final AnimationObjects animationObjects, @NotNull final FaceObjects faceObjects, final boolean createDirectionPane, @Nullable final File mapImageCacheDir, @Nullable final ImageIcon compassIcon, @NotNull final String gridartaJarFilename, @NotNull final FileFilter scriptFileFilter, @NotNull final String scriptExtension, @NotNull final String scriptName, final int spellType, @Nullable final String spellFile, final int typeNoEventConnector, final boolean includeFaceText, final int undefinedSpellIndex, @NotNull final int[] lockedItemsTypeNumbers, final boolean autoValidatorDefault, @NotNull final String scriptsDir) { this.scriptExtension = scriptExtension; appPrefsModel = createAppPrefsModel(); final MapArchObjectFactory<A> mapArchObjectFactory = newMapArchObjectFactory(); @@ -559,7 +559,7 @@ @NotNull protected abstract GameObjectFactory<G, A, R> newGameObjectFactory(); - protected abstract AbstractArchetypeParser<G, A, R> newArchetypeParser(final GameObjectParser<G, A, R> gameObjectParser, final ArchetypeChooserControl<G, A, R, V> archetypeChooserControl, final AnimationObjects<? extends AnimationObject> animationObjects, final ArchetypeSet<G, A, R> archetypeSet, @NotNull final GameObjectFactory<G, A, R> gameObjectFactory); + protected abstract AbstractArchetypeParser<G, A, R> newArchetypeParser(final GameObjectParser<G, A, R> gameObjectParser, final ArchetypeChooserControl<G, A, R, V> archetypeChooserControl, final AnimationObjects animationObjects, final ArchetypeSet<G, A, R> archetypeSet, @NotNull final GameObjectFactory<G, A, R> gameObjectFactory); protected abstract void createActions(); @@ -569,7 +569,7 @@ @NotNull protected abstract MapActions init1(@NotNull final MapViewSettings mapViewSettings, @NotNull final MapArchObjectParserFactory<A> mapArchObjectParserFactory, @NotNull final MapArchObjectFactory<A> mapArchObjectFactory, @NotNull final GlobalSettings globalSettings, @NotNull final MapManager<G, A, R, V> mapManager, @NotNull final MapViewManager<G, A, R, V> mapViewManager, @NotNull final SelectedSquareView<G, A, R, V> selectedSquareView, @NotNull final GameObjectMatcher exitMatcher); - protected abstract void init4(@NotNull final GameObjectParser<G, A, R> gameObjectParser, @NotNull final AbstractArchetypeParser<G, A, R> archetypeParser, @NotNull final EditTypes editTypes, @NotNull final FaceObjects faceObjects, @NotNull final AnimationObjects<? extends AnimationObject> animationObjects, final MainView<G, A, R, V> mainView, @NotNull final GlobalSettings globalSettings, @NotNull final ArchetypeSet<G, A, R> archetypeSet); + protected abstract void init4(@NotNull final GameObjectParser<G, A, R> gameObjectParser, @NotNull final AbstractArchetypeParser<G, A, R> archetypeParser, @NotNull final EditTypes editTypes, @NotNull final FaceObjects faceObjects, @NotNull final AnimationObjects animationObjects, final MainView<G, A, R, V> mainView, @NotNull final GlobalSettings globalSettings, @NotNull final ArchetypeSet<G, A, R> archetypeSet); protected abstract void deleteLibraries(); Modified: trunk/src/app/net/sf/gridarta/gameobject/GameObject.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/GameObject.java 2008-11-07 09:32:09 UTC (rev 5673) +++ trunk/src/app/net/sf/gridarta/gameobject/GameObject.java 2008-11-07 09:43:51 UTC (rev 5674) @@ -68,7 +68,7 @@ private static ScriptArchEditor scriptArchEditor = null; @Nullable - private static AnimationObjects<? extends AnimationObject> animationObjects = null; + private static AnimationObjects animationObjects = null; /** * Face name, can be from animation or face. This is determined by taking @@ -226,7 +226,7 @@ * @param noFace the image icons for game objects having no face * @param scriptArchData the script arch data instance to use */ - public static void initialize(@Nullable final ArchetypeSet<?, ?, ?> archetypeSet, final ArchetypeTypeSet archetypeTypeSet, final GameObjectMatchers gameObjectMatchers, final ScriptArchEditor scriptArchEditor, @Nullable final AnimationObjects<? extends AnimationObject> animationObjects, @NotNull final ImageIcon noFace, @NotNull final ScriptArchData<?> scriptArchData) { + public static void initialize(@Nullable final ArchetypeSet<?, ?, ?> archetypeSet, final ArchetypeTypeSet archetypeTypeSet, final GameObjectMatchers gameObjectMatchers, final ScriptArchEditor scriptArchEditor, @Nullable final AnimationObjects animationObjects, @NotNull final ImageIcon noFace, @NotNull final ScriptArchData<?> scriptArchData) { GameObject.archetypeSet = archetypeSet; GameObject.archetypeTypeSet = archetypeTypeSet; GameObject.gameObjectMatchers = gameObjectMatchers; Modified: trunk/src/app/net/sf/gridarta/gameobject/anim/AnimationObjects.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/anim/AnimationObjects.java 2008-11-07 09:32:09 UTC (rev 5673) +++ trunk/src/app/net/sf/gridarta/gameobject/anim/AnimationObjects.java 2008-11-07 09:43:51 UTC (rev 5674) @@ -32,7 +32,7 @@ * AnimationObjects is a container for {@link AnimationObject}s. * @author <a href="mailto:ch...@ri...">Christian Hujer</a> */ -public interface AnimationObjects<E extends AnimationObject> extends Collectable, NamedObjects<E> { +public interface AnimationObjects extends Collectable, NamedObjects<AnimationObject> { /** * Add an animation object. Modified: trunk/src/app/net/sf/gridarta/gameobject/anim/DefaultAnimationObjects.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/anim/DefaultAnimationObjects.java 2008-11-07 09:32:09 UTC (rev 5673) +++ trunk/src/app/net/sf/gridarta/gameobject/anim/DefaultAnimationObjects.java 2008-11-07 09:43:51 UTC (rev 5674) @@ -42,7 +42,7 @@ * Abstract base implementation of {@link AnimationObjects}. * @author <a href="mailto:ch...@ri...">Christian Hujer</a> */ -public class DefaultAnimationObjects<E extends AnimationObject> extends AbstractNamedObjects<E> implements AnimationObjects<E> { +public class DefaultAnimationObjects extends AbstractNamedObjects<AnimationObject> implements AnimationObjects { /** Action Factory. */ private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("net.sf.gridarta"); @@ -92,7 +92,7 @@ * @throws DuplicateAnimationException in case the animation was not unique */ public void addAnimationObject(final String animName, final String list, @Nullable final String path) throws DuplicateAnimationException { - final E animationObject; + final AnimationObject animationObject; if (path == null) { final String animPath = animMap.get(animName); animationObject = newAnimationObject(animName, list, animPath == null ? "/" + animName : animPath); @@ -113,8 +113,8 @@ * @return the anmation object instance */ @NotNull - protected E newAnimationObject(@NotNull final String animName, @NotNull final String animList, @Nullable final String path) { - return (E) new DefaultAnimationObject(animName, animList, path); + private static AnimationObject newAnimationObject(@NotNull final String animName, @NotNull final String animList, @Nullable final String path) { + return new DefaultAnimationObject(animName, animList, path); } /** {@inheritDoc} */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-11-07 10:07:55
|
Revision: 5675 http://gridarta.svn.sourceforge.net/gridarta/?rev=5675&view=rev Author: akirschbaum Date: 2008-11-07 10:07:52 +0000 (Fri, 07 Nov 2008) Log Message: ----------- Remove redundant type parameters. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gameobject/ArchetypeParser.java trunk/crossfire/src/cfeditor/gameobject/ArchetypeSetLoader.java trunk/daimonin/src/daieditor/gameobject/ArchetypeParser.java trunk/daimonin/src/daieditor/gameobject/ArchetypeSetLoader.java trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeAnimName.java trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeParser.java trunk/src/app/net/sf/gridarta/gameobject/AbstractArchetypeSetLoader.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/AnimationTab.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/GameObjectAttributesControl.java Modified: trunk/crossfire/src/cfeditor/gameobject/ArchetypeParser.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/ArchetypeParser.java 2008-11-07 09:43:51 UTC (rev 5674) +++ trunk/crossfire/src/cfeditor/gameobject/ArchetypeParser.java 2008-11-07 10:07:52 UTC (rev 5675) @@ -67,7 +67,7 @@ /** * The animation objects instance. */ - private final AnimationObjects<?> animationObjects; + private final AnimationObjects animationObjects; /** The archetype set. */ @NotNull @@ -98,7 +98,7 @@ * @param gameObjectFactory the factory for creating game objects * @param smoothFaces the smooth faces instance to update */ - public ArchetypeParser(final GameObjectParser<GameObject, MapArchObject, Archetype> gameObjectParser, final ArchetypeChooserControl<GameObject, MapArchObject, Archetype, CMapViewBasic> archetypeChooserControl, final AnimationObjects<?> animationObjects, @NotNull final ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final GameObjectFactory<GameObject, MapArchObject, Archetype> gameObjectFactory, @NotNull final SmoothFaces smoothFaces) { + public ArchetypeParser(final GameObjectParser<GameObject, MapArchObject, Archetype> gameObjectParser, final ArchetypeChooserControl<GameObject, MapArchObject, Archetype, CMapViewBasic> archetypeChooserControl, final AnimationObjects animationObjects, @NotNull final ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final GameObjectFactory<GameObject, MapArchObject, Archetype> gameObjectFactory, @NotNull final SmoothFaces smoothFaces) { this.gameObjectParser = gameObjectParser; this.archetypeChooserControl = archetypeChooserControl; this.animationObjects = animationObjects; Modified: trunk/crossfire/src/cfeditor/gameobject/ArchetypeSetLoader.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/ArchetypeSetLoader.java 2008-11-07 09:43:51 UTC (rev 5674) +++ trunk/crossfire/src/cfeditor/gameobject/ArchetypeSetLoader.java 2008-11-07 10:07:52 UTC (rev 5675) @@ -36,7 +36,6 @@ import net.sf.gridarta.gameobject.AbstractArchetypeParser; import net.sf.gridarta.gameobject.AbstractArchetypeSetLoader; import net.sf.gridarta.gameobject.ArchetypeSet; -import net.sf.gridarta.gameobject.anim.AnimationObject; import net.sf.gridarta.gameobject.anim.AnimationObjects; import net.sf.gridarta.gameobject.anim.AnimationParseException; import net.sf.gridarta.gameobject.anim.DuplicateAnimationException; @@ -113,7 +112,7 @@ * The animation objects instance. */ @NotNull - private final AnimationObjects<? extends AnimationObject> animationObjects; + private final AnimationObjects animationObjects; /** * Creates a new instance. @@ -127,7 +126,7 @@ * @param animationObjects the animation objects instance * @param throwableHandler the throwable handler to use */ - public ArchetypeSetLoader(@NotNull final GlobalSettings globalSettings, @NotNull final GameObjectParser<GameObject, MapArchObject, Archetype> gameObjectParser, @NotNull final String collectedDirectory, @NotNull final ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final AbstractArchetypeParser<GameObject, MapArchObject, Archetype> archetypeParser, @NotNull final EditTypes editTypes, @NotNull final FaceObjects faceObjects, @NotNull final AnimationObjects<? extends AnimationObject> animationObjects, @NotNull final ThrowableHandler<Throwable> throwableHandler) { + public ArchetypeSetLoader(@NotNull final GlobalSettings globalSettings, @NotNull final GameObjectParser<GameObject, MapArchObject, Archetype> gameObjectParser, @NotNull final String collectedDirectory, @NotNull final ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final AbstractArchetypeParser<GameObject, MapArchObject, Archetype> archetypeParser, @NotNull final EditTypes editTypes, @NotNull final FaceObjects faceObjects, @NotNull final AnimationObjects animationObjects, @NotNull final ThrowableHandler<Throwable> throwableHandler) { super(collectedDirectory, animationObjects, throwableHandler, faceObjects); this.globalSettings = globalSettings; this.gameObjectParser = gameObjectParser; Modified: trunk/daimonin/src/daieditor/gameobject/ArchetypeParser.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/ArchetypeParser.java 2008-11-07 09:43:51 UTC (rev 5674) +++ trunk/daimonin/src/daieditor/gameobject/ArchetypeParser.java 2008-11-07 10:07:52 UTC (rev 5675) @@ -58,7 +58,7 @@ /** * The animation objects instance. */ - private final AnimationObjects<?> animationObjects; + private final AnimationObjects animationObjects; /** The archetype set. */ @NotNull @@ -81,7 +81,7 @@ * @param archetypeSet the archetype set * @param gameObjectFactory the factory for creating game objects */ - public ArchetypeParser(final ArchetypeChooserControl<GameObject, MapArchObject, Archetype, CMapViewBasic> archetypeChooserControl, final AnimationObjects<?> animationObjects, @NotNull final ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final GameObjectFactory<GameObject, MapArchObject, Archetype> gameObjectFactory) { + public ArchetypeParser(final ArchetypeChooserControl<GameObject, MapArchObject, Archetype, CMapViewBasic> archetypeChooserControl, final AnimationObjects animationObjects, @NotNull final ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final GameObjectFactory<GameObject, MapArchObject, Archetype> gameObjectFactory) { this.archetypeChooserControl = archetypeChooserControl; this.animationObjects = animationObjects; this.archetypeSet = archetypeSet; Modified: trunk/daimonin/src/daieditor/gameobject/ArchetypeSetLoader.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/ArchetypeSetLoader.java 2008-11-07 09:43:51 UTC (rev 5674) +++ trunk/daimonin/src/daieditor/gameobject/ArchetypeSetLoader.java 2008-11-07 10:07:52 UTC (rev 5675) @@ -115,7 +115,7 @@ * The animation objects instance. */ @NotNull - private final AnimationObjects<? extends AnimationObject> animationObjects; + private final AnimationObjects animationObjects; /** * The throwable handler to use. @@ -142,7 +142,7 @@ * @param animationObjects the animation objects instance * @param throwableHandler the throwable handler to use */ - public ArchetypeSetLoader(@NotNull final GlobalSettings globalSettings, @NotNull final GameObjectParser<GameObject, MapArchObject, Archetype> gameObjectParser, @NotNull final String collectedDirectory, @NotNull final ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final AbstractArchetypeParser<GameObject, MapArchObject, Archetype> archetypeParser, @NotNull final EditTypes editTypes, @NotNull final FaceObjects faceObjects, @NotNull final AnimationObjects<? extends AnimationObject> animationObjects, @NotNull final ThrowableHandler<Throwable> throwableHandler) { + public ArchetypeSetLoader(@NotNull final GlobalSettings globalSettings, @NotNull final GameObjectParser<GameObject, MapArchObject, Archetype> gameObjectParser, @NotNull final String collectedDirectory, @NotNull final ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final AbstractArchetypeParser<GameObject, MapArchObject, Archetype> archetypeParser, @NotNull final EditTypes editTypes, @NotNull final FaceObjects faceObjects, @NotNull final AnimationObjects animationObjects, @NotNull final ThrowableHandler<Throwable> throwableHandler) { super(collectedDirectory, animationObjects, throwableHandler, faceObjects); this.globalSettings = globalSettings; this.gameObjectParser = gameObjectParser; Modified: trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeAnimName.java =================================================================== --- trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeAnimName.java 2008-11-07 09:43:51 UTC (rev 5674) +++ trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeAnimName.java 2008-11-07 10:07:52 UTC (rev 5675) @@ -36,14 +36,14 @@ private final int typeNoEventConnector; @NotNull - private final AnimationObjects<?> animationObjects; + private final AnimationObjects animationObjects; private final boolean includeFaceText; /** * Creates a new instance. */ - public ArchetypeAttributeAnimName(@NotNull final String nameOld, @NotNull final String nameNew, @NotNull final String text, final int inputLength, final int typeNoEventConnector, @NotNull final AnimationObjects<?> animationObjects, final boolean includeFaceText) { + public ArchetypeAttributeAnimName(@NotNull final String nameOld, @NotNull final String nameNew, @NotNull final String text, final int inputLength, final int typeNoEventConnector, @NotNull final AnimationObjects animationObjects, final boolean includeFaceText) { super(nameOld, nameNew, text, inputLength); this.typeNoEventConnector = typeNoEventConnector; this.animationObjects = animationObjects; Modified: trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeParser.java =================================================================== --- trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeParser.java 2008-11-07 09:43:51 UTC (rev 5674) +++ trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeParser.java 2008-11-07 10:07:52 UTC (rev 5675) @@ -101,7 +101,7 @@ * The animation objects to use. */ @NotNull - private final AnimationObjects<?> animationObjects; + private final AnimationObjects animationObjects; /** * The numbered spells. @@ -147,7 +147,7 @@ * @param archetypeTypeSet the archetype types * @param treasureListTree the treasure lists */ - public ArchetypeAttributeParser(final int typeNoEventConnector, final boolean includeFaceText, @NotNull final GlobalSettings globalSettings, @NotNull final FileFilter mapFileFilter, @NotNull final FileFilter scriptFileFilter, @NotNull final FaceObjects faceObjects, @NotNull final AnimationObjects<?> animationObjects, @NotNull final Spells<NumberSpell> numberSpells, @NotNull final Spells<GameObjectSpell<G, A, R>> gameObjectSpells, final int undefinedSpellIndex, @NotNull final ArchetypeTypeSet<G, A, R> archetypeTypeSet, @NotNull final CFTreasureListTree<G, A, R> treasureListTree) { + public ArchetypeAttributeParser(final int typeNoEventConnector, final boolean includeFaceText, @NotNull final GlobalSettings globalSettings, @NotNull final FileFilter mapFileFilter, @NotNull final FileFilter scriptFileFilter, @NotNull final FaceObjects faceObjects, @NotNull final AnimationObjects animationObjects, @NotNull final Spells<NumberSpell> numberSpells, @NotNull final Spells<GameObjectSpell<G, A, R>> gameObjectSpells, final int undefinedSpellIndex, @NotNull final ArchetypeTypeSet<G, A, R> archetypeTypeSet, @NotNull final CFTreasureListTree<G, A, R> treasureListTree) { this.typeNoEventConnector = typeNoEventConnector; this.includeFaceText = includeFaceText; this.globalSettings = globalSettings; Modified: trunk/src/app/net/sf/gridarta/gameobject/AbstractArchetypeSetLoader.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/AbstractArchetypeSetLoader.java 2008-11-07 09:43:51 UTC (rev 5674) +++ trunk/src/app/net/sf/gridarta/gameobject/AbstractArchetypeSetLoader.java 2008-11-07 10:07:52 UTC (rev 5675) @@ -23,7 +23,6 @@ import java.io.File; import java.io.IOException; import java.io.Reader; -import net.sf.gridarta.gameobject.anim.AnimationObject; import net.sf.gridarta.gameobject.anim.AnimationObjects; import net.sf.gridarta.gameobject.anim.AnimationParseException; import net.sf.gridarta.gameobject.anim.DuplicateAnimationException; @@ -58,7 +57,7 @@ * The animation objects instance. */ @NotNull - private final AnimationObjects<? extends AnimationObject> animationObjects; + private final AnimationObjects animationObjects; /** * The throwable handler to use. @@ -79,7 +78,7 @@ * @param throwableHandler the throwable handler to use * @param faceObjects the face ojects instance */ - protected AbstractArchetypeSetLoader(@NotNull final String collectedDirectory, @NotNull final AnimationObjects<? extends AnimationObject> animationObjects, @NotNull final ThrowableHandler<Throwable> throwableHandler, @NotNull final FaceObjects faceObjects) { + protected AbstractArchetypeSetLoader(@NotNull final String collectedDirectory, @NotNull final AnimationObjects animationObjects, @NotNull final ThrowableHandler<Throwable> throwableHandler, @NotNull final FaceObjects faceObjects) { this.collectedDirectory = collectedDirectory; this.animationObjects = animationObjects; this.throwableHandler = throwableHandler; Modified: trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/AnimationTab.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/AnimationTab.java 2008-11-07 09:43:51 UTC (rev 5674) +++ trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/AnimationTab.java 2008-11-07 10:07:52 UTC (rev 5675) @@ -38,7 +38,7 @@ /** The animtation objects instance to use. */ @NotNull - private final AnimationObjects<?> animationObjects; + private final AnimationObjects animationObjects; /** The label that displays the current animation name. */ private final JLabel archAnimText = new JLabel(); @@ -48,7 +48,7 @@ * @param animationObjects the animation objects * @param gameObjectAttributesModel the model to track */ - public AnimationTab(@NotNull final AnimationObjects<?> animationObjects, @NotNull final GameObjectAttributesModel<G, A, R> gameObjectAttributesModel) { + public AnimationTab(@NotNull final AnimationObjects animationObjects, @NotNull final GameObjectAttributesModel<G, A, R> gameObjectAttributesModel) { super(gameObjectAttributesModel); this.animationObjects = animationObjects; refresh(gameObjectAttributesModel.getSelectedGameObject()); Modified: trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/GameObjectAttributesControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/GameObjectAttributesControl.java 2008-11-07 09:43:51 UTC (rev 5674) +++ trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/GameObjectAttributesControl.java 2008-11-07 10:07:52 UTC (rev 5675) @@ -319,7 +319,7 @@ * @param selectedSquareView the selected square view instance * @param parent the parent component for dialog windows */ - public GameObjectAttributesControl(@NotNull final GameObjectAttributesModel<G, A, R> gameObjectAttributesModel, @NotNull final GameObjectAttributesDialogFactory<G, A, R, V> gameObjectAttributesDialogFactory, @NotNull final ObjectChooser<G, A, R> objectChooser, @NotNull final ArchetypeTypeSet<G, A, R> archetypeTypeSet, @NotNull final MapManager<G, A, R, V> mapManager, @NotNull final MapViewManager<G, A, R, V> mapViewManager, @NotNull final AnimationObjects<?> animationObjects, final LockedItemsControl<G, A, R, V> lockedItemsControl, @NotNull final GameObjectMatcher monsterMatcher, @NotNull final SelectedSquareControl<G, A, R, V> selectedSquareControl, @NotNull final SelectedSquareView<G, A, R, V> selectedSquareView, @NotNull final Frame parent) { + public GameObjectAttributesControl(@NotNull final GameObjectAttributesModel<G, A, R> gameObjectAttributesModel, @NotNull final GameObjectAttributesDialogFactory<G, A, R, V> gameObjectAttributesDialogFactory, @NotNull final ObjectChooser<G, A, R> objectChooser, @NotNull final ArchetypeTypeSet<G, A, R> archetypeTypeSet, @NotNull final MapManager<G, A, R, V> mapManager, @NotNull final MapViewManager<G, A, R, V> mapViewManager, @NotNull final AnimationObjects animationObjects, final LockedItemsControl<G, A, R, V> lockedItemsControl, @NotNull final GameObjectMatcher monsterMatcher, @NotNull final SelectedSquareControl<G, A, R, V> selectedSquareControl, @NotNull final SelectedSquareView<G, A, R, V> selectedSquareView, @NotNull final Frame parent) { super(new BorderLayout()); this.gameObjectAttributesModel = gameObjectAttributesModel; this.gameObjectAttributesDialogFactory = gameObjectAttributesDialogFactory; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-11-09 10:38:41
|
Revision: 5676 http://gridarta.svn.sourceforge.net/gridarta/?rev=5676&view=rev Author: akirschbaum Date: 2008-11-09 10:38:30 +0000 (Sun, 09 Nov 2008) Log Message: ----------- Move code to create AnimationObjects instance to common code base. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/daimonin/src/daieditor/CMainControl.java trunk/src/app/net/sf/gridarta/AbstractMainControl.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-11-07 10:07:52 UTC (rev 5675) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-11-09 10:38:30 UTC (rev 5676) @@ -57,7 +57,6 @@ import net.sf.gridarta.gameobject.Collectable; import net.sf.gridarta.gameobject.GameObjectFactory; import net.sf.gridarta.gameobject.anim.AnimationObjects; -import net.sf.gridarta.gameobject.anim.DefaultAnimationObjects; import net.sf.gridarta.gameobject.face.DefaultFaceObjects; import net.sf.gridarta.gameobject.face.FaceObjectProviders; import net.sf.gridarta.gameobject.face.FaceObjects; @@ -142,7 +141,7 @@ * @throws RuntimeException If the controller cannot be initialized. */ public CMainControl() { - super("cfeditor", new DefaultAnimationObjects(IGUIConstants.ANIMTREE_FILE), new DefaultFaceObjects(IGUIConstants.PNG_FILE, IGUIConstants.FACETREE_FILE, Pattern.compile("^.*\t\\.?(.*)"), "\\%1$05d\t./arch%2$s"), false, ConfigFileUtils.getHomeFile("thumbnails"), null, "CrossfireEditor.jar", pythonFileFilter, ".py", "Python", Archetype.TYPE_SPELL, null, Archetype.TYPE_EVENT_CONNECTOR, false, 0, new int[] { Archetype.TYPE_LOCKED_DOOR, Archetype.TYPE_SPECIAL_KEY, Archetype.TYPE_TRIGGER_ALTAR, Archetype.TYPE_DETECTOR, Archetype.TYPE_TRIGGER_MARKER, Archetype.TYPE_MARKER, Archetype.TYPE_INVENTORY_CHECKER, Archetype.TYPE_CONTAINER, }, PREFS_VALIDATOR_AUTO_DEFAULT, IGUIConstants.SCRIPTS_DIR); + super("cfeditor", IGUIConstants.ANIMTREE_FILE, new DefaultFaceObjects(IGUIConstants.PNG_FILE, IGUIConstants.FACETREE_FILE, Pattern.compile("^.*\t\\.?(.*)"), "\\%1$05d\t./arch%2$s"), false, ConfigFileUtils.getHomeFile("thumbnails"), null, "CrossfireEditor.jar", pythonFileFilter, ".py", "Python", Archetype.TYPE_SPELL, null, Archetype.TYPE_EVENT_CONNECTOR, false, 0, new int[] { Archetype.TYPE_LOCKED_DOOR, Archetype.TYPE_SPECIAL_KEY, Archetype.TYPE_TRIGGER_ALTAR, Archetype.TYPE_DETECTOR, Archetype.TYPE_TRIGGER_MARKER, Archetype.TYPE_MARKER, Archetype.TYPE_INVENTORY_CHECKER, Archetype.TYPE_CONTAINER, }, PREFS_VALIDATOR_AUTO_DEFAULT, IGUIConstants.SCRIPTS_DIR); } /** {@inheritDoc} */ Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-11-07 10:07:52 UTC (rev 5675) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-11-09 10:38:30 UTC (rev 5676) @@ -58,7 +58,6 @@ import net.sf.gridarta.gameobject.Collectable; import net.sf.gridarta.gameobject.GameObjectFactory; import net.sf.gridarta.gameobject.anim.AnimationObjects; -import net.sf.gridarta.gameobject.anim.DefaultAnimationObjects; import net.sf.gridarta.gameobject.face.DefaultFaceObjects; import net.sf.gridarta.gameobject.face.FaceObjectProviders; import net.sf.gridarta.gameobject.face.FaceObjects; @@ -175,7 +174,7 @@ * @throws RuntimeException If the controller cannot be initialized. */ public CMainControl() { - super("daieditor", new DefaultAnimationObjects(IGUIConstants.ANIMTREE_FILE), new DefaultFaceObjects(IGUIConstants.PNG_FILE, IGUIConstants.FACETREE_FILE, Pattern.compile("^(.*)"), "%2$s"), true, null, GUIUtils.getSysIcon(IGUIConstants.TILE_NORTH), "DaimoninEditor.jar", luaFileFilter, ".lua", "Lua", 0, IGUIConstants.SPELL_FILE, 0, true, -1, new int[] { Archetype.TYPE_LOCKED_DOOR, Archetype.TYPE_SPECIAL_KEY, Archetype.TYPE_ALTAR_TRIGGER, Archetype.TYPE_MARKER, Archetype.TYPE_INVENTORY_CHECKER, Archetype.TYPE_SPAWN_POINT, Archetype.TYPE_CONTAINER, }, PREFS_VALIDATOR_AUTO_DEFAULT, IGUIConstants.SCRIPTS_DIR); + super("daieditor", IGUIConstants.ANIMTREE_FILE, new DefaultFaceObjects(IGUIConstants.PNG_FILE, IGUIConstants.FACETREE_FILE, Pattern.compile("^(.*)"), "%2$s"), true, null, GUIUtils.getSysIcon(IGUIConstants.TILE_NORTH), "DaimoninEditor.jar", luaFileFilter, ".lua", "Lua", 0, IGUIConstants.SPELL_FILE, 0, true, -1, new int[] { Archetype.TYPE_LOCKED_DOOR, Archetype.TYPE_SPECIAL_KEY, Archetype.TYPE_ALTAR_TRIGGER, Archetype.TYPE_MARKER, Archetype.TYPE_INVENTORY_CHECKER, Archetype.TYPE_SPAWN_POINT, Archetype.TYPE_CONTAINER, }, PREFS_VALIDATOR_AUTO_DEFAULT, IGUIConstants.SCRIPTS_DIR); } /** {@inheritDoc} */ Modified: trunk/src/app/net/sf/gridarta/AbstractMainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2008-11-07 10:07:52 UTC (rev 5675) +++ trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2008-11-09 10:38:30 UTC (rev 5676) @@ -54,8 +54,8 @@ import net.sf.gridarta.gameobject.Collectable; import net.sf.gridarta.gameobject.GameObject; import net.sf.gridarta.gameobject.GameObjectFactory; -import net.sf.gridarta.gameobject.anim.AnimationObject; import net.sf.gridarta.gameobject.anim.AnimationObjects; +import net.sf.gridarta.gameobject.anim.DefaultAnimationObjects; import net.sf.gridarta.gameobject.face.FaceObjects; import net.sf.gridarta.gameobject.match.GameObjectMatcher; import net.sf.gridarta.gameobject.match.GameObjectMatchers; @@ -304,7 +304,8 @@ /** * Creates a new instance. * @param key The action factory key - * @param animationObjects the animation objects instance + * @param animationObjectsFilename the filename of the animation objects + * file * @param faceObjects the face objects instance * @param createDirectionPane whether the direction panel should be created * @param mapImageCacheDir the map image cache directory or @@ -328,7 +329,7 @@ * default * @param scriptsDir the plugin scripts directory */ - protected AbstractMainControl(@NotNull final String key, @NotNull final AnimationObjects animationObjects, @NotNull final FaceObjects faceObjects, final boolean createDirectionPane, @Nullable final File mapImageCacheDir, @Nullable final ImageIcon compassIcon, @NotNull final String gridartaJarFilename, @NotNull final FileFilter scriptFileFilter, @NotNull final String scriptExtension, @NotNull final String scriptName, final int spellType, @Nullable final String spellFile, final int typeNoEventConnector, final boolean includeFaceText, final int undefinedSpellIndex, @NotNull final int[] lockedItemsTypeNumbers, final boolean autoValidatorDefault, @NotNull final String scriptsDir) { + protected AbstractMainControl(@NotNull final String key, @NotNull final String animationObjectsFilename, @NotNull final FaceObjects faceObjects, final boolean createDirectionPane, @Nullable final File mapImageCacheDir, @Nullable final ImageIcon compassIcon, @NotNull final String gridartaJarFilename, @NotNull final FileFilter scriptFileFilter, @NotNull final String scriptExtension, @NotNull final String scriptName, final int spellType, @Nullable final String spellFile, final int typeNoEventConnector, final boolean includeFaceText, final int undefinedSpellIndex, @NotNull final int[] lockedItemsTypeNumbers, final boolean autoValidatorDefault, @NotNull final String scriptsDir) { this.scriptExtension = scriptExtension; appPrefsModel = createAppPrefsModel(); final MapArchObjectFactory<A> mapArchObjectFactory = newMapArchObjectFactory(); @@ -400,6 +401,7 @@ validators = createMapValidators(globalSettings, gameObjectMatchers); final List<Collectable> collectables = new ArrayList<Collectable>(); collectables.add(archetypeSet); + final AnimationObjects animationObjects = new DefaultAnimationObjects(animationObjectsFilename); collectables.add(animationObjects); collectables.add(faceObjects); addCollectables(collectables); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-11-09 10:52:29
|
Revision: 5677 http://gridarta.svn.sourceforge.net/gridarta/?rev=5677&view=rev Author: akirschbaum Date: 2008-11-09 10:52:23 +0000 (Sun, 09 Nov 2008) Log Message: ----------- Remove an AbstractMainControl's constructor parameter. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/daimonin/src/daieditor/CMainControl.java trunk/src/app/net/sf/gridarta/AbstractMainControl.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-11-09 10:38:30 UTC (rev 5676) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-11-09 10:52:23 UTC (rev 5677) @@ -141,12 +141,19 @@ * @throws RuntimeException If the controller cannot be initialized. */ public CMainControl() { - super("cfeditor", IGUIConstants.ANIMTREE_FILE, new DefaultFaceObjects(IGUIConstants.PNG_FILE, IGUIConstants.FACETREE_FILE, Pattern.compile("^.*\t\\.?(.*)"), "\\%1$05d\t./arch%2$s"), false, ConfigFileUtils.getHomeFile("thumbnails"), null, "CrossfireEditor.jar", pythonFileFilter, ".py", "Python", Archetype.TYPE_SPELL, null, Archetype.TYPE_EVENT_CONNECTOR, false, 0, new int[] { Archetype.TYPE_LOCKED_DOOR, Archetype.TYPE_SPECIAL_KEY, Archetype.TYPE_TRIGGER_ALTAR, Archetype.TYPE_DETECTOR, Archetype.TYPE_TRIGGER_MARKER, Archetype.TYPE_MARKER, Archetype.TYPE_INVENTORY_CHECKER, Archetype.TYPE_CONTAINER, }, PREFS_VALIDATOR_AUTO_DEFAULT, IGUIConstants.SCRIPTS_DIR); + super("cfeditor", IGUIConstants.ANIMTREE_FILE, false, ConfigFileUtils.getHomeFile("thumbnails"), null, "CrossfireEditor.jar", pythonFileFilter, ".py", "Python", Archetype.TYPE_SPELL, null, Archetype.TYPE_EVENT_CONNECTOR, false, 0, new int[] { Archetype.TYPE_LOCKED_DOOR, Archetype.TYPE_SPECIAL_KEY, Archetype.TYPE_TRIGGER_ALTAR, Archetype.TYPE_DETECTOR, Archetype.TYPE_TRIGGER_MARKER, Archetype.TYPE_MARKER, Archetype.TYPE_INVENTORY_CHECKER, Archetype.TYPE_CONTAINER, }, PREFS_VALIDATOR_AUTO_DEFAULT, IGUIConstants.SCRIPTS_DIR); } /** {@inheritDoc} */ @NotNull @Override + protected FaceObjects createFaceObjects() { + return new DefaultFaceObjects(IGUIConstants.PNG_FILE, IGUIConstants.FACETREE_FILE, Pattern.compile("^.*\t\\.?(.*)"), "\\%1$05d\t./arch%2$s"); + } + + /** {@inheritDoc} */ + @NotNull + @Override protected GlobalSettings newGlobalSettings() { return new GlobalSettingsImpl(); } Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-11-09 10:38:30 UTC (rev 5676) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-11-09 10:52:23 UTC (rev 5677) @@ -174,12 +174,19 @@ * @throws RuntimeException If the controller cannot be initialized. */ public CMainControl() { - super("daieditor", IGUIConstants.ANIMTREE_FILE, new DefaultFaceObjects(IGUIConstants.PNG_FILE, IGUIConstants.FACETREE_FILE, Pattern.compile("^(.*)"), "%2$s"), true, null, GUIUtils.getSysIcon(IGUIConstants.TILE_NORTH), "DaimoninEditor.jar", luaFileFilter, ".lua", "Lua", 0, IGUIConstants.SPELL_FILE, 0, true, -1, new int[] { Archetype.TYPE_LOCKED_DOOR, Archetype.TYPE_SPECIAL_KEY, Archetype.TYPE_ALTAR_TRIGGER, Archetype.TYPE_MARKER, Archetype.TYPE_INVENTORY_CHECKER, Archetype.TYPE_SPAWN_POINT, Archetype.TYPE_CONTAINER, }, PREFS_VALIDATOR_AUTO_DEFAULT, IGUIConstants.SCRIPTS_DIR); + super("daieditor", IGUIConstants.ANIMTREE_FILE, true, null, GUIUtils.getSysIcon(IGUIConstants.TILE_NORTH), "DaimoninEditor.jar", luaFileFilter, ".lua", "Lua", 0, IGUIConstants.SPELL_FILE, 0, true, -1, new int[] { Archetype.TYPE_LOCKED_DOOR, Archetype.TYPE_SPECIAL_KEY, Archetype.TYPE_ALTAR_TRIGGER, Archetype.TYPE_MARKER, Archetype.TYPE_INVENTORY_CHECKER, Archetype.TYPE_SPAWN_POINT, Archetype.TYPE_CONTAINER, }, PREFS_VALIDATOR_AUTO_DEFAULT, IGUIConstants.SCRIPTS_DIR); } /** {@inheritDoc} */ @NotNull @Override + protected FaceObjects createFaceObjects() { + return new DefaultFaceObjects(IGUIConstants.PNG_FILE, IGUIConstants.FACETREE_FILE, Pattern.compile("^(.*)"), "%2$s"); + } + + /** {@inheritDoc} */ + @NotNull + @Override protected GlobalSettings newGlobalSettings() { return new GlobalSettingsImpl(); } Modified: trunk/src/app/net/sf/gridarta/AbstractMainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2008-11-09 10:38:30 UTC (rev 5676) +++ trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2008-11-09 10:52:23 UTC (rev 5677) @@ -306,7 +306,6 @@ * @param key The action factory key * @param animationObjectsFilename the filename of the animation objects * file - * @param faceObjects the face objects instance * @param createDirectionPane whether the direction panel should be created * @param mapImageCacheDir the map image cache directory or * <code>null</code> to use the map directory @@ -329,7 +328,7 @@ * default * @param scriptsDir the plugin scripts directory */ - protected AbstractMainControl(@NotNull final String key, @NotNull final String animationObjectsFilename, @NotNull final FaceObjects faceObjects, final boolean createDirectionPane, @Nullable final File mapImageCacheDir, @Nullable final ImageIcon compassIcon, @NotNull final String gridartaJarFilename, @NotNull final FileFilter scriptFileFilter, @NotNull final String scriptExtension, @NotNull final String scriptName, final int spellType, @Nullable final String spellFile, final int typeNoEventConnector, final boolean includeFaceText, final int undefinedSpellIndex, @NotNull final int[] lockedItemsTypeNumbers, final boolean autoValidatorDefault, @NotNull final String scriptsDir) { + protected AbstractMainControl(@NotNull final String key, @NotNull final String animationObjectsFilename, final boolean createDirectionPane, @Nullable final File mapImageCacheDir, @Nullable final ImageIcon compassIcon, @NotNull final String gridartaJarFilename, @NotNull final FileFilter scriptFileFilter, @NotNull final String scriptExtension, @NotNull final String scriptName, final int spellType, @Nullable final String spellFile, final int typeNoEventConnector, final boolean includeFaceText, final int undefinedSpellIndex, @NotNull final int[] lockedItemsTypeNumbers, final boolean autoValidatorDefault, @NotNull final String scriptsDir) { this.scriptExtension = scriptExtension; appPrefsModel = createAppPrefsModel(); final MapArchObjectFactory<A> mapArchObjectFactory = newMapArchObjectFactory(); @@ -361,6 +360,7 @@ final ArchetypeTypeSet<G, A, R> archetypeTypeSet = new ArchetypeTypeSet<G, A, R>(); mapViewManager = new MapViewManager<G, A, R, V>(); SystemIcons.init(); + final FaceObjects faceObjects = createFaceObjects(); createMapImageCache(mapImageCacheDir, SystemIcons.getDefaultIcon(), SystemIcons.getDefaultPreview(), new StatusBar<G, A, R, V>(mapManager, mapViewManager, archetypeSet, faceObjects)); final ActionFactory actionFactory = ActionFactory.getFactory(key); mainView = new MainView<G, A, R, V>(this, editTypes, mapManager, mapViewManager, actionFactory, mapManagerActions.getCloseAllAction(), statusBar, getBuildNumberAsString()); @@ -511,6 +511,9 @@ } @NotNull + protected abstract FaceObjects createFaceObjects(); + + @NotNull protected abstract GlobalSettings newGlobalSettings(); @NotNull This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-11-09 11:19:37
|
Revision: 5679 http://gridarta.svn.sourceforge.net/gridarta/?rev=5679&view=rev Author: akirschbaum Date: 2008-11-09 11:19:27 +0000 (Sun, 09 Nov 2008) Log Message: ----------- Remove unused code. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/daimonin/src/daieditor/CMainControl.java trunk/src/app/net/sf/gridarta/AbstractMainControl.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-11-09 11:00:13 UTC (rev 5678) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-11-09 11:19:27 UTC (rev 5679) @@ -217,13 +217,6 @@ /** {@inheritDoc} */ @NotNull @Override - protected MapReaderFactory<GameObject, MapArchObject> newMapReaderFactory(@NotNull final MapArchObjectFactory<MapArchObject> mapArchObjectFactory, @NotNull final MapArchObjectParserFactory<MapArchObject> mapArchObjectParserFactory, @NotNull final GameObjectParserFactory<GameObject, MapArchObject, Archetype> gameObjectParserFactory) { - return new DefaultMapReaderFactory(mapArchObjectFactory, mapArchObjectParserFactory, gameObjectParserFactory); - } - - /** {@inheritDoc} */ - @NotNull - @Override protected GameObjectParserFactory<GameObject, MapArchObject, Archetype> newGameObjectParserFactory(@NotNull final GameObjectFactory<GameObject, MapArchObject, Archetype> gameObjectFactory) { return new DefaultGameObjectParserFactory(gameObjectFactory); } Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-11-09 11:00:13 UTC (rev 5678) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-11-09 11:19:27 UTC (rev 5679) @@ -92,7 +92,6 @@ import net.sf.gridarta.gui.prefs.UpdatePrefs; import net.sf.gridarta.gui.selectedsquare.SelectedSquareView; import net.sf.gridarta.gui.utils.GUIUtils; -import net.sf.gridarta.io.DefaultMapReaderFactory; import net.sf.gridarta.io.GameObjectParser; import net.sf.gridarta.io.GameObjectParserFactory; import net.sf.gridarta.io.MapArchObjectParserFactory; @@ -126,7 +125,6 @@ import net.sf.gridarta.treasurelist.CFTreasureListTree; import net.sf.gridarta.treasurelist.TreasureLocation; import net.sf.gridarta.treasurelist.TreasureTreeNode; -import net.sf.japi.io.args.ArgParser; import net.sf.japi.swing.ActionFactory; import net.sf.japi.swing.ActionMethod; import net.sf.japi.swing.prefs.PreferencesGroup; @@ -248,13 +246,6 @@ /** {@inheritDoc} */ @NotNull @Override - protected MapReaderFactory<GameObject, MapArchObject> newMapReaderFactory(@NotNull final MapArchObjectFactory<MapArchObject> mapArchObjectFactory, @NotNull final MapArchObjectParserFactory<MapArchObject> mapArchObjectParserFactory, @NotNull final GameObjectParserFactory<GameObject, MapArchObject, Archetype> gameObjectParserFactory) { - return new DefaultMapReaderFactory(mapArchObjectFactory, mapArchObjectParserFactory, gameObjectParserFactory); - } - - /** {@inheritDoc} */ - @NotNull - @Override protected GameObjectParserFactory<GameObject, MapArchObject, Archetype> newGameObjectParserFactory(@NotNull final GameObjectFactory<GameObject, MapArchObject, Archetype> gameObjectFactory) { return new DefaultGameObjectParserFactory(gameObjectFactory); } Modified: trunk/src/app/net/sf/gridarta/AbstractMainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2008-11-09 11:00:13 UTC (rev 5678) +++ trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2008-11-09 11:19:27 UTC (rev 5679) @@ -544,9 +544,6 @@ protected abstract MapViewFactory<G, A, R, V> newMapViewFactory(@NotNull final MapViewSettings mapViewSettings, @NotNull final FaceObjects faceObjects, @NotNull final SelectedSquareView<G, A, R, V> selectedSquareView, @NotNull final AbstractMainControl<G, A, R, V> mainControl, @NotNull final MainView<G, A, R, V> mainView, @NotNull final EditTypes editTypes, @NotNull final MapImageCache<G, A, R, V> mapImageCache, @NotNull final ToolPalette<G, A, R, V> toolPalette, @NotNull final FilterControl<G, A, R, V> filterControl); @NotNull - protected abstract MapReaderFactory<G, A> newMapReaderFactory(@NotNull final MapArchObjectFactory<A> mapArchObjectFactory, @NotNull final MapArchObjectParserFactory<A> mapArchObjectParserFactory, @NotNull final GameObjectParserFactory<G, A, R> gameObjectParserFactory); - - @NotNull protected abstract GameObjectParserFactory<G, A, R> newGameObjectParserFactory(@NotNull final GameObjectFactory<G, A, R> gameObjectFactory); @NotNull This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-11-09 14:27:27
|
Revision: 5681 http://gridarta.svn.sourceforge.net/gridarta/?rev=5681&view=rev Author: akirschbaum Date: 2008-11-09 14:27:16 +0000 (Sun, 09 Nov 2008) Log Message: ----------- Implement #1627422 (Check box option to avoid startup warnings) for GameObjectMatchers.xml related errors. Modified Paths: -------------- trunk/crossfire/ChangeLog trunk/crossfire/src/cfeditor/CMainControl.java trunk/daimonin/ChangeLog trunk/daimonin/src/daieditor/CMainControl.java trunk/src/app/net/sf/gridarta/AbstractMainControl.java trunk/src/app/net/sf/gridarta/gameobject/match/GameObjectMatcherParser.java trunk/src/app/net/sf/gridarta/gameobject/match/GameObjectMatchers.java trunk/src/app/net/sf/gridarta/gameobject/match/GameObjectMatchersParser.java trunk/src/app/net/sf/gridarta/messages.properties trunk/src/app/net/sf/gridarta/messages_de.properties trunk/src/app/net/sf/gridarta/messages_fr.properties trunk/src/app/net/sf/gridarta/messages_sv.properties trunk/src/app/net/sf/gridarta/utils/XmlHelper.java Added Paths: ----------- trunk/src/app/net/sf/gridarta/gameobject/match/ParsingException.java trunk/src/app/net/sf/gridarta/gui/errorview/ trunk/src/app/net/sf/gridarta/gui/errorview/DefaultErrorView.java trunk/src/app/net/sf/gridarta/gui/errorview/ErrorEntry.java trunk/src/app/net/sf/gridarta/gui/errorview/ErrorViewCollector.java Modified: trunk/crossfire/ChangeLog =================================================================== --- trunk/crossfire/ChangeLog 2008-11-09 11:27:45 UTC (rev 5680) +++ trunk/crossfire/ChangeLog 2008-11-09 14:27:16 UTC (rev 5681) @@ -1,3 +1,10 @@ +2008-11-09 Andreas Kirschbaum + + * Partially implement #1627422 (Check box option to avoid startup + warnings): add an error dialog box for collecting all error + messages in a single dialog. Use it for GameObjectMatchers.xml + related errors. + 2008-11-06 Andreas Kirschbaum * Rename "Scripts" tab to "Events" in game object attributes Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-11-09 11:27:45 UTC (rev 5680) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-11-09 14:27:16 UTC (rev 5681) @@ -71,6 +71,7 @@ import net.sf.gridarta.gui.MainView; import net.sf.gridarta.gui.MapViewManager; import net.sf.gridarta.gui.archetypechooser.ArchetypeChooserControl; +import net.sf.gridarta.gui.errorview.ErrorViewCollector; import net.sf.gridarta.gui.map.DefaultMapActions; import net.sf.gridarta.gui.map.MapActions; import net.sf.gridarta.gui.map.MapPropertiesDialogFactory; @@ -89,7 +90,6 @@ import net.sf.gridarta.gui.prefs.UpdatePrefs; import net.sf.gridarta.gui.selectedsquare.SelectedSquareView; import net.sf.gridarta.io.ConfigFileUtils; -import net.sf.gridarta.io.DefaultMapReaderFactory; import net.sf.gridarta.io.GameObjectParser; import net.sf.gridarta.io.GameObjectParserFactory; import net.sf.gridarta.io.MapArchObjectParserFactory; @@ -317,7 +317,7 @@ /** {@inheritDoc} */ @NotNull @Override - protected DelegatingMapValidator<GameObject, MapArchObject, Archetype> createMapValidators(@NotNull final GlobalSettings globalSettings, @NotNull final GameObjectMatchers gameObjectMatchers) { + protected DelegatingMapValidator<GameObject, MapArchObject, Archetype> createMapValidators(@NotNull final ErrorViewCollector errorViewCollector, @NotNull final GlobalSettings globalSettings, @NotNull final GameObjectMatchers gameObjectMatchers) { final DelegatingMapValidator<GameObject, MapArchObject, Archetype> mapValidators = new DelegatingMapValidator<GameObject, MapArchObject, Archetype>(); final AttributeRangeChecker<GameObject, MapArchObject, Archetype> attributeRangeChecker = new AttributeRangeChecker<GameObject, MapArchObject, Archetype>(); // make sure sustenance is [-20..20]; amulet of Sustenance is +15 so +20 should be safe Modified: trunk/daimonin/ChangeLog =================================================================== --- trunk/daimonin/ChangeLog 2008-11-09 11:27:45 UTC (rev 5680) +++ trunk/daimonin/ChangeLog 2008-11-09 14:27:16 UTC (rev 5681) @@ -1,3 +1,10 @@ +2008-11-09 Andreas Kirschbaum + + * Partially implement #1627422 (Check box option to avoid startup + warnings): add an error dialog box for collecting error messages + in a single dialog. Use it for GameObjectMatchers.xml related + errors. + 2008-11-06 Andreas Kirschbaum * Rename "Scripts" tab to "Events" in game object attributes Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-11-09 11:27:45 UTC (rev 5680) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-11-09 14:27:16 UTC (rev 5681) @@ -74,6 +74,7 @@ import net.sf.gridarta.gui.MainView; import net.sf.gridarta.gui.MapViewManager; import net.sf.gridarta.gui.archetypechooser.ArchetypeChooserControl; +import net.sf.gridarta.gui.errorview.ErrorViewCollector; import net.sf.gridarta.gui.map.DefaultMapActions; import net.sf.gridarta.gui.map.MapActions; import net.sf.gridarta.gui.map.MapPropertiesDialogFactory; @@ -125,6 +126,7 @@ import net.sf.gridarta.treasurelist.CFTreasureListTree; import net.sf.gridarta.treasurelist.TreasureLocation; import net.sf.gridarta.treasurelist.TreasureTreeNode; +import net.sf.japi.io.args.ArgParser; import net.sf.japi.swing.ActionFactory; import net.sf.japi.swing.ActionMethod; import net.sf.japi.swing.prefs.PreferencesGroup; @@ -372,12 +374,12 @@ /** {@inheritDoc} */ @NotNull @Override - protected DelegatingMapValidator<GameObject, MapArchObject, Archetype> createMapValidators(@NotNull final GlobalSettings globalSettings, @NotNull final GameObjectMatchers gameObjectMatchers) { + protected DelegatingMapValidator<GameObject, MapArchObject, Archetype> createMapValidators(@NotNull final ErrorViewCollector errorViewCollector, @NotNull final GlobalSettings globalSettings, @NotNull final GameObjectMatchers gameObjectMatchers) { final DelegatingMapValidator<GameObject, MapArchObject, Archetype> mapValidators = new DelegatingMapValidator<GameObject, MapArchObject, Archetype>(); final CustomTypeChecker<GameObject, MapArchObject, Archetype> customTypeChecker = new CustomTypeChecker<GameObject, MapArchObject, Archetype>(); customTypeChecker.addIgnore(Archetype.TYPE_MOB, Archetype.TYPE_SPAWN_POINT_MOB, Archetype.TYPE_SPAWN_POINT); final SlayingChecker<GameObject, MapArchObject, Archetype> slayingChecker = new SlayingChecker<GameObject, MapArchObject, Archetype>(Pattern.compile("^[a-zA-Z_0-9/.]*$")); - final GameObjectMatcher environmentSensorMatcher = gameObjectMatchers.getMatcherFatal("system_environment_sensor"); + final GameObjectMatcher environmentSensorMatcher = gameObjectMatchers.getMatcherFatal(errorViewCollector, "system_environment_sensor"); slayingChecker.addMatcher(environmentSensorMatcher, Pattern.compile("|([0-1][0-9]|2[0-3]):[0-5][0-9]-([0-1][0-9]|2[0-3]):[0-5][0-9]")); mapValidators.add( new BlockedSpawnPointChecker<GameObject, MapArchObject, Archetype>(Archetype.TYPE_SPAWN_POINT), Modified: trunk/src/app/net/sf/gridarta/AbstractMainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2008-11-09 11:27:45 UTC (rev 5680) +++ trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2008-11-09 14:27:16 UTC (rev 5681) @@ -82,6 +82,8 @@ import net.sf.gridarta.gui.archetypechooser.ArchetypeChooserControl; import net.sf.gridarta.gui.archetypechooser.ArchetypeChooserModel; import net.sf.gridarta.gui.connectionview.LockedItemsControl; +import net.sf.gridarta.gui.errorview.DefaultErrorView; +import net.sf.gridarta.gui.errorview.ErrorViewCollector; import net.sf.gridarta.gui.gameobjectattributesdialog.GameObjectAttributesDialogFactory; import net.sf.gridarta.gui.gameobjectattributespanel.GameObjectAttributesControl; import net.sf.gridarta.gui.gameobjectattributespanel.GameObjectAttributesModel; @@ -385,19 +387,21 @@ ScriptEditControlInstance.init(scriptFileFilter, scriptExtension, mainView, new File(globalSettings.getMapsDirectory()), Preferences.userNodeForPackage(MainControl.class)); final XmlHelper xmlHelper; try { - xmlHelper = new XmlHelper(mainView); + xmlHelper = new XmlHelper(); } catch (final ParserConfigurationException ex) { log.error("Cannot create XML parser: " + ex.getMessage()); throw new MissingResourceException("Cannot create XML parser: " + ex.getMessage(), null, null); } + final DefaultErrorView errorView = new DefaultErrorView(mainView); + final ErrorViewCollector gameObjectMatchersErrorViewCollector = new ErrorViewCollector(errorView, "GameObjectMatchers.xml"); final GameObjectMatchers gameObjectMatchers = new GameObjectMatchers(xmlHelper.getDocumentBuilder(), xmlHelper.getXPath()); try { final String filename = IOUtils.getResourceURLAsString(globalSettings.getConfigurationDirectory(), "GameObjectMatchers.xml"); - gameObjectMatchers.readGameObjectMatchers(filename); + gameObjectMatchers.readGameObjectMatchers(filename, gameObjectMatchersErrorViewCollector); } catch (final IOException ex) { - log.error("Cannot read GameObjectMatchers.xml: " + ex.getMessage()); + gameObjectMatchersErrorViewCollector.addWarning("cannot read file: " + ex.getMessage()); } - validators = createMapValidators(globalSettings, gameObjectMatchers); + validators = createMapValidators(gameObjectMatchersErrorViewCollector, globalSettings, gameObjectMatchers); final List<Collectable> collectables = new ArrayList<Collectable>(); collectables.add(archetypeSet); final AnimationObjects animationObjects = new DefaultAnimationObjects(animationObjectsFilename); @@ -407,11 +411,25 @@ mainActions = new MainActions<G, A, R, V>(replaceDialogManager, this, mainView, globalSettings, validators, editTypes, archetypeSet, copyBuffer, ACTION_FACTORY, objectChooser, mapManager, mapViewManager, collectables); final GameObjectMatcher floorMatcher = gameObjectMatchers.getMatcher("system_floor", "floor"); final GameObjectMatcher wallMatcher = gameObjectMatchers.getMatcher("system_wall", "wall"); - final GameObjectMatcher monsterMatcher = gameObjectMatchers.getMatcherFatal("system_monster", "monster"); - final GameObjectMatcher belowFloorMatcher = gameObjectMatchers.getMatcherWarn("system_below_floor", "below_floor"); + final GameObjectMatcher monsterMatcher; + try { + monsterMatcher = gameObjectMatchers.getMatcherFatal(gameObjectMatchersErrorViewCollector, "system_monster", "monster"); + } catch (final MissingResourceException ex) { + waitDialog(errorView); + System.exit(1); + throw new AssertionError(); + } + final GameObjectMatcher belowFloorMatcher = gameObjectMatchers.getMatcherWarn(gameObjectMatchersErrorViewCollector, "system_below_floor", "below_floor"); DeletionTool.init(floorMatcher, wallMatcher, monsterMatcher); InsertionMode.init(floorMatcher, wallMatcher, belowFloorMatcher); - final GameObjectMatcher exitMatcher = gameObjectMatchers.getMatcherFatal("system_exit", "exit"); + final GameObjectMatcher exitMatcher; + try { + exitMatcher = gameObjectMatchers.getMatcherFatal(gameObjectMatchersErrorViewCollector, "system_exit", "exit"); + } catch (final MissingResourceException ex) { + waitDialog(errorView); + System.exit(1); + throw new AssertionError(); + } final ScriptArchUtils scriptArchUtils = newScriptArchUtils(); final MapViewSettings mapViewSettings = new MapViewSettings(); final MapActions mapActions = init1(mapViewSettings, mapArchObjectParserFactory, mapArchObjectFactory, globalSettings, mapManager, mapViewManager, selectedSquareView, exitMatcher); @@ -507,8 +525,28 @@ fileControl = new FileControl<G, A, R, V>(globalSettings, archetypeSet, mapPreviewAccessory, mapManager, mainView, mapFileFilter, scriptFileFilter, newMapDialogFactory, scriptExtension); mapFileActions.setFileControl(fileControl); tmpMapManager.setFileControl(fileControl); + if (errorView.hasErrors() || errorView.hasWarnings()) { + waitDialog(errorView); + if (errorView.hasErrors()) { + System.exit(1); + throw new AssertionError(); + } + } } + /** + * Waits until the error dialog has been dismissed. + * @param errorView the error view instance + */ + private static void waitDialog(final DefaultErrorView errorView) { + try { + errorView.waitDialog(); + } catch (final InterruptedException ex) { + System.exit(1); + throw new AssertionError(); + } + } + @NotNull protected abstract FaceObjects createFaceObjects(); @@ -581,7 +619,7 @@ * @return A MapValidator that delegates to other map validators. */ @NotNull - protected abstract DelegatingMapValidator<G, A, R> createMapValidators(@NotNull final GlobalSettings globalSettings, @NotNull final GameObjectMatchers gameObjectMatchers); + protected abstract DelegatingMapValidator<G, A, R> createMapValidators(@NotNull final ErrorViewCollector errorViewCollector, @NotNull final GlobalSettings globalSettings, @NotNull final GameObjectMatchers gameObjectMatchers); /** * Creates a new {@link NewMapDialogFactory} instance. Modified: trunk/src/app/net/sf/gridarta/gameobject/match/GameObjectMatcherParser.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/match/GameObjectMatcherParser.java 2008-11-09 11:27:45 UTC (rev 5680) +++ trunk/src/app/net/sf/gridarta/gameobject/match/GameObjectMatcherParser.java 2008-11-09 14:27:16 UTC (rev 5681) @@ -58,12 +58,13 @@ * @param el the XML node to create from * @param editType the edit type for the new matcher * @return the created matcher + * @throws ParsingException if a parsing error occurs */ - public NamedGameObjectMatcher parseMatcher(final Element el, final int editType) { + public NamedGameObjectMatcher parseMatcher(final Element el, final int editType) throws ParsingException { final String currentLanguage = Locale.getDefault().getLanguage(); final String localName = el.getLocalName(); if (!"GameObjectMatcher".equals(localName)) { - throw new IllegalArgumentException("Wrong local element name: expected \"GameObjectMatcher\" but got \" + localName + \""); + throw new ParsingException("wrong local element name: expected \"GameObjectMatcher\" but got \" + localName + \""); } final String id = el.getAttribute("id"); String title = getLanguageTitle(el, currentLanguage); @@ -104,8 +105,9 @@ * Creates a {@link GameObjectMatcher} from XML. * @param el the XML node to create from * @return the created matcher + * @throws ParsingException if a parsing error occurs */ - private static GameObjectMatcher createMatcher(final Element el) { + private static GameObjectMatcher createMatcher(final Element el) throws ParsingException { final String localName = el.getLocalName(); if ("TypeNrs".equals(localName)) { return createTypeNrsArchObjectMatcher(el); @@ -116,15 +118,16 @@ } else if ("And".equals(localName)) { return createAndMatcher(el); } - throw new IllegalArgumentException("Expected Element node name to be one of \"TypeNrs\", \"Attrib\", \"Or\", \"And\"."); + throw new ParsingException("expected element node name to be one of \"TypeNrs\", \"Attrib\", \"Or\", \"And\"."); } /** * Creates an {@link AndGameObjectMatcher}. * @param el <code><And/></code> xml element with matchers to and * @return the created matcher + * @throws ParsingException if a parsing error occurs */ - private static AndGameObjectMatcher createAndMatcher(final Element el) { + private static AndGameObjectMatcher createAndMatcher(final Element el) throws ParsingException { return new AndGameObjectMatcher(getChildMatchers(el)); } @@ -132,8 +135,9 @@ * Creates an {@link OrGameObjectMatcher}. * @param el <code><Or/></code> xml element with matchers to or * @return the created matcher + * @throws ParsingException if a parsing error occurs */ - private static OrGameObjectMatcher createOrMatcher(final Element el) { + private static OrGameObjectMatcher createOrMatcher(final Element el) throws ParsingException { return new OrGameObjectMatcher(getChildMatchers(el)); } @@ -144,8 +148,9 @@ * @param el the XML element to look for children * @return a <code>Collection</code> with <code>GameObjectMatcher</code>s * that are the children of <code>el</code> + * @throws ParsingException if a parsing error occurs */ - private static Collection<GameObjectMatcher> getChildMatchers(final Element el) { + private static Collection<GameObjectMatcher> getChildMatchers(final Element el) throws ParsingException { final List<GameObjectMatcher> childMatchers = new ArrayList<GameObjectMatcher>(); final NodeList childNodes = el.getChildNodes(); for (int i = 0; i < childNodes.getLength(); i++) { @@ -175,13 +180,18 @@ * Creates a {@link TypeNrsGameObjectMatcher}. * @param el <code><TypeNrs/></code> xml element * @return the created matcher + * @throws ParsingException if a parsing error occurs */ - private static TypeNrsGameObjectMatcher createTypeNrsArchObjectMatcher(final Element el) { + private static TypeNrsGameObjectMatcher createTypeNrsArchObjectMatcher(final Element el) throws ParsingException { final String numbers = el.getAttribute("numbers"); final String[] typeNrs = patternSpaces.split(numbers, 0); final int[] types = new int[typeNrs.length]; for (int i = 0; i < types.length; i++) { - types[i] = Integer.parseInt(typeNrs[i]); // XXX: handle NumberFormatException + try { + types[i] = Integer.parseInt(typeNrs[i]); + } catch (final NumberFormatException ex) { + throw new ParsingException("invalid number: " + typeNrs[i]); + } } return new TypeNrsGameObjectMatcher(types); } Modified: trunk/src/app/net/sf/gridarta/gameobject/match/GameObjectMatchers.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/match/GameObjectMatchers.java 2008-11-09 11:27:45 UTC (rev 5680) +++ trunk/src/app/net/sf/gridarta/gameobject/match/GameObjectMatchers.java 2008-11-09 14:27:16 UTC (rev 5681) @@ -31,6 +31,7 @@ import javax.xml.parsers.DocumentBuilder; import javax.xml.xpath.XPath; import net.sf.gridarta.gameobject.GameObject; +import net.sf.gridarta.gui.errorview.ErrorViewCollector; import org.apache.log4j.Logger; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -73,10 +74,11 @@ /** * Parses a .xml file defining game object matchers. * @param filename the file to parse + * @param errorViewCollector the error view collector to use * @throws IOException if the file cannot be parsed */ - public void readGameObjectMatchers(@NotNull final String filename) throws IOException { - new GameObjectMatchersParser(documentBuilder, xpath).readGameObjectMatchers(filename, gameObjectMatchers, gameObjectMatchersByIds); + public void readGameObjectMatchers(@NotNull final String filename, @NotNull final ErrorViewCollector errorViewCollector) throws IOException { + new GameObjectMatchersParser(documentBuilder, xpath).readGameObjectMatchers(filename, gameObjectMatchers, gameObjectMatchersByIds, errorViewCollector); } /** @@ -98,14 +100,15 @@ /** * Returns a matcher by id; prints a warning if the matcher does not exist. + * @param errorViewCollector the error view collector to use * @param ids the ids to find * @return the matcher, or <code>null</code> if no such matcher exists */ @Nullable - public NamedGameObjectMatcher getMatcherWarn(@NotNull final String... ids) { + public NamedGameObjectMatcher getMatcherWarn(@NotNull final ErrorViewCollector errorViewCollector, @NotNull final String... ids) { final NamedGameObjectMatcher matcher = getMatcher(ids); if (matcher == null) { - log.warn("GameObjectMatcher '" + ids[0] + "' does not exist"); + errorViewCollector.addWarning("GameObjectMatcher '" + ids[0] + "' does not exist"); } return matcher; } @@ -113,15 +116,16 @@ /** * Returns a matcher by id; thows an exception if the matcher does not * exist. + * @param errorViewCollector the error view collector to use * @param ids the ids to find * @return the matcher * @throws MissingResourceException if the matcher does not exist */ @NotNull - public NamedGameObjectMatcher getMatcherFatal(@NotNull final String... ids) { + public NamedGameObjectMatcher getMatcherFatal(@NotNull final ErrorViewCollector errorViewCollector, @NotNull final String... ids) { final NamedGameObjectMatcher matcher = getMatcher(ids); if (matcher == null) { - log.fatal("GameObjectMatcher '" + ids[0] + "' does not exist"); + errorViewCollector.addError("GameObjectMatcher '" + ids[0] + "' does not exist"); throw new MissingResourceException("GameObjectMatcher '" + ids[0] + "' does not exist", null, null); } return matcher; Modified: trunk/src/app/net/sf/gridarta/gameobject/match/GameObjectMatchersParser.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/match/GameObjectMatchersParser.java 2008-11-09 11:27:45 UTC (rev 5680) +++ trunk/src/app/net/sf/gridarta/gameobject/match/GameObjectMatchersParser.java 2008-11-09 14:27:16 UTC (rev 5681) @@ -24,6 +24,7 @@ import java.util.Map; import javax.xml.parsers.DocumentBuilder; import javax.xml.xpath.XPath; +import net.sf.gridarta.gui.errorview.ErrorViewCollector; import net.sf.japi.xml.NodeListIterator; import org.apache.log4j.Logger; import org.jetbrains.annotations.NotNull; @@ -63,9 +64,10 @@ * @param gameObjectMatchers the game object matchers to update * @param gameObjectMatchersByIds the numbered game object matchers to * update + * @param errorViewCollector the error view collector to use * @throws IOException if the file cannot be parsed */ - public void readGameObjectMatchers(@NotNull final String filename, @NotNull final List<NamedGameObjectMatcher> gameObjectMatchers, @NotNull final Map<String, NamedGameObjectMatcher> gameObjectMatchersByIds) throws IOException { + public void readGameObjectMatchers(@NotNull final String filename, @NotNull final List<NamedGameObjectMatcher> gameObjectMatchers, @NotNull final Map<String, NamedGameObjectMatcher> gameObjectMatchersByIds, @NotNull final ErrorViewCollector errorViewCollector) throws IOException { final GameObjectMatcherParser aom = new GameObjectMatcherParser(xpath); final Document doc; try { @@ -75,7 +77,13 @@ } int editType = 1; for (final Element node : new NodeListIterator<Element>(doc.getElementsByTagName("GameObjectMatcher"))) { - final NamedGameObjectMatcher archObjectMatcher = aom.parseMatcher(node, editType); + final NamedGameObjectMatcher archObjectMatcher; + try { + archObjectMatcher = aom.parseMatcher(node, editType); + } catch (final ParsingException ex) { + errorViewCollector.addError(node.getAttribute("id") + ": " + ex.getMessage()); + continue; + } gameObjectMatchers.add(archObjectMatcher); if (archObjectMatcher.getID() != null) { gameObjectMatchersByIds.put(archObjectMatcher.getID(), archObjectMatcher); @@ -83,7 +91,7 @@ if (editType != 0 && !archObjectMatcher.isSystemMatcher()) { editType <<= 1; if (editType == 0) { - log.warn("Too many GameObjectMatchers, ignoring rest"); + errorViewCollector.addWarning("too many GameObjectMatchers, ignoring rest"); } } } Added: trunk/src/app/net/sf/gridarta/gameobject/match/ParsingException.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/match/ParsingException.java (rev 0) +++ trunk/src/app/net/sf/gridarta/gameobject/match/ParsingException.java 2008-11-09 14:27:16 UTC (rev 5681) @@ -0,0 +1,43 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2007 The Gridarta Developers. + * + * 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 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 program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package net.sf.gridarta.gameobject.match; + +import org.jetbrains.annotations.NotNull; + +/** + * Thrown when a parsing error occurs. + * @author Andreas Kirschbaum + */ +public class ParsingException extends Exception { + + /** + * The serial version UID. + */ + private static final long serialVersionUID = 1; + + /** + * Creates a new instance. + * @param parsingError the parsing error + */ + public ParsingException(@NotNull final String parsingError) { + super(parsingError); + } + +} // class ParsingException Property changes on: trunk/src/app/net/sf/gridarta/gameobject/match/ParsingException.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF Added: trunk/src/app/net/sf/gridarta/gui/errorview/DefaultErrorView.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/errorview/DefaultErrorView.java (rev 0) +++ trunk/src/app/net/sf/gridarta/gui/errorview/DefaultErrorView.java 2008-11-09 14:27:16 UTC (rev 5681) @@ -0,0 +1,214 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2007 The Gridarta Developers. + * + * 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 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 program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package net.sf.gridarta.gui.errorview; + +import java.awt.Component; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import javax.swing.JDialog; +import javax.swing.JOptionPane; +import javax.swing.JScrollPane; +import javax.swing.JTree; +import javax.swing.tree.TreePath; +import net.sf.gridarta.data.AbstractNamedObjects; +import net.sf.gridarta.data.NamedNodeTreeCellRenderer; +import net.sf.gridarta.data.NamedObject; +import net.sf.gridarta.data.NamedTreeNode; +import net.sf.japi.swing.ActionFactory; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * A dialog displaying a tree of error messages. + * @author Andreas Kirschbaum + */ +public class DefaultErrorView extends AbstractNamedObjects<ErrorEntry> { + + /** Action Factory. */ + private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("net.sf.gridarta"); + + /** + * The parent component for showing the error dialog. + */ + @NotNull + private final Component parent; + + /** + * Whether at least one error message has been added. + */ + private boolean errors = false; + + /** + * Whether at least one warning message has been added. + */ + private boolean warnings = false; + + /** + * A counter for creating unique key names. + */ + private int counter = 0; + + /** + * The dialog instance. Set to <code>null</code> until created. + */ + @Nullable + private JDialog dialog; + + /** + * The synchronization object used to access {@link #dialog}. + */ + @NotNull + private final Object dialogSync = new Object(); + + /** + * Creates a new instance. + * @param parent the parent component for showing the error dialog + */ + public DefaultErrorView(@NotNull final Component parent) { + super(ACTION_FACTORY.getString("errorViewTitle")); + this.parent = parent; + } + + /** + * Adds an error message. + * @param category the error category + * @param message the error message + */ + public void addError(@NotNull final String category, @NotNull final String message) { + final String key = "/" + category + "/" + String.format("%05d", counter++); + put(new ErrorEntry(key, message)); + showDialog(key); + errors = true; + } + + /** + * Adds a warning message. + * @param category the warning category + * @param message the warning message + */ + public void addWarning(@NotNull final String category, @NotNull final String message) { + final String key = "/" + category + "/" + String.format("%05d", counter++); + put(new ErrorEntry(key, "Warning: " + message)); + showDialog(key); + warnings = true; + } + + /** + * Whether at least one error message has been added. + * @return whether error exist + */ + public boolean hasErrors() { + return errors; + } + + /** + * Whether at least one warning message has been added. + * @return whether error exist + */ + public boolean hasWarnings() { + return warnings; + } + + /** + * Shows a dialog showing the object tree. Returns after the dialog has + * been dismissed. + * @param key the key to open + */ + private void showDialog(@NotNull final String key) { + synchronized (dialogSync) { + if (dialog == null) { + showDialog(parent, key); + } + } + } + + /** + * Shows a dialog showing the object tree. Returns after the dialog has + * been created. + * @param parentComponent parent component to show dialog on + * @param initial initially selected node name + */ + private void showDialog(@NotNull final Component parentComponent, @NotNull final String initial) { + final NamedObject initialObject = get(initial); + final String initialPath = initialObject != null ? initialObject.getPath() : initial; + final JTree tree = new JTree(getTreeRoot()); + tree.setCellRenderer(new NamedNodeTreeCellRenderer()); + final JScrollPane scroller = new JScrollPane(tree); + tree.setExpandsSelectedPaths(true); + final TreePath path = getTreeRoot().getPathFor(initialPath); + tree.makeVisible(path); + tree.setSelectionPath(path); + tree.scrollPathToVisible(path); + final JOptionPane pane = new JOptionPane(scroller, JOptionPane.PLAIN_MESSAGE, JOptionPane.DEFAULT_OPTION, null, null, null) { + + /** The serial version UID. */ + private static final long serialVersionUID = 1; + + /** {@inheritDoc} */ + @Override + public void setValue(final Object newValue) { + super.setValue(newValue); + if (newValue != UNINITIALIZED_VALUE) { + synchronized (dialogSync) { + if (dialog != null) { + dialog.dispose(); + dialog = null; + dialogSync.notifyAll(); + } + } + } + } + + }; + dialog = pane.createDialog(parentComponent, ACTION_FACTORY.getString("errorViewTitle")); + pane.selectInitialValue(); + tree.addMouseListener(new MouseAdapter() { + @Override + public void mousePressed(final MouseEvent e) { + if (e.getClickCount() == 2) { + final TreePath selPath = tree.getPathForLocation(e.getX(), e.getY()); + if (selPath != null) { + final NamedTreeNode<?> node = (NamedTreeNode<?>) selPath.getLastPathComponent(); + if (node.isLeaf()) { + pane.setValue(0); + } + } + } + } + }); + dialog.pack(); + dialog.setModal(false); + dialog.setVisible(true); + } + + /** + * Waits until the dialog has been dismissed. + * @throws InterruptedException if the current thread has been interrupted + * while waiting for the dialog to close + */ + public void waitDialog() throws InterruptedException { + synchronized (dialogSync) { + if (dialog != null) { + dialogSync.wait(); + } + } + } + +} // class DefaultFaceObjects Property changes on: trunk/src/app/net/sf/gridarta/gui/errorview/DefaultErrorView.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF Added: trunk/src/app/net/sf/gridarta/gui/errorview/ErrorEntry.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/errorview/ErrorEntry.java (rev 0) +++ trunk/src/app/net/sf/gridarta/gui/errorview/ErrorEntry.java 2008-11-09 14:27:16 UTC (rev 5681) @@ -0,0 +1,66 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2007 The Gridarta Developers. + * + * 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 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 program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package net.sf.gridarta.gui.errorview; + +import javax.swing.ImageIcon; +import net.sf.gridarta.data.AbstractNamedObject; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * An entry in a {@link DefaultErrorView}. + * @author Andreas Kirschbaum + */ +public class ErrorEntry extends AbstractNamedObject { + + /** + * The serial version UID. + */ + private static final long serialVersionUID = 1; + + /** + * The error message. + */ + @NotNull + private final String errorMessage; + + /** + * Creates a new instance. + * @param path the path name + * @param errorMessage the error message + */ + protected ErrorEntry(@NotNull final String path, @NotNull final String errorMessage) { + super(path); + this.errorMessage = errorMessage; + } + + /** {@inheritDoc} */ + @NotNull + public String getName() { + return errorMessage; + } + + /** {@inheritDoc} */ + @Nullable + public ImageIcon getDisplayIcon() { + return null; + } + +} // class ErrorEntry Property changes on: trunk/src/app/net/sf/gridarta/gui/errorview/ErrorEntry.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF Added: trunk/src/app/net/sf/gridarta/gui/errorview/ErrorViewCollector.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/errorview/ErrorViewCollector.java (rev 0) +++ trunk/src/app/net/sf/gridarta/gui/errorview/ErrorViewCollector.java 2008-11-09 14:27:16 UTC (rev 5681) @@ -0,0 +1,69 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2007 The Gridarta Developers. + * + * 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 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 program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package net.sf.gridarta.gui.errorview; + +import org.jetbrains.annotations.NotNull; + +/** + * Convenience class for adding messages to a {@link DefaultErrorView} instance + * using a fixed category name. + * @author Andreas Kirschbaum + */ +public class ErrorViewCollector { + + /** + * The {@link DefaultErrorView} to add to. + */ + @NotNull + private final DefaultErrorView errorView; + + /** + * The category name for error messages. + */ + @NotNull + private final String category; + + /** + * Creates a new instance. + * @param errorView the error view to add to + * @param category the category name for error messages + */ + public ErrorViewCollector(@NotNull final DefaultErrorView errorView, @NotNull final String category) { + this.errorView = errorView; + this.category = category; + } + + /** + * Adds a warning message. + * @param message the message + */ + public void addWarning(@NotNull final String message) { + errorView.addWarning(category, message); + } + + /** + * Adds an error message. + * @param message the message + */ + public void addError(@NotNull final String message) { + errorView.addError(category, message); + } + +} // class ErrorViewCollector Property changes on: trunk/src/app/net/sf/gridarta/gui/errorview/ErrorViewCollector.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF Modified: trunk/src/app/net/sf/gridarta/messages.properties =================================================================== --- trunk/src/app/net/sf/gridarta/messages.properties 2008-11-09 11:27:45 UTC (rev 5680) +++ trunk/src/app/net/sf/gridarta/messages.properties 2008-11-09 14:27:16 UTC (rev 5681) @@ -1275,3 +1275,9 @@ pluginConfirmSaveChanges.title=Save changes? pluginConfirmSaveChanges.message=Do you want to save changes to plugin {0}? + + +############ +# Error View + +errorViewTitle=Errors Modified: trunk/src/app/net/sf/gridarta/messages_de.properties =================================================================== --- trunk/src/app/net/sf/gridarta/messages_de.properties 2008-11-09 11:27:45 UTC (rev 5680) +++ trunk/src/app/net/sf/gridarta/messages_de.properties 2008-11-09 14:27:16 UTC (rev 5681) @@ -1115,3 +1115,9 @@ pluginConfirmSaveChanges.title=\xC4nderungen sichern? pluginConfirmSaveChanges.message=Wollen Sie die \xC4nderungen des Plugins {0} sichern? + + +############ +# Error View + +errorViewTitle=Fehler Modified: trunk/src/app/net/sf/gridarta/messages_fr.properties =================================================================== --- trunk/src/app/net/sf/gridarta/messages_fr.properties 2008-11-09 11:27:45 UTC (rev 5680) +++ trunk/src/app/net/sf/gridarta/messages_fr.properties 2008-11-09 14:27:16 UTC (rev 5681) @@ -1111,3 +1111,9 @@ #pluginConfirmSaveChanges.title=\xC4nderungen sichern? #pluginConfirmSaveChanges.message= + + +############ +# Error View + +#errorViewTitle= Modified: trunk/src/app/net/sf/gridarta/messages_sv.properties =================================================================== --- trunk/src/app/net/sf/gridarta/messages_sv.properties 2008-11-09 11:27:45 UTC (rev 5680) +++ trunk/src/app/net/sf/gridarta/messages_sv.properties 2008-11-09 14:27:16 UTC (rev 5681) @@ -1115,3 +1115,9 @@ pluginConfirmSaveChanges.title=Spara \xE4ndringar? #pluginConfirmSaveChanges.message= + + +############ +# Error View + +#errorViewTitle= Modified: trunk/src/app/net/sf/gridarta/utils/XmlHelper.java =================================================================== --- trunk/src/app/net/sf/gridarta/utils/XmlHelper.java 2008-11-09 11:27:45 UTC (rev 5680) +++ trunk/src/app/net/sf/gridarta/utils/XmlHelper.java 2008-11-09 14:27:16 UTC (rev 5681) @@ -19,15 +19,12 @@ package net.sf.gridarta.utils; -import java.awt.Component; import java.io.IOException; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import javax.xml.xpath.XPath; import javax.xml.xpath.XPathFactory; -import net.sf.japi.swing.misc.JSAXErrorHandler; -import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.xml.sax.EntityResolver; import org.xml.sax.InputSource; @@ -47,12 +44,10 @@ /** * Initialize the XML engine. - * @param viewToBlock View to block for the {@link JSAXErrorHandler} that - * shows a GUI for XML errors. * @throws ParserConfigurationException in case the xml parser couldn't be * set up */ - public XmlHelper(@NotNull final Component viewToBlock) throws ParserConfigurationException { + public XmlHelper() throws ParserConfigurationException { // TODO: Change hard coded document builder factory to user configurable settings final DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setCoalescing(true); @@ -63,7 +58,6 @@ dbf.setValidating(true); dbf.setXIncludeAware(true); documentBuilder = dbf.newDocumentBuilder(); - documentBuilder.setErrorHandler(new JSAXErrorHandler(viewToBlock)); documentBuilder.setEntityResolver(new GridartaEntityResolver()); xpath = XPathFactory.newInstance().newXPath(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-11-09 15:12:19
|
Revision: 5682 http://gridarta.svn.sourceforge.net/gridarta/?rev=5682&view=rev Author: akirschbaum Date: 2008-11-09 15:12:15 +0000 (Sun, 09 Nov 2008) Log Message: ----------- Implement #1627422 (Check box option to avoid startup warnings) for TreasureLists.xml related errors. Modified Paths: -------------- trunk/crossfire/ChangeLog trunk/daimonin/ChangeLog trunk/src/app/net/sf/gridarta/AbstractMainControl.java Modified: trunk/crossfire/ChangeLog =================================================================== --- trunk/crossfire/ChangeLog 2008-11-09 14:27:16 UTC (rev 5681) +++ trunk/crossfire/ChangeLog 2008-11-09 15:12:15 UTC (rev 5682) @@ -2,8 +2,8 @@ * Partially implement #1627422 (Check box option to avoid startup warnings): add an error dialog box for collecting all error - messages in a single dialog. Use it for GameObjectMatchers.xml - related errors. + messages in a single dialog. Use it for GameObjectMatchers.xml and + TreasureLists.xml related errors. 2008-11-06 Andreas Kirschbaum Modified: trunk/daimonin/ChangeLog =================================================================== --- trunk/daimonin/ChangeLog 2008-11-09 14:27:16 UTC (rev 5681) +++ trunk/daimonin/ChangeLog 2008-11-09 15:12:15 UTC (rev 5682) @@ -1,9 +1,9 @@ 2008-11-09 Andreas Kirschbaum * Partially implement #1627422 (Check box option to avoid startup - warnings): add an error dialog box for collecting error messages - in a single dialog. Use it for GameObjectMatchers.xml related - errors. + warnings): add an error dialog box for collecting all error + messages in a single dialog. Use it for GameObjectMatchers.xml and + TreasureLists.xml related errors. 2008-11-06 Andreas Kirschbaum Modified: trunk/src/app/net/sf/gridarta/AbstractMainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2008-11-09 14:27:16 UTC (rev 5681) +++ trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2008-11-09 15:12:15 UTC (rev 5682) @@ -433,15 +433,16 @@ final ScriptArchUtils scriptArchUtils = newScriptArchUtils(); final MapViewSettings mapViewSettings = new MapViewSettings(); final MapActions mapActions = init1(mapViewSettings, mapArchObjectParserFactory, mapArchObjectFactory, globalSettings, mapManager, mapViewManager, selectedSquareView, exitMatcher); + final ErrorViewCollector treasureListsErrorViewCollector = new ErrorViewCollector(errorView, "TreasureLists.xml"); Map<String, TreasureTreeNode> specialTreasureLists; try { final Document specialTreasureListsDocument = xmlHelper.getDocumentBuilder().parse(IOUtils.getResourceURLAsString(globalSettings.getConfigurationDirectory(), "TreasureLists.xml")); specialTreasureLists = TreasureListsParser.parseTreasureLists(specialTreasureListsDocument); } catch (final IOException ex) { - log.warn("Cannot read TreasureLists.xml: " + ex.getMessage()); + treasureListsErrorViewCollector.addWarning("cannot read file: " + ex.getMessage()); specialTreasureLists = Collections.emptyMap(); } catch (final SAXException ex) { - log.warn("Cannot read TreasureLists.xml: " + ex.getMessage()); + treasureListsErrorViewCollector.addWarning("cannot parse file: " + ex.getMessage()); specialTreasureLists = Collections.emptyMap(); } final CFTreasureListTree<G, A, R> treasureListTree = createTreasureListTree(globalSettings, archetypeSet, specialTreasureLists); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-11-09 21:57:07
|
Revision: 5705 http://gridarta.svn.sourceforge.net/gridarta/?rev=5705&view=rev Author: akirschbaum Date: 2008-11-09 21:44:49 +0000 (Sun, 09 Nov 2008) Log Message: ----------- Order import statements. Modified Paths: -------------- trunk/daimonin/src/daieditor/gameobject/ArchetypeSetLoader.java trunk/src/app/net/sf/gridarta/map/MapControlFactory.java trunk/src/app/net/sf/gridarta/map/validation/checks/DoubleLayerChecker.java trunk/src/app/net/sf/gridarta/map/validation/checks/DoubleTypeChecker.java trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java Modified: trunk/daimonin/src/daieditor/gameobject/ArchetypeSetLoader.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/ArchetypeSetLoader.java 2008-11-09 21:43:06 UTC (rev 5704) +++ trunk/daimonin/src/daieditor/gameobject/ArchetypeSetLoader.java 2008-11-09 21:44:49 UTC (rev 5705) @@ -37,7 +37,6 @@ import net.sf.gridarta.gameobject.AbstractArchetypeParser; import net.sf.gridarta.gameobject.AbstractArchetypeSetLoader; import net.sf.gridarta.gameobject.ArchetypeSet; -import net.sf.gridarta.gameobject.anim.AnimationObject; import net.sf.gridarta.gameobject.anim.AnimationObjects; import net.sf.gridarta.gameobject.anim.AnimationParseException; import net.sf.gridarta.gameobject.anim.DuplicateAnimationException; Modified: trunk/src/app/net/sf/gridarta/map/MapControlFactory.java =================================================================== --- trunk/src/app/net/sf/gridarta/map/MapControlFactory.java 2008-11-09 21:43:06 UTC (rev 5704) +++ trunk/src/app/net/sf/gridarta/map/MapControlFactory.java 2008-11-09 21:44:49 UTC (rev 5705) @@ -23,9 +23,9 @@ import java.io.File; import java.io.IOException; import java.util.List; +import net.sf.gridarta.EditTypes; import net.sf.gridarta.MapImageCache; import net.sf.gridarta.Size2D; -import net.sf.gridarta.EditTypes; import net.sf.gridarta.autojoin.AutojoinLists; import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.GameObject; Modified: trunk/src/app/net/sf/gridarta/map/validation/checks/DoubleLayerChecker.java =================================================================== --- trunk/src/app/net/sf/gridarta/map/validation/checks/DoubleLayerChecker.java 2008-11-09 21:43:06 UTC (rev 5704) +++ trunk/src/app/net/sf/gridarta/map/validation/checks/DoubleLayerChecker.java 2008-11-09 21:44:49 UTC (rev 5705) @@ -27,7 +27,6 @@ import net.sf.gridarta.map.MapSquare; import net.sf.gridarta.map.validation.AbstractValidator; import net.sf.gridarta.map.validation.ErrorCollector; -import net.sf.gridarta.map.validation.GameObjectsValidationError; import net.sf.gridarta.map.validation.SquareValidator; /** Modified: trunk/src/app/net/sf/gridarta/map/validation/checks/DoubleTypeChecker.java =================================================================== --- trunk/src/app/net/sf/gridarta/map/validation/checks/DoubleTypeChecker.java 2008-11-09 21:43:06 UTC (rev 5704) +++ trunk/src/app/net/sf/gridarta/map/validation/checks/DoubleTypeChecker.java 2008-11-09 21:44:49 UTC (rev 5705) @@ -28,7 +28,6 @@ import net.sf.gridarta.map.validation.AbstractValidator; import net.sf.gridarta.map.validation.ErrorCollector; import net.sf.gridarta.map.validation.SquareValidator; -import net.sf.gridarta.map.validation.ValidationError; /** * A SquareValidator to assert that there are no two arches of the same type on Modified: trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java =================================================================== --- trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java 2008-11-09 21:43:06 UTC (rev 5704) +++ trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java 2008-11-09 21:44:49 UTC (rev 5705) @@ -33,12 +33,12 @@ import javax.swing.JList; import javax.swing.JPanel; import net.sf.gridarta.DefaultMapManager; +import net.sf.gridarta.EditTypes; import net.sf.gridarta.GlobalSettings; import net.sf.gridarta.GlobalSettingsImpl; import net.sf.gridarta.MapImageCache; import net.sf.gridarta.MapManager; import net.sf.gridarta.Size2D; -import net.sf.gridarta.EditTypes; import net.sf.gridarta.autojoin.AutojoinLists; import net.sf.gridarta.gameobject.AbstractArchetypeSet; import net.sf.gridarta.gameobject.Archetype; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-11-11 21:15:16
|
Revision: 5714 http://gridarta.svn.sourceforge.net/gridarta/?rev=5714&view=rev Author: akirschbaum Date: 2008-11-11 21:15:10 +0000 (Tue, 11 Nov 2008) Log Message: ----------- Partially implement #1627422 (Check box option to avoid startup warnings): Use it for "treasures" file related errors. Modified Paths: -------------- trunk/crossfire/ChangeLog trunk/crossfire/src/cfeditor/CMainControl.java trunk/daimonin/ChangeLog trunk/daimonin/src/daieditor/CMainControl.java trunk/src/app/net/sf/gridarta/AbstractMainControl.java trunk/src/app/net/sf/gridarta/treasurelist/CFTreasureListTree.java trunk/src/app/net/sf/gridarta/treasurelist/TreasureLoader.java Modified: trunk/crossfire/ChangeLog =================================================================== --- trunk/crossfire/ChangeLog 2008-11-11 21:01:43 UTC (rev 5713) +++ trunk/crossfire/ChangeLog 2008-11-11 21:15:10 UTC (rev 5714) @@ -1,3 +1,8 @@ +2008-11-11 Andreas Kirschbaum + + * Partially implement #1627422 (Check box option to avoid startup + warnings): Use it for "treasures" file related errors. + 2008-11-10 Andreas Kirschbaum * Improve map validator "Suspicious attribute value": check that Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-11-11 21:01:43 UTC (rev 5713) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-11-11 21:15:10 UTC (rev 5714) @@ -71,6 +71,7 @@ import net.sf.gridarta.gui.MainView; import net.sf.gridarta.gui.MapViewManager; import net.sf.gridarta.gui.archetypechooser.ArchetypeChooserControl; +import net.sf.gridarta.gui.errorview.DefaultErrorView; import net.sf.gridarta.gui.errorview.ErrorViewCollector; import net.sf.gridarta.gui.map.DefaultMapActions; import net.sf.gridarta.gui.map.MapActions; @@ -279,8 +280,8 @@ /** {@inheritDoc} */ @NotNull @Override - protected CFTreasureListTree<GameObject, MapArchObject, Archetype> createTreasureListTree(@NotNull final GlobalSettings globalSettings, @NotNull final net.sf.gridarta.gameobject.ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final Map<String, TreasureTreeNode> specialTreasureLists) { - return new CFTreasureListTree<GameObject, MapArchObject, Archetype>(getMainView(), archetypeSet, specialTreasureLists, + protected CFTreasureListTree<GameObject, MapArchObject, Archetype> createTreasureListTree(@NotNull final DefaultErrorView errorView, @NotNull final GlobalSettings globalSettings, @NotNull final net.sf.gridarta.gameobject.ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final Map<String, TreasureTreeNode> specialTreasureLists) { + return new CFTreasureListTree<GameObject, MapArchObject, Archetype>(errorView, getMainView(), archetypeSet, specialTreasureLists, new TreasureLocation(globalSettings.getCollectedDirectory(), IGUIConstants.TREASURES_FILE) ); } Modified: trunk/daimonin/ChangeLog =================================================================== --- trunk/daimonin/ChangeLog 2008-11-11 21:01:43 UTC (rev 5713) +++ trunk/daimonin/ChangeLog 2008-11-11 21:15:10 UTC (rev 5714) @@ -1,5 +1,10 @@ 2008-11-11 Andreas Kirschbaum + * Partially implement #1627422 (Check box option to avoid startup + warnings): Use it for "treasures" file related errors. + +2008-11-11 Andreas Kirschbaum + * Improve map validator "Suspicious attribute value": check that attacks>=0 and resistances<=100. Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-11-11 21:01:43 UTC (rev 5713) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-11-11 21:15:10 UTC (rev 5714) @@ -74,6 +74,7 @@ import net.sf.gridarta.gui.MainView; import net.sf.gridarta.gui.MapViewManager; import net.sf.gridarta.gui.archetypechooser.ArchetypeChooserControl; +import net.sf.gridarta.gui.errorview.DefaultErrorView; import net.sf.gridarta.gui.errorview.ErrorViewCollector; import net.sf.gridarta.gui.map.DefaultMapActions; import net.sf.gridarta.gui.map.MapActions; @@ -312,8 +313,8 @@ /** {@inheritDoc} */ @NotNull @Override - protected CFTreasureListTree<GameObject, MapArchObject, Archetype> createTreasureListTree(@NotNull final GlobalSettings globalSettings, @NotNull final net.sf.gridarta.gameobject.ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final Map<String, TreasureTreeNode> specialTreasureLists) { - return new CFTreasureListTree<GameObject, MapArchObject, Archetype>(getMainView(), archetypeSet, specialTreasureLists, + protected CFTreasureListTree<GameObject, MapArchObject, Archetype> createTreasureListTree(@NotNull final DefaultErrorView errorView, @NotNull final GlobalSettings globalSettings, @NotNull final net.sf.gridarta.gameobject.ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final Map<String, TreasureTreeNode> specialTreasureLists) { + return new CFTreasureListTree<GameObject, MapArchObject, Archetype>(errorView, getMainView(), archetypeSet, specialTreasureLists, new TreasureLocation(globalSettings.getCollectedDirectory(), IGUIConstants.TREASURES_FILE), new TreasureLocation(globalSettings.getMapsDirectory(), null) ); Modified: trunk/src/app/net/sf/gridarta/AbstractMainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2008-11-11 21:01:43 UTC (rev 5713) +++ trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2008-11-11 21:15:10 UTC (rev 5714) @@ -436,7 +436,7 @@ treasureListsErrorViewCollector.addWarning("cannot parse file: " + ex.getMessage()); specialTreasureLists = Collections.emptyMap(); } - final CFTreasureListTree<G, A, R> treasureListTree = createTreasureListTree(globalSettings, archetypeSet, specialTreasureLists); + final CFTreasureListTree<G, A, R> treasureListTree = createTreasureListTree(errorView, globalSettings, archetypeSet, specialTreasureLists); final ArchetypeAttributeParser<G, A, R> archetypeAttributeParser = new ArchetypeAttributeParser<G, A, R>(typeNoEventConnector, includeFaceText, globalSettings, mapFileFilter, scriptFileFilter, faceObjects, animationObjects, numberSpells, gameObjectSpells, undefinedSpellIndex, archetypeTypeSet, treasureListTree); final ArchetypeTypeParser<G, A, R> archetypeTypeParser = new ArchetypeTypeParser<G, A, R>(archetypeAttributeParser); final ArchetypeTypeSetParser<G, A, R> archetypeTypeSetParser = new ArchetypeTypeSetParser<G, A, R>(xmlHelper.getDocumentBuilder(), xmlHelper.getXPath(), archetypeTypeSet, archetypeTypeParser); @@ -595,7 +595,7 @@ protected abstract void createActions(); @NotNull - protected abstract CFTreasureListTree<G, A, R> createTreasureListTree(@NotNull final GlobalSettings globalSettings, @NotNull final ArchetypeSet<G, A, R> archetypeSet, @NotNull Map<String, TreasureTreeNode> specialTreasureLists); + protected abstract CFTreasureListTree<G, A, R> createTreasureListTree(@NotNull final DefaultErrorView errorView, @NotNull final GlobalSettings globalSettings, @NotNull final ArchetypeSet<G, A, R> archetypeSet, @NotNull Map<String, TreasureTreeNode> specialTreasureLists); @NotNull protected abstract MapActions init1(@NotNull final MapViewSettings mapViewSettings, @NotNull final MapArchObjectParserFactory<A> mapArchObjectParserFactory, @NotNull final MapArchObjectFactory<A> mapArchObjectFactory, @NotNull final GlobalSettings globalSettings, @NotNull final MapManager<G, A, R, V> mapManager, @NotNull final MapViewManager<G, A, R, V> mapViewManager, @NotNull final SelectedSquareView<G, A, R, V> selectedSquareView, @NotNull final GameObjectMatcher exitMatcher); Modified: trunk/src/app/net/sf/gridarta/treasurelist/CFTreasureListTree.java =================================================================== --- trunk/src/app/net/sf/gridarta/treasurelist/CFTreasureListTree.java 2008-11-11 21:01:43 UTC (rev 5713) +++ trunk/src/app/net/sf/gridarta/treasurelist/CFTreasureListTree.java 2008-11-11 21:15:10 UTC (rev 5714) @@ -42,6 +42,7 @@ import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.ArchetypeSet; import net.sf.gridarta.gameobject.GameObject; +import net.sf.gridarta.gui.errorview.DefaultErrorView; import net.sf.gridarta.help.Help; import net.sf.gridarta.map.MapArchObject; import net.sf.japi.swing.ActionFactory; @@ -91,12 +92,13 @@ /** * Create a new instance. + * @param errorView the error view to use * @param parent the parent frame for dialog boxes * @param archetypeSet ArchetypeSet to get treasures from. * @param specialTreasureLists the special treasure lists * @param treasures The treasures to load. */ - public CFTreasureListTree(@NotNull final JFrame parent, @NotNull final ArchetypeSet<G, A, R> archetypeSet, final Map<String, TreasureTreeNode> specialTreasureLists, final TreasureLocation... treasures) { + public CFTreasureListTree(@NotNull final DefaultErrorView errorView, @NotNull final JFrame parent, @NotNull final ArchetypeSet<G, A, R> archetypeSet, final Map<String, TreasureTreeNode> specialTreasureLists, final TreasureLocation... treasures) { super(root); this.parent = parent; @@ -106,7 +108,7 @@ for (final TreasureTreeNode folder : new HashSet<TreasureTreeNode>(specialTreasureLists.values())) { root.add(folder); } - treasureTable = new TreasureLoader().parseTreasures(treasures, specialTreasureLists, root); + treasureTable = new TreasureLoader().parseTreasures(errorView, treasures, specialTreasureLists, root); ACTION_FACTORY.createAction(true, "viewTreasurelists", this); } Modified: trunk/src/app/net/sf/gridarta/treasurelist/TreasureLoader.java =================================================================== --- trunk/src/app/net/sf/gridarta/treasurelist/TreasureLoader.java 2008-11-11 21:01:43 UTC (rev 5713) +++ trunk/src/app/net/sf/gridarta/treasurelist/TreasureLoader.java 2008-11-11 21:15:10 UTC (rev 5714) @@ -32,6 +32,8 @@ import java.util.List; import java.util.Map; import javax.swing.tree.DefaultMutableTreeNode; +import net.sf.gridarta.gui.errorview.DefaultErrorView; +import net.sf.gridarta.gui.errorview.ErrorViewCollector; import net.sf.gridarta.utils.IOUtils; import net.sf.japi.util.EnumerationIterator; import org.apache.log4j.Logger; @@ -51,9 +53,6 @@ private int tListCount = 0; // number of treasurelists - // all syntax-errors encountered during datafile-parsing get written in this log - private final StringBuilder errorLog = new StringBuilder(); - /** * Comparator for TreasureTreeNodes that compares their object name case * insensitive. @@ -78,16 +77,17 @@ /** * Parse the treasure-data from the CF file "treasures.txt" into this JTree * instance. This method must be called AFTER arch-loading is complete! + * @param errorView the error view to use * @param treasures The treasures to load. */ @NotNull - public Map<String, TreasureTreeNode> parseTreasures(@NotNull final TreasureLocation[] treasures, @NotNull final Map<String, TreasureTreeNode> specialTreasureLists, @NotNull final DefaultMutableTreeNode root) { + public Map<String, TreasureTreeNode> parseTreasures(@NotNull final DefaultErrorView errorView, @NotNull final TreasureLocation[] treasures, @NotNull final Map<String, TreasureTreeNode> specialTreasureLists, @NotNull final DefaultMutableTreeNode root) { final List<TreasureTreeNode> tmpList = new ArrayList<TreasureTreeNode>(); // tmp. container for all treasurelists final List<TreasureTreeNode> needLink = new ArrayList<TreasureTreeNode>(); // all sub-treasurelist nodes that need linking // first step: parsing datafile, adding all treasurelists to the tmpList vector for (final TreasureLocation treasureLocation : treasures) { - loadTreasureList(treasureLocation.getDname(), treasureLocation.getFname(), tmpList, needLink); + loadTreasureList(new ErrorViewCollector(errorView, treasureLocation.getFname()), treasureLocation.getDname(), treasureLocation.getFname(), tmpList, needLink); } // second step: sort alphabetically and link sub-treasurelist entries @@ -139,9 +139,6 @@ } } - if (errorLog.toString().trim().length() > 0) { - log.warn("Syntax errors in treasurelist file:\n" + errorLog); - } if (log.isInfoEnabled()) { log.info(tListCount + " treasurelists loaded."); } @@ -153,14 +150,16 @@ * This method takes a filename or directory name as argument. In case of a * directory it is recursivly traversed and all treasurelist files (*.tl) * get parsed. + * @param errorViewCollector the error view collector to use * @param dname directory to read from * @param fname filename to parse; <code>null</code> to recursivey parse * <code>dname</code> * @param tmpList tmp. container for all treasurelists * @param needLink all sub-treasurelist nodes that need linking - * @see #parseTreasures(TreasureLocation[], Map, DefaultMutableTreeNode) + * @see #parseTreasures(DefaultErrorView, TreasureLocation[], Map, + * DefaultMutableTreeNode) */ - private void loadTreasureList(final String dname, final String fname, final List<TreasureTreeNode> tmpList, final List<TreasureTreeNode> needLink) { + private void loadTreasureList(@NotNull final ErrorViewCollector errorViewCollector, final String dname, final String fname, final List<TreasureTreeNode> tmpList, final List<TreasureTreeNode> needLink) { if (fname == null) { final File f = new File(dname); // This is a directory -> only accept *.tl files and directories @@ -169,9 +168,9 @@ Arrays.sort(traverse); for (final String entry : traverse) { if (entry.endsWith(".tl")) { - loadTreasureList(dname, entry, tmpList, needLink); + loadTreasureList(errorViewCollector, dname, entry, tmpList, needLink); } else { - loadTreasureList(dname + "/" + entry, null, tmpList, needLink); + loadTreasureList(errorViewCollector, dname + "/" + entry, null, tmpList, needLink); } } } @@ -196,17 +195,17 @@ tListCount++; // read this treasurelist till the very end - readInsideList(node, reader, needLink); + readInsideList(errorViewCollector, node, reader, needLink); } else { - errorLog.append("Unexpected line: \"").append(line).append("\"\n"); + errorViewCollector.addWarning("unexpected line: \"" + line + "\""); } } } } finally { reader.close(); } - } catch (final IOException e) { - // FIXME: Either do something or DOCUMENT NOT TO DO SOMETHING! + } catch (final IOException ex) { + errorViewCollector.addError("cannot read file: " + ex.getMessage()); } } @@ -240,6 +239,7 @@ /** * Read and parse the text inside a treasurelist. + * @param errorViewCollector the error view collector to use * @param parentNode parent treenode * @param reader Reader to read from. * @param needLink List containing all sub-treasurelist nodes which need @@ -247,7 +247,7 @@ * @throws IOException in case of I/O problems reading from * <var>reader</var>. */ - private void readInsideList(final TreasureTreeNode parentNode, final BufferedReader reader, final List<TreasureTreeNode> needLink) throws IOException { + private void readInsideList(@NotNull final ErrorViewCollector errorViewCollector, final TreasureTreeNode parentNode, final BufferedReader reader, final List<TreasureTreeNode> needLink) throws IOException { TreasureTreeNode node = null; boolean insideArch = false; @@ -275,7 +275,7 @@ insideArch = true; } else { - errorLog.append("in list ").append(parentNode.getTreasureObj().getName()).append(": unknown line: \"").append(line).append("\"\n"); + errorViewCollector.addWarning("in list " + parentNode.getTreasureObj().getName() + ": unknown line: \"" + line + "\""); } } else { // reading inside an arch-section @@ -285,19 +285,19 @@ try { node.getTreasureObj().setChance(Integer.parseInt(line.substring(line.indexOf(' ') + 1).trim())); } catch (final NumberFormatException e) { - errorLog.append("in list ").append(parentNode.getTreasureObj().getName()).append(": arch ").append(node.getTreasureObj().getName()).append(" chance is not a number.\n"); + errorViewCollector.addWarning("in list " + parentNode.getTreasureObj().getName() + ": arch " + node.getTreasureObj().getName() + " chance is not a number."); } } else if (line.startsWith("nrof")) { try { node.getTreasureObj().setNrof(Integer.parseInt(line.substring(line.indexOf(' ') + 1).trim())); } catch (final NumberFormatException e) { - errorLog.append("in list ").append(parentNode.getTreasureObj().getName()).append(": arch ").append(node.getTreasureObj().getName()).append(" nrof value is not a number.\n"); + errorViewCollector.addWarning("in list " + parentNode.getTreasureObj().getName() + ": arch " + node.getTreasureObj().getName() + " nrof value is not a number."); } } else if (line.startsWith("magic")) { try { node.getTreasureObj().setMagic(Integer.parseInt(line.substring(line.indexOf(' ') + 1).trim())); } catch (final NumberFormatException e) { - errorLog.append("in list ").append(parentNode.getTreasureObj().getName()).append(": arch ").append(node.getTreasureObj().getName()).append(" magic value is not a number.\n"); + errorViewCollector.addWarning("in list " + parentNode.getTreasureObj().getName() + ": arch " + node.getTreasureObj().getName() + " magic value is not a number."); } } else if (line.startsWith("artifact_chance")) { // ignored for now; prevent error message when loading Daimonin treasure lists @@ -317,7 +317,7 @@ // if first arch not generated, process subtree final int chance; if (node.getTreasureObj().getChance() == TreasureObj.UNSET) { - errorLog.append("in list ").append(parentNode.getTreasureObj().getName()).append(": arch ").append(node.getTreasureObj().getName()).append(" has NO-list but chance is unset!\n"); + errorViewCollector.addWarning("in list " + parentNode.getTreasureObj().getName() + ": arch " + node.getTreasureObj().getName() + " has NO-list but chance is unset!"); chance = 0; } else { chance = 100 - node.getTreasureObj().getChance(); @@ -328,7 +328,7 @@ node.add(subNode); // parse this subtree - readInsideList(subNode, reader, needLink); + readInsideList(errorViewCollector, subNode, reader, needLink); } else if (line.equals("yes")) { // if first arch not generated, process subtree final TreasureTreeNode subNode = new TreasureTreeNode("YES", TreasureObj.YES); @@ -336,9 +336,9 @@ node.add(subNode); // parse this subtree - readInsideList(subNode, reader, needLink); + readInsideList(errorViewCollector, subNode, reader, needLink); } else { - errorLog.append("in list ").append(parentNode.getTreasureObj().getName()).append(", arch ").append(node.getTreasureObj().getName()).append(": unexpected line: \"").append(line).append("\"\n"); + errorViewCollector.addError("in list " + parentNode.getTreasureObj().getName() + ", arch " + node.getTreasureObj().getName() + ": unexpected line: \"" + line + "\""); } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-11-12 06:48:39
|
Revision: 5715 http://gridarta.svn.sourceforge.net/gridarta/?rev=5715&view=rev Author: akirschbaum Date: 2008-11-12 06:48:32 +0000 (Wed, 12 Nov 2008) Log Message: ----------- Partially implement #1627422 (Check box option to avoid startup warnings): Use it for "types.xml" file related errors. Modified Paths: -------------- trunk/crossfire/ChangeLog trunk/daimonin/ChangeLog trunk/src/app/net/sf/gridarta/AbstractMainControl.java trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeParser.java trunk/src/app/net/sf/gridarta/archtype/ArchetypeTypeParser.java trunk/src/app/net/sf/gridarta/archtype/ArchetypeTypeSetParser.java trunk/src/app/net/sf/gridarta/archtype/CAttribBitmask.java trunk/src/app/net/sf/gridarta/gui/errorview/DefaultErrorView.java Removed Paths: ------------- trunk/src/app/net/sf/gridarta/archtype/ArchetypeTypeParseException.java Modified: trunk/crossfire/ChangeLog =================================================================== --- trunk/crossfire/ChangeLog 2008-11-11 21:15:10 UTC (rev 5714) +++ trunk/crossfire/ChangeLog 2008-11-12 06:48:32 UTC (rev 5715) @@ -1,3 +1,8 @@ +2008-11-12 Andreas Kirschbaum + + * Partially implement #1627422 (Check box option to avoid startup + warnings): Use it for "types.xml" file related errors. + 2008-11-11 Andreas Kirschbaum * Partially implement #1627422 (Check box option to avoid startup Modified: trunk/daimonin/ChangeLog =================================================================== --- trunk/daimonin/ChangeLog 2008-11-11 21:15:10 UTC (rev 5714) +++ trunk/daimonin/ChangeLog 2008-11-12 06:48:32 UTC (rev 5715) @@ -1,3 +1,8 @@ +2008-11-12 Andreas Kirschbaum + + * Partially implement #1627422 (Check box option to avoid startup + warnings): Use it for "types.xml" file related errors. + 2008-11-11 Andreas Kirschbaum * Partially implement #1627422 (Check box option to avoid startup Modified: trunk/src/app/net/sf/gridarta/AbstractMainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2008-11-11 21:15:10 UTC (rev 5714) +++ trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2008-11-12 06:48:32 UTC (rev 5715) @@ -440,12 +440,14 @@ final ArchetypeAttributeParser<G, A, R> archetypeAttributeParser = new ArchetypeAttributeParser<G, A, R>(typeNoEventConnector, includeFaceText, globalSettings, mapFileFilter, scriptFileFilter, faceObjects, animationObjects, numberSpells, gameObjectSpells, undefinedSpellIndex, archetypeTypeSet, treasureListTree); final ArchetypeTypeParser<G, A, R> archetypeTypeParser = new ArchetypeTypeParser<G, A, R>(archetypeAttributeParser); final ArchetypeTypeSetParser<G, A, R> archetypeTypeSetParser = new ArchetypeTypeSetParser<G, A, R>(xmlHelper.getDocumentBuilder(), xmlHelper.getXPath(), archetypeTypeSet, archetypeTypeParser); + final ErrorViewCollector typesErrorViewCollector = new ErrorViewCollector(errorView, CommonConstants.TYPEDEF_FILE); try { final String filename = IOUtils.getResourceURLAsString(globalSettings.getConfigurationDirectory(), CommonConstants.TYPEDEF_FILE); - archetypeTypeSetParser.loadTypesFromXML(filename); + archetypeTypeSetParser.loadTypesFromXML(typesErrorViewCollector, filename); } catch (final FileNotFoundException ex) { - log.error("Cannot read " + CommonConstants.TYPEDEF_FILE + ": " + ex.getMessage()); + typesErrorViewCollector.addError("cannot read file: " + ex.getMessage()); } + checkForErrors(errorView); scriptArchUtils.setEventTypes(archetypeTypeSet.getListTable().get("event")); final LockedItemsControl<G, A, R, V> lockedItemsControl = new LockedItemsControl<G, A, R, V>(mapManager, mapViewManager, lockedItemsTypeNumbers); final GameObjectAttributesModel<G, A, R> gameObjectAttributesModel = new GameObjectAttributesModel<G, A, R>(); @@ -517,12 +519,19 @@ fileControl = new FileControl<G, A, R, V>(globalSettings, archetypeSet, mapPreviewAccessory, mapManager, mainView, mapFileFilter, scriptFileFilter, newMapDialogFactory, scriptExtension); mapFileActions.setFileControl(fileControl); tmpMapManager.setFileControl(fileControl); - if (errorView.hasErrors() || errorView.hasWarnings()) { + checkForErrors(errorView); + } + + /** + * Checks whether a {@link DefaultErrorView} instance contains at least one + * error. Quits the application if an error exists. + * @param errorView the error view to check + */ + private static void checkForErrors(@NotNull final DefaultErrorView errorView) { + if (errorView.hasErrors()) { waitDialog(errorView); - if (errorView.hasErrors()) { - System.exit(1); - throw new AssertionError(); - } + System.exit(1); + throw new AssertionError(); } } Modified: trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeParser.java =================================================================== --- trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeParser.java 2008-11-11 21:15:10 UTC (rev 5714) +++ trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeParser.java 2008-11-12 06:48:32 UTC (rev 5715) @@ -20,12 +20,12 @@ package net.sf.gridarta.archtype; import javax.swing.filechooser.FileFilter; -import net.sf.gridarta.CommonConstants; import net.sf.gridarta.GlobalSettings; import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.GameObject; import net.sf.gridarta.gameobject.anim.AnimationObjects; import net.sf.gridarta.gameobject.face.FaceObjects; +import net.sf.gridarta.gui.errorview.ErrorViewCollector; import net.sf.gridarta.map.MapArchObject; import net.sf.gridarta.spells.GameObjectSpell; import net.sf.gridarta.spells.NumberSpell; @@ -164,6 +164,7 @@ /** * Loading the data from an xml element into this object. + * @param errorViewCollector the error view collector for reporting errors * @param root the xml 'attribute' element * @param tlist the archtype list * @param typeName (descriptive) name of the type this attribute belongs to @@ -171,7 +172,7 @@ * @return true if the parsing was successful */ @SuppressWarnings({"FeatureEnvy"}) - public ArchetypeAttribute<G, A, R> load(final Element root, final ArchetypeTypeSet<G, A, R> tlist, final String typeName) { + public ArchetypeAttribute<G, A, R> load(@NotNull final ErrorViewCollector errorViewCollector, final Element root, final ArchetypeTypeSet<G, A, R> tlist, final String typeName) { // parse the info text from the element's "body" final String text = parseText(root); @@ -187,7 +188,7 @@ // type name final Attr typeAttr = root.getAttributeNode(XML_ATTR_TYPE); if (typeAttr == null) { - log.error("In '" + CommonConstants.TYPEDEF_FILE + "': Type " + typeName + " has attribute missing '" + XML_ATTR_TYPE + "'."); + errorViewCollector.addError("type " + typeName + " has attribute missing '" + XML_ATTR_TYPE + "'."); return null; } final String atype = typeAttr.getValue().trim(); @@ -199,7 +200,7 @@ try { inputLength = Integer.parseInt(inputLengthAttr.getValue()); } catch (final NumberFormatException de) { - log.error("In '" + CommonConstants.TYPEDEF_FILE + "': Type " + typeName + " has attribute with invalid length '" + inputLengthAttr.getValue() + "' (must be a number)."); + errorViewCollector.addError("type " + typeName + " has attribute with invalid length '" + inputLengthAttr.getValue() + "' (must be a number)."); } } @@ -211,7 +212,7 @@ final Attr trueAttr = root.getAttributeNode("true"); final Attr falseAttr = root.getAttributeNode("false"); if (trueAttr == null || falseAttr == null) { - log.error("In '" + CommonConstants.TYPEDEF_FILE + "': Type " + typeName + " has bool_special attribute missing 'true' or 'false' value."); + errorViewCollector.addError("type " + typeName + " has bool_special attribute missing 'true' or 'false' value."); return null; } @@ -248,7 +249,7 @@ } if (nameOld == null || nameOld.length() == 0 || endingOld == null || endingOld.length() == 0) { - log.warn("In '" + CommonConstants.TYPEDEF_FILE + "': Type " + typeName + " has text attribute missing '" + XML_KEY_ARCH_BEGIN + "' or '" + XML_KEY_ARCH_END + "'."); + errorViewCollector.addError("type " + typeName + " has text attribute missing '" + XML_KEY_ARCH_BEGIN + "' or '" + XML_KEY_ARCH_END + "'."); return null; } @@ -258,7 +259,7 @@ } else if (atype.equalsIgnoreCase("fixed")) { final Attr valueAttr = root.getAttributeNode("value"); if (valueAttr == null) { - log.warn("In '" + CommonConstants.TYPEDEF_FILE + "': Type " + typeName + " has fixed attribute missing 'value'."); + errorViewCollector.addError("type " + typeName + " has fixed attribute missing 'value'."); return null; } nameNew = valueAttr.getValue().trim(); @@ -275,7 +276,7 @@ // got a bitmask attribute final String bitmaskName = atype.substring(8).trim(); if (!tlist.getBitmaskTable().containsKey(bitmaskName)) { - log.warn("In '" + CommonConstants.TYPEDEF_FILE + "', type " + typeName + ": Bitmask \"" + bitmaskName + "\" is undefined."); + errorViewCollector.addError("type " + typeName + ": Bitmask \"" + bitmaskName + "\" is undefined."); return null; } return new ArchetypeAttributeBitmask<G, A, R>(nameOld, nameNew, text, inputLength, bitmaskName, archetypeTypeSet); @@ -283,7 +284,7 @@ // got a bitmask attribute final String listName = atype.substring(5).trim(); if (!tlist.getListTable().containsKey(listName)) { - log.warn("In '" + CommonConstants.TYPEDEF_FILE + "', type " + typeName + ": List \"" + listName + "\" is undefined."); + errorViewCollector.addError("type " + typeName + ": List \"" + listName + "\" is undefined."); return null; } return new ArchetypeAttributeList<G, A, R>(nameOld, nameNew, text, inputLength, listName, archetypeTypeSet); @@ -293,14 +294,14 @@ final int seppos = listNames.indexOf(','); if (seppos == -1 || seppos == listNames.length() - 1) { - log.error("In '" + CommonConstants.TYPEDEF_FILE + "': Type " + typeName + ", double list: '" + atype + "' does not contain two comma-separated lists."); + errorViewCollector.addError("type " + typeName + ", double list: '" + atype + "' does not contain two comma-separated lists."); return null; } final String listName1 = listNames.substring(0, seppos); final String listName2 = listNames.substring(seppos + 1); if (!tlist.getListTable().containsKey(listName1) || !tlist.getListTable().containsKey(listName2)) { - log.error("In '" + CommonConstants.TYPEDEF_FILE + "', type " + typeName + ": List \"" + listName1 + "\" or \"" + listName2 + "\" is undefined."); + errorViewCollector.addError("type " + typeName + ": List \"" + listName1 + "\" or \"" + listName2 + "\" is undefined."); return null; } return new ArchetypeAttributeDoubleList<G, A, R>(nameOld, nameNew, text, inputLength, listName1, listName2, archetypeTypeSet); @@ -308,7 +309,7 @@ return new ArchetypeAttributeTreasure<G, A, R>(nameOld, nameNew, text, inputLength, treasureListTree); } else { // unknown type - log.warn("In '" + CommonConstants.TYPEDEF_FILE + "': Type " + typeName + " has an attribute with unknown type: '" + atype + "'."); + errorViewCollector.addError("type " + typeName + " has an attribute with unknown type: '" + atype + "'."); return null; } } Deleted: trunk/src/app/net/sf/gridarta/archtype/ArchetypeTypeParseException.java =================================================================== --- trunk/src/app/net/sf/gridarta/archtype/ArchetypeTypeParseException.java 2008-11-11 21:15:10 UTC (rev 5714) +++ trunk/src/app/net/sf/gridarta/archtype/ArchetypeTypeParseException.java 2008-11-12 06:48:32 UTC (rev 5715) @@ -1,45 +0,0 @@ -/* - * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. - * Copyright (C) 2000-2007 The Gridarta Developers. - * - * 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 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 program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -package net.sf.gridarta.archtype; - -import java.io.IOException; - -/** - * Thrown when parsing a CFArchType failed. - * @author <a href="mailto:ch...@ri...">Christian Hujer</a> - */ -public class ArchetypeTypeParseException extends IOException { - - /** The serial version UID. */ - private static final long serialVersionUID = 1; - - /** Create an ArchTypeParseException. */ - public ArchetypeTypeParseException() { - } - - /** - * Create an ArchTypeParseException. - * @param s The detail message. - */ - public ArchetypeTypeParseException(final String s) { - super(s); - } - -} // class ArchetypeTypeParseException Modified: trunk/src/app/net/sf/gridarta/archtype/ArchetypeTypeParser.java =================================================================== --- trunk/src/app/net/sf/gridarta/archtype/ArchetypeTypeParser.java 2008-11-11 21:15:10 UTC (rev 5714) +++ trunk/src/app/net/sf/gridarta/archtype/ArchetypeTypeParser.java 2008-11-12 06:48:32 UTC (rev 5715) @@ -25,9 +25,9 @@ import java.util.List; import java.util.Map; import java.util.Set; -import net.sf.gridarta.CommonConstants; import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.GameObject; +import net.sf.gridarta.gui.errorview.ErrorViewCollector; import net.sf.gridarta.map.MapArchObject; import net.sf.japi.xml.NodeListIterator; import org.apache.log4j.Logger; @@ -89,16 +89,15 @@ * Loading the data from an xml type element into this instance. Since * users are expected to edit the type definitions, I have tried to design * the parser to be somewhat robust and provide error feedback. + * @param errorViewCollector the error view collector for reporting error * @param parent the parent archetype type * @param root the xml 'type' element which is going to be parsed * @param archetypeTypeSet archetype type list * @param ignoreListTable the ignore_lists contents * @return the archetype type or <code>null</code> - * @throws ArchetypeTypeParseException In case <var>root</var> is malformed or - * contains bogus data. * @todo I'm sucking slow, improve me */ - public ArchetypeType<G, A, R> load(final ArchetypeType<G, A, R> parent, final Element root, final ArchetypeTypeSet<G, A, R> archetypeTypeSet, @NotNull final Map<String, List<String>> ignoreListTable) throws ArchetypeTypeParseException { + public ArchetypeType<G, A, R> load(@NotNull final ErrorViewCollector errorViewCollector, final ArchetypeType<G, A, R> parent, final Element root, final ArchetypeTypeSet<G, A, R> archetypeTypeSet, @NotNull final Map<String, List<String>> ignoreListTable) { final ArchetypeType<G, A, R> result = new ArchetypeType<G, A, R>(parent); // this vector is used to store a temporary linked list of attributes @@ -137,7 +136,7 @@ final Attr a1 = elem.getAttributeNode(ArchetypeAttributeParser.XML_KEY_ARCH); final Attr a2 = elem.getAttributeNode(XML_VALUE); if (a1 == null || a2 == null) { - throw new ArchetypeTypeParseException("In '" + XML_REQUIRED + "' element of type " + result.typeName + ": " + XML_ATTRIBUTE + " missing '" + ArchetypeAttributeParser.XML_KEY_ARCH + "' or '" + XML_VALUE + "'."); + errorViewCollector.addError(XML_REQUIRED + ": element of type " + result.typeName + ": " + XML_ATTRIBUTE + " missing '" + ArchetypeAttributeParser.XML_KEY_ARCH + "' or '" + XML_VALUE + "'."); } else { tmp.add(a1.getValue().trim()); tmp.add(a2.getValue().trim()); @@ -151,7 +150,7 @@ } } catch (final NumberFormatException e) { // parsing type number failed: - throw new ArchetypeTypeParseException("In " + CommonConstants.TYPEDEF_FILE + ": Type " + result.typeName + " has invalid type number '" + root.getAttribute("number") + "'."); + errorViewCollector.addError("type " + result.typeName + " has invalid type number '" + root.getAttribute("number") + "'."); } // parse 'ignore' elements @@ -161,7 +160,7 @@ for (final Element elem : new NodeListIterator<Element>(signore, XML_ATTRIBUTE)) { final Attr a1 = elem.getAttributeNode(ArchetypeAttributeParser.XML_KEY_ARCH); if (a1 == null) { - throw new ArchetypeTypeParseException("In '" + XML_IGNORE + "' section of type " + result.typeName + ": " + XML_ATTRIBUTE + " missing '" + ArchetypeAttributeParser.XML_KEY_ARCH + "'."); + errorViewCollector.addError(XML_IGNORE + ": section of type " + result.typeName + ": " + XML_ATTRIBUTE + " missing '" + ArchetypeAttributeParser.XML_KEY_ARCH + "'."); } else { ignoreTable.put(a1.getValue().trim(), ""); } @@ -171,7 +170,7 @@ for (final Element elem : new NodeListIterator<Element>(signore, "ignore_list")) { final Attr a1 = elem.getAttributeNode("name"); if (a1 == null) { - throw new ArchetypeTypeParseException("In '" + XML_IGNORE + "' section of type " + result.typeName + ": ignore_list missing 'name'."); + errorViewCollector.addError(XML_IGNORE + ": section of type " + result.typeName + ": ignore_list missing 'name'."); } else if (ignoreListTable.containsKey(a1.getValue().trim())) { // just copy everything from ignorelist to this ignore section final List<String> ignlist = ignoreListTable.get(a1.getValue().trim()); @@ -179,7 +178,7 @@ ignoreTable.put(ignItem, ""); } } else { - throw new ArchetypeTypeParseException("In '" + XML_IGNORE + "' section of type " + result.typeName + ": ignore_list with name \"" + a1.getValue() + "\" is undefined."); + errorViewCollector.addError(XML_IGNORE + ": section of type " + result.typeName + ": ignore_list with name \"" + a1.getValue() + "\" is undefined."); } } } @@ -202,7 +201,7 @@ if ((elem = NodeListIterator.getFirstChild(root, XML_IMPORT_TYPE)) != null) { final Attr a1 = elem.getAttributeNode("name"); if (a1 == null) { - throw new ArchetypeTypeParseException("In file '" + CommonConstants.TYPEDEF_FILE + "': Type " + result.typeName + " has " + XML_IMPORT_TYPE + " element without 'name'."); + errorViewCollector.addError("type " + result.typeName + " has " + XML_IMPORT_TYPE + " element without 'name'."); } else { importName = a1.getValue().trim(); } @@ -213,7 +212,7 @@ for (final Element elem : new NodeListIterator<Element>(root, Node.ELEMENT_NODE)) { // attribute directly in type element if (elem.getNodeName().equalsIgnoreCase(XML_ATTRIBUTE)) { - parseAttribute(result, elem, secNames, false, null, attrList, archetypeTypeSet); + parseAttribute(errorViewCollector, result, elem, secNames, false, null, attrList, archetypeTypeSet); final Attr a1 = elem.getAttributeNode(ArchetypeAttributeParser.XML_KEY_ARCH); if (a1 != null) { autoIgnoreTable.add(a1.getValue().trim()); @@ -224,7 +223,8 @@ if (elem.getNodeName().equalsIgnoreCase(XML_SECTION) && elem.hasChildNodes()) { final Attr a1 = elem.getAttributeNode("name"); if (a1 == null) { - throw new ArchetypeTypeParseException("In " + CommonConstants.TYPEDEF_FILE + ": Type " + result.typeName + " contains a " + XML_SECTION + " missing 'name'."); + errorViewCollector.addError("type " + result.typeName + " contains a " + XML_SECTION + " missing 'name'."); + continue; } // get section name final String section = a1.getValue().trim(); @@ -234,7 +234,7 @@ // parse all attributes in the section for (final Element elem2 : new NodeListIterator<Element>(elem, XML_ATTRIBUTE)) { // got an attribute element possibly in a section - parseAttribute(result, elem2, secNames, true, section, attrList, archetypeTypeSet); + parseAttribute(errorViewCollector, result, elem2, secNames, true, section, attrList, archetypeTypeSet); final Attr a2 = elem2.getAttributeNode(ArchetypeAttributeParser.XML_KEY_ARCH); if (a2 != null) { autoIgnoreTable.add(a2.getValue().trim()); @@ -313,7 +313,7 @@ } } } else { - throw new ArchetypeTypeParseException("Syntax Error in file '" + CommonConstants.TYPEDEF_FILE + "' (" + result.typeName + "):\n import type \"" + importName + "\" not found!"); + errorViewCollector.addError(result.typeName + ": import type \"" + importName + "\" not found!"); } } @@ -351,6 +351,7 @@ * is added to the temporare linked list provided by the parameters (see * below). Assignment of sections to attributes also happens in this * method. + * @param errorViewCollector the error view collector for reporting errors * @param archetypeType the archetype type to modify * @param elem the xml attribute element * @param secNames vector storing all section names @@ -360,8 +361,8 @@ * @param attrList list of attributes * @param tlist arch type list */ - private void parseAttribute(final ArchetypeType<G, A, R> archetypeType, final Element elem, final List<String> secNames, final boolean inSection, final String section, final List<ArchetypeAttribute<G, A, R>> attrList, final ArchetypeTypeSet<G, A, R> tlist) { - final ArchetypeAttribute<G, A, R> attrib = archetypeAttributeParser.load(elem, tlist, archetypeType.typeName); + private void parseAttribute(@NotNull final ErrorViewCollector errorViewCollector, final ArchetypeType<G, A, R> archetypeType, final Element elem, final List<String> secNames, final boolean inSection, final String section, final List<ArchetypeAttribute<G, A, R>> attrList, final ArchetypeTypeSet<G, A, R> tlist) { + final ArchetypeAttribute<G, A, R> attrib = archetypeAttributeParser.load(errorViewCollector, elem, tlist, archetypeType.typeName); if (attrib != null) { attrList.add(attrib); @@ -388,4 +389,5 @@ } } } + } // class ArchetypeTypeParser Modified: trunk/src/app/net/sf/gridarta/archtype/ArchetypeTypeSetParser.java =================================================================== --- trunk/src/app/net/sf/gridarta/archtype/ArchetypeTypeSetParser.java 2008-11-11 21:15:10 UTC (rev 5714) +++ trunk/src/app/net/sf/gridarta/archtype/ArchetypeTypeSetParser.java 2008-11-12 06:48:32 UTC (rev 5715) @@ -27,9 +27,9 @@ import javax.xml.parsers.DocumentBuilder; import javax.xml.xpath.XPath; import javax.xml.xpath.XPathExpressionException; -import net.sf.gridarta.CommonConstants; import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.GameObject; +import net.sf.gridarta.gui.errorview.ErrorViewCollector; import net.sf.gridarta.map.MapArchObject; import net.sf.japi.xml.NodeListIterator; import org.apache.log4j.Logger; @@ -88,7 +88,7 @@ this.archetypeTypeParser = archetypeTypeParser; } - public void loadTypesFromXML(@NotNull final String filename) { + public void loadTypesFromXML(@NotNull final ErrorViewCollector errorViewCollector, @NotNull final String filename) { final Map<String, List<String>> ignoreListTable = new HashMap<String, List<String>>(); try { // parse xml document @@ -96,21 +96,21 @@ // start parsing the xml final Element root = doc.getDocumentElement(); - parseBitmasks(root); - parseLists(root); - parseIgnoreLists(root, ignoreListTable); - archetypeTypeSet.defaultArchetypeType = parseDefaultType(root, ignoreListTable); - parseTypes(root, ignoreListTable); + parseBitmasks(errorViewCollector, root); + parseLists(errorViewCollector, root); + parseIgnoreLists(errorViewCollector, root, ignoreListTable); + archetypeTypeSet.defaultArchetypeType = parseDefaultType(errorViewCollector, root, ignoreListTable); + parseTypes(errorViewCollector, root, ignoreListTable); if (log.isInfoEnabled()) { log.info("Loaded " + archetypeTypeSet.archetypeTypeList.size() + " types from '" + filename + "\'"); } } catch (final SAXException e) { - log.error("Parsing error in '" + filename + "':\n" + e.getMessage()); + errorViewCollector.addError("parsing error in '" + filename + "': " + e.getMessage()); } catch (final IOException e) { - log.error("Cannot read file '" + filename + "'!"); + errorViewCollector.addError("cannot read file '" + filename + "': " + e.getMessage()); } catch (final XPathExpressionException e) { - log.error("XPath error: " + e.getMessage()); + errorViewCollector.addError("XPath error: " + e.getMessage()); } archetypeTypeSet.fallbackArchetypeType = archetypeTypeSet.archetypeTypeNames.get("Misc"); @@ -119,18 +119,18 @@ } } - private void parseBitmasks(final Element root) throws XPathExpressionException { + private void parseBitmasks(@NotNull final ErrorViewCollector errorViewCollector, final Element root) throws XPathExpressionException { for (final Element elem : new NodeListIterator<Element>(xpath, root, "bitmasks/bitmask")) { - archetypeTypeSet.bitmaskTable.put(elem.getAttribute("name"), new CAttribBitmask<G, A, R>(xpath, elem)); + archetypeTypeSet.bitmaskTable.put(elem.getAttribute("name"), new CAttribBitmask<G, A, R>(errorViewCollector, xpath, elem)); } } - private void parseLists(final Element root) throws ArchetypeTypeParseException, XPathExpressionException { + private void parseLists(@NotNull final ErrorViewCollector errorViewCollector, final Element root) throws XPathExpressionException { for (final Element elem : new NodeListIterator<Element>(xpath, root, "lists/list")) { if (elem.getAttribute("name") == null) { - throw new ArchetypeTypeParseException("In file '" + CommonConstants.TYPEDEF_FILE + "': cannot load list element without 'name'."); + errorViewCollector.addError("cannot load list element without 'name'."); } else { - final List<?> list = parseListFromElement(elem); + final List<?> list = parseListFromElement(errorViewCollector, elem); if (list != null && !list.isEmpty()) { archetypeTypeSet.listTable.put(elem.getAttribute("name"), list); } @@ -140,31 +140,36 @@ /** * Parse a list vector from an xml list element. + * @param errorViewCollector the error view collector for reporting errors * @param root element to parse * @return List with data parsed from <var>root</var> * @throws XPathExpressionException In case of XPath issues (should never * happen). * @todo improve this comment */ - private List<?> parseListFromElement(final Element root) throws ArchetypeTypeParseException, XPathExpressionException { + private List<?> parseListFromElement(@NotNull final ErrorViewCollector errorViewCollector, final Element root) throws XPathExpressionException { // XXX The list created here contains altering types: Integer for even, String for odd indices. final List<Object> list = new ArrayList<Object>(); for (final Element elem : new NodeListIterator<Element>(xpath, root, "listentry")) { + final String name = elem.getAttribute("name"); + final int value; // every list entry adds value (Integer) and name (String) to the vector try { - list.add(Integer.valueOf(elem.getAttribute("value"))); - list.add(elem.getAttribute("name")); + value = Integer.valueOf(elem.getAttribute("value")); } catch (final NumberFormatException ignore) { - throw new ArchetypeTypeParseException("In '" + CommonConstants.TYPEDEF_FILE + "', list " + root.getAttribute("name") + ": value '" + elem.getAttribute("value") + "' is not an integer."); + errorViewCollector.addError(name + ": value '" + elem.getAttribute("value") + "' is not an integer."); + continue; } + list.add(value); + list.add(name); } return list; } - private void parseIgnoreLists(final Element root, @NotNull final Map<String, List<String>> ignoreListTable) throws ArchetypeTypeParseException, XPathExpressionException { + private void parseIgnoreLists(@NotNull final ErrorViewCollector errorViewCollector, final Element root, @NotNull final Map<String, List<String>> ignoreListTable) throws XPathExpressionException { for (final Element elem : new NodeListIterator<Element>(xpath, root, "ignore_list|ignorelists/ignore_list")) { if (elem.getAttribute("name") == null) { - throw new ArchetypeTypeParseException("In file '" + CommonConstants.TYPEDEF_FILE + "': cannot load ignore_list element without 'name'."); + errorViewCollector.addError("cannot load ignore_list element without 'name'."); } else { final String lname = elem.getAttribute("name").trim(); final List<String> content = new ArrayList<String>(); @@ -173,7 +178,7 @@ if (a != null) { content.add(a.getValue().trim()); } else { - throw new ArchetypeTypeParseException("In file '" + CommonConstants.TYPEDEF_FILE + "': ignore_list '" + lname + "' has " + ArchetypeTypeParser.XML_ATTRIBUTE + " missing '" + ArchetypeAttributeParser.XML_KEY_ARCH + "'."); + errorViewCollector.addError(lname + ": " + ArchetypeTypeParser.XML_ATTRIBUTE + " missing '" + ArchetypeAttributeParser.XML_KEY_ARCH + "'."); } } // now add the list vector to the ignoreListTable: @@ -184,21 +189,21 @@ } } - private ArchetypeType<G, A, R> parseDefaultType(final Element root, @NotNull final Map<String, List<String>> ignoreListTable) throws ArchetypeTypeParseException { + private ArchetypeType<G, A, R> parseDefaultType(@NotNull final ErrorViewCollector errorViewCollector, final Element root, @NotNull final Map<String, List<String>> ignoreListTable) { // parse default type final Element el = NodeListIterator.getFirstChild(root, "default_type"); if (el == null) { - throw new ArchetypeTypeParseException("In file '" + CommonConstants.TYPEDEF_FILE + "': default_type element is missing!"); + errorViewCollector.addError("default_type element is missing!"); } - return archetypeTypeParser.load(null, el, archetypeTypeSet, ignoreListTable); + return archetypeTypeParser.load(errorViewCollector, null, el, archetypeTypeSet, ignoreListTable); } - private void parseTypes(final Element root, @NotNull final Map<String, List<String>> ignoreListTable) throws ArchetypeTypeParseException { + private void parseTypes(@NotNull final ErrorViewCollector errorViewCollector, final Element root, @NotNull final Map<String, List<String>> ignoreListTable) { // parse all type elements for (final Element elem : new NodeListIterator<Element>(root, "type")) { if (!"no".equals(elem.getAttribute("available"))) { - final ArchetypeType<G, A, R> newType = archetypeTypeParser.load(archetypeTypeSet.defaultArchetypeType, elem, archetypeTypeSet, ignoreListTable); + final ArchetypeType<G, A, R> newType = archetypeTypeParser.load(errorViewCollector, archetypeTypeSet.defaultArchetypeType, elem, archetypeTypeSet, ignoreListTable); if (newType != null) { // attach the new ArchetypeType element to the list archetypeTypeSet.archetypeTypeList.add(newType); Modified: trunk/src/app/net/sf/gridarta/archtype/CAttribBitmask.java =================================================================== --- trunk/src/app/net/sf/gridarta/archtype/CAttribBitmask.java 2008-11-11 21:15:10 UTC (rev 5714) +++ trunk/src/app/net/sf/gridarta/archtype/CAttribBitmask.java 2008-11-12 06:48:32 UTC (rev 5715) @@ -33,11 +33,13 @@ import javax.xml.xpath.XPathExpressionException; import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.GameObject; +import net.sf.gridarta.gui.errorview.ErrorViewCollector; import net.sf.gridarta.gui.gameobjectattributesdialog.DialogAttribBitmask; import net.sf.gridarta.map.MapArchObject; import net.sf.gridarta.utils.WrappingStringBuilder; import net.sf.japi.xml.NodeListIterator; import org.apache.log4j.Logger; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.w3c.dom.Element; @@ -85,11 +87,12 @@ /** * Constructor of a bitmask from XML element. + * @param errorViewCollector the error view collector for reporting errors * @param xpath XPath for XPath evaluation * @param bitmasksElement xml bitmask element * @throws XPathExpressionException in case of XPath evaluation errors */ - public CAttribBitmask(final XPath xpath, final Element bitmasksElement) throws XPathExpressionException { + public CAttribBitmask(@NotNull final ErrorViewCollector errorViewCollector, final XPath xpath, final Element bitmasksElement) throws XPathExpressionException { final NodeListIterator<Element> entries = new NodeListIterator<Element>(xpath, bitmasksElement, "bmentry"); isNamed = bitmasksElement.getAttribute("is_named").equals("yes"); final String[] tmp = new String[32]; @@ -98,7 +101,8 @@ final String bitAttr = elem.getAttribute("bit"); final String valueAttr = elem.getAttribute("value"); if (bitAttr.length() != 0 && valueAttr.length() != 0) { - throw new IllegalArgumentException("element contains both 'bit' and 'value' attributes"); + errorViewCollector.addError(bitmasksElement.getAttribute("name") + ": element contains both 'bit' and 'value' attributes"); + continue; } final int value; @@ -107,54 +111,66 @@ try { bitValue = Integer.parseInt(bitAttr); } catch (final NumberFormatException ex) { - throw new IllegalArgumentException("invalid 'bit' value: " + bitAttr); + errorViewCollector.addError(bitmasksElement.getAttribute("name") + ": invalid 'bit' value: " + bitAttr); + continue; } if (bitValue < 0 || bitValue >= tmp.length) { - throw new IllegalArgumentException("invalid 'bit' value: " + bitValue); + errorViewCollector.addError(bitmasksElement.getAttribute("name") + ": invalid 'bit' value: " + bitValue); + continue; } if (tmp[bitValue] != null) { - throw new IllegalArgumentException("duplicate 'bit' value: " + bitValue); + errorViewCollector.addError(bitmasksElement.getAttribute("name") + ": duplicate 'bit' value: " + bitValue); + continue; } tmp[bitValue] = elem.getAttribute("name"); value = 1 << bitValue; bitValues = Math.max(bitValues, bitValue + 1); } else { if (!isNamed) { - throw new IllegalArgumentException("'value' attribute allowed only in named bitmasks"); + errorViewCollector.addError(bitmasksElement.getAttribute("name") + ": 'value' attribute allowed only in named bitmasks"); + continue; } try { value = Integer.parseInt(valueAttr); } catch (final NumberFormatException ex) { - throw new IllegalArgumentException("invalid 'value' value: " + valueAttr); + errorViewCollector.addError(bitmasksElement.getAttribute("name") + ": invalid 'value' value: " + valueAttr); + continue; } } final String encodingAttr = elem.getAttribute("encoding"); if (isNamed) { if (encodingAttr.length() == 0) { - throw new IllegalArgumentException("missing 'encoding' attribute"); + errorViewCollector.addError(bitmasksElement.getAttribute("name") + ": missing 'encoding' attribute"); + continue; } namedValues.put(encodingAttr, value); encodings.put(value, encodingAttr); } else { if (encodingAttr.length() != 0) { - throw new IllegalArgumentException("unused 'encoding' attribute"); + errorViewCollector.addError(bitmasksElement.getAttribute("name") + ": unused 'encoding' attribute"); + continue; } } names.put(value, elem.getAttribute("name")); } if (bitValues <= 0) { - throw new IllegalArgumentException("no 'bit' entries"); + number = 0; + bitName = new String[number]; + errorViewCollector.addError(bitmasksElement.getAttribute("name") + ": no 'bit' entries"); + return; } number = bitValues; bitName = new String[bitValues]; System.arraycopy(tmp, 0, bitName, 0, bitValues); if (isNamed && !encodings.containsKey(0)) { - throw new IllegalArgumentException("missing name for value 0"); + errorViewCollector.addError(bitmasksElement.getAttribute("name") + ": missing name for value 0"); + return; } if (isNamed && !encodings.containsKey((1 << bitName.length) - 1)) { - throw new IllegalArgumentException("missing name for value " + ((1 << bitName.length) - 1)); + errorViewCollector.addError(bitmasksElement.getAttribute("name") + ": missing name for value " + ((1 << bitName.length) - 1)); + return; } } Modified: trunk/src/app/net/sf/gridarta/gui/errorview/DefaultErrorView.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/errorview/DefaultErrorView.java 2008-11-11 21:15:10 UTC (rev 5714) +++ trunk/src/app/net/sf/gridarta/gui/errorview/DefaultErrorView.java 2008-11-12 06:48:32 UTC (rev 5715) @@ -71,11 +71,6 @@ private boolean errors = false; /** - * Whether at least one warning message has been added. - */ - private boolean warnings = false; - - /** * The dialog instance. Set to <code>null</code> until created. */ @Nullable @@ -119,7 +114,6 @@ final ErrorEntry errorEntry = new ErrorEntry(treeModel, "Warning: " + message, false); category.add(errorEntry); showDialog(category, errorEntry); - warnings = true; } /** @@ -149,14 +143,6 @@ } /** - * Whether at least one warning message has been added. - * @return whether error exist - */ - public boolean hasWarnings() { - return warnings; - } - - /** * Shows a dialog showing the object tree. Returns after the dialog has * been dismissed. * @param category the category node This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-11-12 08:49:46
|
Revision: 5717 http://gridarta.svn.sourceforge.net/gridarta/?rev=5717&view=rev Author: akirschbaum Date: 2008-11-12 08:49:40 +0000 (Wed, 12 Nov 2008) Log Message: ----------- Move ArchetypeSetLoader.loadArchetypes() to common code base. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/gameobject/ArchetypeSetLoader.java trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/gameobject/ArchetypeSetLoader.java trunk/src/app/net/sf/gridarta/AbstractMainControl.java trunk/src/app/net/sf/gridarta/gameobject/AbstractArchetypeSetLoader.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-11-12 06:52:22 UTC (rev 5716) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-11-12 08:49:40 UTC (rev 5717) @@ -53,6 +53,7 @@ import net.sf.gridarta.MapManager; import net.sf.gridarta.filter.FilterControl; import net.sf.gridarta.gameobject.AbstractArchetypeParser; +import net.sf.gridarta.gameobject.AbstractArchetypeSetLoader; import net.sf.gridarta.gameobject.ArchetypeFactory; import net.sf.gridarta.gameobject.Collectable; import net.sf.gridarta.gameobject.GameObjectFactory; @@ -306,8 +307,8 @@ /** {@inheritDoc} */ @Override - protected void init4(@NotNull final GameObjectParser<GameObject, MapArchObject, Archetype> gameObjectParser, @NotNull final AbstractArchetypeParser<GameObject, MapArchObject, Archetype> archetypeParser, @NotNull final EditTypes editTypes, @NotNull final FaceObjects faceObjects, @NotNull final AnimationObjects animationObjects, @NotNull final MainView<GameObject, MapArchObject, Archetype, CMapViewBasic> mainView, @NotNull final GlobalSettings globalSettings, @NotNull final net.sf.gridarta.gameobject.ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet) { - new ArchetypeSetLoader(globalSettings, gameObjectParser, globalSettings.getCollectedDirectory(), archetypeSet, archetypeParser, editTypes, faceObjects, animationObjects, this).loadArchetypes(mainView); + protected AbstractArchetypeSetLoader newArchetypeSetLoader(@NotNull final GameObjectParser<GameObject, MapArchObject, Archetype> gameObjectParser, @NotNull final AbstractArchetypeParser<GameObject, MapArchObject, Archetype> archetypeParser, @NotNull final EditTypes editTypes, @NotNull final FaceObjects faceObjects, @NotNull final AnimationObjects animationObjects, @NotNull final GlobalSettings globalSettings, @NotNull final net.sf.gridarta.gameobject.ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet) { + return new ArchetypeSetLoader(globalSettings, gameObjectParser, globalSettings.getCollectedDirectory(), archetypeSet, archetypeParser, editTypes, faceObjects, animationObjects, this); } /** {@inheritDoc} */ Modified: trunk/crossfire/src/cfeditor/gameobject/ArchetypeSetLoader.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/ArchetypeSetLoader.java 2008-11-12 06:52:22 UTC (rev 5716) +++ trunk/crossfire/src/cfeditor/gameobject/ArchetypeSetLoader.java 2008-11-12 08:49:40 UTC (rev 5717) @@ -138,10 +138,8 @@ this.animationObjects = animationObjects; } - /** - * Loads archetypes. - * @param parent the parent component for error messages - */ + /** {@inheritDoc} */ + @Override public void loadArchetypes(@NotNull final Component parent) { final long timeStart = System.currentTimeMillis(); if (log.isInfoEnabled()) { Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-11-12 06:52:22 UTC (rev 5716) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-11-12 08:49:40 UTC (rev 5717) @@ -54,6 +54,7 @@ import net.sf.gridarta.MapManager; import net.sf.gridarta.filter.FilterControl; import net.sf.gridarta.gameobject.AbstractArchetypeParser; +import net.sf.gridarta.gameobject.AbstractArchetypeSetLoader; import net.sf.gridarta.gameobject.ArchetypeFactory; import net.sf.gridarta.gameobject.Collectable; import net.sf.gridarta.gameobject.GameObjectFactory; @@ -340,9 +341,9 @@ /** {@inheritDoc} */ @Override - protected void init4(@NotNull final GameObjectParser<GameObject, MapArchObject, Archetype> gameObjectParser, @NotNull final AbstractArchetypeParser<GameObject, MapArchObject, Archetype> archetypeParser, @NotNull final EditTypes editTypes, @NotNull final FaceObjects faceObjects, @NotNull final AnimationObjects animationObjects, @NotNull final MainView<GameObject, MapArchObject, Archetype, CMapViewBasic> mainView, @NotNull final GlobalSettings globalSettings, @NotNull final net.sf.gridarta.gameobject.ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet) { + protected AbstractArchetypeSetLoader newArchetypeSetLoader(@NotNull final GameObjectParser<GameObject, MapArchObject, Archetype> gameObjectParser, @NotNull final AbstractArchetypeParser<GameObject, MapArchObject, Archetype> archetypeParser, @NotNull final EditTypes editTypes, @NotNull final FaceObjects faceObjects, @NotNull final AnimationObjects animationObjects, @NotNull final GlobalSettings globalSettings, @NotNull final net.sf.gridarta.gameobject.ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet) { MultiPositionData.init(globalSettings.getConfigurationDirectory()); - new ArchetypeSetLoader(globalSettings, gameObjectParser, globalSettings.getCollectedDirectory(), archetypeSet, archetypeParser, editTypes, faceObjects, animationObjects, this).loadArchetypes(mainView); + return new ArchetypeSetLoader(globalSettings, gameObjectParser, globalSettings.getCollectedDirectory(), archetypeSet, archetypeParser, editTypes, faceObjects, animationObjects, this); } /** {@inheritDoc} */ Modified: trunk/daimonin/src/daieditor/gameobject/ArchetypeSetLoader.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/ArchetypeSetLoader.java 2008-11-12 06:52:22 UTC (rev 5716) +++ trunk/daimonin/src/daieditor/gameobject/ArchetypeSetLoader.java 2008-11-12 08:49:40 UTC (rev 5717) @@ -154,10 +154,8 @@ this.throwableHandler = throwableHandler; } - /** - * Loads archetypes. - * @param parent the parent component for error messages - */ + /** {@inheritDoc} */ + @Override public void loadArchetypes(@NotNull final Component parent) { final long timeStart = System.currentTimeMillis(); if (log.isInfoEnabled()) { Modified: trunk/src/app/net/sf/gridarta/AbstractMainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2008-11-12 06:52:22 UTC (rev 5716) +++ trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2008-11-12 08:49:40 UTC (rev 5717) @@ -48,6 +48,7 @@ import net.sf.gridarta.filter.FilterControl; import net.sf.gridarta.filter.NamedFilterList; import net.sf.gridarta.gameobject.AbstractArchetypeParser; +import net.sf.gridarta.gameobject.AbstractArchetypeSetLoader; import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.ArchetypeFactory; import net.sf.gridarta.gameobject.ArchetypeSet; @@ -482,7 +483,7 @@ final ScriptArchEditor<G> scriptArchEditor = newScriptArchEditor(scriptedEventFactory, scriptExtension, scriptName, scriptArchUtils.createEventTypeBox(), scriptFileFilter, globalSettings, mapManager); scriptArchEditor.initEventTypeBoxes(scriptArchUtils); GameObject.initialize(archetypeSet, archetypeTypeSet, gameObjectMatchers, scriptArchEditor, animationObjects, SystemIcons.getNofaceTileIcon(), newScriptArchData(scriptedEventFactory, scriptArchUtils, scriptArchEditor)); - init4(gameObjectParser, archetypeParser, editTypes, faceObjects, animationObjects, mainView, globalSettings, archetypeSet); + newArchetypeSetLoader(gameObjectParser, archetypeParser, editTypes, faceObjects, animationObjects, globalSettings, archetypeSet).loadArchetypes(mainView); if (spellType != 0) { new ArchetypeSetSpellLoader<G, A, R>().load(archetypeSet, spellType, gameObjectSpells); gameObjectSpells.sort(); @@ -613,7 +614,7 @@ @NotNull protected abstract MapActions init1(@NotNull final MapViewSettings mapViewSettings, @NotNull final MapArchObjectParserFactory<A> mapArchObjectParserFactory, @NotNull final MapArchObjectFactory<A> mapArchObjectFactory, @NotNull final GlobalSettings globalSettings, @NotNull final MapManager<G, A, R, V> mapManager, @NotNull final MapViewManager<G, A, R, V> mapViewManager, @NotNull final SelectedSquareView<G, A, R, V> selectedSquareView, @NotNull final GameObjectMatcher exitMatcher); - protected abstract void init4(@NotNull final GameObjectParser<G, A, R> gameObjectParser, @NotNull final AbstractArchetypeParser<G, A, R> archetypeParser, @NotNull final EditTypes editTypes, @NotNull final FaceObjects faceObjects, @NotNull final AnimationObjects animationObjects, final MainView<G, A, R, V> mainView, @NotNull final GlobalSettings globalSettings, @NotNull final ArchetypeSet<G, A, R> archetypeSet); + protected abstract AbstractArchetypeSetLoader newArchetypeSetLoader(@NotNull final GameObjectParser<G, A, R> gameObjectParser, @NotNull final AbstractArchetypeParser<G, A, R> archetypeParser, @NotNull final EditTypes editTypes, @NotNull final FaceObjects faceObjects, @NotNull final AnimationObjects animationObjects, @NotNull final GlobalSettings globalSettings, @NotNull final ArchetypeSet<G, A, R> archetypeSet); protected abstract void deleteLibraries(); Modified: trunk/src/app/net/sf/gridarta/gameobject/AbstractArchetypeSetLoader.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/AbstractArchetypeSetLoader.java 2008-11-12 06:52:22 UTC (rev 5716) +++ trunk/src/app/net/sf/gridarta/gameobject/AbstractArchetypeSetLoader.java 2008-11-12 08:49:40 UTC (rev 5717) @@ -130,4 +130,10 @@ @NotNull protected abstract String generateFaceName(@NotNull final String name); + /** + * Loads archetypes. + * @param parent the parent component for error messages + */ + public abstract void loadArchetypes(@NotNull final Component parent); + } // class AbstractArchetypeSetLoader This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-11-12 20:01:24
|
Revision: 5718 http://gridarta.svn.sourceforge.net/gridarta/?rev=5718&view=rev Author: akirschbaum Date: 2008-11-12 20:01:17 +0000 (Wed, 12 Nov 2008) Log Message: ----------- Add more errors to error collector dialog. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/gameobject/ArchetypeSetLoader.java trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/gameobject/ArchetypeSetLoader.java trunk/src/app/net/sf/gridarta/AbstractMainControl.java trunk/src/app/net/sf/gridarta/gameobject/AbstractArchetypeSetLoader.java trunk/src/app/net/sf/gridarta/gameobject/anim/AnimationObjects.java trunk/src/app/net/sf/gridarta/gameobject/anim/DefaultAnimationObjects.java trunk/src/app/net/sf/gridarta/gameobject/face/DefaultFaceObjects.java trunk/src/app/net/sf/gridarta/gameobject/face/FaceObjects.java trunk/src/app/net/sf/gridarta/messages.properties trunk/src/app/net/sf/gridarta/treasurelist/TreasureLoader.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-11-12 08:49:40 UTC (rev 5717) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-11-12 20:01:17 UTC (rev 5718) @@ -308,7 +308,7 @@ /** {@inheritDoc} */ @Override protected AbstractArchetypeSetLoader newArchetypeSetLoader(@NotNull final GameObjectParser<GameObject, MapArchObject, Archetype> gameObjectParser, @NotNull final AbstractArchetypeParser<GameObject, MapArchObject, Archetype> archetypeParser, @NotNull final EditTypes editTypes, @NotNull final FaceObjects faceObjects, @NotNull final AnimationObjects animationObjects, @NotNull final GlobalSettings globalSettings, @NotNull final net.sf.gridarta.gameobject.ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet) { - return new ArchetypeSetLoader(globalSettings, gameObjectParser, globalSettings.getCollectedDirectory(), archetypeSet, archetypeParser, editTypes, faceObjects, animationObjects, this); + return new ArchetypeSetLoader(globalSettings, gameObjectParser, globalSettings.getCollectedDirectory(), archetypeSet, archetypeParser, editTypes, faceObjects, animationObjects); } /** {@inheritDoc} */ Modified: trunk/crossfire/src/cfeditor/gameobject/ArchetypeSetLoader.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/ArchetypeSetLoader.java 2008-11-12 08:49:40 UTC (rev 5717) +++ trunk/crossfire/src/cfeditor/gameobject/ArchetypeSetLoader.java 2008-11-12 20:01:17 UTC (rev 5718) @@ -38,15 +38,13 @@ import net.sf.gridarta.gameobject.ArchetypeSet; import net.sf.gridarta.gameobject.anim.AnimationObjects; import net.sf.gridarta.gameobject.anim.AnimationParseException; -import net.sf.gridarta.gameobject.anim.DuplicateAnimationException; import net.sf.gridarta.gameobject.face.ArchFaceProvider; -import net.sf.gridarta.gameobject.face.DuplicateFaceException; import net.sf.gridarta.gameobject.face.FaceObjectProviders; import net.sf.gridarta.gameobject.face.FaceObjects; +import net.sf.gridarta.gui.errorview.DefaultErrorView; +import net.sf.gridarta.gui.errorview.ErrorViewCollector; import net.sf.gridarta.io.GameObjectParser; import net.sf.gridarta.utils.IOUtils; -import net.sf.japi.swing.ActionFactory; -import net.sf.japi.util.ThrowableHandler; import org.apache.log4j.Logger; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -63,9 +61,6 @@ /** The Logger for printing log messages. */ private static final Logger log = Logger.getLogger(ArchetypeSetLoader.class); - /** Action Factory. */ - private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("cfeditor"); - /** * The global settings instance. */ @@ -124,10 +119,9 @@ * @param editTypes the edit types instance * @param faceObjects the face objects instance * @param animationObjects the animation objects instance - * @param throwableHandler the throwable handler to use */ - public ArchetypeSetLoader(@NotNull final GlobalSettings globalSettings, @NotNull final GameObjectParser<GameObject, MapArchObject, Archetype> gameObjectParser, @NotNull final String collectedDirectory, @NotNull final ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final AbstractArchetypeParser<GameObject, MapArchObject, Archetype> archetypeParser, @NotNull final EditTypes editTypes, @NotNull final FaceObjects faceObjects, @NotNull final AnimationObjects animationObjects, @NotNull final ThrowableHandler<Throwable> throwableHandler) { - super(collectedDirectory, animationObjects, throwableHandler, faceObjects); + public ArchetypeSetLoader(@NotNull final GlobalSettings globalSettings, @NotNull final GameObjectParser<GameObject, MapArchObject, Archetype> gameObjectParser, @NotNull final String collectedDirectory, @NotNull final ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final AbstractArchetypeParser<GameObject, MapArchObject, Archetype> archetypeParser, @NotNull final EditTypes editTypes, @NotNull final FaceObjects faceObjects, @NotNull final AnimationObjects animationObjects) { + super(collectedDirectory, animationObjects, faceObjects); this.globalSettings = globalSettings; this.gameObjectParser = gameObjectParser; this.collectedDirectory = collectedDirectory; @@ -140,7 +134,7 @@ /** {@inheritDoc} */ @Override - public void loadArchetypes(@NotNull final Component parent) { + public void loadArchetypes(@NotNull final DefaultErrorView errorView, @NotNull final Component parent) { final long timeStart = System.currentTimeMillis(); if (log.isInfoEnabled()) { log.info("Start to load archetypes..."); @@ -152,14 +146,14 @@ final String fname; // here we go... if (globalSettings.isArchLoadedFromCollection()) { - loadArchFromCollected(archetypeParser, invObjects, parent); // load arches & images from collection + loadArchFromCollected(errorView, archetypeParser, invObjects); // load arches & images from collection fname = IGUIConstants.ARCH_FILE; } else { FaceObjectProviders.setNormal(new ArchFaceProvider()); archetypeSet.setLoadedFromArchive(false); // don't load from the collected files fname = globalSettings.getArchDirectory(); final File dir = new File(fname); - loadArchetypesFromFiles(archetypeParser, null, dir, 0, "default", "default", false, invObjects, parent); // load arches & images from individual files + loadArchetypesFromFiles(new ErrorViewCollector(errorView, dir.getPath()), archetypeParser, null, dir, 0, "default", "default", false, invObjects, parent); // load arches & images from individual files } archetypeSet.reportErrors(parent); @@ -181,20 +175,20 @@ /** * Load all arches and pngs from the collected files "archtypes" and * "crossfire.0" + * @param errorView the error view for reporting errors * @param archetypeParser the archetype parser to use * @param invObjects collects all inventory objects - * @param parent the parent component for error messages */ - private void loadArchFromCollected(@NotNull final AbstractArchetypeParser<GameObject, MapArchObject, Archetype> archetypeParser, @NotNull final List<GameObject> invObjects, @NotNull final Component parent) { + private void loadArchFromCollected(@NotNull final DefaultErrorView errorView, @NotNull final AbstractArchetypeParser<GameObject, MapArchObject, Archetype> archetypeParser, @NotNull final List<GameObject> invObjects) { archetypeSet.setLoadedFromArchive(true); // load from the collected files try { animationObjects.loadAnimTree(collectedDirectory, IGUIConstants.ANIMTREE_FILE); - } catch (final IOException e) { - log.warn("Cannot load animation tree file:" + e.getMessage()); + } catch (final IOException ex) { + errorView.addWarning(collectedDirectory + "/" + IGUIConstants.ANIMTREE_FILE, "can't load file: "+ ex.getMessage()); } + loadAnimationsFromCollect(errorView); try { - loadAnimationsFromCollect(); // open the resource file final BufferedReader stream = IOUtils.createReader(collectedDirectory, IGUIConstants.ARCH_FILE); try { @@ -203,18 +197,16 @@ } finally { stream.close(); } - faceObjects.loadFacesCollection(collectedDirectory, IGUIConstants.PNG_FILE, IGUIConstants.FACETREE_FILE); - } catch (final IOException e) { - // TODO - log.error("Error:", e); - } catch (final DuplicateFaceException e) { - ACTION_FACTORY.showMessageDialog(parent, "loadDuplicateFace", e.getDuplicate().getFaceName(), e.getDuplicate().getOriginalFilename(), e.getExisting().getOriginalFilename()); + } catch (final IOException ex) { + errorView.addError(collectedDirectory + "/" + IGUIConstants.ARCH_FILE, ex.getMessage()); } + faceObjects.loadFacesCollection(errorView, collectedDirectory, IGUIConstants.PNG_FILE, IGUIConstants.FACETREE_FILE); } /** * Loads all archetypes and faces by recursing through the * <code>arch/</code> directory tree. + * @param errorViewCollector the error view collector for reporting errors * @param archetypeParser the archetype parser to use * @param path the base directory relative path of <code>f</code> * @param f file path where we currently are @@ -226,7 +218,7 @@ * @param invObjects collects all inventory objects * @param parent the parent component for error messages */ - private void loadArchetypesFromFiles(@NotNull final AbstractArchetypeParser<GameObject, MapArchObject, Archetype> archetypeParser, @Nullable final String path, @NotNull final File f, final int folderLevel, @NotNull final String panelName, @NotNull final String folderName, final boolean noPanel, @NotNull final List<GameObject> invObjects, @NotNull final Component parent) { + private void loadArchetypesFromFiles(@NotNull final ErrorViewCollector errorViewCollector, @NotNull final AbstractArchetypeParser<GameObject, MapArchObject, Archetype> archetypeParser, @Nullable final String path, @NotNull final File f, final int folderLevel, @NotNull final String panelName, @NotNull final String folderName, final boolean noPanel, @NotNull final List<GameObject> invObjects, @NotNull final Component parent) { final String name = f.getName(); if (f.isDirectory()) { // now, setup the arch panels @@ -238,10 +230,10 @@ final String thisFolderName = folderLevel == 1 || folderLevel == 2 ? name : folderName; final String newPath = path == null ? "" : path + "/" + name; for (final String entry : entries) { - loadArchetypesFromFiles(archetypeParser, newPath, new File(f, entry), folderLevel + 1, thisPanelName, thisFolderName, false, invObjects, parent); + loadArchetypesFromFiles(errorViewCollector, archetypeParser, newPath, new File(f, entry), folderLevel + 1, thisPanelName, thisFolderName, false, invObjects, parent); } } else { - log.warn("Cannot read directory: " + f); + errorViewCollector.addWarning("can't read directory: " + f); } } } else if (f.isFile()) { // watch out for stuff that's not a file and not a directory!!! @@ -253,7 +245,7 @@ addPNGFace(f.getAbsolutePath(), path, name, parent); } } else if (name.endsWith(".face")) { - parseDefFace(f.getAbsolutePath(), path); + parseDefFace(errorViewCollector, f.getAbsolutePath(), path); } } } @@ -261,25 +253,24 @@ /** * Parsing face files (*.face). I think such files are no longer used and so * is this code. + * @param errorViewCollector the error view collector for reporting errors * @param path the base directory relative path of <code>filename</code> * @param filename filename */ - private void parseDefFace(@NotNull final String path, @NotNull final String filename) { + private void parseDefFace(@NotNull final ErrorViewCollector errorViewCollector, @NotNull final String path, @NotNull final String filename) { try { final Reader in = new BufferedReader(new FileReader(path)); try { - animationObjects.loadAnims(in, "animation ", true, filename); + animationObjects.loadAnims(errorViewCollector, in, "animation ", true, filename); } finally { in.close(); } } catch (final FileNotFoundException e) { - log.warn("Error opening face file: " + e); - } catch (final IOException e) { - log.warn("Error reading face file: " + e); - } catch (AnimationParseException e) { - log.warn("Error reading face file: " + e); - } catch (DuplicateAnimationException e) { - log.warn("Error reading face file: " + e); + errorViewCollector.addWarning("can't open file"); + } catch (final IOException ex) { + errorViewCollector.addWarning("can't read file: " + ex.getMessage()); + } catch (final AnimationParseException ex) { + errorViewCollector.addWarning("parsing error: " + ex.getMessage()); } } Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-11-12 08:49:40 UTC (rev 5717) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-11-12 20:01:17 UTC (rev 5718) @@ -343,7 +343,7 @@ @Override protected AbstractArchetypeSetLoader newArchetypeSetLoader(@NotNull final GameObjectParser<GameObject, MapArchObject, Archetype> gameObjectParser, @NotNull final AbstractArchetypeParser<GameObject, MapArchObject, Archetype> archetypeParser, @NotNull final EditTypes editTypes, @NotNull final FaceObjects faceObjects, @NotNull final AnimationObjects animationObjects, @NotNull final GlobalSettings globalSettings, @NotNull final net.sf.gridarta.gameobject.ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet) { MultiPositionData.init(globalSettings.getConfigurationDirectory()); - return new ArchetypeSetLoader(globalSettings, gameObjectParser, globalSettings.getCollectedDirectory(), archetypeSet, archetypeParser, editTypes, faceObjects, animationObjects, this); + return new ArchetypeSetLoader(globalSettings, gameObjectParser, globalSettings.getCollectedDirectory(), archetypeSet, archetypeParser, editTypes, faceObjects, animationObjects); } /** {@inheritDoc} */ Modified: trunk/daimonin/src/daieditor/gameobject/ArchetypeSetLoader.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/ArchetypeSetLoader.java 2008-11-12 08:49:40 UTC (rev 5717) +++ trunk/daimonin/src/daieditor/gameobject/ArchetypeSetLoader.java 2008-11-12 20:01:17 UTC (rev 5718) @@ -41,14 +41,13 @@ import net.sf.gridarta.gameobject.anim.AnimationParseException; import net.sf.gridarta.gameobject.anim.DuplicateAnimationException; import net.sf.gridarta.gameobject.face.ArchFaceProvider; -import net.sf.gridarta.gameobject.face.DuplicateFaceException; import net.sf.gridarta.gameobject.face.FaceObjectProviders; import net.sf.gridarta.gameobject.face.FaceObjects; +import net.sf.gridarta.gui.errorview.DefaultErrorView; +import net.sf.gridarta.gui.errorview.ErrorViewCollector; import net.sf.gridarta.io.GameObjectParser; import net.sf.gridarta.utils.IOUtils; import net.sf.gridarta.utils.Pair; -import net.sf.japi.swing.ActionFactory; -import net.sf.japi.util.ThrowableHandler; import org.apache.log4j.Logger; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -65,9 +64,6 @@ /** The Logger for printing log messages. */ private static final Logger log = Logger.getLogger(ArchetypeSetLoader.class); - /** Action Factory. */ - private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("cfeditor"); - /** * The global settings instance. */ @@ -117,12 +113,6 @@ private final AnimationObjects animationObjects; /** - * The throwable handler to use. - */ - @NotNull - private final ThrowableHandler<Throwable> throwableHandler; - - /** * The animation files. This variable is only used during arch collection * from files. */ @@ -139,10 +129,9 @@ * @param editTypes the edit types instance * @param faceObjects the face objects instance * @param animationObjects the animation objects instance - * @param throwableHandler the throwable handler to use */ - public ArchetypeSetLoader(@NotNull final GlobalSettings globalSettings, @NotNull final GameObjectParser<GameObject, MapArchObject, Archetype> gameObjectParser, @NotNull final String collectedDirectory, @NotNull final ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final AbstractArchetypeParser<GameObject, MapArchObject, Archetype> archetypeParser, @NotNull final EditTypes editTypes, @NotNull final FaceObjects faceObjects, @NotNull final AnimationObjects animationObjects, @NotNull final ThrowableHandler<Throwable> throwableHandler) { - super(collectedDirectory, animationObjects, throwableHandler, faceObjects); + public ArchetypeSetLoader(@NotNull final GlobalSettings globalSettings, @NotNull final GameObjectParser<GameObject, MapArchObject, Archetype> gameObjectParser, @NotNull final String collectedDirectory, @NotNull final ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final AbstractArchetypeParser<GameObject, MapArchObject, Archetype> archetypeParser, @NotNull final EditTypes editTypes, @NotNull final FaceObjects faceObjects, @NotNull final AnimationObjects animationObjects) { + super(collectedDirectory, animationObjects, faceObjects); this.globalSettings = globalSettings; this.gameObjectParser = gameObjectParser; this.collectedDirectory = collectedDirectory; @@ -151,12 +140,11 @@ this.editTypes = editTypes; this.faceObjects = faceObjects; this.animationObjects = animationObjects; - this.throwableHandler = throwableHandler; } /** {@inheritDoc} */ @Override - public void loadArchetypes(@NotNull final Component parent) { + public void loadArchetypes(@NotNull final DefaultErrorView errorView, @NotNull final Component parent) { final long timeStart = System.currentTimeMillis(); if (log.isInfoEnabled()) { log.info("Start to load archetypes..."); @@ -168,7 +156,7 @@ final String fname; // here we go... if (globalSettings.isArchLoadedFromCollection()) { - loadArchFromCollected(archetypeParser, invObjects, parent); // load arches & images from collection + loadArchFromCollected(errorView, archetypeParser, invObjects); // load arches & images from collection fname = IGUIConstants.ARCH_FILE; } else { FaceObjectProviders.setNormal(new ArchFaceProvider()); @@ -177,14 +165,18 @@ fname = globalSettings.getArchDirectory(); final File dir = new File(fname); addPNGFace(new File(dir, "dev/editor/bug.101.png").getAbsolutePath(), "/dev/editor", "bug.101.png", parent); - loadArchetypesFromFiles(archetypeParser, null, dir, 0, "default", "default", false, invObjects, parent); // load arches & images from individual files - loadAnimsFromFiles(); + final ErrorViewCollector archDirectoryErrorViewCollector = new ErrorViewCollector(errorView, fname); + loadArchetypesFromFiles(archDirectoryErrorViewCollector, archetypeParser, null, dir, 0, "default", "default", false, invObjects, parent); // load arches & images from individual files + loadAnimsFromFiles(archDirectoryErrorViewCollector); } archetypeSet.reportErrors(parent); - loadArchesFromArtifacts(archetypeParser, collectedDirectory + "/" + IGUIConstants.ARTIFACTS_FILE, "Artifacts", "artifacts", invObjects); - loadArchesFromArtifacts(archetypeParser, globalSettings.getMapsDirectory(), "Artifacts", "maps", invObjects); + final String artifactsFilename = collectedDirectory + "/" + IGUIConstants.ARTIFACTS_FILE; + loadArchesFromArtifacts(new ErrorViewCollector(errorView, artifactsFilename), archetypeParser, artifactsFilename, "Artifacts", "artifacts", invObjects); + final String mapsDirectory = globalSettings.getMapsDirectory(); + loadArchesFromArtifacts(new ErrorViewCollector(errorView, mapsDirectory), archetypeParser, mapsDirectory, "Artifacts", "maps", invObjects); + gameObjectParser.collectTempList(parent, archetypeSet, editTypes, invObjects, fname, true); archetypeSet.connectFaces(); // attach faces to arches @@ -203,16 +195,20 @@ /** * Load all arches and pngs from the collected files "archtypes" and * "crossfire.0" + * @param errorView the error view for reporting errors * @param archetypeParser the archetype parser to use * @param invObjects collects all inventory objects - * @param parent the parent component for error messages */ - private void loadArchFromCollected(@NotNull final AbstractArchetypeParser<GameObject, MapArchObject, Archetype> archetypeParser, @NotNull final List<GameObject> invObjects, @NotNull final Component parent) { + private void loadArchFromCollected(@NotNull final DefaultErrorView errorView, @NotNull final AbstractArchetypeParser<GameObject, MapArchObject, Archetype> archetypeParser, @NotNull final List<GameObject> invObjects) { archetypeSet.setLoadedFromArchive(true); // load from the collected files try { animationObjects.loadAnimTree(collectedDirectory, IGUIConstants.ANIMTREE_FILE); - loadAnimationsFromCollect(); + } catch (final IOException ex) { + errorView.addError(collectedDirectory + "/" + IGUIConstants.ANIMTREE_FILE, "can't load file: " + ex.getMessage()); + } + loadAnimationsFromCollect(errorView); + try { // open the resource file final BufferedReader stream = IOUtils.createReader(collectedDirectory, IGUIConstants.ARCH_FILE); try { @@ -221,18 +217,16 @@ } finally { stream.close(); } - faceObjects.loadFacesCollection(collectedDirectory, IGUIConstants.PNG_FILE, IGUIConstants.FACETREE_FILE); - } catch (final IOException e) { - // TODO - log.error("Error:", e); - } catch (final DuplicateFaceException e) { - ACTION_FACTORY.showMessageDialog(parent, "loadDuplicateFace", e.getDuplicate().getFaceName(), e.getDuplicate().getOriginalFilename(), e.getExisting().getOriginalFilename()); + } catch (final IOException ex) { + errorView.addError(collectedDirectory + "/" + IGUIConstants.ARCH_FILE, "can't load file: " + ex.getMessage()); } + faceObjects.loadFacesCollection(errorView, collectedDirectory, IGUIConstants.PNG_FILE, IGUIConstants.FACETREE_FILE); } /** * Loads all archetypes and faces by recursing through the * <code>arch/</code> directory tree. + * @param errorViewCollector the error view collector for reporting errors * @param archetypeParser the archetype parser to use * @param path the base directory relative path for <code>f</code> * @param f file path where we currently are @@ -244,7 +238,7 @@ * @param invObjects collects all inventory objects * @param parent the parent component for error messages */ - private void loadArchetypesFromFiles(@NotNull final AbstractArchetypeParser<GameObject, MapArchObject, Archetype> archetypeParser, @Nullable final String path, final File f, final int folderLevel, @Nullable final String panelName, @NotNull final String folderName, final boolean noPanel, @NotNull final List<GameObject> invObjects, @NotNull final Component parent) { + private void loadArchetypesFromFiles(@NotNull final ErrorViewCollector errorViewCollector, @NotNull final AbstractArchetypeParser<GameObject, MapArchObject, Archetype> archetypeParser, @Nullable final String path, final File f, final int folderLevel, @Nullable final String panelName, @NotNull final String folderName, final boolean noPanel, @NotNull final List<GameObject> invObjects, @NotNull final Component parent) { final String name = f.getName(); if (f.isDirectory()) { // now, setup the arch panels @@ -256,10 +250,10 @@ final String thisFolderName = folderLevel == 1 || folderLevel == 2 ? name : folderName; final String newPath = path == null ? "" : path + "/" + name; for (final String entry : entries) { - loadArchetypesFromFiles(archetypeParser, newPath, new File(f, entry), folderLevel + 1, thisPanelName, thisFolderName, noPanel || name.equalsIgnoreCase("intern"), invObjects, parent); + loadArchetypesFromFiles(errorViewCollector, archetypeParser, newPath, new File(f, entry), folderLevel + 1, thisPanelName, thisFolderName, noPanel || name.equalsIgnoreCase("intern"), invObjects, parent); } } else { - log.warn("Cannot read directory: " + f); + errorViewCollector.addWarning("can't read directory: " + f); } } } else if (f.isFile()) { // watch out for stuff that's not a file and not a directory!!! @@ -278,6 +272,7 @@ * This method takes a filename or directory name as argument. In case of a * directory it is recursivly traversed and all artifact files (*.art) get * parsed. + * @param errorViewCollector the error view collector for reporting errors * @param archetypeParser the archetype parser to use * @param filename This can be a filename or a directory name Load "pseudo * arches" from file "artifacts" WARNING: Don't include multi arches in the @@ -286,7 +281,7 @@ * @param folderName the folder to add artifacts to * @param invObjects collects all inventory objects */ - private void loadArchesFromArtifacts(@NotNull final AbstractArchetypeParser<GameObject, MapArchObject, Archetype> archetypeParser, final String filename, @NotNull final String panelName, @NotNull final String folderName, @NotNull final List<GameObject> invObjects) { + private void loadArchesFromArtifacts(@NotNull final ErrorViewCollector errorViewCollector, @NotNull final AbstractArchetypeParser<GameObject, MapArchObject, Archetype> archetypeParser, final String filename, @NotNull final String panelName, @NotNull final String folderName, @NotNull final List<GameObject> invObjects) { final File f = new File(filename); if (f.isDirectory()) { // This is a directory -> only accept *.art files and directories @@ -301,7 +296,7 @@ if (traverse != null) { Arrays.sort(traverse); for (final String entry : traverse) { - loadArchesFromArtifacts(archetypeParser, filename + "/" + entry, panelName, folderName, invObjects); + loadArchesFromArtifacts(errorViewCollector, archetypeParser, filename + "/" + entry, panelName, folderName, invObjects); } } // This was a directory -> nothing to parse @@ -357,7 +352,7 @@ // TODO:Then why not check this and throw an exception if not? final Archetype archetype = archetypeSet.getArchetype(defArchName); if (name == null || defArchName == null || name.length() == 0 || defArchName.length() == 0 || archetype == null) { - log.warn("Artifacts file: Line " + lineCount + " Object >" + defArchName + "< / >" + name + "< / >" + objTitle + "< has missing name or defArch"); + errorViewCollector.addWarning("line " + lineCount + " Object >" + defArchName + "< / >" + name + "< / >" + objTitle + "< has missing name or defArch"); } else if (editorCode != 0 && editorCode != 2) { // the next line of our file is part of a arch parse until a "end" comes // now the editor will do the same as the real server: // get the default arch as base and parse the new values over it @@ -381,10 +376,10 @@ } finally { myInput.close(); } - } catch (final FileNotFoundException e) { - log.warn("Artifacts file '" + filename + "' could not be found"); - } catch (final IOException e) { - log.warn("IOException in reading Artifacts!"); + } catch (final FileNotFoundException ex) { + errorViewCollector.addWarning("can't open file"); + } catch (final IOException ex) { + errorViewCollector.addWarning("can't read file: " + ex.getMessage()); } } @@ -398,22 +393,24 @@ /** * This method loads animations that are separately defined by looping * through all files that were previously collected by {@link - * #loadArchetypesFromFiles(AbstractArchetypeParser, File, String, File, - * int, String, String, boolean, List, Component)}. Do not invoke this - * method if <code>loadArchetypesFromFiles()</code> wasn't invoked. + * #loadArchetypesFromFiles(ErrorViewCollector, AbstractArchetypeParser, + * String, File, int, String, String, boolean, List, Component)}. Do not + * invoke this method if <code>loadArchetypesFromFiles()</code> wasn't + * invoked. + * @param errorViewCollector the error view collector for reporting errors */ - private void loadAnimsFromFiles() { + private void loadAnimsFromFiles(@NotNull final ErrorViewCollector errorViewCollector) { for (final Pair<String, File> pair : animFiles) { final String animPath = pair.getFirst(); final File animFile = pair.getSecond(); try { - animationObjects.loadAnims(animPath, animFile, "anim ", false); - } catch (final DuplicateAnimationException e) { - throwableHandler.handleThrowable(e); - } catch (final IOException e) { - throwableHandler.handleThrowable(e); - } catch (final AnimationParseException e) { - throwableHandler.handleThrowable(new AnimationParseException(e, animFile.toURI())); + animationObjects.loadAnims(errorViewCollector, animPath, animFile, "anim ", false); + } catch (final DuplicateAnimationException ex) { + errorViewCollector.addWarning(animFile + ": duplicate animation: " + ex.getMessage()); + } catch (final IOException ex) { + errorViewCollector.addWarning(animFile + ": can't read file: " + ex.getMessage()); + } catch (final AnimationParseException ex) { + errorViewCollector.addWarning(animFile + ": parsing error: " + ex.getMessage()); } } animFiles = null; Modified: trunk/src/app/net/sf/gridarta/AbstractMainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2008-11-12 08:49:40 UTC (rev 5717) +++ trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2008-11-12 20:01:17 UTC (rev 5718) @@ -483,7 +483,7 @@ final ScriptArchEditor<G> scriptArchEditor = newScriptArchEditor(scriptedEventFactory, scriptExtension, scriptName, scriptArchUtils.createEventTypeBox(), scriptFileFilter, globalSettings, mapManager); scriptArchEditor.initEventTypeBoxes(scriptArchUtils); GameObject.initialize(archetypeSet, archetypeTypeSet, gameObjectMatchers, scriptArchEditor, animationObjects, SystemIcons.getNofaceTileIcon(), newScriptArchData(scriptedEventFactory, scriptArchUtils, scriptArchEditor)); - newArchetypeSetLoader(gameObjectParser, archetypeParser, editTypes, faceObjects, animationObjects, globalSettings, archetypeSet).loadArchetypes(mainView); + newArchetypeSetLoader(gameObjectParser, archetypeParser, editTypes, faceObjects, animationObjects, globalSettings, archetypeSet).loadArchetypes(errorView, mainView); if (spellType != 0) { new ArchetypeSetSpellLoader<G, A, R>().load(archetypeSet, spellType, gameObjectSpells); gameObjectSpells.sort(); Modified: trunk/src/app/net/sf/gridarta/gameobject/AbstractArchetypeSetLoader.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/AbstractArchetypeSetLoader.java 2008-11-12 08:49:40 UTC (rev 5717) +++ trunk/src/app/net/sf/gridarta/gameobject/AbstractArchetypeSetLoader.java 2008-11-12 20:01:17 UTC (rev 5718) @@ -25,14 +25,14 @@ import java.io.Reader; import net.sf.gridarta.gameobject.anim.AnimationObjects; import net.sf.gridarta.gameobject.anim.AnimationParseException; -import net.sf.gridarta.gameobject.anim.DuplicateAnimationException; import net.sf.gridarta.gameobject.face.ArchFaceProvider; import net.sf.gridarta.gameobject.face.DuplicateFaceException; import net.sf.gridarta.gameobject.face.FaceObjectProviders; import net.sf.gridarta.gameobject.face.FaceObjects; +import net.sf.gridarta.gui.errorview.DefaultErrorView; +import net.sf.gridarta.gui.errorview.ErrorViewCollector; import net.sf.gridarta.utils.IOUtils; import net.sf.japi.swing.ActionFactory; -import net.sf.japi.util.ThrowableHandler; import org.jetbrains.annotations.NotNull; /** @@ -60,12 +60,6 @@ private final AnimationObjects animationObjects; /** - * The throwable handler to use. - */ - @NotNull - private final ThrowableHandler<Throwable> throwableHandler; - - /** * The face objects instance. */ @NotNull @@ -75,32 +69,32 @@ * Creates a new instance. * @param collectedDirectory the collected directory * @param animationObjects the animation objects instance - * @param throwableHandler the throwable handler to use * @param faceObjects the face ojects instance */ - protected AbstractArchetypeSetLoader(@NotNull final String collectedDirectory, @NotNull final AnimationObjects animationObjects, @NotNull final ThrowableHandler<Throwable> throwableHandler, @NotNull final FaceObjects faceObjects) { + protected AbstractArchetypeSetLoader(@NotNull final String collectedDirectory, @NotNull final AnimationObjects animationObjects, @NotNull final FaceObjects faceObjects) { this.collectedDirectory = collectedDirectory; this.animationObjects = animationObjects; - this.throwableHandler = throwableHandler; this.faceObjects = faceObjects; } - /** Loading all animations from the big collected animations file. */ + /** + * Loads all animations from the big collected animations file. + * @param errorView the error view for reporting errors + */ @SuppressWarnings({"InstanceMethodNamingConvention"}) - protected void loadAnimationsFromCollect() { + protected void loadAnimationsFromCollect(@NotNull final DefaultErrorView errorView) { + final ErrorViewCollector errorViewCollector = new ErrorViewCollector(errorView, "animations"); try { final Reader in = IOUtils.createReader(collectedDirectory, "animations"); try { - animationObjects.loadAnims(in, "anim ", false, null); + animationObjects.loadAnims(errorViewCollector, in, "anim ", false, null); } finally { in.close(); } - } catch (final DuplicateAnimationException e) { - throwableHandler.handleThrowable(e); - } catch (final IOException e) { - throwableHandler.handleThrowable(e); - } catch (final AnimationParseException e) { - throwableHandler.handleThrowable(new AnimationParseException(e, new File("animations").toURI())); + } catch (final IOException ex) { + errorViewCollector.addError("can't load file: " + ex.getMessage()); + } catch (final AnimationParseException ex) { + errorViewCollector.addError("parsing error: " + ex.getMessage()); } } @@ -132,8 +126,9 @@ /** * Loads archetypes. + * @param errorView the error view for reporting errors * @param parent the parent component for error messages */ - public abstract void loadArchetypes(@NotNull final Component parent); + public abstract void loadArchetypes(@NotNull final DefaultErrorView errorView, @NotNull final Component parent); } // class AbstractArchetypeSetLoader Modified: trunk/src/app/net/sf/gridarta/gameobject/anim/AnimationObjects.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/anim/AnimationObjects.java 2008-11-12 08:49:40 UTC (rev 5717) +++ trunk/src/app/net/sf/gridarta/gameobject/anim/AnimationObjects.java 2008-11-12 20:01:17 UTC (rev 5718) @@ -25,6 +25,7 @@ import java.io.Reader; import net.sf.gridarta.data.NamedObjects; import net.sf.gridarta.gameobject.Collectable; +import net.sf.gridarta.gui.errorview.ErrorViewCollector; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -51,6 +52,7 @@ /** * Loads animations from a file. + * @param errorViewCollector the error view collector for reporting errors * @param path the animation path * @param animFile file to load animations from * @param startKey the key that begins an animation block; it must end with @@ -63,13 +65,14 @@ * errors * @throws DuplicateAnimationException in case an animation was not unique */ - void loadAnims(@NotNull final String path, @NotNull File animFile, @NotNull String startKey, boolean ignoreOtherText) throws FileNotFoundException, IOException, AnimationParseException, DuplicateAnimationException; + void loadAnims(@NotNull ErrorViewCollector errorViewCollector, @NotNull final String path, @NotNull File animFile, @NotNull String startKey, boolean ignoreOtherText) throws FileNotFoundException, IOException, AnimationParseException, DuplicateAnimationException; /** * Loads any number of animations from a reader. It is not neccessary to * provide a BufferedReader for buffering. This method will always wrap the * supplied <var>reader</var> with a BufferedReader if the supplied reader * isn't already a BufferedReader itself. + * @param errorViewCollector the error view collector for reporting errors * @param reader Reader to load animations from * @param startKey the key that begins an animation block; it must end with * a space character @@ -80,9 +83,8 @@ * @throws IOException in case of I/O errors * @throws AnimationParseException in case parsing the animation reveals * errors - * @throws DuplicateAnimationException in case an animation was not unique */ - void loadAnims(Reader reader, @NotNull String startKey, boolean ignoreOtherText, @Nullable String path) throws IOException, AnimationParseException, DuplicateAnimationException; + void loadAnims(@NotNull ErrorViewCollector errorViewCollector, Reader reader, @NotNull String startKey, boolean ignoreOtherText, @Nullable String path) throws IOException, AnimationParseException; /** * Loads animations from a file. Modified: trunk/src/app/net/sf/gridarta/gameobject/anim/DefaultAnimationObjects.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/anim/DefaultAnimationObjects.java 2008-11-12 08:49:40 UTC (rev 5717) +++ trunk/src/app/net/sf/gridarta/gameobject/anim/DefaultAnimationObjects.java 2008-11-12 20:01:17 UTC (rev 5718) @@ -32,6 +32,7 @@ import java.util.HashMap; import java.util.Map; import net.sf.gridarta.data.AbstractNamedObjects; +import net.sf.gridarta.gui.errorview.ErrorViewCollector; import net.sf.gridarta.utils.IOUtils; import net.sf.japi.swing.ActionFactory; import net.sf.japi.swing.misc.Progress; @@ -69,10 +70,10 @@ } /** {@inheritDoc} */ - public void loadAnims(@NotNull final String path, @NotNull final File animFile, @NotNull final String startKey, final boolean ignoreOtherText) throws FileNotFoundException, IOException, AnimationParseException, DuplicateAnimationException { + public void loadAnims(@NotNull final ErrorViewCollector errorViewCollector, @NotNull final String path, @NotNull final File animFile, @NotNull final String startKey, final boolean ignoreOtherText) throws FileNotFoundException, IOException, AnimationParseException, DuplicateAnimationException { final Reader in = new InputStreamReader(new FileInputStream(animFile), IOUtils.MAP_ENCODING); try { - loadAnims(in, startKey, ignoreOtherText, path); + loadAnims(errorViewCollector, in, startKey, ignoreOtherText, path); } finally { in.close(); } @@ -132,7 +133,7 @@ /** {@inheritDoc} */ @SuppressWarnings({"IOResourceOpenedButNotSafelyClosed"}) - public void loadAnims(final Reader reader, @NotNull final String startKey, final boolean ignoreOtherText, @Nullable final String path) throws IOException, AnimationParseException, DuplicateAnimationException { + public void loadAnims(@NotNull final ErrorViewCollector errorViewCollector, final Reader reader, @NotNull final String startKey, final boolean ignoreOtherText, @Nullable final String path) throws IOException, AnimationParseException { final BufferedReader in = reader instanceof BufferedReader ? (BufferedReader) reader : new BufferedReader(reader); boolean inAnim = false; String animName = null; @@ -155,7 +156,11 @@ throw new AnimationParseException(startKey + "...", line, lineNumber); } inAnim = false; - addAnimationObject(animName, animText.toString(), path); + try { + addAnimationObject(animName, animText.toString(), path); + } catch (final DuplicateAnimationException ex) { + errorViewCollector.addWarning("duplicate animation: " + animName); + } } else if (inAnim) { animText.append(line).append('\n'); } else if (!ignoreOtherText) { Modified: trunk/src/app/net/sf/gridarta/gameobject/face/DefaultFaceObjects.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/face/DefaultFaceObjects.java 2008-11-12 08:49:40 UTC (rev 5717) +++ trunk/src/app/net/sf/gridarta/gameobject/face/DefaultFaceObjects.java 2008-11-12 20:01:17 UTC (rev 5718) @@ -39,6 +39,8 @@ import java.util.regex.Pattern; import net.sf.gridarta.CommonConstants; import net.sf.gridarta.data.AbstractNamedObjects; +import net.sf.gridarta.gui.errorview.DefaultErrorView; +import net.sf.gridarta.gui.errorview.ErrorViewCollector; import net.sf.gridarta.utils.ArrayUtils; import net.sf.gridarta.utils.IOUtils; import net.sf.japi.swing.ActionFactory; @@ -258,96 +260,107 @@ } /** {@inheritDoc} */ - public void loadFacesCollection(@NotNull final String collectedDirectory, @NotNull final String faceFile, @NotNull final String treeFile) throws IOException, FileNotFoundException, DuplicateFaceException { - final File tmpFaceFile = IOUtils.getFile(collectedDirectory, faceFile); - FaceObjectProviders.setNormal(new CollectedFaceProvider(tmpFaceFile)); - final InputStream inputStream = new FileInputStream(tmpFaceFile); - final ByteArrayOutputStream bufOut = new ByteArrayOutputStream((int) tmpFaceFile.length()); + public void loadFacesCollection(@NotNull final DefaultErrorView errorView, @NotNull final String collectedDirectory, @NotNull final String faceFile, @NotNull final String treeFile) { + final File tmpFaceFile; try { - final byte[] buf = new byte[4096]; - for (; ;) { - final int len = inputStream.read(buf); - if (len == -1) { - break; - } - bufOut.write(buf, 0, len); - } - } finally { - inputStream.close(); + tmpFaceFile = IOUtils.getFile(collectedDirectory, faceFile); + } catch (final IOException ex) { + errorView.addError(collectedDirectory + "/" + faceFile, "can't load file: " + ex.getMessage()); + return; } - final byte[] data = bufOut.toByteArray(); - - // Note: treeIn might stay null, this is optional data. - BufferedReader treeIn = null; + final ErrorViewCollector faceFileErrorViewCollector = new ErrorViewCollector(errorView, tmpFaceFile.getPath()); try { - //cher: it is safely closed but optional. InspectionGadgets doesn't detect where it's closed. - //noinspection IOResourceOpenedButNotSafelyClosed - treeIn = IOUtils.createReader(collectedDirectory, treeFile); - } catch (final FileNotFoundException e) { - log.warn(ACTION_FACTORY.format("logCantLoadFaceTree", treeFile)); - } - final byte[] tag = "IMAGE ".getBytes(); // this is the starting string for a new png - final StringBuilder faceB = new StringBuilder(); // face name of png - try { - int offset = 0; - while (offset < data.length) { - // File: Structure* - // Structure: "IMAGE " seqnr ' ' size ' ' facename '\n' PNGBinary - if (!ArrayUtils.contains(data, offset, tag)) { // check for IMAGE - throw new IOException("Error in file " + pngFile + " at position " + offset); - } - offset += 6; // skip "IMAGE "; - while (data[offset++] != (byte) 0x20) { - ; // skip seqnr ' ' - } - int size = 0; - char c; - while ((c = (char) data[offset++]) != ' ') { // read size ' ' - if (c < '0' || c > '9') { - log.warn("Syntax error in file " + pngFile + " at position " + offset + "."); - throw new IOException("syntax error at position " + offset + ": not a digit"); + FaceObjectProviders.setNormal(new CollectedFaceProvider(tmpFaceFile)); + final InputStream inputStream = new FileInputStream(tmpFaceFile); + final ByteArrayOutputStream bufOut = new ByteArrayOutputStream((int) tmpFaceFile.length()); + try { + final byte[] buf = new byte[4096]; + for (; ;) { + final int len = inputStream.read(buf); + if (len == -1) { + break; } - size *= 10; - size += c - '0'; + bufOut.write(buf, 0, len); } - faceB.setLength(0); - while ((c = (char) data[offset++]) != '\n') { // read facename '\n' - if (c == '/') { - faceB.setLength(0); - } else { - faceB.append(c); + } finally { + inputStream.close(); + } + final byte[] data = bufOut.toByteArray(); + + // Note: treeIn might stay null, this is optional data. + final ErrorViewCollector treeFileErrorViewCollector = new ErrorViewCollector(errorView, collectedDirectory + "/" + treeFile); + BufferedReader treeIn = null; + try { + //cher: it is safely closed but optional. InspectionGadgets doesn't detect where it's closed. + //noinspection IOResourceOpenedButNotSafelyClosed + treeIn = IOUtils.createReader(collectedDirectory, treeFile); + } catch (final FileNotFoundException e) { + treeFileErrorViewCollector.addWarning("can't load file"); + } + final byte[] tag = "IMAGE ".getBytes(); // this is the starting string for a new png + final StringBuilder faceB = new StringBuilder(); // face name of png + try { + int offset = 0; + while (offset < data.length) { + // File: Structure* + // Structure: "IMAGE " seqnr ' ' size ' ' facename '\n' PNGBinary + if (!ArrayUtils.contains(data, offset, tag)) { // check for IMAGE + throw new IOException("expecting 'IMAGE' at position " + offset); } - } - final String faceName = faceB.toString().intern(); + offset += 6; // skip "IMAGE "; + while (data[offset++] != (byte) 0x20) { + ; // skip seqnr ' ' + } + int size = 0; + char c; + while ((c = (char) data[offset++]) != ' ') { // read size ' ' + if (c < '0' || c > '9') { + throw new IOException("syntax error at position " + offset + ": not a digit"); + } + size *= 10; + size += c - '0'; + } + faceB.setLength(0); + while ((c = (char) data[offset++]) != '\n') { // read facename '\n' + if (c == '/') { + faceB.setLength(0); + } else { + faceB.append(c); + } + } + final String faceName = faceB.toString().intern(); - if (offset + size > data.length) { - throw new IOException("Truncated face data in file " + pngFile + " at position " + offset); - } + if (offset + size > data.length) { + throw new IOException("truncated at position " + offset); + } - if (treeIn != null) { - final String originalFilename = treeIn.readLine(); - if (originalFilename == null) { - log.warn(ACTION_FACTORY.format("logFaceObjectWithoutOriginalName", faceName)); - } else { - final Matcher matcher = faceTreeInputPattern.matcher(originalFilename); - if (!matcher.matches()) { - log.warn("Syntax error in " + treeFile + ": " + originalFilename); + if (treeIn != null) { + final String originalFilename = treeIn.readLine(); + if (originalFilename == null) { + log.warn(ACTION_FACTORY.format("logFaceObjectWithoutOriginalName", faceName)); } else { - addFaceObject(faceName, matcher.group(1), offset, size); + final Matcher matcher = faceTreeInputPattern.matcher(originalFilename); + if (!matcher.matches()) { + treeFileErrorViewCollector.addWarning("syntax error: " + originalFilename); + } else { + try { + addFaceObject(faceName, matcher.group(1), offset, size); + } catch (final DuplicateFaceException ex) { + faceFileErrorViewCollector.addWarning("duplicate face: " + ex.getDuplicate().getFaceName()); + } + } } } + ((CollectedFaceProvider) FaceObjectProviders.normal).addInfo(faceName, offset, size); // TODO Remove me + offset += size; } - ((CollectedFaceProvider) FaceObjectProviders.normal).addInfo(faceName, offset, size); // TODO Remove me - offset += size; - } - } finally { - try { + } finally { if (treeIn != null) { treeIn.close(); } - } catch (final IOException e) { - /* ignore */ } + } catch (final IOException ex) { + faceFileErrorViewCollector.addError("can't load file: " + ex.getMessage()); } } Modified: trunk/src/app/net/sf/gridarta/gameobject/face/FaceObjects.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/face/FaceObjects.java 2008-11-12 08:49:40 UTC (rev 5717) +++ trunk/src/app/net/sf/gridarta/gameobject/face/FaceObjects.java 2008-11-12 20:01:17 UTC (rev 5718) @@ -19,10 +19,9 @@ package net.sf.gridarta.gameobject.face; -import java.io.FileNotFoundException; -import java.io.IOException; import net.sf.gridarta.data.NamedObjects; import net.sf.gridarta.gameobject.Collectable; +import net.sf.gridarta.gui.errorview.DefaultErrorView; import org.jetbrains.annotations.NotNull; /** @@ -33,14 +32,12 @@ /** * Loads all faces from a png collection file. + * @param errorView the error view for reporting errors * @param collectedDirectory directory to load from * @param faceFile file to load faces from * @param treeFile file to load tree information from - * @throws IOException in case of I/O errors - * @throws FileNotFoundException in case the file couldn't be opened - * @throws DuplicateFaceException in case a face was not unique */ - void loadFacesCollection(@NotNull String collectedDirectory, @NotNull String faceFile, @NotNull String treeFile) throws IOException, FileNotFoundException, DuplicateFaceException; + void loadFacesCollection(@NotNull DefaultErrorView errorView, @NotNull String collectedDirectory, @NotNull String faceFile, @NotNull String treeFile); /** * Adds a new face object. Modified: trunk/src/app/net/sf/gridarta/messages.properties =================================================================== --- trunk/src/app/net/sf/gridarta/messages.properties 2008-11-12 08:49:40 UTC (rev 5717) +++ trunk/src/app/net/sf/gridarta/messages.properties 2008-11-12 20:01:17 UTC (rev 5718) @@ -526,7 +526,6 @@ logUnexpectedException=Unexpected exception: {0} logArchfileNotFound=Archfile {0} could not be found logCanonIOE=IOException while canonizing path: {0} -logCantLoadFaceTree=Can''t load face tree. You won''t be able to easily choose faces from a tree. To change this, you need either a version of <code>arch/</code> that contains <code>{0}</code>, or you have to collect arches yourself. logExitWithExit=Exiting with System.exit(). logExitWithoutExit=Trying to exit without System.exit(). logFaceObjectWithoutOriginalName=No originalName for {0}! Modified: trunk/src/app/net/sf/gridarta/treasurelist/TreasureLoader.java =================================================================== --- trunk/src/app/net/sf/gridarta/treasurelist/TreasureLoader.java 2008-11-12 08:49:40 UTC (rev 5717) +++ trunk/src/app/net/sf/gridarta/treasurelist/TreasureLoader.java 2008-11-12 20:01:17 UTC (rev 5718) @@ -87,7 +87,10 @@ // first step: parsing datafile, adding all treasurelists to the tmpList vector for (final TreasureLocation treasureLocation : treasures) { - loadTreasureList(new ErrorViewCollector(errorView, treasureLocation.getFname()), treasureLocation.getDname(), treasureLocation.getFname(), tmpList, needLink); + final String dname = treasureLocation.getDname(); + final String fname = treasureLocation.getFname(); + final ErrorViewCollector errorViewCollector = new ErrorViewCollector(errorView, fname == null ? dname : dname + fname); + loadTreasureList(errorViewCollector, dname, fname, tmpList, needLink); } // second step: sort alphabetically and link sub-treasurelist entries This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-11-12 22:12:30
|
Revision: 5723 http://gridarta.svn.sourceforge.net/gridarta/?rev=5723&view=rev Author: akirschbaum Date: 2008-11-12 22:12:24 +0000 (Wed, 12 Nov 2008) Log Message: ----------- Partially implement #1627422 (Check box option to avoid startup warnings): Use it for "spells.xml" file related errors. Modified Paths: -------------- trunk/daimonin/ChangeLog trunk/src/app/net/sf/gridarta/AbstractMainControl.java trunk/src/app/net/sf/gridarta/spells/XMLSpellLoader.java Modified: trunk/daimonin/ChangeLog =================================================================== --- trunk/daimonin/ChangeLog 2008-11-12 22:02:13 UTC (rev 5722) +++ trunk/daimonin/ChangeLog 2008-11-12 22:12:24 UTC (rev 5723) @@ -1,7 +1,8 @@ 2008-11-12 Andreas Kirschbaum * Partially implement #1627422 (Check box option to avoid startup - warnings): Use it for "types.xml" file related errors. + warnings): Use it for "types.xml" and "spells.xml" file related + errors. 2008-11-11 Andreas Kirschbaum Modified: trunk/src/app/net/sf/gridarta/AbstractMainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2008-11-12 22:02:13 UTC (rev 5722) +++ trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2008-11-12 22:12:24 UTC (rev 5723) @@ -489,7 +489,7 @@ gameObjectSpells.sort(); } if (spellFile != null) { - XMLSpellLoader.load(globalSettings.getConfigurationDirectory(), spellFile, xmlHelper.getDocumentBuilder(), numberSpells); + XMLSpellLoader.load(errorView, globalSettings.getConfigurationDirectory(), spellFile, xmlHelper.getDocumentBuilder(), numberSpells); numberSpells.sort(); } Modified: trunk/src/app/net/sf/gridarta/spells/XMLSpellLoader.java =================================================================== --- trunk/src/app/net/sf/gridarta/spells/XMLSpellLoader.java 2008-11-12 22:02:13 UTC (rev 5722) +++ trunk/src/app/net/sf/gridarta/spells/XMLSpellLoader.java 2008-11-12 22:12:24 UTC (rev 5723) @@ -21,6 +21,8 @@ import java.io.IOException; import javax.xml.parsers.DocumentBuilder; +import net.sf.gridarta.gui.errorview.DefaultErrorView; +import net.sf.gridarta.gui.errorview.ErrorViewCollector; import net.sf.gridarta.utils.IOUtils; import net.sf.japi.xml.NodeListIterator; import org.apache.log4j.Logger; @@ -46,12 +48,14 @@ /** * Load an XML spell definitions file. + * @param errorView the error view for reporting errors * @param baseDir The base directory of <code>filename</code>. * @param filename The file name of the spell definitions file. * @param documentBuilder The Document Builder to use for parsing. * @param spells The <code>Spells</code> instance to add the spells to. */ - public static void load(@NotNull final String baseDir, @NotNull final String filename, @NotNull final DocumentBuilder documentBuilder, @NotNull final Spells<NumberSpell> spells) { + public static void load(@NotNull final DefaultErrorView errorView, @NotNull final String baseDir, @NotNull final String filename, @NotNull final DocumentBuilder documentBuilder, @NotNull final Spells<NumberSpell> spells) { + final ErrorViewCollector errorViewCollector = new ErrorViewCollector(errorView, baseDir + "/" + filename); try { // parse xml document final Document doc = documentBuilder.parse(IOUtils.getResourceURLAsString(baseDir, filename)); @@ -59,23 +63,22 @@ // retrieve the spell data from the xml final Element root = doc.getDocumentElement(); if (root == null || !"spells".equalsIgnoreCase(root.getNodeName())) { - log.warn("File '" + filename + "' lacks root element 'spells'."); + errorViewCollector.addWarning("root element 'spells' is missing"); } else { // initialize array with appropriate size int numSpells = 0; for (final Element spellElem : new NodeListIterator<Element>(root, "spell")) { - if (spellElem.getAttribute("id") == null) { - log.warn("In File '" + filename + "': Found 'spell' element without 'id'"); + errorViewCollector.addWarning("found 'spell' element without 'id'"); } else if (spellElem.getAttribute("name") == null) { - log.warn("In File '" + filename + "': Found 'spell' element without 'name'"); + errorViewCollector.addWarning("found 'spell' element without 'name'"); } else { try { // parse spell number and -name spells.add(new NumberSpell(spellElem.getAttribute("name").trim(), Integer.parseInt(spellElem.getAttribute("id")))); numSpells++; } catch (final NumberFormatException de) { - log.warn("Parsing error in '" + filename + "':\n spell id '" + spellElem.getAttribute("id") + "' is not an integer."); + errorViewCollector.addWarning("parsing error: spell id '" + spellElem.getAttribute("id") + "' is not an integer."); } } } @@ -83,13 +86,13 @@ // loading successful log.info("Loaded " + numSpells + " defined spells from '" + filename + "'"); if (numSpells == 0) { - log.warn("File '" + filename + "' has no content."); + errorViewCollector.addWarning("no content"); } } - } catch (final SAXException e) { - log.error("Parsing error in '" + filename + "':\n" + e.getMessage() + '\n'); - } catch (final IOException e) { - log.error("Cannot read file '" + filename + "'!"); + } catch (final SAXException ex) { + errorViewCollector.addError("parsing error:" + ex.getMessage()); + } catch (final IOException ex) { + errorViewCollector.addError("can't read file: " + ex.getMessage()); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-11-12 22:38:51
|
Revision: 5725 http://gridarta.svn.sourceforge.net/gridarta/?rev=5725&view=rev Author: akirschbaum Date: 2008-11-12 22:38:44 +0000 (Wed, 12 Nov 2008) Log Message: ----------- Replace String with File. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/gameobject/ArchetypeParser.java trunk/crossfire/src/cfeditor/gameobject/ArchetypeSetLoader.java trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/MultiPositionData.java trunk/daimonin/src/daieditor/gameobject/ArchetypeParser.java trunk/daimonin/src/daieditor/gameobject/ArchetypeSetLoader.java trunk/src/app/net/sf/gridarta/AbstractMainControl.java trunk/src/app/net/sf/gridarta/autojoin/AutojoinLists.java trunk/src/app/net/sf/gridarta/gameobject/AbstractArchetypeParser.java trunk/src/app/net/sf/gridarta/gameobject/AbstractArchetypeSetLoader.java trunk/src/app/net/sf/gridarta/gameobject/ArchetypeParser.java trunk/src/app/net/sf/gridarta/gameobject/anim/AnimationObjects.java trunk/src/app/net/sf/gridarta/gameobject/anim/DefaultAnimationObjects.java trunk/src/app/net/sf/gridarta/gameobject/face/DefaultFaceObjects.java trunk/src/app/net/sf/gridarta/gameobject/face/FaceObjects.java trunk/src/app/net/sf/gridarta/treasurelist/TreasureLoader.java trunk/src/app/net/sf/gridarta/utils/IOUtils.java trunk/src/app/net/sf/gridarta/utils/XmlHelper.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-11-12 22:17:29 UTC (rev 5724) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-11-12 22:38:44 UTC (rev 5725) @@ -308,7 +308,7 @@ /** {@inheritDoc} */ @Override protected AbstractArchetypeSetLoader newArchetypeSetLoader(@NotNull final GameObjectParser<GameObject, MapArchObject, Archetype> gameObjectParser, @NotNull final AbstractArchetypeParser<GameObject, MapArchObject, Archetype> archetypeParser, @NotNull final EditTypes editTypes, @NotNull final FaceObjects faceObjects, @NotNull final AnimationObjects animationObjects, @NotNull final GlobalSettings globalSettings, @NotNull final net.sf.gridarta.gameobject.ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet) { - return new ArchetypeSetLoader(globalSettings, gameObjectParser, globalSettings.getCollectedDirectory(), archetypeSet, archetypeParser, editTypes, faceObjects, animationObjects); + return new ArchetypeSetLoader(globalSettings, gameObjectParser, new File(globalSettings.getCollectedDirectory()), archetypeSet, archetypeParser, editTypes, faceObjects, animationObjects); } /** {@inheritDoc} */ Modified: trunk/crossfire/src/cfeditor/gameobject/ArchetypeParser.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/ArchetypeParser.java 2008-11-12 22:17:29 UTC (rev 5724) +++ trunk/crossfire/src/cfeditor/gameobject/ArchetypeParser.java 2008-11-12 22:38:44 UTC (rev 5725) @@ -108,7 +108,7 @@ } /** {@inheritDoc} */ - public void parseArchetypeFromStream(final BufferedReader in, @Nullable final GameObject prototype, @Nullable final String line, @Nullable final String archName, @NotNull final String panelName, @NotNull final String folderName, final String fname, @NotNull final List<GameObject> invObjects) throws IOException { + public void parseArchetypeFromStream(final BufferedReader in, @Nullable final GameObject prototype, @Nullable final String line, @Nullable final String archName, @NotNull final String panelName, @NotNull final String folderName, @NotNull final File file, @NotNull final List<GameObject> invObjects) throws IOException { // start with new clean GameObject instance @Nullable GameObject archetype; if (prototype == null) { @@ -120,7 +120,7 @@ // path is needed when we don't read from collection because there is no editor_folder in arc files @Nullable final String path; if (!archetypeSet.isLoadedFromArchive() && archName == null) { - String tmpPath = (new File(PathManager.getArchPath(fname))).getParent(); + String tmpPath = (new File(PathManager.getArchPath(file.getPath()))).getParent(); if (tmpPath == null) { tmpPath = "/"; } else { Modified: trunk/crossfire/src/cfeditor/gameobject/ArchetypeSetLoader.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/ArchetypeSetLoader.java 2008-11-12 22:17:29 UTC (rev 5724) +++ trunk/crossfire/src/cfeditor/gameobject/ArchetypeSetLoader.java 2008-11-12 22:38:44 UTC (rev 5725) @@ -77,7 +77,7 @@ * The collected directory. */ @NotNull - private final String collectedDirectory; + private final File collectedDirectory; /** * The archetype set to update. @@ -120,7 +120,7 @@ * @param faceObjects the face objects instance * @param animationObjects the animation objects instance */ - public ArchetypeSetLoader(@NotNull final GlobalSettings globalSettings, @NotNull final GameObjectParser<GameObject, MapArchObject, Archetype> gameObjectParser, @NotNull final String collectedDirectory, @NotNull final ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final AbstractArchetypeParser<GameObject, MapArchObject, Archetype> archetypeParser, @NotNull final EditTypes editTypes, @NotNull final FaceObjects faceObjects, @NotNull final AnimationObjects animationObjects) { + public ArchetypeSetLoader(@NotNull final GlobalSettings globalSettings, @NotNull final GameObjectParser<GameObject, MapArchObject, Archetype> gameObjectParser, @NotNull final File collectedDirectory, @NotNull final ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final AbstractArchetypeParser<GameObject, MapArchObject, Archetype> archetypeParser, @NotNull final EditTypes editTypes, @NotNull final FaceObjects faceObjects, @NotNull final AnimationObjects animationObjects) { super(collectedDirectory, animationObjects, faceObjects); this.globalSettings = globalSettings; this.gameObjectParser = gameObjectParser; @@ -185,7 +185,7 @@ try { animationObjects.loadAnimTree(collectedDirectory, IGUIConstants.ANIMTREE_FILE); } catch (final IOException ex) { - errorView.addWarning(collectedDirectory + "/" + IGUIConstants.ANIMTREE_FILE, "can't load file: "+ ex.getMessage()); + errorView.addWarning(new File(collectedDirectory, IGUIConstants.ANIMTREE_FILE).getPath(), "can't load file: "+ ex.getMessage()); } loadAnimationsFromCollect(errorView); try { @@ -198,7 +198,7 @@ stream.close(); } } catch (final IOException ex) { - errorView.addError(collectedDirectory + "/" + IGUIConstants.ARCH_FILE, ex.getMessage()); + errorView.addError(new File(collectedDirectory, IGUIConstants.ARCH_FILE).getPath(), ex.getMessage()); } faceObjects.loadFacesCollection(errorView, collectedDirectory, IGUIConstants.PNG_FILE, IGUIConstants.FACETREE_FILE); } @@ -239,7 +239,7 @@ } else if (f.isFile()) { // watch out for stuff that's not a file and not a directory!!! if (name.endsWith(".arc")) { archetypeSet.setCurrentFile(f); - archetypeParser.parseArchetype(f.getPath(), panelName, folderName, invObjects); + archetypeParser.parseArchetype(f, panelName, folderName, invObjects); } else if (name.endsWith(".png")) { if (archetypeSet.getImageSet() == null || name.contains("." + archetypeSet.getImageSet() + ".")) { addPNGFace(f.getAbsolutePath(), path, name, parent); Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-11-12 22:17:29 UTC (rev 5724) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-11-12 22:38:44 UTC (rev 5725) @@ -342,8 +342,8 @@ /** {@inheritDoc} */ @Override protected AbstractArchetypeSetLoader newArchetypeSetLoader(@NotNull final GameObjectParser<GameObject, MapArchObject, Archetype> gameObjectParser, @NotNull final AbstractArchetypeParser<GameObject, MapArchObject, Archetype> archetypeParser, @NotNull final EditTypes editTypes, @NotNull final FaceObjects faceObjects, @NotNull final AnimationObjects animationObjects, @NotNull final GlobalSettings globalSettings, @NotNull final net.sf.gridarta.gameobject.ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet) { - MultiPositionData.init(globalSettings.getConfigurationDirectory()); - return new ArchetypeSetLoader(globalSettings, gameObjectParser, globalSettings.getCollectedDirectory(), archetypeSet, archetypeParser, editTypes, faceObjects, animationObjects); + MultiPositionData.init(new File(globalSettings.getConfigurationDirectory())); + return new ArchetypeSetLoader(globalSettings, gameObjectParser, new File(globalSettings.getCollectedDirectory()), archetypeSet, archetypeParser, editTypes, faceObjects, animationObjects); } /** {@inheritDoc} */ Modified: trunk/daimonin/src/daieditor/MultiPositionData.java =================================================================== --- trunk/daimonin/src/daieditor/MultiPositionData.java 2008-11-12 22:17:29 UTC (rev 5724) +++ trunk/daimonin/src/daieditor/MultiPositionData.java 2008-11-12 22:38:44 UTC (rev 5725) @@ -22,9 +22,11 @@ import java.awt.Dimension; import java.awt.Point; import java.io.BufferedReader; +import java.io.File; import java.io.IOException; import net.sf.gridarta.utils.IOUtils; import org.apache.log4j.Logger; +import org.jetbrains.annotations.NotNull; /** * The MultiPositionData class stores an array of numbers which is required in @@ -56,7 +58,7 @@ * This is the static init method. It is called once in the global * initialization phase. */ - public static void init(final String configurationDirectory) { + public static void init(final File configurationDirectory) { instance = new MultiPositionData(); instance.load(configurationDirectory); } @@ -65,7 +67,7 @@ * Load the array-data from file. An error is reported when the numbers in * the file don't match expected array dimensions. */ - private void load(final String configurationDirectory) { + private void load(@NotNull final File configurationDirectory) { // read datafile line by line, parsing numbers into the array try { final BufferedReader reader = IOUtils.createReader(configurationDirectory, IGUIConstants.ARCHDEF_FILE); Modified: trunk/daimonin/src/daieditor/gameobject/ArchetypeParser.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/ArchetypeParser.java 2008-11-12 22:17:29 UTC (rev 5724) +++ trunk/daimonin/src/daieditor/gameobject/ArchetypeParser.java 2008-11-12 22:38:44 UTC (rev 5725) @@ -90,7 +90,7 @@ /** {@inheritDoc} */ @SuppressWarnings({"StringContatenationInLoop", "ObjectAllocationInLoop"}) - public void parseArchetypeFromStream(final BufferedReader in, @Nullable final GameObject prototype, @Nullable final String line, @Nullable final String archName, @NotNull final String panelName, @NotNull final String folderName, final String fname, @NotNull final List<GameObject> invObjects) throws IOException { + public void parseArchetypeFromStream(final BufferedReader in, @Nullable final GameObject prototype, @Nullable final String line, @Nullable final String archName, @NotNull final String panelName, @NotNull final String folderName, @NotNull final File file, @NotNull final List<GameObject> invObjects) throws IOException { // start with new clean GameObject instance @Nullable GameObject archetype; if (prototype == null) { @@ -102,7 +102,7 @@ // path is needed when we don't read from collection because there is no editor_folder in arc files @Nullable final String path; if (!archetypeSet.isLoadedFromArchive() && archName == null) { - String tmpPath = (new File(PathManager.getArchPath(fname))).getParent(); + String tmpPath = (new File(PathManager.getArchPath(file.getPath()))).getParent(); if (tmpPath == null) { tmpPath = "/"; } else { Modified: trunk/daimonin/src/daieditor/gameobject/ArchetypeSetLoader.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/ArchetypeSetLoader.java 2008-11-12 22:17:29 UTC (rev 5724) +++ trunk/daimonin/src/daieditor/gameobject/ArchetypeSetLoader.java 2008-11-12 22:38:44 UTC (rev 5725) @@ -80,7 +80,7 @@ * The collected directory. */ @NotNull - private final String collectedDirectory; + private final File collectedDirectory; /** * The archetype set to update. @@ -130,7 +130,7 @@ * @param faceObjects the face objects instance * @param animationObjects the animation objects instance */ - public ArchetypeSetLoader(@NotNull final GlobalSettings globalSettings, @NotNull final GameObjectParser<GameObject, MapArchObject, Archetype> gameObjectParser, @NotNull final String collectedDirectory, @NotNull final ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final AbstractArchetypeParser<GameObject, MapArchObject, Archetype> archetypeParser, @NotNull final EditTypes editTypes, @NotNull final FaceObjects faceObjects, @NotNull final AnimationObjects animationObjects) { + public ArchetypeSetLoader(@NotNull final GlobalSettings globalSettings, @NotNull final GameObjectParser<GameObject, MapArchObject, Archetype> gameObjectParser, @NotNull final File collectedDirectory, @NotNull final ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final AbstractArchetypeParser<GameObject, MapArchObject, Archetype> archetypeParser, @NotNull final EditTypes editTypes, @NotNull final FaceObjects faceObjects, @NotNull final AnimationObjects animationObjects) { super(collectedDirectory, animationObjects, faceObjects); this.globalSettings = globalSettings; this.gameObjectParser = gameObjectParser; @@ -171,11 +171,11 @@ } archetypeSet.reportErrors(parent); - final String artifactsFilename = collectedDirectory + "/" + IGUIConstants.ARTIFACTS_FILE; - loadArchesFromArtifacts(new ErrorViewCollector(errorView, artifactsFilename), archetypeParser, artifactsFilename, "Artifacts", "artifacts", invObjects); + final File artifactsFile = new File(collectedDirectory, IGUIConstants.ARTIFACTS_FILE); + loadArchesFromArtifacts(new ErrorViewCollector(errorView, artifactsFile.getPath()), archetypeParser, artifactsFile, "Artifacts", "artifacts", invObjects); - final String mapsDirectory = globalSettings.getMapsDirectory(); - loadArchesFromArtifacts(new ErrorViewCollector(errorView, mapsDirectory), archetypeParser, mapsDirectory, "Artifacts", "maps", invObjects); + final File mapsDirectory = new File(globalSettings.getMapsDirectory()); + loadArchesFromArtifacts(new ErrorViewCollector(errorView, mapsDirectory.getPath()), archetypeParser, mapsDirectory, "Artifacts", "maps", invObjects); gameObjectParser.collectTempList(parent, archetypeSet, editTypes, invObjects, fname, true); archetypeSet.connectFaces(); // attach faces to arches @@ -205,7 +205,7 @@ try { animationObjects.loadAnimTree(collectedDirectory, IGUIConstants.ANIMTREE_FILE); } catch (final IOException ex) { - errorView.addError(collectedDirectory + "/" + IGUIConstants.ANIMTREE_FILE, "can't load file: " + ex.getMessage()); + errorView.addError(new File(collectedDirectory, IGUIConstants.ANIMTREE_FILE).getPath(), "can't load file: " + ex.getMessage()); } loadAnimationsFromCollect(errorView); try { @@ -213,12 +213,12 @@ final BufferedReader stream = IOUtils.createReader(collectedDirectory, IGUIConstants.ARCH_FILE); try { // load all arches - archetypeParser.parseArchetypeFromStream(stream, "default", "default", IGUIConstants.ARCH_FILE, invObjects); + archetypeParser.parseArchetypeFromStream(stream, "default", "default", new File(IGUIConstants.ARCH_FILE), invObjects); } finally { stream.close(); } } catch (final IOException ex) { - errorView.addError(collectedDirectory + "/" + IGUIConstants.ARCH_FILE, "can't load file: " + ex.getMessage()); + errorView.addError(new File(collectedDirectory, IGUIConstants.ARCH_FILE).getPath(), "can't load file: " + ex.getMessage()); } faceObjects.loadFacesCollection(errorView, collectedDirectory, IGUIConstants.PNG_FILE, IGUIConstants.FACETREE_FILE); } @@ -259,7 +259,7 @@ } else if (f.isFile()) { // watch out for stuff that's not a file and not a directory!!! if (name.endsWith(".arc")) { archetypeSet.setCurrentFile(f); - archetypeParser.parseArchetype(f.getPath(), panelName, folderName, invObjects); + archetypeParser.parseArchetype(f, panelName, folderName, invObjects); } else if (name.endsWith(".png")) { addPNGFace(f.getAbsolutePath(), path, name, parent); } else if (name.endsWith(".anim")) { @@ -274,15 +274,14 @@ * parsed. * @param errorViewCollector the error view collector for reporting errors * @param archetypeParser the archetype parser to use - * @param filename This can be a filename or a directory name Load "pseudo + * @param f This can be a filename or a directory name Load "pseudo * arches" from file "artifacts" WARNING: Don't include multi arches in the * artifacts file This code can't handle it nor the real server * @param panelName the panel to add artifacts to * @param folderName the folder to add artifacts to * @param invObjects collects all inventory objects */ - private void loadArchesFromArtifacts(@NotNull final ErrorViewCollector errorViewCollector, @NotNull final AbstractArchetypeParser<GameObject, MapArchObject, Archetype> archetypeParser, final String filename, @NotNull final String panelName, @NotNull final String folderName, @NotNull final List<GameObject> invObjects) { - final File f = new File(filename); + private void loadArchesFromArtifacts(@NotNull final ErrorViewCollector errorViewCollector, @NotNull final AbstractArchetypeParser<GameObject, MapArchObject, Archetype> archetypeParser, final File f, @NotNull final String panelName, @NotNull final String folderName, @NotNull final List<GameObject> invObjects) { if (f.isDirectory()) { // This is a directory -> only accept *.art files and directories final String[] traverse = f.list(new FilenameFilter() { @@ -296,7 +295,7 @@ if (traverse != null) { Arrays.sort(traverse); for (final String entry : traverse) { - loadArchesFromArtifacts(errorViewCollector, archetypeParser, filename + "/" + entry, panelName, folderName, invObjects); + loadArchesFromArtifacts(errorViewCollector, archetypeParser, new File(f, entry), panelName, folderName, invObjects); } } // This was a directory -> nothing to parse @@ -305,7 +304,7 @@ // This is an artifact file to parse try { - final BufferedReader myInput = new BufferedReader(new FileReader(filename)); + final BufferedReader myInput = new BufferedReader(new FileReader(f)); //Open the file for reading try { int editorCode = -1; @@ -358,7 +357,7 @@ // get the default arch as base and parse the new values over it // the extended functions of the artifacts file can be ignored here. // XXX: the cast "(GameObject) archetype" is a hack and should be removed. For now it is necessary because parseArchetypeFromStream() needs a GameObject rather than a Archetype because Archetype.clone() does not exist. - archetypeParser.parseArchetypeFromStream(myInput, editorCode == 2 ? null : (GameObject) archetype, thisLine, name, panelName, folderName, filename, invObjects); + archetypeParser.parseArchetypeFromStream(myInput, editorCode == 2 ? null : (GameObject) archetype, thisLine, name, panelName, folderName, f, invObjects); // note: in the parser is a small part where we handle the title setting // and the reverse type setting for type == -1 (unique items marker in artifacts file) } else { Modified: trunk/src/app/net/sf/gridarta/AbstractMainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2008-11-12 22:17:29 UTC (rev 5724) +++ trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2008-11-12 22:38:44 UTC (rev 5725) @@ -510,7 +510,7 @@ } scriptControl.loadScripts(new File(globalSettings.getMapDir(), scriptsDir)); archetypeChooserControl.getArchetypeChooserView().finishBuildProcess(); - autojoinLists.loadList(archetypeSet, globalSettings.getConfigurationDirectory()); + autojoinLists.loadList(archetypeSet, new File(globalSettings.getConfigurationDirectory())); if (archetypeSet.getLoadStatus() == ArchetypeSet.LoadStatus.EMPTY) { ACTION_FACTORY.showMessageDialog(mainView, "loadArchesNoArchfiles"); } else { Modified: trunk/src/app/net/sf/gridarta/autojoin/AutojoinLists.java =================================================================== --- trunk/src/app/net/sf/gridarta/autojoin/AutojoinLists.java 2008-11-12 22:17:29 UTC (rev 5724) +++ trunk/src/app/net/sf/gridarta/autojoin/AutojoinLists.java 2008-11-12 22:38:44 UTC (rev 5725) @@ -20,6 +20,7 @@ package net.sf.gridarta.autojoin; import java.io.BufferedReader; +import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; import java.util.IdentityHashMap; @@ -71,9 +72,9 @@ * Load all the autojoin lists from the datafile. The links from the default * arches to their appropriate AutojoinLists also get set here. * @param archstack the stack of default arches - * @param baseDir The configuration directory to load autojoin info from. + * @param baseDir the configuration directory to load autojoin info from. */ - public void loadList(final ArchetypeSet<G, A, R> archstack, @NotNull final String baseDir) { + public void loadList(final ArchetypeSet<G, A, R> archstack, @NotNull final File baseDir) { try { // open the resource file final BufferedReader stream = IOUtils.createReader(baseDir, FILENAME); Modified: trunk/src/app/net/sf/gridarta/gameobject/AbstractArchetypeParser.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/AbstractArchetypeParser.java 2008-11-12 22:17:29 UTC (rev 5724) +++ trunk/src/app/net/sf/gridarta/gameobject/AbstractArchetypeParser.java 2008-11-12 22:38:44 UTC (rev 5725) @@ -20,6 +20,7 @@ package net.sf.gridarta.gameobject; import java.io.BufferedReader; +import java.io.File; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; @@ -46,22 +47,22 @@ } /** {@inheritDoc} */ - public void parseArchetypeFromStream(final BufferedReader in, @NotNull final String panelName, @NotNull final String folderName, final String fname, @NotNull final List<G> invObjects) throws IOException { - parseArchetypeFromStream(in, null, null, null, panelName, folderName, fname, invObjects); + public void parseArchetypeFromStream(final BufferedReader in, @NotNull final String panelName, @NotNull final String folderName, @NotNull final File file, @NotNull final List<G> invObjects) throws IOException { + parseArchetypeFromStream(in, null, null, null, panelName, folderName, file, invObjects); } /** {@inheritDoc} */ - public void parseArchetype(final String fname, @NotNull final String panelName, @NotNull final String folderName, @NotNull final List<G> invObjects) { + public void parseArchetype(@NotNull final File file, @NotNull final String panelName, @NotNull final String folderName, @NotNull final List<G> invObjects) { //Open the file for reading try { - final BufferedReader in = new BufferedReader(new FileReader(fname)); + final BufferedReader in = new BufferedReader(new FileReader(file)); try { - parseArchetypeFromStream(in, panelName, folderName, fname, invObjects); + parseArchetypeFromStream(in, panelName, folderName, file, invObjects); } finally { in.close(); } } catch (final FileNotFoundException e) { - log.warn(ACTION_FACTORY.format("logArchfileNotFound", fname)); + log.warn(ACTION_FACTORY.format("logArchfileNotFound", file)); } catch (final IOException e) { // TODO log.error("IOException in parseDefArch!"); Modified: trunk/src/app/net/sf/gridarta/gameobject/AbstractArchetypeSetLoader.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/AbstractArchetypeSetLoader.java 2008-11-12 22:17:29 UTC (rev 5724) +++ trunk/src/app/net/sf/gridarta/gameobject/AbstractArchetypeSetLoader.java 2008-11-12 22:38:44 UTC (rev 5725) @@ -51,7 +51,7 @@ * The collected directory. */ @NotNull - private final String collectedDirectory; + private final File collectedDirectory; /** * The animation objects instance. @@ -71,7 +71,7 @@ * @param animationObjects the animation objects instance * @param faceObjects the face ojects instance */ - protected AbstractArchetypeSetLoader(@NotNull final String collectedDirectory, @NotNull final AnimationObjects animationObjects, @NotNull final FaceObjects faceObjects) { + protected AbstractArchetypeSetLoader(@NotNull final File collectedDirectory, @NotNull final AnimationObjects animationObjects, @NotNull final FaceObjects faceObjects) { this.collectedDirectory = collectedDirectory; this.animationObjects = animationObjects; this.faceObjects = faceObjects; Modified: trunk/src/app/net/sf/gridarta/gameobject/ArchetypeParser.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/ArchetypeParser.java 2008-11-12 22:17:29 UTC (rev 5724) +++ trunk/src/app/net/sf/gridarta/gameobject/ArchetypeParser.java 2008-11-12 22:38:44 UTC (rev 5725) @@ -20,6 +20,7 @@ package net.sf.gridarta.gameobject; import java.io.BufferedReader; +import java.io.File; import java.io.IOException; import java.util.List; import net.sf.gridarta.map.MapArchObject; @@ -37,12 +38,12 @@ /** * Read an Archetype from a file. - * @param fname filename of the archetype definition file (*.arc) + * @param file file of the archetype definition file (*.arc) * @param panelName the panel name to add the archetype to * @param folderName the folder name to add the archetype to * @param invObjects collects all inventory objects */ - void parseArchetype(String fname, @NotNull String panelName, @NotNull String folderName, @NotNull List<G> invObjects); + void parseArchetype(@NotNull File file, @NotNull String panelName, @NotNull String folderName, @NotNull List<G> invObjects); /** * Here we read an Archetype from a filestream, parse the data and put the @@ -53,24 +54,24 @@ * @param archName archetype-object name (only for artifacts) * @param panelName the panel name to add the archetype to * @param folderName the folder name to add the archetype to - * @param fname filename of the Archetype + * @param file file of the Archetype * @param invObjects collects all inventory objects * @throws IOException in case of I/O problems * @throws java.io.EOFException in case an uncomplete object was found */ - void parseArchetypeFromStream(BufferedReader in, @Nullable G prototype, @Nullable String line, @Nullable String archName, @NotNull String panelName, @NotNull String folderName, String fname, @NotNull List<G> invObjects) throws IOException; + void parseArchetypeFromStream(BufferedReader in, @Nullable G prototype, @Nullable String line, @Nullable String archName, @NotNull String panelName, @NotNull String folderName, @NotNull File file, @NotNull List<G> invObjects) throws IOException; /** * Short form of {@link #parseArchetypeFromStream(BufferedReader, - * GameObject, String, String, String, String, String, List)}. + * GameObject, String, String, String, String, File, List)}. * @param in <code>BufferedReader</code> file stream of archetype data * @param panelName the panel name to add the archetype to * @param folderName the folder name to add the archetype to - * @param fname filename of the Archetype + * @param file file of the Archetype * @param invObjects collects all inventory objects * @throws IOException in case of I/O problems * @throws java.io.EOFException in case an uncomplete object was found */ - void parseArchetypeFromStream(BufferedReader in, @NotNull String panelName, @NotNull String folderName, String fname, @NotNull List<G> invObjects) throws IOException; + void parseArchetypeFromStream(BufferedReader in, @NotNull String panelName, @NotNull String folderName, @NotNull File file, @NotNull List<G> invObjects) throws IOException; } // interface ArchetypeParser Modified: trunk/src/app/net/sf/gridarta/gameobject/anim/AnimationObjects.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/anim/AnimationObjects.java 2008-11-12 22:17:29 UTC (rev 5724) +++ trunk/src/app/net/sf/gridarta/gameobject/anim/AnimationObjects.java 2008-11-12 22:38:44 UTC (rev 5725) @@ -93,6 +93,6 @@ * @throws IOException in case of I/O errors * @throws FileNotFoundException in case the file couldn't be opened */ - void loadAnimTree(@NotNull String collectedDirectory, @NotNull String animTreeFile) throws FileNotFoundException, IOException; + void loadAnimTree(@NotNull File collectedDirectory, @NotNull String animTreeFile) throws FileNotFoundException, IOException; } // interface AnimationObjects Modified: trunk/src/app/net/sf/gridarta/gameobject/anim/DefaultAnimationObjects.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/anim/DefaultAnimationObjects.java 2008-11-12 22:17:29 UTC (rev 5724) +++ trunk/src/app/net/sf/gridarta/gameobject/anim/DefaultAnimationObjects.java 2008-11-12 22:38:44 UTC (rev 5725) @@ -173,7 +173,7 @@ } /** {@inheritDoc} */ - public void loadAnimTree(@NotNull final String collectedDirectory, @NotNull final String animTreeFile) throws FileNotFoundException, IOException { + public void loadAnimTree(@NotNull final File collectedDirectory, @NotNull final String animTreeFile) throws FileNotFoundException, IOException { final BufferedReader in = IOUtils.createReader(collectedDirectory, animTreeFile); try { loadAnimTree(in); Modified: trunk/src/app/net/sf/gridarta/gameobject/face/DefaultFaceObjects.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/face/DefaultFaceObjects.java 2008-11-12 22:17:29 UTC (rev 5724) +++ trunk/src/app/net/sf/gridarta/gameobject/face/DefaultFaceObjects.java 2008-11-12 22:38:44 UTC (rev 5725) @@ -260,12 +260,12 @@ } /** {@inheritDoc} */ - public void loadFacesCollection(@NotNull final DefaultErrorView errorView, @NotNull final String collectedDirectory, @NotNull final String faceFile, @NotNull final String treeFile) { + public void loadFacesCollection(@NotNull final DefaultErrorView errorView, @NotNull final File collectedDirectory, @NotNull final String faceFile, @NotNull final String treeFile) { final File tmpFaceFile; try { tmpFaceFile = IOUtils.getFile(collectedDirectory, faceFile); } catch (final IOException ex) { - errorView.addError(collectedDirectory + "/" + faceFile, "can't load file: " + ex.getMessage()); + errorView.addError(new File(collectedDirectory, faceFile).getPath(), "can't load file: " + ex.getMessage()); return; } final ErrorViewCollector faceFileErrorViewCollector = new ErrorViewCollector(errorView, tmpFaceFile.getPath()); @@ -288,7 +288,7 @@ final byte[] data = bufOut.toByteArray(); // Note: treeIn might stay null, this is optional data. - final ErrorViewCollector treeFileErrorViewCollector = new ErrorViewCollector(errorView, collectedDirectory + "/" + treeFile); + final ErrorViewCollector treeFileErrorViewCollector = new ErrorViewCollector(errorView, new File(collectedDirectory, treeFile).getPath()); BufferedReader treeIn = null; try { //cher: it is safely closed but optional. InspectionGadgets doesn't detect where it's closed. Modified: trunk/src/app/net/sf/gridarta/gameobject/face/FaceObjects.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/face/FaceObjects.java 2008-11-12 22:17:29 UTC (rev 5724) +++ trunk/src/app/net/sf/gridarta/gameobject/face/FaceObjects.java 2008-11-12 22:38:44 UTC (rev 5725) @@ -19,6 +19,7 @@ package net.sf.gridarta.gameobject.face; +import java.io.File; import net.sf.gridarta.data.NamedObjects; import net.sf.gridarta.gameobject.Collectable; import net.sf.gridarta.gui.errorview.DefaultErrorView; @@ -37,7 +38,7 @@ * @param faceFile file to load faces from * @param treeFile file to load tree information from */ - void loadFacesCollection(@NotNull DefaultErrorView errorView, @NotNull String collectedDirectory, @NotNull String faceFile, @NotNull String treeFile); + void loadFacesCollection(@NotNull DefaultErrorView errorView, @NotNull File collectedDirectory, @NotNull String faceFile, @NotNull String treeFile); /** * Adds a new face object. Modified: trunk/src/app/net/sf/gridarta/treasurelist/TreasureLoader.java =================================================================== --- trunk/src/app/net/sf/gridarta/treasurelist/TreasureLoader.java 2008-11-12 22:17:29 UTC (rev 5724) +++ trunk/src/app/net/sf/gridarta/treasurelist/TreasureLoader.java 2008-11-12 22:38:44 UTC (rev 5725) @@ -90,7 +90,7 @@ final String dname = treasureLocation.getDname(); final String fname = treasureLocation.getFname(); final ErrorViewCollector errorViewCollector = new ErrorViewCollector(errorView, fname == null ? dname : dname + fname); - loadTreasureList(errorViewCollector, dname, fname, tmpList, needLink); + loadTreasureList(errorViewCollector, new File(dname), fname, tmpList, needLink); } // second step: sort alphabetically and link sub-treasurelist entries @@ -154,7 +154,7 @@ * directory it is recursivly traversed and all treasurelist files (*.tl) * get parsed. * @param errorViewCollector the error view collector to use - * @param dname directory to read from + * @param dir directory to read from * @param fname filename to parse; <code>null</code> to recursivey parse * <code>dname</code> * @param tmpList tmp. container for all treasurelists @@ -162,18 +162,17 @@ * @see #parseTreasures(DefaultErrorView, TreasureLocation[], Map, * DefaultMutableTreeNode) */ - private void loadTreasureList(@NotNull final ErrorViewCollector errorViewCollector, final String dname, final String fname, final List<TreasureTreeNode> tmpList, final List<TreasureTreeNode> needLink) { + private void loadTreasureList(@NotNull final ErrorViewCollector errorViewCollector, @NotNull final File dir, final String fname, final List<TreasureTreeNode> tmpList, final List<TreasureTreeNode> needLink) { if (fname == null) { - final File f = new File(dname); // This is a directory -> only accept *.tl files and directories - final String[] traverse = f.list(treasureListFilter); + final String[] traverse = dir.list(treasureListFilter); if (traverse != null) { Arrays.sort(traverse); for (final String entry : traverse) { if (entry.endsWith(".tl")) { - loadTreasureList(errorViewCollector, dname, entry, tmpList, needLink); + loadTreasureList(errorViewCollector, dir, entry, tmpList, needLink); } else { - loadTreasureList(errorViewCollector, dname + "/" + entry, null, tmpList, needLink); + loadTreasureList(errorViewCollector, new File(dir, entry), null, tmpList, needLink); } } } @@ -182,7 +181,7 @@ } try { - final BufferedReader reader = IOUtils.createReader(dname, fname); + final BufferedReader reader = IOUtils.createReader(dir, fname); try { // read the whole file line by line for (String rawLine; (rawLine = reader.readLine()) != null;) { Modified: trunk/src/app/net/sf/gridarta/utils/IOUtils.java =================================================================== --- trunk/src/app/net/sf/gridarta/utils/IOUtils.java 2008-11-12 22:17:29 UTC (rev 5724) +++ trunk/src/app/net/sf/gridarta/utils/IOUtils.java 2008-11-12 22:38:44 UTC (rev 5725) @@ -63,14 +63,14 @@ /** * Open the resource file for reading. - * @param dname directory name to read from + * @param dir directory to read from * @param fname file name of file to read * @return Stream for reading from <var>fname</var> * @throws FileNotFoundException In case all tries to open the file failed */ @NotNull - public static BufferedInputStream createStream(@Nullable final String dname, @NotNull final String fname) throws FileNotFoundException { - return new BufferedInputStream(createStreamImpl(dname, fname)); + public static BufferedInputStream createStream(@Nullable final File dir, @NotNull final String fname) throws FileNotFoundException { + return new BufferedInputStream(createStreamImpl(dir, fname)); } /** @@ -128,16 +128,16 @@ /** * Open the resource file for reading. - * @param dname directory name to read from + * @param dir directory to read from * @param fname file name of file to read * @return Stream for reading from <var>fname</var> * @throws FileNotFoundException In case all tries to open the file failed */ @SuppressWarnings({"MethodWithMultipleReturnPoints", "MethodWithMoreThanThreeNegations"}) @NotNull - private static InputStream createStreamImpl(@Nullable final String dname, @NotNull final String fname) throws FileNotFoundException { + private static InputStream createStreamImpl(@Nullable final File dir, @NotNull final String fname) throws FileNotFoundException { try { // 1st try normal binary file relative to specified directory - return new FileInputStream(new File(dname, fname)); + return new FileInputStream(new File(dir, fname)); } catch (final FileNotFoundException ignore) { // ignore } @@ -147,7 +147,7 @@ // ignore } final URI currentDir = new File(System.getProperty("user.dir")).toURI(); - final String relWithDir = currentDir.relativize(new File(dname, fname).toURI()).toString(); + final String relWithDir = currentDir.relativize(new File(dir, fname).toURI()).toString(); final String relPlain = currentDir.relativize(new File(fname).toURI()).toString(); final ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader(); // 3rd try context class loader relative to specified directory @@ -170,36 +170,36 @@ if (stream4 != null) { return stream4; } - throw new FileNotFoundException("couldn't find " + new File(dname, fname) + "."); + throw new FileNotFoundException("couldn't find " + new File(dir, fname) + "."); } /** * Open the resource file for reading. - * @param dname name of directory that the file is in (null means the file - * is located in the editor root dir) + * @param dir directory that the file is in (null means the file is located + * in the editor root dir) * @param fname name of the resource file * @return Stream for reading from <var>fname</var> * @throws FileNotFoundException In case all three tries to open the file * failed */ @NotNull - public static BufferedReader createReader(@Nullable final String dname, @NotNull final String fname) throws FileNotFoundException { - return new BufferedReader(createReaderImpl(dname, fname)); + public static BufferedReader createReader(@Nullable final File dir, @NotNull final String fname) throws FileNotFoundException { + return new BufferedReader(createReaderImpl(dir, fname)); } /** * Open the resource file for reading. - * @param dname name of directory that the file is in (null means the file - * is located in the editor root dir) + * @param dir directory that the file is in (null means the file is located + * in the editor root dir) * @param fname name of the resource file * @return Stream for reading from <var>fname</var> * @throws FileNotFoundException In case all three tries to open the file * failed */ @NotNull - private static Reader createReaderImpl(@Nullable final String dname, @NotNull final String fname) throws FileNotFoundException { + private static Reader createReaderImpl(@Nullable final File dir, @NotNull final String fname) throws FileNotFoundException { try { - return new InputStreamReader(createStreamImpl(dname, fname), MAP_ENCODING); + return new InputStreamReader(createStreamImpl(dir, fname), MAP_ENCODING); } catch (final UnsupportedEncodingException e) { throw new AssertionError(e); } @@ -305,22 +305,22 @@ * the file system. Returns the passed file if it is a regular file. * Otherwise copies the passed file into a temporary regular file and * returns the copy. - * @param dname directory name to read from + * @param dir directory to read from * @param fname file name of file to read * @return the file * @throws IOException if the file does not exist or cannot be copied to * the file system */ @NotNull - public static File getFile(@Nullable final String dname, @NotNull final String fname) throws IOException { - final File file = new File(getResourceURLAsString(new File(dname), fname)); + public static File getFile(@Nullable final File dir, @NotNull final String fname) throws IOException { + final File file = new File(getResourceURLAsString(dir, fname)); if (file.exists()) { return file; } final File tmpFile = File.createTempFile("gridarta", null); tmpFile.deleteOnExit(); - final BufferedInputStream inputStream = createStream(dname, fname); + final BufferedInputStream inputStream = createStream(dir, fname); try { final FileOutputStream outputStream = new FileOutputStream(tmpFile); try { Modified: trunk/src/app/net/sf/gridarta/utils/XmlHelper.java =================================================================== --- trunk/src/app/net/sf/gridarta/utils/XmlHelper.java 2008-11-12 22:17:29 UTC (rev 5724) +++ trunk/src/app/net/sf/gridarta/utils/XmlHelper.java 2008-11-12 22:38:44 UTC (rev 5725) @@ -19,6 +19,7 @@ package net.sf.gridarta.utils; +import java.io.File; import java.io.IOException; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; @@ -88,7 +89,7 @@ return null; } - return new InputSource(IOUtils.createStream("system/dtd", systemId.replaceAll(".*/", ""))); + return new InputSource(IOUtils.createStream(new File("system/dtd"), systemId.replaceAll(".*/", ""))); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-11-12 22:46:16
|
Revision: 5726 http://gridarta.svn.sourceforge.net/gridarta/?rev=5726&view=rev Author: akirschbaum Date: 2008-11-12 22:46:12 +0000 (Wed, 12 Nov 2008) Log Message: ----------- Replace String with File. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gameobject/ArchetypeSetLoader.java trunk/daimonin/src/daieditor/gameobject/ArchetypeSetLoader.java trunk/src/app/net/sf/gridarta/io/AbstractGameObjectParser.java trunk/src/app/net/sf/gridarta/io/DefaultMapReader.java trunk/src/app/net/sf/gridarta/io/GameObjectParser.java Modified: trunk/crossfire/src/cfeditor/gameobject/ArchetypeSetLoader.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/ArchetypeSetLoader.java 2008-11-12 22:38:44 UTC (rev 5725) +++ trunk/crossfire/src/cfeditor/gameobject/ArchetypeSetLoader.java 2008-11-12 22:46:12 UTC (rev 5726) @@ -143,21 +143,20 @@ archetypeSet.setLoadStatus(ArchetypeSet.LoadStatus.LOADING); // status: loading final List<GameObject> invObjects = new ArrayList<GameObject>(); - final String fname; + final File dir; // here we go... if (globalSettings.isArchLoadedFromCollection()) { loadArchFromCollected(errorView, archetypeParser, invObjects); // load arches & images from collection - fname = IGUIConstants.ARCH_FILE; + dir = new File(IGUIConstants.ARCH_FILE); } else { FaceObjectProviders.setNormal(new ArchFaceProvider()); archetypeSet.setLoadedFromArchive(false); // don't load from the collected files - fname = globalSettings.getArchDirectory(); - final File dir = new File(fname); + dir = new File(globalSettings.getArchDirectory()); loadArchetypesFromFiles(new ErrorViewCollector(errorView, dir.getPath()), archetypeParser, null, dir, 0, "default", "default", false, invObjects, parent); // load arches & images from individual files } archetypeSet.reportErrors(parent); - gameObjectParser.collectTempList(parent, archetypeSet, editTypes, invObjects, fname, true); + gameObjectParser.collectTempList(parent, archetypeSet, editTypes, invObjects, dir, true); archetypeSet.connectFaces(); // attach faces to arches // print message if no arches were found Modified: trunk/daimonin/src/daieditor/gameobject/ArchetypeSetLoader.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/ArchetypeSetLoader.java 2008-11-12 22:38:44 UTC (rev 5725) +++ trunk/daimonin/src/daieditor/gameobject/ArchetypeSetLoader.java 2008-11-12 22:46:12 UTC (rev 5726) @@ -153,19 +153,18 @@ archetypeSet.setLoadStatus(ArchetypeSet.LoadStatus.LOADING); // status: loading final List<GameObject> invObjects = new ArrayList<GameObject>(); - final String fname; + final File dir; // here we go... if (globalSettings.isArchLoadedFromCollection()) { loadArchFromCollected(errorView, archetypeParser, invObjects); // load arches & images from collection - fname = IGUIConstants.ARCH_FILE; + dir = new File(IGUIConstants.ARCH_FILE); } else { FaceObjectProviders.setNormal(new ArchFaceProvider()); archetypeSet.setLoadedFromArchive(false); // don't load from the collected files animFiles = new ArrayList<Pair<String, File>>(); - fname = globalSettings.getArchDirectory(); - final File dir = new File(fname); + dir = new File(globalSettings.getArchDirectory()); addPNGFace(new File(dir, "dev/editor/bug.101.png").getAbsolutePath(), "/dev/editor", "bug.101.png", parent); - final ErrorViewCollector archDirectoryErrorViewCollector = new ErrorViewCollector(errorView, fname); + final ErrorViewCollector archDirectoryErrorViewCollector = new ErrorViewCollector(errorView, dir.getPath()); loadArchetypesFromFiles(archDirectoryErrorViewCollector, archetypeParser, null, dir, 0, "default", "default", false, invObjects, parent); // load arches & images from individual files loadAnimsFromFiles(archDirectoryErrorViewCollector); } @@ -177,7 +176,7 @@ final File mapsDirectory = new File(globalSettings.getMapsDirectory()); loadArchesFromArtifacts(new ErrorViewCollector(errorView, mapsDirectory.getPath()), archetypeParser, mapsDirectory, "Artifacts", "maps", invObjects); - gameObjectParser.collectTempList(parent, archetypeSet, editTypes, invObjects, fname, true); + gameObjectParser.collectTempList(parent, archetypeSet, editTypes, invObjects, dir, true); archetypeSet.connectFaces(); // attach faces to arches // print message if no arches were found Modified: trunk/src/app/net/sf/gridarta/io/AbstractGameObjectParser.java =================================================================== --- trunk/src/app/net/sf/gridarta/io/AbstractGameObjectParser.java 2008-11-12 22:38:44 UTC (rev 5725) +++ trunk/src/app/net/sf/gridarta/io/AbstractGameObjectParser.java 2008-11-12 22:46:12 UTC (rev 5726) @@ -21,6 +21,7 @@ import java.awt.Component; import java.io.BufferedReader; +import java.io.File; import java.io.IOException; import java.util.ArrayList; import java.util.Collection; @@ -176,7 +177,7 @@ } /** {@inheritDoc} */ - public void collectTempList(@NotNull final Component parent, @NotNull final ArchetypeSet<G, A, R> archetypeSet, @NotNull final EditTypes editTypes, final List<G> objects, final String uri, final boolean isInteractive) { + public void collectTempList(@NotNull final Component parent, @NotNull final ArchetypeSet<G, A, R> archetypeSet, @NotNull final EditTypes editTypes, final List<G> objects, @NotNull final File file, final boolean isInteractive) { final List<G> tailList = new ArrayList<G>(); final Set<String> undefinedArchetypeNames = new TreeSet<String>(); @@ -211,7 +212,7 @@ for (final String archetypeName : undefinedArchetypeNames) { noarch.append(archetypeName).append('\n'); } - if (ACTION_FACTORY.showQuestionDialog(parent, "collectTemplistAutodelete", uri, gameObjectsWithoutArchetype.size(), noarch)) { + if (ACTION_FACTORY.showQuestionDialog(parent, "collectTemplistAutodelete", file, gameObjectsWithoutArchetype.size(), noarch)) { objects.removeAll(gameObjectsWithoutArchetype); } } Modified: trunk/src/app/net/sf/gridarta/io/DefaultMapReader.java =================================================================== --- trunk/src/app/net/sf/gridarta/io/DefaultMapReader.java 2008-11-12 22:38:44 UTC (rev 5725) +++ trunk/src/app/net/sf/gridarta/io/DefaultMapReader.java 2008-11-12 22:46:12 UTC (rev 5726) @@ -91,9 +91,9 @@ @NotNull private final BufferedReader myInput; - /** The uri to read from. */ + /** The file to read from. */ @NotNull - private final String uri; + private final File file; /** A comparator to sort multi-part objects before single-part objects. */ private static final Comparator<GameObject<?, ?, ?>> sorter = new Comparator<GameObject<?, ?, ?>>() { @@ -126,7 +126,7 @@ this.parent = parent; this.archetypeSet = archetypeSet; this.editTypes = editTypes; - uri = file.toURI().toString(); + this.file = file; try { myInput = new BufferedReader(new InputStreamReader(new FileInputStream(file), IOUtils.MAP_ENCODING)); } catch (final UnsupportedEncodingException e) { @@ -166,7 +166,7 @@ while (gameObjectParser.load(myInput, objects) != null) { } - gameObjectParser.collectTempList(parent, archetypeSet, editTypes, objects, uri, isInteractive); + gameObjectParser.collectTempList(parent, archetypeSet, editTypes, objects, file, isInteractive); Collections.sort(objects, sorter); } Modified: trunk/src/app/net/sf/gridarta/io/GameObjectParser.java =================================================================== --- trunk/src/app/net/sf/gridarta/io/GameObjectParser.java 2008-11-12 22:38:44 UTC (rev 5725) +++ trunk/src/app/net/sf/gridarta/io/GameObjectParser.java 2008-11-12 22:46:12 UTC (rev 5726) @@ -21,6 +21,7 @@ import java.awt.Component; import java.io.BufferedReader; +import java.io.File; import java.io.IOException; import java.util.Collection; import java.util.List; @@ -81,10 +82,10 @@ * @param archetypeSet the archetype set * @param editTypes the edit types instance * @param objects List of GameObjects to collect - * @param uri URI they were read from (for error messages). + * @param file file they were read from (for error messages). * @param isInteractive if set, may ask to delete undefined archetypes; if * unset, keep undefined archetypes */ - void collectTempList(@NotNull Component parent, @NotNull ArchetypeSet<G, A, R> archetypeSet, @NotNull EditTypes editTypes, List<G> objects, String uri, boolean isInteractive); + void collectTempList(@NotNull Component parent, @NotNull ArchetypeSet<G, A, R> archetypeSet, @NotNull EditTypes editTypes, List<G> objects, @NotNull File file, boolean isInteractive); } // interface GameObjectParser This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-11-12 22:52:45
|
Revision: 5727 http://gridarta.svn.sourceforge.net/gridarta/?rev=5727&view=rev Author: akirschbaum Date: 2008-11-12 22:52:40 +0000 (Wed, 12 Nov 2008) Log Message: ----------- Replace String with File. Modified Paths: -------------- trunk/crossfire/src/cfeditor/GlobalSettingsImpl.java trunk/crossfire/src/cfeditor/gameobject/ArchetypeSetLoader.java trunk/crossfire/src/cfeditor/gui/prefs/ResPrefs.java trunk/daimonin/src/daieditor/GlobalSettingsImpl.java trunk/daimonin/src/daieditor/gameobject/ArchetypeSetLoader.java trunk/daimonin/src/daieditor/gui/prefs/ResPrefs.java trunk/src/app/net/sf/gridarta/GlobalSettings.java trunk/src/app/net/sf/gridarta/GlobalSettingsImpl.java trunk/src/app/net/sf/gridarta/io/PathManager.java Modified: trunk/crossfire/src/cfeditor/GlobalSettingsImpl.java =================================================================== --- trunk/crossfire/src/cfeditor/GlobalSettingsImpl.java 2008-11-12 22:46:12 UTC (rev 5726) +++ trunk/crossfire/src/cfeditor/GlobalSettingsImpl.java 2008-11-12 22:52:40 UTC (rev 5727) @@ -82,7 +82,7 @@ /** (Re-)initializes the directories. */ public void initDirs() { setMapsDirectory(prefs.get(ResourceFileManager.MAP_DIR_KEY, ResourceFileManager.DEFAULT_MAP_DIR)); - setArchDirectory(prefs.get(ResourceFileManager.ARCH_DIR_KEY, ResourceFileManager.DEFAULT_ARCH_DIR)); + setArchDirectory(new File(prefs.get(ResourceFileManager.ARCH_DIR_KEY, ResourceFileManager.DEFAULT_ARCH_DIR))); setScriptDirectory(prefs.get(ResourceFileManager.SCRIPT_DIR_KEY, ResourceFileManager.DEFAULT_SCRIPT_DIR)); // set map dir Modified: trunk/crossfire/src/cfeditor/gameobject/ArchetypeSetLoader.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/ArchetypeSetLoader.java 2008-11-12 22:46:12 UTC (rev 5726) +++ trunk/crossfire/src/cfeditor/gameobject/ArchetypeSetLoader.java 2008-11-12 22:52:40 UTC (rev 5727) @@ -151,7 +151,7 @@ } else { FaceObjectProviders.setNormal(new ArchFaceProvider()); archetypeSet.setLoadedFromArchive(false); // don't load from the collected files - dir = new File(globalSettings.getArchDirectory()); + dir = globalSettings.getArchDirectory(); loadArchetypesFromFiles(new ErrorViewCollector(errorView, dir.getPath()), archetypeParser, null, dir, 0, "default", "default", false, invObjects, parent); // load arches & images from individual files } archetypeSet.reportErrors(parent); Modified: trunk/crossfire/src/cfeditor/gui/prefs/ResPrefs.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/prefs/ResPrefs.java 2008-11-12 22:46:12 UTC (rev 5726) +++ trunk/crossfire/src/cfeditor/gui/prefs/ResPrefs.java 2008-11-12 22:52:40 UTC (rev 5727) @@ -118,7 +118,7 @@ /** {@inheritDoc} */ public void revert() { - archField.setText(globalSettings.getArchDirectory()); + archField.setText(globalSettings.getArchDirectory().getPath()); mapField.setText(globalSettings.getMapsDirectory()); scriptField.setText(globalSettings.getScriptDirectory()); loadArches.setSelected(globalSettings.isArchLoadedFromCollection()); @@ -170,7 +170,7 @@ private Component createResourcePanel() { final Box resourcePanel = Box.createVerticalBox(); resourcePanel.setBorder(createTitledBorder("optionsResPaths")); - archField = createFileField(resourcePanel, "optionsResArch", globalSettings.getArchDirectory(), JFileChooser.DIRECTORIES_ONLY); + archField = createFileField(resourcePanel, "optionsResArch", globalSettings.getArchDirectory().getPath(), JFileChooser.DIRECTORIES_ONLY); mapField = createFileField(resourcePanel, "optionsResMaps", globalSettings.getMapsDirectory(), JFileChooser.DIRECTORIES_ONLY); scriptField = createFileField(resourcePanel, "optionsResScripts", globalSettings.getScriptDirectory(), JFileChooser.DIRECTORIES_ONLY); return resourcePanel; Modified: trunk/daimonin/src/daieditor/GlobalSettingsImpl.java =================================================================== --- trunk/daimonin/src/daieditor/GlobalSettingsImpl.java 2008-11-12 22:46:12 UTC (rev 5726) +++ trunk/daimonin/src/daieditor/GlobalSettingsImpl.java 2008-11-12 22:52:40 UTC (rev 5727) @@ -45,13 +45,13 @@ /** {@inheritDoc} */ @NotNull public String getConfigurationDirectory() { - return getArchDirectory() + "/dev/editor/conf"; + return new File(getArchDirectory(), "/dev/editor/conf").getPath(); } /** {@inheritDoc} */ @NotNull public String getCollectedDirectory() { - return getArchDirectory(); + return getArchDirectory().getPath(); } /** {@inheritDoc} */ @@ -66,7 +66,7 @@ /** (Re-)initializes the directories. */ public void initDirs() { setMapsDirectory(prefs.get(ResourceFileManager.MAP_DIR_KEY, ResourceFileManager.DEFAULT_MAP_DIR)); - setArchDirectory(prefs.get(ResourceFileManager.ARCH_DIR_KEY, ResourceFileManager.DEFAULT_ARCH_DIR)); + setArchDirectory(new File(prefs.get(ResourceFileManager.ARCH_DIR_KEY, ResourceFileManager.DEFAULT_ARCH_DIR))); setScriptDirectory(prefs.get(ResourceFileManager.SCRIPT_DIR_KEY, ResourceFileManager.DEFAULT_SCRIPT_DIR)); mediaDir = prefs.get(ResourceFileManager.MEDIA_DIR_KEY, ResourceFileManager.DEFAULT_MEDIA_DIR); setMapDir(new File(getMapsDirectory())); Modified: trunk/daimonin/src/daieditor/gameobject/ArchetypeSetLoader.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/ArchetypeSetLoader.java 2008-11-12 22:46:12 UTC (rev 5726) +++ trunk/daimonin/src/daieditor/gameobject/ArchetypeSetLoader.java 2008-11-12 22:52:40 UTC (rev 5727) @@ -162,7 +162,7 @@ FaceObjectProviders.setNormal(new ArchFaceProvider()); archetypeSet.setLoadedFromArchive(false); // don't load from the collected files animFiles = new ArrayList<Pair<String, File>>(); - dir = new File(globalSettings.getArchDirectory()); + dir = globalSettings.getArchDirectory(); addPNGFace(new File(dir, "dev/editor/bug.101.png").getAbsolutePath(), "/dev/editor", "bug.101.png", parent); final ErrorViewCollector archDirectoryErrorViewCollector = new ErrorViewCollector(errorView, dir.getPath()); loadArchetypesFromFiles(archDirectoryErrorViewCollector, archetypeParser, null, dir, 0, "default", "default", false, invObjects, parent); // load arches & images from individual files Modified: trunk/daimonin/src/daieditor/gui/prefs/ResPrefs.java =================================================================== --- trunk/daimonin/src/daieditor/gui/prefs/ResPrefs.java 2008-11-12 22:46:12 UTC (rev 5726) +++ trunk/daimonin/src/daieditor/gui/prefs/ResPrefs.java 2008-11-12 22:52:40 UTC (rev 5727) @@ -109,7 +109,7 @@ /** {@inheritDoc} */ public void revert() { - archField.setText(globalSettings.getArchDirectory()); + archField.setText(globalSettings.getArchDirectory().getPath()); mapField.setText(globalSettings.getMapsDirectory()); scriptField.setText(globalSettings.getScriptDirectory()); mediaField.setText(globalSettings.getMediaDefaultFolder()); @@ -127,7 +127,7 @@ /** {@inheritDoc} */ public boolean isChanged() { return !( - archField.getText().equals(globalSettings.getArchDirectory()) + archField.getText().equals(globalSettings.getArchDirectory().getPath()) && mapField.getText().equals(globalSettings.getMapsDirectory()) && scriptField.getText().equals(globalSettings.getScriptDirectory()) && mediaField.getText().equals(globalSettings.getMediaDefaultFolder()) @@ -158,7 +158,7 @@ private Component createResourcePanel() { final Box resourcePanel = Box.createVerticalBox(); resourcePanel.setBorder(createTitledBorder("optionsResPaths")); - archField = createFileField(resourcePanel, "optionsResArch", globalSettings.getArchDirectory(), JFileChooser.DIRECTORIES_ONLY); + archField = createFileField(resourcePanel, "optionsResArch", globalSettings.getArchDirectory().getPath(), JFileChooser.DIRECTORIES_ONLY); mapField = createFileField(resourcePanel, "optionsResMaps", globalSettings.getMapsDirectory(), JFileChooser.DIRECTORIES_ONLY); scriptField = createFileField(resourcePanel, "optionsResScripts", globalSettings.getScriptDirectory(), JFileChooser.DIRECTORIES_ONLY); mediaField = createFileField(resourcePanel, "optionsResMedia", globalSettings.getMediaDefaultFolder(), JFileChooser.DIRECTORIES_ONLY); Modified: trunk/src/app/net/sf/gridarta/GlobalSettings.java =================================================================== --- trunk/src/app/net/sf/gridarta/GlobalSettings.java 2008-11-12 22:46:12 UTC (rev 5726) +++ trunk/src/app/net/sf/gridarta/GlobalSettings.java 2008-11-12 22:52:40 UTC (rev 5727) @@ -32,7 +32,7 @@ * Returns the archetype directory. * @return the archetype directory */ - String getArchDirectory(); + File getArchDirectory(); /** * Get the default folder of maps. Modified: trunk/src/app/net/sf/gridarta/GlobalSettingsImpl.java =================================================================== --- trunk/src/app/net/sf/gridarta/GlobalSettingsImpl.java 2008-11-12 22:46:12 UTC (rev 5726) +++ trunk/src/app/net/sf/gridarta/GlobalSettingsImpl.java 2008-11-12 22:52:40 UTC (rev 5727) @@ -34,7 +34,7 @@ /** Preferences. */ protected static final Preferences prefs = Preferences.userNodeForPackage(MainControl.class); - private String archDirectory; + private File archDirectory; private String mapsDirectory; @@ -61,11 +61,11 @@ private boolean autoPopupDocu = false; /** {@inheritDoc} */ - public String getArchDirectory() { + public File getArchDirectory() { return archDirectory; } - protected void setArchDirectory(final String archDirectory) { + protected void setArchDirectory(final File archDirectory) { this.archDirectory = archDirectory; } Modified: trunk/src/app/net/sf/gridarta/io/PathManager.java =================================================================== --- trunk/src/app/net/sf/gridarta/io/PathManager.java 2008-11-12 22:46:12 UTC (rev 5726) +++ trunk/src/app/net/sf/gridarta/io/PathManager.java 2008-11-12 22:52:40 UTC (rev 5727) @@ -62,7 +62,7 @@ * @return fixed path */ public static String getArchPath(final String path) { - final String archDirName = globalSettings.getArchDirectory(); + final String archDirName = globalSettings.getArchDirectory().getPath(); String archPath = path.replace('\\', '/'); if (archPath.startsWith(archDirName)) { archPath = archPath.substring(archDirName.length()); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-11-12 22:58:18
|
Revision: 5728 http://gridarta.svn.sourceforge.net/gridarta/?rev=5728&view=rev Author: akirschbaum Date: 2008-11-12 22:58:14 +0000 (Wed, 12 Nov 2008) Log Message: ----------- Replace String with File. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/daimonin/src/daieditor/CMainControl.java trunk/src/app/net/sf/gridarta/treasurelist/TreasureLoader.java trunk/src/app/net/sf/gridarta/treasurelist/TreasureLocation.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-11-12 22:52:40 UTC (rev 5727) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-11-12 22:58:14 UTC (rev 5728) @@ -283,7 +283,7 @@ @Override protected CFTreasureListTree<GameObject, MapArchObject, Archetype> createTreasureListTree(@NotNull final DefaultErrorView errorView, @NotNull final GlobalSettings globalSettings, @NotNull final net.sf.gridarta.gameobject.ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final Map<String, TreasureTreeNode> specialTreasureLists) { return new CFTreasureListTree<GameObject, MapArchObject, Archetype>(errorView, getMainView(), archetypeSet, specialTreasureLists, - new TreasureLocation(globalSettings.getCollectedDirectory(), IGUIConstants.TREASURES_FILE) + new TreasureLocation(new File(globalSettings.getCollectedDirectory()), IGUIConstants.TREASURES_FILE) ); } Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-11-12 22:52:40 UTC (rev 5727) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-11-12 22:58:14 UTC (rev 5728) @@ -316,8 +316,8 @@ @Override protected CFTreasureListTree<GameObject, MapArchObject, Archetype> createTreasureListTree(@NotNull final DefaultErrorView errorView, @NotNull final GlobalSettings globalSettings, @NotNull final net.sf.gridarta.gameobject.ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final Map<String, TreasureTreeNode> specialTreasureLists) { return new CFTreasureListTree<GameObject, MapArchObject, Archetype>(errorView, getMainView(), archetypeSet, specialTreasureLists, - new TreasureLocation(globalSettings.getCollectedDirectory(), IGUIConstants.TREASURES_FILE), - new TreasureLocation(globalSettings.getMapsDirectory(), null) + new TreasureLocation(new File(globalSettings.getCollectedDirectory()), IGUIConstants.TREASURES_FILE), + new TreasureLocation(new File(globalSettings.getMapsDirectory()), null) ); } Modified: trunk/src/app/net/sf/gridarta/treasurelist/TreasureLoader.java =================================================================== --- trunk/src/app/net/sf/gridarta/treasurelist/TreasureLoader.java 2008-11-12 22:52:40 UTC (rev 5727) +++ trunk/src/app/net/sf/gridarta/treasurelist/TreasureLoader.java 2008-11-12 22:58:14 UTC (rev 5728) @@ -87,10 +87,10 @@ // first step: parsing datafile, adding all treasurelists to the tmpList vector for (final TreasureLocation treasureLocation : treasures) { - final String dname = treasureLocation.getDname(); + final File dname = treasureLocation.getDname(); final String fname = treasureLocation.getFname(); - final ErrorViewCollector errorViewCollector = new ErrorViewCollector(errorView, fname == null ? dname : dname + fname); - loadTreasureList(errorViewCollector, new File(dname), fname, tmpList, needLink); + final ErrorViewCollector errorViewCollector = new ErrorViewCollector(errorView, (fname == null ? dname : new File(dname, fname)).getPath()); + loadTreasureList(errorViewCollector, dname, fname, tmpList, needLink); } // second step: sort alphabetically and link sub-treasurelist entries Modified: trunk/src/app/net/sf/gridarta/treasurelist/TreasureLocation.java =================================================================== --- trunk/src/app/net/sf/gridarta/treasurelist/TreasureLocation.java 2008-11-12 22:52:40 UTC (rev 5727) +++ trunk/src/app/net/sf/gridarta/treasurelist/TreasureLocation.java 2008-11-12 22:58:14 UTC (rev 5728) @@ -19,6 +19,7 @@ package net.sf.gridarta.treasurelist; +import java.io.File; import org.jetbrains.annotations.Nullable; /** @@ -29,7 +30,7 @@ /** The directory to read from. */ @Nullable - private final String dname; + private final File dname; /** * The filename to parse; <code>null</code> to recursivey parse @@ -44,7 +45,7 @@ * @param fname The filename to parse; <code>null</code> to recursivey parse * <code>dname</code>. */ - public TreasureLocation(@Nullable final String dname, @Nullable final String fname) { + public TreasureLocation(@Nullable final File dname, @Nullable final String fname) { this.dname = dname; this.fname = fname; } @@ -54,7 +55,7 @@ * @return The directory to read from. */ @Nullable - public String getDname() { + public File getDname() { return dname; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-11-12 23:10:15
|
Revision: 5729 http://gridarta.svn.sourceforge.net/gridarta/?rev=5729&view=rev Author: akirschbaum Date: 2008-11-12 23:10:09 +0000 (Wed, 12 Nov 2008) Log Message: ----------- Fix incorrect nullable annotations. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gameobject/ArchetypeParser.java trunk/daimonin/src/daieditor/gameobject/ArchetypeParser.java trunk/src/app/net/sf/gridarta/gameobject/AbstractArchetypeParser.java trunk/src/app/net/sf/gridarta/gameobject/ArchetypeParser.java Modified: trunk/crossfire/src/cfeditor/gameobject/ArchetypeParser.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/ArchetypeParser.java 2008-11-12 22:58:14 UTC (rev 5728) +++ trunk/crossfire/src/cfeditor/gameobject/ArchetypeParser.java 2008-11-12 23:10:09 UTC (rev 5729) @@ -108,7 +108,7 @@ } /** {@inheritDoc} */ - public void parseArchetypeFromStream(final BufferedReader in, @Nullable final GameObject prototype, @Nullable final String line, @Nullable final String archName, @NotNull final String panelName, @NotNull final String folderName, @NotNull final File file, @NotNull final List<GameObject> invObjects) throws IOException { + public void parseArchetypeFromStream(final BufferedReader in, @Nullable final GameObject prototype, @Nullable final String line, @Nullable final String archName, @NotNull final String panelName, @NotNull final String folderName, @Nullable final File file, @NotNull final List<GameObject> invObjects) throws IOException { // start with new clean GameObject instance @Nullable GameObject archetype; if (prototype == null) { Modified: trunk/daimonin/src/daieditor/gameobject/ArchetypeParser.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/ArchetypeParser.java 2008-11-12 22:58:14 UTC (rev 5728) +++ trunk/daimonin/src/daieditor/gameobject/ArchetypeParser.java 2008-11-12 23:10:09 UTC (rev 5729) @@ -90,7 +90,7 @@ /** {@inheritDoc} */ @SuppressWarnings({"StringContatenationInLoop", "ObjectAllocationInLoop"}) - public void parseArchetypeFromStream(final BufferedReader in, @Nullable final GameObject prototype, @Nullable final String line, @Nullable final String archName, @NotNull final String panelName, @NotNull final String folderName, @NotNull final File file, @NotNull final List<GameObject> invObjects) throws IOException { + public void parseArchetypeFromStream(final BufferedReader in, @Nullable final GameObject prototype, @Nullable final String line, @Nullable final String archName, @NotNull final String panelName, @NotNull final String folderName, @Nullable final File file, @NotNull final List<GameObject> invObjects) throws IOException { // start with new clean GameObject instance @Nullable GameObject archetype; if (prototype == null) { Modified: trunk/src/app/net/sf/gridarta/gameobject/AbstractArchetypeParser.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/AbstractArchetypeParser.java 2008-11-12 22:58:14 UTC (rev 5728) +++ trunk/src/app/net/sf/gridarta/gameobject/AbstractArchetypeParser.java 2008-11-12 23:10:09 UTC (rev 5729) @@ -29,6 +29,7 @@ import net.sf.japi.swing.ActionFactory; import org.apache.log4j.Logger; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * Abstract base implementation of {@link ArchetypeParser}. @@ -47,7 +48,7 @@ } /** {@inheritDoc} */ - public void parseArchetypeFromStream(final BufferedReader in, @NotNull final String panelName, @NotNull final String folderName, @NotNull final File file, @NotNull final List<G> invObjects) throws IOException { + public void parseArchetypeFromStream(final BufferedReader in, @NotNull final String panelName, @NotNull final String folderName, @Nullable final File file, @NotNull final List<G> invObjects) throws IOException { parseArchetypeFromStream(in, null, null, null, panelName, folderName, file, invObjects); } Modified: trunk/src/app/net/sf/gridarta/gameobject/ArchetypeParser.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/ArchetypeParser.java 2008-11-12 22:58:14 UTC (rev 5728) +++ trunk/src/app/net/sf/gridarta/gameobject/ArchetypeParser.java 2008-11-12 23:10:09 UTC (rev 5729) @@ -59,7 +59,7 @@ * @throws IOException in case of I/O problems * @throws java.io.EOFException in case an uncomplete object was found */ - void parseArchetypeFromStream(BufferedReader in, @Nullable G prototype, @Nullable String line, @Nullable String archName, @NotNull String panelName, @NotNull String folderName, @NotNull File file, @NotNull List<G> invObjects) throws IOException; + void parseArchetypeFromStream(BufferedReader in, @Nullable G prototype, @Nullable String line, @Nullable String archName, @NotNull String panelName, @NotNull String folderName, @Nullable File file, @NotNull List<G> invObjects) throws IOException; /** * Short form of {@link #parseArchetypeFromStream(BufferedReader, @@ -72,6 +72,6 @@ * @throws IOException in case of I/O problems * @throws java.io.EOFException in case an uncomplete object was found */ - void parseArchetypeFromStream(BufferedReader in, @NotNull String panelName, @NotNull String folderName, @NotNull File file, @NotNull List<G> invObjects) throws IOException; + void parseArchetypeFromStream(BufferedReader in, @NotNull String panelName, @NotNull String folderName, @Nullable File file, @NotNull List<G> invObjects) throws IOException; } // interface ArchetypeParser This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-11-12 23:12:15
|
Revision: 5730 http://gridarta.svn.sourceforge.net/gridarta/?rev=5730&view=rev Author: akirschbaum Date: 2008-11-12 23:12:11 +0000 (Wed, 12 Nov 2008) Log Message: ----------- Replace String with File. Modified Paths: -------------- trunk/crossfire/src/cfeditor/GlobalSettingsImpl.java trunk/crossfire/src/cfeditor/gui/prefs/ResPrefs.java trunk/daimonin/src/daieditor/GlobalSettingsImpl.java trunk/daimonin/src/daieditor/gui/prefs/ResPrefs.java trunk/src/app/net/sf/gridarta/GlobalSettings.java trunk/src/app/net/sf/gridarta/GlobalSettingsImpl.java Modified: trunk/crossfire/src/cfeditor/GlobalSettingsImpl.java =================================================================== --- trunk/crossfire/src/cfeditor/GlobalSettingsImpl.java 2008-11-12 23:10:09 UTC (rev 5729) +++ trunk/crossfire/src/cfeditor/GlobalSettingsImpl.java 2008-11-12 23:12:11 UTC (rev 5730) @@ -83,7 +83,7 @@ public void initDirs() { setMapsDirectory(prefs.get(ResourceFileManager.MAP_DIR_KEY, ResourceFileManager.DEFAULT_MAP_DIR)); setArchDirectory(new File(prefs.get(ResourceFileManager.ARCH_DIR_KEY, ResourceFileManager.DEFAULT_ARCH_DIR))); - setScriptDirectory(prefs.get(ResourceFileManager.SCRIPT_DIR_KEY, ResourceFileManager.DEFAULT_SCRIPT_DIR)); + setScriptDirectory(new File(prefs.get(ResourceFileManager.SCRIPT_DIR_KEY, ResourceFileManager.DEFAULT_SCRIPT_DIR))); // set map dir if (getMapsDirectory().length() > 0) { Modified: trunk/crossfire/src/cfeditor/gui/prefs/ResPrefs.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/prefs/ResPrefs.java 2008-11-12 23:10:09 UTC (rev 5729) +++ trunk/crossfire/src/cfeditor/gui/prefs/ResPrefs.java 2008-11-12 23:12:11 UTC (rev 5730) @@ -120,7 +120,7 @@ public void revert() { archField.setText(globalSettings.getArchDirectory().getPath()); mapField.setText(globalSettings.getMapsDirectory()); - scriptField.setText(globalSettings.getScriptDirectory()); + scriptField.setText(globalSettings.getScriptDirectory().getPath()); loadArches.setSelected(globalSettings.isArchLoadedFromCollection()); imageSetBox.setSelectedIndex(linearSearch(imageSets, getCurrentImageSet())); } @@ -141,7 +141,7 @@ return !( archField.getText().equals(globalSettings.getArchDirectory()) && mapField.getText().equals(globalSettings.getMapsDirectory()) - && scriptField.getText().equals(globalSettings.getScriptDirectory()) + && scriptField.getText().equals(globalSettings.getScriptDirectory().getPath()) && loadArches.isSelected() == prefs.getBoolean(GlobalSettings.LOAD_ARCH_COLL, globalSettings.isArchLoadedFromCollection()) && imageSet.equals(getCurrentImageSet()) ); @@ -172,7 +172,7 @@ resourcePanel.setBorder(createTitledBorder("optionsResPaths")); archField = createFileField(resourcePanel, "optionsResArch", globalSettings.getArchDirectory().getPath(), JFileChooser.DIRECTORIES_ONLY); mapField = createFileField(resourcePanel, "optionsResMaps", globalSettings.getMapsDirectory(), JFileChooser.DIRECTORIES_ONLY); - scriptField = createFileField(resourcePanel, "optionsResScripts", globalSettings.getScriptDirectory(), JFileChooser.DIRECTORIES_ONLY); + scriptField = createFileField(resourcePanel, "optionsResScripts", globalSettings.getScriptDirectory().getPath(), JFileChooser.DIRECTORIES_ONLY); return resourcePanel; } Modified: trunk/daimonin/src/daieditor/GlobalSettingsImpl.java =================================================================== --- trunk/daimonin/src/daieditor/GlobalSettingsImpl.java 2008-11-12 23:10:09 UTC (rev 5729) +++ trunk/daimonin/src/daieditor/GlobalSettingsImpl.java 2008-11-12 23:12:11 UTC (rev 5730) @@ -67,7 +67,7 @@ public void initDirs() { setMapsDirectory(prefs.get(ResourceFileManager.MAP_DIR_KEY, ResourceFileManager.DEFAULT_MAP_DIR)); setArchDirectory(new File(prefs.get(ResourceFileManager.ARCH_DIR_KEY, ResourceFileManager.DEFAULT_ARCH_DIR))); - setScriptDirectory(prefs.get(ResourceFileManager.SCRIPT_DIR_KEY, ResourceFileManager.DEFAULT_SCRIPT_DIR)); + setScriptDirectory(new File(prefs.get(ResourceFileManager.SCRIPT_DIR_KEY, ResourceFileManager.DEFAULT_SCRIPT_DIR))); mediaDir = prefs.get(ResourceFileManager.MEDIA_DIR_KEY, ResourceFileManager.DEFAULT_MEDIA_DIR); setMapDir(new File(getMapsDirectory())); finishInitDirs(); Modified: trunk/daimonin/src/daieditor/gui/prefs/ResPrefs.java =================================================================== --- trunk/daimonin/src/daieditor/gui/prefs/ResPrefs.java 2008-11-12 23:10:09 UTC (rev 5729) +++ trunk/daimonin/src/daieditor/gui/prefs/ResPrefs.java 2008-11-12 23:12:11 UTC (rev 5730) @@ -111,7 +111,7 @@ public void revert() { archField.setText(globalSettings.getArchDirectory().getPath()); mapField.setText(globalSettings.getMapsDirectory()); - scriptField.setText(globalSettings.getScriptDirectory()); + scriptField.setText(globalSettings.getScriptDirectory().getPath()); mediaField.setText(globalSettings.getMediaDefaultFolder()); loadArches.setSelected(globalSettings.isArchLoadedFromCollection()); } @@ -129,7 +129,7 @@ return !( archField.getText().equals(globalSettings.getArchDirectory().getPath()) && mapField.getText().equals(globalSettings.getMapsDirectory()) - && scriptField.getText().equals(globalSettings.getScriptDirectory()) + && scriptField.getText().equals(globalSettings.getScriptDirectory().getPath()) && mediaField.getText().equals(globalSettings.getMediaDefaultFolder()) && loadArches.isSelected() == prefs.getBoolean(GlobalSettings.LOAD_ARCH_COLL, globalSettings.isArchLoadedFromCollection()) ); @@ -160,7 +160,7 @@ resourcePanel.setBorder(createTitledBorder("optionsResPaths")); archField = createFileField(resourcePanel, "optionsResArch", globalSettings.getArchDirectory().getPath(), JFileChooser.DIRECTORIES_ONLY); mapField = createFileField(resourcePanel, "optionsResMaps", globalSettings.getMapsDirectory(), JFileChooser.DIRECTORIES_ONLY); - scriptField = createFileField(resourcePanel, "optionsResScripts", globalSettings.getScriptDirectory(), JFileChooser.DIRECTORIES_ONLY); + scriptField = createFileField(resourcePanel, "optionsResScripts", globalSettings.getScriptDirectory().getPath(), JFileChooser.DIRECTORIES_ONLY); mediaField = createFileField(resourcePanel, "optionsResMedia", globalSettings.getMediaDefaultFolder(), JFileChooser.DIRECTORIES_ONLY); return resourcePanel; } Modified: trunk/src/app/net/sf/gridarta/GlobalSettings.java =================================================================== --- trunk/src/app/net/sf/gridarta/GlobalSettings.java 2008-11-12 23:10:09 UTC (rev 5729) +++ trunk/src/app/net/sf/gridarta/GlobalSettings.java 2008-11-12 23:12:11 UTC (rev 5730) @@ -51,7 +51,7 @@ * Get the default folder of scripts. * @return default folder of scripts. */ - String getScriptDirectory(); + File getScriptDirectory(); void setImageDirectory(String imageDirectory); Modified: trunk/src/app/net/sf/gridarta/GlobalSettingsImpl.java =================================================================== --- trunk/src/app/net/sf/gridarta/GlobalSettingsImpl.java 2008-11-12 23:10:09 UTC (rev 5729) +++ trunk/src/app/net/sf/gridarta/GlobalSettingsImpl.java 2008-11-12 23:12:11 UTC (rev 5730) @@ -41,7 +41,7 @@ @NotNull private File mapDir; - private String scriptDirectory; + private File scriptDirectory; /** The current main directory. */ private File currentDirectory = new File(System.getProperty("user.dir")); @@ -89,11 +89,11 @@ } /** {@inheritDoc} */ - public String getScriptDirectory() { + public File getScriptDirectory() { return scriptDirectory; } - protected void setScriptDirectory(final String scriptDirectory) { + protected void setScriptDirectory(final File scriptDirectory) { this.scriptDirectory = scriptDirectory; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-11-12 23:15:11
|
Revision: 5732 http://gridarta.svn.sourceforge.net/gridarta/?rev=5732&view=rev Author: akirschbaum Date: 2008-11-12 23:15:06 +0000 (Wed, 12 Nov 2008) Log Message: ----------- Replace String with File. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/GlobalSettingsImpl.java trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/GlobalSettingsImpl.java trunk/src/app/net/sf/gridarta/GlobalSettings.java trunk/src/app/net/sf/gridarta/gui/MainActions.java trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-11-12 23:12:40 UTC (rev 5731) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-11-12 23:15:06 UTC (rev 5732) @@ -283,7 +283,7 @@ @Override protected CFTreasureListTree<GameObject, MapArchObject, Archetype> createTreasureListTree(@NotNull final DefaultErrorView errorView, @NotNull final GlobalSettings globalSettings, @NotNull final net.sf.gridarta.gameobject.ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final Map<String, TreasureTreeNode> specialTreasureLists) { return new CFTreasureListTree<GameObject, MapArchObject, Archetype>(errorView, getMainView(), archetypeSet, specialTreasureLists, - new TreasureLocation(new File(globalSettings.getCollectedDirectory()), IGUIConstants.TREASURES_FILE) + new TreasureLocation(globalSettings.getCollectedDirectory(), IGUIConstants.TREASURES_FILE) ); } @@ -308,7 +308,7 @@ /** {@inheritDoc} */ @Override protected AbstractArchetypeSetLoader newArchetypeSetLoader(@NotNull final GameObjectParser<GameObject, MapArchObject, Archetype> gameObjectParser, @NotNull final AbstractArchetypeParser<GameObject, MapArchObject, Archetype> archetypeParser, @NotNull final EditTypes editTypes, @NotNull final FaceObjects faceObjects, @NotNull final AnimationObjects animationObjects, @NotNull final GlobalSettings globalSettings, @NotNull final net.sf.gridarta.gameobject.ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet) { - return new ArchetypeSetLoader(globalSettings, gameObjectParser, new File(globalSettings.getCollectedDirectory()), archetypeSet, archetypeParser, editTypes, faceObjects, animationObjects); + return new ArchetypeSetLoader(globalSettings, gameObjectParser, globalSettings.getCollectedDirectory(), archetypeSet, archetypeParser, editTypes, faceObjects, animationObjects); } /** {@inheritDoc} */ Modified: trunk/crossfire/src/cfeditor/GlobalSettingsImpl.java =================================================================== --- trunk/crossfire/src/cfeditor/GlobalSettingsImpl.java 2008-11-12 23:12:40 UTC (rev 5731) +++ trunk/crossfire/src/cfeditor/GlobalSettingsImpl.java 2008-11-12 23:15:06 UTC (rev 5732) @@ -62,8 +62,8 @@ /** {@inheritDoc} */ @NotNull - public String getCollectedDirectory() { - return getConfigurationDirectory(); + public File getCollectedDirectory() { + return new File(getConfigurationDirectory()); } /** {@inheritDoc} */ Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-11-12 23:12:40 UTC (rev 5731) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-11-12 23:15:06 UTC (rev 5732) @@ -316,7 +316,7 @@ @Override protected CFTreasureListTree<GameObject, MapArchObject, Archetype> createTreasureListTree(@NotNull final DefaultErrorView errorView, @NotNull final GlobalSettings globalSettings, @NotNull final net.sf.gridarta.gameobject.ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final Map<String, TreasureTreeNode> specialTreasureLists) { return new CFTreasureListTree<GameObject, MapArchObject, Archetype>(errorView, getMainView(), archetypeSet, specialTreasureLists, - new TreasureLocation(new File(globalSettings.getCollectedDirectory()), IGUIConstants.TREASURES_FILE), + new TreasureLocation(globalSettings.getCollectedDirectory(), IGUIConstants.TREASURES_FILE), new TreasureLocation(new File(globalSettings.getMapsDirectory()), null) ); } @@ -343,7 +343,7 @@ @Override protected AbstractArchetypeSetLoader newArchetypeSetLoader(@NotNull final GameObjectParser<GameObject, MapArchObject, Archetype> gameObjectParser, @NotNull final AbstractArchetypeParser<GameObject, MapArchObject, Archetype> archetypeParser, @NotNull final EditTypes editTypes, @NotNull final FaceObjects faceObjects, @NotNull final AnimationObjects animationObjects, @NotNull final GlobalSettings globalSettings, @NotNull final net.sf.gridarta.gameobject.ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet) { MultiPositionData.init(new File(globalSettings.getConfigurationDirectory())); - return new ArchetypeSetLoader(globalSettings, gameObjectParser, new File(globalSettings.getCollectedDirectory()), archetypeSet, archetypeParser, editTypes, faceObjects, animationObjects); + return new ArchetypeSetLoader(globalSettings, gameObjectParser, globalSettings.getCollectedDirectory(), archetypeSet, archetypeParser, editTypes, faceObjects, animationObjects); } /** {@inheritDoc} */ Modified: trunk/daimonin/src/daieditor/GlobalSettingsImpl.java =================================================================== --- trunk/daimonin/src/daieditor/GlobalSettingsImpl.java 2008-11-12 23:12:40 UTC (rev 5731) +++ trunk/daimonin/src/daieditor/GlobalSettingsImpl.java 2008-11-12 23:15:06 UTC (rev 5732) @@ -50,8 +50,8 @@ /** {@inheritDoc} */ @NotNull - public String getCollectedDirectory() { - return getArchDirectory().getPath(); + public File getCollectedDirectory() { + return getArchDirectory(); } /** {@inheritDoc} */ Modified: trunk/src/app/net/sf/gridarta/GlobalSettings.java =================================================================== --- trunk/src/app/net/sf/gridarta/GlobalSettings.java 2008-11-12 23:12:40 UTC (rev 5731) +++ trunk/src/app/net/sf/gridarta/GlobalSettings.java 2008-11-12 23:15:06 UTC (rev 5732) @@ -100,6 +100,6 @@ * @return the directory */ @NotNull - String getCollectedDirectory(); + File getCollectedDirectory(); } // interface GlobalSettings Modified: trunk/src/app/net/sf/gridarta/gui/MainActions.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/MainActions.java 2008-11-12 23:12:40 UTC (rev 5731) +++ trunk/src/app/net/sf/gridarta/gui/MainActions.java 2008-11-12 23:15:06 UTC (rev 5732) @@ -20,7 +20,6 @@ package net.sf.gridarta.gui; import java.awt.Component; -import java.io.File; import java.util.List; import javax.swing.Action; import javax.swing.JFrame; @@ -654,7 +653,7 @@ collector = new Collector(collectArches); collector.setCollectables(collectables); - collector.setCollectedDirectory(new File(globalSettings.getCollectedDirectory())); + collector.setCollectedDirectory(globalSettings.getCollectedDirectory()); collector.start(); aCollectArches.setEnabled(isCollectArchesEnabled()); } Modified: trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java =================================================================== --- trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java 2008-11-12 23:12:40 UTC (rev 5731) +++ trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java 2008-11-12 23:15:06 UTC (rev 5732) @@ -885,7 +885,7 @@ /** {@inheritDoc} */ @NotNull - public String getCollectedDirectory() { + public File getCollectedDirectory() { throw new AssertionError(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-11-12 23:19:30
|
Revision: 5733 http://gridarta.svn.sourceforge.net/gridarta/?rev=5733&view=rev Author: akirschbaum Date: 2008-11-12 23:19:26 +0000 (Wed, 12 Nov 2008) Log Message: ----------- Replace String with File. Modified Paths: -------------- trunk/daimonin/src/daieditor/CMainControl.java trunk/src/app/net/sf/gridarta/spells/SpellsUtils.java Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-11-12 23:15:06 UTC (rev 5732) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-11-12 23:19:26 UTC (rev 5733) @@ -535,7 +535,7 @@ /** Collect Spells. */ @ActionMethod public void collectSpells() { - new SpellsUtils(IGUIConstants.SPELL_FILE).importSpellsWanted(globalSettings.getConfigurationDirectory(), getMainView()); + new SpellsUtils(IGUIConstants.SPELL_FILE).importSpellsWanted(new File(globalSettings.getConfigurationDirectory()), getMainView()); } /** Modified: trunk/src/app/net/sf/gridarta/spells/SpellsUtils.java =================================================================== --- trunk/src/app/net/sf/gridarta/spells/SpellsUtils.java 2008-11-12 23:15:06 UTC (rev 5732) +++ trunk/src/app/net/sf/gridarta/spells/SpellsUtils.java 2008-11-12 23:19:26 UTC (rev 5733) @@ -70,10 +70,10 @@ /** * Opens a file chooser to select the spellist file, then import spells. - * @param baseDir the directory to use + * @param dir the directory to use * @param parent Component the parent component for dialog boxes */ - public void importSpellsWanted(@NotNull final String baseDir, @NotNull final Component parent) { + public void importSpellsWanted(@NotNull final File dir, @NotNull final Component parent) { // open a file chooser window final JFileChooser fileChooser = new JFileChooser(); fileChooser.setDialogTitle("Open CF Spellist File"); @@ -89,7 +89,7 @@ if (returnVal == JFileChooser.APPROVE_OPTION) { // now import spells from selected file final File spellfile = fileChooser.getSelectedFile(); - final int spnum = importSpells(spellfile, baseDir); + final int spnum = importSpells(spellfile, dir); if (spnum > 0) { // yeah it worked ACTION_FACTORY.showMessageDialog(parent, "importSpellsSuccess", spnum); @@ -104,10 +104,10 @@ * Read all spells from a Crossfire or Daimonin spellist file and write an * alphabetical list into "spells.def". * @param spellfile spellfile to read - * @param baseDir The base directory to load the spells file from. + * @param dir The base directory to load the spells file from. * @return number of successfully collected spells */ - private int importSpells(final File spellfile, final String baseDir) { + private int importSpells(final File spellfile, @NotNull final File dir) { final Map<String, String> spells = new TreeMap<String, String>(); if (spellfile.getName().equalsIgnoreCase("spellist.h")) { try { @@ -142,14 +142,13 @@ // FIXME: This should use DOM for writing the file. final File dfile; // create new file for writing (replaces old one if existent) - if (baseDir.length() > 0) { - final File dir = new File(baseDir); + if (dir.getPath().length() > 0) { if (!dir.exists() || !dir.isDirectory()) { // FIXME What if dir exists and is not a directory? mkdir will fail then! // create the config dir new File("resource").mkdir(); - new File(baseDir).mkdir(); + dir.mkdir(); } - dfile = new File(baseDir, spellFile); + dfile = new File(dir, spellFile); } else { dfile = new File(spellFile); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-11-12 23:24:34
|
Revision: 5736 http://gridarta.svn.sourceforge.net/gridarta/?rev=5736&view=rev Author: akirschbaum Date: 2008-11-12 23:24:29 +0000 (Wed, 12 Nov 2008) Log Message: ----------- Replace String with File. Modified Paths: -------------- trunk/crossfire/src/cfeditor/GlobalSettingsImpl.java trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/GlobalSettingsImpl.java trunk/src/app/net/sf/gridarta/AbstractMainControl.java trunk/src/app/net/sf/gridarta/GlobalSettings.java trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java Modified: trunk/crossfire/src/cfeditor/GlobalSettingsImpl.java =================================================================== --- trunk/crossfire/src/cfeditor/GlobalSettingsImpl.java 2008-11-12 23:21:49 UTC (rev 5735) +++ trunk/crossfire/src/cfeditor/GlobalSettingsImpl.java 2008-11-12 23:24:29 UTC (rev 5736) @@ -56,14 +56,14 @@ /** {@inheritDoc} */ @NotNull - public String getConfigurationDirectory() { - return "resource/conf"; + public File getConfigurationDirectory() { + return new File("resource/conf"); } /** {@inheritDoc} */ @NotNull public File getCollectedDirectory() { - return new File(getConfigurationDirectory()); + return getConfigurationDirectory(); } /** {@inheritDoc} */ Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-11-12 23:21:49 UTC (rev 5735) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-11-12 23:24:29 UTC (rev 5736) @@ -342,7 +342,7 @@ /** {@inheritDoc} */ @Override protected AbstractArchetypeSetLoader newArchetypeSetLoader(@NotNull final GameObjectParser<GameObject, MapArchObject, Archetype> gameObjectParser, @NotNull final AbstractArchetypeParser<GameObject, MapArchObject, Archetype> archetypeParser, @NotNull final EditTypes editTypes, @NotNull final FaceObjects faceObjects, @NotNull final AnimationObjects animationObjects, @NotNull final GlobalSettings globalSettings, @NotNull final net.sf.gridarta.gameobject.ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet) { - MultiPositionData.init(new File(globalSettings.getConfigurationDirectory())); + MultiPositionData.init(globalSettings.getConfigurationDirectory()); return new ArchetypeSetLoader(globalSettings, gameObjectParser, globalSettings.getCollectedDirectory(), archetypeSet, archetypeParser, editTypes, faceObjects, animationObjects); } @@ -535,7 +535,7 @@ /** Collect Spells. */ @ActionMethod public void collectSpells() { - new SpellsUtils(IGUIConstants.SPELL_FILE).importSpellsWanted(new File(globalSettings.getConfigurationDirectory()), getMainView()); + new SpellsUtils(IGUIConstants.SPELL_FILE).importSpellsWanted(globalSettings.getConfigurationDirectory(), getMainView()); } /** Modified: trunk/daimonin/src/daieditor/GlobalSettingsImpl.java =================================================================== --- trunk/daimonin/src/daieditor/GlobalSettingsImpl.java 2008-11-12 23:21:49 UTC (rev 5735) +++ trunk/daimonin/src/daieditor/GlobalSettingsImpl.java 2008-11-12 23:24:29 UTC (rev 5736) @@ -44,8 +44,8 @@ /** {@inheritDoc} */ @NotNull - public String getConfigurationDirectory() { - return new File(getArchDirectory(), "dev/editor/conf").getPath(); + public File getConfigurationDirectory() { + return new File(getArchDirectory(), "dev/editor/conf"); } /** {@inheritDoc} */ Modified: trunk/src/app/net/sf/gridarta/AbstractMainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2008-11-12 23:21:49 UTC (rev 5735) +++ trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2008-11-12 23:24:29 UTC (rev 5736) @@ -388,7 +388,7 @@ final ErrorViewCollector gameObjectMatchersErrorViewCollector = new ErrorViewCollector(errorView, "GameObjectMatchers.xml"); final GameObjectMatchers gameObjectMatchers = new GameObjectMatchers(xmlHelper.getDocumentBuilder(), xmlHelper.getXPath()); try { - final String filename = IOUtils.getResourceURLAsString(new File(globalSettings.getConfigurationDirectory()), "GameObjectMatchers.xml"); + final String filename = IOUtils.getResourceURLAsString(globalSettings.getConfigurationDirectory(), "GameObjectMatchers.xml"); gameObjectMatchers.readGameObjectMatchers(filename, gameObjectMatchersErrorViewCollector); } catch (final IOException ex) { gameObjectMatchersErrorViewCollector.addWarning("cannot read file: " + ex.getMessage()); @@ -428,7 +428,7 @@ final ErrorViewCollector treasureListsErrorViewCollector = new ErrorViewCollector(errorView, "TreasureLists.xml"); Map<String, TreasureTreeNode> specialTreasureLists; try { - final Document specialTreasureListsDocument = xmlHelper.getDocumentBuilder().parse(IOUtils.getResourceURLAsString(new File(globalSettings.getConfigurationDirectory()), "TreasureLists.xml")); + final Document specialTreasureListsDocument = xmlHelper.getDocumentBuilder().parse(IOUtils.getResourceURLAsString(globalSettings.getConfigurationDirectory(), "TreasureLists.xml")); specialTreasureLists = TreasureListsParser.parseTreasureLists(specialTreasureListsDocument); } catch (final IOException ex) { treasureListsErrorViewCollector.addWarning("cannot read file: " + ex.getMessage()); @@ -443,7 +443,7 @@ final ArchetypeTypeSetParser<G, A, R> archetypeTypeSetParser = new ArchetypeTypeSetParser<G, A, R>(xmlHelper.getDocumentBuilder(), xmlHelper.getXPath(), archetypeTypeSet, archetypeTypeParser); final ErrorViewCollector typesErrorViewCollector = new ErrorViewCollector(errorView, CommonConstants.TYPEDEF_FILE); try { - final String filename = IOUtils.getResourceURLAsString(new File(globalSettings.getConfigurationDirectory()), CommonConstants.TYPEDEF_FILE); + final String filename = IOUtils.getResourceURLAsString(globalSettings.getConfigurationDirectory(), CommonConstants.TYPEDEF_FILE); archetypeTypeSetParser.loadTypesFromXML(typesErrorViewCollector, filename); } catch (final FileNotFoundException ex) { typesErrorViewCollector.addError("cannot read file: " + ex.getMessage()); @@ -489,7 +489,7 @@ gameObjectSpells.sort(); } if (spellFile != null) { - XMLSpellLoader.load(errorView, new File(globalSettings.getConfigurationDirectory()), spellFile, xmlHelper.getDocumentBuilder(), numberSpells); + XMLSpellLoader.load(errorView, globalSettings.getConfigurationDirectory(), spellFile, xmlHelper.getDocumentBuilder(), numberSpells); numberSpells.sort(); } @@ -510,7 +510,7 @@ } scriptControl.loadScripts(new File(globalSettings.getMapDir(), scriptsDir)); archetypeChooserControl.getArchetypeChooserView().finishBuildProcess(); - autojoinLists.loadList(archetypeSet, new File(globalSettings.getConfigurationDirectory())); + autojoinLists.loadList(archetypeSet, globalSettings.getConfigurationDirectory()); if (archetypeSet.getLoadStatus() == ArchetypeSet.LoadStatus.EMPTY) { ACTION_FACTORY.showMessageDialog(mainView, "loadArchesNoArchfiles"); } else { Modified: trunk/src/app/net/sf/gridarta/GlobalSettings.java =================================================================== --- trunk/src/app/net/sf/gridarta/GlobalSettings.java 2008-11-12 23:21:49 UTC (rev 5735) +++ trunk/src/app/net/sf/gridarta/GlobalSettings.java 2008-11-12 23:24:29 UTC (rev 5736) @@ -93,7 +93,7 @@ * @return the directory */ @NotNull - String getConfigurationDirectory(); + File getConfigurationDirectory(); /** * Returns the directory where collected archetypes are stored. Modified: trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java =================================================================== --- trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java 2008-11-12 23:21:49 UTC (rev 5735) +++ trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java 2008-11-12 23:24:29 UTC (rev 5736) @@ -879,7 +879,7 @@ /** {@inheritDoc} */ @NotNull - public String getConfigurationDirectory() { + public File getConfigurationDirectory() { throw new AssertionError(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-11-12 23:26:46
|
Revision: 5737 http://gridarta.svn.sourceforge.net/gridarta/?rev=5737&view=rev Author: akirschbaum Date: 2008-11-12 23:26:43 +0000 (Wed, 12 Nov 2008) Log Message: ----------- Replace String with File. Modified Paths: -------------- trunk/crossfire/src/cfeditor/GlobalSettingsImpl.java trunk/daimonin/src/daieditor/GlobalSettingsImpl.java trunk/daimonin/src/daieditor/gui/map/MapPropertiesDialog.java trunk/daimonin/src/daieditor/gui/prefs/ResPrefs.java trunk/src/app/net/sf/gridarta/GlobalSettings.java trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java Modified: trunk/crossfire/src/cfeditor/GlobalSettingsImpl.java =================================================================== --- trunk/crossfire/src/cfeditor/GlobalSettingsImpl.java 2008-11-12 23:24:29 UTC (rev 5736) +++ trunk/crossfire/src/cfeditor/GlobalSettingsImpl.java 2008-11-12 23:26:43 UTC (rev 5737) @@ -50,7 +50,7 @@ /** {@inheritDoc} */ @NotNull - public String getMediaDefaultFolder() { + public File getMediaDefaultFolder() { throw new AssertionError("not implemented"); } Modified: trunk/daimonin/src/daieditor/GlobalSettingsImpl.java =================================================================== --- trunk/daimonin/src/daieditor/GlobalSettingsImpl.java 2008-11-12 23:24:29 UTC (rev 5736) +++ trunk/daimonin/src/daieditor/GlobalSettingsImpl.java 2008-11-12 23:26:43 UTC (rev 5737) @@ -28,11 +28,11 @@ */ public class GlobalSettingsImpl extends net.sf.gridarta.GlobalSettingsImpl { - private String mediaDir; + private File mediaDir; /** {@inheritDoc} */ @NotNull - public String getMediaDefaultFolder() { + public File getMediaDefaultFolder() { return mediaDir; } @@ -68,7 +68,7 @@ setMapsDirectory(prefs.get(ResourceFileManager.MAP_DIR_KEY, ResourceFileManager.DEFAULT_MAP_DIR)); setArchDirectory(new File(prefs.get(ResourceFileManager.ARCH_DIR_KEY, ResourceFileManager.DEFAULT_ARCH_DIR))); setScriptDirectory(new File(prefs.get(ResourceFileManager.SCRIPT_DIR_KEY, ResourceFileManager.DEFAULT_SCRIPT_DIR))); - mediaDir = prefs.get(ResourceFileManager.MEDIA_DIR_KEY, ResourceFileManager.DEFAULT_MEDIA_DIR); + mediaDir = new File(prefs.get(ResourceFileManager.MEDIA_DIR_KEY, ResourceFileManager.DEFAULT_MEDIA_DIR)); setMapDir(new File(getMapsDirectory())); finishInitDirs(); } Modified: trunk/daimonin/src/daieditor/gui/map/MapPropertiesDialog.java =================================================================== --- trunk/daimonin/src/daieditor/gui/map/MapPropertiesDialog.java 2008-11-12 23:24:29 UTC (rev 5736) +++ trunk/daimonin/src/daieditor/gui/map/MapPropertiesDialog.java 2008-11-12 23:26:43 UTC (rev 5737) @@ -28,7 +28,6 @@ import java.awt.GridBagLayout; import java.awt.GridLayout; import java.awt.Insets; -import java.io.File; import javax.swing.BorderFactory; import javax.swing.BoxLayout; import javax.swing.JButton; @@ -303,7 +302,7 @@ mapSound.setText(map.getBackgroundMusic()); final JPanel mapSoundPanel = new JPanel(new BorderLayout()); mapSoundPanel.add(mapSound); - mapSoundPanel.add(new JFileChooserButton(new File(globalSettings.getMediaDefaultFolder()), mapSound, JFileChooser.FILES_ONLY), BorderLayout.EAST); + mapSoundPanel.add(new JFileChooserButton(globalSettings.getMediaDefaultFolder(), mapSound, JFileChooser.FILES_ONLY), BorderLayout.EAST); mapPanel.add(mapSoundPanel, gbc); mapPanel.add(new JLabel(ACTION_FACTORY.getString("mapWidth")), labelGbc); Modified: trunk/daimonin/src/daieditor/gui/prefs/ResPrefs.java =================================================================== --- trunk/daimonin/src/daieditor/gui/prefs/ResPrefs.java 2008-11-12 23:24:29 UTC (rev 5736) +++ trunk/daimonin/src/daieditor/gui/prefs/ResPrefs.java 2008-11-12 23:26:43 UTC (rev 5737) @@ -112,7 +112,7 @@ archField.setText(globalSettings.getArchDirectory().getPath()); mapField.setText(globalSettings.getMapsDirectory()); scriptField.setText(globalSettings.getScriptDirectory().getPath()); - mediaField.setText(globalSettings.getMediaDefaultFolder()); + mediaField.setText(globalSettings.getMediaDefaultFolder().getPath()); loadArches.setSelected(globalSettings.isArchLoadedFromCollection()); } @@ -130,7 +130,7 @@ archField.getText().equals(globalSettings.getArchDirectory().getPath()) && mapField.getText().equals(globalSettings.getMapsDirectory()) && scriptField.getText().equals(globalSettings.getScriptDirectory().getPath()) - && mediaField.getText().equals(globalSettings.getMediaDefaultFolder()) + && mediaField.getText().equals(globalSettings.getMediaDefaultFolder().getPath()) && loadArches.isSelected() == prefs.getBoolean(GlobalSettings.LOAD_ARCH_COLL, globalSettings.isArchLoadedFromCollection()) ); } @@ -161,7 +161,7 @@ archField = createFileField(resourcePanel, "optionsResArch", globalSettings.getArchDirectory().getPath(), JFileChooser.DIRECTORIES_ONLY); mapField = createFileField(resourcePanel, "optionsResMaps", globalSettings.getMapsDirectory(), JFileChooser.DIRECTORIES_ONLY); scriptField = createFileField(resourcePanel, "optionsResScripts", globalSettings.getScriptDirectory().getPath(), JFileChooser.DIRECTORIES_ONLY); - mediaField = createFileField(resourcePanel, "optionsResMedia", globalSettings.getMediaDefaultFolder(), JFileChooser.DIRECTORIES_ONLY); + mediaField = createFileField(resourcePanel, "optionsResMedia", globalSettings.getMediaDefaultFolder().getPath(), JFileChooser.DIRECTORIES_ONLY); return resourcePanel; } Modified: trunk/src/app/net/sf/gridarta/GlobalSettings.java =================================================================== --- trunk/src/app/net/sf/gridarta/GlobalSettings.java 2008-11-12 23:24:29 UTC (rev 5736) +++ trunk/src/app/net/sf/gridarta/GlobalSettings.java 2008-11-12 23:26:43 UTC (rev 5737) @@ -85,7 +85,7 @@ File getPickmapDir(); @NotNull - String getMediaDefaultFolder(); + File getMediaDefaultFolder(); /** * Returns the configuration directory which is used to load configuration Modified: trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java =================================================================== --- trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java 2008-11-12 23:24:29 UTC (rev 5736) +++ trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java 2008-11-12 23:26:43 UTC (rev 5737) @@ -873,7 +873,7 @@ /** {@inheritDoc} */ @NotNull - public String getMediaDefaultFolder() { + public File getMediaDefaultFolder() { throw new AssertionError(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-11-12 23:36:58
|
Revision: 5739 http://gridarta.svn.sourceforge.net/gridarta/?rev=5739&view=rev Author: akirschbaum Date: 2008-11-12 23:36:53 +0000 (Wed, 12 Nov 2008) Log Message: ----------- Replace String with File. Modified Paths: -------------- trunk/crossfire/src/cfeditor/GlobalSettingsImpl.java trunk/crossfire/src/cfeditor/gui/prefs/ResPrefs.java trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/GlobalSettingsImpl.java trunk/daimonin/src/daieditor/gameobject/ArchetypeSetLoader.java trunk/daimonin/src/daieditor/gui/prefs/ResPrefs.java trunk/src/app/net/sf/gridarta/AbstractMainControl.java trunk/src/app/net/sf/gridarta/GlobalSettings.java trunk/src/app/net/sf/gridarta/GlobalSettingsImpl.java trunk/src/app/net/sf/gridarta/gameobject/scripts/DefaultScriptArchEditor.java trunk/src/app/net/sf/gridarta/gameobject/scripts/ScriptedEventEditor.java trunk/src/app/net/sf/gridarta/io/PathManager.java Modified: trunk/crossfire/src/cfeditor/GlobalSettingsImpl.java =================================================================== --- trunk/crossfire/src/cfeditor/GlobalSettingsImpl.java 2008-11-12 23:29:21 UTC (rev 5738) +++ trunk/crossfire/src/cfeditor/GlobalSettingsImpl.java 2008-11-12 23:36:53 UTC (rev 5739) @@ -81,13 +81,13 @@ /** (Re-)initializes the directories. */ public void initDirs() { - setMapsDirectory(prefs.get(ResourceFileManager.MAP_DIR_KEY, ResourceFileManager.DEFAULT_MAP_DIR)); + setMapsDirectory(new File(prefs.get(ResourceFileManager.MAP_DIR_KEY, ResourceFileManager.DEFAULT_MAP_DIR))); setArchDirectory(new File(prefs.get(ResourceFileManager.ARCH_DIR_KEY, ResourceFileManager.DEFAULT_ARCH_DIR))); setScriptDirectory(new File(prefs.get(ResourceFileManager.SCRIPT_DIR_KEY, ResourceFileManager.DEFAULT_SCRIPT_DIR))); // set map dir - if (getMapsDirectory().length() > 0) { - setMapDir(new File(getMapsDirectory())); + if (getMapsDirectory().getPath().length() > 0) { + setMapDir(getMapsDirectory()); } else { // if map dir not set, default to current dir if (!getCurrentDirectory().exists()) { Modified: trunk/crossfire/src/cfeditor/gui/prefs/ResPrefs.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/prefs/ResPrefs.java 2008-11-12 23:29:21 UTC (rev 5738) +++ trunk/crossfire/src/cfeditor/gui/prefs/ResPrefs.java 2008-11-12 23:36:53 UTC (rev 5739) @@ -119,7 +119,7 @@ /** {@inheritDoc} */ public void revert() { archField.setText(globalSettings.getArchDirectory().getPath()); - mapField.setText(globalSettings.getMapsDirectory()); + mapField.setText(globalSettings.getMapsDirectory().getPath()); scriptField.setText(globalSettings.getScriptDirectory().getPath()); loadArches.setSelected(globalSettings.isArchLoadedFromCollection()); imageSetBox.setSelectedIndex(linearSearch(imageSets, getCurrentImageSet())); @@ -139,8 +139,8 @@ final String selectedimageSet = (String) imageSetBox.getSelectedItem(); final String imageSet = selectedimageSet == null ? "disabled" : selectedimageSet; return !( - archField.getText().equals(globalSettings.getArchDirectory()) - && mapField.getText().equals(globalSettings.getMapsDirectory()) + archField.getText().equals(globalSettings.getArchDirectory().getPath()) + && mapField.getText().equals(globalSettings.getMapsDirectory().getPath()) && scriptField.getText().equals(globalSettings.getScriptDirectory().getPath()) && loadArches.isSelected() == prefs.getBoolean(GlobalSettings.LOAD_ARCH_COLL, globalSettings.isArchLoadedFromCollection()) && imageSet.equals(getCurrentImageSet()) @@ -171,7 +171,7 @@ final Box resourcePanel = Box.createVerticalBox(); resourcePanel.setBorder(createTitledBorder("optionsResPaths")); archField = createFileField(resourcePanel, "optionsResArch", globalSettings.getArchDirectory().getPath(), JFileChooser.DIRECTORIES_ONLY); - mapField = createFileField(resourcePanel, "optionsResMaps", globalSettings.getMapsDirectory(), JFileChooser.DIRECTORIES_ONLY); + mapField = createFileField(resourcePanel, "optionsResMaps", globalSettings.getMapsDirectory().getPath(), JFileChooser.DIRECTORIES_ONLY); scriptField = createFileField(resourcePanel, "optionsResScripts", globalSettings.getScriptDirectory().getPath(), JFileChooser.DIRECTORIES_ONLY); return resourcePanel; } Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-11-12 23:29:21 UTC (rev 5738) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-11-12 23:36:53 UTC (rev 5739) @@ -317,7 +317,7 @@ protected CFTreasureListTree<GameObject, MapArchObject, Archetype> createTreasureListTree(@NotNull final DefaultErrorView errorView, @NotNull final GlobalSettings globalSettings, @NotNull final net.sf.gridarta.gameobject.ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final Map<String, TreasureTreeNode> specialTreasureLists) { return new CFTreasureListTree<GameObject, MapArchObject, Archetype>(errorView, getMainView(), archetypeSet, specialTreasureLists, new TreasureLocation(globalSettings.getCollectedDirectory(), IGUIConstants.TREASURES_FILE), - new TreasureLocation(new File(globalSettings.getMapsDirectory()), null) + new TreasureLocation(globalSettings.getMapsDirectory(), null) ); } Modified: trunk/daimonin/src/daieditor/GlobalSettingsImpl.java =================================================================== --- trunk/daimonin/src/daieditor/GlobalSettingsImpl.java 2008-11-12 23:29:21 UTC (rev 5738) +++ trunk/daimonin/src/daieditor/GlobalSettingsImpl.java 2008-11-12 23:36:53 UTC (rev 5739) @@ -65,11 +65,11 @@ /** (Re-)initializes the directories. */ public void initDirs() { - setMapsDirectory(prefs.get(ResourceFileManager.MAP_DIR_KEY, ResourceFileManager.DEFAULT_MAP_DIR)); + setMapsDirectory(new File(prefs.get(ResourceFileManager.MAP_DIR_KEY, ResourceFileManager.DEFAULT_MAP_DIR))); setArchDirectory(new File(prefs.get(ResourceFileManager.ARCH_DIR_KEY, ResourceFileManager.DEFAULT_ARCH_DIR))); setScriptDirectory(new File(prefs.get(ResourceFileManager.SCRIPT_DIR_KEY, ResourceFileManager.DEFAULT_SCRIPT_DIR))); mediaDir = new File(prefs.get(ResourceFileManager.MEDIA_DIR_KEY, ResourceFileManager.DEFAULT_MEDIA_DIR)); - setMapDir(new File(getMapsDirectory())); + setMapDir(getMapsDirectory()); finishInitDirs(); } Modified: trunk/daimonin/src/daieditor/gameobject/ArchetypeSetLoader.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/ArchetypeSetLoader.java 2008-11-12 23:29:21 UTC (rev 5738) +++ trunk/daimonin/src/daieditor/gameobject/ArchetypeSetLoader.java 2008-11-12 23:36:53 UTC (rev 5739) @@ -173,7 +173,7 @@ final File artifactsFile = new File(collectedDirectory, IGUIConstants.ARTIFACTS_FILE); loadArchesFromArtifacts(new ErrorViewCollector(errorView, artifactsFile.getPath()), archetypeParser, artifactsFile, "Artifacts", "artifacts", invObjects); - final File mapsDirectory = new File(globalSettings.getMapsDirectory()); + final File mapsDirectory = globalSettings.getMapsDirectory(); loadArchesFromArtifacts(new ErrorViewCollector(errorView, mapsDirectory.getPath()), archetypeParser, mapsDirectory, "Artifacts", "maps", invObjects); gameObjectParser.collectTempList(parent, archetypeSet, editTypes, invObjects, dir, true); Modified: trunk/daimonin/src/daieditor/gui/prefs/ResPrefs.java =================================================================== --- trunk/daimonin/src/daieditor/gui/prefs/ResPrefs.java 2008-11-12 23:29:21 UTC (rev 5738) +++ trunk/daimonin/src/daieditor/gui/prefs/ResPrefs.java 2008-11-12 23:36:53 UTC (rev 5739) @@ -110,7 +110,7 @@ /** {@inheritDoc} */ public void revert() { archField.setText(globalSettings.getArchDirectory().getPath()); - mapField.setText(globalSettings.getMapsDirectory()); + mapField.setText(globalSettings.getMapsDirectory().getPath()); scriptField.setText(globalSettings.getScriptDirectory().getPath()); mediaField.setText(globalSettings.getMediaDefaultFolder().getPath()); loadArches.setSelected(globalSettings.isArchLoadedFromCollection()); @@ -128,7 +128,7 @@ public boolean isChanged() { return !( archField.getText().equals(globalSettings.getArchDirectory().getPath()) - && mapField.getText().equals(globalSettings.getMapsDirectory()) + && mapField.getText().equals(globalSettings.getMapsDirectory().getPath()) && scriptField.getText().equals(globalSettings.getScriptDirectory().getPath()) && mediaField.getText().equals(globalSettings.getMediaDefaultFolder().getPath()) && loadArches.isSelected() == prefs.getBoolean(GlobalSettings.LOAD_ARCH_COLL, globalSettings.isArchLoadedFromCollection()) @@ -159,7 +159,7 @@ final Box resourcePanel = Box.createVerticalBox(); resourcePanel.setBorder(createTitledBorder("optionsResPaths")); archField = createFileField(resourcePanel, "optionsResArch", globalSettings.getArchDirectory().getPath(), JFileChooser.DIRECTORIES_ONLY); - mapField = createFileField(resourcePanel, "optionsResMaps", globalSettings.getMapsDirectory(), JFileChooser.DIRECTORIES_ONLY); + mapField = createFileField(resourcePanel, "optionsResMaps", globalSettings.getMapsDirectory().getPath(), JFileChooser.DIRECTORIES_ONLY); scriptField = createFileField(resourcePanel, "optionsResScripts", globalSettings.getScriptDirectory().getPath(), JFileChooser.DIRECTORIES_ONLY); mediaField = createFileField(resourcePanel, "optionsResMedia", globalSettings.getMediaDefaultFolder().getPath(), JFileChooser.DIRECTORIES_ONLY); return resourcePanel; Modified: trunk/src/app/net/sf/gridarta/AbstractMainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2008-11-12 23:29:21 UTC (rev 5738) +++ trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2008-11-12 23:36:53 UTC (rev 5739) @@ -376,7 +376,7 @@ new UndoControl<G, A, R, V>(mapManager); final UpdaterManager updaterManager = new UpdaterManager(key, this, mapManager, mainView, gridartaJarFilename); updaterManager.startup(); - ScriptEditControlInstance.init(scriptFileFilter, scriptExtension, mainView, new File(globalSettings.getMapsDirectory()), Preferences.userNodeForPackage(MainControl.class)); + ScriptEditControlInstance.init(scriptFileFilter, scriptExtension, mainView, globalSettings.getMapsDirectory(), Preferences.userNodeForPackage(MainControl.class)); final XmlHelper xmlHelper; try { xmlHelper = new XmlHelper(); Modified: trunk/src/app/net/sf/gridarta/GlobalSettings.java =================================================================== --- trunk/src/app/net/sf/gridarta/GlobalSettings.java 2008-11-12 23:29:21 UTC (rev 5738) +++ trunk/src/app/net/sf/gridarta/GlobalSettings.java 2008-11-12 23:36:53 UTC (rev 5739) @@ -38,7 +38,7 @@ * Get the default folder of maps. * @return default folder of maps. */ - String getMapsDirectory(); + File getMapsDirectory(); /** * Get the map directory. Modified: trunk/src/app/net/sf/gridarta/GlobalSettingsImpl.java =================================================================== --- trunk/src/app/net/sf/gridarta/GlobalSettingsImpl.java 2008-11-12 23:29:21 UTC (rev 5738) +++ trunk/src/app/net/sf/gridarta/GlobalSettingsImpl.java 2008-11-12 23:36:53 UTC (rev 5739) @@ -36,7 +36,7 @@ private File archDirectory; - private String mapsDirectory; + private File mapsDirectory; @NotNull private File mapDir; @@ -70,11 +70,11 @@ } /** {@inheritDoc} */ - public String getMapsDirectory() { + public File getMapsDirectory() { return mapsDirectory; } - protected void setMapsDirectory(final String mapsDirectory) { + protected void setMapsDirectory(final File mapsDirectory) { this.mapsDirectory = mapsDirectory; } Modified: trunk/src/app/net/sf/gridarta/gameobject/scripts/DefaultScriptArchEditor.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/scripts/DefaultScriptArchEditor.java 2008-11-12 23:29:21 UTC (rev 5738) +++ trunk/src/app/net/sf/gridarta/gameobject/scripts/DefaultScriptArchEditor.java 2008-11-12 23:36:53 UTC (rev 5739) @@ -180,7 +180,7 @@ if (fileChooser.showOpenDialog(newScriptFrame) == JFileChooser.APPROVE_OPTION) { // user has selected a file final File f = fileChooser.getSelectedFile(); - inputScriptPath.setText(ScriptUtils.localizeEventPath(mapManager.getLocalMapDir(), f, new File(globalSettings.getMapsDirectory()))); + inputScriptPath.setText(ScriptUtils.localizeEventPath(mapManager.getLocalMapDir(), f, globalSettings.getMapsDirectory())); } } }); @@ -259,7 +259,7 @@ String absScriptPath; if (scriptPath.startsWith("/")) { // script path is absolute - final File mapDir = new File(globalSettings.getMapsDirectory()); // global map directory + final File mapDir = globalSettings.getMapsDirectory(); // global map directory if (!mapDir.exists()) { // if map dir doesn't exist, this is not going to work frame.setVisible(false); Modified: trunk/src/app/net/sf/gridarta/gameobject/scripts/ScriptedEventEditor.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/scripts/ScriptedEventEditor.java 2008-11-12 23:29:21 UTC (rev 5738) +++ trunk/src/app/net/sf/gridarta/gameobject/scripts/ScriptedEventEditor.java 2008-11-12 23:36:53 UTC (rev 5739) @@ -80,29 +80,21 @@ */ public static void openScript(@NotNull final MapManager<?, ?, ?, ?> mapManager, final String scriptPath, @NotNull final Component parent) { // trying to get the absolute path to scriptfile: - final StringBuilder tmpPath = new StringBuilder(); + final File scriptFile; if (scriptPath.startsWith("/")) { // filepath is absolue (to map base directory): - tmpPath.append(globalSettings.getMapsDirectory()); - tmpPath.append(scriptPath); + scriptFile = new File(globalSettings.getMapsDirectory(), scriptPath.substring(1)); } else { // file path is relative to map dir - final String mapPath = mapManager.getLocalMapDir().getAbsolutePath(); - tmpPath.append(mapPath); - if (!mapPath.endsWith("/")) { - tmpPath.append('/'); - } - tmpPath.append(scriptPath); + scriptFile = new File(mapManager.getLocalMapDir(), scriptPath); } - final String path = tmpPath.toString().replace('\\', '/'); // now see if that file really exists: - final File scriptFile = new File(path); if (scriptFile.exists() && scriptFile.isFile()) { ScriptEditControlInstance.getInstance().openScriptFile(scriptFile.getAbsolutePath()); } else { // file does not exist! - ACTION_FACTORY.showMessageDialog(parent, "openScriptNotFound", path); + ACTION_FACTORY.showMessageDialog(parent, "openScriptNotFound", scriptFile); } } Modified: trunk/src/app/net/sf/gridarta/io/PathManager.java =================================================================== --- trunk/src/app/net/sf/gridarta/io/PathManager.java 2008-11-12 23:29:21 UTC (rev 5738) +++ trunk/src/app/net/sf/gridarta/io/PathManager.java 2008-11-12 23:36:53 UTC (rev 5739) @@ -82,7 +82,7 @@ * @return fixed path */ public static String getMapPath(final String path) { - final String mapDirName = globalSettings.getMapsDirectory(); + final String mapDirName = globalSettings.getMapsDirectory().getPath(); String mapPath = path.replace('\\', '/'); if (mapPath.startsWith(mapDirName)) { mapPath = mapPath.substring(mapDirName.length()); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-11-12 23:40:50
|
Revision: 5740 http://gridarta.svn.sourceforge.net/gridarta/?rev=5740&view=rev Author: akirschbaum Date: 2008-11-12 23:40:45 +0000 (Wed, 12 Nov 2008) Log Message: ----------- Replace String with File. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gameobject/ArchetypeSetLoader.java trunk/daimonin/src/daieditor/gameobject/ArchetypeSetLoader.java trunk/src/app/net/sf/gridarta/AbstractMainControl.java trunk/src/app/net/sf/gridarta/gameobject/AbstractArchetypeSetLoader.java trunk/src/app/net/sf/gridarta/gameobject/face/DefaultFaceObjects.java trunk/src/app/net/sf/gridarta/gui/errorview/ErrorViewCollector.java trunk/src/app/net/sf/gridarta/spells/XMLSpellLoader.java trunk/src/app/net/sf/gridarta/treasurelist/TreasureLoader.java Modified: trunk/crossfire/src/cfeditor/gameobject/ArchetypeSetLoader.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/ArchetypeSetLoader.java 2008-11-12 23:36:53 UTC (rev 5739) +++ trunk/crossfire/src/cfeditor/gameobject/ArchetypeSetLoader.java 2008-11-12 23:40:45 UTC (rev 5740) @@ -152,7 +152,7 @@ FaceObjectProviders.setNormal(new ArchFaceProvider()); archetypeSet.setLoadedFromArchive(false); // don't load from the collected files dir = globalSettings.getArchDirectory(); - loadArchetypesFromFiles(new ErrorViewCollector(errorView, dir.getPath()), archetypeParser, null, dir, 0, "default", "default", false, invObjects, parent); // load arches & images from individual files + loadArchetypesFromFiles(new ErrorViewCollector(errorView, dir), archetypeParser, null, dir, 0, "default", "default", false, invObjects, parent); // load arches & images from individual files } archetypeSet.reportErrors(parent); Modified: trunk/daimonin/src/daieditor/gameobject/ArchetypeSetLoader.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/ArchetypeSetLoader.java 2008-11-12 23:36:53 UTC (rev 5739) +++ trunk/daimonin/src/daieditor/gameobject/ArchetypeSetLoader.java 2008-11-12 23:40:45 UTC (rev 5740) @@ -164,17 +164,17 @@ animFiles = new ArrayList<Pair<String, File>>(); dir = globalSettings.getArchDirectory(); addPNGFace(new File(dir, "dev/editor/bug.101.png").getAbsolutePath(), "/dev/editor", "bug.101.png", parent); - final ErrorViewCollector archDirectoryErrorViewCollector = new ErrorViewCollector(errorView, dir.getPath()); + final ErrorViewCollector archDirectoryErrorViewCollector = new ErrorViewCollector(errorView, dir); loadArchetypesFromFiles(archDirectoryErrorViewCollector, archetypeParser, null, dir, 0, "default", "default", false, invObjects, parent); // load arches & images from individual files loadAnimsFromFiles(archDirectoryErrorViewCollector); } archetypeSet.reportErrors(parent); final File artifactsFile = new File(collectedDirectory, IGUIConstants.ARTIFACTS_FILE); - loadArchesFromArtifacts(new ErrorViewCollector(errorView, artifactsFile.getPath()), archetypeParser, artifactsFile, "Artifacts", "artifacts", invObjects); + loadArchesFromArtifacts(new ErrorViewCollector(errorView, artifactsFile), archetypeParser, artifactsFile, "Artifacts", "artifacts", invObjects); final File mapsDirectory = globalSettings.getMapsDirectory(); - loadArchesFromArtifacts(new ErrorViewCollector(errorView, mapsDirectory.getPath()), archetypeParser, mapsDirectory, "Artifacts", "maps", invObjects); + loadArchesFromArtifacts(new ErrorViewCollector(errorView, mapsDirectory), archetypeParser, mapsDirectory, "Artifacts", "maps", invObjects); gameObjectParser.collectTempList(parent, archetypeSet, editTypes, invObjects, dir, true); archetypeSet.connectFaces(); // attach faces to arches Modified: trunk/src/app/net/sf/gridarta/AbstractMainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2008-11-12 23:36:53 UTC (rev 5739) +++ trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2008-11-12 23:40:45 UTC (rev 5740) @@ -385,7 +385,7 @@ throw new MissingResourceException("Cannot create XML parser: " + ex.getMessage(), null, null); } final DefaultErrorView errorView = new DefaultErrorView(mainView); - final ErrorViewCollector gameObjectMatchersErrorViewCollector = new ErrorViewCollector(errorView, "GameObjectMatchers.xml"); + final ErrorViewCollector gameObjectMatchersErrorViewCollector = new ErrorViewCollector(errorView, new File(globalSettings.getConfigurationDirectory(), "GameObjectMatchers.xml")); final GameObjectMatchers gameObjectMatchers = new GameObjectMatchers(xmlHelper.getDocumentBuilder(), xmlHelper.getXPath()); try { final String filename = IOUtils.getResourceURLAsString(globalSettings.getConfigurationDirectory(), "GameObjectMatchers.xml"); @@ -425,7 +425,7 @@ final ScriptArchUtils scriptArchUtils = newScriptArchUtils(); final MapViewSettings mapViewSettings = new MapViewSettings(); final MapActions mapActions = init1(mapViewSettings, mapArchObjectParserFactory, mapArchObjectFactory, globalSettings, mapManager, mapViewManager, selectedSquareView, exitMatcher); - final ErrorViewCollector treasureListsErrorViewCollector = new ErrorViewCollector(errorView, "TreasureLists.xml"); + final ErrorViewCollector treasureListsErrorViewCollector = new ErrorViewCollector(errorView, new File(globalSettings.getConfigurationDirectory(), "TreasureLists.xml")); Map<String, TreasureTreeNode> specialTreasureLists; try { final Document specialTreasureListsDocument = xmlHelper.getDocumentBuilder().parse(IOUtils.getResourceURLAsString(globalSettings.getConfigurationDirectory(), "TreasureLists.xml")); @@ -441,7 +441,7 @@ final ArchetypeAttributeParser<G, A, R> archetypeAttributeParser = new ArchetypeAttributeParser<G, A, R>(typeNoEventConnector, includeFaceText, globalSettings, mapFileFilter, scriptFileFilter, faceObjects, animationObjects, numberSpells, gameObjectSpells, undefinedSpellIndex, archetypeTypeSet, treasureListTree); final ArchetypeTypeParser<G, A, R> archetypeTypeParser = new ArchetypeTypeParser<G, A, R>(archetypeAttributeParser); final ArchetypeTypeSetParser<G, A, R> archetypeTypeSetParser = new ArchetypeTypeSetParser<G, A, R>(xmlHelper.getDocumentBuilder(), xmlHelper.getXPath(), archetypeTypeSet, archetypeTypeParser); - final ErrorViewCollector typesErrorViewCollector = new ErrorViewCollector(errorView, CommonConstants.TYPEDEF_FILE); + final ErrorViewCollector typesErrorViewCollector = new ErrorViewCollector(errorView, new File(globalSettings.getConfigurationDirectory(), CommonConstants.TYPEDEF_FILE)); try { final String filename = IOUtils.getResourceURLAsString(globalSettings.getConfigurationDirectory(), CommonConstants.TYPEDEF_FILE); archetypeTypeSetParser.loadTypesFromXML(typesErrorViewCollector, filename); Modified: trunk/src/app/net/sf/gridarta/gameobject/AbstractArchetypeSetLoader.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/AbstractArchetypeSetLoader.java 2008-11-12 23:36:53 UTC (rev 5739) +++ trunk/src/app/net/sf/gridarta/gameobject/AbstractArchetypeSetLoader.java 2008-11-12 23:40:45 UTC (rev 5740) @@ -83,7 +83,7 @@ */ @SuppressWarnings({"InstanceMethodNamingConvention"}) protected void loadAnimationsFromCollect(@NotNull final DefaultErrorView errorView) { - final ErrorViewCollector errorViewCollector = new ErrorViewCollector(errorView, "animations"); + final ErrorViewCollector errorViewCollector = new ErrorViewCollector(errorView, new File(collectedDirectory, "animations")); try { final Reader in = IOUtils.createReader(collectedDirectory, "animations"); try { Modified: trunk/src/app/net/sf/gridarta/gameobject/face/DefaultFaceObjects.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/face/DefaultFaceObjects.java 2008-11-12 23:36:53 UTC (rev 5739) +++ trunk/src/app/net/sf/gridarta/gameobject/face/DefaultFaceObjects.java 2008-11-12 23:40:45 UTC (rev 5740) @@ -268,7 +268,7 @@ errorView.addError(new File(collectedDirectory, faceFile).getPath(), "can't load file: " + ex.getMessage()); return; } - final ErrorViewCollector faceFileErrorViewCollector = new ErrorViewCollector(errorView, tmpFaceFile.getPath()); + final ErrorViewCollector faceFileErrorViewCollector = new ErrorViewCollector(errorView, tmpFaceFile); try { FaceObjectProviders.setNormal(new CollectedFaceProvider(tmpFaceFile)); final InputStream inputStream = new FileInputStream(tmpFaceFile); @@ -288,7 +288,7 @@ final byte[] data = bufOut.toByteArray(); // Note: treeIn might stay null, this is optional data. - final ErrorViewCollector treeFileErrorViewCollector = new ErrorViewCollector(errorView, new File(collectedDirectory, treeFile).getPath()); + final ErrorViewCollector treeFileErrorViewCollector = new ErrorViewCollector(errorView, new File(collectedDirectory, treeFile)); BufferedReader treeIn = null; try { //cher: it is safely closed but optional. InspectionGadgets doesn't detect where it's closed. Modified: trunk/src/app/net/sf/gridarta/gui/errorview/ErrorViewCollector.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/errorview/ErrorViewCollector.java 2008-11-12 23:36:53 UTC (rev 5739) +++ trunk/src/app/net/sf/gridarta/gui/errorview/ErrorViewCollector.java 2008-11-12 23:40:45 UTC (rev 5740) @@ -19,6 +19,7 @@ package net.sf.gridarta.gui.errorview; +import java.io.File; import org.jetbrains.annotations.NotNull; /** @@ -45,9 +46,9 @@ * @param errorView the error view to add to * @param category the category name for error messages */ - public ErrorViewCollector(@NotNull final DefaultErrorView errorView, @NotNull final String category) { + public ErrorViewCollector(@NotNull final DefaultErrorView errorView, @NotNull final File category) { this.errorView = errorView; - this.category = category; + this.category = category.getPath(); } /** Modified: trunk/src/app/net/sf/gridarta/spells/XMLSpellLoader.java =================================================================== --- trunk/src/app/net/sf/gridarta/spells/XMLSpellLoader.java 2008-11-12 23:36:53 UTC (rev 5739) +++ trunk/src/app/net/sf/gridarta/spells/XMLSpellLoader.java 2008-11-12 23:40:45 UTC (rev 5740) @@ -56,7 +56,7 @@ * @param spells The <code>Spells</code> instance to add the spells to. */ public static void load(@NotNull final DefaultErrorView errorView, @NotNull final File baseDir, @NotNull final String filename, @NotNull final DocumentBuilder documentBuilder, @NotNull final Spells<NumberSpell> spells) { - final ErrorViewCollector errorViewCollector = new ErrorViewCollector(errorView, baseDir.getPath() + "/" + filename); + final ErrorViewCollector errorViewCollector = new ErrorViewCollector(errorView, new File(baseDir, filename)); try { // parse xml document final Document doc = documentBuilder.parse(IOUtils.getResourceURLAsString(baseDir, filename)); Modified: trunk/src/app/net/sf/gridarta/treasurelist/TreasureLoader.java =================================================================== --- trunk/src/app/net/sf/gridarta/treasurelist/TreasureLoader.java 2008-11-12 23:36:53 UTC (rev 5739) +++ trunk/src/app/net/sf/gridarta/treasurelist/TreasureLoader.java 2008-11-12 23:40:45 UTC (rev 5740) @@ -89,7 +89,7 @@ for (final TreasureLocation treasureLocation : treasures) { final File dname = treasureLocation.getDname(); final String fname = treasureLocation.getFname(); - final ErrorViewCollector errorViewCollector = new ErrorViewCollector(errorView, (fname == null ? dname : new File(dname, fname)).getPath()); + final ErrorViewCollector errorViewCollector = new ErrorViewCollector(errorView, fname == null ? dname : new File(dname, fname)); loadTreasureList(errorViewCollector, dname, fname, tmpList, needLink); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |