From: <aki...@us...> - 2010-05-24 19:23:25
|
Revision: 7988 http://gridarta.svn.sourceforge.net/gridarta/?rev=7988&view=rev Author: akirschbaum Date: 2010-05-24 19:23:19 +0000 (Mon, 24 May 2010) Log Message: ----------- Cleanup parser for/document <ignorelists> elements within types.xml. Modified Paths: -------------- trunk/resource/system/dtd/types.dtd trunk/src/app/net/sf/gridarta/model/archetypetype/ArchetypeTypeSetParser.java Modified: trunk/resource/system/dtd/types.dtd =================================================================== --- trunk/resource/system/dtd/types.dtd 2010-05-24 19:08:48 UTC (rev 7987) +++ trunk/resource/system/dtd/types.dtd 2010-05-24 19:23:19 UTC (rev 7988) @@ -72,7 +72,7 @@ encoding CDATA #IMPLIED > -<!ELEMENT ignore_list (attribute* | EMPTY)> +<!ELEMENT ignore_list (attribute*)> <!ATTLIST ignore_list name CDATA #REQUIRED > Modified: trunk/src/app/net/sf/gridarta/model/archetypetype/ArchetypeTypeSetParser.java =================================================================== --- trunk/src/app/net/sf/gridarta/model/archetypetype/ArchetypeTypeSetParser.java 2010-05-24 19:08:48 UTC (rev 7987) +++ trunk/src/app/net/sf/gridarta/model/archetypetype/ArchetypeTypeSetParser.java 2010-05-24 19:23:19 UTC (rev 7988) @@ -33,6 +33,7 @@ import net.sf.gridarta.model.errorview.ErrorViewCollector; import net.sf.gridarta.model.gameobject.GameObject; import net.sf.gridarta.model.map.maparchobject.MapArchObject; +import net.sf.gridarta.utils.SyntaxErrorException; import net.sf.japi.xml.NodeListIterator; import org.apache.log4j.Category; import org.apache.log4j.Logger; @@ -324,25 +325,29 @@ final Iterator<Element> it = new NodeListIterator<Element>(xpath, element, "ignore_list|ignorelists/ignore_list"); while (it.hasNext()) { final Element elem = it.next(); - if (elem.getAttribute("name") == null) { - errorViewCollector.addWarning(ErrorViewCategory.TYPES_ENTRY_INVALID, "cannot load ignore_list element without 'name'."); - } else { - final String name = elem.getAttribute("name").trim(); - final List<String> content = new ArrayList<String>(); - final Iterator<Element> it2 = new NodeListIterator<Element>(elem, ArchetypeTypeParser.XML_ATTRIBUTE); - while (it2.hasNext()) { - final Element el2 = it2.next(); - final Attr a = el2.getAttributeNode(ArchetypeAttributeParser.XML_KEY_ARCH); - if (a != null) { - content.add(a.getValue().trim()); - } else { - errorViewCollector.addWarning(ErrorViewCategory.TYPES_ENTRY_INVALID, name + ": " + ArchetypeTypeParser.XML_ATTRIBUTE + " missing '" + ArchetypeAttributeParser.XML_KEY_ARCH + "'."); - } + final String name = elem.getAttribute("name"); + if (ignoreListTable.containsKey(name)) { + errorViewCollector.addWarning(ErrorViewCategory.TYPES_ENTRY_INVALID, name + ": duplicate name"); + } + + final List<String> content = new ArrayList<String>(); + final Iterator<Element> it2 = new NodeListIterator<Element>(elem, "attribute"); + while (it2.hasNext()) { + final Element el2 = it2.next(); + final Attr a = el2.getAttributeNode("arch"); + if (a != null) { + content.add(a.getValue()); + } else { + errorViewCollector.addWarning(ErrorViewCategory.TYPES_ENTRY_INVALID, name + ": attribute missing 'arch'."); } - if (!content.isEmpty()) { - ignoreListTable.put(name, content); + + try { + rejectAttributes(el2, "type", "arch_begin", "arch_end", "editor", "value", "min", "max", "check_min", "check_max", "length", "true", "false", "marker"); + } catch (final SyntaxErrorException ex) { + errorViewCollector.addWarning(ErrorViewCategory.TYPES_ENTRY_INVALID, name + ": " + ex.getMessage() + "."); } } + ignoreListTable.put(name, content); } return ignoreListTable; } @@ -380,4 +385,18 @@ } } + /** + * Makes sure an {@link Element} does not define attributes. + * @param element the element to check + * @param attributes the attributes to check for + * @throws SyntaxErrorException if an attribute was found + */ + private static void rejectAttributes(@NotNull final Element element, @NotNull final String... attributes) throws SyntaxErrorException { + for (final String attribute : attributes) { + if (element.hasAttribute(attribute)) { + throw new SyntaxErrorException("unexpected attribute '" + attribute + "'"); + } + } + } + } // class ArchetypeTypeSetParser This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-05-24 19:56:41
|
Revision: 7989 http://gridarta.svn.sourceforge.net/gridarta/?rev=7989&view=rev Author: akirschbaum Date: 2010-05-24 19:56:35 +0000 (Mon, 24 May 2010) Log Message: ----------- Cleanup parser for/document <ignorelists> elements within types.xml. Modified Paths: -------------- trunk/resource/system/dtd/types.dtd trunk/src/app/net/sf/gridarta/model/archetypetype/ArchetypeTypeParser.java trunk/src/app/net/sf/gridarta/model/archetypetype/ArchetypeTypeSetParser.java Added Paths: ----------- trunk/src/app/net/sf/gridarta/model/archetypetype/IgnorelistsDefinition.java Modified: trunk/resource/system/dtd/types.dtd =================================================================== --- trunk/resource/system/dtd/types.dtd 2010-05-24 19:23:19 UTC (rev 7988) +++ trunk/resource/system/dtd/types.dtd 2010-05-24 19:56:35 UTC (rev 7989) @@ -72,6 +72,9 @@ encoding CDATA #IMPLIED > +<!-- name: name of the ignore list; must be unique --> +<!-- attribute: 'arch' attribute specifies the section name to be ignored; + other attributes are not allowed --> <!ELEMENT ignore_list (attribute*)> <!ATTLIST ignore_list name CDATA #REQUIRED @@ -106,6 +109,7 @@ name CDATA #REQUIRED > +<!-- arch: section name to be ignored (within <ignore_list>) --> <!-- min/max: absolute allowed range; editor rejects --> <!-- check_min/check_max: recommended range; editor warns --> <!ELEMENT attribute (#PCDATA)> Modified: trunk/src/app/net/sf/gridarta/model/archetypetype/ArchetypeTypeParser.java =================================================================== --- trunk/src/app/net/sf/gridarta/model/archetypetype/ArchetypeTypeParser.java 2010-05-24 19:23:19 UTC (rev 7988) +++ trunk/src/app/net/sf/gridarta/model/archetypetype/ArchetypeTypeParser.java 2010-05-24 19:56:35 UTC (rev 7989) @@ -23,7 +23,6 @@ import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; -import java.util.List; import java.util.Map; import net.sf.gridarta.model.archetype.Archetype; import net.sf.gridarta.model.errorview.ErrorViewCategory; @@ -115,17 +114,17 @@ * @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 + * @param ignorelistsDefinition the ignore_lists contents * @return the archetype type or <code>null</code> * @todo I'm sucking slow, improve me */ @NotNull - public ArchetypeType<G, A, R> load(@NotNull final ErrorViewCollector errorViewCollector, @Nullable final ArchetypeType<G, A, R> parent, @NotNull final Element root, @NotNull final ArchetypeTypeSet<G, A, R> archetypeTypeSet, @NotNull final Map<String, List<String>> ignoreListTable) { + public ArchetypeType<G, A, R> load(@NotNull final ErrorViewCollector errorViewCollector, @Nullable final ArchetypeType<G, A, R> parent, @NotNull final Element root, @NotNull final ArchetypeTypeSet<G, A, R> archetypeTypeSet, @NotNull final IgnorelistsDefinition ignorelistsDefinition) { final boolean isDefaultType = root.getNodeName().equals("default_type"); final String typeName = parseTypeName(root, isDefaultType); final Map<String, String> ignoreTable = new HashMap<String, String>(); final int typeNo = parseTypeNo(root, isDefaultType, typeName, errorViewCollector); - final ArchetypeAttributesDefinition typeAttributes = parseTypeAttributes(root, isDefaultType, typeName, typeNo, errorViewCollector, ignoreTable, ignoreListTable); + final ArchetypeAttributesDefinition typeAttributes = parseTypeAttributes(root, isDefaultType, typeName, typeNo, errorViewCollector, ignoreTable, ignorelistsDefinition); final String importName = parseImportName(root, typeName, errorViewCollector); final ArchetypeAttributes<G, A, R> attributes = new ArchetypeAttributes<G, A, R>(); final SectionNames sectionNames = new SectionNames(); @@ -245,11 +244,11 @@ * @param typeNo the type number for error messages * @param errorViewCollector the error view collector for error messages * @param ignoreTable returns the "ignore" attributes - * @param ignoreListTable the defined ignore lists + * @param ignorelistsDefinition the defined ignore lists * @return the type attributes */ @NotNull - private static ArchetypeAttributesDefinition parseTypeAttributes(@NotNull final Element root, final boolean isDefaultType, @NotNull final String typeName, final int typeNo, @NotNull final ErrorViewCollector errorViewCollector, @NotNull final Map<String, String> ignoreTable, @NotNull final Map<String, List<String>> ignoreListTable) { + private static ArchetypeAttributesDefinition parseTypeAttributes(@NotNull final Element root, final boolean isDefaultType, @NotNull final String typeName, final int typeNo, @NotNull final ErrorViewCollector errorViewCollector, @NotNull final Map<String, String> ignoreTable, @NotNull final IgnorelistsDefinition ignorelistsDefinition) { if (isDefaultType) { // special case: default type (this one contains the default attributes) return new ArchetypeAttributesDefinition(); @@ -264,7 +263,7 @@ parseAttributeAttributes(typeName, errorViewCollector, ignoreTable, ignoreElement); // load attributes from ignore lists - parseIgnoreListAttribute(typeName, errorViewCollector, ignoreTable, ignoreListTable, ignoreElement); + parseIgnoreListAttribute(typeName, errorViewCollector, ignoreTable, ignorelistsDefinition, ignoreElement); } return typeAttributes; @@ -322,24 +321,27 @@ * @param typeName the type name for error messages * @param errorViewCollector the error view collector for error messages * @param ignoreTable the ignore table to add to - * @param ignoreListTable the ignore lists to use + * @param ignorelistsDefinition the ignore lists to use * @param ignoreElement the ignore element to parse */ - private static void parseIgnoreListAttribute(@NotNull final String typeName, @NotNull final ErrorViewCollector errorViewCollector, @NotNull final Map<String, String> ignoreTable, final Map<String, List<String>> ignoreListTable, @NotNull final Element ignoreElement) { + private static void parseIgnoreListAttribute(@NotNull final String typeName, @NotNull final ErrorViewCollector errorViewCollector, @NotNull final Map<String, String> ignoreTable, @NotNull final IgnorelistsDefinition ignorelistsDefinition, @NotNull final Element ignoreElement) { final Iterator<Element> it2 = new NodeListIterator<Element>(ignoreElement, "ignore_list"); while (it2.hasNext()) { final Element elem = it2.next(); final Attr a1 = elem.getAttributeNode("name"); if (a1 == null) { errorViewCollector.addWarning(ErrorViewCategory.TYPES_ENTRY_INVALID, XML_IGNORE + ": section of type " + typeName + ": ignore_list missing 'name'."); - } else if (ignoreListTable.containsKey(a1.getValue().trim())) { - // just copy everything from ignore list to this ignore section - final Iterable<String> ignoreList = ignoreListTable.get(a1.getValue().trim()); - for (final String ignItem : ignoreList) { - ignoreTable.put(ignItem, ""); + } else { + final String name = a1.getValue().trim(); + final Iterable<String> ignoreList = ignorelistsDefinition.get(name); + if (ignoreList != null) { + // just copy everything from ignore list to this ignore section + for (final String ignItem : ignoreList) { + ignoreTable.put(ignItem, ""); + } + } else { + errorViewCollector.addWarning(ErrorViewCategory.TYPES_ENTRY_INVALID, XML_IGNORE + ": section of type " + typeName + ": ignore_list with name \"" + a1.getValue() + "\" is undefined."); } - } else { - errorViewCollector.addWarning(ErrorViewCategory.TYPES_ENTRY_INVALID, XML_IGNORE + ": section of type " + typeName + ": ignore_list with name \"" + a1.getValue() + "\" is undefined."); } } } Modified: trunk/src/app/net/sf/gridarta/model/archetypetype/ArchetypeTypeSetParser.java =================================================================== --- trunk/src/app/net/sf/gridarta/model/archetypetype/ArchetypeTypeSetParser.java 2010-05-24 19:23:19 UTC (rev 7988) +++ trunk/src/app/net/sf/gridarta/model/archetypetype/ArchetypeTypeSetParser.java 2010-05-24 19:56:35 UTC (rev 7989) @@ -20,11 +20,7 @@ package net.sf.gridarta.model.archetypetype; import java.io.IOException; -import java.util.ArrayList; -import java.util.HashMap; import java.util.Iterator; -import java.util.List; -import java.util.Map; import javax.xml.parsers.DocumentBuilder; import javax.xml.xpath.XPath; import javax.xml.xpath.XPathExpressionException; @@ -129,9 +125,9 @@ final Element root = document.getDocumentElement(); parseBitmasks(errorViewCollector, root); parseLists(errorViewCollector, root); - final Map<String, List<String>> ignoreListTable = parseIgnoreLists(errorViewCollector, root); - parseDefaultType(errorViewCollector, root, ignoreListTable); - parseTypes(errorViewCollector, root, ignoreListTable); + final IgnorelistsDefinition ignorelistsDefinition = parseIgnoreLists(errorViewCollector, root); + parseDefaultType(errorViewCollector, root, ignorelistsDefinition); + parseTypes(errorViewCollector, root, ignorelistsDefinition); if (log.isInfoEnabled()) { log.info("Loaded " + archetypeTypeSet.getLength() + " types from '" + filename + "\'"); @@ -320,23 +316,26 @@ * @throws XPathExpressionException if an internal error occurs */ @NotNull - private Map<String, List<String>> parseIgnoreLists(@NotNull final ErrorViewCollector errorViewCollector, final Element element) throws XPathExpressionException { - final Map<String, List<String>> ignoreListTable = new HashMap<String, List<String>>(); + private IgnorelistsDefinition parseIgnoreLists(@NotNull final ErrorViewCollector errorViewCollector, final Element element) throws XPathExpressionException { + final IgnorelistsDefinition ignorelistsDefinition = new IgnorelistsDefinition(); final Iterator<Element> it = new NodeListIterator<Element>(xpath, element, "ignore_list|ignorelists/ignore_list"); while (it.hasNext()) { final Element elem = it.next(); final String name = elem.getAttribute("name"); - if (ignoreListTable.containsKey(name)) { + if (ignorelistsDefinition.containsKey(name)) { errorViewCollector.addWarning(ErrorViewCategory.TYPES_ENTRY_INVALID, name + ": duplicate name"); } - final List<String> content = new ArrayList<String>(); final Iterator<Element> it2 = new NodeListIterator<Element>(elem, "attribute"); while (it2.hasNext()) { final Element el2 = it2.next(); final Attr a = el2.getAttributeNode("arch"); if (a != null) { - content.add(a.getValue()); + try { + ignorelistsDefinition.put(name, a.getValue()); + } catch (final IllegalArgumentException ex) { + errorViewCollector.addWarning(ErrorViewCategory.TYPES_ENTRY_INVALID, name + ": " + ex.getMessage() + "."); + } } else { errorViewCollector.addWarning(ErrorViewCategory.TYPES_ENTRY_INVALID, name + ": attribute missing 'arch'."); } @@ -347,25 +346,24 @@ errorViewCollector.addWarning(ErrorViewCategory.TYPES_ENTRY_INVALID, name + ": " + ex.getMessage() + "."); } } - ignoreListTable.put(name, content); } - return ignoreListTable; + return ignorelistsDefinition; } /** * Parses the "default_type" section of a types.xml file. * @param errorViewCollector the error view collector for reporting errors * @param element the element to parse - * @param ignoreListTable the contents of the "ignorelists" section + * @param ignorelistsDefinition the contents of the "ignorelists" section */ - private void parseDefaultType(@NotNull final ErrorViewCollector errorViewCollector, final Element element, @NotNull final Map<String, List<String>> ignoreListTable) { + private void parseDefaultType(@NotNull final ErrorViewCollector errorViewCollector, final Element element, @NotNull final IgnorelistsDefinition ignorelistsDefinition) { final Element el = NodeListIterator.getFirstChild(element, "default_type"); if (el == null) { errorViewCollector.addWarning(ErrorViewCategory.TYPES_ENTRY_INVALID, "default_type element is missing!"); return; } - final ArchetypeType<G, A, R> defaultType = archetypeTypeParser.load(errorViewCollector, null, el, archetypeTypeSet, ignoreListTable); + final ArchetypeType<G, A, R> defaultType = archetypeTypeParser.load(errorViewCollector, null, el, archetypeTypeSet, ignorelistsDefinition); archetypeTypeSet.setDefaultArchetypeType(defaultType); } @@ -373,14 +371,14 @@ * Parses the "type" section of a types.xml file. * @param errorViewCollector the error view collector for reporting errors * @param element the element to parse - * @param ignoreListTable the contents of the "ignorelists" section + * @param ignorelistsDefinition the contents of the "ignorelists" section */ - private void parseTypes(@NotNull final ErrorViewCollector errorViewCollector, final Element element, @NotNull final Map<String, List<String>> ignoreListTable) { + private void parseTypes(@NotNull final ErrorViewCollector errorViewCollector, final Element element, @NotNull final IgnorelistsDefinition ignorelistsDefinition) { final Iterator<Element> it = new NodeListIterator<Element>(element, "type"); while (it.hasNext()) { final Element elem = it.next(); if (!elem.getAttribute("available").equals("no")) { - archetypeTypeSet.add(archetypeTypeParser.load(errorViewCollector, archetypeTypeSet.getDefaultArchetypeType(), elem, archetypeTypeSet, ignoreListTable)); + archetypeTypeSet.add(archetypeTypeParser.load(errorViewCollector, archetypeTypeSet.getDefaultArchetypeType(), elem, archetypeTypeSet, ignorelistsDefinition)); } } } Added: trunk/src/app/net/sf/gridarta/model/archetypetype/IgnorelistsDefinition.java =================================================================== --- trunk/src/app/net/sf/gridarta/model/archetypetype/IgnorelistsDefinition.java (rev 0) +++ trunk/src/app/net/sf/gridarta/model/archetypetype/IgnorelistsDefinition.java 2010-05-24 19:56:35 UTC (rev 7989) @@ -0,0 +1,87 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2010 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.model.archetypetype; + +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * The contents of an <ignorelists> element of a types.xml file. + * @author Andreas Kirschbaum + */ +public class IgnorelistsDefinition { + + /** + * The ignore list entries. Maps ignore list name to ignored section names. + */ + @NotNull + private final Map<String, Set<String>> ignoreListTable = new HashMap<String, Set<String>>(); + + /** + * Returns whether an ignore list name exists. + * @param name the ignore list name + * @return whether the name exists + */ + public boolean containsKey(@NotNull final String name) { + return ignoreListTable.containsKey(name); + } + + /** + * Adds a new entry. + * @param name the ignore list name + * @param value the section name to be ignored + * @throws IllegalArgumentException if the parameters are not valid + */ + public void put(@NotNull final String name, @NotNull final String value) { + if (name.isEmpty()) { + throw new IllegalArgumentException("empty name"); + } + + if (value.isEmpty()) { + throw new IllegalArgumentException("empty value for name '" + name + "'"); + } + + Set<String> values = ignoreListTable.get(name); + if (values == null) { + values = new HashSet<String>(); + ignoreListTable.put(name, values); + } + if (!values.add(value)) { + throw new IllegalArgumentException("duplicate value '" + value + "' for name '" + name + "'"); + } + } + + /** + * Returns the ignored section names for a ignore list name. + * @param name the ignore list name + * @return the ignored section names + */ + @Nullable + public Iterable<String> get(@NotNull final String name) { + final Set<String> values = ignoreListTable.get(name); + return values == null ? null : Collections.unmodifiableCollection(values); + } + +} // class IgnorelistsDefinition Property changes on: trunk/src/app/net/sf/gridarta/model/archetypetype/IgnorelistsDefinition.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-05-24 21:42:46
|
Revision: 7990 http://gridarta.svn.sourceforge.net/gridarta/?rev=7990&view=rev Author: akirschbaum Date: 2010-05-24 21:42:37 +0000 (Mon, 24 May 2010) Log Message: ----------- Remove unneeded type parameters. Modified Paths: -------------- trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/maincontrol/DefaultEditorFactory.java trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/model/gameobject/DefaultGameObjectFactory.java trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/model/gameobject/GameObject.java trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/maincontrol/DefaultEditorFactory.java trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/maincontrol/DefaultEditorFactory.java trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/model/gameobject/DefaultGameObjectFactory.java trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/model/gameobject/GameObject.java trunk/src/app/net/sf/gridarta/gui/archetypetype/ArchetypeTypeChecks.java trunk/src/app/net/sf/gridarta/gui/findarchetypes/FindArchetypesDialog.java trunk/src/app/net/sf/gridarta/gui/findarchetypes/FindArchetypesDialogManager.java trunk/src/app/net/sf/gridarta/gui/findarchetypes/TableModel.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/DialogAttribute.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/DialogAttributeAnimationName.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/DialogAttributeBitmask.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/DialogAttributeBool.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/DialogAttributeBoolSpec.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/DialogAttributeFaceName.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/DialogAttributeFloat.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/DialogAttributeInt.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/DialogAttributeInvSpell.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/DialogAttributeList.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/DialogAttributeLong.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/DialogAttributeMapPath.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/DialogAttributeScriptFile.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/DialogAttributeSpell.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/DialogAttributeString.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/DialogAttributeText.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/DialogAttributeTreasure.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/DialogAttributeZSpell.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/GameObjectAttributesDialogFactory.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/GuiInfo.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/HelpActionListener.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/MaskChangeAL.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/ArchTab.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/TextEditorTab.java trunk/src/app/net/sf/gridarta/gui/gameobjecttexteditor/GameObjectTextEditor.java trunk/src/app/net/sf/gridarta/gui/objectchoicedisplay/ObjectChoiceDisplay.java trunk/src/app/net/sf/gridarta/gui/objectchooser/DefaultObjectChooser.java trunk/src/app/net/sf/gridarta/maincontrol/DefaultMainControl.java trunk/src/app/net/sf/gridarta/maincontrol/EditorFactory.java trunk/src/app/net/sf/gridarta/maincontrol/GUIMainControl.java trunk/src/app/net/sf/gridarta/maincontrol/GridartaEditor.java trunk/src/app/net/sf/gridarta/maincontrol/ImageCreatorFactory.java trunk/src/app/net/sf/gridarta/model/archetypetype/AbstractArchetypeAttributeInvSpell.java trunk/src/app/net/sf/gridarta/model/archetypetype/AbstractArchetypeAttributeList.java trunk/src/app/net/sf/gridarta/model/archetypetype/AbstractArchetypeAttributeSpell.java trunk/src/app/net/sf/gridarta/model/archetypetype/ArchetypeAttribute.java trunk/src/app/net/sf/gridarta/model/archetypetype/ArchetypeAttributeAnimationName.java trunk/src/app/net/sf/gridarta/model/archetypetype/ArchetypeAttributeBitmask.java trunk/src/app/net/sf/gridarta/model/archetypetype/ArchetypeAttributeBool.java trunk/src/app/net/sf/gridarta/model/archetypetype/ArchetypeAttributeBoolSpec.java trunk/src/app/net/sf/gridarta/model/archetypetype/ArchetypeAttributeFaceName.java trunk/src/app/net/sf/gridarta/model/archetypetype/ArchetypeAttributeFactory.java trunk/src/app/net/sf/gridarta/model/archetypetype/ArchetypeAttributeFixed.java trunk/src/app/net/sf/gridarta/model/archetypetype/ArchetypeAttributeFloat.java trunk/src/app/net/sf/gridarta/model/archetypetype/ArchetypeAttributeInt.java trunk/src/app/net/sf/gridarta/model/archetypetype/ArchetypeAttributeInvSpell.java trunk/src/app/net/sf/gridarta/model/archetypetype/ArchetypeAttributeList.java trunk/src/app/net/sf/gridarta/model/archetypetype/ArchetypeAttributeLong.java trunk/src/app/net/sf/gridarta/model/archetypetype/ArchetypeAttributeMapPath.java trunk/src/app/net/sf/gridarta/model/archetypetype/ArchetypeAttributeParser.java trunk/src/app/net/sf/gridarta/model/archetypetype/ArchetypeAttributeScriptFile.java trunk/src/app/net/sf/gridarta/model/archetypetype/ArchetypeAttributeSpell.java trunk/src/app/net/sf/gridarta/model/archetypetype/ArchetypeAttributeString.java trunk/src/app/net/sf/gridarta/model/archetypetype/ArchetypeAttributeText.java trunk/src/app/net/sf/gridarta/model/archetypetype/ArchetypeAttributeTreasure.java trunk/src/app/net/sf/gridarta/model/archetypetype/ArchetypeAttributeVisitor.java trunk/src/app/net/sf/gridarta/model/archetypetype/ArchetypeAttributeZSpell.java trunk/src/app/net/sf/gridarta/model/archetypetype/ArchetypeAttributes.java trunk/src/app/net/sf/gridarta/model/archetypetype/ArchetypeType.java trunk/src/app/net/sf/gridarta/model/archetypetype/ArchetypeTypeParser.java trunk/src/app/net/sf/gridarta/model/archetypetype/ArchetypeTypeSet.java trunk/src/app/net/sf/gridarta/model/archetypetype/ArchetypeTypeSetParser.java trunk/src/app/net/sf/gridarta/model/archetypetype/AttributeBitmask.java trunk/src/app/net/sf/gridarta/model/archetypetype/DefaultArchetypeAttributeFactory.java trunk/src/app/net/sf/gridarta/model/gameobject/GameObjectUtils.java trunk/src/test/net/sf/gridarta/model/archetypetype/ArchetypeTypeSetParserTest.java Modified: trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/maincontrol/DefaultEditorFactory.java =================================================================== --- trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/maincontrol/DefaultEditorFactory.java 2010-05-24 19:56:35 UTC (rev 7989) +++ trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/maincontrol/DefaultEditorFactory.java 2010-05-24 21:42:37 UTC (rev 7990) @@ -208,7 +208,7 @@ */ @NotNull @Override - public DefaultMainControl<GameObject, MapArchObject, Archetype> newMainControl(final boolean forceReadFromFiles, @NotNull final ErrorView errorView, @NotNull final GlobalSettings globalSettings, @NotNull final ConfigSourceFactory configSourceFactory, @NotNull final PathManager pathManager, @NotNull final GameObjectMatchers gameObjectMatchers, @NotNull final GameObjectFactory<GameObject, MapArchObject, Archetype> gameObjectFactory, @NotNull final ArchetypeTypeSet<GameObject, MapArchObject, Archetype> archetypeTypeSet, @NotNull final net.sf.gridarta.model.archetype.ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final ArchetypeChooserModel<GameObject, MapArchObject, Archetype> archetypeChooserModel, @NotNull final AutojoinLists<GameObject, MapArchObject, Archetype> autojoinLists, @NotNull final AbstractMapManager<GameObject, MapArchObject, Archetype> mapManager, @NotNull final ScriptModel<GameObject, MapArchObject, Archetype> scriptModel, @NotNull final DelegatingMapValidator<GameObject, MapArchObject, Archetype> validators, @NotNull final ScriptedEventEditor<GameObject, MapArchObject, Archetype> scriptedEventEditor, @NotNull final AbstractResources<GameObject, MapArchObject, Archetype> resources, @NotNull final Spells<NumberSpell> numberSpells, @NotNull final Spells<GameObjectSpell<GameObject, MapArchObject, Archetype>> gameObjectSpells, @NotNull final AttributeRangeChecker<GameObject, MapArchObject, Archetype> attributeRangeChecker, @NotNull final PluginParameterFactory<GameObject, MapArchObject, Archetype> pluginParameterFactory) { + public DefaultMainControl<GameObject, MapArchObject, Archetype> newMainControl(final boolean forceReadFromFiles, @NotNull final ErrorView errorView, @NotNull final GlobalSettings globalSettings, @NotNull final ConfigSourceFactory configSourceFactory, @NotNull final PathManager pathManager, @NotNull final GameObjectMatchers gameObjectMatchers, @NotNull final GameObjectFactory<GameObject, MapArchObject, Archetype> gameObjectFactory, @NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final net.sf.gridarta.model.archetype.ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final ArchetypeChooserModel<GameObject, MapArchObject, Archetype> archetypeChooserModel, @NotNull final AutojoinLists<GameObject, MapArchObject, Archetype> autojoinLists, @NotNull final AbstractMapManager<GameObject, MapArchObject, Archetype> mapManager, @NotNull final ScriptModel<GameObject, MapArchObject, Archetype> scriptModel, @NotNull final DelegatingMapValidator<GameObject, MapArchObject, Archetype> validators, @NotNull final ScriptedEventEditor<GameObject, MapArchObject, Archetype> scriptedEventEditor, @NotNull final AbstractResources<GameObject, MapArchObject, Archetype> resources, @NotNull final Spells<NumberSpell> numberSpells, @NotNull final Spells<GameObjectSpell<GameObject, MapArchObject, Archetype>> gameObjectSpells, @NotNull final AttributeRangeChecker<GameObject, MapArchObject, Archetype> attributeRangeChecker, @NotNull final PluginParameterFactory<GameObject, MapArchObject, Archetype> pluginParameterFactory) { return new DefaultMainControl<GameObject, MapArchObject, Archetype>(FileFilters.pythonFileFilter, ".py", "Python", 0, IGUIConstants.SPELL_FILE, IGUIConstants.SCRIPTS_DIR, errorView, this, forceReadFromFiles, globalSettings, configSourceFactory, pathManager, gameObjectMatchers, gameObjectFactory, archetypeTypeSet, archetypeSet, archetypeChooserModel, autojoinLists, mapManager, scriptModel, validators, scriptedEventEditor, resources, numberSpells, gameObjectSpells, attributeRangeChecker, pluginParameterFactory); } @@ -243,7 +243,7 @@ */ @NotNull @Override - public GameObjectFactory<GameObject, MapArchObject, Archetype> newGameObjectFactory(@NotNull final FaceObjectProviders faceObjectProviders, @NotNull final AnimationObjects animationObjects, @NotNull final ArchetypeTypeSet<GameObject, MapArchObject, Archetype> archetypeTypeSet) { + public GameObjectFactory<GameObject, MapArchObject, Archetype> newGameObjectFactory(@NotNull final FaceObjectProviders faceObjectProviders, @NotNull final AnimationObjects animationObjects, @NotNull final ArchetypeTypeSet archetypeTypeSet) { return new DefaultGameObjectFactory(faceObjectProviders, animationObjects, archetypeTypeSet); } @@ -537,7 +537,7 @@ */ @NotNull @Override - public GUIMainControl<GameObject, MapArchObject, Archetype> createGUIMainControl(@NotNull final DefaultMainControl<GameObject, MapArchObject, Archetype> mainControl, @NotNull final ErrorView errorView, @NotNull final GUIUtils guiUtils, @NotNull final ConfigSourceFactory configSourceFactory, @NotNull final RendererFactory<GameObject, MapArchObject, Archetype> rendererFactory, @NotNull final FilterControl<GameObject, MapArchObject, Archetype> filterControl, @NotNull final ScriptExecutor<GameObject, MapArchObject, Archetype> scriptExecutor, @NotNull final ScriptParameters scriptParameters, @NotNull final AbstractMapManager<GameObject, MapArchObject, Archetype> mapManager, @NotNull final MapManager<GameObject, MapArchObject, Archetype> pickmapManager, @NotNull final MapControlFactory<GameObject, MapArchObject, Archetype> mapControlFactory, @NotNull final net.sf.gridarta.model.archetype.ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final FaceObjects faceObjects, @NotNull final GlobalSettings globalSettings, @NotNull final MapViewSettings mapViewSettings, @NotNull final FaceObjectProviders faceObjectProviders, @NotNull final PathManager pathManager, @NotNull final InsertionMode<GameObject, MapArchObject, Archetype> topmostInsertionMode, @NotNull final GameObjectFactory<GameObject, MapArchObject, Archetype> gameObjectFactory, @NotNull final SystemIcons systemIcons, @NotNull final ArchetypeTypeSet<GameObject, MapArchObject, Archetype> archetypeTypeSet, @NotNull final MapArchObjectFactory<MapArchObject> mapArchObjectFactory, @NotNull final DefaultMapReaderFactory<GameObject, MapArchObject, Archetype> mapReaderFactory, @NotNull final DelegatingMapValidator<GameObject, MapArchObject, Archetype> validators, @NotNull final GameObjectMatchers gameObjectMatchers, @NotNull final ScriptModel<GameObject, MapArchObject, Archetype> scriptModel, @NotNull final AnimationObjects animationObjects, @NotNull final ArchetypeChooserModel<GameObject, MapArchObject, Archetype> archetypeChooserModel, @NotNull final ScriptedEventEditor<GameObject, MapArchObject, Archetype> scriptedEventEditor, @NotNull final AbstractResources<GameObject, MapArchObject, Archetype> resources, @NotNull final Spells<NumberSpell> numberSpells, @NotNull final Spells<GameObjectSpell<GameObject, MapArchObject, Archetype>> gameObjectSpells, @NotNull final AttributeRangeChecker<GameObject, MapArchObject, Archetype> attributeRangeChecker, @NotNull final PluginParameterFactory<GameObject, MapArchObject, Archetype> pluginParameterFactory) { + public GUIMainControl<GameObject, MapArchObject, Archetype> createGUIMainControl(@NotNull final DefaultMainControl<GameObject, MapArchObject, Archetype> mainControl, @NotNull final ErrorView errorView, @NotNull final GUIUtils guiUtils, @NotNull final ConfigSourceFactory configSourceFactory, @NotNull final RendererFactory<GameObject, MapArchObject, Archetype> rendererFactory, @NotNull final FilterControl<GameObject, MapArchObject, Archetype> filterControl, @NotNull final ScriptExecutor<GameObject, MapArchObject, Archetype> scriptExecutor, @NotNull final ScriptParameters scriptParameters, @NotNull final AbstractMapManager<GameObject, MapArchObject, Archetype> mapManager, @NotNull final MapManager<GameObject, MapArchObject, Archetype> pickmapManager, @NotNull final MapControlFactory<GameObject, MapArchObject, Archetype> mapControlFactory, @NotNull final net.sf.gridarta.model.archetype.ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final FaceObjects faceObjects, @NotNull final GlobalSettings globalSettings, @NotNull final MapViewSettings mapViewSettings, @NotNull final FaceObjectProviders faceObjectProviders, @NotNull final PathManager pathManager, @NotNull final InsertionMode<GameObject, MapArchObject, Archetype> topmostInsertionMode, @NotNull final GameObjectFactory<GameObject, MapArchObject, Archetype> gameObjectFactory, @NotNull final SystemIcons systemIcons, @NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final MapArchObjectFactory<MapArchObject> mapArchObjectFactory, @NotNull final DefaultMapReaderFactory<GameObject, MapArchObject, Archetype> mapReaderFactory, @NotNull final DelegatingMapValidator<GameObject, MapArchObject, Archetype> validators, @NotNull final GameObjectMatchers gameObjectMatchers, @NotNull final ScriptModel<GameObject, MapArchObject, Archetype> scriptModel, @NotNull final AnimationObjects animationObjects, @NotNull final ArchetypeChooserModel<GameObject, MapArchObject, Archetype> archetypeChooserModel, @NotNull final ScriptedEventEditor<GameObject, MapArchObject, Archetype> scriptedEventEditor, @NotNull final AbstractResources<GameObject, MapArchObject, Archetype> resources, @NotNull final Spells<NumberSpell> numberSpells, @NotNull final Spells<GameObjectSpell<GameObject, MapArchObject, Archetype>> gameObjectSpells, @NotNull final AttributeRangeChecker<GameObject, MapArchObject, Archetype> attributeRangeChecker, @NotNull final PluginParameterFactory<GameObject, MapArchObject, Archetype> pluginParameterFactory) { return mainControl.createGUIMainControl(FileFilters.pythonFileFilter, ".py", true, mapManager, pickmapManager, archetypeSet, mapControlFactory, guiUtils.getResourceIcon(IGUIConstants.TILE_NORTH), "AtrinikEditor.jar", 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.SPELL_FILE, this, errorView, new SubdirectoryCacheFiles(".dedit"), configSourceFactory, rendererFactory, filterControl, scriptExecutor, scriptParameters, faceObjects, globalSettings, mapViewSettings, faceObjectProviders, pathManager, topmostInsertionMode, gameObjectFactory, systemIcons, -1, archetypeTypeSet, mapArchObjectFactory, mapReaderFactory, validators, gameObjectMatchers, IGUIConstants.SCRIPTS_DIR, scriptModel, animationObjects, archetypeChooserModel, false, scriptedEventEditor, new int[] { CommonConstants.NORTH_EAST, CommonConstants.SOUTH_EAST, CommonConstants.SOUTH_WEST, CommonConstants.NORTH_WEST, CommonConstants.EAST, CommonConstants.SOUTH, CommonConstants.WEST, CommonConstants.NORTH, }, resources, gameObjectSpells, numberSpells, attributeRangeChecker, pluginParameterFactory); } Modified: trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/model/gameobject/DefaultGameObjectFactory.java =================================================================== --- trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/model/gameobject/DefaultGameObjectFactory.java 2010-05-24 19:56:35 UTC (rev 7989) +++ trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/model/gameobject/DefaultGameObjectFactory.java 2010-05-24 21:42:37 UTC (rev 7990) @@ -52,7 +52,7 @@ * The {@link ArchetypeTypeSet} for looking up archetype types. */ @NotNull - private final ArchetypeTypeSet<GameObject, MapArchObject, Archetype> archetypeTypeSet; + private final ArchetypeTypeSet archetypeTypeSet; /** * Creates a new instance. @@ -61,7 +61,7 @@ * @param archetypeTypeSet the archetype type set for looking up archetype * types */ - public DefaultGameObjectFactory(@NotNull final FaceObjectProviders faceObjectProviders, @NotNull final AnimationObjects animationObjects, @NotNull final ArchetypeTypeSet<GameObject, MapArchObject, Archetype> archetypeTypeSet) { + public DefaultGameObjectFactory(@NotNull final FaceObjectProviders faceObjectProviders, @NotNull final AnimationObjects animationObjects, @NotNull final ArchetypeTypeSet archetypeTypeSet) { this.faceObjectProviders = faceObjectProviders; this.animationObjects = animationObjects; this.archetypeTypeSet = archetypeTypeSet; Modified: trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/model/gameobject/GameObject.java =================================================================== --- trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/model/gameobject/GameObject.java 2010-05-24 19:56:35 UTC (rev 7989) +++ trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/model/gameobject/GameObject.java 2010-05-24 21:42:37 UTC (rev 7990) @@ -55,7 +55,7 @@ * The {@link ArchetypeTypeSet} for looking up archetype types. */ @NotNull - private final ArchetypeTypeSet<GameObject, MapArchObject, Archetype> archetypeTypeSet; + private final ArchetypeTypeSet archetypeTypeSet; /** * Creates a new instance. @@ -67,7 +67,7 @@ * types */ @Deprecated - public GameObject(@NotNull final String archetypeName, @NotNull final FaceObjectProviders faceObjectProviders, @NotNull final AnimationObjects animationObjects, @NotNull final ArchetypeTypeSet<GameObject, MapArchObject, Archetype> archetypeTypeSet) { + public GameObject(@NotNull final String archetypeName, @NotNull final FaceObjectProviders faceObjectProviders, @NotNull final AnimationObjects animationObjects, @NotNull final ArchetypeTypeSet archetypeTypeSet) { super(archetypeName, faceObjectProviders, animationObjects); this.archetypeTypeSet = archetypeTypeSet; } @@ -81,7 +81,7 @@ * @param archetypeTypeSet the archetype type set for looking up archetype * types */ - public GameObject(@NotNull final Archetype archetype, @NotNull final FaceObjectProviders faceObjectProviders, @NotNull final AnimationObjects animationObjects, @NotNull final ArchetypeTypeSet<GameObject, MapArchObject, Archetype> archetypeTypeSet) { + public GameObject(@NotNull final Archetype archetype, @NotNull final FaceObjectProviders faceObjectProviders, @NotNull final AnimationObjects animationObjects, @NotNull final ArchetypeTypeSet archetypeTypeSet) { super(archetype, faceObjectProviders, animationObjects); this.archetypeTypeSet = archetypeTypeSet; } Modified: trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/maincontrol/DefaultEditorFactory.java =================================================================== --- trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/maincontrol/DefaultEditorFactory.java 2010-05-24 19:56:35 UTC (rev 7989) +++ trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/maincontrol/DefaultEditorFactory.java 2010-05-24 21:42:37 UTC (rev 7990) @@ -158,7 +158,7 @@ */ @NotNull @Override - public DefaultMainControl<GameObject, MapArchObject, Archetype> newMainControl(final boolean forceReadFromFiles, @NotNull final ErrorView errorView, @NotNull final GlobalSettings globalSettings, @NotNull final ConfigSourceFactory configSourceFactory, @NotNull final PathManager pathManager, @NotNull final GameObjectMatchers gameObjectMatchers, @NotNull final GameObjectFactory<GameObject, MapArchObject, Archetype> gameObjectFactory, @NotNull final ArchetypeTypeSet<GameObject, MapArchObject, Archetype> archetypeTypeSet, @NotNull final net.sf.gridarta.model.archetype.ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final ArchetypeChooserModel<GameObject, MapArchObject, Archetype> archetypeChooserModel, @NotNull final AutojoinLists<GameObject, MapArchObject, Archetype> autojoinLists, @NotNull final AbstractMapManager<GameObject, MapArchObject, Archetype> mapManager, @NotNull final ScriptModel<GameObject, MapArchObject, Archetype> scriptModel, @NotNull final DelegatingMapValidator<GameObject, MapArchObject, Archetype> validators, @NotNull final ScriptedEventEditor<GameObject, MapArchObject, Archetype> scriptedEventEditor, @NotNull final AbstractResources<GameObject, MapArchObject, Archetype> resources, @NotNull final Spells<NumberSpell> numberSpells, @NotNull final Spells<GameObjectSpell<GameObject, MapArchObject, Archetype>> gameObjectSpells, @NotNull final AttributeRangeChecker<GameObject, MapArchObject, Archetype> attributeRangeChecker, @NotNull final PluginParameterFactory<GameObject, MapArchObject, Archetype> pluginParameterFactory) { + public DefaultMainControl<GameObject, MapArchObject, Archetype> newMainControl(final boolean forceReadFromFiles, @NotNull final ErrorView errorView, @NotNull final GlobalSettings globalSettings, @NotNull final ConfigSourceFactory configSourceFactory, @NotNull final PathManager pathManager, @NotNull final GameObjectMatchers gameObjectMatchers, @NotNull final GameObjectFactory<GameObject, MapArchObject, Archetype> gameObjectFactory, @NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final net.sf.gridarta.model.archetype.ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final ArchetypeChooserModel<GameObject, MapArchObject, Archetype> archetypeChooserModel, @NotNull final AutojoinLists<GameObject, MapArchObject, Archetype> autojoinLists, @NotNull final AbstractMapManager<GameObject, MapArchObject, Archetype> mapManager, @NotNull final ScriptModel<GameObject, MapArchObject, Archetype> scriptModel, @NotNull final DelegatingMapValidator<GameObject, MapArchObject, Archetype> validators, @NotNull final ScriptedEventEditor<GameObject, MapArchObject, Archetype> scriptedEventEditor, @NotNull final AbstractResources<GameObject, MapArchObject, Archetype> resources, @NotNull final Spells<NumberSpell> numberSpells, @NotNull final Spells<GameObjectSpell<GameObject, MapArchObject, Archetype>> gameObjectSpells, @NotNull final AttributeRangeChecker<GameObject, MapArchObject, Archetype> attributeRangeChecker, @NotNull final PluginParameterFactory<GameObject, MapArchObject, Archetype> pluginParameterFactory) { return new DefaultMainControl<GameObject, MapArchObject, Archetype>(FileFilters.pythonFileFilter, ".py", "Python", Archetype.TYPE_SPELL, null, IGUIConstants.SCRIPTS_DIR, errorView, this, false, globalSettings, configSourceFactory, pathManager, gameObjectMatchers, gameObjectFactory, archetypeTypeSet, archetypeSet, archetypeChooserModel, autojoinLists, mapManager, scriptModel, validators, scriptedEventEditor, resources, numberSpells, gameObjectSpells, attributeRangeChecker, pluginParameterFactory); } @@ -193,7 +193,7 @@ */ @NotNull @Override - public GameObjectFactory<GameObject, MapArchObject, Archetype> newGameObjectFactory(@NotNull final FaceObjectProviders faceObjectProviders, @NotNull final AnimationObjects animationObjects, @NotNull final ArchetypeTypeSet<GameObject, MapArchObject, Archetype> archetypeTypeSet) { + public GameObjectFactory<GameObject, MapArchObject, Archetype> newGameObjectFactory(@NotNull final FaceObjectProviders faceObjectProviders, @NotNull final AnimationObjects animationObjects, @NotNull final ArchetypeTypeSet archetypeTypeSet) { return new DefaultGameObjectFactory(faceObjectProviders, animationObjects); } @@ -404,7 +404,7 @@ */ @NotNull @Override - public GUIMainControl<GameObject, MapArchObject, Archetype> createGUIMainControl(@NotNull final DefaultMainControl<GameObject, MapArchObject, Archetype> mainControl, @NotNull final ErrorView errorView, @NotNull final GUIUtils guiUtils, @NotNull final ConfigSourceFactory configSourceFactory, @NotNull final RendererFactory<GameObject, MapArchObject, Archetype> rendererFactory, @NotNull final FilterControl<GameObject, MapArchObject, Archetype> filterControl, @NotNull final ScriptExecutor<GameObject, MapArchObject, Archetype> scriptExecutor, @NotNull final ScriptParameters scriptParameters, @NotNull final AbstractMapManager<GameObject, MapArchObject, Archetype> mapManager, @NotNull final MapManager<GameObject, MapArchObject, Archetype> pickmapManager, @NotNull final MapControlFactory<GameObject, MapArchObject, Archetype> mapControlFactory, @NotNull final net.sf.gridarta.model.archetype.ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final FaceObjects faceObjects, @NotNull final GlobalSettings globalSettings, @NotNull final MapViewSettings mapViewSettings, @NotNull final FaceObjectProviders faceObjectProviders, @NotNull final PathManager pathManager, @NotNull final InsertionMode<GameObject, MapArchObject, Archetype> topmostInsertionMode, @NotNull final GameObjectFactory<GameObject, MapArchObject, Archetype> gameObjectFactory, @NotNull final SystemIcons systemIcons, @NotNull final ArchetypeTypeSet<GameObject, MapArchObject, Archetype> archetypeTypeSet, @NotNull final MapArchObjectFactory<MapArchObject> mapArchObjectFactory, @NotNull final DefaultMapReaderFactory<GameObject, MapArchObject, Archetype> mapReaderFactory, @NotNull final DelegatingMapValidator<GameObject, MapArchObject, Archetype> validators, @NotNull final GameObjectMatchers gameObjectMatchers, @NotNull final ScriptModel<GameObject, MapArchObject, Archetype> scriptModel, @NotNull final AnimationObjects animationObjects, @NotNull final ArchetypeChooserModel<GameObject, MapArchObject, Archetype> archetypeChooserModel, @NotNull final ScriptedEventEditor<GameObject, MapArchObject, Archetype> scriptedEventEditor, @NotNull final AbstractResources<GameObject, MapArchObject, Archetype> resources, @NotNull final Spells<NumberSpell> numberSpells, @NotNull final Spells<GameObjectSpell<GameObject, MapArchObject, Archetype>> gameObjectSpells, @NotNull final AttributeRangeChecker<GameObject, MapArchObject, Archetype> attributeRangeChecker, @NotNull final PluginParameterFactory<GameObject, MapArchObject, Archetype> pluginParameterFactory) { + public GUIMainControl<GameObject, MapArchObject, Archetype> createGUIMainControl(@NotNull final DefaultMainControl<GameObject, MapArchObject, Archetype> mainControl, @NotNull final ErrorView errorView, @NotNull final GUIUtils guiUtils, @NotNull final ConfigSourceFactory configSourceFactory, @NotNull final RendererFactory<GameObject, MapArchObject, Archetype> rendererFactory, @NotNull final FilterControl<GameObject, MapArchObject, Archetype> filterControl, @NotNull final ScriptExecutor<GameObject, MapArchObject, Archetype> scriptExecutor, @NotNull final ScriptParameters scriptParameters, @NotNull final AbstractMapManager<GameObject, MapArchObject, Archetype> mapManager, @NotNull final MapManager<GameObject, MapArchObject, Archetype> pickmapManager, @NotNull final MapControlFactory<GameObject, MapArchObject, Archetype> mapControlFactory, @NotNull final net.sf.gridarta.model.archetype.ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final FaceObjects faceObjects, @NotNull final GlobalSettings globalSettings, @NotNull final MapViewSettings mapViewSettings, @NotNull final FaceObjectProviders faceObjectProviders, @NotNull final PathManager pathManager, @NotNull final InsertionMode<GameObject, MapArchObject, Archetype> topmostInsertionMode, @NotNull final GameObjectFactory<GameObject, MapArchObject, Archetype> gameObjectFactory, @NotNull final SystemIcons systemIcons, @NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final MapArchObjectFactory<MapArchObject> mapArchObjectFactory, @NotNull final DefaultMapReaderFactory<GameObject, MapArchObject, Archetype> mapReaderFactory, @NotNull final DelegatingMapValidator<GameObject, MapArchObject, Archetype> validators, @NotNull final GameObjectMatchers gameObjectMatchers, @NotNull final ScriptModel<GameObject, MapArchObject, Archetype> scriptModel, @NotNull final AnimationObjects animationObjects, @NotNull final ArchetypeChooserModel<GameObject, MapArchObject, Archetype> archetypeChooserModel, @NotNull final ScriptedEventEditor<GameObject, MapArchObject, Archetype> scriptedEventEditor, @NotNull final AbstractResources<GameObject, MapArchObject, Archetype> resources, @NotNull final Spells<NumberSpell> numberSpells, @NotNull final Spells<GameObjectSpell<GameObject, MapArchObject, Archetype>> gameObjectSpells, @NotNull final AttributeRangeChecker<GameObject, MapArchObject, Archetype> attributeRangeChecker, @NotNull final PluginParameterFactory<GameObject, MapArchObject, Archetype> pluginParameterFactory) { return mainControl.createGUIMainControl(FileFilters.pythonFileFilter, ".py", false, mapManager, pickmapManager, archetypeSet, mapControlFactory, null, "CrossfireEditor.jar", 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, null, this, errorView, new DirectoryCacheFiles(ConfigFileUtils.getHomeFile("thumbnails"), ".png"), configSourceFactory, rendererFactory, filterControl, scriptExecutor, scriptParameters, faceObjects, globalSettings, mapViewSettings, faceObjectProviders, pathManager, topmostInsertionMode, gameObjectFactory, systemIcons, 0, archetypeTypeSet, mapArchObjectFactory, mapReaderFactory, validators, gameObjectMatchers, IGUIConstants.SCRIPTS_DIR, scriptModel, animationObjects, archetypeChooserModel, true, scriptedEventEditor, new int[] { CommonConstants.NORTH, CommonConstants.EAST, CommonConstants.SOUTH, CommonConstants.WEST, CommonConstants.NORTH_EAST, CommonConstants.SOUTH_EAST, CommonConstants.SOUTH_WEST, CommonConstants.NORTH_WEST, }, resources, gameObjectSpells, numberSpells, attributeRangeChecker, pluginParameterFactory); } Modified: trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/maincontrol/DefaultEditorFactory.java =================================================================== --- trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/maincontrol/DefaultEditorFactory.java 2010-05-24 19:56:35 UTC (rev 7989) +++ trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/maincontrol/DefaultEditorFactory.java 2010-05-24 21:42:37 UTC (rev 7990) @@ -209,7 +209,7 @@ */ @NotNull @Override - public DefaultMainControl<GameObject, MapArchObject, Archetype> newMainControl(final boolean forceReadFromFiles, @NotNull final ErrorView errorView, @NotNull final GlobalSettings globalSettings, @NotNull final ConfigSourceFactory configSourceFactory, @NotNull final PathManager pathManager, @NotNull final GameObjectMatchers gameObjectMatchers, @NotNull final GameObjectFactory<GameObject, MapArchObject, Archetype> gameObjectFactory, @NotNull final ArchetypeTypeSet<GameObject, MapArchObject, Archetype> archetypeTypeSet, @NotNull final net.sf.gridarta.model.archetype.ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final ArchetypeChooserModel<GameObject, MapArchObject, Archetype> archetypeChooserModel, @NotNull final AutojoinLists<GameObject, MapArchObject, Archetype> autojoinLists, @NotNull final AbstractMapManager<GameObject, MapArchObject, Archetype> mapManager, @NotNull final ScriptModel<GameObject, MapArchObject, Archetype> scriptModel, @NotNull final DelegatingMapValidator<GameObject, MapArchObject, Archetype> validators, @NotNull final ScriptedEventEditor<GameObject, MapArchObject, Archetype> scriptedEventEditor, @NotNull final AbstractResources<GameObject, MapArchObject, Archetype> resources, @NotNull final Spells<NumberSpell> numberSpells, @NotNull final Spells<GameObjectSpell<GameObject, MapArchObject, Archetype>> gameObjectSpells, @NotNull final AttributeRangeChecker<GameObject, MapArchObject, Archetype> attributeRangeChecker, @NotNull final PluginParameterFactory<GameObject, MapArchObject, Archetype> pluginParameterFactory) { + public DefaultMainControl<GameObject, MapArchObject, Archetype> newMainControl(final boolean forceReadFromFiles, @NotNull final ErrorView errorView, @NotNull final GlobalSettings globalSettings, @NotNull final ConfigSourceFactory configSourceFactory, @NotNull final PathManager pathManager, @NotNull final GameObjectMatchers gameObjectMatchers, @NotNull final GameObjectFactory<GameObject, MapArchObject, Archetype> gameObjectFactory, @NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final net.sf.gridarta.model.archetype.ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final ArchetypeChooserModel<GameObject, MapArchObject, Archetype> archetypeChooserModel, @NotNull final AutojoinLists<GameObject, MapArchObject, Archetype> autojoinLists, @NotNull final AbstractMapManager<GameObject, MapArchObject, Archetype> mapManager, @NotNull final ScriptModel<GameObject, MapArchObject, Archetype> scriptModel, @NotNull final DelegatingMapValidator<GameObject, MapArchObject, Archetype> validators, @NotNull final ScriptedEventEditor<GameObject, MapArchObject, Archetype> scriptedEventEditor, @NotNull final AbstractResources<GameObject, MapArchObject, Archetype> resources, @NotNull final Spells<NumberSpell> numberSpells, @NotNull final Spells<GameObjectSpell<GameObject, MapArchObject, Archetype>> gameObjectSpells, @NotNull final AttributeRangeChecker<GameObject, MapArchObject, Archetype> attributeRangeChecker, @NotNull final PluginParameterFactory<GameObject, MapArchObject, Archetype> pluginParameterFactory) { return new DefaultMainControl<GameObject, MapArchObject, Archetype>(FileFilters.luaFileFilter, ".lua", "Lua", 0, IGUIConstants.SPELL_FILE, IGUIConstants.SCRIPTS_DIR, errorView, this, forceReadFromFiles, globalSettings, configSourceFactory, pathManager, gameObjectMatchers, gameObjectFactory, archetypeTypeSet, archetypeSet, archetypeChooserModel, autojoinLists, mapManager, scriptModel, validators, scriptedEventEditor, resources, numberSpells, gameObjectSpells, attributeRangeChecker, pluginParameterFactory); } @@ -244,7 +244,7 @@ */ @NotNull @Override - public GameObjectFactory<GameObject, MapArchObject, Archetype> newGameObjectFactory(@NotNull final FaceObjectProviders faceObjectProviders, @NotNull final AnimationObjects animationObjects, @NotNull final ArchetypeTypeSet<GameObject, MapArchObject, Archetype> archetypeTypeSet) { + public GameObjectFactory<GameObject, MapArchObject, Archetype> newGameObjectFactory(@NotNull final FaceObjectProviders faceObjectProviders, @NotNull final AnimationObjects animationObjects, @NotNull final ArchetypeTypeSet archetypeTypeSet) { return new DefaultGameObjectFactory(faceObjectProviders, animationObjects, archetypeTypeSet); } @@ -538,7 +538,7 @@ */ @NotNull @Override - public GUIMainControl<GameObject, MapArchObject, Archetype> createGUIMainControl(@NotNull final DefaultMainControl<GameObject, MapArchObject, Archetype> mainControl, @NotNull final ErrorView errorView, @NotNull final GUIUtils guiUtils, @NotNull final ConfigSourceFactory configSourceFactory, @NotNull final RendererFactory<GameObject, MapArchObject, Archetype> rendererFactory, @NotNull final FilterControl<GameObject, MapArchObject, Archetype> filterControl, @NotNull final ScriptExecutor<GameObject, MapArchObject, Archetype> scriptExecutor, @NotNull final ScriptParameters scriptParameters, @NotNull final AbstractMapManager<GameObject, MapArchObject, Archetype> mapManager, @NotNull final MapManager<GameObject, MapArchObject, Archetype> pickmapManager, @NotNull final MapControlFactory<GameObject, MapArchObject, Archetype> mapControlFactory, @NotNull final net.sf.gridarta.model.archetype.ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final FaceObjects faceObjects, @NotNull final GlobalSettings globalSettings, @NotNull final MapViewSettings mapViewSettings, @NotNull final FaceObjectProviders faceObjectProviders, @NotNull final PathManager pathManager, @NotNull final InsertionMode<GameObject, MapArchObject, Archetype> topmostInsertionMode, @NotNull final GameObjectFactory<GameObject, MapArchObject, Archetype> gameObjectFactory, @NotNull final SystemIcons systemIcons, @NotNull final ArchetypeTypeSet<GameObject, MapArchObject, Archetype> archetypeTypeSet, @NotNull final MapArchObjectFactory<MapArchObject> mapArchObjectFactory, @NotNull final DefaultMapReaderFactory<GameObject, MapArchObject, Archetype> mapReaderFactory, @NotNull final DelegatingMapValidator<GameObject, MapArchObject, Archetype> validators, @NotNull final GameObjectMatchers gameObjectMatchers, @NotNull final ScriptModel<GameObject, MapArchObject, Archetype> scriptModel, @NotNull final AnimationObjects animationObjects, @NotNull final ArchetypeChooserModel<GameObject, MapArchObject, Archetype> archetypeChooserModel, @NotNull final ScriptedEventEditor<GameObject, MapArchObject, Archetype> scriptedEventEditor, @NotNull final AbstractResources<GameObject, MapArchObject, Archetype> resources, @NotNull final Spells<NumberSpell> numberSpells, @NotNull final Spells<GameObjectSpell<GameObject, MapArchObject, Archetype>> gameObjectSpells, @NotNull final AttributeRangeChecker<GameObject, MapArchObject, Archetype> attributeRangeChecker, @NotNull final PluginParameterFactory<GameObject, MapArchObject, Archetype> pluginParameterFactory) { + public GUIMainControl<GameObject, MapArchObject, Archetype> createGUIMainControl(@NotNull final DefaultMainControl<GameObject, MapArchObject, Archetype> mainControl, @NotNull final ErrorView errorView, @NotNull final GUIUtils guiUtils, @NotNull final ConfigSourceFactory configSourceFactory, @NotNull final RendererFactory<GameObject, MapArchObject, Archetype> rendererFactory, @NotNull final FilterControl<GameObject, MapArchObject, Archetype> filterControl, @NotNull final ScriptExecutor<GameObject, MapArchObject, Archetype> scriptExecutor, @NotNull final ScriptParameters scriptParameters, @NotNull final AbstractMapManager<GameObject, MapArchObject, Archetype> mapManager, @NotNull final MapManager<GameObject, MapArchObject, Archetype> pickmapManager, @NotNull final MapControlFactory<GameObject, MapArchObject, Archetype> mapControlFactory, @NotNull final net.sf.gridarta.model.archetype.ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final FaceObjects faceObjects, @NotNull final GlobalSettings globalSettings, @NotNull final MapViewSettings mapViewSettings, @NotNull final FaceObjectProviders faceObjectProviders, @NotNull final PathManager pathManager, @NotNull final InsertionMode<GameObject, MapArchObject, Archetype> topmostInsertionMode, @NotNull final GameObjectFactory<GameObject, MapArchObject, Archetype> gameObjectFactory, @NotNull final SystemIcons systemIcons, @NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final MapArchObjectFactory<MapArchObject> mapArchObjectFactory, @NotNull final DefaultMapReaderFactory<GameObject, MapArchObject, Archetype> mapReaderFactory, @NotNull final DelegatingMapValidator<GameObject, MapArchObject, Archetype> validators, @NotNull final GameObjectMatchers gameObjectMatchers, @NotNull final ScriptModel<GameObject, MapArchObject, Archetype> scriptModel, @NotNull final AnimationObjects animationObjects, @NotNull final ArchetypeChooserModel<GameObject, MapArchObject, Archetype> archetypeChooserModel, @NotNull final ScriptedEventEditor<GameObject, MapArchObject, Archetype> scriptedEventEditor, @NotNull final AbstractResources<GameObject, MapArchObject, Archetype> resources, @NotNull final Spells<NumberSpell> numberSpells, @NotNull final Spells<GameObjectSpell<GameObject, MapArchObject, Archetype>> gameObjectSpells, @NotNull final AttributeRangeChecker<GameObject, MapArchObject, Archetype> attributeRangeChecker, @NotNull final PluginParameterFactory<GameObject, MapArchObject, Archetype> pluginParameterFactory) { return mainControl.createGUIMainControl(FileFilters.luaFileFilter, ".lua", true, mapManager, pickmapManager, archetypeSet, mapControlFactory, guiUtils.getResourceIcon(IGUIConstants.TILE_NORTH), "DaimoninEditor.jar", 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.SPELL_FILE, this, errorView, new SubdirectoryCacheFiles(".dedit"), configSourceFactory, rendererFactory, filterControl, scriptExecutor, scriptParameters, faceObjects, globalSettings, mapViewSettings, faceObjectProviders, pathManager, topmostInsertionMode, gameObjectFactory, systemIcons, -1, archetypeTypeSet, mapArchObjectFactory, mapReaderFactory, validators, gameObjectMatchers, IGUIConstants.SCRIPTS_DIR, scriptModel, animationObjects, archetypeChooserModel, false, scriptedEventEditor, new int[] { CommonConstants.NORTH_EAST, CommonConstants.SOUTH_EAST, CommonConstants.SOUTH_WEST, CommonConstants.NORTH_WEST, CommonConstants.EAST, CommonConstants.SOUTH, CommonConstants.WEST, CommonConstants.NORTH, }, resources, gameObjectSpells, numberSpells, attributeRangeChecker, pluginParameterFactory); } Modified: trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/model/gameobject/DefaultGameObjectFactory.java =================================================================== --- trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/model/gameobject/DefaultGameObjectFactory.java 2010-05-24 19:56:35 UTC (rev 7989) +++ trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/model/gameobject/DefaultGameObjectFactory.java 2010-05-24 21:42:37 UTC (rev 7990) @@ -52,7 +52,7 @@ * The {@link ArchetypeTypeSet} for looking up archetype types. */ @NotNull - private final ArchetypeTypeSet<GameObject, MapArchObject, Archetype> archetypeTypeSet; + private final ArchetypeTypeSet archetypeTypeSet; /** * Creates a new instance. @@ -61,7 +61,7 @@ * @param archetypeTypeSet the archetype type set for looking up archetype * types */ - public DefaultGameObjectFactory(@NotNull final FaceObjectProviders faceObjectProviders, @NotNull final AnimationObjects animationObjects, @NotNull final ArchetypeTypeSet<GameObject, MapArchObject, Archetype> archetypeTypeSet) { + public DefaultGameObjectFactory(@NotNull final FaceObjectProviders faceObjectProviders, @NotNull final AnimationObjects animationObjects, @NotNull final ArchetypeTypeSet archetypeTypeSet) { this.faceObjectProviders = faceObjectProviders; this.animationObjects = animationObjects; this.archetypeTypeSet = archetypeTypeSet; Modified: trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/model/gameobject/GameObject.java =================================================================== --- trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/model/gameobject/GameObject.java 2010-05-24 19:56:35 UTC (rev 7989) +++ trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/model/gameobject/GameObject.java 2010-05-24 21:42:37 UTC (rev 7990) @@ -55,7 +55,7 @@ * The {@link ArchetypeTypeSet} for looking up archetype types. */ @NotNull - private final ArchetypeTypeSet<GameObject, MapArchObject, Archetype> archetypeTypeSet; + private final ArchetypeTypeSet archetypeTypeSet; /** * Creates a new instance. @@ -67,7 +67,7 @@ * types */ @Deprecated - public GameObject(@NotNull final String archetypeName, @NotNull final FaceObjectProviders faceObjectProviders, @NotNull final AnimationObjects animationObjects, @NotNull final ArchetypeTypeSet<GameObject, MapArchObject, Archetype> archetypeTypeSet) { + public GameObject(@NotNull final String archetypeName, @NotNull final FaceObjectProviders faceObjectProviders, @NotNull final AnimationObjects animationObjects, @NotNull final ArchetypeTypeSet archetypeTypeSet) { super(archetypeName, faceObjectProviders, animationObjects); this.archetypeTypeSet = archetypeTypeSet; } @@ -81,7 +81,7 @@ * @param archetypeTypeSet the archetype type set for looking up archetype * types */ - public GameObject(@NotNull final Archetype archetype, @NotNull final FaceObjectProviders faceObjectProviders, @NotNull final AnimationObjects animationObjects, @NotNull final ArchetypeTypeSet<GameObject, MapArchObject, Archetype> archetypeTypeSet) { + public GameObject(@NotNull final Archetype archetype, @NotNull final FaceObjectProviders faceObjectProviders, @NotNull final AnimationObjects animationObjects, @NotNull final ArchetypeTypeSet archetypeTypeSet) { super(archetype, faceObjectProviders, animationObjects); this.archetypeTypeSet = archetypeTypeSet; } Modified: trunk/src/app/net/sf/gridarta/gui/archetypetype/ArchetypeTypeChecks.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/archetypetype/ArchetypeTypeChecks.java 2010-05-24 19:56:35 UTC (rev 7989) +++ trunk/src/app/net/sf/gridarta/gui/archetypetype/ArchetypeTypeChecks.java 2010-05-24 21:42:37 UTC (rev 7990) @@ -73,8 +73,8 @@ * @param attributeRangeChecker the attribute range checker to add to * @param archetypeTypeSet the archetype type set to use */ - public static <G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> void addChecks(@NotNull final ArchetypeTypeSet<G, A, R> archetypeTypeSet, @NotNull final AttributeRangeChecker<G, A, R> attributeRangeChecker) { - for (final ArchetypeType<G, A, R> archetypeType : archetypeTypeSet) { + public static <G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> void addChecks(@NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final AttributeRangeChecker<G, A, R> attributeRangeChecker) { + for (final ArchetypeType archetypeType : archetypeTypeSet) { addChecks(archetypeTypeSet, attributeRangeChecker, archetypeType); } } @@ -86,23 +86,23 @@ * @param archetypeTypeSet the archetype type set to use * @param archetypeType the archetype type */ - private static <G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> void addChecks(@NotNull final ArchetypeTypeSet<G, A, R> archetypeTypeSet, @NotNull final AttributeRangeChecker<G, A, R> attributeRangeChecker, @NotNull final ArchetypeType<G, A, R> archetypeType) { + private static <G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> void addChecks(@NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final AttributeRangeChecker<G, A, R> attributeRangeChecker, @NotNull final ArchetypeType archetypeType) { if (archetypeType.hasTypeAttributes()) { return; // XXX: make such attributes work } - final ArchetypeAttributeVisitor<G, A, R> archetypeAttributeVisitor = new ArchetypeAttributeVisitor<G, A, R>() { + final ArchetypeAttributeVisitor archetypeAttributeVisitor = new ArchetypeAttributeVisitor() { /** {@inheritDoc} */ @Override - public void visit(@NotNull final ArchetypeAttributeAnimationName<G, A, R> archetypeAttribute) { + public void visit(@NotNull final ArchetypeAttributeAnimationName archetypeAttribute) { // XXX: missing } /** {@inheritDoc} */ @Override - public void visit(@NotNull final ArchetypeAttributeBitmask<G, A, R> archetypeAttribute) { - final AttributeBitmask<G, A, R> bitmask = archetypeTypeSet.getBitmask(archetypeAttribute.getBitmaskName()); + public void visit(@NotNull final ArchetypeAttributeBitmask archetypeAttribute) { + final AttributeBitmask bitmask = archetypeTypeSet.getBitmask(archetypeAttribute.getBitmaskName()); if (bitmask != null) { try { attributeRangeChecker.add(archetypeType.getTypeNo(), archetypeAttribute.getArchetypeAttributeName(), archetypeAttribute.getAttributeName(), 0, bitmask.getMaxValue()); @@ -114,7 +114,7 @@ /** {@inheritDoc} */ @Override - public void visit(@NotNull final ArchetypeAttributeBool<G, A, R> archetypeAttribute) { + public void visit(@NotNull final ArchetypeAttributeBool archetypeAttribute) { try { attributeRangeChecker.add(archetypeType.getTypeNo(), archetypeAttribute.getArchetypeAttributeName(), archetypeAttribute.getAttributeName(), 0, 1); } catch (final InvalidCheckException ex) { @@ -124,31 +124,31 @@ /** {@inheritDoc} */ @Override - public void visit(@NotNull final ArchetypeAttributeBoolSpec<G, A, R> archetypeAttribute) { + public void visit(@NotNull final ArchetypeAttributeBoolSpec archetypeAttribute) { // XXX: missing } /** {@inheritDoc} */ @Override - public void visit(@NotNull final ArchetypeAttributeFaceName<G, A, R> archetypeAttribute) { + public void visit(@NotNull final ArchetypeAttributeFaceName archetypeAttribute) { // XXX: missing } /** {@inheritDoc} */ @Override - public void visit(@NotNull final ArchetypeAttributeFixed<G, A, R> archetypeAttribute) { + public void visit(@NotNull final ArchetypeAttributeFixed archetypeAttribute) { // XXX: missing } /** {@inheritDoc} */ @Override - public void visit(@NotNull final ArchetypeAttributeFloat<G, A, R> archetypeAttribute) { + public void visit(@NotNull final ArchetypeAttributeFloat archetypeAttribute) { // XXX: missing } /** {@inheritDoc} */ @Override - public void visit(@NotNull final ArchetypeAttributeInt<G, A, R> archetypeAttribute) { + public void visit(@NotNull final ArchetypeAttributeInt archetypeAttribute) { try { attributeRangeChecker.add(archetypeType.getTypeNo(), archetypeAttribute.getArchetypeAttributeName(), archetypeAttribute.getAttributeName(), archetypeAttribute.getMinCheckValue(), archetypeAttribute.getMaxCheckValue()); } catch (final InvalidCheckException ex) { @@ -158,67 +158,67 @@ /** {@inheritDoc} */ @Override - public void visit(@NotNull final ArchetypeAttributeInvSpell<G, A, R> archetypeAttribute) { + public void visit(@NotNull final ArchetypeAttributeInvSpell archetypeAttribute) { // XXX: missing } /** {@inheritDoc} */ @Override - public void visit(@NotNull final ArchetypeAttributeList<G, A, R> archetypeAttribute) { + public void visit(@NotNull final ArchetypeAttributeList archetypeAttribute) { // XXX: missing } /** {@inheritDoc} */ @Override - public void visit(@NotNull final ArchetypeAttributeLong<G, A, R> archetypeAttribute) { + public void visit(@NotNull final ArchetypeAttributeLong archetypeAttribute) { // XXX: missing } /** {@inheritDoc} */ @Override - public void visit(@NotNull final ArchetypeAttributeMapPath<G, A, R> archetypeAttribute) { + public void visit(@NotNull final ArchetypeAttributeMapPath archetypeAttribute) { // XXX: missing } /** {@inheritDoc} */ @Override - public void visit(@NotNull final ArchetypeAttributeScriptFile<G, A, R> archetypeAttribute) { + public void visit(@NotNull final ArchetypeAttributeScriptFile archetypeAttribute) { // XXX: missing } /** {@inheritDoc} */ @Override - public void visit(@NotNull final ArchetypeAttributeSpell<G, A, R> archetypeAttribute) { + public void visit(@NotNull final ArchetypeAttributeSpell archetypeAttribute) { // XXX: missing } /** {@inheritDoc} */ @Override - public void visit(@NotNull final ArchetypeAttributeString<G, A, R> archetypeAttribute) { + public void visit(@NotNull final ArchetypeAttributeString archetypeAttribute) { // XXX: missing } /** {@inheritDoc} */ @Override - public void visit(@NotNull final ArchetypeAttributeText<G, A, R> archetypeAttribute) { + public void visit(@NotNull final ArchetypeAttributeText archetypeAttribute) { // XXX: missing } /** {@inheritDoc} */ @Override - public void visit(@NotNull final ArchetypeAttributeTreasure<G, A, R> archetypeAttribute) { + public void visit(@NotNull final ArchetypeAttributeTreasure archetypeAttribute) { // XXX: missing } /** {@inheritDoc} */ @Override - public void visit(@NotNull final ArchetypeAttributeZSpell<G, A, R> archetypeAttribute) { + public void visit(@NotNull final ArchetypeAttributeZSpell archetypeAttribute) { // XXX: missing } }; - for (final ArchetypeAttribute<G, A, R> archetypeAttribute : archetypeType) { + for (final ArchetypeAttribute archetypeAttribute : archetypeType) { archetypeAttribute.visit(archetypeAttributeVisitor); } } Modified: trunk/src/app/net/sf/gridarta/gui/findarchetypes/FindArchetypesDialog.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/findarchetypes/FindArchetypesDialog.java 2010-05-24 19:56:35 UTC (rev 7989) +++ trunk/src/app/net/sf/gridarta/gui/findarchetypes/FindArchetypesDialog.java 2010-05-24 21:42:37 UTC (rev 7990) @@ -147,7 +147,7 @@ * search results. * @param archetypeTypeSet the instance for looking up archetype types */ - public FindArchetypesDialog(final Component parent, final ArchetypeChooserControl<G, A, R> archetypeChooserControl, final ObjectChooser<G, A, R> objectChooser, final ArchetypeTypeSet<G, A, R> archetypeTypeSet) { + public FindArchetypesDialog(final Component parent, final ArchetypeChooserControl<G, A, R> archetypeChooserControl, final ObjectChooser<G, A, R> objectChooser, final ArchetypeTypeSet archetypeTypeSet) { this.archetypeChooserControl = archetypeChooserControl; this.objectChooser = objectChooser; Modified: trunk/src/app/net/sf/gridarta/gui/findarchetypes/FindArchetypesDialogManager.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/findarchetypes/FindArchetypesDialogManager.java 2010-05-24 19:56:35 UTC (rev 7989) +++ trunk/src/app/net/sf/gridarta/gui/findarchetypes/FindArchetypesDialogManager.java 2010-05-24 21:42:37 UTC (rev 7990) @@ -72,7 +72,7 @@ * The {@link ArchetypeTypeSet} for looking up archetype types. */ @NotNull - private final ArchetypeTypeSet<G, A, R> archetypeTypeSet; + private final ArchetypeTypeSet archetypeTypeSet; /** * Creates a new instance. @@ -83,7 +83,7 @@ * @param archetypeTypeSet the archetype type set for looking up archetype * types */ - public FindArchetypesDialogManager(@NotNull final Component parent, @NotNull final ArchetypeChooserControl<G, A, R> archetypeChooserControl, @NotNull final ObjectChooser<G, A, R> objectChooser, @NotNull final ArchetypeTypeSet<G, A, R> archetypeTypeSet) { + public FindArchetypesDialogManager(@NotNull final Component parent, @NotNull final ArchetypeChooserControl<G, A, R> archetypeChooserControl, @NotNull final ObjectChooser<G, A, R> objectChooser, @NotNull final ArchetypeTypeSet archetypeTypeSet) { super("findArchetypes"); this.parent = parent; this.archetypeChooserControl = archetypeChooserControl; Modified: trunk/src/app/net/sf/gridarta/gui/findarchetypes/TableModel.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/findarchetypes/TableModel.java 2010-05-24 19:56:35 UTC (rev 7989) +++ trunk/src/app/net/sf/gridarta/gui/findarchetypes/TableModel.java 2010-05-24 21:42:37 UTC (rev 7990) @@ -62,7 +62,7 @@ /** * The instance for looking up archetype types. */ - private final ArchetypeTypeSet<G, A, R> archetypeTypeSet; + private final ArchetypeTypeSet archetypeTypeSet; /** * The model's contents. @@ -107,7 +107,7 @@ * Creates a new instance. * @param archetypeTypeSet the instance for looking up archetype types */ - public TableModel(final ArchetypeTypeSet<G, A, R> archetypeTypeSet) { + public TableModel(final ArchetypeTypeSet archetypeTypeSet) { this.archetypeTypeSet = archetypeTypeSet; } @@ -168,7 +168,7 @@ return archetype.getArchetypeName(); case 2: - final ArchetypeType<G, A, R> archetypeType = archetypeTypeSet.getArchetypeType(archetype); + final ArchetypeType archetypeType = archetypeTypeSet.getArchetypeType(archetype); return archetypeType.getTypeName() + " (" + archetypeType.getTypeNo() + ')'; ... [truncated message content] |
From: <aki...@us...> - 2010-05-24 21:55:43
|
Revision: 7991 http://gridarta.svn.sourceforge.net/gridarta/?rev=7991&view=rev Author: akirschbaum Date: 2010-05-24 21:55:36 +0000 (Mon, 24 May 2010) Log Message: ----------- Fix typos. Modified Paths: -------------- trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/maincontrol/DefaultEditorFactory.java trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/maincontrol/DefaultEditorFactory.java trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/maincontrol/DefaultEditorFactory.java trunk/gridarta.ipr trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/HelpActionListener.java trunk/src/app/net/sf/gridarta/gui/objectchooser/DefaultObjectChooser.java trunk/src/app/net/sf/gridarta/gui/prefs/AppPrefs.java trunk/src/app/net/sf/gridarta/maincontrol/EditorFactory.java trunk/src/app/net/sf/gridarta/maincontrol/GUIMainControl.java trunk/src/app/net/sf/gridarta/maincontrol/GridartaEditor.java trunk/src/app/net/sf/gridarta/model/archetypetype/ArchetypeAttributeFactory.java trunk/src/app/net/sf/gridarta/model/archetypetype/ArchetypeAttributes.java Added Paths: ----------- trunk/src/app/net/sf/gridarta/gui/prefs/AppPreferencesModel.java Removed Paths: ------------- trunk/src/app/net/sf/gridarta/gui/prefs/AppPrefsModel.java Modified: trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/maincontrol/DefaultEditorFactory.java =================================================================== --- trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/maincontrol/DefaultEditorFactory.java 2010-05-24 21:42:37 UTC (rev 7990) +++ trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/maincontrol/DefaultEditorFactory.java 2010-05-24 21:55:36 UTC (rev 7991) @@ -36,7 +36,7 @@ import net.sf.gridarta.gui.mappropertiesdialog.MapPropertiesDialogFactory; import net.sf.gridarta.gui.newmap.NewMapDialogFactory; import net.sf.gridarta.gui.prefs.AppPrefs; -import net.sf.gridarta.gui.prefs.AppPrefsModel; +import net.sf.gridarta.gui.prefs.AppPreferencesModel; import net.sf.gridarta.gui.prefs.DevPrefs; import net.sf.gridarta.gui.prefs.GUIPrefs; import net.sf.gridarta.gui.prefs.MapValidatorPrefs; @@ -159,27 +159,27 @@ /** * Preferences default for auto validation. */ - private static final boolean PREFS_VALIDATOR_AUTO_DEFAULT = false; + private static final boolean PREFERENCES_VALIDATOR_AUTO_DEFAULT = false; /** * The horizontal size of a map square. */ - private static final int SQUARE_ISO_XLEN = 48; + private static final int SQUARE_ISO_X_LEN = 48; /** * The horizontal center of a map square. */ - private static final int SQUARE_ISO_XLEN2 = 24; + private static final int SQUARE_ISO_X_LEN2 = 24; /** * The vertical size of a map square. */ - private static final int SQUARE_ISO_YLEN = 23; + private static final int SQUARE_ISO_Y_LEN = 23; /** * The vertical center of a map square. */ - private static final int SQUARE_ISO_YLEN2 = 12; + private static final int SQUARE_ISO_Y_LEN2 = 12; /** * The Logger for printing log messages. @@ -195,7 +195,7 @@ * The {@link IsoMapSquareInfo} instance. */ @NotNull - private final IsoMapSquareInfo isoMapSquareInfo = new IsoMapSquareInfo(SQUARE_ISO_XLEN, SQUARE_ISO_XLEN2, SQUARE_ISO_YLEN, SQUARE_ISO_YLEN2); + private final IsoMapSquareInfo isoMapSquareInfo = new IsoMapSquareInfo(SQUARE_ISO_X_LEN, SQUARE_ISO_X_LEN2, SQUARE_ISO_Y_LEN, SQUARE_ISO_Y_LEN2); /** * The {@link MultiPositionData} to query for multi-part objects. @@ -216,7 +216,7 @@ * {@inheritDoc} */ @Override - public int getDoubleFaceOffest() { + public int getDoubleFaceOffset() { return isoMapSquareInfo.getYlen() - 1; } @@ -471,8 +471,8 @@ */ @NotNull @Override - public AppPrefsModel createAppPrefsModel() { - return new AppPrefsModel("../server/atrinik_server", System.getProperty("os.name").toLowerCase().startsWith("win") ? "../client/atrinik.exe" : "../client-0.1/atrinik", "vim"); + public AppPreferencesModel createAppPreferencesModel() { + return new AppPreferencesModel("../server/atrinik_server", System.getProperty("os.name").toLowerCase().startsWith("win") ? "../client/atrinik.exe" : "../client-0.1/atrinik", "vim"); } /** @@ -528,8 +528,8 @@ */ @NotNull @Override - public PreferencesGroup createPreferencesGroup(@NotNull final GlobalSettings globalSettings, @NotNull final DelegatingMapValidator<GameObject, MapArchObject, Archetype> validators, @NotNull final AppPrefsModel appPrefsModel, @NotNull final ExitConnectorModel exitConnectorModel, @NotNull final ConfigSourceFactory configSourceFactory) { - return new PreferencesGroup("Gridarta for Atrinik", new ResPrefs(globalSettings, configSourceFactory), new AppPrefs(appPrefsModel), new NetPrefs(), new GUIPrefs(globalSettings), new MiscPrefs(exitConnectorModel, globalSettings), new DevPrefs(), new UpdatePrefs(), new MapValidatorPrefs(validators, PREFS_VALIDATOR_AUTO_DEFAULT)); // prefsGroup + public PreferencesGroup createPreferencesGroup(@NotNull final GlobalSettings globalSettings, @NotNull final DelegatingMapValidator<GameObject, MapArchObject, Archetype> validators, @NotNull final AppPreferencesModel appPreferencesModel, @NotNull final ExitConnectorModel exitConnectorModel, @NotNull final ConfigSourceFactory configSourceFactory) { + return new PreferencesGroup("Gridarta for Atrinik", new ResPrefs(globalSettings, configSourceFactory), new AppPrefs(appPreferencesModel), new NetPrefs(), new GUIPrefs(globalSettings), new MiscPrefs(exitConnectorModel, globalSettings), new DevPrefs(), new UpdatePrefs(), new MapValidatorPrefs(validators, PREFERENCES_VALIDATOR_AUTO_DEFAULT)); } /** @@ -538,7 +538,7 @@ @NotNull @Override public GUIMainControl<GameObject, MapArchObject, Archetype> createGUIMainControl(@NotNull final DefaultMainControl<GameObject, MapArchObject, Archetype> mainControl, @NotNull final ErrorView errorView, @NotNull final GUIUtils guiUtils, @NotNull final ConfigSourceFactory configSourceFactory, @NotNull final RendererFactory<GameObject, MapArchObject, Archetype> rendererFactory, @NotNull final FilterControl<GameObject, MapArchObject, Archetype> filterControl, @NotNull final ScriptExecutor<GameObject, MapArchObject, Archetype> scriptExecutor, @NotNull final ScriptParameters scriptParameters, @NotNull final AbstractMapManager<GameObject, MapArchObject, Archetype> mapManager, @NotNull final MapManager<GameObject, MapArchObject, Archetype> pickmapManager, @NotNull final MapControlFactory<GameObject, MapArchObject, Archetype> mapControlFactory, @NotNull final net.sf.gridarta.model.archetype.ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final FaceObjects faceObjects, @NotNull final GlobalSettings globalSettings, @NotNull final MapViewSettings mapViewSettings, @NotNull final FaceObjectProviders faceObjectProviders, @NotNull final PathManager pathManager, @NotNull final InsertionMode<GameObject, MapArchObject, Archetype> topmostInsertionMode, @NotNull final GameObjectFactory<GameObject, MapArchObject, Archetype> gameObjectFactory, @NotNull final SystemIcons systemIcons, @NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final MapArchObjectFactory<MapArchObject> mapArchObjectFactory, @NotNull final DefaultMapReaderFactory<GameObject, MapArchObject, Archetype> mapReaderFactory, @NotNull final DelegatingMapValidator<GameObject, MapArchObject, Archetype> validators, @NotNull final GameObjectMatchers gameObjectMatchers, @NotNull final ScriptModel<GameObject, MapArchObject, Archetype> scriptModel, @NotNull final AnimationObjects animationObjects, @NotNull final ArchetypeChooserModel<GameObject, MapArchObject, Archetype> archetypeChooserModel, @NotNull final ScriptedEventEditor<GameObject, MapArchObject, Archetype> scriptedEventEditor, @NotNull final AbstractResources<GameObject, MapArchObject, Archetype> resources, @NotNull final Spells<NumberSpell> numberSpells, @NotNull final Spells<GameObjectSpell<GameObject, MapArchObject, Archetype>> gameObjectSpells, @NotNull final AttributeRangeChecker<GameObject, MapArchObject, Archetype> attributeRangeChecker, @NotNull final PluginParameterFactory<GameObject, MapArchObject, Archetype> pluginParameterFactory) { - return mainControl.createGUIMainControl(FileFilters.pythonFileFilter, ".py", true, mapManager, pickmapManager, archetypeSet, mapControlFactory, guiUtils.getResourceIcon(IGUIConstants.TILE_NORTH), "AtrinikEditor.jar", 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.SPELL_FILE, this, errorView, new SubdirectoryCacheFiles(".dedit"), configSourceFactory, rendererFactory, filterControl, scriptExecutor, scriptParameters, faceObjects, globalSettings, mapViewSettings, faceObjectProviders, pathManager, topmostInsertionMode, gameObjectFactory, systemIcons, -1, archetypeTypeSet, mapArchObjectFactory, mapReaderFactory, validators, gameObjectMatchers, IGUIConstants.SCRIPTS_DIR, scriptModel, animationObjects, archetypeChooserModel, false, scriptedEventEditor, new int[] { CommonConstants.NORTH_EAST, CommonConstants.SOUTH_EAST, CommonConstants.SOUTH_WEST, CommonConstants.NORTH_WEST, CommonConstants.EAST, CommonConstants.SOUTH, CommonConstants.WEST, CommonConstants.NORTH, }, resources, gameObjectSpells, numberSpells, attributeRangeChecker, pluginParameterFactory); + return mainControl.createGUIMainControl(FileFilters.pythonFileFilter, ".py", true, mapManager, pickmapManager, archetypeSet, mapControlFactory, guiUtils.getResourceIcon(IGUIConstants.TILE_NORTH), "AtrinikEditor.jar", 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, }, PREFERENCES_VALIDATOR_AUTO_DEFAULT, IGUIConstants.SPELL_FILE, this, errorView, new SubdirectoryCacheFiles(".dedit"), configSourceFactory, rendererFactory, filterControl, scriptExecutor, scriptParameters, faceObjects, globalSettings, mapViewSettings, faceObjectProviders, pathManager, topmostInsertionMode, gameObjectFactory, systemIcons, -1, archetypeTypeSet, mapArchObjectFactory, mapReaderFactory, validators, gameObjectMatchers, IGUIConstants.SCRIPTS_DIR, scriptModel, animationObjects, archetypeChooserModel, false, scriptedEventEditor, new int[] { CommonConstants.NORTH_EAST, CommonConstants.SOUTH_EAST, CommonConstants.SOUTH_WEST, CommonConstants.NORTH_WEST, CommonConstants.EAST, CommonConstants.SOUTH, CommonConstants.WEST, CommonConstants.NORTH, }, resources, gameObjectSpells, numberSpells, attributeRangeChecker, pluginParameterFactory); } /** Modified: trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/maincontrol/DefaultEditorFactory.java =================================================================== --- trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/maincontrol/DefaultEditorFactory.java 2010-05-24 21:42:37 UTC (rev 7990) +++ trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/maincontrol/DefaultEditorFactory.java 2010-05-24 21:55:36 UTC (rev 7991) @@ -30,8 +30,8 @@ import net.sf.gridarta.gui.map.renderer.RendererFactory; import net.sf.gridarta.gui.mappropertiesdialog.MapPropertiesDialogFactory; import net.sf.gridarta.gui.newmap.NewMapDialogFactory; +import net.sf.gridarta.gui.prefs.AppPreferencesModel; import net.sf.gridarta.gui.prefs.AppPrefs; -import net.sf.gridarta.gui.prefs.AppPrefsModel; import net.sf.gridarta.gui.prefs.DevPrefs; import net.sf.gridarta.gui.prefs.GUIPrefs; import net.sf.gridarta.gui.prefs.MapValidatorPrefs; @@ -140,7 +140,7 @@ /** * Preferences default for auto validation. */ - private static final boolean PREFS_VALIDATOR_AUTO_DEFAULT = true; + private static final boolean PREFERENCES_VALIDATOR_AUTO_DEFAULT = true; /** * The {@link Logger} for printing log messages. @@ -166,7 +166,7 @@ * {@inheritDoc} */ @Override - public int getDoubleFaceOffest() { + public int getDoubleFaceOffset() { return 1; } @@ -361,8 +361,8 @@ */ @NotNull @Override - public AppPrefsModel createAppPrefsModel() { - return new AppPrefsModel("crossfire-server", System.getProperty("os.name").toLowerCase().startsWith("win") ? "GTKClient.exe" : "crossfire-client-gtk2", "vim"); + public AppPreferencesModel createAppPreferencesModel() { + return new AppPreferencesModel("crossfire-server", System.getProperty("os.name").toLowerCase().startsWith("win") ? "GTKClient.exe" : "crossfire-client-gtk2", "vim"); } /** @@ -395,8 +395,8 @@ */ @NotNull @Override - public PreferencesGroup createPreferencesGroup(@NotNull final GlobalSettings globalSettings, @NotNull final DelegatingMapValidator<GameObject, MapArchObject, Archetype> validators, @NotNull final AppPrefsModel appPrefsModel, @NotNull final ExitConnectorModel exitConnectorModel, @NotNull final ConfigSourceFactory configSourceFactory) { - return new PreferencesGroup("Gridarta for Crossfire", new ResPrefs(globalSettings, configSourceFactory), new AppPrefs(appPrefsModel), new NetPrefs(), new GUIPrefs(globalSettings), new MiscPrefs(exitConnectorModel, globalSettings), new DevPrefs(), new UpdatePrefs(), new MapValidatorPrefs(validators, PREFS_VALIDATOR_AUTO_DEFAULT)); // prefsGroup + public PreferencesGroup createPreferencesGroup(@NotNull final GlobalSettings globalSettings, @NotNull final DelegatingMapValidator<GameObject, MapArchObject, Archetype> validators, @NotNull final AppPreferencesModel appPreferencesModel, @NotNull final ExitConnectorModel exitConnectorModel, @NotNull final ConfigSourceFactory configSourceFactory) { + return new PreferencesGroup("Gridarta for Crossfire", new ResPrefs(globalSettings, configSourceFactory), new AppPrefs(appPreferencesModel), new NetPrefs(), new GUIPrefs(globalSettings), new MiscPrefs(exitConnectorModel, globalSettings), new DevPrefs(), new UpdatePrefs(), new MapValidatorPrefs(validators, PREFERENCES_VALIDATOR_AUTO_DEFAULT)); } /** @@ -405,7 +405,7 @@ @NotNull @Override public GUIMainControl<GameObject, MapArchObject, Archetype> createGUIMainControl(@NotNull final DefaultMainControl<GameObject, MapArchObject, Archetype> mainControl, @NotNull final ErrorView errorView, @NotNull final GUIUtils guiUtils, @NotNull final ConfigSourceFactory configSourceFactory, @NotNull final RendererFactory<GameObject, MapArchObject, Archetype> rendererFactory, @NotNull final FilterControl<GameObject, MapArchObject, Archetype> filterControl, @NotNull final ScriptExecutor<GameObject, MapArchObject, Archetype> scriptExecutor, @NotNull final ScriptParameters scriptParameters, @NotNull final AbstractMapManager<GameObject, MapArchObject, Archetype> mapManager, @NotNull final MapManager<GameObject, MapArchObject, Archetype> pickmapManager, @NotNull final MapControlFactory<GameObject, MapArchObject, Archetype> mapControlFactory, @NotNull final net.sf.gridarta.model.archetype.ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final FaceObjects faceObjects, @NotNull final GlobalSettings globalSettings, @NotNull final MapViewSettings mapViewSettings, @NotNull final FaceObjectProviders faceObjectProviders, @NotNull final PathManager pathManager, @NotNull final InsertionMode<GameObject, MapArchObject, Archetype> topmostInsertionMode, @NotNull final GameObjectFactory<GameObject, MapArchObject, Archetype> gameObjectFactory, @NotNull final SystemIcons systemIcons, @NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final MapArchObjectFactory<MapArchObject> mapArchObjectFactory, @NotNull final DefaultMapReaderFactory<GameObject, MapArchObject, Archetype> mapReaderFactory, @NotNull final DelegatingMapValidator<GameObject, MapArchObject, Archetype> validators, @NotNull final GameObjectMatchers gameObjectMatchers, @NotNull final ScriptModel<GameObject, MapArchObject, Archetype> scriptModel, @NotNull final AnimationObjects animationObjects, @NotNull final ArchetypeChooserModel<GameObject, MapArchObject, Archetype> archetypeChooserModel, @NotNull final ScriptedEventEditor<GameObject, MapArchObject, Archetype> scriptedEventEditor, @NotNull final AbstractResources<GameObject, MapArchObject, Archetype> resources, @NotNull final Spells<NumberSpell> numberSpells, @NotNull final Spells<GameObjectSpell<GameObject, MapArchObject, Archetype>> gameObjectSpells, @NotNull final AttributeRangeChecker<GameObject, MapArchObject, Archetype> attributeRangeChecker, @NotNull final PluginParameterFactory<GameObject, MapArchObject, Archetype> pluginParameterFactory) { - return mainControl.createGUIMainControl(FileFilters.pythonFileFilter, ".py", false, mapManager, pickmapManager, archetypeSet, mapControlFactory, null, "CrossfireEditor.jar", 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, null, this, errorView, new DirectoryCacheFiles(ConfigFileUtils.getHomeFile("thumbnails"), ".png"), configSourceFactory, rendererFactory, filterControl, scriptExecutor, scriptParameters, faceObjects, globalSettings, mapViewSettings, faceObjectProviders, pathManager, topmostInsertionMode, gameObjectFactory, systemIcons, 0, archetypeTypeSet, mapArchObjectFactory, mapReaderFactory, validators, gameObjectMatchers, IGUIConstants.SCRIPTS_DIR, scriptModel, animationObjects, archetypeChooserModel, true, scriptedEventEditor, new int[] { CommonConstants.NORTH, CommonConstants.EAST, CommonConstants.SOUTH, CommonConstants.WEST, CommonConstants.NORTH_EAST, CommonConstants.SOUTH_EAST, CommonConstants.SOUTH_WEST, CommonConstants.NORTH_WEST, }, resources, gameObjectSpells, numberSpells, attributeRangeChecker, pluginParameterFactory); + return mainControl.createGUIMainControl(FileFilters.pythonFileFilter, ".py", false, mapManager, pickmapManager, archetypeSet, mapControlFactory, null, "CrossfireEditor.jar", 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, }, PREFERENCES_VALIDATOR_AUTO_DEFAULT, null, this, errorView, new DirectoryCacheFiles(ConfigFileUtils.getHomeFile("thumbnails"), ".png"), configSourceFactory, rendererFactory, filterControl, scriptExecutor, scriptParameters, faceObjects, globalSettings, mapViewSettings, faceObjectProviders, pathManager, topmostInsertionMode, gameObjectFactory, systemIcons, 0, archetypeTypeSet, mapArchObjectFactory, mapReaderFactory, validators, gameObjectMatchers, IGUIConstants.SCRIPTS_DIR, scriptModel, animationObjects, archetypeChooserModel, true, scriptedEventEditor, new int[] { CommonConstants.NORTH, CommonConstants.EAST, CommonConstants.SOUTH, CommonConstants.WEST, CommonConstants.NORTH_EAST, CommonConstants.SOUTH_EAST, CommonConstants.SOUTH_WEST, CommonConstants.NORTH_WEST, }, resources, gameObjectSpells, numberSpells, attributeRangeChecker, pluginParameterFactory); } /** Modified: trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/maincontrol/DefaultEditorFactory.java =================================================================== --- trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/maincontrol/DefaultEditorFactory.java 2010-05-24 21:42:37 UTC (rev 7990) +++ trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/maincontrol/DefaultEditorFactory.java 2010-05-24 21:55:36 UTC (rev 7991) @@ -36,7 +36,7 @@ import net.sf.gridarta.gui.mappropertiesdialog.MapPropertiesDialogFactory; import net.sf.gridarta.gui.newmap.NewMapDialogFactory; import net.sf.gridarta.gui.prefs.AppPrefs; -import net.sf.gridarta.gui.prefs.AppPrefsModel; +import net.sf.gridarta.gui.prefs.AppPreferencesModel; import net.sf.gridarta.gui.prefs.DevPrefs; import net.sf.gridarta.gui.prefs.GUIPrefs; import net.sf.gridarta.gui.prefs.MapValidatorPrefs; @@ -160,27 +160,27 @@ /** * Preferences default for auto validation. */ - private static final boolean PREFS_VALIDATOR_AUTO_DEFAULT = false; + private static final boolean PREFERENCES_VALIDATOR_AUTO_DEFAULT = false; /** * The horizontal size of a map square. */ - private static final int SQUARE_ISO_XLEN = 48; + private static final int SQUARE_ISO_X_LEN = 48; /** * The horizontal center of a map square. */ - private static final int SQUARE_ISO_XLEN2 = 24; + private static final int SQUARE_ISO_X_LEN2 = 24; /** * The vertical size of a map square. */ - private static final int SQUARE_ISO_YLEN = 23; + private static final int SQUARE_ISO_Y_LEN = 23; /** * The vertical center of a map square. */ - private static final int SQUARE_ISO_YLEN2 = 12; + private static final int SQUARE_ISO_Y_LEN2 = 12; /** * The Logger for printing log messages. @@ -196,7 +196,7 @@ * The {@link IsoMapSquareInfo} instance. */ @NotNull - private final IsoMapSquareInfo isoMapSquareInfo = new IsoMapSquareInfo(SQUARE_ISO_XLEN, SQUARE_ISO_XLEN2, SQUARE_ISO_YLEN, SQUARE_ISO_YLEN2); + private final IsoMapSquareInfo isoMapSquareInfo = new IsoMapSquareInfo(SQUARE_ISO_X_LEN, SQUARE_ISO_X_LEN2, SQUARE_ISO_Y_LEN, SQUARE_ISO_Y_LEN2); /** * The {@link MultiPositionData} to query for multi-part objects. @@ -217,7 +217,7 @@ * {@inheritDoc} */ @Override - public int getDoubleFaceOffest() { + public int getDoubleFaceOffset() { return isoMapSquareInfo.getYlen() - 1; } @@ -472,8 +472,8 @@ */ @NotNull @Override - public AppPrefsModel createAppPrefsModel() { - return new AppPrefsModel("../server/daimonin_server", System.getProperty("os.name").toLowerCase().startsWith("win") ? "../client/Daimonin.exe" : "../client-BETA3-0.966/daimonin", "vim"); + public AppPreferencesModel createAppPreferencesModel() { + return new AppPreferencesModel("../server/daimonin_server", System.getProperty("os.name").toLowerCase().startsWith("win") ? "../client/Daimonin.exe" : "../client-BETA3-0.966/daimonin", "vim"); } /** @@ -529,8 +529,8 @@ */ @NotNull @Override - public PreferencesGroup createPreferencesGroup(@NotNull final GlobalSettings globalSettings, @NotNull final DelegatingMapValidator<GameObject, MapArchObject, Archetype> validators, @NotNull final AppPrefsModel appPrefsModel, @NotNull final ExitConnectorModel exitConnectorModel, @NotNull final ConfigSourceFactory configSourceFactory) { - return new PreferencesGroup("Gridarta for Daimonin", new ResPrefs(globalSettings, configSourceFactory), new AppPrefs(appPrefsModel), new NetPrefs(), new GUIPrefs(globalSettings), new MiscPrefs(exitConnectorModel, globalSettings), new DevPrefs(), new UpdatePrefs(), new MapValidatorPrefs(validators, PREFS_VALIDATOR_AUTO_DEFAULT)); // prefsGroup + public PreferencesGroup createPreferencesGroup(@NotNull final GlobalSettings globalSettings, @NotNull final DelegatingMapValidator<GameObject, MapArchObject, Archetype> validators, @NotNull final AppPreferencesModel appPreferencesModel, @NotNull final ExitConnectorModel exitConnectorModel, @NotNull final ConfigSourceFactory configSourceFactory) { + return new PreferencesGroup("Gridarta for Daimonin", new ResPrefs(globalSettings, configSourceFactory), new AppPrefs(appPreferencesModel), new NetPrefs(), new GUIPrefs(globalSettings), new MiscPrefs(exitConnectorModel, globalSettings), new DevPrefs(), new UpdatePrefs(), new MapValidatorPrefs(validators, PREFERENCES_VALIDATOR_AUTO_DEFAULT)); } /** @@ -539,7 +539,7 @@ @NotNull @Override public GUIMainControl<GameObject, MapArchObject, Archetype> createGUIMainControl(@NotNull final DefaultMainControl<GameObject, MapArchObject, Archetype> mainControl, @NotNull final ErrorView errorView, @NotNull final GUIUtils guiUtils, @NotNull final ConfigSourceFactory configSourceFactory, @NotNull final RendererFactory<GameObject, MapArchObject, Archetype> rendererFactory, @NotNull final FilterControl<GameObject, MapArchObject, Archetype> filterControl, @NotNull final ScriptExecutor<GameObject, MapArchObject, Archetype> scriptExecutor, @NotNull final ScriptParameters scriptParameters, @NotNull final AbstractMapManager<GameObject, MapArchObject, Archetype> mapManager, @NotNull final MapManager<GameObject, MapArchObject, Archetype> pickmapManager, @NotNull final MapControlFactory<GameObject, MapArchObject, Archetype> mapControlFactory, @NotNull final net.sf.gridarta.model.archetype.ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final FaceObjects faceObjects, @NotNull final GlobalSettings globalSettings, @NotNull final MapViewSettings mapViewSettings, @NotNull final FaceObjectProviders faceObjectProviders, @NotNull final PathManager pathManager, @NotNull final InsertionMode<GameObject, MapArchObject, Archetype> topmostInsertionMode, @NotNull final GameObjectFactory<GameObject, MapArchObject, Archetype> gameObjectFactory, @NotNull final SystemIcons systemIcons, @NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final MapArchObjectFactory<MapArchObject> mapArchObjectFactory, @NotNull final DefaultMapReaderFactory<GameObject, MapArchObject, Archetype> mapReaderFactory, @NotNull final DelegatingMapValidator<GameObject, MapArchObject, Archetype> validators, @NotNull final GameObjectMatchers gameObjectMatchers, @NotNull final ScriptModel<GameObject, MapArchObject, Archetype> scriptModel, @NotNull final AnimationObjects animationObjects, @NotNull final ArchetypeChooserModel<GameObject, MapArchObject, Archetype> archetypeChooserModel, @NotNull final ScriptedEventEditor<GameObject, MapArchObject, Archetype> scriptedEventEditor, @NotNull final AbstractResources<GameObject, MapArchObject, Archetype> resources, @NotNull final Spells<NumberSpell> numberSpells, @NotNull final Spells<GameObjectSpell<GameObject, MapArchObject, Archetype>> gameObjectSpells, @NotNull final AttributeRangeChecker<GameObject, MapArchObject, Archetype> attributeRangeChecker, @NotNull final PluginParameterFactory<GameObject, MapArchObject, Archetype> pluginParameterFactory) { - return mainControl.createGUIMainControl(FileFilters.luaFileFilter, ".lua", true, mapManager, pickmapManager, archetypeSet, mapControlFactory, guiUtils.getResourceIcon(IGUIConstants.TILE_NORTH), "DaimoninEditor.jar", 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.SPELL_FILE, this, errorView, new SubdirectoryCacheFiles(".dedit"), configSourceFactory, rendererFactory, filterControl, scriptExecutor, scriptParameters, faceObjects, globalSettings, mapViewSettings, faceObjectProviders, pathManager, topmostInsertionMode, gameObjectFactory, systemIcons, -1, archetypeTypeSet, mapArchObjectFactory, mapReaderFactory, validators, gameObjectMatchers, IGUIConstants.SCRIPTS_DIR, scriptModel, animationObjects, archetypeChooserModel, false, scriptedEventEditor, new int[] { CommonConstants.NORTH_EAST, CommonConstants.SOUTH_EAST, CommonConstants.SOUTH_WEST, CommonConstants.NORTH_WEST, CommonConstants.EAST, CommonConstants.SOUTH, CommonConstants.WEST, CommonConstants.NORTH, }, resources, gameObjectSpells, numberSpells, attributeRangeChecker, pluginParameterFactory); + return mainControl.createGUIMainControl(FileFilters.luaFileFilter, ".lua", true, mapManager, pickmapManager, archetypeSet, mapControlFactory, guiUtils.getResourceIcon(IGUIConstants.TILE_NORTH), "DaimoninEditor.jar", 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, }, PREFERENCES_VALIDATOR_AUTO_DEFAULT, IGUIConstants.SPELL_FILE, this, errorView, new SubdirectoryCacheFiles(".dedit"), configSourceFactory, rendererFactory, filterControl, scriptExecutor, scriptParameters, faceObjects, globalSettings, mapViewSettings, faceObjectProviders, pathManager, topmostInsertionMode, gameObjectFactory, systemIcons, -1, archetypeTypeSet, mapArchObjectFactory, mapReaderFactory, validators, gameObjectMatchers, IGUIConstants.SCRIPTS_DIR, scriptModel, animationObjects, archetypeChooserModel, false, scriptedEventEditor, new int[] { CommonConstants.NORTH_EAST, CommonConstants.SOUTH_EAST, CommonConstants.SOUTH_WEST, CommonConstants.NORTH_WEST, CommonConstants.EAST, CommonConstants.SOUTH, CommonConstants.WEST, CommonConstants.NORTH, }, resources, gameObjectSpells, numberSpells, attributeRangeChecker, pluginParameterFactory); } /** Modified: trunk/gridarta.ipr =================================================================== --- trunk/gridarta.ipr 2010-05-24 21:42:37 UTC (rev 7990) +++ trunk/gridarta.ipr 2010-05-24 21:55:36 UTC (rev 7991) @@ -1150,6 +1150,7 @@ <w>gridarta</w> <w>ignorelists</w> <w>indices</w> + <w>japi</w> <w>javac</w> <w>longdescription</w> <w>matchers</w> Modified: trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/HelpActionListener.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/HelpActionListener.java 2010-05-24 21:42:37 UTC (rev 7990) +++ trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/HelpActionListener.java 2010-05-24 21:55:36 UTC (rev 7991) @@ -39,9 +39,9 @@ private static final Category log = Logger.getLogger(HelpActionListener.class); /** - * CFArchAttrib which contains help information. + * The {@link ArchetypeAttribute} which contains help information. */ - private final ArchetypeAttribute attrib; // attribute structure + private final ArchetypeAttribute archetypeAttribute; /** * The component for help dialogs. @@ -57,7 +57,7 @@ if (a == null) { throw new IllegalArgumentException("HelpActionListener without context"); } - attrib = a; + archetypeAttribute = a; this.parent = parent; } @@ -66,8 +66,8 @@ */ @Override public void actionPerformed(final ActionEvent e) { - if (attrib != null) { - popupHelp(attrib.getAttributeName(), attrib.getDescription()); + if (archetypeAttribute != null) { + popupHelp(archetypeAttribute.getAttributeName(), archetypeAttribute.getDescription()); } else { assert false; log.warn("Help without help context!"); Modified: trunk/src/app/net/sf/gridarta/gui/objectchooser/DefaultObjectChooser.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/objectchooser/DefaultObjectChooser.java 2010-05-24 21:42:37 UTC (rev 7990) +++ trunk/src/app/net/sf/gridarta/gui/objectchooser/DefaultObjectChooser.java 2010-05-24 21:55:36 UTC (rev 7991) @@ -82,7 +82,7 @@ private final ObjectChoiceDisplay objectChoiceDisplay; /** - * Panel holding both archlist and pickmaps. + * Panel holding both archetype chooser and pickmap chooser. */ private final JTabbedPane tabbedPane = new JTabbedPane(SwingConstants.TOP); @@ -241,7 +241,6 @@ addTab(archetypeChooserControl); addTab(pickmapChooserControl); - // this listener informs the mainview which panel is active: archlist or pickmaps? tabbedPane.addChangeListener(changeListener); updateSelectedIndex(); add(tabbedPane, BorderLayout.CENTER); @@ -263,7 +262,7 @@ } /** - * Records whether the archtype chooser or the pickmap chooser is active. + * Records whether the archetype chooser or the pickmap chooser is active. * @param index the active tab index */ private void setActiveTab(final int index) { Copied: trunk/src/app/net/sf/gridarta/gui/prefs/AppPreferencesModel.java (from rev 7989, trunk/src/app/net/sf/gridarta/gui/prefs/AppPrefsModel.java) =================================================================== --- trunk/src/app/net/sf/gridarta/gui/prefs/AppPreferencesModel.java (rev 0) +++ trunk/src/app/net/sf/gridarta/gui/prefs/AppPreferencesModel.java 2010-05-24 21:55:36 UTC (rev 7991) @@ -0,0 +1,161 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2010 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.prefs; + +import java.util.prefs.Preferences; +import net.sf.gridarta.MainControl; +import net.sf.gridarta.model.io.PathManager; +import org.jetbrains.annotations.NotNull; + +/** + * Maintains the application preferences state. + * @author Andreas Kirschbaum + */ +public class AppPreferencesModel { + + /** + * Preferences key for server application. + */ + private static final String PREFERENCES_APP_SERVER = "appServer"; + + /** + * Preferences key for client application. + */ + private static final String PREFERENCES_APP_CLIENT = "appClient"; + + /** + * Preferences key for editor application. + */ + private static final String PREFERENCES_APP_EDITOR = "appEditor"; + + /** + * Preferences. + */ + private static final Preferences PREFERENCES = Preferences.userNodeForPackage(MainControl.class); + + /** + * The default value for the server setting. + */ + @NotNull + private final String serverDefault; + + /** + * The default value for the client setting. + */ + @NotNull + private final String clientDefault; + + /** + * The default value for the editor setting. + */ + @NotNull + private final String editorDefault; + + /** + * Creates a new instance. + * @param serverDefault the default value for the server setting + * @param clientDefault the default value for the client setting + * @param editorDefault the default value for the editor setting + */ + public AppPreferencesModel(@NotNull final String serverDefault, @NotNull final String clientDefault, @NotNull final String editorDefault) { + this.serverDefault = serverDefault; + this.clientDefault = clientDefault; + this.editorDefault = editorDefault; + } + + /** + * Sets the server setting. + * @param server the server setting + */ + public static void setServer(@NotNull final String server) { + PREFERENCES.put(PREFERENCES_APP_SERVER, PathManager.path(server)); + } + + /** + * Sets the client setting. + * @param client the client setting + */ + public static void setClient(@NotNull final String client) { + PREFERENCES.put(PREFERENCES_APP_CLIENT, PathManager.path(client)); + } + + /** + * Sets the editor setting. + * @param editor the editor setting + */ + public static void setEditor(@NotNull final String editor) { + PREFERENCES.put(PREFERENCES_APP_EDITOR, PathManager.path(editor)); + } + + /** + * Returns the server setting. + * @return the server setting + */ + @NotNull + public String getServer() { + return PREFERENCES.get(PREFERENCES_APP_SERVER, serverDefault); + } + + /** + * Returns the client setting. + * @return the client setting + */ + @NotNull + public String getClient() { + return PREFERENCES.get(PREFERENCES_APP_CLIENT, clientDefault); + } + + /** + * Returns the editor setting. + * @return the editor setting + */ + @NotNull + public String getEditor() { + return PREFERENCES.get(PREFERENCES_APP_EDITOR, editorDefault); + } + + /** + * Returns the server setting's default value. + * @return the server setting's default value + */ + @NotNull + public String getServerDefault() { + return serverDefault; + } + + /** + * Returns the client setting's default value. + * @return the client setting's default value + */ + @NotNull + public String getClientDefault() { + return clientDefault; + } + + /** + * Returns the editor setting's default value. + * @return the editor setting's default value + */ + @NotNull + public String getEditorDefault() { + return editorDefault; + } + +} // class AppPreferencesModel Property changes on: trunk/src/app/net/sf/gridarta/gui/prefs/AppPreferencesModel.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF Modified: trunk/src/app/net/sf/gridarta/gui/prefs/AppPrefs.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/prefs/AppPrefs.java 2010-05-24 21:42:37 UTC (rev 7990) +++ trunk/src/app/net/sf/gridarta/gui/prefs/AppPrefs.java 2010-05-24 21:55:36 UTC (rev 7991) @@ -56,7 +56,7 @@ * The model. */ @NotNull - private final AppPrefsModel appPrefsModel; + private final AppPreferencesModel appPreferencesModel; /** * TextField for server executable. @@ -75,10 +75,10 @@ /** * Creates a new instance. - * @param appPrefsModel the model + * @param appPreferencesModel the model */ - public AppPrefs(@NotNull final AppPrefsModel appPrefsModel) { - this.appPrefsModel = appPrefsModel; + public AppPrefs(@NotNull final AppPreferencesModel appPreferencesModel) { + this.appPreferencesModel = appPreferencesModel; setListLabelText(ACTION_BUILDER.getString("prefsApp.title")); setListLabelIcon(ACTION_BUILDER.getIcon("prefsApp.icon")); @@ -100,9 +100,9 @@ */ @Override public void apply() { - AppPrefsModel.setServer(serverField.getText()); - AppPrefsModel.setClient(clientField.getText()); - AppPrefsModel.setEditor(editorField.getText()); + AppPreferencesModel.setServer(serverField.getText()); + AppPreferencesModel.setClient(clientField.getText()); + AppPreferencesModel.setEditor(editorField.getText()); } /** @@ -110,9 +110,9 @@ */ @Override public void revert() { - serverField.setText(appPrefsModel.getServer()); - clientField.setText(appPrefsModel.getClient()); - editorField.setText(appPrefsModel.getEditor()); + serverField.setText(appPreferencesModel.getServer()); + clientField.setText(appPreferencesModel.getClient()); + editorField.setText(appPreferencesModel.getEditor()); } /** @@ -120,9 +120,9 @@ */ @Override public void defaults() { - serverField.setText(appPrefsModel.getServerDefault()); - clientField.setText(appPrefsModel.getClientDefault()); - editorField.setText(appPrefsModel.getEditorDefault()); + serverField.setText(appPreferencesModel.getServerDefault()); + clientField.setText(appPreferencesModel.getClientDefault()); + editorField.setText(appPreferencesModel.getEditorDefault()); } /** @@ -130,7 +130,7 @@ */ @Override public boolean isChanged() { - return !(serverField.getText().equals(appPrefsModel.getServer()) && clientField.getText().equals(appPrefsModel.getClient()) && editorField.getText().equals(appPrefsModel.getEditor())); + return !(serverField.getText().equals(appPreferencesModel.getServer()) && clientField.getText().equals(appPreferencesModel.getClient()) && editorField.getText().equals(appPreferencesModel.getEditor())); } /** @@ -142,9 +142,9 @@ final PreferencesHelper preferencesHelper = new PreferencesHelper(panel); panel.setBorder(createTitledBorder("optionsApps")); - serverField = preferencesHelper.createFileField("optionsAppServer", appPrefsModel.getServer(), JFileChooser.FILES_ONLY); - clientField = preferencesHelper.createFileField("optionsAppClient", appPrefsModel.getClient(), JFileChooser.FILES_ONLY); - editorField = preferencesHelper.createFileField("optionsAppEditor", appPrefsModel.getEditor(), JFileChooser.FILES_ONLY); + serverField = preferencesHelper.createFileField("optionsAppServer", appPreferencesModel.getServer(), JFileChooser.FILES_ONLY); + clientField = preferencesHelper.createFileField("optionsAppClient", appPreferencesModel.getClient(), JFileChooser.FILES_ONLY); + editorField = preferencesHelper.createFileField("optionsAppEditor", appPreferencesModel.getEditor(), JFileChooser.FILES_ONLY); return panel; } Deleted: trunk/src/app/net/sf/gridarta/gui/prefs/AppPrefsModel.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/prefs/AppPrefsModel.java 2010-05-24 21:42:37 UTC (rev 7990) +++ trunk/src/app/net/sf/gridarta/gui/prefs/AppPrefsModel.java 2010-05-24 21:55:36 UTC (rev 7991) @@ -1,161 +0,0 @@ -/* - * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. - * Copyright (C) 2000-2010 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.prefs; - -import java.util.prefs.Preferences; -import net.sf.gridarta.MainControl; -import net.sf.gridarta.model.io.PathManager; -import org.jetbrains.annotations.NotNull; - -/** - * Maintains the application preferences state. - * @author Andreas Kirschbaum - */ -public class AppPrefsModel { - - /** - * Preferences key for server application. - */ - private static final String PREFS_APP_SERVER = "appServer"; - - /** - * Preferences key for client application. - */ - private static final String PREFS_APP_CLIENT = "appClient"; - - /** - * Preferences key for editor application. - */ - private static final String PREFS_APP_EDITOR = "appEditor"; - - /** - * Preferences. - */ - private static final Preferences PREFS = Preferences.userNodeForPackage(MainControl.class); - - /** - * The default value for the server setting. - */ - @NotNull - private final String serverDefault; - - /** - * The default value for the client setting. - */ - @NotNull - private final String clientDefault; - - /** - * The default value for the editor setting. - */ - @NotNull - private final String editorDefault; - - /** - * Creates a new instance. - * @param serverDefault the default value for the server setting - * @param clientDefault the default value for the client setting - * @param editorDefault the default value for the editor setting - */ - public AppPrefsModel(@NotNull final String serverDefault, @NotNull final String clientDefault, @NotNull final String editorDefault) { - this.serverDefault = serverDefault; - this.clientDefault = clientDefault; - this.editorDefault = editorDefault; - } - - /** - * Sets the server setting. - * @param server the server setting - */ - public static void setServer(@NotNull final String server) { - PREFS.put(PREFS_APP_SERVER, PathManager.path(server)); - } - - /** - * Sets the client setting. - * @param client the client setting - */ - public static void setClient(@NotNull final String client) { - PREFS.put(PREFS_APP_CLIENT, PathManager.path(client)); - } - - /** - * Sets the editor setting. - * @param editor the editor setting - */ - public static void setEditor(@NotNull final String editor) { - PREFS.put(PREFS_APP_EDITOR, PathManager.path(editor)); - } - - /** - * Returns the server setting. - * @return the server setting - */ - @NotNull - public String getServer() { - return PREFS.get(PREFS_APP_SERVER, serverDefault); - } - - /** - * Returns the client setting. - * @return the client setting - */ - @NotNull - public String getClient() { - return PREFS.get(PREFS_APP_CLIENT, clientDefault); - } - - /** - * Returns the editor setting. - * @return the editor setting - */ - @NotNull - public String getEditor() { - return PREFS.get(PREFS_APP_EDITOR, editorDefault); - } - - /** - * Returns the server setting's default value. - * @return the server setting's default value - */ - @NotNull - public String getServerDefault() { - return serverDefault; - } - - /** - * Returns the client setting's default value. - * @return the client setting's default value - */ - @NotNull - public String getClientDefault() { - return clientDefault; - } - - /** - * Returns the editor setting's default value. - * @return the editor setting's default value - */ - @NotNull - public String getEditorDefault() { - return editorDefault; - } - -} // class AppPrefsModel Modified: trunk/src/app/net/sf/gridarta/maincontrol/EditorFactory.java =================================================================== --- trunk/src/app/net/sf/gridarta/maincontrol/EditorFactory.java 2010-05-24 21:42:37 UTC (rev 7990) +++ trunk/src/app/net/sf/gridarta/maincontrol/EditorFactory.java 2010-05-24 21:55:36 UTC (rev 7991) @@ -26,7 +26,7 @@ import net.sf.gridarta.gui.map.renderer.RendererFactory; import net.sf.gridarta.gui.mappropertiesdialog.MapPropertiesDialogFactory; import net.sf.gridarta.gui.newmap.NewMapDialogFactory; -import net.sf.gridarta.gui.prefs.AppPrefsModel; +import net.sf.gridarta.gui.prefs.AppPreferencesModel; import net.sf.gridarta.gui.scripts.ScriptArchDataUtils; import net.sf.gridarta.gui.scripts.ScriptedEventEditor; import net.sf.gridarta.mapmanager.AbstractMapManager; @@ -109,7 +109,7 @@ * @param numberSpells the number spells to use * @param gameObjectSpells the game object spells to use * @param attributeRangeChecker the attribute range checker to use - * @param pluginParameterFactory the plugin parameter factoy to use + * @param pluginParameterFactory the plugin parameter factory to use * @return the new instance */ @NotNull @@ -119,7 +119,7 @@ * Returns the offset for drawing double faces. * @return the offset */ - int getDoubleFaceOffest(); + int getDoubleFaceOffset(); /** * Creates a new {@link MapArchObjectFactory} instance. @@ -219,7 +219,7 @@ * @param mapValidators the map validators that delegates to add to * @param errorViewCollector the error view collector to use * @param globalSettings the global settings instance - * @param gameObjectMatchers the defined game object machers + * @param gameObjectMatchers the defined game object matchers * @param attributeRangeChecker the attribute range checker to use */ void initMapValidators(@NotNull DelegatingMapValidator<G, A, R> mapValidators, @NotNull ErrorViewCollector errorViewCollector, @NotNull GlobalSettings globalSettings, @NotNull GameObjectMatchers gameObjectMatchers, @NotNull AttributeRangeChecker<G, A, R> attributeRangeChecker); @@ -297,11 +297,11 @@ MapViewFactory<G, A, R> newMapViewFactory(@NotNull RendererFactory<G, A, R> rendererFactory, @NotNull PathManager pathManager); /** - * Creates a new {@link AppPrefsModel} instance. + * Creates a new {@link AppPreferencesModel} instance. * @return the new instance */ @NotNull - AppPrefsModel createAppPrefsModel(); + AppPreferencesModel createAppPreferencesModel(); /** * Creates a new {@link MapPropertiesDialogFactory} instance. @@ -333,13 +333,13 @@ * Creates a new {@link PreferencesGroup} instance. * @param globalSettings the global settings to use * @param validators the validators to use - * @param appPrefsModel the app prefs model to use - * @param exitConnectorModel the exit eonnector model to use + * @param appPreferencesModel the app preferences model to use + * @param exitConnectorModel the exit connector model to use * @param configSourceFactory the config source factory to use * @return the new instance */ @NotNull - PreferencesGroup createPreferencesGroup(@NotNull GlobalSettings globalSettings, @NotNull DelegatingMapValidator<G, A, R> validators, @NotNull AppPrefsModel appPrefsModel, @NotNull ExitConnectorModel exitConnectorModel, @NotNull ConfigSourceFactory configSourceFactory); + PreferencesGroup createPreferencesGroup(@NotNull GlobalSettings globalSettings, @NotNull DelegatingMapValidator<G, A, R> validators, @NotNull AppPreferencesModel appPreferencesModel, @NotNull ExitConnectorModel exitConnectorModel, @NotNull ConfigSourceFactory configSourceFactory); /** * Creates a new {@link GUIMainControl} instance. Modified: trunk/src/app/net/sf/gridarta/maincontrol/GUIMainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/maincontrol/GUIMainControl.java 2010-05-24 21:42:37 UTC (rev 7990) +++ trunk/src/app/net/sf/gridarta/maincontrol/GUIMainControl.java 2010-05-24 21:55:36 UTC (rev 7991) @@ -93,7 +93,7 @@ import net.sf.gridarta.gui.objectchooser.DefaultObjectChooser; import net.sf.gridarta.gui.pickmapchooser.PickmapChooserControl; import net.sf.gridarta.gui.pickmapchooser.PickmapChooserModel; -import net.sf.gridarta.gui.prefs.AppPrefsModel; +import net.sf.gridarta.gui.prefs.AppPreferencesModel; import net.sf.gridarta.gui.replacedialog.ReplaceDialogManager; import net.sf.gridarta.gui.script.ScriptController; import net.sf.gridarta.gui.script.parameter.PluginParameterViewFactory; @@ -296,10 +296,10 @@ private PreferencesGroup prefsGroup = null; /** - * The {@link AppPrefsModel} instance. + * The {@link AppPreferencesModel} instance. */ @NotNull - private final AppPrefsModel appPrefsModel; + private final AppPreferencesModel appPreferencesModel; /** * Client Control Component. @@ -402,7 +402,7 @@ imageCreator = new ImageCreator<G, A, R>(mapManager, rendererFactory); final ImageCreator2<G, A, R> imageCreator2 = new ImageCreator2<G, A, R>(globalSettings, imageCreator); spellUtils = spellFile != null ? new SpellsUtils(spellFile) : null; - appPrefsModel = editorFactory.createAppPrefsModel(); + appPreferencesModel = editorFactory.createAppPreferencesModel(); final MapViewManager<G, A, R> mapViewManager = new MapViewManager<G, A, R>(); statusBar = new StatusBar<G, A, R>(mapManager, mapViewManager, archetypeSet, faceObjects); final MapImageCache<G, A, R> mapImageCache = new MapImageCache<G, A, R>(mapManager, systemIcons.getDefaultIcon(), systemIcons.getDefaultPreview(), rendererFactory, cacheFiles); @@ -616,7 +616,7 @@ @ActionMethod public void options() { if (prefsGroup == null) { - prefsGroup = editorFactory.createPreferencesGroup(globalSettings, validators, appPrefsModel, exitConnectorModel, configSourceFactory); + prefsGroup = editorFactory.createPreferencesGroup(globalSettings, validators, appPreferencesModel, exitConnectorModel, configSourceFactory); } PreferencesPane.showPreferencesDialog(mainViewFrame, prefsGroup, false); } @@ -681,10 +681,10 @@ @ActionMethod public void controlServer() { if (controlServer == null) { - controlServer = new ProcessRunner("controlServer", appPrefsModel.getServer()); + controlServer = new ProcessRunner("controlServer", appPreferencesModel.getServer()); ACTION_BUILDER.showOnetimeMessageDialog(mainViewFrame, JOptionPane.WARNING_MESSAGE, "controlServerWarning"); } else { - controlServer.setCommand(appPrefsModel.getServer()); + controlServer.setCommand(appPreferencesModel.getServer()); } controlServer.showDialog(mainViewFrame); } @@ -695,9 +695,9 @@ @ActionMethod public void controlClient() { if (controlClient == null) { - controlClient = new ProcessRunner("controlClient", appPrefsModel.getClient()); + controlClient = new ProcessRunner("controlClient", appPreferencesModel.getClient()); } else { - controlClient.setCommand(appPrefsModel.getClient()); + controlClient.setCommand(appPreferencesModel.getClient()); } controlClient.showDialog(mainViewFrame); } Modified: trunk/src/app/net/sf/gridarta/maincontrol/GridartaEditor.java =================================================================== --- trunk/src/app/net/sf/gridarta/maincontrol/GridartaEditor.java 2010-05-24 21:42:37 UTC (rev 7990) +++ trunk/src/app/net/sf/gridarta/maincontrol/GridartaEditor.java 2010-05-24 21:55:36 UTC (rev 7991) @@ -227,7 +227,7 @@ final ArchFaceProvider archFaceProvider = new ArchFaceProvider(); final FaceObjects faceObjects = editorFactory.createFaceObjects(archFaceProvider); editorFactory.initSmoothFaces(faceObjects); - final int doubleFaceOffset = editorFactory.getDoubleFaceOffest(); + final int doubleFaceOffset = editorFactory.getDoubleFaceOffset(); final FaceObjectProviders faceObjectProviders = new FaceObjectProviders(doubleFaceOffset, faceObjects, systemIcons); final ArchetypeTypeSet archetypeTypeSet = new ArchetypeTypeSet(); final AnimationObjects animationObjects = editorFactory.newAnimationObjects(); Modified: trunk/src/app/net/sf/gridarta/model/archetypetype/ArchetypeAttributeFactory.java =================================================================== --- trunk/src/app/net/sf/gridarta/model/archetypetype/ArchetypeAttributeFactory.java 2010-05-24 21:42:37 UTC (rev 7990) +++ trunk/src/app/net/sf/gridarta/model/archetypetype/ArchetypeAttributeFactory.java 2010-05-24 21:55:36 UTC (rev 7991) @@ -254,7 +254,7 @@ ArchetypeAttribute newArchetypeAttributeTreasure(@NotNull String archetypeAttributeName, @NotNull String attributeName, @NotNull String description, int inputLength, @NotNull String sectionName); /** - * Creates a new "zspell" archetype attribute. + * Creates a new "z-spell" archetype attribute. * @param archetypeAttributeName the archetype attribute name * @param attributeName the user interface attribute name * @param description the attribute's description Modified: trunk/src/app/net/sf/gridarta/model/archetypetype/ArchetypeAttributes.java =================================================================== --- trunk/src/app/net/sf/gridarta/model/archetypetype/ArchetypeAttributes.java 2010-05-24 21:42:37 UTC (rev 7990) +++ trunk/src/app/net/sf/gridarta/model/archetypetype/ArchetypeAttributes.java 2010-05-24 21:55:36 UTC (rev 7991) @@ -64,7 +64,7 @@ /** * Returns whether no {@link ArchetypeAttribute ArchetypeAttributes} exist. - * @return wether no archetype attributes exist + * @return whether no archetype attributes exist */ public boolean isEmpty() { return archetypeAttributes.isEmpty(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-05-25 16:30:08
|
Revision: 7999 http://gridarta.svn.sourceforge.net/gridarta/?rev=7999&view=rev Author: akirschbaum Date: 2010-05-25 16:30:00 +0000 (Tue, 25 May 2010) Log Message: ----------- Cleanup parser for/document <type> and <default_type> elements within types.xml. Modified Paths: -------------- trunk/resource/system/dtd/types.dtd trunk/src/app/net/sf/gridarta/model/archetypetype/ArchetypeAttributeParser.java trunk/src/app/net/sf/gridarta/model/archetypetype/ArchetypeTypeParser.java trunk/src/app/net/sf/gridarta/model/archetypetype/ArchetypeTypeSetParser.java Modified: trunk/resource/system/dtd/types.dtd =================================================================== --- trunk/resource/system/dtd/types.dtd 2010-05-25 07:40:59 UTC (rev 7998) +++ trunk/resource/system/dtd/types.dtd 2010-05-25 16:30:00 UTC (rev 7999) @@ -85,6 +85,8 @@ xml:base CDATA #IMPLIED > +<!-- available: the type is ignored when set to "no"; can be used to + temporarily disable type definitions. --> <!ELEMENT type (import_type?,required?,ignore?,description?,use?,(section | attribute)*)> <!ATTLIST type xml:base CDATA #IMPLIED @@ -109,6 +111,8 @@ name CDATA #REQUIRED > +<!-- type: type number; integer value --> +<!-- name: name for the type --> <!-- arch: section name to be ignored (within <ignore_list>) --> <!-- min/max: absolute allowed range; editor rejects --> <!-- check_min/check_max: recommended range; editor warns --> Modified: trunk/src/app/net/sf/gridarta/model/archetypetype/ArchetypeAttributeParser.java =================================================================== --- trunk/src/app/net/sf/gridarta/model/archetypetype/ArchetypeAttributeParser.java 2010-05-25 07:40:59 UTC (rev 7998) +++ trunk/src/app/net/sf/gridarta/model/archetypetype/ArchetypeAttributeParser.java 2010-05-25 16:30:00 UTC (rev 7999) @@ -92,7 +92,7 @@ * @param typeName (descriptive) name of the type this attribute belongs to * (e.g. "Weapon") * @param sectionName the section name for the new attribute - * @return the archetype attribute + * @return the archetype attribute or <code>null</code> if an error occurs * @throws MissingAttributeException if the element cannot be parsed */ @Nullable Modified: trunk/src/app/net/sf/gridarta/model/archetypetype/ArchetypeTypeParser.java =================================================================== --- trunk/src/app/net/sf/gridarta/model/archetypetype/ArchetypeTypeParser.java 2010-05-25 07:40:59 UTC (rev 7998) +++ trunk/src/app/net/sf/gridarta/model/archetypetype/ArchetypeTypeParser.java 2010-05-25 16:30:00 UTC (rev 7999) @@ -22,7 +22,6 @@ import java.util.Collection; import java.util.HashSet; import java.util.Iterator; -import java.util.Set; import net.sf.gridarta.model.errorview.ErrorViewCategory; import net.sf.gridarta.model.errorview.ErrorViewCollector; import net.sf.japi.xml.NodeListIterator; @@ -44,33 +43,69 @@ * Attribute Element Name. */ @NotNull - public static final String XML_ATTRIBUTE = "attribute"; + public static final String XML_ELEMENT_ATTRIBUTE = "attribute"; /** * Required Element Name. */ @NotNull - private static final String XML_REQUIRED = "required"; + private static final String XML_ELEMENT_REQUIRED = "required"; /** * Ignore Element Name. */ @NotNull - private static final String XML_IGNORE = "ignore"; + private static final String XML_ELEMENT_IGNORE = "ignore"; /** + * Ignore List Element Name. + */ + @NotNull + private static final String XML_ELEMENT_IGNORE_LIST = "ignore_list"; + + /** * Import Type Element Name. */ @NotNull - private static final String XML_IMPORT_TYPE = "import_type"; + private static final String XML_ELEMENT_IMPORT_TYPE = "import_type"; /** - * Value Element Name. + * Section Element Name. */ @NotNull - private static final String XML_VALUE = "value"; + private static final String XML_ELEMENT_SECTION = "section"; /** + * The "arch" attribute name of a {@link #XML_ELEMENT_ATTRIBUTE} element. + */ + @NotNull + public static final String XML_ATTRIBUTE_ARCH = "arch"; + + /** + * The "value" attribute name of a {@link #XML_ELEMENT_ATTRIBUTE} element. + */ + @NotNull + private static final String XML_ATTRIBUTE_VALUE = "value"; + + /** + * The "name" attribute name of a {@link #XML_ELEMENT_IGNORE_LIST} element. + */ + @NotNull + private static final String XML_IGNORE_LIST_NAME = "name"; + + /** + * The "name" attribute name of a {@link #XML_ELEMENT_IMPORT_TYPE} element. + */ + @NotNull + private static final String XML_IMPORT_TYPE_NAME = "name"; + + /** + * The "name" attribute name of a {@link #XML_ELEMENT_SECTION} element. + */ + @NotNull + private static final String XML_SECTION_NAME = "name"; + + /** * Description Element Name. */ @NotNull @@ -83,12 +118,6 @@ private static final String XML_USE = "use"; /** - * Section Element Name. - */ - @NotNull - private static final String XML_SECTION = "section"; - - /** * The parser to use. */ @NotNull @@ -103,42 +132,41 @@ } /** - * 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. + * Parses an element which contains a list of <attribute> elements + * from a types.xml file. + * @param typeElement the xml 'type' element which is going to be parsed * @param errorViewCollector the error view collector for reporting errors * @param parent the parent archetype type - * @param root the xml 'type' element which is going to be parsed * @param archetypeTypeSet archetype type list * @param ignorelistsDefinition the ignore_lists contents + * @param isDefaultType whether this element is the "default_type" * @return the archetype type or <code>null</code> * @todo I'm sucking slow, improve me */ @NotNull - public ArchetypeType load(@NotNull final ErrorViewCollector errorViewCollector, @Nullable final ArchetypeType parent, @NotNull final Element root, @NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final IgnorelistsDefinition ignorelistsDefinition) { - final boolean isDefaultType = root.getNodeName().equals("default_type"); - final String typeName = parseTypeName(root, isDefaultType); - final Set<String> ignoreTable = new HashSet<String>(); - final int typeNo = parseTypeNo(root, isDefaultType, typeName, errorViewCollector); - final ArchetypeAttributesDefinition typeAttributes = parseTypeAttributes(root, isDefaultType, typeName, typeNo, errorViewCollector, ignoreTable, ignorelistsDefinition); - final String importName = parseImportName(root, typeName, errorViewCollector); + public ArchetypeType loadAttributeList(@NotNull final Element typeElement, @NotNull final ErrorViewCollector errorViewCollector, @Nullable final ArchetypeType parent, @NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final IgnorelistsDefinition ignorelistsDefinition, final boolean isDefaultType) { + final String typeName = parseTypeName(typeElement, isDefaultType); + final int typeNo = parseTypeNo(typeElement, isDefaultType, typeName, errorViewCollector); + final Collection<String> ignoreTable = new HashSet<String>(); + final ArchetypeAttributesDefinition typeAttributes = isDefaultType ? new ArchetypeAttributesDefinition() : parseTypeAttributes(typeElement, typeName, errorViewCollector, ignoreTable, ignorelistsDefinition); + final String importType = parseImportType(typeElement, typeName, errorViewCollector); final ArchetypeAttributes attributes = new ArchetypeAttributes(); final SectionNames sectionNames = new SectionNames(); final Collection<String> autoIgnoreTable = new HashSet<String>(); - attributes.addAll(parseAttrList(root, errorViewCollector, typeName, typeNo, sectionNames, autoIgnoreTable, archetypeTypeSet)); + attributes.addAll(parseAttributeList(typeElement, errorViewCollector, typeName, typeNo, sectionNames, autoIgnoreTable, archetypeTypeSet)); if (parent != null) { attributes.addAll(getDefaultList(parent, autoIgnoreTable, ignoreTable)); if (parent.hasAttribute()) { - attributes.addAll(importName(importName, errorViewCollector, typeName, archetypeTypeSet, autoIgnoreTable)); + attributes.addAll(importName(importType, errorViewCollector, typeName, archetypeTypeSet, autoIgnoreTable)); } } attributes.setSectionNames(sectionNames); - return new ArchetypeType(typeName, typeNo, parseDescription(root), parseUse(root), sectionNames.getSectionNames(), attributes, typeAttributes); + return new ArchetypeType(typeName, typeNo, parseDescription(typeElement), parseUse(typeElement), sectionNames.getSectionNames(), attributes, typeAttributes); } @NotNull - private ArchetypeAttributes getDefaultList(@NotNull final Iterable<ArchetypeAttribute> archetypeType, @NotNull final Collection<String> autoIgnoreTable, @NotNull final Set<String> ignoreTable) { + private ArchetypeAttributes getDefaultList(@NotNull final Iterable<ArchetypeAttribute> archetypeType, @NotNull final Collection<String> autoIgnoreTable, @NotNull final Collection<String> ignoreTable) { final ArchetypeAttributes defaultList = new ArchetypeAttributes(); for (final ArchetypeAttribute archetypeAttribute : archetypeType) { @@ -183,50 +211,66 @@ return importList; } + /** + * Parses the {@link #XML_ELEMENT_IMPORT_TYPE} of a "type" or "default_type" + * {@link Element}. + * @param typeElement the element + * @param typeName the type name for error messages + * @param errorViewCollector the error view collector for error messages + * @return the import type name or <code>null</code> if no import_type is + * present or an error occurs + */ @Nullable - private static String parseImportName(@NotNull final Element root, @NotNull final String typeName, @NotNull final ErrorViewCollector errorViewCollector) { - final Element elem = NodeListIterator.getFirstChild(root, XML_IMPORT_TYPE); - if (elem == null) { + private static String parseImportType(@NotNull final Element typeElement, @NotNull final String typeName, @NotNull final ErrorViewCollector errorViewCollector) { + final Element importTypeElement = NodeListIterator.getFirstChild(typeElement, XML_ELEMENT_IMPORT_TYPE); + if (importTypeElement == null) { return null; } - final Attr a1 = elem.getAttributeNode("name"); - if (a1 == null) { - errorViewCollector.addWarning(ErrorViewCategory.TYPES_ENTRY_INVALID, "type " + typeName + " has " + XML_IMPORT_TYPE + " element without 'name'."); + final Attr nameAttribute = importTypeElement.getAttributeNode(XML_IMPORT_TYPE_NAME); + if (nameAttribute == null) { + errorViewCollector.addWarning(ErrorViewCategory.TYPES_ENTRY_INVALID, "type " + typeName + " has " + XML_ELEMENT_IMPORT_TYPE + " element without '" + XML_IMPORT_TYPE_NAME + "'."); return null; } - return a1.getValue().trim(); + final String name = nameAttribute.getValue(); + if (name.isEmpty()) { + errorViewCollector.addWarning(ErrorViewCategory.TYPES_ENTRY_INVALID, "type " + typeName + " has " + XML_ELEMENT_IMPORT_TYPE + " element with empty '" + XML_IMPORT_TYPE_NAME + "'."); + return null; + } + + return name; } /** * Parses the type name of a "type" or "default_type" {@link Element}. - * @param root the element + * @param typeElement the element * @param isDefaultType whether the element is a "default_type" * @return the type name */ @NotNull - private static String parseTypeName(@NotNull final Element root, final boolean isDefaultType) { - return isDefaultType ? "default" : root.getAttribute("name").trim(); + private static String parseTypeName(@NotNull final Element typeElement, final boolean isDefaultType) { + return isDefaultType ? "default" : typeElement.getAttribute("name").trim(); } /** * Parses the type number of a "type" or "default_type" {@link Element}. - * @param root the element + * @param typeElement the element * @param isDefaultType whether the element is a "default_type" * @param typeName the type name for error messages * @param errorViewCollector the error view collector for error messages * @return the type number */ - private static int parseTypeNo(@NotNull final Element root, final boolean isDefaultType, @NotNull final String typeName, @NotNull final ErrorViewCollector errorViewCollector) { + private static int parseTypeNo(@NotNull final Element typeElement, final boolean isDefaultType, @NotNull final String typeName, @NotNull final ErrorViewCollector errorViewCollector) { if (isDefaultType) { return -1; } + final String number = typeElement.getAttribute("number"); try { - return Integer.parseInt(root.getAttribute("number").trim()); + return Integer.parseInt(number); } catch (final NumberFormatException ignored) { - errorViewCollector.addWarning(ErrorViewCategory.TYPES_ENTRY_INVALID, "type " + typeName + " has invalid type number '" + root.getAttribute("number") + "'."); + errorViewCollector.addWarning(ErrorViewCategory.TYPES_ENTRY_INVALID, "type " + typeName + " has invalid type number '" + number + "'."); return -1; } } @@ -234,111 +278,123 @@ /** * Parses the type attributes of a "type" or "default_type" {@link * Element}. - * @param root the element - * @param isDefaultType whether the element is a "default_type" + * @param typeElement the element * @param typeName the type name for error messages - * @param typeNo the type number for error messages * @param errorViewCollector the error view collector for error messages * @param ignoreTable returns the "ignore" attributes * @param ignorelistsDefinition the defined ignore lists * @return the type attributes */ @NotNull - private static ArchetypeAttributesDefinition parseTypeAttributes(@NotNull final Element root, final boolean isDefaultType, @NotNull final String typeName, final int typeNo, @NotNull final ErrorViewCollector errorViewCollector, @NotNull final Set<String> ignoreTable, @NotNull final IgnorelistsDefinition ignorelistsDefinition) { - if (isDefaultType) { - // special case: default type (this one contains the default attributes) - return new ArchetypeAttributesDefinition(); - } + private static ArchetypeAttributesDefinition parseTypeAttributes(@NotNull final Element typeElement, @NotNull final String typeName, @NotNull final ErrorViewCollector errorViewCollector, @NotNull final Collection<String> ignoreTable, @NotNull final IgnorelistsDefinition ignorelistsDefinition) { + final ArchetypeAttributesDefinition typeAttributes = parseRequiredAttribute(typeElement, typeName, errorViewCollector); - final ArchetypeAttributesDefinition typeAttributes = parseRequiredAttribute(root, typeName, errorViewCollector); - - // parse 'ignore' elements - final Element ignoreElement = NodeListIterator.getFirstChild(root, XML_IGNORE); + final Element ignoreElement = NodeListIterator.getFirstChild(typeElement, XML_ELEMENT_IGNORE); if (ignoreElement != null) { - // load all attributes in the ignore section - parseAttributeAttributes(typeName, errorViewCollector, ignoreTable, ignoreElement); - - // load attributes from ignore lists - parseIgnoreListAttribute(typeName, errorViewCollector, ignoreTable, ignorelistsDefinition, ignoreElement); + parseAttributeAttributes(ignoreElement, typeName, errorViewCollector, ignoreTable); + parseIgnoreListAttribute(ignoreElement, typeName, errorViewCollector, ignoreTable, ignorelistsDefinition); } return typeAttributes; } /** - * Parses the {@link #XML_REQUIRED} child. - * @param root the root element + * Parses the {@link #XML_ELEMENT_REQUIRED} child. + * @param typeElement the root element * @param typeName the type name * @param errorViewCollector the error view collector for error messages * @return the type definitions */ @NotNull - private static ArchetypeAttributesDefinition parseRequiredAttribute(@NotNull final Element root, @NotNull final String typeName, @NotNull final ErrorViewCollector errorViewCollector) { + private static ArchetypeAttributesDefinition parseRequiredAttribute(@NotNull final Element typeElement, @NotNull final String typeName, @NotNull final ErrorViewCollector errorViewCollector) { final ArchetypeAttributesDefinition attributes = new ArchetypeAttributesDefinition(); - final Element required = NodeListIterator.getFirstChild(root, XML_REQUIRED); - if (required != null) { - final Iterator<Element> it = new NodeListIterator<Element>(required, XML_ATTRIBUTE); + final Element requiredElement = NodeListIterator.getFirstChild(typeElement, XML_ELEMENT_REQUIRED); + if (requiredElement != null) { + final Iterator<Element> it = new NodeListIterator<Element>(requiredElement, XML_ELEMENT_ATTRIBUTE); while (it.hasNext()) { - final Element elem = it.next(); - final Attr a1 = elem.getAttributeNode(ArchetypeAttributeParser.XML_KEY_ARCH); - final Attr a2 = elem.getAttributeNode(XML_VALUE); - if (a1 == null || a2 == null) { - errorViewCollector.addWarning(ErrorViewCategory.TYPES_ENTRY_INVALID, XML_REQUIRED + ": element of type " + typeName + ": " + XML_ATTRIBUTE + " missing '" + ArchetypeAttributeParser.XML_KEY_ARCH + "' or '" + XML_VALUE + "'."); - } else { - attributes.add(new ArchetypeAttributeDefinition(a1.getValue().trim(), a2.getValue().trim())); + final Element attributeElement = it.next(); + final Attr archAttribute = attributeElement.getAttributeNode(XML_ATTRIBUTE_ARCH); + if (archAttribute == null) { + errorViewCollector.addWarning(ErrorViewCategory.TYPES_ENTRY_INVALID, XML_ELEMENT_REQUIRED + ": element of type " + typeName + ": " + XML_ELEMENT_ATTRIBUTE + " missing '" + XML_ATTRIBUTE_ARCH + "'."); + continue; } + final String arch = archAttribute.getValue(); + if (arch.isEmpty()) { + errorViewCollector.addWarning(ErrorViewCategory.TYPES_ENTRY_INVALID, XML_ELEMENT_REQUIRED + ": element of type " + typeName + ": " + XML_ELEMENT_ATTRIBUTE + " empty '" + XML_ATTRIBUTE_ARCH + "'."); + continue; + } + + final Attr valueAttribute = attributeElement.getAttributeNode(XML_ATTRIBUTE_VALUE); + if (valueAttribute == null) { + errorViewCollector.addWarning(ErrorViewCategory.TYPES_ENTRY_INVALID, XML_ELEMENT_REQUIRED + ": element of type " + typeName + ": " + XML_ELEMENT_ATTRIBUTE + " missing '" + XML_ATTRIBUTE_VALUE + "'."); + continue; + } + final String value = valueAttribute.getValue(); + if (value.isEmpty()) { + errorViewCollector.addWarning(ErrorViewCategory.TYPES_ENTRY_INVALID, XML_ELEMENT_REQUIRED + ": element of type " + typeName + ": " + XML_ELEMENT_ATTRIBUTE + " empty '" + XML_ATTRIBUTE_VALUE + "'."); + continue; + } + + attributes.add(new ArchetypeAttributeDefinition(arch, value)); } } return attributes; } /** - * Parses the {@link #XML_ATTRIBUTE} child. + * Parses the {@link #XML_ELEMENT_ATTRIBUTE} child. + * @param ignoreElement the ignore element to parse * @param typeName the type name for error messages * @param errorViewCollector the error view collector for error messages * @param ignoreTable the ignore table to add to - * @param ignoreElement the ignore element to parse */ - private static void parseAttributeAttributes(@NotNull final String typeName, @NotNull final ErrorViewCollector errorViewCollector, @NotNull final Set<String> ignoreTable, @NotNull final Element ignoreElement) { - final Iterator<Element> it = new NodeListIterator<Element>(ignoreElement, XML_ATTRIBUTE); + private static void parseAttributeAttributes(@NotNull final Element ignoreElement, @NotNull final String typeName, @NotNull final ErrorViewCollector errorViewCollector, @NotNull final Collection<String> ignoreTable) { + final Iterator<Element> it = new NodeListIterator<Element>(ignoreElement, XML_ELEMENT_ATTRIBUTE); while (it.hasNext()) { final Element elem = it.next(); - final Attr a1 = elem.getAttributeNode(ArchetypeAttributeParser.XML_KEY_ARCH); - if (a1 == null) { - errorViewCollector.addWarning(ErrorViewCategory.TYPES_ENTRY_INVALID, XML_IGNORE + ": section of type " + typeName + ": " + XML_ATTRIBUTE + " missing '" + ArchetypeAttributeParser.XML_KEY_ARCH + "'."); - } else { - ignoreTable.add(a1.getValue().trim()); + final Attr archAttribute = elem.getAttributeNode(XML_ATTRIBUTE_ARCH); + if (archAttribute == null) { + errorViewCollector.addWarning(ErrorViewCategory.TYPES_ENTRY_INVALID, XML_ELEMENT_IGNORE + ": section of type " + typeName + ": " + XML_ELEMENT_ATTRIBUTE + " missing '" + XML_ATTRIBUTE_ARCH + "'."); + continue; } + final String arch = archAttribute.getValue(); + if (arch.isEmpty()) { + errorViewCollector.addWarning(ErrorViewCategory.TYPES_ENTRY_INVALID, XML_ELEMENT_IGNORE + ": section of type " + typeName + ": " + XML_ELEMENT_ATTRIBUTE + " empty '" + XML_ATTRIBUTE_ARCH + "'."); + continue; + } + + ignoreTable.add(arch); } } /** * Parses the "ignore_list" children. + * @param ignoreElement the ignore element to parse * @param typeName the type name for error messages * @param errorViewCollector the error view collector for error messages * @param ignoreTable the ignore table to add to * @param ignorelistsDefinition the ignore lists to use - * @param ignoreElement the ignore element to parse */ - private static void parseIgnoreListAttribute(@NotNull final String typeName, @NotNull final ErrorViewCollector errorViewCollector, @NotNull final Set<String> ignoreTable, @NotNull final IgnorelistsDefinition ignorelistsDefinition, @NotNull final Element ignoreElement) { - final Iterator<Element> it2 = new NodeListIterator<Element>(ignoreElement, "ignore_list"); + private static void parseIgnoreListAttribute(@NotNull final Element ignoreElement, @NotNull final String typeName, @NotNull final ErrorViewCollector errorViewCollector, @NotNull final Collection<String> ignoreTable, @NotNull final IgnorelistsDefinition ignorelistsDefinition) { + final Iterator<Element> it2 = new NodeListIterator<Element>(ignoreElement, XML_ELEMENT_IGNORE_LIST); while (it2.hasNext()) { final Element elem = it2.next(); - final Attr a1 = elem.getAttributeNode("name"); - if (a1 == null) { - errorViewCollector.addWarning(ErrorViewCategory.TYPES_ENTRY_INVALID, XML_IGNORE + ": section of type " + typeName + ": ignore_list missing 'name'."); - } else { - final String name = a1.getValue().trim(); - final Iterable<String> ignoreList = ignorelistsDefinition.get(name); - if (ignoreList != null) { - // just copy everything from ignore list to this ignore section - for (final String ignItem : ignoreList) { - ignoreTable.add(ignItem); - } - } else { - errorViewCollector.addWarning(ErrorViewCategory.TYPES_ENTRY_INVALID, XML_IGNORE + ": section of type " + typeName + ": ignore_list with name \"" + a1.getValue() + "\" is undefined."); - } + final Attr nameAttribute = elem.getAttributeNode(XML_IGNORE_LIST_NAME); + if (nameAttribute == null) { + errorViewCollector.addWarning(ErrorViewCategory.TYPES_ENTRY_INVALID, XML_ELEMENT_IGNORE + ": section of type " + typeName + ": ignore_list missing '" + XML_IGNORE_LIST_NAME + "'."); + continue; } + + final String name = nameAttribute.getValue(); + final Iterable<String> ignoreList = ignorelistsDefinition.get(name); + if (ignoreList == null) { + errorViewCollector.addWarning(ErrorViewCategory.TYPES_ENTRY_INVALID, XML_ELEMENT_IGNORE + ": section of type " + typeName + ": ignore_list with name \"" + name + "\" is undefined."); + continue; + } + + for (final String ignoreItem : ignoreList) { + ignoreTable.add(ignoreItem); + } } } @@ -366,80 +422,105 @@ } /** - * Parses an XML attribute element. If parsing succeeds, the new {@link - * ArchetypeAttribute} is added to the temporary linked list provided by the - * parameters (see below). Assignment of sections to attributes also happens - * in this method. + * Parses the {@link #XML_ELEMENT_ATTRIBUTE} and {@link + * #XML_ELEMENT_SECTION} children of a "type" or "default_type" element. + * @param typeElement the type element to parse * @param errorViewCollector the error view collector for reporting errors - * @param typeName the archetype type's name - * @param typeNo the archetype type's type number - * @param elem the XML attribute element + * @param typeName the type name of the element being parsed + * @param typeNo the type number of the element being parsed * @param sectionNames the defined section names - * @param inSection true if this attribute belongs to a (custom-defined) - * section - * @param section name of the section (only relevant if 'inSection'==true) - * @param archetypeTypeSet arch type list - * @return the parsed attribute or <code>null</code> if an error occurs + * @param archetypeTypeSet archetype type list + * @return the archetype type or <code>null</code> */ - @Nullable - private ArchetypeAttribute parseAttribute(@NotNull final ErrorViewCollector errorViewCollector, @NotNull final String typeName, final int typeNo, final Element elem, final SectionNames sectionNames, final boolean inSection, final String section, final ArchetypeTypeSet archetypeTypeSet) { - final ArchetypeAttribute archetypeAttribute; - try { - archetypeAttribute = archetypeAttributeParser.load(errorViewCollector, elem, archetypeTypeSet, typeName, inSection ? section : typeNo == -1 ? SectionNames.GENERAL_SECTION : SectionNames.SPECIAL_SECTION); - } catch (final MissingAttributeException ex) { - errorViewCollector.addWarning(ErrorViewCategory.TYPES_ENTRY_INVALID, "type " + typeName + ": " + ex.getMessage()); - return null; - } - - if (archetypeAttribute != null) { - sectionNames.defineSectionName(archetypeAttribute.getSectionName()); - } - return archetypeAttribute; - } - @NotNull - private ArchetypeAttributes parseAttrList(@NotNull final Element root, @NotNull final ErrorViewCollector errorViewCollector, @NotNull final String typeName, final int typeNo, @NotNull final SectionNames sectionNames, @NotNull final Collection<String> autoIgnoreTable, @NotNull final ArchetypeTypeSet archetypeTypeSet) { - final ArchetypeAttributes attributeList = new ArchetypeAttributes(); + private ArchetypeAttributes parseAttributeList(@NotNull final Element typeElement, @NotNull final ErrorViewCollector errorViewCollector, @NotNull final String typeName, final int typeNo, @NotNull final SectionNames sectionNames, @NotNull final Collection<String> autoIgnoreTable, @NotNull final ArchetypeTypeSet archetypeTypeSet) { + final ArchetypeAttributes archetypeAttributes = new ArchetypeAttributes(); - // now get all children and process them in order: - final Iterator<Element> it = new NodeListIterator<Element>(root, Node.ELEMENT_NODE); + final Iterator<Element> it = new NodeListIterator<Element>(typeElement, Node.ELEMENT_NODE); while (it.hasNext()) { - final Element elem = it.next(); - // attribute directly in type element - if (elem.getNodeName().equals(XML_ATTRIBUTE)) { - parseAttr(errorViewCollector, typeName, typeNo, elem, sectionNames, null, archetypeTypeSet, attributeList, autoIgnoreTable); + final Element node = it.next(); + final String nodeName = node.getNodeName(); + + if (nodeName.equals(XML_ELEMENT_ATTRIBUTE)) { + parseAttribute(node, errorViewCollector, typeName, typeNo, sectionNames, null, archetypeTypeSet, archetypeAttributes, autoIgnoreTable); } - // attributes in a section - if (elem.getNodeName().equals(XML_SECTION) && elem.hasChildNodes()) { - final Attr a1 = elem.getAttributeNode("name"); - if (a1 == null) { - errorViewCollector.addWarning(ErrorViewCategory.TYPES_ENTRY_INVALID, "type " + typeName + " contains a " + XML_SECTION + " missing 'name'."); + if (nodeName.equals(XML_ELEMENT_SECTION) && node.hasChildNodes()) { + final Attr nameAttribute = node.getAttributeNode(XML_SECTION_NAME); + if (nameAttribute == null) { + errorViewCollector.addWarning(ErrorViewCategory.TYPES_ENTRY_INVALID, "type " + typeName + " contains a " + XML_ELEMENT_SECTION + " missing '" + XML_SECTION_NAME + "'."); continue; } - final String sectionName = a1.getValue().trim(); + final String sectionName = nameAttribute.getValue(); + if (sectionName.isEmpty()) { + errorViewCollector.addWarning(ErrorViewCategory.TYPES_ENTRY_INVALID, "type " + typeName + " contains a " + XML_ELEMENT_SECTION + " with empty '" + XML_SECTION_NAME + "'."); + continue; + } + sectionNames.defineSectionName(sectionName); - // parse all attributes in the section - final Iterator<Element> it2 = new NodeListIterator<Element>(elem, XML_ATTRIBUTE); + final Iterator<Element> it2 = new NodeListIterator<Element>(node, XML_ELEMENT_ATTRIBUTE); while (it2.hasNext()) { - final Element elem2 = it2.next(); - // got an attribute element possibly in a section - parseAttr(errorViewCollector, typeName, typeNo, elem2, sectionNames, sectionName, archetypeTypeSet, attributeList, autoIgnoreTable); + parseAttribute(it2.next(), errorViewCollector, typeName, typeNo, sectionNames, sectionName, archetypeTypeSet, archetypeAttributes, autoIgnoreTable); } } } - return attributeList; + return archetypeAttributes; } - private void parseAttr(@NotNull final ErrorViewCollector errorViewCollector, @NotNull final String typeName, final int typeNo, @NotNull final Element elem, @NotNull final SectionNames sectionNames, @Nullable final String section, @NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final ArchetypeAttributes attrList, @NotNull final Collection<String> autoIgnoreTable) { - final ArchetypeAttribute archetypeAttribute = parseAttribute(errorViewCollector, typeName, typeNo, elem, sectionNames, section != null, section, archetypeTypeSet); + /** + * Parses an {@link #XML_ELEMENT_ATTRIBUTE} element. + * @param attributeElement the attribute element to parse + * @param errorViewCollector the error view collector for reporting errors + * @param typeName the type name of the element being parsed + * @param typeNo the type number of the element being parsed + * @param sectionNames the defined section names + * @param sectionName the section name or <code>null</code> for top-level + * attributes + * @param archetypeTypeSet archetype type list + */ + private void parseAttribute(@NotNull final Element attributeElement, @NotNull final ErrorViewCollector errorViewCollector, @NotNull final String typeName, final int typeNo, @NotNull final SectionNames sectionNames, @Nullable final String sectionName, @NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final ArchetypeAttributes archetypeAttributes, @NotNull final Collection<String> autoIgnoreTable) { + final ArchetypeAttribute archetypeAttribute = parseAttribute(attributeElement, errorViewCollector, typeName, typeNo, sectionName, archetypeTypeSet); if (archetypeAttribute != null) { - attrList.add(archetypeAttribute); + sectionNames.defineSectionName(archetypeAttribute.getSectionName()); + archetypeAttributes.add(archetypeAttribute); autoIgnoreTable.add(archetypeAttribute.getArchetypeAttributeName()); } } + /** + * Parses an XML attribute element. If parsing succeeds, the new {@link + * ArchetypeAttribute} is added to the temporary linked list provided by the + * parameters (see below). Assignment of sections to attributes also happens + * in this method. + * @param attributeElement the XML attribute element + * @param errorViewCollector the error view collector for reporting errors + * @param typeName the archetype type's name + * @param typeNo the archetype type's type number + * @param sectionName name of the section or <code>null</code> for top-level + * attribute definitions + * @param archetypeTypeSet arch type list + * @return the parsed attribute or <code>null</code> if an error occurs + */ + @Nullable + private ArchetypeAttribute parseAttribute(@NotNull final Element attributeElement, @NotNull final ErrorViewCollector errorViewCollector, @NotNull final String typeName, final int typeNo, @Nullable final String sectionName, @NotNull final ArchetypeTypeSet archetypeTypeSet) { + final String effectiveSectionName; + if (sectionName != null) { + effectiveSectionName = sectionName; + } else if (typeNo == -1) { + effectiveSectionName = SectionNames.GENERAL_SECTION; + } else { + effectiveSectionName = SectionNames.SPECIAL_SECTION; + } + + try { + return archetypeAttributeParser.load(errorViewCollector, attributeElement, archetypeTypeSet, typeName, effectiveSectionName); + } catch (final MissingAttributeException ex) { + errorViewCollector.addWarning(ErrorViewCategory.TYPES_ENTRY_INVALID, "type " + typeName + ": " + ex.getMessage()); + return null; + } + } + } // class ArchetypeTypeParser Modified: trunk/src/app/net/sf/gridarta/model/archetypetype/ArchetypeTypeSetParser.java =================================================================== --- trunk/src/app/net/sf/gridarta/model/archetypetype/ArchetypeTypeSetParser.java 2010-05-25 07:40:59 UTC (rev 7998) +++ trunk/src/app/net/sf/gridarta/model/archetypetype/ArchetypeTypeSetParser.java 2010-05-25 16:30:00 UTC (rev 7999) @@ -46,6 +46,25 @@ public class ArchetypeTypeSetParser { /** + * The name of the "default_type" element. + */ + @NotNull + private static final String XML_ELEMENT_DEFAULT_TYPE = "default_type"; + + /** + * The name of the "type" element. + */ + @NotNull + private static final String XML_ELEMENT_TYPE = "type"; + + /** + * The name of the "available" attribute within {@link #XML_ELEMENT_TYPE} + * elements. + */ + @NotNull + private static final String XML_TYPE_AVAILABLE = "available"; + + /** * The logger for printing log messages. */ @NotNull @@ -119,13 +138,20 @@ */ public void loadTypesFromXML(@NotNull final ErrorViewCollector errorViewCollector, @NotNull final String filename, @NotNull final Document document) { try { - final Element root = document.getDocumentElement(); - parseBitmasks(errorViewCollector, root); - parseLists(errorViewCollector, root); - final IgnorelistsDefinition ignorelistsDefinition = parseIgnoreLists(errorViewCollector, root); - parseDefaultType(errorViewCollector, root, ignorelistsDefinition); - parseTypes(errorViewCollector, root, ignorelistsDefinition); + final Element rootElement = document.getDocumentElement(); + parseBitmasks(errorViewCollector, rootElement); + parseLists(errorViewCollector, rootElement); + final IgnorelistsDefinition ignorelistsDefinition = parseIgnoreLists(errorViewCollector, rootElement); + final Element defaultTypeElement = NodeListIterator.getFirstChild(rootElement, XML_ELEMENT_DEFAULT_TYPE); + assert defaultTypeElement != null; // types.xml makes sure this holds + parseDefaultType(errorViewCollector, defaultTypeElement, ignorelistsDefinition); + + final Iterator<Element> typeElements = new NodeListIterator<Element>(rootElement, XML_ELEMENT_TYPE); + while (typeElements.hasNext()) { + parseTypes(typeElements.next(), errorViewCollector, ignorelistsDefinition); + } + if (log.isInfoEnabled()) { log.info("Loaded " + archetypeTypeSet.getLength() + " types from '" + filename + "\'"); } @@ -350,33 +376,23 @@ /** * Parses the "default_type" section of a types.xml file. * @param errorViewCollector the error view collector for reporting errors - * @param element the element to parse + * @param defaultTypeElement the element to parse * @param ignorelistsDefinition the contents of the "ignorelists" section */ - private void parseDefaultType(@NotNull final ErrorViewCollector errorViewCollector, final Element element, @NotNull final IgnorelistsDefinition ignorelistsDefinition) { - final Element el = NodeListIterator.getFirstChild(element, "default_type"); - if (el == null) { - errorViewCollector.addWarning(ErrorViewCategory.TYPES_ENTRY_INVALID, "default_type element is missing!"); - return; - } - - final ArchetypeType defaultType = archetypeTypeParser.load(errorViewCollector, null, el, archetypeTypeSet, ignorelistsDefinition); + private void parseDefaultType(@NotNull final ErrorViewCollector errorViewCollector, @NotNull final Element defaultTypeElement, @NotNull final IgnorelistsDefinition ignorelistsDefinition) { + final ArchetypeType defaultType = archetypeTypeParser.loadAttributeList(defaultTypeElement, errorViewCollector, null, archetypeTypeSet, ignorelistsDefinition, true); archetypeTypeSet.setDefaultArchetypeType(defaultType); } /** - * Parses the "type" section of a types.xml file. + * Parses a "type" element of a types.xml file. + * @param typeElement the type element to parse * @param errorViewCollector the error view collector for reporting errors - * @param element the element to parse * @param ignorelistsDefinition the contents of the "ignorelists" section */ - private void parseTypes(@NotNull final ErrorViewCollector errorViewCollector, final Element element, @NotNull final IgnorelistsDefinition ignorelistsDefinition) { - final Iterator<Element> it = new NodeListIterator<Element>(element, "type"); - while (it.hasNext()) { - final Element elem = it.next(); - if (!elem.getAttribute("available").equals("no")) { - archetypeTypeSet.add(archetypeTypeParser.load(errorViewCollector, archetypeTypeSet.getDefaultArchetypeType(), elem, archetypeTypeSet, ignorelistsDefinition)); - } + private void parseTypes(@NotNull final Element typeElement, @NotNull final ErrorViewCollector errorViewCollector, @NotNull final IgnorelistsDefinition ignorelistsDefinition) { + if (!typeElement.getAttribute(XML_TYPE_AVAILABLE).equals("no")) { + archetypeTypeSet.add(archetypeTypeParser.loadAttributeList(typeElement, errorViewCollector, archetypeTypeSet.getDefaultArchetypeType(), archetypeTypeSet, ignorelistsDefinition, false)); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-05-26 18:19:34
|
Revision: 8000 http://gridarta.svn.sourceforge.net/gridarta/?rev=8000&view=rev Author: akirschbaum Date: 2010-05-26 18:19:27 +0000 (Wed, 26 May 2010) Log Message: ----------- Cleanup parser for types.xml. Modified Paths: -------------- trunk/resource/system/dtd/types.dtd trunk/src/app/net/sf/gridarta/maincontrol/DefaultMainControl.java trunk/src/app/net/sf/gridarta/model/archetypetype/ArchetypeAttributeParser.java trunk/src/app/net/sf/gridarta/model/archetypetype/ArchetypeTypeParser.java trunk/src/app/net/sf/gridarta/model/archetypetype/ArchetypeTypeSetParser.java trunk/src/app/net/sf/gridarta/model/archetypetype/AttributeBitmask.java trunk/src/test/net/sf/gridarta/model/archetypetype/ArchetypeTypeSetParserTest.java Modified: trunk/resource/system/dtd/types.dtd =================================================================== --- trunk/resource/system/dtd/types.dtd 2010-05-25 16:30:00 UTC (rev 7999) +++ trunk/resource/system/dtd/types.dtd 2010-05-26 18:19:27 UTC (rev 8000) @@ -38,6 +38,9 @@ xml:base CDATA #IMPLIED > +<!-- name: the name of the bitmask; must be unique --> +<!-- is_named: whether values are to be encoded as strings in external + representation --> <!ELEMENT bitmask (bmentry+)> <!ATTLIST bitmask name CDATA #REQUIRED Modified: trunk/src/app/net/sf/gridarta/maincontrol/DefaultMainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/maincontrol/DefaultMainControl.java 2010-05-25 16:30:00 UTC (rev 7999) +++ trunk/src/app/net/sf/gridarta/maincontrol/DefaultMainControl.java 2010-05-26 18:19:27 UTC (rev 8000) @@ -239,7 +239,7 @@ final ArchetypeAttributeFactory archetypeAttributeFactory = new DefaultArchetypeAttributeFactory(); final ArchetypeAttributeParser archetypeAttributeParser = new ArchetypeAttributeParser(archetypeAttributeFactory); final ArchetypeTypeParser archetypeTypeParser = new ArchetypeTypeParser(archetypeAttributeParser); - final ArchetypeTypeSetParser archetypeTypeSetParser = new ArchetypeTypeSetParser(xmlHelper.getDocumentBuilder(), xmlHelper.getXPath(), archetypeTypeSet, archetypeTypeParser); + final ArchetypeTypeSetParser archetypeTypeSetParser = new ArchetypeTypeSetParser(xmlHelper.getDocumentBuilder(), archetypeTypeSet, archetypeTypeParser); ArchetypeTypeList eventTypeSet = null; try { final URL url = IOUtils.getResource(globalSettings.getConfigurationDirectory(), CommonConstants.TYPEDEF_FILE); Modified: trunk/src/app/net/sf/gridarta/model/archetypetype/ArchetypeAttributeParser.java =================================================================== --- trunk/src/app/net/sf/gridarta/model/archetypetype/ArchetypeAttributeParser.java 2010-05-25 16:30:00 UTC (rev 7999) +++ trunk/src/app/net/sf/gridarta/model/archetypetype/ArchetypeAttributeParser.java 2010-05-26 18:19:27 UTC (rev 8000) @@ -34,42 +34,110 @@ public class ArchetypeAttributeParser { /** - * XML attribute name for arch. + * The name of the "attribute" element. */ @NotNull - public static final String XML_KEY_ARCH = "arch"; + public static final String XML_ELEMENT_ATTRIBUTE = "attribute"; /** - * XML attribute name for begin of arch. + * The name of the "arch" attribute within {@link #XML_ELEMENT_ATTRIBUTE} + * elements. */ @NotNull - private static final String XML_KEY_ARCH_BEGIN = "arch_begin"; + public static final String XML_ATTRIBUTE_ARCH = "arch"; /** - * XML attribute name for end of arch. + * The name of the "editor" attribute within {@link #XML_ELEMENT_ATTRIBUTE} + * elements. */ @NotNull - private static final String XML_KEY_ARCH_END = "arch_end"; + public static final String XML_ATTRIBUTE_EDITOR = "editor"; /** - * XML attribute name for editor specific information. + * The name of the "value" attribute within {@link #XML_ELEMENT_ATTRIBUTE} + * elements. */ @NotNull - private static final String XML_KEY_EDITOR = "editor"; + public static final String XML_ATTRIBUTE_VALUE = "value"; /** - * XML attribute name for type definitions. + * The name of the "min" attribute within {@link #XML_ELEMENT_ATTRIBUTE} + * elements. */ @NotNull - private static final String XML_ATTRIBUTE_TYPE = "type"; + public static final String XML_ATTRIBUTE_MIN = "min"; /** - * XML attribute name for length information. + * The name of the "max" attribute within {@link #XML_ELEMENT_ATTRIBUTE} + * elements. */ @NotNull - private static final String XML_INPUT_LENGTH = "length"; + public static final String XML_ATTRIBUTE_MAX = "max"; /** + * The name of the "check_min" attribute within {@link + * #XML_ELEMENT_ATTRIBUTE} elements. + */ + @NotNull + public static final String XML_ATTRIBUTE_CHECK_MIN = "check_min"; + + /** + * The name of the "check_max" attribute within {@link + * #XML_ELEMENT_ATTRIBUTE} elements. + */ + @NotNull + public static final String XML_ATTRIBUTE_CHECK_MAX = "check_max"; + + /** + * The name of the "type" attribute within {@link #XML_ELEMENT_ATTRIBUTE} + * elements. + */ + @NotNull + public static final String XML_ATTRIBUTE_TYPE = "type"; + + /** + * The name of the "arch_begin" attribute within {@link + * #XML_ELEMENT_ATTRIBUTE} elements. + */ + @NotNull + public static final String XML_ATTRIBUTE_ARCH_BEGIN = "arch_begin"; + + /** + * The name of the "arch_end" attribute within {@link + * #XML_ELEMENT_ATTRIBUTE} elements. + */ + @NotNull + public static final String XML_ATTRIBUTE_ARCH_END = "arch_end"; + + /** + * The name of the "length" attribute within {@link #XML_ELEMENT_ATTRIBUTE} + * elements. + */ + @NotNull + public static final String XML_ATTRIBUTE_LENGTH = "length"; + + /** + * The name of the "true" attribute within {@link #XML_ELEMENT_ATTRIBUTE} + * elements. + */ + @NotNull + public static final String XML_ATTRIBUTE_TRUE = "true"; + + /** + * The name of the "false" attribute within {@link #XML_ELEMENT_ATTRIBUTE} + * elements. + */ + @NotNull + public static final String XML_ATTRIBUTE_FALSE = "false"; + + /** + * The name of the "marker" attribute within {@link #XML_ELEMENT_ATTRIBUTE} + * elements. + */ + @NotNull + public static final String XML_ATTRIBUTE_MARKER = "marker"; + + /** * The {@link ArchetypeAttributeFactory} for creating {@link * ArchetypeAttribute}s. */ @@ -86,8 +154,8 @@ /** * Loading the data from an xml element into this object. + * @param attributeElement the xml 'attribute' element * @param errorViewCollector the error view collector for reporting errors - * @param root the xml 'attribute' element * @param archetypeTypeSet the archetype type list * @param typeName (descriptive) name of the type this attribute belongs to * (e.g. "Weapon") @@ -97,67 +165,67 @@ */ @Nullable @SuppressWarnings({ "FeatureEnvy" }) - public ArchetypeAttribute load(@NotNull final ErrorViewCollector errorViewCollector, @NotNull final Element root, @NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final String typeName, @NotNull final String sectionName) throws MissingAttributeException { - final String description = parseText(root); - final int inputLength = getAttributeIntValue(root, XML_INPUT_LENGTH, 0, typeName, errorViewCollector); - final String attributeType = getAttributeValue(root, XML_ATTRIBUTE_TYPE); + public ArchetypeAttribute load(@NotNull final Element attributeElement, @NotNull final ErrorViewCollector errorViewCollector, @NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final String typeName, @NotNull final String sectionName) throws MissingAttributeException { + final String description = parseText(attributeElement); + final int inputLength = getAttributeIntValue(attributeElement, XML_ATTRIBUTE_LENGTH, 0, typeName, errorViewCollector); + final String attributeType = getAttributeValue(attributeElement, XML_ATTRIBUTE_TYPE); if (attributeType.equals("bool")) { - return archetypeAttributeFactory.newArchetypeAttributeBool(getAttributeValue(root, XML_KEY_ARCH), getAttributeValue(root, XML_KEY_EDITOR), description, inputLength, sectionName); + return archetypeAttributeFactory.newArchetypeAttributeBool(getAttributeValue(attributeElement, XML_ATTRIBUTE_ARCH), getAttributeValue(attributeElement, XML_ATTRIBUTE_EDITOR), description, inputLength, sectionName); } else if (attributeType.equals("bool_special")) { - return archetypeAttributeFactory.newArchetypeAttributeBoolSpec(getAttributeValue(root, XML_KEY_ARCH), getAttributeValue(root, XML_KEY_EDITOR), description, inputLength, sectionName, getAttributeValue(root, "true"), getAttributeValue(root, "false")); + return archetypeAttributeFactory.newArchetypeAttributeBoolSpec(getAttributeValue(attributeElement, XML_ATTRIBUTE_ARCH), getAttributeValue(attributeElement, XML_ATTRIBUTE_EDITOR), description, inputLength, sectionName, getAttributeValue(attributeElement, XML_ATTRIBUTE_TRUE), getAttributeValue(attributeElement, XML_ATTRIBUTE_FALSE)); } else if (attributeType.equals("int")) { - final int minValue = getAttributeIntValue(root, "min", Integer.MIN_VALUE, typeName, errorViewCollector); - final int maxValue = getAttributeIntValue(root, "max", Integer.MAX_VALUE, typeName, errorViewCollector); - final int minCheckValue = getAttributeIntValue(root, "check_min", minValue, typeName, errorViewCollector); - final int maxCheckValue = getAttributeIntValue(root, "check_max", maxValue, typeName, errorViewCollector); + final int minValue = getAttributeIntValue(attributeElement, XML_ATTRIBUTE_MIN, Integer.MIN_VALUE, typeName, errorViewCollector); + final int maxValue = getAttributeIntValue(attributeElement, XML_ATTRIBUTE_MAX, Integer.MAX_VALUE, typeName, errorViewCollector); + final int minCheckValue = getAttributeIntValue(attributeElement, XML_ATTRIBUTE_CHECK_MIN, minValue, typeName, errorViewCollector); + final int maxCheckValue = getAttributeIntValue(attributeElement, XML_ATTRIBUTE_CHECK_MAX, maxValue, typeName, errorViewCollector); if (minValue > maxValue) { - errorViewCollector.addWarning(ErrorViewCategory.TYPES_ENTRY_INVALID, "type " + typeName + " has invalid min..max range: " + minValue + ".." + maxValue + "."); + errorViewCollector.addWarning(ErrorViewCategory.TYPES_ENTRY_INVALID, "type " + typeName + " has invalid " + XML_ATTRIBUTE_MIN + ".." + XML_ATTRIBUTE_MAX + " range: " + minValue + ".." + maxValue + "."); return null; } if (minCheckValue > maxCheckValue) { - errorViewCollector.addWarning(ErrorViewCategory.TYPES_ENTRY_INVALID, "type " + typeName + " has invalid check_min..check_max range: " + minCheckValue + ".." + maxCheckValue + "."); + errorViewCollector.addWarning(ErrorViewCategory.TYPES_ENTRY_INVALID, "type " + typeName + " has invalid " + XML_ATTRIBUTE_CHECK_MIN + ".." + XML_ATTRIBUTE_CHECK_MAX + " range: " + minCheckValue + ".." + maxCheckValue + "."); return null; } if (minCheckValue < minValue) { - errorViewCollector.addWarning(ErrorViewCategory.TYPES_ENTRY_INVALID, "type " + typeName + " has invalid check_min value: " + minCheckValue + " < min = " + minValue + "."); + errorViewCollector.addWarning(ErrorViewCategory.TYPES_ENTRY_INVALID, "type " + typeName + " has invalid " + XML_ATTRIBUTE_CHECK_MIN + " value: " + minCheckValue + " < " + XML_ATTRIBUTE_MIN + " = " + minValue + "."); return null; } if (maxCheckValue > maxValue) { - errorViewCollector.addWarning(ErrorViewCategory.TYPES_ENTRY_INVALID, "type " + typeName + " has invalid check_max value: " + maxCheckValue + " > max = " + maxValue + "."); + errorViewCollector.addWarning(ErrorViewCategory.TYPES_ENTRY_INVALID, "type " + typeName + " has invalid " + XML_ATTRIBUTE_CHECK_MAX + " value: " + maxCheckValue + " > " + XML_ATTRIBUTE_MAX + " = " + maxValue + "."); return null; } - return archetypeAttributeFactory.newArchetypeAttributeInt(getAttributeValue(root, XML_KEY_ARCH), getAttributeValue(root, XML_KEY_EDITOR), description, inputLength, sectionName, minValue, maxValue, minCheckValue, maxCheckValue); + return archetypeAttributeFactory.newArchetypeAttributeInt(getAttributeValue(attributeElement, XML_ATTRIBUTE_ARCH), getAttributeValue(attributeElement, XML_ATTRIBUTE_EDITOR), description, inputLength, sectionName, minValue, maxValue, minCheckValue, maxCheckValue); } else if (attributeType.equals("long")) { - return archetypeAttributeFactory.newArchetypeAttributeLong(getAttributeValue(root, XML_KEY_ARCH), getAttributeValue(root, XML_KEY_EDITOR), description, inputLength, sectionName); + return archetypeAttributeFactory.newArchetypeAttributeLong(getAttributeValue(attributeElement, XML_ATTRIBUTE_ARCH), getAttributeValue(attributeElement, XML_ATTRIBUTE_EDITOR), description, inputLength, sectionName); } else if (attributeType.equals("float")) { - return archetypeAttributeFactory.newArchetypeAttributeFloat(getAttributeValue(root, XML_KEY_ARCH), getAttributeValue(root, XML_KEY_EDITOR), description, inputLength, sectionName); + return archetypeAttributeFactory.newArchetypeAttributeFloat(getAttributeValue(attributeElement, XML_ATTRIBUTE_ARCH), getAttributeValue(attributeElement, XML_ATTRIBUTE_EDITOR), description, inputLength, sectionName); } else if (attributeType.equals("string")) { - return archetypeAttributeFactory.newArchetypeAttributeString(getAttributeValue(root, XML_KEY_ARCH), getAttributeValue(root, XML_KEY_EDITOR), description, inputLength, sectionName); + return archetypeAttributeFactory.newArchetypeAttributeString(getAttributeValue(attributeElement, XML_ATTRIBUTE_ARCH), getAttributeValue(attributeElement, XML_ATTRIBUTE_EDITOR), description, inputLength, sectionName); } else if (attributeType.equals("map_path")) { - return archetypeAttributeFactory.newArchetypeAttributeMapPath(getAttributeValue(root, XML_KEY_ARCH), getAttributeValue(root, XML_KEY_EDITOR), description, inputLength, sectionName); + return archetypeAttributeFactory.newArchetypeAttributeMapPath(getAttributeValue(attributeElement, XML_ATTRIBUTE_ARCH), getAttributeValue(attributeElement, XML_ATTRIBUTE_EDITOR), description, inputLength, sectionName); } else if (attributeType.equals("script_file")) { - return archetypeAttributeFactory.newArchetypeAttributeScriptFile(getAttributeValue(root, XML_KEY_ARCH), getAttributeValue(root, XML_KEY_EDITOR), description, inputLength, sectionName); + return archetypeAttributeFactory.newArchetypeAttributeScriptFile(getAttributeValue(attributeElement, XML_ATTRIBUTE_ARCH), getAttributeValue(attributeElement, XML_ATTRIBUTE_EDITOR), description, inputLength, sectionName); } else if (attributeType.equals("facename")) { - return archetypeAttributeFactory.newArchetypeAttributeFacename(getAttributeValue(root, XML_KEY_ARCH), getAttributeValue(root, XML_KEY_EDITOR), description, inputLength, sectionName); + return archetypeAttributeFactory.newArchetypeAttributeFacename(getAttributeValue(attributeElement, XML_ATTRIBUTE_ARCH), getAttributeValue(attributeElement, XML_ATTRIBUTE_EDITOR), description, inputLength, sectionName); } else if (attributeType.equals("animname")) { - return archetypeAttributeFactory.newArchetypeAttributeAnimname(getAttributeValue(root, XML_KEY_ARCH), getAttributeValue(root, XML_KEY_EDITOR), description, inputLength, sectionName); + return archetypeAttributeFactory.newArchetypeAttributeAnimname(getAttributeValue(attributeElement, XML_ATTRIBUTE_ARCH), getAttributeValue(attributeElement, XML_ATTRIBUTE_EDITOR), description, inputLength, sectionName); } else if (attributeType.equals("text")) { - return archetypeAttributeFactory.newArchetypeAttributeText(getAttributeValue(root, XML_KEY_ARCH_BEGIN), getAttributeValue(root, XML_KEY_ARCH_END), getAttributeValue(root, XML_KEY_EDITOR), description, inputLength, getAttributeValueOptional(root, "marker")); + return archetypeAttributeFactory.newArchetypeAttributeText(getAttributeValue(attributeElement, XML_ATTRIBUTE_ARCH_BEGIN), getAttributeValue(attributeElement, XML_ATTRIBUTE_ARCH_END), getAttributeValue(attributeElement, XML_ATTRIBUTE_EDITOR), description, inputLength, getAttributeValueOptional(attributeElement, XML_ATTRIBUTE_MARKER)); } else if (attributeType.equals("fixed")) { - return archetypeAttributeFactory.newArchetypeAttributeFixed(getAttributeValue(root, XML_KEY_ARCH), getAttributeValue(root, "value"), description, inputLength, sectionName); + return archetypeAttributeFactory.newArchetypeAttributeFixed(getAttributeValue(attributeElement, XML_ATTRIBUTE_ARCH), getAttributeValue(attributeElement, XML_ATTRIBUTE_VALUE), description, inputLength, sectionName); } else if (attributeType.equals("spell")) { - return archetypeAttributeFactory.newArchetypeAttributeSpell(getAttributeValue(root, XML_KEY_ARCH), getAttributeValue(root, XML_KEY_EDITOR), description, inputLength, sectionName); + return archetypeAttributeFactory.newArchetypeAttributeSpell(getAttributeValue(attributeElement, XML_ATTRIBUTE_ARCH), getAttributeValue(attributeElement, XML_ATTRIBUTE_EDITOR), description, inputLength, sectionName); } else if (attributeType.equals("nz_spell")) { - return archetypeAttributeFactory.newArchetypeAttributeZSpell(getAttributeValue(root, XML_KEY_ARCH), getAttributeValue(root, XML_KEY_EDITOR), description, inputLength, sectionName); + return archetypeAttributeFactory.newArchetypeAttributeZSpell(getAttributeValue(attributeElement, XML_ATTRIBUTE_ARCH), getAttributeValue(attributeElement, XML_ATTRIBUTE_EDITOR), description, inputLength, sectionName); } else if (attributeType.equals("inv_spell")) { - return archetypeAttributeFactory.newArchetypeAttributeInvSpell(getAttributeValue(root, XML_KEY_ARCH), getAttributeValue(root, XML_KEY_EDITOR), description, inputLength, sectionName); + return archetypeAttributeFactory.newArchetypeAttributeInvSpell(getAttributeValue(attributeElement, XML_ATTRIBUTE_ARCH), getAttributeValue(attributeElement, XML_ATTRIBUTE_EDITOR), description, inputLength, sectionName); } else if (attributeType.equals("inv_spell_optional")) { - return archetypeAttributeFactory.newArchetypeAttributeInvSpellOptional(getAttributeValue(root, XML_KEY_ARCH), getAttributeValue(root, XML_KEY_EDITOR), description, inputLength, sectionName); + return archetypeAttributeFactory.newArchetypeAttributeInvSpellOptional(getAttributeValue(attributeElement, XML_ATTRIBUTE_ARCH), getAttributeValue(attributeElement, XML_ATTRIBUTE_EDITOR), description, inputLength, sectionName); } else if (attributeType.startsWith("bitmask")) { // got a bitmask attribute final String bitmaskName = attributeType.substring(8).trim(); @@ -165,7 +233,7 @@ errorViewCollector.addWarning(ErrorViewCategory.TYPES_ENTRY_INVALID, "type " + typeName + ": Bitmask \"" + bitmaskName + "\" is undefined."); return null; } - return archetypeAttributeFactory.newArchetypeAttributeBitmask(getAttributeValue(root, XML_KEY_ARCH), getAttributeValue(root, XML_KEY_EDITOR), description, inputLength, sectionName, bitmaskName); + return archetypeAttributeFactory.newArchetypeAttributeBitmask(getAttributeValue(attributeElement, XML_ATTRIBUTE_ARCH), getAttributeValue(attributeElement, XML_ATTRIBUTE_EDITOR), description, inputLength, sectionName, bitmaskName); } else if (attributeType.startsWith("list_")) { // got a bitmask attribute final String listName = attributeType.substring(5).trim(); @@ -173,9 +241,9 @@ errorViewCollector.addWarning(ErrorViewCategory.TYPES_ENTRY_INVALID, "type " + typeName + ": List \"" + listName + "\" is undefined."); return null; } - return archetypeAttributeFactory.newArchetypeAttributeList(getAttributeValue(root, XML_KEY_ARCH), getAttributeValue(root, XML_KEY_EDITOR), description, inputLength, sectionName, listName); + return archetypeAttributeFactory.newArchetypeAttributeList(getAttributeValue(attributeElement, XML_ATTRIBUTE_ARCH), getAttributeValue(attributeElement, XML_ATTRIBUTE_EDITOR), description, inputLength, sectionName, listName); } else if (attributeType.equals("treasurelist")) { - return archetypeAttributeFactory.newArchetypeAttributeTreasure(getAttributeValue(root, XML_KEY_ARCH), getAttributeValue(root, XML_KEY_EDITOR), description, inputLength, sectionName); + return archetypeAttributeFactory.newArchetypeAttributeTreasure(getAttributeValue(attributeElement, XML_ATTRIBUTE_ARCH), getAttributeValue(attributeElement, XML_ATTRIBUTE_EDITOR), description, inputLength, sectionName); } else { // unknown type errorViewCollector.addWarning(ErrorViewCategory.TYPES_ENTRY_INVALID, "type " + typeName + " has an attribute with unknown type: '" + attributeType + "'."); @@ -187,12 +255,12 @@ * This method reads the text out of the element's "body" and cuts off white * spaces at front/end of lines. Probably a more correct approach would be * to display the info text in an html context. - * @param root xml attribute element + * @param attributeElement xml attribute element * @return the body's text */ @NotNull - private static String parseText(@NotNull final Node root) { - final String tmp = root.getTextContent().trim(); + private static String parseText(@NotNull final Node attributeElement) { + final String tmp = attributeElement.getTextContent().trim(); if (tmp.startsWith("<html>")) { return tmp.replaceAll("\\s*\n\\s*", " "); } else { Modified: trunk/src/app/net/sf/gridarta/model/archetypetype/ArchetypeTypeParser.java =================================================================== --- trunk/src/app/net/sf/gridarta/model/archetypetype/ArchetypeTypeParser.java 2010-05-25 16:30:00 UTC (rev 7999) +++ trunk/src/app/net/sf/gridarta/model/archetypetype/ArchetypeTypeParser.java 2010-05-26 18:19:27 UTC (rev 8000) @@ -132,101 +132,104 @@ } /** - * Parses an element which contains a list of <attribute> elements - * from a types.xml file. + * Parses an element which contains a list of {@link + * ArchetypeAttributeParser#XML_ELEMENT_ATTRIBUTE} elements from a types.xml + * file. * @param typeElement the xml 'type' element which is going to be parsed * @param errorViewCollector the error view collector for reporting errors - * @param parent the parent archetype type + * @param archetypeType the parent archetype type * @param archetypeTypeSet archetype type list * @param ignorelistsDefinition the ignore_lists contents * @param isDefaultType whether this element is the "default_type" * @return the archetype type or <code>null</code> - * @todo I'm sucking slow, improve me */ @NotNull - public ArchetypeType loadAttributeList(@NotNull final Element typeElement, @NotNull final ErrorViewCollector errorViewCollector, @Nullable final ArchetypeType parent, @NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final IgnorelistsDefinition ignorelistsDefinition, final boolean isDefaultType) { + public ArchetypeType loadAttributeList(@NotNull final Element typeElement, @NotNull final ErrorViewCollector errorViewCollector, @Nullable final ArchetypeType archetypeType, @NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final IgnorelistsDefinition ignorelistsDefinition, final boolean isDefaultType) { final String typeName = parseTypeName(typeElement, isDefaultType); final int typeNo = parseTypeNo(typeElement, isDefaultType, typeName, errorViewCollector); final Collection<String> ignoreTable = new HashSet<String>(); final ArchetypeAttributesDefinition typeAttributes = isDefaultType ? new ArchetypeAttributesDefinition() : parseTypeAttributes(typeElement, typeName, errorViewCollector, ignoreTable, ignorelistsDefinition); - final String importType = parseImportType(typeElement, typeName, errorViewCollector); + + final Element importTypeElement = NodeListIterator.getFirstChild(typeElement, XML_ELEMENT_IMPORT_TYPE); + final String importType = importTypeElement == null ? null : parseImportType(importTypeElement, typeName, errorViewCollector); + final ArchetypeAttributes attributes = new ArchetypeAttributes(); final SectionNames sectionNames = new SectionNames(); - final Collection<String> autoIgnoreTable = new HashSet<String>(); - attributes.addAll(parseAttributeList(typeElement, errorViewCollector, typeName, typeNo, sectionNames, autoIgnoreTable, archetypeTypeSet)); - if (parent != null) { - attributes.addAll(getDefaultList(parent, autoIgnoreTable, ignoreTable)); - if (parent.hasAttribute()) { - attributes.addAll(importName(importType, errorViewCollector, typeName, archetypeTypeSet, autoIgnoreTable)); + addAttributeList(typeElement, attributes, errorViewCollector, typeName, typeNo, sectionNames, archetypeTypeSet); + if (archetypeType != null) { + final Collection<String> autoIgnoreTable = new HashSet<String>(); + for (final ArchetypeAttribute attribute : attributes) { + autoIgnoreTable.add(attribute.getArchetypeAttributeName()); } + + addDefaultList(archetypeType, attributes, autoIgnoreTable, ignoreTable); + if (importType != null && archetypeType.hasAttribute()) { + addImportList(importType, attributes, errorViewCollector, typeName, archetypeTypeSet, autoIgnoreTable); + } } attributes.setSectionNames(sectionNames); return new ArchetypeType(typeName, typeNo, parseDescription(typeElement), parseUse(typeElement), sectionNames.getSectionNames(), attributes, typeAttributes); } - @NotNull - private ArchetypeAttributes getDefaultList(@NotNull final Iterable<ArchetypeAttribute> archetypeType, @NotNull final Collection<String> autoIgnoreTable, @NotNull final Collection<String> ignoreTable) { - final ArchetypeAttributes defaultList = new ArchetypeAttributes(); - + /** + * Adds all attributes of am {@link ArchetypeType} to an {@link + * ArchetypeAttributes} that are not ignored. + * @param archetypeType the archetype type + * @param attributes the archetype attributes to add to + * @param autoIgnoreTable the attributes to ignore + * @param ignoreTable the attributes to ignore + */ + private static void addDefaultList(@NotNull final Iterable<ArchetypeAttribute> archetypeType, @NotNull final ArchetypeAttributes attributes, @NotNull final Collection<String> autoIgnoreTable, @NotNull final Collection<String> ignoreTable) { for (final ArchetypeAttribute archetypeAttribute : archetypeType) { // add all attributes from the default_type which are not in the ignoreTable if (!ignoreTable.contains(archetypeAttribute.getArchetypeAttributeName()) && !autoIgnoreTable.contains(archetypeAttribute.getArchetypeAttributeName())) { - defaultList.add(archetypeAttribute.clone()); + attributes.add(archetypeAttribute.clone()); } } - - return defaultList; } - @NotNull - private ArchetypeAttributes importName(@Nullable final String importName, @NotNull final ErrorViewCollector errorViewCollector, @NotNull final String typeName, @NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final Collection<String> autoIgnoreTable) { - if (importName == null) { - return new ArchetypeAttributes(); - } - - final Iterable<ArchetypeAttribute> impType = archetypeTypeSet.getArchetypeType(importName); - if (impType == null) { + /** + * Adds all imported attributes to an {@link ArchetypeAttributes}. + * @param importName the name of the import list to import + * @param attributes the archetype attributes to add to + * @param errorViewCollector the error view collector for reporting errors + * @param typeName the type name for error messages + * @param archetypeTypeSet the archetype type set + * @param autoIgnoreTable the attributes to ignore + */ + private static void addImportList(@NotNull final String importName, @NotNull final ArchetypeAttributes attributes, @NotNull final ErrorViewCollector errorViewCollector, @NotNull final String typeName, @NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final Collection<String> autoIgnoreTable) { + final Iterable<ArchetypeAttribute> importType = archetypeTypeSet.getArchetypeType(importName); + if (importType == null) { errorViewCollector.addWarning(ErrorViewCategory.TYPES_ENTRY_INVALID, typeName + ": import type \"" + importName + "\" not found!"); - return new ArchetypeAttributes(); + return; } - return importAttributes(impType, autoIgnoreTable); - } - - @NotNull - private ArchetypeAttributes importAttributes(@NotNull final Iterable<ArchetypeAttribute> impType, @NotNull final Collection<String> autoIgnoreTable) { - final ArchetypeAttributes importList = new ArchetypeAttributes(); - - for (final ArchetypeAttribute archetypeAttribute : impType) { + for (final ArchetypeAttribute archetypeAttribute : importType) { if (autoIgnoreTable.contains(archetypeAttribute.getArchetypeAttributeName())) { continue; } - if (!archetypeAttribute.getSectionName().equals(SectionNames.GENERAL_SECTION)) { - importList.add(archetypeAttribute.clone()); + if (archetypeAttribute.getSectionName().equals(SectionNames.GENERAL_SECTION)) { + continue; } + + attributes.add(archetypeAttribute.clone()); } - - return importList; } /** - * Parses the {@link #XML_ELEMENT_IMPORT_TYPE} of a "type" or "default_type" - * {@link Element}. - * @param typeElement the element + * Parses the {@link #XML_ELEMENT_IMPORT_TYPE} of an {@link + * ArchetypeTypeSetParser#XML_ELEMENT_TYPE} or {@link + * ArchetypeTypeSetParser#XML_ELEMENT_DEFAULT_TYPE} {@link Element}. + * @param importTypeElement the element * @param typeName the type name for error messages * @param errorViewCollector the error view collector for error messages * @return the import type name or <code>null</code> if no import_type is - * present or an error occurs + * present or an error occurs */ @Nullable - private static String parseImportType(@NotNull final Element typeElement, @NotNull final String typeName, @NotNull final ErrorViewCollector errorViewCollector) { - final Element importTypeElement = NodeListIterator.getFirstChild(typeElement, XML_ELEMENT_IMPORT_TYPE); - if (importTypeElement == null) { - return null; - } - + private static String parseImportType(@NotNull final Element importTypeElement, @NotNull final String typeName, @NotNull final ErrorViewCollector errorViewCollector) { final Attr nameAttribute = importTypeElement.getAttributeNode(XML_IMPORT_TYPE_NAME); if (nameAttribute == null) { errorViewCollector.addWarning(ErrorViewCategory.TYPES_ENTRY_INVALID, "type " + typeName + " has " + XML_ELEMENT_IMPORT_TYPE + " element without '" + XML_IMPORT_TYPE_NAME + "'."); @@ -243,14 +246,16 @@ } /** - * Parses the type name of a "type" or "default_type" {@link Element}. + * Parses the type name of an {@link ArchetypeTypeSetParser#XML_ELEMENT_TYPE} + * or {@link ArchetypeTypeSetParser#XML_ELEMENT_DEFAULT_TYPE} {@link + * Element}. * @param typeElement the element * @param isDefaultType whether the element is a "default_type" * @return the type name */ @NotNull private static String parseTypeName(@NotNull final Element typeElement, final boolean isDefaultType) { - return isDefaultType ? "default" : typeElement.getAttribute("name").trim(); + return isDefaultType ? "default" : typeElement.getAttribute(ArchetypeTypeSetParser.XML_TYPE_NAME); } /** @@ -266,7 +271,7 @@ return -1; } - final String number = typeElement.getAttribute("number"); + final String number = typeElement.getAttribute(ArchetypeTypeSetParser.XML_TYPE_NUMBER); try { return Integer.parseInt(number); } catch (final NumberFormatException ignored) { @@ -310,9 +315,10 @@ final ArchetypeAttributesDefinition attributes = new ArchetypeAttributesDefinition(); final Element requiredElement = NodeListIterator.getFirstChild(typeElement, XML_ELEMENT_REQUIRED); if (requiredElement != null) { - final Iterator<Element> it = new NodeListIterator<Element>(requiredElement, XML_ELEMENT_ATTRIBUTE); - while (it.hasNext()) { - final Element attributeElement = it.next(); + final Iterator<Element> attributeIterator = new NodeListIterator<Element>(requiredElement, XML_ELEMENT_ATTRIBUTE); + while (attributeIterator.hasNext()) { + final Element attributeElement = attributeIterator.next(); + final Attr archAttribute = attributeElement.getAttributeNode(XML_ATTRIBUTE_ARCH); if (archAttribute == null) { errorViewCollector.addWarning(ErrorViewCategory.TYPES_ENTRY_INVALID, XML_ELEMENT_REQUIRED + ": element of type " + typeName + ": " + XML_ELEMENT_ATTRIBUTE + " missing '" + XML_ATTRIBUTE_ARCH + "'."); @@ -349,14 +355,16 @@ * @param ignoreTable the ignore table to add to */ private static void parseAttributeAttributes(@NotNull final Element ignoreElement, @NotNull final String typeName, @NotNull final ErrorViewCollector errorViewCollector, @NotNull final Collection<String> ignoreTable) { - final Iterator<Element> it = new NodeListIterator<Element>(ignoreElement, XML_ELEMENT_ATTRIBUTE); - while (it.hasNext()) { - final Element elem = it.next(); - final Attr archAttribute = elem.getAttributeNode(XML_ATTRIBUTE_ARCH); + final Iterator<Element> attributeIterator = new NodeListIterator<Element>(ignoreElement, XML_ELEMENT_ATTRIBUTE); + while (attributeIterator.hasNext()) { + final Element attributeElement = attributeIterator.next(); + + final Attr archAttribute = attributeElement.getAttributeNode(XML_ATTRIBUTE_ARCH); if (archAttribute == null) { errorViewCollector.addWarning(ErrorViewCategory.TYPES_ENTRY_INVALID, XML_ELEMENT_IGNORE + ": section of type " + typeName + ": " + XML_ELEMENT_ATTRIBUTE + " missing '" + XML_ATTRIBUTE_ARCH + "'."); continue; } + final String arch = archAttribute.getValue(); if (arch.isEmpty()) { errorViewCollector.addWarning(ErrorViewCategory.TYPES_ENTRY_INVALID, XML_ELEMENT_IGNORE + ": section of type " + typeName + ": " + XML_ELEMENT_ATTRIBUTE + " empty '" + XML_ATTRIBUTE_ARCH + "'."); @@ -376,19 +384,20 @@ * @param ignorelistsDefinition the ignore lists to use */ private static void parseIgnoreListAttribute(@NotNull final Element ignoreElement, @NotNull final String typeName, @NotNull final ErrorViewCollector errorViewCollector, @NotNull final Collection<String> ignoreTable, @NotNull final IgnorelistsDefinition ignorelistsDefinition) { - final Iterator<Element> it2 = new NodeListIterator<Element>(ignoreElement, XML_ELEMENT_IGNORE_LIST); - while (it2.hasNext()) { - final Element elem = it2.next(); - final Attr nameAttribute = elem.getAttributeNode(XML_IGNORE_LIST_NAME); + final Iterator<Element> ignoreListIterator = new NodeListIterator<Element>(ignoreElement, XML_ELEMENT_IGNORE_LIST); + while (ignoreListIterator.hasNext()) { + final Element ignoreListElement = ignoreListIterator.next(); + + final Attr nameAttribute = ignoreListElement.getAttributeNode(XML_IGNORE_LIST_NAME); if (nameAttribute == null) { - errorViewCollector.addWarning(ErrorViewCategory.TYPES_ENTRY_INVALID, XML_ELEMENT_IGNORE + ": section of type " + typeName + ": ignore_list missing '" + XML_IGNORE_LIST_NAME + "'."); + errorViewCollector.addWarning(ErrorViewCategory.TYPES_ENTRY_INVALID, XML_ELEMENT_IGNORE + ": section of type " + typeName + ": "+ XML_ELEMENT_IGNORE_LIST + " missing '" + XML_IGNORE_LIST_NAME + "'."); continue; } final String name = nameAttribute.getValue(); final Iterable<String> ignoreList = ignorelistsDefinition.get(name); if (ignoreList == null) { - errorViewCollector.addWarning(ErrorViewCategory.TYPES_ENTRY_INVALID, XML_ELEMENT_IGNORE + ": section of type " + typeName + ": ignore_list with name \"" + name + "\" is undefined."); + errorViewCollector.addWarning(ErrorViewCategory.TYPES_ENTRY_INVALID, XML_ELEMENT_IGNORE + ": section of type " + typeName + ": " + XML_ELEMENT_IGNORE_LIST + " with "+ XML_IGNORE_LIST_NAME + " \"" + name + "\" is undefined."); continue; } @@ -423,30 +432,26 @@ /** * Parses the {@link #XML_ELEMENT_ATTRIBUTE} and {@link - * #XML_ELEMENT_SECTION} children of a "type" or "default_type" element. + * #XML_ELEMENT_SECTION} children of a "type" or "default_type" element and + * adds all found attributes to an {@link ArchetypeAttribute}. * @param typeElement the type element to parse + * @param attributes the archetype attributes to add to * @param errorViewCollector the error view collector for reporting errors * @param typeName the type name of the element being parsed * @param typeNo the type number of the element being parsed * @param sectionNames the defined section names * @param archetypeTypeSet archetype type list - * @return the archetype type or <code>null</code> */ - @NotNull - private ArchetypeAttributes parseAttributeList(@NotNull final Element typeElement, @NotNull final ErrorViewCollector errorViewCollector, @NotNull final String typeName, final int typeNo, @NotNull final SectionNames sectionNames, @NotNull final Collection<String> autoIgnoreTable, @NotNull final ArchetypeTypeSet archetypeTypeSet) { - final ArchetypeAttributes archetypeAttributes = new ArchetypeAttributes(); + private void addAttributeList(@NotNull final Element typeElement, @NotNull final ArchetypeAttributes attributes, @NotNull final ErrorViewCollector errorViewCollector, @NotNull final String typeName, final int typeNo, @NotNull final SectionNames sectionNames, @NotNull final ArchetypeTypeSet archetypeTypeSet) { + final Iterator<Element> childIterator = new NodeListIterator<Element>(typeElement, Node.ELEMENT_NODE); + while (childIterator.hasNext()) { + final Element childElement = childIterator.next(); + final String childName = childElement.getNodeName(); - final Iterator<Element> it = new NodeListIterator<Element>(typeElement, Node.ELEMENT_NODE); - while (it.hasNext()) { - final Element node = it.next(); - final String nodeName = node.getNodeName(); - - if (nodeName.equals(XML_ELEMENT_ATTRIBUTE)) { - parseAttribute(node, errorViewCollector, typeName, typeNo, sectionNames, null, archetypeTypeSet, archetypeAttributes, autoIgnoreTable); - } - - if (nodeName.equals(XML_ELEMENT_SECTION) && node.hasChildNodes()) { - final Attr nameAttribute = node.getAttributeNode(XML_SECTION_NAME); + if (childName.equals(XML_ELEMENT_ATTRIBUTE)) { + parseAttribute(childElement, errorViewCollector, typeName, typeNo, sectionNames, null, archetypeTypeSet, attributes); + } else if (childName.equals(XML_ELEMENT_SECTION) && childElement.hasChildNodes()) { + final Attr nameAttribute = childElement.getAttributeNode(XML_SECTION_NAME); if (nameAttribute == null) { errorViewCollector.addWarning(ErrorViewCategory.TYPES_ENTRY_INVALID, "type " + typeName + " contains a " + XML_ELEMENT_SECTION + " missing '" + XML_SECTION_NAME + "'."); continue; @@ -460,14 +465,12 @@ sectionNames.defineSectionName(sectionName); - final Iterator<Element> it2 = new NodeListIterator<Element>(node, XML_ELEMENT_ATTRIBUTE); - while (it2.hasNext()) { - parseAttribute(it2.next(), errorViewCollector, typeName, typeNo, sectionNames, sectionName, archetypeTypeSet, archetypeAttributes, autoIgnoreTable); + final Iterator<Element> attributeIterator = new NodeListIterator<Element>(childElement, XML_ELEMENT_ATTRIBUTE); + while (attributeIterator.hasNext()) { + parseAttribute(attributeIterator.next(), errorViewCollector, typeName, typeNo, sectionNames, sectionName, archetypeTypeSet, attributes); } } } - - return archetypeAttributes; } /** @@ -480,14 +483,16 @@ * @param sectionName the section name or <code>null</code> for top-level * attributes * @param archetypeTypeSet archetype type list + * @param attributes the attribute will be added to this */ - private void parseAttribute(@NotNull final Element attributeElement, @NotNull final ErrorViewCollector errorViewCollector, @NotNull final String typeName, final int typeNo, @NotNull final SectionNames sectionNames, @Nullable final String sectionName, @NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final ArchetypeAttributes archetypeAttributes, @NotNull final Collection<String> autoIgnoreTable) { + private void parseAttribute(@NotNull final Element attributeElement, @NotNull final ErrorViewCollector errorViewCollector, @NotNull final String typeName, final int typeNo, @NotNull final SectionNames sectionNames, @Nullable final String sectionName, @NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final ArchetypeAttributes attributes) { final ArchetypeAttribute archetypeAttribute = parseAttribute(attributeElement, errorViewCollector, typeName, typeNo, sectionName, archetypeTypeSet); - if (archetypeAttribute != null) { - sectionNames.defineSectionName(archetypeAttribute.getSectionName()); - archetypeAttributes.add(archetypeAttribute); - autoIgnoreTable.add(archetypeAttribute.getArchetypeAttributeName()); + if (archetypeAttribute == null) { + return; } + + sectionNames.defineSectionName(archetypeAttribute.getSectionName()); + attributes.add(archetypeAttribute); } /** @@ -516,7 +521,7 @@ } try { - return archetypeAttributeParser.load(errorViewCollector, attributeElement, archetypeTypeSet, typeName, effectiveSectionName); + return archetypeAttributeParser.load(attributeElement, errorViewCollector, archetypeTypeSet, typeName, effectiveSectionName); } catch (final MissingAttributeException ex) { errorViewCollector.addWarning(ErrorViewCategory.TYPES_ENTRY_INVALID, "type " + typeName + ": " + ex.getMessage()); return null; Modified: trunk/src/app/net/sf/gridarta/model/archetypetype/ArchetypeTypeSetParser.java =================================================================== --- trunk/src/app/net/sf/gridarta/model/archetypetype/ArchetypeTypeSetParser.java 2010-05-25 16:30:00 UTC (rev 7999) +++ trunk/src/app/net/sf/gridarta/model/archetypetype/ArchetypeTypeSetParser.java 2010-05-26 18:19:27 UTC (rev 8000) @@ -22,8 +22,6 @@ import java.io.IOException; import java.util.Iterator; import javax.xml.parsers.DocumentBuilder; -import javax.xml.xpath.XPath; -import javax.xml.xpath.XPathExpressionException; import net.sf.gridarta.model.errorview.ErrorViewCategory; import net.sf.gridarta.model.errorview.ErrorViewCollector; import net.sf.gridarta.utils.SyntaxErrorException; @@ -52,6 +50,105 @@ private static final String XML_ELEMENT_DEFAULT_TYPE = "default_type"; /** + * The name of the "bitmasks" element. + */ + @NotNull + private static final String XML_ELEMENT_BITMASKS = "bitmasks"; + + /** + * The name of the "bitmask" element. + */ + @NotNull + private static final String XML_ELEMENT_BITMASK = "bitmask"; + + /** + * The name of the "name" attribute within {@link #XML_ELEMENT_BITMASK} + * elements. + */ + @NotNull + private static final String XML_BITMASK_NAME = "name"; + + /** + * The name of the "is_named" attribute within {@link #XML_ELEMENT_BITMASK} + * elements. + */ + @NotNull + private static final String XML_BITMASK_IS_NAMED = "is_named"; + + /** + * The name of the "bmentry" element. + */ + @NotNull + private static final String XML_ELEMENT_BMENTRY = "bmentry"; + + /** + * The name of the "bit" attribute within {@link #XML_ELEMENT_BMENTRY} + * elements. + */ + @NotNull + private static final String XML_BMENTRY_BIT = "bit"; + + /** + * The name of the "name" attribute within {@link #XML_ELEMENT_BMENTRY} + * elements. + */ + @NotNull + private static final String XML_BMENTRY_NAME = "name"; + + /** + * The name of the "value" attribute within {@link #XML_ELEMENT_BMENTRY} + * elements. + */ + @NotNull + private static final String XML_BMENTRY_VALUE = "value"; + + /** + * The name of the "encoding" attribute within {@link #XML_ELEMENT_BMENTRY} + * elements. + */ + @NotNull + private static final String XML_BMENTRY_ENCODING = "encoding"; + + /** + * The name of the "lists" element. + */ + @NotNull + private static final String XML_ELEMENT_LISTS = "lists"; + + /** + * The name of the "list" element. + */ + @NotNull + private static final String XML_ELEMENT_LIST = "list"; + + /** + * The name of the "name" attribute within {@link #XML_ELEMENT_LIST} + * elements. + */ + @NotNull + private static final String XML_LIST_NAME = "name"; + + /** + * The name of the "listentry" element. + */ + @NotNull + private static final String XML_ELEMENT_LISTENTRY = "listentry"; + + /** + * The name of the "name" attribute within {@link #XML_ELEMENT_LISTENTRY} + * elements. + */ + @NotNull + private static final String XML_LISTENTRY_NAME = "name"; + + /** + * The name of the "value" attribute within {@link #XML_ELEMENT_LISTENTRY} + * elements. + */ + @NotNull + private static final String XML_LISTENTRY_VALUE = "value"; + + /** * The name of the "type" element. */ @NotNull @@ -65,6 +162,39 @@ private static final String XML_TYPE_AVAILABLE = "available"; /** + * The name of the "name" attribute within {@link #XML_ELEMENT_TYPE} or + * {@link #XML_ELEMENT_DEFAULT_TYPE} elements. + */ + @NotNull + public static final String XML_TYPE_NAME = "name"; + + /** + * The name of the "number" attribute within {@link #XML_ELEMENT_TYPE} + * elements. + */ + @NotNull + public static final String XML_TYPE_NUMBER = "number"; + + /** + * The name of the "ignorelists" element. + */ + @NotNull + private static final String XML_ELEMENT_IGNORELISTS = "ignorelists"; + + /** + * The name of the "ignore_list" element. + */ + @NotNull + private static final String XML_ELEMENT_IGNORE_LIST = "ignore_list"; + + /** + * The name of the "name" attribute within {@link #XML_ELEMENT_IGNORE_LIST} + * elements. + */ + @NotNull + private static final String XML_IGNORE_LIST_NAME = "name"; + + /** * The logger for printing log messages. */ @NotNull @@ -77,12 +207,6 @@ private final DocumentBuilder documentBuilder; /** - * The {@link }XPath} for using XPath. - */ - @NotNull - private final XPath xpath; - - /** * The {@link ArchetypeTypeSet} to update. */ @NotNull @@ -97,14 +221,11 @@ /** * Creates a new instance. * @param documentBuilder the document builder to use - * @param xpath the XPath instance to use for applying for XPath - * expressions * @param archetypeTypeSet the archetype type set to update * @param archetypeTypeParser the archetype type parser to use */ - public ArchetypeTypeSetParser(@NotNull final DocumentBuilder documentBuilder, @NotNull final XPath xpath, @NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final ArchetypeTypeParser archetypeTypeParser) { + public ArchetypeTypeSetParser(@NotNull final DocumentBuilder documentBuilder, @NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final ArchetypeTypeParser archetypeTypeParser) { this.documentBuilder = documentBuilder; - this.xpath = xpath; this.archetypeTypeSet = archetypeTypeSet; this.archetypeTypeParser = archetypeTypeParser; } @@ -137,68 +258,77 @@ * file */ public void loadTypesFromXML(@NotNull final ErrorViewCollector errorViewCollector, @NotNull final String filename, @NotNull final Document document) { - try { - final Element rootElement = document.getDocumentElement(); - parseBitmasks(errorViewCollector, rootElement); - parseLists(errorViewCollector, rootElement); - final IgnorelistsDefinition ignorelistsDefinition = parseIgnoreLists(errorViewCollector, rootElement); + final Element rootElement = document.getDocumentElement(); + parseBitmasks(getChild(rootElement, XML_ELEMENT_BITMASKS), errorViewCollector); + parseLists(getChild(rootElement, XML_ELEMENT_LISTS), errorViewCollector); + final IgnorelistsDefinition ignorelistsDefinition = parseIgnoreLists(getChild(rootElement, XML_ELEMENT_IGNORELISTS), errorViewCollector); + parseDefaultType(getChild(rootElement, XML_ELEMENT_DEFAULT_TYPE), errorViewCollector, ignorelistsDefinition); - final Element defaultTypeElement = NodeListIterator.getFirstChild(rootElement, XML_ELEMENT_DEFAULT_TYPE); - assert defaultTypeElement != null; // types.xml makes sure this holds - parseDefaultType(errorViewCollector, defaultTypeElement, ignorelistsDefinition); + final Iterator<Element> typeElements = new NodeListIterator<Element>(rootElement, XML_ELEMENT_TYPE); + while (typeElements.hasNext()) { + parseTypes(typeElements.next(), errorViewCollector, ignorelistsDefinition); + } - final Iterator<Element> typeElements = new NodeListIterator<Element>(rootElement, XML_ELEMENT_TYPE); - while (typeElements.hasNext()) { - parseTypes(typeElements.next(), errorViewCollector, ignorelistsDefinition); - } - - if (log.isInfoEnabled()) { - log.info("Loaded " + archetypeTypeSet.getLength() + " types from '" + filename + "\'"); - } - } catch (final XPathExpressionException e) { - errorViewCollector.addWarning(ErrorViewCategory.INTERNAL_ERROR, "XPath error: " + e.getMessage()); + if (log.isInfoEnabled()) { + log.info("Loaded " + archetypeTypeSet.getLength() + " types from '" + filename + "\'"); } archetypeTypeSet.defineFallbackArchetypeType(); } /** - * Parses the "bitmasks" section of a types.xml file. + * Returns a child {@link Element} of a parent element. The child element + * must exist. + * @param parentElement the parent element + * @param childName the name of the child element + * @return the child element + */ + @NotNull + private static Element getChild(@NotNull final Element parentElement, @NotNull final String childName) { + final Element element = NodeListIterator.getFirstChild(parentElement, childName); + if (element == null) { + throw new IllegalArgumentException("child element '" + childName + "' does not exist"); + } + return element; + } + + /** + * Parses the {@link #XML_ELEMENT_BITMASKS} section of a types.xml file. + * @param bitmasksElement the element to parse * @param errorViewCollector the error view collector for reporting errors - * @param element the element to parse - * @throws XPathExpressionException if an internal error occurs */ - private void parseBitmasks(@NotNull final ErrorViewCollector errorViewCollector, final Element element) throws XPathExpressionException { - final Iterator<Element> it = new NodeListIterator<Element>(xpath, element, "bitmasks/bitmask"); - while (it.hasNext()) { - final Element elem = it.next(); - final AttributeBitmask attributeBitmask = parseBitmask(errorViewCollector, elem); + private void parseBitmasks(@NotNull final Element bitmasksElement, @NotNull final ErrorViewCollector errorViewCollector) { + final Iterator<Element> bitmaskIterator = new NodeListIterator<Element>(bitmasksElement, XML_ELEMENT_BITMASK); + while (bitmaskIterator.hasNext()) { + final Element bitmaskElement = bitmaskIterator.next(); + + final String name = bitmaskElement.getAttribute(XML_BITMASK_NAME); + final AttributeBitmask attributeBitmask = parseBitmask(bitmaskElement, name, errorViewCollector); if (attributeBitmask != null) { - archetypeTypeSet.addBitmask(elem.getAttribute("name"), attributeBitmask); + archetypeTypeSet.addBitmask(name, attributeBitmask); } } } /** - * Parses a "bitmasks/bitmask" section of a types.xml file. + * Parses a {@link #XML_ELEMENT_BITMASK} section of a types.xml file. + * @param bitmaskElement the element to parse + * @param name the name of the bitmask element * @param errorViewCollector the error view collector for reporting errors - * @param element the element to parse or <code>null</code> if the entry is - * invalid - * @return the parsed bitmask attribute - * @throws XPathExpressionException if an internal error occurs + * @return the parsed bitmask attribute or <code>null</code> if the entry is + * invalid */ @Nullable - private AttributeBitmask parseBitmask(@NotNull final ErrorViewCollector errorViewCollector, @NotNull final Element element) throws XPathExpressionException { - final String name = element.getAttribute("name"); - final boolean isNamed = element.getAttribute("is_named").equals("yes"); + private static AttributeBitmask parseBitmask(@NotNull final Element bitmaskElement, @NotNull final String name, @NotNull final ErrorViewCollector errorViewCollector) { + final boolean isNamed = bitmaskElement.getAttribute(XML_BITMASK_IS_NAMED).equals("yes"); final AttributeBitmask attributeBitmask = new AttributeBitmask(isNamed); - final NodeListIterator<Element> entries = new NodeListIterator<Element>(xpath, element, "bmentry"); + final NodeListIterator<Element> entries = new NodeListIterator<Element>(bitmaskElement, XML_ELEMENT_BMENTRY); while (entries.hasNext()) { - parseBmentry(errorViewCollector, entries.next(), name, isNamed, attributeBitmask); + parseBmentry(entries.next(), errorViewCollector, name, isNamed, attributeBitmask); } if (attributeBitmask.getNumber() <= 0) { - errorViewCollector.addWarning(ErrorViewCategory.TYPES_ENTRY_INVALID, name + ": no 'bit' entries"); + errorViewCollector.addWarning(ErrorViewCategory.TYPES_ENTRY_INVALID, name + ": no '" + XML_BMENTRY_BIT + "' entries"); return null; } @@ -215,35 +345,35 @@ } /** - * Parses a "bmentry" section of a types.xml file. + * Parses a {@link #XML_ELEMENT_BMENTRY} section of a types.xml file. * @param errorViewCollector the error view collector for reporting errors - * @param element the "bmentry" section to parse + * @param bmentryElement the "bmentry" section to parse * @param bitmaskName the name of the parent's "bitmask" section for error * messages * @param isNamed whether the bitmask attribute is named * @param attributeBitmask the bitmask attribute to update */ - private static void parseBmentry(@NotNull final ErrorViewCollector errorViewCollector, @NotNull final Element element, @NotNull final String bitmaskName, final boolean isNamed, @NotNull final AttributeBitmask attributeBitmask) { - final String bitAttribute = element.getAttribute("bit"); + private static void parseBmentry(@NotNull final Element bmentryElement, @NotNull final ErrorViewCollector errorViewCollector, @NotNull final String bitmaskName, final boolean isNamed, @NotNull final AttributeBitmask attributeBitmask) { + final String bitAttribute = bmentryElement.getAttribute(XML_BMENTRY_BIT); - final String valueAttribute = element.getAttribute("value"); + final String valueAttribute = bmentryElement.getAttribute(XML_BMENTRY_VALUE); if (bitAttribute.length() != 0 && valueAttribute.length() != 0) { - errorViewCollector.addWarning(ErrorViewCategory.TYPES_ENTRY_INVALID, bitmaskName + ": element contains both 'bit' and 'value' attributes"); + errorViewCollector.addWarning(ErrorViewCategory.TYPES_ENTRY_INVALID, bitmaskName + ": element contains both '" + XML_BMENTRY_BIT + "' and '" + XML_BMENTRY_VALUE + "' attributes"); return; } - final String name = element.getAttribute("name"); + final String name = bmentryElement.getAttribute(XML_BMENTRY_NAME); final int value; if (bitAttribute.length() == 0) { if (!isNamed) { - errorViewCollector.addWarning(ErrorViewCategory.TYPES_ENTRY_INVALID, bitmaskName + ": 'value' attribute allowed only in named bitmasks"); + errorViewCollector.addWarning(ErrorViewCategory.TYPES_ENTRY_INVALID, bitmaskName + ": '" + XML_BMENTRY_VALUE + "' attribute allowed only in named bitmasks"); return; } try { value = Integer.parseInt(valueAttribute); } catch (final NumberFormatException ignored) { - errorViewCollector.addWarning(ErrorViewCategory.TYPES_ENTRY_INVALID, bitmaskName + ": invalid 'value' value: " + valueAttribute); + errorViewCollector.addWarning(ErrorViewCategory.TYPES_ENTRY_INVALID, bitmaskName + ": invalid '" + XML_BMENTRY_VALUE + "' value: " + valueAttribute); return; } } else { @@ -251,15 +381,15 @@ try { bitValue = Integer.parseInt(bitAttribute); } catch (final NumberFormatException ignored) { - errorViewCollector.addWarning(ErrorViewCategory.TYPES_ENTRY_INVALID, bitmaskName + ": invalid 'bit' value: " + bitAttribute); + errorViewCollector.addWarning(ErrorViewCategory.TYPES_ENTRY_INVALID, bitmaskName + ": invalid '" + ... [truncated message content] |
From: <aki...@us...> - 2010-05-26 18:39:38
|
Revision: 8001 http://gridarta.svn.sourceforge.net/gridarta/?rev=8001&view=rev Author: akirschbaum Date: 2010-05-26 18:39:32 +0000 (Wed, 26 May 2010) Log Message: ----------- Implement #2093373 (Ability to import more than one type). Modified Paths: -------------- trunk/atrinik/ChangeLog trunk/crossfire/ChangeLog trunk/daimonin/ChangeLog trunk/resource/system/dtd/types.dtd trunk/src/app/net/sf/gridarta/model/archetypetype/ArchetypeTypeParser.java trunk/src/test/net/sf/gridarta/model/archetypetype/ArchetypeTypeSetParserTest.java Modified: trunk/atrinik/ChangeLog =================================================================== --- trunk/atrinik/ChangeLog 2010-05-26 18:19:27 UTC (rev 8000) +++ trunk/atrinik/ChangeLog 2010-05-26 18:39:32 UTC (rev 8001) @@ -1,3 +1,9 @@ +2010-05-26 Andreas Kirschbaum + + * Implement #2093373 (Ability to import more than one type). Now + types.xml is "<!ELEMENT type (import_type*..." rather than + "...import_type?...". + 2010-05-24 Andreas Kirschbaum * Fix edit operations involving multi-square game objects. Modified: trunk/crossfire/ChangeLog =================================================================== --- trunk/crossfire/ChangeLog 2010-05-26 18:19:27 UTC (rev 8000) +++ trunk/crossfire/ChangeLog 2010-05-26 18:39:32 UTC (rev 8001) @@ -1,3 +1,9 @@ +2010-05-26 Andreas Kirschbaum + + * Implement #2093373 (Ability to import more than one type). Now + types.xml is "<!ELEMENT type (import_type*..." rather than + "...import_type?...". + 2010-05-24 Andreas Kirschbaum * Fix edit operations involving multi-square game objects. Modified: trunk/daimonin/ChangeLog =================================================================== --- trunk/daimonin/ChangeLog 2010-05-26 18:19:27 UTC (rev 8000) +++ trunk/daimonin/ChangeLog 2010-05-26 18:39:32 UTC (rev 8001) @@ -1,3 +1,9 @@ +2010-05-26 Andreas Kirschbaum + + * Implement #2093373 (Ability to import more than one type). Now + types.xml is "<!ELEMENT type (import_type*..." rather than + "...import_type?...". + 2010-05-24 Andreas Kirschbaum * Fix edit operations involving multi-square game objects. Modified: trunk/resource/system/dtd/types.dtd =================================================================== --- trunk/resource/system/dtd/types.dtd 2010-05-26 18:19:27 UTC (rev 8000) +++ trunk/resource/system/dtd/types.dtd 2010-05-26 18:39:32 UTC (rev 8001) @@ -88,9 +88,12 @@ xml:base CDATA #IMPLIED > +<!-- import_type: imports are applied in the given order; attributes defined in + the type or in a preceding import_type are not imported; the default_type + is implicitly imported at the end. --> <!-- available: the type is ignored when set to "no"; can be used to temporarily disable type definitions. --> -<!ELEMENT type (import_type?,required?,ignore?,description?,use?,(section | attribute)*)> +<!ELEMENT type (import_type*,required?,ignore?,description?,use?,(section | attribute)*)> <!ATTLIST type xml:base CDATA #IMPLIED name CDATA #REQUIRED Modified: trunk/src/app/net/sf/gridarta/model/archetypetype/ArchetypeTypeParser.java =================================================================== --- trunk/src/app/net/sf/gridarta/model/archetypetype/ArchetypeTypeParser.java 2010-05-26 18:19:27 UTC (rev 8000) +++ trunk/src/app/net/sf/gridarta/model/archetypetype/ArchetypeTypeParser.java 2010-05-26 18:39:32 UTC (rev 8001) @@ -22,6 +22,7 @@ import java.util.Collection; import java.util.HashSet; import java.util.Iterator; +import java.util.LinkedHashSet; import net.sf.gridarta.model.errorview.ErrorViewCategory; import net.sf.gridarta.model.errorview.ErrorViewCollector; import net.sf.japi.xml.NodeListIterator; @@ -150,8 +151,15 @@ final Collection<String> ignoreTable = new HashSet<String>(); final ArchetypeAttributesDefinition typeAttributes = isDefaultType ? new ArchetypeAttributesDefinition() : parseTypeAttributes(typeElement, typeName, errorViewCollector, ignoreTable, ignorelistsDefinition); - final Element importTypeElement = NodeListIterator.getFirstChild(typeElement, XML_ELEMENT_IMPORT_TYPE); - final String importType = importTypeElement == null ? null : parseImportType(importTypeElement, typeName, errorViewCollector); + final Collection<String> importTypes = new LinkedHashSet<String>(); + final Iterator<Element> importTypeIterator = new NodeListIterator<Element>(typeElement, XML_ELEMENT_IMPORT_TYPE); + while (importTypeIterator.hasNext()) { + final Element importTypeElement = importTypeIterator.next(); + final String importType = parseImportType(importTypeElement, typeName, errorViewCollector); + if (importType != null && !importTypes.add(importType)) { + errorViewCollector.addWarning(ErrorViewCategory.TYPES_ENTRY_INVALID, "type " + typeName + " has duplicate import for '" + importType + "'."); + } + } final ArchetypeAttributes attributes = new ArchetypeAttributes(); final SectionNames sectionNames = new SectionNames(); @@ -162,10 +170,13 @@ autoIgnoreTable.add(attribute.getArchetypeAttributeName()); } + if (archetypeType.hasAttribute()) { + for (final String importType : importTypes) { + addImportList(importType, attributes, errorViewCollector, typeName, archetypeTypeSet, autoIgnoreTable); + } + } + addDefaultList(archetypeType, attributes, autoIgnoreTable, ignoreTable); - if (importType != null && archetypeType.hasAttribute()) { - addImportList(importType, attributes, errorViewCollector, typeName, archetypeTypeSet, autoIgnoreTable); - } } attributes.setSectionNames(sectionNames); @@ -196,7 +207,8 @@ * @param errorViewCollector the error view collector for reporting errors * @param typeName the type name for error messages * @param archetypeTypeSet the archetype type set - * @param autoIgnoreTable the attributes to ignore + * @param autoIgnoreTable the attributes to ignore; imported attributes are + * added */ private static void addImportList(@NotNull final String importName, @NotNull final ArchetypeAttributes attributes, @NotNull final ErrorViewCollector errorViewCollector, @NotNull final String typeName, @NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final Collection<String> autoIgnoreTable) { final Iterable<ArchetypeAttribute> importType = archetypeTypeSet.getArchetypeType(importName); @@ -206,7 +218,8 @@ } for (final ArchetypeAttribute archetypeAttribute : importType) { - if (autoIgnoreTable.contains(archetypeAttribute.getArchetypeAttributeName())) { + final String attributeName = archetypeAttribute.getArchetypeAttributeName(); + if (autoIgnoreTable.contains(attributeName)) { continue; } @@ -215,6 +228,7 @@ } attributes.add(archetypeAttribute.clone()); + autoIgnoreTable.add(attributeName); } } Modified: trunk/src/test/net/sf/gridarta/model/archetypetype/ArchetypeTypeSetParserTest.java =================================================================== --- trunk/src/test/net/sf/gridarta/model/archetypetype/ArchetypeTypeSetParserTest.java 2010-05-26 18:19:27 UTC (rev 8000) +++ trunk/src/test/net/sf/gridarta/model/archetypetype/ArchetypeTypeSetParserTest.java 2010-05-26 18:39:32 UTC (rev 8001) @@ -130,10 +130,144 @@ + "string/name2_attr1[name2] section=1/Special\n" + "string/name1_attr2[name2] section=1/Special\n" + "string/default_attr2[name2] section=1/Special\n" + /* imports */ + + "string/name1_attr1[name1] section=1/Special\n" /* defaults */ + "string/default_attr1[default] section=0/General\n" + + "\n"); + } + + /** + * Checks that multi-imports do work. + * @throws ParserConfigurationException if the test fails + * @throws UnsupportedEncodingException if the test fails + */ + @Test + public void testImport2() throws ParserConfigurationException, UnsupportedEncodingException { + check("<bitmasks/>\n" + + "<lists/>\n" + + "<ignorelists/>\n" + + "<default_type>\n" + + "<attribute arch=\"attr1\" editor=\"default\" type=\"string\">description</attribute>\n" + + "<attribute arch=\"attr3\" editor=\"default\" type=\"string\">description</attribute>\n" + + "<attribute arch=\"attr5\" editor=\"default\" type=\"string\">description</attribute>\n" + + "<attribute arch=\"attr7\" editor=\"default\" type=\"string\">description</attribute>\n" + + "<attribute arch=\"attr9\" editor=\"default\" type=\"string\">description</attribute>\n" + + "<attribute arch=\"attrB\" editor=\"default\" type=\"string\">description</attribute>\n" + + "<attribute arch=\"attrD\" editor=\"default\" type=\"string\">description</attribute>\n" + + "<attribute arch=\"attrF\" editor=\"default\" type=\"string\">description</attribute>\n" + + "</default_type>\n" + + "<type number=\"1\" name=\"name1\">\n" + + "<description>description1</description>\n" + + "<attribute arch=\"attr2\" editor=\"name1\" type=\"string\">description</attribute>\n" + + "<attribute arch=\"attr3\" editor=\"name1\" type=\"string\">description</attribute>\n" + + "<attribute arch=\"attr6\" editor=\"name1\" type=\"string\">description</attribute>\n" + + "<attribute arch=\"attr7\" editor=\"name1\" type=\"string\">description</attribute>\n" + + "<attribute arch=\"attrA\" editor=\"name1\" type=\"string\">description</attribute>\n" + + "<attribute arch=\"attrB\" editor=\"name1\" type=\"string\">description</attribute>\n" + + "<attribute arch=\"attrE\" editor=\"name1\" type=\"string\">description</attribute>\n" + + "<attribute arch=\"attrF\" editor=\"name1\" type=\"string\">description</attribute>\n" + + "</type>\n" + + "<type number=\"2\" name=\"name2\">\n" + + "<description>description2</description>\n" + + "<attribute arch=\"attr4\" editor=\"name2\" type=\"string\">description</attribute>\n" + + "<attribute arch=\"attr5\" editor=\"name2\" type=\"string\">description</attribute>\n" + + "<attribute arch=\"attr6\" editor=\"name2\" type=\"string\">description</attribute>\n" + + "<attribute arch=\"attr7\" editor=\"name2\" type=\"string\">description</attribute>\n" + + "<attribute arch=\"attrC\" editor=\"name2\" type=\"string\">description</attribute>\n" + + "<attribute arch=\"attrD\" editor=\"name2\" type=\"string\">description</attribute>\n" + + "<attribute arch=\"attrE\" editor=\"name2\" type=\"string\">description</attribute>\n" + + "<attribute arch=\"attrF\" editor=\"name2\" type=\"string\">description</attribute>\n" + + "</type>\n" + + "<type number=\"3\" name=\"name3\">\n" + + "<import_type name=\"name1\"/>\n" + + "<import_type name=\"name2\"/>\n" + + "<description>description3</description>\n" + + "<attribute arch=\"attr8\" editor=\"name3\" type=\"string\">description</attribute>\n" + + "<attribute arch=\"attr9\" editor=\"name3\" type=\"string\">description</attribute>\n" + + "<attribute arch=\"attrA\" editor=\"name3\" type=\"string\">description</attribute>\n" + + "<attribute arch=\"attrB\" editor=\"name3\" type=\"string\">description</attribute>\n" + + "<attribute arch=\"attrC\" editor=\"name3\" type=\"string\">description</attribute>\n" + + "<attribute arch=\"attrD\" editor=\"name3\" type=\"string\">description</attribute>\n" + + "<attribute arch=\"attrE\" editor=\"name3\" type=\"string\">description</attribute>\n" + + "<attribute arch=\"attrF\" editor=\"name3\" type=\"string\">description</attribute>\n" + + "</type>\n" + + "", + false, + "default_type:-1,default\n" + + ":\n" + + ":\n" + /* attributes */ + + "string/attr1[default] section=0/General\n" + + "string/attr3[default] section=0/General\n" + + "string/attr5[default] section=0/General\n" + + "string/attr7[default] section=0/General\n" + + "string/attr9[default] section=0/General\n" + + "string/attrB[default] section=0/General\n" + + "string/attrD[default] section=0/General\n" + + "string/attrF[default] section=0/General\n" + /* defaults */ /* imports */ - + "string/name1_attr1[name1] section=1/Special\n" + + "\n" + + "type:1,name1\n" + + ":\n" + + ":\n" + /* attributes */ + + "string/attr2[name1] section=1/Special\n" + + "string/attr3[name1] section=1/Special\n" + + "string/attr6[name1] section=1/Special\n" + + "string/attr7[name1] section=1/Special\n" + + "string/attrA[name1] section=1/Special\n" + + "string/attrB[name1] section=1/Special\n" + + "string/attrE[name1] section=1/Special\n" + + "string/attrF[name1] section=1/Special\n" + /* defaults */ + + "string/attr1[default] section=0/General\n" + + "string/attr5[default] section=0/General\n" + + "string/attr9[default] section=0/General\n" + + "string/attrD[default] section=0/General\n" + /* imports */ + + "\n" + + "type:2,name2\n" + + ":\n" + + ":\n" + /* attributes */ + + "string/attr4[name2] section=1/Special\n" + + "string/attr5[name2] section=1/Special\n" + + "string/attr6[name2] section=1/Special\n" + + "string/attr7[name2] section=1/Special\n" + + "string/attrC[name2] section=1/Special\n" + + "string/attrD[name2] section=1/Special\n" + + "string/attrE[name2] section=1/Special\n" + + "string/attrF[name2] section=1/Special\n" + /* defaults */ + + "string/attr1[default] section=0/General\n" + + "string/attr3[default] section=0/General\n" + + "string/attr9[default] section=0/General\n" + + "string/attrB[default] section=0/General\n" + /* attributes */ + /* imports */ + + "\n" + + "type:3,name3\n" + + ":\n" + + ":\n" + + "string/attr8[name3] section=1/Special\n" + + "string/attr9[name3] section=1/Special\n" + + "string/attrA[name3] section=1/Special\n" + + "string/attrB[name3] section=1/Special\n" + + "string/attrC[name3] section=1/Special\n" + + "string/attrD[name3] section=1/Special\n" + + "string/attrE[name3] section=1/Special\n" + + "string/attrF[name3] section=1/Special\n" + /* imports */ + + "string/attr2[name1] section=1/Special\n" + + "string/attr3[name1] section=1/Special\n" + + "string/attr6[name1] section=1/Special\n" + + "string/attr7[name1] section=1/Special\n" + + "string/attr4[name2] section=1/Special\n" + + "string/attr5[name2] section=1/Special\n" + /* defaults */ + + "string/attr1[default] section=0/General\n" + "\n"); } @@ -168,10 +302,10 @@ + "type:1,name1\n" + ":\n" + ":\n" + /* attributes */ + /* imports */ /* defaults */ + "string/default_attr2[default] section=0/General\n" - /* attributes */ - /* imports */ + "\n"); } @@ -218,11 +352,11 @@ + ":\n" + ":\n" /* attributes */ - /* defaults */ - + "string/default_attr1[default] section=0/General\n" /* imports */ + "string/name1_attr1[name1] section=1/Special\n" // imported attributes are not affected by ignores + "string/name1_attr2[name1] section=1/Special\n" + /* defaults */ + + "string/default_attr1[default] section=0/General\n" + "\n"); } @@ -257,8 +391,8 @@ /* attributes */ + "string/name1_attr1[name1] section=1/Special\n" // defined attributes are not affected by ignores + "string/name1_attr2[name1] section=1/Special\n" + /* imports */ /* defaults */ - /* imports */ + "\n"); } @@ -288,9 +422,9 @@ + ":\n" + ":\n" /* attributes */ + /* imports */ /* defaults */ + "text/msg[default] section=2/default\n" - /* imports */ + "\n"); } @@ -323,8 +457,8 @@ + ":\n" /* attributes */ + "text/msg[name1] section=2/name1\n" + /* imports */ /* defaults */ - /* imports */ + "\n"); } @@ -357,8 +491,8 @@ + ":\n" + ":\n" /* attributes */ + /* imports */ /* defaults */ - /* imports */ + "\n"); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-05-26 20:20:04
|
Revision: 8008 http://gridarta.svn.sourceforge.net/gridarta/?rev=8008&view=rev Author: akirschbaum Date: 2010-05-26 20:19:58 +0000 (Wed, 26 May 2010) Log Message: ----------- Make sure the updater dialogs are displayed in front of the main window. Modified Paths: -------------- trunk/atrinik/ChangeLog trunk/crossfire/ChangeLog trunk/daimonin/ChangeLog trunk/src/app/net/sf/gridarta/maincontrol/GUIMainControl.java Modified: trunk/atrinik/ChangeLog =================================================================== --- trunk/atrinik/ChangeLog 2010-05-26 20:15:56 UTC (rev 8007) +++ trunk/atrinik/ChangeLog 2010-05-26 20:19:58 UTC (rev 8008) @@ -1,5 +1,8 @@ 2010-05-26 Andreas Kirschbaum + * Make sure the updater dialogs are displayed in front of the main + window. + * Implement #2093373 (Ability to import more than one type). Now types.xml is "<!ELEMENT type (import_type*..." rather than "...import_type?...". Modified: trunk/crossfire/ChangeLog =================================================================== --- trunk/crossfire/ChangeLog 2010-05-26 20:15:56 UTC (rev 8007) +++ trunk/crossfire/ChangeLog 2010-05-26 20:19:58 UTC (rev 8008) @@ -1,5 +1,8 @@ 2010-05-26 Andreas Kirschbaum + * Make sure the updater dialogs are displayed in front of the main + window. + * Implement #2093373 (Ability to import more than one type). Now types.xml is "<!ELEMENT type (import_type*..." rather than "...import_type?...". Modified: trunk/daimonin/ChangeLog =================================================================== --- trunk/daimonin/ChangeLog 2010-05-26 20:15:56 UTC (rev 8007) +++ trunk/daimonin/ChangeLog 2010-05-26 20:19:58 UTC (rev 8008) @@ -1,5 +1,8 @@ 2010-05-26 Andreas Kirschbaum + * Make sure the updater dialogs are displayed in front of the main + window. + * Implement #2093373 (Ability to import more than one type). Now types.xml is "<!ELEMENT type (import_type*..." rather than "...import_type?...". Modified: trunk/src/app/net/sf/gridarta/maincontrol/GUIMainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/maincontrol/GUIMainControl.java 2010-05-26 20:15:56 UTC (rev 8007) +++ trunk/src/app/net/sf/gridarta/maincontrol/GUIMainControl.java 2010-05-26 20:19:58 UTC (rev 8008) @@ -339,6 +339,12 @@ private final ShortcutsManager shortcutsManager; /** + * The {@link UpdaterManager} instance. + */ + @NotNull + private final UpdaterManager updaterManager; + + /** * Creates a new instance. * @param createDirectionPane whether the direction panel should be created * @param mapManager the map manager @@ -459,8 +465,7 @@ final ToolPalette<G, A, R> toolPalette = new ToolPalette<G, A, R>(mapViewSettings, selectedSquareView, selectedSquareModel, objectChooser, pickmapChooserControl, floorMatcher, wallMatcher, monsterMatcher, insertionModeSet); new FindArchetypesDialogManager<G, A, R>(mainViewFrame, archetypeChooserControl, objectChooser, archetypeTypeSet); new UndoControl<G, A, R>(mapManager, gameObjectFactory, gameObjectMatchers); - final UpdaterManager updaterManager = new UpdaterManager(exiter, mapManager, mainViewFrame, gridartaJarFilename); - updaterManager.startup(); + updaterManager = new UpdaterManager(exiter, mapManager, mainViewFrame, gridartaJarFilename); final GameObjectAttributesTab<G, A, R> textEditorTab = new TextEditorTab<G, A, R>(gameObjectAttributesModel, archetypeTypeSet); final GameObjectTab<G, A, R> gameObjectTab = new GameObjectTab<G, A, R>("gameObject", gameObjectAttributesControl, Location.BOTTOM, 0, true); @@ -812,6 +817,7 @@ public void run(@NotNull final Iterable<String> args) { mainViewFrame.setVisible(true); TipOfTheDayManager.showAtStartup(mainViewFrame); + updaterManager.startup(); openFiles(args); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-05-26 20:42:22
|
Revision: 8010 http://gridarta.svn.sourceforge.net/gridarta/?rev=8010&view=rev Author: akirschbaum Date: 2010-05-26 20:42:15 +0000 (Wed, 26 May 2010) Log Message: ----------- Remve outdated TODO comments. Modified Paths: -------------- trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/model/gameobject/GameObject.java trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/model/gameobject/GameObject.java trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/model/gameobject/GameObject.java trunk/src/app/net/sf/gridarta/gui/archetypechooser/ArchetypeChooserControl.java trunk/src/app/net/sf/gridarta/gui/mapuserlistener/MapUserListener.java trunk/src/app/net/sf/gridarta/mapmanager/DefaultFileControl.java trunk/src/app/net/sf/gridarta/model/baseobject/BaseObject.java trunk/src/app/net/sf/gridarta/model/baseobject/GameObjectContainer.java trunk/src/app/net/sf/gridarta/model/map/maparchobject/MapArchObject.java trunk/src/app/net/sf/gridarta/model/map/mapmodel/DefaultMapModel.java trunk/src/app/net/sf/gridarta/model/spells/Spells.java trunk/src/app/net/sf/gridarta/script/Script.java Modified: trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/model/gameobject/GameObject.java =================================================================== --- trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/model/gameobject/GameObject.java 2010-05-26 20:24:23 UTC (rev 8009) +++ trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/model/gameobject/GameObject.java 2010-05-26 20:42:15 UTC (rev 8010) @@ -35,11 +35,6 @@ * @author <a href="mailto:mic...@no...">Michael Toennies</a> * @author <a href="mailto:and...@gm...">Andreas Vogl</a> * @author <a href="mailto:ch...@ri...">Christian Hujer</a> - * @todo the archobject should be directly asked for a face, and eventually it - * should cache faces itself; that would speed up painting maps - * @todo this class maybe could be split into 3 classes: AbstractArchObject as - * abstract base class, DefArchObject for default arches and GameObject for - * normal arches. * @todo this class is not always the best place for multipart object handling, * see also {@link net.sf.gridarta.model.baseobject.GameObjectContainer} for * issues about this Modified: trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/model/gameobject/GameObject.java =================================================================== --- trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/model/gameobject/GameObject.java 2010-05-26 20:24:23 UTC (rev 8009) +++ trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/model/gameobject/GameObject.java 2010-05-26 20:42:15 UTC (rev 8010) @@ -36,11 +36,6 @@ * @author <a href="mailto:mic...@no...">Michael Toennies</a> * @author <a href="mailto:and...@gm...">Andreas Vogl</a> * @author <a href="mailto:ch...@ri...">Christian Hujer</a> - * @todo the archobject should be directly asked for a face, and eventually it - * should cache faces itself; that would speed up painting maps - * @todo this class maybe could be split into 3 classes: AbstractArchObject as - * abstract base class, DefArchObject for default arches and GameObject for - * normal arches. * @todo this class is not always the best place for multipart object handling, * see also {@link net.sf.gridarta.model.baseobject.GameObjectContainer} for * issues about this Modified: trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/model/gameobject/GameObject.java =================================================================== --- trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/model/gameobject/GameObject.java 2010-05-26 20:24:23 UTC (rev 8009) +++ trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/model/gameobject/GameObject.java 2010-05-26 20:42:15 UTC (rev 8010) @@ -35,11 +35,6 @@ * @author <a href="mailto:mic...@no...">Michael Toennies</a> * @author <a href="mailto:and...@gm...">Andreas Vogl</a> * @author <a href="mailto:ch...@ri...">Christian Hujer</a> - * @todo the archobject should be directly asked for a face, and eventually it - * should cache faces itself; that would speed up painting maps - * @todo this class maybe could be split into 3 classes: AbstractArchObject as - * abstract base class, DefArchObject for default arches and GameObject for - * normal arches. * @todo this class is not always the best place for multipart object handling, * see also {@link net.sf.gridarta.model.baseobject.GameObjectContainer} for * issues about this Modified: trunk/src/app/net/sf/gridarta/gui/archetypechooser/ArchetypeChooserControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/archetypechooser/ArchetypeChooserControl.java 2010-05-26 20:24:23 UTC (rev 8009) +++ trunk/src/app/net/sf/gridarta/gui/archetypechooser/ArchetypeChooserControl.java 2010-05-26 20:42:15 UTC (rev 8010) @@ -147,7 +147,7 @@ @Override public R getSelection() { final ArchetypeChooserPanel<G, A, R> selectedPanel = archetypeChooserModel.getSelectedPanel(); - return selectedPanel != null ? selectedPanel.getSelectedFolder().getSelectedArchetype() : null; // XXX: should not cast Archetype -> GameObject + return selectedPanel != null ? selectedPanel.getSelectedFolder().getSelectedArchetype() : null; } /** @@ -155,7 +155,7 @@ */ @NotNull @Override - public List<R> getSelections() { // XXX: should return List<Archetype<G, A, R>> + public List<R> getSelections() { final R archObject = getSelection(); if (archObject == null) { return Collections.emptyList(); Modified: trunk/src/app/net/sf/gridarta/gui/mapuserlistener/MapUserListener.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/mapuserlistener/MapUserListener.java 2010-05-26 20:24:23 UTC (rev 8009) +++ trunk/src/app/net/sf/gridarta/gui/mapuserlistener/MapUserListener.java 2010-05-26 20:42:15 UTC (rev 8010) @@ -35,7 +35,6 @@ import org.jetbrains.annotations.Nullable; /** - * TODO Description. * @author <a href="mailto:dlv...@gm...">Daniel Viegas</a> */ public class MapUserListener<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> implements MouseListener, MouseMotionListener { Modified: trunk/src/app/net/sf/gridarta/mapmanager/DefaultFileControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/mapmanager/DefaultFileControl.java 2010-05-26 20:24:23 UTC (rev 8009) +++ trunk/src/app/net/sf/gridarta/mapmanager/DefaultFileControl.java 2010-05-26 20:42:15 UTC (rev 8010) @@ -229,8 +229,7 @@ } } else if (!file.exists()) { if (isScriptFile) { - // TODO: pass filename - scriptEditControl.newScript(); + scriptEditControl.newScript(); // TODO: pass filename } else { newMapDialogFactory.newMap(); // XXX: pass file } Modified: trunk/src/app/net/sf/gridarta/model/baseobject/BaseObject.java =================================================================== --- trunk/src/app/net/sf/gridarta/model/baseobject/BaseObject.java 2010-05-26 20:24:23 UTC (rev 8009) +++ trunk/src/app/net/sf/gridarta/model/baseobject/BaseObject.java 2010-05-26 20:42:15 UTC (rev 8010) @@ -319,7 +319,6 @@ * @return next of this multipart object or <code>null</code> if this isn't * a multipart object or this is the last part of a multipart * object. - * @todo check whether this should return G or Archetype<G> */ @Nullable T getMultiNext(); Modified: trunk/src/app/net/sf/gridarta/model/baseobject/GameObjectContainer.java =================================================================== --- trunk/src/app/net/sf/gridarta/model/baseobject/GameObjectContainer.java 2010-05-26 20:24:23 UTC (rev 8009) +++ trunk/src/app/net/sf/gridarta/model/baseobject/GameObjectContainer.java 2010-05-26 20:42:15 UTC (rev 8010) @@ -589,8 +589,6 @@ /** * {@inheritDoc} - * @todo either this class should be Cloneable or the catch clause needs to - * be changed. */ @NotNull @Override Modified: trunk/src/app/net/sf/gridarta/model/map/maparchobject/MapArchObject.java =================================================================== --- trunk/src/app/net/sf/gridarta/model/map/maparchobject/MapArchObject.java 2010-05-26 20:24:23 UTC (rev 8009) +++ trunk/src/app/net/sf/gridarta/model/map/maparchobject/MapArchObject.java 2010-05-26 20:42:15 UTC (rev 8010) @@ -270,8 +270,6 @@ /** * Returns the message text. * @return The message text. - * @todo original comment said returns map text, so what does it? return map - * text or message text? */ @NotNull String getText(); Modified: trunk/src/app/net/sf/gridarta/model/map/mapmodel/DefaultMapModel.java =================================================================== --- trunk/src/app/net/sf/gridarta/model/map/mapmodel/DefaultMapModel.java 2010-05-26 20:24:23 UTC (rev 8009) +++ trunk/src/app/net/sf/gridarta/model/map/mapmodel/DefaultMapModel.java 2010-05-26 20:42:15 UTC (rev 8010) @@ -725,9 +725,6 @@ * @retval <code>true</code> if the multi-square arch would still fit on * this map * @retval <code>false</code> otherwise - * @todo discuss whether this method really belongs to the interface of - * MapModel as it is only used by MapModel implementations and heavily - * depends on how arches, especially multi-square arches are implemented. */ private boolean isMultiArchFittingToMap(@NotNull final Archetype<G, A, R> archetype, @NotNull final Point pos, final boolean allowDouble) { for (Archetype<G, A, R> part = archetype; part != null; part = part.getMultiNext()) { Modified: trunk/src/app/net/sf/gridarta/model/spells/Spells.java =================================================================== --- trunk/src/app/net/sf/gridarta/model/spells/Spells.java 2010-05-26 20:24:23 UTC (rev 8009) +++ trunk/src/app/net/sf/gridarta/model/spells/Spells.java 2010-05-26 20:42:15 UTC (rev 8010) @@ -29,7 +29,6 @@ /** * Common base class for spells and spell lists. * @author <a href="mailto:ch...@ri...">Christian Hujer</a> - * @todo move spell related stuff from CFArchTypeList to this class. */ public class Spells<S extends Spell> implements Iterable<S> { Modified: trunk/src/app/net/sf/gridarta/script/Script.java =================================================================== --- trunk/src/app/net/sf/gridarta/script/Script.java 2010-05-26 20:24:23 UTC (rev 8009) +++ trunk/src/app/net/sf/gridarta/script/Script.java 2010-05-26 20:42:15 UTC (rev 8010) @@ -104,10 +104,8 @@ } /** - * Returns the code of this ScriptModel. - * @return The code of this ScriptModel. - * @todo Improve name - what code is it? Source code? A special coded - * String? + * Returns the source code of this script model. + * @return the source code of this script model */ public String getCode() { return code; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-05-26 20:48:43
|
Revision: 8011 http://gridarta.svn.sourceforge.net/gridarta/?rev=8011&view=rev Author: akirschbaum Date: 2010-05-26 20:48:36 +0000 (Wed, 26 May 2010) Log Message: ----------- Retain customized attributes when replacing with multi-part game objects from pickmaps. Modified Paths: -------------- trunk/atrinik/ChangeLog trunk/crossfire/ChangeLog trunk/daimonin/ChangeLog trunk/src/app/net/sf/gridarta/gui/replacedialog/ReplaceDialog.java Modified: trunk/atrinik/ChangeLog =================================================================== --- trunk/atrinik/ChangeLog 2010-05-26 20:42:15 UTC (rev 8010) +++ trunk/atrinik/ChangeLog 2010-05-26 20:48:36 UTC (rev 8011) @@ -1,5 +1,8 @@ 2010-05-26 Andreas Kirschbaum + * Retain customized attributes when replacing with multi-part game + objects from pickmaps. + * Make sure the updater dialogs are displayed in front of the main window. Modified: trunk/crossfire/ChangeLog =================================================================== --- trunk/crossfire/ChangeLog 2010-05-26 20:42:15 UTC (rev 8010) +++ trunk/crossfire/ChangeLog 2010-05-26 20:48:36 UTC (rev 8011) @@ -1,5 +1,8 @@ 2010-05-26 Andreas Kirschbaum + * Retain customized attributes when replacing with multi-part game + objects from pickmaps. + * Make sure the updater dialogs are displayed in front of the main window. Modified: trunk/daimonin/ChangeLog =================================================================== --- trunk/daimonin/ChangeLog 2010-05-26 20:42:15 UTC (rev 8010) +++ trunk/daimonin/ChangeLog 2010-05-26 20:48:36 UTC (rev 8011) @@ -1,5 +1,8 @@ 2010-05-26 Andreas Kirschbaum + * Retain customized attributes when replacing with multi-part game + objects from pickmaps. + * Make sure the updater dialogs are displayed in front of the main window. Modified: trunk/src/app/net/sf/gridarta/gui/replacedialog/ReplaceDialog.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/replacedialog/ReplaceDialog.java 2010-05-26 20:42:15 UTC (rev 8010) +++ trunk/src/app/net/sf/gridarta/gui/replacedialog/ReplaceDialog.java 2010-05-26 20:48:36 UTC (rev 8011) @@ -493,10 +493,7 @@ } // insert replacement object if (randomArch.isMulti()) { - // multi's cannot be inserted properly, so we just put them ontop - mapModel.insertBaseObject(randomArch.getArchetype(), new Point(square.getMapX(), square.getMapY()), false, false, insertionModeSet.getTopmostInsertionMode()); - - // TODO: if from pickmap it could have special attributes -> copy them + mapModel.insertBaseObject(randomArch, new Point(square.getMapX(), square.getMapY()), false, false, insertionModeSet.getTopmostInsertionMode()); } else { mapModel.insertArchToMap(randomArch, prevArch, new Point(square.getMapX(), square.getMapY()), false); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-05-26 21:35:16
|
Revision: 8014 http://gridarta.svn.sourceforge.net/gridarta/?rev=8014&view=rev Author: akirschbaum Date: 2010-05-26 21:35:09 +0000 (Wed, 26 May 2010) Log Message: ----------- Extract duplicated code into NumberUtils. Modified Paths: -------------- trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/model/io/MapArchObjectParser.java trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/model/io/MapArchObjectParser.java trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/model/io/MapArchObjectParser.java trunk/src/app/net/sf/gridarta/gui/newmap/AbstractMapsizeNewMapDialog.java trunk/src/app/net/sf/gridarta/gui/newmap/NewMapDialog.java trunk/src/app/net/sf/gridarta/mainactions/MainActions.java trunk/src/app/net/sf/gridarta/model/archetypetype/AttributeBitmask.java trunk/src/app/net/sf/gridarta/model/baseobject/AbstractBaseObject.java trunk/src/app/net/sf/gridarta/model/io/AbstractMapArchObjectParser.java trunk/src/app/net/sf/gridarta/script/parameter/DoubleParameter.java trunk/src/app/net/sf/gridarta/utils/ActionBuilderUtils.java Added Paths: ----------- trunk/src/app/net/sf/gridarta/utils/NumberUtils.java Modified: trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/model/io/MapArchObjectParser.java =================================================================== --- trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/model/io/MapArchObjectParser.java 2010-05-26 21:34:40 UTC (rev 8013) +++ trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/model/io/MapArchObjectParser.java 2010-05-26 21:35:09 UTC (rev 8014) @@ -22,6 +22,7 @@ import java.io.IOException; import java.util.Formatter; import net.sf.gridarta.model.io.AbstractMapArchObjectParser; +import net.sf.gridarta.utils.NumberUtils; import net.sf.gridarta.var.atrinik.model.maparchobject.MapArchObject; import org.jetbrains.annotations.NotNull; @@ -129,72 +130,72 @@ @Override protected boolean parseLine(@NotNull final String line, @NotNull final MapArchObject mapArchObject) { if (line.startsWith("no_save ")) { - mapArchObject.setNoSave(parseInteger(line.substring(8)) != 0); + mapArchObject.setNoSave(NumberUtils.parseInt(line.substring(8)) != 0); return true; } if (line.startsWith("no_magic ")) { - mapArchObject.setNoMagic(parseInteger(line.substring(9)) != 0); + mapArchObject.setNoMagic(NumberUtils.parseInt(line.substring(9)) != 0); return true; } if (line.startsWith("no_priest ")) { - mapArchObject.setNoPriest(parseInteger(line.substring(10)) != 0); + mapArchObject.setNoPriest(NumberUtils.parseInt(line.substring(10)) != 0); return true; } if (line.startsWith("no_summon ")) { - mapArchObject.setNoSummon(parseInteger(line.substring(10)) != 0); + mapArchObject.setNoSummon(NumberUtils.parseInt(line.substring(10)) != 0); return true; } if (line.startsWith("no_harm ")) { - mapArchObject.setNoHarm(parseInteger(line.substring(8)) != 0); + mapArchObject.setNoHarm(NumberUtils.parseInt(line.substring(8)) != 0); return true; } if (line.startsWith("fixed_login ")) { - mapArchObject.setFixedLogin(parseInteger(line.substring(12)) != 0); + mapArchObject.setFixedLogin(NumberUtils.parseInt(line.substring(12)) != 0); return true; } if (line.startsWith("perm_death ")) { - mapArchObject.setPermDeath(parseInteger(line.substring(11)) != 0); + mapArchObject.setPermDeath(NumberUtils.parseInt(line.substring(11)) != 0); return true; } if (line.startsWith("ultra_death ")) { - mapArchObject.setUltraDeath(parseInteger(line.substring(12)) != 0); + mapArchObject.setUltraDeath(NumberUtils.parseInt(line.substring(12)) != 0); return true; } if (line.startsWith("ultimate_death ")) { - mapArchObject.setUltimateDeath(parseInteger(line.substring(15)) != 0); + mapArchObject.setUltimateDeath(NumberUtils.parseInt(line.substring(15)) != 0); return true; } if (line.startsWith("pvp ")) { - mapArchObject.setPvp(parseInteger(line.substring(4)) != 0); + mapArchObject.setPvp(NumberUtils.parseInt(line.substring(4)) != 0); return true; } if (line.startsWith("plugins ")) { - mapArchObject.setPlugins(parseInteger(line.substring(8)) != 0); + mapArchObject.setPlugins(NumberUtils.parseInt(line.substring(8)) != 0); return true; } if (line.startsWith("tileset_id ")) { - mapArchObject.setTilesetId(parseInteger(line.substring(11))); + mapArchObject.setTilesetId(NumberUtils.parseInt(line.substring(11))); return true; } if (line.startsWith("tileset_x ")) { - mapArchObject.setTilesetX(parseInteger(line.substring(10))); + mapArchObject.setTilesetX(NumberUtils.parseInt(line.substring(10))); return true; } if (line.startsWith("tileset_y ")) { - mapArchObject.setTilesetY(parseInteger(line.substring(10))); + mapArchObject.setTilesetY(NumberUtils.parseInt(line.substring(10))); return true; } Modified: trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/model/io/MapArchObjectParser.java =================================================================== --- trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/model/io/MapArchObjectParser.java 2010-05-26 21:34:40 UTC (rev 8013) +++ trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/model/io/MapArchObjectParser.java 2010-05-26 21:35:09 UTC (rev 8014) @@ -23,6 +23,7 @@ import java.io.IOException; import java.util.Formatter; import net.sf.gridarta.model.io.AbstractMapArchObjectParser; +import net.sf.gridarta.utils.NumberUtils; import net.sf.gridarta.var.crossfire.model.maparchobject.MapArchObject; import org.jetbrains.annotations.NotNull; @@ -170,17 +171,17 @@ } if (line.startsWith("unique ")) { - mapArchObject.setUnique(parseInteger(line.substring(7)) != 0); + mapArchObject.setUnique(NumberUtils.parseInt(line.substring(7)) != 0); return true; } if (line.startsWith("template ")) { - mapArchObject.setTemplate(parseInteger(line.substring(9)) != 0); + mapArchObject.setTemplate(NumberUtils.parseInt(line.substring(9)) != 0); return true; } if (line.startsWith("nosmooth ")) { - mapArchObject.setNosmooth(parseInteger(line.substring(9)) != 0); + mapArchObject.setNosmooth(NumberUtils.parseInt(line.substring(9)) != 0); return true; } @@ -195,47 +196,47 @@ } if (line.startsWith("shopmin ")) { - mapArchObject.setShopMin(parseInteger(line.substring(8))); + mapArchObject.setShopMin(NumberUtils.parseInt(line.substring(8))); return true; } if (line.startsWith("shopmax ")) { - mapArchObject.setShopMax(parseInteger(line.substring(8))); + mapArchObject.setShopMax(NumberUtils.parseInt(line.substring(8))); return true; } if (line.startsWith("shopgreed ")) { - mapArchObject.setShopGreed(parseDouble(line.substring(10))); + mapArchObject.setShopGreed(NumberUtils.parseDouble(line.substring(10))); return true; } if (line.startsWith("temp ")) { - mapArchObject.setTemp(parseInteger(line.substring(5))); + mapArchObject.setTemp(NumberUtils.parseInt(line.substring(5))); return true; } if (line.startsWith("pressure ")) { - mapArchObject.setPressure(parseInteger(line.substring(9))); + mapArchObject.setPressure(NumberUtils.parseInt(line.substring(9))); return true; } if (line.startsWith("humid ")) { - mapArchObject.setHumid(parseInteger(line.substring(6))); + mapArchObject.setHumid(NumberUtils.parseInt(line.substring(6))); return true; } if (line.startsWith("windspeed ")) { - mapArchObject.setWindspeed(parseInteger(line.substring(10))); + mapArchObject.setWindspeed(NumberUtils.parseInt(line.substring(10))); return true; } if (line.startsWith("winddir ")) { - mapArchObject.setWinddir(parseInteger(line.substring(8))); + mapArchObject.setWinddir(NumberUtils.parseInt(line.substring(8))); return true; } if (line.startsWith("sky ")) { - mapArchObject.setSky(parseInteger(line.substring(4))); + mapArchObject.setSky(NumberUtils.parseInt(line.substring(4))); return true; } Modified: trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/model/io/MapArchObjectParser.java =================================================================== --- trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/model/io/MapArchObjectParser.java 2010-05-26 21:34:40 UTC (rev 8013) +++ trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/model/io/MapArchObjectParser.java 2010-05-26 21:35:09 UTC (rev 8014) @@ -22,6 +22,7 @@ import java.io.IOException; import java.util.Formatter; import net.sf.gridarta.model.io.AbstractMapArchObjectParser; +import net.sf.gridarta.utils.NumberUtils; import net.sf.gridarta.var.daimonin.model.maparchobject.MapArchObject; import org.jetbrains.annotations.NotNull; @@ -126,67 +127,67 @@ @Override protected boolean parseLine(@NotNull final String line, @NotNull final MapArchObject mapArchObject) { if (line.startsWith("no_save ")) { - mapArchObject.setNoSave(parseInteger(line.substring(8)) != 0); + mapArchObject.setNoSave(NumberUtils.parseInt(line.substring(8)) != 0); return true; } if (line.startsWith("no_magic ")) { - mapArchObject.setNoMagic(parseInteger(line.substring(9)) != 0); + mapArchObject.setNoMagic(NumberUtils.parseInt(line.substring(9)) != 0); return true; } if (line.startsWith("no_priest ")) { - mapArchObject.setNoPriest(parseInteger(line.substring(10)) != 0); + mapArchObject.setNoPriest(NumberUtils.parseInt(line.substring(10)) != 0); return true; } if (line.startsWith("no_summon ")) { - mapArchObject.setNoSummon(parseInteger(line.substring(10)) != 0); + mapArchObject.setNoSummon(NumberUtils.parseInt(line.substring(10)) != 0); return true; } if (line.startsWith("no_harm ")) { - mapArchObject.setNoHarm(parseInteger(line.substring(8)) != 0); + mapArchObject.setNoHarm(NumberUtils.parseInt(line.substring(8)) != 0); return true; } if (line.startsWith("fixed_login ")) { - mapArchObject.setFixedLogin(parseInteger(line.substring(12)) != 0); + mapArchObject.setFixedLogin(NumberUtils.parseInt(line.substring(12)) != 0); return true; } if (line.startsWith("perm_death ")) { - mapArchObject.setPermDeath(parseInteger(line.substring(11)) != 0); + mapArchObject.setPermDeath(NumberUtils.parseInt(line.substring(11)) != 0); return true; } if (line.startsWith("ultra_death ")) { - mapArchObject.setUltraDeath(parseInteger(line.substring(12)) != 0); + mapArchObject.setUltraDeath(NumberUtils.parseInt(line.substring(12)) != 0); return true; } if (line.startsWith("ultimate_death ")) { - mapArchObject.setUltimateDeath(parseInteger(line.substring(15)) != 0); + mapArchObject.setUltimateDeath(NumberUtils.parseInt(line.substring(15)) != 0); return true; } if (line.startsWith("pvp ")) { - mapArchObject.setPvp(parseInteger(line.substring(4)) != 0); + mapArchObject.setPvp(NumberUtils.parseInt(line.substring(4)) != 0); return true; } if (line.startsWith("tileset_id ")) { - mapArchObject.setTilesetId(parseInteger(line.substring(11))); + mapArchObject.setTilesetId(NumberUtils.parseInt(line.substring(11))); return true; } if (line.startsWith("tileset_x ")) { - mapArchObject.setTilesetX(parseInteger(line.substring(10))); + mapArchObject.setTilesetX(NumberUtils.parseInt(line.substring(10))); return true; } if (line.startsWith("tileset_y ")) { - mapArchObject.setTilesetY(parseInteger(line.substring(10))); + mapArchObject.setTilesetY(NumberUtils.parseInt(line.substring(10))); return true; } Modified: trunk/src/app/net/sf/gridarta/gui/newmap/AbstractMapsizeNewMapDialog.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/newmap/AbstractMapsizeNewMapDialog.java 2010-05-26 21:34:40 UTC (rev 8013) +++ trunk/src/app/net/sf/gridarta/gui/newmap/AbstractMapsizeNewMapDialog.java 2010-05-26 21:35:09 UTC (rev 8014) @@ -28,6 +28,7 @@ import net.sf.gridarta.model.archetype.Archetype; import net.sf.gridarta.model.gameobject.GameObject; import net.sf.gridarta.model.map.maparchobject.MapArchObject; +import net.sf.gridarta.utils.NumberUtils; import net.sf.gridarta.utils.Size2D; import net.sf.japi.swing.action.ActionBuilder; import net.sf.japi.swing.action.ActionBuilderFactory; @@ -240,17 +241,9 @@ */ private int getMapWidth() { final String text = mapWidthField.getText(); - final int width; - try { - width = Integer.parseInt(text); - } catch (final NumberFormatException ignored) { - return -1; - } - if (width < 1) { - return -1; - } + final int width = NumberUtils.parseInt(text); + return width < 1 ? -1 : width; - return width; } /** @@ -259,17 +252,9 @@ */ private int getMapHeight() { final String text = mapHeightField.getText(); - final int height; - try { - height = Integer.parseInt(text); - } catch (final NumberFormatException ignored) { - return -1; - } - if (height < 1) { - return -1; - } + final int height = NumberUtils.parseInt(text); + return height < 1 ? -1 : height; - return height; } } // class AbstractMapsizeNewMapDialog Modified: trunk/src/app/net/sf/gridarta/gui/newmap/NewMapDialog.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/newmap/NewMapDialog.java 2010-05-26 21:34:40 UTC (rev 8013) +++ trunk/src/app/net/sf/gridarta/gui/newmap/NewMapDialog.java 2010-05-26 21:35:09 UTC (rev 8014) @@ -31,6 +31,7 @@ import net.sf.gridarta.model.gameobject.GameObject; import net.sf.gridarta.model.map.maparchobject.MapArchObject; import net.sf.gridarta.model.map.maparchobject.MapArchObjectFactory; +import net.sf.gridarta.utils.NumberUtils; import net.sf.gridarta.utils.Size2D; import net.sf.japi.swing.action.ActionBuilder; import net.sf.japi.swing.action.ActionBuilderFactory; @@ -217,12 +218,7 @@ */ private int getDifficulty() { final String text = mapDifficultyField.getText(); - final int difficulty; - try { - difficulty = Integer.parseInt(text); - } catch (final NumberFormatException ignored) { - return -1; - } + final int difficulty = NumberUtils.parseInt(text); return difficulty >= 1 ? difficulty : -1; } Modified: trunk/src/app/net/sf/gridarta/mainactions/MainActions.java =================================================================== --- trunk/src/app/net/sf/gridarta/mainactions/MainActions.java 2010-05-26 21:34:40 UTC (rev 8013) +++ trunk/src/app/net/sf/gridarta/mainactions/MainActions.java 2010-05-26 21:35:09 UTC (rev 8014) @@ -69,6 +69,7 @@ import net.sf.gridarta.utils.ActionUtils; import net.sf.gridarta.utils.Exiter; import net.sf.gridarta.utils.ExiterListener; +import net.sf.gridarta.utils.NumberUtils; import net.sf.gridarta.utils.Size2D; import net.sf.gridarta.validation.DelegatingMapValidator; import net.sf.japi.swing.action.ActionBuilder; @@ -1543,12 +1544,7 @@ return -1; } - int rand; - try { - rand = Integer.parseInt(input); - } catch (final NumberFormatException ignored) { - rand = -1; - } + final int rand = NumberUtils.parseInt(input); if (rand < 1 || rand > 100) { JOptionPane.showMessageDialog(parent, "The fill density must be between 1-100.", "Illegal Value.", JOptionPane.ERROR_MESSAGE); } else { Modified: trunk/src/app/net/sf/gridarta/model/archetypetype/AttributeBitmask.java =================================================================== --- trunk/src/app/net/sf/gridarta/model/archetypetype/AttributeBitmask.java 2010-05-26 21:34:40 UTC (rev 8013) +++ trunk/src/app/net/sf/gridarta/model/archetypetype/AttributeBitmask.java 2010-05-26 21:35:09 UTC (rev 8014) @@ -25,6 +25,7 @@ import java.util.List; import java.util.Map; import java.util.regex.Pattern; +import net.sf.gridarta.utils.NumberUtils; import net.sf.gridarta.utils.WrappingStringBuilder; import org.apache.log4j.Category; import org.apache.log4j.Logger; @@ -199,11 +200,7 @@ */ public int decodeValue(@NotNull final String encodedValue) { if (!isNamed) { - try { - return Integer.parseInt(encodedValue); - } catch (final NumberFormatException ignored) { - return 0; - } + return NumberUtils.parseInt(encodedValue); } if (encodedValue.length() == 0) { Modified: trunk/src/app/net/sf/gridarta/model/baseobject/AbstractBaseObject.java =================================================================== --- trunk/src/app/net/sf/gridarta/model/baseobject/AbstractBaseObject.java 2010-05-26 21:34:40 UTC (rev 8013) +++ trunk/src/app/net/sf/gridarta/model/baseobject/AbstractBaseObject.java 2010-05-26 21:35:09 UTC (rev 8014) @@ -29,6 +29,7 @@ import net.sf.gridarta.model.gameobject.GameObject; import net.sf.gridarta.model.gameobject.MultiArchData; import net.sf.gridarta.model.map.maparchobject.MapArchObject; +import net.sf.gridarta.utils.NumberUtils; import net.sf.gridarta.utils.StringUtils; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -295,18 +296,7 @@ */ @Override public int getAttributeInt(@NotNull final String attributeName, final boolean queryArchetype) { - final String str = getAttributeString(attributeName, queryArchetype); - if (str.length() <= 0) { - return 0; - } - - try { - return Integer.parseInt(str); - } catch (final NumberFormatException ignore) { - // ignore - } - - return 0; + return NumberUtils.parseInt(getAttributeString(attributeName, queryArchetype)); } /** @@ -322,13 +312,7 @@ */ @Override public long getAttributeLong(@NotNull final String attributeName, final boolean queryArchetype) { - long result = 0L; - try { - result = Long.parseLong(getAttributeString(attributeName, queryArchetype)); - } catch (final NumberFormatException ignore) { - // ignore - } - return result; + return NumberUtils.parseLong(getAttributeString(attributeName, queryArchetype)); } /** @@ -344,13 +328,7 @@ */ @Override public double getAttributeDouble(@NotNull final String attributeName, final boolean queryArchetype) { - double result = 0.0; - try { - result = Double.parseDouble(getAttributeString(attributeName, queryArchetype)); - } catch (final NumberFormatException ignore) { - // ignore - } - return result; + return NumberUtils.parseDouble(getAttributeString(attributeName, queryArchetype)); } /** Modified: trunk/src/app/net/sf/gridarta/model/io/AbstractMapArchObjectParser.java =================================================================== --- trunk/src/app/net/sf/gridarta/model/io/AbstractMapArchObjectParser.java 2010-05-26 21:34:40 UTC (rev 8013) +++ trunk/src/app/net/sf/gridarta/model/io/AbstractMapArchObjectParser.java 2010-05-26 21:35:09 UTC (rev 8014) @@ -22,6 +22,7 @@ import java.io.BufferedReader; import java.io.IOException; import net.sf.gridarta.model.map.maparchobject.MapArchObject; +import net.sf.gridarta.utils.NumberUtils; import net.sf.gridarta.utils.Size2D; import org.jetbrains.annotations.NotNull; @@ -77,27 +78,27 @@ } else if (line.startsWith("name ")) { mapArchObject.setMapName(line.substring(5)); } else if (line.startsWith("width ")) { - width = parseInteger(line.substring(6)); + width = NumberUtils.parseInt(line.substring(6)); } else if (line.startsWith("height ")) { - height = parseInteger(line.substring(7)); + height = NumberUtils.parseInt(line.substring(7)); } else if (line.startsWith("enter_x ")) { - mapArchObject.setEnterX(parseInteger(line.substring(8))); + mapArchObject.setEnterX(NumberUtils.parseInt(line.substring(8))); } else if (line.startsWith("enter_y ")) { - mapArchObject.setEnterY(parseInteger(line.substring(8))); + mapArchObject.setEnterY(NumberUtils.parseInt(line.substring(8))); } else if (line.startsWith("reset_timeout ")) { - mapArchObject.setResetTimeout(parseInteger(line.substring(14))); + mapArchObject.setResetTimeout(NumberUtils.parseInt(line.substring(14))); } else if (line.startsWith("swap_time ")) { - mapArchObject.setSwapTime(parseInteger(line.substring(10))); + mapArchObject.setSwapTime(NumberUtils.parseInt(line.substring(10))); } else if (line.startsWith("difficulty ")) { - mapArchObject.setDifficulty(parseInteger(line.substring(11))); + mapArchObject.setDifficulty(NumberUtils.parseInt(line.substring(11))); } else if (line.startsWith("darkness ")) { - mapArchObject.setDarkness(parseInteger(line.substring(9))); + mapArchObject.setDarkness(NumberUtils.parseInt(line.substring(9))); } else if (line.startsWith("fixed_resettime ")) { - if (parseInteger(line.substring(16)) != 0) { + if (NumberUtils.parseInt(line.substring(16)) != 0) { mapArchObject.setFixedReset(true); } } else if (line.startsWith("outdoor ")) { - if (parseInteger(line.substring(8)) != 0) { + if (NumberUtils.parseInt(line.substring(8)) != 0) { mapArchObject.setOutdoor(true); } } else if (line.startsWith("tile_path_")) { @@ -130,32 +131,6 @@ } /** - * Parse an integer string. - * @param s The string to parse. - * @return The integer value, or zero if value not readable. - */ - protected static int parseInteger(@NotNull final String s) { - try { - return Integer.parseInt(s); - } catch (final NumberFormatException ignored) { - return 0; - } - } - - /** - * Parse a double string. - * @param s The string to parse. - * @return The double value, or zero if value not readable. - */ - protected static double parseDouble(@NotNull final String s) { - try { - return Double.parseDouble(s); - } catch (final NumberFormatException ignored) { - return 0.0; - } - } - - /** * Parse a line for this editor type. * @param line The line to parse. * @param mapArchObject The map arch object to update. Modified: trunk/src/app/net/sf/gridarta/script/parameter/DoubleParameter.java =================================================================== --- trunk/src/app/net/sf/gridarta/script/parameter/DoubleParameter.java 2010-05-26 21:34:40 UTC (rev 8013) +++ trunk/src/app/net/sf/gridarta/script/parameter/DoubleParameter.java 2010-05-26 21:35:09 UTC (rev 8014) @@ -22,6 +22,7 @@ import net.sf.gridarta.model.archetype.Archetype; import net.sf.gridarta.model.gameobject.GameObject; import net.sf.gridarta.model.map.maparchobject.MapArchObject; +import net.sf.gridarta.utils.NumberUtils; import org.jdom.Element; import org.jetbrains.annotations.NotNull; @@ -42,12 +43,7 @@ public void fromXML(@NotNull final Element e) { super.fromXML(e); final String val = e.getChildText("value"); - try { - final Double iVal = Double.parseDouble(val); - setValue(iVal); - } catch (final NumberFormatException ignored) { - setValue(0.0); - } + setValue(NumberUtils.parseDouble(val)); final DoubleConfig o = new DoubleConfig(); try { o.setMin(Double.parseDouble(e.getChildTextTrim("minimum"))); Modified: trunk/src/app/net/sf/gridarta/utils/ActionBuilderUtils.java =================================================================== --- trunk/src/app/net/sf/gridarta/utils/ActionBuilderUtils.java 2010-05-26 21:34:40 UTC (rev 8013) +++ trunk/src/app/net/sf/gridarta/utils/ActionBuilderUtils.java 2010-05-26 21:35:09 UTC (rev 8014) @@ -58,11 +58,7 @@ return defaultValue; } - try { - return Integer.parseInt(value); - } catch (final NumberFormatException ignored) { - return defaultValue; - } + return NumberUtils.parseInt(value, defaultValue); } /** Added: trunk/src/app/net/sf/gridarta/utils/NumberUtils.java =================================================================== --- trunk/src/app/net/sf/gridarta/utils/NumberUtils.java (rev 0) +++ trunk/src/app/net/sf/gridarta/utils/NumberUtils.java 2010-05-26 21:35:09 UTC (rev 8014) @@ -0,0 +1,85 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2010 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.utils; + +import org.jetbrains.annotations.NotNull; + +/** + * Utility class for parsing strings into numbers. + * @author Andreas Kirschbaum + */ +public class NumberUtils { + + /** + * Private constructor to prevent instantiation. + */ + private NumberUtils() { + } + + /** + * Parses an integer string. + * @param s the string to parse + * @return the integer value or zero if value not readable + */ + public static int parseInt(@NotNull final String s) { + return parseInt(s, 0); + } + + /** + * Parses an integer string. + * @param s the string to parse + * @param defaultValue the default value + * @return the integer value or the default value if value not readable + */ + public static int parseInt(@NotNull final String s, final int defaultValue) { + try { + return Integer.parseInt(s); + } catch (final NumberFormatException ignored) { + return defaultValue; + } + } + + /** + * Parses a long string. + * @param s the string to parse + * @return the long value or zero if value not readable + */ + public static long parseLong(@NotNull final String s) { + try { + return Long.parseLong(s); + } catch (final NumberFormatException ignored) { + return 0L; + } + } + + /** + * Parses a double string. + * @param s the string to parse + * @return the double value or zero if value not readable + */ + public static double parseDouble(@NotNull final String s) { + try { + return Double.parseDouble(s); + } catch (final NumberFormatException ignored) { + return 0.0; + } + } + +} // class NumberUtils Property changes on: trunk/src/app/net/sf/gridarta/utils/NumberUtils.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-05-27 18:21:46
|
Revision: 8022 http://gridarta.svn.sourceforge.net/gridarta/?rev=8022&view=rev Author: akirschbaum Date: 2010-05-27 18:21:39 +0000 (Thu, 27 May 2010) Log Message: ----------- Fix typos. Modified Paths: -------------- trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/model/archetype/ArchetypeParser.java trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/model/archetype/ArchetypeParser.java trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/model/archetype/ArchetypeParser.java trunk/src/app/net/sf/gridarta/model/archetype/AbstractArchetypeParser.java trunk/src/test/net/sf/gridarta/model/archetype/TestArchetypeParser.java Modified: trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/model/archetype/ArchetypeParser.java =================================================================== --- trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/model/archetype/ArchetypeParser.java 2010-05-27 18:18:21 UTC (rev 8021) +++ trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/model/archetype/ArchetypeParser.java 2010-05-27 18:21:39 UTC (rev 8022) @@ -97,7 +97,7 @@ @Override protected boolean processLine(@NotNull final BufferedReader in, @NotNull final String line, @NotNull final String line2, @NotNull final DefaultArchetypeBuilder archetypeBuilder, @NotNull final ErrorViewCollector errorViewCollector, @NotNull final List<GameObject> invObjects) { if (line.startsWith("mpart_id ")) { - // shape ID for multiparts + // shape ID for multi-parts try { multiShapeID = Integer.parseInt(line.substring(9).trim()); @@ -112,7 +112,7 @@ } if (line.startsWith("mpart_nr ")) { - // part nr for multiparts + // part nr for multi-parts try { final int i = Integer.parseInt(line.substring(9).trim()); archetypeBuilder.setMultiPartNr(i); @@ -143,8 +143,8 @@ * {@inheritDoc} */ @Override - protected void finishParseArchetype(@NotNull final Archetype archetype, final boolean archmore) { - if (archmore) { + protected void finishParseArchetype(@NotNull final Archetype archetype, final boolean archMore) { + if (archMore) { calcLowestMulti(archetype); } } @@ -160,16 +160,16 @@ /** * Calculate the lowest part of this multi-arch. This lowest part is needed * because in ISO view, the big image is drawn for it's lowest part, in - * order to get the overlappings correct. <p/> + * order to get the overlapping correct. <p/> * @param arch last tail part of this multi - * @todo This method is called repeatedly for each multipart. It would be - * better if it was called only once per multipart. + * @todo This method is called repeatedly for each multi-part. It would be + * better if it was called only once per multi-part. */ private void calcLowestMulti(final net.sf.gridarta.model.archetype.Archetype<GameObject, MapArchObject, Archetype> arch) { final Archetype head = arch.getHead(); int minYOffset = multiPositionData.getYOffset(head.getMultiShapeID(), head.getMultiPartNr()); - // 1.step: find the maximal y-offest + // 1.step: find the maximal y-offset for (net.sf.gridarta.model.archetype.Archetype<GameObject, MapArchObject, Archetype> tail = head.getMultiNext(); tail != null; tail = tail.getMultiNext()) { final int t = multiPositionData.getYOffset(tail.getMultiShapeID(), tail.getMultiPartNr()); if (t < minYOffset) { Modified: trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/model/archetype/ArchetypeParser.java =================================================================== --- trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/model/archetype/ArchetypeParser.java 2010-05-27 18:18:21 UTC (rev 8021) +++ trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/model/archetype/ArchetypeParser.java 2010-05-27 18:21:39 UTC (rev 8022) @@ -149,7 +149,7 @@ * {@inheritDoc} */ @Override - protected void finishParseArchetype(@NotNull final Archetype archetype, final boolean archmore) { + protected void finishParseArchetype(@NotNull final Archetype archetype, final boolean archMore) { } /** Modified: trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/model/archetype/ArchetypeParser.java =================================================================== --- trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/model/archetype/ArchetypeParser.java 2010-05-27 18:18:21 UTC (rev 8021) +++ trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/model/archetype/ArchetypeParser.java 2010-05-27 18:21:39 UTC (rev 8022) @@ -96,7 +96,7 @@ @Override protected boolean processLine(@NotNull final BufferedReader in, @NotNull final String line, @NotNull final String line2, @NotNull final DefaultArchetypeBuilder archetypeBuilder, @NotNull final ErrorViewCollector errorViewCollector, @NotNull final List<GameObject> invObjects) { if (line.startsWith("mpart_id ")) { - // shape ID for multiparts + // shape ID for multi-parts try { multiShapeID = Integer.parseInt(line.substring(9).trim()); @@ -111,7 +111,7 @@ } if (line.startsWith("mpart_nr ")) { - // part nr for multiparts + // part nr for multi-parts try { final int i = Integer.parseInt(line.substring(9).trim()); archetypeBuilder.setMultiPartNr(i); @@ -142,8 +142,8 @@ * {@inheritDoc} */ @Override - protected void finishParseArchetype(@NotNull final Archetype archetype, final boolean archmore) { - if (archmore) { + protected void finishParseArchetype(@NotNull final Archetype archetype, final boolean archMore) { + if (archMore) { calcLowestMulti(archetype); } } @@ -159,16 +159,16 @@ /** * Calculate the lowest part of this multi-arch. This lowest part is needed * because in ISO view, the big image is drawn for it's lowest part, in - * order to get the overlappings correct. <p/> + * order to get the overlapping correct. <p/> * @param arch last tail part of this multi - * @todo This method is called repeatedly for each multipart. It would be - * better if it was called only once per multipart. + * @todo This method is called repeatedly for each multi-part. It would be + * better if it was called only once per multi-part. */ private void calcLowestMulti(final net.sf.gridarta.model.archetype.Archetype<GameObject, MapArchObject, Archetype> arch) { final Archetype head = arch.getHead(); int minYOffset = multiPositionData.getYOffset(head.getMultiShapeID(), head.getMultiPartNr()); - // 1.step: find the maximal y-offest + // 1.step: find the maximal y-offset for (Archetype tail = head.getMultiNext(); tail != null; tail = tail.getMultiNext()) { final int t = multiPositionData.getYOffset(tail.getMultiShapeID(), tail.getMultiPartNr()); if (t < minYOffset) { Modified: trunk/src/app/net/sf/gridarta/model/archetype/AbstractArchetypeParser.java =================================================================== --- trunk/src/app/net/sf/gridarta/model/archetype/AbstractArchetypeParser.java 2010-05-27 18:18:21 UTC (rev 8021) +++ trunk/src/app/net/sf/gridarta/model/archetype/AbstractArchetypeParser.java 2010-05-27 18:21:39 UTC (rev 8022) @@ -297,7 +297,7 @@ } /** - * Called whan a new archetype starts. + * Called when a new archetype starts. */ protected abstract void initParseArchetype(); @@ -334,9 +334,9 @@ * #finishParseArchetypePart(Archetype, Archetype, ErrorViewCollector)} is * called first. * @param archetype the archetype - * @param archmore whether another part follows + * @param archMore whether another part follows */ - protected abstract void finishParseArchetype(@NotNull final R archetype, final boolean archmore); + protected abstract void finishParseArchetype(@NotNull final R archetype, final boolean archMore); /** * Returns whether an archetype should be added to the archetype chooser. Modified: trunk/src/test/net/sf/gridarta/model/archetype/TestArchetypeParser.java =================================================================== --- trunk/src/test/net/sf/gridarta/model/archetype/TestArchetypeParser.java 2010-05-27 18:18:21 UTC (rev 8021) +++ trunk/src/test/net/sf/gridarta/model/archetype/TestArchetypeParser.java 2010-05-27 18:21:39 UTC (rev 8022) @@ -79,7 +79,7 @@ * {@inheritDoc} */ @Override - protected void finishParseArchetype(@NotNull final TestArchetype archetype, final boolean archmore) { + protected void finishParseArchetype(@NotNull final TestArchetype archetype, final boolean archMore) { } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-05-27 18:28:31
|
Revision: 8023 http://gridarta.svn.sourceforge.net/gridarta/?rev=8023&view=rev Author: akirschbaum Date: 2010-05-27 18:28:24 +0000 (Thu, 27 May 2010) Log Message: ----------- Extract code into functions. Modified Paths: -------------- trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/model/archetype/ArchetypeParser.java trunk/src/app/net/sf/gridarta/model/archetype/AbstractArchetypeParser.java Modified: trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/model/archetype/ArchetypeParser.java =================================================================== --- trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/model/archetype/ArchetypeParser.java 2010-05-27 18:21:39 UTC (rev 8022) +++ trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/model/archetype/ArchetypeParser.java 2010-05-27 18:28:24 UTC (rev 8023) @@ -101,23 +101,7 @@ } if (line.equals("lore")) { - final StringBuilder loreText = new StringBuilder(); - while (true) { - final String thisLine = in.readLine(); - if (thisLine == null) { - errorViewCollector.addError(ErrorViewCategory.ARCHETYPE_INVALID, "Truncated archetype: lore not terminated by endlore"); - break; - } - - if (thisLine.trim().equals("endlore")) { - break; - } - - // keep leading whitespace - loreText.append(thisLine).append("\n"); - } - - archetypeBuilder.setLoreText(loreText.toString()); + parseLore(in, archetypeBuilder, errorViewCollector); return true; } @@ -139,6 +123,34 @@ } /** + * Parses a "lore..endlore" block. + * @param in the reader to read from + * @param archetypeBuilder the archetype builder to update + * @param errorViewCollector the error view collector for reporting errors + * @throws IOException if an I/O error occurs + */ + private static void parseLore(@NotNull final BufferedReader in, @NotNull final DefaultArchetypeBuilder archetypeBuilder, @NotNull final ErrorViewCollector errorViewCollector) throws IOException { + final StringBuilder loreText = new StringBuilder(); + + while (true) { + final String thisLine = in.readLine(); + if (thisLine == null) { + errorViewCollector.addError(ErrorViewCategory.ARCHETYPE_INVALID, "Truncated archetype: lore not terminated by endlore"); + return; + } + + if (thisLine.trim().equals("endlore")) { + break; + } + + // keep leading whitespace + loreText.append(thisLine).append("\n"); + } + + archetypeBuilder.setLoreText(loreText.toString()); + } + + /** * {@inheritDoc} */ @Override Modified: trunk/src/app/net/sf/gridarta/model/archetype/AbstractArchetypeParser.java =================================================================== --- trunk/src/app/net/sf/gridarta/model/archetype/AbstractArchetypeParser.java 2010-05-27 18:21:39 UTC (rev 8022) +++ trunk/src/app/net/sf/gridarta/model/archetype/AbstractArchetypeParser.java 2010-05-27 18:28:24 UTC (rev 8023) @@ -168,57 +168,9 @@ } else if (thisLine.equals("end")) { break; } else if (thisLine.equals("msg")) { - final StringBuilder msgText = new StringBuilder(); - - while (true) { - thisLine2 = in.readLine(); - if (thisLine2 == null) { - errorViewCollector.addError(ErrorViewCategory.ARCHETYPE_INVALID, "Truncated archetype: msg not terminated by endmsg"); - break LOOP; - } - - final String thisLine3 = thisLine2.trim(); - if (thisLine3.equals("endmsg")) { - break; - } - - // keep leading whitespace - msgText.append(thisLine2).append("\n"); - } - - if (msgText.length() > 0) { - archetypeBuilder.setMsgText(msgText.toString()); - } + parseMsg(in, errorViewCollector); } else if (thisLine.equals("anim")) { - final StringBuilder animText = new StringBuilder(); - - while (true) { - thisLine2 = in.readLine(); - if (thisLine2 == null) { - errorViewCollector.addError(ErrorViewCategory.ARCHETYPE_INVALID, "Truncated animation: anim not terminated by mina"); - break LOOP; - } - - final String thisLine3 = thisLine2.trim(); - if (thisLine3.startsWith("#") || thisLine3.length() == 0) { - continue; - } - - if (thisLine3.equals("mina")) { - break; - } - - animText.append(thisLine3).append("\n"); - } - - final String animationName = "_" + archetypeBuilder.getArchetypeName(); - try { - animationObjects.addAnimationObject(animationName, animText.toString(), path + animationName); - } catch (final DuplicateAnimationException e) { - errorViewCollector.addWarning(ErrorViewCategory.ARCHETYPE_INVALID, ACTION_BUILDER.format("logDuplicateAnimation", e.getDuplicate().getAnimName())); - } catch (final IllegalAnimationException ex) { - errorViewCollector.addWarning(ErrorViewCategory.ARCHETYPE_INVALID, "illegal animation: " + ex.getAnimationObject().getPath()); - } + parseAnim(in, errorViewCollector, path); } else if (thisLine.startsWith("visibility ")) { errorViewCollector.addWarning(ErrorViewCategory.ARCHETYPE_INVALID, "Ignoring obsolete 'visibility' attribute: " + archetypeBuilder.getArchetypeName()); } else if (thisLine.startsWith("magicmap ")) { @@ -297,6 +249,75 @@ } /** + * Parses a "msg..endmsg" block. + * @param in the reader to read from + * @param errorViewCollector the error view collector for reporting errors + * @throws IOException if an I/O error occurs + */ + private void parseMsg(@NotNull final BufferedReader in, @NotNull final ErrorViewCollector errorViewCollector) throws IOException { + final StringBuilder msgText = new StringBuilder(); + + while (true) { + final String thisLine2 = in.readLine(); + if (thisLine2 == null) { + errorViewCollector.addError(ErrorViewCategory.ARCHETYPE_INVALID, "Truncated archetype: msg not terminated by endmsg"); + return; + } + + final String thisLine3 = thisLine2.trim(); + if (thisLine3.equals("endmsg")) { + break; + } + + // keep leading whitespace + msgText.append(thisLine2).append("\n"); + } + + if (msgText.length() > 0) { + archetypeBuilder.setMsgText(msgText.toString()); + } + } + + /** + * Parses an "anim..mina" block. + * @param in the reader to read from + * @param errorViewCollector the error view collector for reporting errors + * @param path the archetype's path name + * @throws IOException if an I/O error occurs + */ + private void parseAnim(@NotNull final BufferedReader in, @NotNull final ErrorViewCollector errorViewCollector, @NotNull final String path) throws IOException { + final StringBuilder animText = new StringBuilder(); + + while (true) { + final String thisLine2 = in.readLine(); + if (thisLine2 == null) { + errorViewCollector.addError(ErrorViewCategory.ARCHETYPE_INVALID, "Truncated animation: anim not terminated by mina"); + return; + } + + final String thisLine3 = thisLine2.trim(); + if (thisLine3.startsWith("#") || thisLine3.length() == 0) { + continue; + } + + if (thisLine3.equals("mina")) { + break; + } + + animText.append(thisLine3).append("\n"); + } + + final String animationName = "_" + archetypeBuilder.getArchetypeName(); + try { + animationObjects.addAnimationObject(animationName, animText.toString(), path + animationName); + } catch (final DuplicateAnimationException e) { + errorViewCollector.addWarning(ErrorViewCategory.ARCHETYPE_INVALID, ACTION_BUILDER.format("logDuplicateAnimation", e.getDuplicate().getAnimName())); + } catch (final IllegalAnimationException ex) { + errorViewCollector.addWarning(ErrorViewCategory.ARCHETYPE_INVALID, "illegal animation: " + ex.getAnimationObject().getPath()); + } + } + + /** * Called when a new archetype starts. */ protected abstract void initParseArchetype(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-05-27 18:38:42
|
Revision: 8024 http://gridarta.svn.sourceforge.net/gridarta/?rev=8024&view=rev Author: akirschbaum Date: 2010-05-27 18:38:36 +0000 (Thu, 27 May 2010) Log Message: ----------- Avoid duplicate work when parsing Atrinik or Daimonin multi-part archetypes. Modified Paths: -------------- trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/model/archetype/ArchetypeParser.java trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/model/archetype/ArchetypeParser.java trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/model/archetype/ArchetypeParser.java trunk/src/app/net/sf/gridarta/model/archetype/AbstractArchetypeParser.java trunk/src/test/net/sf/gridarta/model/archetype/TestArchetypeParser.java Modified: trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/model/archetype/ArchetypeParser.java =================================================================== --- trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/model/archetype/ArchetypeParser.java 2010-05-27 18:28:24 UTC (rev 8023) +++ trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/model/archetype/ArchetypeParser.java 2010-05-27 18:38:36 UTC (rev 8024) @@ -143,8 +143,8 @@ * {@inheritDoc} */ @Override - protected void finishParseArchetype(@NotNull final Archetype archetype, final boolean archMore) { - if (archMore) { + protected void finishParseArchetype(@NotNull final Archetype archetype) { + if (archetype.isMulti()) { calcLowestMulti(archetype); } } @@ -162,8 +162,6 @@ * because in ISO view, the big image is drawn for it's lowest part, in * order to get the overlapping correct. <p/> * @param arch last tail part of this multi - * @todo This method is called repeatedly for each multi-part. It would be - * better if it was called only once per multi-part. */ private void calcLowestMulti(final net.sf.gridarta.model.archetype.Archetype<GameObject, MapArchObject, Archetype> arch) { final Archetype head = arch.getHead(); Modified: trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/model/archetype/ArchetypeParser.java =================================================================== --- trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/model/archetype/ArchetypeParser.java 2010-05-27 18:28:24 UTC (rev 8023) +++ trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/model/archetype/ArchetypeParser.java 2010-05-27 18:38:36 UTC (rev 8024) @@ -161,7 +161,7 @@ * {@inheritDoc} */ @Override - protected void finishParseArchetype(@NotNull final Archetype archetype, final boolean archMore) { + protected void finishParseArchetype(@NotNull final Archetype archetype) { } /** Modified: trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/model/archetype/ArchetypeParser.java =================================================================== --- trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/model/archetype/ArchetypeParser.java 2010-05-27 18:28:24 UTC (rev 8023) +++ trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/model/archetype/ArchetypeParser.java 2010-05-27 18:38:36 UTC (rev 8024) @@ -142,8 +142,8 @@ * {@inheritDoc} */ @Override - protected void finishParseArchetype(@NotNull final Archetype archetype, final boolean archMore) { - if (archMore) { + protected void finishParseArchetype(@NotNull final Archetype archetype) { + if (archetype.isMulti()) { calcLowestMulti(archetype); } } @@ -161,8 +161,6 @@ * because in ISO view, the big image is drawn for it's lowest part, in * order to get the overlapping correct. <p/> * @param arch last tail part of this multi - * @todo This method is called repeatedly for each multi-part. It would be - * better if it was called only once per multi-part. */ private void calcLowestMulti(final net.sf.gridarta.model.archetype.Archetype<GameObject, MapArchObject, Archetype> arch) { final Archetype head = arch.getHead(); Modified: trunk/src/app/net/sf/gridarta/model/archetype/AbstractArchetypeParser.java =================================================================== --- trunk/src/app/net/sf/gridarta/model/archetype/AbstractArchetypeParser.java 2010-05-27 18:28:24 UTC (rev 8023) +++ trunk/src/app/net/sf/gridarta/model/archetype/AbstractArchetypeParser.java 2010-05-27 18:38:36 UTC (rev 8024) @@ -141,6 +141,9 @@ final String archetypeName = archName != null ? archName : thisLine2.trim().substring(7); archetypeBuilder.reinit(archetypeName); if (!archMore) { + if (firstArch != null) { + finishParseArchetype(firstArch); + } firstArch = null; } @@ -231,7 +234,6 @@ errorViewCollector.addWarning(ErrorViewCategory.ARCHETYPE_INVALID, ex.getMessage()); } - finishParseArchetype(archetype, archMore); archMore = false; if (archName != null) { @@ -246,6 +248,10 @@ thisLine2 = in.readLine(); } + + if (firstArch != null) { + finishParseArchetype(firstArch); + } } /** @@ -351,13 +357,10 @@ protected abstract void finishParseArchetypePart(@NotNull final R firstArch, @NotNull final R archetype, @NotNull final ErrorViewCollector errorViewCollector); /** - * Called after the "end" line. For tail parts {@link - * #finishParseArchetypePart(Archetype, Archetype, ErrorViewCollector)} is - * called first. + * Called after all parts of an archetype have been processed. * @param archetype the archetype - * @param archMore whether another part follows */ - protected abstract void finishParseArchetype(@NotNull final R archetype, final boolean archMore); + protected abstract void finishParseArchetype(@NotNull final R archetype); /** * Returns whether an archetype should be added to the archetype chooser. Modified: trunk/src/test/net/sf/gridarta/model/archetype/TestArchetypeParser.java =================================================================== --- trunk/src/test/net/sf/gridarta/model/archetype/TestArchetypeParser.java 2010-05-27 18:28:24 UTC (rev 8023) +++ trunk/src/test/net/sf/gridarta/model/archetype/TestArchetypeParser.java 2010-05-27 18:38:36 UTC (rev 8024) @@ -79,7 +79,7 @@ * {@inheritDoc} */ @Override - protected void finishParseArchetype(@NotNull final TestArchetype archetype, final boolean archMore) { + protected void finishParseArchetype(@NotNull final TestArchetype archetype) { } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-05-29 07:12:30
|
Revision: 8029 http://gridarta.svn.sourceforge.net/gridarta/?rev=8029&view=rev Author: akirschbaum Date: 2010-05-29 07:12:23 +0000 (Sat, 29 May 2010) Log Message: ----------- Fix typos. Modified Paths: -------------- trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/model/maparchobject/DefaultMapArchObjectFactory.java trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/model/maparchobject/DefaultMapArchObjectFactory.java trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/model/maparchobject/DefaultMapArchObjectFactory.java trunk/gridarta.ipr trunk/src/app/net/sf/gridarta/gui/misc/Recent.java trunk/src/app/net/sf/gridarta/gui/misc/RecentManager.java trunk/src/app/net/sf/gridarta/gui/prefs/MiscPrefs.java trunk/src/app/net/sf/gridarta/maincontrol/GUIMainControl.java trunk/src/app/net/sf/gridarta/model/map/mapcontrol/DefaultMapControl.java trunk/src/app/net/sf/gridarta/model/settings/DefaultGlobalSettings.java trunk/src/app/net/sf/gridarta/model/settings/GlobalSettings.java trunk/src/test/net/sf/gridarta/model/settings/TestGlobalSettings.java Modified: trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/model/maparchobject/DefaultMapArchObjectFactory.java =================================================================== --- trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/model/maparchobject/DefaultMapArchObjectFactory.java 2010-05-29 06:50:41 UTC (rev 8028) +++ trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/model/maparchobject/DefaultMapArchObjectFactory.java 2010-05-29 07:12:23 UTC (rev 8029) @@ -51,7 +51,7 @@ public MapArchObject newMapArchObject(final boolean addDefaultAttributes) { final MapArchObject mapArchObject = new MapArchObject(); if (addDefaultAttributes) { - mapArchObject.addText("Created: " + String.format("%tF", System.currentTimeMillis()) + " " + globalSettings.getUsername()); + mapArchObject.addText("Created: " + String.format("%tF", System.currentTimeMillis()) + " " + globalSettings.getUserName()); mapArchObject.setDarkness(-1); } return mapArchObject; Modified: trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/model/maparchobject/DefaultMapArchObjectFactory.java =================================================================== --- trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/model/maparchobject/DefaultMapArchObjectFactory.java 2010-05-29 06:50:41 UTC (rev 8028) +++ trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/model/maparchobject/DefaultMapArchObjectFactory.java 2010-05-29 07:12:23 UTC (rev 8029) @@ -51,7 +51,7 @@ public MapArchObject newMapArchObject(final boolean addDefaultAttributes) { final MapArchObject mapArchObject = new MapArchObject(); if (addDefaultAttributes) { - mapArchObject.addText("Created: " + String.format("%tF", System.currentTimeMillis()) + " " + globalSettings.getUsername()); + mapArchObject.addText("Created: " + String.format("%tF", System.currentTimeMillis()) + " " + globalSettings.getUserName()); } return mapArchObject; } Modified: trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/model/maparchobject/DefaultMapArchObjectFactory.java =================================================================== --- trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/model/maparchobject/DefaultMapArchObjectFactory.java 2010-05-29 06:50:41 UTC (rev 8028) +++ trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/model/maparchobject/DefaultMapArchObjectFactory.java 2010-05-29 07:12:23 UTC (rev 8029) @@ -51,7 +51,7 @@ public MapArchObject newMapArchObject(final boolean addDefaultAttributes) { final MapArchObject mapArchObject = new MapArchObject(); if (addDefaultAttributes) { - mapArchObject.addText("Created: " + String.format("%tF", System.currentTimeMillis()) + " " + globalSettings.getUsername()); + mapArchObject.addText("Created: " + String.format("%tF", System.currentTimeMillis()) + " " + globalSettings.getUserName()); mapArchObject.setDarkness(-1); } return mapArchObject; Modified: trunk/gridarta.ipr =================================================================== --- trunk/gridarta.ipr 2010-05-29 06:50:41 UTC (rev 8028) +++ trunk/gridarta.ipr 2010-05-29 07:12:23 UTC (rev 8029) @@ -1163,11 +1163,13 @@ <w>pickmaps</w> <w>plugins</w> <w>popup</w> + <w>recents</w> <w>resize</w> <w>resized</w> <w>resizes</w> <w>rethrown</w> <w>shortdescription</w> + <w>shortdescriptionformat</w> <w>startup</w> <w>teleporter</w> <w>teleporters</w> Modified: trunk/src/app/net/sf/gridarta/gui/misc/Recent.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/misc/Recent.java 2010-05-29 06:50:41 UTC (rev 8028) +++ trunk/src/app/net/sf/gridarta/gui/misc/Recent.java 2010-05-29 07:12:23 UTC (rev 8029) @@ -59,7 +59,7 @@ * The {@link Preferences}. */ @NotNull - private static final Preferences prefs = Preferences.userNodeForPackage(RecentManager.class); + private static final Preferences preferences = Preferences.userNodeForPackage(RecentManager.class); /** * Title = map name. @@ -133,8 +133,8 @@ this.mapViewsManager = mapViewsManager; this.mapImageCache = mapImageCache; this.fileControl = fileControl; - title = prefs.get("recentTitle[" + Integer.toString(index - 1) + ']', null); - mapFile = new File(prefs.get("recentFilename[" + Integer.toString(index - 1) + ']', null)); + title = preferences.get("recentTitle[" + Integer.toString(index - 1) + ']', null); + mapFile = new File(preferences.get("recentFilename[" + Integer.toString(index - 1) + ']', null)); putValue(SHORT_DESCRIPTION, ACTION_BUILDER.format("recentItem.shortdescriptionformat", title, getShortFileName())); putValue(SMALL_ICON, getIcon()); putValue(NAME, title); @@ -168,8 +168,8 @@ * @param index index (starting with 1) */ public void setIndex(final int index) { - prefs.put("recentTitle[" + Integer.toString(index - 1) + ']', title); - prefs.put("recentFilename[" + Integer.toString(index - 1) + ']', mapFile.getPath()); + preferences.put("recentTitle[" + Integer.toString(index - 1) + ']', title); + preferences.put("recentFilename[" + Integer.toString(index - 1) + ']', mapFile.getPath()); } /** Modified: trunk/src/app/net/sf/gridarta/gui/misc/RecentManager.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/misc/RecentManager.java 2010-05-29 06:50:41 UTC (rev 8028) +++ trunk/src/app/net/sf/gridarta/gui/misc/RecentManager.java 2010-05-29 07:12:23 UTC (rev 8029) @@ -59,7 +59,7 @@ * Preferences. */ @NotNull - private static final Preferences prefs = Preferences.userNodeForPackage(RecentManager.class); + private static final Preferences preferences = Preferences.userNodeForPackage(RecentManager.class); /** * The {@link MapViewsManager} instance. @@ -183,7 +183,7 @@ recents.remove(recent); // remove old entry to get new entry at first pos. recents.addFirst(recent); // Now remove those that are too many. - // Please keep this while loop as the constant 10 might be replaced by a prefs var + // Please keep this while loop as the constant 10 might be replaced by a preferences var int i = 0; for (final ListIterator<Recent<G, A, R>> it = recents.listIterator(); it.hasNext();) { it.next().setIndex(it.nextIndex()); // this looks bogus but it's intentionally currentIndex + 1 @@ -191,7 +191,7 @@ it.remove(); } } - prefs.putInt("recentNum", recents.size()); + preferences.putInt("recentNum", recents.size()); updateRecent(recents); } @@ -218,7 +218,7 @@ * Initializes the recent state. */ public void initRecent() { - final int numRecents = prefs.getInt("recentNum", 0); + final int numRecents = preferences.getInt("recentNum", 0); for (int i = 0; i < numRecents; i++) { recents.add(new Recent<G, A, R>(i + 1, globalSettings, mapViewsManager, mapImageCache, fileControl)); } Modified: trunk/src/app/net/sf/gridarta/gui/prefs/MiscPrefs.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/prefs/MiscPrefs.java 2010-05-29 06:50:41 UTC (rev 8028) +++ trunk/src/app/net/sf/gridarta/gui/prefs/MiscPrefs.java 2010-05-29 07:12:23 UTC (rev 8029) @@ -130,7 +130,7 @@ */ @Override public void apply() { - globalSettings.setUsername(userField.getText()); + globalSettings.setUserName(userField.getText()); MapFileFilter.setPerformingRealChecks(checkMaps.isSelected()); exitConnectorModel.setAutoCreateExit(autoCreateExit.isSelected()); exitConnectorModel.setPasteExitName(pasteExitName.isSelected()); @@ -142,7 +142,7 @@ */ @Override public void revert() { - userField.setText(globalSettings.getUsername()); + userField.setText(globalSettings.getUserName()); checkMaps.setSelected(MapFileFilter.isPerformingRealChecks()); autoCreateExit.setSelected(exitConnectorModel.isAutoCreateExit()); pasteExitName.setSelected(exitConnectorModel.isPasteExitName()); @@ -154,7 +154,7 @@ */ @Override public void defaults() { - userField.setText(globalSettings.getUsernameDefault()); + userField.setText(globalSettings.getUserNameDefault()); checkMaps.setSelected(true); autoCreateExit.setSelected(ExitConnectorModel.AUTO_CREATE_EXIT_DEFAULT); pasteExitName.setSelected(ExitConnectorModel.PASTE_EXIT_NAME_DEFAULT); @@ -166,7 +166,7 @@ */ @Override public boolean isChanged() { - return !(userField.getText().equals(globalSettings.getUsername()) && checkMaps.isSelected() == MapFileFilter.isPerformingRealChecks() && autoCreateExit.isSelected() == exitConnectorModel.isAutoCreateExit() && pasteExitName.isSelected() == exitConnectorModel.isPasteExitName() && exitArchetypeName.getText().equals(exitConnectorModel.getExitArchetypeName())); + return !(userField.getText().equals(globalSettings.getUserName()) && checkMaps.isSelected() == MapFileFilter.isPerformingRealChecks() && autoCreateExit.isSelected() == exitConnectorModel.isAutoCreateExit() && pasteExitName.isSelected() == exitConnectorModel.isPasteExitName() && exitArchetypeName.getText().equals(exitConnectorModel.getExitArchetypeName())); } /** @@ -177,7 +177,7 @@ final JComponent panel = new JPanel(new GridBagLayout()); final PreferencesHelper preferencesHelper = new PreferencesHelper(panel); panel.setBorder(createTitledBorder(ACTION_BUILDER.getString("optionsUser"))); - userField = new JTextField(globalSettings.getUsername()); + userField = new JTextField(globalSettings.getUserName()); preferencesHelper.addComponent(userField); return panel; } Modified: trunk/src/app/net/sf/gridarta/maincontrol/GUIMainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/maincontrol/GUIMainControl.java 2010-05-29 06:50:41 UTC (rev 8028) +++ trunk/src/app/net/sf/gridarta/maincontrol/GUIMainControl.java 2010-05-29 07:12:23 UTC (rev 8029) @@ -539,11 +539,11 @@ new ArchetypeValidator(animationObjects, faceObjects, errorView).validate(archetypeSet); new AnimationValidator(faceObjects, errorView).validate(animationObjects); - if (globalSettings.isAutoPopupDocu()) { + if (globalSettings.isAutoPopupDocumentation()) { // do an automated help popup because the docu version has increased // (people won't notice the docu otherwise - nobody expects a docu in opensource) helpActions.showHelp(); - globalSettings.setAutoPopupDocu(false); + globalSettings.setAutoPopupDocumentation(false); } editorFactory.deleteLibraries(mainViewFrame); Modified: trunk/src/app/net/sf/gridarta/model/map/mapcontrol/DefaultMapControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/model/map/mapcontrol/DefaultMapControl.java 2010-05-29 06:50:41 UTC (rev 8028) +++ trunk/src/app/net/sf/gridarta/model/map/mapcontrol/DefaultMapControl.java 2010-05-29 07:12:23 UTC (rev 8029) @@ -174,7 +174,7 @@ } if (mapModel.isModified()) { - mapModel.getMapArchObject().updateModifiedAttribute(globalSettings.getUsername()); + mapModel.getMapArchObject().updateModifiedAttribute(globalSettings.getUserName()); } encodeMapFile(file); } Modified: trunk/src/app/net/sf/gridarta/model/settings/DefaultGlobalSettings.java =================================================================== --- trunk/src/app/net/sf/gridarta/model/settings/DefaultGlobalSettings.java 2010-05-29 06:50:41 UTC (rev 8028) +++ trunk/src/app/net/sf/gridarta/model/settings/DefaultGlobalSettings.java 2010-05-29 07:12:23 UTC (rev 8029) @@ -66,28 +66,28 @@ private static final String IMAGE_SET_KEY = "useImageSet"; /** - * The preferences key for storing the last known docu version. + * The preferences key for storing the last known documentation version. */ @NotNull - private static final String DOCU_VERSION_KEY = "docuVersion"; + private static final String DOCUMENTATION_VERSION_KEY = "docuVersion"; /** - * Key for info whether the main windows's toolbar is shown. + * Key for info whether the main window's toolbar is shown. */ @NotNull private static final String SHOW_MAIN_TOOLBAR_KEY = "ShowMainToolbar"; /** - * Preferences key for username. + * Preferences key for user name. */ @NotNull - private static final String PREFS_USERNAME = "username"; + private static final String PREFERENCES_USER_NAME = "username"; /** - * Preferences default value for username. + * Preferences default value for user name. */ @NotNull - private static final String PREFS_USERNAME_DEFAULT = System.getProperty("user.name"); + private static final String PREFERENCES_USER_NAME_DEFAULT = System.getProperty("user.name"); /** * The preferences key for configuration source. @@ -99,7 +99,7 @@ * Preferences. */ @NotNull - private static final Preferences prefs = Preferences.userNodeForPackage(MainControl.class); + private static final Preferences preferences = Preferences.userNodeForPackage(MainControl.class); /** * The default value for the maps directory. @@ -191,9 +191,9 @@ private boolean hasChangedDir = false; /** - * Time for an automated docu popup. + * Time for an automated documentation popup. */ - private boolean autoPopupDocu = false; + private boolean autoPopupDocumentation = false; /** * The {@link PreferenceChangeListener} used to detect settings changes. @@ -207,15 +207,15 @@ if (evt.getKey().equals(SHOW_MAIN_TOOLBAR_KEY)) { fireShowMainToolbarChanged(); } else if (evt.getKey().equals(ARCH_DIRECTORY_KEY)) { - archDirectory = new File(prefs.get(ARCH_DIRECTORY_KEY, archDirectoryDefault)); + archDirectory = new File(preferences.get(ARCH_DIRECTORY_KEY, archDirectoryDefault)); } else if (evt.getKey().equals(MAP_DIRECTORY_KEY)) { - mapsDirectory = new File(prefs.get(MAP_DIRECTORY_KEY, mapsDirectoryDefault)); + mapsDirectory = new File(preferences.get(MAP_DIRECTORY_KEY, mapsDirectoryDefault)); } else if (evt.getKey().equals(MEDIA_DIRECTORY_KEY)) { - mediaDirectory = new File(prefs.get(MEDIA_DIRECTORY_KEY, mediaDirectoryDefault)); + mediaDirectory = new File(preferences.get(MEDIA_DIRECTORY_KEY, mediaDirectoryDefault)); } else if (evt.getKey().equals(IMAGE_SET_KEY)) { - imageSet = prefs.get(IMAGE_SET_KEY, imageSetDefault); + imageSet = preferences.get(IMAGE_SET_KEY, imageSetDefault); } else if (evt.getKey().equals(CONFIG_SOURCE_KEY)) { - configSource = configSourceFactory.getConfigSource(prefs.get(CONFIG_SOURCE_KEY, "")); + configSource = configSourceFactory.getConfigSource(preferences.get(CONFIG_SOURCE_KEY, "")); } } @@ -233,18 +233,18 @@ hasImageSet = ActionBuilderUtils.getBoolean(ACTION_BUILDER, "imageSet"); imageSetDefault = ActionBuilderUtils.getString(ACTION_BUILDER, "imageSetDefault", "none"); this.configSourceFactory = configSourceFactory; - prefs.addPreferenceChangeListener(preferenceChangeListener); - archDirectory = new File(prefs.get(ARCH_DIRECTORY_KEY, archDirectoryDefault)); - mapsDirectory = new File(prefs.get(MAP_DIRECTORY_KEY, mapsDirectoryDefault)); - mediaDirectory = new File(prefs.get(MEDIA_DIRECTORY_KEY, mediaDirectoryDefault)); - imageSet = prefs.get(IMAGE_SET_KEY, imageSetDefault); - configSource = configSourceFactory.getConfigSource(prefs.get(CONFIG_SOURCE_KEY, "")); - final int docuVersion = ActionBuilderUtils.getInt(ACTION_BUILDER, "docuVersion", 0); - if (docuVersion > 0 && prefs.getInt(DOCU_VERSION_KEY, 0) < docuVersion) { - // remember to open docu - autoPopupDocu = true; - // update docu version right now, because we want the help popup only one time - prefs.putInt(DOCU_VERSION_KEY, docuVersion); + preferences.addPreferenceChangeListener(preferenceChangeListener); + archDirectory = new File(preferences.get(ARCH_DIRECTORY_KEY, archDirectoryDefault)); + mapsDirectory = new File(preferences.get(MAP_DIRECTORY_KEY, mapsDirectoryDefault)); + mediaDirectory = new File(preferences.get(MEDIA_DIRECTORY_KEY, mediaDirectoryDefault)); + imageSet = preferences.get(IMAGE_SET_KEY, imageSetDefault); + configSource = configSourceFactory.getConfigSource(preferences.get(CONFIG_SOURCE_KEY, "")); + final int documentationVersion = ActionBuilderUtils.getInt(ACTION_BUILDER, "docuVersion", 0); + if (documentationVersion > 0 && preferences.getInt(DOCUMENTATION_VERSION_KEY, 0) < documentationVersion) { + // remember to open documentation + autoPopupDocumentation = true; + // update documentation version right now, because we want the help popup only one time + preferences.putInt(DOCUMENTATION_VERSION_KEY, documentationVersion); } } @@ -276,7 +276,7 @@ } this.archDirectory = archDirectory; - prefs.put(ARCH_DIRECTORY_KEY, archDirectory.toString()); + preferences.put(ARCH_DIRECTORY_KEY, archDirectory.toString()); } /** @@ -307,7 +307,7 @@ } this.mapsDirectory = mapsDirectory; - prefs.put(MAP_DIRECTORY_KEY, mapsDirectory.toString()); + preferences.put(MAP_DIRECTORY_KEY, mapsDirectory.toString()); } /** @@ -366,7 +366,7 @@ } this.mediaDirectory = mediaDirectory; - prefs.put(MEDIA_DIRECTORY_KEY, mediaDirectory.getPath()); + preferences.put(MEDIA_DIRECTORY_KEY, mediaDirectory.getPath()); } /** @@ -408,7 +408,7 @@ } this.imageSet = imageSet; - prefs.put(IMAGE_SET_KEY, imageSet); + preferences.put(IMAGE_SET_KEY, imageSet); } /** @@ -447,7 +447,7 @@ } this.configSource = configSource; - prefs.put(CONFIG_SOURCE_KEY, configSource.getName()); + preferences.put(CONFIG_SOURCE_KEY, configSource.getName()); } /** @@ -470,16 +470,16 @@ * {@inheritDoc} */ @Override - public boolean isAutoPopupDocu() { - return autoPopupDocu; + public boolean isAutoPopupDocumentation() { + return autoPopupDocumentation; } /** * {@inheritDoc} */ @Override - public void setAutoPopupDocu(final boolean autoPopupDocu) { - this.autoPopupDocu = autoPopupDocu; + public void setAutoPopupDocumentation(final boolean autoPopupDocumentation) { + this.autoPopupDocumentation = autoPopupDocumentation; } /** @@ -488,7 +488,7 @@ */ @Override public boolean isShowMainToolbar() { - return prefs.getBoolean(SHOW_MAIN_TOOLBAR_KEY, SHOW_MAIN_TOOLBAR_DEFAULT); + return preferences.getBoolean(SHOW_MAIN_TOOLBAR_KEY, SHOW_MAIN_TOOLBAR_DEFAULT); } /** @@ -496,7 +496,7 @@ */ @Override public void setShowMainToolbar(final boolean selected) { - prefs.putBoolean(SHOW_MAIN_TOOLBAR_KEY, selected); + preferences.putBoolean(SHOW_MAIN_TOOLBAR_KEY, selected); } /** @@ -504,8 +504,8 @@ */ @NotNull @Override - public String getUsername() { - return prefs.get(PREFS_USERNAME, PREFS_USERNAME_DEFAULT); + public String getUserName() { + return preferences.get(PREFERENCES_USER_NAME, PREFERENCES_USER_NAME_DEFAULT); } /** @@ -513,16 +513,16 @@ */ @NotNull @Override - public String getUsernameDefault() { - return PREFS_USERNAME_DEFAULT; + public String getUserNameDefault() { + return PREFERENCES_USER_NAME_DEFAULT; } /** * {@inheritDoc} */ @Override - public void setUsername(@NotNull final String username) { - prefs.put(PREFS_USERNAME, username); + public void setUserName(@NotNull final String userName) { + preferences.put(PREFERENCES_USER_NAME, userName); } } // class DefaultGlobalSettings Modified: trunk/src/app/net/sf/gridarta/model/settings/GlobalSettings.java =================================================================== --- trunk/src/app/net/sf/gridarta/model/settings/GlobalSettings.java 2010-05-29 06:50:41 UTC (rev 8028) +++ trunk/src/app/net/sf/gridarta/model/settings/GlobalSettings.java 2010-05-29 07:12:23 UTC (rev 8029) @@ -28,7 +28,7 @@ public interface GlobalSettings { /** - * Default value for whether the main windows's toolbar is shown. + * Default value for whether the main window's toolbar is shown. */ boolean SHOW_MAIN_TOOLBAR_DEFAULT = true; @@ -102,9 +102,9 @@ void setChangedDir(boolean hasChangedDir); - boolean isAutoPopupDocu(); + boolean isAutoPopupDocumentation(); - void setAutoPopupDocu(boolean autoPopupDocu); + void setAutoPopupDocumentation(boolean autoPopupDocumentation); @NotNull File getCurrentDirectory(); @@ -198,24 +198,24 @@ void setShowMainToolbar(boolean selected); /** - * Returns the username. - * @return the username + * Returns the user name. + * @return the user name */ @NotNull - String getUsername(); + String getUserName(); /** - * Returns the default username. - * @return the default username + * Returns the default user name. + * @return the default user name */ @NotNull - String getUsernameDefault(); + String getUserNameDefault(); /** - * Sets the username. - * @param username the username + * Sets the user name. + * @param userName the user name */ - void setUsername(@NotNull String username); + void setUserName(@NotNull String userName); /** * Adds a {@link GlobalSettingsListener} to be notified of changes. Modified: trunk/src/test/net/sf/gridarta/model/settings/TestGlobalSettings.java =================================================================== --- trunk/src/test/net/sf/gridarta/model/settings/TestGlobalSettings.java 2010-05-29 06:50:41 UTC (rev 8028) +++ trunk/src/test/net/sf/gridarta/model/settings/TestGlobalSettings.java 2010-05-29 07:12:23 UTC (rev 8029) @@ -134,7 +134,7 @@ * {@inheritDoc} */ @Override - public boolean isAutoPopupDocu() { + public boolean isAutoPopupDocumentation() { throw new AssertionError(); } @@ -142,7 +142,7 @@ * {@inheritDoc} */ @Override - public void setAutoPopupDocu(final boolean autoPopupDocu) { + public void setAutoPopupDocumentation(final boolean autoPopupDocumentation) { throw new AssertionError(); } @@ -276,7 +276,7 @@ */ @NotNull @Override - public String getUsername() { + public String getUserName() { throw new AssertionError(); } @@ -285,7 +285,7 @@ */ @NotNull @Override - public String getUsernameDefault() { + public String getUserNameDefault() { throw new AssertionError(); } @@ -293,7 +293,7 @@ * {@inheritDoc} */ @Override - public void setUsername(@NotNull final String username) { + public void setUserName(@NotNull final String userName) { throw new AssertionError(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-05-29 19:04:02
|
Revision: 8035 http://gridarta.svn.sourceforge.net/gridarta/?rev=8035&view=rev Author: akirschbaum Date: 2010-05-29 19:03:56 +0000 (Sat, 29 May 2010) Log Message: ----------- Fix incorrect resource path names on Windows machines. Modified Paths: -------------- trunk/atrinik/ChangeLog trunk/crossfire/ChangeLog trunk/daimonin/ChangeLog trunk/src/app/net/sf/gridarta/model/settings/AbstractConfigSource.java Modified: trunk/atrinik/ChangeLog =================================================================== --- trunk/atrinik/ChangeLog 2010-05-29 07:26:23 UTC (rev 8034) +++ trunk/atrinik/ChangeLog 2010-05-29 19:03:56 UTC (rev 8035) @@ -1,3 +1,7 @@ +2010-05-29 Andreas Kirschbaum + + * Fix incorrect resource path names on Windows machines. + 2010-05-26 Andreas Kirschbaum * Retain customized attributes when replacing with multi-part game Modified: trunk/crossfire/ChangeLog =================================================================== --- trunk/crossfire/ChangeLog 2010-05-29 07:26:23 UTC (rev 8034) +++ trunk/crossfire/ChangeLog 2010-05-29 19:03:56 UTC (rev 8035) @@ -1,3 +1,7 @@ +2010-05-29 Andreas Kirschbaum + + * Fix incorrect resource path names on Windows machines. + 2010-05-26 Andreas Kirschbaum * Retain customized attributes when replacing with multi-part game Modified: trunk/daimonin/ChangeLog =================================================================== --- trunk/daimonin/ChangeLog 2010-05-29 07:26:23 UTC (rev 8034) +++ trunk/daimonin/ChangeLog 2010-05-29 19:03:56 UTC (rev 8035) @@ -1,3 +1,7 @@ +2010-05-29 Andreas Kirschbaum + + * Fix incorrect resource path names on Windows machines. + 2010-05-26 Andreas Kirschbaum * Retain customized attributes when replacing with multi-part game Modified: trunk/src/app/net/sf/gridarta/model/settings/AbstractConfigSource.java =================================================================== --- trunk/src/app/net/sf/gridarta/model/settings/AbstractConfigSource.java 2010-05-29 07:26:23 UTC (rev 8034) +++ trunk/src/app/net/sf/gridarta/model/settings/AbstractConfigSource.java 2010-05-29 19:03:56 UTC (rev 8035) @@ -78,7 +78,7 @@ } else { throw new IOException("unknown variable '${" + group + "} in '" + key + "=" + spec + "'"); } - matcher.appendReplacement(sb, replacement); + matcher.appendReplacement(sb, Matcher.quoteReplacement(replacement)); } matcher.appendTail(sb); final String result = sb.toString(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-05-30 07:42:01
|
Revision: 8037 http://gridarta.svn.sourceforge.net/gridarta/?rev=8037&view=rev Author: akirschbaum Date: 2010-05-30 07:41:54 +0000 (Sun, 30 May 2010) Log Message: ----------- Order import statements. Modified Paths: -------------- trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/maincontrol/DefaultEditorFactory.java trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/maincontrol/DefaultEditorFactory.java Modified: trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/maincontrol/DefaultEditorFactory.java =================================================================== --- trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/maincontrol/DefaultEditorFactory.java 2010-05-30 07:30:21 UTC (rev 8036) +++ trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/maincontrol/DefaultEditorFactory.java 2010-05-30 07:41:54 UTC (rev 8037) @@ -35,8 +35,8 @@ import net.sf.gridarta.gui.map.renderer.RendererFactory; import net.sf.gridarta.gui.mappropertiesdialog.MapPropertiesDialogFactory; import net.sf.gridarta.gui.newmap.NewMapDialogFactory; +import net.sf.gridarta.gui.prefs.AppPreferencesModel; import net.sf.gridarta.gui.prefs.AppPrefs; -import net.sf.gridarta.gui.prefs.AppPreferencesModel; import net.sf.gridarta.gui.prefs.DevPrefs; import net.sf.gridarta.gui.prefs.GUIPrefs; import net.sf.gridarta.gui.prefs.MapValidatorPrefs; Modified: trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/maincontrol/DefaultEditorFactory.java =================================================================== --- trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/maincontrol/DefaultEditorFactory.java 2010-05-30 07:30:21 UTC (rev 8036) +++ trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/maincontrol/DefaultEditorFactory.java 2010-05-30 07:41:54 UTC (rev 8037) @@ -35,8 +35,8 @@ import net.sf.gridarta.gui.map.renderer.RendererFactory; import net.sf.gridarta.gui.mappropertiesdialog.MapPropertiesDialogFactory; import net.sf.gridarta.gui.newmap.NewMapDialogFactory; +import net.sf.gridarta.gui.prefs.AppPreferencesModel; import net.sf.gridarta.gui.prefs.AppPrefs; -import net.sf.gridarta.gui.prefs.AppPreferencesModel; import net.sf.gridarta.gui.prefs.DevPrefs; import net.sf.gridarta.gui.prefs.GUIPrefs; import net.sf.gridarta.gui.prefs.MapValidatorPrefs; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-05-30 08:48:53
|
Revision: 8041 http://gridarta.svn.sourceforge.net/gridarta/?rev=8041&view=rev Author: akirschbaum Date: 2010-05-30 08:48:46 +0000 (Sun, 30 May 2010) Log Message: ----------- Fix typos. Modified Paths: -------------- trunk/gridarta.ipr trunk/src/app/net/sf/gridarta/maincontrol/GUIMainControl.java Modified: trunk/gridarta.ipr =================================================================== --- trunk/gridarta.ipr 2010-05-30 08:39:30 UTC (rev 8040) +++ trunk/gridarta.ipr 2010-05-30 08:48:46 UTC (rev 8041) @@ -1144,6 +1144,7 @@ <w>endmsg</w> <w>exiter</w> <w>facename</w> + <w>filenames</w> <w>filter<?, ?></w> <w>formatter</w> <w>goto</w> Modified: trunk/src/app/net/sf/gridarta/maincontrol/GUIMainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/maincontrol/GUIMainControl.java 2010-05-30 08:39:30 UTC (rev 8040) +++ trunk/src/app/net/sf/gridarta/maincontrol/GUIMainControl.java 2010-05-30 08:48:46 UTC (rev 8041) @@ -208,7 +208,7 @@ /** * Preferences. */ - private static final Preferences prefs = Preferences.userNodeForPackage(MainControl.class); + private static final Preferences preferences = Preferences.userNodeForPackage(MainControl.class); /** * The status bar instance. @@ -222,7 +222,7 @@ private final PickmapChooserControl<G, A, R> pickmapChooserControl; /** - * The main windows's {@link JFrame}. + * The main window's {@link JFrame}. */ @NotNull private final JFrame mainViewFrame; @@ -433,7 +433,7 @@ final ReplaceDialogManager<G, A, R> replaceDialogManager = new ReplaceDialogManager<G, A, R>(mainViewFrame, copyBuffer, objectChooser, mapViewManager, faceObjectProviders, insertionModeSet); new About(mainViewFrame); exiter = new DefaultExiter(mainViewFrame); - scriptEditControl = new ScriptEditControl(scriptFileFilter, scriptExtension, mainViewFrame, globalSettings.getMapsDirectory(), prefs, exiter); + scriptEditControl = new ScriptEditControl(scriptFileFilter, scriptExtension, mainViewFrame, globalSettings.getMapsDirectory(), preferences, exiter); final TextAreaDefaults textAreaDefaults = new TextAreaDefaults(scriptEditControl); gameObjectAttributesDialogFactory.setTextAreaDefaults(textAreaDefaults); scriptEditControl.setTextAreaDefaults(textAreaDefaults); @@ -541,8 +541,8 @@ new AnimationValidator(faceObjects, errorView).validate(animationObjects); if (globalSettings.isAutoPopupDocumentation()) { - // do an automated help popup because the docu version has increased - // (people won't notice the docu otherwise - nobody expects a docu in opensource) + // do an automated help popup because the documentation version has increased + // (people won't notice the documentation otherwise - nobody expects a documentation in open source) helpActions.showHelp(); globalSettings.setAutoPopupDocumentation(false); } @@ -741,9 +741,9 @@ mainView.handleThrowable(t); } - public void processFile(final String filelist) throws IOException { + public void processFile(final String fileList) throws IOException { try { - final FileInputStream fis = new FileInputStream(filelist); + final FileInputStream fis = new FileInputStream(fileList); try { final InputStreamReader isr = new InputStreamReader(fis); try { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-06-02 07:20:47
|
Revision: 8060 http://gridarta.svn.sourceforge.net/gridarta/?rev=8060&view=rev Author: akirschbaum Date: 2010-06-02 07:20:40 +0000 (Wed, 02 Jun 2010) Log Message: ----------- Fix archetype collection: do not drop mpart_id attributes for tail parts. Modified Paths: -------------- trunk/atrinik/ChangeLog trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/model/archetype/ArchetypeParser.java trunk/build.xml trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/model/archetype/ArchetypeParser.java trunk/daimonin/ChangeLog trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/model/archetype/ArchetypeParser.java trunk/src/app/net/sf/gridarta/model/archetype/AbstractArchetypeParser.java trunk/src/test/net/sf/gridarta/model/archetype/ArchetypeParserTest.java trunk/src/test/net/sf/gridarta/model/archetype/TestArchetypeParser.java Added Paths: ----------- trunk/atrinik/src/test/net/sf/gridarta/var/atrinik/model/archetype/ trunk/atrinik/src/test/net/sf/gridarta/var/atrinik/model/archetype/ArchetypeParserTest.java trunk/src/test/net/sf/gridarta/model/archetype/AbstractArchetypeParserTest.java trunk/src/test/net/sf/gridarta/var/ trunk/src/test/net/sf/gridarta/var/atrinik/ trunk/src/test/net/sf/gridarta/var/atrinik/model/ trunk/src/test/net/sf/gridarta/var/atrinik/model/archetype/ Modified: trunk/atrinik/ChangeLog =================================================================== --- trunk/atrinik/ChangeLog 2010-05-31 17:53:34 UTC (rev 8059) +++ trunk/atrinik/ChangeLog 2010-06-02 07:20:40 UTC (rev 8060) @@ -1,3 +1,8 @@ +2010-06-02 Andreas Kirschbaum + + * Fix archetype collection: do not drop mpart_id attributes for + tail parts. + 2010-05-30 Alex Tokar * Update map header flags in map properties dialog to be in-sync Modified: trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/model/archetype/ArchetypeParser.java =================================================================== --- trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/model/archetype/ArchetypeParser.java 2010-05-31 17:53:34 UTC (rev 8059) +++ trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/model/archetype/ArchetypeParser.java 2010-06-02 07:20:40 UTC (rev 8060) @@ -130,11 +130,10 @@ * {@inheritDoc} */ @Override - protected void finishParseArchetypePart(@NotNull final Archetype firstArch, @NotNull final Archetype archetype, @NotNull final ErrorViewCollector errorViewCollector) { - // set or check mpart_nr - if (firstArch.getMultiRefCount() == 2) { - firstArch.setMultiShapeID(multiShapeID); - } else if (multiShapeID != firstArch.getMultiShapeID()) { + protected void finishParseArchetypePart(@Nullable final Archetype firstArch, @NotNull final Archetype archetype, @NotNull final ErrorViewCollector errorViewCollector) { + // set or check mpart_id + archetype.setMultiShapeID(multiShapeID); + if (firstArch != null && multiShapeID != firstArch.getMultiShapeID()) { errorViewCollector.addWarning(ErrorViewCategory.ARCHETYPE_INVALID, ACTION_BUILDER.format("logDefArchWithInvalidMpartNr", archetype.getArchetypeName(), firstArch.getArchetypeName(), Integer.toString(multiShapeID), Integer.toString(firstArch.getMultiShapeID()))); } } Added: trunk/atrinik/src/test/net/sf/gridarta/var/atrinik/model/archetype/ArchetypeParserTest.java =================================================================== --- trunk/atrinik/src/test/net/sf/gridarta/var/atrinik/model/archetype/ArchetypeParserTest.java (rev 0) +++ trunk/atrinik/src/test/net/sf/gridarta/var/atrinik/model/archetype/ArchetypeParserTest.java 2010-06-02 07:20:40 UTC (rev 8060) @@ -0,0 +1,131 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2010 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.var.atrinik.model.archetype; + +import java.io.IOException; +import java.util.regex.Pattern; +import net.sf.gridarta.model.anim.AnimationObjects; +import net.sf.gridarta.model.anim.DefaultAnimationObjects; +import net.sf.gridarta.model.archetype.AbstractArchetypeBuilder; +import net.sf.gridarta.model.archetype.AbstractArchetypeParser; +import net.sf.gridarta.model.archetype.AbstractArchetypeParserTest; +import net.sf.gridarta.model.archetype.UndefinedArchetypeException; +import net.sf.gridarta.model.archetypetype.ArchetypeTypeSet; +import net.sf.gridarta.model.face.ArchFaceProvider; +import net.sf.gridarta.model.face.DefaultFaceObjects; +import net.sf.gridarta.model.face.FaceObjectProviders; +import net.sf.gridarta.model.face.FaceObjects; +import net.sf.gridarta.model.gameobject.IsoMapSquareInfo; +import net.sf.gridarta.model.gameobject.MultiPositionData; +import net.sf.gridarta.utils.GUIUtils; +import net.sf.gridarta.utils.SystemIcons; +import net.sf.gridarta.var.atrinik.model.gameobject.DefaultGameObjectFactory; +import net.sf.gridarta.var.atrinik.model.gameobject.GameObject; +import net.sf.gridarta.var.atrinik.model.maparchobject.MapArchObject; +import net.sf.japi.swing.action.ActionBuilder; +import net.sf.japi.swing.action.ActionBuilderFactory; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.Test; + +/** + * Regression tests for {@link ArchetypeParser}. + * @author Andreas Kirschbaum + */ +public class ArchetypeParserTest extends AbstractArchetypeParserTest<GameObject, MapArchObject, Archetype> { + + /** + * The loaded archetypes. + */ + @Nullable + private ArchetypeSet archetypeSet = null; + + /** + * Checks that mpart_id fields are parsed correctly. + * @throws IOException if the test fails + * @throws UndefinedArchetypeException if the test fails + */ + @Test + public void testMpartIdOk() throws IOException, UndefinedArchetypeException { + check("Object head\nmpart_id 1\nend\nMore\nObject tail\nmpart_id 1\nend\n", false, false, 2); + Assert.assertEquals(1, getArchetypeSet().getArchetype("head").getMultiShapeID()); + Assert.assertEquals(1, getArchetypeSet().getArchetype("tail").getMultiShapeID()); + } + + /** + * Checks that mpart_id fields are parsed correctly. + * @throws IOException if the test fails + * @throws UndefinedArchetypeException if the test fails + */ + @Test + public void testMpartIdInconsistent() throws IOException, UndefinedArchetypeException { + check("Object head\nmpart_id 1\nend\nMore\nObject tail\nmpart_id 2\nend\n", false, true, 2); + Assert.assertEquals(1, getArchetypeSet().getArchetype("head").getMultiShapeID()); + Assert.assertEquals(2, getArchetypeSet().getArchetype("tail").getMultiShapeID()); + } + + /** + * Initializes the test. + */ + @BeforeClass + public static void setUp() { + final ActionBuilder actionBuilder = ActionBuilderFactory.getInstance().getActionBuilder("net.sf.gridarta"); + actionBuilder.addParent(ActionBuilderFactory.getInstance().getActionBuilder("net.sf.gridarta.var.atrinik")); + } + + /** + * {@inheritDoc} + */ + @NotNull + @Override + protected AbstractArchetypeParser<GameObject, MapArchObject, Archetype, ? extends AbstractArchetypeBuilder<GameObject, MapArchObject, Archetype>> newArchetypeParser() { + final ArchFaceProvider archFaceProvider = new ArchFaceProvider(); + final FaceObjects faceObjects = new DefaultFaceObjects("png", "facetree", Pattern.compile(".*"), "facetree.output", archFaceProvider); + final GUIUtils guiUtils = new GUIUtils(); + final SystemIcons systemIcons = new SystemIcons(guiUtils); + final FaceObjectProviders faceObjectProviders = new FaceObjectProviders(0, faceObjects, systemIcons); + final AnimationObjects animationObjects = new DefaultAnimationObjects("animtree"); + final ArchetypeTypeSet archetypeTypeSet = new ArchetypeTypeSet(); + final DefaultGameObjectFactory gameObjectFactory = new DefaultGameObjectFactory(faceObjectProviders, animationObjects, archetypeTypeSet); + final DefaultArchetypeFactory archetypeFactory = new DefaultArchetypeFactory(faceObjectProviders, animationObjects); + archetypeSet = new ArchetypeSet(archetypeFactory); + archetypeSet.setLoadedFromArchive(true); + assert archetypeSet != null; + final IsoMapSquareInfo isoMapSquareInfo = new IsoMapSquareInfo(1, 1, 1, 1); + final MultiPositionData multiPositionData = new MultiPositionData(isoMapSquareInfo); + assert archetypeSet != null; + return new ArchetypeParser(animationObjects, archetypeSet, gameObjectFactory, multiPositionData); + } + + /** + * {@inheritDoc} + */ + @NotNull + @Override + protected ArchetypeSet getArchetypeSet() { + if (archetypeSet == null) { + throw new IllegalStateException(); + } + return archetypeSet; + } + +} // class ArchetypeParserTest Property changes on: trunk/atrinik/src/test/net/sf/gridarta/var/atrinik/model/archetype/ArchetypeParserTest.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF Modified: trunk/build.xml =================================================================== --- trunk/build.xml 2010-05-31 17:53:34 UTC (rev 8059) +++ trunk/build.xml 2010-06-02 07:20:40 UTC (rev 8060) @@ -458,9 +458,13 @@ <copy todir="classes/test"> <fileset dir="resource" includes="**/*.properties,**/*.dtd"/> <fileset dir="src/test" includes="**/*.properties,**/*.testdata"/> + <fileset dir="src/app" includes="**/*.properties,**/*.testdata"/> <fileset dir="atrinik/src/test" includes="**/*.properties,**/*.testdata"/> + <fileset dir="atrinik/src/app" includes="**/*.properties,**/*.testdata"/> <fileset dir="crossfire/src/test" includes="**/*.properties,**/*.testdata"/> + <fileset dir="crossfire/src/app" includes="**/*.properties,**/*.testdata"/> <fileset dir="daimonin/src/test" includes="**/*.properties,**/*.testdata"/> + <fileset dir="daimonin/src/app" includes="**/*.properties,**/*.testdata"/> </copy> <junit printsummary="no" haltonfailure="yes"> <classpath> Modified: trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/model/archetype/ArchetypeParser.java =================================================================== --- trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/model/archetype/ArchetypeParser.java 2010-05-31 17:53:34 UTC (rev 8059) +++ trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/model/archetype/ArchetypeParser.java 2010-06-02 07:20:40 UTC (rev 8060) @@ -154,7 +154,7 @@ * {@inheritDoc} */ @Override - protected void finishParseArchetypePart(@NotNull final Archetype firstArch, @NotNull final Archetype archetype, @NotNull final ErrorViewCollector errorViewCollector) { + protected void finishParseArchetypePart(@Nullable final Archetype firstArch, @NotNull final Archetype archetype, @NotNull final ErrorViewCollector errorViewCollector) { } /** Modified: trunk/daimonin/ChangeLog =================================================================== --- trunk/daimonin/ChangeLog 2010-05-31 17:53:34 UTC (rev 8059) +++ trunk/daimonin/ChangeLog 2010-06-02 07:20:40 UTC (rev 8060) @@ -1,3 +1,8 @@ +2010-06-02 Andreas Kirschbaum + + * Fix archetype collection: do not drop mpart_id attributes for + tail parts. + 2010-05-29 Andreas Kirschbaum * Fix incorrect resource path names on Windows machines. Modified: trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/model/archetype/ArchetypeParser.java =================================================================== --- trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/model/archetype/ArchetypeParser.java 2010-05-31 17:53:34 UTC (rev 8059) +++ trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/model/archetype/ArchetypeParser.java 2010-06-02 07:20:40 UTC (rev 8060) @@ -129,11 +129,10 @@ * {@inheritDoc} */ @Override - protected void finishParseArchetypePart(@NotNull final Archetype firstArch, @NotNull final Archetype archetype, @NotNull final ErrorViewCollector errorViewCollector) { - // set or check mpart_nr - if (firstArch.getMultiRefCount() == 2) { - firstArch.setMultiShapeID(multiShapeID); - } else if (multiShapeID != firstArch.getMultiShapeID()) { + protected void finishParseArchetypePart(@Nullable final Archetype firstArch, @NotNull final Archetype archetype, @NotNull final ErrorViewCollector errorViewCollector) { + // set or check mpart_id + archetype.setMultiShapeID(multiShapeID); + if (firstArch != null && multiShapeID != firstArch.getMultiShapeID()) { errorViewCollector.addWarning(ErrorViewCategory.ARCHETYPE_INVALID, ACTION_BUILDER.format("logDefArchWithInvalidMpartNr", archetype.getArchetypeName(), firstArch.getArchetypeName(), Integer.toString(multiShapeID), Integer.toString(firstArch.getMultiShapeID()))); } } Modified: trunk/src/app/net/sf/gridarta/model/archetype/AbstractArchetypeParser.java =================================================================== --- trunk/src/app/net/sf/gridarta/model/archetype/AbstractArchetypeParser.java 2010-05-31 17:53:34 UTC (rev 8059) +++ trunk/src/app/net/sf/gridarta/model/archetype/AbstractArchetypeParser.java 2010-06-02 07:20:40 UTC (rev 8060) @@ -198,7 +198,6 @@ if (firstArch != null) { firstArch.addTailPart(archetype); - finishParseArchetypePart(firstArch, archetype, errorViewCollector); } else if (addToPanel(isInternPath, editorFolder, archetype)) { final String panel; final String folder; @@ -217,6 +216,7 @@ } else { archetype.setEditorFolder(GameObject.EDITOR_FOLDER_INTERN); } + finishParseArchetypePart(firstArch, archetype, errorViewCollector); try { archetypeSet.addArchetype(archetype); } catch (final DuplicateArchetypeException ex) { @@ -338,12 +338,13 @@ protected abstract boolean processLine(@NotNull final BufferedReader in, @NotNull final String line, @NotNull final String line2, @NotNull final B archetypeBuilder, @NotNull final ErrorViewCollector errorViewCollector, @NotNull final List<G> invObjects) throws IOException; /** - * Called after the "end" line of a tail part has been read. - * @param firstArch the head part + * Called after the "end" line of a part has been read. + * @param firstArch the head part or <code>null</code> if + * <code>archetype</code> is the head part * @param archetype the tail part * @param errorViewCollector the error view collector for reporting errors */ - protected abstract void finishParseArchetypePart(@NotNull final R firstArch, @NotNull final R archetype, @NotNull final ErrorViewCollector errorViewCollector); + protected abstract void finishParseArchetypePart(@Nullable final R firstArch, @NotNull final R archetype, @NotNull final ErrorViewCollector errorViewCollector); /** * Called after all parts of an archetype have been processed. Added: trunk/src/test/net/sf/gridarta/model/archetype/AbstractArchetypeParserTest.java =================================================================== --- trunk/src/test/net/sf/gridarta/model/archetype/AbstractArchetypeParserTest.java (rev 0) +++ trunk/src/test/net/sf/gridarta/model/archetype/AbstractArchetypeParserTest.java 2010-06-02 07:20:40 UTC (rev 8060) @@ -0,0 +1,80 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2010 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.model.archetype; + +import java.io.BufferedReader; +import java.io.File; +import java.io.IOException; +import java.io.Reader; +import java.io.StringReader; +import java.util.ArrayList; +import java.util.List; +import net.sf.gridarta.model.errorview.ErrorViewCollector; +import net.sf.gridarta.model.errorview.TestErrorView; +import net.sf.gridarta.model.gameobject.GameObject; +import net.sf.gridarta.model.map.maparchobject.MapArchObject; +import org.jetbrains.annotations.NotNull; +import org.junit.Assert; + +/** + * Abstract base class for regression tests for {@link ArchetypeParser}. + * @author Andreas Kirschbaum + */ +public abstract class AbstractArchetypeParserTest<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> { + + /** + * Creates a new archetype parser and parses the given input. + * @param input the input to parse + * @param hasErrors whether errors are expected + * @param hasWarnings whether warnings are expected + * @param archetypes the number of archetypes to expect + * @throws IOException if parsing fails + */ + protected void check(@NotNull final String input, final boolean hasErrors, final boolean hasWarnings, final int archetypes) throws IOException { + final AbstractArchetypeParser<G, A, R, ?> archetypeParser = newArchetypeParser(); + final TestErrorView errorView = new TestErrorView(); + final List<G> invObjects = new ArrayList<G>(); + final Reader reader = new StringReader(input); + final BufferedReader bufferedReader = new BufferedReader(reader); + try { + archetypeParser.parseArchetypeFromStream(bufferedReader, null, null, null, "panel", "folder", "", invObjects, new ErrorViewCollector(errorView, new File("*string*"))); + } finally { + bufferedReader.close(); + } + Assert.assertEquals(hasErrors, errorView.hasErrors()); + Assert.assertEquals(hasWarnings, errorView.hasWarnings()); + Assert.assertEquals(archetypes, getArchetypeSet().getArchetypeCount()); + } + + /** + * Creates a new {@link AbstractArchetypeParser} instance. + * @return the new instance + */ + @NotNull + protected abstract AbstractArchetypeParser<G, A, R, ? extends AbstractArchetypeBuilder<G, A, R>> newArchetypeParser(); + + /** + * Returns the {@link ArchetypeSet}. + * @return the archetype set + */ + @NotNull + protected abstract ArchetypeSet<G, A, R> getArchetypeSet(); + +} // class AbstractArchetypeParserTest Property changes on: trunk/src/test/net/sf/gridarta/model/archetype/AbstractArchetypeParserTest.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF Modified: trunk/src/test/net/sf/gridarta/model/archetype/ArchetypeParserTest.java =================================================================== --- trunk/src/test/net/sf/gridarta/model/archetype/ArchetypeParserTest.java 2010-05-31 17:53:34 UTC (rev 8059) +++ trunk/src/test/net/sf/gridarta/model/archetype/ArchetypeParserTest.java 2010-06-02 07:20:40 UTC (rev 8060) @@ -19,18 +19,10 @@ package net.sf.gridarta.model.archetype; -import java.io.BufferedReader; -import java.io.File; import java.io.IOException; -import java.io.Reader; -import java.io.StringReader; -import java.util.ArrayList; -import java.util.List; import java.util.regex.Pattern; import net.sf.gridarta.model.anim.AnimationObjects; import net.sf.gridarta.model.anim.DefaultAnimationObjects; -import net.sf.gridarta.model.errorview.ErrorViewCollector; -import net.sf.gridarta.model.errorview.TestErrorView; import net.sf.gridarta.model.face.ArchFaceProvider; import net.sf.gridarta.model.face.DefaultFaceObjects; import net.sf.gridarta.model.face.FaceObjectProviders; @@ -49,13 +41,13 @@ * Regression tests for {@link AbstractArchetypeParser}. * @author Andreas Kirschbaum */ -public class ArchetypeParserTest { +public class ArchetypeParserTest extends AbstractArchetypeParserTest<TestGameObject, TestMapArchObject, TestArchetype> { /** * The loaded archetypes. */ @Nullable - private TestArchetypeSet archetypeSet = null; + private ArchetypeSet<TestGameObject, TestMapArchObject, TestArchetype> archetypeSet = null; /** * Checks that a missing "object" line is detected. @@ -83,9 +75,7 @@ @Test public void testMsgTextEmpty() throws IOException, UndefinedArchetypeException { check("Object test\nmsg\nendmsg\nend\n", false, false, 1); - assert archetypeSet != null; - final Archetype<TestGameObject, TestMapArchObject, TestArchetype> archetype = archetypeSet.getArchetype("test"); - Assert.assertNull(archetype.getMsgText()); + Assert.assertNull(getArchetypeSet().getArchetype("test").getMsgText()); } /** @@ -96,9 +86,7 @@ @Test public void testMsgTextLines() throws IOException, UndefinedArchetypeException { check("Object test\nmsg\nabc\ndef\nghi\nendmsg\nend\n", false, false, 1); - assert archetypeSet != null; - final Archetype<TestGameObject, TestMapArchObject, TestArchetype> archetype = archetypeSet.getArchetype("test"); - Assert.assertEquals("abc\ndef\nghi\n", archetype.getMsgText()); + Assert.assertEquals("abc\ndef\nghi\n", getArchetypeSet().getArchetype("test").getMsgText()); } /** @@ -109,9 +97,7 @@ @Test public void testMsgTextTrailingWhitespace() throws IOException, UndefinedArchetypeException { check("Object test\nmsg\nabc \ndef\nghi \n\nendmsg\nend\n", false, false, 1); - assert archetypeSet != null; - final Archetype<TestGameObject, TestMapArchObject, TestArchetype> archetype = archetypeSet.getArchetype("test"); - Assert.assertEquals("abc\ndef\nghi\n\n", archetype.getMsgText()); + Assert.assertEquals("abc\ndef\nghi\n\n", getArchetypeSet().getArchetype("test").getMsgText()); } /** @@ -122,9 +108,7 @@ @Test public void testMsgTextLeadingWhitespace() throws IOException, UndefinedArchetypeException { check("Object test\nmsg\n\n abc\ndef\n ghi\nendmsg\nend\n", false, false, 1); - assert archetypeSet != null; - final Archetype<TestGameObject, TestMapArchObject, TestArchetype> archetype = archetypeSet.getArchetype("test"); - Assert.assertEquals("\n abc\ndef\n ghi\n", archetype.getMsgText()); + Assert.assertEquals("\n abc\ndef\n ghi\n", getArchetypeSet().getArchetype("test").getMsgText()); } /** @@ -137,35 +121,11 @@ } /** - * Creates a new archetype parser and parses the given input. - * @param input the input to parse - * @param hasErrors whether errors are expected - * @param hasWarnings whether warnings are expected - * @param archetypes the number of archetypes to expect - * @throws IOException if parsing fails + * {@inheritDoc} */ - private void check(@NotNull final String input, final boolean hasErrors, final boolean hasWarnings, final int archetypes) throws IOException { - final AbstractArchetypeParser<TestGameObject, TestMapArchObject, TestArchetype, TestArchetypeBuilder> archetypeParser = newArchetypeParser(); - final TestErrorView errorView = new TestErrorView(); - final List<TestGameObject> invObjects = new ArrayList<TestGameObject>(); - final Reader reader = new StringReader(input); - final BufferedReader bufferedReader = new BufferedReader(reader); - try { - archetypeParser.parseArchetypeFromStream(bufferedReader, null, null, null, "panel", "folder", "", invObjects, new ErrorViewCollector(errorView, new File("*string*"))); - } finally { - bufferedReader.close(); - } - Assert.assertEquals(hasErrors, errorView.hasErrors()); - Assert.assertEquals(hasWarnings, errorView.hasWarnings()); - assert archetypeSet != null; - Assert.assertEquals(archetypes, archetypeSet.getArchetypeCount()); - } - - /** - * Creates a new {@link TestArchetypeParser} instance. - * @return the new instance - */ - public AbstractArchetypeParser<TestGameObject, TestMapArchObject, TestArchetype, TestArchetypeBuilder> newArchetypeParser() { + @NotNull + @Override + protected AbstractArchetypeParser<TestGameObject, TestMapArchObject, TestArchetype, ? extends AbstractArchetypeBuilder<TestGameObject, TestMapArchObject, TestArchetype>> newArchetypeParser() { final ArchFaceProvider archFaceProvider = new ArchFaceProvider(); final FaceObjects faceObjects = new DefaultFaceObjects("png", "facetree", Pattern.compile(".*"), "facetree.output", archFaceProvider); final GUIUtils guiUtils = new GUIUtils(); @@ -181,4 +141,16 @@ return new TestArchetypeParser(archetypeBuilder, animationObjects, archetypeSet); } + /** + * {@inheritDoc} + */ + @NotNull + @Override + protected ArchetypeSet<TestGameObject, TestMapArchObject, TestArchetype> getArchetypeSet() { + if (archetypeSet == null) { + throw new IllegalStateException(); + } + return archetypeSet; + } + } // class ArchetypeParserTest Modified: trunk/src/test/net/sf/gridarta/model/archetype/TestArchetypeParser.java =================================================================== --- trunk/src/test/net/sf/gridarta/model/archetype/TestArchetypeParser.java 2010-05-31 17:53:34 UTC (rev 8059) +++ trunk/src/test/net/sf/gridarta/model/archetype/TestArchetypeParser.java 2010-06-02 07:20:40 UTC (rev 8060) @@ -72,7 +72,7 @@ * {@inheritDoc} */ @Override - protected void finishParseArchetypePart(@NotNull final TestArchetype firstArch, @NotNull final TestArchetype archetype, @NotNull final ErrorViewCollector errorViewCollector) { + protected void finishParseArchetypePart(@Nullable final TestArchetype firstArch, @NotNull final TestArchetype archetype, @NotNull final ErrorViewCollector errorViewCollector) { } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-06-03 10:48:24
|
Revision: 8064 http://gridarta.svn.sourceforge.net/gridarta/?rev=8064&view=rev Author: akirschbaum Date: 2010-06-03 10:48:17 +0000 (Thu, 03 Jun 2010) Log Message: ----------- Fix "Move Env" and "Move Inv" actions in selected square view when applied to multi-part game objects. Modified Paths: -------------- trunk/atrinik/ChangeLog trunk/crossfire/ChangeLog trunk/daimonin/ChangeLog trunk/src/app/net/sf/gridarta/gui/selectedsquare/SelectedSquareActions.java trunk/src/app/net/sf/gridarta/model/baseobject/AbstractBaseObject.java trunk/src/app/net/sf/gridarta/model/baseobject/BaseObject.java trunk/src/app/net/sf/gridarta/model/map/mapmodel/DefaultMapModel.java trunk/src/app/net/sf/gridarta/model/map/mapmodel/MapModel.java trunk/src/test/net/sf/gridarta/model/gameobject/TestGameObject.java Added Paths: ----------- trunk/src/test/net/sf/gridarta/gui/selectedsquare/ trunk/src/test/net/sf/gridarta/gui/selectedsquare/SelectedSquareActionsTest.java Modified: trunk/atrinik/ChangeLog =================================================================== --- trunk/atrinik/ChangeLog 2010-06-03 10:30:20 UTC (rev 8063) +++ trunk/atrinik/ChangeLog 2010-06-03 10:48:17 UTC (rev 8064) @@ -1,3 +1,8 @@ +2010-06-03 Andreas Kirschbaum + + * Fix "Move Env" and "Move Inv" actions in selected square view + when applied to multi-part game objects. + 2010-06-02 Andreas Kirschbaum * Fix archetype collection: do not drop mpart_id attributes for Modified: trunk/crossfire/ChangeLog =================================================================== --- trunk/crossfire/ChangeLog 2010-06-03 10:30:20 UTC (rev 8063) +++ trunk/crossfire/ChangeLog 2010-06-03 10:48:17 UTC (rev 8064) @@ -1,3 +1,8 @@ +2010-06-03 Andreas Kirschbaum + + * Fix "Move Env" and "Move Inv" actions in selected square view + when applied to multi-part game objects. + 2010-05-29 Andreas Kirschbaum * Fix incorrect resource path names on Windows machines. Modified: trunk/daimonin/ChangeLog =================================================================== --- trunk/daimonin/ChangeLog 2010-06-03 10:30:20 UTC (rev 8063) +++ trunk/daimonin/ChangeLog 2010-06-03 10:48:17 UTC (rev 8064) @@ -1,3 +1,8 @@ +2010-06-03 Andreas Kirschbaum + + * Fix "Move Env" and "Move Inv" actions in selected square view + when applied to multi-part game objects. + 2010-06-02 Andreas Kirschbaum * Fix archetype collection: do not drop mpart_id attributes for Modified: trunk/src/app/net/sf/gridarta/gui/selectedsquare/SelectedSquareActions.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/selectedsquare/SelectedSquareActions.java 2010-06-03 10:30:20 UTC (rev 8063) +++ trunk/src/app/net/sf/gridarta/gui/selectedsquare/SelectedSquareActions.java 2010-06-03 10:48:17 UTC (rev 8064) @@ -19,8 +19,8 @@ package net.sf.gridarta.gui.selectedsquare; +import java.awt.Point; import net.sf.gridarta.model.archetype.Archetype; -import net.sf.gridarta.model.baseobject.GameObjectContainer; import net.sf.gridarta.model.gameobject.GameObject; import net.sf.gridarta.model.map.maparchobject.MapArchObject; import net.sf.gridarta.model.map.mapmodel.MapModel; @@ -183,17 +183,18 @@ return false; } + final MapSquare<G, A, R> mapSquare = gameObject.getMapSquare(); + assert mapSquare != null; + final MapModel<G, A, R> mapModel = mapSquare.getMapModel(); + final Point pos = new Point(mapSquare.getMapX(), mapSquare.getMapY()); + if (!envGameObject.isInContainer() && gameObject.getArchetype().isMulti() && !mapModel.isMultiArchFittingToMap(gameObject.getArchetype(), pos, true)) { + return false; + } + if (performAction) { - final GameObjectContainer<G, A, R> envGameObjectContainer = envGameObject.getContainer(); - assert envGameObjectContainer != null; - - final MapSquare<G, A, R> mapSquare = gameObject.getMapSquare(); - assert mapSquare != null; - final MapModel<G, A, R> mapModel = mapSquare.getMapModel(); mapModel.beginTransaction("Move To Environment"); try { - gameObject.remove(); - envGameObjectContainer.addBefore(gameObject, envGameObject); + mapModel.moveEnv(gameObject, pos, envGameObject); } finally { mapModel.endTransaction(); } @@ -224,8 +225,7 @@ final MapModel<G, A, R> mapModel = mapSquare.getMapModel(); mapModel.beginTransaction("Move To Inventory"); try { - gameObject.remove(); - prevGameObject.addFirst(gameObject); + mapModel.moveInv(gameObject, prevGameObject); } finally { mapModel.endTransaction(); } Modified: trunk/src/app/net/sf/gridarta/model/baseobject/AbstractBaseObject.java =================================================================== --- trunk/src/app/net/sf/gridarta/model/baseobject/AbstractBaseObject.java 2010-06-03 10:30:20 UTC (rev 8063) +++ trunk/src/app/net/sf/gridarta/model/baseobject/AbstractBaseObject.java 2010-06-03 10:48:17 UTC (rev 8064) @@ -573,6 +573,14 @@ * {@inheritDoc} */ @Override + public void removeTailParts() { + multi = null; + } + + /** + * {@inheritDoc} + */ + @Override public T getHead() { return multi != null ? multi.getHead() : getThis(); } Modified: trunk/src/app/net/sf/gridarta/model/baseobject/BaseObject.java =================================================================== --- trunk/src/app/net/sf/gridarta/model/baseobject/BaseObject.java 2010-06-03 10:30:20 UTC (rev 8063) +++ trunk/src/app/net/sf/gridarta/model/baseobject/BaseObject.java 2010-06-03 10:48:17 UTC (rev 8064) @@ -339,6 +339,12 @@ void addTailPart(@NotNull T tail); /** + * Removes all tail parts of this game object. Afterwards {@link #isMulti()} + * will return <code>false</code>. + */ + void removeTailParts(); + + /** * Return the head part of a multi-part object. For single-part objects it * is the object itself. * @return the head of the object Modified: trunk/src/app/net/sf/gridarta/model/map/mapmodel/DefaultMapModel.java =================================================================== --- trunk/src/app/net/sf/gridarta/model/map/mapmodel/DefaultMapModel.java 2010-06-03 10:30:20 UTC (rev 8063) +++ trunk/src/app/net/sf/gridarta/model/map/mapmodel/DefaultMapModel.java 2010-06-03 10:48:17 UTC (rev 8064) @@ -32,6 +32,7 @@ import net.sf.gridarta.model.archetypechooser.ArchetypeChooserModel; import net.sf.gridarta.model.autojoin.AutojoinLists; import net.sf.gridarta.model.baseobject.BaseObject; +import net.sf.gridarta.model.baseobject.GameObjectContainer; import net.sf.gridarta.model.gameobject.GameObject; import net.sf.gridarta.model.gameobject.GameObjectFactory; import net.sf.gridarta.model.map.maparchobject.MapArchObject; @@ -716,17 +717,10 @@ } /** - * Checks whether an GameObject (multi-arch) would still fit on this map. - * @param archetype the archetype to check - * @param pos position of multi-square head - * @param allowDouble whether overlapping multi-square arches should be - * allowed (check is done using the arch name) - * @return whether the multi-arch would still fit on this map - * @retval <code>true</code> if the multi-square arch would still fit on - * this map - * @retval <code>false</code> otherwise + * {@inheritDoc} */ - private boolean isMultiArchFittingToMap(@NotNull final Archetype<G, A, R> archetype, @NotNull final Point pos, final boolean allowDouble) { + @Override + public boolean isMultiArchFittingToMap(@NotNull final Archetype<G, A, R> archetype, @NotNull final Point pos, final boolean allowDouble) { for (Archetype<G, A, R> part = archetype; part != null; part = part.getMultiNext()) { final Point point = new Point(part.getMultiX(), part.getMultiY()); point.translate(pos.x, pos.y); @@ -890,6 +884,46 @@ * {@inheritDoc} */ @Override + public void moveEnv(@NotNull final G gameObject, @NotNull final Point pos, @NotNull final G nextGameObject) { + assert !gameObject.isMulti(); // no tail parts should be present when inside inventory of another game object + final GameObjectContainer<G,A,R> nextGameObjectContainer = nextGameObject.getContainer(); + if (nextGameObjectContainer == null) { + throw new IllegalArgumentException(); + } + final MapSquare<G, A, R> mapSquare = nextGameObjectContainer.getMapSquare(); + if (mapSquare == null || mapSquare.getMapModel() != this) { + throw new IllegalArgumentException(); + } + gameObject.remove(); + nextGameObjectContainer.addBefore(gameObject, nextGameObject); + + // regenerate tail parts when inserted into a map square + if (!nextGameObject.isInContainer() && gameObject.getArchetype().isMulti()) { + final Point tmp = new Point(); + for (R archetypeTail = gameObject.getArchetype().getMultiNext(); archetypeTail != null; archetypeTail = archetypeTail.getMultiNext()) { + final G gameObjectTail = archetypeTail.newInstance(gameObjectFactory); + gameObject.addTailPart(gameObjectTail); + tmp.x = pos.x + archetypeTail.getMultiX(); + tmp.y = pos.y + archetypeTail.getMultiY(); + addGameObjectToMap(gameObjectTail, tmp, topmostInsertionMode); + } + } + } + + /** + * {@inheritDoc} + */ + @Override + public void moveInv(@NotNull final G gameObject, @NotNull final GameObject<G, A, R> prevGameObject) { + gameObject.remove(); + gameObject.removeTailParts(); + prevGameObject.addFirst(gameObject); + } + + /** + * {@inheritDoc} + */ + @Override public boolean isAreaEmpty(final int left, final int top, final int width, final int height) { final Point point = new Point(); for (int x = left; x < left + width; x++) { Modified: trunk/src/app/net/sf/gridarta/model/map/mapmodel/MapModel.java =================================================================== --- trunk/src/app/net/sf/gridarta/model/map/mapmodel/MapModel.java 2010-06-03 10:30:20 UTC (rev 8063) +++ trunk/src/app/net/sf/gridarta/model/map/mapmodel/MapModel.java 2010-06-03 10:48:17 UTC (rev 8064) @@ -314,6 +314,21 @@ void addGameObjectToMap(@NotNull G gameObject, @NotNull Point pos, @NotNull InsertionMode<G, A, R> insertionMode); /** + * Moves a {@link GameObject} to its environment. + * @param gameObject the game object to move + * @param pos the insertion position + * @param nextGameObject the next game object + */ + void moveEnv(@NotNull G gameObject, @NotNull Point pos, @NotNull G nextGameObject); + + /** + * Moves a {@link GameObject} to the inventory of another game object. + * @param gameObject the game object to move + * @param prevGameObject the previous game object + */ + void moveInv(@NotNull G gameObject, @NotNull GameObject<G, A, R> prevGameObject); + + /** * Inserts a {@link BaseObject} to a map. Archetypes are instantiated, game * objects are cloned. The direction of the inserted game object is set to * the direction of the archetype chooser. This function allows multi-square @@ -357,6 +372,19 @@ void removeGameObject(@NotNull G gameObject, boolean join); /** + * Checks whether an GameObject (multi-arch) would still fit on this map. + * @param archetype the archetype to check + * @param pos position of multi-square head + * @param allowDouble whether overlapping multi-square arches should be + * allowed (check is done using the arch name) + * @return whether the multi-arch would still fit on this map + * @retval <code>true</code> if the multi-square arch would still fit on + * this map + * @retval <code>false</code> otherwise + */ + boolean isMultiArchFittingToMap(@NotNull Archetype<G, A, R> archetype, @NotNull Point pos, boolean allowDouble); + + /** * Sets the errors in this map. * @param errors the errors */ Added: trunk/src/test/net/sf/gridarta/gui/selectedsquare/SelectedSquareActionsTest.java =================================================================== --- trunk/src/test/net/sf/gridarta/gui/selectedsquare/SelectedSquareActionsTest.java (rev 0) +++ trunk/src/test/net/sf/gridarta/gui/selectedsquare/SelectedSquareActionsTest.java 2010-06-03 10:48:17 UTC (rev 8064) @@ -0,0 +1,895 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2010 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.selectedsquare; + +import java.awt.Point; +import java.io.File; +import net.sf.gridarta.gui.map.mapview.MapView; +import net.sf.gridarta.gui.map.mapview.MapViewBasic; +import net.sf.gridarta.gui.map.renderer.RendererFactory; +import net.sf.gridarta.gui.map.renderer.TestRendererFactory; +import net.sf.gridarta.gui.map.test.TestMapControlCreator; +import net.sf.gridarta.model.archetype.DuplicateArchetypeException; +import net.sf.gridarta.model.archetype.TestArchetype; +import net.sf.gridarta.model.gameobject.TestGameObject; +import net.sf.gridarta.model.map.maparchobject.TestMapArchObject; +import net.sf.gridarta.model.map.mapcontrol.MapControl; +import net.sf.gridarta.model.map.mapmodel.MapModel; +import net.sf.gridarta.model.map.mapmodel.MapSquare; +import net.sf.gridarta.utils.Size2D; +import org.jetbrains.annotations.NotNull; +import org.junit.Assert; +import org.junit.Test; + +/** + * Regression tests for {@link SelectedSquareActions}. + * @author Andreas Kirschbaum + */ +public class SelectedSquareActionsTest { + + /** + * The first map file. + */ + private static final File MAP_FILE1 = new File("a"); + + /** + * The first map name. + */ + private static final String MAP_NAME1 = "name1"; + + /** + * Checks that {@link SelectedSquareActions#doMoveSquareTop(boolean)} does + * work for single-square game objects. + * @throws DuplicateArchetypeException if the test fails + */ + @Test + public void testDoMoveSquareTopSingle() throws DuplicateArchetypeException { + final TestMapControlCreator testMapControlCreator = new TestMapControlCreator(); + final MapControl<TestGameObject, TestMapArchObject, TestArchetype> mapControl = testMapControlCreator.newMapControl(MAP_FILE1, MAP_NAME1, new Size2D(1, 1)); + final SelectedSquareModel<TestGameObject, TestMapArchObject, TestArchetype> selectedSquareModel = newSelectedSquareModel(mapControl, testMapControlCreator); + final SelectedSquareActions<TestGameObject, TestMapArchObject, TestArchetype> selectedSquareActions = new SelectedSquareActions<TestGameObject, TestMapArchObject, TestArchetype>(selectedSquareModel); + + final Point point = new Point(0, 0); + final MapModel<TestGameObject,TestMapArchObject,TestArchetype> mapModel = mapControl.getMapModel(); + mapModel.beginTransaction("TEST"); + final MapSquare<TestGameObject, TestMapArchObject, TestArchetype> mapSquare = mapModel.getMapSquare(point); + final TestGameObject ob2 = testMapControlCreator.insertFloor(mapModel, point); + final TestGameObject ob1 = testMapControlCreator.insertExit(mapModel, point); + + TestMapControlCreator.checkContents(mapSquare, ob2, ob1); + + // empty selection => nothing to move + Assert.assertFalse(selectedSquareActions.doMoveSquareTop(false)); + Assert.assertFalse(selectedSquareActions.doMoveSquareTop(true)); + + selectedSquareModel.setSelectedMapSquare(mapSquare, null, 0); + selectedSquareModel.setSelectedGameObject(ob2, 1); + + // [ob2, ob1] => ob2 can move + Assert.assertTrue(selectedSquareActions.doMoveSquareTop(false)); + Assert.assertTrue(selectedSquareActions.doMoveSquareTop(true)); + TestMapControlCreator.checkContents(mapSquare, ob1, ob2); + + // [ob1, ob2] => ob2 cannot move + Assert.assertFalse(selectedSquareActions.doMoveSquareTop(false)); + Assert.assertFalse(selectedSquareActions.doMoveSquareTop(true)); + TestMapControlCreator.checkContents(mapSquare, ob1, ob2); + } + + /** + * Checks that {@link SelectedSquareActions#doMoveSquareTop(boolean)} does + * work for multi-square game objects. + * @throws DuplicateArchetypeException if the test fails + */ + @Test + public void testDoMoveSquareTopMulti() throws DuplicateArchetypeException { + final TestMapControlCreator testMapControlCreator = new TestMapControlCreator(); + final MapControl<TestGameObject, TestMapArchObject, TestArchetype> mapControl = testMapControlCreator.newMapControl(MAP_FILE1, MAP_NAME1, new Size2D(2, 1)); + final SelectedSquareModel<TestGameObject, TestMapArchObject, TestArchetype> selectedSquareModel = newSelectedSquareModel(mapControl, testMapControlCreator); + final SelectedSquareActions<TestGameObject, TestMapArchObject, TestArchetype> selectedSquareActions = new SelectedSquareActions<TestGameObject, TestMapArchObject, TestArchetype>(selectedSquareModel); + + final Point pointHead = new Point(0, 0); + final Point pointTail = new Point(1, 0); + final MapModel<TestGameObject,TestMapArchObject,TestArchetype> mapModel = mapControl.getMapModel(); + mapModel.beginTransaction("TEST"); + final MapSquare<TestGameObject, TestMapArchObject, TestArchetype> mapSquareHead = mapModel.getMapSquare(pointHead); + final MapSquare<TestGameObject, TestMapArchObject, TestArchetype> mapSquareTail = mapModel.getMapSquare(pointTail); + final TestGameObject ob1Head = testMapControlCreator.insertFloor(mapModel, pointHead); + final TestGameObject ob1Tail = testMapControlCreator.insertFloor(mapModel, pointTail); + final TestGameObject ob2Head = testMapControlCreator.insertMob21(mapModel, pointHead); + final TestGameObject ob2Tail = ob2Head.getMultiNext(); + + TestMapControlCreator.checkContents(mapSquareHead, ob1Head, ob2Head); + TestMapControlCreator.checkContents(mapSquareTail, ob1Tail, ob2Tail); + + // empty selection => nothing to move + Assert.assertFalse(selectedSquareActions.doMoveSquareTop(false)); + Assert.assertFalse(selectedSquareActions.doMoveSquareTop(true)); + + selectedSquareModel.setSelectedMapSquare(mapSquareHead, null, 0); + selectedSquareModel.setSelectedGameObject(ob1Head, 1); + + // [ob1, ob2] => ob1 can move + Assert.assertTrue(selectedSquareActions.doMoveSquareTop(false)); + Assert.assertTrue(selectedSquareActions.doMoveSquareTop(true)); + TestMapControlCreator.checkContents(mapSquareHead, ob2Head, ob1Head); + TestMapControlCreator.checkContents(mapSquareTail, ob1Tail, ob2Tail); + + // [ob2, ob1] => ob1 cannot move + Assert.assertFalse(selectedSquareActions.doMoveSquareTop(false)); + Assert.assertFalse(selectedSquareActions.doMoveSquareTop(true)); + TestMapControlCreator.checkContents(mapSquareHead, ob2Head, ob1Head); + TestMapControlCreator.checkContents(mapSquareTail, ob1Tail, ob2Tail); + + selectedSquareModel.setSelectedMapSquare(mapSquareTail, null, 0); + selectedSquareModel.setSelectedGameObject(ob1Tail, 1); + + // [ob1, ob2] => ob1 can move // XXX: this probably should be changed: moving tail parts is not sensible + Assert.assertTrue(selectedSquareActions.doMoveSquareTop(false)); + Assert.assertTrue(selectedSquareActions.doMoveSquareTop(true)); + TestMapControlCreator.checkContents(mapSquareHead, ob2Head, ob1Head); + TestMapControlCreator.checkContents(mapSquareTail, ob2Tail, ob1Tail); + + // [ob2, ob1] => ob1 cannot move + Assert.assertFalse(selectedSquareActions.doMoveSquareTop(false)); + Assert.assertFalse(selectedSquareActions.doMoveSquareTop(true)); + TestMapControlCreator.checkContents(mapSquareHead, ob2Head, ob1Head); + TestMapControlCreator.checkContents(mapSquareTail, ob2Tail, ob1Tail); + } + + /** + * Checks that {@link SelectedSquareActions#doMoveSquareUp(boolean)} does + * work for single-square game objects. + * @throws DuplicateArchetypeException if the test fails + */ + @Test + public void testDoMoveSquareUpSingle() throws DuplicateArchetypeException { + final TestMapControlCreator testMapControlCreator = new TestMapControlCreator(); + final MapControl<TestGameObject, TestMapArchObject, TestArchetype> mapControl = testMapControlCreator.newMapControl(MAP_FILE1, MAP_NAME1, new Size2D(1, 1)); + final SelectedSquareModel<TestGameObject, TestMapArchObject, TestArchetype> selectedSquareModel = newSelectedSquareModel(mapControl, testMapControlCreator); + final SelectedSquareActions<TestGameObject, TestMapArchObject, TestArchetype> selectedSquareActions = new SelectedSquareActions<TestGameObject, TestMapArchObject, TestArchetype>(selectedSquareModel); + + final Point point = new Point(0, 0); + final MapModel<TestGameObject,TestMapArchObject,TestArchetype> mapModel = mapControl.getMapModel(); + mapModel.beginTransaction("TEST"); + final MapSquare<TestGameObject, TestMapArchObject, TestArchetype> mapSquare = mapModel.getMapSquare(point); + final TestGameObject ob2 = testMapControlCreator.insertFloor(mapModel, point); + final TestGameObject ob1 = testMapControlCreator.insertExit(mapModel, point); + + TestMapControlCreator.checkContents(mapSquare, ob2, ob1); + + // empty selection => nothing to move + Assert.assertFalse(selectedSquareActions.doMoveSquareUp(false)); + Assert.assertFalse(selectedSquareActions.doMoveSquareUp(true)); + + selectedSquareModel.setSelectedMapSquare(mapSquare, null, 0); + selectedSquareModel.setSelectedGameObject(ob2, 1); + + // [ob2, ob1] => ob2 can move + Assert.assertTrue(selectedSquareActions.doMoveSquareUp(false)); + Assert.assertTrue(selectedSquareActions.doMoveSquareUp(true)); + TestMapControlCreator.checkContents(mapSquare, ob1, ob2); + + // [ob1, ob2] => ob2 cannot move + Assert.assertFalse(selectedSquareActions.doMoveSquareUp(false)); + Assert.assertFalse(selectedSquareActions.doMoveSquareUp(true)); + TestMapControlCreator.checkContents(mapSquare, ob1, ob2); + } + + /** + * Checks that {@link SelectedSquareActions#doMoveSquareUp(boolean)} does + * work for multi-square game objects. + * @throws DuplicateArchetypeException if the test fails + */ + @Test + public void testDoMoveSquareUpMulti() throws DuplicateArchetypeException { + final TestMapControlCreator testMapControlCreator = new TestMapControlCreator(); + final MapControl<TestGameObject, TestMapArchObject, TestArchetype> mapControl = testMapControlCreator.newMapControl(MAP_FILE1, MAP_NAME1, new Size2D(2, 1)); + final SelectedSquareModel<TestGameObject, TestMapArchObject, TestArchetype> selectedSquareModel = newSelectedSquareModel(mapControl, testMapControlCreator); + final SelectedSquareActions<TestGameObject, TestMapArchObject, TestArchetype> selectedSquareActions = new SelectedSquareActions<TestGameObject, TestMapArchObject, TestArchetype>(selectedSquareModel); + + final Point pointHead = new Point(0, 0); + final Point pointTail = new Point(1, 0); + final MapModel<TestGameObject,TestMapArchObject,TestArchetype> mapModel = mapControl.getMapModel(); + mapModel.beginTransaction("TEST"); + final MapSquare<TestGameObject, TestMapArchObject, TestArchetype> mapSquareHead = mapModel.getMapSquare(pointHead); + final MapSquare<TestGameObject, TestMapArchObject, TestArchetype> mapSquareTail = mapModel.getMapSquare(pointTail); + final TestGameObject ob2Head = testMapControlCreator.insertFloor(mapModel, pointHead); + final TestGameObject ob2Tail = testMapControlCreator.insertFloor(mapModel, pointTail); + final TestGameObject ob1Head = testMapControlCreator.insertMob21(mapModel, pointHead); + final TestGameObject ob1Tail = ob1Head.getMultiNext(); + + TestMapControlCreator.checkContents(mapSquareHead, ob2Head, ob1Head); + TestMapControlCreator.checkContents(mapSquareTail, ob2Tail, ob1Tail); + + // empty selection => nothing to move + Assert.assertFalse(selectedSquareActions.doMoveSquareUp(false)); + Assert.assertFalse(selectedSquareActions.doMoveSquareUp(true)); + + selectedSquareModel.setSelectedMapSquare(mapSquareHead, null, 0); + selectedSquareModel.setSelectedGameObject(ob2Head, 1); + + // [ob2, ob1] => ob2 can move + Assert.assertTrue(selectedSquareActions.doMoveSquareUp(false)); + Assert.assertTrue(selectedSquareActions.doMoveSquareUp(true)); + TestMapControlCreator.checkContents(mapSquareHead, ob1Head, ob2Head); + TestMapControlCreator.checkContents(mapSquareTail, ob2Tail, ob1Tail); + + // [ob1, ob2] => ob2 cannot move + Assert.assertFalse(selectedSquareActions.doMoveSquareUp(false)); + Assert.assertFalse(selectedSquareActions.doMoveSquareUp(true)); + TestMapControlCreator.checkContents(mapSquareHead, ob1Head, ob2Head); + TestMapControlCreator.checkContents(mapSquareTail, ob2Tail, ob1Tail); + + selectedSquareModel.setSelectedMapSquare(mapSquareTail, null, 0); + selectedSquareModel.setSelectedGameObject(ob2Tail, 1); + + // [ob2, ob1] => ob2 can move // XXX: this probably should be changed: moving tail parts is not sensible + Assert.assertTrue(selectedSquareActions.doMoveSquareUp(false)); + Assert.assertTrue(selectedSquareActions.doMoveSquareUp(true)); + TestMapControlCreator.checkContents(mapSquareHead, ob1Head, ob2Head); + TestMapControlCreator.checkContents(mapSquareTail, ob1Tail, ob2Tail); + + // [ob1, ob2] => ob2 cannot move + Assert.assertFalse(selectedSquareActions.doMoveSquareUp(false)); + Assert.assertFalse(selectedSquareActions.doMoveSquareUp(true)); + TestMapControlCreator.checkContents(mapSquareHead, ob1Head, ob2Head); + TestMapControlCreator.checkContents(mapSquareTail, ob1Tail, ob2Tail); + } + + /** + * Checks that {@link SelectedSquareActions#doMoveSquareDown(boolean)} does + * work for single-square game objects. + * @throws DuplicateArchetypeException if the test fails + */ + @Test + public void testDoMoveSquareDownSingle() throws DuplicateArchetypeException { + final TestMapControlCreator testMapControlCreator = new TestMapControlCreator(); + final MapControl<TestGameObject, TestMapArchObject, TestArchetype> mapControl = testMapControlCreator.newMapControl(MAP_FILE1, MAP_NAME1, new Size2D(1, 1)); + final SelectedSquareModel<TestGameObject, TestMapArchObject, TestArchetype> selectedSquareModel = newSelectedSquareModel(mapControl, testMapControlCreator); + final SelectedSquareActions<TestGameObject, TestMapArchObject, TestArchetype> selectedSquareActions = new SelectedSquareActions<TestGameObject, TestMapArchObject, TestArchetype>(selectedSquareModel); + + final Point point = new Point(0, 0); + final MapModel<TestGameObject,TestMapArchObject,TestArchetype> mapModel = mapControl.getMapModel(); + mapModel.beginTransaction("TEST"); + final MapSquare<TestGameObject, TestMapArchObject, TestArchetype> mapSquare = mapModel.getMapSquare(point); + final TestGameObject ob1 = testMapControlCreator.insertExit(mapModel, point); + final TestGameObject ob2 = testMapControlCreator.insertFloor(mapModel, point); + + TestMapControlCreator.checkContents(mapSquare, ob1, ob2); + + // empty selection => nothing to move + Assert.assertFalse(selectedSquareActions.doMoveSquareDown(false)); + Assert.assertFalse(selectedSquareActions.doMoveSquareDown(true)); + + selectedSquareModel.setSelectedMapSquare(mapSquare, null, 0); + selectedSquareModel.setSelectedGameObject(ob2, 1); + + // [ob1, ob2] => ob2 can move + Assert.assertTrue(selectedSquareActions.doMoveSquareDown(false)); + Assert.assertTrue(selectedSquareActions.doMoveSquareDown(true)); + TestMapControlCreator.checkContents(mapSquare, ob2, ob1); + + // [ob2, ob1] => ob2 cannot move + Assert.assertFalse(selectedSquareActions.doMoveSquareDown(false)); + Assert.assertFalse(selectedSquareActions.doMoveSquareDown(true)); + TestMapControlCreator.checkContents(mapSquare, ob2, ob1); + } + + /** + * Checks that {@link SelectedSquareActions#doMoveSquareDown(boolean)} does + * work for multi-square game objects. + * @throws DuplicateArchetypeException if the test fails + */ + @Test + public void testDoMoveSquareDownMulti() throws DuplicateArchetypeException { + final TestMapControlCreator testMapControlCreator = new TestMapControlCreator(); + final MapControl<TestGameObject, TestMapArchObject, TestArchetype> mapControl = testMapControlCreator.newMapControl(MAP_FILE1, MAP_NAME1, new Size2D(2, 1)); + final SelectedSquareModel<TestGameObject, TestMapArchObject, TestArchetype> selectedSquareModel = newSelectedSquareModel(mapControl, testMapControlCreator); + final SelectedSquareActions<TestGameObject, TestMapArchObject, TestArchetype> selectedSquareActions = new SelectedSquareActions<TestGameObject, TestMapArchObject, TestArchetype>(selectedSquareModel); + + final Point pointHead = new Point(0, 0); + final Point pointTail = new Point(1, 0); + final MapModel<TestGameObject,TestMapArchObject,TestArchetype> mapModel = mapControl.getMapModel(); + mapModel.beginTransaction("TEST"); + final MapSquare<TestGameObject, TestMapArchObject, TestArchetype> mapSquareHead = mapModel.getMapSquare(pointHead); + final MapSquare<TestGameObject, TestMapArchObject, TestArchetype> mapSquareTail = mapModel.getMapSquare(pointTail); + final TestGameObject ob1Head = testMapControlCreator.insertMob21(mapModel, pointHead); + final TestGameObject ob1Tail = ob1Head.getMultiNext(); + final TestGameObject ob2Head = testMapControlCreator.insertFloor(mapModel, pointHead); + final TestGameObject ob2Tail = testMapControlCreator.insertFloor(mapModel, pointTail); + + TestMapControlCreator.checkContents(mapSquareHead, ob1Head, ob2Head); + TestMapControlCreator.checkContents(mapSquareTail, ob1Tail, ob2Tail); + + // empty selection => nothing to move + Assert.assertFalse(selectedSquareActions.doMoveSquareDown(false)); + Assert.assertFalse(selectedSquareActions.doMoveSquareDown(true)); + + selectedSquareModel.setSelectedMapSquare(mapSquareHead, null, 0); + selectedSquareModel.setSelectedGameObject(ob2Head, 1); + + // [ob2, ob1] => ob2 can move + Assert.assertTrue(selectedSquareActions.doMoveSquareDown(false)); + Assert.assertTrue(selectedSquareActions.doMoveSquareDown(true)); + TestMapControlCreator.checkContents(mapSquareHead, ob2Head, ob1Head); + TestMapControlCreator.checkContents(mapSquareTail, ob1Tail, ob2Tail); + + // [ob1, ob2] => ob2 cannot move + Assert.assertFalse(selectedSquareActions.doMoveSquareDown(false)); + Assert.assertFalse(selectedSquareActions.doMoveSquareDown(true)); + TestMapControlCreator.checkContents(mapSquareHead, ob2Head, ob1Head); + TestMapControlCreator.checkContents(mapSquareTail, ob1Tail, ob2Tail); + + selectedSquareModel.setSelectedMapSquare(mapSquareTail, null, 0); + selectedSquareModel.setSelectedGameObject(ob2Tail, 1); + + // [ob2, ob1] => ob2 can move // XXX: this probably should be changed: moving tail parts is not sensible + Assert.assertTrue(selectedSquareActions.doMoveSquareDown(false)); + Assert.assertTrue(selectedSquareActions.doMoveSquareDown(true)); + TestMapControlCreator.checkContents(mapSquareHead, ob2Head, ob1Head); + TestMapControlCreator.checkContents(mapSquareTail, ob2Tail, ob1Tail); + + // [ob1, ob2] => ob2 cannot move + Assert.assertFalse(selectedSquareActions.doMoveSquareDown(false)); + Assert.assertFalse(selectedSquareActions.doMoveSquareDown(true)); + TestMapControlCreator.checkContents(mapSquareHead, ob2Head, ob1Head); + TestMapControlCreator.checkContents(mapSquareTail, ob2Tail, ob1Tail); + } + + /** + * Checks that {@link SelectedSquareActions#doMoveSquareBottom(boolean)} does + * work for single-square game objects. + * @throws DuplicateArchetypeException if the test fails + */ + @Test + public void testDoMoveSquareBottomSingle() throws DuplicateArchetypeException { + final TestMapControlCreator testMapControlCreator = new TestMapControlCreator(); + final MapControl<TestGameObject, TestMapArchObject, TestArchetype> mapControl = testMapControlCreator.newMapControl(MAP_FILE1, MAP_NAME1, new Size2D(1, 1)); + final SelectedSquareModel<TestGameObject, TestMapArchObject, TestArchetype> selectedSquareModel = newSelectedSquareModel(mapControl, testMapControlCreator); + final SelectedSquareActions<TestGameObject, TestMapArchObject, TestArchetype> selectedSquareActions = new SelectedSquareActions<TestGameObject, TestMapArchObject, TestArchetype>(selectedSquareModel); + + final Point point = new Point(0, 0); + final MapModel<TestGameObject,TestMapArchObject,TestArchetype> mapModel = mapControl.getMapModel(); + mapModel.beginTransaction("TEST"); + final MapSquare<TestGameObject, TestMapArchObject, TestArchetype> mapSquare = mapModel.getMapSquare(point); + final TestGameObject ob1 = testMapControlCreator.insertExit(mapModel, point); + final TestGameObject ob2 = testMapControlCreator.insertFloor(mapModel, point); + + TestMapControlCreator.checkContents(mapSquare, ob1, ob2); + + // empty selection => nothing to move + Assert.assertFalse(selectedSquareActions.doMoveSquareBottom(false)); + Assert.assertFalse(selectedSquareActions.doMoveSquareBottom(true)); + + selectedSquareModel.setSelectedMapSquare(mapSquare, null, 0); + selectedSquareModel.setSelectedGameObject(ob2, 1); + + // [ob1, ob2] => ob2 can move + Assert.assertTrue(selectedSquareActions.doMoveSquareBottom(false)); + Assert.assertTrue(selectedSquareActions.doMoveSquareBottom(true)); + TestMapControlCreator.checkContents(mapSquare, ob2, ob1); + + // [ob2, ob1] => ob2 cannot move + Assert.assertFalse(selectedSquareActions.doMoveSquareBottom(false)); + Assert.assertFalse(selectedSquareActions.doMoveSquareBottom(true)); + TestMapControlCreator.checkContents(mapSquare, ob2, ob1); + } + + /** + * Checks that {@link SelectedSquareActions#doMoveSquareBottom(boolean)} does + * work for multi-square game objects. + * @throws DuplicateArchetypeException if the test fails + */ + @Test + public void testDoMoveSquareBottomMulti() throws DuplicateArchetypeException { + final TestMapControlCreator testMapControlCreator = new TestMapControlCreator(); + final MapControl<TestGameObject, TestMapArchObject, TestArchetype> mapControl = testMapControlCreator.newMapControl(MAP_FILE1, MAP_NAME1, new Size2D(2, 1)); + final SelectedSquareModel<TestGameObject, TestMapArchObject, TestArchetype> selectedSquareModel = newSelectedSquareModel(mapControl, testMapControlCreator); + final SelectedSquareActions<TestGameObject, TestMapArchObject, TestArchetype> selectedSquareActions = new SelectedSquareActions<TestGameObject, TestMapArchObject, TestArchetype>(selectedSquareModel); + + final Point pointHead = new Point(0, 0); + final Point pointTail = new Point(1, 0); + final MapModel<TestGameObject,TestMapArchObject,TestArchetype> mapModel = mapControl.getMapModel(); + mapModel.beginTransaction("TEST"); + final MapSquare<TestGameObject, TestMapArchObject, TestArchetype> mapSquareHead = mapModel.getMapSquare(pointHead); + final MapSquare<TestGameObject, TestMapArchObject, TestArchetype> mapSquareTail = mapModel.getMapSquare(pointTail); + final TestGameObject ob1Head = testMapControlCreator.insertMob21(mapModel, pointHead); + final TestGameObject ob1Tail = ob1Head.getMultiNext(); + final TestGameObject ob2Head = testMapControlCreator.insertFloor(mapModel, pointHead); + final TestGameObject ob2Tail = testMapControlCreator.insertFloor(mapModel, pointTail); + + TestMapControlCreator.checkContents(mapSquareHead, ob1Head, ob2Head); + TestMapControlCreator.checkContents(mapSquareTail, ob1Tail, ob2Tail); + + // empty selection => nothing to move + Assert.assertFalse(selectedSquareActions.doMoveSquareBottom(false)); + Assert.assertFalse(selectedSquareActions.doMoveSquareBottom(true)); + + selectedSquareModel.setSelectedMapSquare(mapSquareHead, null, 0); + selectedSquareModel.setSelectedGameObject(ob2Head, 1); + + // [ob2, ob1] => ob2 can move + Assert.assertTrue(selectedSquareActions.doMoveSquareBottom(false)); + Assert.assertTrue(selectedSquareActions.doMoveSquareBottom(true)); + TestMapControlCreator.checkContents(mapSquareHead, ob2Head, ob1Head); + TestMapControlCreator.checkContents(mapSquareTail, ob1Tail, ob2Tail); + + // [ob1, ob2] => ob2 cannot move + Assert.assertFalse(selectedSquareActions.doMoveSquareBottom(false)); + Assert.assertFalse(selectedSquareActions.doMoveSquareBottom(true)); + TestMapControlCreator.checkContents(mapSquareHead, ob2Head, ob1Head); + TestMapControlCreator.checkContents(mapSquareTail, ob1Tail, ob2Tail); + + selectedSquareModel.setSelectedMapSquare(mapSquareTail, null, 0); + selectedSquareModel.setSelectedGameObject(ob2Tail, 1); + + // [ob2, ob1] => ob2 can move // XXX: this probably should be changed: moving tail parts is not sensible + Assert.assertTrue(selectedSquareActions.doMoveSquareBottom(false)); + Assert.assertTrue(selectedSquareActions.doMoveSquareBottom(true)); + TestMapControlCreator.checkContents(mapSquareHead, ob2Head, ob1Head); + TestMapControlCreator.checkContents(mapSquareTail, ob2Tail, ob1Tail); + + // [ob1, ob2] => ob2 cannot move + Assert.assertFalse(selectedSquareActions.doMoveSquareBottom(false)); + Assert.assertFalse(selectedSquareActions.doMoveSquareBottom(true)); + TestMapControlCreator.checkContents(mapSquareHead, ob2Head, ob1Head); + TestMapControlCreator.checkContents(mapSquareTail, ob2Tail, ob1Tail); + } + + /** + * Checks that {@link SelectedSquareActions#doMoveSquareEnv(boolean)} does + * work for single-square game objects. + * @throws DuplicateArchetypeException if the test fails + */ + @Test + public void testDoMoveSquareEnvSingle1() throws DuplicateArchetypeException { + final TestMapControlCreator testMapControlCreator = new TestMapControlCreator(); + final MapControl<TestGameObject, TestMapArchObject, TestArchetype> mapControl = testMapControlCreator.newMapControl(MAP_FILE1, MAP_NAME1, new Size2D(1, 1)); + final SelectedSquareModel<TestGameObject, TestMapArchObject, TestArchetype> selectedSquareModel = newSelectedSquareModel(mapControl, testMapControlCreator); + final SelectedSquareActions<TestGameObject, TestMapArchObject, TestArchetype> selectedSquareActions = new SelectedSquareActions<TestGameObject, TestMapArchObject, TestArchetype>(selectedSquareModel); + + final Point point = new Point(0, 0); + final MapModel<TestGameObject,TestMapArchObject,TestArchetype> mapModel = mapControl.getMapModel(); + mapModel.beginTransaction("TEST"); + final MapSquare<TestGameObject, TestMapArchObject, TestArchetype> mapSquare = mapModel.getMapSquare(point); + final TestGameObject ob1 = testMapControlCreator.insertExit(mapModel, point); + + TestMapControlCreator.checkContents(mapSquare, ob1); + + // empty selection => nothing to move + Assert.assertFalse(selectedSquareActions.doMoveSquareEnv(false)); + Assert.assertFalse(selectedSquareActions.doMoveSquareEnv(true)); + + selectedSquareModel.setSelectedMapSquare(mapSquare, null, 0); + selectedSquareModel.setSelectedGameObject(ob1, 0); + + // [ob1] => ob1 cannot move + Assert.assertFalse(selectedSquareActions.doMoveSquareEnv(false)); + Assert.assertFalse(selectedSquareActions.doMoveSquareEnv(true)); + TestMapControlCreator.checkContents(mapSquare, ob1); + } + + /** + * Checks that {@link SelectedSquareActions#doMoveSquareEnv(boolean)} does + * work for single-square game objects. + * @throws DuplicateArchetypeException if the test fails + */ + @Test + public void testDoMoveSquareEnvSingle2() throws DuplicateArchetypeException { + final TestMapControlCreator testMapControlCreator = new TestMapControlCreator(); + final MapControl<TestGameObject, TestMapArchObject, TestArchetype> mapControl = testMapControlCreator.newMapControl(MAP_FILE1, MAP_NAME1, new Size2D(1, 1)); + final SelectedSquareModel<TestGameObject, TestMapArchObject, TestArchetype> selectedSquareModel = newSelectedSquareModel(mapControl, testMapControlCreator); + final SelectedSquareActions<TestGameObject, TestMapArchObject, TestArchetype> selectedSquareActions = new SelectedSquareActions<TestGameObject, TestMapArchObject, TestArchetype>(selectedSquareModel); + + final Point point = new Point(0, 0); + final MapModel<TestGameObject,TestMapArchObject,TestArchetype> mapModel = mapControl.getMapModel(); + mapModel.beginTransaction("TEST"); + final MapSquare<TestGameObject, TestMapArchObject, TestArchetype> mapSquare = mapModel.getMapSquare(point); + final TestGameObject ob1 = testMapControlCreator.insertExit(mapModel, point); + final TestGameObject ob2 = testMapControlCreator.insertExit(mapModel, point); + final TestGameObject ob3 = testMapControlCreator.insertExit(mapModel, point); + final TestGameObject ob4 = testMapControlCreator.insertExit(ob2); + + TestMapControlCreator.checkContents(mapSquare, ob1, ob2, ob3); + TestMapControlCreator.checkContents(ob2, ob4); + + // empty selection => nothing to move + Assert.assertFalse(selectedSquareActions.doMoveSquareEnv(false)); + Assert.assertFalse(selectedSquareActions.doMoveSquareEnv(true)); + + selectedSquareModel.setSelectedMapSquare(mapSquare, null, 0); + selectedSquareModel.setSelectedGameObject(ob4, 0); + + // ob4 can move + Assert.assertTrue(selectedSquareActions.doMoveSquareEnv(false)); + Assert.assertTrue(selectedSquareActions.doMoveSquareEnv(true)); + TestMapControlCreator.checkContents(mapSquare, ob1, ob4, ob2, ob3); + Assert.assertEquals(mapSquare, selectedSquareModel.getCurrentMapSquare()); + Assert.assertEquals(ob4, selectedSquareModel.getSelectedGameObject()); + + // ob4 cannot move + Assert.assertFalse(selectedSquareActions.doMoveSquareEnv(false)); + Assert.assertFalse(selectedSquareActions.doMoveSquareEnv(true)); + TestMapControlCreator.checkContents(mapSquare, ob1, ob4, ob2, ob3); + Assert.assertEquals(mapSquare, selectedSquareModel.getCurrentMapSquare()); + Assert.assertEquals(ob4, selectedSquareModel.getSelectedGameObject()); + } + + /** + * Checks that {@link SelectedSquareActions#doMoveSquareEnv(boolean)} does + * work for single-square game objects. + * @throws DuplicateArchetypeException if the test fails + */ + @Test + public void testDoMoveSquareEnvSingle3() throws DuplicateArchetypeException { + final TestMapControlCreator testMapControlCreator = new TestMapControlCreator(); + final MapControl<TestGameObject, TestMapArchObject, TestArchetype> mapControl = testMapControlCreator.newMapControl(MAP_FILE1, MAP_NAME1, new Size2D(1, 1)); + final SelectedSquareModel<TestGameObject, TestMapArchObject, TestArchetype> selectedSquareModel = newSelectedSquareModel(mapControl, testMapControlCreator); + final SelectedSquareActions<TestGameObject, TestMapArchObject, TestArchetype> selectedSquareActions = new SelectedSquareActions<TestGameObject, TestMapArchObject, TestArchetype>(selectedSquareModel); + + final Point point = new Point(0, 0); + final MapModel<TestGameObject,TestMapArchObject,TestArchetype> mapModel = mapControl.getMapModel(); + mapModel.beginTransaction("TEST"); + final MapSquare<TestGameObject, TestMapArchObject, TestArchetype> mapSquare = mapModel.getMapSquare(point); + final TestGameObject ob1 = testMapControlCreator.insertExit(mapModel, point); + final TestGameObject ob2 = testMapControlCreator.insertExit(ob1); + final TestGameObject ob3 = testMapControlCreator.insertExit(ob2); + final TestGameObject ob4 = testMapControlCreator.insertExit(ob2); + final TestGameObject ob5 = testMapControlCreator.insertExit(ob2); + + TestMapControlCreator.checkContents(mapSquare, ob1); + TestMapControlCreator.checkContents(ob1, ob2); + TestMapControlCreator.checkContents(ob2, ob3, ob4, ob5); + + // empty selection => nothing to move + Assert.assertFalse(selectedSquareActions.doMoveSquareEnv(false)); + Assert.assertFalse(selectedSquareActions.doMoveSquareEnv(true)); + + selectedSquareModel.setSelectedMapSquare(mapSquare, null, 0); + selectedSquareModel.setSelectedGameObject(ob4, 0); + + // ob4 can move + Assert.assertTrue(selectedSquareActions.doMoveSquareEnv(false)); + Assert.assertTrue(selectedSquareActions.doMoveSquareEnv(true)); + TestMapControlCreator.checkContents(mapSquare, ob1); + TestMapControlCreator.checkContents(ob1, ob4, ob2); + TestMapControlCreator.checkContents(ob2, ob3, ob5); + Assert.assertEquals(mapSquare, selectedSquareModel.getCurrentMapSquare()); + Assert.assertEquals(ob4, selectedSquareModel.getSelectedGameObject()); + + // ob4 can move + Assert.assertTrue(selectedSquareActions.doMoveSquareEnv(false)); + Assert.assertTrue(selectedSquareActions.doMoveSquareEnv(true)); + TestMapControlCreator.checkContents(mapSquare, ob4, ob1); + TestMapControlCreator.checkContents(ob1, ob2); + TestMapControlCreator.checkContents(ob2, ob3, ob5); + Assert.assertEquals(mapSquare, selectedSquareModel.getCurrentMapSquare()); + Assert.assertEquals(ob4, selectedSquareModel.getSelectedGameObject()); + + // ob4 cannot move + Assert.assertFalse(selectedSquareActions.doMoveSquareEnv(false)); + Assert.assertFalse(selectedSquareActions.doMoveSquareEnv(true)); + TestMapControlCreator.checkContents(mapSquare, ob4, ob1); + TestMapControlCreator.checkContents(ob1, ob2); + TestMapControlCreator.checkContents(ob2, ob3, ob5); + Assert.assertEquals(mapSquare, selectedSquareModel.getCurrentMapSquare()); + Assert.assertEquals(ob4, selectedSquareModel.getSelectedGameObject()); + } + + /** + * Checks that {@link SelectedSquareActions#doMoveSquareEnv(boolean)} does + * work for multi-square game objects. + * @throws DuplicateArchetypeException if the test fails + */ + @Test + public void testDoMoveSquareEnvMulti3() throws DuplicateArchetypeException { + final TestMapControlCreator testMapControlCreator = new TestMapControlCreator(); + final MapControl<TestGameObject, TestMapArchObject, TestArchetype> mapControl = testMapControlCreator.newMapControl(MAP_FILE1, MAP_NAME1, new Size2D(2, 1)); + final SelectedSquareModel<TestGameObject, TestMapArchObject, TestArchetype> selectedSquareModel = newSelectedSquareModel(mapControl, testMapControlCreator); + final SelectedSquareActions<TestGameObject, TestMapArchObject, TestArchetype> selectedSquareActions = new SelectedSquareActions<TestGameObject, TestMapArchObject, TestArchetype>(selectedSquareModel); + + final Point point = new Point(0, 0); + final MapModel<TestGameObject,TestMapArchObject,TestArchetype> mapModel = mapControl.getMapModel(); + mapModel.beginTransaction("TEST"); + final MapSquare<TestGameObject, TestMapArchObject, TestArchetype> mapSquareHead = mapModel.getMapSquare(point); + final MapSquare<TestGameObject, TestMapArchObject, TestArchetype> mapSquareTail = mapModel.getMapSquare(new Point(1, 0)); + final TestGameObject ob1 = testMapControlCreator.insertExit(mapModel, point); + final TestGameObject ob2 = testMapControlCreator.insertExit(ob1); + final TestGameObject ob3 = testMapControlCreator.insertExit(ob2); + final TestGameObject ob4Head = testMapControlCreator.insertMob21(ob2); + final TestGameObject ob5 = testMapControlCreator.insertExit(ob2); + + TestMapControlCreator.checkContents(mapSquareHead, ob1); + TestMapControlCreator.checkContents(ob1, ob2); + TestMapControlCreator.checkContents(ob2, ob3, ob4Head, ob5); + TestMapControlCreator.checkContents(mapSquareTail); + + // empty selection => nothing to move + Assert.assertFalse(selectedSquareActions.doMoveSquareEnv(false)); + Assert.assertFalse(selectedSquareActions.doMoveSquareEnv(true)); + + selectedSquareModel.setSelectedMapSquare(mapSquareHead, null, 0); + selectedSquareModel.setSelectedGameObject(ob4Head, 0); + + // ob4Head can move + Assert.assertTrue(selectedSquareActions.doMoveSquareEnv(false)); + Assert.assertTrue(selectedSquareActions.doMoveSquareEnv(true)); + TestMapControlCreator.checkContents(mapSquareHead, ob1); + TestMapControlCreator.checkContents(ob1, ob4Head, ob2); + final TestGameObject ob4Tail1 = ob4Head.getMultiNext(); + Assert.assertNull(ob4Tail1); + TestMapControlCreator.checkContents(ob2, ob3, ob5); + TestMapControlCreator.checkContents(mapSquareTail); + Assert.assertEquals(mapSquareHead, selectedSquareModel.getCurrentMapSquare()); + Assert.assertEquals(ob4Head, selectedSquareModel.getSelectedGameObject()); + + // ob4Head can move + Assert.assertTrue(selectedSquareActions.doMoveSquareEnv(false)); + Assert.assertTrue(selectedSquareActions.doMoveSquareEnv(true)); + TestMapControlCreator.checkContents(mapSquareHead, ob4Head, ob1); + TestMapControlCreator.checkContents(ob1, ob2); + TestMapControlCreator.checkContents(ob2, ob3, ob5); + final TestGameObject ob4Tail2 = ob4Head.getMultiNext(); + Assert.assertNotNull(ob4Tail2); + TestMapControlCreator.checkContents(mapSquareTail, ob4Tail2); + Assert.assertEquals(mapSquareHead, selectedSquareModel.getCurrentMapSquare()); + Assert.assertEquals(ob4Head, selectedSquareModel.getSelectedGameObject()); + + // ob4Head cannot move + Assert.assertFalse(selectedSquareActions.doMoveSquareEnv(false)); + Assert.assertFalse(selectedSquareActions.doMoveSquareEnv(true)); + TestMapControlCreator.checkContents(mapSquareHead, ob4Head, ob1); + TestMapControlCreator.checkContents(ob1, ob2); + TestMapControlCreator.checkContents(ob2, ob3, ob5); + Assert.assertEquals(ob4Tail2, ob4Head.getMultiNext()); + TestMapControlCreator.checkContents(mapSquareTail, ob4Tail2); + Assert.assertEquals(mapSquareHead, selectedSquareModel.getCurrentMapSquare()); + Assert.assertEquals(ob4Head, selectedSquareModel.getSelectedGameObject()); + } + + /** + * Checks that {@link SelectedSquareActions#doMoveSquareEnv(boolean)} does + * work for multi-square game objects. + * @throws DuplicateArchetypeException if the test fails + */ + @Test + public void testDoMoveSquareEnvMulti4() throws DuplicateArchetypeException { + final TestMapControlCreator testMapControlCreator = new TestMapControlCreator(); + final MapControl<TestGameObject, TestMapArchObject, TestArchetype> mapControl = testMapControlCreator.newMapControl(MAP_FILE1, MAP_NAME1, new Size2D(1, 1)); + final SelectedSquareModel<TestGameObject, TestMapArchObject, TestArchetype> selectedSquareModel = newSelectedSquareModel(mapControl, testMapControlCreator); + final SelectedSquareActions<TestGameObject, TestMapArchObject, TestArchetype> selectedSquareActions = new SelectedSquareActions<TestGameObject, TestMapArchObject, TestArchetype>(selectedSquareModel); + + final Point point = new Point(0, 0); + final MapModel<TestGameObject,TestMapArchObject,TestArchetype> mapModel = mapControl.getMapModel(); + mapModel.beginTransaction("TEST"); + final MapSquare<TestGameObject, TestMapArchObject, TestArchetype> mapSquareHead = mapModel.getMapSquare(point); + final TestGameObject ob1 = testMapControlCreator.insertExit(mapModel, point); + final TestGameObject ob2Head = testMapControlCreator.insertMob21(ob1); + + TestMapControlCreator.checkContents(mapSquareHead, ob1); + TestMapControlCreator.checkContents(ob1, ob2Head); + + selectedSquareModel.setSelectedMapSquare(mapSquareHead, null, 0); + selectedSquareModel.setSelectedGameObject(ob2Head, 0); + + // ob2Head cannot move: would not fit into map + Assert.assertFalse(selectedSquareActions.doMoveSquareEnv(false)); + Assert.assertFalse(selectedSquareActions.doMoveSquareEnv(true)); + TestMapControlCreator.checkContents(mapSquareHead, ob1); + TestMapControlCreator.checkContents(ob1, ob2Head); + Assert.assertNull(ob2Head.getMultiNext()); + } + + /** + * Checks that {@link SelectedSquareActions#doMoveSquareInv(boolean)} does + * work for single-square game objects. + * @throws DuplicateArchetypeException if the test fails + */ + @Test + public void testDoMoveSquareInvSingle1() throws DuplicateArchetypeException { + final TestMapControlCreator testMapControlCreator = new TestMapControlCreator(); + final MapControl<TestGameObject, TestMapArchObject, TestArchetype> mapControl = testMapControlCreator.newMapControl(MAP_FILE1, MAP_NAME1, new Size2D(1, 1)); + final SelectedSquareModel<TestGameObject, TestMapArchObject, TestArchetype> selectedSquareModel = newSelectedSquareModel(mapControl, testMapControlCreator); + final SelectedSquareActions<TestGameObject, TestMapArchObject, TestArchetype> selectedSquareActions = new SelectedSquareActions<TestGameObject, TestMapArchObject, TestArchetype>(selectedSquareModel); + + final Point point = new Point(0, 0); + final MapModel<TestGameObject,TestMapArchObject,TestArchetype> mapModel = mapControl.getMapModel(); + mapModel.beginTransaction("TEST"); + final MapSquare<TestGameObject, TestMapArchObject, TestArchetype> mapSquare = mapModel.getMapSquare(point); + final TestGameObject ob4 = testMapControlCreator.insertExit(mapModel, point); + final TestGameObject ob3 = testMapControlCreator.insertExit(mapModel, point); + final TestGameObject ob2 = testMapControlCreator.insertExit(mapModel, point); + final TestGameObject ob1 = testMapControlCreator.insertExit(mapModel, point); + + TestMapControlCreator.checkContents(mapSquare, ob4, ob3, ob2, ob1); + + // empty selection => nothing to move + Assert.assertFalse(selectedSquareActions.doMoveSquareInv(false)); + Assert.assertFalse(selectedSquareActions.doMoveSquareInv(true)); + + // select ob3 + selectedSquareModel.setSelectedMapSquare(mapSquare, null, 0); + selectedSquareModel.setSelectedGameObject(ob3, 0); + + // ob3 can move + Assert.assertTrue(selectedSquareActions.doMoveSquareInv(false)); + Assert.assertTrue(selectedSquareActions.doMoveSquareInv(true)); + TestMapControlCreator.checkContents(mapSquare, ob4, ob2, ob1); + TestMapControlCreator.checkContents(ob2, ob3); + Assert.assertEquals(mapSquare, selectedSquareModel.getCurrentMapSquare()); + Assert.assertEquals(ob3, selectedSquareModel.getSelectedGameObject()); + + // ob3 cannot move + Assert.assertFalse(selectedSquareActions.doMoveSquareInv(false)); + Assert.assertFalse(selectedSquareActions.doMoveSquareInv(true)); + TestMapControlCreator.checkContents(mapSquare, ob4, ob2, ob1); + TestMapControlCreator.checkContents(ob2, ob3); + Assert.assertEquals(mapSquare, selectedSquareModel.getCurrentMapSquare()); + Assert.assertEquals(ob3, selectedSquareModel.getSelectedGameObject()); + + // select ob2 + selectedSquareModel.setSelectedGameObject(ob2, 0); + + // ob2 can move + Assert.assertTrue(selectedSquareActions.doMoveSquareInv(false)); + Assert.assertTrue(selectedSquareActions.doMoveSquareInv(true)); + TestMapControlCreator.checkContents(mapSquare, ob4, ob1); + TestMapControlCreator.checkContents(ob1, ob2); + TestMapControlCreator.checkContents(ob2, ob3); + Assert.assertEquals(mapSquare, selectedSquareModel.getCurrentMapSquare()); + Assert.assertEquals(ob2, selectedSquareModel.getSelectedGameObject()); + + // ob2 cannot move + Assert.assertFalse(selectedSquareActions.doMoveSquareInv(false)); + Assert.assertFalse(selectedSquareActions.doMoveSquareInv(true)); + TestMapControlCreator.checkContents(mapSquare, ob4, ob1); + TestMapControlCreator.checkContents(ob1, ob2); + TestMapControlCreator.checkContents(ob2, ob3); + Assert.assertEquals(mapSquare, selectedSquareModel.getCurrentMapSquare()); + Assert.assertEquals(ob2, selectedSquareModel.getSelectedGameObject()); + + // select ob4 + selectedSquareModel.setSelectedGameObject(ob4, 0); + + // ob4 can move + Assert.assertTrue(selectedSquareActions.doMoveSquareInv(false)); + Assert.assertTrue(selectedSquareActions.doMoveSquareInv(true)); + TestMapControlCreator.checkContents(mapSquare, ob1); + TestMapControlCreator.checkContents(ob1, ob4, ob2); + TestMapControlCreator.checkContents(ob2, ob3); + Assert.assertEquals(mapSquare, selectedSquareModel.getCurrentMapSquare()); + Assert.assertEquals(ob4, selectedSquareModel.getSelectedGameObject()); + + // ob4 can move + Assert.assertTrue(selectedSquareActions.doMoveSquareInv(false)); + Assert.assertTrue(selectedSquareActions.doMoveSquareInv(true)); + TestMapControlCreator.checkContents(mapSquare, ob1); + TestMapControlCreator.checkContents(ob1, ob2); + TestMapControlCreator.checkContents(ob2, ob4, ob3); + Assert.assertEquals(mapSquare, selectedSquareModel.getCurrentMapSquare()); + Assert.assertEquals(ob4, selectedSquareModel.getSelectedGameObject()); + + // ob4 can move + Assert.assertTrue(selectedSquareActions.doMoveSquareInv(false)); + Assert.assertTrue(selectedSquareActions.doMoveSquareInv(true)); + TestMapControlCreator.checkContents(mapSquare, ob1); + TestMapControlCreator.checkCont... [truncated message content] |
From: <aki...@us...> - 2010-06-03 12:37:27
|
Revision: 8067 http://gridarta.svn.sourceforge.net/gridarta/?rev=8067&view=rev Author: akirschbaum Date: 2010-06-03 12:37:19 +0000 (Thu, 03 Jun 2010) Log Message: ----------- Prevent Paste/Undo/Redo from breaking the map when applied to game objects having inventories. Modified Paths: -------------- trunk/atrinik/ChangeLog trunk/crossfire/ChangeLog trunk/daimonin/ChangeLog trunk/src/app/net/sf/gridarta/model/baseobject/GameObjectContainer.java trunk/src/test/net/sf/gridarta/gui/map/test/TestMapControlCreator.java Added Paths: ----------- trunk/src/test/net/sf/gridarta/gui/copybuffer/ trunk/src/test/net/sf/gridarta/gui/copybuffer/CopyBufferTest.java trunk/src/test/net/sf/gridarta/model/gameobject/GameObjectFactoryTest.java trunk/src/test/net/sf/gridarta/model/map/maparchobject/TestMapArchObjectFactory.java Modified: trunk/atrinik/ChangeLog =================================================================== --- trunk/atrinik/ChangeLog 2010-06-03 12:30:17 UTC (rev 8066) +++ trunk/atrinik/ChangeLog 2010-06-03 12:37:19 UTC (rev 8067) @@ -1,5 +1,8 @@ 2010-06-03 Andreas Kirschbaum + * Prevent Paste/Undo/Redo from breaking the map when applied to + game objects having inventories. + * Fix "Move Env" and "Move Inv" actions in selected square view when applied to multi-part game objects. Modified: trunk/crossfire/ChangeLog =================================================================== --- trunk/crossfire/ChangeLog 2010-06-03 12:30:17 UTC (rev 8066) +++ trunk/crossfire/ChangeLog 2010-06-03 12:37:19 UTC (rev 8067) @@ -1,5 +1,8 @@ 2010-06-03 Andreas Kirschbaum + * Prevent Paste/Undo/Redo from breaking the map when applied to + game objects having inventories. + * Fix "Move Env" and "Move Inv" actions in selected square view when applied to multi-part game objects. Modified: trunk/daimonin/ChangeLog =================================================================== --- trunk/daimonin/ChangeLog 2010-06-03 12:30:17 UTC (rev 8066) +++ trunk/daimonin/ChangeLog 2010-06-03 12:37:19 UTC (rev 8067) @@ -1,5 +1,8 @@ 2010-06-03 Andreas Kirschbaum + * Prevent Paste/Undo/Redo from breaking the map when applied to + game objects having inventories. + * Fix "Move Env" and "Move Inv" actions in selected square view when applied to multi-part game objects. Modified: trunk/src/app/net/sf/gridarta/model/baseobject/GameObjectContainer.java =================================================================== --- trunk/src/app/net/sf/gridarta/model/baseobject/GameObjectContainer.java 2010-06-03 12:30:17 UTC (rev 8066) +++ trunk/src/app/net/sf/gridarta/model/baseobject/GameObjectContainer.java 2010-06-03 12:37:19 UTC (rev 8067) @@ -600,7 +600,7 @@ for (final BaseObject<G, A, R, G> gameObject : contents) { final G clonedGameObject = gameObject.clone(); clone.contents.add(clonedGameObject); - setThisContainer(clonedGameObject); + clone.setThisContainer(clonedGameObject); } return clone; } catch (final CloneNotSupportedException e) { Added: trunk/src/test/net/sf/gridarta/gui/copybuffer/CopyBufferTest.java =================================================================== --- trunk/src/test/net/sf/gridarta/gui/copybuffer/CopyBufferTest.java (rev 0) +++ trunk/src/test/net/sf/gridarta/gui/copybuffer/CopyBufferTest.java 2010-06-03 12:37:19 UTC (rev 8067) @@ -0,0 +1,95 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2010 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.copybuffer; + +import java.awt.Point; +import java.awt.Rectangle; +import java.io.File; +import net.sf.gridarta.gui.map.mapview.MapView; +import net.sf.gridarta.gui.map.test.TestMapControlCreator; +import net.sf.gridarta.model.archetype.DuplicateArchetypeException; +import net.sf.gridarta.model.archetype.TestArchetype; +import net.sf.gridarta.model.gameobject.TestGameObject; +import net.sf.gridarta.model.map.grid.SelectionMode; +import net.sf.gridarta.model.map.maparchobject.TestMapArchObject; +import net.sf.gridarta.model.map.mapcontrol.MapControl; +import net.sf.gridarta.model.map.mapmodel.MapModel; +import net.sf.gridarta.utils.Size2D; +import org.junit.Test; + +/** + * Regression tests for {@link CopyBuffer}. + * @author Andreas Kirschbaum + */ +public class CopyBufferTest { + + /** + * The first map file. + */ + private static final File MAP_FILE1 = new File("a"); + + /** + * The first map name. + */ + private static final String MAP_NAME1 = "name1"; + + /** + * Checks that {@link CopyBuffer#cut(MapView, Rectangle)} followed by {@link + * CopyBuffer#paste(MapView, Point)} does work. + * @throws DuplicateArchetypeException if the test fails + */ + @Test + public void testCutPaste1() throws DuplicateArchetypeException { + final TestMapControlCreator testMapControlCreator = new TestMapControlCreator(); + final MapControl<TestGameObject, TestMapArchObject, TestArchetype> mapControl = testMapControlCreator.newMapControl(MAP_FILE1, MAP_NAME1, new Size2D(3, 3)); + + final Point point = new Point(1, 1); + final MapModel<TestGameObject,TestMapArchObject,TestArchetype> mapModel = mapControl.getMapModel(); + mapModel.beginTransaction("TEST"); + final TestGameObject ob1 = testMapControlCreator.insertFloor(mapModel, point); + final TestGameObject ob2 = testMapControlCreator.insertMob21(ob1); + + TestMapControlCreator.checkMapContents(mapModel, + "||", + "|floor|", + "||"); + TestMapControlCreator.checkContents(ob1, ob2); + + // select + cut + final CopyBuffer<TestGameObject, TestMapArchObject, TestArchetype> copyBuffer = testMapControlCreator.newCopyBuffer(); + final MapView<TestGameObject, TestMapArchObject, TestArchetype> mapView = testMapControlCreator.newMapView(mapControl); + mapView.getMapViewBasic().getMapGrid().select(new Point(1, 1), new Point(1, 1), SelectionMode.ADD); + copyBuffer.cut(mapView, new Rectangle(1, 1, 1, 1)); + + TestMapControlCreator.checkMapContents(mapModel, + "||", + "||", + "||"); + + // paste + copyBuffer.paste(mapView, new Point(1, 1)); + + TestMapControlCreator.checkMapContents(mapModel, + "||", + "|floor|", + "||"); + } + +} // class CopyBufferTest Property changes on: trunk/src/test/net/sf/gridarta/gui/copybuffer/CopyBufferTest.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF Modified: trunk/src/test/net/sf/gridarta/gui/map/test/TestMapControlCreator.java =================================================================== --- trunk/src/test/net/sf/gridarta/gui/map/test/TestMapControlCreator.java 2010-06-03 12:30:17 UTC (rev 8066) +++ trunk/src/test/net/sf/gridarta/gui/map/test/TestMapControlCreator.java 2010-06-03 12:37:19 UTC (rev 8067) @@ -22,6 +22,7 @@ import java.awt.Point; import java.io.File; import java.util.regex.Pattern; +import net.sf.gridarta.gui.copybuffer.CopyBuffer; import net.sf.gridarta.gui.map.mapview.MapView; import net.sf.gridarta.gui.map.mapview.MapViewBasic; import net.sf.gridarta.gui.map.renderer.RendererFactory; @@ -47,6 +48,7 @@ import net.sf.gridarta.model.face.DefaultFaceObjects; import net.sf.gridarta.model.face.FaceObjectProviders; import net.sf.gridarta.model.face.FaceObjects; +import net.sf.gridarta.model.gameobject.GameObject; import net.sf.gridarta.model.gameobject.GameObjectFactory; import net.sf.gridarta.model.gameobject.TestGameObject; import net.sf.gridarta.model.gameobject.TestGameObjectFactory; @@ -55,7 +57,9 @@ import net.sf.gridarta.model.io.PathManager; import net.sf.gridarta.model.io.TestMapReaderFactory; import net.sf.gridarta.model.io.TestMapWriter; +import net.sf.gridarta.model.map.maparchobject.MapArchObjectFactory; import net.sf.gridarta.model.map.maparchobject.TestMapArchObject; +import net.sf.gridarta.model.map.maparchobject.TestMapArchObjectFactory; import net.sf.gridarta.model.map.mapcontrol.MapControl; import net.sf.gridarta.model.map.mapcontrol.MapControlFactory; import net.sf.gridarta.model.map.mapcontrol.TestMapControlFactory; @@ -99,6 +103,12 @@ private static final int MOB_TYPE = 3; /** + * An empty array of strings. + */ + @NotNull + private static final String[] EMPTY_STRING_ARRAY = new String[0]; + + /** * The {@link SystemIcons} instance. */ @NotNull @@ -159,6 +169,23 @@ private final GlobalSettings globalSettings; /** + * The {@link MapViewSettings} instance. + */ + @NotNull + private final MapViewSettings mapViewSettings; + + /** + * The {@link MapArchObjectFactory} instance. + */ + @NotNull + private final MapArchObjectFactory<TestMapArchObject> mapArchObjectFactory = new TestMapArchObjectFactory(); + /** + * The {@link MapControlFactory} instance. + */ + @NotNull + private final MapControlFactory<TestGameObject, TestMapArchObject, TestArchetype> mapControlFactory; + + /** * The "topmost" {@link InsertionMode} instance. */ @NotNull @@ -184,7 +211,7 @@ archetypeSet = new TestArchetypeSet(archetypeFactory, "archetypes"); final MapReaderFactory<TestGameObject, TestMapArchObject> mapReaderFactory = new TestMapReaderFactory(); globalSettings = new TestGlobalSettings(); - final MapViewSettings mapViewSettings = new MapViewSettings(); + mapViewSettings = new MapViewSettings(); final MapWriter<TestGameObject, TestMapArchObject, TestArchetype> mapWriter = new TestMapWriter(); final FaceObjectProviders faceObjectProviders = newFaceObjectProviders(); final AutojoinLists<TestGameObject, TestMapArchObject, TestArchetype> autojoinLists = new AutojoinLists<TestGameObject, TestMapArchObject, TestArchetype>(mapViewSettings); @@ -195,7 +222,7 @@ topmostInsertionMode = new TopmostInsertionMode<TestGameObject, TestMapArchObject, TestArchetype>(); insertionModeSet = new InsertionModeSet<TestGameObject, TestMapArchObject, TestArchetype>(topmostInsertionMode); insertionModeSet.init(new TypeNrsGameObjectMatcher(), new TypeNrsGameObjectMatcher(), new TypeNrsGameObjectMatcher()); - final MapControlFactory<TestGameObject, TestMapArchObject, TestArchetype> mapControlFactory = new TestMapControlFactory(mapWriter, autojoinLists, archetypeChooserModel, gameObjectFactory, globalSettings, gameObjectMatchers, topmostInsertionMode); + mapControlFactory = new TestMapControlFactory(mapWriter, autojoinLists, archetypeChooserModel, gameObjectFactory, globalSettings, gameObjectMatchers, topmostInsertionMode); final AbstractMapManager<TestGameObject, TestMapArchObject, TestArchetype> tmpMapManager = new DefaultMapManager<TestGameObject, TestMapArchObject, TestArchetype>(mapReaderFactory, mapControlFactory, globalSettings); tmpMapManager.setFileControl(new TestFileControl()); mapManager = tmpMapManager; @@ -225,7 +252,7 @@ * @return the map control */ public MapControl<TestGameObject, TestMapArchObject, TestArchetype> newMapControl(@Nullable final File mapFile, @NotNull final String mapName, @NotNull final Size2D mapSize) { - final TestMapArchObject mapArchObject = new TestMapArchObject(); + final TestMapArchObject mapArchObject = mapArchObjectFactory.newMapArchObject(false); mapArchObject.setMapSize(mapSize); mapArchObject.setMapName(mapName); final MapControl<TestGameObject, TestMapArchObject, TestArchetype> mapControl = mapManager.newMap(null, mapArchObject, mapFile, true); @@ -398,9 +425,42 @@ if (i < gameObjects.length) { Assert.fail("map square is missing game object '" + gameObjects[i].getBestName() + "'"); } + + final boolean inContainer = mapSquare instanceof GameObject; + for (final TestGameObject gameObject : mapSquare) { + Assert.assertEquals(inContainer, gameObject.isInContainer()); + if (inContainer) { + // game objects within inventories must not contain tail parts + Assert.assertFalse(gameObject.isMulti()); + } else { + // game objects on the map must have expanded tail parts + Assert.assertEquals(gameObject.getArchetype().isMulti(), gameObject.isMulti()); + } + } } /** + * Checks that a {@link MapSquare} contains the given game objects. + * @param mapSquare the map square + * @param gameObjects the game object + */ + public static void checkContentsString(@NotNull final MapSquare<TestGameObject, TestMapArchObject, TestArchetype> mapSquare, @NotNull final String... gameObjects) { + int i = 0; + for (final TestGameObject gameObject : mapSquare) { + final String gameObjectName = gameObject.getBestName(); + if (i >= gameObjects.length) { + Assert.fail("map square " + mapSquare.getMapX() + "/" + mapSquare.getMapY() + " contains excess game object '" + gameObjectName + "'"); + } else if (!gameObjectName.equals(gameObjects[i])) { + Assert.fail("map square " + mapSquare.getMapX() + "/" + mapSquare.getMapY() + " contains wrong game object '" + gameObjectName + "' at index " + i + ", expected '" + gameObjects[i] + "'"); + } + i++; + } + if (i < gameObjects.length) { + Assert.fail("map square " + mapSquare.getMapX() + "/" + mapSquare.getMapY() + " is missing game object '" + gameObjects[i] + "'"); + } + } + + /** * Creates a new {@link MapView} instance. * @param mapControl the associated map control * @return the map view instance @@ -413,4 +473,48 @@ return mapView; } + /** + * Returns a new {@link CopyBuffer} instance. + * @return the copy buffer instance + */ + @NotNull + public CopyBuffer<TestGameObject, TestMapArchObject, TestArchetype> newCopyBuffer() { + return new CopyBuffer<TestGameObject, TestMapArchObject, TestArchetype>(mapViewSettings, gameObjectFactory, mapArchObjectFactory, mapControlFactory, insertionModeSet); + } + + /** + * Checks for expected {@link MapModel}'s contents. + * @param mapModel the map model + * @param lines the expected contents + */ + public static void checkMapContents(@NotNull final MapModel<TestGameObject, TestMapArchObject, TestArchetype> mapModel, @NotNull final String... lines) { + final Size2D mapSize = mapModel.getMapArchObject().getMapSize(); + Assert.assertEquals(lines.length, mapSize.getHeight()); + final Pattern pattern1 = Pattern.compile("\\|"); + final Pattern pattern2 = Pattern.compile(","); + final Point pos = new Point(); + for (int y = 0; y < lines.length; y++) { + final String line = lines[y]; + final String[] square = pattern1.split(line, -1); + Assert.assertEquals(square.length, mapSize.getWidth()); + + for (int x = 0; x < square.length; x++) { + final String square2 = square[x]; + final String[] gameObjects = square2.isEmpty() ? EMPTY_STRING_ARRAY : pattern2.split(square2, -1); + pos.x = x; + pos.y = y; + checkContentsString(mapModel.getMapSquare(pos), gameObjects); + } + } + } + + /** + * Returns the {@link GameObjectFactory} instance. + * @return the game object factory + */ + @NotNull + public GameObjectFactory<TestGameObject, TestMapArchObject, TestArchetype> getGameObjectFactory() { + return gameObjectFactory; + } + } // class TestMapControlCreator Added: trunk/src/test/net/sf/gridarta/model/gameobject/GameObjectFactoryTest.java =================================================================== --- trunk/src/test/net/sf/gridarta/model/gameobject/GameObjectFactoryTest.java (rev 0) +++ trunk/src/test/net/sf/gridarta/model/gameobject/GameObjectFactoryTest.java 2010-06-03 12:37:19 UTC (rev 8067) @@ -0,0 +1,69 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2010 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.model.gameobject; + +import java.awt.Point; +import java.io.File; +import net.sf.gridarta.gui.map.test.TestMapControlCreator; +import net.sf.gridarta.gui.selectedsquare.SelectedSquareActions; +import net.sf.gridarta.model.archetype.DuplicateArchetypeException; +import net.sf.gridarta.model.archetype.TestArchetype; +import net.sf.gridarta.model.map.maparchobject.TestMapArchObject; +import net.sf.gridarta.model.map.mapcontrol.MapControl; +import net.sf.gridarta.model.map.mapmodel.MapModel; +import net.sf.gridarta.utils.Size2D; +import org.junit.Assert; +import org.junit.Test; + +/** + * Regression tests for {@link GameObjectFactory}. + * @author Andreas Kirschbaum + */ +public class GameObjectFactoryTest { + + /** + * Checks that {@link SelectedSquareActions#doMoveSquareTop(boolean)} does + * work for single-square game objects. + * @throws DuplicateArchetypeException if the test fails + */ + @Test + public void testDoMoveSquareTopSingle() throws DuplicateArchetypeException { + final TestMapControlCreator testMapControlCreator = new TestMapControlCreator(); + final MapControl<TestGameObject, TestMapArchObject, TestArchetype> mapControl = testMapControlCreator.newMapControl(new File("file"), "name", new Size2D(1, 1)); + + final Point point = new Point(0, 0); + final MapModel<TestGameObject,TestMapArchObject,TestArchetype> mapModel = mapControl.getMapModel(); + mapModel.beginTransaction("TEST"); + final TestGameObject ob1 = testMapControlCreator.insertFloor(mapModel, point); + final TestGameObject ob2 = testMapControlCreator.insertExit(ob1); + + final TestGameObject ob1Clone = testMapControlCreator.getGameObjectFactory().cloneGameObject(ob1); + + Assert.assertNotSame(ob1, ob1Clone); + Assert.assertEquals(1, ob1Clone.countInvObjects()); + final TestGameObject ob2Clone = ob1Clone.getFirst(); + Assert.assertNotNull(ob2Clone); + Assert.assertNotSame(ob2, ob2Clone); + + Assert.assertSame(ob1, ob2.getContainer()); + Assert.assertSame(ob1Clone, ob2Clone.getContainer()); + } + +} // class GameObjectFactoryTest Property changes on: trunk/src/test/net/sf/gridarta/model/gameobject/GameObjectFactoryTest.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF Added: trunk/src/test/net/sf/gridarta/model/map/maparchobject/TestMapArchObjectFactory.java =================================================================== --- trunk/src/test/net/sf/gridarta/model/map/maparchobject/TestMapArchObjectFactory.java (rev 0) +++ trunk/src/test/net/sf/gridarta/model/map/maparchobject/TestMapArchObjectFactory.java 2010-06-03 12:37:19 UTC (rev 8067) @@ -0,0 +1,39 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2010 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.model.map.maparchobject; + +import org.jetbrains.annotations.NotNull; + +/** + * A {@link MapArchObjectFactory} for regression tests. + * @author Andreas Kirschbaum + */ +public class TestMapArchObjectFactory implements MapArchObjectFactory<TestMapArchObject> { + + /** + * {@inheritDoc} + */ + @NotNull + @Override + public TestMapArchObject newMapArchObject(final boolean addDefaultAttributes) { + return new TestMapArchObject(); + } + +} // class TestMapArchObjectFactory Property changes on: trunk/src/test/net/sf/gridarta/model/map/maparchobject/TestMapArchObjectFactory.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-06-03 15:17:42
|
Revision: 8075 http://gridarta.svn.sourceforge.net/gridarta/?rev=8075&view=rev Author: akirschbaum Date: 2010-06-03 15:17:35 +0000 (Thu, 03 Jun 2010) Log Message: ----------- Prevent the selected square view from moving around tail parts. Modified Paths: -------------- trunk/atrinik/ChangeLog trunk/crossfire/ChangeLog trunk/daimonin/ChangeLog trunk/src/app/net/sf/gridarta/gui/selectedsquare/SelectedSquareActions.java trunk/src/test/net/sf/gridarta/gui/selectedsquare/SelectedSquareActionsTest.java Modified: trunk/atrinik/ChangeLog =================================================================== --- trunk/atrinik/ChangeLog 2010-06-03 15:06:06 UTC (rev 8074) +++ trunk/atrinik/ChangeLog 2010-06-03 15:17:35 UTC (rev 8075) @@ -1,5 +1,7 @@ 2010-06-03 Andreas Kirschbaum + * Prevent the selected square view from moving around tail parts. + * Prevent Paste/Undo/Redo from breaking the map when applied to game objects having inventories. Modified: trunk/crossfire/ChangeLog =================================================================== --- trunk/crossfire/ChangeLog 2010-06-03 15:06:06 UTC (rev 8074) +++ trunk/crossfire/ChangeLog 2010-06-03 15:17:35 UTC (rev 8075) @@ -1,5 +1,7 @@ 2010-06-03 Andreas Kirschbaum + * Prevent the selected square view from moving around tail parts. + * Prevent Paste/Undo/Redo from breaking the map when applied to game objects having inventories. Modified: trunk/daimonin/ChangeLog =================================================================== --- trunk/daimonin/ChangeLog 2010-06-03 15:06:06 UTC (rev 8074) +++ trunk/daimonin/ChangeLog 2010-06-03 15:17:35 UTC (rev 8075) @@ -1,5 +1,7 @@ 2010-06-03 Andreas Kirschbaum + * Prevent the selected square view from moving around tail parts. + * Prevent Paste/Undo/Redo from breaking the map when applied to game objects having inventories. Modified: trunk/src/app/net/sf/gridarta/gui/selectedsquare/SelectedSquareActions.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/selectedsquare/SelectedSquareActions.java 2010-06-03 15:06:06 UTC (rev 8074) +++ trunk/src/app/net/sf/gridarta/gui/selectedsquare/SelectedSquareActions.java 2010-06-03 15:17:35 UTC (rev 8075) @@ -54,7 +54,7 @@ */ public boolean doMoveSquareTop(final boolean performAction) { final GameObject<G, A, R> gameObject = selectedSquareModel.getSelectedGameObject(); - if (gameObject == null) { + if (gameObject == null || !gameObject.isHead()) { return false; } @@ -84,7 +84,7 @@ */ public boolean doMoveSquareUp(final boolean performAction) { final GameObject<G, A, R> gameObject = selectedSquareModel.getSelectedGameObject(); - if (gameObject == null) { + if (gameObject == null || !gameObject.isHead()) { return false; } @@ -114,7 +114,7 @@ */ public boolean doMoveSquareDown(final boolean performAction) { final GameObject<G, A, R> gameObject = selectedSquareModel.getSelectedGameObject(); - if (gameObject == null) { + if (gameObject == null || !gameObject.isHead()) { return false; } @@ -144,7 +144,7 @@ */ public boolean doMoveSquareBottom(final boolean performAction) { final GameObject<G, A, R> gameObject = selectedSquareModel.getSelectedGameObject(); - if (gameObject == null) { + if (gameObject == null || !gameObject.isHead()) { return false; } @@ -174,7 +174,7 @@ */ public boolean doMoveSquareEnv(final boolean performAction) { final G gameObject = selectedSquareModel.getSelectedGameObject(); - if (gameObject == null) { + if (gameObject == null || !gameObject.isHead()) { return false; } @@ -210,7 +210,7 @@ */ public boolean doMoveSquareInv(final boolean performAction) { final G gameObject = selectedSquareModel.getSelectedGameObject(); - if (gameObject == null) { + if (gameObject == null || !gameObject.isHead()) { return false; } Modified: trunk/src/test/net/sf/gridarta/gui/selectedsquare/SelectedSquareActionsTest.java =================================================================== --- trunk/src/test/net/sf/gridarta/gui/selectedsquare/SelectedSquareActionsTest.java 2010-06-03 15:06:06 UTC (rev 8074) +++ trunk/src/test/net/sf/gridarta/gui/selectedsquare/SelectedSquareActionsTest.java 2010-06-03 15:17:35 UTC (rev 8075) @@ -874,6 +874,44 @@ } /** + * Checks that tail parts cannot be moved. + * @throws DuplicateArchetypeException if the test fails + */ + @Test + public void testMoveTailPart() throws DuplicateArchetypeException { + final TestMapControlCreator testMapControlCreator = new TestMapControlCreator(); + final MapControl<TestGameObject, TestMapArchObject, TestArchetype> mapControl = testMapControlCreator.newMapControl(MAP_FILE1, MAP_NAME1, new Size2D(2, 1)); + final SelectedSquareModel<TestGameObject, TestMapArchObject, TestArchetype> selectedSquareModel = newSelectedSquareModel(mapControl, testMapControlCreator); + final SelectedSquareActions<TestGameObject, TestMapArchObject, TestArchetype> selectedSquareActions = new SelectedSquareActions<TestGameObject, TestMapArchObject, TestArchetype>(selectedSquareModel); + + final Point pointHead = new Point(0, 0); + final Point pointTail = new Point(1, 0); + final MapModel<TestGameObject,TestMapArchObject,TestArchetype> mapModel = mapControl.getMapModel(); + mapModel.beginTransaction("TEST"); + final MapSquare<TestGameObject, TestMapArchObject, TestArchetype> mapSquareHead = mapModel.getMapSquare(pointHead); + final MapSquare<TestGameObject, TestMapArchObject, TestArchetype> mapSquareTail = mapModel.getMapSquare(pointTail); + final TestGameObject ob1Head = testMapControlCreator.insertExit(mapModel, pointHead); + final TestGameObject ob1Tail = testMapControlCreator.insertExit(mapModel, pointTail); + final TestGameObject ob2Head = testMapControlCreator.insertMob21(mapModel, pointHead); + final TestGameObject ob3Head = testMapControlCreator.insertExit(mapModel, pointHead); + final TestGameObject ob3Tail = testMapControlCreator.insertExit(mapModel, pointTail); + + TestMapControlCreator.checkMapContents(mapModel, "exit,mob21,exit|exit,mob21b,exit"); + + // select ob2Tail + selectedSquareModel.setSelectedMapSquare(mapSquareTail, null, 0); + selectedSquareModel.setSelectedGameObject(ob2Head.getMultiNext(), 0); + + // ob2Tail cannot move + Assert.assertFalse(selectedSquareActions.doMoveSquareTop(false)); + Assert.assertFalse(selectedSquareActions.doMoveSquareUp(false)); + Assert.assertFalse(selectedSquareActions.doMoveSquareDown(false)); + Assert.assertFalse(selectedSquareActions.doMoveSquareBottom(false)); + Assert.assertFalse(selectedSquareActions.doMoveSquareInv(false)); + Assert.assertFalse(selectedSquareActions.doMoveSquareEnv(false)); + } + + /** * Creates a new {@link SelectedSquareModel}. * @param mapControl the associated map control * @param testMapControlCreator the test map control creator to use This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-06-03 16:19:43
|
Revision: 8079 http://gridarta.svn.sourceforge.net/gridarta/?rev=8079&view=rev Author: akirschbaum Date: 2010-06-03 16:19:36 +0000 (Thu, 03 Jun 2010) Log Message: ----------- Make "Move Inv" to always insert into the head part. Modified Paths: -------------- trunk/atrinik/ChangeLog trunk/crossfire/ChangeLog trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/gui/map/renderer/AbstractFlatMapRenderer.java trunk/daimonin/ChangeLog trunk/src/app/net/sf/gridarta/gui/selectedsquare/SelectedSquareActions.java trunk/src/app/net/sf/gridarta/model/map/mapmodel/DefaultMapModel.java trunk/src/test/net/sf/gridarta/gui/selectedsquare/SelectedSquareActionsTest.java Modified: trunk/atrinik/ChangeLog =================================================================== --- trunk/atrinik/ChangeLog 2010-06-03 16:17:16 UTC (rev 8078) +++ trunk/atrinik/ChangeLog 2010-06-03 16:19:36 UTC (rev 8079) @@ -1,5 +1,7 @@ 2010-06-03 Andreas Kirschbaum + * Make "Move Inv" to always insert into the head part. + * Prevent the selected square view from moving around tail parts. * Prevent Paste/Undo/Redo from breaking the map when applied to Modified: trunk/crossfire/ChangeLog =================================================================== --- trunk/crossfire/ChangeLog 2010-06-03 16:17:16 UTC (rev 8078) +++ trunk/crossfire/ChangeLog 2010-06-03 16:19:36 UTC (rev 8079) @@ -1,5 +1,7 @@ 2010-06-03 Andreas Kirschbaum + * Make "Move Inv" to always insert into the head part. + * Prevent the selected square view from moving around tail parts. * Prevent Paste/Undo/Redo from breaking the map when applied to Modified: trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/gui/map/renderer/AbstractFlatMapRenderer.java =================================================================== --- trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/gui/map/renderer/AbstractFlatMapRenderer.java 2010-06-03 16:17:16 UTC (rev 8078) +++ trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/gui/map/renderer/AbstractFlatMapRenderer.java 2010-06-03 16:19:36 UTC (rev 8079) @@ -204,9 +204,11 @@ private void addMapSquares(@NotNull final Iterable<GameObject> gameObjects, @NotNull final Collection<MapSquare<GameObject, MapArchObject, Archetype>> toRepaint) { for (final net.sf.gridarta.model.gameobject.GameObject<GameObject, MapArchObject, Archetype> gameObject : gameObjects) { if (!gameObject.isInContainer()) { - final MapSquare<GameObject, MapArchObject, Archetype> square = gameObject.getMapSquare(); - if (square != null) { - getSquaresToRepaint(square, toRepaint); + for (net.sf.gridarta.model.gameobject.GameObject<GameObject, MapArchObject, Archetype> gameObjectPart = gameObject; gameObjectPart != null; gameObjectPart = gameObjectPart.getMultiNext()) { + final MapSquare<GameObject, MapArchObject, Archetype> square = gameObjectPart.getMapSquare(); + if (square != null) { + getSquaresToRepaint(square, toRepaint); + } } } } Modified: trunk/daimonin/ChangeLog =================================================================== --- trunk/daimonin/ChangeLog 2010-06-03 16:17:16 UTC (rev 8078) +++ trunk/daimonin/ChangeLog 2010-06-03 16:19:36 UTC (rev 8079) @@ -1,5 +1,7 @@ 2010-06-03 Andreas Kirschbaum + * Make "Move Inv" to always insert into the head part. + * Prevent the selected square view from moving around tail parts. * Prevent Paste/Undo/Redo from breaking the map when applied to Modified: trunk/src/app/net/sf/gridarta/gui/selectedsquare/SelectedSquareActions.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/selectedsquare/SelectedSquareActions.java 2010-06-03 16:17:16 UTC (rev 8078) +++ trunk/src/app/net/sf/gridarta/gui/selectedsquare/SelectedSquareActions.java 2010-06-03 16:19:36 UTC (rev 8079) @@ -225,7 +225,7 @@ final MapModel<G, A, R> mapModel = mapSquare.getMapModel(); mapModel.beginTransaction("Move To Inventory"); try { - mapModel.moveInv(gameObject, prevGameObject); + mapModel.moveInv(gameObject, prevGameObject.getHead()); } finally { mapModel.endTransaction(); } Modified: trunk/src/app/net/sf/gridarta/model/map/mapmodel/DefaultMapModel.java =================================================================== --- trunk/src/app/net/sf/gridarta/model/map/mapmodel/DefaultMapModel.java 2010-06-03 16:17:16 UTC (rev 8078) +++ trunk/src/app/net/sf/gridarta/model/map/mapmodel/DefaultMapModel.java 2010-06-03 16:19:36 UTC (rev 8079) @@ -915,6 +915,10 @@ */ @Override public void moveInv(@NotNull final G gameObject, @NotNull final GameObject<G, A, R> prevGameObject) { + if (!gameObject.isHead() || !prevGameObject.isHead()) { + throw new IllegalArgumentException(); + } + gameObject.remove(); gameObject.removeTailParts(); prevGameObject.addFirst(gameObject); Modified: trunk/src/test/net/sf/gridarta/gui/selectedsquare/SelectedSquareActionsTest.java =================================================================== --- trunk/src/test/net/sf/gridarta/gui/selectedsquare/SelectedSquareActionsTest.java 2010-06-03 16:17:16 UTC (rev 8078) +++ trunk/src/test/net/sf/gridarta/gui/selectedsquare/SelectedSquareActionsTest.java 2010-06-03 16:19:36 UTC (rev 8079) @@ -874,6 +874,44 @@ } /** + * Checks that {@link SelectedSquareActions#doMoveSquareInv(boolean)} always + * inserts into the head-part. + * @throws DuplicateArchetypeException if the test fails + */ + @Test + public void testDoMoveSquareInvIntoHead1() throws DuplicateArchetypeException { + final TestMapControlCreator testMapControlCreator = new TestMapControlCreator(); + final MapControl<TestGameObject, TestMapArchObject, TestArchetype> mapControl = testMapControlCreator.newMapControl(MAP_FILE1, MAP_NAME1, new Size2D(3, 1)); + final SelectedSquareModel<TestGameObject, TestMapArchObject, TestArchetype> selectedSquareModel = newSelectedSquareModel(mapControl, testMapControlCreator); + final SelectedSquareActions<TestGameObject, TestMapArchObject, TestArchetype> selectedSquareActions = new SelectedSquareActions<TestGameObject, TestMapArchObject, TestArchetype>(selectedSquareModel); + + final Point point0 = new Point(0, 0); + final Point point1 = new Point(1, 0); + final MapModel<TestGameObject,TestMapArchObject,TestArchetype> mapModel = mapControl.getMapModel(); + mapModel.beginTransaction("TEST"); + final MapSquare<TestGameObject, TestMapArchObject, TestArchetype> mapSquare0 = mapModel.getMapSquare(point0); + final MapSquare<TestGameObject, TestMapArchObject, TestArchetype> mapSquare1 = mapModel.getMapSquare(point1); + final TestGameObject ob2 = testMapControlCreator.insertMob21(mapModel, point1); + final TestGameObject ob1 = testMapControlCreator.insertMob21(mapModel, point0); + + TestMapControlCreator.checkMapContents(mapModel, "mob21|mob21,mob21b|mob21b"); + + // select ob2 + selectedSquareModel.setSelectedMapSquare(mapSquare1, null, 0); + selectedSquareModel.setSelectedGameObject(ob2, 0); + + // move ob2 into ob1 + Assert.assertTrue(selectedSquareActions.doMoveSquareInv(true)); + + TestMapControlCreator.checkMapContents(mapModel, "mob21|mob21b|"); + TestMapControlCreator.checkContents(mapSquare0, ob1); + final TestGameObject ob1Tail = ob1.getMultiNext(); + Assert.assertNotNull(ob1Tail); + TestMapControlCreator.checkContents(mapSquare1, ob1Tail); + TestMapControlCreator.checkContents(ob1, ob2); + } + + /** * Checks that tail parts cannot be moved. * @throws DuplicateArchetypeException if the test fails */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-06-03 16:58:55
|
Revision: 8081 http://gridarta.svn.sourceforge.net/gridarta/?rev=8081&view=rev Author: akirschbaum Date: 2010-06-03 16:58:45 +0000 (Thu, 03 Jun 2010) Log Message: ----------- Make "Move Env" to always insert into the selected map square. Modified Paths: -------------- trunk/atrinik/ChangeLog trunk/crossfire/ChangeLog trunk/daimonin/ChangeLog trunk/src/app/net/sf/gridarta/gui/selectedsquare/SelectedSquareActions.java trunk/src/app/net/sf/gridarta/model/baseobject/GameObjectContainer.java trunk/src/app/net/sf/gridarta/model/map/mapmodel/DefaultMapModel.java trunk/src/test/net/sf/gridarta/gui/selectedsquare/SelectedSquareActionsTest.java Modified: trunk/atrinik/ChangeLog =================================================================== --- trunk/atrinik/ChangeLog 2010-06-03 16:28:17 UTC (rev 8080) +++ trunk/atrinik/ChangeLog 2010-06-03 16:58:45 UTC (rev 8081) @@ -1,5 +1,7 @@ 2010-06-03 Andreas Kirschbaum + * Make "Move Env" to always insert into the selected map square. + * Make "Move Inv" to always insert into the head part. * Prevent the selected square view from moving around tail parts. Modified: trunk/crossfire/ChangeLog =================================================================== --- trunk/crossfire/ChangeLog 2010-06-03 16:28:17 UTC (rev 8080) +++ trunk/crossfire/ChangeLog 2010-06-03 16:58:45 UTC (rev 8081) @@ -1,5 +1,7 @@ 2010-06-03 Andreas Kirschbaum + * Make "Move Env" to always insert into the selected map square. + * Make "Move Inv" to always insert into the head part. * Prevent the selected square view from moving around tail parts. Modified: trunk/daimonin/ChangeLog =================================================================== --- trunk/daimonin/ChangeLog 2010-06-03 16:28:17 UTC (rev 8080) +++ trunk/daimonin/ChangeLog 2010-06-03 16:58:45 UTC (rev 8081) @@ -1,5 +1,7 @@ 2010-06-03 Andreas Kirschbaum + * Make "Move Env" to always insert into the selected map square. + * Make "Move Inv" to always insert into the head part. * Prevent the selected square view from moving around tail parts. Modified: trunk/src/app/net/sf/gridarta/gui/selectedsquare/SelectedSquareActions.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/selectedsquare/SelectedSquareActions.java 2010-06-03 16:28:17 UTC (rev 8080) +++ trunk/src/app/net/sf/gridarta/gui/selectedsquare/SelectedSquareActions.java 2010-06-03 16:58:45 UTC (rev 8081) @@ -183,8 +183,16 @@ return false; } - final MapSquare<G, A, R> mapSquare = gameObject.getMapSquare(); - assert mapSquare != null; + final MapSquareSelection<G, A, R> mapSquareSelection = selectedSquareModel.getSelectedMapSquare(); + if (mapSquareSelection == null) { + return false; + } + + final MapSquare<G, A, R> mapSquare = mapSquareSelection.getMapSquare(); + if (mapSquare == null) { + return false; + } + final MapModel<G, A, R> mapModel = mapSquare.getMapModel(); final Point pos = new Point(mapSquare.getMapX(), mapSquare.getMapY()); if (!envGameObject.isInContainer() && gameObject.getArchetype().isMulti() && !mapModel.isMultiArchFittingToMap(gameObject.getArchetype(), pos, true)) { Modified: trunk/src/app/net/sf/gridarta/model/baseobject/GameObjectContainer.java =================================================================== --- trunk/src/app/net/sf/gridarta/model/baseobject/GameObjectContainer.java 2010-06-03 16:28:17 UTC (rev 8080) +++ trunk/src/app/net/sf/gridarta/model/baseobject/GameObjectContainer.java 2010-06-03 16:58:45 UTC (rev 8081) @@ -462,12 +462,16 @@ return; } + if (!nextGameObject.isHead()) { + throw new IllegalArgumentException(); + } + notifyBeginChange(); try { boolean added = false; int index = 0; for (final G tmpGameObject : contents) { - if (tmpGameObject == nextGameObject) { + if (tmpGameObject.getHead() == nextGameObject) { contents.add(index, gameObject); added = true; break; Modified: trunk/src/app/net/sf/gridarta/model/map/mapmodel/DefaultMapModel.java =================================================================== --- trunk/src/app/net/sf/gridarta/model/map/mapmodel/DefaultMapModel.java 2010-06-03 16:28:17 UTC (rev 8080) +++ trunk/src/app/net/sf/gridarta/model/map/mapmodel/DefaultMapModel.java 2010-06-03 16:58:45 UTC (rev 8081) @@ -885,11 +885,19 @@ */ @Override public void moveEnv(@NotNull final G gameObject, @NotNull final Point pos, @NotNull final G nextGameObject) { - assert !gameObject.isMulti(); // no tail parts should be present when inside inventory of another game object - final GameObjectContainer<G,A,R> nextGameObjectContainer = nextGameObject.getContainer(); - if (nextGameObjectContainer == null) { + if (!nextGameObject.isHead()) { throw new IllegalArgumentException(); } + assert !gameObject.isMulti(); // no tail parts should be present when inside inventory of another game object + final GameObjectContainer<G, A, R> nextGameObjectContainer; + if (nextGameObject.isInContainer()) { + nextGameObjectContainer = nextGameObject.getContainer(); + if (nextGameObjectContainer == null) { + throw new IllegalArgumentException(); + } + } else { + nextGameObjectContainer = getMapSquare(pos); + } final MapSquare<G, A, R> mapSquare = nextGameObjectContainer.getMapSquare(); if (mapSquare == null || mapSquare.getMapModel() != this) { throw new IllegalArgumentException(); Modified: trunk/src/test/net/sf/gridarta/gui/selectedsquare/SelectedSquareActionsTest.java =================================================================== --- trunk/src/test/net/sf/gridarta/gui/selectedsquare/SelectedSquareActionsTest.java 2010-06-03 16:28:17 UTC (rev 8080) +++ trunk/src/test/net/sf/gridarta/gui/selectedsquare/SelectedSquareActionsTest.java 2010-06-03 16:58:45 UTC (rev 8081) @@ -949,6 +949,39 @@ } /** + * Checks that {@link SelectedSquareActions#doMoveSquareEnv(boolean)} + * inserts into selected map square. + * @throws DuplicateArchetypeException if the test fails + */ + @Test + public void testMoveEnvIntoSelectedMapSquare() throws DuplicateArchetypeException { + final TestMapControlCreator testMapControlCreator = new TestMapControlCreator(); + final MapControl<TestGameObject, TestMapArchObject, TestArchetype> mapControl = testMapControlCreator.newMapControl(MAP_FILE1, MAP_NAME1, new Size2D(3, 1)); + final SelectedSquareModel<TestGameObject, TestMapArchObject, TestArchetype> selectedSquareModel = newSelectedSquareModel(mapControl, testMapControlCreator); + final SelectedSquareActions<TestGameObject, TestMapArchObject, TestArchetype> selectedSquareActions = new SelectedSquareActions<TestGameObject, TestMapArchObject, TestArchetype>(selectedSquareModel); + + final Point point0 = new Point(0, 0); + final Point point1 = new Point(1, 0); + final MapModel<TestGameObject,TestMapArchObject,TestArchetype> mapModel = mapControl.getMapModel(); + mapModel.beginTransaction("TEST"); + final MapSquare<TestGameObject, TestMapArchObject, TestArchetype> mapSquare0 = mapModel.getMapSquare(point0); + final MapSquare<TestGameObject, TestMapArchObject, TestArchetype> mapSquare1 = mapModel.getMapSquare(point1); + final TestGameObject ob1 = testMapControlCreator.insertMob21(mapModel, point0); + final TestGameObject ob2 = testMapControlCreator.insertMob21(ob1); + + TestMapControlCreator.checkMapContents(mapModel, "mob21|mob21b|"); + + // select ob2 in mapSquare1 + selectedSquareModel.setSelectedMapSquare(mapSquare1, null, 0); + selectedSquareModel.setSelectedGameObject(ob2, 0); + + // move ob2 into mapSquare1 + Assert.assertTrue(selectedSquareActions.doMoveSquareEnv(true)); + + TestMapControlCreator.checkMapContents(mapModel, "mob21|mob21,mob21b|mob21b"); + } + + /** * Creates a new {@link SelectedSquareModel}. * @param mapControl the associated map control * @param testMapControlCreator the test map control creator to use This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-06-03 23:00:48
|
Revision: 8088 http://gridarta.svn.sourceforge.net/gridarta/?rev=8088&view=rev Author: akirschbaum Date: 2010-06-03 23:00:42 +0000 (Thu, 03 Jun 2010) Log Message: ----------- Properly retain "elevation" game object attributes when editing maps. Modified Paths: -------------- trunk/crossfire/ChangeLog trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/model/gameobject/GameObject.java trunk/crossfire.iml trunk/src/app/net/sf/gridarta/model/baseobject/GameObjectContainer.java trunk/src/app/net/sf/gridarta/model/gameobject/DefaultIsoGameObject.java trunk/src/app/net/sf/gridarta/model/gameobject/GameObject.java trunk/src/test/net/sf/gridarta/model/gameobject/TestGameObject.java Added Paths: ----------- trunk/crossfire/src/test/net/ trunk/crossfire/src/test/net/sf/ trunk/crossfire/src/test/net/sf/gridarta/ trunk/crossfire/src/test/net/sf/gridarta/var/ trunk/crossfire/src/test/net/sf/gridarta/var/crossfire/ trunk/crossfire/src/test/net/sf/gridarta/var/crossfire/model/ trunk/crossfire/src/test/net/sf/gridarta/var/crossfire/model/gameobject/ trunk/crossfire/src/test/net/sf/gridarta/var/crossfire/model/gameobject/GameObjectCreator.java trunk/crossfire/src/test/net/sf/gridarta/var/crossfire/model/gameobject/PropagateElevationTest.java Modified: trunk/crossfire/ChangeLog =================================================================== --- trunk/crossfire/ChangeLog 2010-06-03 22:38:31 UTC (rev 8087) +++ trunk/crossfire/ChangeLog 2010-06-03 23:00:42 UTC (rev 8088) @@ -1,3 +1,8 @@ +2010-06-04 Andreas Kirschbaum + + * Properly retain "elevation" game object attributes when editing + maps. + 2010-06-03 Andreas Kirschbaum * Make "Move Env" to always insert into the selected map square. Modified: trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/model/gameobject/GameObject.java =================================================================== --- trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/model/gameobject/GameObject.java 2010-06-03 22:38:31 UTC (rev 8087) +++ trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/model/gameobject/GameObject.java 2010-06-03 23:00:42 UTC (rev 8088) @@ -80,7 +80,7 @@ * {@inheritDoc} */ @Override - public void propagateElevation(@NotNull final BaseObject<GameObject, MapArchObject, Archetype, ?> gameObject) { + public void propagateElevation(@NotNull final BaseObject<?, ?, ?, ?> gameObject) { final String elevation = gameObject.getAttributeString(ELEVATION, false); if (elevation.length() != 0) { setAttributeString(ELEVATION, elevation); Added: trunk/crossfire/src/test/net/sf/gridarta/var/crossfire/model/gameobject/GameObjectCreator.java =================================================================== --- trunk/crossfire/src/test/net/sf/gridarta/var/crossfire/model/gameobject/GameObjectCreator.java (rev 0) +++ trunk/crossfire/src/test/net/sf/gridarta/var/crossfire/model/gameobject/GameObjectCreator.java 2010-06-03 23:00:42 UTC (rev 8088) @@ -0,0 +1,86 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2010 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.var.crossfire.model.gameobject; + +import java.util.regex.Pattern; +import net.sf.gridarta.model.anim.AnimationObjects; +import net.sf.gridarta.model.anim.DefaultAnimationObjects; +import net.sf.gridarta.model.face.ArchFaceProvider; +import net.sf.gridarta.model.face.DefaultFaceObjects; +import net.sf.gridarta.model.face.FaceObjectProviders; +import net.sf.gridarta.model.face.FaceObjects; +import net.sf.gridarta.utils.GUIUtils; +import net.sf.gridarta.utils.SystemIcons; +import net.sf.gridarta.var.crossfire.model.archetype.Archetype; +import net.sf.gridarta.var.crossfire.model.archetype.DefaultArchetype; +import org.jetbrains.annotations.NotNull; + +/** + * Creates {@link GameObject GameObjects}. + * @author Andreas Kirschbaum + */ +public class GameObjectCreator { + + /** + * The {@link Archetype} for created game objects. + */ + @NotNull + private final Archetype archetype; + + /** + * The {@link FaceObjectProviders} for created game objects. + */ + @NotNull + private final FaceObjectProviders faceObjectProviders; + + /** + * The {@link AnimationObjects} for created game objects. + */ + @NotNull + private final AnimationObjects animationObjects; + + /** + * Creates a new instance. + */ + GameObjectCreator() { + final ArchFaceProvider archFaceProvider = new ArchFaceProvider(); + final FaceObjects faceObjects = new DefaultFaceObjects("pngFile", "faceTreeFile", Pattern.compile(""), "", archFaceProvider); + final GUIUtils guiUtils = new GUIUtils(); + final SystemIcons systemIcons = new SystemIcons(guiUtils); + faceObjectProviders = new FaceObjectProviders(1, faceObjects, systemIcons); + animationObjects = new DefaultAnimationObjects("animTreeFile"); + archetype = new DefaultArchetype("arch", faceObjectProviders, animationObjects); + } + + /** + * Creates a new {@link GameObject}. + * @param elevation the game object's elevation + * @return the new game object + */ + @NotNull + public GameObject newGameObject(final int elevation) { + final GameObject gameObject = new GameObject(archetype, faceObjectProviders, animationObjects); + if (elevation != 0) { + gameObject.setAttributeString(GameObject.ELEVATION, Integer.toString(elevation)); + } + return gameObject; + } + +} // class GameObjectCreator Property changes on: trunk/crossfire/src/test/net/sf/gridarta/var/crossfire/model/gameobject/GameObjectCreator.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF Added: trunk/crossfire/src/test/net/sf/gridarta/var/crossfire/model/gameobject/PropagateElevationTest.java =================================================================== --- trunk/crossfire/src/test/net/sf/gridarta/var/crossfire/model/gameobject/PropagateElevationTest.java (rev 0) +++ trunk/crossfire/src/test/net/sf/gridarta/var/crossfire/model/gameobject/PropagateElevationTest.java 2010-06-03 23:00:42 UTC (rev 8088) @@ -0,0 +1,351 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2010 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.var.crossfire.model.gameobject; + +import java.util.Iterator; +import net.sf.gridarta.model.baseobject.GameObjectContainer; +import net.sf.gridarta.var.crossfire.model.archetype.Archetype; +import net.sf.gridarta.var.crossfire.model.maparchobject.MapArchObject; +import org.jetbrains.annotations.NotNull; +import org.junit.Assert; +import org.junit.Test; + +/** + * Checks that {@link GameObjectContainer GameObjectContainers} correctly + * propagate elevation information when being modified. + * @author Andreas Kirschbaum + */ +public class PropagateElevationTest { + + /** + * Checks that {@link + * GameObjectContainer#addFirst(net.sf.gridarta.model.gameobject.GameObject)} + * does work correctly. + */ + @Test + public void testAddFirst() { + final GameObjectCreator gameObjectCreator = new GameObjectCreator(); + final GameObjectContainer<GameObject, MapArchObject, Archetype> gameObjectContainer = gameObjectCreator.newGameObject(0); + + // first game object => keep + gameObjectContainer.addFirst(gameObjectCreator.newGameObject(123)); + check(gameObjectContainer, 123); + + // without elevation => propagate + gameObjectContainer.addFirst(gameObjectCreator.newGameObject(0)); + check(gameObjectContainer, 123); + + // with elevation => ignore but propagate + gameObjectContainer.addFirst(gameObjectCreator.newGameObject(321)); + check(gameObjectContainer, 123); + } + + /** + * Checks that {@link + * GameObjectContainer#addLast(net.sf.gridarta.model.gameobject.GameObject)} + * does work correctly. + */ + @Test + public void testAddLast() { + final GameObjectCreator gameObjectCreator = new GameObjectCreator(); + final GameObjectContainer<GameObject, MapArchObject, Archetype> gameObjectContainer = gameObjectCreator.newGameObject(0); + + // first game object => keep + gameObjectContainer.addLast(gameObjectCreator.newGameObject(123)); + check(gameObjectContainer, 123); + + // without elevation => keep + gameObjectContainer.addLast(gameObjectCreator.newGameObject(0)); + check(gameObjectContainer, 123, 0); + + // with elevation => keep + gameObjectContainer.addLast(gameObjectCreator.newGameObject(321)); + check(gameObjectContainer, 123, 0, 321); + } + + /** + * Checks that {@link + * GameObjectContainer#insertBefore(net.sf.gridarta.model.gameobject.GameObject, + * GameObject)} does work correctly. + */ + @Test + public void testInsertBefore() { + final GameObjectCreator gameObjectCreator = new GameObjectCreator(); + final GameObjectContainer<GameObject, MapArchObject, Archetype> gameObjectContainer = gameObjectCreator.newGameObject(0); + + // first game object => keep + gameObjectContainer.insertBefore(gameObjectCreator.newGameObject(1), null); + check(gameObjectContainer, 1); + + // without elevation => propagate + gameObjectContainer.insertBefore(gameObjectCreator.newGameObject(0), null); + check(gameObjectContainer, 1, 0); + + // with elevation => ignore but propagate + final GameObject ob1 = gameObjectCreator.newGameObject(2); + gameObjectContainer.insertBefore(ob1, null); + check(gameObjectContainer, 1, 0, 0); + + // with elevation => keep + gameObjectContainer.insertBefore(gameObjectCreator.newGameObject(3), ob1); + check(gameObjectContainer, 1, 3, 0, 0); + + // with elevation => ignore but propagate + gameObjectContainer.insertBefore(gameObjectCreator.newGameObject(4), null); + check(gameObjectContainer, 1, 0, 3, 0, 0); + } + + /** + * Checks that {@link + * GameObjectContainer#insertAfter(net.sf.gridarta.model.gameobject.GameObject, + * GameObject)} does work correctly. + */ + @Test + public void testInsertAfter() { + final GameObjectCreator gameObjectCreator = new GameObjectCreator(); + final GameObjectContainer<GameObject, MapArchObject, Archetype> gameObjectContainer = gameObjectCreator.newGameObject(0); + + // first game object => keep + gameObjectContainer.insertAfter(null, gameObjectCreator.newGameObject(1)); + check(gameObjectContainer, 1); + + // at end => keep + final GameObject ob1 = gameObjectCreator.newGameObject(2); + gameObjectContainer.insertAfter(null, ob1); + check(gameObjectContainer, 1, 2); + + // at front, without elevation => propagate + gameObjectContainer.insertAfter(ob1, gameObjectCreator.newGameObject(0)); + check(gameObjectContainer, 1, 0, 2); + + // middle => keep + gameObjectContainer.insertAfter(ob1, gameObjectCreator.newGameObject(3)); + check(gameObjectContainer, 1, 0, 3, 2); + + // at front, with elevation => ignore but propagate + gameObjectContainer.insertAfter(gameObjectContainer.getFirst(), gameObjectCreator.newGameObject(4)); + check(gameObjectContainer, 1, 0, 0, 3, 2); + } + + /** + * Checks that {@link + * GameObjectContainer#moveBottom(net.sf.gridarta.model.gameobject.GameObject)} + * does work correctly. + */ + @Test + public void testMoveBottom() { + final GameObjectCreator gameObjectCreator = new GameObjectCreator(); + final GameObjectContainer<GameObject, MapArchObject, Archetype> container1 = newContainer(gameObjectCreator, 1, 0, 0, 0); + container1.moveBottom(get(container1, 0)); + check(container1, 1, 0, 0, 0); + container1.moveBottom(get(container1, 1)); + check(container1, 1, 0, 0, 0); + container1.moveBottom(get(container1, 3)); + check(container1, 1, 0, 0, 0); + } + + /** + * Checks that {@link + * GameObjectContainer#moveDown(net.sf.gridarta.model.gameobject.GameObject)} + * does work correctly. + */ + @Test + public void testMoveDown() { + final GameObjectCreator gameObjectCreator = new GameObjectCreator(); + final GameObjectContainer<GameObject, MapArchObject, Archetype> container1 = newContainer(gameObjectCreator, 1, 0, 0, 0); + container1.moveDown(get(container1, 0)); + check(container1, 1, 0, 0, 0); + container1.moveDown(get(container1, 1)); + check(container1, 1, 0, 0, 0); + container1.moveDown(get(container1, 3)); + check(container1, 1, 0, 0, 0); + } + + /** + * Checks that {@link + * GameObjectContainer#moveUp(net.sf.gridarta.model.gameobject.GameObject)} + * does work correctly. + */ + @Test + public void testMoveUp() { + final GameObjectCreator gameObjectCreator = new GameObjectCreator(); + final GameObjectContainer<GameObject, MapArchObject, Archetype> container1 = newContainer(gameObjectCreator, 1, 0, 0, 0); + container1.moveUp(get(container1, 0)); + check(container1, 1, 0, 0, 0); + container1.moveUp(get(container1, 1)); + check(container1, 1, 0, 0, 0); + container1.moveUp(get(container1, 3)); + check(container1, 1, 0, 0, 0); + } + + /** + * Checks that {@link + * GameObjectContainer#moveTop(net.sf.gridarta.model.gameobject.GameObject)} + * does work correctly. + */ + @Test + public void testMoveTop() { + final GameObjectCreator gameObjectCreator = new GameObjectCreator(); + final GameObjectContainer<GameObject, MapArchObject, Archetype> container1 = newContainer(gameObjectCreator, 1, 0, 0, 0); + container1.moveTop(get(container1, 0)); + check(container1, 1, 0, 0, 0); + container1.moveTop(get(container1, 1)); + check(container1, 1, 0, 0, 0); + container1.moveTop(get(container1, 3)); + check(container1, 1, 0, 0, 0); + } + + /** + * Checks that {@link + * GameObjectContainer#remove(net.sf.gridarta.model.gameobject.GameObject)} + * does work correctly. + */ + @Test + public void testRemove() { + final GameObjectCreator gameObjectCreator = new GameObjectCreator(); + final GameObjectContainer<GameObject, MapArchObject, Archetype> container1 = newContainer(gameObjectCreator, 1, 0, 0, 0); + container1.remove(get(container1, 0)); + check(container1, 1, 0, 0); + container1.remove(get(container1, 2)); + check(container1, 1, 0); + container1.remove(get(container1, 0)); + check(container1, 1); + container1.remove(get(container1, 0)); + check(container1); + } + + /** + * Checks that {@link + * GameObjectContainer#replace(net.sf.gridarta.model.gameobject.GameObject, + * GameObject)} does work correctly. + */ + @Test + public void testReplace() { + final GameObjectCreator gameObjectCreator = new GameObjectCreator(); + final GameObjectContainer<GameObject, MapArchObject, Archetype> container1 = newContainer(gameObjectCreator, 1, 0, 0, 0); + container1.replace(get(container1, 0), gameObjectCreator.newGameObject(2)); + check(container1, 1, 0, 0, 0); + container1.replace(get(container1, 1), gameObjectCreator.newGameObject(3)); + check(container1, 1, 3, 0, 0); + container1.replace(get(container1, 0), gameObjectCreator.newGameObject(4)); + check(container1, 1, 3, 0, 0); + } + + /** + * Checks that {@link GameObjectContainer#iterator()}'s {@link + * Iterator#remove()} does work correctly. + */ + @Test + public void testIterator() { + final GameObjectCreator gameObjectCreator = new GameObjectCreator(); + final GameObjectContainer<GameObject, MapArchObject, Archetype> container1 = newContainer(gameObjectCreator, 1, 0, 0, 0, 0, 0); + final Iterator<GameObject> it = container1.iterator(); + it.next(); + it.remove(); + check(container1, 1, 0, 0, 0, 0); + it.next(); + it.remove(); + check(container1, 1, 0, 0, 0); + it.next(); + it.next(); + it.remove(); + check(container1, 1, 0, 0); + } + + /** + * Checks that {@link GameObjectContainer#reverse()}'s {@link + * Iterator#remove()} does work correctly. + */ + @Test + public void testReverse() { + final GameObjectCreator gameObjectCreator = new GameObjectCreator(); + final GameObjectContainer<GameObject, MapArchObject, Archetype> container1 = newContainer(gameObjectCreator, 1, 0, 0, 0, 0, 0); + final Iterator<GameObject> it= container1.reverse().iterator(); + it.next(); + it.remove(); + check(container1, 1, 0, 0, 0, 0); + it.next(); + it.remove(); + check(container1, 1, 0, 0, 0); + it.next(); + it.next(); + it.remove(); + check(container1, 1, 0, 0); + it.next(); + it.remove(); + check(container1, 1, 0); + it.next(); + it.remove(); + check(container1, 1); + Assert.assertFalse(it.hasNext()); + } + + /** + * Creates a new {@link GameObjectContainer} that contains game objects with + * the given elevation values. + * @param gameObjectCreator the game object creator to use + * @param elevations the elevations + * @return the game object container + */ + @NotNull + private static GameObjectContainer<GameObject, MapArchObject, Archetype> newContainer(@NotNull final GameObjectCreator gameObjectCreator, final int... elevations) { + final GameObjectContainer<GameObject, MapArchObject, Archetype> gameObject = gameObjectCreator.newGameObject(0); + for (final int elevation : elevations) { + gameObject.addLast(gameObjectCreator.newGameObject(elevation)); + } + return gameObject; + } + + /** + * Returns the game object at a given index. + * @param gameObjects the game objects to search + * @param index the index + * @return the game object at <code>index</code> + */ + @NotNull + private static GameObject get(@NotNull final Iterable<GameObject> gameObjects, final int index) { + int left = index; + for (final GameObject gameObject : gameObjects) { + if (left == 0) { + return gameObject; + } + left--; + } + + Assert.fail("index " + index + " not found"); + throw new AssertionError(); + } + + /** + * Checks some game objects for expected elevation values. + * @param gameObjects the game objects + * @param elevation the expected elevation value for the first game object + */ + private static void check(@NotNull final Iterable<GameObject> gameObjects, final int... elevation) { + int i = 0; + for (final GameObject gameObject : gameObjects) { + final int thisElevation = gameObject.getAttributeInt(GameObject.ELEVATION); + final int expectedElevation = i < elevation.length ? elevation[i] : 0; + Assert.assertEquals(gameObject.getBestName(), expectedElevation, thisElevation); + i++; + } + } + +} // class PropagateElevationTest Property changes on: trunk/crossfire/src/test/net/sf/gridarta/var/crossfire/model/gameobject/PropagateElevationTest.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF Modified: trunk/crossfire.iml =================================================================== --- trunk/crossfire.iml 2010-06-03 22:38:31 UTC (rev 8087) +++ trunk/crossfire.iml 2010-06-03 23:00:42 UTC (rev 8088) @@ -11,6 +11,9 @@ </content> <orderEntry type="inheritedJdk" /> <orderEntry type="sourceFolder" forTests="false" /> + <orderEntry type="module" module-name="gridarta" /> + <orderEntry type="module" module-name="utils" /> + <orderEntry type="module" module-name="preferences" /> <orderEntry type="module-library"> <library> <CLASSES> @@ -20,9 +23,6 @@ <SOURCES /> </library> </orderEntry> - <orderEntry type="module" module-name="gridarta" /> - <orderEntry type="module" module-name="utils" /> - <orderEntry type="module" module-name="preferences" /> <orderEntry type="module-library"> <library> <CLASSES> @@ -35,6 +35,15 @@ <orderEntry type="module-library"> <library> <CLASSES> + <root url="jar://$MODULE_DIR$/lib/junit-4.2.jar!/" /> + </CLASSES> + <JAVADOC /> + <SOURCES /> + </library> + </orderEntry> + <orderEntry type="module-library"> + <library> + <CLASSES> <root url="jar://$MODULE_DIR$/lib/jdom.jar!/" /> </CLASSES> <JAVADOC /> Modified: trunk/src/app/net/sf/gridarta/model/baseobject/GameObjectContainer.java =================================================================== --- trunk/src/app/net/sf/gridarta/model/baseobject/GameObjectContainer.java 2010-06-03 22:38:31 UTC (rev 8087) +++ trunk/src/app/net/sf/gridarta/model/baseobject/GameObjectContainer.java 2010-06-03 23:00:42 UTC (rev 8088) @@ -139,9 +139,12 @@ public void remove() { // keep this in sync with GameObjectContainer#remove(G) // we can't simply invoke GameObjectContainer#remove(current) because that would result in a ConcurrentModificationException. - delegate.remove(); notifyBeginChange(); try { + if (contents.size() >= 2 && contents.get(0) == current) { + contents.get(1).propagateElevation(current); + } + delegate.remove(); current.setContainer(null, 0, 0); } finally { notifyEndChange(); @@ -244,12 +247,12 @@ * @fixme this implementation does not take care of multi square objects. */ public void remove(@NotNull final G gameObject) { + // keep this in sync with iterator() notifyBeginChange(); try { if (contents.size() >= 2 && contents.get(0) == gameObject) { contents.get(1).propagateElevation(gameObject); } - // keep this in sync with iterator() if (!contents.remove(gameObject)) { throw new NotInsideContainerException(this, gameObject); } @@ -473,6 +476,9 @@ int index = 0; for (final G tmpGameObject : contents) { if (tmpGameObject.getHead() == previousGameObject) { + if (index == 0) { + gameObject.propagateElevation(contents.get(0)); + } contents.add(index, gameObject); added = true; break; @@ -491,25 +497,31 @@ /** * Add a GameObject before another. * @param gameObject GameObject to insert - * @param nextGameObject nextGameObject anchor + * @param nextGameObject nextGameObject anchor or <code>null</code> to add + * first * @throws IllegalArgumentException if <var>gameObject</var> already is * inside another container or <var>prev</var> isn't inside this container */ - public void insertBefore(@NotNull final G gameObject, @NotNull final G nextGameObject) { + public void insertBefore(@NotNull final G gameObject, @Nullable final G nextGameObject) { if (gameObject.isInContainer()) { throw new IllegalArgumentException("Can't add " + gameObject + " to " + this + " because it's already inside " + gameObject.getContainer()); } + if (nextGameObject == null) { + addFirst(gameObject); + return; + } + + if (!nextGameObject.isHead()) { + throw new IllegalArgumentException(); + } + notifyBeginChange(); try { final int insertIndex = contents.indexOf(nextGameObject); if (insertIndex == -1) { throw new IllegalArgumentException("Can't insert " + gameObject + " before " + nextGameObject + " because that isn't inside " + this); } - if (insertIndex == 0) { - assert contents.size() >= 1; - gameObject.propagateElevation(contents.get(0)); - } contents.add(insertIndex + 1, gameObject); setThisContainer(gameObject); } finally { @@ -625,7 +637,7 @@ * An iterator for iterating over a list in reverse order. * @todo move this class to JAPI */ - private static class ReverseIterator<T> implements Iterator<T> { + private static class ReverseIterator<T extends GameObject<?, ?, ?>> implements Iterator<T> { /** * The iterator used for delegation. @@ -634,10 +646,17 @@ private final ListIterator<T> delegate; /** + * The list being iterated over. + */ + @NotNull + private final List<T> list; + + /** * Create a reverse iterator. * @param list to iterate over in reverse order */ private ReverseIterator(@NotNull final List<T> list) { + this.list = list; delegate = list.listIterator(list.size()); } @@ -665,6 +684,9 @@ */ @Override public void remove() { + if (delegate.nextIndex() == 0 && list.size() >= 2) { + list.get(1).propagateElevation(list.get(0)); + } delegate.remove(); } Modified: trunk/src/app/net/sf/gridarta/model/gameobject/DefaultIsoGameObject.java =================================================================== --- trunk/src/app/net/sf/gridarta/model/gameobject/DefaultIsoGameObject.java 2010-06-03 22:38:31 UTC (rev 8087) +++ trunk/src/app/net/sf/gridarta/model/gameobject/DefaultIsoGameObject.java 2010-06-03 23:00:42 UTC (rev 8088) @@ -91,7 +91,7 @@ * {@inheritDoc} */ @Override - public void propagateElevation(@NotNull final BaseObject<G, A, R, ?> gameObject) { + public void propagateElevation(@NotNull final BaseObject<?, ?, ?, ?> gameObject) { } /** Modified: trunk/src/app/net/sf/gridarta/model/gameobject/GameObject.java =================================================================== --- trunk/src/app/net/sf/gridarta/model/gameobject/GameObject.java 2010-06-03 22:38:31 UTC (rev 8087) +++ trunk/src/app/net/sf/gridarta/model/gameobject/GameObject.java 2010-06-03 23:00:42 UTC (rev 8088) @@ -79,7 +79,7 @@ * If there is elevation data in the other game object, move it to here. * @param gameObject the other game object */ - void propagateElevation(@NotNull BaseObject<G, A, R, ?> gameObject); + void propagateElevation(@NotNull BaseObject<?, ?, ?, ?> gameObject); /** * {@inheritDoc} The Iterator returned does not recurse, it only contains Modified: trunk/src/test/net/sf/gridarta/model/gameobject/TestGameObject.java =================================================================== --- trunk/src/test/net/sf/gridarta/model/gameobject/TestGameObject.java 2010-06-03 22:38:31 UTC (rev 8087) +++ trunk/src/test/net/sf/gridarta/model/gameobject/TestGameObject.java 2010-06-03 23:00:42 UTC (rev 8088) @@ -83,7 +83,7 @@ * {@inheritDoc} */ @Override - public void propagateElevation(@NotNull final BaseObject<TestGameObject, TestMapArchObject, TestArchetype, ?> gameObject) { + public void propagateElevation(@NotNull final BaseObject<?, ?, ?, ?> gameObject) { // ignore } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |