From: <aki...@us...> - 2008-08-21 22:36:46
|
Revision: 4975 http://gridarta.svn.sourceforge.net/gridarta/?rev=4975&view=rev Author: akirschbaum Date: 2008-08-21 22:36:51 +0000 (Thu, 21 Aug 2008) Log Message: ----------- Move code to common code base. 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 trunk/src/app/net/sf/gridarta/AbstractMainControl.java trunk/src/app/net/sf/gridarta/MapActions.java trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-08-21 22:24:57 UTC (rev 4974) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-08-21 22:36:51 UTC (rev 4975) @@ -149,9 +149,6 @@ */ public CMainControl(@NotNull final GridartaObjectsFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> gridartaObjectsFactory) { super(gridartaObjectsFactory, new DefaultRendererFactory(), "cfeditor", new GlobalSettingsImpl(), new AnimationObjects(), new FaceObjects(), new DefaultMapControlFactory(gridartaObjectsFactory), false, CResourceLoader.getHomeFile("thumbnails"), null, "DaimoninEditor.jar", pythonFileFilter, ".py", Archetype.TYPE_SPELL, null); - - final MapActions mapActions = new MapActions(mainView, mainView, gridartaObjectsFactory, globalSettings, mapManager, mapViewManager, exitMatcher, mapFileFilter, selectedSquareView); - archetypeTypeSet.getListTable().put("event", ScriptArchUtils.getEventTypes()); Map<String, TreasureTreeNode> specialTreasureLists; try { final Document specialTreasureListsDocument = xmlHelper.getDocumentBuilder().parse(IOUtils.getResourceURLAsString(getConfigurationDirectory(), "TreasureLists.xml")); @@ -252,6 +249,14 @@ /** {@inheritDoc} */ @NotNull @Override + protected MapActions init1() { + archetypeTypeSet.getListTable().put("event", ScriptArchUtils.getEventTypes()); + return new MapActions(mainView, mainView, gridartaObjectsFactory, globalSettings, mapManager, mapViewManager, exitMatcher, mapFileFilter, selectedSquareView); + } + + /** {@inheritDoc} */ + @NotNull + @Override protected DelegatingMapValidator<GameObject, MapArchObject, Archetype> createMapValidators() { final DelegatingMapValidator<GameObject, MapArchObject, Archetype> mapValidators = new DelegatingMapValidator<GameObject, MapArchObject, Archetype>(); final AttributeRangeChecker<GameObject, MapArchObject, Archetype> attributeRangeChecker = new AttributeRangeChecker<GameObject, MapArchObject, Archetype>(); Modified: trunk/crossfire/src/cfeditor/MapActions.java =================================================================== --- trunk/crossfire/src/cfeditor/MapActions.java 2008-08-21 22:24:57 UTC (rev 4974) +++ trunk/crossfire/src/cfeditor/MapActions.java 2008-08-21 22:36:51 UTC (rev 4975) @@ -198,7 +198,7 @@ updateActions(); } - /** Set the state of all actions. */ + /** {@inheritDoc} */ public void updateMenuState() { aAutoJoin.setSelected(autoJoin); } Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-08-21 22:24:57 UTC (rev 4974) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-08-21 22:36:51 UTC (rev 4975) @@ -211,8 +211,6 @@ */ public CMainControl(@NotNull final GridartaObjectsFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> gridartaObjectsFactory) { super(gridartaObjectsFactory, new DefaultRendererFactory(), "daieditor", new GlobalSettingsImpl(), new AnimationObjects(), new FaceObjects(), new DefaultMapControlFactory(gridartaObjectsFactory), true, null, GUIUtils.getSysIcon(IGUIConstants.TILE_NORTH), "CrossfireEditor.jar", luaFileFilter, ".lua", 0, IGUIConstants.SPELL_FILE); - - final MapActions mapActions = new MapActions(mainView, mainView, gridartaObjectsFactory, (GlobalSettingsImpl) globalSettings, mapManager, mapViewManager, exitMatcher, mapFileFilter, selectedSquareView); Map<String, TreasureTreeNode> specialTreasureLists; try { final Document specialTreasureListsDocument = xmlHelper.getDocumentBuilder().parse(IOUtils.getResourceURLAsString(getConfigurationDirectory(), "TreasureLists.xml")); @@ -331,6 +329,13 @@ /** {@inheritDoc} */ @NotNull @Override + protected MapActions init1() { + return new MapActions(mainView, mainView, gridartaObjectsFactory, globalSettings, mapManager, mapViewManager, exitMatcher, mapFileFilter, selectedSquareView); + } + + /** {@inheritDoc} */ + @NotNull + @Override protected DelegatingMapValidator<GameObject, MapArchObject, Archetype> createMapValidators() { final DelegatingMapValidator<GameObject, MapArchObject, Archetype> mapValidators = new DelegatingMapValidator<GameObject, MapArchObject, Archetype>(); final CustomTypeChecker<GameObject, MapArchObject, Archetype> customTypeChecker = new CustomTypeChecker<GameObject, MapArchObject, Archetype>(); Modified: trunk/daimonin/src/daieditor/MapActions.java =================================================================== --- trunk/daimonin/src/daieditor/MapActions.java 2008-08-21 22:24:57 UTC (rev 4974) +++ trunk/daimonin/src/daieditor/MapActions.java 2008-08-21 22:36:51 UTC (rev 4975) @@ -152,7 +152,7 @@ * @param mapFileFilter the Swing file filter to use * @param selectedSquareView the selected square vuew to use */ - public MapActions(@NotNull final Component parent, @NotNull final JFrame helpParent, @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) { + public MapActions(@NotNull final Component parent, @NotNull final JFrame helpParent, @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.helpParent = helpParent; this.gridartaObjectsFactory = gridartaObjectsFactory; @@ -194,7 +194,7 @@ updateActions(); } - /** Set the state of all actions. */ + /** {@inheritDoc} */ public void updateMenuState() { aAutoJoin.setSelected(autoJoin); } Modified: trunk/src/app/net/sf/gridarta/AbstractMainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2008-08-21 22:24:57 UTC (rev 4974) +++ trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2008-08-21 22:36:51 UTC (rev 4975) @@ -134,6 +134,12 @@ /** Swing FileFilter for all unignored files. */ public static final FileFilter unignoredFilter = new HideFileFilterProxy(new EndingFileFilter(true, ACTION_FACTORY.getString("fileDialog.filter.unignored"), "")); + /** + * The gridarta objects factory. + */ + @NotNull + protected final GridartaObjectsFactory<G, A, R, V> gridartaObjectsFactory; + /** The map control factory. */ protected final MapControlFactory<G, A, R, V> mapControlFactory; @@ -275,6 +281,9 @@ @NotNull protected final GameObjectMatcher exitMatcher; + @NotNull + protected final MapActions mapActions; + /** * Creates a new instance. * @param gridartaObjectsFactory the gridarta objects factory @@ -298,6 +307,7 @@ * load numbered spells */ protected AbstractMainControl(@NotNull final GridartaObjectsFactory<G, A, R, V> gridartaObjectsFactory, @NotNull final RendererFactory<G, A, R> rendererFactory, @NotNull final String key, @NotNull final GlobalSettings globalSettings, @NotNull final AnimationObjects<? extends AnimationObject> animationObjects, @NotNull final FaceObjects faceObjects, @NotNull final MapControlFactory<G, A, R, V> mapControlFactory, final boolean createDirectionPane, @Nullable final File mapImageCacheDir, @Nullable final ImageIcon compassIcon, @NotNull final String gridartaJarFilename, @NotNull final FileFilter scriptFileFilter, @NotNull final String scriptExtension, final int spellType, @Nullable final String spellFile) { + this.gridartaObjectsFactory = gridartaObjectsFactory; this.globalSettings = globalSettings; this.mapControlFactory = mapControlFactory; final DefaultMapManager<G, A, R, V> tmpMapManager = new DefaultMapManager<G, A, R, V>(this, key, gridartaObjectsFactory, mapControlFactory, globalSettings); @@ -382,8 +392,12 @@ log.fatal("GameObjectMatcher 'exit' does not exist"); throw new MissingResourceException("GameObjectMatcher 'exit' does not exist", null, null); } + mapActions = init1(); } + @NotNull + protected abstract MapActions init1(); + /** * Initializes the map validators. * @return A MapValidator that delegates to other map validators. Modified: trunk/src/app/net/sf/gridarta/MapActions.java =================================================================== --- trunk/src/app/net/sf/gridarta/MapActions.java 2008-08-21 22:24:57 UTC (rev 4974) +++ trunk/src/app/net/sf/gridarta/MapActions.java 2008-08-21 22:36:51 UTC (rev 4975) @@ -32,4 +32,9 @@ */ boolean isAutoJoin(); + /** + * Sets the state of all actions. + */ + void updateMenuState(); + } // interface MapActions Modified: trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java =================================================================== --- trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java 2008-08-21 22:24:57 UTC (rev 4974) +++ trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java 2008-08-21 22:36:51 UTC (rev 4975) @@ -496,6 +496,13 @@ /** {@inheritDoc} */ @NotNull @Override + protected MapActions init1() { + throw new AssertionError(); + } + + /** {@inheritDoc} */ + @NotNull + @Override protected DelegatingMapValidator<TestGameObject, TestMapArchObject, TestArchetype> createMapValidators() { throw new AssertionError(); } @@ -966,6 +973,11 @@ return false; } + /** {@inheritDoc} */ + public void updateMenuState() { + throw new AssertionError(); + } + } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |