From: <aki...@us...> - 2008-08-06 10:33:05
|
Revision: 4769 http://gridarta.svn.sourceforge.net/gridarta/?rev=4769&view=rev Author: akirschbaum Date: 2008-08-06 10:33:08 +0000 (Wed, 06 Aug 2008) Log Message: ----------- Split off model class GameObjectAttributesModel from GameObjectAttributesPanel. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/gui/ArchTab.java trunk/crossfire/src/cfeditor/gui/GameObjectAttributesPanel.java trunk/crossfire/src/cfeditor/gui/script/parameter/ArchComboBox.java trunk/crossfire/src/cfeditor/gui/script/parameter/ArchComboBoxEditor.java trunk/crossfire/src/cfeditor/gui/script/parameter/ArchParameterView.java trunk/crossfire/src/cfeditor/script/parameter/ArchParameter.java trunk/crossfire/src/cfeditor/script/parameter/PluginParameterFactory.java trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/gui/ArchTab.java trunk/daimonin/src/daieditor/gui/GameObjectAttributesPanel.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/AbstractGameObjectAttributesTab.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/AnimationTab.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/ArchTab.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/ConnectionsTab.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/GameObjectAttributesPanel.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/GameObjectAttributesTab.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/LockedItemsTab.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/MonstersTab.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/MsgTextTab.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/ScriptTab.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/WarningsTab.java Added Paths: ----------- trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/GameObjectAttributesModel.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/GameObjectAttributesModelListener.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-08-06 08:12:03 UTC (rev 4768) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-08-06 10:33:08 UTC (rev 4769) @@ -83,6 +83,7 @@ import net.sf.gridarta.gui.archetypechooser.ArchetypeChooserModel; import net.sf.gridarta.gui.connectionview.LockedItemsControl; import net.sf.gridarta.gui.gameobjectattributesdialog.GameObjectAttributesDialogFactory; +import net.sf.gridarta.gui.gameobjectattributespanel.GameObjectAttributesModel; import net.sf.gridarta.gui.map.MapCursorControl; import net.sf.gridarta.gui.map.MapView; import net.sf.gridarta.gui.map.tools.DeletionTool; @@ -325,8 +326,9 @@ // Initialize the main view final LockedItemsControl<GameObject, MapArchObject, Archetype, CMapViewBasic> lockedItemsControl = new LockedItemsControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(mapManager, 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); - gameObjectAttributesPanel = new GameObjectAttributesPanel(this, objectChooser, archetypeTypeSet, mapManager, animationObjects, lockedItemsControl, monsterMatcher, selectedSquareControl, selectedSquareView, mainView); - PluginParameterFactory.init(archetypeSet, gameObjectAttributesPanel, objectChooser, mapManager); + final GameObjectAttributesModel<GameObject, MapArchObject, Archetype> gameObjectAttributesModel = new GameObjectAttributesModel<GameObject, MapArchObject, Archetype>(); + gameObjectAttributesPanel = new GameObjectAttributesPanel(gameObjectAttributesModel, this, objectChooser, archetypeTypeSet, mapManager, animationObjects, lockedItemsControl, monsterMatcher, selectedSquareControl, selectedSquareView, mainView); + PluginParameterFactory.init(archetypeSet, gameObjectAttributesModel, objectChooser, mapManager); final NamedFilterList defaultNamedFilterList = new NamedFilterList(gameObjectMatchers.getFilters()); final CFilterControl filterControl = new CFilterControl(null, mapManager, defaultNamedFilterList); ((CrossfireObjectsFactory) gridartaObjectsFactory).setFilterControl(filterControl); Modified: trunk/crossfire/src/cfeditor/gui/ArchTab.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/ArchTab.java 2008-08-06 08:12:03 UTC (rev 4768) +++ trunk/crossfire/src/cfeditor/gui/ArchTab.java 2008-08-06 10:33:08 UTC (rev 4769) @@ -23,6 +23,7 @@ import cfeditor.gameobject.GameObject; import cfeditor.map.MapArchObject; import net.sf.gridarta.archtype.ArchetypeTypeSet; +import net.sf.gridarta.gui.gameobjectattributespanel.GameObjectAttributesModel; import org.jetbrains.annotations.NotNull; public class ArchTab extends net.sf.gridarta.gui.gameobjectattributespanel.ArchTab<GameObject, MapArchObject, Archetype> { @@ -30,9 +31,10 @@ /** * Creates a new instance. * @param archetypeTypeSet the archetype type set + * @param gameObjectAttributesModel the model to track */ - public ArchTab(@NotNull final ArchetypeTypeSet<GameObject, MapArchObject, Archetype> archetypeTypeSet) { - super(archetypeTypeSet); + public ArchTab(@NotNull final ArchetypeTypeSet<GameObject, MapArchObject, Archetype> archetypeTypeSet, @NotNull final GameObjectAttributesModel<GameObject, MapArchObject, Archetype> gameObjectAttributesModel) { + super(archetypeTypeSet, gameObjectAttributesModel); } /** {@inheritDoc} */ Modified: trunk/crossfire/src/cfeditor/gui/GameObjectAttributesPanel.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/GameObjectAttributesPanel.java 2008-08-06 08:12:03 UTC (rev 4768) +++ trunk/crossfire/src/cfeditor/gui/GameObjectAttributesPanel.java 2008-08-06 10:33:08 UTC (rev 4769) @@ -32,6 +32,7 @@ import net.sf.gridarta.gui.connectionview.LockedItemsControl; import net.sf.gridarta.gui.gameobjectattributespanel.AnimationTab; import net.sf.gridarta.gui.gameobjectattributespanel.ConnectionsTab; +import net.sf.gridarta.gui.gameobjectattributespanel.GameObjectAttributesModel; import net.sf.gridarta.gui.gameobjectattributespanel.LockedItemsTab; import net.sf.gridarta.gui.gameobjectattributespanel.MonstersTab; import net.sf.gridarta.gui.gameobjectattributespanel.MsgTextTab; @@ -55,16 +56,16 @@ private static final long serialVersionUID = 1L; /* Build Panel */ - public GameObjectAttributesPanel(@NotNull final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, @NotNull final ObjectChooser<GameObject, MapArchObject, Archetype> objectChooser, @NotNull final ArchetypeTypeSet<GameObject, MapArchObject, Archetype> archetypeTypeSet, final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, @NotNull final AnimationObjects<?> animationObjects, final LockedItemsControl<GameObject, MapArchObject, Archetype, CMapViewBasic> lockedItemsControl, @NotNull final GameObjectMatcher monsterMatcher, @NotNull final SelectedSquareControl<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareControl, @NotNull final SelectedSquareView<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareView, @NotNull final Frame parent) { - super(mainControl, objectChooser, mapManager, selectedSquareControl); - addTab(new ArchTab(archetypeTypeSet)); - addTab(new MsgTextTab<GameObject, MapArchObject, Archetype>()); - addTab(new ScriptTab<GameObject, MapArchObject, Archetype>(parent, mainControl)); - addTab(new AnimationTab<GameObject, MapArchObject, Archetype>(animationObjects)); - addTab(new ConnectionsTab<GameObject, MapArchObject, Archetype, CMapViewBasic>(mapManager)); - addTab(new LockedItemsTab<GameObject, MapArchObject, Archetype>(lockedItemsControl)); - addTab(new MonstersTab<GameObject, MapArchObject, Archetype, CMapViewBasic>(mapManager, monsterMatcher)); - addTab(new WarningsTab<GameObject, MapArchObject, Archetype, CMapViewBasic>(mapManager, selectedSquareView)); + public GameObjectAttributesPanel(final GameObjectAttributesModel<GameObject, MapArchObject, Archetype> gameObjectAttributesModel, @NotNull final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, @NotNull final ObjectChooser<GameObject, MapArchObject, Archetype> objectChooser, @NotNull final ArchetypeTypeSet<GameObject, MapArchObject, Archetype> archetypeTypeSet, final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, @NotNull final AnimationObjects<?> animationObjects, final LockedItemsControl<GameObject, MapArchObject, Archetype, CMapViewBasic> lockedItemsControl, @NotNull final GameObjectMatcher monsterMatcher, @NotNull final SelectedSquareControl<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareControl, @NotNull final SelectedSquareView<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareView, @NotNull final Frame parent) { + super(gameObjectAttributesModel, mainControl, objectChooser, mapManager, selectedSquareControl); + addTab(new ArchTab(archetypeTypeSet, gameObjectAttributesModel)); + addTab(new MsgTextTab<GameObject, MapArchObject, Archetype>(gameObjectAttributesModel)); + addTab(new ScriptTab<GameObject, MapArchObject, Archetype>(parent, mainControl, gameObjectAttributesModel)); + addTab(new AnimationTab<GameObject, MapArchObject, Archetype>(animationObjects, gameObjectAttributesModel)); + addTab(new ConnectionsTab<GameObject, MapArchObject, Archetype, CMapViewBasic>(mapManager, gameObjectAttributesModel)); + addTab(new LockedItemsTab<GameObject, MapArchObject, Archetype>(lockedItemsControl, gameObjectAttributesModel)); + addTab(new MonstersTab<GameObject, MapArchObject, Archetype, CMapViewBasic>(mapManager, monsterMatcher, gameObjectAttributesModel)); + addTab(new WarningsTab<GameObject, MapArchObject, Archetype, CMapViewBasic>(mapManager, selectedSquareView, gameObjectAttributesModel)); } } // class GameObjectAttributesPanel Modified: trunk/crossfire/src/cfeditor/gui/script/parameter/ArchComboBox.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/script/parameter/ArchComboBox.java 2008-08-06 08:12:03 UTC (rev 4768) +++ trunk/crossfire/src/cfeditor/gui/script/parameter/ArchComboBox.java 2008-08-06 10:33:08 UTC (rev 4769) @@ -22,11 +22,10 @@ import cfeditor.gameobject.Archetype; import cfeditor.gameobject.ArchetypeSet; import cfeditor.gameobject.GameObject; -import cfeditor.gui.map.CMapViewBasic; import cfeditor.map.MapArchObject; import java.awt.Dimension; import javax.swing.JComboBox; -import net.sf.gridarta.gui.gameobjectattributespanel.GameObjectAttributesPanel; +import net.sf.gridarta.gui.gameobjectattributespanel.GameObjectAttributesModel; import net.sf.gridarta.gui.objectchooser.ObjectChooser; import org.apache.log4j.Logger; import org.jetbrains.annotations.NotNull; @@ -42,10 +41,10 @@ private final ArchComboBoxModel archComboBoxModel; - public ArchComboBox(@NotNull final GameObjectAttributesPanel<GameObject, MapArchObject, Archetype, CMapViewBasic> gameObjectAttributesPanel, @NotNull final ArchetypeSet archetypeSet, @NotNull final ObjectChooser<GameObject, MapArchObject, Archetype> objectChooser) { + public ArchComboBox(@NotNull final GameObjectAttributesModel<GameObject, MapArchObject, Archetype> gameObjectAttributesModel, @NotNull final ArchetypeSet archetypeSet, @NotNull final ObjectChooser<GameObject, MapArchObject, Archetype> objectChooser) { setMaximumRowCount(4); archComboBoxModel = new ArchComboBoxModel(archetypeSet); - archComboBoxEditor = new ArchComboBoxEditor(this, archComboBoxModel, objectChooser, gameObjectAttributesPanel, archetypeSet); + archComboBoxEditor = new ArchComboBoxEditor(this, archComboBoxModel, objectChooser, gameObjectAttributesModel, archetypeSet); final MyCellRenderer cellRenderer = new MyCellRenderer(archComboBoxEditor, archetypeSet); //setPrototypeDisplayValue(cellRenderer.sizeTester); setRenderer(cellRenderer); Modified: trunk/crossfire/src/cfeditor/gui/script/parameter/ArchComboBoxEditor.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/script/parameter/ArchComboBoxEditor.java 2008-08-06 08:12:03 UTC (rev 4768) +++ trunk/crossfire/src/cfeditor/gui/script/parameter/ArchComboBoxEditor.java 2008-08-06 10:33:08 UTC (rev 4769) @@ -22,7 +22,6 @@ import cfeditor.gameobject.Archetype; import cfeditor.gameobject.ArchetypeSet; import cfeditor.gameobject.GameObject; -import cfeditor.gui.map.CMapViewBasic; import cfeditor.map.MapArchObject; import java.awt.Color; import java.awt.Component; @@ -44,7 +43,7 @@ import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentListener; import net.sf.gridarta.CommonConstants; -import net.sf.gridarta.gui.gameobjectattributespanel.GameObjectAttributesPanel; +import net.sf.gridarta.gui.gameobjectattributespanel.GameObjectAttributesModel; import net.sf.gridarta.gui.objectchooser.ObjectChooser; import org.jetbrains.annotations.Nullable; @@ -56,7 +55,7 @@ private final ObjectChooser<GameObject, MapArchObject, Archetype> objectChooser; - private final GameObjectAttributesPanel<GameObject, MapArchObject, Archetype, CMapViewBasic> gameObjectAttributesPanel; + private final GameObjectAttributesModel<GameObject, MapArchObject, Archetype> gameObjectAttributesModel; private final ArchetypeSet archetypeSet; @@ -70,11 +69,11 @@ private boolean locked = false; - public ArchComboBoxEditor(final ArchComboBox archComboBox, final ArchComboBoxModel archComboBoxModel, final ObjectChooser<GameObject, MapArchObject, Archetype> objectChooser, final GameObjectAttributesPanel<GameObject, MapArchObject, Archetype, CMapViewBasic> gameObjectAttributesPanel, final ArchetypeSet archetypeSet) { + public ArchComboBoxEditor(final ArchComboBox archComboBox, final ArchComboBoxModel archComboBoxModel, final ObjectChooser<GameObject, MapArchObject, Archetype> objectChooser, final GameObjectAttributesModel<GameObject, MapArchObject, Archetype> gameObjectAttributesModel, final ArchetypeSet archetypeSet) { this.archComboBox = archComboBox; this.archComboBoxModel = archComboBoxModel; this.objectChooser = objectChooser; - this.gameObjectAttributesPanel = gameObjectAttributesPanel; + this.gameObjectAttributesModel = gameObjectAttributesModel; this.archetypeSet = archetypeSet; } @@ -117,7 +116,7 @@ fromActive.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent e) { try { - final Archetype ao = archComboBoxModel.getNearsetMatch(gameObjectAttributesPanel.getSelectedGameObject().getArchetypeName()); + final Archetype ao = archComboBoxModel.getNearsetMatch(gameObjectAttributesModel.getSelectedGameObject().getArchetypeName()); archComboBox.setSelectedItem(ao); setItem(ao); } catch (final Exception ex) {//null pointer exception Modified: trunk/crossfire/src/cfeditor/gui/script/parameter/ArchParameterView.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/script/parameter/ArchParameterView.java 2008-08-06 08:12:03 UTC (rev 4768) +++ trunk/crossfire/src/cfeditor/gui/script/parameter/ArchParameterView.java 2008-08-06 10:33:08 UTC (rev 4769) @@ -22,7 +22,6 @@ import cfeditor.gameobject.Archetype; import cfeditor.gameobject.ArchetypeSet; import cfeditor.gameobject.GameObject; -import cfeditor.gui.map.CMapViewBasic; import cfeditor.map.MapArchObject; import cfeditor.script.parameter.ArchParameter; import cfeditor.script.parameter.PluginParameter; @@ -30,7 +29,7 @@ import java.awt.event.ItemListener; import javax.swing.JComponent; import javax.swing.JPanel; -import net.sf.gridarta.gui.gameobjectattributespanel.GameObjectAttributesPanel; +import net.sf.gridarta.gui.gameobjectattributespanel.GameObjectAttributesModel; import net.sf.gridarta.gui.objectchooser.ObjectChooser; import org.jetbrains.annotations.NotNull; @@ -50,8 +49,8 @@ return this.value; } - public ArchParameterView(final ArchParameter param, @NotNull final GameObjectAttributesPanel<GameObject, MapArchObject, Archetype, CMapViewBasic> gameObjectAttributesPanel, @NotNull final ArchetypeSet archetypeSet, @NotNull final ObjectChooser<GameObject, MapArchObject, Archetype> objectChooser) { - value = new ArchComboBox(gameObjectAttributesPanel, archetypeSet, objectChooser); + public ArchParameterView(final ArchParameter param, @NotNull final GameObjectAttributesModel<GameObject, MapArchObject, Archetype> gameObjectAttributesModel, @NotNull final ArchetypeSet archetypeSet, @NotNull final ObjectChooser<GameObject, MapArchObject, Archetype> objectChooser) { + value = new ArchComboBox(gameObjectAttributesModel, archetypeSet, objectChooser); parameter = param; value.setSelectedItem(param.getValue()); value.addItemListener(new ItemListener() { Modified: trunk/crossfire/src/cfeditor/script/parameter/ArchParameter.java =================================================================== --- trunk/crossfire/src/cfeditor/script/parameter/ArchParameter.java 2008-08-06 08:12:03 UTC (rev 4768) +++ trunk/crossfire/src/cfeditor/script/parameter/ArchParameter.java 2008-08-06 10:33:08 UTC (rev 4769) @@ -22,11 +22,10 @@ import cfeditor.gameobject.Archetype; import cfeditor.gameobject.ArchetypeSet; import cfeditor.gameobject.GameObject; -import cfeditor.gui.map.CMapViewBasic; import cfeditor.gui.script.parameter.ArchParameterView; import cfeditor.gui.script.parameter.PluginParameterView; import cfeditor.map.MapArchObject; -import net.sf.gridarta.gui.gameobjectattributespanel.GameObjectAttributesPanel; +import net.sf.gridarta.gui.gameobjectattributespanel.GameObjectAttributesModel; import net.sf.gridarta.gui.objectchooser.ObjectChooser; import org.jdom.Element; import org.jetbrains.annotations.NotNull; @@ -39,7 +38,7 @@ private String valueString; @NotNull - private static GameObjectAttributesPanel<GameObject, MapArchObject, Archetype, CMapViewBasic> gameObjectAttributesPanel; + private static GameObjectAttributesModel<GameObject, MapArchObject, Archetype> gameObjectAttributesModel; @NotNull private static ObjectChooser<GameObject, MapArchObject, Archetype> objectChooser; @@ -48,9 +47,9 @@ super(getParameterType()); } - public static void init(@NotNull final ArchetypeSet archetypeSet, @NotNull final GameObjectAttributesPanel<GameObject, MapArchObject, Archetype, CMapViewBasic> gameObjectAttributesPanel, @NotNull final ObjectChooser<GameObject, MapArchObject, Archetype> objectChooser) { + public static void init(@NotNull final ArchetypeSet archetypeSet, @NotNull final GameObjectAttributesModel<GameObject, MapArchObject, Archetype> gameObjectAttributesModel, @NotNull final ObjectChooser<GameObject, MapArchObject, Archetype> objectChooser) { ArchParameter.archetypeSet = archetypeSet; - ArchParameter.gameObjectAttributesPanel = gameObjectAttributesPanel; + ArchParameter.gameObjectAttributesModel = gameObjectAttributesModel; ArchParameter.objectChooser = objectChooser; } @@ -63,7 +62,7 @@ @Override public PluginParameterView getView() { - return new ArchParameterView(this, gameObjectAttributesPanel, archetypeSet, objectChooser); + return new ArchParameterView(this, gameObjectAttributesModel, archetypeSet, objectChooser); } @Override Modified: trunk/crossfire/src/cfeditor/script/parameter/PluginParameterFactory.java =================================================================== --- trunk/crossfire/src/cfeditor/script/parameter/PluginParameterFactory.java 2008-08-06 08:12:03 UTC (rev 4768) +++ trunk/crossfire/src/cfeditor/script/parameter/PluginParameterFactory.java 2008-08-06 10:33:08 UTC (rev 4769) @@ -27,7 +27,7 @@ import java.util.LinkedHashMap; import java.util.Map; import net.sf.gridarta.MapManager; -import net.sf.gridarta.gui.gameobjectattributespanel.GameObjectAttributesPanel; +import net.sf.gridarta.gui.gameobjectattributespanel.GameObjectAttributesModel; import net.sf.gridarta.gui.objectchooser.ObjectChooser; import org.apache.log4j.Logger; import org.jdom.Element; @@ -45,8 +45,8 @@ private static final Map<String, Class<? extends PluginParameter>> parameterTypes = new LinkedHashMap<String, Class<? extends PluginParameter>>(); - public static void init(@NotNull final ArchetypeSet archetypeSet, @NotNull final GameObjectAttributesPanel<GameObject, MapArchObject, Archetype, CMapViewBasic> gameObjectAttributesPanel, @NotNull final ObjectChooser<GameObject, MapArchObject, Archetype> objectChooser, @NotNull final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager) { - ArchParameter.init(archetypeSet, gameObjectAttributesPanel, objectChooser); + public static void init(@NotNull final ArchetypeSet archetypeSet, @NotNull final GameObjectAttributesModel<GameObject, MapArchObject, Archetype> gameObjectAttributesModel, @NotNull final ObjectChooser<GameObject, MapArchObject, Archetype> objectChooser, @NotNull final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager) { + ArchParameter.init(archetypeSet, gameObjectAttributesModel, objectChooser); MapParameter.init(mapManager); parameterTypes.put(StringParameter.getParameterType(), StringParameter.class); parameterTypes.put(IntegerParameter.getParameterType(), IntegerParameter.class); Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-08-06 08:12:03 UTC (rev 4768) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-08-06 10:33:08 UTC (rev 4769) @@ -91,6 +91,7 @@ import net.sf.gridarta.gui.archetypechooser.ArchetypeChooserModel; import net.sf.gridarta.gui.connectionview.LockedItemsControl; import net.sf.gridarta.gui.gameobjectattributesdialog.GameObjectAttributesDialogFactory; +import net.sf.gridarta.gui.gameobjectattributespanel.GameObjectAttributesModel; import net.sf.gridarta.gui.map.MapCursorControl; import net.sf.gridarta.gui.map.MapView; import net.sf.gridarta.gui.map.tools.DeletionTool; @@ -391,7 +392,8 @@ // Initialize the main view final LockedItemsControl<GameObject, MapArchObject, Archetype, CMapViewBasic> lockedItemsControl = new LockedItemsControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(mapManager, 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); - gameObjectAttributesPanel = new GameObjectAttributesPanel(this, objectChooser, archetypeTypeSet, mapManager, animationObjects, lockedItemsControl, monsterMatcher, selectedSquareControl, selectedSquareView, mainView); + final GameObjectAttributesModel<GameObject, MapArchObject, Archetype> gameObjectAttributesModel = new GameObjectAttributesModel<GameObject, MapArchObject, Archetype>(); + gameObjectAttributesPanel = new GameObjectAttributesPanel(gameObjectAttributesModel, this, objectChooser, archetypeTypeSet, mapManager, animationObjects, lockedItemsControl, monsterMatcher, selectedSquareControl, selectedSquareView, mainView); final ObjectChoiceDisplay<GameObject, MapArchObject, Archetype, CMapViewBasic> objectChoiceDisplay = new ObjectChoiceDisplay<GameObject, MapArchObject, Archetype, CMapViewBasic>(replaceDialogManager, archetypeTypeSet, objectChooser, archetypeChooserModel, pickmapChooserControl); final ToolPalette<GameObject, MapArchObject, Archetype, CMapViewBasic> toolPalette = new ToolPalette<GameObject, MapArchObject, Archetype, CMapViewBasic>(editTypes, selectedSquareView, objectChooser, pickmapChooserControl, copyBuffer); final LeftPanel leftPanel = new LeftPanel(objectChooser, toolPalette, objectChoiceDisplay); Modified: trunk/daimonin/src/daieditor/gui/ArchTab.java =================================================================== --- trunk/daimonin/src/daieditor/gui/ArchTab.java 2008-08-06 08:12:03 UTC (rev 4768) +++ trunk/daimonin/src/daieditor/gui/ArchTab.java 2008-08-06 10:33:08 UTC (rev 4769) @@ -23,6 +23,7 @@ import daieditor.gameobject.GameObject; import daieditor.map.MapArchObject; import net.sf.gridarta.archtype.ArchetypeTypeSet; +import net.sf.gridarta.gui.gameobjectattributespanel.GameObjectAttributesModel; import org.jetbrains.annotations.NotNull; public class ArchTab extends net.sf.gridarta.gui.gameobjectattributespanel.ArchTab<GameObject, MapArchObject, Archetype> { @@ -30,9 +31,10 @@ /** * Creates a new instance. * @param archetypeTypeSet the archetype type set + * @param gameObjectAttributesModel the model to track */ - public ArchTab(@NotNull final ArchetypeTypeSet<GameObject, MapArchObject, Archetype> archetypeTypeSet) { - super(archetypeTypeSet); + public ArchTab(@NotNull final ArchetypeTypeSet<GameObject, MapArchObject, Archetype> archetypeTypeSet, @NotNull final GameObjectAttributesModel<GameObject, MapArchObject, Archetype> gameObjectAttributesModel) { + super(archetypeTypeSet, gameObjectAttributesModel); } /** {@inheritDoc} */ Modified: trunk/daimonin/src/daieditor/gui/GameObjectAttributesPanel.java =================================================================== --- trunk/daimonin/src/daieditor/gui/GameObjectAttributesPanel.java 2008-08-06 08:12:03 UTC (rev 4768) +++ trunk/daimonin/src/daieditor/gui/GameObjectAttributesPanel.java 2008-08-06 10:33:08 UTC (rev 4769) @@ -32,6 +32,7 @@ import net.sf.gridarta.gui.connectionview.LockedItemsControl; import net.sf.gridarta.gui.gameobjectattributespanel.AnimationTab; import net.sf.gridarta.gui.gameobjectattributespanel.ConnectionsTab; +import net.sf.gridarta.gui.gameobjectattributespanel.GameObjectAttributesModel; import net.sf.gridarta.gui.gameobjectattributespanel.LockedItemsTab; import net.sf.gridarta.gui.gameobjectattributespanel.MonstersTab; import net.sf.gridarta.gui.gameobjectattributespanel.MsgTextTab; @@ -55,16 +56,16 @@ private static final long serialVersionUID = 1L; /* Build Panel */ - public GameObjectAttributesPanel(@NotNull final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, @NotNull final ObjectChooser<GameObject, MapArchObject, Archetype> objectChooser, @NotNull final ArchetypeTypeSet<GameObject, MapArchObject, Archetype> archetypeTypeSet, final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, @NotNull final AnimationObjects<?> animationObjects, final LockedItemsControl<GameObject, MapArchObject, Archetype, CMapViewBasic> lockedItemsControl, @NotNull final GameObjectMatcher monsterMatcher, @NotNull final SelectedSquareControl<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareControl, @NotNull final SelectedSquareView<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareView, @NotNull final Frame parent) { - super(mainControl, objectChooser, mapManager, selectedSquareControl); - addTab(new ArchTab(archetypeTypeSet)); - addTab(new MsgTextTab<GameObject, MapArchObject, Archetype>()); - addTab(new ScriptTab<GameObject, MapArchObject, Archetype>(parent, mainControl)); - addTab(new AnimationTab<GameObject, MapArchObject, Archetype>(animationObjects)); - addTab(new ConnectionsTab<GameObject, MapArchObject, Archetype, CMapViewBasic>(mapManager)); - addTab(new LockedItemsTab<GameObject, MapArchObject, Archetype>(lockedItemsControl)); - addTab(new MonstersTab<GameObject, MapArchObject, Archetype, CMapViewBasic>(mapManager, monsterMatcher)); - addTab(new WarningsTab<GameObject, MapArchObject, Archetype, CMapViewBasic>(mapManager, selectedSquareView)); + public GameObjectAttributesPanel(@NotNull final GameObjectAttributesModel<GameObject, MapArchObject, Archetype>gameObjectAttributesModel, @NotNull final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, @NotNull final ObjectChooser<GameObject, MapArchObject, Archetype> objectChooser, @NotNull final ArchetypeTypeSet<GameObject, MapArchObject, Archetype> archetypeTypeSet, final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, @NotNull final AnimationObjects<?> animationObjects, final LockedItemsControl<GameObject, MapArchObject, Archetype, CMapViewBasic> lockedItemsControl, @NotNull final GameObjectMatcher monsterMatcher, @NotNull final SelectedSquareControl<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareControl, @NotNull final SelectedSquareView<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareView, @NotNull final Frame parent) { + super(gameObjectAttributesModel, mainControl, objectChooser, mapManager, selectedSquareControl); + addTab(new ArchTab(archetypeTypeSet, gameObjectAttributesModel)); + addTab(new MsgTextTab<GameObject, MapArchObject, Archetype>(gameObjectAttributesModel)); + addTab(new ScriptTab<GameObject, MapArchObject, Archetype>(parent, mainControl, gameObjectAttributesModel)); + addTab(new AnimationTab<GameObject, MapArchObject, Archetype>(animationObjects, gameObjectAttributesModel)); + addTab(new ConnectionsTab<GameObject, MapArchObject, Archetype, CMapViewBasic>(mapManager, gameObjectAttributesModel)); + addTab(new LockedItemsTab<GameObject, MapArchObject, Archetype>(lockedItemsControl, gameObjectAttributesModel)); + addTab(new MonstersTab<GameObject, MapArchObject, Archetype, CMapViewBasic>(mapManager, monsterMatcher, gameObjectAttributesModel)); + addTab(new WarningsTab<GameObject, MapArchObject, Archetype, CMapViewBasic>(mapManager, selectedSquareView, gameObjectAttributesModel)); } } // class GameObjectAttributesPanel Modified: trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/AbstractGameObjectAttributesTab.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/AbstractGameObjectAttributesTab.java 2008-08-06 08:12:03 UTC (rev 4768) +++ trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/AbstractGameObjectAttributesTab.java 2008-08-06 10:33:08 UTC (rev 4769) @@ -26,6 +26,7 @@ import net.sf.gridarta.gameobject.GameObject; import net.sf.gridarta.map.MapArchObject; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * Base class for {@link GameObjectAttributesTab} implementations. @@ -60,6 +61,33 @@ private Color tabColor = TAB_COLOR_DEFAULT; /** + * The currently selected game object. + */ + @Nullable + private G gameObject = null; + + /** + * The listener attached to the tracked model. + */ + private final GameObjectAttributesModelListener<G, A, R> gameObjectAttributesModelListener = new GameObjectAttributesModelListener<G, A, R>() { + + /** {@inheritDoc} */ + public void selectedGameObjectChanged(@Nullable final G selectedGameObject) { + AbstractGameObjectAttributesTab.this.gameObject = selectedGameObject; + refresh(selectedGameObject); + } + + }; + + /** + * Creates a new instance. + * @param gameObjectAttributesModel the model to track + */ + protected AbstractGameObjectAttributesTab(@NotNull final GameObjectAttributesModel<G, A, R> gameObjectAttributesModel) { + gameObjectAttributesModel.addGameObjectAttributesModelListener(gameObjectAttributesModelListener); + } + + /** * Sets the tab color. * @param tabColor the tab color */ @@ -90,4 +118,21 @@ return tabColor; } + /** {@inheritDoc} */ + public final void apply() { + apply(gameObject); + } + + /** + * Refreshes the display. + * @param gameObject the game object to set the contents from + */ + protected abstract void refresh(@Nullable final G gameObject); + + /** + * Applies settings to the given game object. + * @param gameObject the game object to set the contents of + */ + protected abstract void apply(@Nullable final G gameObject); + } // class AbstractGameObjectAttributesTab Modified: trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/AnimationTab.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/AnimationTab.java 2008-08-06 08:12:03 UTC (rev 4768) +++ trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/AnimationTab.java 2008-08-06 10:33:08 UTC (rev 4769) @@ -46,9 +46,12 @@ /** * Creates a new instance. * @param animationObjects the animation objects + * @param gameObjectAttributesModel the model to track */ - public AnimationTab(@NotNull final AnimationObjects<?> animationObjects) { + public AnimationTab(@NotNull final AnimationObjects<?> animationObjects, @NotNull final GameObjectAttributesModel<G, A, R> gameObjectAttributesModel) { + super(gameObjectAttributesModel); this.animationObjects = animationObjects; + refresh(gameObjectAttributesModel.getSelectedGameObject()); } /** {@inheritDoc} */ @@ -67,7 +70,8 @@ } /** {@inheritDoc} */ - public void refresh(@Nullable final G gameObject) { + @Override + protected void refresh(@Nullable final G gameObject) { if (gameObject == null) { setTabColor(TAB_COLOR_DEFAULT); setAnimationName(null); @@ -93,7 +97,8 @@ } /** {@inheritDoc} */ - public void apply() { + @Override + protected void apply(@Nullable final G gameObject) { } /** Modified: trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/ArchTab.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/ArchTab.java 2008-08-06 08:12:03 UTC (rev 4768) +++ trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/ArchTab.java 2008-08-06 10:33:08 UTC (rev 4769) @@ -77,17 +77,19 @@ private final JToggleButton[] directionButtons = new JToggleButton[9]; /** - * The displayed game object. + * The panel consisting of the direction buttons. */ - @Nullable - private G selectedGameObject = null; + private final JPanel dirPanel = createDirPanel(); /** * Creates a new instance. * @param archetypeTypeSet the archetype type set + * @param gameObjectAttributesModel the model to track */ - protected ArchTab(@NotNull final ArchetypeTypeSet<G, A, R> archetypeTypeSet) { + protected ArchTab(@NotNull final ArchetypeTypeSet<G, A, R> archetypeTypeSet, @NotNull final GameObjectAttributesModel<G, A, R> gameObjectAttributesModel) { + super(gameObjectAttributesModel); this.archetypeTypeSet = archetypeTypeSet; + refresh(gameObjectAttributesModel.getSelectedGameObject()); } /** {@inheritDoc} */ @@ -148,29 +150,33 @@ gbc.gridwidth = 1; gbc.gridheight = 5; gbc.weightx = 0.0; - panel.add(createDirPanel(), gbc); + panel.add(dirPanel, gbc); return panel; } + /** + * Creates the panel consisting of the direction buttons. + * @return the panel + */ private JPanel createDirPanel() { - final JPanel dirPanel = new JPanel(new GridBagLayout()); + final JPanel panel = new JPanel(new GridBagLayout()); final GridBagConstraints gbc = new GridBagConstraints(); gbc.fill = GridBagConstraints.BOTH; gbc.anchor = GridBagConstraints.CENTER; gbc.insets = new Insets(2, 2, 2, 2); - createButton(7, dirPanel, gbc, 0, 0); - createButton(8, dirPanel, gbc, 1, 0); - createButton(1, dirPanel, gbc, 2, 0); - createButton(6, dirPanel, gbc, 0, 1); - createButton(0, dirPanel, gbc, 1, 1); - createButton(2, dirPanel, gbc, 2, 1); - createButton(5, dirPanel, gbc, 0, 2); - createButton(4, dirPanel, gbc, 1, 2); - createButton(3, dirPanel, gbc, 2, 2); + createButton(7, panel, gbc, 0, 0); + createButton(8, panel, gbc, 1, 0); + createButton(1, panel, gbc, 2, 0); + createButton(6, panel, gbc, 0, 1); + createButton(0, panel, gbc, 1, 1); + createButton(2, panel, gbc, 2, 1); + createButton(5, panel, gbc, 0, 2); + createButton(4, panel, gbc, 1, 2); + createButton(3, panel, gbc, 2, 2); - return dirPanel; + return panel; } /** @@ -193,35 +199,35 @@ } /** {@inheritDoc} */ - public void apply() { + @Override + protected void apply(@Nullable final G gameObject) { // We update all panels: name, face, msg and archText (more to come...) // the obj name: if (StringUtils.isNonwhitespaceText(archNameField.getText())) { // there is something in // if this equal the default name... - final R archetype = selectedGameObject.getArchetype(); + final R archetype = gameObject.getArchetype(); if (archetype.getObjName() != null) { if (archNameField.getText().compareTo(archetype.getObjName()) == 0) { - selectedGameObject.setObjName(null); // yes, we don't need it in map + gameObject.setObjName(null); // yes, we don't need it in map } else { - selectedGameObject.setObjName(archNameField.getText()); // overrule in map selectedGameObject + gameObject.setObjName(archNameField.getText()); // overrule in map gameObject } } else - if (archNameField.getText().compareTo(selectedGameObject.getArchetypeName()) == 0) { - selectedGameObject.setObjName(null); + if (archNameField.getText().compareTo(gameObject.getArchetypeName()) == 0) { + gameObject.setObjName(null); } else { // def is null, something is in panel, so we set it - selectedGameObject.setObjName(archNameField.getText()); // overrule in map selectedGameObject + gameObject.setObjName(archNameField.getText()); // overrule in map gameObject } } else { - selectedGameObject.setObjName(null); // nothing in, nothing in map selectedGameObject - // hm, there is no way yet to overrule a default selectedGameObject name with "nothing" + gameObject.setObjName(null); // nothing in, nothing in map gameObject + // hm, there is no way yet to overrule a default gameObject name with "nothing" // like <name > ore <name "">..?? } } /** {@inheritDoc} */ - public void refresh(@Nullable final G gameObject) { - selectedGameObject = gameObject; - + @Override + protected void refresh(@Nullable final G gameObject) { setTabColor(gameObject == null ? Color.black : Color.blue); // archNameField Modified: trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/ConnectionsTab.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/ConnectionsTab.java 2008-08-06 08:12:03 UTC (rev 4768) +++ trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/ConnectionsTab.java 2008-08-06 10:33:08 UTC (rev 4769) @@ -26,9 +26,12 @@ /** * Creates a new instance. * @param mapManager the map manager to use + * @param gameObjectAttributesModel the model to track */ - public ConnectionsTab(@NotNull final MapManager<G, A, R, V> mapManager) { + public ConnectionsTab(@NotNull final MapManager<G, A, R, V> mapManager, @NotNull final GameObjectAttributesModel<G, A, R> gameObjectAttributesModel) { + super(gameObjectAttributesModel); this.mapManager = mapManager; + refresh(gameObjectAttributesModel.getSelectedGameObject()); } /** {@inheritDoc} */ @@ -45,11 +48,13 @@ } /** {@inheritDoc} */ - public void refresh(@Nullable final G gameObject) { + @Override + protected void refresh(@Nullable final G gameObject) { } /** {@inheritDoc} */ - public void apply() { + @Override + protected void apply(@Nullable final G gameObject) { } } // class ConnectionsTab Added: trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/GameObjectAttributesModel.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/GameObjectAttributesModel.java (rev 0) +++ trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/GameObjectAttributesModel.java 2008-08-06 10:33:08 UTC (rev 4769) @@ -0,0 +1,88 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2007 The Gridarta Developers. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package net.sf.gridarta.gui.gameobjectattributespanel; + +import java.util.ArrayList; +import java.util.List; +import net.sf.gridarta.gameobject.Archetype; +import net.sf.gridarta.gameobject.GameObject; +import net.sf.gridarta.map.MapArchObject; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * The model of the game object attributes dialog. + * @author Andreas Kirschbaum + */ +public class GameObjectAttributesModel<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> { + + /** + * The selected game object. + */ + @Nullable + private G selectedGameObject = null; + + /** + * The registered listeners. + */ + private final List<GameObjectAttributesModelListener<G, A, R>> listeners = new ArrayList<GameObjectAttributesModelListener<G, A, R>>(); + + /** + * If a game object is selected, the MapArchPanels (bottom right windows) + * get updated. + * @param selectedGameObject the selected game object + */ + public void setSelectedGameObject(@Nullable final G selectedGameObject) { + if (this.selectedGameObject == selectedGameObject) { + return; + } + + this.selectedGameObject = selectedGameObject; + for (final GameObjectAttributesModelListener<G, A, R> listener : listeners) { + listener.selectedGameObjectChanged(selectedGameObject); + } + } + + /** + * Returns the selected game object. + * @return the selected game object + */ + @Nullable + public G getSelectedGameObject() { + return selectedGameObject; + } + + /** + * Adds a listener to be notified. + * @param listener the listener + */ + public void addGameObjectAttributesModelListener(@NotNull final GameObjectAttributesModelListener<G, A, R> listener) { + listeners.add(listener); + } + + /** + * Removes a listener to be notified. + * @param listener the listener + */ + public void removeGameObjectAttributesModelListener(@NotNull final GameObjectAttributesModelListener<G, A, R> listener) { + listeners.add(listener); + } + +} // class GameObjectAttributesModel Property changes on: trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/GameObjectAttributesModel.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF Added: trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/GameObjectAttributesModelListener.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/GameObjectAttributesModelListener.java (rev 0) +++ trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/GameObjectAttributesModelListener.java 2008-08-06 10:33:08 UTC (rev 4769) @@ -0,0 +1,39 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2007 The Gridarta Developers. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package net.sf.gridarta.gui.gameobjectattributespanel; + +import net.sf.gridarta.gameobject.Archetype; +import net.sf.gridarta.gameobject.GameObject; +import net.sf.gridarta.map.MapArchObject; +import org.jetbrains.annotations.Nullable; + +/** + * Listener for {@link GameObjectAttributesModel} related events. + * @author Andreas Kirschbaum + */ +public interface GameObjectAttributesModelListener<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> { + + /** + * Called whenever the selected game object has changed. + * @param selectedGameObject the selected game object + */ + void selectedGameObjectChanged(@Nullable G selectedGameObject); + +} // interface GameObjectAttributesModelListener Property changes on: trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/GameObjectAttributesModelListener.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF Modified: trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/GameObjectAttributesPanel.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/GameObjectAttributesPanel.java 2008-08-06 08:12:03 UTC (rev 4768) +++ trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/GameObjectAttributesPanel.java 2008-08-06 10:33:08 UTC (rev 4769) @@ -83,8 +83,10 @@ /** The tabs of this GameObjectAttributesPanel. */ private final JTabbedPane panelDesktop = new JTabbedPane(SwingConstants.TOP); - /** The selected game object. */ - private G selectedGameObject = null; + /** + * The model used by this controller. + */ + private final GameObjectAttributesModel<G, A, R> gameObjectAttributesModel; /** Last known active map. This map has {@link #mapModelListener} attached. */ @Nullable @@ -173,6 +175,7 @@ /** {@inheritDoc} */ public void mapSquaresChanged(final MapModelEvent<G, A, R> e) { + final G selectedGameObject = gameObjectAttributesModel.getSelectedGameObject(); if (selectedGameObject == null) { return; } @@ -189,6 +192,7 @@ /** {@inheritDoc} */ public void mapObjectsChanged(final MapModelEvent<G, A, R> e) { + final G selectedGameObject = gameObjectAttributesModel.getSelectedGameObject(); for (final G gameObject : e.getGameObjects()) { if (selectedGameObject == gameObject) { refreshDisplay(); @@ -208,12 +212,24 @@ /** {@inheritDoc} */ public void selectedGameObjectChanged(@Nullable final G gameObject) { - setSelectedGameObject(gameObject); + gameObjectAttributesModel.setSelectedGameObject(gameObject); } }; /** + * The listener attached to {@link #gameObjectAttributesModel}. + */ + private final GameObjectAttributesModelListener<G, A, R> gameObjectAttributesModelListener = new GameObjectAttributesModelListener<G, A, R>() { + + /** {@inheritDoc} */ + public void selectedGameObjectChanged(@Nullable final G selectedGameObject) { + refreshDisplay(); + } + + }; + + /** * The listener attached to all tabs. */ private final GameObjectAttributesTabListener<G, A, R> gameObjectAttributesTabListener = new GameObjectAttributesTabListener<G, A, R>() { @@ -227,14 +243,16 @@ /** * Create the GameObjectAttributesPanel. + * @param gameObjectAttributesModel the model to use * @param mainControl MainControl to use, e.g. for accessing * AnimationObjects. * @param objectChooser the object chooser instance * @param mapManager the map manager instance * @param selectedSquareControl the selected square control instance */ - protected GameObjectAttributesPanel(@NotNull final MainControl<G, A, R, V> mainControl, @NotNull final ObjectChooser<G, A, R> objectChooser, @NotNull final MapManager<G, A, R, V> mapManager, @NotNull final SelectedSquareControl<G, A, R, V> selectedSquareControl) { + protected GameObjectAttributesPanel(@NotNull final GameObjectAttributesModel<G, A, R> gameObjectAttributesModel, @NotNull final MainControl<G, A, R, V> mainControl, @NotNull final ObjectChooser<G, A, R> objectChooser, @NotNull final MapManager<G, A, R, V> mapManager, @NotNull final SelectedSquareControl<G, A, R, V> selectedSquareControl) { super(new BorderLayout()); + this.gameObjectAttributesModel = gameObjectAttributesModel; this.mainControl = mainControl; this.objectChooser = objectChooser; @@ -253,6 +271,7 @@ mapArchPanel.add(panelDesktop, BorderLayout.CENTER); selectedSquareControl.addSelectedSquareListener(selectedSquareListener); + gameObjectAttributesModel.addGameObjectAttributesModelListener(gameObjectAttributesModelListener); refreshDisplay(); currentMap = mapManager.getCurrentMap(); @@ -283,28 +302,9 @@ panelDesktop.setForegroundAt(tabIndex.get(tab), tabColor); } - /** - * Return the selected game object. - * @return the selected game object, or <code>null</code> if no game object - * is selected - */ - @Nullable - public G getSelectedGameObject() { - return selectedGameObject; - } - - /** - * If a game object is selected, the MapArchPanels (bottom right windows) - * get updated. - * @param selectedGameObject the selected game object - */ - private void setSelectedGameObject(@Nullable final G selectedGameObject) { - this.selectedGameObject = selectedGameObject; - refreshDisplay(); - } - - /** Update the displayed information for {@link #selectedGameObject}. */ + /** Update the displayed information for the selected game object. */ private void refreshDisplay() { + final G selectedGameObject = gameObjectAttributesModel.getSelectedGameObject(); final G gameObject = selectedGameObject == null ? null : selectedGameObject.getHead(); aMapArchApply.setEnabled(gameObject != null); @@ -312,14 +312,12 @@ aMapArchAttrib.setEnabled(gameObject != null); gameObjectTextEditor.refreshDisplay(gameObject); - for (final GameObjectAttributesTab<G, A, R> tab : tabs) { - tab.refresh(gameObject); - } } /** Action method for applying the changes made in the arch panel. */ @ActionMethod public void mapArchApply() { + final G selectedGameObject = gameObjectAttributesModel.getSelectedGameObject(); applyArchPanelChanges(selectedGameObject); } @@ -329,6 +327,7 @@ */ @ActionMethod public void mapArchAttrib() { + final G selectedGameObject = gameObjectAttributesModel.getSelectedGameObject(); mainControl.openAttrDialog(selectedGameObject); } @@ -343,6 +342,7 @@ return; } + final G selectedGameObject = gameObjectAttributesModel.getSelectedGameObject(); if (selectedGameObject == null) { return; } @@ -429,7 +429,7 @@ private void applyDirectionChanges(final G gameObject, final int dir) { gameObjectTextEditor.applyDirectionChanges(dir, gameObject.getArchetype().getDirection()); applyArchPanelChanges(gameObject); - setSelectedGameObject(gameObject); + gameObjectAttributesModel.setSelectedGameObject(gameObject); } /** @@ -437,6 +437,7 @@ * @param direction Direction number */ private void direction(final int direction) { + final G selectedGameObject = gameObjectAttributesModel.getSelectedGameObject(); applyDirectionChanges(selectedGameObject, direction); } Modified: trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/GameObjectAttributesTab.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/GameObjectAttributesTab.java 2008-08-06 08:12:03 UTC (rev 4768) +++ trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/GameObjectAttributesTab.java 2008-08-06 10:33:08 UTC (rev 4769) @@ -25,7 +25,6 @@ import net.sf.gridarta.gameobject.GameObject; import net.sf.gridarta.map.MapArchObject; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; /** * A tab in the game object attributes panel. @@ -48,15 +47,8 @@ JPanel getPanel(); /** - * Refresh the "Arch" tab in the Game Object Attributes Panel. - * @param gameObject The game object to set the contents from. + * Applies the current settings. */ - void refresh(@Nullable G gameObject); - - /** - * Applies the current settings the game object previously set by {@link - * #refresh(GameObject)}. - */ void apply(); /** Modified: trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/LockedItemsTab.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/LockedItemsTab.java 2008-08-06 08:12:03 UTC (rev 4768) +++ trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/LockedItemsTab.java 2008-08-06 10:33:08 UTC (rev 4769) @@ -43,9 +43,12 @@ /** * Creates a new instance. * @param lockedItemsControl the locked items control to display + * @param gameObjectAttributesModel the model to track */ - public LockedItemsTab(@NotNull final LockedItemsControl<G, A, R, ?> lockedItemsControl) { + public LockedItemsTab(@NotNull final LockedItemsControl<G, A, R, ?> lockedItemsControl, @NotNull final GameObjectAttributesModel<G, A, R> gameObjectAttributesModel) { + super(gameObjectAttributesModel); this.lockedItemsControl = lockedItemsControl; + refresh(gameObjectAttributesModel.getSelectedGameObject()); } /** {@inheritDoc} */ @@ -61,11 +64,13 @@ } /** {@inheritDoc} */ - public void refresh(@Nullable final G gameObject) { + @Override + protected void refresh(@Nullable final G gameObject) { } /** {@inheritDoc} */ - public void apply() { + @Override + protected void apply(@Nullable final G gameObject) { } } // class LockedItemsTab Modified: trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/MonstersTab.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/MonstersTab.java 2008-08-06 08:12:03 UTC (rev 4768) +++ trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/MonstersTab.java 2008-08-06 10:33:08 UTC (rev 4769) @@ -53,10 +53,13 @@ * Creates a new instance. * @param mapManager the map manager to use * @param monsterMatcher the matcher for matching monsters + * @param gameObjectAttributesModel the model to track */ - public MonstersTab(@NotNull final MapManager<G, A, R, V> mapManager, @NotNull final GameObjectMatcher monsterMatcher) { + public MonstersTab(@NotNull final MapManager<G, A, R, V> mapManager, @NotNull final GameObjectMatcher monsterMatcher, @NotNull final GameObjectAttributesModel<G, A, R> gameObjectAttributesModel) { + super(gameObjectAttributesModel); this.mapManager = mapManager; this.monsterMatcher = monsterMatcher; + refresh(gameObjectAttributesModel.getSelectedGameObject()); } /** {@inheritDoc} */ @@ -73,11 +76,12 @@ } /** {@inheritDoc} */ - public void refresh(@Nullable final G gameObject) { + @Override + protected void refresh(@Nullable final G gameObject) { } /** {@inheritDoc} */ - public void apply() { + protected void apply(@Nullable final G gameObject) { } } // class MonstersTab Modified: trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/MsgTextTab.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/MsgTextTab.java 2008-08-06 08:12:03 UTC (rev 4768) +++ trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/MsgTextTab.java 2008-08-06 10:33:08 UTC (rev 4769) @@ -46,16 +46,13 @@ private final JTextArea archTextArea = new JTextArea(4, 25); /** - * The displayed game object. - */ - @Nullable - private G selectedGameObject; - - /** * Creates a new instance. + * @param gameObjectAttributesModel the model to track */ - public MsgTextTab() { + public MsgTextTab(@NotNull final GameObjectAttributesModel<G, A, R> gameObjectAttributesModel) { + super(gameObjectAttributesModel); archTextArea.setLineWrap(true); + refresh(gameObjectAttributesModel.getSelectedGameObject()); } /** {@inheritDoc} */ @@ -81,9 +78,8 @@ } /** {@inheritDoc} */ - public void refresh(@Nullable final G gameObject) { - selectedGameObject = gameObject; - + @Override + protected void refresh(@Nullable final G gameObject) { final boolean hasMessage; if (gameObject == null) { archTextArea.setForeground(Color.black); @@ -112,8 +108,9 @@ } /** {@inheritDoc} */ - public void apply() { - final R archetype = selectedGameObject.getArchetype(); + @Override + protected void apply(@Nullable final G gameObject) { + final R archetype = gameObject.getArchetype(); // the msg TEXT!! ("msg ... endmsg") // if there is an entry in the archTextArea (msg window), this // overrules the default text (if any) @@ -127,19 +124,19 @@ newMsgText = ""; } if (newMsgText.equals(archetype.getMsgText().trim())) { - selectedGameObject.deleteMsgText(); // yes, we don't need it in map + gameObject.deleteMsgText(); // yes, we don't need it in map ... [truncated message content] |