From: <aki...@us...> - 2008-07-30 19:49:01
|
Revision: 4588 http://gridarta.svn.sourceforge.net/gridarta/?rev=4588&view=rev Author: akirschbaum Date: 2008-07-30 19:48:39 +0000 (Wed, 30 Jul 2008) Log Message: ----------- Split ArchetypeAttributeType and DialogAttrib classes into sub-classes, one for each archetype attribute type. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java trunk/daimonin/src/daieditor/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeParser.java trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeType.java trunk/src/app/net/sf/gridarta/archtype/ArchetypeTypeParser.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/AbstractGameObjectAttributesDialog.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/DialogAttrib.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/DialogAttribBitmask.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/MaskChangeAL.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/ViewTreasurelistAL.java Added Paths: ----------- trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeTypeAnimName.java trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeTypeBitmask.java trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeTypeBool.java trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeTypeBoolSpec.java trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeTypeDoubleList.java trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeTypeFaceName.java trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeTypeFactory.java trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeTypeFixed.java trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeTypeFloat.java trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeTypeInt.java trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeTypeInvSpell.java trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeTypeInvSpellOptional.java trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeTypeList.java trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeTypeLong.java trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeTypeMapPath.java trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeTypeScriptFile.java trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeTypeSpell.java trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeTypeString.java trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeTypeText.java trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeTypeTreasure.java trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeTypeVisitor.java trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeTypeZSpell.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/DialogAttribAnimName.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/DialogAttribBool.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/DialogAttribBoolSpec.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/DialogAttribDoubleList.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/DialogAttribFaceName.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/DialogAttribFloat.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/DialogAttribInt.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/DialogAttribInvSpell.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/DialogAttribInvSpellOptional.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/DialogAttribList.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/DialogAttribLong.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/DialogAttribMapPath.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/DialogAttribScriptFile.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/DialogAttribSpell.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/DialogAttribString.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/DialogAttribText.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/DialogAttribTreasure.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/DialogAttribZSpell.java Modified: trunk/crossfire/src/cfeditor/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java 2008-07-30 19:10:44 UTC (rev 4587) +++ trunk/crossfire/src/cfeditor/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java 2008-07-30 19:48:39 UTC (rev 4588) @@ -23,18 +23,14 @@ import cfeditor.gameobject.GameObject; import cfeditor.gui.map.CMapViewBasic; import cfeditor.map.MapArchObject; -import java.util.List; import java.util.Vector; -import javax.swing.JCheckBox; import javax.swing.JComboBox; -import javax.swing.JFormattedTextField; -import javax.swing.JTextField; import javax.swing.filechooser.FileFilter; -import javax.swing.text.JTextComponent; import net.sf.gridarta.MainControl; import net.sf.gridarta.MapManager; import net.sf.gridarta.archtype.ArchetypeAttribute; -import net.sf.gridarta.archtype.ArchetypeAttributeType; +import net.sf.gridarta.archtype.ArchetypeAttributeTypeFixed; +import net.sf.gridarta.archtype.ArchetypeAttributeTypeZSpell; import net.sf.gridarta.archtype.ArchetypeType; import net.sf.gridarta.archtype.ArchetypeTypeSet; import net.sf.gridarta.gameobject.ArchetypeSet; @@ -43,14 +39,10 @@ import net.sf.gridarta.gui.gameobjectattributesdialog.AbstractGameObjectAttributesDialog; import net.sf.gridarta.gui.gameobjectattributesdialog.AbstractGameObjectAttributesDialogFactory; import net.sf.gridarta.gui.gameobjectattributesdialog.DialogAttrib; -import net.sf.gridarta.gui.gameobjectattributesdialog.DialogAttribBitmask; import net.sf.gridarta.gui.gameobjectattributesdialog.StringKeyManager; -import net.sf.gridarta.gui.map.TilePanel; -import net.sf.gridarta.spells.GameObjectSpell; import net.sf.gridarta.spells.NumberSpell; import net.sf.gridarta.spells.Spell; import net.sf.gridarta.spells.Spells; -import net.sf.gridarta.textedit.textarea.JEditTextArea; import net.sf.gridarta.treasurelist.CFTreasureListTree; import org.jetbrains.annotations.NotNull; @@ -70,21 +62,11 @@ private final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager; /** - * The object type for event objects. - */ - private final int typeNoEventConnector; - - /** * The index used for "no" spell. */ private final int undefinedSpellIndex; /** - * Whether face names are included in the object text. - */ - private final boolean includeFaceText; - - /** * Constructor, creates the GUI layout. * @param gameObjectAttributesDialogFactory the associated factory * @param archetypeTypeSet the list of CF type-data @@ -102,11 +84,9 @@ * text */ public GameObjectAttributesDialog(@NotNull final AbstractGameObjectAttributesDialogFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> gameObjectAttributesDialogFactory, @NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final GameObject gameObject, @NotNull final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, @NotNull final ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final AnimationObjects<?> animationObjects, @NotNull final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, @NotNull final CFTreasureListTree<GameObject, MapArchObject, Archetype> treasureListTree, @NotNull final FaceObjects faceObjects, @NotNull final FileFilter mapFileFilter, final int typeNoEventConnector, final int undefinedSpellIndex, final boolean includeFaceText) { - super(gameObjectAttributesDialogFactory, archetypeTypeSet, gameObject, mainControl, archetypeSet, animationObjects, treasureListTree, faceObjects, mapFileFilter, typeNoEventConnector); + super(gameObjectAttributesDialogFactory, archetypeTypeSet, gameObject, mainControl, archetypeSet, animationObjects, treasureListTree, faceObjects, mapFileFilter, typeNoEventConnector, undefinedSpellIndex, includeFaceText); this.mapManager = mapManager; - this.typeNoEventConnector = typeNoEventConnector; this.undefinedSpellIndex = undefinedSpellIndex; - this.includeFaceText = includeFaceText; } /** {@inheritDoc} */ @@ -121,7 +101,7 @@ // do we have "none" spell? final int selectedIndex; - if (spnum == undefinedSpellIndex && attr.getDataType() == ArchetypeAttributeType.ZSPELL) { + if (spnum == undefinedSpellIndex && attr.getDataType() instanceof ArchetypeAttributeTypeZSpell) { selectedIndex = 0; } else { // now look up the spell-number in the array of spells @@ -156,304 +136,30 @@ return -1; } - /** - * This method is called when the "apply"-button has been pressed. All the - * settings from the dialog get written into the GameObject. - * @return true if the settings were applied, false if error occurred - */ + /** {@inheritDoc} */ @Override protected boolean applySettings2() { final ArchetypeType typeStruct = archetypeTypeSet.getTypeOfArch(gameObject); // the type structure for this gameObject final StringBuilder newArchText = new StringBuilder(); - String newName = null; - String newFace = null; - String newMsg = null; - for (final DialogAttrib<?> attr : dialogAttribs) { - final ArchetypeAttributeType dType = attr.ref.getDataType(); - - switch (dType) { - case BOOL: { - // a boolean attribute (flag) - if (((DialogAttrib<JCheckBox>) attr).getInput().isSelected() != (archetype.getAttributeInt(attr.ref.getNameOld()) == 1)) { - newArchText.append(attr.ref.getNameOld()).append(" ").append(((DialogAttrib<JCheckBox>) attr).getInput().isSelected() ? 1 : 0).append("\n"); - } + final String[] newName = new String[1]; + final String[] newFace = new String[1]; + final String[] newMsg = new String[1]; + final String[] newAnim = new String[1]; + for (final DialogAttrib<GameObject, MapArchObject, Archetype, ?> attr : dialogAttribs) { + final String text = attr.getText2(gameObject, archetype, newName, newFace, newMsg, newAnim, typeStruct, this); + if (text == null) { + return false; } - break; - case BOOL_SPEC: { - // a boolean attribute with customized true/false values - final String valString; // value-string to apply - if (((DialogAttrib<JCheckBox>) attr).getInput().isSelected()) { - valString = attr.ref.getMisc()[0]; // true string - } else { - valString = attr.ref.getMisc()[1]; // false string - } - // now see if we need to write it into the archtext or not - if ((valString.equals("0") && !(archetype.getAttributeString(attr.ref.getNameOld()).length() == 0)) || (!valString.equals("0") && !archetype.getAttributeString(attr.ref.getNameOld()).equals(valString))) { - newArchText.append(attr.ref.getNameOld()).append(" ").append(valString).append("\n"); - } + if (text.length() > 0) { + newArchText.append(text).append("\n"); } - break; - case INT: - case LONG: - case FLOAT: { - // an int attribute - if (dType == ArchetypeAttributeType.INT && ((DialogAttrib<JFormattedTextField>) attr).getInput().getText().trim().length() == 0) { - if (archetype.getAttributeInt(attr.ref.getNameOld()) != 0) { - newArchText.append(attr.ref.getNameOld()).append(" 0\n"); - } - } else - if (dType == ArchetypeAttributeType.LONG && ((DialogAttrib<JFormattedTextField>) attr).getInput().getText().trim().length() == 0) { - if (archetype.getAttributeLong(attr.ref.getNameOld()) != 0) { - newArchText.append(attr.ref.getNameOld()).append(" 0\n"); - } - } else - if (dType == ArchetypeAttributeType.FLOAT && ((DialogAttrib<JFormattedTextField>) attr).getInput().getText().trim().length() == 0) { - if (archetype.getAttributeString(attr.ref.getNameOld()).length() > 0) { - newArchText.append(attr.ref.getNameOld()).append(" 0.0\n"); - } - } else { - try { - switch (dType) { - case INT: { - final int value = ((Number) ((DialogAttrib<JFormattedTextField>) attr).getInput().getValue()).intValue(); - if (archetype.getAttributeInt(attr.ref.getNameOld()) != value) { - newArchText.append(attr.ref.getNameOld()).append(" ").append(value).append("\n"); - } - } - break; - case LONG: { - final long value = ((Number) ((DialogAttrib<JFormattedTextField>) attr).getInput().getValue()).longValue(); - if (archetype.getAttributeLong(attr.ref.getNameOld()) != value) { - newArchText.append(attr.ref.getNameOld()).append(" ").append(value).append("\n"); - } - } - break; - case FLOAT: { - final double value = ((Number) ((DialogAttrib<JFormattedTextField>) attr).getInput().getValue()).doubleValue(); - // The following floating point equality comparison is okay and known not to cause problems. - //noinspection FloatingPointEquality - if (archetype.getAttributeDouble(attr.ref.getNameOld()) != value) { - newArchText.append(attr.ref.getNameOld()).append(" ").append(value).append("\n"); - } - } - break; - default: - assert false; - break; - } - } catch (final NumberFormatException e) { - // parsing failed: wrong entry!! - showMessageDialog(this, "Attribute '" + attr.ref.getNameNew() + "' must be a number!", "Input Error", ERROR_MESSAGE); - return false; - } - } - } - break; - case STRING: - case FACENAME: - case ANIMNAME: { - // a String attribute - final String inline = ((DialogAttrib<JTextField>) attr).getInput().getText().trim(); - - if (inline != null) { - if (attr.ref.getNameOld().equalsIgnoreCase("name")) { - // special case #1: "name"-textfield - if (typeNoEventConnector != 0 && typeStruct.getTypeNo() == typeNoEventConnector) { - // events are special: they do not inherit the - // archetype name for empty names - newName = inline; - } else - if (archetype.getObjName() != null && archetype.getObjName().length() > 0) { - if (!inline.equals(archetype.getObjName())) { - newName = inline; - } else { - newName = ""; - } - } else - if (!inline.equals(archetype.getArchetypeName())) { - newName = inline; - } else { - newName = ""; - } - } else - if (attr.ref.getNameOld().equalsIgnoreCase("animation")) { - if (inline.length() > 0 && !inline.equals(archetype.getAttributeString(attr.ref.getNameOld()))) { - newArchText.append(attr.ref.getNameOld()).append(" ").append(inline).append("\n"); - gameObject.setAnimName(inline); - } else { - gameObject.setAnimName(archetype.getAnimName()); - } - } else if (attr.ref.getNameOld().equalsIgnoreCase("face")) { - if (includeFaceText && inline.length() > 0) { - // decide we have to add a "face <name>" string to the gameObject text - // Note, that the realFaceName itself is set below - if (archetype.getFaceName() == null || archetype.getFaceName().compareTo(inline.trim()) != 0) { - newArchText.append(attr.ref.getNameOld()).append(" ").append(inline).append("\n"); - } - } - newFace = inline; - } else { - if (!inline.equals(archetype.getAttributeString(attr.ref.getNameOld()))) { - newArchText.append(attr.ref.getNameOld()).append(" ").append(inline).append("\n"); - } - } - } - } - break; - case MAP_PATH: - case SCRIPT_FILE: { - final String newString = ((DialogAttrib<TilePanel>) attr).getInput().getText().trim(); - if (!archetype.getAttributeString(attr.ref.getNameOld()).equals(newString)) { - newArchText.append(attr.ref.getNameOld()).append(" ").append(newString).append("\n"); - } - } - break; - case TEXT: { - // a String attribute - if (attr.ref.getNameOld().equalsIgnoreCase("msg") && ((DialogAttrib<JEditTextArea>) attr).getInput().getText().trim().length() > 0) { - newMsg = ((DialogAttrib<JEditTextArea>) attr).getInput().getText().trim(); - } - } - break; - case SPELL: - case ZSPELL: - case LIST: { - // get attribute value that should go into the gameObject - final int attrVal; // attribute value - switch (dType) { - case SPELL: - case ZSPELL: - final int index = ((DialogAttrib<JComboBox>) attr).getInput().getSelectedIndex(); - attrVal = index == 0 ? undefinedSpellIndex : mainControl.getNumberSpells().getSpell(index - 1).getNumber(); - break; - case LIST: - // get selected index of ComboBox - final int attrValTmp = ((JComboBox) attr.getInput()).getSelectedIndex(); - // fetch value according to this list entry: - attrVal = ((List<Integer>) archetypeTypeSet.getListTable().get(attr.ref.getMisc()[0])).get(2 * attrValTmp); - break; - default: - assert false; - attrVal = 0; - break; - } - - if (archetype.getAttributeInt(attr.ref.getNameOld()) != attrVal) { - newArchText.append(attr.ref.getNameOld()).append(" ").append(attrVal).append("\n"); - } - } - break; - case INV_SPELL: - case INV_SPELL_OPTIONAL: { - final JComboBox comboBox = ((DialogAttrib<JComboBox>) attr).getInput(); - final int index = comboBox.getSelectedIndex(); - final boolean isOptionalSpell = dType == ArchetypeAttributeType.INV_SPELL_OPTIONAL; - if (index < mainControl.getGameObjectSpells().size() + (isOptionalSpell ? 1 : 0)) { - final boolean isModified; - switch (gameObject.countInvObjects()) { - case 0: - // game object has no inventory ==> isModified if - // anything other than <none> is selected - isModified = index != mainControl.getGameObjectSpells().size(); - break; - - default: - // game object has multiple inventories ==> always isModified - isModified = true; - break; - - case 1: - if (index >= mainControl.getGameObjectSpells().size()) { - // game object has one inventory, <none> is - // selected ==> isModified - isModified = true; - } else { - // game object has one inventory, a spell is - // selected ==> isModified if a different spell is - // selected - final GameObject invObject = gameObject.iterator().next(); - if (!invObject.isDefaultGameObject()) { - isModified = true; - } else { - final String invObjectArchetypeName = invObject.getArchetype().getArchetypeName(); - final GameObjectSpell<GameObject, MapArchObject, Archetype> spellObject = mainControl.getGameObjectSpells().getSpell(index); - isModified = !invObjectArchetypeName.equals(spellObject.getArchetypeName()); - } - } - break; - } - if (isModified) { - gameObject.removeAll(); - if (index < mainControl.getGameObjectSpells().size()) { - final GameObject spellObject = mainControl.getGameObjectSpells().getSpell(index).createGameObject(); - spellObject.postParseGameObject(0); - gameObject.addLast(spellObject); - } - - // remove the entry for a customized spell - final int modelSize = comboBox.getModel().getSize(); - if (modelSize > mainControl.getGameObjectSpells().size() + (isOptionalSpell ? 1 : 0)) { - comboBox.removeItemAt(modelSize - 1); - } - } - } - } - break; - case DBLLIST: { - final int val1 = ((List<Integer>) archetypeTypeSet.getListTable().get(attr.ref.getMisc()[0])).get(2 * ((JComboBox[]) attr.getInput())[0].getSelectedIndex()); - final int val2 = ((List<Integer>) archetypeTypeSet.getListTable().get(attr.ref.getMisc()[1])).get(2 * ((JComboBox[]) attr.getInput())[1].getSelectedIndex()); - final int combinedVal = val1 + val2; - - if (archetype.getAttributeInt(attr.ref.getNameOld()) != combinedVal) { - newArchText.append(attr.ref.getNameOld()).append(" ").append(combinedVal).append("\n"); - } - } - break; - case BITMASK: { - // a bitmask attribute (similar to integer, but easier because no parsing needed) - final String value = ((DialogAttribBitmask) attr).getEncodedValue(); // get bitmask value - String oldValue = archetype.getAttributeString(attr.ref.getNameOld()); - if (oldValue.length() == 0) { - oldValue = "0"; - } - - if (!oldValue.equals(value)) { - newArchText.append(attr.ref.getNameOld()).append(" ").append(value).append("\n"); - } - } - break; - case TREASURE: { - // a treasurelist attribute - final String inline = ((JTextComponent) attr.getInput()).getText().trim(); // input string - - if (inline != null) { - final boolean isNone = inline.equals(CFTreasureListTree.NONE_SYM) || inline.length() == 0; - - if (!isNone && !CFTreasureListTree.containsTreasureList(inline) && !inline.equalsIgnoreCase(archetype.getAttributeString(attr.ref.getNameOld()))) { - // The user has specified a WRONG treasurelist name, and it does not come - // from the default gameObject. -> Error and out. - showMessageDialog(this, "In attribute '" + attr.ref.getNameNew() + "':\n" + "'" + inline + "' is not a known treasurelist name!", "Input Error", ERROR_MESSAGE); - return false; - } - - if (!inline.equalsIgnoreCase(archetype.getAttributeString(attr.ref.getNameOld())) && !(isNone && archetype.getAttributeString(attr.ref.getNameOld()).length() == 0)) { - if (isNone) { - newArchText.append(attr.ref.getNameOld()).append(" none\n"); - } else { - newArchText.append(attr.ref.getNameOld()).append(" ").append(inline).append("\n"); - } - } - } - } - break; - } } // Also write all the 'fixed' attributes into the archtext for (int i = 0; type.getAttr().length > i; i++) { // ### TODO: for changed types, copy fixed attributes over default arches ### - if (type.getAttr()[i].getDataType() == ArchetypeAttributeType.FIXED) { + if (type.getAttr()[i].getDataType() instanceof ArchetypeAttributeTypeFixed) { final String defaultValue = archetype.getAttributeString(type.getAttr()[i].getNameOld()); if (defaultValue.length() == 0 || (gameObject.getArchTypNr() != archetype.getArchTypNr() && !defaultValue.equalsIgnoreCase(type.getAttr()[i].getNameNew()))) { // usually, fixed attributes are only applied when *not* defined in the archetype. @@ -480,27 +186,27 @@ // --- parsing succeeded, now we write it into the gameObject/map --- gameObject.setObjectText(newArchText.toString()); //gameObject.setArchTypNr(); - if (newName != null) { - if (newName.length() == 0) { + if (newName[0] != null) { + if (newName[0].length() == 0) { gameObject.setObjName(null); } else { - gameObject.setObjName(newName); + gameObject.setObjName(newName[0]); } } - if (newFace != null) { - gameObject.setRealFace(newFace); + if (newFace[0] != null) { + gameObject.setRealFace(newFace[0]); } // now lets assign the visible face - perhaps we have still a anim gameObject.setObjectFace(); imagePanel.setIcon(getFace(gameObject)); - if (newMsg != null) { + if (newMsg[0] != null) { // set new msg text only when it is not equal to Archetype - if (!newMsg.trim().equals(archetype.getMsgText() == null ? "" : archetype.getMsgText().trim())) { + if (!newMsg[0].trim().equals(archetype.getMsgText() == null ? "" : archetype.getMsgText().trim())) { gameObject.deleteMsgText(); - gameObject.addMsgText(newMsg); + gameObject.addMsgText(newMsg[0]); } else { gameObject.deleteMsgText(); } @@ -513,6 +219,10 @@ gameObject.deleteMsgText(); // all empty } + if (newAnim[0] != null) { + gameObject.setAnimName(newAnim[0]); + } + // deal with syntax errors now if (errors != null) { if (typeStruct == archetypeTypeSet.getArchetypeType(0)) { Modified: trunk/daimonin/src/daieditor/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java =================================================================== --- trunk/daimonin/src/daieditor/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java 2008-07-30 19:10:44 UTC (rev 4587) +++ trunk/daimonin/src/daieditor/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java 2008-07-30 19:48:39 UTC (rev 4588) @@ -23,18 +23,14 @@ import daieditor.gameobject.GameObject; import daieditor.gui.map.CMapViewBasic; import daieditor.map.MapArchObject; -import java.util.List; import java.util.Vector; -import javax.swing.JCheckBox; import javax.swing.JComboBox; -import javax.swing.JFormattedTextField; -import javax.swing.JTextField; import javax.swing.filechooser.FileFilter; -import javax.swing.text.JTextComponent; import net.sf.gridarta.MainControl; import net.sf.gridarta.MapManager; import net.sf.gridarta.archtype.ArchetypeAttribute; -import net.sf.gridarta.archtype.ArchetypeAttributeType; +import net.sf.gridarta.archtype.ArchetypeAttributeTypeFixed; +import net.sf.gridarta.archtype.ArchetypeAttributeTypeZSpell; import net.sf.gridarta.archtype.ArchetypeType; import net.sf.gridarta.archtype.ArchetypeTypeSet; import net.sf.gridarta.gameobject.ArchetypeSet; @@ -43,14 +39,10 @@ import net.sf.gridarta.gui.gameobjectattributesdialog.AbstractGameObjectAttributesDialog; import net.sf.gridarta.gui.gameobjectattributesdialog.AbstractGameObjectAttributesDialogFactory; import net.sf.gridarta.gui.gameobjectattributesdialog.DialogAttrib; -import net.sf.gridarta.gui.gameobjectattributesdialog.DialogAttribBitmask; import net.sf.gridarta.gui.gameobjectattributesdialog.StringKeyManager; -import net.sf.gridarta.gui.map.TilePanel; -import net.sf.gridarta.spells.GameObjectSpell; import net.sf.gridarta.spells.NumberSpell; import net.sf.gridarta.spells.Spell; import net.sf.gridarta.spells.Spells; -import net.sf.gridarta.textedit.textarea.JEditTextArea; import net.sf.gridarta.treasurelist.CFTreasureListTree; import org.jetbrains.annotations.NotNull; @@ -70,21 +62,11 @@ private final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager; /** - * The object type for event objects. - */ - private final int typeNoEventConnector; - - /** * The index used for "no" spell. */ private final int undefinedSpellIndex; /** - * Whether face names are included in the object text. - */ - private final boolean includeFaceText; - - /** * Constructor, creates the GUI layout. * @param gameObjectAttributesDialogFactory the associated factory * @param archetypeTypeSet the list of CF type-data @@ -102,11 +84,9 @@ * text */ public GameObjectAttributesDialog(@NotNull final AbstractGameObjectAttributesDialogFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> gameObjectAttributesDialogFactory, @NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final GameObject gameObject, @NotNull final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, @NotNull final ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final AnimationObjects<?> animationObjects, @NotNull final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, @NotNull final CFTreasureListTree<GameObject, MapArchObject, Archetype> treasureListTree, @NotNull final FaceObjects faceObjects, @NotNull final FileFilter mapFileFilter, final int typeNoEventConnector, final int undefinedSpellIndex, final boolean includeFaceText) { - super(gameObjectAttributesDialogFactory, archetypeTypeSet, gameObject, mainControl, archetypeSet, animationObjects, treasureListTree, faceObjects, mapFileFilter, typeNoEventConnector); + super(gameObjectAttributesDialogFactory, archetypeTypeSet, gameObject, mainControl, archetypeSet, animationObjects, treasureListTree, faceObjects, mapFileFilter, typeNoEventConnector, undefinedSpellIndex, includeFaceText); this.mapManager = mapManager; - this.typeNoEventConnector = typeNoEventConnector; this.undefinedSpellIndex = undefinedSpellIndex; - this.includeFaceText = includeFaceText; } /** {@inheritDoc} */ @@ -121,7 +101,7 @@ // do we have "none" spell? final int selectedIndex; - if (spnum == undefinedSpellIndex && attr.getDataType() == ArchetypeAttributeType.ZSPELL) { + if (spnum == undefinedSpellIndex && attr.getDataType() instanceof ArchetypeAttributeTypeZSpell) { selectedIndex = 0; } else { // now look up the spell-number in the array of spells @@ -156,304 +136,30 @@ return -1; } - /** - * This method is called when the "apply"-button has been pressed. All the - * settings from the dialog get written into the GameObject. - * @return true if the settings were applied, false if error occurred - */ + /** {@inheritDoc} */ @Override protected boolean applySettings2() { final ArchetypeType typeStruct = archetypeTypeSet.getTypeOfArch(gameObject); // the type structure for this gameObject final StringBuilder newArchText = new StringBuilder(); - String newName = null; - String newFace = null; - String newMsg = null; - for (final DialogAttrib<?> attr : dialogAttribs) { - final ArchetypeAttributeType dType = attr.ref.getDataType(); - - switch (dType) { - case BOOL: { - // a boolean attribute (flag) - if (((DialogAttrib<JCheckBox>) attr).getInput().isSelected() != (archetype.getAttributeInt(attr.ref.getNameOld()) == 1)) { - newArchText.append(attr.ref.getNameOld()).append(" ").append(((DialogAttrib<JCheckBox>) attr).getInput().isSelected() ? 1 : 0).append("\n"); - } + final String[] newName = new String[1]; + final String[] newFace = new String[1]; + final String[] newMsg = new String[1]; + final String[] newAnim = new String[1]; + for (final DialogAttrib<GameObject, MapArchObject, Archetype, ?> attr : dialogAttribs) { + final String text = attr.getText2(gameObject, archetype, newName, newFace, newMsg, newAnim, typeStruct, this); + if (text == null) { + return false; } - break; - case BOOL_SPEC: { - // a boolean attribute with customized true/false values - final String valString; // value-string to apply - if (((DialogAttrib<JCheckBox>) attr).getInput().isSelected()) { - valString = attr.ref.getMisc()[0]; // true string - } else { - valString = attr.ref.getMisc()[1]; // false string - } - // now see if we need to write it into the archtext or not - if ((valString.equals("0") && !(archetype.getAttributeString(attr.ref.getNameOld()).length() == 0)) || (!valString.equals("0") && !archetype.getAttributeString(attr.ref.getNameOld()).equals(valString))) { - newArchText.append(attr.ref.getNameOld()).append(" ").append(valString).append("\n"); - } + if (text.length() > 0) { + newArchText.append(text).append("\n"); } - break; - case INT: - case LONG: - case FLOAT: { - // an int attribute - if (dType == ArchetypeAttributeType.INT && ((DialogAttrib<JFormattedTextField>) attr).getInput().getText().trim().length() == 0) { - if (archetype.getAttributeInt(attr.ref.getNameOld()) != 0) { - newArchText.append(attr.ref.getNameOld()).append(" 0\n"); - } - } else - if (dType == ArchetypeAttributeType.LONG && ((DialogAttrib<JFormattedTextField>) attr).getInput().getText().trim().length() == 0) { - if (archetype.getAttributeLong(attr.ref.getNameOld()) != 0) { - newArchText.append(attr.ref.getNameOld()).append(" 0\n"); - } - } else - if (dType == ArchetypeAttributeType.FLOAT && ((DialogAttrib<JFormattedTextField>) attr).getInput().getText().trim().length() == 0) { - if (archetype.getAttributeString(attr.ref.getNameOld()).length() > 0) { - newArchText.append(attr.ref.getNameOld()).append(" 0.0\n"); - } - } else { - try { - switch (dType) { - case INT: { - final int value = ((Number) ((DialogAttrib<JFormattedTextField>) attr).getInput().getValue()).intValue(); - if (archetype.getAttributeInt(attr.ref.getNameOld()) != value) { - newArchText.append(attr.ref.getNameOld()).append(" ").append(value).append("\n"); - } - } - break; - case LONG: { - final long value = ((Number) ((DialogAttrib<JFormattedTextField>) attr).getInput().getValue()).longValue(); - if (archetype.getAttributeLong(attr.ref.getNameOld()) != value) { - newArchText.append(attr.ref.getNameOld()).append(" ").append(value).append("\n"); - } - } - break; - case FLOAT: { - final double value = ((Number) ((DialogAttrib<JFormattedTextField>) attr).getInput().getValue()).doubleValue(); - // The following floating point equality comparison is okay and known not to cause problems. - //noinspection FloatingPointEquality - if (archetype.getAttributeDouble(attr.ref.getNameOld()) != value) { - newArchText.append(attr.ref.getNameOld()).append(" ").append(value).append("\n"); - } - } - break; - default: - assert false; - break; - } - } catch (final NumberFormatException e) { - // parsing failed: wrong entry!! - showMessageDialog(this, "Attribute '" + attr.ref.getNameNew() + "' must be a number!", "Input Error", ERROR_MESSAGE); - return false; - } - } - } - break; - case STRING: - case FACENAME: - case ANIMNAME: { - // a String attribute - final String inline = ((DialogAttrib<JTextField>) attr).getInput().getText().trim(); - - if (inline != null) { - if (attr.ref.getNameOld().equalsIgnoreCase("name")) { - // special case #1: "name"-textfield - if (typeNoEventConnector != 0 && typeStruct.getTypeNo() == typeNoEventConnector) { - // events are special: they do not inherit the - // archetype name for empty names - newName = inline; - } else - if (archetype.getObjName() != null && archetype.getObjName().length() > 0) { - if (!inline.equals(archetype.getObjName())) { - newName = inline; - } else { - newName = ""; - } - } else - if (!inline.equals(archetype.getArchetypeName())) { - newName = inline; - } else { - newName = ""; - } - } else - if (attr.ref.getNameOld().equalsIgnoreCase("animation")) { - if (inline.length() > 0 && !inline.equals(archetype.getAttributeString(attr.ref.getNameOld()))) { - newArchText.append(attr.ref.getNameOld()).append(" ").append(inline).append("\n"); - gameObject.setAnimName(inline); - } else { - gameObject.setAnimName(archetype.getAnimName()); - } - } else if (attr.ref.getNameOld().equalsIgnoreCase("face")) { - if (includeFaceText && inline.length() > 0) { - // decide we have to add a "face <name>" string to the gameObject text - // Note, that the realFaceName itself is set below - if (archetype.getFaceName() == null || archetype.getFaceName().compareTo(inline.trim()) != 0) { - newArchText.append(attr.ref.getNameOld()).append(" ").append(inline).append("\n"); - } - } - newFace = inline; - } else { - if (!inline.equals(archetype.getAttributeString(attr.ref.getNameOld()))) { - newArchText.append(attr.ref.getNameOld()).append(" ").append(inline).append("\n"); - } - } - } - } - break; - case MAP_PATH: - case SCRIPT_FILE: { - final String newString = ((DialogAttrib<TilePanel>) attr).getInput().getText().trim(); - if (!archetype.getAttributeString(attr.ref.getNameOld()).equals(newString)) { - newArchText.append(attr.ref.getNameOld()).append(" ").append(newString).append("\n"); - } - } - break; - case TEXT: { - // a String attribute - if (attr.ref.getNameOld().equalsIgnoreCase("msg") && ((DialogAttrib<JEditTextArea>) attr).getInput().getText().trim().length() > 0) { - newMsg = ((DialogAttrib<JEditTextArea>) attr).getInput().getText().trim(); - } - } - break; - case SPELL: - case ZSPELL: - case LIST: { - // get attribute value that should go into the gameObject - final int attrVal; // attribute value - switch (dType) { - case SPELL: - case ZSPELL: - final int index = ((DialogAttrib<JComboBox>) attr).getInput().getSelectedIndex(); - attrVal = index == 0 ? undefinedSpellIndex : mainControl.getNumberSpells().getSpell(index - 1).getNumber(); - break; - case LIST: - // get selected index of ComboBox - final int attrValTmp = ((JComboBox) attr.getInput()).getSelectedIndex(); - // fetch value according to this list entry: - attrVal = ((List<Integer>) archetypeTypeSet.getListTable().get(attr.ref.getMisc()[0])).get(2 * attrValTmp); - break; - default: - assert false; - attrVal = 0; - break; - } - - if (archetype.getAttributeInt(attr.ref.getNameOld()) != attrVal) { - newArchText.append(attr.ref.getNameOld()).append(" ").append(attrVal).append("\n"); - } - } - break; - case INV_SPELL: - case INV_SPELL_OPTIONAL: { - final JComboBox comboBox = ((DialogAttrib<JComboBox>) attr).getInput(); - final int index = comboBox.getSelectedIndex(); - final boolean isOptionalSpell = dType == ArchetypeAttributeType.INV_SPELL_OPTIONAL; - if (index < mainControl.getGameObjectSpells().size() + (isOptionalSpell ? 1 : 0)) { - final boolean isModified; - switch (gameObject.countInvObjects()) { - case 0: - // game object has no inventory ==> isModified if - // anything other than <none> is selected - isModified = index != mainControl.getGameObjectSpells().size(); - break; - - default: - // game object has multiple inventories ==> always isModified - isModified = true; - break; - - case 1: - if (index >= mainControl.getGameObjectSpells().size()) { - // game object has one inventory, <none> is - // selected ==> isModified - isModified = true; - } else { - // game object has one inventory, a spell is - // selected ==> isModified if a different spell is - // selected - final GameObject invObject = gameObject.iterator().next(); - if (!invObject.isDefaultGameObject()) { - isModified = true; - } else { - final String invObjectArchetypeName = invObject.getArchetype().getArchetypeName(); - final GameObjectSpell<GameObject, MapArchObject, Archetype> spellObject = mainControl.getGameObjectSpells().getSpell(index); - isModified = !invObjectArchetypeName.equals(spellObject.getArchetypeName()); - } - } - break; - } - if (isModified) { - gameObject.removeAll(); - if (index < mainControl.getGameObjectSpells().size()) { - final GameObject spellObject = mainControl.getGameObjectSpells().getSpell(index).createGameObject(); - spellObject.postParseGameObject(0); - gameObject.addLast(spellObject); - } - - // remove the entry for a customized spell - final int modelSize = comboBox.getModel().getSize(); - if (modelSize > mainControl.getGameObjectSpells().size() + (isOptionalSpell ? 1 : 0)) { - comboBox.removeItemAt(modelSize - 1); - } - } - } - } - break; - case DBLLIST: { - final int val1 = ((List<Integer>) archetypeTypeSet.getListTable().get(attr.ref.getMisc()[0])).get(2 * ((JComboBox[]) attr.getInput())[0].getSelectedIndex()); - final int val2 = ((List<Integer>) archetypeTypeSet.getListTable().get(attr.ref.getMisc()[1])).get(2 * ((JComboBox[]) attr.getInput())[1].getSelectedIndex()); - final int combinedVal = val1 + val2; - - if (archetype.getAttributeInt(attr.ref.getNameOld()) != combinedVal) { - newArchText.append(attr.ref.getNameOld()).append(" ").append(combinedVal).append("\n"); - } - } - break; - case BITMASK: { - // a bitmask attribute (similar to integer, but easier because no parsing needed) - final String value = ((DialogAttribBitmask) attr).getEncodedValue(); // get bitmask value - String oldValue = archetype.getAttributeString(attr.ref.getNameOld()); - if (oldValue.length() == 0) { - oldValue = "0"; - } - - if (!oldValue.equals(value)) { - newArchText.append(attr.ref.getNameOld()).append(" ").append(value).append("\n"); - } - } - break; - case TREASURE: { - // a treasurelist attribute - final String inline = ((JTextComponent) attr.getInput()).getText().trim(); // input string - - if (inline != null) { - final boolean isNone = inline.equals(CFTreasureListTree.NONE_SYM) || inline.length() == 0; - - if (!isNone && !CFTreasureListTree.containsTreasureList(inline) && !inline.equalsIgnoreCase(archetype.getAttributeString(attr.ref.getNameOld()))) { - // The user has specified a WRONG treasurelist name, and it does not come - // from the default gameObject. -> Error and out. - showMessageDialog(this, "In attribute '" + attr.ref.getNameNew() + "':\n" + "'" + inline + "' is not a known treasurelist name!", "Input Error", ERROR_MESSAGE); - return false; - } - - if (!inline.equalsIgnoreCase(archetype.getAttributeString(attr.ref.getNameOld())) && !(isNone && archetype.getAttributeString(attr.ref.getNameOld()).length() == 0)) { - if (isNone) { - newArchText.append(attr.ref.getNameOld()).append(" none\n"); - } else { - newArchText.append(attr.ref.getNameOld()).append(" ").append(inline).append("\n"); - } - } - } - } - break; - } } // Also write all the 'fixed' attributes into the archtext for (int i = 0; type.getAttr().length > i; i++) { // ### TODO: for changed types, copy fixed attributes over default arches ### - if (type.getAttr()[i].getDataType() == ArchetypeAttributeType.FIXED) { + if (type.getAttr()[i].getDataType() instanceof ArchetypeAttributeTypeFixed) { final String defaultValue = archetype.getAttributeString(type.getAttr()[i].getNameOld()); if (defaultValue.length() == 0 || (gameObject.getArchTypNr() != archetype.getArchTypNr() && !defaultValue.equalsIgnoreCase(type.getAttr()[i].getNameNew()))) { // usually, fixed attributes are only applied when *not* defined in the archetype. @@ -480,27 +186,27 @@ // --- parsing succeeded, now we write it into the gameObject/map --- gameObject.setObjectText(newArchText.toString()); //gameObject.setArchTypNr(); - if (newName != null) { - if (newName.length() == 0) { + if (newName[0] != null) { + if (newName[0].length() == 0) { gameObject.setObjName(null); } else { - gameObject.setObjName(newName); + gameObject.setObjName(newName[0]); } } - if (newFace != null) { - gameObject.setRealFace(newFace); + if (newFace[0] != null) { + gameObject.setRealFace(newFace[0]); } // now lets assign the visible face - perhaps we have still a anim gameObject.setObjectFace(); imagePanel.setIcon(getFace(gameObject)); - if (newMsg != null) { + if (newMsg[0] != null) { // set new msg text only when it is not equal to Archetype - if (!newMsg.trim().equals(archetype.getMsgText() == null ? "" : archetype.getMsgText().trim())) { + if (!newMsg[0].trim().equals(archetype.getMsgText() == null ? "" : archetype.getMsgText().trim())) { gameObject.deleteMsgText(); - gameObject.addMsgText(newMsg); + gameObject.addMsgText(newMsg[0]); } else { gameObject.deleteMsgText(); } @@ -513,6 +219,10 @@ gameObject.deleteMsgText(); // all empty } + if (newAnim[0] != null) { + gameObject.setAnimName(newAnim[0]); + } + // deal with syntax errors now if (errors != null) { if (typeStruct == archetypeTypeSet.getArchetypeType(0)) { Modified: trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeParser.java =================================================================== --- trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeParser.java 2008-07-30 19:10:44 UTC (rev 4587) +++ trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeParser.java 2008-07-30 19:48:39 UTC (rev 4588) @@ -110,10 +110,10 @@ // which type of attribute is it? if (atype.equalsIgnoreCase("bool")) { - dataType = ArchetypeAttributeType.BOOL; // normal bool + dataType = ArchetypeAttributeTypeFactory.BOOL; // normal bool } else if (atype.equalsIgnoreCase("bool_special")) { // customized boolean type: - dataType = ArchetypeAttributeType.BOOL_SPEC; + dataType = ArchetypeAttributeTypeFactory.BOOL_SPEC; // parse true and false values: a1 = root.getAttributeNode("true"); @@ -127,23 +127,23 @@ misc[0] = a1.getValue().trim(); // string for true misc[1] = a2.getValue().trim(); // string for false } else if (atype.equalsIgnoreCase("int")) { - dataType = ArchetypeAttributeType.INT; + dataType = ArchetypeAttributeTypeFactory.INT; } else if (atype.equalsIgnoreCase("long")) { - dataType = ArchetypeAttributeType.LONG; + dataType = ArchetypeAttributeTypeFactory.LONG; } else if (atype.equalsIgnoreCase("float")) { - dataType = ArchetypeAttributeType.FLOAT; + dataType = ArchetypeAttributeTypeFactory.FLOAT; } else if (atype.equalsIgnoreCase("string")) { - dataType = ArchetypeAttributeType.STRING; + dataType = ArchetypeAttributeTypeFactory.STRING; } else if (atype.equalsIgnoreCase("map_path")) { - dataType = ArchetypeAttributeType.MAP_PATH; + dataType = ArchetypeAttributeTypeFactory.MAP_PATH; } else if (atype.equalsIgnoreCase("script_file")) { - dataType = ArchetypeAttributeType.SCRIPT_FILE; + dataType = ArchetypeAttributeTypeFactory.SCRIPT_FILE; } else if (atype.equalsIgnoreCase("facename")) { - dataType = ArchetypeAttributeType.FACENAME; + dataType = ArchetypeAttributeTypeFactory.FACENAME; } else if (atype.equalsIgnoreCase("animname")) { - dataType = ArchetypeAttributeType.ANIMNAME; + dataType = ArchetypeAttributeTypeFactory.ANIMNAME; } else if (atype.equalsIgnoreCase("text")) { - dataType = ArchetypeAttributeType.TEXT; + dataType = ArchetypeAttributeTypeFactory.TEXT; // for text data, the terminating string has to be read too if ((a1 = root.getAttributeNode(XML_KEY_ARCH_BEGIN)) != null) { nameOld = a1.getValue().trim(); @@ -164,7 +164,7 @@ } } else if ("fixed".equalsIgnoreCase(atype)) { // fixed attribute - dataType = ArchetypeAttributeType.FIXED; + dataType = ArchetypeAttributeTypeFactory.FIXED; if ((a1 = root.getAttributeNode("value")) != null) { nameNew = a1.getValue().trim(); } else { @@ -173,23 +173,23 @@ } } else if ("spell".equalsIgnoreCase(atype)) { // spell attribute - dataType = ArchetypeAttributeType.SPELL; + dataType = ArchetypeAttributeTypeFactory.SPELL; } else if ("nz_spell".equalsIgnoreCase(atype)) { // spell attribute - dataType = ArchetypeAttributeType.ZSPELL; + dataType = ArchetypeAttributeTypeFactory.ZSPELL; } else if ("inv_spell".equalsIgnoreCase(atype)) { // spell attribute - dataType = ArchetypeAttributeType.INV_SPELL; + dataType = ArchetypeAttributeTypeFactory.INV_SPELL; } else if ("inv_spell_optional".equalsIgnoreCase(atype)) { // spell attribute - dataType = ArchetypeAttributeType.INV_SPELL_OPTIONAL; + dataType = ArchetypeAttributeTypeFactory.INV_SPELL_OPTIONAL; } else if (atype.startsWith("bitmask")) { // got a bitmask attribute final String bitmaskName = atype.substring(8).trim(); if (tlist.getBitmaskTable().containsKey(bitmaskName)) { // the bitmask is well defined - dataType = ArchetypeAttributeType.BITMASK; + dataType = ArchetypeAttributeTypeFactory.BITMASK; misc = new String[1]; misc[0] = bitmaskName; // store bitmask name in misc[0] } else { @@ -201,7 +201,7 @@ final String listName = atype.substring(5).trim(); if (tlist.getListTable().containsKey(listName)) { // the list is well defined - dataType = ArchetypeAttributeType.LIST; + dataType = ArchetypeAttributeTypeFactory.LIST; misc = new String[1]; misc[0] = listName; // store list name in misc[0] } else { @@ -223,7 +223,7 @@ if (tlist.getListTable().containsKey(listName1) && tlist.getListTable().containsKey(listName2)) { // the lists are well defined - dataType = ArchetypeAttributeType.DBLLIST; + dataType = ArchetypeAttributeTypeFactory.DBLLIST; misc = new String[2]; misc[0] = listName1; // store list name in misc[0] misc[1] = listName2; // store list name in misc[1] @@ -231,7 +231,7 @@ log.error("In '" + CommonConstants.TYPEDEF_FILE + "', type " + typeName + ": List \"" + listName1 + "\" or \"" + listName2 + "\" is undefined."); } } else if ("treasurelist".equalsIgnoreCase(atype)) { - dataType = ArchetypeAttributeType.TREASURE; + dataType = ArchetypeAttributeTypeFactory.TREASURE; } else { // unknown type log.warn("In '" + CommonConstants.TYPEDEF_FILE + "': Type " + typeName + " has an attribute with unknown type: '" + atype + "'."); Modified: trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeType.java =================================================================== --- trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeType.java 2008-07-30 19:10:44 UTC (rev 4587) +++ trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeType.java 2008-07-30 19:48:39 UTC (rev 4588) @@ -23,66 +23,8 @@ * Enumeration for Archetype Attribute Types. * @author <a href="mailto:ch...@ri...">Christian Hujer</a> */ -public enum ArchetypeAttributeType { +public interface ArchetypeAttributeType { - /** Boolean -> Checkbox. */ - BOOL, + void accept(ArchetypeAttributeTypeVisitor visitor); - /** Boolean -> Checkbox, with customized true/false values. */ - BOOL_SPEC, - - /** Integer -> Textfield. */ - INT, - - /** Long -> Textfield. */ - LONG, - - /** Float -> Textfield. */ - FLOAT, - - /** String -> Textfield. */ - STRING, - - /** Map path name. */ - MAP_PATH, - - /** Script file n... [truncated message content] |