From: <aki...@us...> - 2008-07-26 05:48:26
|
Revision: 4459 http://gridarta.svn.sourceforge.net/gridarta/?rev=4459&view=rev Author: akirschbaum Date: 2008-07-26 05:48:33 +0000 (Sat, 26 Jul 2008) Log Message: ----------- Remove calls to MainControl.getArchetypeSet(). Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/daimonin/src/daieditor/CMainControl.java trunk/src/app/net/sf/gridarta/gui/archetypechooser/ArchetypeChooserControl.java trunk/src/app/net/sf/gridarta/gui/archetypechooser/ArchetypePanel.java trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-07-26 05:35:52 UTC (rev 4458) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-07-26 05:48:33 UTC (rev 4459) @@ -224,7 +224,7 @@ ACTION_FACTORY.createActions(true, this, "createNew", "open", "options", "exit", "newScript", "editScript", "zoom", "gc", "onlineHelp", "tod", "about"); final MapManagerActions<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManagerActions = new MapManagerActions<GameObject, MapArchObject, Archetype, CMapViewBasic>(getMapManager()); PathManager.setGlobalSettings(globalSettings); - final ArchetypeChooserControl<GameObject, MapArchObject, Archetype, CMapViewBasic> archetypeChooserControl = new ArchetypeChooserControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(this, false); + final ArchetypeChooserControl<GameObject, MapArchObject, Archetype, CMapViewBasic> archetypeChooserControl = new ArchetypeChooserControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(this, archetypeSet, false); newMapDialogFactory = new NewMapDialogFactory<GameObject, MapArchObject, Archetype, CMapViewBasic>(this, IGUIConstants.DEF_MAPSIZE, IGUIConstants.DEF_MAPSIZE, 0, false, false, IGUIConstants.DEF_PICKMAP_WIDTH, IGUIConstants.DEF_PICKMAP_HEIGHT); pickmapChooserControl = new PickmapChooserControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(newMapDialogFactory, this, new File(globalSettings.getMapDir(), IGUIConstants.PICKMAP_DIR), getMapManager()); newMapDialogFactory.setPickmapChooserControl(pickmapChooserControl); Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-07-26 05:35:52 UTC (rev 4458) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-07-26 05:48:33 UTC (rev 4459) @@ -281,7 +281,7 @@ ACTION_FACTORY.createAction(true, "collectSpells", this); final MapManagerActions<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManagerActions = new MapManagerActions<GameObject, MapArchObject, Archetype, CMapViewBasic>(getMapManager()); PathManager.setGlobalSettings(globalSettings); - final ArchetypeChooserControl<GameObject, MapArchObject, Archetype, CMapViewBasic> archetypeChooserControl = new ArchetypeChooserControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(this, true); + final ArchetypeChooserControl<GameObject, MapArchObject, Archetype, CMapViewBasic> archetypeChooserControl = new ArchetypeChooserControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(this, archetypeSet, true); newMapDialogFactory = new NewMapDialogFactory<GameObject, MapArchObject, Archetype, CMapViewBasic>(this, IGUIConstants.DEF_MAPSIZE, IGUIConstants.DEF_MAPSIZE, IGUIConstants.DEF_MAPDIFFICULTY, true, true, IGUIConstants.DEF_PICKMAP_WIDTH, IGUIConstants.DEF_PICKMAP_HEIGHT); pickmapChooserControl = new PickmapChooserControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(newMapDialogFactory, this, new File(globalSettings.getArchDefaultFolder(), IGUIConstants.PICKMAP_DIR), getMapManager()); newMapDialogFactory.setPickmapChooserControl(pickmapChooserControl); Modified: trunk/src/app/net/sf/gridarta/gui/archetypechooser/ArchetypeChooserControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/archetypechooser/ArchetypeChooserControl.java 2008-07-26 05:35:52 UTC (rev 4458) +++ trunk/src/app/net/sf/gridarta/gui/archetypechooser/ArchetypeChooserControl.java 2008-07-26 05:48:33 UTC (rev 4459) @@ -39,6 +39,7 @@ import net.sf.gridarta.CommonConstants; import net.sf.gridarta.MainControl; import net.sf.gridarta.gameobject.Archetype; +import net.sf.gridarta.gameobject.ArchetypeSet; import net.sf.gridarta.gameobject.GameObject; import net.sf.gridarta.gui.map.MapViewBasic; import net.sf.gridarta.map.InsertionMode; @@ -66,6 +67,12 @@ private final MainControl<G, A, R, V> mainControl; /** + * The archetype set to display. + */ + @NotNull + private final ArchetypeSet<G, A, R> archetypeSet; + + /** * Name of the selected archetype. * @serial include */ @@ -98,10 +105,12 @@ /** * Create a new instance. * @param mainControl The main control. + * @param archetypeSet the archetype set to display * @param createDirectionPane Whether to create a "direction" panel. */ - public ArchetypeChooserControl(@NotNull final MainControl<G, A, R, V> mainControl, final boolean createDirectionPane) { + public ArchetypeChooserControl(@NotNull final MainControl<G, A, R, V> mainControl, @NotNull final ArchetypeSet<G, A, R> archetypeSet, final boolean createDirectionPane) { this.mainControl = mainControl; + this.archetypeSet = archetypeSet; tabDesktop.setBorder(BorderFactory.createEmptyBorder(CommonConstants.SPACE_PICKARCH_TOP, 0, 0, 0)); archPane.add(tabDesktop); if (createDirectionPane) { @@ -257,7 +266,7 @@ */ @NotNull private ArchetypePanel<G, A, R, V> createArchetypePanel() { - return new ArchetypePanel<G, A, R, V>(this, mainControl); + return new ArchetypePanel<G, A, R, V>(this, mainControl, archetypeSet); } /** Modified: trunk/src/app/net/sf/gridarta/gui/archetypechooser/ArchetypePanel.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/archetypechooser/ArchetypePanel.java 2008-07-26 05:35:52 UTC (rev 4458) +++ trunk/src/app/net/sf/gridarta/gui/archetypechooser/ArchetypePanel.java 2008-07-26 05:48:33 UTC (rev 4459) @@ -41,6 +41,7 @@ import net.sf.gridarta.CommonConstants; import net.sf.gridarta.MainControl; import net.sf.gridarta.gameobject.Archetype; +import net.sf.gridarta.gameobject.ArchetypeSet; import net.sf.gridarta.gameobject.GameObject; import net.sf.gridarta.gui.map.MapViewBasic; import net.sf.gridarta.map.MapArchObject; @@ -90,6 +91,12 @@ private final MainControl<G, A, R, V> mainControl; /** + * The archetype set to display. + */ + @NotNull + private final ArchetypeSet<G, A, R> archetypeSet; + + /** * Comparator used to sort entries shown in {@link #archList} according to * archetype name. */ @@ -135,11 +142,13 @@ * Creates an ArchetypePanel. * @param archetypeChooserControl The Archetype Chooser. * @param mainControl The main control. + * @param archetypeSet the archetype set to display */ - protected ArchetypePanel(@NotNull final ArchetypeChooserControl<G, A, R, V> archetypeChooserControl, @NotNull final MainControl<G, A, R, V> mainControl) { + protected ArchetypePanel(@NotNull final ArchetypeChooserControl<G, A, R, V> archetypeChooserControl, @NotNull final MainControl<G, A, R, V> mainControl, @NotNull final ArchetypeSet<G, A, R> archetypeSet) { super(new BorderLayout()); this.archetypeChooserControl = archetypeChooserControl; this.mainControl = mainControl; + this.archetypeSet = archetypeSet; comboBox = new JComboBox(); @@ -168,7 +177,7 @@ * archetype names. */ private void updateCellRenderer(final boolean displayObjectNames) { - archList.setCellRenderer(displayObjectNames ? new DisplayNameCellRenderer<R>(mainControl.getArchetypeSet()) : new ArchetypeNameCellRenderer<R>(mainControl.getArchetypeSet())); + archList.setCellRenderer(displayObjectNames ? new DisplayNameCellRenderer<R>(archetypeSet) : new ArchetypeNameCellRenderer<R>(archetypeSet)); final Object selectedValue = archList.getSelectedValue(); showArchList(); if (selectedValue != null) { Modified: trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java =================================================================== --- trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java 2008-07-26 05:35:52 UTC (rev 4458) +++ trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java 2008-07-26 05:48:33 UTC (rev 4459) @@ -22,10 +22,12 @@ import java.awt.Point; import java.io.File; import java.io.FileNotFoundException; +import java.io.IOException; import java.util.List; import java.util.SortedSet; import java.util.TreeSet; import javax.swing.JList; +import javax.swing.ImageIcon; import javax.swing.filechooser.FileFilter; import net.sf.gridarta.AbstractMainControl; import net.sf.gridarta.CFArchTypeList; @@ -33,10 +35,12 @@ import net.sf.gridarta.GridartaObjectsFactory; import net.sf.gridarta.MainControl; import net.sf.gridarta.Size2D; +import net.sf.gridarta.gameobject.AbstractArchetypeSet; import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.ArchetypeParser; import net.sf.gridarta.gameobject.ArchetypeSet; import net.sf.gridarta.gameobject.GameObject; +import net.sf.gridarta.gameobject.AbstractArchetypeParser; import net.sf.gridarta.gameobject.anim.AnimationObjects; import net.sf.gridarta.gameobject.face.FaceObjects; import net.sf.gridarta.gameobject.match.GameObjectMatcher; @@ -65,6 +69,7 @@ import net.sf.gridarta.spells.GameObjectSpell; import net.sf.gridarta.spells.NumberSpell; import net.sf.gridarta.spells.Spells; +import net.sf.japi.swing.misc.Progress; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.junit.Assert; @@ -374,7 +379,8 @@ gridartaObjectsFactory = new TestGridartaObjectsFactory(); final TestMainControl mainControl = new TestMainControl(gridartaObjectsFactory, "test"); final TestMapArchObject mapArchObject = new TestMapArchObject(); - final ArchetypeChooserControl<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> archetypeChooserControl = new ArchetypeChooserControl<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic>(mainControl, false); + final TestArchetypeSet archetypeSet = new TestArchetypeSet(gridartaObjectsFactory); + final ArchetypeChooserControl<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> archetypeChooserControl = new ArchetypeChooserControl<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic>(mainControl, archetypeSet, false); final TestMapControl mapControl = new TestMapControl(gridartaObjectsFactory, mainControl, null, mapArchObject, false, null, archetypeChooserControl); mapModel = new DefaultMapModel<TestGameObject, TestMapArchObject, TestArchetype>(mainControl, mapControl, null, mapArchObject, null, archetypeChooserControl); @@ -926,4 +932,41 @@ } } + /** + * An {@link ArchetypeSet} implementation for testing purposes. + */ + private static class TestArchetypeSet extends AbstractArchetypeSet<TestGameObject, TestMapArchObject, TestArchetype> { + + /** + * Create a new instance. + * @param gridartaObjectsFactory the gridarta objects factory to use + */ + protected TestArchetypeSet(@NotNull final GridartaObjectsFactory<TestGameObject, TestMapArchObject, TestArchetype, ?> gridartaObjectsFactory) { + super(gridartaObjectsFactory); + } + + /** {@inheritDoc} */ + public void loadArchetypes(@NotNull final AbstractArchetypeParser<TestGameObject, TestMapArchObject, TestArchetype> testGameObjectTestMapArchObjectTestArchetypeAbstractArchetypeParser) { + throw new AssertionError(); + } + + /** {@inheritDoc} */ + @NotNull + public ImageIcon getFace(@NotNull final TestArchetype archetype) { + throw new AssertionError(); + } + + /** {@inheritDoc} */ + @NotNull + public ImageIcon getFace(@NotNull final TestGameObject gameObject) { + throw new AssertionError(); + } + + /** {@inheritDoc} */ + public void collect(@NotNull final Progress progress, @NotNull final File dir) throws IOException { + throw new AssertionError(); + } + + } + } // class DefaultMapModelTest This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |