From: <aki...@us...> - 2008-07-28 08:37:12
|
Revision: 4538 http://gridarta.svn.sourceforge.net/gridarta/?rev=4538&view=rev Author: akirschbaum Date: 2008-07-28 08:37:19 +0000 (Mon, 28 Jul 2008) Log Message: ----------- Remove calls to MainControl.getMainView(). Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/MapActions.java trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/MapActions.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-07-28 08:27:58 UTC (rev 4537) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-07-28 08:37:19 UTC (rev 4538) @@ -286,7 +286,7 @@ log.fatal("GameObjectMatcher 'exit' does not exist"); throw new MissingResourceException("GameObjectMatcher 'exit' does not exist", null, null); } - mapActions = new MapActions(this, getMapManager(), exitMatcher, mapFileFilter, selectedSquareView); + mapActions = new MapActions(mainView, this, getMapManager(), exitMatcher, mapFileFilter, selectedSquareView); archetypeTypeSet.getListTable().put("event", ScriptArchUtils.getEventTypes()); try { final String filename = IOUtils.getResourceURLAsString(getConfigurationDirectory(), CommonConstants.TYPEDEF_FILE); Modified: trunk/crossfire/src/cfeditor/MapActions.java =================================================================== --- trunk/crossfire/src/cfeditor/MapActions.java 2008-07-28 08:27:58 UTC (rev 4537) +++ trunk/crossfire/src/cfeditor/MapActions.java 2008-07-28 08:37:19 UTC (rev 4538) @@ -24,6 +24,7 @@ import cfeditor.gui.map.CMapViewBasic; import cfeditor.gui.map.MapPropertiesDialog; import cfeditor.map.MapArchObject; +import java.awt.Component; import java.awt.Dimension; import java.awt.Point; import java.awt.Rectangle; @@ -100,6 +101,12 @@ /** Indicates whether autojoining is on/off. */ private boolean autoJoin; + /** + * The component for showing dialog boxes. + */ + @NotNull + private final Component parent; + /** The main control to use. */ private final CMainControl mainControl; @@ -123,13 +130,15 @@ /** * Create a new instance. + * @param parent the component for showing dialog boxes * @param mainControl the main control to use * @param mapManager the map 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(final CMainControl mainControl, 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, final CMainControl mainControl, final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, final GameObjectMatcher exitMatcher, final FileFilter mapFileFilter, @NotNull final SelectedSquareView<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareView) { + this.parent = parent; this.mainControl = mainControl; this.mapManager = mapManager; this.exitMatcher = exitMatcher; @@ -341,10 +350,10 @@ // path points to the same map if (destinationPoint != null) { if (destinationPoint.x == 0 && destinationPoint.y == 0) { - ACTION_FACTORY.showMessageDialog(mainControl.getMainView(), "enterExitNowhere"); + ACTION_FACTORY.showMessageDialog(parent, "enterExitNowhere"); } else if (!currentMap.getMapModel().isPointValid(destinationPoint)) { - ACTION_FACTORY.showMessageDialog(mainControl.getMainView(), "enterExitOutside"); + ACTION_FACTORY.showMessageDialog(parent, "enterExitOutside"); } else { currentMapView.getMapViewBasic().setCursorPosition(destinationPoint); } @@ -358,7 +367,7 @@ // destination is a random map; extract the final non-random map final String destinationMap = getRandomMapParameter(exit, "final_map"); if (destinationMap == null) { - ACTION_FACTORY.showMessageDialog(mainControl.getMainView(), "enterExitRandomDestination"); + ACTION_FACTORY.showMessageDialog(parent, "enterExitRandomDestination"); return; } newfile = new File(mainControl.getGlobalSettings().getMapDir().getAbsolutePath(), destinationMap); @@ -369,7 +378,7 @@ } else { // we have a relative path: if (currentMap.getMapFile() == null) { - ACTION_FACTORY.showMessageDialog(mainControl.getMainView(), "enterExitNotSaved"); + ACTION_FACTORY.showMessageDialog(parent, "enterExitNotSaved"); return; } newfile = new File(currentMap.getMapFile().getParent(), path); @@ -378,7 +387,7 @@ if (!newfile.exists() || newfile.isDirectory()) { // The path is wrong // TODO: Differ between non-existing paths, wrongly formatted paths and directories - give more info to the user. - ACTION_FACTORY.showMessageDialog(mainControl.getMainView(), "enterExitInvalidPath", newfile.getAbsolutePath()); + ACTION_FACTORY.showMessageDialog(parent, "enterExitInvalidPath", newfile.getAbsolutePath()); return; } @@ -390,7 +399,7 @@ try { canonicalNewFile = newfile.getCanonicalFile(); } catch (final IOException e) { - ACTION_FACTORY.showMessageDialog(mainControl.getMainView(), "enterTileIOException", newfile.getAbsolutePath()); + ACTION_FACTORY.showMessageDialog(parent, "enterTileIOException", newfile.getAbsolutePath()); return; } final MapView<GameObject, MapArchObject, Archetype, CMapViewBasic> newMapView = mapManager.openMapFileWithView(canonicalNewFile, null); @@ -409,7 +418,7 @@ newMapView.getMapViewBasic().setViewPosition(calculateNewViewPosition(currentMapView.getMapViewBasic(), newMapView.getMapViewBasic(), direction)); } - if (ACTION_FACTORY.showOnetimeConfirmDialog(mainControl.getMainView(), JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, "enterExitClose") == JOptionPane.YES_OPTION) { + if (ACTION_FACTORY.showOnetimeConfirmDialog(parent, JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, "enterExitClose") == JOptionPane.YES_OPTION) { // only close current level if a new file was opened and user wants to close it mapManager.closeView(currentMapView); } Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-07-28 08:27:58 UTC (rev 4537) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-07-28 08:37:19 UTC (rev 4538) @@ -347,7 +347,7 @@ log.fatal("GameObjectMatcher 'exit' does not exist"); throw new MissingResourceException("GameObjectMatcher 'exit' does not exist", null, null); } - mapActions = new MapActions(this, getMapManager(), exitMatcher, mapFileFilter, selectedSquareView); + mapActions = new MapActions(mainView, this, getMapManager(), exitMatcher, mapFileFilter, selectedSquareView); try { final String filename = IOUtils.getResourceURLAsString(getConfigurationDirectory(), CommonConstants.TYPEDEF_FILE); archetypeTypeSet.loadTypesFromXML(filename); Modified: trunk/daimonin/src/daieditor/MapActions.java =================================================================== --- trunk/daimonin/src/daieditor/MapActions.java 2008-07-28 08:27:58 UTC (rev 4537) +++ trunk/daimonin/src/daieditor/MapActions.java 2008-07-28 08:37:19 UTC (rev 4538) @@ -24,6 +24,7 @@ import daieditor.gui.map.CMapViewBasic; import daieditor.gui.map.MapPropertiesDialog; import daieditor.map.MapArchObject; +import java.awt.Component; import java.awt.Dimension; import java.awt.Point; import java.awt.Rectangle; @@ -96,6 +97,12 @@ /** Indicates whether autojoining is on/off. */ private boolean autoJoin; + /** + * The component for showing dialog boxes. + */ + @NotNull + private final Component parent; + /** The main control to use. */ private final CMainControl mainControl; @@ -119,13 +126,15 @@ /** * Create a new instance. + * @param parent the component for showing dialog boxes * @param mainControl the main control to use * @param mapManager the map 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(final CMainControl mainControl, 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, final CMainControl mainControl, final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, final GameObjectMatcher exitMatcher, final FileFilter mapFileFilter, @NotNull final SelectedSquareView<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareView) { + this.parent = parent; this.mainControl = mainControl; this.mapManager = mapManager; this.exitMatcher = exitMatcher; @@ -340,7 +349,7 @@ } else { // we have a relative path: if (currentMap.getMapFile() == null) { - ACTION_FACTORY.showMessageDialog(mainControl.getMainView(), "enterExitNotSaved"); + ACTION_FACTORY.showMessageDialog(parent, "enterExitNotSaved"); return; } newfile = new File(currentMap.getMapFile().getParent(), path); @@ -349,12 +358,12 @@ // path points to the same map if (destinationPoint != null) { if (destinationPoint.x == 0 && destinationPoint.y == 0) { - ACTION_FACTORY.showMessageDialog(mainControl.getMainView(), "enterExitNowhere"); + ACTION_FACTORY.showMessageDialog(parent, "enterExitNowhere"); } else if (currentMap.getMapModel().isPointValid(destinationPoint)) { currentMapView.getMapViewBasic().setCursorPosition(destinationPoint); } else { - ACTION_FACTORY.showMessageDialog(mainControl.getMainView(), "enterExitOutside"); + ACTION_FACTORY.showMessageDialog(parent, "enterExitOutside"); } } return; @@ -363,7 +372,7 @@ if (!newfile.exists() || newfile.isDirectory()) { // The path is wrong // TODO: Differ between non-existing paths, wrongly formatted paths and directories - give more info to the user. - ACTION_FACTORY.showMessageDialog(mainControl.getMainView(), "enterExitInvalidPath", newfile.getAbsolutePath()); + ACTION_FACTORY.showMessageDialog(parent, "enterExitInvalidPath", newfile.getAbsolutePath()); return; } @@ -375,7 +384,7 @@ try { canonicalNewFile = newfile.getCanonicalFile(); } catch (final IOException e) { - ACTION_FACTORY.showMessageDialog(mainControl.getMainView(), "enterTileIOException", newfile.getAbsolutePath()); + ACTION_FACTORY.showMessageDialog(parent, "enterTileIOException", newfile.getAbsolutePath()); return; } final MapView<GameObject, MapArchObject, Archetype, CMapViewBasic> newMapView = mapManager.openMapFileWithView(canonicalNewFile, null); @@ -394,7 +403,7 @@ newMapView.getMapViewBasic().setViewPosition(calculateNewViewPosition(currentMapView.getMapViewBasic(), newMapView.getMapViewBasic(), direction)); } - if (ACTION_FACTORY.showOnetimeConfirmDialog(mainControl.getMainView(), JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, "enterExitClose") == JOptionPane.YES_OPTION) { + if (ACTION_FACTORY.showOnetimeConfirmDialog(parent, JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, "enterExitClose") == JOptionPane.YES_OPTION) { // only close current level if a new file was opened and user wants to close it mapManager.closeView(currentMapView); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |