From: <aki...@us...> - 2008-08-08 21:31:44
|
Revision: 4807 http://gridarta.svn.sourceforge.net/gridarta/?rev=4807&view=rev Author: akirschbaum Date: 2008-08-08 21:31:28 +0000 (Fri, 08 Aug 2008) Log Message: ----------- Add MapViewManagerListener; removes dependency MapViewManager -> MapManager. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CFJavaEditor.java trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/MapActions.java trunk/crossfire/src/cfeditor/gui/GameObjectAttributesControl.java trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/MapActions.java trunk/daimonin/src/daieditor/gui/GameObjectAttributesControl.java trunk/src/app/net/sf/gridarta/CurrentMapListener.java trunk/src/app/net/sf/gridarta/DefaultMapManager.java trunk/src/app/net/sf/gridarta/MainControl.java trunk/src/app/net/sf/gridarta/MapManager.java trunk/src/app/net/sf/gridarta/MapManagerListener.java trunk/src/app/net/sf/gridarta/gui/ErrorListView.java trunk/src/app/net/sf/gridarta/gui/MainActions.java trunk/src/app/net/sf/gridarta/gui/MainView.java trunk/src/app/net/sf/gridarta/gui/MapViewManager.java trunk/src/app/net/sf/gridarta/gui/StatusBar.java trunk/src/app/net/sf/gridarta/gui/connectionview/ConnectionControl.java trunk/src/app/net/sf/gridarta/gui/connectionview/ConnectionView.java trunk/src/app/net/sf/gridarta/gui/connectionview/LockedItemsControl.java trunk/src/app/net/sf/gridarta/gui/connectionview/LockedItemsView.java trunk/src/app/net/sf/gridarta/gui/connectionview/MonsterControl.java trunk/src/app/net/sf/gridarta/gui/connectionview/MonsterView.java trunk/src/app/net/sf/gridarta/gui/connectionview/View.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/ConnectionsTab.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/GameObjectAttributesControl.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/MonstersTab.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/WarningsTab.java trunk/src/app/net/sf/gridarta/gui/map/GoLocationDialogManager.java trunk/src/app/net/sf/gridarta/gui/map/MapCursorActions.java trunk/src/app/net/sf/gridarta/gui/map/MapCursorControl.java trunk/src/app/net/sf/gridarta/gui/map/MapFileActions.java trunk/src/app/net/sf/gridarta/gui/map/ShrinkMapSizeDialogManager.java trunk/src/app/net/sf/gridarta/gui/map/ViewActions.java trunk/src/app/net/sf/gridarta/gui/pickmapchooser/PickmapChooserControl.java trunk/src/app/net/sf/gridarta/gui/selectedsquare/MapTileSelectionCache.java trunk/src/app/net/sf/gridarta/gui/selectedsquare/SelectedSquareControl.java trunk/src/app/net/sf/gridarta/gui/selectedsquare/SelectedSquareView.java trunk/src/app/net/sf/gridarta/gui/undo/UndoControl.java trunk/src/app/net/sf/gridarta/map/AutoValidator.java trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java Added Paths: ----------- trunk/src/app/net/sf/gridarta/gui/MapViewManagerListener.java Modified: trunk/crossfire/src/cfeditor/CFJavaEditor.java =================================================================== --- trunk/crossfire/src/cfeditor/CFJavaEditor.java 2008-08-08 20:03:10 UTC (rev 4806) +++ trunk/crossfire/src/cfeditor/CFJavaEditor.java 2008-08-08 21:31:28 UTC (rev 4807) @@ -20,7 +20,6 @@ package cfeditor; import java.awt.Component; -import java.io.File; import java.io.IOException; import java.util.ArrayList; import java.util.List; @@ -148,8 +147,7 @@ } if (outfile != null) { - mainControl.openFiles(infiles); - mainControl.createImageWanted(mainControl.getCurrentMapView(), new File(outfile)); // create map image + mainControl.createImageFile(infiles, outfile); System.exit(0); // exit } Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-08-08 20:03:10 UTC (rev 4806) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-08-08 21:31:28 UTC (rev 4807) @@ -44,6 +44,7 @@ import java.io.IOException; import java.lang.reflect.InvocationTargetException; import java.util.Collections; +import java.util.List; import java.util.Map; import java.util.MissingResourceException; import java.util.prefs.Preferences; @@ -75,6 +76,7 @@ import net.sf.gridarta.gui.MapFileFilter; import net.sf.gridarta.gui.MapManagerActions; import net.sf.gridarta.gui.MapPreview; +import net.sf.gridarta.gui.MapViewManager; import net.sf.gridarta.gui.RecentManager; import net.sf.gridarta.gui.ReplaceDialogManager; import net.sf.gridarta.gui.StatusBar; @@ -135,7 +137,6 @@ import net.sf.japi.util.filter.file.EndingFileFilter; import org.apache.log4j.Logger; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; import org.w3c.dom.Document; import org.xml.sax.SAXException; @@ -219,6 +220,12 @@ private final GameObjectAttributesControl gameObjectAttributesControl; /** + * The map view manager instance. + */ + @NotNull + private final MapViewManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapViewManager; + + /** * Constructs the main controller and its model and view. * @throws RuntimeException If the controller cannot be initialized. */ @@ -244,15 +251,16 @@ gameObjectAttributesDialogFactory = new GameObjectAttributesDialogFactory<GameObject, MapArchObject, Archetype, CMapViewBasic>(archetypeTypeSet, archetypeSet, mapManager); archetypeChooserControl.init(false, gameObjectAttributesDialogFactory); objectChooser = new DefaultObjectChooser<GameObject, MapArchObject, Archetype, CMapViewBasic>(archetypeChooserControl, pickmapChooserControl); - final SelectedSquareControl<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareControl = new SelectedSquareControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(ACTION_FACTORY, gameObjectAttributesDialogFactory, objectChooser, mapManager, editTypes, mapTileListBottom, null, archetypeSet); + mapViewManager = new MapViewManager<GameObject, MapArchObject, Archetype, CMapViewBasic>(); + final SelectedSquareControl<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareControl = new SelectedSquareControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(ACTION_FACTORY, gameObjectAttributesDialogFactory, objectChooser, mapManager, mapViewManager, editTypes, mapTileListBottom, null, archetypeSet); final SelectedSquareView<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareView = selectedSquareControl.getSelectedSquareView(); - new MapCursorControl<GameObject, MapArchObject, Archetype, CMapViewBasic>("cfeditor", this, gameObjectAttributesDialogFactory, mapManager, selectedSquareControl, selectedSquareView); + new MapCursorControl<GameObject, MapArchObject, Archetype, CMapViewBasic>("cfeditor", this, gameObjectAttributesDialogFactory, mapManager, mapViewManager, selectedSquareControl, selectedSquareView); replaceDialogManager.setObjectChooser(objectChooser); - mainActions = new MainActions<GameObject, MapArchObject, Archetype, CMapViewBasic>(replaceDialogManager, this, editTypes, archetypeSet, copyBuffer, pickmapChooserControl, animationObjects, ACTION_FACTORY, faceObjects, objectChooser, mapManager); + mainActions = new MainActions<GameObject, MapArchObject, Archetype, CMapViewBasic>(replaceDialogManager, this, editTypes, archetypeSet, copyBuffer, pickmapChooserControl, animationObjects, ACTION_FACTORY, faceObjects, objectChooser, mapManager, mapViewManager); SystemIcons.init(); GameObject.setArchetypeSet(archetypeSet, SystemIcons.getNofaceTileIcon()); - createMapImageCache(CResourceLoader.getHomeFile("thumbnails"), SystemIcons.getDefaultIcon(), SystemIcons.getDefaultPreview(), new StatusBar<GameObject, MapArchObject, Archetype, CMapViewBasic>(mapManager, archetypeSet, faceObjects)); - mainView = new MainView<GameObject, MapArchObject, Archetype, CMapViewBasic>(this, editTypes, mapManager, ACTION_FACTORY, mapManagerActions.getCloseAllAction(), statusBar); + createMapImageCache(CResourceLoader.getHomeFile("thumbnails"), SystemIcons.getDefaultIcon(), SystemIcons.getDefaultPreview(), new StatusBar<GameObject, MapArchObject, Archetype, CMapViewBasic>(mapManager, mapViewManager, archetypeSet, faceObjects)); + mainView = new MainView<GameObject, MapArchObject, Archetype, CMapViewBasic>(this, editTypes, mapManager, mapViewManager, ACTION_FACTORY, mapManagerActions.getCloseAllAction(), statusBar); gameObjectAttributesDialogFactory.setParent(mainView); new About("cfeditor", mainView); new UndoControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(mapManager); @@ -299,7 +307,7 @@ log.fatal("GameObjectMatcher 'exit' does not exist"); throw new MissingResourceException("GameObjectMatcher 'exit' does not exist", null, null); } - final MapActions mapActions = new MapActions(mainView, this, gridartaObjectsFactory, globalSettings, mapManager, exitMatcher, mapFileFilter, selectedSquareView); + final MapActions mapActions = new MapActions(mainView, this, gridartaObjectsFactory, globalSettings, mapManager, mapViewManager, exitMatcher, mapFileFilter, selectedSquareView); archetypeTypeSet.getListTable().put("event", ScriptArchUtils.getEventTypes()); Map<String, TreasureTreeNode> specialTreasureLists; try { @@ -328,9 +336,9 @@ AbstractScriptArchEditor.initEventTypeBoxes(".py", "Python", ScriptArchUtils.createEventTypeBox(), pythonFileFilter, globalSettings, this); // 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); + final LockedItemsControl<GameObject, MapArchObject, Archetype, CMapViewBasic> lockedItemsControl = new LockedItemsControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(mapManager, mapViewManager, 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); final GameObjectAttributesModel<GameObject, MapArchObject, Archetype> gameObjectAttributesModel = new GameObjectAttributesModel<GameObject, MapArchObject, Archetype>(); - gameObjectAttributesControl = new GameObjectAttributesControl(gameObjectAttributesModel, this, gameObjectAttributesDialogFactory, objectChooser, archetypeTypeSet, mapManager, animationObjects, lockedItemsControl, monsterMatcher, selectedSquareControl, selectedSquareView, mainView); + gameObjectAttributesControl = new GameObjectAttributesControl(gameObjectAttributesModel, this, gameObjectAttributesDialogFactory, objectChooser, archetypeTypeSet, mapManager, mapViewManager, 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); @@ -751,16 +759,6 @@ new MapPreview(gridartaObjectsFactory.newSimpleLevelRenderer(currentMap.getMapModel()).getFullImage()); } - /** - * Returns the current top map view we are working with. - * @return the current top map view we are working with, or - * <code>null</code> if no map is open - */ - @Nullable - public MapView<GameObject, MapArchObject, Archetype, CMapViewBasic> getCurrentMapView() { - return mainView == null ? null : mainView.getCurrentMapView(); - } - /** {@inheritDoc} */ @NotNull public String getConfigurationDirectory() { @@ -818,4 +816,9 @@ } } + public void createImageFile(final List<String> infiles, final String outfile) { + openFiles(infiles); + createImageWanted(mapViewManager.getCurrentMapView(), new File(outfile)); // create map image + } + } // class CMainControl Modified: trunk/crossfire/src/cfeditor/MapActions.java =================================================================== --- trunk/crossfire/src/cfeditor/MapActions.java 2008-08-08 20:03:10 UTC (rev 4806) +++ trunk/crossfire/src/cfeditor/MapActions.java 2008-08-08 21:31:28 UTC (rev 4807) @@ -41,6 +41,7 @@ import net.sf.gridarta.MainControl; import net.sf.gridarta.MapManager; import net.sf.gridarta.gameobject.match.GameObjectMatcher; +import net.sf.gridarta.gui.MapViewManager; import net.sf.gridarta.gui.map.MapCursorEvent; import net.sf.gridarta.gui.map.MapView; import net.sf.gridarta.gui.map.ShrinkMapSizeDialogManager; @@ -147,11 +148,12 @@ * @param gridartaObjectsFactory the gridarta objects factory instance * @param globalSettings the global settings instance * @param mapManager the map manager + * @param mapViewManager the map view manager * @param exitMatcher the game object matcher selecting exit objects * @param mapFileFilter the Swing file filter to use * @param selectedSquareView the selected square vuew to use */ - public MapActions(@NotNull final Component parent, final CMainControl mainControl, @NotNull final GridartaObjectsFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> gridartaObjectsFactory, @NotNull final GlobalSettings globalSettings,final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, final GameObjectMatcher exitMatcher, final FileFilter mapFileFilter, @NotNull final SelectedSquareView<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareView) { + public MapActions(@NotNull final Component parent, @NotNull final CMainControl mainControl, @NotNull final GridartaObjectsFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> gridartaObjectsFactory, @NotNull final GlobalSettings globalSettings, @NotNull final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, @NotNull final MapViewManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapViewManager, final GameObjectMatcher exitMatcher, final FileFilter mapFileFilter, @NotNull final SelectedSquareView<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareView) { this.parent = parent; this.mainControl = mainControl; this.gridartaObjectsFactory = gridartaObjectsFactory; @@ -168,7 +170,7 @@ aDirections[i] = ACTION_FACTORY.createAction(true, directionsMap[i], this); } - currentMapListener = new CurrentMapListener<GameObject, MapArchObject, Archetype, CMapViewBasic>(mainControl, mapManager, null, false, false, true) { + currentMapListener = new CurrentMapListener<GameObject, MapArchObject, Archetype, CMapViewBasic>(mapManager, mapViewManager, null, false, false, true) { /** {@inheritDoc} */ @Override Modified: trunk/crossfire/src/cfeditor/gui/GameObjectAttributesControl.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/GameObjectAttributesControl.java 2008-08-08 20:03:10 UTC (rev 4806) +++ trunk/crossfire/src/cfeditor/gui/GameObjectAttributesControl.java 2008-08-08 21:31:28 UTC (rev 4807) @@ -29,6 +29,7 @@ import net.sf.gridarta.archtype.ArchetypeTypeSet; import net.sf.gridarta.gameobject.anim.AnimationObjects; import net.sf.gridarta.gameobject.match.GameObjectMatcher; +import net.sf.gridarta.gui.MapViewManager; import net.sf.gridarta.gui.connectionview.LockedItemsControl; import net.sf.gridarta.gui.gameobjectattributesdialog.GameObjectAttributesDialogFactory; import net.sf.gridarta.gui.gameobjectattributespanel.AnimationTab; @@ -57,15 +58,15 @@ private static final long serialVersionUID = 1L; /* Build Panel */ - public GameObjectAttributesControl(final GameObjectAttributesModel<GameObject, MapArchObject, Archetype> gameObjectAttributesModel, @NotNull final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, @NotNull final GameObjectAttributesDialogFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> gameObjectAttributesDialogFactory, @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) { + public GameObjectAttributesControl(final GameObjectAttributesModel<GameObject, MapArchObject, Archetype> gameObjectAttributesModel, @NotNull final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, @NotNull final GameObjectAttributesDialogFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> gameObjectAttributesDialogFactory, @NotNull final ObjectChooser<GameObject, MapArchObject, Archetype> objectChooser, @NotNull final ArchetypeTypeSet<GameObject, MapArchObject, Archetype> archetypeTypeSet, @NotNull final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, @NotNull final MapViewManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapViewManager, @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, gameObjectAttributesDialogFactory, objectChooser, mapManager, selectedSquareControl); addTab(new ArchTab(archetypeTypeSet, gameObjectAttributesModel, gameObjectTextEditor)); 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 ConnectionsTab<GameObject, MapArchObject, Archetype, CMapViewBasic>(mapManager, mapViewManager, gameObjectAttributesModel)); addTab(new LockedItemsTab<GameObject, MapArchObject, Archetype>(lockedItemsControl, gameObjectAttributesModel)); - addTab(new MonstersTab<GameObject, MapArchObject, Archetype, CMapViewBasic>(mapManager, monsterMatcher, gameObjectAttributesModel)); + addTab(new MonstersTab<GameObject, MapArchObject, Archetype, CMapViewBasic>(mapManager, mapViewManager, monsterMatcher, gameObjectAttributesModel)); addTab(new WarningsTab<GameObject, MapArchObject, Archetype, CMapViewBasic>(mapManager, selectedSquareView, gameObjectAttributesModel)); } Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-08-08 20:03:10 UTC (rev 4806) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-08-08 21:31:28 UTC (rev 4807) @@ -83,6 +83,7 @@ import net.sf.gridarta.gui.MapFileFilter; import net.sf.gridarta.gui.MapManagerActions; import net.sf.gridarta.gui.MapPreview; +import net.sf.gridarta.gui.MapViewManager; import net.sf.gridarta.gui.RecentManager; import net.sf.gridarta.gui.ReplaceDialogManager; import net.sf.gridarta.gui.StatusBar; @@ -156,7 +157,6 @@ import net.sf.japi.util.filter.file.GlobFileFilter; import org.apache.log4j.Logger; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; import org.w3c.dom.Document; import org.xml.sax.SAXException; @@ -279,6 +279,12 @@ private final GameObjectAttributesControl gameObjectAttributesControl; /** + * The map view manager instance. + */ + @NotNull + private final MapViewManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapViewManager; + + /** * Constructs the main controller and its model and view. * @throws RuntimeException If the controller cannot be initialized. */ @@ -307,15 +313,16 @@ gameObjectAttributesDialogFactory = new GameObjectAttributesDialogFactory<GameObject, MapArchObject, Archetype, CMapViewBasic>(archetypeTypeSet, archetypeSet, mapManager); archetypeChooserControl.init(true, gameObjectAttributesDialogFactory); objectChooser = new DefaultObjectChooser<GameObject, MapArchObject, Archetype, CMapViewBasic>(archetypeChooserControl, pickmapChooserControl); - final SelectedSquareControl<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareControl = new SelectedSquareControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(ACTION_FACTORY, gameObjectAttributesDialogFactory, objectChooser, mapManager, editTypes, mapTileListBottom, GUIUtils.getSysIcon(IGUIConstants.TILE_NORTH), archetypeSet); + mapViewManager = new MapViewManager<GameObject, MapArchObject, Archetype, CMapViewBasic>(); + final SelectedSquareControl<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareControl = new SelectedSquareControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(ACTION_FACTORY, gameObjectAttributesDialogFactory, objectChooser, mapManager, mapViewManager, editTypes, mapTileListBottom, GUIUtils.getSysIcon(IGUIConstants.TILE_NORTH), archetypeSet); final SelectedSquareView<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareView = selectedSquareControl.getSelectedSquareView(); - new MapCursorControl<GameObject, MapArchObject, Archetype, CMapViewBasic>("daieditor", this, gameObjectAttributesDialogFactory, mapManager, selectedSquareControl, selectedSquareView); + new MapCursorControl<GameObject, MapArchObject, Archetype, CMapViewBasic>("daieditor", this, gameObjectAttributesDialogFactory, mapManager, mapViewManager, selectedSquareControl, selectedSquareView); replaceDialogManager.setObjectChooser(objectChooser); - mainActions = new MainActions<GameObject, MapArchObject, Archetype, CMapViewBasic>(replaceDialogManager, this, editTypes, archetypeSet, copyBuffer, pickmapChooserControl, animationObjects, ACTION_FACTORY, faceObjects, objectChooser, mapManager); + mainActions = new MainActions<GameObject, MapArchObject, Archetype, CMapViewBasic>(replaceDialogManager, this, editTypes, archetypeSet, copyBuffer, pickmapChooserControl, animationObjects, ACTION_FACTORY, faceObjects, objectChooser, mapManager, mapViewManager); SystemIcons.init(); GameObject.setAnimationObjects(animationObjects, SystemIcons.getNofaceTileIcon()); - createMapImageCache(null, SystemIcons.getDefaultIcon(), SystemIcons.getDefaultPreview(), new StatusBar<GameObject, MapArchObject, Archetype, CMapViewBasic>(mapManager, archetypeSet, faceObjects)); - mainView = new MainView<GameObject, MapArchObject, Archetype, CMapViewBasic>(this, editTypes, mapManager, ACTION_FACTORY, mapManagerActions.getCloseAllAction(), statusBar); + createMapImageCache(null, SystemIcons.getDefaultIcon(), SystemIcons.getDefaultPreview(), new StatusBar<GameObject, MapArchObject, Archetype, CMapViewBasic>(mapManager, mapViewManager, archetypeSet, faceObjects)); + mainView = new MainView<GameObject, MapArchObject, Archetype, CMapViewBasic>(this, editTypes, mapManager, mapViewManager, ACTION_FACTORY, mapManagerActions.getCloseAllAction(), statusBar); gameObjectAttributesDialogFactory.setParent(mainView); new About("daieditor", mainView); new UndoControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(mapManager); @@ -365,7 +372,7 @@ log.fatal("GameObjectMatcher 'exit' does not exist"); throw new MissingResourceException("GameObjectMatcher 'exit' does not exist", null, null); } - final MapActions mapActions = new MapActions(mainView, this, gridartaObjectsFactory, (GlobalSettingsImpl) globalSettings, mapManager, exitMatcher, mapFileFilter, selectedSquareView); + final MapActions mapActions = new MapActions(mainView, this, gridartaObjectsFactory, (GlobalSettingsImpl) globalSettings, mapManager, mapViewManager, exitMatcher, mapFileFilter, selectedSquareView); Map<String, TreasureTreeNode> specialTreasureLists; try { final Document specialTreasureListsDocument = xmlHelper.getDocumentBuilder().parse(IOUtils.getResourceURLAsString(getConfigurationDirectory(), "TreasureLists.xml")); @@ -394,9 +401,9 @@ AbstractScriptArchEditor.initEventTypeBoxes(".lua", "Lua", ScriptArchUtils.createEventTypeBox(), luaFileFilter, globalSettings, this); // 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); + final LockedItemsControl<GameObject, MapArchObject, Archetype, CMapViewBasic> lockedItemsControl = new LockedItemsControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(mapManager, mapViewManager, 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); final GameObjectAttributesModel<GameObject, MapArchObject, Archetype> gameObjectAttributesModel = new GameObjectAttributesModel<GameObject, MapArchObject, Archetype>(); - gameObjectAttributesControl = new GameObjectAttributesControl(gameObjectAttributesModel, this, gameObjectAttributesDialogFactory, objectChooser, archetypeTypeSet, mapManager, animationObjects, lockedItemsControl, monsterMatcher, selectedSquareControl, selectedSquareView, mainView); + gameObjectAttributesControl = new GameObjectAttributesControl(gameObjectAttributesModel, this, gameObjectAttributesDialogFactory, objectChooser, archetypeTypeSet, mapManager, mapViewManager, 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); @@ -943,16 +950,6 @@ new MapPreview(gridartaObjectsFactory.newSimpleLevelRenderer(currentMap.getMapModel()).getFullImage()); } - /** - * Returns the current top map view we are working with. - * @return the current top map view we are working with, or - * <code>null</code> if no map is open - */ - @Nullable - public MapView<GameObject, MapArchObject, Archetype, CMapViewBasic> getCurrentMapView() { - return mainView == null ? null : mainView.getCurrentMapView(); - } - /** {@inheritDoc} */ @NotNull public String getConfigurationDirectory() { Modified: trunk/daimonin/src/daieditor/MapActions.java =================================================================== --- trunk/daimonin/src/daieditor/MapActions.java 2008-08-08 20:03:10 UTC (rev 4806) +++ trunk/daimonin/src/daieditor/MapActions.java 2008-08-08 21:31:28 UTC (rev 4807) @@ -40,6 +40,7 @@ import net.sf.gridarta.MainControl; import net.sf.gridarta.MapManager; import net.sf.gridarta.gameobject.match.GameObjectMatcher; +import net.sf.gridarta.gui.MapViewManager; import net.sf.gridarta.gui.map.MapCursorEvent; import net.sf.gridarta.gui.map.MapView; import net.sf.gridarta.gui.map.ShrinkMapSizeDialogManager; @@ -142,11 +143,12 @@ * @param gridartaObjectsFactory the gridarta objects factory instance * @param globalSettings the global settings instance * @param mapManager the map manager + * @param mapViewManager the map view manager * @param exitMatcher the game object matcher selecting exit objects * @param mapFileFilter the Swing file filter to use * @param selectedSquareView the selected square vuew to use */ - public MapActions(@NotNull final Component parent, @NotNull final CMainControl mainControl, @NotNull final GridartaObjectsFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> gridartaObjectsFactory, @NotNull final GlobalSettingsImpl globalSettings, final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, final GameObjectMatcher exitMatcher, final FileFilter mapFileFilter, @NotNull final SelectedSquareView<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareView) { + public MapActions(@NotNull final Component parent, @NotNull final CMainControl mainControl, @NotNull final GridartaObjectsFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> gridartaObjectsFactory, @NotNull final GlobalSettingsImpl globalSettings, @NotNull final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, @NotNull final MapViewManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapViewManager, final GameObjectMatcher exitMatcher, final FileFilter mapFileFilter, @NotNull final SelectedSquareView<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareView) { this.parent = parent; this.mainControl = mainControl; this.gridartaObjectsFactory = gridartaObjectsFactory; @@ -163,7 +165,7 @@ aDirections[i] = ACTION_FACTORY.createAction(true, directionsMap[i], this); } - currentMapListener = new CurrentMapListener<GameObject, MapArchObject, Archetype, CMapViewBasic>(mainControl, mapManager, null, false, false, true) { + currentMapListener = new CurrentMapListener<GameObject, MapArchObject, Archetype, CMapViewBasic>(mapManager, mapViewManager, null, false, false, true) { /** {@inheritDoc} */ @Override Modified: trunk/daimonin/src/daieditor/gui/GameObjectAttributesControl.java =================================================================== --- trunk/daimonin/src/daieditor/gui/GameObjectAttributesControl.java 2008-08-08 20:03:10 UTC (rev 4806) +++ trunk/daimonin/src/daieditor/gui/GameObjectAttributesControl.java 2008-08-08 21:31:28 UTC (rev 4807) @@ -29,6 +29,7 @@ import net.sf.gridarta.archtype.ArchetypeTypeSet; import net.sf.gridarta.gameobject.anim.AnimationObjects; import net.sf.gridarta.gameobject.match.GameObjectMatcher; +import net.sf.gridarta.gui.MapViewManager; import net.sf.gridarta.gui.connectionview.LockedItemsControl; import net.sf.gridarta.gui.gameobjectattributesdialog.GameObjectAttributesDialogFactory; import net.sf.gridarta.gui.gameobjectattributespanel.AnimationTab; @@ -57,15 +58,15 @@ private static final long serialVersionUID = 1L; /* Build Panel */ - public GameObjectAttributesControl(@NotNull final GameObjectAttributesModel<GameObject, MapArchObject, Archetype>gameObjectAttributesModel, @NotNull final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, @NotNull final GameObjectAttributesDialogFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> gameObjectAttributesDialogFactory, @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) { + public GameObjectAttributesControl(@NotNull final GameObjectAttributesModel<GameObject, MapArchObject, Archetype>gameObjectAttributesModel, @NotNull final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, @NotNull final GameObjectAttributesDialogFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> gameObjectAttributesDialogFactory, @NotNull final ObjectChooser<GameObject, MapArchObject, Archetype> objectChooser, @NotNull final ArchetypeTypeSet<GameObject, MapArchObject, Archetype> archetypeTypeSet, @NotNull final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, @NotNull final MapViewManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapViewManager, @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, gameObjectAttributesDialogFactory, objectChooser, mapManager, selectedSquareControl); addTab(new ArchTab(archetypeTypeSet, gameObjectAttributesModel, gameObjectTextEditor)); 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 ConnectionsTab<GameObject, MapArchObject, Archetype, CMapViewBasic>(mapManager, mapViewManager, gameObjectAttributesModel)); addTab(new LockedItemsTab<GameObject, MapArchObject, Archetype>(lockedItemsControl, gameObjectAttributesModel)); - addTab(new MonstersTab<GameObject, MapArchObject, Archetype, CMapViewBasic>(mapManager, monsterMatcher, gameObjectAttributesModel)); + addTab(new MonstersTab<GameObject, MapArchObject, Archetype, CMapViewBasic>(mapManager, mapViewManager, monsterMatcher, gameObjectAttributesModel)); addTab(new WarningsTab<GameObject, MapArchObject, Archetype, CMapViewBasic>(mapManager, selectedSquareView, gameObjectAttributesModel)); } Modified: trunk/src/app/net/sf/gridarta/CurrentMapListener.java =================================================================== --- trunk/src/app/net/sf/gridarta/CurrentMapListener.java 2008-08-08 20:03:10 UTC (rev 4806) +++ trunk/src/app/net/sf/gridarta/CurrentMapListener.java 2008-08-08 21:31:28 UTC (rev 4807) @@ -21,6 +21,8 @@ import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.GameObject; +import net.sf.gridarta.gui.MapViewManager; +import net.sf.gridarta.gui.MapViewManagerListener; import net.sf.gridarta.gui.map.MapCursorEvent; import net.sf.gridarta.gui.map.MapCursorListener; import net.sf.gridarta.gui.map.MapView; @@ -138,18 +140,6 @@ } /** {@inheritDoc} */ - public void currentMapViewChanged(@Nullable final MapView<G, A, R, V> mapView) { - if (trackMapCursor && currentMapView != null) { - currentMapView.getMapViewBasic().removeMapCursorListener(mapCursorListener); - } - currentMapView = mapView; - if (trackMapCursor && currentMapView != null) { - currentMapView.getMapViewBasic().addMapCursorListener(mapCursorListener); - } - mapViewHasChanged(); - } - - /** {@inheritDoc} */ public void mapCreated(@NotNull final MapControl<G, A, R, V> mapControl) { // ignore } @@ -172,9 +162,29 @@ }; /** + * The map view manager listener which is attached to the current map if + * the current map is tracked. Otherwise it is unused. + */ + private final MapViewManagerListener<G, A, R, V> mapViewManagerListener = new MapViewManagerListener<G, A, R, V>() { + + /** {@inheritDoc} */ + public void currentMapViewChanged(@Nullable final MapView<G, A, R, V> mapView) { + if (trackMapCursor && currentMapView != null) { + currentMapView.getMapViewBasic().removeMapCursorListener(mapCursorListener); + } + currentMapView = mapView; + if (trackMapCursor && currentMapView != null) { + currentMapView.getMapViewBasic().addMapCursorListener(mapCursorListener); + } + mapViewHasChanged(); + } + + }; + + /** * Create a new instance that tracks the map state. - * @param mainControl the main control to forward actions * @param mapManager the map manager + * @param mapViewManager the map view manager * @param mapControl the map control to check for changes, or * <code>null</code> to check <code>mainControl</code>'s current map * @param trackMapModified if set, notify about changes of the map modified @@ -184,7 +194,7 @@ * @param trackMapCursor if set, notify about map cursor changes of the * current map view */ - protected CurrentMapListener(@NotNull final MainControl<G, A, R, V> mainControl, @NotNull final MapManager<G, A, R, V> mapManager, @Nullable final MapControl<G, A, R, V> mapControl, final boolean trackMapModified, final boolean trackMapFileName, final boolean trackMapCursor) { + protected CurrentMapListener(@NotNull final MapManager<G, A, R, V> mapManager, @NotNull final MapViewManager<G, A, R, V> mapViewManager, @Nullable final MapControl<G, A, R, V> mapControl, final boolean trackMapModified, final boolean trackMapFileName, final boolean trackMapCursor) { this.mapManager = mapManager; this.mapControl = mapControl; this.trackMapModified = trackMapModified; @@ -196,11 +206,12 @@ if (currentMap != null) { currentMap.addMapControlListener(mapControlListener); } - currentMapView = mainControl.getCurrentMapView(); + mapViewManager.addMapViewManagerListener(mapViewManagerListener); + currentMapView = mapViewManager.getCurrentMapView(); } else { currentMap = mapControl; currentMap.addMapControlListener(mapControlListener); - currentMapView = mainControl.getCurrentMapView(); + currentMapView = mapViewManager.getCurrentMapView(); if (currentMapView != null && currentMapView.getMapControl() != currentMap) { currentMapView = null; } Modified: trunk/src/app/net/sf/gridarta/DefaultMapManager.java =================================================================== --- trunk/src/app/net/sf/gridarta/DefaultMapManager.java 2008-08-08 20:03:10 UTC (rev 4806) +++ trunk/src/app/net/sf/gridarta/DefaultMapManager.java 2008-08-08 21:31:28 UTC (rev 4807) @@ -430,13 +430,6 @@ } /** {@inheritDoc} */ - public void fireCurrentMapViewChangedEvent(@Nullable final MapView<G, A, R, V> currentMapView) { - for (final MapManagerListener<G, A, R, V> listener : listenerList.getListeners(MapManagerListener.class)) { - listener.currentMapViewChanged(currentMapView); - } - } - - /** {@inheritDoc} */ public void addMapManagerListener(@NotNull final MapManagerListener<G, A, R, V> listener) { listenerList.add(MapManagerListener.class, listener); } Modified: trunk/src/app/net/sf/gridarta/MainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/MainControl.java 2008-08-08 20:03:10 UTC (rev 4806) +++ trunk/src/app/net/sf/gridarta/MainControl.java 2008-08-08 21:31:28 UTC (rev 4807) @@ -31,7 +31,6 @@ import net.sf.gridarta.map.MapModel; import net.sf.japi.swing.ActionMethod; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; /** * This interface is only for unification. It should become obsolete after a @@ -50,13 +49,6 @@ MainView<G, A, R, V> getMainView(); /** - * Returns the current map view. - * @return The current map view - */ - @Nullable - MapView<G, A, R, V> getCurrentMapView(); - - /** * Invoked when user wants to save a map to certain file. * @param mapControl the map to be saved * @return <code>true</code> if the user confirmed saving the map and the Modified: trunk/src/app/net/sf/gridarta/MapManager.java =================================================================== --- trunk/src/app/net/sf/gridarta/MapManager.java 2008-08-08 20:03:10 UTC (rev 4806) +++ trunk/src/app/net/sf/gridarta/MapManager.java 2008-08-08 21:31:28 UTC (rev 4807) @@ -172,12 +172,6 @@ void removeMapManagerListener(@NotNull MapManagerListener<G, A, R, V> listener); /** - * Notify all listeners about a changed current map view. - * @param currentMapView the current map view - */ - void fireCurrentMapViewChangedEvent(@Nullable MapView<G, A, R, V> currentMapView); - - /** * Notify all listeners about a map view to be closed. * @param mapView map view that's being closed */ Modified: trunk/src/app/net/sf/gridarta/MapManagerListener.java =================================================================== --- trunk/src/app/net/sf/gridarta/MapManagerListener.java 2008-08-08 20:03:10 UTC (rev 4806) +++ trunk/src/app/net/sf/gridarta/MapManagerListener.java 2008-08-08 21:31:28 UTC (rev 4807) @@ -35,8 +35,7 @@ * #mapCreated(MapControl)} - after a map has been created or opened <li>{@link * #currentMapChanged(MapControl)} - the newly created map now is the current * map <li>{@link #mapViewCreated(MapView)} - after a map view has been created - * <li>{@link #currentMapViewChanged(MapView)} - the new map view now is the - * current map view <li>{@link #mapViewClosing(MapView)} - the map view has been + * <li>{@link #mapViewClosing(MapView)} - the map view has been * closed <li>{@link #mapClosing(MapControl)} - the map has been closed </ul> * @author Andreas Kirschbaum */ @@ -50,13 +49,6 @@ void currentMapChanged(@Nullable MapControl<G, A, R, V> mapControl); /** - * This event handler is called when the current map view has changed. - * @param mapView the new map view, or <code>null</code> if no opened map - * view exists - */ - void currentMapViewChanged(@Nullable MapView<G, A, R, V> mapView); - - /** * This event handler is called when a map was created. * @param mapControl the created map control */ Modified: trunk/src/app/net/sf/gridarta/gui/ErrorListView.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/ErrorListView.java 2008-08-08 20:03:10 UTC (rev 4806) +++ trunk/src/app/net/sf/gridarta/gui/ErrorListView.java 2008-08-08 21:31:28 UTC (rev 4807) @@ -109,11 +109,6 @@ } /** {@inheritDoc} */ - public void currentMapViewChanged(@Nullable final MapView<G, A, R, V> mapView) { - // ignore - } - - /** {@inheritDoc} */ public void mapCreated(@NotNull final MapControl<G, A, R, V> mapControl) { // ignore } Modified: trunk/src/app/net/sf/gridarta/gui/MainActions.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/MainActions.java 2008-08-08 20:03:10 UTC (rev 4806) +++ trunk/src/app/net/sf/gridarta/gui/MainActions.java 2008-08-08 21:31:28 UTC (rev 4807) @@ -200,12 +200,6 @@ } /** {@inheritDoc} */ - public void currentMapViewChanged(@Nullable final MapView<G, A, R, V> mapView) { - currentMapView = mapView; - refreshMenus(); - } - - /** {@inheritDoc} */ public void mapCreated(@NotNull final MapControl<G, A, R, V> mapControl) { // ignore: a current map changed event will be generated } @@ -229,6 +223,17 @@ }; + /** The map manager listener to detect created and closed map views. */ + private final MapViewManagerListener<G, A, R, V> mapViewManagerListener = new MapViewManagerListener<G, A, R, V>() { + + /** {@inheritDoc} */ + public void currentMapViewChanged(@Nullable final MapView<G, A, R, V> mapView) { + currentMapView = mapView; + refreshMenus(); + } + + }; + /** The map grid listener used to detect map grid changes. */ private final MapGridListener mapGridListener = new MapGridListener() { @@ -312,8 +317,9 @@ * @param faceObjects the FaceObjects instance to use * @param objectChooser the animation objects instance to use * @param mapManager the map manager instance + * @param mapViewManager the map view manager instance */ - public MainActions(@NotNull final ReplaceDialogManager<G, A, R, V> replaceDialogManager, @NotNull final MainControl<G, A, R, V> mainControl, @NotNull final EditTypes<G, A, R, V> editTypes, @NotNull final ArchetypeSet<G, A, R> archetypeSet, @NotNull final CopyBuffer<G, A, R, V> copyBuffer, @NotNull final PickmapChooserControl<G, A, R, V> pickmapChooserControl, @NotNull final AnimationObjects<?> animationObjects, @NotNull final ActionFactory actionFactory, @NotNull final FaceObjects faceObjects, @NotNull final ObjectChooser<G, A, R> objectChooser, @NotNull final MapManager<G, A, R, V> mapManager) { + public MainActions(@NotNull final ReplaceDialogManager<G, A, R, V> replaceDialogManager, @NotNull final MainControl<G, A, R, V> mainControl, @NotNull final EditTypes<G, A, R, V> editTypes, @NotNull final ArchetypeSet<G, A, R> archetypeSet, @NotNull final CopyBuffer<G, A, R, V> copyBuffer, @NotNull final PickmapChooserControl<G, A, R, V> pickmapChooserControl, @NotNull final AnimationObjects<?> animationObjects, @NotNull final ActionFactory actionFactory, @NotNull final FaceObjects faceObjects, @NotNull final ObjectChooser<G, A, R> objectChooser, @NotNull final MapManager<G, A, R, V> mapManager, @NotNull final MapViewManager<G, A, R, V> mapViewManager) { this.replaceDialogManager = replaceDialogManager; this.mainControl = mainControl; this.editTypes = editTypes; @@ -348,7 +354,8 @@ aValidateMap = actionFactory.createAction(true, "validateMap", this); mapManager.addMapManagerListener(mapManagerListener); currentMap = mapManager.getCurrentMap(); - currentMapView = mainControl.getCurrentMapView(); + mapViewManager.addMapViewManagerListener(mapViewManagerListener); + currentMapView = mapViewManager.getCurrentMapView(); } /** Must be called after object creation. */ Modified: trunk/src/app/net/sf/gridarta/gui/MainView.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/MainView.java 2008-08-08 20:03:10 UTC (rev 4806) +++ trunk/src/app/net/sf/gridarta/gui/MainView.java 2008-08-08 21:31:28 UTC (rev 4807) @@ -44,7 +44,6 @@ import net.sf.gridarta.EditTypes; import net.sf.gridarta.MainControl; import net.sf.gridarta.MapManager; -import net.sf.gridarta.MapManagerListener; import net.sf.gridarta.archtype.ArchetypeTypeSet; import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.GameObject; @@ -222,38 +221,13 @@ /** * The listener used to detect map view changes. */ - private final MapManagerListener<G, A, R, V> mapManagerListener = new MapManagerListener<G, A, R, V>() { + private final MapViewManagerListener<G, A, R, V> mapViewManagerListener = new MapViewManagerListener<G, A, R, V>() { /** {@inheritDoc} */ - public void currentMapChanged(@Nullable final MapControl<G, A, R, V> mapControl) { - // ignore - } - - /** {@inheritDoc} */ public void currentMapViewChanged(@Nullable final MapView<G, A, R, V> mapView) { rebuildWindowMenu(); } - /** {@inheritDoc} */ - public void mapCreated(@NotNull final MapControl<G, A, R, V> mapControl) { - // ignore - } - - /** {@inheritDoc} */ - public void mapViewCreated(@NotNull final MapView<G, A, R, V> mapView) { - // ignore - } - - /** {@inheritDoc} */ - public void mapClosing(@NotNull final MapControl<G, A, R, V> mapControl) { - // ignore - } - - /** {@inheritDoc} */ - public void mapViewClosing(@NotNull final MapView<G, A, R, V> mapView) { - // ignore - } - }; /** @@ -261,15 +235,16 @@ * @param mainControl MainControl to attach to. * @param editTypes the edit types instance * @param mapManager the map manager + * @param mapViewManager the map view manager * @param actionFactory the action factory to use * @param aCloseAll the action "close all map windows" * @param statusBar the status bar instance */ - public MainView(@NotNull final MainControl<G, A, R, V> mainControl, @NotNull final EditTypes<G, A, R, V> editTypes, @NotNull final MapManager<G, A, R, V> mapManager, @NotNull final ActionFactory actionFactory, @NotNull final Action aCloseAll, @NotNull final Component statusBar) { + public MainView(@NotNull final MainControl<G, A, R, V> mainControl, @NotNull final EditTypes<G, A, R, V> editTypes, @NotNull final MapManager<G, A, R, V> mapManager, @NotNull final MapViewManager<G, A, R, V> mapViewManager, @NotNull final ActionFactory actionFactory, @NotNull final Action aCloseAll, @NotNull final Component statusBar) { super(actionFactory.format("mainWindow.title", AbstractMainControl.getBuildNumberAsString())); this.mapManager = mapManager; - mapViewManager = new MapViewManager<G, A, R, V>(mapManager); - mapFileAction = new MapFileActions<G, A, R, V>(mainControl, mapManager, null); + this.mapViewManager = mapViewManager; + mapFileAction = new MapFileActions<G, A, R, V>(mainControl, mapManager, mapViewManager, null); add(statusBar, BorderLayout.SOUTH); setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); addWindowListener(new WindowAdapter() { @@ -285,7 +260,7 @@ aNextWindow = actionFactory.createAction(true, "nextWindow", this); actionFactory.createAction(true, "viewTreasurelists", mainControl); - viewActions = new ViewActions<G, A, R, V>(mainControl, editTypes, mapManager); + viewActions = new ViewActions<G, A, R, V>(editTypes, mapManager, mapViewManager); final ImageIcon icon = GUIUtils.getIcon(GUIConstants.APP_ICON); if (icon != null) { @@ -294,7 +269,7 @@ updateFocus(false); - mapManager.addMapManagerListener(mapManagerListener); + mapViewManager.addMapViewManagerListener(mapViewManagerListener); } /** Open the online help window. */ @@ -595,16 +570,6 @@ } /** - * Returns the current top map view we are working with. - * @return the current top map view we are working with, or - * <code>null</code> if no map is open - */ - @Nullable - public MapView<G, A, R, V> getCurrentMapView() { - return mapViewManager.getFirstMapView(); - } - - /** * Determine whether "prev window" should be enabled. * @return the map view to activate, or <code>null</code> if "prev window" * should be disabled Modified: trunk/src/app/net/sf/gridarta/gui/MapViewManager.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/MapViewManager.java 2008-08-08 20:03:10 UTC (rev 4806) +++ trunk/src/app/net/sf/gridarta/gui/MapViewManager.java 2008-08-08 21:31:28 UTC (rev 4807) @@ -23,7 +23,6 @@ import java.util.Collections; import java.util.Iterator; import java.util.List; -import net.sf.gridarta.MapManager; import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.GameObject; import net.sf.gridarta.gui.map.MapView; @@ -45,23 +44,21 @@ private final List<MapView<G, A, R, V>> mapViews = Collections.synchronizedList(new ArrayList<MapView<G, A, R, V>>()); /** - * The map manager to notify. - */ - @NotNull - private final MapManager<G, A, R, V> mapManager; - - /** * The current map view. */ @Nullable private MapView<G, A, R, V> currentMapView = null; /** + * The registered listeners. + */ + @NotNull + private final List<MapViewManagerListener<G, A, R, V>> listeners = new ArrayList<MapViewManagerListener<G, A, R, V>>(); + + /** * Creates a new instance. - * @param mapManager the map manager to notify */ - public MapViewManager(@NotNull final MapManager<G, A, R, V> mapManager) { - this.mapManager = mapManager; + public MapViewManager() { } public void setCurrentLevelView(final MapView<G, A, R, V> mapView) { @@ -146,13 +143,41 @@ * Updates the current map view and notifies all listeners of changes. */ private void updateCurrentMapView() { - final MapView<G, A, R, V> newCurrentMapView = getFirstMapView(); + final MapView<G, A, R, V> newCurrentMapView = getCurrentMapView(); if (currentMapView == newCurrentMapView) { return; } currentMapView = newCurrentMapView; - mapManager.fireCurrentMapViewChangedEvent(currentMapView); + for (final MapViewManagerListener<G, A, R, V> listener : listeners) { + listener.currentMapViewChanged(currentMapView); + } } + /** + * Adds a listener to be notified. + * @param listener the listener to add + */ + public void addMapViewManagerListener(@NotNull final MapViewManagerListener<G, A, R, V> listener) { + listeners.add(listener); + } + + /** + * Removes a listener to be notified. + * @param listener the listener to remove + */ + public void removeMapViewManagerListener(@NotNull final MapViewManagerListener<G, A, R, V> listener) { + listeners.remove(listener); + } + + /** + * Returns the current top map view we are working with. + * @return the current top map view we are working with or + * <code>null</code> if no map is open + */ + @Nullable + public MapView<G, A, R, V> getCurrentMapView() { + return getFirstMapView(); + } + } // class MapViewManager Added: trunk/src/app/net/sf/gridarta/gui/MapViewManagerListener.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/MapViewManagerListener.java (rev 0) +++ trunk/src/app/net/sf/gridarta/gui/MapViewManagerListener.java 2008-08-08 21:31:28 UTC (rev 4807) @@ -0,0 +1,43 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2007 The Gridarta Developers. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package net.sf.gridarta.gui; + +import net.sf.gridarta.gameobject.Archetype; +import net.sf.gridarta.gameobject.GameObject; +import net.sf.gridarta.gui.map.MapView; +import net.sf.gridarta.gui.map.MapViewBasic; +import net.sf.gridarta.map.MapArchObject; +import org.jetbrains.annotations.Nullable; + +/** + * Interface for listeners interested in events related to {@link + * MapViewManager} instances. + * @author Andreas Kirschbaum + */ +public interface MapViewManagerListener<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>, V extends MapViewBasic<G, A, R, V>> { + + /** + * This event handler is called when the current map view has changed. + * @param mapView the new map view or <code>null</code> if no opened map + * view exists + */ + void currentMapViewChanged(@Nullable MapView<G, A, R, V> mapView); + +} // interface MapViewManagerListener Property changes on: trunk/src/app/net/sf/gridarta/gui/MapViewManagerListener.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF Modified: trunk/src/app/net/sf/gridarta/gui/StatusBar.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/StatusBar.java 2008-08-08 20:03:10 UTC (rev 4806) +++ trunk/src/app/net/sf/gridarta/gui/StatusBar.java 2008-08-08 21:31:28 UTC (rev 4807) @@ -124,11 +124,6 @@ } /** {@inheritDoc} */ - public void currentMapViewChanged(@Nullable final MapView<G, A, R, V> mapView) { - setCurrentMapView(mapView); - } - - /** {@inheritDoc} */ public void mapCreated(@NotNull final MapControl<G, A, R, V> mapControl) { setStatusText("Creating new map " + mapControl.getMapModel().getMapArchObject().getMapDisplayName() + "."); mapControl.addMapControlListener(mapControlListener); @@ -151,6 +146,16 @@ }; + /** The map view manager listener to detect current map changes. */ + private final MapViewManagerListener<G, A, R, V> mapViewManagerListener = new MapViewManagerListener<G, A, R, V>() { + + /** {@inheritDoc} */ + public void currentMapViewChanged(@Nullable final MapView<G, A, R, V> mapView) { + setCurrentMapView(mapView); + } + + }; + /** * The {@link MapControlListener} used to detect saved maps. */ @@ -202,10 +207,11 @@ * Constructs a statusbar that has the given main controller object set as * its controller. * @param mapManager the map manager + * @param mapViewManager the map view manager * @param archetypeSet the archetype set * @param faceObjects the FaceObjects instance to use */ - public StatusBar(@NotNull final MapManager<G, A, R, V> mapManager, @No... [truncated message content] |