From: <aki...@us...> - 2008-04-01 08:29:10
|
Revision: 3797 http://gridarta.svn.sourceforge.net/gridarta/?rev=3797&view=rev Author: akirschbaum Date: 2008-04-01 01:28:59 -0700 (Tue, 01 Apr 2008) Log Message: ----------- Add View|Show Only menu to DaimoninEditor. Allows to restrict the game objects shown on the map view. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/messages.properties trunk/crossfire/src/cfeditor/messages_de.properties trunk/crossfire/src/cfeditor/messages_fr.properties trunk/crossfire/src/cfeditor/messages_sv.properties trunk/daimonin/ChangeLog trunk/daimonin/src/daieditor/CMainView.java trunk/daimonin/src/daieditor/action.properties trunk/daimonin/src/daieditor/messages.properties trunk/daimonin/src/daieditor/messages_de.properties trunk/daimonin/src/daieditor/messages_fr.properties trunk/daimonin/src/daieditor/messages_sv.properties trunk/src/app/net/sf/gridarta/AbstractMainControl.java trunk/src/app/net/sf/gridarta/messages.properties trunk/src/app/net/sf/gridarta/messages_de.properties trunk/src/app/net/sf/gridarta/messages_fr.properties trunk/src/app/net/sf/gridarta/messages_sv.properties Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-04-01 00:03:43 UTC (rev 3796) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-04-01 08:28:59 UTC (rev 3797) @@ -488,27 +488,6 @@ treasureListTree.showDialog(); } - /** {@inheritDoc} */ - @Override public void setEditType(final int editType) { - if ((this.editType & editType) == editType) { - return; - } - - super.setEditType(editType); - - getMapManager().addEditType(editType); - } - - /** {@inheritDoc} */ - @Override public void unsetEditType(final int editType) { - if ((this.editType & editType) == 0) { - return; - } - - super.unsetEditType(editType); - getMapManager().refreshCurrentMap(); - } - public void onlineHelp() { mainView.openHelpWindow(); } Modified: trunk/crossfire/src/cfeditor/messages.properties =================================================================== --- trunk/crossfire/src/cfeditor/messages.properties 2008-04-01 00:03:43 UTC (rev 3796) +++ trunk/crossfire/src/cfeditor/messages.properties 2008-04-01 08:28:59 UTC (rev 3797) @@ -261,13 +261,6 @@ enabled.text= -####### -# View - -view.text=View -view.mnemonic=V - - ######### # Plugins Modified: trunk/crossfire/src/cfeditor/messages_de.properties =================================================================== --- trunk/crossfire/src/cfeditor/messages_de.properties 2008-04-01 00:03:43 UTC (rev 3796) +++ trunk/crossfire/src/cfeditor/messages_de.properties 2008-04-01 08:28:59 UTC (rev 3797) @@ -238,13 +238,6 @@ enabled.text= -####### -# View - -view.text=Ansicht -view.mnemonic=A - - ######### # Plugins Modified: trunk/crossfire/src/cfeditor/messages_fr.properties =================================================================== --- trunk/crossfire/src/cfeditor/messages_fr.properties 2008-04-01 00:03:43 UTC (rev 3796) +++ trunk/crossfire/src/cfeditor/messages_fr.properties 2008-04-01 08:28:59 UTC (rev 3797) @@ -239,13 +239,6 @@ #enabled.text= -####### -# View - -view.text=Affichage -view.mnemonic=A - - ######### # Plugins Modified: trunk/crossfire/src/cfeditor/messages_sv.properties =================================================================== --- trunk/crossfire/src/cfeditor/messages_sv.properties 2008-04-01 00:03:43 UTC (rev 3796) +++ trunk/crossfire/src/cfeditor/messages_sv.properties 2008-04-01 08:28:59 UTC (rev 3797) @@ -237,13 +237,6 @@ #enabled.text= -####### -# View - -view.text=Visning -view.mnemonic=V - - ######### # Plugins Modified: trunk/daimonin/ChangeLog =================================================================== --- trunk/daimonin/ChangeLog 2008-04-01 00:03:43 UTC (rev 3796) +++ trunk/daimonin/ChangeLog 2008-04-01 08:28:59 UTC (rev 3797) @@ -1,3 +1,8 @@ +2008-04-01 Andreas Kirschbaum + + * Add View|Show Only menu. Allows to restrict the game objects + shown on the map view. + 2008-03-29 Andreas Kirschbaum * Change modifier keys for tile selection: Modified: trunk/daimonin/src/daieditor/CMainView.java =================================================================== --- trunk/daimonin/src/daieditor/CMainView.java 2008-04-01 00:03:43 UTC (rev 3796) +++ trunk/daimonin/src/daieditor/CMainView.java 2008-04-01 08:28:59 UTC (rev 3797) @@ -52,6 +52,7 @@ import net.sf.gridarta.gui.NewMapDialogFactory; import net.sf.gridarta.gui.connectionview.LockedItemsControl; import net.sf.gridarta.gui.map.MapView; +import net.sf.gridarta.gui.map.ViewActions; import net.sf.gridarta.gui.selectedsquare.SelectedSquareControl; import net.sf.japi.swing.ActionFactory; import net.sf.japi.util.ThrowableHandler; @@ -117,6 +118,8 @@ /** Action for "next window". */ private final Action aNextWindow = ACTION_FACTORY.createAction(true, "nextWindow", this); + private final ViewActions<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> viewActions; + private final MapActions mapActions; /** The actions of the "Archetypes" menu. */ @@ -150,6 +153,7 @@ aViewTreasurelists = ACTION_FACTORY.createAction(true, "viewTreasurelists", mainControl); this.aCloseAll = aCloseAll; + viewActions = new ViewActions<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(mainControl, mapManager); mapActions = new MapActions(mainControl, mapManager); final ImageIcon icon = GUIUtils.getIcon(IGUIConstants.APP_ICON); Modified: trunk/daimonin/src/daieditor/action.properties =================================================================== --- trunk/daimonin/src/daieditor/action.properties 2008-04-01 00:03:43 UTC (rev 3796) +++ trunk/daimonin/src/daieditor/action.properties 2008-04-01 08:28:59 UTC (rev 3797) @@ -37,8 +37,8 @@ #view.menu=+lafs - changeFont - showMonsters showExits showBackground showDoorsKeys showWall showEquipment showTreasure showConnected resetShow #view.menu=changeFont - viewShow viewAlpha #view.menu=viewShow viewAlpha gridVisible drawDouble - prevWindow nextWindow -view.menu=gridVisible drawDouble - prevWindow nextWindow -#viewShow.menu = showMonsters showExits showBackground showDoorsKeys showWall showEquipment showTreasure showConnected resetShow +view.menu=viewShow gridVisible drawDouble - prevWindow nextWindow +viewShow.menu=showMonster showExit showBackground showDoor showWall showEquipment showTreasure showConnected resetView #viewAlpha.menu = alphaMonsters alphaExits alphaBackground alphaDoorsKeys alphaWall alphaEquipment alphaTreasure alphaConnected resetAlpha #window.menu=newWindow - closeAll +windows window.menu=closeAll Modified: trunk/daimonin/src/daieditor/messages.properties =================================================================== --- trunk/daimonin/src/daieditor/messages.properties 2008-04-01 00:03:43 UTC (rev 3796) +++ trunk/daimonin/src/daieditor/messages.properties 2008-04-01 08:28:59 UTC (rev 3797) @@ -373,41 +373,14 @@ view.text=View view.mnemonic=V -#viewShow.text=Show Only -#viewShow.shortdescription=Select some filters to be drawn exclusively -#viewShow.mnemonic=S +viewShow.text=Show Only +viewShow.shortdescription=Select some filters to be drawn exclusively +viewShow.mnemonic=S #viewAlpha.text=Show transparent #viewAlpha.shortdescription=Select some filters to be drawn transparent #viewAlpha.mnemonic=T -#showMonsters.text=Monsters -#showMonsters.mnemonic=M - -#showExits.text=Exits -#showExits.mnemonic=E - -#showBackground.text=Background -#showBackground.mnemonic=B - -#showDoorsKeys.text=Doors & Keys -#showDoorsKeys.mnemonic=D - -#showWall.text=Walls -#showWall.mnemonic=W - -#showEquipment.text=Equipment -#showEquipment.mnemonic=Q - -#showTreasure.text=Treasure -#showTreasure.mnemonic=T - -#showConnected.text=Connected -#showConnected.mnemonic=C - -#resetShow.text=Reset Show -#resetShow.mnemonic=R - #alphaMonsters.text=Monsters #alphaMonsters.mnemonic=M Modified: trunk/daimonin/src/daieditor/messages_de.properties =================================================================== --- trunk/daimonin/src/daieditor/messages_de.properties 2008-04-01 00:03:43 UTC (rev 3796) +++ trunk/daimonin/src/daieditor/messages_de.properties 2008-04-01 08:28:59 UTC (rev 3797) @@ -345,41 +345,14 @@ view.text=Ansicht view.mnemonic=A -#viewShow.text=Zeige nur -#viewShow.shortdescription= -#viewShow.mnemonic= +viewShow.text=Zeige nur +viewShow.shortdescription= +viewShow.mnemonic=Z #viewAlpha.text=Durchsichtig #viewAlpha.shortdescription= #viewAlpha.mnemonic= -#showMonsters.text=Zeige Monster -#showMonsters.mnemonic=M - -#showExits.text=Zeige Ausg\xE4nge -#showExits.mnemonic= - -#showBackground.text=Zeige Hintergrund -#showBackground.mnemonic= - -#showDoorsKeys.text=Zeige T\xFCren und Schl\xFCssel -#showDoorsKeys.mnemonic= - -#showWall.text=Zeige W\xE4nde -#showWall.mnemonic= - -#showEquipment.text=Zeige Ausr\xFCstung -#showEquipment.mnemonic= - -#showTreasure.text=Zeige Sch\xE4tze -#showTreasure.mnemonic= - -#showConnected.text=Zeige Verbindungen -#showConnected.mnemonic= - -#resetShow.text=Ansicht zur\xFCcksetzen -#resetShow.mnemonic= - #alphaMonsters.text=Durchsichtige Monster #alphaMonsters.mnemonic= Modified: trunk/daimonin/src/daieditor/messages_fr.properties =================================================================== --- trunk/daimonin/src/daieditor/messages_fr.properties 2008-04-01 00:03:43 UTC (rev 3796) +++ trunk/daimonin/src/daieditor/messages_fr.properties 2008-04-01 08:28:59 UTC (rev 3797) @@ -347,37 +347,6 @@ #viewShow.shortdescription= #viewShow.mnemonic= -#viewAlpha.text= -#viewAlpha.shortdescription= -#viewAlpha.mnemonic= - -#showMonsters.text=Afficher monstres -#showMonsters.mnemonic=M - -#showExits.text=Afficher sorties -#showExits.mnemonic=S - -#showBackground.text=Afficher fond -#showBackground.mnemonic=F - -#showDoorsKeys.text=Afficher portes et cl\xE9s -#showDoorsKeys.mnemonic=P - -#showWall.text=Afficher murs -#showWall.mnemonic=M - -#showEquipment.text=Afficher \xE9quipement -#showEquipment.mnemonic=E - -#showTreasure.text=Afficher tr\xE9sors -#showTreasure.mnemonic=T - -#showConnected.text=Afficher objets connect\xE9s -#showConnected.mnemonic=C - -#resetShow.text=Vue normale -#resetShow.mnemonic=N - #alphaMonsters.text= #alphaMonsters.mnemonic= Modified: trunk/daimonin/src/daieditor/messages_sv.properties =================================================================== --- trunk/daimonin/src/daieditor/messages_sv.properties 2008-04-01 00:03:43 UTC (rev 3796) +++ trunk/daimonin/src/daieditor/messages_sv.properties 2008-04-01 08:28:59 UTC (rev 3797) @@ -347,41 +347,10 @@ view.text=Visning view.mnemonic=V -#viewShow.text=Visa endast -#viewShow.shortdescription=V\xE4lj kategorier att visa exklusivt -#viewShow.mnemonic=S +viewShow.text=Visa endast +viewShow.shortdescription=V\xE4lj kategorier att visa exklusivt +viewShow.mnemonic=V -#viewAlpha.text=Visa genomskinligt -#viewAlpha.shortdescription=V\xE4lj kategorier att visa genomskinligt -#viewAlpha.mnemonic=T - -#showMonsters.text=Monster -#showMonsters.mnemonic=M - -#showExits.text=Utg\xE5ngar -#showExits.mnemonic=U - -#showBackground.text=Bakgrund -#showBackground.mnemonic=B - -#showDoorsKeys.text=D\xF6rrar och nycklar -#showDoorsKeys.mnemonic=D - -#showWall.text=V\xE4ggar -#showWall.mnemonic=V - -#showEquipment.text=Utrustning -#showEquipment.mnemonic=R - -#showTreasure.text=Skatter -#showTreasure.mnemonic=S - -#showConnected.text=Anslutna -#showConnected.mnemonic=A - -#resetShow.text=\xC5terst\xE4ll visning -#resetShow.mnemonic=\xC5 - #alphaMonsters.text=Monster #alphaMonsters.mnemonic=M Modified: trunk/src/app/net/sf/gridarta/AbstractMainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2008-04-01 00:03:43 UTC (rev 3796) +++ trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2008-04-01 08:28:59 UTC (rev 3797) @@ -133,12 +133,23 @@ /** {@inheritDoc} */ public void setEditType(final int editType) { + if ((this.editType & editType) == editType) { + return; + } + this.editType |= editType; + + getMapManager().addEditType(editType); } /** {@inheritDoc} */ public void unsetEditType(final int editType) { + if ((this.editType & editType) == 0) { + return; + } + this.editType &= ~editType; + getMapManager().refreshCurrentMap(); } /** {@inheritDoc} */ Modified: trunk/src/app/net/sf/gridarta/messages.properties =================================================================== --- trunk/src/app/net/sf/gridarta/messages.properties 2008-04-01 00:03:43 UTC (rev 3796) +++ trunk/src/app/net/sf/gridarta/messages.properties 2008-04-01 08:28:59 UTC (rev 3797) @@ -514,6 +514,9 @@ ###### # View +view.text=View +view.mnemonic=V + showMonster.text=Show monsters showMonster.mnemonic=M Modified: trunk/src/app/net/sf/gridarta/messages_de.properties =================================================================== --- trunk/src/app/net/sf/gridarta/messages_de.properties 2008-04-01 00:03:43 UTC (rev 3796) +++ trunk/src/app/net/sf/gridarta/messages_de.properties 2008-04-01 08:28:59 UTC (rev 3797) @@ -478,6 +478,9 @@ ###### # View +view.text=Ansicht +view.mnemonic=A + showMonster.text=Monster anzeigen showMonster.mnemonic=M Modified: trunk/src/app/net/sf/gridarta/messages_fr.properties =================================================================== --- trunk/src/app/net/sf/gridarta/messages_fr.properties 2008-04-01 00:03:43 UTC (rev 3796) +++ trunk/src/app/net/sf/gridarta/messages_fr.properties 2008-04-01 08:28:59 UTC (rev 3797) @@ -477,6 +477,9 @@ ###### # View +view.text=Affichage +view.mnemonic=A + showMonster.text=Afficher monstres showMonster.mnemonic=M Modified: trunk/src/app/net/sf/gridarta/messages_sv.properties =================================================================== --- trunk/src/app/net/sf/gridarta/messages_sv.properties 2008-04-01 00:03:43 UTC (rev 3796) +++ trunk/src/app/net/sf/gridarta/messages_sv.properties 2008-04-01 08:28:59 UTC (rev 3797) @@ -476,6 +476,9 @@ ###### # View +view.text=Visning +view.mnemonic=V + showMonster.text=Monster showMonster.mnemonic=M This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-04-01 20:11:01
|
Revision: 3800 http://gridarta.svn.sourceforge.net/gridarta/?rev=3800&view=rev Author: akirschbaum Date: 2008-04-01 13:10:00 -0700 (Tue, 01 Apr 2008) Log Message: ----------- Retain main window's state (maximized, iconized, etc.) across editor restarts. Modified Paths: -------------- trunk/crossfire/ChangeLog trunk/crossfire/src/cfeditor/CMainView.java trunk/src/app/net/sf/gridarta/messages.properties Modified: trunk/crossfire/ChangeLog =================================================================== --- trunk/crossfire/ChangeLog 2008-04-01 19:51:13 UTC (rev 3799) +++ trunk/crossfire/ChangeLog 2008-04-01 20:10:00 UTC (rev 3800) @@ -1,3 +1,8 @@ +2008-04-01 Andreas Kirschbaum + + * Retain main window's state (maximized, iconized, etc.) across + editor restarts. + 2008-03-29 Andreas Kirschbaum * Change modifier keys for tile selection: Modified: trunk/crossfire/src/cfeditor/CMainView.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainView.java 2008-04-01 19:51:13 UTC (rev 3799) +++ trunk/crossfire/src/cfeditor/CMainView.java 2008-04-01 20:10:00 UTC (rev 3800) @@ -80,6 +80,9 @@ /** Preferences. */ private static final Preferences prefs = Preferences.userNodeForPackage(MainControl.class); + /** The key used to store the main window state in the preferences. */ + private static final String WINDOW_STATE = "WindowState"; + /** Default value for {@link #MAP_TILE_LIST_BOTTOM_KEY}. */ public static final boolean MAP_TILE_LIST_BOTTOM_DEFAULT = false; @@ -185,6 +188,7 @@ prefs.getInt(WINDOW_Y, (int) (screen.getY() + (screen.getHeight() - defheight) / 2.0)), prefs.getInt(WINDOW_WIDTH, defwidth), prefs.getInt(WINDOW_HEIGHT, defheight)); + setExtendedState(prefs.getInt(WINDOW_STATE, getExtendedState())); refreshMenus(); } @@ -252,6 +256,7 @@ prefs.putInt(DIVIDER_LOCATION_KEY, splitPane.getDividerLocation()); prefs.putInt(DIVIDER_LOCATION_KEY2, splitDownPane.getDividerLocation()); prefs.putInt(DIVIDER_LOCATION_KEY3, splitRightPane.getDividerLocation()); + prefs.putInt(WINDOW_STATE, getExtendedState()); objectChooser.appExitNotify(); gameObjectAttributesPanel.appExitNotify(); Modified: trunk/src/app/net/sf/gridarta/messages.properties =================================================================== --- trunk/src/app/net/sf/gridarta/messages.properties 2008-04-01 19:51:13 UTC (rev 3799) +++ trunk/src/app/net/sf/gridarta/messages.properties 2008-04-01 20:10:00 UTC (rev 3800) @@ -639,6 +639,7 @@ prefs.Validator.SysObjectNotOnLayerZero=Whether this map validator check is is enabled. prefs.Validator.UndefinedArchetype=Whether this map validator check is is enabled. prefs.Validator.UnsetSlaying=Whether this map validator check is is enabled. +prefs.WindowState=Main windows''s state (maximized, iconized, etc.) ############### This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-04-01 21:52:39
|
Revision: 3805 http://gridarta.svn.sourceforge.net/gridarta/?rev=3805&view=rev Author: akirschbaum Date: 2008-04-01 14:51:46 -0700 (Tue, 01 Apr 2008) Log Message: ----------- Unify code. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/CMainView.java trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/CMainView.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-04-01 21:31:37 UTC (rev 3804) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-04-01 21:51:46 UTC (rev 3805) @@ -244,7 +244,7 @@ mapCursorControl = new MapCursorControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>("cfeditor", this, getMapManager()); ACTION_FACTORY.createActions(true, this, "createNew", "open", "options", "exit", "gc", "onlineHelp", "tod", "about"); mapManagerActions = new MapManagerActions<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(getMapManager()); - mainView = new CMainView(this, getMapManager(), mapManagerActions.getCloseAllAction()); + mainView = new CMainView(this, getMapManager(), ACTION_FACTORY, mapManagerActions.getCloseAllAction()); new About("cfeditor", mainView); undoControl = new UndoControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(getMapManager()); updaterManager = new UpdaterManager("cfeditor", this, mainView, "CrossfireEditor.jar"); Modified: trunk/crossfire/src/cfeditor/CMainView.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainView.java 2008-04-01 21:31:37 UTC (rev 3804) +++ trunk/crossfire/src/cfeditor/CMainView.java 2008-04-01 21:51:46 UTC (rev 3805) @@ -69,7 +69,7 @@ public final class CMainView extends MainView<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> { /** Action Factory to create Actions. */ - private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("cfeditor"); + private final ActionFactory actionFactory; /** Serial Version UID. */ private static final long serialVersionUID = 1L; @@ -110,10 +110,10 @@ private final Action aCloseAll; /** Action for "prev window". */ - private final Action aPrevWindow = ACTION_FACTORY.createAction(true, "prevWindow", this); + private final Action aPrevWindow; /** Action for "next window". */ - private final Action aNextWindow = ACTION_FACTORY.createAction(true, "nextWindow", this); + private final Action aNextWindow; private final ViewActions<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> viewActions; @@ -141,13 +141,17 @@ * Constructs the main view and registers the given main controller. * @param mainControl MainControl to attach to. * @param mapManager the map manager + * @param actionFactory the action factory to use * @param aCloseAll the action "close all map windows" */ - CMainView(@NotNull final CMainControl mainControl, @NotNull final MapManager<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> mapManager, @NotNull final Action aCloseAll) { - super(mainControl, mapManager, ACTION_FACTORY.format("mainWindow.title")); + CMainView(@NotNull final CMainControl mainControl, @NotNull final MapManager<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> mapManager, @NotNull final ActionFactory actionFactory, @NotNull final Action aCloseAll) { + super(mainControl, mapManager, actionFactory.format("mainWindow.title")); this.mainControl = mainControl; - aViewTreasurelists = ACTION_FACTORY.createAction(true, "viewTreasurelists", mainControl); + this.actionFactory = actionFactory; + aViewTreasurelists = actionFactory.createAction(true, "viewTreasurelists", mainControl); this.aCloseAll = aCloseAll; + aPrevWindow = actionFactory.createAction(true, "prevWindow", this); + aNextWindow = actionFactory.createAction(true, "nextWindow", this); viewActions = new ViewActions<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(mainControl, mapManager); mapActions = new MapActions(mainControl, mapManager); @@ -178,7 +182,7 @@ add(toolbarPanel, BorderLayout.CENTER); archetypesActions = new ArchetypesActions<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(this, objectChooser.getArchetypeChooserControl(), mainControl.getArchetypeSet(), objectChooser); - setJMenuBar(ACTION_FACTORY.createMenuBar(true, "main")); + setJMenuBar(actionFactory.createMenuBar(true, "main")); mapActions.updateMenuState(); @@ -198,7 +202,7 @@ * @return the toolbar */ private JToolBar createMainToolbar() { - final JToolBar toolbar = ACTION_FACTORY.createToolBar("main"); + final JToolBar toolbar = actionFactory.createToolBar("main"); prefs.addPreferenceChangeListener(preferenceChangeListener); toolbar.setVisible(prefs.getBoolean(SHOW_MAIN_TOOLBAR_KEY, SHOW_MAIN_TOOLBAR_DEFAULT)); return toolbar; @@ -327,7 +331,7 @@ try { mapView.setIcon(false); } catch (final PropertyVetoException e) { - log.warn(ACTION_FACTORY.format("logUnexpectedException", e)); + log.warn(actionFactory.format("logUnexpectedException", e)); } activateAndRaiseMapView(mapView); return; @@ -382,7 +386,7 @@ try { mapView.setIcon(false); } catch (final PropertyVetoException e) { - log.warn(ACTION_FACTORY.format("logUnexpectedException", e)); + log.warn(actionFactory.format("logUnexpectedException", e)); } activateMapView(mapView); return; @@ -421,7 +425,7 @@ * Rebuild the window menu. */ private void rebuildWindowMenu() { - final JMenu menuWindow = (JMenu) ACTION_FACTORY.find(getJMenuBar(), "window"); + final JMenu menuWindow = (JMenu) actionFactory.find(getJMenuBar(), "window"); MenuHelper.removeAll(menuWindow); menuWindow.add(aCloseAll); if (!mapViews.isEmpty()) { Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-04-01 21:31:37 UTC (rev 3804) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-04-01 21:51:46 UTC (rev 3805) @@ -293,7 +293,7 @@ ACTION_FACTORY.createActions(true, this, "createNew", "open", "options", "exit", "newScript", "editScript", "controlServer", "controlClient", "cleanCompletelyBlockedSquares", "zoom", "gc", "onlineHelp", "tod", "about"); ACTION_FACTORY.createToggles(true, this, "drawDouble"); mapManagerActions = new MapManagerActions<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(getMapManager()); - mainView = new CMainView(this, getMapManager(), mapManagerActions.getCloseAllAction()); + mainView = new CMainView(this, getMapManager(), ACTION_FACTORY, mapManagerActions.getCloseAllAction()); new About("daieditor", mainView); undoControl = new UndoControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(getMapManager()); updaterManager = new UpdaterManager("daieditor", this, mainView, "DaimoninEditor.jar"); Modified: trunk/daimonin/src/daieditor/CMainView.java =================================================================== --- trunk/daimonin/src/daieditor/CMainView.java 2008-04-01 21:31:37 UTC (rev 3804) +++ trunk/daimonin/src/daieditor/CMainView.java 2008-04-01 21:51:46 UTC (rev 3805) @@ -70,7 +70,7 @@ public final class CMainView extends MainView<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> implements ThrowableHandler { /** Action Factory to create Actions. */ - private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("daieditor"); + private final ActionFactory actionFactory; /** Serial Version UID. */ private static final long serialVersionUID = 1L; @@ -113,10 +113,10 @@ private final Action aCloseAll; /** Action for "prev window". */ - private final Action aPrevWindow = ACTION_FACTORY.createAction(true, "prevWindow", this); + private final Action aPrevWindow; /** Action for "next window". */ - private final Action aNextWindow = ACTION_FACTORY.createAction(true, "nextWindow", this); + private final Action aNextWindow; private final ViewActions<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> viewActions; @@ -144,14 +144,18 @@ * Constructs the main view and registers the given main controller. * @param mainControl MainControl to attach to. * @param mapManager the map manager + * @param actionFactory the action factory to use * @param aCloseAll the action "close all map windows" */ - CMainView(@NotNull final CMainControl mainControl, @NotNull final MapManager<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> mapManager, @NotNull final Action aCloseAll) { - super(mainControl, mapManager, ACTION_FACTORY.format("mainWindow.title", CMainControl.getBuildNumberAsString())); + CMainView(@NotNull final CMainControl mainControl, @NotNull final MapManager<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> mapManager, @NotNull final ActionFactory actionFactory, @NotNull final Action aCloseAll) { + super(mainControl, mapManager, actionFactory.format("mainWindow.title", CMainControl.getBuildNumberAsString())); this.mainControl = mainControl; - aCollectSpells = ACTION_FACTORY.createAction(true, "collectSpells", mainControl); - aViewTreasurelists = ACTION_FACTORY.createAction(true, "viewTreasurelists", mainControl); + this.actionFactory = actionFactory; + aCollectSpells = actionFactory.createAction(true, "collectSpells", mainControl); + aViewTreasurelists = actionFactory.createAction(true, "viewTreasurelists", mainControl); this.aCloseAll = aCloseAll; + aPrevWindow = actionFactory.createAction(true, "prevWindow", this); + aNextWindow = actionFactory.createAction(true, "nextWindow", this); viewActions = new ViewActions<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(mainControl, mapManager); mapActions = new MapActions(mainControl, mapManager); @@ -182,7 +186,7 @@ add(toolbarPanel, BorderLayout.CENTER); archetypesActions = new ArchetypesActions<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(this, objectChooser.getArchetypeChooserControl(), mainControl.getArchetypeSet(), objectChooser); - setJMenuBar(ACTION_FACTORY.createMenuBar(true, "main")); + setJMenuBar(actionFactory.createMenuBar(true, "main")); mapActions.updateMenuState(); @@ -202,7 +206,7 @@ * @return the toolbar */ private JToolBar createMainToolbar() { - final JToolBar toolbar = ACTION_FACTORY.createToolBar("main"); + final JToolBar toolbar = actionFactory.createToolBar("main"); prefs.addPreferenceChangeListener(preferenceChangeListener); toolbar.setVisible(prefs.getBoolean(SHOW_MAIN_TOOLBAR_KEY, SHOW_MAIN_TOOLBAR_DEFAULT)); return toolbar; @@ -331,7 +335,7 @@ try { mapView.setIcon(false); } catch (final PropertyVetoException e) { - log.warn(ACTION_FACTORY.format("logUnexpectedException", e)); + log.warn(actionFactory.format("logUnexpectedException", e)); } activateAndRaiseMapView(mapView); return; @@ -386,7 +390,7 @@ try { mapView.setIcon(false); } catch (final PropertyVetoException e) { - log.warn(ACTION_FACTORY.format("logUnexpectedException", e)); + log.warn(actionFactory.format("logUnexpectedException", e)); } activateMapView(mapView); return; @@ -425,7 +429,7 @@ * Rebuild the window menu. */ private void rebuildWindowMenu() { - final JMenu menuWindow = (JMenu) ACTION_FACTORY.find(getJMenuBar(), "window"); + final JMenu menuWindow = (JMenu) actionFactory.find(getJMenuBar(), "window"); MenuHelper.removeAll(menuWindow); menuWindow.add(aCloseAll); if (!mapViews.isEmpty()) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-04-01 22:01:16
|
Revision: 3806 http://gridarta.svn.sourceforge.net/gridarta/?rev=3806&view=rev Author: akirschbaum Date: 2008-04-01 15:01:14 -0700 (Tue, 01 Apr 2008) Log Message: ----------- Unify code. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainView.java trunk/daimonin/src/daieditor/CMainView.java trunk/src/app/net/sf/gridarta/gui/selectedsquare/SelectedSquareControl.java trunk/src/app/net/sf/gridarta/gui/selectedsquare/SelectedSquareView.java Modified: trunk/crossfire/src/cfeditor/CMainView.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainView.java 2008-04-01 21:51:46 UTC (rev 3805) +++ trunk/crossfire/src/cfeditor/CMainView.java 2008-04-01 22:01:14 UTC (rev 3806) @@ -224,7 +224,7 @@ objectChooser = new InsertionObjectChooser(newMapDialogFactory, mainControl); final boolean mapTileListBottom = prefs.getBoolean(MainView.MAP_TILE_LIST_BOTTOM_KEY, CMainView.MAP_TILE_LIST_BOTTOM_DEFAULT); - selectedSquareControl = new SelectedSquareControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>("cfeditor", mainControl, this, mapTileListBottom, null); + selectedSquareControl = new SelectedSquareControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(actionFactory, mainControl, this, mapTileListBottom, null); final LockedItemsControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> lockedItemsControl = new LockedItemsControl<GameObject, MapArchObject, Archetype, MapControl, 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(mainControl, mapManager, this, lockedItemsControl); Modified: trunk/daimonin/src/daieditor/CMainView.java =================================================================== --- trunk/daimonin/src/daieditor/CMainView.java 2008-04-01 21:51:46 UTC (rev 3805) +++ trunk/daimonin/src/daieditor/CMainView.java 2008-04-01 22:01:14 UTC (rev 3806) @@ -228,7 +228,7 @@ objectChooser = new InsertionObjectChooser(newMapDialogFactory, mainControl); final boolean mapTileListBottom = prefs.getBoolean(MainView.MAP_TILE_LIST_BOTTOM_KEY, CMainView.MAP_TILE_LIST_BOTTOM_DEFAULT); - selectedSquareControl = new SelectedSquareControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>("daieditor", mainControl, this, mapTileListBottom, GUIUtils.getSysIcon(IGUIConstants.TILE_NORTH)); + selectedSquareControl = new SelectedSquareControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(actionFactory, mainControl, this, mapTileListBottom, GUIUtils.getSysIcon(IGUIConstants.TILE_NORTH)); final LockedItemsControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> lockedItemsControl = new LockedItemsControl<GameObject, MapArchObject, Archetype, MapControl, 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(mainControl, mapManager, this, lockedItemsControl); Modified: trunk/src/app/net/sf/gridarta/gui/selectedsquare/SelectedSquareControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/selectedsquare/SelectedSquareControl.java 2008-04-01 21:51:46 UTC (rev 3805) +++ trunk/src/app/net/sf/gridarta/gui/selectedsquare/SelectedSquareControl.java 2008-04-01 22:01:14 UTC (rev 3806) @@ -35,6 +35,7 @@ import net.sf.gridarta.map.MapArchObject; import net.sf.gridarta.map.MapControl; import net.sf.gridarta.map.MapSquare; +import net.sf.japi.swing.ActionFactory; import net.sf.japi.swing.ActionMethod; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -81,7 +82,7 @@ /** * Create a SelectedSquareControl. - * @param key the action factory key + * @param actionFactory the action factory * @param mainControl MainControl, used for icons * @param mainView MainView, used for updating UI * @param mapTileListBottom set if the map tile list should be at the @@ -89,11 +90,11 @@ * @param compassIcon If non-<code>null</code>, display this icon on the * top of the list */ - public SelectedSquareControl(@NotNull final String key, final MainControl<G, A, R, C, V> mainControl, final MainView<G, A, R, C, V> mainView, final boolean mapTileListBottom, @Nullable final ImageIcon compassIcon) { + public SelectedSquareControl(@NotNull final ActionFactory actionFactory, final MainControl<G, A, R, C, V> mainControl, final MainView<G, A, R, C, V> mainView, final boolean mapTileListBottom, @Nullable final ImageIcon compassIcon) { this.mainControl = mainControl; this.mainView = mainView; - view = new SelectedSquareView<G, A, R, C, V>(key, this, mainControl, mapTileListBottom, compassIcon); + view = new SelectedSquareView<G, A, R, C, V>(actionFactory, this, mainControl, mapTileListBottom, compassIcon); } MouseListener getMouseListener() { Modified: trunk/src/app/net/sf/gridarta/gui/selectedsquare/SelectedSquareView.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/selectedsquare/SelectedSquareView.java 2008-04-01 21:51:46 UTC (rev 3805) +++ trunk/src/app/net/sf/gridarta/gui/selectedsquare/SelectedSquareView.java 2008-04-01 22:01:14 UTC (rev 3806) @@ -217,7 +217,7 @@ /** * Create a new instance. * - * @param key the action factory key + * @param actionFactory the action factory * * @param control the controller for this view * @@ -229,7 +229,7 @@ * @param compassIcon if non-<code>null</code>, display this icon on the * top of the list */ - SelectedSquareView(@NotNull final String key, @NotNull final SelectedSquareControl<G, A, R, C, V> control, @NotNull final MainControl<G, A, R, C, V> mainControl, final boolean mapTileListBottom, @Nullable final ImageIcon compassIcon) { + SelectedSquareView(@NotNull final ActionFactory actionFactory, @NotNull final SelectedSquareControl<G, A, R, C, V> control, @NotNull final MainControl<G, A, R, C, V> mainControl, final boolean mapTileListBottom, @Nullable final ImageIcon compassIcon) { this.mainControl = mainControl; this.control = control; mapTileSelectionCache = new MapTileSelectionCache<G, A, R, C, V>(mainControl.getMapManager()); @@ -253,7 +253,6 @@ } else { add(arrows, BorderLayout.SOUTH); // put up/down buttons south } - final ActionFactory actionFactory = ActionFactory.getFactory(key); for (final String keyPostfix : new String[] { "Top", "Up", "Down", "Bottom" }) { final JButton button = new JButton(actionFactory.createAction(true, "moveTile" + keyPostfix, control)); arrows.add(button); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-04-01 22:09:07
|
Revision: 3807 http://gridarta.svn.sourceforge.net/gridarta/?rev=3807&view=rev Author: akirschbaum Date: 2008-04-01 15:08:53 -0700 (Tue, 01 Apr 2008) Log Message: ----------- Unify CMainView. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/CMainView.java trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/CMainView.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-04-01 22:01:14 UTC (rev 3806) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-04-01 22:08:53 UTC (rev 3807) @@ -259,7 +259,7 @@ ScriptEditControl.init(strMapDir, this); // Initialize the main view - mainView.init(newMapDialogFactory); + mainView.init(newMapDialogFactory, null); scriptControl.getView().setMenu((JMenu) ACTION_FACTORY.find(mainView.getJMenuBar(), "plugins")); archetypeParser = new ArchetypeParser(this, mainView.getObjectChooser().getArchetypeChooserControl()); animationObjects = new AnimationObjects(); Modified: trunk/crossfire/src/cfeditor/CMainView.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainView.java 2008-04-01 22:01:14 UTC (rev 3806) +++ trunk/crossfire/src/cfeditor/CMainView.java 2008-04-01 22:08:53 UTC (rev 3807) @@ -167,8 +167,10 @@ /** * Initializes (builds) this view. * @param newMapDialogFactory the factory for creating new pickmaps + * @param compassIcon If non-<code>null</code>, display this icon on the + * top of the list */ - void init(@NotNull final NewMapDialogFactory<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> newMapDialogFactory) { + void init(@NotNull final NewMapDialogFactory<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> newMapDialogFactory, @Nullable final ImageIcon compassIcon) { // calculate some default values in case there is no settings file final Rectangle screen = getGraphicsConfiguration().getBounds(); final int defwidth = (int) (0.9 * screen.getWidth()); @@ -178,7 +180,7 @@ final JPanel toolbarPanel = new JPanel(new BorderLayout()); toolbarPanel.add(mainToolbar, BorderLayout.NORTH); - toolbarPanel.add(createCenterPanel(defwidth, defheight, newMapDialogFactory), BorderLayout.CENTER); + toolbarPanel.add(createCenterPanel(defwidth, defheight, newMapDialogFactory, compassIcon), BorderLayout.CENTER); add(toolbarPanel, BorderLayout.CENTER); archetypesActions = new ArchetypesActions<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(this, objectChooser.getArchetypeChooserControl(), mainControl.getArchetypeSet(), objectChooser); @@ -213,9 +215,11 @@ * @param defwidth default width * @param defheight default height * @param newMapDialogFactory the factory for creating new pickmaps + * @param compassIcon If non-<code>null</code>, display this icon on the + * top of the list * @return center panel */ - private JPanel createCenterPanel(final int defwidth, final int defheight, @NotNull final NewMapDialogFactory<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> newMapDialogFactory) { + private JPanel createCenterPanel(final int defwidth, final int defheight, @NotNull final NewMapDialogFactory<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> newMapDialogFactory, @Nullable final ImageIcon compassIcon) { final JPanel centerPanel = new JPanel(new BorderLayout()); final int divLocationRight = prefs.getInt(DIVIDER_LOCATION_KEY3, (int) (defwidth * 0.62)); @@ -224,7 +228,7 @@ objectChooser = new InsertionObjectChooser(newMapDialogFactory, mainControl); final boolean mapTileListBottom = prefs.getBoolean(MainView.MAP_TILE_LIST_BOTTOM_KEY, CMainView.MAP_TILE_LIST_BOTTOM_DEFAULT); - selectedSquareControl = new SelectedSquareControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(actionFactory, mainControl, this, mapTileListBottom, null); + selectedSquareControl = new SelectedSquareControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(actionFactory, mainControl, this, mapTileListBottom, compassIcon); final LockedItemsControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> lockedItemsControl = new LockedItemsControl<GameObject, MapArchObject, Archetype, MapControl, 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(mainControl, mapManager, this, lockedItemsControl); Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-04-01 22:01:14 UTC (rev 3806) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-04-01 22:08:53 UTC (rev 3807) @@ -311,7 +311,7 @@ ScriptEditControl.init(strMapDir, this); // Initialize the main view - mainView.init(newMapDialogFactory); + mainView.init(newMapDialogFactory, GUIUtils.getSysIcon(IGUIConstants.TILE_NORTH)); archetypeParser = new ArchetypeParser(this, mainView.getObjectChooser().getArchetypeChooserControl()); animationObjects = new AnimationObjects(); faceObjects = new FaceObjects(); Modified: trunk/daimonin/src/daieditor/CMainView.java =================================================================== --- trunk/daimonin/src/daieditor/CMainView.java 2008-04-01 22:01:14 UTC (rev 3806) +++ trunk/daimonin/src/daieditor/CMainView.java 2008-04-01 22:08:53 UTC (rev 3807) @@ -171,8 +171,10 @@ /** * Initializes (builds) this view. * @param newMapDialogFactory the factory for creating new pickmaps + * @param compassIcon If non-<code>null</code>, display this icon on the + * top of the list */ - void init(@NotNull final NewMapDialogFactory<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> newMapDialogFactory) { + void init(@NotNull final NewMapDialogFactory<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> newMapDialogFactory, @Nullable final ImageIcon compassIcon) { // calculate some default values in case there is no settings file final Rectangle screen = getGraphicsConfiguration().getBounds(); final int defwidth = (int) (0.9 * screen.getWidth()); @@ -182,7 +184,7 @@ final JPanel toolbarPanel = new JPanel(new BorderLayout()); toolbarPanel.add(mainToolbar, BorderLayout.NORTH); - toolbarPanel.add(createCenterPanel(defwidth, defheight, newMapDialogFactory), BorderLayout.CENTER); + toolbarPanel.add(createCenterPanel(defwidth, defheight, newMapDialogFactory, compassIcon), BorderLayout.CENTER); add(toolbarPanel, BorderLayout.CENTER); archetypesActions = new ArchetypesActions<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(this, objectChooser.getArchetypeChooserControl(), mainControl.getArchetypeSet(), objectChooser); @@ -217,9 +219,11 @@ * @param defwidth default width * @param defheight default height * @param newMapDialogFactory the factory for creating new pickmaps + * @param compassIcon If non-<code>null</code>, display this icon on the + * top of the list * @return center panel */ - private JPanel createCenterPanel(final int defwidth, final int defheight, @NotNull final NewMapDialogFactory<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> newMapDialogFactory) { + private JPanel createCenterPanel(final int defwidth, final int defheight, @NotNull final NewMapDialogFactory<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> newMapDialogFactory, @Nullable final ImageIcon compassIcon) { final JPanel centerPanel = new JPanel(new BorderLayout()); final int divLocationRight = prefs.getInt(DIVIDER_LOCATION_KEY3, (int) (defwidth * 0.62)); @@ -228,7 +232,7 @@ objectChooser = new InsertionObjectChooser(newMapDialogFactory, mainControl); final boolean mapTileListBottom = prefs.getBoolean(MainView.MAP_TILE_LIST_BOTTOM_KEY, CMainView.MAP_TILE_LIST_BOTTOM_DEFAULT); - selectedSquareControl = new SelectedSquareControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(actionFactory, mainControl, this, mapTileListBottom, GUIUtils.getSysIcon(IGUIConstants.TILE_NORTH)); + selectedSquareControl = new SelectedSquareControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(actionFactory, mainControl, this, mapTileListBottom, compassIcon); final LockedItemsControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> lockedItemsControl = new LockedItemsControl<GameObject, MapArchObject, Archetype, MapControl, 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(mainControl, mapManager, this, lockedItemsControl); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-04-01 22:24:23
|
Revision: 3808 http://gridarta.svn.sourceforge.net/gridarta/?rev=3808&view=rev Author: akirschbaum Date: 2008-04-01 15:24:23 -0700 (Tue, 01 Apr 2008) Log Message: ----------- Unify CMainView. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/CMainView.java trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/CMainView.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-04-01 22:08:53 UTC (rev 3807) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-04-01 22:24:23 UTC (rev 3808) @@ -66,6 +66,7 @@ import net.sf.gridarta.gui.NewMapDialogFactory; import net.sf.gridarta.gui.RecentManager; import net.sf.gridarta.gui.SystemIcons; +import net.sf.gridarta.gui.connectionview.LockedItemsControl; import net.sf.gridarta.gui.map.MapCursorControl; import net.sf.gridarta.gui.map.MapView; import net.sf.gridarta.gui.prefs.MapValidatorPrefs; @@ -259,7 +260,7 @@ ScriptEditControl.init(strMapDir, this); // Initialize the main view - mainView.init(newMapDialogFactory, null); + mainView.init(newMapDialogFactory, null, new LockedItemsControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(getMapManager(), 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)); scriptControl.getView().setMenu((JMenu) ACTION_FACTORY.find(mainView.getJMenuBar(), "plugins")); archetypeParser = new ArchetypeParser(this, mainView.getObjectChooser().getArchetypeChooserControl()); animationObjects = new AnimationObjects(); Modified: trunk/crossfire/src/cfeditor/CMainView.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainView.java 2008-04-01 22:08:53 UTC (rev 3807) +++ trunk/crossfire/src/cfeditor/CMainView.java 2008-04-01 22:24:23 UTC (rev 3808) @@ -169,8 +169,9 @@ * @param newMapDialogFactory the factory for creating new pickmaps * @param compassIcon If non-<code>null</code>, display this icon on the * top of the list + * @param lockedItemsControl the locked items control */ - void init(@NotNull final NewMapDialogFactory<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> newMapDialogFactory, @Nullable final ImageIcon compassIcon) { + void init(@NotNull final NewMapDialogFactory<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> newMapDialogFactory, @Nullable final ImageIcon compassIcon, @NotNull final LockedItemsControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> lockedItemsControl) { // calculate some default values in case there is no settings file final Rectangle screen = getGraphicsConfiguration().getBounds(); final int defwidth = (int) (0.9 * screen.getWidth()); @@ -180,7 +181,7 @@ final JPanel toolbarPanel = new JPanel(new BorderLayout()); toolbarPanel.add(mainToolbar, BorderLayout.NORTH); - toolbarPanel.add(createCenterPanel(defwidth, defheight, newMapDialogFactory, compassIcon), BorderLayout.CENTER); + toolbarPanel.add(createCenterPanel(defwidth, defheight, newMapDialogFactory, compassIcon, lockedItemsControl), BorderLayout.CENTER); add(toolbarPanel, BorderLayout.CENTER); archetypesActions = new ArchetypesActions<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(this, objectChooser.getArchetypeChooserControl(), mainControl.getArchetypeSet(), objectChooser); @@ -217,9 +218,10 @@ * @param newMapDialogFactory the factory for creating new pickmaps * @param compassIcon If non-<code>null</code>, display this icon on the * top of the list + * @param lockedItemsControl the locked items control * @return center panel */ - private JPanel createCenterPanel(final int defwidth, final int defheight, @NotNull final NewMapDialogFactory<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> newMapDialogFactory, @Nullable final ImageIcon compassIcon) { + private JPanel createCenterPanel(final int defwidth, final int defheight, @NotNull final NewMapDialogFactory<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> newMapDialogFactory, @Nullable final ImageIcon compassIcon, @NotNull final LockedItemsControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> lockedItemsControl) { final JPanel centerPanel = new JPanel(new BorderLayout()); final int divLocationRight = prefs.getInt(DIVIDER_LOCATION_KEY3, (int) (defwidth * 0.62)); @@ -229,7 +231,6 @@ objectChooser = new InsertionObjectChooser(newMapDialogFactory, mainControl); final boolean mapTileListBottom = prefs.getBoolean(MainView.MAP_TILE_LIST_BOTTOM_KEY, CMainView.MAP_TILE_LIST_BOTTOM_DEFAULT); selectedSquareControl = new SelectedSquareControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(actionFactory, mainControl, this, mapTileListBottom, compassIcon); - final LockedItemsControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> lockedItemsControl = new LockedItemsControl<GameObject, MapArchObject, Archetype, MapControl, 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(mainControl, mapManager, this, lockedItemsControl); if (mapTileListBottom) { Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-04-01 22:08:53 UTC (rev 3807) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-04-01 22:24:23 UTC (rev 3808) @@ -73,6 +73,7 @@ import net.sf.gridarta.gui.NewMapDialogFactory; import net.sf.gridarta.gui.RecentManager; import net.sf.gridarta.gui.SystemIcons; +import net.sf.gridarta.gui.connectionview.LockedItemsControl; import net.sf.gridarta.gui.map.MapCursorControl; import net.sf.gridarta.gui.map.MapView; import net.sf.gridarta.gui.prefs.MapValidatorPrefs; @@ -311,7 +312,7 @@ ScriptEditControl.init(strMapDir, this); // Initialize the main view - mainView.init(newMapDialogFactory, GUIUtils.getSysIcon(IGUIConstants.TILE_NORTH)); + mainView.init(newMapDialogFactory, GUIUtils.getSysIcon(IGUIConstants.TILE_NORTH), new LockedItemsControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(getMapManager(), 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)); archetypeParser = new ArchetypeParser(this, mainView.getObjectChooser().getArchetypeChooserControl()); animationObjects = new AnimationObjects(); faceObjects = new FaceObjects(); Modified: trunk/daimonin/src/daieditor/CMainView.java =================================================================== --- trunk/daimonin/src/daieditor/CMainView.java 2008-04-01 22:08:53 UTC (rev 3807) +++ trunk/daimonin/src/daieditor/CMainView.java 2008-04-01 22:24:23 UTC (rev 3808) @@ -173,8 +173,9 @@ * @param newMapDialogFactory the factory for creating new pickmaps * @param compassIcon If non-<code>null</code>, display this icon on the * top of the list + * @param lockedItemsControl the locked items control */ - void init(@NotNull final NewMapDialogFactory<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> newMapDialogFactory, @Nullable final ImageIcon compassIcon) { + void init(@NotNull final NewMapDialogFactory<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> newMapDialogFactory, @Nullable final ImageIcon compassIcon, @NotNull final LockedItemsControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> lockedItemsControl) { // calculate some default values in case there is no settings file final Rectangle screen = getGraphicsConfiguration().getBounds(); final int defwidth = (int) (0.9 * screen.getWidth()); @@ -184,7 +185,7 @@ final JPanel toolbarPanel = new JPanel(new BorderLayout()); toolbarPanel.add(mainToolbar, BorderLayout.NORTH); - toolbarPanel.add(createCenterPanel(defwidth, defheight, newMapDialogFactory, compassIcon), BorderLayout.CENTER); + toolbarPanel.add(createCenterPanel(defwidth, defheight, newMapDialogFactory, compassIcon, lockedItemsControl), BorderLayout.CENTER); add(toolbarPanel, BorderLayout.CENTER); archetypesActions = new ArchetypesActions<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(this, objectChooser.getArchetypeChooserControl(), mainControl.getArchetypeSet(), objectChooser); @@ -221,9 +222,10 @@ * @param newMapDialogFactory the factory for creating new pickmaps * @param compassIcon If non-<code>null</code>, display this icon on the * top of the list + * @param lockedItemsControl the locked items control * @return center panel */ - private JPanel createCenterPanel(final int defwidth, final int defheight, @NotNull final NewMapDialogFactory<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> newMapDialogFactory, @Nullable final ImageIcon compassIcon) { + private JPanel createCenterPanel(final int defwidth, final int defheight, @NotNull final NewMapDialogFactory<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> newMapDialogFactory, @Nullable final ImageIcon compassIcon, @NotNull final LockedItemsControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> lockedItemsControl) { final JPanel centerPanel = new JPanel(new BorderLayout()); final int divLocationRight = prefs.getInt(DIVIDER_LOCATION_KEY3, (int) (defwidth * 0.62)); @@ -233,7 +235,6 @@ objectChooser = new InsertionObjectChooser(newMapDialogFactory, mainControl); final boolean mapTileListBottom = prefs.getBoolean(MainView.MAP_TILE_LIST_BOTTOM_KEY, CMainView.MAP_TILE_LIST_BOTTOM_DEFAULT); selectedSquareControl = new SelectedSquareControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(actionFactory, mainControl, this, mapTileListBottom, compassIcon); - final LockedItemsControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> lockedItemsControl = new LockedItemsControl<GameObject, MapArchObject, Archetype, MapControl, 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(mainControl, mapManager, this, lockedItemsControl); if (mapTileListBottom) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-04-02 20:07:48
|
Revision: 3816 http://gridarta.svn.sourceforge.net/gridarta/?rev=3816&view=rev Author: akirschbaum Date: 2008-04-02 13:07:53 -0700 (Wed, 02 Apr 2008) Log Message: ----------- Simplify code. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/daimonin/src/daieditor/CMainControl.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-04-02 19:59:58 UTC (rev 3815) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-04-02 20:07:53 UTC (rev 3816) @@ -339,9 +339,7 @@ if (log.isInfoEnabled()) { log.info("Arch loading took " + (System.currentTimeMillis() - timeStart) / 1000.0 + " Seconds"); } - } - if (archetypeSet.getLoadStatus() != ArchetypeSet.LoadStatus.EMPTY) { mainView.getObjectChooser().getPickmapChooserControl().loadPickmaps(true); } Map<String, TreasureTreeNode> specialTreasureLists; Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-04-02 19:59:58 UTC (rev 3815) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-04-02 20:07:53 UTC (rev 3816) @@ -406,9 +406,7 @@ if (log.isInfoEnabled()) { log.info("Arch loading took " + (System.currentTimeMillis() - timeStart) / 1000.0 + " Seconds"); } - } - if (archetypeSet.getLoadStatus() != ArchetypeSet.LoadStatus.EMPTY) { mainView.getObjectChooser().getPickmapChooserControl().loadPickmaps(true); } Map<String, TreasureTreeNode> specialTreasureLists; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-04-02 21:15:52
|
Revision: 3821 http://gridarta.svn.sourceforge.net/gridarta/?rev=3821&view=rev Author: akirschbaum Date: 2008-04-02 14:15:57 -0700 (Wed, 02 Apr 2008) Log Message: ----------- Remove MainControl.getPickmapDir(). Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/CMainView.java trunk/crossfire/src/cfeditor/gui/InsertionObjectChooser.java trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/CMainView.java trunk/daimonin/src/daieditor/gui/InsertionObjectChooser.java trunk/src/app/net/sf/gridarta/MainControl.java trunk/src/app/net/sf/gridarta/gui/pickmapchooser/PickmapChooserControl.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-04-02 20:30:53 UTC (rev 3820) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-04-02 21:15:57 UTC (rev 3821) @@ -261,7 +261,7 @@ ScriptEditControl.init(strMapDir, this); // Initialize the main view - mainView.init(newMapDialogFactory, null, new LockedItemsControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(getMapManager(), 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)); + mainView.init(newMapDialogFactory, null, new LockedItemsControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(getMapManager(), 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), new File(mapDir, IGUIConstants.PICKMAP_DIR)); scriptControl.getView().setMenu((JMenu) ACTION_FACTORY.find(mainView.getJMenuBar(), "plugins")); archetypeParser = new ArchetypeParser(this, mainView.getObjectChooser().getArchetypeChooserControl()); animationObjects = new AnimationObjects(); @@ -958,11 +958,6 @@ return "resource/conf"; } - /** {@inheritDoc} */ - public File getPickmapDir() { - return new File(getMapDir(), IGUIConstants.PICKMAP_DIR); - } - private List<?> getEventTypes() { final List<Object> result = new ArrayList<Object>(); for (int typeNumber = 1; ScriptArchData.typeArchName(typeNumber) != null; typeNumber++) { Modified: trunk/crossfire/src/cfeditor/CMainView.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainView.java 2008-04-02 20:30:53 UTC (rev 3820) +++ trunk/crossfire/src/cfeditor/CMainView.java 2008-04-02 21:15:57 UTC (rev 3821) @@ -29,6 +29,7 @@ import java.awt.Rectangle; import java.awt.Toolkit; import java.beans.PropertyVetoException; +import java.io.File; import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -170,8 +171,9 @@ * @param compassIcon If non-<code>null</code>, display this icon on the * top of the list * @param lockedItemsControl the locked items control + * @param pickmapDir the pickmaps directory */ - void init(@NotNull final NewMapDialogFactory<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> newMapDialogFactory, @Nullable final ImageIcon compassIcon, @NotNull final LockedItemsControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> lockedItemsControl) { + void init(@NotNull final NewMapDialogFactory<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> newMapDialogFactory, @Nullable final ImageIcon compassIcon, @NotNull final LockedItemsControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> lockedItemsControl, @NotNull final File pickmapDir) { // calculate some default values in case there is no settings file final Rectangle screen = getGraphicsConfiguration().getBounds(); final int defwidth = (int) (0.9 * screen.getWidth()); @@ -181,7 +183,7 @@ final JPanel toolbarPanel = new JPanel(new BorderLayout()); toolbarPanel.add(mainToolbar, BorderLayout.NORTH); - toolbarPanel.add(createCenterPanel(defwidth, defheight, newMapDialogFactory, compassIcon, lockedItemsControl), BorderLayout.CENTER); + toolbarPanel.add(createCenterPanel(defwidth, defheight, newMapDialogFactory, compassIcon, lockedItemsControl, pickmapDir), BorderLayout.CENTER); add(toolbarPanel, BorderLayout.CENTER); archetypesActions = new ArchetypesActions<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(this, objectChooser.getArchetypeChooserControl(), mainControl.getArchetypeSet(), objectChooser); @@ -219,16 +221,17 @@ * @param compassIcon If non-<code>null</code>, display this icon on the * top of the list * @param lockedItemsControl the locked items control + * @param pickmapDir the pickmaps directory * @return center panel */ - private JPanel createCenterPanel(final int defwidth, final int defheight, @NotNull final NewMapDialogFactory<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> newMapDialogFactory, @Nullable final ImageIcon compassIcon, @NotNull final LockedItemsControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> lockedItemsControl) { + private JPanel createCenterPanel(final int defwidth, final int defheight, @NotNull final NewMapDialogFactory<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> newMapDialogFactory, @Nullable final ImageIcon compassIcon, @NotNull final LockedItemsControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> lockedItemsControl, @NotNull final File pickmapDir) { final JPanel centerPanel = new JPanel(new BorderLayout()); final int divLocationRight = prefs.getInt(DIVIDER_LOCATION_KEY3, (int) (defwidth * 0.62)); final int divLocationDown = prefs.getInt(DIVIDER_LOCATION_KEY2, (int) (defheight * 0.76)); final int divLocation = prefs.getInt(DIVIDER_LOCATION_KEY, (int) (defwidth * 0.17)); - objectChooser = new InsertionObjectChooser(newMapDialogFactory, mainControl); + objectChooser = new InsertionObjectChooser(newMapDialogFactory, mainControl, pickmapDir); final boolean mapTileListBottom = prefs.getBoolean(MainView.MAP_TILE_LIST_BOTTOM_KEY, CMainView.MAP_TILE_LIST_BOTTOM_DEFAULT); selectedSquareControl = new SelectedSquareControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(actionFactory, mainControl, this, mapTileListBottom, compassIcon); gameObjectAttributesPanel = new GameObjectAttributesPanel(mainControl, mapManager, this, lockedItemsControl); Modified: trunk/crossfire/src/cfeditor/gui/InsertionObjectChooser.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/InsertionObjectChooser.java 2008-04-02 20:30:53 UTC (rev 3820) +++ trunk/crossfire/src/cfeditor/gui/InsertionObjectChooser.java 2008-04-02 21:15:57 UTC (rev 3821) @@ -29,6 +29,7 @@ import java.awt.BorderLayout; import java.awt.Dimension; import java.awt.Toolkit; +import java.io.File; import java.util.List; import java.util.prefs.Preferences; import javax.swing.JSplitPane; @@ -85,9 +86,10 @@ * Build Panel. * @param newMapDialogFactory the factory for creating new pickmaps * @param mainControl CMainControl + * @param pickmapDir the pickmaps directory */ - public InsertionObjectChooser(@NotNull final NewMapDialogFactory<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> newMapDialogFactory, final CMainControl mainControl) { - pickmapChooserControl = new PickmapChooserControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(newMapDialogFactory, mainControl, this); + public InsertionObjectChooser(@NotNull final NewMapDialogFactory<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> newMapDialogFactory, final CMainControl mainControl, @NotNull final File pickmapDir) { + pickmapChooserControl = new PickmapChooserControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(newMapDialogFactory, mainControl, this, pickmapDir); archetypeChooserControl = new ArchetypeChooserControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(mainControl, false); archetypeChooserControl.addArchetypeChooserListener(new ArchetypeChooserListener<GameObject, MapArchObject, Archetype>() { /** {@inheritDoc} */ Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-04-02 20:30:53 UTC (rev 3820) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-04-02 21:15:57 UTC (rev 3821) @@ -316,7 +316,7 @@ ScriptEditControl.init(strMapDir, this); // Initialize the main view - mainView.init(newMapDialogFactory, GUIUtils.getSysIcon(IGUIConstants.TILE_NORTH), new LockedItemsControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(getMapManager(), 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)); + mainView.init(newMapDialogFactory, GUIUtils.getSysIcon(IGUIConstants.TILE_NORTH), new LockedItemsControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(getMapManager(), 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), new File(strArchDir, IGUIConstants.PICKMAP_DIR)); archetypeParser = new ArchetypeParser(this, mainView.getObjectChooser().getArchetypeChooserControl()); animationObjects = new AnimationObjects(); faceObjects = new FaceObjects(); @@ -1125,9 +1125,4 @@ return getArchDefaultFolder() + "/dev/editor/conf"; } - /** {@inheritDoc} */ - public File getPickmapDir() { - return new File(getArchDefaultFolder(), IGUIConstants.PICKMAP_DIR); - } - } // class CMainControl Modified: trunk/daimonin/src/daieditor/CMainView.java =================================================================== --- trunk/daimonin/src/daieditor/CMainView.java 2008-04-02 20:30:53 UTC (rev 3820) +++ trunk/daimonin/src/daieditor/CMainView.java 2008-04-02 21:15:57 UTC (rev 3821) @@ -29,6 +29,7 @@ import java.awt.Rectangle; import java.awt.Toolkit; import java.beans.PropertyVetoException; +import java.io.File; import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -170,8 +171,9 @@ * @param compassIcon If non-<code>null</code>, display this icon on the * top of the list * @param lockedItemsControl the locked items control + * @param pickmapDir the pickmaps directory */ - void init(@NotNull final NewMapDialogFactory<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> newMapDialogFactory, @Nullable final ImageIcon compassIcon, @NotNull final LockedItemsControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> lockedItemsControl) { + void init(@NotNull final NewMapDialogFactory<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> newMapDialogFactory, @Nullable final ImageIcon compassIcon, @NotNull final LockedItemsControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> lockedItemsControl, @NotNull final File pickmapDir) { // calculate some default values in case there is no settings file final Rectangle screen = getGraphicsConfiguration().getBounds(); final int defwidth = (int) (0.9 * screen.getWidth()); @@ -181,7 +183,7 @@ final JPanel toolbarPanel = new JPanel(new BorderLayout()); toolbarPanel.add(mainToolbar, BorderLayout.NORTH); - toolbarPanel.add(createCenterPanel(defwidth, defheight, newMapDialogFactory, compassIcon, lockedItemsControl), BorderLayout.CENTER); + toolbarPanel.add(createCenterPanel(defwidth, defheight, newMapDialogFactory, compassIcon, lockedItemsControl, pickmapDir), BorderLayout.CENTER); add(toolbarPanel, BorderLayout.CENTER); archetypesActions = new ArchetypesActions<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(this, objectChooser.getArchetypeChooserControl(), mainControl.getArchetypeSet(), objectChooser); @@ -219,16 +221,17 @@ * @param compassIcon If non-<code>null</code>, display this icon on the * top of the list * @param lockedItemsControl the locked items control + * @param pickmapDir the pickmaps directory * @return center panel */ - private JPanel createCenterPanel(final int defwidth, final int defheight, @NotNull final NewMapDialogFactory<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> newMapDialogFactory, @Nullable final ImageIcon compassIcon, @NotNull final LockedItemsControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> lockedItemsControl) { + private JPanel createCenterPanel(final int defwidth, final int defheight, @NotNull final NewMapDialogFactory<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> newMapDialogFactory, @Nullable final ImageIcon compassIcon, @NotNull final LockedItemsControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> lockedItemsControl, @NotNull final File pickmapDir) { final JPanel centerPanel = new JPanel(new BorderLayout()); final int divLocationRight = prefs.getInt(DIVIDER_LOCATION_KEY3, (int) (defwidth * 0.62)); final int divLocationDown = prefs.getInt(DIVIDER_LOCATION_KEY2, (int) (defheight * 0.76)); final int divLocation = prefs.getInt(DIVIDER_LOCATION_KEY, (int) (defwidth * 0.17)); - objectChooser = new InsertionObjectChooser(newMapDialogFactory, mainControl); + objectChooser = new InsertionObjectChooser(newMapDialogFactory, mainControl, pickmapDir); final boolean mapTileListBottom = prefs.getBoolean(MainView.MAP_TILE_LIST_BOTTOM_KEY, CMainView.MAP_TILE_LIST_BOTTOM_DEFAULT); selectedSquareControl = new SelectedSquareControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(actionFactory, mainControl, this, mapTileListBottom, compassIcon); gameObjectAttributesPanel = new GameObjectAttributesPanel(mainControl, mapManager, this, lockedItemsControl); Modified: trunk/daimonin/src/daieditor/gui/InsertionObjectChooser.java =================================================================== --- trunk/daimonin/src/daieditor/gui/InsertionObjectChooser.java 2008-04-02 20:30:53 UTC (rev 3820) +++ trunk/daimonin/src/daieditor/gui/InsertionObjectChooser.java 2008-04-02 21:15:57 UTC (rev 3821) @@ -28,6 +28,7 @@ import daieditor.map.MapArchObject; import daieditor.map.MapControl; import java.awt.BorderLayout; +import java.io.File; import java.util.List; import javax.swing.JSplitPane; import javax.swing.JTabbedPane; @@ -77,9 +78,10 @@ * Build Panel. * @param newMapDialogFactory the factory for creating new pickmaps * @param mainControl CMainControl + * @param pickmapDir the pickmaps directory */ - public InsertionObjectChooser(@NotNull final NewMapDialogFactory<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> newMapDialogFactory, final CMainControl mainControl) { - pickmapChooserControl = new PickmapChooserControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(newMapDialogFactory, mainControl, this); + public InsertionObjectChooser(@NotNull final NewMapDialogFactory<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> newMapDialogFactory, final CMainControl mainControl, @NotNull final File pickmapDir) { + pickmapChooserControl = new PickmapChooserControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(newMapDialogFactory, mainControl, this, pickmapDir); archetypeChooserControl = new ArchetypeChooserControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(mainControl, true); archetypeChooserControl.addArchetypeChooserListener(new ArchetypeChooserListener<GameObject, MapArchObject, Archetype>() { /** {@inheritDoc} */ Modified: trunk/src/app/net/sf/gridarta/MainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/MainControl.java 2008-04-02 20:30:53 UTC (rev 3820) +++ trunk/src/app/net/sf/gridarta/MainControl.java 2008-04-02 21:15:57 UTC (rev 3821) @@ -276,13 +276,6 @@ void openAttrDialog(G gameObject); /** - * Return the directory for storing pickmap files. - * - * @return The directory for storing pickmap files. - */ - File getPickmapDir(); - - /** * Check a map. * @param map the map to check */ Modified: trunk/src/app/net/sf/gridarta/gui/pickmapchooser/PickmapChooserControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/pickmapchooser/PickmapChooserControl.java 2008-04-02 20:30:53 UTC (rev 3820) +++ trunk/src/app/net/sf/gridarta/gui/pickmapchooser/PickmapChooserControl.java 2008-04-02 21:15:57 UTC (rev 3821) @@ -64,6 +64,9 @@ /** The object chooser. */ @NotNull private final InsertionObjectChooser<G, A, R> objectChooser; + /** The pickmap root directory. */ + @NotNull private final File pickmapDir; + /** * All open pickmaps. The sort order matches {@link * PickmapChooserView#pickmapPanel}. @@ -122,10 +125,12 @@ * @param newMapDialogFactory the factory for creating new pickmaps * @param mainControl the main control * @param objectChooser the object chooser + * @param pickmapDir the pickmaps directory */ - public PickmapChooserControl(@NotNull final NewMapDialogFactory<G, A, R, C, V> newMapDialogFactory, @NotNull final MainControl<G, A, R, C, V> mainControl, @NotNull final InsertionObjectChooser<G, A, R> objectChooser) { + public PickmapChooserControl(@NotNull final NewMapDialogFactory<G, A, R, C, V> newMapDialogFactory, @NotNull final MainControl<G, A, R, C, V> mainControl, @NotNull final InsertionObjectChooser<G, A, R> objectChooser, @NotNull final File pickmapDir) { this.mainControl = mainControl; this.objectChooser = objectChooser; + this.pickmapDir = pickmapDir; actions = new Actions<G, A, R, C, V>(newMapDialogFactory, this); view = new PickmapChooserView(); actions.init(); @@ -142,7 +147,6 @@ * chooser if at least one pickmap was loaded. */ public void loadPickmaps(final boolean movePickmapChooserToFront) { - final File pickmapDir = mainControl.getPickmapDir(); if (!pickmapDir.exists() || !pickmapDir.isDirectory()) { log.warn("Pickmaps directory not found: " + pickmapDir); return; @@ -164,10 +168,10 @@ * Loads all pickmaps from a directory. * @param dir the directory */ - private void loadPickmapDirectory(@NotNull final File pickmapDir) { - final File[] files = pickmapDir.listFiles(); + private void loadPickmapDirectory(@NotNull final File dir) { + final File[] files = dir.listFiles(); if (files == null) { - log.warn("Pickmaps directory not readable: " + pickmapDir); + log.warn("Pickmaps directory not readable: " + dir); return; } Arrays.sort(files); @@ -212,7 +216,7 @@ * if an error has occurred */ public boolean addNewPickmap(final Component parent, final A mapArchObject, @NotNull final String pickmapName) { - final File mapFile = new File(mainControl.getPickmapDir(), pickmapName); + final File mapFile = new File(pickmapDir, pickmapName); for(final C pickmap : pickmaps) { if (mapFile.equals(pickmap.getMapFile())) { ACTION_FACTORY.showMessageDialog(parent, "pickmapExists", mapFile); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-04-03 08:09:43
|
Revision: 3823 http://gridarta.svn.sourceforge.net/gridarta/?rev=3823&view=rev Author: akirschbaum Date: 2008-04-03 01:09:32 -0700 (Thu, 03 Apr 2008) Log Message: ----------- Include file name of invalid map file in error message. Modified Paths: -------------- trunk/crossfire/src/cfeditor/MapActions.java trunk/src/app/net/sf/gridarta/messages.properties trunk/src/app/net/sf/gridarta/messages_de.properties trunk/src/app/net/sf/gridarta/messages_sv.properties Modified: trunk/crossfire/src/cfeditor/MapActions.java =================================================================== --- trunk/crossfire/src/cfeditor/MapActions.java 2008-04-02 21:18:42 UTC (rev 3822) +++ trunk/crossfire/src/cfeditor/MapActions.java 2008-04-03 08:09:32 UTC (rev 3823) @@ -283,7 +283,7 @@ if (!newfile.exists() || newfile.isDirectory()) { // The path is wrong - ACTION_FACTORY.showMessageDialog(mainControl.getMainView(), "enterExitInvalidPath"); + ACTION_FACTORY.showMessageDialog(mainControl.getMainView(), "enterExitInvalidPath", newfile.getAbsolutePath()); return; } @@ -365,7 +365,7 @@ if (!newfile.exists() || newfile.isDirectory()) { // The path is wrong - ACTION_FACTORY.showMessageDialog(currentMapView.getComponent(), "enterExitInvalidPath"); + ACTION_FACTORY.showMessageDialog(currentMapView.getComponent(), "enterExitInvalidPath", newfile.getAbsolutePath()); return; } Modified: trunk/src/app/net/sf/gridarta/messages.properties =================================================================== --- trunk/src/app/net/sf/gridarta/messages.properties 2008-04-02 21:18:42 UTC (rev 3822) +++ trunk/src/app/net/sf/gridarta/messages.properties 2008-04-03 08:09:32 UTC (rev 3823) @@ -143,7 +143,7 @@ enterExitOutside.title=Destination invalid enterExitOutside.message=The destination of this exit is outside the map. enterExitInvalidPath.title=Invalid path -enterExitInvalidPath.message=The specified path is invalid. +enterExitInvalidPath.message=The specified path is invalid:\n{0} revertPickmapGone.title=Cannot revert pickmap revertPickmapGone.message=The file for pickmap "{0}" doesn''t exist. Modified: trunk/src/app/net/sf/gridarta/messages_de.properties =================================================================== --- trunk/src/app/net/sf/gridarta/messages_de.properties 2008-04-02 21:18:42 UTC (rev 3822) +++ trunk/src/app/net/sf/gridarta/messages_de.properties 2008-04-03 08:09:32 UTC (rev 3823) @@ -131,7 +131,7 @@ enterExitOutside.title=Ziel ung\xFCltig enterExitOutside.message=Der Ausgang besitzt Zielkoordinaten au\xDFerhalb der Karte. enterExitInvalidPath.title=Ung\xFCltiger Pfad -enterExitInvalidPath.message=Der Ausgang zeigt auf einen ung\xFCltigen Dateinamen. +enterExitInvalidPath.message=Der Ausgang zeigt auf einen ung\xFCltigen Dateinamen:\n{0} revertPickmapGone.title=Kann \xC4nderungen nicht zur\xFCcknehmen revertPickmapGone.message=F\xFCr die Pickmap ''{0}'' existiert keine Datei. Modified: trunk/src/app/net/sf/gridarta/messages_sv.properties =================================================================== --- trunk/src/app/net/sf/gridarta/messages_sv.properties 2008-04-02 21:18:42 UTC (rev 3822) +++ trunk/src/app/net/sf/gridarta/messages_sv.properties 2008-04-03 08:09:32 UTC (rev 3823) @@ -128,7 +128,7 @@ enterExitOutside.title=M\xE5let ogiltigt enterExitOutside.message=M\xE5let f\xF6r utg\xE5ngen ligger utanf\xF6r kartan. enterExitInvalidPath.title=Ogiltig s\xF6kv\xE4g -enterExitInvalidPath.message=Den angivna s\xF6kv\xE4gen \xE4r ogiltig. +enterExitInvalidPath.message=Den angivna s\xF6kv\xE4gen \xE4r ogiltig:\n{0} revertPickmapGone.title=Kan inte \xE5terst\xE4lla plockkartan. revertPickmapGone.message=Filen f\xF6r plockkartan "{0}" existerar inte. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-04-06 08:55:44
|
Revision: 3831 http://gridarta.svn.sourceforge.net/gridarta/?rev=3831&view=rev Author: akirschbaum Date: 2008-04-06 01:55:48 -0700 (Sun, 06 Apr 2008) Log Message: ----------- Move new map dialog code to separate package. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/CMainView.java trunk/crossfire/src/cfeditor/gui/InsertionObjectChooser.java trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/CMainView.java trunk/daimonin/src/daieditor/gui/InsertionObjectChooser.java trunk/src/app/net/sf/gridarta/gui/pickmapchooser/CurrentPickmapActions.java trunk/src/app/net/sf/gridarta/gui/pickmapchooser/PickmapChooserControl.java Added Paths: ----------- trunk/src/app/net/sf/gridarta/gui/newmap/ trunk/src/app/net/sf/gridarta/gui/newmap/NewMapDialog.java trunk/src/app/net/sf/gridarta/gui/newmap/NewMapDialogFactory.java Removed Paths: ------------- trunk/src/app/net/sf/gridarta/gui/NewMapDialog.java trunk/src/app/net/sf/gridarta/gui/NewMapDialogFactory.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-04-04 20:31:01 UTC (rev 3830) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-04-06 08:55:48 UTC (rev 3831) @@ -64,12 +64,12 @@ import net.sf.gridarta.gui.MainView; import net.sf.gridarta.gui.MapFileFilter; import net.sf.gridarta.gui.MapManagerActions; -import net.sf.gridarta.gui.NewMapDialogFactory; import net.sf.gridarta.gui.RecentManager; import net.sf.gridarta.gui.SystemIcons; import net.sf.gridarta.gui.connectionview.LockedItemsControl; import net.sf.gridarta.gui.map.MapCursorControl; import net.sf.gridarta.gui.map.MapView; +import net.sf.gridarta.gui.newmap.NewMapDialogFactory; import net.sf.gridarta.gui.prefs.MapValidatorPrefs; import net.sf.gridarta.gui.prefs.MiscPrefs; import net.sf.gridarta.gui.prefs.UpdatePrefs; Modified: trunk/crossfire/src/cfeditor/CMainView.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainView.java 2008-04-04 20:31:01 UTC (rev 3830) +++ trunk/crossfire/src/cfeditor/CMainView.java 2008-04-06 08:55:48 UTC (rev 3831) @@ -50,10 +50,10 @@ import net.sf.gridarta.gui.GSplitPane; import net.sf.gridarta.gui.GUIUtils; import net.sf.gridarta.gui.MainView; -import net.sf.gridarta.gui.NewMapDialogFactory; import net.sf.gridarta.gui.connectionview.LockedItemsControl; import net.sf.gridarta.gui.map.MapView; import net.sf.gridarta.gui.map.ViewActions; +import net.sf.gridarta.gui.newmap.NewMapDialogFactory; import net.sf.gridarta.gui.selectedsquare.SelectedSquareControl; import net.sf.japi.swing.ActionFactory; import org.apache.log4j.Logger; Modified: trunk/crossfire/src/cfeditor/gui/InsertionObjectChooser.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/InsertionObjectChooser.java 2008-04-04 20:31:01 UTC (rev 3830) +++ trunk/crossfire/src/cfeditor/gui/InsertionObjectChooser.java 2008-04-06 08:55:48 UTC (rev 3831) @@ -38,10 +38,10 @@ import net.sf.gridarta.MainControl; import net.sf.gridarta.gui.AbstractInsertionObjectChooser; import net.sf.gridarta.gui.GSplitPane; -import net.sf.gridarta.gui.NewMapDialogFactory; import net.sf.gridarta.gui.ObjectChoiceDisplay; import net.sf.gridarta.gui.archetypechooser.ArchetypeChooserControl; import net.sf.gridarta.gui.archetypechooser.ArchetypeChooserListener; +import net.sf.gridarta.gui.newmap.NewMapDialogFactory; import net.sf.gridarta.gui.pickmapchooser.PickmapChooserControl; import net.sf.japi.swing.ActionFactory; import org.jetbrains.annotations.NotNull; Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-04-04 20:31:01 UTC (rev 3830) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-04-06 08:55:48 UTC (rev 3831) @@ -71,12 +71,12 @@ import net.sf.gridarta.gui.MainView; import net.sf.gridarta.gui.MapFileFilter; import net.sf.gridarta.gui.MapManagerActions; -import net.sf.gridarta.gui.NewMapDialogFactory; import net.sf.gridarta.gui.RecentManager; import net.sf.gridarta.gui.SystemIcons; import net.sf.gridarta.gui.connectionview.LockedItemsControl; import net.sf.gridarta.gui.map.MapCursorControl; import net.sf.gridarta.gui.map.MapView; +import net.sf.gridarta.gui.newmap.NewMapDialogFactory; import net.sf.gridarta.gui.prefs.MapValidatorPrefs; import net.sf.gridarta.gui.prefs.MiscPrefs; import net.sf.gridarta.gui.prefs.UpdatePrefs; Modified: trunk/daimonin/src/daieditor/CMainView.java =================================================================== --- trunk/daimonin/src/daieditor/CMainView.java 2008-04-04 20:31:01 UTC (rev 3830) +++ trunk/daimonin/src/daieditor/CMainView.java 2008-04-06 08:55:48 UTC (rev 3831) @@ -50,10 +50,10 @@ import net.sf.gridarta.gui.GSplitPane; import net.sf.gridarta.gui.GUIUtils; import net.sf.gridarta.gui.MainView; -import net.sf.gridarta.gui.NewMapDialogFactory; import net.sf.gridarta.gui.connectionview.LockedItemsControl; import net.sf.gridarta.gui.map.MapView; import net.sf.gridarta.gui.map.ViewActions; +import net.sf.gridarta.gui.newmap.NewMapDialogFactory; import net.sf.gridarta.gui.selectedsquare.SelectedSquareControl; import net.sf.japi.swing.ActionFactory; import org.apache.log4j.Logger; Modified: trunk/daimonin/src/daieditor/gui/InsertionObjectChooser.java =================================================================== --- trunk/daimonin/src/daieditor/gui/InsertionObjectChooser.java 2008-04-04 20:31:01 UTC (rev 3830) +++ trunk/daimonin/src/daieditor/gui/InsertionObjectChooser.java 2008-04-06 08:55:48 UTC (rev 3831) @@ -35,10 +35,10 @@ import javax.swing.SwingConstants; import net.sf.gridarta.gui.AbstractInsertionObjectChooser; import net.sf.gridarta.gui.GSplitPane; -import net.sf.gridarta.gui.NewMapDialogFactory; import net.sf.gridarta.gui.ObjectChoiceDisplay; import net.sf.gridarta.gui.archetypechooser.ArchetypeChooserControl; import net.sf.gridarta.gui.archetypechooser.ArchetypeChooserListener; +import net.sf.gridarta.gui.newmap.NewMapDialogFactory; import net.sf.gridarta.gui.pickmapchooser.PickmapChooserControl; import net.sf.japi.swing.ActionFactory; import org.jetbrains.annotations.NotNull; Deleted: trunk/src/app/net/sf/gridarta/gui/NewMapDialog.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/NewMapDialog.java 2008-04-04 20:31:01 UTC (rev 3830) +++ trunk/src/app/net/sf/gridarta/gui/NewMapDialog.java 2008-04-06 08:55:48 UTC (rev 3831) @@ -1,384 +0,0 @@ -/* - * 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 java.awt.Component; -import java.awt.FlowLayout; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.Insets; -import java.util.prefs.Preferences; -import javax.swing.Box; -import javax.swing.BoxLayout; -import javax.swing.JButton; -import javax.swing.JCheckBox; -import javax.swing.JDialog; -import javax.swing.JFormattedTextField; -import javax.swing.JLabel; -import javax.swing.JOptionPane; -import javax.swing.JPanel; -import javax.swing.JTextField; -import javax.swing.WindowConstants; -import javax.swing.border.CompoundBorder; -import javax.swing.border.EtchedBorder; -import javax.swing.border.TitledBorder; -import net.sf.gridarta.AbstractMainControl; -import net.sf.gridarta.CommonConstants; -import net.sf.gridarta.MainControl; -import net.sf.gridarta.Size2D; -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 net.sf.gridarta.map.MapControl; -import net.sf.gridarta.map.MapType; -import net.sf.japi.swing.ActionFactory; - -/** - * Dialog used to ask the user the properties for the new level. Contains a - * tabbed pane for creating a level either based on a template or from a - * scratch. - * @author <a href="mailto:mic...@no...">Michael Toennies</a> - * @author <a href="mailto:and...@gm...">Andreas Vogl</a> - * @author <a href="mailto:ch...@ri...">Christian Hujer</a> - */ -public final class NewMapDialog<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>, C extends MapControl<G, A, R>, V extends MapViewBasic<G, A, R>> extends JOptionPane { - - /** Serial Version UID. */ - private static final long serialVersionUID = 1L; - - /** Action Factory. */ - private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("net.sf.gridarta"); - - /** - * Whether to show the "mapSizeDefault" checkbox. - */ - private final boolean showMapSizeDefault; - - /** - * Whether to show the "mapDifficulty" field. - */ - private final boolean showMapDifficulty; - - /** - * The default width for new maps. - */ - private final int defaultWidth; - - /** - * The default height for new maps. - */ - private final int defaultHeight; - - /** - * The default height for new maps. - */ - private final int defaultDifficulty; - - /** - * Whether to use the default map size. - * @val true override default map size - * @val false use default map size - * @default true - */ - private boolean mapSizeDefault; - - /** Preferences. */ - private static final Preferences prefs = Preferences.userNodeForPackage(MainControl.class); - - /** The key used to store the last used level width in preferences. */ - private static final String DEFAULT_LEVEL_WIDTH_KEY = "NewLevelDialog.mapWidth"; - - /** The key used to store the last used level height in preferences. */ - private static final String DEFAULT_LEVEL_HEIGHT_KEY = "NewLevelDialog.mapHeight"; - - /** The key used to store the last used difficulty in preferences. */ - private static final String DEFAULT_DIFFICULTY_KEY = "NewLevelDialog.difficulty"; - - /** The controller of this new level dialog view. */ - private final MainControl<G, A, R, C, V> mainControl; - - /** Type of map to create: pickmap or normal map. */ - private final MapType mapType; - - /** Desired filename for new map, null if not specified. */ - private final String filename; - - /** - * Textfield for the name of the map. - * This is only used for {@link MapType#GAMEMAP} to determine the title of the new map. - * The filename of the new map is unset and will be specified when the user saves the map for the first time. - */ - private final JTextField mapNameField = new JTextField(16); - - /** - * Checkbox to set whether the default width / height should be overridden. - */ - private final JCheckBox mapSizeDefaultCheckbox = new JCheckBox(ACTION_FACTORY.createToggle(false, "mapSizeDefault", this)); - - /** - * Textfield for the width of the new map. - */ - private final JFormattedTextField mapWidthField = new JFormattedTextField(); - - /** - * Textfield for the height of the new map. - */ - private final JFormattedTextField mapHeightField = new JFormattedTextField(); - - /** - * Textfield for the difficulty of the new map. - */ - private final JFormattedTextField mapDifficultyField = new JFormattedTextField(); - - /** JButton for ok. */ - private final JButton okButton = new JButton(ACTION_FACTORY.createAction(false, "mapOkay", this)); - - /** JButton for cancel. */ - private final JButton cancelButton = new JButton(ACTION_FACTORY.createAction(false, "mapCancel", this)); - - private final JDialog dialog; - - /** - * Constructs a new level dialog. Builds the dialog UI. - * @param mainControl the controller of this dialog. - * @param parentComponent the parent component of this dialog - * @param filename desired filename for new map, null if not specified - * @param mapType type of map to create - * @param showMapSizeDefault Whether to show the "mapSizeDefault" checkbox. - * @param showMapDifficulty Whether to show the "mapDifficulty" field. - * @param defaultWidth The default width for new maps. - * @param defaultHeight The default height for new maps. - * @param defaultDifficulty The default difficulty for new maps. - */ - public NewMapDialog(final MainControl<G, A, R, C, V> mainControl, final Component parentComponent, final String filename, final MapType mapType, final boolean showMapSizeDefault, final boolean showMapDifficulty, final int defaultWidth, final int defaultHeight, final int defaultDifficulty) { - okButton.setDefaultCapable(true); - setOptions(new Object[]{okButton, cancelButton}); - - this.mainControl = mainControl; - this.mapType = mapType; - this.filename = filename; - this.showMapSizeDefault = showMapSizeDefault; - this.showMapDifficulty = showMapDifficulty; - this.defaultWidth = defaultWidth; - this.defaultHeight = defaultHeight; - this.defaultDifficulty = defaultDifficulty; - mapSizeDefault = showMapSizeDefault; - setMessage(createPanel()); - - dialog = createDialog(parentComponent, ACTION_FACTORY.getString(mapType == MapType.PICKMAP ? "newPickmap.title" : "newMap.title")); - dialog.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); - dialog.getRootPane().setDefaultButton(okButton); - dialog.setModal(false); - - if (showMapSizeDefault && mapType != MapType.PICKMAP) { - setMapSizeDefault(true); - } - - dialog.setVisible(true); - mapNameField.selectAll(); - mapWidthField.selectAll(); - mapHeightField.selectAll(); - } - - private JPanel createPanel() { - final JPanel newLevelFromScratchPanel = new JPanel(); - newLevelFromScratchPanel.setLayout(new BoxLayout(newLevelFromScratchPanel, BoxLayout.Y_AXIS)); - - newLevelFromScratchPanel.setBorder(GUIConstants.DIALOG_BORDER); - - // map name panel - final JPanel mapNamePanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); - mapNamePanel.add(new JLabel(ACTION_FACTORY.getString(mapType == MapType.PICKMAP ? "newMapPickmapName" : "newMapMapName"))); - mapNamePanel.add(mapNameField); - newLevelFromScratchPanel.add(mapNamePanel); - newLevelFromScratchPanel.add(Box.createVerticalStrut(5)); - - if (showMapSizeDefault && mapType != MapType.PICKMAP) { - newLevelFromScratchPanel.add(mapSizeDefaultCheckbox); - } - newLevelFromScratchPanel.add(Box.createVerticalStrut(5)); - - final JPanel mapSizePanel = new JPanel(new GridBagLayout()); - final GridBagConstraints gbcLabel = new GridBagConstraints(); - final GridBagConstraints gbcField = new GridBagConstraints(); - gbcLabel.insets = new Insets(2, 2, 2, 2); - gbcField.insets = new Insets(2, 2, 2, 2); - gbcLabel.anchor = GridBagConstraints.EAST; - gbcField.gridwidth = GridBagConstraints.REMAINDER; - mapSizePanel.setBorder(new CompoundBorder(new TitledBorder(new EtchedBorder(), ACTION_FACTORY.getString("newMapParameters")), GUIConstants.DIALOG_BORDER)); - mapSizePanel.add(new JLabel(ACTION_FACTORY.getString("mapWidth")), gbcLabel); - if (mapType == MapType.PICKMAP) { - mapWidthField.setValue(defaultWidth); - } else { - assert mapType == MapType.GAMEMAP; - mapWidthField.setValue(prefs.getInt(DEFAULT_LEVEL_WIDTH_KEY, defaultWidth)); - } - mapWidthField.setColumns(3); - mapSizePanel.add(mapWidthField, gbcField); - mapSizePanel.add(new JLabel(ACTION_FACTORY.getString("mapHeight")), gbcLabel); - if (mapType == MapType.PICKMAP) { - mapHeightField.setValue(defaultHeight); - } else { - //noinspection ConstantConditions - assert mapType == MapType.GAMEMAP; - mapHeightField.setValue(prefs.getInt(DEFAULT_LEVEL_HEIGHT_KEY, defaultHeight)); - } - mapHeightField.setColumns(3); - mapSizePanel.add(mapHeightField, gbcField); - if (showMapDifficulty && mapType == MapType.GAMEMAP) { - mapDifficultyField.setValue(prefs.getInt(DEFAULT_DIFFICULTY_KEY, defaultDifficulty)); - mapSizePanel.add(new JLabel(ACTION_FACTORY.getString("mapDifficulty")), gbcLabel); - mapDifficultyField.setColumns(3); - mapSizePanel.add(mapDifficultyField, gbcField); - } - newLevelFromScratchPanel.add(mapSizePanel); - newLevelFromScratchPanel.add(Box.createVerticalStrut(5)); - - return newLevelFromScratchPanel; - } - - /** Action method for okay. */ - public void mapOkay() { - if (createNewLevel(this)) { - setValue(okButton); - } - } - - /** Action method for cancel. */ - public void mapCancel() { - setValue(cancelButton); - } - - /** {@inheritDoc} */ - @Override public void setValue(final Object newValue) { - super.setValue(newValue); - if (newValue != UNINITIALIZED_VALUE) { - dialog.dispose(); - } - } - - /** - * Checks the given values and creates a new level. - * @param parent the parent component to be used for error messages - * @return True if the level was created, false if the parameters were wrong. - */ - private boolean createNewLevel(final Component parent) { - // Create a new level from scratch - final A mapArchObject = mainControl.getGridartaObjectsFactory().newMapArchObject(); - - final int width; - final int height; - if (mapType == MapType.PICKMAP || !mapSizeDefault) { - // Get and validate the width - try { - width = (Integer) mapWidthField.getValue(); - } catch (final IllegalArgumentException e) { - ACTION_FACTORY.showMessageDialog(this, e instanceof NumberFormatException ? "newMapDimensionNotANumber" : "newMapDimensionOutOfRange"); - mapWidthField.requestFocus(); - return false; - } - if (width < 1) { - ACTION_FACTORY.showMessageDialog(this, "newMapDimensionOutOfRange"); - mapWidthField.requestFocus(); - return false; - } - - // Get and validate the height - try { - height = (Integer) mapHeightField.getValue(); - } catch (final IllegalArgumentException e) { - ACTION_FACTORY.showMessageDialog(this, e instanceof NumberFormatException ? "newMapDimensionNotANumber" : "newMapDimensionOutOfRange"); - mapHeightField.requestFocus(); - return false; - } - if (height < 1) { - ACTION_FACTORY.showMessageDialog(this, "newMapDimensionOutOfRange"); - mapHeightField.requestFocus(); - return false; - } - } else { - width = defaultWidth; - height = defaultHeight; - } - - mapArchObject.setMapSize(new Size2D(width, height)); - - // the map maker must enter a name -- both for maps and pickmaps - final String mapName = mapNameField.getText(); - if (mapName == null || mapName.length() <= 0) { - ACTION_FACTORY.showMessageDialog(this, mapType == MapType.PICKMAP ? "newPickmapNoName" : "newMapNoName"); - mapNameField.requestFocus(); - return false; - } - - if (mapType == MapType.GAMEMAP) { - prefs.putInt(DEFAULT_LEVEL_WIDTH_KEY, width); - prefs.putInt(DEFAULT_LEVEL_HEIGHT_KEY, height); - } - - if (mapType == MapType.GAMEMAP) { - mapArchObject.setMapName(mapName); - if (showMapDifficulty) { - try { - mapArchObject.setDifficulty((Integer) mapDifficultyField.getValue()); - } catch (final IllegalArgumentException e) { - ACTION_FACTORY.showMessageDialog(this, e instanceof NumberFormatException ? "newMapDifficultyNotANumber" : "newMapDifficultyOutOfRange"); - mapDifficultyField.requestFocus(); - return false; - } - } - } else if (mapType == MapType.PICKMAP) { - mapArchObject.setMapName("pickmap"); - } - - // default map text: - mapArchObject.addText("Created: " + String.format("%tF", System.currentTimeMillis()) + " " + prefs.get(AbstractMainControl.PREFS_USERNAME, AbstractMainControl.PREFS_USERNAME_DEFAULT)); - - if (mapType == MapType.GAMEMAP) { - mainControl.getMapManager().newMapWithView(null, mapArchObject, null, null, filename != null ? filename : CommonConstants.DEF_MAPFNAME); - } else if (mapType == MapType.PICKMAP) { - return mainControl.getMainView().getObjectChooser().getPickmapChooserControl().addNewPickmap(parent, mapArchObject, mapName); - } - - return true; - } - - /** - * Set whether to override the default map size. - * @return mapSizeDefault <code>true</code> if the user wants to specify her own map size, otherwise <code>false</code> - */ - public boolean isMapSizeDefault() { - return mapSizeDefault; - } - - /** - * Set whether to override the default map size. - * @param mapSizeDefault <code>true</code> if the user wants to specify her own map size, otherwise <code>false</code> - */ - public void setMapSizeDefault(final boolean mapSizeDefault) { - mapSizeDefaultCheckbox.setSelected(mapSizeDefault); - this.mapSizeDefault = mapSizeDefault; - mapWidthField.setEnabled(!mapSizeDefault); - mapHeightField.setEnabled(!mapSizeDefault); - } - -} // class NewMapDialog Deleted: trunk/src/app/net/sf/gridarta/gui/NewMapDialogFactory.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/NewMapDialogFactory.java 2008-04-04 20:31:01 UTC (rev 3830) +++ trunk/src/app/net/sf/gridarta/gui/NewMapDialogFactory.java 2008-04-06 08:55:48 UTC (rev 3831) @@ -1,117 +0,0 @@ -/* - * 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.MainControl; -import net.sf.gridarta.gameobject.Archetype; -import net.sf.gridarta.gameobject.GameObject; -import net.sf.gridarta.gui.map.MapViewBasic; -import net.sf.gridarta.map.MapArchObject; -import net.sf.gridarta.map.MapControl; -import net.sf.gridarta.map.MapType; -import org.jetbrains.annotations.NotNull; - -/** - * Utility class to create {@link NewMapDialog} instances. - * - * @author Andreas Kirschbaum - */ -public final class NewMapDialogFactory<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>, C extends MapControl<G, A, R>, V extends MapViewBasic<G, A, R>> { - - /** - * The main control instance. - */ - @NotNull private final MainControl<G, A, R, C, V> mainControl; - - /** - * The default width for new maps. - */ - private final int defaultMapWidth; - - /** - * The default height for new maps. - */ - private final int defaultMapHeight; - - /** - * The default difficulty for new maps. - */ - final int defaultMapDifficulty; - - /** - * Whether to show the "mapSizeDefault" checkbox. - */ - final boolean showMapDifficulty; - - /** - * Whether to show the "mapDifficulty" field. - */ - final boolean showMapSizeDefault; - - /** - * The default width for new pickmaps. - */ - private final int defaultPickmapWidth; - - /** - * The default height for new pickmaps. - */ - private final int defaultPickmapHeight; - - /** - * Creates a new instance. - * @param mainControl the main control instance - * @param defaultMapWidth the default width for new maps - * @param defaultMapHeight the default height for new maps - * @param defaultMapDifficulty the default difficulty for new maps - * @param showMapSizeDefault whether to show the "mapSizeDefault" checkbox - * @param showMapDifficulty whether to show the "mapDifficulty" field - * @param defaultPickmapWidth the default width for new pickmaps - * @param defaultPickmapHeight the default height for new pickmaps - */ - public NewMapDialogFactory(@NotNull final MainControl<G, A, R, C, V> mainControl, final int defaultMapWidth, final int defaultMapHeight, final int defaultMapDifficulty, final boolean showMapDifficulty, final boolean showMapSizeDefault, final int defaultPickmapWidth, final int defaultPickmapHeight) - { - this.mainControl = mainControl; - this.defaultMapWidth = defaultMapWidth; - this.defaultMapHeight = defaultMapHeight; - this.defaultMapDifficulty = defaultMapDifficulty; - this.showMapSizeDefault = showMapSizeDefault; - this.showMapDifficulty = showMapDifficulty; - this.defaultPickmapWidth = defaultPickmapWidth; - this.defaultPickmapHeight = defaultPickmapHeight; - } - - /** - * Shows a dialog for creating a new map. - * @param filename the filename for the new map; <code>null</code> if - * unknown - */ - public void showNewMapDialog(final String filename) { - new NewMapDialog<G, A, R, C, V>(mainControl, mainControl.getMainView(), filename, MapType.GAMEMAP, showMapSizeDefault, showMapDifficulty, defaultMapWidth, defaultMapHeight, defaultMapDifficulty); - } - - /** - * Shows a dialog for creating a new pickmap. - */ - public void showNewPickmapDialog() { - new NewMapDialog<G, A, R, C, V>(mainControl, mainControl.getMainView(), null, MapType.PICKMAP, false, false, defaultPickmapWidth, defaultPickmapHeight, 0); - } - -} // class NewMapDialogFactory Copied: trunk/src/app/net/sf/gridarta/gui/newmap/NewMapDialog.java (from rev 3830, trunk/src/app/net/sf/gridarta/gui/NewMapDialog.java) =================================================================== --- trunk/src/app/net/sf/gridarta/gui/newmap/NewMapDialog.java (rev 0) +++ trunk/src/app/net/sf/gridarta/gui/newmap/NewMapDialog.java 2008-04-06 08:55:48 UTC (rev 3831) @@ -0,0 +1,385 @@ +/* + * 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.newmap; + +import java.awt.Component; +import java.awt.FlowLayout; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.Insets; +import java.util.prefs.Preferences; +import javax.swing.Box; +import javax.swing.BoxLayout; +import javax.swing.JButton; +import javax.swing.JCheckBox; +import javax.swing.JDialog; +import javax.swing.JFormattedTextField; +import javax.swing.JLabel; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JTextField; +import javax.swing.WindowConstants; +import javax.swing.border.CompoundBorder; +import javax.swing.border.EtchedBorder; +import javax.swing.border.TitledBorder; +import net.sf.gridarta.AbstractMainControl; +import net.sf.gridarta.CommonConstants; +import net.sf.gridarta.MainControl; +import net.sf.gridarta.Size2D; +import net.sf.gridarta.gameobject.Archetype; +import net.sf.gridarta.gameobject.GameObject; +import net.sf.gridarta.gui.GUIConstants; +import net.sf.gridarta.gui.map.MapView; +import net.sf.gridarta.gui.map.MapViewBasic; +import net.sf.gridarta.map.MapArchObject; +import net.sf.gridarta.map.MapControl; +import net.sf.gridarta.map.MapType; +import net.sf.japi.swing.ActionFactory; + +/** + * Dialog used to ask the user the properties for the new level. Contains a + * tabbed pane for creating a level either based on a template or from a + * scratch. + * @author <a href="mailto:mic...@no...">Michael Toennies</a> + * @author <a href="mailto:and...@gm...">Andreas Vogl</a> + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + */ +public final class NewMapDialog<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>, C extends MapControl<G, A, R>, V extends MapViewBasic<G, A, R>> extends JOptionPane { + + /** Serial Version UID. */ + private static final long serialVersionUID = 1L; + + /** Action Factory. */ + private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("net.sf.gridarta"); + + /** + * Whether to show the "mapSizeDefault" checkbox. + */ + private final boolean showMapSizeDefault; + + /** + * Whether to show the "mapDifficulty" field. + */ + private final boolean showMapDifficulty; + + /** + * The default width for new maps. + */ + private final int defaultWidth; + + /** + * The default height for new maps. + */ + private final int defaultHeight; + + /** + * The default height for new maps. + */ + private final int defaultDifficulty; + + /** + * Whether to use the default map size. + * @val true override default map size + * @val false use default map size + * @default true + */ + private boolean mapSizeDefault; + + /** Preferences. */ + private static final Preferences prefs = Preferences.userNodeForPackage(MainControl.class); + + /** The key used to store the last used level width in preferences. */ + private static final String DEFAULT_LEVEL_WIDTH_KEY = "NewLevelDialog.mapWidth"; + + /** The key used to store the last used level height in preferences. */ + private static final String DEFAULT_LEVEL_HEIGHT_KEY = "NewLevelDialog.mapHeight"; + + /** The key used to store the last used difficulty in preferences. */ + private static final String DEFAULT_DIFFICULTY_KEY = "NewLevelDialog.difficulty"; + + /** The controller of this new level dialog view. */ + private final MainControl<G, A, R, C, V> mainControl; + + /** Type of map to create: pickmap or normal map. */ + private final MapType mapType; + + /** Desired filename for new map, null if not specified. */ + private final String filename; + + /** + * Textfield for the name of the map. + * This is only used for {@link MapType#GAMEMAP} to determine the title of the new map. + * The filename of the new map is unset and will be specified when the user saves the map for the first time. + */ + private final JTextField mapNameField = new JTextField(16); + + /** + * Checkbox to set whether the default width / height should be overridden. + */ + private final JCheckBox mapSizeDefaultCheckbox = new JCheckBox(ACTION_FACTORY.createToggle(false, "mapSizeDefault", this)); + + /** + * Textfield for the width of the new map. + */ + private final JFormattedTextField mapWidthField = new JFormattedTextField(); + + /** + * Textfield for the height of the new map. + */ + private final JFormattedTextField mapHeightField = new JFormattedTextField(); + + /** + * Textfield for the difficulty of the new map. + */ + private final JFormattedTextField mapDifficultyField = new JFormattedTextField(); + + /** JButton for ok. */ + private final JButton okButton = new JButton(ACTION_FACTORY.createAction(false, "mapOkay", this)); + + /** JButton for cancel. */ + private final JButton cancelButton = new JButton(ACTION_FACTORY.createAction(false, "mapCancel", this)); + + private final JDialog dialog; + + /** + * Constructs a new level dialog. Builds the dialog UI. + * @param mainControl the controller of this dialog. + * @param parentComponent the parent component of this dialog + * @param filename desired filename for new map, null if not specified + * @param mapType type of map to create + * @param showMapSizeDefault Whether to show the "mapSizeDefault" checkbox. + * @param showMapDifficulty Whether to show the "mapDifficulty" field. + * @param defaultWidth The default width for new maps. + * @param defaultHeight The default height for new maps. + * @param defaultDifficulty The default difficulty for new maps. + */ + public NewMapDialog(final MainControl<G, A, R, C, V> mainControl, final Component parentComponent, final String filename, final MapType mapType, final boolean showMapSizeDefault, final boolean showMapDifficulty, final int defaultWidth, final int defaultHeight, final int defaultDifficulty) { + okButton.setDefaultCapable(true); + setOptions(new Object[]{okButton, cancelButton}); + + this.mainControl = mainControl; + this.mapType = mapType; + this.filename = filename; + this.showMapSizeDefault = showMapSizeDefault; + this.showMapDifficulty = showMapDifficulty; + this.defaultWidth = defaultWidth; + this.defaultHeight = defaultHeight; + this.defaultDifficulty = defaultDifficulty; + mapSizeDefault = showMapSizeDefault; + setMessage(createPanel()); + + dialog = createDialog(parentComponent, ACTION_FACTORY.getString(mapType == MapType.PICKMAP ? "newPickmap.title" : "newMap.title")); + dialog.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); + dialog.getRootPane().setDefaultButton(okButton); + dialog.setModal(false); + + if (showMapSizeDefault && mapType != MapType.PICKMAP) { + setMapSizeDefault(true); + } + + dialog.setVisible(true); + mapNameField.selectAll(); + mapWidthField.selectAll(); + mapHeightField.selectAll(); + } + + private JPanel createPanel() { + final JPanel newLevelFromScratchPanel = new JPanel(); + newLevelFromScratchPanel.setLayout(new BoxLayout(newLevelFromScratchPanel, BoxLayout.Y_AXIS)); + + newLevelFromScratchPanel.setBorder(GUIConstants.DIALOG_BORDER); + + // map name panel + final JPanel mapNamePanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); + mapNamePanel.add(new JLabel(ACTION_FACTORY.getString(mapType == MapType.PICKMAP ? "newMapPickmapName" : "newMapMapName"))); + mapNamePanel.add(mapNameField); + newLevelFromScratchPanel.add(mapNamePanel); + newLevelFromScratchPanel.add(Box.createVerticalStrut(5)); + + if (showMapSizeDefault && mapType != MapType.PICKMAP) { + newLevelFromScratchPanel.add(mapSizeDefaultCheckbox); + } + newLevelFromScratchPanel.add(Box.createVerticalStrut(5)); + + final JPanel mapSizePanel = new JPanel(new GridBagLayout()); + final GridBagConstraints gbcLabel = new GridBagConstraints(); + final GridBagConstraints gbcField = new GridBagConstraints(); + gbcLabel.insets = new Insets(2, 2, 2, 2); + gbcField.insets = new Insets(2, 2, 2, 2); + gbcLabel.anchor = GridBagConstraints.EAST; + gbcField.gridwidth = GridBagConstraints.REMAINDER; + mapSizePanel.setBorder(new CompoundBorder(new TitledBorder(new EtchedBorder(), ACTION_FACTORY.getString("newMapParameters")), GUIConstants.DIALOG_BORDER)); + mapSizePanel.add(new JLabel(ACTION_FACTORY.getString("mapWidth")), gbcLabel); + if (mapType == MapType.PICKMAP) { + mapWidthField.setValue(defaultWidth); + } else { + assert mapType == MapType.GAMEMAP; + mapWidthField.setValue(prefs.getInt(DEFAULT_LEVEL_WIDTH_KEY, defaultWidth)); + } + mapWidthField.setColumns(3); + mapSizePanel.add(mapWidthField, gbcField); + mapSizePanel.add(new JLabel(ACTION_FACTORY.getString("mapHeight")), gbcLabel); + if (mapType == MapType.PICKMAP) { + mapHeightField.setValue(defaultHeight); + } else { + //noinspection ConstantConditions + assert mapType == MapType.GAMEMAP; + mapHeightField.setValue(prefs.getInt(DEFAULT_LEVEL_HEIGHT_KEY, defaultHeight)); + } + mapHeightField.setColumns(3); + mapSizePanel.add(mapHeightField, gbcField); + if (showMapDifficulty && mapType == MapType.GAMEMAP) { + mapDifficultyField.setValue(prefs.getInt(DEFAULT_DIFFICULTY_KEY, defaultDifficulty)); + mapSizePanel.add(new JLabel(ACTION_FACTORY.getString("mapDifficulty")), gbcLabel); + mapDifficultyField.setColumns(3); + mapSizePanel.add(mapDifficultyField, gbcField); + } + newLevelFromScratchPanel.add(mapSizePanel); + newLevelFromScratchPanel.add(Box.createVerticalStrut(5)); + + return newLevelFromScratchPanel; + } + + /** Action method for okay. */ + public void mapOkay() { + if (createNewLevel(this)) { + setValue(okButton); + } + } + + /** Action method for cancel. */ + public void mapCancel() { + setValue(cancelButton); + } + + /** {@inheritDoc} */ + @Override public void setValue(final Object newValue) { + super.setValue(newValue); + if (newValue != UNINITIALIZED_VALUE) { + dialog.dispose(); + } + } + + /** + * Checks the given values and creates a new level. + * @param parent the parent component to be used for error messages + * @return True if the level was created, false if the parameters were wrong. + */ + private boolean createNewLevel(final Component parent) { + // Create a new level from scratch + final A mapArchObject = mainControl.getGridartaObjectsFactory().newMapArchObject(); + + final int width; + final int height; + if (mapType == MapType.PICKMAP || !mapSizeDefault) { + // Get and validate the width + try { + width = (Integer) mapWidthField.getValue(); + } catch (final IllegalArgumentException e) { + ACTION_FACTORY.showMessageDialog(this, e instanceof NumberFormatException ? "newMapDimensionNotANumber" : "newMapDimensionOutOfRange"); + mapWidthField.requestFocus(); + return false; + } + if (width < 1) { + ACTION_FACTORY.showMessageDialog(this, "newMapDimensionOutOfRange"); + mapWidthField.requestFocus(); + return false; + } + + // Get and validate the height + try { + height = (Integer) mapHeightField.getValue(); + } catch (final IllegalArgumentException e) { + ACTION_FACTORY.showMessageDialog(this, e instanceof NumberFormatException ? "newMapDimensionNotANumber" : "newMapDimensionOutOfRange"); + mapHeightField.requestFocus(); + return false; + } + if (height < 1) { + ACTION_FACTORY.showMessageDialog(this, "newMapDimensionOutOfRange"); + mapHeightField.requestFocus(); + return false; + } + } else { + width = defaultWidth; + height = defaultHeight; + } + + mapArchObject.setMapSize(new Size2D(width, height)); + + // the map maker must enter a name -- both for maps and pickmaps + final String mapName = mapNameField.getText(); + if (mapName == null || mapName.length() <= 0) { + ACTION_FACTORY.showMessageDialog(this, mapType == MapType.PICKMAP ? "newPickmapNoName" : "newMapNoName"); + mapNameField.requestFocus(); + return false; + } + + if (mapType == MapType.GAMEMAP) { + prefs.putInt(DEFAULT_LEVEL_WIDTH_KEY, width); + prefs.putInt(DEFAULT_LEVEL_HEIGHT_KEY, height); + } + + if (mapType == MapType.GAMEMAP) { + mapArchObject.setMapName(mapName); + if (showMapDifficulty) { + try { + mapArchObject.setDifficulty((Integer) mapDifficultyField.getValue()); + } catch (final IllegalArgumentException e) { + ACTION_FACTORY.showMessageDialog(this, e instanceof NumberFormatException ? "newMapDifficultyNotANumber" : "newMapDifficultyOutOfRange"); + mapDifficultyField.requestFocus(); + return false; + } + } + } else if (mapType == MapType.PICKMAP) { + mapArchObject.setMapName("pickmap"); + } + + // default map text: + mapArchObject.addText("Created: " + String.format("%tF", System.currentTimeMillis()) + " " + prefs.get(AbstractMainControl.PREFS_USERNAME, AbstractMainControl.PREFS_USERNAME_DEFAULT)); + + if (mapType == MapType.GAMEMAP) { + mainControl.getMapManager().newMapWithView(null, mapArchObject, null, null, filename != null ? filename : CommonConstants.DEF_MAPFNAME); + } else if (mapType == MapType.PICKMAP) { + return mainControl.getMainView().getObjectChooser().getPickmapChooserControl().addNewPickmap(parent, mapArchObject, mapName); + } + + return true; + } + + /** + * Set whether to override the default map size. + * @return mapSizeDefault <code>true</code> if the user wants to specify her own map size, otherwise <code>false</code> + */ + public boolean isMapSizeDefault() { + return mapSizeDefault; + } + + /** + * Set whether to override the default map size. + * @param mapSizeDefault <code>true</code> if the user wants to specify her own map size, otherwise <code>false</code> + */ + public void setMapSizeDefault(final boolean mapSizeDefault) { + mapSizeDefaultCheckbox.setSelected(mapSizeDefault); + this.mapSizeDefault = mapSizeDefault; + mapWidthField.setEnabled(!mapSizeDefault); + mapHeightField.setEnabled(!mapSizeDefault); + } + +} // class NewMapDialog Copied: trunk/src/app/net/sf/gridarta/gui/newmap/NewMapDialogFactory.java (from rev 3830, trunk/src/app/net/sf/gridarta/gui/NewMapDialogFactory.java) =================================================================== --- trunk/src/app/net/sf/gridarta/gui/newmap/NewMapDialogFactory.java (rev 0) +++ trunk/src/app/net/sf/gridarta/gui/newmap/NewMapDialogFactory.java 2008-04-06 08:55:48 UTC (rev 3831) @@ -0,0 +1,117 @@ +/* + * 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.newmap; + +import net.sf.gridarta.MainControl; +import net.sf.gridarta.gameobject.Archetype; +import net.sf.gridarta.gameobject.GameObject; +import net.sf.gridarta.gui.map.MapViewBasic; +import net.sf.gridarta.map.MapArchObject; +import net.sf.gridarta.map.MapControl; +import net.sf.gridarta.map.MapType; +import org.jetbrains.annotations.NotNull; + +/** + * Utility class to create {@link NewMapDialog} instances. + * + * @author Andreas Kirschbaum + */ +public final class NewMapDialogFactory<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>, C extends MapControl<G, A, R>, V extends MapViewBasic<G, A, R>> { + + /** + * The main control instance. + */ + @NotNull private final MainControl<G, A, R, C, V> mainControl; + + /** + * The default width for new maps. + */ + private final int defaultMapWidth; + + /** + * The default height for new maps. + */ + private final int defaultMapHeight; + + /** + * The default difficulty for new maps. + */ + final int defaultMapDifficulty; + + /** + * Whether to show the "mapSizeDefault" checkbox. + */ + final boolean showMapDifficulty; + + /** + * Whether to show the "mapDifficulty" field. + */ + final boolean showMapSizeDefault; + + /** + * The default width for new pickmaps. + */ + private final int defaultPickmapWidth; + + /** + * The default height for new pickmaps. + */ + private final int defaultPickmapHeight; + + /** + * Creates a new instance. + * @param mainControl the main control instance + * @param defaultMapWidth the default width for new maps + * @param defaultMapHeight the default height for new maps + * @param defaultMapDifficulty the default difficulty for new maps + * @param showMapSizeDefault whether to show the "mapSizeDefault" checkbox + * @param showMapDifficulty whether to show the "mapDifficulty" field + * @param defaultPickmapWidth the default width for new pickmaps + * @param defaultPickmapHeight the default height for new pickmaps + */ + public NewMapDialogFactory(@NotNull final MainControl<G, A, R, C, V> mainControl, final int defaultMapWidth, final int defaultMapHeight, final int defaultMapDifficulty, final boolean showMapDifficulty, final boolean showMapSizeDefault, final int defaultPickmapWidth, final int defaultPickmapHeight) + { + this.mainControl = mainControl; + this.defaultMapWidth = defaultMapWidth; + this.defaultMapHeight = defaultMapHeight; + this.defaultMapDifficulty = defaultMapDifficulty; + this.showMapSizeDefault = showMapSizeDefault; + this.showMapDifficulty = showMapDifficulty; + this.defaultPickmapWidth = defaultPickmapWidth; + this.defaultPickmapHeight = defaultPickmapHeight; + } + + /** + * Shows a dialog for creating a new map. + * @param filename the filename for the new map; <code>null</code> if + * unknown + */ + public void showNewMapDialog(final String filename) { + new NewMapDialog<G, A, R, C, V>(mainControl, mainControl.getMainView(), filename, MapType.GAMEMAP, showMapSizeDefault, showMapDifficulty, defaultMapWidth, defaultMapHeight, defaultMapDifficulty); + } + + /** + * Shows a dialog for creating a new pickmap. + */ + public void showNewPickmapDialog() { + new NewMapDialog<G, A, R, C, V>(mainControl, mainControl.getMainView(), null, MapType.PICKMAP, false, false, defaultPickmapWidth, defaultPickmapHeight, 0); + } + +} // class NewMapDialogFactory Modified: trunk/src/app/net/sf/gridarta/gui/pickmapchooser/CurrentPickmapActions.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/pickmapchooser/CurrentPickmapActions.java 2008-04-04 20:31:01 UTC (rev 3830) +++ trunk/src/app/net/sf/gridarta/gui/pickmapchooser/CurrentPickmapActions.java 2008-04-06 08:55:48 UTC (rev 3831) @@ -24,8 +24,8 @@ import net.sf.gridarta.MainControl; import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.GameObject; -import net.sf.gridarta.gui.NewMapDialogFactory; import net.sf.gridarta.gui.map.MapViewBasic; +import net.sf.gridarta.gui.newmap.NewMapDialogFactory; import net.sf.gridarta.map.MapArchObject; import net.sf.gridarta.map.MapControl; import net.sf.gridarta.map.MapControlListener; Modified: trunk/src/app/net/sf/gridarta/gui/pickmapchooser/PickmapChooserControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/pickmapchooser/PickmapChooserControl.java 2008-04-04 20:31:01 UTC (rev 3830) +++ trunk/src/app/net/sf/gridarta/gui/pickmapchooser/PickmapChooserControl.java 2008-04-06 08:55:48 UTC (rev 3831) @@ -32,8 +32,8 @@ import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.GameObject; import net.sf.gridarta.gui.InsertionObjectChooser; -import net.sf.gridarta.gui.NewMapDialogFactory; import net.sf.gridarta.gui.map.MapViewBasic; +import net.sf.gridarta.gui.newmap.NewMapDialogFactory; import net.sf.gridarta.io.MapReader; import net.sf.gridarta.map.MapArchObject; import net.sf.gridarta.map.MapControl; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-04-06 21:15:34
|
Revision: 3835 http://gridarta.svn.sourceforge.net/gridarta/?rev=3835&view=rev Author: akirschbaum Date: 2008-04-06 14:15:38 -0700 (Sun, 06 Apr 2008) Log Message: ----------- Remove unused import statements. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/gui/InsertionObjectChooser.java trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/gui/GameObjectAttributesDialog.java trunk/daimonin/src/daieditor/gui/InsertionObjectChooser.java trunk/src/app/net/sf/gridarta/gui/map/MapFileActions.java trunk/src/app/net/sf/gridarta/gui/newmap/AbstractNewMapDialog.java trunk/src/app/net/sf/gridarta/gui/newmap/NewMapDialog.java trunk/src/app/net/sf/gridarta/gui/newmap/NewMapDialogFactory.java trunk/src/app/net/sf/gridarta/gui/newmap/NewPickmapDialog.java trunk/src/app/net/sf/gridarta/textedit/textarea/tokenmarker/DaimoninAITokenMarker.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-04-06 21:02:50 UTC (rev 3834) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-04-06 21:15:38 UTC (rev 3835) @@ -57,11 +57,8 @@ import net.sf.gridarta.gameobject.Collectable; import net.sf.gridarta.gameobject.Collector; import net.sf.gridarta.gui.About; -import net.sf.gridarta.gui.GUIConstants; -import net.sf.gridarta.gui.GUIUtils; import net.sf.gridarta.gui.HideFileFilterProxy; import net.sf.gridarta.gui.MainActions; -import net.sf.gridarta.gui.MainView; import net.sf.gridarta.gui.MapFileFilter; import net.sf.gridarta.gui.MapManagerActions; import net.sf.gridarta.gui.RecentManager; Modified: trunk/crossfire/src/cfeditor/gui/InsertionObjectChooser.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/InsertionObjectChooser.java 2008-04-06 21:02:50 UTC (rev 3834) +++ trunk/crossfire/src/cfeditor/gui/InsertionObjectChooser.java 2008-04-06 21:15:38 UTC (rev 3835) @@ -21,7 +21,6 @@ import cfeditor.CMainControl; import cfeditor.CMapViewBasic; -import cfeditor.IGUIConstants; import cfeditor.gameobject.Archetype; import cfeditor.gameobject.GameObject; import cfeditor.map.MapArchObject; Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-04-06 21:02:50 UTC (rev 3834) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-04-06 21:15:38 UTC (rev 3835) @@ -64,11 +64,9 @@ import net.sf.gridarta.gameobject.match.MutableOrGameObjectMatcher; import net.sf.gridarta.gameobject.match.ViewGameObjectMatcherManager; import net.sf.gridarta.gui.About; -import net.sf.gridarta.gui.GUIConstants; import net.sf.gridarta.gui.GUIUtils; import net.sf.gridarta.gui.HideFileFilterProxy; import net.sf.gridarta.gui.MainActions; -import net.sf.gridarta.gui.MainView; import net.sf.gridarta.gui.MapFileFilter; import net.sf.gridarta.gui.MapManagerActions; import net.sf.gridarta.gui.RecentManager; Modified: trunk/daimonin/src/daieditor/gui/GameObjectAttributesDialog.java =================================================================== --- trunk/daimonin/src/daieditor/gui/GameObjectAttributesDialog.java 2008-04-06 21:02:50 UTC (rev 3834) +++ trunk/daimonin/src/daieditor/gui/GameObjectAttributesDialog.java 2008-04-06 21:15:38 UTC (rev 3835) @@ -31,7 +31,6 @@ import javax.swing.JComboBox; import javax.swing.JDialog; import javax.swing.JFormattedTextField; -import javax.swing.JTextArea; import javax.swing.JTextField; import javax.swing.text.JTextComponent; import net.sf.gridarta.CFArchAttrib; Modified: trunk/daimonin/src/daieditor/gui/InsertionObjectChooser.java =================================================================== --- trunk/daimonin/src/daieditor/gui/InsertionObjectChooser.java 2008-04-06 21:02:50 UTC (rev 3834) +++ trunk/daimonin/src/daieditor/gui/InsertionObjectChooser.java 2008-04-06 21:15:38 UTC (rev 3835) @@ -21,7 +21,6 @@ import daieditor.CMainControl; import daieditor.CMapViewBasic; -import daieditor.IGUIConstants; import daieditor.gameobject.Archetype; import daieditor.gameobject.GameObject; import daieditor.gui.map.tools.ToolPalette; Modified: trunk/src/app/net/sf/gridarta/gui/map/MapFileActions.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/MapFileActions.java 2008-04-06 21:02:50 UTC (rev 3834) +++ trunk/src/app/net/sf/gridarta/gui/map/MapFileActions.java 2008-04-06 21:15:38 UTC (rev 3835) @@ -19,8 +19,6 @@ package net.sf.gridarta.gui.map; -import java.util.ArrayList; -import java.util.List; import javax.swing.Action; import net.sf.gridarta.CurrentMapListener; import net.sf.gridarta.MainControl; Modified: trunk/src/app/net/sf/gridarta/gui/newmap/AbstractNewMapDialog.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/newmap/AbstractNewMapDialog.java 2008-04-06 21:02:50 UTC (rev 3834) +++ trunk/src/app/net/sf/gridarta/gui/newmap/AbstractNewMapDialog.java 2008-04-06 21:15:38 UTC (rev 3835) @@ -20,7 +20,6 @@ package net.sf.gridarta.gui.newmap; import java.awt.Component; -import java.awt.FlowLayout; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import java.awt.Insets; @@ -28,10 +27,7 @@ import javax.swing.Box; import javax.swing.BoxLayout; import javax.swing.JButton; -import javax.swing.JCheckBox; import javax.swing.JDialog; -import javax.swing.JFormattedTextField; -import javax.swing.JLabel; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JTextField; @@ -39,14 +35,10 @@ import javax.swing.border.CompoundBorder; import javax.swing.border.EtchedBorder; import javax.swing.border.TitledBorder; -import net.sf.gridarta.AbstractMainControl; -import net.sf.gridarta.CommonConstants; import net.sf.gridarta.MainControl; -import net.sf.gridarta.Size2D; import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.GameObject; import net.sf.gridarta.gui.GUIConstants; -import net.sf.gridarta.gui.map.MapView; import net.sf.gridarta.gui.map.MapViewBasic; import net.sf.gridarta.map.MapArchObject; import net.sf.gridarta.map.MapControl; Modified: trunk/src/app/net/sf/gridarta/gui/newmap/NewMapDialog.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/newmap/NewMapDialog.java 2008-04-06 21:02:50 UTC (rev 3834) +++ trunk/src/app/net/sf/gridarta/gui/newmap/NewMapDialog.java 2008-04-06 21:15:38 UTC (rev 3835) @@ -22,31 +22,14 @@ import java.awt.Component; import java.awt.FlowLayout; import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.Insets; -import java.util.prefs.Preferences; -import javax.swing.Box; -import javax.swing.BoxLayout; -import javax.swing.JButton; -import javax.swing.JCheckBox; -import javax.swing.JDialog; import javax.swing.JFormattedTextField; import javax.swing.JLabel; -import javax.swing.JOptionPane; import javax.swing.JPanel; -import javax.swing.JTextField; -import javax.swing.WindowConstants; -import javax.swing.border.CompoundBorder; -import javax.swing.border.EtchedBorder; -import javax.swing.border.TitledBorder; import net.sf.gridarta.AbstractMainControl; import net.sf.gridarta.CommonConstants; import net.sf.gridarta.MainControl; -import net.sf.gridarta.Size2D; import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.GameObject; -import net.sf.gridarta.gui.GUIConstants; -import net.sf.gridarta.gui.map.MapView; import net.sf.gridarta.gui.map.MapViewBasic; import net.sf.gridarta.map.MapArchObject; import net.sf.gridarta.map.MapControl; Modified: trunk/src/app/net/sf/gridarta/gui/newmap/NewMapDialogFactory.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/newmap/NewMapDialogFactory.java 2008-04-06 21:02:50 UTC (rev 3834) +++ trunk/src/app/net/sf/gridarta/gui/newmap/NewMapDialogFactory.java 2008-04-06 21:15:38 UTC (rev 3835) @@ -25,7 +25,6 @@ import net.sf.gridarta.gui.map.MapViewBasic; import net.sf.gridarta.map.MapArchObject; import net.sf.gridarta.map.MapControl; -import net.sf.gridarta.map.MapType; import org.jetbrains.annotations.NotNull; /** Modified: trunk/src/app/net/sf/gridarta/gui/newmap/NewPickmapDialog.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/newmap/NewPickmapDialog.java 2008-04-06 21:02:50 UTC (rev 3834) +++ trunk/src/app/net/sf/gridarta/gui/newmap/NewPickmapDialog.java 2008-04-06 21:15:38 UTC (rev 3835) @@ -22,31 +22,12 @@ import java.awt.Component; import java.awt.FlowLayout; import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.Insets; -import java.util.prefs.Preferences; -import javax.swing.Box; -import javax.swing.BoxLayout; -import javax.swing.JButton; -import javax.swing.JCheckBox; -import javax.swing.JDialog; -import javax.swing.JFormattedTextField; import javax.swing.JLabel; -import javax.swing.JOptionPane; import javax.swing.JPanel; -import javax.swing.JTextField; -import javax.swing.WindowConstants; -import javax.swing.border.CompoundBorder; -import javax.swing.border.EtchedBorder; -import javax.swing.border.TitledBorder; import net.sf.gridarta.AbstractMainControl; -import net.sf.gridarta.CommonConstants; import net.sf.gridarta.MainControl; -import net.sf.gridarta.Size2D; import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.GameObject; -import net.sf.gridarta.gui.GUIConstants; -import net.sf.gridarta.gui.map.MapView; import net.sf.gridarta.gui.map.MapViewBasic; import net.sf.gridarta.map.MapArchObject; import net.sf.gridarta.map.MapControl; Modified: trunk/src/app/net/sf/gridarta/textedit/textarea/tokenmarker/DaimoninAITokenMarker.java =================================================================== --- trunk/src/app/net/sf/gridarta/textedit/textarea/tokenmarker/DaimoninAITokenMarker.java 2008-04-06 21:02:50 UTC (rev 3834) +++ trunk/src/app/net/sf/gridarta/textedit/textarea/tokenmarker/DaimoninAITokenMarker.java 2008-04-06 21:15:38 UTC (rev 3835) @@ -20,12 +20,10 @@ package net.sf.gridarta.textedit.textarea.tokenmarker; import java.util.ArrayList; -import java.util.Collections; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; -import java.util.Set; import java.util.regex.Pattern; import javax.swing.text.Segment; import net.sf.gridarta.textedit.textarea.Token; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-04-06 21:56:35
|
Revision: 3836 http://gridarta.svn.sourceforge.net/gridarta/?rev=3836&view=rev Author: akirschbaum Date: 2008-04-06 14:54:57 -0700 (Sun, 06 Apr 2008) Log Message: ----------- Move code to create map default attributes into GridartaObjectsFactory.newMapArchObject(). Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/CrossfireObjectsFactory.java trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/DaimoninObjectsFactory.java trunk/src/app/net/sf/gridarta/GridartaObjectsFactory.java trunk/src/app/net/sf/gridarta/gui/map/AbstractMapTilePane.java trunk/src/app/net/sf/gridarta/gui/newmap/NewMapDialog.java trunk/src/app/net/sf/gridarta/gui/newmap/NewPickmapDialog.java trunk/src/app/net/sf/gridarta/io/DefaultMapReader.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-04-06 21:15:38 UTC (rev 3835) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-04-06 21:54:57 UTC (rev 3836) @@ -299,7 +299,7 @@ net.sf.gridarta.gameobject.GameObject.setTypeList(typeList); // set reference in GameObject - getCopyBuffer().init(getGridartaObjectsFactory().newMapArchObject()); + getCopyBuffer().init(getGridartaObjectsFactory().newMapArchObject(false)); mainActions.init(); recentManager = new RecentManager(this, (JMenu) ACTION_FACTORY.find(mainView.getJMenuBar(), "recent")); Modified: trunk/crossfire/src/cfeditor/CrossfireObjectsFactory.java =================================================================== --- trunk/crossfire/src/cfeditor/CrossfireObjectsFactory.java 2008-04-06 21:15:38 UTC (rev 3835) +++ trunk/crossfire/src/cfeditor/CrossfireObjectsFactory.java 2008-04-06 21:54:57 UTC (rev 3836) @@ -22,6 +22,7 @@ import java.io.File; import java.io.FileNotFoundException; import java.util.List; +import java.util.prefs.Preferences; import cfeditor.gameobject.Archetype; import cfeditor.gameobject.GameObject; import cfeditor.gameobject.UndefinedArchetype; @@ -29,7 +30,9 @@ import cfeditor.io.MapArchObjectParser; import cfeditor.map.MapArchObject; import cfeditor.map.MapControl; +import net.sf.gridarta.AbstractMainControl; import net.sf.gridarta.GridartaObjectsFactory; +import net.sf.gridarta.MainControl; import net.sf.gridarta.io.DefaultMapReader; import net.sf.gridarta.io.MapReader; import org.jetbrains.annotations.NotNull; @@ -42,14 +45,21 @@ */ public class CrossfireObjectsFactory implements GridartaObjectsFactory<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> { + /** Preferences. */ + private static final Preferences prefs = Preferences.userNodeForPackage(MainControl.class); + /** {@inheritDoc} */ @NotNull public GameObject newGameObject() { return new GameObject(); } /** {@inheritDoc} */ - @NotNull public MapArchObject newMapArchObject() { - return new MapArchObject(); + @NotNull public MapArchObject newMapArchObject(final boolean addDefaultAttributes) { + final MapArchObject mapArchObject = new MapArchObject(); + if (addDefaultAttributes) { + mapArchObject.addText("Created: " + String.format("%tF", System.currentTimeMillis()) + " " + prefs.get(AbstractMainControl.PREFS_USERNAME, AbstractMainControl.PREFS_USERNAME_DEFAULT)); + } + return mapArchObject; } /** {@inheritDoc} */ Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-04-06 21:15:38 UTC (rev 3835) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-04-06 21:54:57 UTC (rev 3836) @@ -353,7 +353,7 @@ net.sf.gridarta.gameobject.GameObject.setTypeList(typeList); // set reference in GameObject - getCopyBuffer().init(getGridartaObjectsFactory().newMapArchObject()); + getCopyBuffer().init(getGridartaObjectsFactory().newMapArchObject(false)); mainActions.init(); // Delete libraries. Modified: trunk/daimonin/src/daieditor/DaimoninObjectsFactory.java =================================================================== --- trunk/daimonin/src/daieditor/DaimoninObjectsFactory.java 2008-04-06 21:15:38 UTC (rev 3835) +++ trunk/daimonin/src/daieditor/DaimoninObjectsFactory.java 2008-04-06 21:54:57 UTC (rev 3836) @@ -22,6 +22,7 @@ import java.io.File; import java.io.FileNotFoundException; import java.util.List; +import java.util.prefs.Preferences; import daieditor.gameobject.Archetype; import daieditor.gameobject.GameObject; import daieditor.gameobject.UndefinedArchetype; @@ -29,7 +30,9 @@ import daieditor.io.MapArchObjectParser; import daieditor.map.MapArchObject; import daieditor.map.MapControl; +import net.sf.gridarta.AbstractMainControl; import net.sf.gridarta.GridartaObjectsFactory; +import net.sf.gridarta.MainControl; import net.sf.gridarta.io.DefaultMapReader; import net.sf.gridarta.io.MapReader; import org.jetbrains.annotations.NotNull; @@ -42,14 +45,21 @@ */ public class DaimoninObjectsFactory implements GridartaObjectsFactory<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> { + /** Preferences. */ + private static final Preferences prefs = Preferences.userNodeForPackage(MainControl.class); + /** {@inheritDoc} */ @NotNull public GameObject newGameObject() { return new GameObject(); } /** {@inheritDoc} */ - @NotNull public MapArchObject newMapArchObject() { - return new MapArchObject(); + @NotNull public MapArchObject newMapArchObject(final boolean addDefaultAttributes) { + final MapArchObject mapArchObject = new MapArchObject(); + if (addDefaultAttributes) { + mapArchObject.addText("Created: " + String.format("%tF", System.currentTimeMillis()) + " " + prefs.get(AbstractMainControl.PREFS_USERNAME, AbstractMainControl.PREFS_USERNAME_DEFAULT)); + } + return mapArchObject; } /** {@inheritDoc} */ Modified: trunk/src/app/net/sf/gridarta/GridartaObjectsFactory.java =================================================================== --- trunk/src/app/net/sf/gridarta/GridartaObjectsFactory.java 2008-04-06 21:15:38 UTC (rev 3835) +++ trunk/src/app/net/sf/gridarta/GridartaObjectsFactory.java 2008-04-06 21:54:57 UTC (rev 3836) @@ -42,10 +42,11 @@ /** * Create a new {@link MapArchObject} instance. - * + * @param addDefaultAttributes if set, add default attributes such as + * "Created:" * @return The new map arch object. */ - @NotNull A newMapArchObject(); + @NotNull A newMapArchObject(boolean addDefaultAttributes); /** * Create a new {@link GameObject} instance. Modified: trunk/src/app/net/sf/gridarta/gui/map/AbstractMapTilePane.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/AbstractMapTilePane.java 2008-04-06 21:15:38 UTC (rev 3835) +++ trunk/src/app/net/sf/gridarta/gui/map/AbstractMapTilePane.java 2008-04-06 21:54:57 UTC (rev 3836) @@ -521,7 +521,7 @@ final BufferedReader myInput = new BufferedReader(new InputStreamReader(new FileInputStream(file), IOUtils.MAP_ENCODING)); try { // first of all we read the map arch (if that fails we throw an exception) - final A mapArchObject = mainControl.getGridartaObjectsFactory().newMapArchObject(); + final A mapArchObject = mainControl.getGridartaObjectsFactory().newMapArchObject(false); mainControl.getGridartaObjectsFactory().newMapArchObjectParser().load(myInput, mapArchObject); maphead = new TileMapHeader(mapArchObject); Modified: trunk/src/app/net/sf/gridarta/gui/newmap/NewMapDialog.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/newmap/NewMapDialog.java 2008-04-06 21:15:38 UTC (rev 3835) +++ trunk/src/app/net/sf/gridarta/gui/newmap/NewMapDialog.java 2008-04-06 21:54:57 UTC (rev 3836) @@ -122,7 +122,7 @@ /** {@inheritDoc} */ @Override protected boolean createNew() { // Create a new level from scratch - final A mapArchObject = mainControl.getGridartaObjectsFactory().newMapArchObject(); + final A mapArchObject = mainControl.getGridartaObjectsFactory().newMapArchObject(true); if (!setMapSize(mapArchObject)) { return false; @@ -152,9 +152,6 @@ mapArchObject.setDifficulty(difficulty); } - // default map text: - mapArchObject.addText("Created: " + String.format("%tF", System.currentTimeMillis()) + " " + prefs.get(AbstractMainControl.PREFS_USERNAME, AbstractMainControl.PREFS_USERNAME_DEFAULT)); - mainControl.getMapManager().newMapWithView(null, mapArchObject, null, null, filename != null ? filename : CommonConstants.DEF_MAPFNAME); return true; } Modified: trunk/src/app/net/sf/gridarta/gui/newmap/NewPickmapDialog.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/newmap/NewPickmapDialog.java 2008-04-06 21:15:38 UTC (rev 3835) +++ trunk/src/app/net/sf/gridarta/gui/newmap/NewPickmapDialog.java 2008-04-06 21:54:57 UTC (rev 3836) @@ -81,7 +81,7 @@ /** {@inheritDoc} */ @Override protected boolean createNew() { // Create a new level from scratch - final A mapArchObject = mainControl.getGridartaObjectsFactory().newMapArchObject(); + final A mapArchObject = mainControl.getGridartaObjectsFactory().newMapArchObject(true); if (!setMapSize(mapArchObject)) { return false; @@ -97,9 +97,6 @@ mapArchObject.setMapName("pickmap"); - // default map text: - mapArchObject.addText("Created: " + String.format("%tF", System.currentTimeMillis()) + " " + prefs.get(AbstractMainControl.PREFS_USERNAME, AbstractMainControl.PREFS_USERNAME_DEFAULT)); - return mainControl.getMainView().getObjectChooser().getPickmapChooserControl().addNewPickmap(this, mapArchObject, mapName); } Modified: trunk/src/app/net/sf/gridarta/io/DefaultMapReader.java =================================================================== --- trunk/src/app/net/sf/gridarta/io/DefaultMapReader.java 2008-04-06 21:15:38 UTC (rev 3835) +++ trunk/src/app/net/sf/gridarta/io/DefaultMapReader.java 2008-04-06 21:54:57 UTC (rev 3836) @@ -116,7 +116,7 @@ public void decodeMapFile(final boolean isInteractive) throws IOException { final GridartaObjectsFactory<G, A, R, ?, ?> gridartaObjectsFactory = mainControl.getGridartaObjectsFactory(); - mapArchObject = gridartaObjectsFactory.newMapArchObject(); + mapArchObject = gridartaObjectsFactory.newMapArchObject(false); gridartaObjectsFactory.newMapArchObjectParser().load(myInput, mapArchObject); final GameObjectParser gameObjectParser = gridartaObjectsFactory.newGameObjectParser(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-04-07 18:47:46
|
Revision: 3837 http://gridarta.svn.sourceforge.net/gridarta/?rev=3837&view=rev Author: akirschbaum Date: 2008-04-07 11:47:40 -0700 (Mon, 07 Apr 2008) Log Message: ----------- Replace "close pickmap" with "delete pickmap". Modified Paths: -------------- trunk/crossfire/ChangeLog trunk/daimonin/ChangeLog trunk/src/app/net/sf/gridarta/action.properties trunk/src/app/net/sf/gridarta/gui/pickmapchooser/CurrentPickmapActions.java trunk/src/app/net/sf/gridarta/gui/pickmapchooser/PickmapChooserControl.java trunk/src/app/net/sf/gridarta/messages.properties trunk/src/app/net/sf/gridarta/messages_de.properties trunk/src/app/net/sf/gridarta/messages_fr.properties trunk/src/app/net/sf/gridarta/messages_sv.properties Modified: trunk/crossfire/ChangeLog =================================================================== --- trunk/crossfire/ChangeLog 2008-04-06 21:54:57 UTC (rev 3836) +++ trunk/crossfire/ChangeLog 2008-04-07 18:47:40 UTC (rev 3837) @@ -1,3 +1,7 @@ +2008-04-07 Andreas Kirschbaum + + * Replace "close pickmap" with "delete pickmap". + 2008-04-01 Andreas Kirschbaum * Retain main window's state (maximized, iconized, etc.) across Modified: trunk/daimonin/ChangeLog =================================================================== --- trunk/daimonin/ChangeLog 2008-04-06 21:54:57 UTC (rev 3836) +++ trunk/daimonin/ChangeLog 2008-04-07 18:47:40 UTC (rev 3837) @@ -1,3 +1,7 @@ +2008-04-07 Andreas Kirschbaum + + * Replace "close pickmap" with "delete pickmap". + 2008-04-01 Andreas Kirschbaum * Reduce default pickmap size to 7x7. Modified: trunk/src/app/net/sf/gridarta/action.properties =================================================================== --- trunk/src/app/net/sf/gridarta/action.properties 2008-04-06 21:54:57 UTC (rev 3836) +++ trunk/src/app/net/sf/gridarta/action.properties 2008-04-07 18:47:40 UTC (rev 3837) @@ -41,10 +41,10 @@ redo.icon=general/Redo16 -pickmaps.menu=lockAllPickmaps - addNewPickmap closePickmap - openPickmapMap - savePickmap revertPickmap +pickmaps.menu=lockAllPickmaps - addNewPickmap deletePickmap - openPickmapMap - savePickmap revertPickmap lockAllPickmaps.icon=EmptySmallIcon addNewPickmap.icon=general/New16 -closePickmap.icon=EmptySmallIcon +deletePickmap.icon=EmptySmallIcon openPickmapMap.icon=general/Open16 savePickmap.icon=general/Save16 revertPickmap.icon=general/Refresh16 Modified: trunk/src/app/net/sf/gridarta/gui/pickmapchooser/CurrentPickmapActions.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/pickmapchooser/CurrentPickmapActions.java 2008-04-06 21:54:57 UTC (rev 3836) +++ trunk/src/app/net/sf/gridarta/gui/pickmapchooser/CurrentPickmapActions.java 2008-04-07 18:47:40 UTC (rev 3837) @@ -61,8 +61,8 @@ /** Action called for "open active pickmap as map". */ private final Action aOpenPickmapMap = ACTION_FACTORY.createAction(true, "openPickmapMap", this); - /** Action called for "close active pickmap". */ - private final Action aClosePickmap = ACTION_FACTORY.createAction(true, "closePickmap", this); + /** Action called for "delete active pickmap". */ + private final Action aDeletePickmap = ACTION_FACTORY.createAction(true, "deletePickmap", this); /** Action called for "save active pickmap". */ private final Action aSavePickmap = ACTION_FACTORY.createAction(true, "savePickmap", this); @@ -150,11 +150,11 @@ } } - /** Invoked when the user wants to close the active pickmap. */ - public void closePickmap() { - final C pickmap = getClosePickmap(); + /** Invoked when the user wants to delete the active pickmap. */ + public void deletePickmap() { + final C pickmap = getDeletePickmap(); if (pickmap != null) { - control.closePickmapWanted(pickmap); + control.deletePickmapWanted(pickmap); } } @@ -203,7 +203,7 @@ * @return the pickmap to close, or <code>null</code> if "close active * pickmap" is disabled */ - @Nullable private C getClosePickmap() { + @Nullable private C getDeletePickmap() { if (isLockAllPickmaps() || !active) { return null; } @@ -322,7 +322,7 @@ protected void refresh() { aAddNewPickmap.setEnabled(isAddNewPickmapEnabled()); aOpenPickmapMap.setEnabled(getOpenPickmapMap() != null); - aClosePickmap.setEnabled(getClosePickmap() != null); + aDeletePickmap.setEnabled(getDeletePickmap() != null); aSavePickmap.setEnabled(getSavePickmap() != null); aRevertPickmap.setEnabled(getRevertPickmap() != null); } Modified: trunk/src/app/net/sf/gridarta/gui/pickmapchooser/PickmapChooserControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/pickmapchooser/PickmapChooserControl.java 2008-04-06 21:54:57 UTC (rev 3836) +++ trunk/src/app/net/sf/gridarta/gui/pickmapchooser/PickmapChooserControl.java 2008-04-07 18:47:40 UTC (rev 3837) @@ -359,18 +359,15 @@ } } - public void closePickmapWanted(@NotNull final C pickmap) { - if (pickmap.isModified() && !ACTION_FACTORY.showQuestionDialog(mainControl.getMainView(), "confirmClosePickmap", pickmap.getMapFileName())) { + public void deletePickmapWanted(@NotNull final C pickmap) { + if (!ACTION_FACTORY.showQuestionDialog(mainControl.getMainView(), "confirmDeletePickmap", pickmap.getMapFileName())) { return; } final File pickmapFile = pickmap.getMapFile(); mainControl.getMapManager().closeLevel(pickmap, true); - - if (ACTION_FACTORY.showQuestionDialog(mainControl.getMainView(), "confirmDeletePickmap", pickmap.getMapFileName(), pickmap.getMapFileName())) { - if (pickmapFile != null) { - pickmapFile.delete(); - } + if (pickmapFile != null) { + pickmapFile.delete(); } } Modified: trunk/src/app/net/sf/gridarta/messages.properties =================================================================== --- trunk/src/app/net/sf/gridarta/messages.properties 2008-04-06 21:54:57 UTC (rev 3836) +++ trunk/src/app/net/sf/gridarta/messages.properties 2008-04-07 18:47:40 UTC (rev 3837) @@ -148,11 +148,8 @@ revertPickmapGone.title=Cannot revert pickmap revertPickmapGone.message=The file for pickmap "{0}" doesn''t exist. -confirmClosePickmap.title=Close pickmap? -confirmClosePickmap.message=If you close the pickmap ''{0}'', all recent\nchanges will be lost. Do you really want to close it? - confirmDeletePickmap.title=Delete pickmap file? -confirmDeletePickmap.message=The pickmap ''{0}'' has been closed.\nDo you also want to remove the pickmap file ''{1}''?\nDoing so will permanently delete the pickmap. +confirmDeletePickmap.message=Do you really want to delete the pickmap file ''{0}''?\nDoing so will permanently delete the pickmap. confirmSaveChanges.title=Save changes? confirmSaveChanges.message=Do you want to save changes to map {0}? @@ -498,8 +495,8 @@ addNewPickmap.text=Add New Pickmap addNewPickmap.mnemonic=N -closePickmap.text=Close Active Pickmap -closePickmap.mnemonic=C +deletePickmap.text=Delete Active Pickmap +deletePickmap.mnemonic=D openPickmapMap.text=Open Active Pickmap as Map openPickmapMap.mnemonic=O Modified: trunk/src/app/net/sf/gridarta/messages_de.properties =================================================================== --- trunk/src/app/net/sf/gridarta/messages_de.properties 2008-04-06 21:54:57 UTC (rev 3836) +++ trunk/src/app/net/sf/gridarta/messages_de.properties 2008-04-07 18:47:40 UTC (rev 3837) @@ -136,11 +136,8 @@ revertPickmapGone.title=Kann \xC4nderungen nicht zur\xFCcknehmen revertPickmapGone.message=F\xFCr die Pickmap ''{0}'' existiert keine Datei. -confirmClosePickmap.title=Pickmap schlie\xDFen? -confirmClosePickmap.message=Die letzten \xC4nderungen gehen verloren,\nwenn Sie die Pickmap ''{0}'' schlie\xDFen.\nSind Sie sicher, dass Sie das wollen? - confirmDeletePickmap.title=Pickmap l\xF6schen? -confirmDeletePickmap.message=Die Pickmap ''{0}'' wurde geschlossen.\nWollen Sie auch die Datei ''{1}'' l\xF6schen?\nDies wird die Pickmap endg\xFCltig l\xF6schen. +confirmDeletePickmap.message=Wollen Sie die Pickmap-Datei ''{0}'' l\xF6schen?\nDies wird die Pickmap endg\xFCltig l\xF6schen. confirmSaveChanges.title=\xC4nderungen sichern? confirmSaveChanges.message=Wollen Sie die \xC4nderungen der Karte {0} sichern? @@ -462,8 +459,8 @@ addNewPickmap.text=Pickmap hinzuf\xFCgen addNewPickmap.mnemonic=H -closePickmap.text=Aktive Pickmap schlie\xDFen -closePickmap.mnemonic=S +deletePickmap.text=Aktive Pickmap l\xF6schen +deletePickmap.mnemonic=L openPickmapMap.text=Aktive Pickmap als Karte \xF6ffnen openPickmapMap.mnemonic=F Modified: trunk/src/app/net/sf/gridarta/messages_fr.properties =================================================================== --- trunk/src/app/net/sf/gridarta/messages_fr.properties 2008-04-06 21:54:57 UTC (rev 3836) +++ trunk/src/app/net/sf/gridarta/messages_fr.properties 2008-04-07 18:47:40 UTC (rev 3837) @@ -135,9 +135,6 @@ #revertPickmapGone.title= #revertPickmapGone.message= -#confirmClosePickmap.title=kClose pickmap? -#confirmClosePickmap.message= - #confirmDeletePickmap.title= #confirmDeletePickmap.message= @@ -461,8 +458,8 @@ addNewPickmap.text=Nouvel assortiment addNewPickmap.mnemonic=N -closePickmap.text=Fermer assortiment actif -closePickmap.mnemonic=F +#deletePickmap.text= +#deletePickmap.mnemonic= openPickmapMap.text=Ouvrir assortiment actif comme carte openPickmapMap.mnemonic=O Modified: trunk/src/app/net/sf/gridarta/messages_sv.properties =================================================================== --- trunk/src/app/net/sf/gridarta/messages_sv.properties 2008-04-06 21:54:57 UTC (rev 3836) +++ trunk/src/app/net/sf/gridarta/messages_sv.properties 2008-04-07 18:47:40 UTC (rev 3837) @@ -133,11 +133,8 @@ revertPickmapGone.title=Kan inte \xE5terst\xE4lla plockkartan. revertPickmapGone.message=Filen f\xF6r plockkartan "{0}" existerar inte. -confirmClosePickmap.title=St\xE4nga plockkarta? -confirmClosePickmap.message=Om du st\xE4nger plockkartan ''{0}'' kommer alla nyliga\n\xE4ndringar att f\xF6rloras.\n Vill du verkligen st\xE4nga den? - confirmDeletePickmap.title=Radera fil f\xF6r plockkarta? -confirmDeletePickmap.message=Plockkartan ''{0}'' \xE4r st\xE4ngd.\nVill du ocks\xE5 ta bort filen ''{1}''?\nBorttagning av filen kommer att permanent radera plockkartan. +confirmDeletePickmap.message=Vill du ocks\xE5 ta bort filen ''{0}''?\nBorttagning av filen kommer att permanent radera plockkartan. confirmSaveChanges.title=Spara \xE4ndringar? confirmSaveChanges.message=Vill du spara \xE4ndringar p\xE5 kartan {0}? @@ -460,8 +457,8 @@ addNewPickmap.text=L\xE4gg till ny plockkarta addNewPickmap.mnemonic=N -closePickmap.text=St\xE4ng aktiv plockkarta -closePickmap.mnemonic=T +#closePickmap.text= +#closePickmap.mnemonic= openPickmapMap.text=\xD6ppna aktiv plockkarta som karta openPickmapMap.mnemonic=P This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-04-07 20:08:52
|
Revision: 3839 http://gridarta.svn.sourceforge.net/gridarta/?rev=3839&view=rev Author: akirschbaum Date: 2008-04-07 13:07:02 -0700 (Mon, 07 Apr 2008) Log Message: ----------- Implement pickmap folders. Pickmap groups allow grouping pickmaps by themes. Modified Paths: -------------- trunk/crossfire/ChangeLog trunk/crossfire/src/cfeditor/CMainView.java trunk/daimonin/ChangeLog trunk/daimonin/src/daieditor/CMainView.java trunk/src/app/net/sf/gridarta/DefaultMapManager.java trunk/src/app/net/sf/gridarta/action.properties trunk/src/app/net/sf/gridarta/gui/AbstractInsertionObjectChooser.java trunk/src/app/net/sf/gridarta/gui/newmap/AbstractNewMapDialog.java trunk/src/app/net/sf/gridarta/gui/newmap/NewMapDialogFactory.java trunk/src/app/net/sf/gridarta/gui/newmap/NewPickmapDialog.java trunk/src/app/net/sf/gridarta/gui/pickmapchooser/CurrentPickmapActions.java trunk/src/app/net/sf/gridarta/gui/pickmapchooser/PickmapChooserControl.java trunk/src/app/net/sf/gridarta/gui/pickmapchooser/PickmapChooserView.java trunk/src/app/net/sf/gridarta/gui/pickmapchooser/PickmapSelectionListener.java trunk/src/app/net/sf/gridarta/map/AbstractMapControl.java trunk/src/app/net/sf/gridarta/messages.properties trunk/src/app/net/sf/gridarta/messages_de.properties trunk/src/app/net/sf/gridarta/messages_fr.properties trunk/src/app/net/sf/gridarta/messages_sv.properties Added Paths: ----------- trunk/src/app/net/sf/gridarta/gui/newmap/NewPickmapFolderDialog.java trunk/src/app/net/sf/gridarta/gui/pickmapchooser/DuplicateFolderException.java trunk/src/app/net/sf/gridarta/gui/pickmapchooser/DuplicatePickmapException.java trunk/src/app/net/sf/gridarta/gui/pickmapchooser/Folder.java trunk/src/app/net/sf/gridarta/gui/pickmapchooser/FolderListAction.java trunk/src/app/net/sf/gridarta/gui/pickmapchooser/FolderListActions.java trunk/src/app/net/sf/gridarta/gui/pickmapchooser/FolderListener.java trunk/src/app/net/sf/gridarta/gui/pickmapchooser/FolderNotEmptyException.java trunk/src/app/net/sf/gridarta/gui/pickmapchooser/InvalidNameException.java trunk/src/app/net/sf/gridarta/gui/pickmapchooser/Loader.java trunk/src/app/net/sf/gridarta/gui/pickmapchooser/Model.java trunk/src/app/net/sf/gridarta/gui/pickmapchooser/ModelListener.java trunk/src/app/net/sf/gridarta/gui/pickmapchooser/Pickmap.java Modified: trunk/crossfire/ChangeLog =================================================================== --- trunk/crossfire/ChangeLog 2008-04-07 19:45:10 UTC (rev 3838) +++ trunk/crossfire/ChangeLog 2008-04-07 20:07:02 UTC (rev 3839) @@ -1,5 +1,8 @@ 2008-04-07 Andreas Kirschbaum + * Implement pickmap folders. Pickmap groups allow grouping + pickmaps by themes. + * Replace "close pickmap" with "delete pickmap". 2008-04-01 Andreas Kirschbaum Modified: trunk/crossfire/src/cfeditor/CMainView.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainView.java 2008-04-07 19:45:10 UTC (rev 3838) +++ trunk/crossfire/src/cfeditor/CMainView.java 2008-04-07 20:07:02 UTC (rev 3839) @@ -188,6 +188,7 @@ archetypesActions = new ArchetypesActions<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(this, objectChooser.getArchetypeChooserControl(), mainControl.getArchetypeSet(), objectChooser); setJMenuBar(actionFactory.createMenuBar(true, "main")); + objectChooser.setPickmapFoldersMenu((JMenu) actionFactory.find(getJMenuBar(), "pickmapFolders")); mapActions.updateMenuState(); Modified: trunk/daimonin/ChangeLog =================================================================== --- trunk/daimonin/ChangeLog 2008-04-07 19:45:10 UTC (rev 3838) +++ trunk/daimonin/ChangeLog 2008-04-07 20:07:02 UTC (rev 3839) @@ -1,5 +1,8 @@ 2008-04-07 Andreas Kirschbaum + * Implement pickmap folders. Pickmap groups allow grouping + pickmaps by themes. + * Replace "close pickmap" with "delete pickmap". 2008-04-01 Andreas Kirschbaum Modified: trunk/daimonin/src/daieditor/CMainView.java =================================================================== --- trunk/daimonin/src/daieditor/CMainView.java 2008-04-07 19:45:10 UTC (rev 3838) +++ trunk/daimonin/src/daieditor/CMainView.java 2008-04-07 20:07:02 UTC (rev 3839) @@ -188,6 +188,7 @@ archetypesActions = new ArchetypesActions<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(this, objectChooser.getArchetypeChooserControl(), mainControl.getArchetypeSet(), objectChooser); setJMenuBar(actionFactory.createMenuBar(true, "main")); + objectChooser.setPickmapFoldersMenu((JMenu) actionFactory.find(getJMenuBar(), "pickmapFolders")); mapActions.updateMenuState(); Modified: trunk/src/app/net/sf/gridarta/DefaultMapManager.java =================================================================== --- trunk/src/app/net/sf/gridarta/DefaultMapManager.java 2008-04-07 19:45:10 UTC (rev 3838) +++ trunk/src/app/net/sf/gridarta/DefaultMapManager.java 2008-04-07 20:07:02 UTC (rev 3839) @@ -158,19 +158,15 @@ } } - if (mapControl.isPickmap()) { - // special case: close a pickmap - mainControl.getMainView().getObjectChooser().getPickmapChooserControl().closePickmap(mapControl); - } else { - while (mapControl.nViews() > 0) { - final MapView<G, A, R, C, V> mapView = mapControl.getMapViewFrame(); - mainControl.getMainView().removeLevelView(mapView); - mapControl.closeView(mapView); - } - - fireMapClosingEvent(mapControl); - levels.remove(mapControl); + assert !mapControl.isPickmap(); + while (mapControl.nViews() > 0) { + final MapView<G, A, R, C, V> mapView = mapControl.getMapViewFrame(); + mainControl.getMainView().removeLevelView(mapView); + mapControl.closeView(mapView); } + + fireMapClosingEvent(mapControl); + levels.remove(mapControl); mapControl.levelCloseNotify(); return true; } Modified: trunk/src/app/net/sf/gridarta/action.properties =================================================================== --- trunk/src/app/net/sf/gridarta/action.properties 2008-04-07 19:45:10 UTC (rev 3838) +++ trunk/src/app/net/sf/gridarta/action.properties 2008-04-07 20:07:02 UTC (rev 3839) @@ -41,13 +41,14 @@ redo.icon=general/Redo16 -pickmaps.menu=lockAllPickmaps - addNewPickmap deletePickmap - openPickmapMap - savePickmap revertPickmap +pickmaps.menu=lockAllPickmaps - addNewPickmap deletePickmap - openPickmapMap - savePickmap revertPickmap - createPickmapFolder deletePickmapFolder - pickmapFolders lockAllPickmaps.icon=EmptySmallIcon addNewPickmap.icon=general/New16 deletePickmap.icon=EmptySmallIcon openPickmapMap.icon=general/Open16 savePickmap.icon=general/Save16 revertPickmap.icon=general/Refresh16 +pickmapFolders.menu= ##################### Modified: trunk/src/app/net/sf/gridarta/gui/AbstractInsertionObjectChooser.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/AbstractInsertionObjectChooser.java 2008-04-07 19:45:10 UTC (rev 3838) +++ trunk/src/app/net/sf/gridarta/gui/AbstractInsertionObjectChooser.java 2008-04-07 20:07:02 UTC (rev 3839) @@ -20,10 +20,12 @@ package net.sf.gridarta.gui; import java.awt.BorderLayout; +import javax.swing.JMenu; import javax.swing.JPanel; import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.GameObject; import net.sf.gridarta.map.MapArchObject; +import org.jetbrains.annotations.Nullable; /** * Abstract base class for the Object Chooser. @@ -55,4 +57,12 @@ return pickmapActive; } + /** + * Sets the pickmap folders menu to manage. + * @param folderMenu the pickmap folders menu + */ + public void setPickmapFoldersMenu(@Nullable final JMenu folderMenu) { + getPickmapChooserControl().setPickmapFoldersMenu(folderMenu); + } + } // class AbstractInsertionObjectChooser Modified: trunk/src/app/net/sf/gridarta/gui/newmap/AbstractNewMapDialog.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/newmap/AbstractNewMapDialog.java 2008-04-07 19:45:10 UTC (rev 3838) +++ trunk/src/app/net/sf/gridarta/gui/newmap/AbstractNewMapDialog.java 2008-04-07 20:07:02 UTC (rev 3839) @@ -111,14 +111,17 @@ panel.add(createMapNamePanel()); panel.add(Box.createVerticalStrut(5)); panel.add(Box.createVerticalStrut(5)); - panel.add(createMapParametersPanel()); + final JPanel parametersPanel = createMapParametersPanel(); + if (parametersPanel != null) { + panel.add(parametersPanel); + } panel.add(Box.createVerticalStrut(5)); return panel; } protected abstract JPanel createMapNamePanel(); - private JPanel createMapParametersPanel() { + protected JPanel createMapParametersPanel() { final JPanel panel = new JPanel(new GridBagLayout()); final GridBagConstraints gbcLabel = new GridBagConstraints(); Modified: trunk/src/app/net/sf/gridarta/gui/newmap/NewMapDialogFactory.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/newmap/NewMapDialogFactory.java 2008-04-07 19:45:10 UTC (rev 3838) +++ trunk/src/app/net/sf/gridarta/gui/newmap/NewMapDialogFactory.java 2008-04-07 20:07:02 UTC (rev 3839) @@ -23,9 +23,12 @@ import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.GameObject; import net.sf.gridarta.gui.map.MapViewBasic; +import net.sf.gridarta.gui.pickmapchooser.Folder; +import net.sf.gridarta.gui.pickmapchooser.Model; import net.sf.gridarta.map.MapArchObject; import net.sf.gridarta.map.MapControl; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * Utility class to create {@link NewMapDialog} instances. @@ -113,4 +116,13 @@ new NewPickmapDialog<G, A, R, C, V>(mainControl, mainControl.getMainView(), defaultPickmapWidth, defaultPickmapHeight); } + /** + * Shows a dialog for creating a new pickmap folder. + * @param model the model to add the pickmap folder to + * @param parent the parent folder to add the pickmap folder to + */ + public void showNewPickmapFolderDialog(@NotNull final Model<G, A, R, C, V> model, @Nullable final Folder<G, A, R, C, V> parent) { + new NewPickmapFolderDialog<G, A, R, C, V>(mainControl.getMainView(), model, parent); + } + } // class NewMapDialogFactory Modified: trunk/src/app/net/sf/gridarta/gui/newmap/NewPickmapDialog.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/newmap/NewPickmapDialog.java 2008-04-07 19:45:10 UTC (rev 3838) +++ trunk/src/app/net/sf/gridarta/gui/newmap/NewPickmapDialog.java 2008-04-07 20:07:02 UTC (rev 3839) @@ -34,7 +34,7 @@ import net.sf.japi.swing.ActionFactory; /** - * Dialog to create a new map file. + * Dialog to create a new pickmap file. * @author Andreas Kirschbaum */ public final class NewPickmapDialog<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>, C extends MapControl<G, A, R>, V extends MapViewBasic<G, A, R>> extends AbstractMapsizeNewMapDialog<G, A, R, C, V> { @@ -95,7 +95,7 @@ return false; } - mapArchObject.setMapName("pickmap"); + mapArchObject.setMapName(mapName); return mainControl.getMainView().getObjectChooser().getPickmapChooserControl().addNewPickmap(this, mapArchObject, mapName); } Added: trunk/src/app/net/sf/gridarta/gui/newmap/NewPickmapFolderDialog.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/newmap/NewPickmapFolderDialog.java (rev 0) +++ trunk/src/app/net/sf/gridarta/gui/newmap/NewPickmapFolderDialog.java 2008-04-07 20:07:02 UTC (rev 3839) @@ -0,0 +1,154 @@ +/* + * 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.newmap; + +import java.awt.Component; +import java.awt.FlowLayout; +import java.awt.GridBagConstraints; +import java.io.File; +import javax.swing.JLabel; +import javax.swing.JPanel; +import net.sf.gridarta.AbstractMainControl; +import net.sf.gridarta.MainControl; +import net.sf.gridarta.gameobject.Archetype; +import net.sf.gridarta.gameobject.GameObject; +import net.sf.gridarta.gui.map.MapViewBasic; +import net.sf.gridarta.gui.pickmapchooser.DuplicateFolderException; +import net.sf.gridarta.gui.pickmapchooser.Folder; +import net.sf.gridarta.gui.pickmapchooser.InvalidNameException; +import net.sf.gridarta.gui.pickmapchooser.Loader; +import net.sf.gridarta.gui.pickmapchooser.Model; +import net.sf.gridarta.map.MapArchObject; +import net.sf.gridarta.map.MapControl; +import net.sf.japi.swing.ActionFactory; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * Dialog to create a new pickmap folder. + * @author Andreas Kirschbaum + */ +public final class NewPickmapFolderDialog<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>, C extends MapControl<G, A, R>, V extends MapViewBasic<G, A, R>> extends AbstractNewMapDialog<G, A, R, C, V> { + + /** Serial Version UID. */ + private static final long serialVersionUID = 1L; + + /** Action Factory. */ + private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("net.sf.gridarta"); + + /** + * The model to add the pickmap folder to. + */ + @NotNull private final Model<G, A, R, C, V> model; + + /** + * The parent folder to add the pickmap folder to. + */ + @Nullable private final Folder<G, A, R, C, V> parent; + + /** + * Creates a "new pickmap folder" dialog. + * @param parentComponent the parent component of this dialog + * @param model the model to add the pickmap folder to + * @param parent the parent folder to add the pickmap folder to + */ + public NewPickmapFolderDialog(final Component parentComponent, @NotNull final Model<G, A, R, C, V> model, @Nullable final Folder<G, A, R, C, V> parent) { + this.model = model; + this.parent = parent; + init1(parentComponent, ACTION_FACTORY.getString("newPickmapFolder.title")); + init2(); + } + + /** {@inheritDoc} */ + @Override protected JPanel createMapNamePanel() { + final JPanel panel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); + panel.add(new JLabel(ACTION_FACTORY.getString("newMapPickmapFolderName"))); + panel.add(mapNameField); + return panel; + } + + @Override protected JPanel createMapParametersPanel() { + return null; + } + + /** {@inheritDoc} */ + @Override protected void addMapSizeDefaultCheckbox(final JPanel panel, final GridBagConstraints gbcLabel) { + throw new AssertionError(); + } + + /** {@inheritDoc} */ + @Override protected void addMapWidthField(final JPanel panel, final GridBagConstraints gbcLabel, final GridBagConstraints gbcField) { + throw new AssertionError(); + } + + /** {@inheritDoc} */ + @Override protected void addMapHeightField(final JPanel panel, final GridBagConstraints gbcLabel, final GridBagConstraints gbcField) { + throw new AssertionError(); + } + + /** {@inheritDoc} */ + @Override protected void addDifficultyField(final JPanel panel, final GridBagConstraints gbcLabel, final GridBagConstraints gbcField) { + throw new AssertionError(); + } + + /** {@inheritDoc} */ + @Override protected boolean createNew() { + final String folderName = mapNameField.getText(); + if (folderName == null || folderName.length() <= 0) { + ACTION_FACTORY.showMessageDialog(this, "newPickmapFolderNoName"); + mapNameField.requestFocus(); + return false; + } + + final Folder<G, A, R, C, V> folder; + try { + folder = new Folder<G, A, R, C, V>(parent, folderName, model); + } catch (final InvalidNameException Nex) { + ACTION_FACTORY.showMessageDialog(this, "newPickmapFolderInvalidName", folderName); + mapNameField.requestFocus(); + return false; + } + + final File folderDir = folder.getDir(); + if (folderDir.exists()) { + ACTION_FACTORY.showMessageDialog(this, "newPickmapFolderExists", folderName); + mapNameField.requestFocus(); + return false; + } + if (!folderDir.mkdir()) { + ACTION_FACTORY.showMessageDialog(this, "mkdirIOError", folderDir); + mapNameField.requestFocus(); + return false; + } + + try { + model.addFolder(folder); + } catch (final DuplicateFolderException ex) { + ACTION_FACTORY.showMessageDialog(this, "newPickmapFolderExists", folderName); + mapNameField.requestFocus(); + return false; + } + + model.setActiveFolder(folder); + + return true; + } + +} // class NewPickmapFolderDialog Property changes on: trunk/src/app/net/sf/gridarta/gui/newmap/NewPickmapFolderDialog.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF Modified: trunk/src/app/net/sf/gridarta/gui/pickmapchooser/CurrentPickmapActions.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/pickmapchooser/CurrentPickmapActions.java 2008-04-07 19:45:10 UTC (rev 3838) +++ trunk/src/app/net/sf/gridarta/gui/pickmapchooser/CurrentPickmapActions.java 2008-04-07 20:07:02 UTC (rev 3839) @@ -74,8 +74,11 @@ @NotNull private final PickmapChooserControl<G, A, R, C, V> control; /** The current active pickmap ontop. */ - private C currentPickmap = null; + @Nullable private Pickmap<G, A, R, C, V> currentPickmap = null; + /** The current active pickmap ontop. */ + @Nullable private C currentPickmapControl = null; + /** Set if all pickmaps are locked. */ private boolean lockAllPickmaps = false; @@ -144,7 +147,7 @@ /** Open active pickmap as normal map for extensive editing. */ public void openPickmapMap() { - final C pickmap = getOpenPickmapMap(); + final Pickmap<G, A, R, C, V> pickmap = getOpenPickmapMap(); if(pickmap != null) { control.openPickmapMap(pickmap); } @@ -152,7 +155,7 @@ /** Invoked when the user wants to delete the active pickmap. */ public void deletePickmap() { - final C pickmap = getDeletePickmap(); + final Pickmap<G, A, R, C, V> pickmap = getDeletePickmap(); if (pickmap != null) { control.deletePickmapWanted(pickmap); } @@ -160,7 +163,7 @@ /** Save current active pickmap. */ public void savePickmap() { - final C pickmap = getSavePickmap(); + final Pickmap<G, A, R, C, V> pickmap = getSavePickmap(); if (pickmap != null) { control.savePickmap(pickmap); } @@ -168,7 +171,7 @@ /** Invoked when user wants to revert the current pickmap to previously saved state. */ public void revertPickmap() { - final C pickmap = getRevertPickmap(); + final Pickmap<G, A, R, C, V> pickmap = getRevertPickmap(); if (pickmap != null) { control.revertPickmap(pickmap); } @@ -190,7 +193,7 @@ * @return the pickmap to open as map, or <code>null</code> if "open * pickmap as map" is disabled */ - @Nullable private C getOpenPickmapMap() { + @Nullable private Pickmap<G, A, R, C, V> getOpenPickmapMap() { if (isLockAllPickmaps() || !active) { return null; } @@ -198,12 +201,12 @@ } /** - * Determine if "close active pickmap" is enabled. + * Determine if "delete active pickmap" is enabled. * - * @return the pickmap to close, or <code>null</code> if "close active + * @return the pickmap to delete, or <code>null</code> if "delete active * pickmap" is disabled */ - @Nullable private C getDeletePickmap() { + @Nullable private Pickmap<G, A, R, C, V> getDeletePickmap() { if (isLockAllPickmaps() || !active) { return null; } @@ -216,12 +219,12 @@ * @return the pickmap to save, or <code>null</code> if "save active * pickmap" is disabled */ - @Nullable private C getSavePickmap() { + @Nullable private Pickmap<G, A, R, C, V> getSavePickmap() { if (isLockAllPickmaps() || !active) { return null; } - if (currentPickmap == null || !currentPickmap.isModified()) { + if (currentPickmap == null || currentPickmapControl == null || !currentPickmapControl.isModified()) { return null; } @@ -234,12 +237,12 @@ * @return the pickmap to revert, or <code>null</code> if "revert active * pickmap" is disabled */ - @Nullable private C getRevertPickmap() { + @Nullable private Pickmap<G, A, R, C, V> getRevertPickmap() { if (isLockAllPickmaps() || !active) { return null; } - if (currentPickmap == null || !currentPickmap.isModified() || !currentPickmap.getMapFile().exists()) { + if (currentPickmap == null || currentPickmapControl == null || !currentPickmapControl.isModified() || !currentPickmap.getFile().exists()) { return null; } @@ -253,7 +256,7 @@ * @return the currently active pickmap or <code>null</code> if there is no pickmap */ @Nullable public C getCurrentPickmap() { - return currentPickmap; + return currentPickmapControl; } /** @@ -261,25 +264,35 @@ * * @param currentPickmap the currently active pickmap */ - public void setCurrentPickmap(@Nullable final C currentPickmap) { - if (this.currentPickmap == currentPickmap) { + public void setCurrentPickmap(@Nullable final Pickmap<G, A, R, C, V> currentPickmap) { + final C currentPickmapControl = currentPickmap == null ? null : currentPickmap.getPickmap(); + if (this.currentPickmap == currentPickmap && this.currentPickmapControl == currentPickmapControl) { return; } - if (this.currentPickmap != null) { - this.currentPickmap.removeMapControlListener(mapControlListener); + if (this.currentPickmapControl != null) { + this.currentPickmapControl.removeMapControlListener(mapControlListener); } this.currentPickmap = currentPickmap; + this.currentPickmapControl = currentPickmapControl; - if (this.currentPickmap != null) { - this.currentPickmap.addMapControlListener(mapControlListener); + if (this.currentPickmapControl != null) { + this.currentPickmapControl.addMapControlListener(mapControlListener); } refresh(); } /** + * Update the current pickmap. This checks whether the map control of the + * current pickmap has changed. + */ + public void updateCurrentPickmap() { + setCurrentPickmap(currentPickmap); + } + + /** * Set whether the pickmap panel is active. * * @param active <code>true</code> if the pickmap panel is active Added: trunk/src/app/net/sf/gridarta/gui/pickmapchooser/DuplicateFolderException.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/pickmapchooser/DuplicateFolderException.java (rev 0) +++ trunk/src/app/net/sf/gridarta/gui/pickmapchooser/DuplicateFolderException.java 2008-04-07 20:07:02 UTC (rev 3839) @@ -0,0 +1,41 @@ +/* + * 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.pickmapchooser; + +import org.jetbrains.annotations.NotNull; + +/** + * Indicates that a folder name is not unique. + * @author Andreas Kirschbaum + */ +public class DuplicateFolderException extends Exception { + + /** The serial version UID. */ + private static final long serialVersionUID = 1; + + /** + * Creates a new instance. + * @param folderName the duplicate folder name + */ + public DuplicateFolderException(@NotNull final String folderName) { + super("duplicate folder: " + folderName); + } + +} // DuplicateFolderException Property changes on: trunk/src/app/net/sf/gridarta/gui/pickmapchooser/DuplicateFolderException.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF Added: trunk/src/app/net/sf/gridarta/gui/pickmapchooser/DuplicatePickmapException.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/pickmapchooser/DuplicatePickmapException.java (rev 0) +++ trunk/src/app/net/sf/gridarta/gui/pickmapchooser/DuplicatePickmapException.java 2008-04-07 20:07:02 UTC (rev 3839) @@ -0,0 +1,41 @@ +/* + * 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.pickmapchooser; + +import org.jetbrains.annotations.NotNull; + +/** + * Indicates that a pickmap name is not unique within its folder. + * @author Andreas Kirschbaum + */ +public class DuplicatePickmapException extends Exception { + + /** The serial version UID. */ + private static final long serialVersionUID = 1; + + /** + * Creates a new instance. + * @param pickmapName the duplicate pickmap name + */ + public DuplicatePickmapException(@NotNull final String pickmapName) { + super("duplicate folder: " + pickmapName); + } + +} // DuplicatePickmapException Property changes on: trunk/src/app/net/sf/gridarta/gui/pickmapchooser/DuplicatePickmapException.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF Added: trunk/src/app/net/sf/gridarta/gui/pickmapchooser/Folder.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/pickmapchooser/Folder.java (rev 0) +++ trunk/src/app/net/sf/gridarta/gui/pickmapchooser/Folder.java 2008-04-07 20:07:02 UTC (rev 3839) @@ -0,0 +1,234 @@ +/* + * 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.pickmapchooser; + +import java.io.File; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.Iterator; +import java.util.List; +import javax.swing.event.EventListenerList; +import net.sf.gridarta.GridartaObjectsFactory; +import net.sf.gridarta.gameobject.Archetype; +import net.sf.gridarta.gameobject.GameObject; +import net.sf.gridarta.gui.map.MapViewBasic; +import net.sf.gridarta.map.MapArchObject; +import net.sf.gridarta.map.MapControl; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * Model class representing a folder of {@link Pickmap}s. A folder is part of a + * {@link Model}. A folder has a name and a base directory. The name is a + * unique identifier in the model; the base directory is the directory where + * all contained pickmaps are stored. + * @author Andreas Kirschbaum + */ +public class Folder<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>, C extends MapControl<G, A, R>, V extends MapViewBasic<G, A, R>> implements Iterable<Pickmap<G, A, R, C, V>> { + + /** The registered event listeners. */ + private final EventListenerList listeners = new EventListenerList(); + + /** + * The parent folder, or <code>null</code> if it is a top-level folder. + */ + @Nullable private final Folder parent; + + /** + * The folder's name. + */ + @NotNull private final String name; + + /** + * The model this folder is part of. + */ + @NotNull private final Model<G, A, R, C, V> model; + + /** + * The pickmaps of this folder. + */ + private final List<Pickmap<G, A, R, C, V>> pickmaps = new ArrayList<Pickmap<G, A, R, C, V>>(); + + /** + * Creates a new instance. + * @param parent the partent folder, or <code>null</code> if it is a + * top-level folder + * @param name the name + * @param model the model this folder is part of + * @throws InvalidNameException if <code>name</code> is not valid + */ + public Folder(@Nullable final Folder parent, @NotNull final String name, @NotNull final Model<G, A, R, C, V> model) throws InvalidNameException { + if (parent == null ? name.length() > 0 : !name.matches("[-a-zA-Z_+ 0-9]+")) { + throw new InvalidNameException(name); + } + + this.parent = parent; + this.name = name; + this.model = model; + } + + /** + * Returns the parent folder. + * @return the parent folder, or <code>null</code> if this folder is a + * top-level folder + */ + @Nullable public Folder getParent() { + return parent; + } + + /** + * Returns the name. + * @return the name + */ + @NotNull public String getName() { + if (parent == null) { + return "*default*"; + } + + return parent.parent == null ? name : parent.getName() + "/" + name; + } + + /** + * Returns the base directory. + * @return the base directory + */ + @NotNull public File getDir() { + return parent != null ? new File(parent.getDir(), name) : model.getBaseDir(); + } + + /** + * Marks this folder as the active folder in its model. + */ + public void setActiveFolder() { + model.setActiveFolder(this); + } + + /** + * Returns whether this folder is the active folder in its model. + * @return whther this folder is active + */ + public boolean isActiveFolder() { + return model.getActiveFolder() == this; + } + + /** + * Adds a new {@link Pickmap} to this folder. + * @param name the map file name + * @param gridartaObjectsFactory the <code>GridartaObjectsFactory</code> + * instance for loading the pickmap map file + * @return the newly created pickmap + * @throws InvalidNameException if the pickmap name is invalid + */ + public synchronized Pickmap<G, A, R, C, V> addPickmap(@NotNull final String name, @NotNull final GridartaObjectsFactory<G, A, R, C, V> gridartaObjectsFactory) throws InvalidNameException { + final Pickmap<G, A, R, C, V> pickmap = new Pickmap(this, name, gridartaObjectsFactory); + pickmaps.add(pickmap); + for (final FolderListener<G, A, R, C, V> listener : listeners.getListeners(FolderListener.class)) { + listener.pickmapAdded(pickmap); + } + return pickmap; + } + + /** + * Removes a {@link Pickmap} from this folder. + * @param pickmap the pickmap to remove + * @param deleteFile if set, also remove the map files + */ + public synchronized void removePickmap(@NotNull final Pickmap<G, A, R, C, V> pickmap, final boolean deleteFile) { + final int index = pickmaps.indexOf(pickmap); + if (index == -1) { + throw new IllegalArgumentException(); + } + if (deleteFile) { + final File file = pickmap.getFile(); + file.delete(); + } + pickmaps.remove(index); + for (final FolderListener<G, A, R, C, V> listener : listeners.getListeners(FolderListener.class)) { + listener.pickmapRemoved(pickmap); + } + pickmap.freePickmap(); + } + + /** + * Removes all {@link Pickmap} from this folder. + * @param deleteFile if set, also remove the map file + */ + public synchronized void removeAllPickmaps(final boolean deleteFile) { + while (pickmaps.size() > 0) { + removePickmap(pickmaps.get(pickmaps.size() - 1), deleteFile); + } + } + + /** + * Returns an {@link Iterator} returning all pickmaps of this folder in + * arbitrary order. + * @return the iterator + */ + public Iterator<Pickmap<G, A, R, C, V>> iterator() { + return Collections.unmodifiableList(pickmaps).iterator(); + } + + /** + * Returns the number of pickmaps in this folder. + * @return the number of pickmaps + */ + public int getPickmaps() { + return pickmaps.size(); + } + + /** + * Adds a {@link FolderListener} to be notified of events. + * @param listener the listener to add + */ + public void addFolderListener(@NotNull final FolderListener<G, A, R, C, V> listener) { + listeners.add(FolderListener.class, listener); + } + + /** + * Removes a {@link FolderListener} to be notified of events. + * @param listener the listener to remove + */ + public void removeFolderListener(@NotNull final FolderListener<G, A, R, C, V> listener) { + listeners.remove(FolderListener.class, listener); + } + + /** + * Returns all unsaved {@link Pickmap}s in this folder. + * @param unsavedPickmaps the collection to add the unsaved pickmaps to + */ + public void getUnsavedPickmaps(@NotNull final Collection<C> unsavedPickmaps) { + for (final Pickmap<G, A, R, C, V> pickmap : pickmaps) { + pickmap.getUnsavedPickmaps(unsavedPickmaps); + } + } + + /** + * Notifies all listeners about a reverted pickmap. + * @param pickmap the pickmap that was reverted + * @param oldPickmap the map control of the pickmap before reverting + */ + public void firePickmapReverted(@NotNull final Pickmap<G, A, R, C, V> pickmap, @NotNull final C oldPickmap) { + for (final FolderListener<G, A, R, C, V> listener : listeners.getListeners(FolderListener.class)) { + listener.pickmapReverted(pickmap, oldPickmap); + } + } + +} // class Folder Property changes on: trunk/src/app/net/sf/gridarta/gui/pickmapchooser/Folder.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF Added: trunk/src/app/net/sf/gridarta/gui/pickmapchooser/FolderListAction.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/pickmapchooser/FolderListAction.java (rev 0) +++ trunk/src/app/net/sf/gridarta/gui/pickmapchooser/FolderListAction.java 2008-04-07 20:07:02 UTC (rev 3839) @@ -0,0 +1,85 @@ +/* + * 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.pickmapchooser; + +import java.awt.event.ActionEvent; +import javax.swing.AbstractAction; +import javax.swing.JCheckBoxMenuItem; +import net.sf.gridarta.MenuHelper; +import net.sf.gridarta.gameobject.Archetype; +import net.sf.gridarta.gameobject.GameObject; +import net.sf.gridarta.gui.map.MapViewBasic; +import net.sf.gridarta.map.MapArchObject; +import net.sf.gridarta.map.MapControl; +import org.jetbrains.annotations.NotNull; + +/** + * An action for the entry in the pickmaps folder menu. If invoked, it sets the + * active folder. + * @author Andreas Kirschbaum + */ +public final class FolderListAction<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>, C extends MapControl<G, A, R>, V extends MapViewBasic<G, A, R>> extends AbstractAction { + + /** The serial version UID. */ + private static final long serialVersionUID = 1; + + /** + * The folder to activate. + */ + @NotNull private final Folder<G, A, R, C, V> folder; + + /** + * The associated menu item. + */ + @NotNull private final JCheckBoxMenuItem menuItem; + + /** + * Creates a new instance. + * @param folder the folder to activate + * @param menuItem the associated menu item + */ + public FolderListAction(@NotNull final Folder<G, A, R, C, V> folder, @NotNull final JCheckBoxMenuItem menuItem) { + super(folder.getName()); + this.folder = folder; + this.menuItem = menuItem; + } + + /** {@inheritDoc} */ + public void actionPerformed(final ActionEvent e) { + folder.setActiveFolder(); + menuItem.setSelected(folder.isActiveFolder()); + } + + /** {@inheritDoc} */ + @Override public boolean equals(final Object obj) { + return !(obj == null || !(obj instanceof FolderListAction)) && folder == ((FolderListAction) obj).folder; + } + + /** {@inheritDoc} */ + @Override public int hashCode() { + return folder.getDir().hashCode(); + } + + /** {@inheritDoc} */ + @Override protected Object clone() throws CloneNotSupportedException { + return super.clone(); + } + +} // class FolderListAction Property changes on: trunk/src/app/net/sf/gridarta/gui/pickmapchooser/FolderListAction.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF Added: trunk/src/app/net/sf/gridarta/gui/pickmapchooser/FolderListActions.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/pickmapchooser/FolderListActions.java (rev 0) +++ trunk/src/app/net/sf/gridarta/gui/pickmapchooser/FolderListActions.java 2008-04-07 20:07:02 UTC (rev 3839) @@ -0,0 +1,177 @@ +/* + * 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.pickmapchooser; + +import java.util.prefs.Preferences; +import javax.swing.Action; +import javax.swing.JCheckBoxMenuItem; +import javax.swing.JMenu; +import net.sf.gridarta.MainControl; +import net.sf.gridarta.MenuHelper; +import net.sf.gridarta.gameobject.Archetype; +import net.sf.gridarta.gameobject.GameObject; +import net.sf.gridarta.gui.map.MapViewBasic; +import net.sf.gridarta.gui.newmap.NewMapDialogFactory; +import net.sf.gridarta.map.MapArchObject; +import net.sf.gridarta.map.MapControl; +import net.sf.gridarta.map.MapControlListener; +import net.sf.japi.swing.ActionFactory; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * Encapsulates functionality related to actions for pickmap folder selection. + * @author Andreas Kirschbaum + */ +public class FolderListActions<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>, C extends MapControl<G, A, R>, V extends MapViewBasic<G, A, R>> { + + /** Action Factory. */ + private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("net.sf.gridarta"); + + /** + * The model to operate on. + */ + @NotNull private final Model<G, A, R, C, V> model; + + /** + * The factory for creating new pickmap folders. + */ + @NotNull private final NewMapDialogFactory<G, A, R, C, V> newMapDialogFactory; + + /** + * The pickmap folders menu to update. + */ + @Nullable private JMenu folderMenu = null; + + /** + * The last known active folder. + */ + @Nullable private Folder<G, A, R, C, V> activeFolder; + + /** Action called for "create new folder". */ + private final Action aCreatePickmapFolder = ACTION_FACTORY.createAction(true, "createPickmapFolder", this); + + /** Action called for "delete active folder". */ + private final Action aDeletePickmapFolder = ACTION_FACTORY.createAction(true, "deletePickmapFolder", this); + + /** + * The {@link ModelListener} which is registered to the selected pickmap. + */ + private final ModelListener<G, A, R, C, V> modelListener = new ModelListener<G, A, R, C, V>() { + + /** {@inheritDoc} */ + public void activeFolderChanged(@Nullable final Folder<G, A, R, C, V> folder) { + activeFolder = folder; + refresh(); + } + + /** {@inheritDoc} */ + public void folderAdded(@NotNull final Folder<G, A, R, C, V> folder) { + refresh(); + } + + /** {@inheritDoc} */ + public void folderRemoved(@NotNull final Folder<G, A, R, C, V> folder) { + refresh(); + } + + }; + + /** + * Creates a new instance. + * @param model the model to operate on + * @param newMapDialogFactory the factory for creating new pickmap folders + */ + public FolderListActions(@NotNull final Model<G, A, R, C, V> model, @NotNull final NewMapDialogFactory<G, A, R, C, V> newMapDialogFactory) { + this.model = model; + this.newMapDialogFactory = newMapDialogFactory; + model.addModelListener(modelListener); + activeFolder = model.getActiveFolder(); + refresh(); + } + + /** + * Sets the pickmap folders menu to manage. If the passed menu is + * <code>null</code>, nothing is updated. + * @param folderMenu the pickmap folders menu + */ + public void setPickmapFoldersMenu(@Nullable final JMenu folderMenu) { + this.folderMenu = folderMenu; + refresh(); + } + + /** + * Updates the actions' states. + */ + private void refresh() { + aDeletePickmapFolder.setEnabled(getDeletePickmapFolderEnabled() != null); + + if (folderMenu == null) { + return; + } + + MenuHelper.removeAll(folderMenu); + for (final Folder<G, A, R, C, V> folder : model) { + final JCheckBoxMenuItem menuItem = new JCheckBoxMenuItem(); + final FolderListAction<G, A, R, C, V> action = new FolderListAction<G, A, R, C, V>(folder, menuItem); + menuItem.setAction(action); + menuItem.setSelected(folder == activeFolder); + folderMenu.add(menuItem); + } + } + + /** + * Action callback function to create a new pickmap folder. + */ + public void createPickmapFolder() { + newMapDialogFactory.showNewPickmapFolderDialog(model, activeFolder); + } + + /** + * Action callback function to delete the current pickmap folder. + */ + public void deletePickmapFolder() { + final Folder<G, A, R, C, V> folder = getDeletePickmapFolderEnabled(); + if (folder == null) { + return; + } + + if (folder.getPickmaps() > 0 && !ACTION_FACTORY.showQuestionDialog(null/*XXX:parent*/, "confirmDeletePickmapFolder", folder.getName(), folder.getPickmaps())) { + return; + } + + try { + model.removeFolder(folder, true); + } catch (final FolderNotEmptyException ex) { + ACTION_FACTORY.showMessageDialog(null/*XXX:parent*/, "deletePickmapFolderNotEmpty", folder.getName()); + } + } + + /** + * Returns whether "delete pickmap folder" should be enabled. + * @return the folder to delete, or <code>null</code> if the action should + * be disabled + */ + private Folder<G, A, R, C, V> getDeletePickmapFolderEnabled() { + final Folder<G, A, R, C, V> folder = activeFolder; + return folder != null && folder.getParent() != null ? folder : null; + } + +} // class FolderListActions Property changes on: trunk/src/app/net/sf/gridarta/gui/pickmapchooser/FolderListActions.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF Added: trunk/src/app/net/sf/gridarta/gui/pickmapchooser/FolderListener.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/pickmapchooser/FolderListener.java (rev 0) +++ trunk/src/app/net/sf/gridarta/gui/pickmapchooser/FolderListener.java 2008-04-07 20:07:02 UTC (rev 3839) @@ -0,0 +1,57 @@ +/* + * 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.pickmapchooser; + +import java.util.EventListener; +import net.sf.gridarta.gameobject.Archetype; +import net.sf.gridarta.gameobject.GameObject; +import net.sf.gridarta.gui.map.MapViewBasic; +import net.sf.gridarta.map.MapArchObject; +import net.sf.gridarta.map.MapControl; +import org.jetbrains.annotations.NotNull; + +/** + * Interface for listeners interested in events of {@link Folder}s. + * @author Andreas Kirschbaum + */ +public interface FolderListener<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>, C extends MapControl<G, A, R>, V extends MapViewBasic<G, A, R>> extends EventListener { + + /** + * A pickmap has been added to the folder. + * @param pickmap the added pickmap + */ + void pickmapAdded(@NotNull Pickmap<G, A, R, C, V> pickmap); + + /** + * A pickmap has been removed from the folder. The passed + * <code>pickmap</code> instance has not been removed from its {@link + * Folder} but not yet unloaded. + * @param pickmap the removed pickmap + */ + void pickmapRemoved(@NotNull Pickmap<G, A, R, C, V> pickmap); + + /** + * A pickmap has been reverted to the contents of its underlying file. + * @param pickmap the reverted pickmap + * @param oldPickmap the map control of the pickmap before revert + */ + void pickmapReverted(@NotNull Pickmap<G, A, R, C, V> pickmap, @NotNull C oldPickmap); + +} // class FolderListener Property changes on: trunk/src/app/net/sf/gridarta/gui/pickmapchooser/FolderListener.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF Added: trunk/src/app/net/sf/gridarta/gui/pickmapchooser/FolderNotEmptyException.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/pickmapchooser/FolderNotEmptyException.java (rev 0) +++ trunk/src/app/net/sf/gridarta/gui/pickmapchooser/FolderNotEmptyException.java 2008-04-07 20:07:02 UTC (rev 3839) @@ -0,0 +1,41 @@ +/* + * 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.pickmapchooser; + +import org.jetbrains.annotations.NotNull; + +/** + * Indicates that a folder contains subfolders. + * @author Andreas Kirschbaum + */ +public class FolderNotEmptyException extends Exception { + + /** The serial version UID. */ + private static final long serialVersionUID = 1; + + /** + * Creates a new instance. + * @param folderName the folder + */ + public FolderNotEmptyException(@NotNull final String folderName) { + super("folder contains subfolders: " + folderName); + } + +} // FolderNotEmptyException Property changes on: trunk/src/app/net/sf/gridarta/gui/pickmapchooser/FolderNotEmptyException.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF Added: trunk/src/app/net/sf/gridarta/gui/pickmapchooser/InvalidNameException.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/pickmapchooser/InvalidNameException.java (rev 0) +++ trunk/src/app/net/sf/gridarta/gui/pickmapchooser/InvalidNameException.java 2008-04-07 20:07:02 UTC (rev 3839) @@ -0,0 +1,41 @@ +/* + * 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.pickmapchooser; + +import org.jetbrains.annotations.NotNull; + +/** + * Indicates that a folder or pickmap name is invalid. + * @author Andreas Kirschbaum + */ +public class InvalidNameException extends Exception { + + /** The serial version UID. */ + private static final long serialVersionUID = 1; + + /** + * Creates a new instance. + * @param name the invalid name + */ + public InvalidNameException(@NotNull final String name) { + super("invalid name: " + name); + } + +} // InvalidNameException Property changes on: trunk/src/app/net/sf/gridarta/gui/pickmapchooser/InvalidNameException.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF Added: trunk/src/app/net/sf/gridarta/gui/pickmapchooser/Loader.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/pickmapchooser/Loader.java (rev 0) +++ trunk/src/app/net/sf/gridarta/gui/pickmapchooser/Loader.java 2008-04-07 20:07:02 UTC (rev 3839) @@ -0,0 +1,130 @@ +/* + * 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.pickmapchooser; + +import java.io.File; +import java.util.Arrays; +import java.util.List; +import net.sf.gridarta.GridartaObjectsFactory; +import net.sf.gridarta.gameobject.Archetype; +import net.sf.gridarta.gameobject.GameObject; +import net.sf.gridarta.gui.map.MapViewBasic; +import net.sf.gridarta.io.MapReader; +import net.sf.gridarta.map.MapArchObject; +import net.sf.gridarta.map.MapControl; +import org.apache.log4j.Logger; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * Loader for pickmaps from a directory. + * @author Andreas Kirschbaum + */ +public class Loader<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>, C extends MapControl<G, A, R>, V extends MapViewBasic<G, A, R>> { + + /** The Logger for printing log messages. */ + private static final Logger log = Logger.getLogger(Loader.class); + + /** + * The model to add the loaded pickmaps to. + */ + @NotNull private final Model model; + + /** + * The {@link GridartaObjectsFactory} instance to use for loading pickmap + * files. + */ + @NotNull private final GridartaObjectsFactory<G, A, R, C, V> gridartaObjectsFactory; + + /** + * Creates a new instance. + * @param model the model to add the loaded pickmaps to + * @param gridartaObjectsFactory the <code>GridartaObjectsFactory</code> + * instance to use for loading pickmap files + */ + public Loader(@NotNull final Model model, @NotNull final GridartaObjectsFactory<G, A, R, C, V> gridartaObjectsFactory) { + this.model = model; + this.gridartaObjectsFactory = gridartaObjectsFactory; + } + + /** + * Loads all pickmap files from a directory and its subdirectories. + */ + public void load() { + final Folder<G, A, R, C, V> folder = load(null, ""); + if (folder != null) { + model.setActiveFolder(folder); + } + } + + /** + * Loads all pickmap files from a directory and its subdirectories. + * @param dir the directory + * @param parent the parent folder, or <code>null</code> + * @param folderName the folder name of <code>dir</code> + * @return the default <code>Folder</code>, or <code>null</code> if this + * directory is empty + */ + private Folder<G, A, R, C, V> load(@Nullable final Folder<G, A, R, C, V> parent, @NotNull final String folderName) { + final File dir = parent == null ? model.getBaseDir() : new File(parent.getDir(), folderName); + final File[] files = dir.listFiles(); + if (files == null) { + log.warn("cannot read directory " + dir); + return null; + } + + final Folder<G, A, R, C, V> folder; + try { + folder = new Folder<G, A, R, C, V>(parent, folderName, model); + } catch (final InvalidNameException ex) { + log.warn("ignoring pickmap folder with invalid name: " + folderName); + return null; + } + try { + model.addFolder(folder); + } catch (final DuplicateFolderException ex) { + log.warn("cannot add folder: " + ex.getMessage()); + return null; + } + + Folder<G, A, R, C, V> result = null; + + Arrays.sort(files); + for (final File file : files) { + if (file.isFile()) { + try { + folder.addPickmap(file.getName(), gridartaObjectsFactory); + } catch (final InvalidNameException ex) { + log.warn("ignoring pickmap with invalid name: " + file); + } + } else if (file.isDirectory()) { + if (!file.getName().startsWith(".")) { + final Folder<G, A, R, C, V> tmp = load(folder, file.getName()); + if (result == null && tmp != null &&... [truncated message content] |
From: <aki...@us...> - 2008-04-08 08:16:26
|
Revision: 3851 http://gridarta.svn.sourceforge.net/gridarta/?rev=3851&view=rev Author: akirschbaum Date: 2008-04-08 01:16:19 -0700 (Tue, 08 Apr 2008) Log Message: ----------- Remove call to AbstractMainControl.getInstance(). Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/CMainView.java trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/CMainView.java trunk/src/app/net/sf/gridarta/gui/ArchetypesActions.java trunk/src/app/net/sf/gridarta/gui/findarchetypes/FindArchetypesDialog.java trunk/src/app/net/sf/gridarta/gui/findarchetypes/TableModel.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-04-08 07:46:35 UTC (rev 3850) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-04-08 08:16:19 UTC (rev 3851) @@ -257,14 +257,6 @@ // initialize the script-editor pad ScriptEditControl.init(strMapDir, this); - // Initialize the main view - mainView.init(newMapDialogFactory, null, new LockedItemsControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(getMapManager(), 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), new File(mapDir, IGUIConstants.PICKMAP_DIR)); - scriptControl.getView().setMenu((JMenu) ACTION_FACTORY.find(mainView.getJMenuBar(), "plugins")); - archetypeParser = new ArchetypeParser(this, mainView.getObjectChooser().getArchetypeChooserControl()); - animationObjects = new AnimationObjects(); - faceObjects = new FaceObjects(); - archetypeSet.loadArchetypes(archetypeParser); - // load the list with archtype-data from "types.xml" final XmlHelper xmlHelper; try { @@ -290,6 +282,14 @@ } gameObjectSpells.sort(); + // Initialize the main view + mainView.init(newMapDialogFactory, null, new LockedItemsControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(getMapManager(), 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), new File(mapDir, IGUIConstants.PICKMAP_DIR), typeList); + scriptControl.getView().setMenu((JMenu) ACTION_FACTORY.find(mainView.getJMenuBar(), "plugins")); + archetypeParser = new ArchetypeParser(this, mainView.getObjectChooser().getArchetypeChooserControl()); + animationObjects = new AnimationObjects(); + faceObjects = new FaceObjects(); + archetypeSet.loadArchetypes(archetypeParser); + if (autoPopupDocu) { // do an automated help popup because the docu version has increased // (people won't notice the docu otherwise - nobody expects a docu in opensource) Modified: trunk/crossfire/src/cfeditor/CMainView.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainView.java 2008-04-08 07:46:35 UTC (rev 3850) +++ trunk/crossfire/src/cfeditor/CMainView.java 2008-04-08 08:16:19 UTC (rev 3851) @@ -43,6 +43,7 @@ import javax.swing.JPanel; import javax.swing.JSplitPane; import javax.swing.JToolBar; +import net.sf.gridarta.CFArchTypeList; import net.sf.gridarta.MainControl; import net.sf.gridarta.MapManager; import net.sf.gridarta.MenuHelper; @@ -172,8 +173,9 @@ * top of the list * @param lockedItemsControl the locked items control * @param pickmapDir the pickmaps directory + * @param archTypeList the instance for looking up archetype types */ - void init(@NotNull final NewMapDialogFactory<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> newMapDialogFactory, @Nullable final ImageIcon compassIcon, @NotNull final LockedItemsControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> lockedItemsControl, @NotNull final File pickmapDir) { + void init(@NotNull final NewMapDialogFactory<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> newMapDialogFactory, @Nullable final ImageIcon compassIcon, @NotNull final LockedItemsControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> lockedItemsControl, @NotNull final File pickmapDir, final CFArchTypeList archTypeList) { // calculate some default values in case there is no settings file final Rectangle screen = getGraphicsConfiguration().getBounds(); final int defwidth = (int) (0.9 * screen.getWidth()); @@ -186,7 +188,7 @@ toolbarPanel.add(createCenterPanel(defwidth, defheight, newMapDialogFactory, compassIcon, lockedItemsControl, pickmapDir), BorderLayout.CENTER); add(toolbarPanel, BorderLayout.CENTER); - archetypesActions = new ArchetypesActions<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(this, objectChooser.getArchetypeChooserControl(), mainControl.getArchetypeSet(), objectChooser); + archetypesActions = new ArchetypesActions<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(this, objectChooser.getArchetypeChooserControl(), mainControl.getArchetypeSet(), objectChooser, archTypeList); setJMenuBar(actionFactory.createMenuBar(true, "main")); objectChooser.setPickmapFoldersMenu((JMenu) actionFactory.find(getJMenuBar(), "pickmapFolders")); Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-04-08 07:46:35 UTC (rev 3850) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-04-08 08:16:19 UTC (rev 3851) @@ -313,13 +313,6 @@ // initialize the script-editor pad ScriptEditControl.init(strMapDir, this); - // Initialize the main view - mainView.init(newMapDialogFactory, GUIUtils.getSysIcon(IGUIConstants.TILE_NORTH), new LockedItemsControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(getMapManager(), 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), new File(strArchDir, IGUIConstants.PICKMAP_DIR)); - archetypeParser = new ArchetypeParser(this, mainView.getObjectChooser().getArchetypeChooserControl()); - animationObjects = new AnimationObjects(); - faceObjects = new FaceObjects(); - archetypeSet.loadArchetypes(archetypeParser); - // load the list with archtype-data from "types.xml" final XmlHelper xmlHelper; try { @@ -344,6 +337,13 @@ } numberSpells.sort(); + // Initialize the main view + mainView.init(newMapDialogFactory, GUIUtils.getSysIcon(IGUIConstants.TILE_NORTH), new LockedItemsControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(getMapManager(), 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), new File(strArchDir, IGUIConstants.PICKMAP_DIR), typeList); + archetypeParser = new ArchetypeParser(this, mainView.getObjectChooser().getArchetypeChooserControl()); + animationObjects = new AnimationObjects(); + faceObjects = new FaceObjects(); + archetypeSet.loadArchetypes(archetypeParser); + if (autoPopupDocu) { // do an automated help popup because the docu version has increased // (people won't notice the docu otherwise - nobody expects a docu in opensource) Modified: trunk/daimonin/src/daieditor/CMainView.java =================================================================== --- trunk/daimonin/src/daieditor/CMainView.java 2008-04-08 07:46:35 UTC (rev 3850) +++ trunk/daimonin/src/daieditor/CMainView.java 2008-04-08 08:16:19 UTC (rev 3851) @@ -43,6 +43,7 @@ import javax.swing.JPanel; import javax.swing.JSplitPane; import javax.swing.JToolBar; +import net.sf.gridarta.CFArchTypeList; import net.sf.gridarta.MainControl; import net.sf.gridarta.MapManager; import net.sf.gridarta.MenuHelper; @@ -172,8 +173,9 @@ * top of the list * @param lockedItemsControl the locked items control * @param pickmapDir the pickmaps directory + * @param archTypeList the instance for looking up archetype types */ - void init(@NotNull final NewMapDialogFactory<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> newMapDialogFactory, @Nullable final ImageIcon compassIcon, @NotNull final LockedItemsControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> lockedItemsControl, @NotNull final File pickmapDir) { + void init(@NotNull final NewMapDialogFactory<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> newMapDialogFactory, @Nullable final ImageIcon compassIcon, @NotNull final LockedItemsControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> lockedItemsControl, @NotNull final File pickmapDir, final CFArchTypeList archTypeList) { // calculate some default values in case there is no settings file final Rectangle screen = getGraphicsConfiguration().getBounds(); final int defwidth = (int) (0.9 * screen.getWidth()); @@ -186,7 +188,7 @@ toolbarPanel.add(createCenterPanel(defwidth, defheight, newMapDialogFactory, compassIcon, lockedItemsControl, pickmapDir), BorderLayout.CENTER); add(toolbarPanel, BorderLayout.CENTER); - archetypesActions = new ArchetypesActions<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(this, objectChooser.getArchetypeChooserControl(), mainControl.getArchetypeSet(), objectChooser); + archetypesActions = new ArchetypesActions<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(this, objectChooser.getArchetypeChooserControl(), mainControl.getArchetypeSet(), objectChooser, archTypeList); setJMenuBar(actionFactory.createMenuBar(true, "main")); objectChooser.setPickmapFoldersMenu((JMenu) actionFactory.find(getJMenuBar(), "pickmapFolders")); Modified: trunk/src/app/net/sf/gridarta/gui/ArchetypesActions.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/ArchetypesActions.java 2008-04-08 07:46:35 UTC (rev 3850) +++ trunk/src/app/net/sf/gridarta/gui/ArchetypesActions.java 2008-04-08 08:16:19 UTC (rev 3851) @@ -20,6 +20,7 @@ package net.sf.gridarta.gui; import java.awt.Component; +import net.sf.gridarta.CFArchTypeList; import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.ArchetypeSet; import net.sf.gridarta.gameobject.GameObject; @@ -80,9 +81,11 @@ * * @param insertionObjectChooser The insertion object chooser to use when * selecting search results in the "find archetypes" dialog. + * + * @param archTypeList the instance for looking up archetype types */ - public ArchetypesActions(@NotNull final Component parent, @NotNull final ArchetypeChooserControl<G, A, R, C, V> archetypeChooserControl, @NotNull final ArchetypeSet<G, A, R> archetypeSet, @NotNull final InsertionObjectChooser<G, A, R> insertionObjectChooser) { - findArchetypesDialog = new FindArchetypesDialog(parent, archetypeSet, insertionObjectChooser); + public ArchetypesActions(@NotNull final Component parent, @NotNull final ArchetypeChooserControl<G, A, R, C, V> archetypeChooserControl, @NotNull final ArchetypeSet<G, A, R> archetypeSet, @NotNull final InsertionObjectChooser<G, A, R> insertionObjectChooser, final CFArchTypeList archTypeList) { + findArchetypesDialog = new FindArchetypesDialog(parent, archetypeSet, insertionObjectChooser, archTypeList); aDisplayObjectNames = (ToggleAction) ACTION_FACTORY.createToggle(true, "displayObjectNames", archetypeChooserControl); ACTION_FACTORY.createAction(true, "findArchetypes", findArchetypesDialog); archetypeChooserControl.addArchetypeChooserListener(archetypeChooserListener); Modified: trunk/src/app/net/sf/gridarta/gui/findarchetypes/FindArchetypesDialog.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/findarchetypes/FindArchetypesDialog.java 2008-04-08 07:46:35 UTC (rev 3850) +++ trunk/src/app/net/sf/gridarta/gui/findarchetypes/FindArchetypesDialog.java 2008-04-08 08:16:19 UTC (rev 3851) @@ -44,6 +44,7 @@ import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; import javax.swing.text.JTextComponent; +import net.sf.gridarta.CFArchTypeList; import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.ArchetypeSet; import net.sf.gridarta.gameobject.GameObject; @@ -149,9 +150,11 @@ * @param archetypeSet The archetype set to search. * * @param insertionObjectChooser The insertion object chooser to use when - * selecting search results. + * selecting search results.# + * + * @param archTypeList the instance for looking up archetype types */ - public FindArchetypesDialog(final Component parent, final ArchetypeSet<G, A, R> archetypeSet, final InsertionObjectChooser<G, A, R> insertionObjectChooser) { + public FindArchetypesDialog(final Component parent, final ArchetypeSet<G, A, R> archetypeSet, final InsertionObjectChooser<G, A, R> insertionObjectChooser, final CFArchTypeList archTypeList) { this.archetypeSet = archetypeSet; this.insertionObjectChooser = insertionObjectChooser; @@ -162,7 +165,7 @@ addAction(nameField, ACTION_FACTORY.createAction(true, "findArchetypesScrollDown", this)); nameField.getDocument().addDocumentListener(documentListener); - resultTableModel = new TableModel<G, A, R>(); + resultTableModel = new TableModel<G, A, R>(archTypeList); resultTable = new JTable(resultTableModel); resultTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); resultTable.setRowSelectionAllowed(true); Modified: trunk/src/app/net/sf/gridarta/gui/findarchetypes/TableModel.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/findarchetypes/TableModel.java 2008-04-08 07:46:35 UTC (rev 3850) +++ trunk/src/app/net/sf/gridarta/gui/findarchetypes/TableModel.java 2008-04-08 08:16:19 UTC (rev 3851) @@ -24,8 +24,8 @@ import java.util.Comparator; import java.util.List; import javax.swing.table.AbstractTableModel; -import net.sf.gridarta.AbstractMainControl; import net.sf.gridarta.CFArchType; +import net.sf.gridarta.CFArchTypeList; import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.GameObject; import net.sf.gridarta.map.MapArchObject; @@ -64,6 +64,11 @@ }; /** + * The instance for looking up archetype types. + */ + private final CFArchTypeList archTypeList; + + /** * The model's contents. */ private final List<R> archetypes = new ArrayList<R>(); @@ -101,6 +106,14 @@ }; /** + * Creates a new instance. + * @param archTypeList the instance for looking up archetype types + */ + public TableModel(final CFArchTypeList archTypeList) { + this.archTypeList = archTypeList; + } + + /** * Clear the model's contents. */ public void clear() { @@ -149,7 +162,7 @@ return archetype.getArchetypeName(); case 2: - final CFArchType archType = AbstractMainControl.getInstance().getTypeList().getType(archetype); + final CFArchType archType = archTypeList.getType(archetype); return archType.getTypeName() + " (" + archType.getTypeNr() + ')'; case 3: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-04-09 16:27:00
|
Revision: 3852 http://gridarta.svn.sourceforge.net/gridarta/?rev=3852&view=rev Author: akirschbaum Date: 2008-04-09 09:26:49 -0700 (Wed, 09 Apr 2008) Log Message: ----------- Do not export InternalFrameListener interface from MainView. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainView.java trunk/daimonin/src/daieditor/CMainView.java trunk/src/app/net/sf/gridarta/gui/MainView.java Modified: trunk/crossfire/src/cfeditor/CMainView.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainView.java 2008-04-08 08:16:19 UTC (rev 3851) +++ trunk/crossfire/src/cfeditor/CMainView.java 2008-04-09 16:26:49 UTC (rev 3852) @@ -281,7 +281,7 @@ public void addLevelView(final MapView<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> mapView) { assert !mapViews.contains(mapView); mapViews.add(0, mapView); - mapView.addInternalFrameListener(this); + mapView.addInternalFrameListener(internalFrameListener); mapDesktop.add(mapView); mapManager.fireMapViewCreatedEvent(mapView); setCurrentLevelView(mapView); @@ -302,7 +302,7 @@ return; } - mapView.removeInternalFrameListener(this); + mapView.removeInternalFrameListener(internalFrameListener); mapViews.remove(mapView); generateCurrentMapViewChangedEvent(); mapManager.fireMapViewClosingEvent(mapView); Modified: trunk/daimonin/src/daieditor/CMainView.java =================================================================== --- trunk/daimonin/src/daieditor/CMainView.java 2008-04-08 08:16:19 UTC (rev 3851) +++ trunk/daimonin/src/daieditor/CMainView.java 2008-04-09 16:26:49 UTC (rev 3852) @@ -281,7 +281,7 @@ public void addLevelView(final MapView<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> mapView) { assert !mapViews.contains(mapView); mapViews.add(0, mapView); - mapView.addInternalFrameListener(this); + mapView.addInternalFrameListener(internalFrameListener); mapDesktop.add(mapView); mapManager.fireMapViewCreatedEvent(mapView); setCurrentLevelView(mapView); @@ -302,7 +302,7 @@ return; } - mapView.removeInternalFrameListener(this); + mapView.removeInternalFrameListener(internalFrameListener); mapViews.remove(mapView); generateCurrentMapViewChangedEvent(); mapManager.fireMapViewClosingEvent(mapView); Modified: trunk/src/app/net/sf/gridarta/gui/MainView.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/MainView.java 2008-04-08 08:16:19 UTC (rev 3851) +++ trunk/src/app/net/sf/gridarta/gui/MainView.java 2008-04-09 16:26:49 UTC (rev 3852) @@ -47,7 +47,7 @@ * @author <a href="mailto:ch...@ri...">Christian Hujer</a> * @todo shouldn't extend JFrame */ -public abstract class MainView<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>, C extends MapControl<G, A, R>, V extends MapViewBasic<G, A, R>> extends JFrame implements InternalFrameListener { +public abstract class MainView<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>, C extends MapControl<G, A, R>, V extends MapViewBasic<G, A, R>> extends JFrame { /** The Logger for printing log messages. */ private static final Logger log = Logger.getLogger(MainView.class); @@ -104,6 +104,46 @@ protected GSplitPane splitRightPane; /** + * The listener attached to map views. + */ + protected final InternalFrameListener internalFrameListener = new InternalFrameListener() { + + /** {@inheritDoc} */ + public void internalFrameActivated(final InternalFrameEvent e) { + final MapView<G, A, R, C, V> mapView = (MapView<G, A, R, C, V>) e.getSource(); + levelViewFocusGainedNotify(mapView); + } + + /** {@inheritDoc} */ + public void internalFrameClosed(final InternalFrameEvent e) { + } + + /** {@inheritDoc} */ + public void internalFrameClosing(final InternalFrameEvent e) { + mapManager.closeView((MapView<G, A, R, C, V>) e.getInternalFrame()); + } + + /** {@inheritDoc} */ + public void internalFrameDeactivated(final InternalFrameEvent e) { + } + + /** {@inheritDoc} */ + public void internalFrameDeiconified(final InternalFrameEvent e) { + } + + /** {@inheritDoc} */ + public void internalFrameIconified(final InternalFrameEvent e) { + final MapView<G, A, R, C, V> mapView = (MapView<G, A, R, C, V>) e.getSource(); + levelViewFocusLostNotify(mapView); + } + + /** {@inheritDoc} */ + public void internalFrameOpened(final InternalFrameEvent e) { + } + + }; + + /** * Creates a new MainView. * @param mainControl MainControl to use. * @param mapManager the map manager @@ -216,39 +256,6 @@ mapDesktop.setSelectedFrame(mapView); } - /** {@inheritDoc} */ - public void internalFrameOpened(final InternalFrameEvent e) { - } - - /** {@inheritDoc} */ - public void internalFrameClosing(final InternalFrameEvent e) { - mapManager.closeView((MapView<G, A, R, C, V>) e.getInternalFrame()); - } - - /** {@inheritDoc} */ - public void internalFrameClosed(final InternalFrameEvent e) { - } - - /** {@inheritDoc} */ - public void internalFrameIconified(final InternalFrameEvent e) { - final MapView<G, A, R, C, V> mapView = (MapView<G, A, R, C, V>) e.getSource(); - levelViewFocusLostNotify(mapView); - } - - /** {@inheritDoc} */ - public void internalFrameDeiconified(final InternalFrameEvent e) { - } - - /** {@inheritDoc} */ - public void internalFrameActivated(final InternalFrameEvent e) { - final MapView<G, A, R, C, V> mapView = (MapView<G, A, R, C, V>) e.getSource(); - levelViewFocusGainedNotify(mapView); - } - - /** {@inheritDoc} */ - public void internalFrameDeactivated(final InternalFrameEvent e) { - } - /** * Notifies that the level views focus is lost it is inserted * as the second in line to the level view vector. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-04-09 17:33:39
|
Revision: 3854 http://gridarta.svn.sourceforge.net/gridarta/?rev=3854&view=rev Author: akirschbaum Date: 2008-04-09 10:33:36 -0700 (Wed, 09 Apr 2008) Log Message: ----------- Move isAutoJoin() from CMainView to CMainControl. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/CMainView.java trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/CMainView.java trunk/src/app/net/sf/gridarta/MainControl.java trunk/src/app/net/sf/gridarta/gui/MainView.java trunk/src/app/net/sf/gridarta/map/DefaultMapModel.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-04-09 16:30:33 UTC (rev 3853) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-04-09 17:33:36 UTC (rev 3854) @@ -147,6 +147,8 @@ /** The map manager actions. */ private final MapManagerActions<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> mapManagerActions; + private final MapActions mapActions; + /** The main view. */ private final CMainView mainView; @@ -243,6 +245,7 @@ mapCursorControl = new MapCursorControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>("cfeditor", this, getMapManager()); ACTION_FACTORY.createActions(true, this, "createNew", "open", "options", "exit", "gc", "onlineHelp", "tod", "about"); mapManagerActions = new MapManagerActions<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(getMapManager()); + mapActions = new MapActions(this, getMapManager()); mainView = new CMainView(this, getMapManager(), ACTION_FACTORY, mapManagerActions.getCloseAllAction()); new About("cfeditor", mainView); undoControl = new UndoControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(getMapManager()); @@ -284,6 +287,7 @@ // Initialize the main view mainView.init(newMapDialogFactory, null, new LockedItemsControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(getMapManager(), 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), new File(mapDir, IGUIConstants.PICKMAP_DIR), typeList); + mapActions.updateMenuState(); scriptControl.getView().setMenu((JMenu) ACTION_FACTORY.find(mainView.getJMenuBar(), "plugins")); archetypeParser = new ArchetypeParser(this, mainView.getObjectChooser().getArchetypeChooserControl()); animationObjects = new AnimationObjects(); @@ -964,4 +968,9 @@ return result; } + /** {@inheritDoc} */ + public boolean isAutoJoin() { + return mapActions.isAutoJoin(); + } + } // class CMainControl Modified: trunk/crossfire/src/cfeditor/CMainView.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainView.java 2008-04-09 16:30:33 UTC (rev 3853) +++ trunk/crossfire/src/cfeditor/CMainView.java 2008-04-09 17:33:36 UTC (rev 3854) @@ -119,8 +119,6 @@ private final ViewActions<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> viewActions; - private final MapActions mapActions; - /** The actions of the "Archetypes" menu. */ private ArchetypesActions<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> archetypesActions; @@ -156,7 +154,6 @@ aNextWindow = actionFactory.createAction(true, "nextWindow", this); viewActions = new ViewActions<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(mainControl, mapManager); - mapActions = new MapActions(mainControl, mapManager); final ImageIcon icon = GUIUtils.getIcon(IGUIConstants.APP_ICON); if (icon != null) { @@ -192,8 +189,6 @@ setJMenuBar(actionFactory.createMenuBar(true, "main")); objectChooser.setPickmapFoldersMenu((JMenu) actionFactory.find(getJMenuBar(), "pickmapFolders")); - mapActions.updateMenuState(); - // set bounds (location and size) of the main frame setBounds( prefs.getInt(WINDOW_X, (int) (screen.getX() + (screen.getWidth() - defwidth) / 2.0)), @@ -459,11 +454,6 @@ } /** {@inheritDoc} */ - public boolean isAutoJoin() { - return mapActions.isAutoJoin(); - } - - /** {@inheritDoc} */ public InsertionObjectChooser getObjectChooser() { return objectChooser; } Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-04-09 16:30:33 UTC (rev 3853) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-04-09 17:33:36 UTC (rev 3854) @@ -184,6 +184,8 @@ /** The map manager actions. */ private final MapManagerActions<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> mapManagerActions; + private final MapActions mapActions; + /** The main view. */ private final CMainView mainView; @@ -296,6 +298,7 @@ ACTION_FACTORY.createToggles(true, this, "drawDouble"); aCollectSpells = ACTION_FACTORY.createAction(true, "collectSpells", this); mapManagerActions = new MapManagerActions<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(getMapManager()); + mapActions = new MapActions(this, getMapManager()); mainView = new CMainView(this, getMapManager(), ACTION_FACTORY, mapManagerActions.getCloseAllAction()); new About("daieditor", mainView); undoControl = new UndoControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(getMapManager()); @@ -339,6 +342,7 @@ // Initialize the main view mainView.init(newMapDialogFactory, GUIUtils.getSysIcon(IGUIConstants.TILE_NORTH), new LockedItemsControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(getMapManager(), 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), new File(strArchDir, IGUIConstants.PICKMAP_DIR), typeList); + mapActions.updateMenuState(); archetypeParser = new ArchetypeParser(this, mainView.getObjectChooser().getArchetypeChooserControl()); animationObjects = new AnimationObjects(); faceObjects = new FaceObjects(); @@ -1123,4 +1127,9 @@ return getArchDefaultFolder() + "/dev/editor/conf"; } + /** {@inheritDoc} */ + public boolean isAutoJoin() { + return mapActions.isAutoJoin(); + } + } // class CMainControl Modified: trunk/daimonin/src/daieditor/CMainView.java =================================================================== --- trunk/daimonin/src/daieditor/CMainView.java 2008-04-09 16:30:33 UTC (rev 3853) +++ trunk/daimonin/src/daieditor/CMainView.java 2008-04-09 17:33:36 UTC (rev 3854) @@ -119,8 +119,6 @@ private final ViewActions<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> viewActions; - private final MapActions mapActions; - /** The actions of the "Archetypes" menu. */ private ArchetypesActions<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> archetypesActions; @@ -156,7 +154,6 @@ aNextWindow = actionFactory.createAction(true, "nextWindow", this); viewActions = new ViewActions<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(mainControl, mapManager); - mapActions = new MapActions(mainControl, mapManager); final ImageIcon icon = GUIUtils.getIcon(IGUIConstants.APP_ICON); if (icon != null) { @@ -192,8 +189,6 @@ setJMenuBar(actionFactory.createMenuBar(true, "main")); objectChooser.setPickmapFoldersMenu((JMenu) actionFactory.find(getJMenuBar(), "pickmapFolders")); - mapActions.updateMenuState(); - // set bounds (location and size) of the main frame setBounds( prefs.getInt(WINDOW_X, (int) (screen.getX() + (screen.getWidth() - defwidth) / 2.0)), @@ -459,11 +454,6 @@ } /** {@inheritDoc} */ - public boolean isAutoJoin() { - return mapActions.isAutoJoin(); - } - - /** {@inheritDoc} */ public InsertionObjectChooser getObjectChooser() { return objectChooser; } Modified: trunk/src/app/net/sf/gridarta/MainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/MainControl.java 2008-04-09 16:30:33 UTC (rev 3853) +++ trunk/src/app/net/sf/gridarta/MainControl.java 2008-04-09 17:33:36 UTC (rev 3854) @@ -305,4 +305,12 @@ */ AutojoinLists<G, A, R> getAutojoinLists(); + /** + * Determine whether autojoining is enabled. + * + * @return <code>true</code> if autojoining is enabled, or + * <code>false</code> if autojoining is disabled + */ + boolean isAutoJoin(); + } // interface MainControl Modified: trunk/src/app/net/sf/gridarta/gui/MainView.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/MainView.java 2008-04-09 16:30:33 UTC (rev 3853) +++ trunk/src/app/net/sf/gridarta/gui/MainView.java 2008-04-09 17:33:36 UTC (rev 3854) @@ -223,14 +223,6 @@ @NotNull public abstract SelectedSquareControl<G, A, R, C, V> getSelectedSquareControl(); /** - * Determine whether autojoining is enabled. - * - * @return <code>true</code> if autojoining is enabled, or - * <code>false</code> if autojoining is disabled - */ - public abstract boolean isAutoJoin(); - - /** * Activate the given map view. * @param mapView the map view */ Modified: trunk/src/app/net/sf/gridarta/map/DefaultMapModel.java =================================================================== --- trunk/src/app/net/sf/gridarta/map/DefaultMapModel.java 2008-04-09 16:30:33 UTC (rev 3853) +++ trunk/src/app/net/sf/gridarta/map/DefaultMapModel.java 2008-04-09 17:33:36 UTC (rev 3854) @@ -547,7 +547,7 @@ // do autojoining final R temp = mainControl.getArchetypeSet().getArchetype(gameObject.getArchetypeName()); - if (mainControl.getMainView().isAutoJoin() && join && mainControl.getAutojoinLists().getAutojoinList(temp) != null && !temp.isMulti()) { + if (mainControl.isAutoJoin() && join && mainControl.getAutojoinLists().getAutojoinList(temp) != null && !temp.isMulti()) { // remove connections to the deleted arch mainControl.getAutojoinLists().getAutojoinList(temp).joinDelete(this, pos); } @@ -663,7 +663,7 @@ return null; } - if (mainControl.getMainView().isAutoJoin() && join && mainControl.getAutojoinLists().getAutojoinList(archetype) != null && !archetype.isMulti()) { + if (mainControl.isAutoJoin() && join && mainControl.getAutojoinLists().getAutojoinList(archetype) != null && !archetype.isMulti()) { // do autojoining if enabled archetype = mainControl.getAutojoinLists().getAutojoinList(archetype).joinInsert(this, pos); if (archetype == null) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-04-09 18:21:13
|
Revision: 3855 http://gridarta.svn.sourceforge.net/gridarta/?rev=3855&view=rev Author: akirschbaum Date: 2008-04-09 11:21:13 -0700 (Wed, 09 Apr 2008) Log Message: ----------- Move IGUIConstants.APP_ICON to common code base. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainView.java trunk/crossfire/src/cfeditor/IGUIConstants.java trunk/daimonin/src/daieditor/CMainView.java trunk/daimonin/src/daieditor/CPreview.java trunk/daimonin/src/daieditor/IGUIConstants.java trunk/src/app/net/sf/gridarta/gui/GUIConstants.java Modified: trunk/crossfire/src/cfeditor/CMainView.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainView.java 2008-04-09 17:33:36 UTC (rev 3854) +++ trunk/crossfire/src/cfeditor/CMainView.java 2008-04-09 18:21:13 UTC (rev 3855) @@ -49,6 +49,7 @@ import net.sf.gridarta.MenuHelper; import net.sf.gridarta.gui.ArchetypesActions; import net.sf.gridarta.gui.GSplitPane; +import net.sf.gridarta.gui.GUIConstants; import net.sf.gridarta.gui.GUIUtils; import net.sf.gridarta.gui.MainView; import net.sf.gridarta.gui.connectionview.LockedItemsControl; @@ -155,7 +156,7 @@ viewActions = new ViewActions<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(mainControl, mapManager); - final ImageIcon icon = GUIUtils.getIcon(IGUIConstants.APP_ICON); + final ImageIcon icon = GUIUtils.getIcon(GUIConstants.APP_ICON); if (icon != null) { setIconImage(icon.getImage()); } Modified: trunk/crossfire/src/cfeditor/IGUIConstants.java =================================================================== --- trunk/crossfire/src/cfeditor/IGUIConstants.java 2008-04-09 17:33:36 UTC (rev 3854) +++ trunk/crossfire/src/cfeditor/IGUIConstants.java 2008-04-09 18:21:13 UTC (rev 3855) @@ -60,9 +60,6 @@ String FACETREE_FILE = "bmaps.paths"; - /** Application icon definitions (icon-dir). */ - String APP_ICON = "CFIcon.gif"; - String NEW_LEVEL_ICON = "NewLevelIcon.gif"; String CLOSE_TAB_SMALLICON = "CloseTabSmallIcon.gif"; Modified: trunk/daimonin/src/daieditor/CMainView.java =================================================================== --- trunk/daimonin/src/daieditor/CMainView.java 2008-04-09 17:33:36 UTC (rev 3854) +++ trunk/daimonin/src/daieditor/CMainView.java 2008-04-09 18:21:13 UTC (rev 3855) @@ -49,6 +49,7 @@ import net.sf.gridarta.MenuHelper; import net.sf.gridarta.gui.ArchetypesActions; import net.sf.gridarta.gui.GSplitPane; +import net.sf.gridarta.gui.GUIConstants; import net.sf.gridarta.gui.GUIUtils; import net.sf.gridarta.gui.MainView; import net.sf.gridarta.gui.connectionview.LockedItemsControl; @@ -155,7 +156,7 @@ viewActions = new ViewActions<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(mainControl, mapManager); - final ImageIcon icon = GUIUtils.getIcon(IGUIConstants.APP_ICON); + final ImageIcon icon = GUIUtils.getIcon(GUIConstants.APP_ICON); if (icon != null) { setIconImage(icon.getImage()); } Modified: trunk/daimonin/src/daieditor/CPreview.java =================================================================== --- trunk/daimonin/src/daieditor/CPreview.java 2008-04-09 17:33:36 UTC (rev 3854) +++ trunk/daimonin/src/daieditor/CPreview.java 2008-04-09 18:21:13 UTC (rev 3855) @@ -88,7 +88,7 @@ frame = new JFrame("Daimonin Map Previewer"); // WARNING: Do not set the icon. There's a bug that will prevent the frame from getting properly disposed. // This code will be put back in as soon as sun fixes the setIconImage() bug in their java.awt.peer.FramePeer impl. - //ImageIcon icon = GUIUtils.getIcon(IGUIConstants.APP_ICON); + //ImageIcon icon = GUIUtils.getIcon(GUIConstants.APP_ICON); //if (icon != null) { // frame.setIconImage(icon.getImage()); //} Modified: trunk/daimonin/src/daieditor/IGUIConstants.java =================================================================== --- trunk/daimonin/src/daieditor/IGUIConstants.java 2008-04-09 17:33:36 UTC (rev 3854) +++ trunk/daimonin/src/daieditor/IGUIConstants.java 2008-04-09 18:21:13 UTC (rev 3855) @@ -85,9 +85,6 @@ String ARTIFACTS_FILE = "artifacts"; // file with artifact definitions - /** Application icon definitions (icon-dir). */ - String APP_ICON = "CFIcon.gif"; - String TILE_NORTH = "north.png"; } // interface IGUIConstants Modified: trunk/src/app/net/sf/gridarta/gui/GUIConstants.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/GUIConstants.java 2008-04-09 17:33:36 UTC (rev 3854) +++ trunk/src/app/net/sf/gridarta/gui/GUIConstants.java 2008-04-09 18:21:13 UTC (rev 3855) @@ -97,4 +97,7 @@ /** The default map preview to use if no icon can be created. */ String DEFAULT_PREVIEW = "default_preview.png"; + /** Application icon definitions (icon-dir). */ + String APP_ICON = "CFIcon.gif"; + } // interface GUIConstants This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-04-09 19:33:34
|
Revision: 3857 http://gridarta.svn.sourceforge.net/gridarta/?rev=3857&view=rev Author: akirschbaum Date: 2008-04-09 12:33:08 -0700 (Wed, 09 Apr 2008) Log Message: ----------- Rename InsertionObjectChooser into ObjectChooser. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainView.java trunk/crossfire/src/cfeditor/gui/map/MapUserListener.java trunk/daimonin/src/daieditor/CMainView.java trunk/src/app/net/sf/gridarta/gui/ArchetypesActions.java trunk/src/app/net/sf/gridarta/gui/MainView.java trunk/src/app/net/sf/gridarta/gui/findarchetypes/FindArchetypesDialog.java trunk/src/app/net/sf/gridarta/gui/pickmapchooser/ArchNPickChangeListener.java trunk/src/app/net/sf/gridarta/gui/pickmapchooser/PickmapChooserControl.java trunk/src/app/net/sf/gridarta/gui/pickmapchooser/PickmapSelectionListener.java Added Paths: ----------- trunk/crossfire/src/cfeditor/gui/ObjectChooser.java trunk/daimonin/src/daieditor/gui/ObjectChooser.java trunk/src/app/net/sf/gridarta/gui/AbstractObjectChooser.java trunk/src/app/net/sf/gridarta/gui/ObjectChooser.java Removed Paths: ------------- trunk/crossfire/src/cfeditor/gui/InsertionObjectChooser.java trunk/daimonin/src/daieditor/gui/InsertionObjectChooser.java trunk/src/app/net/sf/gridarta/gui/AbstractInsertionObjectChooser.java trunk/src/app/net/sf/gridarta/gui/InsertionObjectChooser.java Modified: trunk/crossfire/src/cfeditor/CMainView.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainView.java 2008-04-09 18:24:06 UTC (rev 3856) +++ trunk/crossfire/src/cfeditor/CMainView.java 2008-04-09 19:33:08 UTC (rev 3857) @@ -22,7 +22,7 @@ import cfeditor.gameobject.Archetype; import cfeditor.gameobject.GameObject; import cfeditor.gui.GameObjectAttributesPanel; -import cfeditor.gui.InsertionObjectChooser; +import cfeditor.gui.ObjectChooser; import cfeditor.map.MapArchObject; import cfeditor.map.MapControl; import java.awt.BorderLayout; @@ -93,7 +93,7 @@ private final CMainControl mainControl; /** The panel that contains the object chooser. */ - private InsertionObjectChooser objectChooser; + private ObjectChooser objectChooser; /** All open level views. */ private final List<MapView<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>> mapViews = Collections.synchronizedList(new ArrayList<MapView<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>>()); @@ -230,7 +230,7 @@ final int divLocationDown = prefs.getInt(DIVIDER_LOCATION_KEY2, (int) (defheight * 0.76)); final int divLocation = prefs.getInt(DIVIDER_LOCATION_KEY, (int) (defwidth * 0.17)); - objectChooser = new InsertionObjectChooser(newMapDialogFactory, mainControl, pickmapDir); + objectChooser = new ObjectChooser(newMapDialogFactory, mainControl, pickmapDir); final boolean mapTileListBottom = prefs.getBoolean(MainView.MAP_TILE_LIST_BOTTOM_KEY, CMainView.MAP_TILE_LIST_BOTTOM_DEFAULT); selectedSquareControl = new SelectedSquareControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(actionFactory, mainControl, this, mapTileListBottom, compassIcon); gameObjectAttributesPanel = new GameObjectAttributesPanel(mainControl, mapManager, this, lockedItemsControl); @@ -455,7 +455,7 @@ } /** {@inheritDoc} */ - public InsertionObjectChooser getObjectChooser() { + public ObjectChooser getObjectChooser() { return objectChooser; } Deleted: trunk/crossfire/src/cfeditor/gui/InsertionObjectChooser.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/InsertionObjectChooser.java 2008-04-09 18:24:06 UTC (rev 3856) +++ trunk/crossfire/src/cfeditor/gui/InsertionObjectChooser.java 2008-04-09 19:33:08 UTC (rev 3857) @@ -1,180 +0,0 @@ -/* - * 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 cfeditor.gui; - -import cfeditor.CMainControl; -import cfeditor.CMapViewBasic; -import cfeditor.gameobject.Archetype; -import cfeditor.gameobject.GameObject; -import cfeditor.map.MapArchObject; -import cfeditor.map.MapControl; -import java.awt.BorderLayout; -import java.awt.Dimension; -import java.awt.Toolkit; -import java.io.File; -import java.util.List; -import java.util.prefs.Preferences; -import javax.swing.JSplitPane; -import javax.swing.JTabbedPane; -import javax.swing.SwingConstants; -import net.sf.gridarta.MainControl; -import net.sf.gridarta.gui.AbstractInsertionObjectChooser; -import net.sf.gridarta.gui.GSplitPane; -import net.sf.gridarta.gui.ObjectChoiceDisplay; -import net.sf.gridarta.gui.archetypechooser.ArchetypeChooserControl; -import net.sf.gridarta.gui.archetypechooser.ArchetypeChooserListener; -import net.sf.gridarta.gui.newmap.NewMapDialogFactory; -import net.sf.gridarta.gui.pickmapchooser.PickmapChooserControl; -import net.sf.japi.swing.ActionFactory; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -/** - * The <code>InsertionObjectChooser</code> holds the tile palette. - * @author <a href="mailto:mic...@no...">Michael Toennies</a> - * @author <a href="mailto:and...@gm...">Andreas Vogl</a> - * @author <a href="mailto:ch...@ri...">Christian Hujer</a> - * @author Andreas Kirschbaum - */ -public final class InsertionObjectChooser extends AbstractInsertionObjectChooser<GameObject, MapArchObject, Archetype> implements net.sf.gridarta.gui.InsertionObjectChooser<GameObject, MapArchObject, Archetype> { - - private static final String ARCHPANEL_LOCATION_KEY = "MainWindowArchPanel.dividerLocation"; - - /** Action Factory. */ - private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("cfeditor"); - - /** Serial Version UID. */ - private static final long serialVersionUID = 1L; - - /** Preferences. */ - private static final Preferences prefs = Preferences.userNodeForPackage(MainControl.class); - - /** Panel holding both archlist and pickmaps. */ - private final JTabbedPane archAndPickPane = new JTabbedPane(SwingConstants.TOP); - - /** Our split pane. */ - private final GSplitPane splitPane; - - /** The data/view of selected objects in tab panel. */ - private final ObjectChoiceDisplay<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> objectChoiceDisplay; - - /** The pickmap chooser control. */ - private final PickmapChooserControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> pickmapChooserControl; - - /** The archetype chooser control. */ - private final ArchetypeChooserControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> archetypeChooserControl; - - /** - * Build Panel. - * @param newMapDialogFactory the factory for creating new pickmaps - * @param mainControl CMainControl - * @param pickmapDir the pickmaps directory - */ - public InsertionObjectChooser(@NotNull final NewMapDialogFactory<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> newMapDialogFactory, final CMainControl mainControl, @NotNull final File pickmapDir) { - pickmapChooserControl = new PickmapChooserControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(newMapDialogFactory, mainControl, this, pickmapDir); - archetypeChooserControl = new ArchetypeChooserControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(mainControl, false); - archetypeChooserControl.addArchetypeChooserListener(new ArchetypeChooserListener<GameObject, MapArchObject, Archetype>() { - /** {@inheritDoc} */ - public void selectedArchetypeChanged(@NotNull final GameObject archetype) { - showObjectChooserQuickObject(archetype); - } - - /** {@inheritDoc} */ - public void displayObjectNamesChanged(final boolean displayObjectNamesChanged) { - // ignore - } - }); - - objectChoiceDisplay = new ObjectChoiceDisplay<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(mainControl); - - // archAndPickPane is the panel containing both archpanel and pickmaps - archAndPickPane.addTab(ACTION_FACTORY.getString("objectChooser.archetypesTabTitle"), archetypeChooserControl.getArchetypePanel()); - archAndPickPane.addTab(ACTION_FACTORY.getString("objectChooser.pickmapsTabTitle"), pickmapChooserControl.getPickmapPanel()); - // this listener informs the mainview which panel is active: archlist or pickmaps? - pickmapChooserControl.addArchNPickChangeListener(archAndPickPane); - - // calculate default value in case there is no settings file - final Dimension screen = Toolkit.getDefaultToolkit().getScreenSize(); - - final int divLocation = prefs.getInt(ARCHPANEL_LOCATION_KEY, (int) (0.77 * 0.9 * screen.getHeight())); - - splitPane = new GSplitPane(JSplitPane.VERTICAL_SPLIT, archAndPickPane, objectChoiceDisplay); - splitPane.setDividerLocation(divLocation); - splitPane.setContinuousLayout(true); - splitPane.setResizeWeight(1); - add(splitPane, BorderLayout.CENTER); - } - - /** {@inheritDoc} */ - public void moveArchetypeChooserToFront() { - archAndPickPane.setSelectedIndex(0); - } - - /** {@inheritDoc} */ - public void movePickmapChooserToFront() { - archAndPickPane.setSelectedIndex(1); - } - - /** {@inheritDoc} */ - public void showObjectChooserQuickObject(@Nullable final GameObject gameObject) { - objectChoiceDisplay.showObjectChooserQuickObject(gameObject); - } - - public void appExitNotify() { - prefs.putInt(ARCHPANEL_LOCATION_KEY, splitPane.getDividerLocation()); - } - - /** {@inheritDoc} */ - @Nullable public GameObject getObjectChooserHighlight() { - return isPickmapActive() ? pickmapChooserControl.getSelection() : archetypeChooserControl.getSelection(); - } - - /** {@inheritDoc} */ - @NotNull public List<GameObject> getObjectChooserSelection() { - return isPickmapActive() ? pickmapChooserControl.getSelections() : archetypeChooserControl.getSelections(); - } - - /** - * Return the pickmap chooser control. - * - * @return the pickmap chooser control - */ - @NotNull public PickmapChooserControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> getPickmapChooserControl() { - return pickmapChooserControl; - } - - /** {@inheritDoc} */ - @NotNull public ArchetypeChooserControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> getArchetypeChooserControl() { - return archetypeChooserControl; - } - - /** {@inheritDoc} */ - public void setPickmapActive(final boolean pickmapActive) { - super.setPickmapActive(pickmapActive); - pickmapChooserControl.setActive(pickmapActive); - } - - /** {@inheritDoc} */ - public void selectArchetype(final Archetype archetype) { - moveArchetypeChooserToFront(); - archetypeChooserControl.selectArchetype(archetype); - } - -} // class InsertionObjectChooser Copied: trunk/crossfire/src/cfeditor/gui/ObjectChooser.java (from rev 3855, trunk/crossfire/src/cfeditor/gui/InsertionObjectChooser.java) =================================================================== --- trunk/crossfire/src/cfeditor/gui/ObjectChooser.java (rev 0) +++ trunk/crossfire/src/cfeditor/gui/ObjectChooser.java 2008-04-09 19:33:08 UTC (rev 3857) @@ -0,0 +1,180 @@ +/* + * 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 cfeditor.gui; + +import cfeditor.CMainControl; +import cfeditor.CMapViewBasic; +import cfeditor.gameobject.Archetype; +import cfeditor.gameobject.GameObject; +import cfeditor.map.MapArchObject; +import cfeditor.map.MapControl; +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.Toolkit; +import java.io.File; +import java.util.List; +import java.util.prefs.Preferences; +import javax.swing.JSplitPane; +import javax.swing.JTabbedPane; +import javax.swing.SwingConstants; +import net.sf.gridarta.MainControl; +import net.sf.gridarta.gui.AbstractObjectChooser; +import net.sf.gridarta.gui.GSplitPane; +import net.sf.gridarta.gui.ObjectChoiceDisplay; +import net.sf.gridarta.gui.archetypechooser.ArchetypeChooserControl; +import net.sf.gridarta.gui.archetypechooser.ArchetypeChooserListener; +import net.sf.gridarta.gui.newmap.NewMapDialogFactory; +import net.sf.gridarta.gui.pickmapchooser.PickmapChooserControl; +import net.sf.japi.swing.ActionFactory; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * The <code>ObjectChooser</code> holds the tile palette. + * @author <a href="mailto:mic...@no...">Michael Toennies</a> + * @author <a href="mailto:and...@gm...">Andreas Vogl</a> + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + * @author Andreas Kirschbaum + */ +public final class ObjectChooser extends AbstractObjectChooser<GameObject, MapArchObject, Archetype> implements net.sf.gridarta.gui.ObjectChooser<GameObject, MapArchObject, Archetype> { + + private static final String ARCHPANEL_LOCATION_KEY = "MainWindowArchPanel.dividerLocation"; + + /** Action Factory. */ + private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("cfeditor"); + + /** Serial Version UID. */ + private static final long serialVersionUID = 1L; + + /** Preferences. */ + private static final Preferences prefs = Preferences.userNodeForPackage(MainControl.class); + + /** Panel holding both archlist and pickmaps. */ + private final JTabbedPane archAndPickPane = new JTabbedPane(SwingConstants.TOP); + + /** Our split pane. */ + private final GSplitPane splitPane; + + /** The data/view of selected objects in tab panel. */ + private final ObjectChoiceDisplay<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> objectChoiceDisplay; + + /** The pickmap chooser control. */ + private final PickmapChooserControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> pickmapChooserControl; + + /** The archetype chooser control. */ + private final ArchetypeChooserControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> archetypeChooserControl; + + /** + * Build Panel. + * @param newMapDialogFactory the factory for creating new pickmaps + * @param mainControl CMainControl + * @param pickmapDir the pickmaps directory + */ + public ObjectChooser(@NotNull final NewMapDialogFactory<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> newMapDialogFactory, final CMainControl mainControl, @NotNull final File pickmapDir) { + pickmapChooserControl = new PickmapChooserControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(newMapDialogFactory, mainControl, this, pickmapDir); + archetypeChooserControl = new ArchetypeChooserControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(mainControl, false); + archetypeChooserControl.addArchetypeChooserListener(new ArchetypeChooserListener<GameObject, MapArchObject, Archetype>() { + /** {@inheritDoc} */ + public void selectedArchetypeChanged(@NotNull final GameObject archetype) { + showObjectChooserQuickObject(archetype); + } + + /** {@inheritDoc} */ + public void displayObjectNamesChanged(final boolean displayObjectNamesChanged) { + // ignore + } + }); + + objectChoiceDisplay = new ObjectChoiceDisplay<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(mainControl); + + // archAndPickPane is the panel containing both archpanel and pickmaps + archAndPickPane.addTab(ACTION_FACTORY.getString("objectChooser.archetypesTabTitle"), archetypeChooserControl.getArchetypePanel()); + archAndPickPane.addTab(ACTION_FACTORY.getString("objectChooser.pickmapsTabTitle"), pickmapChooserControl.getPickmapPanel()); + // this listener informs the mainview which panel is active: archlist or pickmaps? + pickmapChooserControl.addArchNPickChangeListener(archAndPickPane); + + // calculate default value in case there is no settings file + final Dimension screen = Toolkit.getDefaultToolkit().getScreenSize(); + + final int divLocation = prefs.getInt(ARCHPANEL_LOCATION_KEY, (int) (0.77 * 0.9 * screen.getHeight())); + + splitPane = new GSplitPane(JSplitPane.VERTICAL_SPLIT, archAndPickPane, objectChoiceDisplay); + splitPane.setDividerLocation(divLocation); + splitPane.setContinuousLayout(true); + splitPane.setResizeWeight(1); + add(splitPane, BorderLayout.CENTER); + } + + /** {@inheritDoc} */ + public void moveArchetypeChooserToFront() { + archAndPickPane.setSelectedIndex(0); + } + + /** {@inheritDoc} */ + public void movePickmapChooserToFront() { + archAndPickPane.setSelectedIndex(1); + } + + /** {@inheritDoc} */ + public void showObjectChooserQuickObject(@Nullable final GameObject gameObject) { + objectChoiceDisplay.showObjectChooserQuickObject(gameObject); + } + + public void appExitNotify() { + prefs.putInt(ARCHPANEL_LOCATION_KEY, splitPane.getDividerLocation()); + } + + /** {@inheritDoc} */ + @Nullable public GameObject getObjectChooserHighlight() { + return isPickmapActive() ? pickmapChooserControl.getSelection() : archetypeChooserControl.getSelection(); + } + + /** {@inheritDoc} */ + @NotNull public List<GameObject> getObjectChooserSelection() { + return isPickmapActive() ? pickmapChooserControl.getSelections() : archetypeChooserControl.getSelections(); + } + + /** + * Return the pickmap chooser control. + * + * @return the pickmap chooser control + */ + @NotNull public PickmapChooserControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> getPickmapChooserControl() { + return pickmapChooserControl; + } + + /** {@inheritDoc} */ + @NotNull public ArchetypeChooserControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> getArchetypeChooserControl() { + return archetypeChooserControl; + } + + /** {@inheritDoc} */ + public void setPickmapActive(final boolean pickmapActive) { + super.setPickmapActive(pickmapActive); + pickmapChooserControl.setActive(pickmapActive); + } + + /** {@inheritDoc} */ + public void selectArchetype(final Archetype archetype) { + moveArchetypeChooserToFront(); + archetypeChooserControl.selectArchetype(archetype); + } + +} // class ObjectChooser Modified: trunk/crossfire/src/cfeditor/gui/map/MapUserListener.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/map/MapUserListener.java 2008-04-09 18:24:06 UTC (rev 3856) +++ trunk/crossfire/src/cfeditor/gui/map/MapUserListener.java 2008-04-09 19:33:08 UTC (rev 3857) @@ -30,7 +30,7 @@ import java.awt.event.MouseEvent; import java.awt.event.MouseListener; import java.awt.event.MouseMotionListener; -import net.sf.gridarta.gui.InsertionObjectChooser; +import net.sf.gridarta.gui.ObjectChooser; import net.sf.gridarta.gui.map.LevelRenderer; import net.sf.gridarta.gui.map.MapCursor; import net.sf.gridarta.gui.map.MapGrid; @@ -53,7 +53,7 @@ private final CMainControl mainControl; - private final InsertionObjectChooser<GameObject, MapArchObject, Archetype> insertionObjectChooser; + private final ObjectChooser<GameObject, MapArchObject, Archetype> objectChooser; private final SelectedSquareView<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> selectedSquareView; @@ -63,11 +63,11 @@ @NotNull private final CMapViewBasic mapView; - public MapUserListener(final CMainControl mainControl, final MapControl mapControl, final CMapViewBasic mapView, final InsertionObjectChooser<GameObject, MapArchObject, Archetype> insertionObjectChooser, final SelectedSquareView<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> selectedSquareView, final PickmapChooserControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> pickmapChooserControl) { + public MapUserListener(final CMainControl mainControl, final MapControl mapControl, final CMapViewBasic mapView, final ObjectChooser<GameObject, MapArchObject, Archetype> objectChooser, final SelectedSquareView<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> selectedSquareView, final PickmapChooserControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> pickmapChooserControl) { this.mainControl = mainControl; this.mapControl = mapControl; this.mapView = mapView; - this.insertionObjectChooser = insertionObjectChooser; + this.objectChooser = objectChooser; this.selectedSquareView = selectedSquareView; this.pickmapChooserControl = pickmapChooserControl; mapCursor = mapView.getMapCursor(); @@ -156,7 +156,7 @@ mapCursor.dragStart(); if (mapCursor.isActive() && mapControl.isPickmap()) { // an arch of a pickmap was selected - insertionObjectChooser.showObjectChooserQuickObject(mapControl.getMapModel().getMapSquare(mapLoc).getFirst()); + objectChooser.showObjectChooserQuickObject(mapControl.getMapModel().getMapSquare(mapLoc).getFirst()); } mapCursor.endTransaction(); } else if (isDelete(e)) { Modified: trunk/daimonin/src/daieditor/CMainView.java =================================================================== --- trunk/daimonin/src/daieditor/CMainView.java 2008-04-09 18:24:06 UTC (rev 3856) +++ trunk/daimonin/src/daieditor/CMainView.java 2008-04-09 19:33:08 UTC (rev 3857) @@ -22,7 +22,7 @@ import daieditor.gameobject.Archetype; import daieditor.gameobject.GameObject; import daieditor.gui.GameObjectAttributesPanel; -import daieditor.gui.InsertionObjectChooser; +import daieditor.gui.ObjectChooser; import daieditor.map.MapArchObject; import daieditor.map.MapControl; import java.awt.BorderLayout; @@ -93,7 +93,7 @@ private final CMainControl mainControl; /** The panel that contains the object chooser. */ - private InsertionObjectChooser objectChooser; + private ObjectChooser objectChooser; /** All open level views. */ private final List<MapView<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>> mapViews = Collections.synchronizedList(new ArrayList<MapView<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>>()); @@ -230,7 +230,7 @@ final int divLocationDown = prefs.getInt(DIVIDER_LOCATION_KEY2, (int) (defheight * 0.76)); final int divLocation = prefs.getInt(DIVIDER_LOCATION_KEY, (int) (defwidth * 0.17)); - objectChooser = new InsertionObjectChooser(newMapDialogFactory, mainControl, pickmapDir); + objectChooser = new ObjectChooser(newMapDialogFactory, mainControl, pickmapDir); final boolean mapTileListBottom = prefs.getBoolean(MainView.MAP_TILE_LIST_BOTTOM_KEY, CMainView.MAP_TILE_LIST_BOTTOM_DEFAULT); selectedSquareControl = new SelectedSquareControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(actionFactory, mainControl, this, mapTileListBottom, compassIcon); gameObjectAttributesPanel = new GameObjectAttributesPanel(mainControl, mapManager, this, lockedItemsControl); @@ -455,7 +455,7 @@ } /** {@inheritDoc} */ - public InsertionObjectChooser getObjectChooser() { + public ObjectChooser getObjectChooser() { return objectChooser; } Deleted: trunk/daimonin/src/daieditor/gui/InsertionObjectChooser.java =================================================================== --- trunk/daimonin/src/daieditor/gui/InsertionObjectChooser.java 2008-04-09 18:24:06 UTC (rev 3856) +++ trunk/daimonin/src/daieditor/gui/InsertionObjectChooser.java 2008-04-09 19:33:08 UTC (rev 3857) @@ -1,178 +0,0 @@ -/* - * 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 daieditor.gui; - -import daieditor.CMainControl; -import daieditor.CMapViewBasic; -import daieditor.gameobject.Archetype; -import daieditor.gameobject.GameObject; -import daieditor.gui.map.tools.ToolPalette; -import daieditor.map.MapArchObject; -import daieditor.map.MapControl; -import java.awt.BorderLayout; -import java.io.File; -import java.util.List; -import javax.swing.JSplitPane; -import javax.swing.JTabbedPane; -import javax.swing.SwingConstants; -import net.sf.gridarta.gui.AbstractInsertionObjectChooser; -import net.sf.gridarta.gui.GSplitPane; -import net.sf.gridarta.gui.ObjectChoiceDisplay; -import net.sf.gridarta.gui.archetypechooser.ArchetypeChooserControl; -import net.sf.gridarta.gui.archetypechooser.ArchetypeChooserListener; -import net.sf.gridarta.gui.newmap.NewMapDialogFactory; -import net.sf.gridarta.gui.pickmapchooser.PickmapChooserControl; -import net.sf.japi.swing.ActionFactory; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -/** - * The <code>InsertionObjectChooser</code> holds the tile palette. - * @author <a href="mailto:mic...@no...">Michael Toennies</a> - * @author <a href="mailto:and...@gm...">Andreas Vogl</a> - * @author <a href="mailto:ch...@ri...">Christian Hujer</a> - * @author Andreas Kirschbaum - */ -public final class InsertionObjectChooser extends AbstractInsertionObjectChooser<GameObject, MapArchObject, Archetype> implements net.sf.gridarta.gui.InsertionObjectChooser<GameObject, MapArchObject, Archetype> { - - /** Action Factory. */ - private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("daieditor"); - - /** Serial Version UID. */ - private static final long serialVersionUID = 1L; - - /** ToolSelector of this subview. */ - private final ToolPalette toolPalette; - - /** Panel holding both archlist and pickmaps. */ - private final JTabbedPane archAndPickPane = new JTabbedPane(SwingConstants.TOP); - - /** The data/view of selected objects in tab panel. */ - private final ObjectChoiceDisplay<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> objectChoiceDisplay; - - /** The pickmap chooser control. */ - private final PickmapChooserControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> pickmapChooserControl; - - /** The archetype chooser control. */ - private final ArchetypeChooserControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> archetypeChooserControl; - - /** - * Build Panel. - * @param newMapDialogFactory the factory for creating new pickmaps - * @param mainControl CMainControl - * @param pickmapDir the pickmaps directory - */ - public InsertionObjectChooser(@NotNull final NewMapDialogFactory<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> newMapDialogFactory, final CMainControl mainControl, @NotNull final File pickmapDir) { - pickmapChooserControl = new PickmapChooserControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(newMapDialogFactory, mainControl, this, pickmapDir); - archetypeChooserControl = new ArchetypeChooserControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(mainControl, true); - archetypeChooserControl.addArchetypeChooserListener(new ArchetypeChooserListener<GameObject, MapArchObject, Archetype>() { - /** {@inheritDoc} */ - public void selectedArchetypeChanged(@NotNull final GameObject archetype) { - showObjectChooserQuickObject(archetype); - } - - /** {@inheritDoc} */ - public void displayObjectNamesChanged(final boolean displayObjectNamesChanged) { - // ignore - } - }); - toolPalette = new ToolPalette(mainControl); - - objectChoiceDisplay = new ObjectChoiceDisplay<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(mainControl); - - // archAndPickPane is the panel containing both archpanel and pickmaps - archAndPickPane.addTab(ACTION_FACTORY.getString("objectChooser.archetypesTabTitle"), archetypeChooserControl.getArchetypePanel()); - archAndPickPane.addTab(ACTION_FACTORY.getString("objectChooser.pickmapsTabTitle"), pickmapChooserControl.getPickmapPanel()); - // this listener informs the mainview which panel is active: archlist or pickmaps? - pickmapChooserControl.addArchNPickChangeListener(archAndPickPane); - - // calculate default value in case there is no settings file - - - // TODO: introduce a tool registry - final JSplitPane splitPane = new GSplitPane(JSplitPane.VERTICAL_SPLIT, toolPalette, archAndPickPane); - splitPane.setContinuousLayout(true); - add(splitPane, BorderLayout.CENTER); - add(objectChoiceDisplay, BorderLayout.SOUTH); - } - - /** {@inheritDoc} */ - public void moveArchetypeChooserToFront() { - archAndPickPane.setSelectedIndex(0); - } - - /** {@inheritDoc} */ - public void movePickmapChooserToFront() { - archAndPickPane.setSelectedIndex(1); - } - - /** {@inheritDoc} */ - public void showObjectChooserQuickObject(@Nullable final GameObject gameObject) { - objectChoiceDisplay.showObjectChooserQuickObject(gameObject); - } - - public void appExitNotify() { - } - - /** {@inheritDoc} */ - @Nullable public GameObject getObjectChooserHighlight() { - return isPickmapActive() ? pickmapChooserControl.getSelection() : archetypeChooserControl.getSelection(); - } - - /** {@inheritDoc} */ - @NotNull public List<GameObject> getObjectChooserSelection() { - return isPickmapActive() ? pickmapChooserControl.getSelections() : archetypeChooserControl.getSelections(); - } - - /** - * Return the pickmap chooser control. - * - * @return the pickmap chooser control - */ - @NotNull public PickmapChooserControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> getPickmapChooserControl() { - return pickmapChooserControl; - } - - /** {@inheritDoc} */ - @NotNull public ArchetypeChooserControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> getArchetypeChooserControl() { - return archetypeChooserControl; - } - - /** {@inheritDoc} */ - public void setPickmapActive(final boolean pickmapActive) { - super.setPickmapActive(pickmapActive); - pickmapChooserControl.setActive(pickmapActive); - } - - /** - * Returns the tool selector pane. - * @return The tool selector pane. - */ - public ToolPalette getToolSelectorPane() { - return toolPalette; - } - - /** {@inheritDoc} */ - public void selectArchetype(final Archetype archetype) { - moveArchetypeChooserToFront(); - archetypeChooserControl.selectArchetype(archetype); - } - -} // class InsertionObjectChooser Copied: trunk/daimonin/src/daieditor/gui/ObjectChooser.java (from rev 3855, trunk/daimonin/src/daieditor/gui/InsertionObjectChooser.java) =================================================================== --- trunk/daimonin/src/daieditor/gui/ObjectChooser.java (rev 0) +++ trunk/daimonin/src/daieditor/gui/ObjectChooser.java 2008-04-09 19:33:08 UTC (rev 3857) @@ -0,0 +1,178 @@ +/* + * 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 daieditor.gui; + +import daieditor.CMainControl; +import daieditor.CMapViewBasic; +import daieditor.gameobject.Archetype; +import daieditor.gameobject.GameObject; +import daieditor.gui.map.tools.ToolPalette; +import daieditor.map.MapArchObject; +import daieditor.map.MapControl; +import java.awt.BorderLayout; +import java.io.File; +import java.util.List; +import javax.swing.JSplitPane; +import javax.swing.JTabbedPane; +import javax.swing.SwingConstants; +import net.sf.gridarta.gui.AbstractObjectChooser; +import net.sf.gridarta.gui.GSplitPane; +import net.sf.gridarta.gui.ObjectChoiceDisplay; +import net.sf.gridarta.gui.archetypechooser.ArchetypeChooserControl; +import net.sf.gridarta.gui.archetypechooser.ArchetypeChooserListener; +import net.sf.gridarta.gui.newmap.NewMapDialogFactory; +import net.sf.gridarta.gui.pickmapchooser.PickmapChooserControl; +import net.sf.japi.swing.ActionFactory; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * The <code>ObjectChooser</code> holds the tile palette. + * @author <a href="mailto:mic...@no...">Michael Toennies</a> + * @author <a href="mailto:and...@gm...">Andreas Vogl</a> + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + * @author Andreas Kirschbaum + */ +public final class ObjectChooser extends AbstractObjectChooser<GameObject, MapArchObject, Archetype> implements net.sf.gridarta.gui.ObjectChooser<GameObject, MapArchObject, Archetype> { + + /** Action Factory. */ + private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("daieditor"); + + /** Serial Version UID. */ + private static final long serialVersionUID = 1L; + + /** ToolSelector of this subview. */ + private final ToolPalette toolPalette; + + /** Panel holding both archlist and pickmaps. */ + private final JTabbedPane archAndPickPane = new JTabbedPane(SwingConstants.TOP); + + /** The data/view of selected objects in tab panel. */ + private final ObjectChoiceDisplay<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> objectChoiceDisplay; + + /** The pickmap chooser control. */ + private final PickmapChooserControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> pickmapChooserControl; + + /** The archetype chooser control. */ + private final ArchetypeChooserControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> archetypeChooserControl; + + /** + * Build Panel. + * @param newMapDialogFactory the factory for creating new pickmaps + * @param mainControl CMainControl + * @param pickmapDir the pickmaps directory + */ + public ObjectChooser(@NotNull final NewMapDialogFactory<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> newMapDialogFactory, final CMainControl mainControl, @NotNull final File pickmapDir) { + pickmapChooserControl = new PickmapChooserControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(newMapDialogFactory, mainControl, this, pickmapDir); + archetypeChooserControl = new ArchetypeChooserControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(mainControl, true); + archetypeChooserControl.addArchetypeChooserListener(new ArchetypeChooserListener<GameObject, MapArchObject, Archetype>() { + /** {@inheritDoc} */ + public void selectedArchetypeChanged(@NotNull final GameObject archetype) { + showObjectChooserQuickObject(archetype); + } + + /** {@inheritDoc} */ + public void displayObjectNamesChanged(final boolean displayObjectNamesChanged) { + // ignore + } + }); + toolPalette = new ToolPalette(mainControl); + + objectChoiceDisplay = new ObjectChoiceDisplay<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(mainControl); + + // archAndPickPane is the panel containing both archpanel and pickmaps + archAndPickPane.addTab(ACTION_FACTORY.getString("objectChooser.archetypesTabTitle"), archetypeChooserControl.getArchetypePanel()); + archAndPickPane.addTab(ACTION_FACTORY.getString("objectChooser.pickmapsTabTitle"), pickmapChooserControl.getPickmapPanel()); + // this listener informs the mainview which panel is active: archlist or pickmaps? + pickmapChooserControl.addArchNPickChangeListener(archAndPickPane); + + // calculate default value in case there is no settings file + + + // TODO: introduce a tool registry + final JSplitPane splitPane = new GSplitPane(JSplitPane.VERTICAL_SPLIT, toolPalette, archAndPickPane); + splitPane.setContinuousLayout(true); + add(splitPane, BorderLayout.CENTER); + add(objectChoiceDisplay, BorderLayout.SOUTH); + } + + /** {@inheritDoc} */ + public void moveArchetypeChooserToFront() { + archAndPickPane.setSelectedIndex(0); + } + + /** {@inheritDoc} */ + public void movePickmapChooserToFront() { + archAndPickPane.setSelectedIndex(1); + } + + /** {@inheritDoc} */ + public void showObjectChooserQuickObject(@Nullable final GameObject gameObject) { + objectChoiceDisplay.showObjectChooserQuickObject(gameObject); + } + + public void appExitNotify() { + } + + /** {@inheritDoc} */ + @Nullable public GameObject getObjectChooserHighlight() { + return isPickmapActive() ? pickmapChooserControl.getSelection() : archetypeChooserControl.getSelection(); + } + + /** {@inheritDoc} */ + @NotNull public List<GameObject> getObjectChooserSelection() { + return isPickmapActive() ? pickmapChooserControl.getSelections() : archetypeChooserControl.getSelections(); + } + + /** + * Return the pickmap chooser control. + * + * @return the pickmap chooser control + */ + @NotNull public PickmapChooserControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> getPickmapChooserControl() { + return pickmapChooserControl; + } + + /** {@inheritDoc} */ + @NotNull public ArchetypeChooserControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> getArchetypeChooserControl() { + return archetypeChooserControl; + } + + /** {@inheritDoc} */ + public void setPickmapActive(final boolean pickmapActive) { + super.setPickmapActive(pickmapActive); + pickmapChooserControl.setActive(pickmapActive); + } + + /** + * Returns the tool selector pane. + * @return The tool selector pane. + */ + public ToolPalette getToolSelectorPane() { + return toolPalette; + } + + /** {@inheritDoc} */ + public void selectArchetype(final Archetype archetype) { + moveArchetypeChooserToFront(); + archetypeChooserControl.selectArchetype(archetype); + } + +} // class ObjectChooser Deleted: trunk/src/app/net/sf/gridarta/gui/AbstractInsertionObjectChooser.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/AbstractInsertionObjectChooser.java 2008-04-09 18:24:06 UTC (rev 3856) +++ trunk/src/app/net/sf/gridarta/gui/AbstractInsertionObjectChooser.java 2008-04-09 19:33:08 UTC (rev 3857) @@ -1,68 +0,0 @@ -/* - * 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 java.awt.BorderLayout; -import javax.swing.JMenu; -import javax.swing.JPanel; -import net.sf.gridarta.gameobject.Archetype; -import net.sf.gridarta.gameobject.GameObject; -import net.sf.gridarta.map.MapArchObject; -import org.jetbrains.annotations.Nullable; - -/** - * Abstract base class for the Object Chooser. - * - * @author Andreas Kirschbaum - */ -public abstract class AbstractInsertionObjectChooser<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> extends JPanel implements InsertionObjectChooser<G, A, R> { - - /** - * <code>true</code> if the PickmapChooser is active, <code>false</code> if - * the Archetype Chooser is active. - */ - private boolean pickmapActive = false; - - /** - * Create a new instance. - */ - protected AbstractInsertionObjectChooser() { - super(new BorderLayout()); - } - - /** {@inheritDoc} */ - public void setPickmapActive(final boolean pickmapActive) { - this.pickmapActive = pickmapActive; - } - - /** {@inheritDoc} */ - public boolean isPickmapActive() { - return pickmapActive; - } - - /** - * Sets the pickmap folders menu to manage. - * @param folderMenu the pickmap folders menu - */ - public void setPickmapFoldersMenu(@Nullable final JMenu folderMenu) { - getPickmapChooserControl().setPickmapFoldersMenu(folderMenu); - } - -} // class AbstractInsertionObjectChooser Copied: trunk/src/app/net/sf/gridarta/gui/AbstractObjectChooser.java (from rev 3855, trunk/src/app/net/sf/gridarta/gui/AbstractInsertionObjectChooser.java) =================================================================== --- trunk/src/app/net/sf/gridarta/gui/AbstractObjectChooser.java (rev 0) +++ trunk/src/app/net/sf/gridarta/gui/AbstractObjectChooser.java 2008-04-09 19:33:08 UTC (rev 3857) @@ -0,0 +1,68 @@ +/* + * 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 java.awt.BorderLayout; +import javax.swing.JMenu; +import javax.swing.JPanel; +import net.sf.gridarta.gameobject.Archetype; +import net.sf.gridarta.gameobject.GameObject; +import net.sf.gridarta.map.MapArchObject; +import org.jetbrains.annotations.Nullable; + +/** + * Abstract base class for the Object Chooser. + * + * @author Andreas Kirschbaum + */ +public abstract class AbstractObjectChooser<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> extends JPanel implements ObjectChooser<G, A, R> { + + /** + * <code>true</code> if the PickmapChooser is active, <code>false</code> if + * the Archetype Chooser is active. + */ + private boolean pickmapActive = false; + + /** + * Create a new instance. + */ + protected AbstractObjectChooser() { + super(new BorderLayout()); + } + + /** {@inheritDoc} */ + public void setPickmapActive(final boolean pickmapActive) { + this.pickmapActive = pickmapActive; + } + + /** {@inheritDoc} */ + public boolean isPickmapActive() { + return pickmapActive; + } + + /** + * Sets the pickmap folders menu to manage. + * @param folderMenu the pickmap folders menu + */ + public void setPickmapFoldersMenu(@Nullable final JMenu folderMenu) { + getPickmapChooserControl().setPickmapFoldersMenu(folderMenu); + } + +} // class AbstractObjectChooser Modified: trunk/src/app/net/sf/gridarta/gui/ArchetypesActions.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/ArchetypesActions.java 2008-04-09 18:24:06 UTC (rev 3856) +++ trunk/src/app/net/sf/gridarta/gui/ArchetypesActions.java 2008-04-09 19:33:08 UTC (rev 3857) @@ -79,13 +79,13 @@ * @param archetypeSet The archetype set to search in the "find archetypes" * dialog. * - * @param insertionObjectChooser The insertion object chooser to use when - * selecting search results in the "find archetypes" dialog. + * @param objectChooser The insertion object chooser to use when selecting + * search results in the "find archetypes" dialog. * * @param archTypeList the instance for looking up archetype types */ - public ArchetypesActions(@NotNull final Component parent, @NotNull final ArchetypeChooserControl<G, A, R, C, V> archetypeChooserControl, @NotNull final ArchetypeSet<G, A, R> archetypeSet, @NotNull final InsertionObjectChooser<G, A, R> insertionObjectChooser, final CFArchTypeList archTypeList) { - findArchetypesDialog = new FindArchetypesDialog(parent, archetypeSet, insertionObjectChooser, archTypeList); + public ArchetypesActions(@NotNull final Component parent, @NotNull final ArchetypeChooserControl<G, A, R, C, V> archetypeChooserControl, @NotNull final ArchetypeSet<G, A, R> archetypeSet, @NotNull final ObjectChooser<G, A, R> objectChooser, final CFArchTypeList archTypeList) { + findArchetypesDialog = new FindArchetypesDialog(parent, archetypeSet, objectChooser, archTypeList); aDisplayObjectNames = (ToggleAction) ACTION_FACTORY.createToggle(true, "displayObjectNames", archetypeChooserControl); ACTION_FACTORY.createAction(true, "findArchetypes", findArchetypesDialog); archetypeChooserControl.addArchetypeChooserListener(archetypeChooserListener); Deleted: trunk/src/app/net/sf/gridarta/gui/InsertionObjectChooser.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/InsertionObjectChooser.java 2008-04-09 18:24:06 UTC (rev 3856) +++ trunk/src/app/net/sf/gridarta/gui/InsertionObjectChooser.java 2008-04-09 19:33:08 UTC (rev 3857) @@ -1,115 +0,0 @@ -/* - * 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 java.util.List; -import net.sf.gridarta.gameobject.Archetype; -import net.sf.gridarta.gameobject.GameObject; -import net.sf.gridarta.gui.archetypechooser.ArchetypeChooserControl; -import net.sf.gridarta.gui.map.MapViewBasic; -import net.sf.gridarta.gui.pickmapchooser.PickmapChooserControl; -import net.sf.gridarta.map.MapArchObject; -import net.sf.gridarta.map.MapControl; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -/** - * Common base interface for InsertionObjectChoosers. - * @author <a href="mailto:ch...@ri...">Christian Hujer</a> - */ -public interface InsertionObjectChooser<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> { - - /** - * Return if the Pickmap Chooser is active. - * - * @return <code>true</code> if the Pickmap Chooser is active, or - * <code>false</code> if the Archetype Chooser is active. - */ - boolean isPickmapActive(); - - /** - * Set whether the Pickmap Chooser is active. - * - * @param pickmapActive <code>true</code> if the Pickmap Chooser is active, - * <code>false</code> if the Archetype Chooser is active. - */ - void setPickmapActive(boolean pickmapActive); - - /** - * Show the given game object's attributes in the quick panel. - * - * @param gameObject the game object to show, or <code>null</code> to clear - * the attributes - */ - void showObjectChooserQuickObject(@Nullable G gameObject); - - /** - * Move the Archetype Chooser in front of the Pickmap Chooser. - */ - void moveArchetypeChooserToFront(); - - /** - * Move the Pickmap Chooser in front of the Archetype Chooser. - */ - void movePickmapChooserToFront(); - - /** - * Returns the active arch in the left-side panel. - * This can either be a default arch from the archlist, or - * a custom arch from a pickmap. - * IMPORTANT: The returned GameObject is not a clone. A copy - * must be generated before inserting such an arch to the map. - * @return the active arch in the left-side panel - */ - @Nullable G getObjectChooserHighlight(); - - /** - * Returns the selected arches in the left-side panel. - * This can either be default arches, or - * custom arches from a pickmap. - * IMPORTANT: The returned GameObject list contains no clone. A copy - * must be generated before inserting such arches to the map. - * @return the selected arches in the left-side panel - */ - @NotNull List<G> getObjectChooserSelection(); - - /** - * Return the pickmap chooser control. - * - * @return the pickmap chooser control - */ - @NotNull <C extends MapControl<G, A, R>, V extends MapViewBasic<G, A, R>> PickmapChooserControl<G, A, R, C, V> getPickmapChooserControl(); - - /** - * Select an archetype in the archetype chooser. If necessary, activates - * archetype chooser. - * - * @param archetype The archetype to selected. - */ - void selectArchetype(R archetype); - - /** - * Return the archetype chooser control. - * - * @return the archetype chooser control - */ - @NotNull <C extends MapControl<G, A, R>, V extends MapViewBasic<G, A, R>> ArchetypeChooserControl<G, A, R, C, V> getArchetypeChooserControl(); - -} // interface InsertionObjectChooser Modified: trunk/src/app/net/sf/gridarta/gui/MainView.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/MainView.java 2008-04-09 18:24:06 UTC (rev 3856) +++ trunk/src/app/net/sf/gridarta/gui/MainView.java 2008-04-09 19:33:08 UTC (rev 3857) @@ -188,7 +188,7 @@ * Return the insertion object chooser. * @return the insertion object chooser */ - public abstract InsertionObjectChooser<G, A, R> getObjectChooser(); + public abstract ObjectChooser<G, A, R> getObjectChooser(); /** * Sets the given level view as the current one. Copied: trunk/src/app/net/sf/gridarta/gui/ObjectChooser.java (from rev 3855, trunk/src/app/net/sf/gridarta/gui/InsertionObjectChooser.java) =================================================================== --- trunk/src/app/net/sf/gridarta/gui/ObjectChooser.java (rev 0) +++ trunk/src/app/net/sf/gridarta/gui/ObjectChooser.java 2008-04-09 19:33:08 UTC (rev 3857) @@ -0,0 +1,115 @@ +/* + * 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 java.util.List; +import net.sf.gridarta.gameobject.Archetype; +import net.sf.gridarta.gameobject.GameObject; +import net.sf.gridarta.gui.archetypechooser.ArchetypeChooserControl; +import net.sf.gridarta.gui.map.MapViewBasic; +import net.sf.gridarta.gui.pickmapchooser.PickmapChooserControl; +import net.sf.gridarta.map.MapArchObject; +import net.sf.gridarta.map.MapControl; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * Common base interface for ObjectChoosers. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + */ +public interface ObjectChooser<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> { + + /** + * Return if the Pickmap Chooser is active. + * + * @return <code>true</code> if the Pickmap Chooser is active, or + * <code>false</code> if the Archetype Chooser is active. + */ + boolean isPickmapActive(); + + /** + * Set whether the Pickmap Chooser is active. + * + * @param pickmapActive <code>true</code> if the Pickmap Chooser is active, + * <code>false</code> if the Archetype Chooser is active. + */ + void setPickmapActive(boolean pickmapActive); + + /** + * Show the given game object's attributes in the quick panel. + * + * @param gameObject the game object to show, or <code>null</code> to clear + * the attributes + */ + void showObjectChooserQuickObject(@Nullable G gameObject); + + /** + * Move the Archetype Chooser in front of the Pickmap Chooser. + */ + void moveArchetypeChooserToFront(); + + /** + * Move the Pickmap Chooser in front of the Archetype Chooser. + */ + void movePickmapChooserToFront(); + + /** + * Returns the active arch in the left-side panel. + * This can either be a default arch from the archlist, or + * a custom arch from a pickmap. + * IMPORTANT: The returned GameObject is not a clone. A copy + * must be generated before inserting such an arch to the map. + * @return the active arch in the left-side panel + */ + @Nullable G getObjectChooserHighlight(); + + /** + * Returns the selected arches in the left-side panel. + * This can either be default arches, or + * custom arches from a pickmap. + * IMPORTANT: The returned GameObject list contains no clone. A copy + * must be generated before inserting such arches to the map. + * @return the selected arches in the left-side panel + */ + @NotNull List<G> getObjectChooserSelection(); + + /** + * Return the pickmap chooser control. + * + * @return the pickmap chooser control + */ + @NotNull <C extends MapControl<G, A, R>, V extends MapViewBasic<G, A, R>> PickmapChooserControl<G, A, R, C, V> getPickmapChooserControl(); + + /** + * Select an archetype in the archetype chooser. If necessary, activates + * archetype chooser. + * + * @param archetype The archetype to selected. + */ + void selectArchetype(R archetype); + + /** + * Return the archetype chooser control. + * + * @return the archetype chooser control + */ + @NotNull <C extends MapControl<G, A, R>, V extends MapViewBasic<G, A, R>> ArchetypeChooserControl<G, A, R, C, V> getArchetypeChooserControl(); + +} // interface ObjectChooser Modified: trunk/src/app/net/sf/gridarta/gui/findarchetypes/FindArchetypesDialog.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/findarchetypes/FindArchetypesDialog.java 2008-04-09 18:24:06 UTC (rev 3856) +++ trunk/src/app/net/sf/gridarta/gui/findarchetypes/FindArchetypesDialog.java 2008-04-09 19:33:08 UTC (rev 3857) @@ -48,7 +48,7 @@ import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.ArchetypeSet; import net.sf.gridarta.gameobject.GameObject; -import net.sf.gridarta.gui.InsertionObjectChooser; +import net.sf.gridarta.gui.ObjectChooser; import net.sf.gridarta.gui.map.MapViewBasic; import net.sf.gridarta.map.MapArchObject; import net.sf.gridarta.map.MapControl; @@ -81,7 +81,7 @@ /** * The insertion object chooser to use when selecing search results. */ - private final InsertionObjectChooser<G, A, R> insertionObjectChooser; + private final ObjectChooser<G, A, R> objectChooser; /** * The name input field. @@ -149,14 +149,14 @@ * * @param archetypeSet The archetype set to search. * - * @param insertionObjectChooser The insertion object chooser to use whe... [truncated message content] |
From: <aki...@us...> - 2008-04-09 20:17:16
|
Revision: 3858 http://gridarta.svn.sourceforge.net/gridarta/?rev=3858&view=rev Author: akirschbaum Date: 2008-04-09 13:17:02 -0700 (Wed, 09 Apr 2008) Log Message: ----------- Move ObjectChooser creation into CMainControl. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/CMainView.java trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/CMainView.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-04-09 19:33:08 UTC (rev 3857) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-04-09 20:17:02 UTC (rev 3858) @@ -28,6 +28,7 @@ import cfeditor.gameobject.face.FaceObjects; import cfeditor.gameobject.scripts.ScriptArchData; import cfeditor.gui.GameObjectAttributesDialog; +import cfeditor.gui.ObjectChooser; import cfeditor.gui.prefs.GUIPrefs; import cfeditor.gui.prefs.ResPrefs; import cfeditor.map.MapArchObject; @@ -149,6 +150,9 @@ private final MapActions mapActions; + /** The object chooser. */ + private final ObjectChooser objectChooser; + /** The main view. */ private final CMainView mainView; @@ -246,14 +250,14 @@ ACTION_FACTORY.createActions(true, this, "createNew", "open", "options", "exit", "gc", "onlineHelp", "tod", "about"); mapManagerActions = new MapManagerActions<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(getMapManager()); mapActions = new MapActions(this, getMapManager()); - mainView = new CMainView(this, getMapManager(), ACTION_FACTORY, mapManagerActions.getCloseAllAction()); + readGlobalSettings(); + objectChooser = new ObjectChooser(newMapDialogFactory, this, new File(mapDir, IGUIConstants.PICKMAP_DIR)); + mainView = new CMainView(this, objectChooser, getMapManager(), ACTION_FACTORY, mapManagerActions.getCloseAllAction()); new About("cfeditor", mainView); undoControl = new UndoControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(getMapManager()); updaterManager = new UpdaterManager("cfeditor", this, mainView, "CrossfireEditor.jar"); updaterManager.startup(); - readGlobalSettings(); - SystemIcons.init(); createMapImageCache(CResourceLoader.getHomeFile("thumbnails"), SystemIcons.getDefaultIcon(), SystemIcons.getDefaultPreview()); @@ -286,7 +290,7 @@ gameObjectSpells.sort(); // Initialize the main view - mainView.init(newMapDialogFactory, null, new LockedItemsControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(getMapManager(), 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), new File(mapDir, IGUIConstants.PICKMAP_DIR), typeList); + mainView.init(null, new LockedItemsControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(getMapManager(), 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), typeList); mapActions.updateMenuState(); scriptControl.getView().setMenu((JMenu) ACTION_FACTORY.find(mainView.getJMenuBar(), "plugins")); archetypeParser = new ArchetypeParser(this, mainView.getObjectChooser().getArchetypeChooserControl()); Modified: trunk/crossfire/src/cfeditor/CMainView.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainView.java 2008-04-09 19:33:08 UTC (rev 3857) +++ trunk/crossfire/src/cfeditor/CMainView.java 2008-04-09 20:17:02 UTC (rev 3858) @@ -55,7 +55,6 @@ import net.sf.gridarta.gui.connectionview.LockedItemsControl; import net.sf.gridarta.gui.map.MapView; import net.sf.gridarta.gui.map.ViewActions; -import net.sf.gridarta.gui.newmap.NewMapDialogFactory; import net.sf.gridarta.gui.selectedsquare.SelectedSquareControl; import net.sf.japi.swing.ActionFactory; import org.apache.log4j.Logger; @@ -141,13 +140,15 @@ /** * Constructs the main view and registers the given main controller. * @param mainControl MainControl to attach to. + * @param objectChooser the object chooser * @param mapManager the map manager * @param actionFactory the action factory to use * @param aCloseAll the action "close all map windows" */ - CMainView(@NotNull final CMainControl mainControl, @NotNull final MapManager<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> mapManager, @NotNull final ActionFactory actionFactory, @NotNull final Action aCloseAll) { + CMainView(@NotNull final CMainControl mainControl, @NotNull final ObjectChooser objectChooser, @NotNull final MapManager<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> mapManager, @NotNull final ActionFactory actionFactory, @NotNull final Action aCloseAll) { super(mainControl, mapManager, actionFactory.format("mainWindow.title", CMainControl.getBuildNumberAsString())); this.mainControl = mainControl; + this.objectChooser = objectChooser; this.actionFactory = actionFactory; aViewTreasurelists = actionFactory.createAction(true, "viewTreasurelists", mainControl); this.aCloseAll = aCloseAll; @@ -166,14 +167,12 @@ /** * Initializes (builds) this view. - * @param newMapDialogFactory the factory for creating new pickmaps * @param compassIcon If non-<code>null</code>, display this icon on the * top of the list * @param lockedItemsControl the locked items control - * @param pickmapDir the pickmaps directory * @param archTypeList the instance for looking up archetype types */ - void init(@NotNull final NewMapDialogFactory<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> newMapDialogFactory, @Nullable final ImageIcon compassIcon, @NotNull final LockedItemsControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> lockedItemsControl, @NotNull final File pickmapDir, final CFArchTypeList archTypeList) { + void init(@Nullable final ImageIcon compassIcon, @NotNull final LockedItemsControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> lockedItemsControl, final CFArchTypeList archTypeList) { // calculate some default values in case there is no settings file final Rectangle screen = getGraphicsConfiguration().getBounds(); final int defwidth = (int) (0.9 * screen.getWidth()); @@ -183,7 +182,7 @@ final JPanel toolbarPanel = new JPanel(new BorderLayout()); toolbarPanel.add(mainToolbar, BorderLayout.NORTH); - toolbarPanel.add(createCenterPanel(defwidth, defheight, newMapDialogFactory, compassIcon, lockedItemsControl, pickmapDir), BorderLayout.CENTER); + toolbarPanel.add(createCenterPanel(defwidth, defheight, compassIcon, lockedItemsControl), BorderLayout.CENTER); add(toolbarPanel, BorderLayout.CENTER); archetypesActions = new ArchetypesActions<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(this, objectChooser.getArchetypeChooserControl(), mainControl.getArchetypeSet(), objectChooser, archTypeList); @@ -216,21 +215,18 @@ * Create the center panel. * @param defwidth default width * @param defheight default height - * @param newMapDialogFactory the factory for creating new pickmaps * @param compassIcon If non-<code>null</code>, display this icon on the * top of the list * @param lockedItemsControl the locked items control - * @param pickmapDir the pickmaps directory * @return center panel */ - private JPanel createCenterPanel(final int defwidth, final int defheight, @NotNull final NewMapDialogFactory<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> newMapDialogFactory, @Nullable final ImageIcon compassIcon, @NotNull final LockedItemsControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> lockedItemsControl, @NotNull final File pickmapDir) { + private JPanel createCenterPanel(final int defwidth, final int defheight, @Nullable final ImageIcon compassIcon, @NotNull final LockedItemsControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> lockedItemsControl) { final JPanel centerPanel = new JPanel(new BorderLayout()); final int divLocationRight = prefs.getInt(DIVIDER_LOCATION_KEY3, (int) (defwidth * 0.62)); final int divLocationDown = prefs.getInt(DIVIDER_LOCATION_KEY2, (int) (defheight * 0.76)); final int divLocation = prefs.getInt(DIVIDER_LOCATION_KEY, (int) (defwidth * 0.17)); - objectChooser = new ObjectChooser(newMapDialogFactory, mainControl, pickmapDir); final boolean mapTileListBottom = prefs.getBoolean(MainView.MAP_TILE_LIST_BOTTOM_KEY, CMainView.MAP_TILE_LIST_BOTTOM_DEFAULT); selectedSquareControl = new SelectedSquareControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(actionFactory, mainControl, this, mapTileListBottom, compassIcon); gameObjectAttributesPanel = new GameObjectAttributesPanel(mainControl, mapManager, this, lockedItemsControl); Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-04-09 19:33:08 UTC (rev 3857) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-04-09 20:17:02 UTC (rev 3858) @@ -26,6 +26,7 @@ import daieditor.gameobject.anim.AnimationObjects; import daieditor.gameobject.face.FaceObjects; import daieditor.gui.GameObjectAttributesDialog; +import daieditor.gui.ObjectChooser; import daieditor.gui.prefs.AppPrefs; import daieditor.gui.prefs.DevPrefs; import daieditor.gui.prefs.GUIPrefs; @@ -186,6 +187,9 @@ private final MapActions mapActions; + /** The object chooser. */ + private final ObjectChooser objectChooser; + /** The main view. */ private final CMainView mainView; @@ -299,14 +303,14 @@ aCollectSpells = ACTION_FACTORY.createAction(true, "collectSpells", this); mapManagerActions = new MapManagerActions<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(getMapManager()); mapActions = new MapActions(this, getMapManager()); - mainView = new CMainView(this, getMapManager(), ACTION_FACTORY, mapManagerActions.getCloseAllAction()); + readGlobalSettings(); + objectChooser = new ObjectChooser(newMapDialogFactory, this, new File(strArchDir, IGUIConstants.PICKMAP_DIR)); + mainView = new CMainView(this, objectChooser, getMapManager(), ACTION_FACTORY, mapManagerActions.getCloseAllAction()); new About("daieditor", mainView); undoControl = new UndoControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(getMapManager()); updaterManager = new UpdaterManager("daieditor", this, mainView, "DaimoninEditor.jar"); updaterManager.startup(); - readGlobalSettings(); - SystemIcons.init(); createMapImageCache(null, SystemIcons.getDefaultIcon(), SystemIcons.getDefaultPreview()); @@ -341,7 +345,7 @@ numberSpells.sort(); // Initialize the main view - mainView.init(newMapDialogFactory, GUIUtils.getSysIcon(IGUIConstants.TILE_NORTH), new LockedItemsControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(getMapManager(), 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), new File(strArchDir, IGUIConstants.PICKMAP_DIR), typeList); + mainView.init(GUIUtils.getSysIcon(IGUIConstants.TILE_NORTH), new LockedItemsControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(getMapManager(), 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), typeList); mapActions.updateMenuState(); archetypeParser = new ArchetypeParser(this, mainView.getObjectChooser().getArchetypeChooserControl()); animationObjects = new AnimationObjects(); Modified: trunk/daimonin/src/daieditor/CMainView.java =================================================================== --- trunk/daimonin/src/daieditor/CMainView.java 2008-04-09 19:33:08 UTC (rev 3857) +++ trunk/daimonin/src/daieditor/CMainView.java 2008-04-09 20:17:02 UTC (rev 3858) @@ -55,7 +55,6 @@ import net.sf.gridarta.gui.connectionview.LockedItemsControl; import net.sf.gridarta.gui.map.MapView; import net.sf.gridarta.gui.map.ViewActions; -import net.sf.gridarta.gui.newmap.NewMapDialogFactory; import net.sf.gridarta.gui.selectedsquare.SelectedSquareControl; import net.sf.japi.swing.ActionFactory; import org.apache.log4j.Logger; @@ -141,13 +140,15 @@ /** * Constructs the main view and registers the given main controller. * @param mainControl MainControl to attach to. + * @param objectChooser the object chooser * @param mapManager the map manager * @param actionFactory the action factory to use * @param aCloseAll the action "close all map windows" */ - CMainView(@NotNull final CMainControl mainControl, @NotNull final MapManager<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> mapManager, @NotNull final ActionFactory actionFactory, @NotNull final Action aCloseAll) { + CMainView(@NotNull final CMainControl mainControl, @NotNull final ObjectChooser objectChooser, @NotNull final MapManager<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> mapManager, @NotNull final ActionFactory actionFactory, @NotNull final Action aCloseAll) { super(mainControl, mapManager, actionFactory.format("mainWindow.title", CMainControl.getBuildNumberAsString())); this.mainControl = mainControl; + this.objectChooser = objectChooser; this.actionFactory = actionFactory; aViewTreasurelists = actionFactory.createAction(true, "viewTreasurelists", mainControl); this.aCloseAll = aCloseAll; @@ -166,14 +167,12 @@ /** * Initializes (builds) this view. - * @param newMapDialogFactory the factory for creating new pickmaps * @param compassIcon If non-<code>null</code>, display this icon on the * top of the list * @param lockedItemsControl the locked items control - * @param pickmapDir the pickmaps directory * @param archTypeList the instance for looking up archetype types */ - void init(@NotNull final NewMapDialogFactory<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> newMapDialogFactory, @Nullable final ImageIcon compassIcon, @NotNull final LockedItemsControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> lockedItemsControl, @NotNull final File pickmapDir, final CFArchTypeList archTypeList) { + void init(@Nullable final ImageIcon compassIcon, @NotNull final LockedItemsControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> lockedItemsControl, final CFArchTypeList archTypeList) { // calculate some default values in case there is no settings file final Rectangle screen = getGraphicsConfiguration().getBounds(); final int defwidth = (int) (0.9 * screen.getWidth()); @@ -183,7 +182,7 @@ final JPanel toolbarPanel = new JPanel(new BorderLayout()); toolbarPanel.add(mainToolbar, BorderLayout.NORTH); - toolbarPanel.add(createCenterPanel(defwidth, defheight, newMapDialogFactory, compassIcon, lockedItemsControl, pickmapDir), BorderLayout.CENTER); + toolbarPanel.add(createCenterPanel(defwidth, defheight, compassIcon, lockedItemsControl), BorderLayout.CENTER); add(toolbarPanel, BorderLayout.CENTER); archetypesActions = new ArchetypesActions<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(this, objectChooser.getArchetypeChooserControl(), mainControl.getArchetypeSet(), objectChooser, archTypeList); @@ -216,21 +215,18 @@ * Create the center panel. * @param defwidth default width * @param defheight default height - * @param newMapDialogFactory the factory for creating new pickmaps * @param compassIcon If non-<code>null</code>, display this icon on the * top of the list * @param lockedItemsControl the locked items control - * @param pickmapDir the pickmaps directory * @return center panel */ - private JPanel createCenterPanel(final int defwidth, final int defheight, @NotNull final NewMapDialogFactory<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> newMapDialogFactory, @Nullable final ImageIcon compassIcon, @NotNull final LockedItemsControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> lockedItemsControl, @NotNull final File pickmapDir) { + private JPanel createCenterPanel(final int defwidth, final int defheight, @Nullable final ImageIcon compassIcon, @NotNull final LockedItemsControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> lockedItemsControl) { final JPanel centerPanel = new JPanel(new BorderLayout()); final int divLocationRight = prefs.getInt(DIVIDER_LOCATION_KEY3, (int) (defwidth * 0.62)); final int divLocationDown = prefs.getInt(DIVIDER_LOCATION_KEY2, (int) (defheight * 0.76)); final int divLocation = prefs.getInt(DIVIDER_LOCATION_KEY, (int) (defwidth * 0.17)); - objectChooser = new ObjectChooser(newMapDialogFactory, mainControl, pickmapDir); final boolean mapTileListBottom = prefs.getBoolean(MainView.MAP_TILE_LIST_BOTTOM_KEY, CMainView.MAP_TILE_LIST_BOTTOM_DEFAULT); selectedSquareControl = new SelectedSquareControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(actionFactory, mainControl, this, mapTileListBottom, compassIcon); gameObjectAttributesPanel = new GameObjectAttributesPanel(mainControl, mapManager, this, lockedItemsControl); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-04-09 20:34:26
|
Revision: 3859 http://gridarta.svn.sourceforge.net/gridarta/?rev=3859&view=rev Author: akirschbaum Date: 2008-04-09 13:32:58 -0700 (Wed, 09 Apr 2008) Log Message: ----------- Move getObjectChooser() from MainView to MainControl. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/CMainView.java trunk/crossfire/src/cfeditor/CMapViewBasic.java trunk/crossfire/src/cfeditor/gui/script/parameter/ArchComboBox.java trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/gui/map/tools/SelectionTool.java trunk/src/app/net/sf/gridarta/CopyBuffer.java trunk/src/app/net/sf/gridarta/MainControl.java trunk/src/app/net/sf/gridarta/gui/GameObjectAttributesPanel.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/ObjectChoiceDisplay.java trunk/src/app/net/sf/gridarta/gui/ReplaceDialog.java trunk/src/app/net/sf/gridarta/gui/newmap/NewPickmapDialog.java trunk/src/app/net/sf/gridarta/gui/selectedsquare/SelectedSquareControl.java trunk/src/app/net/sf/gridarta/map/AbstractMapControl.java trunk/src/app/net/sf/gridarta/map/DefaultMapModel.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-04-09 20:17:02 UTC (rev 3858) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-04-09 20:32:58 UTC (rev 3859) @@ -293,7 +293,7 @@ mainView.init(null, new LockedItemsControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(getMapManager(), 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), typeList); mapActions.updateMenuState(); scriptControl.getView().setMenu((JMenu) ACTION_FACTORY.find(mainView.getJMenuBar(), "plugins")); - archetypeParser = new ArchetypeParser(this, mainView.getObjectChooser().getArchetypeChooserControl()); + archetypeParser = new ArchetypeParser(this, objectChooser.getArchetypeChooserControl()); animationObjects = new AnimationObjects(); faceObjects = new FaceObjects(); archetypeSet.loadArchetypes(archetypeParser); @@ -330,7 +330,7 @@ scriptControl.loadScripts(new File(getMapDir(), IGUIConstants.SCRIPTS_DIR)); mainView.setStatusText("Sorting..."); - mainView.getObjectChooser().getArchetypeChooserControl().finishBuildProcess(); + objectChooser.getArchetypeChooserControl().finishBuildProcess(); // load the autojoin lists mainView.setStatusText("Loading Autojoin Tables..."); @@ -345,7 +345,7 @@ log.info("Arch loading took " + (System.currentTimeMillis() - timeStart) / 1000.0 + " Seconds"); } - mainView.getObjectChooser().getPickmapChooserControl().loadPickmaps(true); + objectChooser.getPickmapChooserControl().loadPickmaps(true); } Map<String, TreasureTreeNode> specialTreasureLists; try { @@ -842,7 +842,7 @@ /** Invoked when user wants to exit from the program. */ public void exit() { - if (ScriptEditControl.getInstance().closeAllTabs() && getMapManager().closeAll() && mainView.getObjectChooser().getPickmapChooserControl().canExit() && scriptControl.canExit()) { + if (ScriptEditControl.getInstance().closeAllTabs() && getMapManager().closeAll() && objectChooser.getPickmapChooserControl().canExit() && scriptControl.canExit()) { doExit(); } } @@ -977,4 +977,9 @@ return mapActions.isAutoJoin(); } + /** {@inheritDoc} */ + public ObjectChooser getObjectChooser() { + return objectChooser; + } + } // class CMainControl Modified: trunk/crossfire/src/cfeditor/CMainView.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainView.java 2008-04-09 20:17:02 UTC (rev 3858) +++ trunk/crossfire/src/cfeditor/CMainView.java 2008-04-09 20:32:58 UTC (rev 3859) @@ -450,11 +450,6 @@ return selectedSquareControl; } - /** {@inheritDoc} */ - public ObjectChooser getObjectChooser() { - return objectChooser; - } - /** * Returns the current top map view we are working with. * @return the current top map view we are working with, or Modified: trunk/crossfire/src/cfeditor/CMapViewBasic.java =================================================================== --- trunk/crossfire/src/cfeditor/CMapViewBasic.java 2008-04-09 20:17:02 UTC (rev 3858) +++ trunk/crossfire/src/cfeditor/CMapViewBasic.java 2008-04-09 20:32:58 UTC (rev 3859) @@ -121,7 +121,7 @@ getViewport().setViewPosition(initial); } - mapUserListener = new MapUserListener(mainControl, mapControl, this, mainControl.getMainView().getObjectChooser(), mainControl.getMainView().getSelectedSquareControl().getSelectedSquareView(), mainControl.getMainView().getObjectChooser().getPickmapChooserControl()); + mapUserListener = new MapUserListener(mainControl, mapControl, this, mainControl.getObjectChooser(), mainControl.getMainView().getSelectedSquareControl().getSelectedSquareView(), mainControl.getObjectChooser().getPickmapChooserControl()); renderer.addMouseListener(mapUserListener); renderer.addMouseMotionListener(mapUserListener); renderer.setErroneousMapSquares(erroneousMapSquares); Modified: trunk/crossfire/src/cfeditor/gui/script/parameter/ArchComboBox.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/script/parameter/ArchComboBox.java 2008-04-09 20:17:02 UTC (rev 3858) +++ trunk/crossfire/src/cfeditor/gui/script/parameter/ArchComboBox.java 2008-04-09 20:32:58 UTC (rev 3859) @@ -133,7 +133,7 @@ fromSelect.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent e) { try { - final Archetype ao = archComboBoxModel.getNearsetMatch(mainControl.getMainView().getObjectChooser().getObjectChooserHighlight().getArchetypeName()); + final Archetype ao = archComboBoxModel.getNearsetMatch(mainControl.getObjectChooser().getObjectChooserHighlight().getArchetypeName()); setSelectedItem(ao); setItem(ao); } catch (final Exception ex) {//null pointer exception Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-04-09 20:17:02 UTC (rev 3858) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-04-09 20:32:58 UTC (rev 3859) @@ -347,7 +347,7 @@ // Initialize the main view mainView.init(GUIUtils.getSysIcon(IGUIConstants.TILE_NORTH), new LockedItemsControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(getMapManager(), 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), typeList); mapActions.updateMenuState(); - archetypeParser = new ArchetypeParser(this, mainView.getObjectChooser().getArchetypeChooserControl()); + archetypeParser = new ArchetypeParser(this, objectChooser.getArchetypeChooserControl()); animationObjects = new AnimationObjects(); faceObjects = new FaceObjects(); archetypeSet.loadArchetypes(archetypeParser); @@ -398,7 +398,7 @@ // load object from a arch file you found mainView.setStatusText("Sorting..."); - mainView.getObjectChooser().getArchetypeChooserControl().finishBuildProcess(); + objectChooser.getArchetypeChooserControl().finishBuildProcess(); // load the autojoin lists mainView.setStatusText("Loading Autojoin Tables..."); @@ -413,7 +413,7 @@ log.info("Arch loading took " + (System.currentTimeMillis() - timeStart) / 1000.0 + " Seconds"); } - mainView.getObjectChooser().getPickmapChooserControl().loadPickmaps(true); + objectChooser.getPickmapChooserControl().loadPickmaps(true); } Map<String, TreasureTreeNode> specialTreasureLists; try { @@ -1009,7 +1009,7 @@ /** Invoked when user wants to exit from the program. */ public void exit() { - if (ScriptEditControl.getInstance().closeAllTabs() && getMapManager().closeAll() && mainView.getObjectChooser().getPickmapChooserControl().canExit()) { + if (ScriptEditControl.getInstance().closeAllTabs() && getMapManager().closeAll() && objectChooser.getPickmapChooserControl().canExit()) { doExit(); } } @@ -1136,4 +1136,9 @@ return mapActions.isAutoJoin(); } + /** {@inheritDoc} */ + public ObjectChooser getObjectChooser() { + return objectChooser; + } + } // class CMainControl Modified: trunk/daimonin/src/daieditor/gui/map/tools/SelectionTool.java =================================================================== --- trunk/daimonin/src/daieditor/gui/map/tools/SelectionTool.java 2008-04-09 20:17:02 UTC (rev 3858) +++ trunk/daimonin/src/daieditor/gui/map/tools/SelectionTool.java 2008-04-09 20:32:58 UTC (rev 3859) @@ -56,7 +56,7 @@ mapCursor.dragStart(); if (mapCursor.isActive() && mapControl.isPickmap()) { // an arch of a pickmap was selected - AbstractMainControl.getInstance().getMainView().getObjectChooser().showObjectChooserQuickObject(mapControl.getMapModel().getMapSquare(mapLoc).getFirst()); + AbstractMainControl.getInstance().getObjectChooser().showObjectChooserQuickObject(mapControl.getMapModel().getMapSquare(mapLoc).getFirst()); } mapCursor.endTransaction(); // Change edit menu if there was a selection before and has gone or the other way around Modified: trunk/src/app/net/sf/gridarta/CopyBuffer.java =================================================================== --- trunk/src/app/net/sf/gridarta/CopyBuffer.java 2008-04-09 20:17:02 UTC (rev 3858) +++ trunk/src/app/net/sf/gridarta/CopyBuffer.java 2008-04-09 20:32:58 UTC (rev 3859) @@ -236,7 +236,7 @@ final List<G> archList; if (seed == null) { - archList = mainControl.getMainView().getObjectChooser().getObjectChooserSelection(); + archList = mainControl.getObjectChooser().getObjectChooserSelection(); } else { archList = seed.getSelectedGameObjects(); } @@ -272,7 +272,7 @@ return; } - final List<G> archList = mainControl.getMainView().getObjectChooser().getObjectChooserSelection(); + final List<G> archList = mainControl.getObjectChooser().getObjectChooserSelection(); if (archList.isEmpty()) { return; } Modified: trunk/src/app/net/sf/gridarta/MainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/MainControl.java 2008-04-09 20:17:02 UTC (rev 3858) +++ trunk/src/app/net/sf/gridarta/MainControl.java 2008-04-09 20:32:58 UTC (rev 3859) @@ -29,6 +29,7 @@ import net.sf.gridarta.gameobject.anim.AbstractAnimationObjects; import net.sf.gridarta.gameobject.face.AbstractFaceObjects; import net.sf.gridarta.gui.MainView; +import net.sf.gridarta.gui.ObjectChooser; import net.sf.gridarta.gui.RecentManager; import net.sf.gridarta.gui.map.MapPreviewAccessory; import net.sf.gridarta.gui.map.MapView; @@ -313,4 +314,10 @@ */ boolean isAutoJoin(); + /** + * Return the insertion object chooser. + * @return the insertion object chooser + */ + ObjectChooser<G, A, R> getObjectChooser(); + } // interface MainControl Modified: trunk/src/app/net/sf/gridarta/gui/GameObjectAttributesPanel.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/GameObjectAttributesPanel.java 2008-04-09 20:17:02 UTC (rev 3858) +++ trunk/src/app/net/sf/gridarta/gui/GameObjectAttributesPanel.java 2008-04-09 20:32:58 UTC (rev 3859) @@ -669,7 +669,7 @@ * Action method for adding an object to the inventory of the currently selected object. */ @ActionMethod public void mapArchAddInv() { - final G arch = mainControl.getMainView().getObjectChooser().getObjectChooserHighlight(); + final G arch = mainControl.getObjectChooser().getObjectChooserHighlight(); if (arch == null) { // nothing selected? return; } Modified: trunk/src/app/net/sf/gridarta/gui/MainActions.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/MainActions.java 2008-04-09 20:17:02 UTC (rev 3858) +++ trunk/src/app/net/sf/gridarta/gui/MainActions.java 2008-04-09 20:32:58 UTC (rev 3859) @@ -462,7 +462,7 @@ */ private void fillRandomWanted(@NotNull final MapView<G, A, R, C, V> mapView, final boolean fillBelow) { final StringBuilder title = new StringBuilder(fillBelow ? "Random fill below " : "Random fill above "); - final G arch = mainControl.getMainView().getObjectChooser().getObjectChooserHighlight(); + final G arch = mainControl.getObjectChooser().getObjectChooserHighlight(); C pickmap = null; /* if we have a single arch, use it as random seed. @@ -473,7 +473,7 @@ if (arch != null) { title.append("with arch ").append(arch.getArchetypeName()); } else { - pickmap = (C) mainControl.getMainView().getObjectChooser().getPickmapChooserControl().getCurrentPickmap(); + pickmap = (C) mainControl.getObjectChooser().getPickmapChooserControl().getCurrentPickmap(); if (pickmap != null) { title.append("with pickmap ").append(pickmap.getMapModel().getMapArchObject().getMapName()); } else { // ok ,we have a problem here: arch == null, pickmap == null... Modified: trunk/src/app/net/sf/gridarta/gui/MainView.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/MainView.java 2008-04-09 20:17:02 UTC (rev 3858) +++ trunk/src/app/net/sf/gridarta/gui/MainView.java 2008-04-09 20:32:58 UTC (rev 3859) @@ -185,12 +185,6 @@ } /** - * Return the insertion object chooser. - * @return the insertion object chooser - */ - public abstract ObjectChooser<G, A, R> getObjectChooser(); - - /** * Sets the given level view as the current one. * @param view0 The new current level view. */ Modified: trunk/src/app/net/sf/gridarta/gui/ObjectChoiceDisplay.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/ObjectChoiceDisplay.java 2008-04-09 20:17:02 UTC (rev 3858) +++ trunk/src/app/net/sf/gridarta/gui/ObjectChoiceDisplay.java 2008-04-09 20:32:58 UTC (rev 3859) @@ -93,7 +93,7 @@ * Sets the archObjNameText when the gameObject is null. */ private void setArchObjNameTextNull() { - if (mainControl.getMainView().getObjectChooser().isPickmapActive()) { + if (mainControl.getObjectChooser().isPickmapActive()) { archObjNameText.setText(" -random pick- "); archObjNameText.setForeground(Color.BLUE); } else { Modified: trunk/src/app/net/sf/gridarta/gui/ReplaceDialog.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/ReplaceDialog.java 2008-04-09 20:17:02 UTC (rev 3858) +++ trunk/src/app/net/sf/gridarta/gui/ReplaceDialog.java 2008-04-09 20:32:58 UTC (rev 3859) @@ -137,8 +137,8 @@ * @param mapView map view of the active map where the action was invoked */ public void display(final MapView<G, A, R, C, V> mapView) { - replaceArch = mainControl.getMainView().getObjectChooser().getObjectChooserHighlight(); // highlighted arch - replacePickmap = mainControl.getMainView().getObjectChooser().getObjectChooserSelection(); // selected arches + replaceArch = mainControl.getObjectChooser().getObjectChooserHighlight(); // highlighted arch + replacePickmap = mainControl.getObjectChooser().getObjectChooserSelection(); // selected arches replaceCopyBuffer = mainControl.getCopyBuffer().getCopyMapCtrl().getAllGameObjects(); if (!isBuilt) { @@ -403,7 +403,7 @@ switch (selectedIndex) { case 0: // replace with arch - replaceArch = mainControl.getMainView().getObjectChooser().getObjectChooserHighlight(); // selected arch + replaceArch = mainControl.getObjectChooser().getObjectChooserHighlight(); // selected arch updateArchSelection(replaceArch, true); break; @@ -419,7 +419,7 @@ case 2: // replace with pickmap - replacePickmap = mainControl.getMainView().getObjectChooser().getObjectChooserSelection(); // selected arches + replacePickmap = mainControl.getObjectChooser().getObjectChooserSelection(); // selected arches iconLabel.setIcon(null); size = replacePickmap.size(); rfArchName.setText(String.valueOf(size)); Modified: trunk/src/app/net/sf/gridarta/gui/newmap/NewPickmapDialog.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/newmap/NewPickmapDialog.java 2008-04-09 20:17:02 UTC (rev 3858) +++ trunk/src/app/net/sf/gridarta/gui/newmap/NewPickmapDialog.java 2008-04-09 20:32:58 UTC (rev 3859) @@ -104,7 +104,7 @@ mapArchObject.setMapName(mapName); - return mainControl.getMainView().getObjectChooser().getPickmapChooserControl().addNewPickmap(this, mapArchObject, mapName); + return mainControl.getObjectChooser().getPickmapChooserControl().addNewPickmap(this, mapArchObject, mapName); } } // class NewPickmapDialog Modified: trunk/src/app/net/sf/gridarta/gui/selectedsquare/SelectedSquareControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/selectedsquare/SelectedSquareControl.java 2008-04-09 20:17:02 UTC (rev 3858) +++ trunk/src/app/net/sf/gridarta/gui/selectedsquare/SelectedSquareControl.java 2008-04-09 20:32:58 UTC (rev 3859) @@ -214,7 +214,7 @@ * @param index the list index to insert at */ public void insertGameObjectFromObjectChooser(final int index) { - final G gameObject = mainControl.getMainView().getObjectChooser().getObjectChooserHighlight(); + final G gameObject = mainControl.getObjectChooser().getObjectChooserHighlight(); if (gameObject == null) { return; } Modified: trunk/src/app/net/sf/gridarta/map/AbstractMapControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/map/AbstractMapControl.java 2008-04-09 20:17:02 UTC (rev 3858) +++ trunk/src/app/net/sf/gridarta/map/AbstractMapControl.java 2008-04-09 20:32:58 UTC (rev 3859) @@ -241,14 +241,14 @@ // this is the arch that would get inserted from pickmap, but it also could // be a default arch (when pickmap has no selection) - final MapControl<G, A, R> activePickmap = mainControl.getMainView().getObjectChooser().getPickmapChooserControl().getCurrentPickmap(); + final MapControl<G, A, R> activePickmap = mainControl.getObjectChooser().getPickmapChooserControl().getCurrentPickmap(); G newarch = activePickmap == null ? null : activePickmap.getMapViewFrame().getSelectedGameObject(); final G newObject; - if (!mainControl.getMainView().getObjectChooser().isPickmapActive() || isPickmap() || (newarch != null && newarch.isArchetype())) { + if (!mainControl.getObjectChooser().isPickmapActive() || isPickmap() || (newarch != null && newarch.isArchetype())) { // insert default arch from archlist: mapModel.beginTransaction("Insert"); // TODO: I18N/L10N - newObject = mapModel.addArchToMap(mainControl.getMainView().getObjectChooser().getArchetypeChooserControl().getSelectedArch(), pos, allowMany, true, false); + newObject = mapModel.addArchToMap(mainControl.getObjectChooser().getArchetypeChooserControl().getSelectedArch(), pos, allowMany, true, false); mapModel.endTransaction(); } else { // insert custom arch from the pickmap: @@ -522,7 +522,7 @@ * to find out its original a pickmap we check the file name. */ if (!isPickmap()) { - mainControl.getMainView().getObjectChooser().getPickmapChooserControl().reloadPickmap(mapFile); + mainControl.getObjectChooser().getPickmapChooserControl().reloadPickmap(mapFile); } resetModified(); } Modified: trunk/src/app/net/sf/gridarta/map/DefaultMapModel.java =================================================================== --- trunk/src/app/net/sf/gridarta/map/DefaultMapModel.java 2008-04-09 20:17:02 UTC (rev 3858) +++ trunk/src/app/net/sf/gridarta/map/DefaultMapModel.java 2008-04-09 20:32:58 UTC (rev 3859) @@ -695,7 +695,7 @@ mapGrid[mapx][mapy].addLast(part); } - final Integer direction = mainControl.getMainView().getObjectChooser().getArchetypeChooserControl().getCurrentDirection(); + final Integer direction = mainControl.getObjectChooser().getArchetypeChooserControl().getCurrentDirection(); if (direction != null) { part.setDirection(direction); part.setAttributeString("direction", Integer.toString(direction)); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-04-09 20:42:10
|
Revision: 3860 http://gridarta.svn.sourceforge.net/gridarta/?rev=3860&view=rev Author: akirschbaum Date: 2008-04-09 13:41:53 -0700 (Wed, 09 Apr 2008) Log Message: ----------- Remove unneeded explicit main view redraws. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/daimonin/src/daieditor/CMainControl.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-04-09 20:32:58 UTC (rev 3859) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-04-09 20:41:53 UTC (rev 3860) @@ -468,7 +468,6 @@ /** {@inheritDoc} */ public void collectArches() { - mainView.update(mainView.getGraphics()); final Progress progress = new ProgressDisplay(mainView, ACTION_FACTORY.getString("archCollectTitle"), 0, ACTION_FACTORY.getString("archCollectArches")); collectArches(progress); } @@ -876,9 +875,6 @@ getMapManager().mapCreateView(newMapControl, viewPositions[i]); } } - - // Update the main view so the new map instantly pops up. - mainView.update(mainView.getGraphics()); } } Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-04-09 20:32:58 UTC (rev 3859) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-04-09 20:41:53 UTC (rev 3860) @@ -1043,9 +1043,6 @@ getMapManager().mapCreateView(newMapControl, viewPositions[i]); } } - - // Update the main view so the new map instantly pops up. - mainView.update(mainView.getGraphics()); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-04-09 20:59:11
|
Revision: 3861 http://gridarta.svn.sourceforge.net/gridarta/?rev=3861&view=rev Author: akirschbaum Date: 2008-04-09 13:58:39 -0700 (Wed, 09 Apr 2008) Log Message: ----------- Remove MainControl.getRecentManager(). Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/daimonin/src/daieditor/CMainControl.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 Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-04-09 20:41:53 UTC (rev 3860) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-04-09 20:58:39 UTC (rev 3861) @@ -224,9 +224,6 @@ /** The treasure lists. */ private final CFTreasureListTree<GameObject, MapArchObject, Archetype> treasureListTree; - /** The recent menu manager. */ - private final RecentManager recentManager; - /** The auto-validator. */ private final AutoValidator<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> autoValidator; @@ -310,7 +307,8 @@ getCopyBuffer().init(getGridartaObjectsFactory().newMapArchObject(false)); mainActions.init(); - recentManager = new RecentManager(this, (JMenu) ACTION_FACTORY.find(mainView.getJMenuBar(), "recent")); + final RecentManager recentManager = new RecentManager(this, (JMenu) ACTION_FACTORY.find(mainView.getJMenuBar(), "recent")); + getMapManager().setRecentManager(recentManager); final long timeStart = System.currentTimeMillis(); if (log.isInfoEnabled()) { @@ -950,11 +948,6 @@ } /** {@inheritDoc} */ - public RecentManager getRecentManager() { - return recentManager; - } - - /** {@inheritDoc} */ @NotNull public String getConfigurationDirectory() { return "resource/conf"; } Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-04-09 20:41:53 UTC (rev 3860) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-04-09 20:58:39 UTC (rev 3861) @@ -279,9 +279,6 @@ /** The treasure lists. */ private final CFTreasureListTree<GameObject, MapArchObject, Archetype> treasureListTree; - /** The recent menu manager. */ - private final RecentManager recentManager; - /** The auto-validator. */ private final AutoValidator<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> autoValidator; @@ -386,7 +383,8 @@ } } - recentManager = new RecentManager(this, (JMenu) ACTION_FACTORY.find(mainView.getJMenuBar(), "recent")); + final RecentManager recentManager = new RecentManager(this, (JMenu) ACTION_FACTORY.find(mainView.getJMenuBar(), "recent")); + getMapManager().setRecentManager(recentManager); final long timeStart = System.currentTimeMillis(); if (log.isInfoEnabled()) { @@ -1119,11 +1117,6 @@ } /** {@inheritDoc} */ - public RecentManager getRecentManager() { - return recentManager; - } - - /** {@inheritDoc} */ @NotNull public String getConfigurationDirectory() { return getArchDefaultFolder() + "/dev/editor/conf"; } Modified: trunk/src/app/net/sf/gridarta/DefaultMapManager.java =================================================================== --- trunk/src/app/net/sf/gridarta/DefaultMapManager.java 2008-04-09 20:41:53 UTC (rev 3860) +++ trunk/src/app/net/sf/gridarta/DefaultMapManager.java 2008-04-09 20:58:39 UTC (rev 3861) @@ -30,6 +30,7 @@ import javax.swing.event.EventListenerList; import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.GameObject; +import net.sf.gridarta.gui.RecentManager; import net.sf.gridarta.gui.map.MapView; import net.sf.gridarta.gui.map.MapViewBasic; import net.sf.gridarta.io.MapReader; @@ -55,6 +56,9 @@ /** The main control. */ @NotNull private final MainControl<G, A, R, C, V> mainControl; + /** The recent manager. */ + private RecentManager recentManager = null; + /** All open maps. */ private final List<C> levels = new ArrayList<C>(); @@ -195,7 +199,7 @@ final MapView<G, A, R, C, V> mapView = newMapWithView(decoder.getGameObjects(), decoder.getMapArchObject(), viewPosition, file, file.getPath()); mapView.getMapControl().setActiveEditType(mainControl.getEditType()); mapView.getMapControl().resetModified(); - mainControl.getRecentManager().addRecent(currentMap.getMapModel().getMapArchObject().getMapDisplayName(), file.toString()); + recentManager.addRecent(currentMap.getMapModel().getMapArchObject().getMapDisplayName(), file.toString()); return mapView; } @@ -442,4 +446,9 @@ } } + /** {@inheritDoc} */ + public void setRecentManager(@NotNull final RecentManager recentManager) { + this.recentManager = recentManager; + } + } // class DefaultMapManager Modified: trunk/src/app/net/sf/gridarta/MainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/MainControl.java 2008-04-09 20:41:53 UTC (rev 3860) +++ trunk/src/app/net/sf/gridarta/MainControl.java 2008-04-09 20:58:39 UTC (rev 3861) @@ -30,7 +30,6 @@ import net.sf.gridarta.gameobject.face.AbstractFaceObjects; import net.sf.gridarta.gui.MainView; import net.sf.gridarta.gui.ObjectChooser; -import net.sf.gridarta.gui.RecentManager; import net.sf.gridarta.gui.map.MapPreviewAccessory; import net.sf.gridarta.gui.map.MapView; import net.sf.gridarta.gui.map.MapViewBasic; @@ -293,13 +292,6 @@ void collectArches(); /** - * return the recent menu manager. - * - * @return the recent menu manager - */ - RecentManager getRecentManager(); - - /** * Return the autojoin lists. * * @return The autojoin lists. Modified: trunk/src/app/net/sf/gridarta/MapManager.java =================================================================== --- trunk/src/app/net/sf/gridarta/MapManager.java 2008-04-09 20:41:53 UTC (rev 3860) +++ trunk/src/app/net/sf/gridarta/MapManager.java 2008-04-09 20:58:39 UTC (rev 3861) @@ -24,6 +24,7 @@ import java.util.List; import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.GameObject; +import net.sf.gridarta.gui.RecentManager; import net.sf.gridarta.gui.map.MapView; import net.sf.gridarta.gui.map.MapViewBasic; import net.sf.gridarta.map.MapArchObject; @@ -212,4 +213,6 @@ */ boolean save(@NotNull final C mapControl); + void setRecentManager(@NotNull RecentManager recentManager); + } // interface MapManager This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-04-09 21:57:37
|
Revision: 3863 http://gridarta.svn.sourceforge.net/gridarta/?rev=3863&view=rev Author: akirschbaum Date: 2008-04-09 14:57:14 -0700 (Wed, 09 Apr 2008) Log Message: ----------- Move getSelectedSquareControl() from MainView to MainControl. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/CMainView.java trunk/crossfire/src/cfeditor/CMapViewBasic.java trunk/crossfire/src/cfeditor/MapActions.java trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/CMainView.java trunk/daimonin/src/daieditor/CMapViewBasic.java trunk/daimonin/src/daieditor/MapActions.java trunk/daimonin/src/daieditor/gui/map/tools/InsertionTool.java trunk/src/app/net/sf/gridarta/MainControl.java trunk/src/app/net/sf/gridarta/gui/ErrorListView.java trunk/src/app/net/sf/gridarta/gui/GameObjectAttributesPanel.java trunk/src/app/net/sf/gridarta/gui/MainView.java trunk/src/app/net/sf/gridarta/gui/map/MapCursorControl.java trunk/src/app/net/sf/gridarta/map/AbstractMapControl.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-04-09 21:03:37 UTC (rev 3862) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-04-09 21:57:14 UTC (rev 3863) @@ -60,6 +60,7 @@ import net.sf.gridarta.gui.About; import net.sf.gridarta.gui.HideFileFilterProxy; import net.sf.gridarta.gui.MainActions; +import net.sf.gridarta.gui.MainView; import net.sf.gridarta.gui.MapFileFilter; import net.sf.gridarta.gui.MapManagerActions; import net.sf.gridarta.gui.RecentManager; @@ -71,6 +72,7 @@ import net.sf.gridarta.gui.prefs.MapValidatorPrefs; import net.sf.gridarta.gui.prefs.MiscPrefs; import net.sf.gridarta.gui.prefs.UpdatePrefs; +import net.sf.gridarta.gui.selectedsquare.SelectedSquareControl; import net.sf.gridarta.gui.undo.UndoControl; import net.sf.gridarta.io.IOUtils; import net.sf.gridarta.map.AutoValidator; @@ -173,6 +175,9 @@ /** The Spells. */ private final Spells<GameObjectSpell<GameObject, MapArchObject, Archetype>> gameObjectSpells = new Spells<GameObjectSpell<GameObject, MapArchObject, Archetype>>(); + /** List of objects on map (right side). */ + private SelectedSquareControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> selectedSquareControl; + /** * The ArchetypeSet, which is a registry of all Archetypes. */ @@ -286,8 +291,10 @@ } gameObjectSpells.sort(); + final boolean mapTileListBottom = prefs.getBoolean(MainView.MAP_TILE_LIST_BOTTOM_KEY, CMainView.MAP_TILE_LIST_BOTTOM_DEFAULT); + selectedSquareControl = new SelectedSquareControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(ACTION_FACTORY, this, mainView, mapTileListBottom, null); // Initialize the main view - mainView.init(null, new LockedItemsControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(getMapManager(), 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), typeList); + mainView.init(new LockedItemsControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(getMapManager(), 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), selectedSquareControl.getSelectedSquareView(), typeList, mapTileListBottom); mapActions.updateMenuState(); scriptControl.getView().setMenu((JMenu) ACTION_FACTORY.find(mainView.getJMenuBar(), "plugins")); archetypeParser = new ArchetypeParser(this, objectChooser.getArchetypeChooserControl()); @@ -971,4 +978,9 @@ return objectChooser; } + /** {@inheritDoc} */ + @NotNull public SelectedSquareControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> getSelectedSquareControl() { + return selectedSquareControl; + } + } // class CMainControl Modified: trunk/crossfire/src/cfeditor/CMainView.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainView.java 2008-04-09 21:03:37 UTC (rev 3862) +++ trunk/crossfire/src/cfeditor/CMainView.java 2008-04-09 21:57:14 UTC (rev 3863) @@ -55,7 +55,7 @@ import net.sf.gridarta.gui.connectionview.LockedItemsControl; import net.sf.gridarta.gui.map.MapView; import net.sf.gridarta.gui.map.ViewActions; -import net.sf.gridarta.gui.selectedsquare.SelectedSquareControl; +import net.sf.gridarta.gui.selectedsquare.SelectedSquareView; import net.sf.japi.swing.ActionFactory; import org.apache.log4j.Logger; import org.jetbrains.annotations.NotNull; @@ -100,9 +100,6 @@ /** Last known map view for generating change events. */ private MapView<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> currentMapView = null; - /** List of objects on map (right side). */ - private SelectedSquareControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> selectedSquareControl; - /** Attributes panel (bottom). */ private GameObjectAttributesPanel gameObjectAttributesPanel; @@ -167,12 +164,11 @@ /** * Initializes (builds) this view. - * @param compassIcon If non-<code>null</code>, display this icon on the - * top of the list * @param lockedItemsControl the locked items control + * @param selectedSquareView the selected square view * @param archTypeList the instance for looking up archetype types */ - void init(@Nullable final ImageIcon compassIcon, @NotNull final LockedItemsControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> lockedItemsControl, final CFArchTypeList archTypeList) { + void init(@NotNull final LockedItemsControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> lockedItemsControl, @NotNull final SelectedSquareView<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> selectedSquareView, final CFArchTypeList archTypeList, final boolean mapTileListBottom) { // calculate some default values in case there is no settings file final Rectangle screen = getGraphicsConfiguration().getBounds(); final int defwidth = (int) (0.9 * screen.getWidth()); @@ -182,7 +178,7 @@ final JPanel toolbarPanel = new JPanel(new BorderLayout()); toolbarPanel.add(mainToolbar, BorderLayout.NORTH); - toolbarPanel.add(createCenterPanel(defwidth, defheight, compassIcon, lockedItemsControl), BorderLayout.CENTER); + toolbarPanel.add(createCenterPanel(defwidth, defheight, lockedItemsControl, selectedSquareView, mapTileListBottom), BorderLayout.CENTER); add(toolbarPanel, BorderLayout.CENTER); archetypesActions = new ArchetypesActions<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(this, objectChooser.getArchetypeChooserControl(), mainControl.getArchetypeSet(), objectChooser, archTypeList); @@ -215,27 +211,24 @@ * Create the center panel. * @param defwidth default width * @param defheight default height - * @param compassIcon If non-<code>null</code>, display this icon on the - * top of the list * @param lockedItemsControl the locked items control + * @param selectedSquareView the selected square view * @return center panel */ - private JPanel createCenterPanel(final int defwidth, final int defheight, @Nullable final ImageIcon compassIcon, @NotNull final LockedItemsControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> lockedItemsControl) { + private JPanel createCenterPanel(final int defwidth, final int defheight, @NotNull final LockedItemsControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> lockedItemsControl, @NotNull final SelectedSquareView<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> selectedSquareView, final boolean mapTileListBottom) { final JPanel centerPanel = new JPanel(new BorderLayout()); final int divLocationRight = prefs.getInt(DIVIDER_LOCATION_KEY3, (int) (defwidth * 0.62)); final int divLocationDown = prefs.getInt(DIVIDER_LOCATION_KEY2, (int) (defheight * 0.76)); final int divLocation = prefs.getInt(DIVIDER_LOCATION_KEY, (int) (defwidth * 0.17)); - final boolean mapTileListBottom = prefs.getBoolean(MainView.MAP_TILE_LIST_BOTTOM_KEY, CMainView.MAP_TILE_LIST_BOTTOM_DEFAULT); - selectedSquareControl = new SelectedSquareControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(actionFactory, mainControl, this, mapTileListBottom, compassIcon); gameObjectAttributesPanel = new GameObjectAttributesPanel(mainControl, mapManager, this, lockedItemsControl); if (mapTileListBottom) { - splitRightPane = new GSplitPane(JSplitPane.HORIZONTAL_SPLIT, gameObjectAttributesPanel, selectedSquareControl.getSelectedSquareView()); + splitRightPane = new GSplitPane(JSplitPane.HORIZONTAL_SPLIT, gameObjectAttributesPanel, selectedSquareView); splitDownPane = new GSplitPane(JSplitPane.VERTICAL_SPLIT, mapDesktop, splitRightPane); } else { - splitRightPane = new GSplitPane(JSplitPane.HORIZONTAL_SPLIT, mapDesktop, selectedSquareControl.getSelectedSquareView()); + splitRightPane = new GSplitPane(JSplitPane.HORIZONTAL_SPLIT, mapDesktop, selectedSquareView); splitDownPane = new GSplitPane(JSplitPane.VERTICAL_SPLIT, splitRightPane, gameObjectAttributesPanel); } splitRightPane.setDividerLocation(divLocationRight); @@ -445,11 +438,6 @@ return gameObjectAttributesPanel; } - /** {@inheritDoc} */ - @NotNull public SelectedSquareControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> getSelectedSquareControl() { - return selectedSquareControl; - } - /** * Returns the current top map view we are working with. * @return the current top map view we are working with, or Modified: trunk/crossfire/src/cfeditor/CMapViewBasic.java =================================================================== --- trunk/crossfire/src/cfeditor/CMapViewBasic.java 2008-04-09 21:03:37 UTC (rev 3862) +++ trunk/crossfire/src/cfeditor/CMapViewBasic.java 2008-04-09 21:57:14 UTC (rev 3863) @@ -103,7 +103,7 @@ mapModel = mapControl.getMapModel(); mapCursor.addMapCursorListener(this); if (!mapControl.isPickmap()) { - mapCursor.addMapCursorListener(mainControl.getMainView().getSelectedSquareControl().getSelectedSquareView()); + mapCursor.addMapCursorListener(mainControl.getSelectedSquareControl().getSelectedSquareView()); } this.mainControl = mainControl; @@ -121,7 +121,7 @@ getViewport().setViewPosition(initial); } - mapUserListener = new MapUserListener(mainControl, mapControl, this, mainControl.getObjectChooser(), mainControl.getMainView().getSelectedSquareControl().getSelectedSquareView(), mainControl.getObjectChooser().getPickmapChooserControl()); + mapUserListener = new MapUserListener(mainControl, mapControl, this, mainControl.getObjectChooser(), mainControl.getSelectedSquareControl().getSelectedSquareView(), mainControl.getObjectChooser().getPickmapChooserControl()); renderer.addMouseListener(mapUserListener); renderer.addMouseMotionListener(mapUserListener); renderer.setErroneousMapSquares(erroneousMapSquares); @@ -135,7 +135,7 @@ renderer.closeNotify(); mapCursor.removeMapCursorListener(this); if (!mapControl.isPickmap()) { - mapCursor.removeMapCursorListener(mainControl.getMainView().getSelectedSquareControl().getSelectedSquareView()); + mapCursor.removeMapCursorListener(mainControl.getSelectedSquareControl().getSelectedSquareView()); } setViewportView(null); mapModel.removeMapModelListener(this); Modified: trunk/crossfire/src/cfeditor/MapActions.java =================================================================== --- trunk/crossfire/src/cfeditor/MapActions.java 2008-04-09 21:03:37 UTC (rev 3862) +++ trunk/crossfire/src/cfeditor/MapActions.java 2008-04-09 21:57:14 UTC (rev 3863) @@ -442,7 +442,7 @@ return null; } - final GameObject selectedExit = mainControl.getMainView().getSelectedSquareControl().getSelectedSquareView().getSelectedGameObject(); + final GameObject selectedExit = mainControl.getSelectedSquareControl().getSelectedSquareView().getSelectedGameObject(); if (selectedExit != null && CFArchTypeList.isExitType(selectedExit.getHead()) && selectedExit.getHead().getAttributeString("slaying").length() > 0) { return selectedExit.getHead(); } Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-04-09 21:03:37 UTC (rev 3862) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-04-09 21:57:14 UTC (rev 3863) @@ -68,6 +68,7 @@ import net.sf.gridarta.gui.GUIUtils; import net.sf.gridarta.gui.HideFileFilterProxy; import net.sf.gridarta.gui.MainActions; +import net.sf.gridarta.gui.MainView; import net.sf.gridarta.gui.MapFileFilter; import net.sf.gridarta.gui.MapManagerActions; import net.sf.gridarta.gui.RecentManager; @@ -79,6 +80,7 @@ import net.sf.gridarta.gui.prefs.MapValidatorPrefs; import net.sf.gridarta.gui.prefs.MiscPrefs; import net.sf.gridarta.gui.prefs.UpdatePrefs; +import net.sf.gridarta.gui.selectedsquare.SelectedSquareControl; import net.sf.gridarta.gui.undo.UndoControl; import net.sf.gridarta.io.IOUtils; import net.sf.gridarta.map.AutoValidator; @@ -213,6 +215,9 @@ /** The Spells. */ private final Spells<GameObjectSpell<GameObject, MapArchObject, Archetype>> gameObjectSpells = new Spells<GameObjectSpell<GameObject, MapArchObject, Archetype>>(); + /** List of objects on map (right side). */ + private SelectedSquareControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> selectedSquareControl; + /** * The ArchetypeSet, which is a registry of all Archetypes. */ @@ -341,8 +346,10 @@ } numberSpells.sort(); + final boolean mapTileListBottom = prefs.getBoolean(MainView.MAP_TILE_LIST_BOTTOM_KEY, CMainView.MAP_TILE_LIST_BOTTOM_DEFAULT); + selectedSquareControl = new SelectedSquareControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(ACTION_FACTORY, this, mainView, mapTileListBottom, GUIUtils.getSysIcon(IGUIConstants.TILE_NORTH)); // Initialize the main view - mainView.init(GUIUtils.getSysIcon(IGUIConstants.TILE_NORTH), new LockedItemsControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(getMapManager(), 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), typeList); + mainView.init(new LockedItemsControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(getMapManager(), 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), selectedSquareControl.getSelectedSquareView(), typeList, mapTileListBottom); mapActions.updateMenuState(); archetypeParser = new ArchetypeParser(this, objectChooser.getArchetypeChooserControl()); animationObjects = new AnimationObjects(); @@ -1131,4 +1138,9 @@ return objectChooser; } + /** {@inheritDoc} */ + @NotNull public SelectedSquareControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> getSelectedSquareControl() { + return selectedSquareControl; + } + } // class CMainControl Modified: trunk/daimonin/src/daieditor/CMainView.java =================================================================== --- trunk/daimonin/src/daieditor/CMainView.java 2008-04-09 21:03:37 UTC (rev 3862) +++ trunk/daimonin/src/daieditor/CMainView.java 2008-04-09 21:57:14 UTC (rev 3863) @@ -55,7 +55,7 @@ import net.sf.gridarta.gui.connectionview.LockedItemsControl; import net.sf.gridarta.gui.map.MapView; import net.sf.gridarta.gui.map.ViewActions; -import net.sf.gridarta.gui.selectedsquare.SelectedSquareControl; +import net.sf.gridarta.gui.selectedsquare.SelectedSquareView; import net.sf.japi.swing.ActionFactory; import org.apache.log4j.Logger; import org.jetbrains.annotations.NotNull; @@ -100,9 +100,6 @@ /** Last known map view for generating change events. */ private MapView<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> currentMapView = null; - /** List of objects on map (right side). */ - private SelectedSquareControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> selectedSquareControl; - /** Attributes panel (bottom). */ private GameObjectAttributesPanel gameObjectAttributesPanel; @@ -167,12 +164,11 @@ /** * Initializes (builds) this view. - * @param compassIcon If non-<code>null</code>, display this icon on the - * top of the list * @param lockedItemsControl the locked items control + * @param selectedSquareView the selected square view * @param archTypeList the instance for looking up archetype types */ - void init(@Nullable final ImageIcon compassIcon, @NotNull final LockedItemsControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> lockedItemsControl, final CFArchTypeList archTypeList) { + void init(@NotNull final LockedItemsControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> lockedItemsControl, @NotNull final SelectedSquareView<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> selectedSquareView, final CFArchTypeList archTypeList, final boolean mapTileListBottom) { // calculate some default values in case there is no settings file final Rectangle screen = getGraphicsConfiguration().getBounds(); final int defwidth = (int) (0.9 * screen.getWidth()); @@ -182,7 +178,7 @@ final JPanel toolbarPanel = new JPanel(new BorderLayout()); toolbarPanel.add(mainToolbar, BorderLayout.NORTH); - toolbarPanel.add(createCenterPanel(defwidth, defheight, compassIcon, lockedItemsControl), BorderLayout.CENTER); + toolbarPanel.add(createCenterPanel(defwidth, defheight, lockedItemsControl, selectedSquareView, mapTileListBottom), BorderLayout.CENTER); add(toolbarPanel, BorderLayout.CENTER); archetypesActions = new ArchetypesActions<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(this, objectChooser.getArchetypeChooserControl(), mainControl.getArchetypeSet(), objectChooser, archTypeList); @@ -215,27 +211,24 @@ * Create the center panel. * @param defwidth default width * @param defheight default height - * @param compassIcon If non-<code>null</code>, display this icon on the - * top of the list * @param lockedItemsControl the locked items control + * @param selectedSquareView the selected square view * @return center panel */ - private JPanel createCenterPanel(final int defwidth, final int defheight, @Nullable final ImageIcon compassIcon, @NotNull final LockedItemsControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> lockedItemsControl) { + private JPanel createCenterPanel(final int defwidth, final int defheight, @NotNull final LockedItemsControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> lockedItemsControl, @NotNull final SelectedSquareView<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> selectedSquareView, final boolean mapTileListBottom) { final JPanel centerPanel = new JPanel(new BorderLayout()); final int divLocationRight = prefs.getInt(DIVIDER_LOCATION_KEY3, (int) (defwidth * 0.62)); final int divLocationDown = prefs.getInt(DIVIDER_LOCATION_KEY2, (int) (defheight * 0.76)); final int divLocation = prefs.getInt(DIVIDER_LOCATION_KEY, (int) (defwidth * 0.17)); - final boolean mapTileListBottom = prefs.getBoolean(MainView.MAP_TILE_LIST_BOTTOM_KEY, CMainView.MAP_TILE_LIST_BOTTOM_DEFAULT); - selectedSquareControl = new SelectedSquareControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(actionFactory, mainControl, this, mapTileListBottom, compassIcon); gameObjectAttributesPanel = new GameObjectAttributesPanel(mainControl, mapManager, this, lockedItemsControl); if (mapTileListBottom) { - splitRightPane = new GSplitPane(JSplitPane.HORIZONTAL_SPLIT, gameObjectAttributesPanel, selectedSquareControl.getSelectedSquareView()); + splitRightPane = new GSplitPane(JSplitPane.HORIZONTAL_SPLIT, gameObjectAttributesPanel, selectedSquareView); splitDownPane = new GSplitPane(JSplitPane.VERTICAL_SPLIT, mapDesktop, splitRightPane); } else { - splitRightPane = new GSplitPane(JSplitPane.HORIZONTAL_SPLIT, mapDesktop, selectedSquareControl.getSelectedSquareView()); + splitRightPane = new GSplitPane(JSplitPane.HORIZONTAL_SPLIT, mapDesktop, selectedSquareView); splitDownPane = new GSplitPane(JSplitPane.VERTICAL_SPLIT, splitRightPane, gameObjectAttributesPanel); } splitRightPane.setDividerLocation(divLocationRight); @@ -445,11 +438,6 @@ return gameObjectAttributesPanel; } - /** {@inheritDoc} */ - @NotNull public SelectedSquareControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> getSelectedSquareControl() { - return selectedSquareControl; - } - /** * Returns the current top map view we are working with. * @return the current top map view we are working with, or Modified: trunk/daimonin/src/daieditor/CMapViewBasic.java =================================================================== --- trunk/daimonin/src/daieditor/CMapViewBasic.java 2008-04-09 21:03:37 UTC (rev 3862) +++ trunk/daimonin/src/daieditor/CMapViewBasic.java 2008-04-09 21:57:14 UTC (rev 3863) @@ -105,7 +105,7 @@ mapModel = mapControl.getMapModel(); mapCursor.addMapCursorListener(this); if (!mapControl.isPickmap()) { - mapCursor.addMapCursorListener(mainControl.getMainView().getSelectedSquareControl().getSelectedSquareView()); + mapCursor.addMapCursorListener(mainControl.getSelectedSquareControl().getSelectedSquareView()); } this.mainControl = mainControl; @@ -138,7 +138,7 @@ renderer.closeNotify(); mapCursor.removeMapCursorListener(this); if (!mapControl.isPickmap()) { - mapCursor.removeMapCursorListener(mainControl.getMainView().getSelectedSquareControl().getSelectedSquareView()); + mapCursor.removeMapCursorListener(mainControl.getSelectedSquareControl().getSelectedSquareView()); } setViewportView(null); mapModel.removeMapModelListener(this); Modified: trunk/daimonin/src/daieditor/MapActions.java =================================================================== --- trunk/daimonin/src/daieditor/MapActions.java 2008-04-09 21:03:37 UTC (rev 3862) +++ trunk/daimonin/src/daieditor/MapActions.java 2008-04-09 21:57:14 UTC (rev 3863) @@ -420,7 +420,7 @@ return null; } - final GameObject selectedExit = mainControl.getMainView().getSelectedSquareControl().getSelectedSquareView().getSelectedGameObject(); + final GameObject selectedExit = mainControl.getSelectedSquareControl().getSelectedSquareView().getSelectedGameObject(); if (selectedExit != null && CFArchTypeList.isExitType(selectedExit.getHead()) && selectedExit.getHead().getAttributeString("slaying").length() > 0) { return selectedExit.getHead(); } Modified: trunk/daimonin/src/daieditor/gui/map/tools/InsertionTool.java =================================================================== --- trunk/daimonin/src/daieditor/gui/map/tools/InsertionTool.java 2008-04-09 21:03:37 UTC (rev 3862) +++ trunk/daimonin/src/daieditor/gui/map/tools/InsertionTool.java 2008-04-09 21:57:14 UTC (rev 3863) @@ -73,7 +73,7 @@ mapCursor.setLocation(p); } mapControl.getMapModel().endTransaction(); - mainControl.getMainView().getSelectedSquareControl().getSelectedSquareView().setSelectedGameObject(insertedObject); + mainControl.getSelectedSquareControl().getSelectedSquareView().setSelectedGameObject(insertedObject); } } @@ -86,7 +86,7 @@ mapControl.getMapModel().beginTransaction("Insert Object"); final GameObject insertedObject = mapControl.insertSelectedObject(p, false); mapControl.getMapModel().endTransaction(); - mainControl.getMainView().getSelectedSquareControl().getSelectedSquareView().setSelectedGameObject(insertedObject); + mainControl.getSelectedSquareControl().getSelectedSquareView().setSelectedGameObject(insertedObject); } } Modified: trunk/src/app/net/sf/gridarta/MainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/MainControl.java 2008-04-09 21:03:37 UTC (rev 3862) +++ trunk/src/app/net/sf/gridarta/MainControl.java 2008-04-09 21:57:14 UTC (rev 3863) @@ -33,6 +33,7 @@ import net.sf.gridarta.gui.map.MapPreviewAccessory; import net.sf.gridarta.gui.map.MapView; import net.sf.gridarta.gui.map.MapViewBasic; +import net.sf.gridarta.gui.selectedsquare.SelectedSquareControl; import net.sf.gridarta.map.MapArchObject; import net.sf.gridarta.map.MapControl; import net.sf.gridarta.map.MapModel; @@ -312,4 +313,11 @@ */ ObjectChooser<G, A, R> getObjectChooser(); + /** + * Return the Selected Square Control. + * + * @return The Selected Square Control. + */ + @NotNull SelectedSquareControl<G, A, R, C, V> getSelectedSquareControl(); + } // interface MainControl Modified: trunk/src/app/net/sf/gridarta/gui/ErrorListView.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/ErrorListView.java 2008-04-09 21:03:37 UTC (rev 3862) +++ trunk/src/app/net/sf/gridarta/gui/ErrorListView.java 2008-04-09 21:57:14 UTC (rev 3863) @@ -234,7 +234,7 @@ if (gameObject != null) { final G topContainer = gameObject.getTopContainer(); currentMapControl.getMapViewFrame().getView().getMapCursor().setLocation(new Point(topContainer.getMapX(), topContainer.getMapY())); - AbstractMainControl.getInstance().getMainView().getSelectedSquareControl().getSelectedSquareView().setSelectedGameObject(gameObject); + AbstractMainControl.getInstance().getSelectedSquareControl().getSelectedSquareView().setSelectedGameObject(gameObject); } else { final MapSquare<G, A, R> mapSquare = error.getMapSquare(); final Point location = mapSquare == null ? null : new Point(mapSquare.getMapX(), mapSquare.getMapY()); Modified: trunk/src/app/net/sf/gridarta/gui/GameObjectAttributesPanel.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/GameObjectAttributesPanel.java 2008-04-09 21:03:37 UTC (rev 3862) +++ trunk/src/app/net/sf/gridarta/gui/GameObjectAttributesPanel.java 2008-04-09 21:57:14 UTC (rev 3863) @@ -311,7 +311,7 @@ panelDesktop.add(createMonsterPanel(), "Monster"); panelDesktop.add(errorListView, "Warnings"); - mainControl.getMainView().getSelectedSquareControl().addSelectedSquareListener(selectedSquareListener); + mainControl.getSelectedSquareControl().addSelectedSquareListener(selectedSquareListener); refreshDisplay(); currentMap = mapManager.getCurrentMap(); @@ -604,7 +604,7 @@ /** This method is invoked when the user pressed the "new script" button. */ public void addNewScriptWanted() { - final G gameObject = mainControl.getMainView().getSelectedSquareControl().getSelectedSquareView().getSelectedGameObject(); // get selected arch + final G gameObject = mainControl.getSelectedSquareControl().getSelectedSquareView().getSelectedGameObject(); // get selected arch if (gameObject != null) { final MapSquare<G, A, R> mapSquare = gameObject.getHead().getMapSquare(); assert mapSquare != null; @@ -622,7 +622,7 @@ * @param task Script type to edit (?). */ public void editScriptWanted(final int task) { - final G gameObject = mainControl.getMainView().getSelectedSquareControl().getSelectedSquareView().getSelectedGameObject(); // get selected gameObject + final G gameObject = mainControl.getSelectedSquareControl().getSelectedSquareView().getSelectedGameObject(); // get selected gameObject if (gameObject == null) { return; } @@ -655,14 +655,14 @@ * Action method for applying the changes made in the arch panel. */ @ActionMethod public void mapArchApply() { - applyArchPanelChanges(mainView.getSelectedSquareControl().getSelectedSquareView().getSelectedGameObject()); + applyArchPanelChanges(mainControl.getSelectedSquareControl().getSelectedSquareView().getSelectedGameObject()); } /** * Action method for displaying the attributes of the currently selected object. */ @ActionMethod public void mapArchAttrib() { - mainControl.openAttrDialog(mainView.getSelectedSquareControl().getSelectedSquareView().getSelectedGameObject()); + mainControl.openAttrDialog(mainControl.getSelectedSquareControl().getSelectedSquareView().getSelectedGameObject()); } /** @@ -674,7 +674,7 @@ return; } - G inv = mainView.getSelectedSquareControl().getSelectedSquareView().getSelectedGameObject(); + G inv = mainControl.getSelectedSquareControl().getSelectedSquareView().getSelectedGameObject(); if (inv == null) { return; } @@ -866,7 +866,7 @@ * @param direction Direction number */ private void direction(final int direction) { - applyDirectionChanges(mainView.getSelectedSquareControl().getSelectedSquareView().getSelectedGameObject(), direction); + applyDirectionChanges(mainControl.getSelectedSquareControl().getSelectedSquareView().getSelectedGameObject(), direction); } /** Action method for direction. */ Modified: trunk/src/app/net/sf/gridarta/gui/MainView.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/MainView.java 2008-04-09 21:03:37 UTC (rev 3862) +++ trunk/src/app/net/sf/gridarta/gui/MainView.java 2008-04-09 21:57:14 UTC (rev 3863) @@ -34,7 +34,6 @@ import net.sf.gridarta.gui.map.MapFileActions; import net.sf.gridarta.gui.map.MapView; import net.sf.gridarta.gui.map.MapViewBasic; -import net.sf.gridarta.gui.selectedsquare.SelectedSquareControl; import net.sf.gridarta.help.Help; import net.sf.gridarta.map.MapArchObject; import net.sf.gridarta.map.MapControl; @@ -210,13 +209,6 @@ @NotNull public abstract GameObjectAttributesPanel<G, A, R, C, V> getGameObjectAttributesPanel(); /** - * Return the Selected Square Control. - * - * @return The Selected Square Control. - */ - @NotNull public abstract SelectedSquareControl<G, A, R, C, V> getSelectedSquareControl(); - - /** * Activate the given map view. * @param mapView the map view */ Modified: trunk/src/app/net/sf/gridarta/gui/map/MapCursorControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/MapCursorControl.java 2008-04-09 21:03:37 UTC (rev 3862) +++ trunk/src/app/net/sf/gridarta/gui/map/MapCursorControl.java 2008-04-09 21:57:14 UTC (rev 3863) @@ -101,17 +101,13 @@ } public void insertArch() { - final MainView<G, A, R, C, V> mainView = mainControl.getMainView(); - assert mainView != null; - final SelectedSquareControl<G, A, R, C, V> selectedSquareControl = mainView.getSelectedSquareControl(); + final SelectedSquareControl<G, A, R, C, V> selectedSquareControl = mainControl.getSelectedSquareControl(); assert selectedSquareControl != null; selectedSquareControl.insertGameObjectFromObjectChooser(); } public void deleteArch() { - final MainView<G, A, R, C, V> mainView = mainControl.getMainView(); - assert mainView != null; - final SelectedSquareControl<G, A, R, C, V> selectedSquareControl = mainView.getSelectedSquareControl(); + final SelectedSquareControl<G, A, R, C, V> selectedSquareControl = mainControl.getSelectedSquareControl(); assert selectedSquareControl != null; selectedSquareControl.deleteSelection(); } @@ -121,9 +117,7 @@ * @param above if <code>true</code> arch above is selected otherwise arch below is selected */ public void selectArch(final boolean above) { - final MainView<G, A, R, C, V> mainView = mainControl.getMainView(); - assert mainView != null; - final SelectedSquareControl<G, A, R, C, V> selectedSquareControl = mainView.getSelectedSquareControl(); + final SelectedSquareControl<G, A, R, C, V> selectedSquareControl = mainControl.getSelectedSquareControl(); assert selectedSquareControl != null; final SelectedSquareView<G, A, R, C, V> selectedSquareView = selectedSquareControl.getSelectedSquareView(); assert selectedSquareView != null; @@ -131,9 +125,7 @@ } public void archAttributes() { - final MainView<G, A, R, C, V> mainView = mainControl.getMainView(); - assert mainView != null; - final SelectedSquareControl<G, A, R, C, V> selectedSquareControl = mainView.getSelectedSquareControl(); + final SelectedSquareControl<G, A, R, C, V> selectedSquareControl = mainControl.getSelectedSquareControl(); assert selectedSquareControl != null; final G arch = selectedSquareControl.getSelectedSquareView().getSelectedGameObject(); if (arch != null) { Modified: trunk/src/app/net/sf/gridarta/map/AbstractMapControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/map/AbstractMapControl.java 2008-04-09 21:03:37 UTC (rev 3862) +++ trunk/src/app/net/sf/gridarta/map/AbstractMapControl.java 2008-04-09 21:57:14 UTC (rev 3863) @@ -303,7 +303,7 @@ // insertion is only allowed for valid *empty* squares if (currentMap != null && isPickmap() && mapModel.isPointValid(pos) && mapModel.getMapSquare(pos).isEmpty()) { // get the currently selected map arch - G newarch = mainControl.getMainView().getSelectedSquareControl().getSelectedSquareView().getSelectedGameObject(); + G newarch = mainControl.getSelectedSquareControl().getSelectedSquareView().getSelectedGameObject(); if (newarch != null) { newarch = newarch.getHead(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-04-09 22:42:38
|
Revision: 3867 http://gridarta.svn.sourceforge.net/gridarta/?rev=3867&view=rev Author: akirschbaum Date: 2008-04-09 15:42:20 -0700 (Wed, 09 Apr 2008) Log Message: ----------- Remove calls to AbstractMainControl.getInstance(). Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/daimonin/src/daieditor/CMainControl.java trunk/src/app/net/sf/gridarta/treasurelist/CFTreasureListTree.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-04-09 22:33:23 UTC (rev 3866) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-04-09 22:42:20 UTC (rev 3867) @@ -363,7 +363,7 @@ log.warn("Cannot read TreasureLists.xml: " + ex.getMessage()); specialTreasureLists = Collections.emptyMap(); } - treasureListTree = new CFTreasureListTree<GameObject, MapArchObject, Archetype>(archetypeSet, specialTreasureLists, + treasureListTree = new CFTreasureListTree<GameObject, MapArchObject, Archetype>(mainView, archetypeSet, specialTreasureLists, new TreasureLocation(getConfigurationDirectory(), IGUIConstants.TREASURES_FILE) ); recentManager.initRecent(); Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-04-09 22:33:23 UTC (rev 3866) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-04-09 22:42:20 UTC (rev 3867) @@ -431,7 +431,7 @@ log.warn("Cannot read TreasureLists.xml: " + ex.getMessage()); specialTreasureLists = Collections.emptyMap(); } - treasureListTree = new CFTreasureListTree<GameObject, MapArchObject, Archetype>(archetypeSet, specialTreasureLists, + treasureListTree = new CFTreasureListTree<GameObject, MapArchObject, Archetype>(mainView, archetypeSet, specialTreasureLists, new TreasureLocation(getArchDefaultFolder(), IGUIConstants.TREASURES_FILE), new TreasureLocation(getMapDefaultFolder(), null) ); Modified: trunk/src/app/net/sf/gridarta/treasurelist/CFTreasureListTree.java =================================================================== --- trunk/src/app/net/sf/gridarta/treasurelist/CFTreasureListTree.java 2008-04-09 22:33:23 UTC (rev 3866) +++ trunk/src/app/net/sf/gridarta/treasurelist/CFTreasureListTree.java 2008-04-09 22:42:20 UTC (rev 3867) @@ -38,10 +38,10 @@ import javax.swing.WindowConstants; import javax.swing.tree.DefaultMutableTreeNode; import javax.swing.tree.TreePath; -import net.sf.gridarta.AbstractMainControl; import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.ArchetypeSet; import net.sf.gridarta.gameobject.GameObject; +import net.sf.gridarta.gui.MainView; import net.sf.gridarta.help.Help; import net.sf.gridarta.map.MapArchObject; import net.sf.japi.swing.ActionFactory; @@ -71,6 +71,9 @@ // hashtable containing references to all treasurelists (tree nodes) private static Map<String, TreasureTreeNode> treasureTable = null; + /** The main view. */ + @NotNull private final MainView<G, A, R, ?, ?> mainView; + /** JDialog containing the tree. */ private JDialog frame; @@ -86,12 +89,14 @@ /** * Create a new instance. + * @param mainView the main view * @param archetypeSet ArchetypeSet to get treasures from. * @param specialTreasureLists the special treasure lists * @param treasures The treasures to load. */ - public CFTreasureListTree(@NotNull final ArchetypeSet<G, A, R> archetypeSet, final Map<String, TreasureTreeNode> specialTreasureLists, final TreasureLocation... treasures) { + public CFTreasureListTree(@NotNull final MainView<G, A, R, ?, ?> mainView, @NotNull final ArchetypeSet<G, A, R> archetypeSet, final Map<String, TreasureTreeNode> specialTreasureLists, final TreasureLocation... treasures) { super(root); + this.mainView = mainView; putClientProperty("JTree.lineStyle", "Angled"); setCellRenderer(new TreasureCellRenderer(archetypeSet, root)); @@ -134,7 +139,7 @@ if (!hasBeenDisplayed) { // open a popup dialog which tmporarily disables all other frames - frame = new JDialog(AbstractMainControl.getInstance().getMainView(), "Treasurelists", false); + frame = new JDialog(mainView, "Treasurelists", false); frame.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE); // click on closebox hides dialog setBorder(BorderFactory.createEmptyBorder(5, 10, 5, 5)); @@ -182,7 +187,7 @@ if (parent != null) { frame.setLocationRelativeTo(parent); } else { - frame.setLocationRelativeTo(AbstractMainControl.getInstance().getMainView()); + frame.setLocationRelativeTo(mainView); } if (input != null) { @@ -269,7 +274,7 @@ final JButton helpButton = new JButton("Help"); helpButton.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent e) { - new Help(AbstractMainControl.getInstance().getMainView(), "treasurelists.html").setVisible(true); + new Help(mainView, "treasurelists.html").setVisible(true); } }); leftSide.add(helpButton); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |