From: <aki...@us...> - 2008-03-14 21:48:18
|
Revision: 3689 http://gridarta.svn.sourceforge.net/gridarta/?rev=3689&view=rev Author: akirschbaum Date: 2008-03-14 14:48:12 -0700 (Fri, 14 Mar 2008) Log Message: ----------- Fix typos. Modified Paths: -------------- trunk/crossfire/src/cfeditor/filter/Filter.java trunk/crossfire/src/cfeditor/filter/NamedFilterList.java trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptedEvent.java trunk/crossfire/src/cfeditor/gui/map/MapPropertiesDialog.java trunk/crossfire/src/cfeditor/gui/prefs/GUIPrefs.java trunk/crossfire/src/cfeditor/map/MapArchObject.java trunk/crossfire/src/cfeditor/map/package-info.java trunk/daimonin/src/daieditor/gameobject/face/FaceObject.java trunk/daimonin/src/daieditor/gameobject/scripts/ScriptedEvent.java trunk/daimonin/src/daieditor/gui/map/MapPropertiesDialog.java trunk/daimonin/src/daieditor/gui/prefs/GUIPrefs.java trunk/daimonin/src/daieditor/map/package-info.java trunk/src/app/net/sf/gridarta/gameobject/GameObject.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/MapFileFilter.java trunk/src/app/net/sf/gridarta/help/Help.java trunk/src/app/net/sf/gridarta/io/PathManager.java trunk/src/app/net/sf/gridarta/map/validation/AbstractValidator.java trunk/src/app/net/sf/gridarta/treasurelist/TreasureCellRenderer.java Modified: trunk/crossfire/src/cfeditor/filter/Filter.java =================================================================== --- trunk/crossfire/src/cfeditor/filter/Filter.java 2008-03-14 21:02:06 UTC (rev 3688) +++ trunk/crossfire/src/cfeditor/filter/Filter.java 2008-03-14 21:48:12 UTC (rev 3689) @@ -26,7 +26,7 @@ /** * Interface for Filters. * - * <p> Interface used to filter and analyse maps. Basically a filter gets an + * <p> Interface used to filter and analyze maps. Basically a filter gets an * {@link GameObject} and tells if it got a match. It also gets reset when the * map square is changed, So more complex behavior can be achieved. * @@ -35,16 +35,16 @@ public interface Filter { /** - * Tells wether we got a match on specific {@link GameObject}. The analysis + * Tells whether we got a match on specific {@link GameObject}. The analysis * tool will call this function with every game object on a given map - * square. The match function is responsible for analysing inventories if + * square. The match function is responsible for analyzing inventories if * it needs to. Unless {@link #hasGlobalMatch(FilterConfig)} returns - * <code>true</code>, when a match occured, this function is not called + * <code>true</code>, when a match occurred, this function is not called * with the remaining game objects on the map square and a reset is issued. * * @param config The filter configuration to use. * - * @param gameObject The game object being analysed on the map. + * @param gameObject The game object being analyzed on the map. * * @return <code>true</code> if it match the criteria, <code>false</code> * otherwise. This value is ignored if <code>hasGlobalMatch()</code> @@ -71,7 +71,7 @@ * match result. If all game objects must be analyzed to decide the result * of a match, the return value of {@link #match(FilterConfig,GameObject)} * is ignored and the returning value of {@link #reset(FilterConfig)} is - * used as replacement. This should mainly used by complex analyse + * used as replacement. This should mainly used by complex analyze * filters. * * @param config The filter configuration to use. Modified: trunk/crossfire/src/cfeditor/filter/NamedFilterList.java =================================================================== --- trunk/crossfire/src/cfeditor/filter/NamedFilterList.java 2008-03-14 21:02:06 UTC (rev 3688) +++ trunk/crossfire/src/cfeditor/filter/NamedFilterList.java 2008-03-14 21:48:12 UTC (rev 3689) @@ -36,10 +36,10 @@ /** * Filter that aggregates named filters. * <p/> - * This filter agregate a list of named filters. - * Each subFilter can be (dis)enabled. - * The names of filters are harcoded for now. - * They may need to be loaded from, eg, an xml file later. + * This filter aggregates a list of named filters. + * Each sub-filter can be (dis)enabled. + * The names of filters are hard-coded for now. + * They may need to be loaded from, e.g., an XML file later. * @author tchize */ public class NamedFilterList implements Filter { Modified: trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptedEvent.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptedEvent.java 2008-03-14 21:02:06 UTC (rev 3688) +++ trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptedEvent.java 2008-03-14 21:48:12 UTC (rev 3689) @@ -83,7 +83,7 @@ * @param eventType type of the event * @param pluginName name of the plugin * @param scriptPath path to the file for this event - * @param options options for this event + * @param options the options for this event * @throws UndefinedEventArchetypeException In case there is no Archetype to create a ScriptedEvent. */ ScriptedEvent(final int eventType, final String pluginName, final String scriptPath, final String options) throws UndefinedEventArchetypeException { @@ -152,7 +152,7 @@ /** * Edit path and plugin name for this event. A popup dialog is shown - * with input textfields for file path and plugin name. + * with input text fields for file path and plugin name. */ public void editParameters() { if (pathFrame == null) { @@ -239,7 +239,7 @@ /** * Return the underlying event game object. * - * @return the underlynig event game object + * @return the underlying event game object */ public GameObject getEventArch() { return event; Modified: trunk/crossfire/src/cfeditor/gui/map/MapPropertiesDialog.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/map/MapPropertiesDialog.java 2008-03-14 21:02:06 UTC (rev 3688) +++ trunk/crossfire/src/cfeditor/gui/map/MapPropertiesDialog.java 2008-03-14 21:48:12 UTC (rev 3689) @@ -134,7 +134,7 @@ /** The MapTilePane. */ private final MapTilePane mapTilePane; - /** Wether the map tile pane was enabled. */ + /** Whether the map tile pane was enabled. */ private final boolean mapTilePaneEnabled; /** Modified: trunk/crossfire/src/cfeditor/gui/prefs/GUIPrefs.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/prefs/GUIPrefs.java 2008-03-14 21:02:06 UTC (rev 3688) +++ trunk/crossfire/src/cfeditor/gui/prefs/GUIPrefs.java 2008-03-14 21:48:12 UTC (rev 3689) @@ -58,7 +58,7 @@ /** ComboBox for choosing the locale. */ private JComboBox localeBox; - /** Wether to place the map tile panel at the bottom or the right. */ + /** Whether to place the map tile panel at the bottom or the right. */ private JCheckBox mapPanelBottom; /** Locale[]. */ Modified: trunk/crossfire/src/cfeditor/map/MapArchObject.java =================================================================== --- trunk/crossfire/src/cfeditor/map/MapArchObject.java 2008-03-14 21:02:06 UTC (rev 3688) +++ trunk/crossfire/src/cfeditor/map/MapArchObject.java 2008-03-14 21:48:12 UTC (rev 3689) @@ -24,7 +24,7 @@ /** * MapArchObject contains the specific meta data about a map that is stored in - * the map-arch, at the very beginning of the map file. The map metadata is + * the map-arch, at the very beginning of the map file. The map meta data is * information like mapSize, difficulty level, darkness etc.). * @author <a href="mailto:and...@gm...">Andreas Vogl</a> * @author <a href="mailto:ch...@ri...">Christian Hujer</a> @@ -72,7 +72,7 @@ /** The item spec for the shop, if there is one. */ @NotNull private String shopItems = ""; - /** The prefered race of the shop. */ + /** The preferred race of the shop. */ @NotNull private String shopRace = ""; /** The greed of the shop. */ Modified: trunk/crossfire/src/cfeditor/map/package-info.java =================================================================== --- trunk/crossfire/src/cfeditor/map/package-info.java 2008-03-14 21:02:06 UTC (rev 3688) +++ trunk/crossfire/src/cfeditor/map/package-info.java 2008-03-14 21:48:12 UTC (rev 3689) @@ -18,9 +18,9 @@ */ /** - * This package containes classes and subpackages related to maps. - * A map is a two-dimensional datastructure. - * The map is modelled by {@link MapModel}. + * This package contains classes and sub-packages related to maps. + * A map is a two-dimensional data structure. + * The map is modeled by {@link MapModel}. * The elements of a map are {@link MapSquare}s. * Each {@link MapSquare} consist of zero or more {@link GameObject}s that are at this map position. * {@link GameObject}s can have {@link GameObject}s as content. Modified: trunk/daimonin/src/daieditor/gameobject/face/FaceObject.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/face/FaceObject.java 2008-03-14 21:02:06 UTC (rev 3688) +++ trunk/daimonin/src/daieditor/gameobject/face/FaceObject.java 2008-03-14 21:48:12 UTC (rev 3689) @@ -57,7 +57,7 @@ private final int size; /** - * Wether this face is a "double" face. + * Whether this face is a "double" face. * @see "Usage FACE_FLAG_DOUBLE in client/src/client.c, client/src/map.c defined by client/src/include/main.h" */ private final boolean isDouble; Modified: trunk/daimonin/src/daieditor/gameobject/scripts/ScriptedEvent.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/scripts/ScriptedEvent.java 2008-03-14 21:02:06 UTC (rev 3688) +++ trunk/daimonin/src/daieditor/gameobject/scripts/ScriptedEvent.java 2008-03-14 21:48:12 UTC (rev 3689) @@ -82,7 +82,7 @@ * @param eventType type of the event * @param pluginName name of the plugin * @param scriptPath path to the file for this event - * @param options options for this event + * @param options the options for this event * @throws UndefinedEventArchetypeException In case there is no Archetype to create a ScriptedEvent. */ ScriptedEvent(final int eventType, final String pluginName, final String scriptPath, final String options) throws UndefinedEventArchetypeException { @@ -151,7 +151,7 @@ /** * Edit path and plugin name for this event. A popup dialog is shown - * with input textfields for file path and plugin name. + * with input text fields for file path and plugin name. */ public void editParameters() { if (pathFrame == null) { @@ -240,7 +240,7 @@ /** * Return the underlying event game object. * - * @return the underlynig event game object + * @return the underlying event game object */ public GameObject getEventArch() { return event; Modified: trunk/daimonin/src/daieditor/gui/map/MapPropertiesDialog.java =================================================================== --- trunk/daimonin/src/daieditor/gui/map/MapPropertiesDialog.java 2008-03-14 21:02:06 UTC (rev 3688) +++ trunk/daimonin/src/daieditor/gui/map/MapPropertiesDialog.java 2008-03-14 21:48:12 UTC (rev 3689) @@ -136,7 +136,7 @@ /** The MapTilePane. */ private final MapTilePane mapTilePane; - /** Wether the map tile pane was enabled. */ + /** Whether the map tile pane was enabled. */ private final boolean mapTilePaneEnabled; /** Modified: trunk/daimonin/src/daieditor/gui/prefs/GUIPrefs.java =================================================================== --- trunk/daimonin/src/daieditor/gui/prefs/GUIPrefs.java 2008-03-14 21:02:06 UTC (rev 3688) +++ trunk/daimonin/src/daieditor/gui/prefs/GUIPrefs.java 2008-03-14 21:48:12 UTC (rev 3689) @@ -58,7 +58,7 @@ /** ComboBox for choosing the locale. */ private JComboBox localeBox; - /** Wether to place the map tile panel at the bottom or the right. */ + /** Whether to place the map tile panel at the bottom or the right. */ private JCheckBox mapPanelBottom; /** Locale[]. */ Modified: trunk/daimonin/src/daieditor/map/package-info.java =================================================================== --- trunk/daimonin/src/daieditor/map/package-info.java 2008-03-14 21:02:06 UTC (rev 3688) +++ trunk/daimonin/src/daieditor/map/package-info.java 2008-03-14 21:48:12 UTC (rev 3689) @@ -18,9 +18,9 @@ */ /** - * This package containes classes and subpackages related to maps. - * A map is a two-dimensional datastructure. - * The map is modelled by {@link MapModel}. + * This package contains classes and sub packages related to maps. + * A map is a two-dimensional data structure. + * The map is modeled by {@link MapModel}. * The elements of a map are {@link MapSquare}s. * Each {@link MapSquare} consist of zero or more {@link GameObject}s that are at this map position. * {@link GameObject}s can have {@link GameObject}s as content. Modified: trunk/src/app/net/sf/gridarta/gameobject/GameObject.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/GameObject.java 2008-03-14 21:02:06 UTC (rev 3688) +++ trunk/src/app/net/sf/gridarta/gameobject/GameObject.java 2008-03-14 21:48:12 UTC (rev 3689) @@ -734,7 +734,7 @@ /** * Get the EditType of an GameObject (e.g. floor, monster, etc). These are - * determined by the various attributes of the GameObject (->objectText). + * determined by the various attributes of the GameObject (->objectText). * @param checkType bitmask containing the edit type(s) to be calculated * @return new editType for this GameObject * @see #getEditType() @@ -1189,10 +1189,10 @@ } /** - * Return whether this game object is unmodifed from its underlying + * Return whether this game object is unmodified from its underlying * archetype. * - * @return Wether this game object is unmodified. + * @return Whether this game object is unmodified. */ public boolean isDefaultGameObject() { return artifact == archetype.isArtifact() Modified: trunk/src/app/net/sf/gridarta/gui/GameObjectAttributesPanel.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/GameObjectAttributesPanel.java 2008-03-14 21:02:06 UTC (rev 3688) +++ trunk/src/app/net/sf/gridarta/gui/GameObjectAttributesPanel.java 2008-03-14 21:48:12 UTC (rev 3689) @@ -690,7 +690,7 @@ return; } - // If the active gameObject is part of a multi, the mutli-head's stats + // If the active gameObject is part of a multi, the multi-head's stats // are taken instead: final G gameObject = activeArch.getHead(); @@ -746,7 +746,7 @@ gameObject.setObjectFace(); // we look for 'type' in the ArchText. In future maybe type should get - // a seperate textfield + // a separate text field if (gameObject.getAttributeString("type", false).length() > 0) { gameObject.setArchTypNr(gameObject.getAttributeInt("type", false)); // specified type } Modified: trunk/src/app/net/sf/gridarta/gui/MainView.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/MainView.java 2008-03-14 21:02:06 UTC (rev 3688) +++ trunk/src/app/net/sf/gridarta/gui/MainView.java 2008-03-14 21:48:12 UTC (rev 3689) @@ -66,7 +66,7 @@ /** The key used to store the main windows divider location to the preferences. */ protected static final String DIVIDER_LOCATION_KEY3 = "MainWindow.dividerLocation3"; - /** Key for info whether map-tile panel is seperate or at bottom. */ + /** Key for info whether map-tile panel is separate or at bottom. */ public static final String MAP_TILE_LIST_BOTTOM_KEY = "MapTileBottom"; /** The main statusbar. */ Modified: trunk/src/app/net/sf/gridarta/gui/MapFileFilter.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/MapFileFilter.java 2008-03-14 21:02:06 UTC (rev 3688) +++ trunk/src/app/net/sf/gridarta/gui/MapFileFilter.java 2008-03-14 21:48:12 UTC (rev 3689) @@ -43,7 +43,7 @@ private static final MapFileFilter instance = new MapFileFilter(); /** - * Wether to actually perform real checks or just file endings. + * Whether to actually perform real checks or just file endings. * <code>true</code> = real checks, * <code>false</code> = fileendings only. */ @@ -72,7 +72,7 @@ /** * Set whether to actually perform real checks or just file endings. - * @param performingRealChecks <code>true</code> for performing real checks, <code>false</code> to compare only fileendings + * @param performingRealChecks <code>true</code> for performing real checks, <code>false</code> to compare only file endings */ public static void setPerformingRealChecks(final boolean performingRealChecks) { MapFileFilter.performingRealChecks = performingRealChecks; Modified: trunk/src/app/net/sf/gridarta/help/Help.java =================================================================== --- trunk/src/app/net/sf/gridarta/help/Help.java 2008-03-14 21:02:06 UTC (rev 3688) +++ trunk/src/app/net/sf/gridarta/help/Help.java 2008-03-14 21:48:12 UTC (rev 3689) @@ -25,7 +25,7 @@ import net.sf.japi.swing.DisposeAction; /** - * <code>CFHelp</code> implements the Help Window is a seperate frame with html content. + * <code>CFHelp</code> implements the Help Window is a separate frame with html content. * @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> @@ -46,7 +46,7 @@ * Creates a "Help". * @param parent the main view to get bounds from to position the help * @param fname may contain different things: - * 1. null -> the file "start.html" is opened + * 1. null -> the file "start.html" is opened * 2. File name of a html-file to be opened * 3. html-text to be displayed directly (no file) * (this text must start with "<HTML>") @@ -60,7 +60,7 @@ final Rectangle mvb = parent.getBounds(); // get main view bounds setBounds(mvb.x + (mvb.width >> 1) - 260, mvb.y + 70, 520, 600); // standard - if (fname == null) { // FIXME: Do not hardcode "start.html" + if (fname == null) { // FIXME: Do not hard-code "start.html" fname = "start.html"; } final HtmlPane html; Modified: trunk/src/app/net/sf/gridarta/io/PathManager.java =================================================================== --- trunk/src/app/net/sf/gridarta/io/PathManager.java 2008-03-14 21:02:06 UTC (rev 3688) +++ trunk/src/app/net/sf/gridarta/io/PathManager.java 2008-03-14 21:48:12 UTC (rev 3689) @@ -25,7 +25,7 @@ /** * This class contains methods for converting relative map paths to absolute map paths and vice versa. - * Serverside, paths to maps always are URIs with the maps directory being the root directory for the maps. + * Server-side, paths to maps always are URIs with the maps directory being the root directory for the maps. * Therefore it makes sense to treat them as URIs in the editor as well. * @author <a href="mailto:ch...@ri...">Christian Hujer</a> * @todo make more use of URI @@ -39,7 +39,7 @@ /** * Private constructor. - * There are only static methods, so prevent this class from being instanciated. + * There are only static methods, so prevent this class from being instantiated. */ private PathManager() { } @@ -54,7 +54,7 @@ /** * Create arch path. - * Replaces all occurences of '\' with '/' and removes the path to the arch directory (absolute, relative or canonical) from the path. + * Replaces all occurrences of '\' with '/' and removes the path to the arch directory (absolute, relative or canonical) from the path. * @param path to create arch path from * @return fixed path */ @@ -73,7 +73,7 @@ /** * Create map path. - * Replaces all occurences of '\' with '/' and removes the path to the map directory (absolute, relative or canonical) from the path. + * Replaces all occurrences of '\' with '/' and removes the path to the map directory (absolute, relative or canonical) from the path. * @param path to create map path from * @return fixed path */ @@ -125,7 +125,7 @@ * Converts a relative path to an absolute path. * If the path already is relative, this method simply returns the path. * If the reference ends on "/", it is treated as being a base directory, otherwise a file that's directory is taken as base. - * @param reference reference file the relative path works on. + * @param reference the reference file the relative path works on. * @param relative destination file with relative path * @return absolute path from the base directory */ @@ -149,7 +149,7 @@ * Converts an absolute path to a relative path. * If the path already is absolute, this method simply returns the path. * If the reference ends on "/", it is treated as being a base directory, otherwise a file that's directory is taken as base. - * @param reference reference file the relative path works on + * @param reference the reference file the relative path works on * @param absolute destination file with relative path * @return absolute path from the base directory */ @@ -201,7 +201,7 @@ * Counts the occurrences of a character within a string. * @param s String to count in * @param c character to count - * @return number of occurences of <var>c</var> in <var>s</var> + * @return number of occurrences of <var>c</var> in <var>s</var> */ private static int findOccurrences(final String s, final char c) { int occurrences = 0; Modified: trunk/src/app/net/sf/gridarta/map/validation/AbstractValidator.java =================================================================== --- trunk/src/app/net/sf/gridarta/map/validation/AbstractValidator.java 2008-03-14 21:02:06 UTC (rev 3688) +++ trunk/src/app/net/sf/gridarta/map/validation/AbstractValidator.java 2008-03-14 21:48:12 UTC (rev 3689) @@ -26,7 +26,7 @@ /** * This is the base class for validators. * @author <a href="mailto:ch...@ri...">Christian Hujer</a> - * @note that this class completely implements the interface Validator but does not declare it to force subclasses to choose the interface to implement. + * @note that this class completely implements the interface {@link Validator} but does not declare it to force subclasses to choose the interface to implement. */ public abstract class AbstractValidator implements Validator { @@ -39,10 +39,10 @@ /** Key. */ private final String key; - /** Wether this MapValidator is enabled. */ + /** Whether this MapValidator is enabled. */ private boolean enabled; - /** Wether this MapValidator is enabled by default. */ + /** Whether this MapValidator is enabled by default. */ private final boolean defaultEnabled; /** Modified: trunk/src/app/net/sf/gridarta/treasurelist/TreasureCellRenderer.java =================================================================== --- trunk/src/app/net/sf/gridarta/treasurelist/TreasureCellRenderer.java 2008-03-14 21:02:06 UTC (rev 3688) +++ trunk/src/app/net/sf/gridarta/treasurelist/TreasureCellRenderer.java 2008-03-14 21:48:12 UTC (rev 3689) @@ -124,7 +124,7 @@ } else { setIcon(noarch); } - // small empty border to keep icons seperated: + // small empty border to keep icons separated: setBorder(BorderFactory.createEmptyBorder(1, 0, 1, 0)); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-03-19 19:09:38
|
Revision: 3690 http://gridarta.svn.sourceforge.net/gridarta/?rev=3690&view=rev Author: akirschbaum Date: 2008-03-19 12:09:34 -0700 (Wed, 19 Mar 2008) Log Message: ----------- Remove unneeded code. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/daimonin/src/daieditor/CMainControl.java trunk/src/app/net/sf/gridarta/gui/archetypechooser/ArchetypeChooserControl.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-03-14 21:48:12 UTC (rev 3689) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-03-19 19:09:34 UTC (rev 3690) @@ -327,7 +327,6 @@ // browse arch archive // load object from a arch file you found - mainView.getObjectChooser().getArchetypeChooserControl().setTabPaneEnabled(false); defaultNamedFilterList = new NamedFilterList(); filterControl = new CFilterControl(null, this, defaultNamedFilterList); @@ -338,7 +337,6 @@ scriptControl.loadScripts(new File(getMapDir(), IGUIConstants.SCRIPTS_DIR)); mainView.setStatusText("Sorting..."); - mainView.getObjectChooser().getArchetypeChooserControl().setTabPaneEnabled(true); mainView.getObjectChooser().getArchetypeChooserControl().finishBuildProcess(); // load the autojoin lists Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-03-14 21:48:12 UTC (rev 3689) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-03-19 19:09:34 UTC (rev 3690) @@ -403,10 +403,8 @@ // browse arch archive // load object from a arch file you found - mainView.getObjectChooser().getArchetypeChooserControl().setTabPaneEnabled(false); mainView.setStatusText("Sorting..."); - mainView.getObjectChooser().getArchetypeChooserControl().setTabPaneEnabled(true); mainView.getObjectChooser().getArchetypeChooserControl().finishBuildProcess(); // load the autojoin lists Modified: trunk/src/app/net/sf/gridarta/gui/archetypechooser/ArchetypeChooserControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/archetypechooser/ArchetypeChooserControl.java 2008-03-14 21:48:12 UTC (rev 3689) +++ trunk/src/app/net/sf/gridarta/gui/archetypechooser/ArchetypeChooserControl.java 2008-03-19 19:09:34 UTC (rev 3690) @@ -137,18 +137,6 @@ } /** - * Sets the enabled state of the tab pane for Archetypes. - * @param tabPaneEnabled <code>true</code> to enable tab pane, <code>false</code> to disable it. - * @deprecated this should be done via MVC instead. - */ - @Deprecated public void setTabPaneEnabled(final boolean tabPaneEnabled) { - archPane.setEnabled(tabPaneEnabled); - if (tabPaneEnabled && selectedPanel != null) { - selectedPanel.showArchList(); - } - } - - /** * Return a panel by name. If this panel does not exist, create a new one. * * @param panelName the panel name This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-03-19 22:25:04
|
Revision: 3691 http://gridarta.svn.sourceforge.net/gridarta/?rev=3691&view=rev Author: akirschbaum Date: 2008-03-19 15:24:54 -0700 (Wed, 19 Mar 2008) Log Message: ----------- Add setup option to hide the main window's toolbar. Modified Paths: -------------- trunk/crossfire/ChangeLog trunk/crossfire/src/cfeditor/CMainView.java trunk/crossfire/src/cfeditor/gui/prefs/GUIPrefs.java trunk/daimonin/ChangeLog trunk/daimonin/src/daieditor/CMainView.java trunk/daimonin/src/daieditor/gui/prefs/GUIPrefs.java trunk/src/app/net/sf/gridarta/gui/MainView.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-03-19 19:09:34 UTC (rev 3690) +++ trunk/crossfire/ChangeLog 2008-03-19 22:24:54 UTC (rev 3691) @@ -1,3 +1,7 @@ +2008-03-19 Andreas Kirschbaum + + * Add setup option to hide the main window's toolbar. + 2008-03-09 Andreas Kirschbaum * Update archetypes. Modified: trunk/crossfire/src/cfeditor/CMainView.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainView.java 2008-03-19 19:09:34 UTC (rev 3690) +++ trunk/crossfire/src/cfeditor/CMainView.java 2008-03-19 22:24:54 UTC (rev 3691) @@ -33,12 +33,15 @@ import java.util.Collections; import java.util.List; import java.util.prefs.Preferences; +import java.util.prefs.PreferenceChangeEvent; +import java.util.prefs.PreferenceChangeListener; import javax.swing.Action; import javax.swing.ImageIcon; import javax.swing.JMenu; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JSplitPane; +import javax.swing.JToolBar; import javax.swing.event.InternalFrameEvent; import net.sf.gridarta.MainControl; import net.sf.gridarta.MenuHelper; @@ -118,6 +121,21 @@ /** The actions of the "Archetypes" menu. */ private ArchetypesActions<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> archetypesActions; + /** The toolbar. */ + private JToolBar mainToolbar = null; + + /** The listener to track preference changes. */ + private final PreferenceChangeListener preferenceChangeListener = new PreferenceChangeListener() + { + /** {@inheritDoc} */ + public void preferenceChange(final PreferenceChangeEvent evt) { + if (mainToolbar != null && evt.getKey().equals(SHOW_MAIN_TOOLBAR_KEY)) { + mainToolbar.setVisible(prefs.getBoolean(SHOW_MAIN_TOOLBAR_KEY, SHOW_MAIN_TOOLBAR_DEFAULT)); + } + } + + }; + /** * Constructs the main view and registers the given main controller. * @param mainControl MainControl to attach to. @@ -150,7 +168,10 @@ final int defwidth = (int) (0.9 * screen.getWidth()); final int defheight = (int) (0.9 * screen.getHeight()); - toolbarPanel.add(ACTION_FACTORY.createToolBar("main"), BorderLayout.NORTH); + mainToolbar = ACTION_FACTORY.createToolBar("main"); + toolbarPanel.add(mainToolbar, BorderLayout.NORTH); + prefs.addPreferenceChangeListener(preferenceChangeListener); + mainToolbar.setVisible(prefs.getBoolean(SHOW_MAIN_TOOLBAR_KEY, SHOW_MAIN_TOOLBAR_DEFAULT)); toolbarPanel.add(createCenterPanel(defwidth, defheight), BorderLayout.CENTER); archetypesActions = new ArchetypesActions<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(this, objectChooser.getArchetypeChooserControl(), mainControl.getArchetypeSet(), objectChooser); setJMenuBar(ACTION_FACTORY.createMenuBar(true, "main")); Modified: trunk/crossfire/src/cfeditor/gui/prefs/GUIPrefs.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/prefs/GUIPrefs.java 2008-03-19 19:09:34 UTC (rev 3690) +++ trunk/crossfire/src/cfeditor/gui/prefs/GUIPrefs.java 2008-03-19 22:24:54 UTC (rev 3691) @@ -61,6 +61,9 @@ /** Whether to place the map tile panel at the bottom or the right. */ private JCheckBox mapPanelBottom; + /** Whether to show the main window's toolbar. */ + private JCheckBox showMainToolbar; + /** Locale[]. */ private Locale[] locales; @@ -97,6 +100,7 @@ prefs.remove(MainControl.PREFS_LANGUAGE); } prefs.putBoolean(MainView.MAP_TILE_LIST_BOTTOM_KEY, mapPanelBottom.isSelected()); + prefs.putBoolean(MainView.SHOW_MAIN_TOOLBAR_KEY, showMainToolbar.isSelected()); } /** {@inheritDoc} */ @@ -104,12 +108,14 @@ final String current = prefs.get(MainControl.PREFS_LANGUAGE, null); localeBox.setSelectedIndex(Arrays.binarySearch(locales, current != null ? new Locale(current) : null, comp)); mapPanelBottom.setSelected(prefs.getBoolean(MainView.MAP_TILE_LIST_BOTTOM_KEY, CMainView.MAP_TILE_LIST_BOTTOM_DEFAULT)); + showMainToolbar.setSelected(prefs.getBoolean(MainView.SHOW_MAIN_TOOLBAR_KEY, MainView.SHOW_MAIN_TOOLBAR_DEFAULT)); } /** {@inheritDoc} */ public void defaults() { localeBox.setSelectedIndex(Arrays.binarySearch(locales, null, comp)); mapPanelBottom.setSelected(CMainView.MAP_TILE_LIST_BOTTOM_DEFAULT); + showMainToolbar.setSelected(MainView.SHOW_MAIN_TOOLBAR_DEFAULT); } /** {@inheritDoc} */ @@ -120,6 +126,7 @@ return !( (loc == null ? current == null : loc.equals(current)) && mapPanelBottom.isSelected() == prefs.getBoolean(MainView.MAP_TILE_LIST_BOTTOM_KEY, CMainView.MAP_TILE_LIST_BOTTOM_DEFAULT) + && showMainToolbar.isSelected() == prefs.getBoolean(MainView.SHOW_MAIN_TOOLBAR_KEY, MainView.SHOW_MAIN_TOOLBAR_DEFAULT) ); } @@ -175,6 +182,11 @@ mapPanelBottom = new JCheckBox(ACTION_FACTORY.createAction(false, "optionsSepMapTile")); mapPanelBottom.setSelected(prefs.getBoolean(MainView.MAP_TILE_LIST_BOTTOM_KEY, CMainView.MAP_TILE_LIST_BOTTOM_DEFAULT)); layoutPanel.add(mapPanelBottom); + + showMainToolbar = new JCheckBox(ACTION_FACTORY.createAction(false, "optionsShowMainToolbar")); + showMainToolbar.setSelected(prefs.getBoolean(MainView.SHOW_MAIN_TOOLBAR_KEY, MainView.SHOW_MAIN_TOOLBAR_DEFAULT)); + layoutPanel.add(showMainToolbar); + return layoutPanel; } Modified: trunk/daimonin/ChangeLog =================================================================== --- trunk/daimonin/ChangeLog 2008-03-19 19:09:34 UTC (rev 3690) +++ trunk/daimonin/ChangeLog 2008-03-19 22:24:54 UTC (rev 3691) @@ -1,3 +1,7 @@ +2008-03-19 Andreas Kirschbaum + + * Add setup option to hide the main window's toolbar. + 2008-03-09 Andreas Kirschbaum * Add syntax highlighting for AI objects. Modified: trunk/daimonin/src/daieditor/CMainView.java =================================================================== --- trunk/daimonin/src/daieditor/CMainView.java 2008-03-19 19:09:34 UTC (rev 3690) +++ trunk/daimonin/src/daieditor/CMainView.java 2008-03-19 22:24:54 UTC (rev 3691) @@ -33,12 +33,15 @@ import java.util.Collections; import java.util.List; import java.util.prefs.Preferences; +import java.util.prefs.PreferenceChangeEvent; +import java.util.prefs.PreferenceChangeListener; import javax.swing.Action; import javax.swing.ImageIcon; import javax.swing.JMenu; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JSplitPane; +import javax.swing.JToolBar; import javax.swing.event.InternalFrameEvent; import net.sf.gridarta.MainControl; import net.sf.gridarta.MenuHelper; @@ -122,6 +125,21 @@ /** The actions of the "Archetypes" menu. */ private ArchetypesActions<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> archetypesActions; + /** The toolbar. */ + private JToolBar mainToolbar = null; + + /** The listener to track preference changes. */ + private final PreferenceChangeListener preferenceChangeListener = new PreferenceChangeListener() + { + /** {@inheritDoc} */ + public void preferenceChange(final PreferenceChangeEvent evt) { + if (mainToolbar != null && evt.getKey().equals(SHOW_MAIN_TOOLBAR_KEY)) { + mainToolbar.setVisible(prefs.getBoolean(SHOW_MAIN_TOOLBAR_KEY, SHOW_MAIN_TOOLBAR_DEFAULT)); + } + } + + }; + /** * Constructs the main view and registers the given main controller. * @param mainControl MainControl to attach to. @@ -154,7 +172,10 @@ final int defwidth = (int) (0.9 * screen.getWidth()); final int defheight = (int) (0.9 * screen.getHeight()); - toolbarPanel.add(ACTION_FACTORY.createToolBar("main"), BorderLayout.NORTH); + mainToolbar = ACTION_FACTORY.createToolBar("main"); + toolbarPanel.add(mainToolbar, BorderLayout.NORTH); + prefs.addPreferenceChangeListener(preferenceChangeListener); + mainToolbar.setVisible(prefs.getBoolean(SHOW_MAIN_TOOLBAR_KEY, SHOW_MAIN_TOOLBAR_DEFAULT)); toolbarPanel.add(createCenterPanel(defwidth, defheight), BorderLayout.CENTER); archetypesActions = new ArchetypesActions<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(this, objectChooser.getArchetypeChooserControl(), mainControl.getArchetypeSet(), objectChooser); setJMenuBar(ACTION_FACTORY.createMenuBar(true, "main")); Modified: trunk/daimonin/src/daieditor/gui/prefs/GUIPrefs.java =================================================================== --- trunk/daimonin/src/daieditor/gui/prefs/GUIPrefs.java 2008-03-19 19:09:34 UTC (rev 3690) +++ trunk/daimonin/src/daieditor/gui/prefs/GUIPrefs.java 2008-03-19 22:24:54 UTC (rev 3691) @@ -61,6 +61,9 @@ /** Whether to place the map tile panel at the bottom or the right. */ private JCheckBox mapPanelBottom; + /** Whether to show the main window's toolbar. */ + private JCheckBox showMainToolbar; + /** Locale[]. */ private Locale[] locales; @@ -97,6 +100,7 @@ prefs.remove(MainControl.PREFS_LANGUAGE); } prefs.putBoolean(MainView.MAP_TILE_LIST_BOTTOM_KEY, mapPanelBottom.isSelected()); + prefs.putBoolean(MainView.SHOW_MAIN_TOOLBAR_KEY, showMainToolbar.isSelected()); } /** {@inheritDoc} */ @@ -104,12 +108,14 @@ final String current = prefs.get(MainControl.PREFS_LANGUAGE, null); localeBox.setSelectedIndex(Arrays.binarySearch(locales, current != null ? new Locale(current) : null, comp)); mapPanelBottom.setSelected(prefs.getBoolean(MainView.MAP_TILE_LIST_BOTTOM_KEY, CMainView.MAP_TILE_LIST_BOTTOM_DEFAULT)); + showMainToolbar.setSelected(prefs.getBoolean(MainView.SHOW_MAIN_TOOLBAR_KEY, MainView.SHOW_MAIN_TOOLBAR_DEFAULT)); } /** {@inheritDoc} */ public void defaults() { localeBox.setSelectedIndex(Arrays.binarySearch(locales, null, comp)); mapPanelBottom.setSelected(CMainView.MAP_TILE_LIST_BOTTOM_DEFAULT); + showMainToolbar.setSelected(MainView.SHOW_MAIN_TOOLBAR_DEFAULT); } /** {@inheritDoc} */ @@ -120,6 +126,7 @@ return !( (loc == null ? current == null : loc.equals(current)) && mapPanelBottom.isSelected() == prefs.getBoolean(MainView.MAP_TILE_LIST_BOTTOM_KEY, CMainView.MAP_TILE_LIST_BOTTOM_DEFAULT) + && showMainToolbar.isSelected() == prefs.getBoolean(MainView.SHOW_MAIN_TOOLBAR_KEY, MainView.SHOW_MAIN_TOOLBAR_DEFAULT) ); } @@ -175,6 +182,11 @@ mapPanelBottom = new JCheckBox(ACTION_FACTORY.createAction(false, "optionsSepMapTile")); mapPanelBottom.setSelected(prefs.getBoolean(MainView.MAP_TILE_LIST_BOTTOM_KEY, CMainView.MAP_TILE_LIST_BOTTOM_DEFAULT)); layoutPanel.add(mapPanelBottom); + + showMainToolbar = new JCheckBox(ACTION_FACTORY.createAction(false, "optionsShowMainToolbar")); + showMainToolbar.setSelected(prefs.getBoolean(MainView.SHOW_MAIN_TOOLBAR_KEY, MainView.SHOW_MAIN_TOOLBAR_DEFAULT)); + layoutPanel.add(showMainToolbar); + return layoutPanel; } Modified: trunk/src/app/net/sf/gridarta/gui/MainView.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/MainView.java 2008-03-19 19:09:34 UTC (rev 3690) +++ trunk/src/app/net/sf/gridarta/gui/MainView.java 2008-03-19 22:24:54 UTC (rev 3691) @@ -69,6 +69,12 @@ /** Key for info whether map-tile panel is separate or at bottom. */ public static final String MAP_TILE_LIST_BOTTOM_KEY = "MapTileBottom"; + /** Key for info whether the main windows's toolbar is shown. */ + public static final String SHOW_MAIN_TOOLBAR_KEY = "ShowMainToolbar"; + + /** Default value for whether the main windows's toolbar is shown. */ + public static final boolean SHOW_MAIN_TOOLBAR_DEFAULT = true; + /** The main statusbar. */ private final StatusBar statusBar; Modified: trunk/src/app/net/sf/gridarta/messages.properties =================================================================== --- trunk/src/app/net/sf/gridarta/messages.properties 2008-03-19 19:09:34 UTC (rev 3690) +++ trunk/src/app/net/sf/gridarta/messages.properties 2008-03-19 22:24:54 UTC (rev 3691) @@ -515,6 +515,8 @@ optionsLayout=Layout Settings optionsSepMapTile.text=Display Map-Tile Panel at the bottom optionsSepMapTile.shortdescription=Unchecking this moves the Map-Tile Panel to the right side of the screen instead of the bottom right corner. +optionsShowMainToolbar.text=Display toolbar +optionsShowMainToolbar.shortdescription=Display the main window''s toolbar. optionsResPaths=Resource Paths optionsResArch=Archfiles optionsResArch.shortdescription=Path name for archetype files @@ -565,6 +567,7 @@ prefs.ScriptEditWindow.width=Width of script editor. prefs.ScriptEditWindow.x=X coordinate of script editor. prefs.ScriptEditWindow.y=Y coordinate of script editor. +prefs.ShowMainToolbar=Whether the main windows''s toolbar is shown. prefs.systemExit=If set to false, never exit the application; should always be set to true except for debugging purposes. prefs.useImageSet=The image set to use. prefs.username=The user name to use for new maps. Modified: trunk/src/app/net/sf/gridarta/messages_de.properties =================================================================== --- trunk/src/app/net/sf/gridarta/messages_de.properties 2008-03-19 19:09:34 UTC (rev 3690) +++ trunk/src/app/net/sf/gridarta/messages_de.properties 2008-03-19 22:24:54 UTC (rev 3691) @@ -479,6 +479,8 @@ optionsLayout=Layout-Einstellungen optionsSepMapTile.text=Map-Tile-Panel unten anzeigen optionsSepMapTile.shortdescription=Map-Tile-Panel unten (anstatt rechts) anzeigen +optionsShowMainToolbar.text=Toolbar anzeigen +optionsShowMainToolbar.shortdescription=Toolbar des Hauptfensters anzeigen optionsResPaths=Pfade optionsResArch=Archetypen optionsResArch.shortdescription=Dateiname der Archetypen-Datei Modified: trunk/src/app/net/sf/gridarta/messages_fr.properties =================================================================== --- trunk/src/app/net/sf/gridarta/messages_fr.properties 2008-03-19 19:09:34 UTC (rev 3690) +++ trunk/src/app/net/sf/gridarta/messages_fr.properties 2008-03-19 22:24:54 UTC (rev 3691) @@ -478,6 +478,8 @@ #optionsLayout= #optionsSepMapTile.text= #optionsSepMapTile.shortdescription= +#optionsShowMainToolbar.text= +#optionsShowMainToolbar.shortdescription= #optionsResPaths= #optionsResArch= #optionsResArch.shortdescription= Modified: trunk/src/app/net/sf/gridarta/messages_sv.properties =================================================================== --- trunk/src/app/net/sf/gridarta/messages_sv.properties 2008-03-19 19:09:34 UTC (rev 3690) +++ trunk/src/app/net/sf/gridarta/messages_sv.properties 2008-03-19 22:24:54 UTC (rev 3691) @@ -477,6 +477,8 @@ optionsLayout=Layout optionsSepMapTile.text=Separat panel f\xF6r kartruta. optionsSepMapTile.shortdescription=Detta flyttar panelen f\xF6r enstaka kartrutor till sk\xE4rmens h\xF6gra kant ist\xE4llet f\xF6r nedre h\xF6gra h\xF6rnet. +#optionsShowMainToolbar.text= +#optionsShowMainToolbar.shortdescription= optionsResPaths=S\xF6kv\xE4gar f\xF6r resurser optionsResArch=Arketypfiler #optionsResArch.shortdescription= This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-03-19 22:36:01
|
Revision: 3692 http://gridarta.svn.sourceforge.net/gridarta/?rev=3692&view=rev Author: akirschbaum Date: 2008-03-19 15:35:03 -0700 (Wed, 19 Mar 2008) Log Message: ----------- Make saving settings work on Windows. Modified Paths: -------------- trunk/crossfire/ChangeLog trunk/src/app/net/sf/gridarta/preferences/Storage.java Modified: trunk/crossfire/ChangeLog =================================================================== --- trunk/crossfire/ChangeLog 2008-03-19 22:24:54 UTC (rev 3691) +++ trunk/crossfire/ChangeLog 2008-03-19 22:35:03 UTC (rev 3692) @@ -1,5 +1,7 @@ 2008-03-19 Andreas Kirschbaum + * Make saving settings work on Windows. + * Add setup option to hide the main window's toolbar. 2008-03-09 Andreas Kirschbaum Modified: trunk/src/app/net/sf/gridarta/preferences/Storage.java =================================================================== --- trunk/src/app/net/sf/gridarta/preferences/Storage.java 2008-03-19 22:24:54 UTC (rev 3691) +++ trunk/src/app/net/sf/gridarta/preferences/Storage.java 2008-03-19 22:35:03 UTC (rev 3692) @@ -360,6 +360,7 @@ fos.close(); } + file.delete(); // Windows cannot overwrite destination file on rename if (!tmpFile.renameTo(file)) { throw new IOException("cannot rename " + tmpFile + " to " + file); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-03-20 19:17:02
|
Revision: 3696 http://gridarta.svn.sourceforge.net/gridarta/?rev=3696&view=rev Author: akirschbaum Date: 2008-03-20 12:17:02 -0700 (Thu, 20 Mar 2008) Log Message: ----------- Fix typos. Modified Paths: -------------- trunk/crossfire/ChangeLog trunk/daimonin/ChangeLog Modified: trunk/crossfire/ChangeLog =================================================================== --- trunk/crossfire/ChangeLog 2008-03-20 19:13:17 UTC (rev 3695) +++ trunk/crossfire/ChangeLog 2008-03-20 19:17:02 UTC (rev 3696) @@ -17,7 +17,7 @@ 2008-03-05 Andreas Kirschbaum - * Add support for "multiply speed" (maxsp) field in geneators. + * Add support for "multiply speed" (maxsp) field in generators. 2008-03-02 Andreas Kirschbaum @@ -26,7 +26,7 @@ * Make fill and replace work when no cursor is active. * Remove "cursor" menu from main menu bar. Fixes #1726143 (Weird - behaviour with *). + behavior with *). 2008-02-22 Andreas Kirschbaum @@ -735,7 +735,7 @@ * Make connection view highlight affected game objects in the map view. - * Add some French and Svedish translations. + * Add some French and Swedish translations. * Update main window title. Modified: trunk/daimonin/ChangeLog =================================================================== --- trunk/daimonin/ChangeLog 2008-03-20 19:13:17 UTC (rev 3695) +++ trunk/daimonin/ChangeLog 2008-03-20 19:17:02 UTC (rev 3696) @@ -18,7 +18,7 @@ * Make fill and replace work when no cursor is active. * Remove "cursor" menu from main menu bar. Fixes #1726143 (Weird - behaviour with *). + behavior with *). 2008-02-22 Andreas Kirschbaum This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-03-20 19:42:17
|
Revision: 3697 http://gridarta.svn.sourceforge.net/gridarta/?rev=3697&view=rev Author: akirschbaum Date: 2008-03-20 12:42:17 -0700 (Thu, 20 Mar 2008) Log Message: ----------- Remove static functions from NewMapDialogFactory. 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/NewMapDialogFactory.java trunk/src/app/net/sf/gridarta/gui/pickmapchooser/Actions.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-03-20 19:17:02 UTC (rev 3696) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-03-20 19:42:17 UTC (rev 3697) @@ -247,6 +247,9 @@ /** The filter control. */ private final CFilterControl filterControl; + /** The factory for creating new maps or pickmaps. */ + private final NewMapDialogFactory<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> newMapDialogFactory = new NewMapDialogFactory<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(); + /** * Constructs the main controller and its model and view. * @@ -271,7 +274,7 @@ ScriptEditControl.init(strMapDir, this); // Initialize the main view - mainView.init(); + mainView.init(newMapDialogFactory); scriptControl.getView().setMenu((JMenu) ACTION_FACTORY.find(mainView.getJMenuBar(), "plugins")); archetypeParser = new ArchetypeParser(this, mainView.getObjectChooser().getArchetypeChooserControl()); animationObjects = new AnimationObjects(); @@ -641,7 +644,7 @@ * @param filename desired filename for the new map, null if not specified */ public void newLevelWanted(final String filename) { - NewMapDialogFactory.showNewMapDialog(this, filename, false, false, IGUIConstants.DEF_MAPSIZE, IGUIConstants.DEF_MAPSIZE, 0); + newMapDialogFactory.showNewMapDialog(this, filename, false, false, IGUIConstants.DEF_MAPSIZE, IGUIConstants.DEF_MAPSIZE, 0); } /** Invoked when user wants to open a file. */ Modified: trunk/crossfire/src/cfeditor/CMainView.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainView.java 2008-03-20 19:17:02 UTC (rev 3696) +++ trunk/crossfire/src/cfeditor/CMainView.java 2008-03-20 19:42:17 UTC (rev 3697) @@ -49,6 +49,7 @@ 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.selectedsquare.SelectedSquareControl; @@ -158,8 +159,9 @@ /** * Initializes (builds) this view. + * @param newMapDialogFactory the factory for creating new pickmaps */ - void init() { + void init(@NotNull final NewMapDialogFactory<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> newMapDialogFactory) { final JPanel toolbarPanel = new JPanel(new BorderLayout()); add(toolbarPanel, BorderLayout.CENTER); @@ -172,7 +174,7 @@ toolbarPanel.add(mainToolbar, BorderLayout.NORTH); prefs.addPreferenceChangeListener(preferenceChangeListener); mainToolbar.setVisible(prefs.getBoolean(SHOW_MAIN_TOOLBAR_KEY, SHOW_MAIN_TOOLBAR_DEFAULT)); - toolbarPanel.add(createCenterPanel(defwidth, defheight), BorderLayout.CENTER); + toolbarPanel.add(createCenterPanel(defwidth, defheight, newMapDialogFactory), BorderLayout.CENTER); archetypesActions = new ArchetypesActions<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(this, objectChooser.getArchetypeChooserControl(), mainControl.getArchetypeSet(), objectChooser); setJMenuBar(ACTION_FACTORY.createMenuBar(true, "main")); @@ -192,16 +194,17 @@ * Create the center panel. * @param defwidth default width * @param defheight default height + * @param newMapDialogFactory the factory for creating new pickmaps * @return center panel */ - private JPanel createCenterPanel(final int defwidth, final int defheight) { + private JPanel createCenterPanel(final int defwidth, final int defheight, @NotNull final NewMapDialogFactory<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> newMapDialogFactory) { 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(mainControl); + objectChooser = new InsertionObjectChooser(newMapDialogFactory, mainControl); selectedSquareControl = new SelectedSquareControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>("cfeditor", mainControl, this, mapTileListBottom, null); final LockedItemsControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> lockedItemsControl = new LockedItemsControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(mainControl, 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, this, lockedItemsControl); Modified: trunk/crossfire/src/cfeditor/gui/InsertionObjectChooser.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/InsertionObjectChooser.java 2008-03-20 19:17:02 UTC (rev 3696) +++ trunk/crossfire/src/cfeditor/gui/InsertionObjectChooser.java 2008-03-20 19:42:17 UTC (rev 3697) @@ -37,6 +37,7 @@ 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; @@ -82,10 +83,11 @@ /** * Build Panel. + * @param newMapDialogFactory the factory for creating new pickmaps * @param mainControl CMainControl */ - public InsertionObjectChooser(final CMainControl mainControl) { - pickmapChooserControl = new PickmapChooserControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(mainControl, this, IGUIConstants.DEF_PICKMAP_WIDTH, IGUIConstants.DEF_PICKMAP_HEIGHT); + 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, IGUIConstants.DEF_PICKMAP_WIDTH, IGUIConstants.DEF_PICKMAP_HEIGHT); 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-03-20 19:17:02 UTC (rev 3696) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-03-20 19:42:17 UTC (rev 3697) @@ -299,6 +299,9 @@ /** The auto-validator. */ private final AutoValidator<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> autoValidator; + /** The factory for creating new maps or pickmaps. */ + private final NewMapDialogFactory<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> newMapDialogFactory = new NewMapDialogFactory<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(); + /** * Constructs the main controller and its model and view. * @@ -327,7 +330,7 @@ ScriptEditControl.init(strMapDir, this); // Initialize the main view - mainView.init(); + mainView.init(newMapDialogFactory); archetypeParser = new ArchetypeParser(this, mainView.getObjectChooser().getArchetypeChooserControl()); animationObjects = new AnimationObjects(); faceObjects = new FaceObjects(); @@ -789,7 +792,7 @@ * @param filename desired filename for the new map, null if not specified */ public void newLevelWanted(final String filename) { - NewMapDialogFactory.showNewMapDialog(this, filename, true, true, IGUIConstants.DEF_MAPSIZE, IGUIConstants.DEF_MAPSIZE, IGUIConstants.DEF_MAPDIFFICULTY); + newMapDialogFactory.showNewMapDialog(this, filename, true, true, IGUIConstants.DEF_MAPSIZE, IGUIConstants.DEF_MAPSIZE, IGUIConstants.DEF_MAPDIFFICULTY); } /** Invoked when user wants to open a file. */ Modified: trunk/daimonin/src/daieditor/CMainView.java =================================================================== --- trunk/daimonin/src/daieditor/CMainView.java 2008-03-20 19:17:02 UTC (rev 3696) +++ trunk/daimonin/src/daieditor/CMainView.java 2008-03-20 19:42:17 UTC (rev 3697) @@ -49,6 +49,7 @@ 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.selectedsquare.SelectedSquareControl; @@ -162,8 +163,9 @@ /** * Initializes (builds) this view. + * @param newMapDialogFactory the factory for creating new pickmaps */ - void init() { + void init(@NotNull final NewMapDialogFactory<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> newMapDialogFactory) { final JPanel toolbarPanel = new JPanel(new BorderLayout()); add(toolbarPanel, BorderLayout.CENTER); @@ -176,7 +178,7 @@ toolbarPanel.add(mainToolbar, BorderLayout.NORTH); prefs.addPreferenceChangeListener(preferenceChangeListener); mainToolbar.setVisible(prefs.getBoolean(SHOW_MAIN_TOOLBAR_KEY, SHOW_MAIN_TOOLBAR_DEFAULT)); - toolbarPanel.add(createCenterPanel(defwidth, defheight), BorderLayout.CENTER); + toolbarPanel.add(createCenterPanel(defwidth, defheight, newMapDialogFactory), BorderLayout.CENTER); archetypesActions = new ArchetypesActions<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(this, objectChooser.getArchetypeChooserControl(), mainControl.getArchetypeSet(), objectChooser); setJMenuBar(ACTION_FACTORY.createMenuBar(true, "main")); @@ -196,16 +198,17 @@ * Create the center panel. * @param defwidth default width * @param defheight default height + * @param newMapDialogFactory the factory for creating new pickmaps * @return center panel */ - private JPanel createCenterPanel(final int defwidth, final int defheight) { + private JPanel createCenterPanel(final int defwidth, final int defheight, @NotNull final NewMapDialogFactory<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> newMapDialogFactory) { 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(mainControl); + objectChooser = new InsertionObjectChooser(newMapDialogFactory, mainControl); selectedSquareControl = new SelectedSquareControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>("daieditor", mainControl, this, mapTileListBottom, GUIUtils.getSysIcon(IGUIConstants.TILE_NORTH)); final LockedItemsControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> lockedItemsControl = new LockedItemsControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(mainControl, 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, this, lockedItemsControl); Modified: trunk/daimonin/src/daieditor/gui/InsertionObjectChooser.java =================================================================== --- trunk/daimonin/src/daieditor/gui/InsertionObjectChooser.java 2008-03-20 19:17:02 UTC (rev 3696) +++ trunk/daimonin/src/daieditor/gui/InsertionObjectChooser.java 2008-03-20 19:42:17 UTC (rev 3697) @@ -34,6 +34,7 @@ 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; @@ -74,10 +75,11 @@ /** * Build Panel. + * @param newMapDialogFactory the factory for creating new pickmaps * @param mainControl CMainControl */ - public InsertionObjectChooser(final CMainControl mainControl) { - pickmapChooserControl = new PickmapChooserControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(mainControl, this, IGUIConstants.DEF_PICKMAP_WIDTH, IGUIConstants.DEF_PICKMAP_HEIGHT); + 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, IGUIConstants.DEF_PICKMAP_WIDTH, IGUIConstants.DEF_PICKMAP_HEIGHT); 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/gui/NewMapDialogFactory.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/NewMapDialogFactory.java 2008-03-20 19:17:02 UTC (rev 3696) +++ trunk/src/app/net/sf/gridarta/gui/NewMapDialogFactory.java 2008-03-20 19:42:17 UTC (rev 3697) @@ -32,15 +32,9 @@ * * @author Andreas Kirschbaum */ -public final class NewMapDialogFactory { +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>> { /** - * Private constructor to prevent instantiation. - */ - private NewMapDialogFactory() { - } - - /** * Show a dialog for creating a new map. * @param mainControl the controller of this dialog. * @param filename desired filename for new map, null if not specified @@ -50,8 +44,8 @@ * @param defaultHeight The default height for new maps. * @param defaultDifficulty The default difficulty for new maps. */ - public static <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>> void showNewMapDialog(final MainControl<G, A, R, C, V> mainControl, final String filename, final boolean showMapSizeDefault, final boolean showMapDifficulty, final int defaultWidth, final int defaultHeight, final int defaultDifficulty) { - new NewMapDialog(mainControl, mainControl.getMainView(), filename, MapType.GAMEMAP, showMapSizeDefault, showMapDifficulty, defaultWidth, defaultHeight, defaultDifficulty); + public void showNewMapDialog(final MainControl<G, A, R, C, V> mainControl, final String filename, final boolean showMapSizeDefault, final boolean showMapDifficulty, final int defaultWidth, final int defaultHeight, final int defaultDifficulty) { + new NewMapDialog<G, A, R, C, V>(mainControl, mainControl.getMainView(), filename, MapType.GAMEMAP, showMapSizeDefault, showMapDifficulty, defaultWidth, defaultHeight, defaultDifficulty); } /** @@ -60,8 +54,8 @@ * @param defaultWidth The default width for new maps. * @param defaultHeight The default height for new maps. */ - public static <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>> void showNewPickmapDialog(final MainControl<G, A, R, C, V> mainControl, final int defaultWidth, final int defaultHeight) { - new NewMapDialog(mainControl, mainControl.getMainView(), null, MapType.PICKMAP, false, false, defaultWidth, defaultHeight, 0); + public void showNewPickmapDialog(final MainControl<G, A, R, C, V> mainControl, final int defaultWidth, final int defaultHeight) { + new NewMapDialog<G, A, R, C, V>(mainControl, mainControl.getMainView(), null, MapType.PICKMAP, false, false, defaultWidth, defaultHeight, 0); } } // class NewMapDialogFactory Modified: trunk/src/app/net/sf/gridarta/gui/pickmapchooser/Actions.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/pickmapchooser/Actions.java 2008-03-20 19:17:02 UTC (rev 3696) +++ trunk/src/app/net/sf/gridarta/gui/pickmapchooser/Actions.java 2008-03-20 19:42:17 UTC (rev 3697) @@ -53,6 +53,9 @@ */ private static final String PICKMAPS_LOCKED = "pickmapsLocked"; + /** The factory for creating new pickmaps. */ + @NotNull private final NewMapDialogFactory<G, A, R, C, V> newMapDialogFactory; + /** Action called for "add new pickmap". */ private final Action aAddNewPickmap = ACTION_FACTORY.createAction(true, "addNewPickmap", this); @@ -114,6 +117,8 @@ /** * Create a new instance. * + * @param newMapDialogFactory the factory for creating new pickmaps + * * @param control the control to forward to * * @param mainControl The main control. @@ -122,7 +127,8 @@ * * @param defaultPickmapHeight The default height of a new pickmap. */ - public Actions(@NotNull final PickmapChooserControl<G, A, R, C, V> control, @NotNull final MainControl<G, A, R, C, V> mainControl, final int defaultPickmapWidth, final int defaultPickmapHeight) { + public Actions(@NotNull final NewMapDialogFactory<G, A, R, C, V> newMapDialogFactory, @NotNull final PickmapChooserControl<G, A, R, C, V> control, @NotNull final MainControl<G, A, R, C, V> mainControl, final int defaultPickmapWidth, final int defaultPickmapHeight) { + this.newMapDialogFactory = newMapDialogFactory; this.control = control; this.mainControl = mainControl; this.defaultPickmapWidth = defaultPickmapWidth; @@ -151,7 +157,7 @@ /** Invoked when user wants to open a new pickmap. */ public void addNewPickmap() { if (isAddNewPickmapEnabled()) { - NewMapDialogFactory.showNewPickmapDialog(mainControl, defaultPickmapWidth, defaultPickmapHeight); + newMapDialogFactory.showNewPickmapDialog(mainControl, defaultPickmapWidth, defaultPickmapHeight); } } Modified: trunk/src/app/net/sf/gridarta/gui/pickmapchooser/PickmapChooserControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/pickmapchooser/PickmapChooserControl.java 2008-03-20 19:17:02 UTC (rev 3696) +++ trunk/src/app/net/sf/gridarta/gui/pickmapchooser/PickmapChooserControl.java 2008-03-20 19:42:17 UTC (rev 3697) @@ -32,6 +32,7 @@ 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.io.MapReader; import net.sf.gridarta.map.MapArchObject; @@ -118,15 +119,16 @@ /** * Create a PickmapChooserControl. + * @param newMapDialogFactory the factory for creating new pickmaps * @param mainControl the main control * @param objectChooser the object chooser * @param defaultPickmapWidth The default width of a new pickmap. * @param defaultPickmapHeight The default height of a new pickmap. */ - public PickmapChooserControl(@NotNull final MainControl<G, A, R, C, V> mainControl, @NotNull final InsertionObjectChooser<G, A, R> objectChooser, final int defaultPickmapWidth, final int defaultPickmapHeight) { + 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, final int defaultPickmapWidth, final int defaultPickmapHeight) { this.mainControl = mainControl; this.objectChooser = objectChooser; - actions = new Actions<G, A, R, C, V>(this, mainControl, defaultPickmapWidth, defaultPickmapHeight); + actions = new Actions<G, A, R, C, V>(newMapDialogFactory, this, mainControl, defaultPickmapWidth, defaultPickmapHeight); view = new PickmapChooserView(); actions.init(); view.addChangeListener(new PickmapSelectionListener(this, objectChooser)); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-03-20 20:10:52
|
Revision: 3698 http://gridarta.svn.sourceforge.net/gridarta/?rev=3698&view=rev Author: akirschbaum Date: 2008-03-20 13:10:57 -0700 (Thu, 20 Mar 2008) Log Message: ----------- Simplify NewMapDialogFactory methods. 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/InsertionObjectChooser.java trunk/src/app/net/sf/gridarta/gui/NewMapDialogFactory.java trunk/src/app/net/sf/gridarta/gui/pickmapchooser/Actions.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-03-20 19:42:17 UTC (rev 3697) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-03-20 20:10:57 UTC (rev 3698) @@ -248,7 +248,7 @@ private final CFilterControl filterControl; /** The factory for creating new maps or pickmaps. */ - private final NewMapDialogFactory<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> newMapDialogFactory = new NewMapDialogFactory<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(); + private final NewMapDialogFactory<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> newMapDialogFactory = new NewMapDialogFactory<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(this, IGUIConstants.DEF_MAPSIZE, IGUIConstants.DEF_MAPSIZE, 0, false, false, IGUIConstants.DEF_PICKMAP_WIDTH, IGUIConstants.DEF_PICKMAP_HEIGHT); /** * Constructs the main controller and its model and view. @@ -644,7 +644,7 @@ * @param filename desired filename for the new map, null if not specified */ public void newLevelWanted(final String filename) { - newMapDialogFactory.showNewMapDialog(this, filename, false, false, IGUIConstants.DEF_MAPSIZE, IGUIConstants.DEF_MAPSIZE, 0); + newMapDialogFactory.showNewMapDialog(filename); } /** Invoked when user wants to open a file. */ Modified: trunk/crossfire/src/cfeditor/gui/InsertionObjectChooser.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/InsertionObjectChooser.java 2008-03-20 19:42:17 UTC (rev 3697) +++ trunk/crossfire/src/cfeditor/gui/InsertionObjectChooser.java 2008-03-20 20:10:57 UTC (rev 3698) @@ -87,7 +87,7 @@ * @param mainControl CMainControl */ 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, IGUIConstants.DEF_PICKMAP_WIDTH, IGUIConstants.DEF_PICKMAP_HEIGHT); + pickmapChooserControl = new PickmapChooserControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(newMapDialogFactory, mainControl, this); 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-03-20 19:42:17 UTC (rev 3697) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-03-20 20:10:57 UTC (rev 3698) @@ -300,7 +300,7 @@ private final AutoValidator<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> autoValidator; /** The factory for creating new maps or pickmaps. */ - private final NewMapDialogFactory<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> newMapDialogFactory = new NewMapDialogFactory<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(); + private final NewMapDialogFactory<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> newMapDialogFactory = new NewMapDialogFactory<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(this, IGUIConstants.DEF_MAPSIZE, IGUIConstants.DEF_MAPSIZE, IGUIConstants.DEF_MAPDIFFICULTY, true, true, IGUIConstants.DEF_PICKMAP_WIDTH, IGUIConstants.DEF_PICKMAP_HEIGHT); /** * Constructs the main controller and its model and view. @@ -792,7 +792,7 @@ * @param filename desired filename for the new map, null if not specified */ public void newLevelWanted(final String filename) { - newMapDialogFactory.showNewMapDialog(this, filename, true, true, IGUIConstants.DEF_MAPSIZE, IGUIConstants.DEF_MAPSIZE, IGUIConstants.DEF_MAPDIFFICULTY); + newMapDialogFactory.showNewMapDialog(filename); } /** Invoked when user wants to open a file. */ Modified: trunk/daimonin/src/daieditor/gui/InsertionObjectChooser.java =================================================================== --- trunk/daimonin/src/daieditor/gui/InsertionObjectChooser.java 2008-03-20 19:42:17 UTC (rev 3697) +++ trunk/daimonin/src/daieditor/gui/InsertionObjectChooser.java 2008-03-20 20:10:57 UTC (rev 3698) @@ -79,7 +79,7 @@ * @param mainControl CMainControl */ 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, IGUIConstants.DEF_PICKMAP_WIDTH, IGUIConstants.DEF_PICKMAP_HEIGHT); + pickmapChooserControl = new PickmapChooserControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(newMapDialogFactory, mainControl, this); 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/gui/NewMapDialogFactory.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/NewMapDialogFactory.java 2008-03-20 19:42:17 UTC (rev 3697) +++ trunk/src/app/net/sf/gridarta/gui/NewMapDialogFactory.java 2008-03-20 20:10:57 UTC (rev 3698) @@ -26,6 +26,7 @@ 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. @@ -35,27 +36,82 @@ 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>> { /** - * Show a dialog for creating a new map. - * @param mainControl the controller of this dialog. - * @param filename desired filename for new map, null if not specified - * @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. + * The main control instance. */ - public void showNewMapDialog(final MainControl<G, A, R, C, V> mainControl, final String filename, final boolean showMapSizeDefault, final boolean showMapDifficulty, final int defaultWidth, final int defaultHeight, final int defaultDifficulty) { - new NewMapDialog<G, A, R, C, V>(mainControl, mainControl.getMainView(), filename, MapType.GAMEMAP, showMapSizeDefault, showMapDifficulty, defaultWidth, defaultHeight, defaultDifficulty); + @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; } /** - * Show a dialog for creating a new pickmap. - * @param mainControl the controller of this dialog. - * @param defaultWidth The default width for new maps. - * @param defaultHeight The default height for new maps. + * Shows a dialog for creating a new map. + * @param filename the filename for the new map; <code>null</code> if + * unknown */ - public void showNewPickmapDialog(final MainControl<G, A, R, C, V> mainControl, final int defaultWidth, final int defaultHeight) { - new NewMapDialog<G, A, R, C, V>(mainControl, mainControl.getMainView(), null, MapType.PICKMAP, false, false, defaultWidth, defaultHeight, 0); + 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/Actions.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/pickmapchooser/Actions.java 2008-03-20 19:42:17 UTC (rev 3697) +++ trunk/src/app/net/sf/gridarta/gui/pickmapchooser/Actions.java 2008-03-20 20:10:57 UTC (rev 3698) @@ -74,15 +74,6 @@ /** The control to forward to. */ @NotNull private final PickmapChooserControl<G, A, R, C, V> control; - /** The main control. */ - @NotNull private final MainControl<G, A, R, C, V> mainControl; - - /** The default width of a new pickmap. */ - private final int defaultPickmapWidth; - - /** The default height of a new pickmap. */ - private final int defaultPickmapHeight; - /** The current active pickmap ontop. */ private C currentPickmap = null; @@ -120,19 +111,10 @@ * @param newMapDialogFactory the factory for creating new pickmaps * * @param control the control to forward to - * - * @param mainControl The main control. - * - * @param defaultPickmapWidth The default width of a new pickmap. - * - * @param defaultPickmapHeight The default height of a new pickmap. */ - public Actions(@NotNull final NewMapDialogFactory<G, A, R, C, V> newMapDialogFactory, @NotNull final PickmapChooserControl<G, A, R, C, V> control, @NotNull final MainControl<G, A, R, C, V> mainControl, final int defaultPickmapWidth, final int defaultPickmapHeight) { + public Actions(@NotNull final NewMapDialogFactory<G, A, R, C, V> newMapDialogFactory, @NotNull final PickmapChooserControl<G, A, R, C, V> control) { this.newMapDialogFactory = newMapDialogFactory; this.control = control; - this.mainControl = mainControl; - this.defaultPickmapWidth = defaultPickmapWidth; - this.defaultPickmapHeight = defaultPickmapHeight; //noinspection AbstractMethodCallInConstructor lockAllPickmaps = getLockAllPickmapsFromPrefs(); ACTION_FACTORY.createToggles(true, this, "lockAllPickmaps"); @@ -157,7 +139,7 @@ /** Invoked when user wants to open a new pickmap. */ public void addNewPickmap() { if (isAddNewPickmapEnabled()) { - newMapDialogFactory.showNewPickmapDialog(mainControl, defaultPickmapWidth, defaultPickmapHeight); + newMapDialogFactory.showNewPickmapDialog(); } } Modified: trunk/src/app/net/sf/gridarta/gui/pickmapchooser/PickmapChooserControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/pickmapchooser/PickmapChooserControl.java 2008-03-20 19:42:17 UTC (rev 3697) +++ trunk/src/app/net/sf/gridarta/gui/pickmapchooser/PickmapChooserControl.java 2008-03-20 20:10:57 UTC (rev 3698) @@ -122,13 +122,11 @@ * @param newMapDialogFactory the factory for creating new pickmaps * @param mainControl the main control * @param objectChooser the object chooser - * @param defaultPickmapWidth The default width of a new pickmap. - * @param defaultPickmapHeight The default height of a new pickmap. */ - 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, final int defaultPickmapWidth, final int defaultPickmapHeight) { + 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) { this.mainControl = mainControl; this.objectChooser = objectChooser; - actions = new Actions<G, A, R, C, V>(newMapDialogFactory, this, mainControl, defaultPickmapWidth, defaultPickmapHeight); + actions = new Actions<G, A, R, C, V>(newMapDialogFactory, this); view = new PickmapChooserView(); actions.init(); view.addChangeListener(new PickmapSelectionListener(this, objectChooser)); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-03-20 22:22:15
|
Revision: 3702 http://gridarta.svn.sourceforge.net/gridarta/?rev=3702&view=rev Author: akirschbaum Date: 2008-03-20 15:22:08 -0700 (Thu, 20 Mar 2008) Log Message: ----------- In map properties dialog, prevent unintentional changes by not extending checkbox lines to the available width. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gui/map/MapPropertiesDialog.java trunk/daimonin/src/daieditor/gui/map/MapPropertiesDialog.java Modified: trunk/crossfire/src/cfeditor/gui/map/MapPropertiesDialog.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/map/MapPropertiesDialog.java 2008-03-20 21:50:03 UTC (rev 3701) +++ trunk/crossfire/src/cfeditor/gui/map/MapPropertiesDialog.java 2008-03-20 22:22:08 UTC (rev 3702) @@ -26,6 +26,7 @@ import java.awt.Component; import java.awt.FlowLayout; import java.awt.GridLayout; +import javax.swing.BoxLayout; import javax.swing.JButton; import javax.swing.JCheckBox; import javax.swing.JDialog; @@ -371,10 +372,13 @@ * @param labelKey (attribute-)label key * @return created Checkbox */ - private static JCheckBox createPanelCBox(final JCheckBox checkBox, final boolean state, final String labelKey) { + private static JPanel createPanelCBox(final JCheckBox checkBox, final boolean state, final String labelKey) { + final JPanel panel = new JPanel(); + panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS)); + panel.add(checkBox); checkBox.setText(ACTION_FACTORY.getString(labelKey)); checkBox.setSelected(state); - return checkBox; + return panel; } /** Modified: trunk/daimonin/src/daieditor/gui/map/MapPropertiesDialog.java =================================================================== --- trunk/daimonin/src/daieditor/gui/map/MapPropertiesDialog.java 2008-03-20 21:50:03 UTC (rev 3701) +++ trunk/daimonin/src/daieditor/gui/map/MapPropertiesDialog.java 2008-03-20 22:22:08 UTC (rev 3702) @@ -31,6 +31,7 @@ import java.awt.Insets; import java.io.File; import javax.swing.BorderFactory; +import javax.swing.BoxLayout; import javax.swing.JButton; import javax.swing.JCheckBox; import javax.swing.JComponent; @@ -386,10 +387,13 @@ * @param labelKey (attribute-)label key * @return created Checkbox */ - private static JCheckBox createPanelCBox(final JCheckBox checkBox, final boolean state, final String labelKey) { + private static JPanel createPanelCBox(final JCheckBox checkBox, final boolean state, final String labelKey) { + final JPanel panel = new JPanel(); + panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS)); + panel.add(checkBox); checkBox.setText(ACTION_FACTORY.getString(labelKey)); checkBox.setSelected(state); - return checkBox; + return panel; } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-03-20 23:34:45
|
Revision: 3704 http://gridarta.svn.sourceforge.net/gridarta/?rev=3704&view=rev Author: akirschbaum Date: 2008-03-20 16:34:50 -0700 (Thu, 20 Mar 2008) Log Message: ----------- Unify error message formatting. Modified Paths: -------------- trunk/crossfire/src/cfeditor/messages.properties trunk/daimonin/src/daieditor/messages.properties Modified: trunk/crossfire/src/cfeditor/messages.properties =================================================================== --- trunk/crossfire/src/cfeditor/messages.properties 2008-03-20 23:31:43 UTC (rev 3703) +++ trunk/crossfire/src/cfeditor/messages.properties 2008-03-20 23:34:50 UTC (rev 3704) @@ -430,6 +430,6 @@ logDuplicateAnimation=Duplicate Animation: {0} logInventoryInDefArch=Found inventory Object in def arch: {0} logFoundCoordInDefArchSingleTileOrHead=Found {0} cmd in single tile or head (add it to arch text): {1} -logDefArchWithZeroType=Arch {0} type number is zero. +logDefArchWithZeroType=Archetype type number is zero: {0}. logDefArchWithInvalidTypeNr=Arch {0} has an invalid type nr: {1} logDefArchWithInvalidDirection=Arch {0} has an invalid direction: {1} Modified: trunk/daimonin/src/daieditor/messages.properties =================================================================== --- trunk/daimonin/src/daieditor/messages.properties 2008-03-20 23:31:43 UTC (rev 3703) +++ trunk/daimonin/src/daieditor/messages.properties 2008-03-20 23:34:50 UTC (rev 3704) @@ -599,7 +599,7 @@ logDuplicateAnimation=Duplicate Animation: {0} logInventoryInDefArch=Found inventory Object in def arch: {0} logFoundCoordInDefArchSingleTileOrHead=Found {0} cmd in single tile or head (add it to arch text): {0} -logDefArchWithZeroType=Arch {0} type number is zero. +logDefArchWithZeroType=Archetype type number is zero: {0}. logDefArchWithInvalidTypeNr=Arch {0} has an invalid type nr: {1} logDefArchWithInvalidDirection=Arch {0} has an invalid direction: {1} logDefArchWithInvalidMpartNr=Arch part {0} has mpart_nr {2}, but head part {1} has mpart_nr {3} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-03-21 16:06:53
|
Revision: 3713 http://gridarta.svn.sourceforge.net/gridarta/?rev=3713&view=rev Author: akirschbaum Date: 2008-03-21 09:06:42 -0700 (Fri, 21 Mar 2008) Log Message: ----------- Remove dead code. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gameobject/ArchetypeParser.java trunk/crossfire/src/cfeditor/gameobject/face/FaceObjects.java trunk/src/app/net/sf/gridarta/gui/NewMapDialog.java trunk/src/app/net/sf/gridarta/gui/ShiftProcessor.java Modified: trunk/crossfire/src/cfeditor/gameobject/ArchetypeParser.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/ArchetypeParser.java 2008-03-21 16:02:50 UTC (rev 3712) +++ trunk/crossfire/src/cfeditor/gameobject/ArchetypeParser.java 2008-03-21 16:06:42 UTC (rev 3713) @@ -88,7 +88,6 @@ } else { archetype = prototype.createClone(0, 0); } - final boolean isInternPath; // path is needed when we don't read from collection because there is no editor_folder in arc files final String path; if (!mainControl.getArchetypeSet().isLoadedFromArchive() && archName == null) { @@ -98,10 +97,8 @@ } else { tmpPath = tmpPath.concat("/"); } - isInternPath = tmpPath.contains("/intern/"); path = tmpPath; } else { - isInternPath = false; path = null; } archetype.resetObjectText(); Modified: trunk/crossfire/src/cfeditor/gameobject/face/FaceObjects.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/face/FaceObjects.java 2008-03-21 16:02:50 UTC (rev 3712) +++ trunk/crossfire/src/cfeditor/gameobject/face/FaceObjects.java 2008-03-21 16:06:42 UTC (rev 3713) @@ -177,7 +177,6 @@ /** {@inheritDoc} */ @Override protected void collectTreeFile(@NotNull final Progress progress, @NotNull final File dir) throws IOException { - final int stripPath = dir.getAbsolutePath().length(); final PrintWriter treeFile = new PrintWriter(new BufferedWriter(new OutputStreamWriter(new FileOutputStream(new File(dir, IGUIConstants.FACETREE_FILE)), "us-ascii")), false); try { int i = 0; Modified: trunk/src/app/net/sf/gridarta/gui/NewMapDialog.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/NewMapDialog.java 2008-03-21 16:02:50 UTC (rev 3712) +++ trunk/src/app/net/sf/gridarta/gui/NewMapDialog.java 2008-03-21 16:06:42 UTC (rev 3713) @@ -354,7 +354,7 @@ mapArchObject.addText("Created: " + String.format("%tF", System.currentTimeMillis()) + " " + prefs.get(AbstractMainControl.PREFS_USERNAME, AbstractMainControl.PREFS_USERNAME_DEFAULT)); if (mapType == MapType.GAMEMAP) { - final MapView<G, A, R, C, V> mapView = mainControl.getMapManager().newMapWithView(null, mapArchObject, null, null, filename != null ? filename : CommonConstants.DEF_MAPFNAME); + 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); } Modified: trunk/src/app/net/sf/gridarta/gui/ShiftProcessor.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/ShiftProcessor.java 2008-03-21 16:02:50 UTC (rev 3712) +++ trunk/src/app/net/sf/gridarta/gui/ShiftProcessor.java 2008-03-21 16:06:42 UTC (rev 3713) @@ -258,7 +258,6 @@ private void shift(final Point pos, final int len) { final List<G> startGameObjects = new LinkedList<G>(); final List<G> gameObjectsToDelete = new LinkedList<G>(); - final Point endPos = new Point(pos.x - len * dx, pos.y - len * dy); final Point prevPos = new Point(pos.x + dx, pos.y + dy); final Point startPos = new Point(); boolean isStart = true; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-03-21 16:34:20
|
Revision: 3718 http://gridarta.svn.sourceforge.net/gridarta/?rev=3718&view=rev Author: akirschbaum Date: 2008-03-21 09:33:44 -0700 (Fri, 21 Mar 2008) Log Message: ----------- Remove redundant code. Modified Paths: -------------- 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/src/app/net/sf/gridarta/gui/map/AbstractMapTilePane.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/messages.properties =================================================================== --- trunk/crossfire/src/cfeditor/messages.properties 2008-03-21 16:21:24 UTC (rev 3717) +++ trunk/crossfire/src/cfeditor/messages.properties 2008-03-21 16:33:44 UTC (rev 3718) @@ -91,8 +91,6 @@ mapTilesClear.shortdescription=Clear all path names mapErrorUnsaved.title=Missing file path mapErrorUnsaved.message=Can''t attach unsaved map.\nMap must be saved to the map folder first! -mapErrorPath.title=Error creating map path -mapErrorPath.message=Please check if the map path exists and is correct: "{0}". mapQueryLoaded.title=Map is loaded mapQueryLoaded.message=The map {0} is opened in the editor.\nShould I autosave & update the map? mapErrorPath2.title=Can''t find map Modified: trunk/crossfire/src/cfeditor/messages_de.properties =================================================================== --- trunk/crossfire/src/cfeditor/messages_de.properties 2008-03-21 16:21:24 UTC (rev 3717) +++ trunk/crossfire/src/cfeditor/messages_de.properties 2008-03-21 16:33:44 UTC (rev 3718) @@ -88,8 +88,6 @@ mapTilesClear.shortdescription=L\xF6scht die Verbindungspfade zu den benachbarten Karten. mapErrorUnsaved.title=Fehlender Dateipfad mapErrorUnsaved.message=Kann ungespeicherte Karte nicht verbinden.\nDie Karte muss zuerst im Kartenverzeichnis gespeichert werden! -mapErrorPath.title=Fehler beim Erzeugen des Pfades -mapErrorPath.message=Bitte \xFCberpr\xFCfe, ob der Dateipfad zur Karte richtig ist: "{0}". mapQueryLoaded.title=Karte ist ge\xF6ffnet mapQueryLoaded.message=Die Karte {0} ist im Editor ge\xF6ffnet.\nSoll ich sie automatisch speichern und aktualisieren? mapErrorPath2.title=Karte nicht gefunden Modified: trunk/crossfire/src/cfeditor/messages_fr.properties =================================================================== --- trunk/crossfire/src/cfeditor/messages_fr.properties 2008-03-21 16:21:24 UTC (rev 3717) +++ trunk/crossfire/src/cfeditor/messages_fr.properties 2008-03-21 16:33:44 UTC (rev 3718) @@ -89,8 +89,6 @@ #mapTilesClear.shortdescription= #mapErrorUnsaved.title= #mapErrorUnsaved.message= -#mapErrorPath.title= -#mapErrorPath.message= #mapQueryLoaded.title= #mapQueryLoaded.message= #mapErrorPath2.title= Modified: trunk/crossfire/src/cfeditor/messages_sv.properties =================================================================== --- trunk/crossfire/src/cfeditor/messages_sv.properties 2008-03-21 16:21:24 UTC (rev 3717) +++ trunk/crossfire/src/cfeditor/messages_sv.properties 2008-03-21 16:33:44 UTC (rev 3718) @@ -87,8 +87,6 @@ mapTilesClear.shortdescription=T\xF6m alla s\xF6kv\xE4gar mapErrorUnsaved.title=S\xF6kv\xE4g saknas mapErrorUnsaved.message=Kan inte ansluta till ej sparad karta.\nKartan m\xE5ste sparas i kartkatalogen f\xF6rst. -mapErrorPath.title=Fel vid skapande av s\xF6kv\xE4g -mapErrorPath.message=Var v\xE4nlig kontrollera att kartans s\xF6kv\xE4g existerar och \xE4r korrekt: "{0}". mapQueryLoaded.title=Kartan \xE4r inladdad mapQueryLoaded.message=Kartan {0} \xE4r \xF6ppen i editorn.\nSka jag autospara och uppdatera den? mapErrorPath2.title=Kan inte hitta karta Modified: trunk/src/app/net/sf/gridarta/gui/map/AbstractMapTilePane.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/AbstractMapTilePane.java 2008-03-21 16:21:24 UTC (rev 3717) +++ trunk/src/app/net/sf/gridarta/gui/map/AbstractMapTilePane.java 2008-03-21 16:33:44 UTC (rev 3718) @@ -276,10 +276,6 @@ /* lets test there is a map with this name & path */ final String mapPath = getCanonicalTilePath(path); - if (mapPath == null) { - ACTION_FACTORY.showMessageDialog(this, "mapErrorPath", path); - return; - } /* run through all loaded maps and see we have a map with this path * if unsaved, ask for stop or autosave */ @@ -317,10 +313,6 @@ /* lets test there is a map with this name & path */ final String mapPath = getCanonicalTilePath(link); - if (mapPath == null) { - ACTION_FACTORY.showMessageDialog(this, "mapErrorPath", link); - return; - } /* run through all loaded maps and see we have a map with this path * if unsaved, ask for stop or autosave */ Modified: trunk/src/app/net/sf/gridarta/messages.properties =================================================================== --- trunk/src/app/net/sf/gridarta/messages.properties 2008-03-21 16:21:24 UTC (rev 3717) +++ trunk/src/app/net/sf/gridarta/messages.properties 2008-03-21 16:33:44 UTC (rev 3718) @@ -213,8 +213,6 @@ mapTilesClear.shortdescription=Clear all path names mapErrorUnsaved.title=Missing file path mapErrorUnsaved.message=Can''t attach unsaved map.\nMap must be saved to the map folder first! -mapErrorPath.title=Error creating map path -mapErrorPath.message=Please check if the map path exists and is correct: "{0}". mapQueryLoaded.title=Map is loaded mapQueryLoaded.message=The map {0} is opened in the editor.\nShould I autosave & update the map? mapErrorPath2.title=Can''t find map Modified: trunk/src/app/net/sf/gridarta/messages_de.properties =================================================================== --- trunk/src/app/net/sf/gridarta/messages_de.properties 2008-03-21 16:21:24 UTC (rev 3717) +++ trunk/src/app/net/sf/gridarta/messages_de.properties 2008-03-21 16:33:44 UTC (rev 3718) @@ -201,8 +201,6 @@ mapTilesClear.shortdescription=L\xF6scht die Verbindungspfade zu den benachbarten Karten. mapErrorUnsaved.title=Fehlender Dateipfad mapErrorUnsaved.message=Kann ungespeicherte Karte nicht verbinden.\nDie Karte muss zuerst im Kartenverzeichnis gespeichert werden! -mapErrorPath.title=Fehler beim Erzeugen des Pfades -mapErrorPath.message=Bitte \xFCberpr\xFCfe, ob der Dateipfad zur Karte richtig ist: "{0}". mapQueryLoaded.title=Karte ist ge\xF6ffnet mapQueryLoaded.message=Die Karte {0} ist im Editor ge\xF6ffnet.\nSoll ich sie automatisch speichern und aktualisieren? mapErrorPath2.title=Karte nicht gefunden Modified: trunk/src/app/net/sf/gridarta/messages_fr.properties =================================================================== --- trunk/src/app/net/sf/gridarta/messages_fr.properties 2008-03-21 16:21:24 UTC (rev 3717) +++ trunk/src/app/net/sf/gridarta/messages_fr.properties 2008-03-21 16:33:44 UTC (rev 3718) @@ -200,8 +200,6 @@ #mapTilesClear.shortdescription= #mapErrorUnsaved.title= #mapErrorUnsaved.message= -#mapErrorPath.title= -#mapErrorPath.message= #mapQueryLoaded.title= #mapQueryLoaded.message= #mapErrorPath2.title= Modified: trunk/src/app/net/sf/gridarta/messages_sv.properties =================================================================== --- trunk/src/app/net/sf/gridarta/messages_sv.properties 2008-03-21 16:21:24 UTC (rev 3717) +++ trunk/src/app/net/sf/gridarta/messages_sv.properties 2008-03-21 16:33:44 UTC (rev 3718) @@ -198,8 +198,6 @@ mapTilesClear.shortdescription=T\xF6m alla s\xF6kv\xE4gar mapErrorUnsaved.title=S\xF6kv\xE4g saknas mapErrorUnsaved.message=Kan inte ansluta till ej sparad karta.\nKartan m\xE5ste sparas i kartkatalogen f\xF6rst. -mapErrorPath.title=Fel vid skapande av s\xF6kv\xE4g -mapErrorPath.message=Var v\xE4nlig kontrollera att kartans s\xF6kv\xE4g existerar och \xE4r korrekt: "{0}". mapQueryLoaded.title=Kartan \xE4r inladdad mapQueryLoaded.message=Kartan {0} \xE4r \xF6ppen i editorn.\nSka jag autospara och uppdatera den? mapErrorPath2.title=Kan inte hitta karta This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-03-21 17:12:51
|
Revision: 3730 http://gridarta.svn.sourceforge.net/gridarta/?rev=3730&view=rev Author: akirschbaum Date: 2008-03-21 10:12:54 -0700 (Fri, 21 Mar 2008) Log Message: ----------- Remov unused code. Modified Paths: -------------- trunk/crossfire/src/cfeditor/io/MapArchObjectParser.java trunk/src/app/net/sf/gridarta/gui/ArchetypesActions.java trunk/src/app/net/sf/gridarta/gui/map/GoLocationDialogManager.java trunk/src/app/net/sf/gridarta/io/DefaultMapReader.java Modified: trunk/crossfire/src/cfeditor/io/MapArchObjectParser.java =================================================================== --- trunk/crossfire/src/cfeditor/io/MapArchObjectParser.java 2008-03-21 17:09:25 UTC (rev 3729) +++ trunk/crossfire/src/cfeditor/io/MapArchObjectParser.java 2008-03-21 17:12:54 UTC (rev 3730) @@ -24,7 +24,6 @@ import java.io.IOException; import java.util.Formatter; import net.sf.gridarta.io.AbstractMapArchObjectParser; -import org.apache.log4j.Logger; import org.jetbrains.annotations.NotNull; /** @@ -41,9 +40,6 @@ /** String which ends the map lore section. */ public static final String TAG_END_LORE = "endmaplore"; - /** The Logger for printing log messages. */ - private static final Logger log = Logger.getLogger(MapArchObjectParser.class); - /** * Set to <code>true</code> while parsing a map lore section. */ Modified: trunk/src/app/net/sf/gridarta/gui/ArchetypesActions.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/ArchetypesActions.java 2008-03-21 17:09:25 UTC (rev 3729) +++ trunk/src/app/net/sf/gridarta/gui/ArchetypesActions.java 2008-03-21 17:12:54 UTC (rev 3730) @@ -31,7 +31,6 @@ import net.sf.gridarta.map.MapControl; import net.sf.japi.swing.ActionFactory; import net.sf.japi.swing.ToggleAction; -import org.apache.log4j.Logger; import org.jetbrains.annotations.NotNull; /** @@ -44,9 +43,6 @@ /** Action Factory. */ private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("net.sf.gridarta"); - /** The Logger for printing log messages. */ - private static final Logger log = Logger.getLogger(ArchetypesActions.class); - /** Action for "display object names". */ private final ToggleAction aDisplayObjectNames; Modified: trunk/src/app/net/sf/gridarta/gui/map/GoLocationDialogManager.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/GoLocationDialogManager.java 2008-03-21 17:09:25 UTC (rev 3729) +++ trunk/src/app/net/sf/gridarta/gui/map/GoLocationDialogManager.java 2008-03-21 17:12:54 UTC (rev 3730) @@ -27,7 +27,6 @@ import net.sf.gridarta.gameobject.GameObject; 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; @@ -39,9 +38,6 @@ */ public final class GoLocationDialogManager<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"); - /** Dialog for each map view. */ private final Map<MapView<G, A, R, C, V>, GoLocationDialog> dialogs = new HashMap<MapView<G, A, R, C, V>, GoLocationDialog>(); Modified: trunk/src/app/net/sf/gridarta/io/DefaultMapReader.java =================================================================== --- trunk/src/app/net/sf/gridarta/io/DefaultMapReader.java 2008-03-21 17:09:25 UTC (rev 3729) +++ trunk/src/app/net/sf/gridarta/io/DefaultMapReader.java 2008-03-21 17:12:54 UTC (rev 3730) @@ -35,7 +35,6 @@ import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.GameObject; import net.sf.gridarta.map.MapArchObject; -import org.apache.log4j.Logger; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -46,9 +45,6 @@ @SuppressWarnings({"IOResourceOpenedButNotSafelyClosed"}) // myInput.close() is invoked in this.close() public final class DefaultMapReader<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> implements MapReader<G, A> { - /** The Logger for printing log messages. */ - private static final Logger log = Logger.getLogger(DefaultMapReader.class); - /** The main control. */ @NotNull private final MainControl<G, A, R, ?, ?> mainControl; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-03-23 11:19:22
|
Revision: 3731 http://gridarta.svn.sourceforge.net/gridarta/?rev=3731&view=rev Author: akirschbaum Date: 2008-03-23 04:19:09 -0700 (Sun, 23 Mar 2008) Log Message: ----------- Move code implementing MapManager related actions to common code base. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/CMainView.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/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/CMainView.java 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/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/MapManagerActions.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-03-21 17:12:54 UTC (rev 3730) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-03-23 11:19:09 UTC (rev 3731) @@ -68,6 +68,7 @@ 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.NewMapDialogFactory; import net.sf.gridarta.gui.RecentManager; import net.sf.gridarta.gui.map.MapCursorControl; @@ -145,6 +146,9 @@ /** Preferences default value for using System.exit(). */ public static final boolean PREFS_SYSTEM_EXIT_DEFAULT = true; + /** The map manager actions. */ + private final MapManagerActions<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> mapManagerActions; + /** The main view. */ private final CMainView mainView; @@ -262,7 +266,8 @@ scriptControl = new ScriptController(this); mapCursorControl = new MapCursorControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>("cfeditor", this); ACTION_FACTORY.createActions(true, this, "createNew", "open", "options", "exit", "gc", "onlineHelp", "tod", "about"); - mainView = new CMainView(this); + mapManagerActions = new MapManagerActions<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(mapManager); + mainView = new CMainView(this, mapManagerActions.getCloseAllAction()); undoControl = new UndoControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(this); readGlobalSettings(); Modified: trunk/crossfire/src/cfeditor/CMainView.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainView.java 2008-03-21 17:12:54 UTC (rev 3730) +++ trunk/crossfire/src/cfeditor/CMainView.java 2008-03-23 11:19:09 UTC (rev 3731) @@ -107,6 +107,7 @@ private final Action aViewTreasurelists; + /** The action for "close all map windows". */ private final Action aCloseAll; /** Action for "prev window". */ @@ -140,12 +141,13 @@ /** * Constructs the main view and registers the given main controller. * @param mainControl MainControl to attach to. + * @param aCloseAll the action "close all map windows" */ - CMainView(@NotNull final CMainControl mainControl) { + CMainView(@NotNull final CMainControl mainControl, @NotNull final Action aCloseAll) { super(mainControl, ACTION_FACTORY.format("mainWindow.title")); this.mainControl = mainControl; aViewTreasurelists = ACTION_FACTORY.createAction(true, "viewTreasurelists", mainControl); - aCloseAll = ACTION_FACTORY.createAction(true, "closeAll", mainControl.getMapManager()); + this.aCloseAll = aCloseAll; viewActions = new ViewActions(mainControl); mapActions = new MapActions(mainControl); Modified: trunk/crossfire/src/cfeditor/messages.properties =================================================================== --- trunk/crossfire/src/cfeditor/messages.properties 2008-03-21 17:12:54 UTC (rev 3730) +++ trunk/crossfire/src/cfeditor/messages.properties 2008-03-23 11:19:09 UTC (rev 3731) @@ -328,13 +328,7 @@ prevWindow.shortdescription=Display previous window prevWindow.accel=shift pressed PAGE_DOWN -closeAll.text=Close All -closeAll.shortdescription=Close all maps -closeAll.longdescription=Closes all opened maps -closeAll.mnemonic=L -closeAll.accel=ctrl shift pressed W - ####### # Help Modified: trunk/crossfire/src/cfeditor/messages_de.properties =================================================================== --- trunk/crossfire/src/cfeditor/messages_de.properties 2008-03-21 17:12:54 UTC (rev 3730) +++ trunk/crossfire/src/cfeditor/messages_de.properties 2008-03-23 11:19:09 UTC (rev 3731) @@ -303,12 +303,7 @@ prevWindow.text=Vorheriges Fenster prevWindow.shortdescription=Zeige das vorherige Fenster -closeAll.text=Alle schlie\xDFen -closeAll.shortdescription=Alle Karten schlie\xDFen -closeAll.longdescription=Schlie\xDFt alle ge\xF6ffneten Karten. -closeAll.mnemonic=A - ####### # Help Modified: trunk/crossfire/src/cfeditor/messages_fr.properties =================================================================== --- trunk/crossfire/src/cfeditor/messages_fr.properties 2008-03-21 17:12:54 UTC (rev 3730) +++ trunk/crossfire/src/cfeditor/messages_fr.properties 2008-03-23 11:19:09 UTC (rev 3731) @@ -304,12 +304,7 @@ prevWindow.text=Fen\xEAtre pr\xE9c\xE9dente prevWindow.shortdescription=Affiche la fen\xEAtre pr\xE9c\xE9dente -closeAll.text=Tout fermer -#closeAll.shortdescription= -#closeAll.longdescription= -closeAll.mnemonic=T - ####### # Help Modified: trunk/crossfire/src/cfeditor/messages_sv.properties =================================================================== --- trunk/crossfire/src/cfeditor/messages_sv.properties 2008-03-21 17:12:54 UTC (rev 3730) +++ trunk/crossfire/src/cfeditor/messages_sv.properties 2008-03-23 11:19:09 UTC (rev 3731) @@ -302,12 +302,7 @@ prevWindow.text=F\xF6reg\xE5ende prevWindow.shortdescription=Visa f\xF6reg\xE5ende f\xF6nster -closeAll.text=St\xE4ng alla -closeAll.shortdescription=St\xE4ng alla kartor -closeAll.longdescription=St\xE4nger alla \xF6ppnade kartor -closeAll.mnemonic=S - ####### # Help Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-03-21 17:12:54 UTC (rev 3730) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-03-23 11:19:09 UTC (rev 3731) @@ -76,6 +76,7 @@ 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.NewMapDialogFactory; import net.sf.gridarta.gui.RecentManager; import net.sf.gridarta.gui.map.MapCursorControl; @@ -180,6 +181,9 @@ /** Preferences default value for editor application. */ public static final String PREFS_APP_EDITOR_DEFAULT = "vim"; + /** The map manager actions. */ + private final MapManagerActions<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> mapManagerActions; + /** The main view. */ private final CMainView mainView; @@ -314,7 +318,8 @@ mapCursorControl = new MapCursorControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>("daieditor", this); ACTION_FACTORY.createActions(true, this, "createNew", "open", "options", "exit", "newScript", "editScript", "controlServer", "controlClient", "cleanCompletelyBlockedSquares", "zoom", "gc", "onlineHelp", "tod", "about", "update"); ACTION_FACTORY.createToggles(true, this, "drawDouble"); - mainView = new CMainView(this); + mapManagerActions = new MapManagerActions<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(mapManager); + mainView = new CMainView(this, mapManagerActions.getCloseAllAction()); undoControl = new UndoControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(this); Updater.startup(mainView, this); Modified: trunk/daimonin/src/daieditor/CMainView.java =================================================================== --- trunk/daimonin/src/daieditor/CMainView.java 2008-03-21 17:12:54 UTC (rev 3730) +++ trunk/daimonin/src/daieditor/CMainView.java 2008-03-23 11:19:09 UTC (rev 3731) @@ -113,6 +113,7 @@ private final Action aViewTreasurelists; + /** The action for "close all map windows". */ private final Action aCloseAll; /** Action for "prev window". */ @@ -144,13 +145,14 @@ /** * Constructs the main view and registers the given main controller. * @param mainControl MainControl to attach to. + * @param aCloseAll the action "close all map windows" */ - CMainView(@NotNull final CMainControl mainControl) { + CMainView(@NotNull final CMainControl mainControl, @NotNull final Action aCloseAll) { super(mainControl, ACTION_FACTORY.format("mainWindow.title", CMainControl.getBuildNumberAsString())); this.mainControl = mainControl; aCollectSpells = ACTION_FACTORY.createAction(true, "collectSpells", mainControl); aViewTreasurelists = ACTION_FACTORY.createAction(true, "viewTreasurelists", mainControl); - aCloseAll = ACTION_FACTORY.createAction(true, "closeAll", mainControl.getMapManager()); + this.aCloseAll = aCloseAll; mapActions = new MapActions(mainControl); initActions(); Modified: trunk/daimonin/src/daieditor/messages.properties =================================================================== --- trunk/daimonin/src/daieditor/messages.properties 2008-03-21 17:12:54 UTC (rev 3730) +++ trunk/daimonin/src/daieditor/messages.properties 2008-03-23 11:19:09 UTC (rev 3731) @@ -461,13 +461,7 @@ prevWindow.shortdescription=Display previous window prevWindow.accel=shift pressed PAGE_DOWN -closeAll.text=Close All -closeAll.shortdescription=Close all maps -closeAll.longdescription=Closes all opened maps -closeAll.mnemonic=L -closeAll.accel=ctrl shift pressed W - ####### # Help Modified: trunk/daimonin/src/daieditor/messages_de.properties =================================================================== --- trunk/daimonin/src/daieditor/messages_de.properties 2008-03-21 17:12:54 UTC (rev 3730) +++ trunk/daimonin/src/daieditor/messages_de.properties 2008-03-23 11:19:09 UTC (rev 3731) @@ -429,12 +429,7 @@ prevWindow.text=Vorheriges Fenster prevWindow.shortdescription=Zeige das vorherige Fenster -closeAll.text=Alle schlie\xDFen -closeAll.shortdescription=Alle Karten schlie\xDFen -closeAll.longdescription=Schlie\xDFt alle ge\xF6ffneten Karten. -closeAll.mnemonic=A - ####### # Help Modified: trunk/daimonin/src/daieditor/messages_fr.properties =================================================================== --- trunk/daimonin/src/daieditor/messages_fr.properties 2008-03-21 17:12:54 UTC (rev 3730) +++ trunk/daimonin/src/daieditor/messages_fr.properties 2008-03-23 11:19:09 UTC (rev 3731) @@ -426,12 +426,7 @@ prevWindow.text=Fen\xEAtre pr\xE9c\xE9dente prevWindow.shortdescription=Affiche la fen\xEAtre pr\xE9c\xE9dente -closeAll.text=Tout fermer -#closeAll.shortdescription= -#closeAll.longdescription= -closeAll.mnemonic=T - ####### # Help Modified: trunk/daimonin/src/daieditor/messages_sv.properties =================================================================== --- trunk/daimonin/src/daieditor/messages_sv.properties 2008-03-21 17:12:54 UTC (rev 3730) +++ trunk/daimonin/src/daieditor/messages_sv.properties 2008-03-23 11:19:09 UTC (rev 3731) @@ -431,12 +431,7 @@ prevWindow.text=F\xF6reg\xE5ende prevWindow.shortdescription=Visa f\xF6reg\xE5ende f\xF6nster -closeAll.text=St\xE4ng alla -closeAll.shortdescription=St\xE4ng alla kartor -closeAll.longdescription=St\xE4nger alla \xF6ppnade kartor -closeAll.mnemonic=S - ####### # Help Added: trunk/src/app/net/sf/gridarta/gui/MapManagerActions.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/MapManagerActions.java (rev 0) +++ trunk/src/app/net/sf/gridarta/gui/MapManagerActions.java 2008-03-23 11:19:09 UTC (rev 3731) @@ -0,0 +1,59 @@ +/* + * 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 javax.swing.Action; +import net.sf.gridarta.MapManager; +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.japi.swing.ActionFactory; +import org.jetbrains.annotations.NotNull; + +/** + * Manages actions related to the {@link MapManager} instance. + * @author Andreas Kirschbaum + */ +public class MapManagerActions<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"); + + /** Action for "close all map windows". */ + private final Action aCloseAll; + + /** + * Creates a new instance. + * @param mapManager the map manager to forward to + */ + public MapManagerActions(@NotNull final MapManager<G, A, R, C, V> mapManager) { + aCloseAll = ACTION_FACTORY.createAction(true, "closeAll", mapManager); + } + + /** + * Returns the {@link Action} for "close all map windows". + */ + public Action getCloseAllAction() { + return aCloseAll; + } + +} // class MapManagerActions Property changes on: trunk/src/app/net/sf/gridarta/gui/MapManagerActions.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF Modified: trunk/src/app/net/sf/gridarta/messages.properties =================================================================== --- trunk/src/app/net/sf/gridarta/messages.properties 2008-03-21 17:12:54 UTC (rev 3730) +++ trunk/src/app/net/sf/gridarta/messages.properties 2008-03-23 11:19:09 UTC (rev 3731) @@ -86,7 +86,14 @@ archAttributes.accel=ENTER +# Map Manager +closeAll.text=Close All +closeAll.shortdescription=Close all maps +closeAll.longdescription=Closes all opened maps +closeAll.mnemonic=L +closeAll.accel=ctrl shift pressed W + # Dialogs pickmapExists.title=Cannot Create Pickmap pickmapExists.message=A pickmap named {0} already exists.\nEither remove the existing one or choose a different name. Modified: trunk/src/app/net/sf/gridarta/messages_de.properties =================================================================== --- trunk/src/app/net/sf/gridarta/messages_de.properties 2008-03-21 17:12:54 UTC (rev 3730) +++ trunk/src/app/net/sf/gridarta/messages_de.properties 2008-03-23 11:19:09 UTC (rev 3731) @@ -75,6 +75,13 @@ archAttributes.text=Objektattribute +# Map Manager +closeAll.text=Alle schlie\xDFen +closeAll.shortdescription=Alle Karten schlie\xDFen +closeAll.longdescription=Schlie\xDFt alle ge\xF6ffneten Karten. +closeAll.mnemonic=A + + # Dialogs pickmapExists.title=Kann Pickmap nicht erstellen pickmapExists.message=Die Pickmap ''{0}'' existiert bereits.\nSie m\xFCssen die existierende Pickmap erst l\xF6schen oder einen anderen Namen w\xE4hlen. Modified: trunk/src/app/net/sf/gridarta/messages_fr.properties =================================================================== --- trunk/src/app/net/sf/gridarta/messages_fr.properties 2008-03-21 17:12:54 UTC (rev 3730) +++ trunk/src/app/net/sf/gridarta/messages_fr.properties 2008-03-23 11:19:09 UTC (rev 3731) @@ -74,6 +74,13 @@ #archAttributes.text= +# Map Manager +closeAll.text=Tout fermer +#closeAll.shortdescription= +#closeAll.longdescription= +closeAll.mnemonic=T + + # Dialogs #pickmapExists.title= #pickmapExists.message= Modified: trunk/src/app/net/sf/gridarta/messages_sv.properties =================================================================== --- trunk/src/app/net/sf/gridarta/messages_sv.properties 2008-03-21 17:12:54 UTC (rev 3730) +++ trunk/src/app/net/sf/gridarta/messages_sv.properties 2008-03-23 11:19:09 UTC (rev 3731) @@ -74,6 +74,13 @@ archAttributes.text=Objektattribut +# Map Manager +closeAll.text=St\xE4ng alla +closeAll.shortdescription=St\xE4ng alla kartor +closeAll.longdescription=St\xE4nger alla \xF6ppnade kartor +closeAll.mnemonic=S + + # Dialogs pickmapExists.title=Kan inte skapa plockkarta pickmapExists.message=En plockkarta med namnet {0} finns redan.\nTa antingen bort den tidigare plockkartan eller v\xE4lj ett annat namn. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-03-23 12:01:48
|
Revision: 3732 http://gridarta.svn.sourceforge.net/gridarta/?rev=3732&view=rev Author: akirschbaum Date: 2008-03-23 05:01:32 -0700 (Sun, 23 Mar 2008) Log Message: ----------- Rename MainControlListener into MapManagerListener. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/daimonin/src/daieditor/CMainControl.java trunk/src/app/net/sf/gridarta/CurrentMapListener.java trunk/src/app/net/sf/gridarta/DefaultMapManager.java trunk/src/app/net/sf/gridarta/MainControl.java trunk/src/app/net/sf/gridarta/MapManager.java trunk/src/app/net/sf/gridarta/gui/ErrorListView.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/StatusBar.java trunk/src/app/net/sf/gridarta/gui/connectionview/View.java trunk/src/app/net/sf/gridarta/gui/map/GoLocationDialogManager.java trunk/src/app/net/sf/gridarta/gui/map/MapCursorActions.java trunk/src/app/net/sf/gridarta/gui/maptilelist/MapTileSelectionCache.java trunk/src/app/net/sf/gridarta/gui/selectedsquare/SelectedSquareView.java trunk/src/app/net/sf/gridarta/gui/undo/UndoControl.java trunk/src/app/net/sf/gridarta/map/AutoValidator.java Added Paths: ----------- trunk/src/app/net/sf/gridarta/MapManagerListener.java Removed Paths: ------------- trunk/src/app/net/sf/gridarta/MainControlListener.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-03-23 11:19:09 UTC (rev 3731) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-03-23 12:01:32 UTC (rev 3732) @@ -57,8 +57,8 @@ import net.sf.gridarta.CommonConstants; import net.sf.gridarta.DefaultMapManager; import net.sf.gridarta.MainControl; -import net.sf.gridarta.MainControlListener; import net.sf.gridarta.MapManager; +import net.sf.gridarta.MapManagerListener; import net.sf.gridarta.XmlHelper; import net.sf.gridarta.gameobject.Collectable; import net.sf.gridarta.gameobject.Collector; @@ -910,13 +910,13 @@ } /** {@inheritDoc} */ - public void addMainControlListener(@NotNull final MainControlListener<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> listener) { - mapManager.addMainControlListener(listener); + public void addMapManagerListener(@NotNull final MapManagerListener<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> listener) { + mapManager.addMapManagerListener(listener); } /** {@inheritDoc} */ - public void removeMainControlListener(@NotNull final MainControlListener<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> listener) { - mapManager.removeMainControlListener(listener); + public void removeMapManagerListener(@NotNull final MapManagerListener<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> listener) { + mapManager.removeMapManagerListener(listener); } /** {@inheritDoc} */ Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-03-23 11:19:09 UTC (rev 3731) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-03-23 12:01:32 UTC (rev 3732) @@ -63,8 +63,8 @@ import net.sf.gridarta.CommonConstants; import net.sf.gridarta.DefaultMapManager; import net.sf.gridarta.MainControl; -import net.sf.gridarta.MainControlListener; import net.sf.gridarta.MapManager; +import net.sf.gridarta.MapManagerListener; import net.sf.gridarta.XmlHelper; import net.sf.gridarta.gameobject.Collectable; import net.sf.gridarta.gameobject.Collector; @@ -1056,13 +1056,13 @@ } /** {@inheritDoc} */ - public void addMainControlListener(@NotNull final MainControlListener<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> listener) { - mapManager.addMainControlListener(listener); + public void addMapManagerListener(@NotNull final MapManagerListener<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> listener) { + mapManager.addMapManagerListener(listener); } /** {@inheritDoc} */ - public void removeMainControlListener(@NotNull final MainControlListener<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> listener) { - mapManager.removeMainControlListener(listener); + public void removeMapManagerListener(@NotNull final MapManagerListener<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> listener) { + mapManager.removeMapManagerListener(listener); } /** {@inheritDoc} */ Modified: trunk/src/app/net/sf/gridarta/CurrentMapListener.java =================================================================== --- trunk/src/app/net/sf/gridarta/CurrentMapListener.java 2008-03-23 11:19:09 UTC (rev 3731) +++ trunk/src/app/net/sf/gridarta/CurrentMapListener.java 2008-03-23 12:01:32 UTC (rev 3732) @@ -122,10 +122,10 @@ }; /** - * The main control listener which is attached to {@link #mainControl} if + * The map manager listener which is attached to {@link #mainControl} if * the current map is tracked. Otherwise it is unused. */ - private final MainControlListener<G, A, R, C, V> mainControlListener = new MainControlListener<G, A, R, C, V>() { + private final MapManagerListener<G, A, R, C, V> mainControlListener = new MapManagerListener<G, A, R, C, V>() { /** {@inheritDoc} */ public void currentMapChanged(@Nullable final C mapControl) { @@ -197,7 +197,7 @@ this.trackMapFileName = trackMapFileName; this.trackMapCursor = trackMapCursor; if (mapControl == null) { - mainControl.addMainControlListener(mainControlListener); + mainControl.addMapManagerListener(mainControlListener); currentMap = mainControl.getMapManager().getCurrentMap(); if (currentMap != null) { currentMap.addMapControlListener(mapControlListener); @@ -222,7 +222,7 @@ */ public void closeNotify() { if (mapControl == null) { - mainControl.removeMainControlListener(mainControlListener); + mainControl.removeMapManagerListener(mainControlListener); } if (currentMap != null) { currentMap.removeMapControlListener(mapControlListener); Modified: trunk/src/app/net/sf/gridarta/DefaultMapManager.java =================================================================== --- trunk/src/app/net/sf/gridarta/DefaultMapManager.java 2008-03-23 11:19:09 UTC (rev 3731) +++ trunk/src/app/net/sf/gridarta/DefaultMapManager.java 2008-03-23 12:01:32 UTC (rev 3732) @@ -58,7 +58,7 @@ /** All open maps. */ private final List<C> levels = new ArrayList<C>(); - /** The MainControlListeners to inform of changes. */ + /** The MapManagerListeners to inform of changes. */ private final EventListenerList listenerList = new EventListenerList(); /** The current top map we are working with. */ @@ -381,7 +381,7 @@ * @param mapControl the created map */ private void fireMapCreatedEvent(@NotNull final C mapControl) { - for (final MainControlListener<G, A, R, C, V> listener : listenerList.getListeners(MainControlListener.class)) { + for (final MapManagerListener<G, A, R, C, V> listener : listenerList.getListeners(MapManagerListener.class)) { listener.mapCreated(mapControl); } } @@ -392,7 +392,7 @@ * @param mapView the created map view */ private void fireMapViewCreatedEvent(@NotNull final MapView<G, A, R, C, V> mapView) { - for (final MainControlListener<G, A, R, C, V> listener : listenerList.getListeners(MainControlListener.class)) { + for (final MapManagerListener<G, A, R, C, V> listener : listenerList.getListeners(MapManagerListener.class)) { listener.mapViewCreated(mapView); } } @@ -402,7 +402,7 @@ * @param mapControl MapControl that's being closed. */ private void fireMapClosingEvent(@NotNull final C mapControl) { - for (final MainControlListener<G, A, R, C, V> listener : listenerList.getListeners(MainControlListener.class)) { + for (final MapManagerListener<G, A, R, C, V> listener : listenerList.getListeners(MapManagerListener.class)) { listener.mapClosing(mapControl); } } @@ -412,7 +412,7 @@ * @param mapView map view that's being closed */ private void fireMapViewClosingEvent(@NotNull final MapView<G, A, R, C, V> mapView) { - for (final MainControlListener<G, A, R, C, V> listener : listenerList.getListeners(MainControlListener.class)) { + for (final MapManagerListener<G, A, R, C, V> listener : listenerList.getListeners(MapManagerListener.class)) { listener.mapViewClosing(mapView); } } @@ -421,26 +421,26 @@ * Notify all listeners about a changed current map. */ private void fireCurrentMapChangedEvent() { - for (final MainControlListener<G, A, R, C, V> listener : listenerList.getListeners(MainControlListener.class)) { + for (final MapManagerListener<G, A, R, C, V> listener : listenerList.getListeners(MapManagerListener.class)) { listener.currentMapChanged(currentMap); } } /** {@inheritDoc} */ public void fireCurrentMapViewChangedEvent(@Nullable final MapView<G, A, R, C, V> currentMapView) { - for (final MainControlListener<G, A, R, C, V> listener : listenerList.getListeners(MainControlListener.class)) { + for (final MapManagerListener<G, A, R, C, V> listener : listenerList.getListeners(MapManagerListener.class)) { listener.currentMapViewChanged(currentMapView); } } /** {@inheritDoc} */ - public void addMainControlListener(@NotNull final MainControlListener<G, A, R, C, V> listener) { - listenerList.add(MainControlListener.class, listener); + public void addMapManagerListener(@NotNull final MapManagerListener<G, A, R, C, V> listener) { + listenerList.add(MapManagerListener.class, listener); } /** {@inheritDoc} */ - public void removeMainControlListener(@NotNull final MainControlListener<G, A, R, C, V> listener) { - listenerList.remove(MainControlListener.class, listener); + public void removeMapManagerListener(@NotNull final MapManagerListener<G, A, R, C, V> listener) { + listenerList.remove(MapManagerListener.class, listener); } } // class DefaultMapManager Modified: trunk/src/app/net/sf/gridarta/MainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/MainControl.java 2008-03-23 11:19:09 UTC (rev 3731) +++ trunk/src/app/net/sf/gridarta/MainControl.java 2008-03-23 12:01:32 UTC (rev 3732) @@ -140,16 +140,16 @@ @Nullable MapView<G, A, R, C, V> getCurrentMapView(); /** - * Register a MainControlListener. - * @param listener MainControlListener to register + * Register a MapManagerListener. + * @param listener MapManagerListener to register */ - void addMainControlListener(@NotNull MainControlListener<G, A, R, C, V> listener); + void addMapManagerListener(@NotNull MapManagerListener<G, A, R, C, V> listener); /** - * Remove a MainControlListener. - * @param listener MainControlListener to remove + * Remove a MapManagerListener. + * @param listener MapManagerListener to remove */ - void removeMainControlListener(@NotNull MainControlListener<G, A, R, C, V> listener); + void removeMapManagerListener(@NotNull MapManagerListener<G, A, R, C, V> listener); /** * Invoked when user wants to save a map to certain file. Deleted: trunk/src/app/net/sf/gridarta/MainControlListener.java =================================================================== --- trunk/src/app/net/sf/gridarta/MainControlListener.java 2008-03-23 11:19:09 UTC (rev 3731) +++ trunk/src/app/net/sf/gridarta/MainControlListener.java 2008-03-23 12:01:32 UTC (rev 3732) @@ -1,83 +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; - -import java.util.EventListener; -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 org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -/** - * Interface for listeners listening to CMainControl changes. - * - * @author Andreas Kirschbaum - */ -public interface MainControlListener<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 { - - /** - * This event handler is called when the current map has changed. - * - * @param mapControl the new map control, or <code>null</code> if no opened - * map exists - */ - void currentMapChanged(@Nullable C mapControl); - - /** - * This event handler is called when the current map view has changed. - * - * @param mapView the new map view, or <code>null</code> if no opened map - * view exists - */ - void currentMapViewChanged(@Nullable MapView<G, A, R, C, V> mapView); - - /** - * This event handler is called when a map was created. - * - * @param mapControl the created map control - */ - void mapCreated(@NotNull C mapControl); - - /** - * This event handler is called when a map view was created. - * - * @param mapView the created map view - */ - void mapViewCreated(@NotNull MapView<G, A, R, C, V> mapView); - - /** - * This event handler is called when a map is to be closed. - * - * @param mapControl the map control that is to be closed - */ - void mapClosing(@NotNull C mapControl); - - /** - * This event handler is called when a map view is to be closed. - * - * @param mapView the map view that is to be closed - */ - void mapViewClosing(@NotNull MapView<G, A, R, C, V> mapView); - -} // interface MainControlListener Modified: trunk/src/app/net/sf/gridarta/MapManager.java =================================================================== --- trunk/src/app/net/sf/gridarta/MapManager.java 2008-03-23 11:19:09 UTC (rev 3731) +++ trunk/src/app/net/sf/gridarta/MapManager.java 2008-03-23 12:01:32 UTC (rev 3732) @@ -166,18 +166,18 @@ void saveMapIfOpened(String path); /** - * Add a {@link MainControlListener} to be notified. + * Add a {@link MapManagerListener} to be notified. * * @param listener The listener to add. */ - void addMainControlListener(@NotNull MainControlListener<G, A, R, C, V> listener); + void addMapManagerListener(@NotNull MapManagerListener<G, A, R, C, V> listener); /** - * Remove a {@link MainControlListener} to be notified. + * Remove a {@link MapManagerListener} to be notified. * * @param listener The listener to remove. */ - void removeMainControlListener(@NotNull MainControlListener<G, A, R, C, V> listener); + void removeMapManagerListener(@NotNull MapManagerListener<G, A, R, C, V> listener); /** * Notify all listeners about a changed current map view. Copied: trunk/src/app/net/sf/gridarta/MapManagerListener.java (from rev 3731, trunk/src/app/net/sf/gridarta/MainControlListener.java) =================================================================== --- trunk/src/app/net/sf/gridarta/MapManagerListener.java (rev 0) +++ trunk/src/app/net/sf/gridarta/MapManagerListener.java 2008-03-23 12:01:32 UTC (rev 3732) @@ -0,0 +1,83 @@ +/* + * 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; + +import java.util.EventListener; +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 org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * Interface for listeners listening to {@link MapManager} changes. + * + * @author Andreas Kirschbaum + */ +public interface MapManagerListener<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 { + + /** + * This event handler is called when the current map has changed. + * + * @param mapControl the new map control, or <code>null</code> if no opened + * map exists + */ + void currentMapChanged(@Nullable C mapControl); + + /** + * This event handler is called when the current map view has changed. + * + * @param mapView the new map view, or <code>null</code> if no opened map + * view exists + */ + void currentMapViewChanged(@Nullable MapView<G, A, R, C, V> mapView); + + /** + * This event handler is called when a map was created. + * + * @param mapControl the created map control + */ + void mapCreated(@NotNull C mapControl); + + /** + * This event handler is called when a map view was created. + * + * @param mapView the created map view + */ + void mapViewCreated(@NotNull MapView<G, A, R, C, V> mapView); + + /** + * This event handler is called when a map is to be closed. + * + * @param mapControl the map control that is to be closed + */ + void mapClosing(@NotNull C mapControl); + + /** + * This event handler is called when a map view is to be closed. + * + * @param mapView the map view that is to be closed + */ + void mapViewClosing(@NotNull MapView<G, A, R, C, V> mapView); + +} // interface MapManagerListener Modified: trunk/src/app/net/sf/gridarta/gui/ErrorListView.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/ErrorListView.java 2008-03-23 11:19:09 UTC (rev 3731) +++ trunk/src/app/net/sf/gridarta/gui/ErrorListView.java 2008-03-23 12:01:32 UTC (rev 3732) @@ -37,7 +37,7 @@ import javax.swing.event.ListSelectionListener; import net.sf.gridarta.AbstractMainControl; import net.sf.gridarta.MainControl; -import net.sf.gridarta.MainControlListener; +import net.sf.gridarta.MapManagerListener; import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.GameObject; import net.sf.gridarta.gui.map.MapView; @@ -101,9 +101,9 @@ }; /** - * The main control listener to detect changes of the active map. + * The map manager listener to detect changes of the active map. */ - private final MainControlListener<G, A, R, C, V> mainControlListener = new MainControlListener<G, A, R, C, V>() { + private final MapManagerListener<G, A, R, C, V> mainControlListener = new MapManagerListener<G, A, R, C, V>() { /** {@inheritDoc} */ public void currentMapChanged(@Nullable final C mapControl) { @@ -155,7 +155,7 @@ highlightEntries(errorList.getSelectedIndex()); } }); - mainControl.addMainControlListener(mainControlListener); + mainControl.addMapManagerListener(mainControlListener); updateErrors(mainControl.getMapManager().getCurrentMap()); } Modified: trunk/src/app/net/sf/gridarta/gui/GameObjectAttributesPanel.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/GameObjectAttributesPanel.java 2008-03-23 11:19:09 UTC (rev 3731) +++ trunk/src/app/net/sf/gridarta/gui/GameObjectAttributesPanel.java 2008-03-23 12:01:32 UTC (rev 3732) @@ -46,7 +46,7 @@ import javax.swing.border.EtchedBorder; import net.sf.gridarta.CFArchType; import net.sf.gridarta.MainControl; -import net.sf.gridarta.MainControlListener; +import net.sf.gridarta.MapManagerListener; import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.GameObject; import net.sf.gridarta.gui.connectionview.ConnectionControl; @@ -173,9 +173,9 @@ private final GameObjectTextEditor gameObjectTextEditor; /** - * The main control listener which is attached to {@link #mainControl}. + * The map manager listener which is attached to {@link #mainControl}. */ - private final MainControlListener<G, A, R, C, V> mainControlListener = new MainControlListener<G, A, R, C, V>() { + private final MapManagerListener<G, A, R, C, V> mainControlListener = new MapManagerListener<G, A, R, C, V>() { /** {@inheritDoc} */ public void currentMapChanged(@Nullable final C mapControl) { @@ -296,7 +296,7 @@ if (currentMap != null) { currentMap.getMapModel().addMapModelListener(mapModelListener); } - mainControl.addMainControlListener(mainControlListener); + mainControl.addMapManagerListener(mainControlListener); archTextArea.setLineWrap(true); } Modified: trunk/src/app/net/sf/gridarta/gui/MainActions.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/MainActions.java 2008-03-23 11:19:09 UTC (rev 3731) +++ trunk/src/app/net/sf/gridarta/gui/MainActions.java 2008-03-23 12:01:32 UTC (rev 3732) @@ -22,7 +22,7 @@ import javax.swing.Action; import javax.swing.JOptionPane; import net.sf.gridarta.MainControl; -import net.sf.gridarta.MainControlListener; +import net.sf.gridarta.MapManagerListener; import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.ArchetypeSet; import net.sf.gridarta.gameobject.ArchetypeSetListener; @@ -131,9 +131,9 @@ @Nullable private MapView<G, A, R, C, V> currentMapView; /** - * The main control listener to detect created and closed map views. + * The map manager listener to detect created and closed map views. */ - private final MainControlListener<G, A, R, C, V> mainControlListener = new MainControlListener<G, A, R, C, V>() { + private final MapManagerListener<G, A, R, C, V> mainControlListener = new MapManagerListener<G, A, R, C, V>() { /** {@inheritDoc} */ public void currentMapChanged(@Nullable final C mapControl) { @@ -280,7 +280,7 @@ aCollectArches = actionFactory.createAction(true, "collectArches", this); aReloadFaces = actionFactory.createAction(true, "reloadFaces", this); aValidateMap = actionFactory.createAction(true, "validateMap", this); - mainControl.addMainControlListener(mainControlListener); + mainControl.addMapManagerListener(mainControlListener); currentMap = mainControl.getMapManager().getCurrentMap(); currentMapView = mainControl.getCurrentMapView(); } Modified: trunk/src/app/net/sf/gridarta/gui/StatusBar.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/StatusBar.java 2008-03-23 11:19:09 UTC (rev 3731) +++ trunk/src/app/net/sf/gridarta/gui/StatusBar.java 2008-03-23 12:01:32 UTC (rev 3732) @@ -33,7 +33,7 @@ import javax.swing.Timer; import javax.swing.border.BevelBorder; import net.sf.gridarta.MainControl; -import net.sf.gridarta.MainControlListener; +import net.sf.gridarta.MapManagerListener; import net.sf.gridarta.gameobject.ArchetypeSet; import net.sf.gridarta.gameobject.face.AbstractFaceObjects; import net.sf.gridarta.gui.map.LevelRenderer; @@ -107,9 +107,9 @@ }; /** - * The main control listener to detect current map changes. + * The map manager listener to detect current map changes. */ - private final MainControlListener mainControlListener = new MainControlListener() { + private final MapManagerListener mainControlListener = new MapManagerListener() { /** {@inheritDoc} */ public void currentMapChanged(@Nullable final MapControl mapControl) { @@ -201,7 +201,7 @@ memory.setBorder(new BevelBorder(BevelBorder.LOWERED)); add(memory, gbc); - mainControl.addMainControlListener(mainControlListener); + mainControl.addMapManagerListener(mainControlListener); new Timer(5000, statusBarUpdate).start(); } Modified: trunk/src/app/net/sf/gridarta/gui/connectionview/View.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/connectionview/View.java 2008-03-23 11:19:09 UTC (rev 3731) +++ trunk/src/app/net/sf/gridarta/gui/connectionview/View.java 2008-03-23 12:01:32 UTC (rev 3732) @@ -30,7 +30,7 @@ import javax.swing.JScrollPane; import javax.swing.event.ListSelectionListener; import net.sf.gridarta.MainControl; -import net.sf.gridarta.MainControlListener; +import net.sf.gridarta.MapManagerListener; import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.GameObject; import net.sf.gridarta.gui.map.MapView; @@ -71,7 +71,7 @@ /** * The main control istener to detect changed active maps. */ - private final MainControlListener<G, A, R, C, V> mainControlListener = new MainControlListener<G, A, R, C, V>() { + private final MapManagerListener<G, A, R, C, V> mainControlListener = new MapManagerListener<G, A, R, C, V>() { /** {@inheritDoc} */ public void currentMapChanged(@Nullable final C mapControl) { @@ -158,7 +158,7 @@ setLayout(new BorderLayout()); connectionList.setCellRenderer(new CellRenderer()); add(new JScrollPane(connectionList)); - mainControl.addMainControlListener(mainControlListener); + mainControl.addMapManagerListener(mainControlListener); } /** Modified: trunk/src/app/net/sf/gridarta/gui/map/GoLocationDialogManager.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/GoLocationDialogManager.java 2008-03-23 11:19:09 UTC (rev 3731) +++ trunk/src/app/net/sf/gridarta/gui/map/GoLocationDialogManager.java 2008-03-23 12:01:32 UTC (rev 3732) @@ -22,7 +22,7 @@ import java.util.HashMap; import java.util.Map; import net.sf.gridarta.MainControl; -import net.sf.gridarta.MainControlListener; +import net.sf.gridarta.MapManagerListener; import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.GameObject; import net.sf.gridarta.map.MapArchObject; @@ -42,9 +42,9 @@ private final Map<MapView<G, A, R, C, V>, GoLocationDialog> dialogs = new HashMap<MapView<G, A, R, C, V>, GoLocationDialog>(); /** - * The main control listener to detect closed map views. + * The map manager listener to detect closed map views. */ - private final MainControlListener<G, A, R, C, V> mainControlListener = new MainControlListener<G, A, R, C, V>() { + private final MapManagerListener<G, A, R, C, V> mainControlListener = new MapManagerListener<G, A, R, C, V>() { /** {@inheritDoc} */ public void currentMapChanged(@Nullable final C mapControl) { @@ -84,7 +84,7 @@ * @param mainControl The main control. */ public GoLocationDialogManager(@NotNull final MainControl<G, A, R, C, V> mainControl) { - mainControl.addMainControlListener(mainControlListener); + mainControl.addMapManagerListener(mainControlListener); } /** Modified: trunk/src/app/net/sf/gridarta/gui/map/MapCursorActions.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/MapCursorActions.java 2008-03-23 11:19:09 UTC (rev 3731) +++ trunk/src/app/net/sf/gridarta/gui/map/MapCursorActions.java 2008-03-23 12:01:32 UTC (rev 3732) @@ -22,7 +22,7 @@ import javax.swing.Action; import net.sf.gridarta.CommonConstants; import net.sf.gridarta.MainControl; -import net.sf.gridarta.MainControlListener; +import net.sf.gridarta.MapManagerListener; import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.GameObject; import net.sf.gridarta.map.MapArchObject; @@ -87,9 +87,9 @@ @Nullable private MapView<G, A, R, C, V> mapView; /** - * The main control listener used to detect changed current maps. + * The map manager listener used to detect changed current maps. */ - private final MainControlListener<G, A, R, C, V> mainControlListener = new MainControlListener<G, A, R, C, V>() { + private final MapManagerListener<G, A, R, C, V> mainControlListener = new MapManagerListener<G, A, R, C, V>() { /** {@inheritDoc} */ public void currentMapChanged(@Nullable final C mapControl) { @@ -167,7 +167,7 @@ aSelectArchBelow = actionFactory.createAction(true, "selectArchBelow", this); aArchAttributes = actionFactory.createAction(true, "archAttributes", this); mapView = mainControl.getCurrentMapView(); - mainControl.addMainControlListener(mainControlListener); + mainControl.addMapManagerListener(mainControlListener); refreshActions(); } Modified: trunk/src/app/net/sf/gridarta/gui/maptilelist/MapTileSelectionCache.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/maptilelist/MapTileSelectionCache.java 2008-03-23 11:19:09 UTC (rev 3731) +++ trunk/src/app/net/sf/gridarta/gui/maptilelist/MapTileSelectionCache.java 2008-03-23 12:01:32 UTC (rev 3732) @@ -22,7 +22,7 @@ import java.util.IdentityHashMap; import java.util.Map; import net.sf.gridarta.MainControl; -import net.sf.gridarta.MainControlListener; +import net.sf.gridarta.MapManagerListener; import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.GameObject; import net.sf.gridarta.gui.map.MapView; @@ -49,7 +49,7 @@ /** * The map control listener used to remove closed maps from {@link #cache}. */ - private final MainControlListener<G, A, R, C, V> mainControlListener = new MainControlListener<G, A, R, C, V>() { + private final MapManagerListener<G, A, R, C, V> mainControlListener = new MapManagerListener<G, A, R, C, V>() { /** {@inheritDoc} */ public void currentMapChanged(@Nullable final C mapControl) { @@ -89,7 +89,7 @@ * @param mainControl the main control to check for map changes */ public MapTileSelectionCache(@NotNull final MainControl mainControl) { - mainControl.addMainControlListener(mainControlListener); + mainControl.addMapManagerListener(mainControlListener); } /** Modified: trunk/src/app/net/sf/gridarta/gui/selectedsquare/SelectedSquareView.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/selectedsquare/SelectedSquareView.java 2008-03-23 11:19:09 UTC (rev 3731) +++ trunk/src/app/net/sf/gridarta/gui/selectedsquare/SelectedSquareView.java 2008-03-23 12:01:32 UTC (rev 3732) @@ -37,7 +37,7 @@ import javax.swing.ListSelectionModel; import javax.swing.ScrollPaneConstants; import net.sf.gridarta.MainControl; -import net.sf.gridarta.MainControlListener; +import net.sf.gridarta.MapManagerListener; import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.GameObject; import net.sf.gridarta.gui.map.MapCursorEvent; @@ -147,9 +147,9 @@ }; /** - * The main control listener. + * The map manager listener. */ - private final MainControlListener<G, A, R, C, V> mainControlListener = new MainControlListener<G, A, R, C, V>() { + private final MapManagerListener<G, A, R, C, V> mainControlListener = new MapManagerListener<G, A, R, C, V>() { /** {@inheritDoc} */ public void currentMapChanged(@Nullable final C mapControl) { @@ -245,7 +245,7 @@ list.addMouseListener(control.getMouseListener()); list.setFocusable(false); // XXX Workaround for Mantis #0000154 This is not clean and should be removed as soon as cut/copy/paste of arches is possible - mainControl.addMainControlListener(mainControlListener); + mainControl.addMapManagerListener(mainControlListener); } /** Modified: trunk/src/app/net/sf/gridarta/gui/undo/UndoControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/undo/UndoControl.java 2008-03-23 11:19:09 UTC (rev 3731) +++ trunk/src/app/net/sf/gridarta/gui/undo/UndoControl.java 2008-03-23 12:01:32 UTC (rev 3732) @@ -23,7 +23,7 @@ import java.util.Map; import javax.swing.Action; import net.sf.gridarta.MainControl; -import net.sf.gridarta.MainControlListener; +import net.sf.gridarta.MapManagerListener; import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.GameObject; import net.sf.gridarta.gui.map.MapView; @@ -120,7 +120,7 @@ /** * Listener to be notified for created/deleted maps. */ - private final MainControlListener<G, A, R, C, V> mainControlListener = new MainControlListener<G, A, R, C, V>() { + private final MapManagerListener<G, A, R, C, V> mainControlListener = new MapManagerListener<G, A, R, C, V>() { /** {@inheritDoc} */ public void currentMapChanged(@Nullable final C mapControl) { @@ -169,7 +169,7 @@ * @param mainControl the main control */ public UndoControl(@NotNull final MainControl<G, A, R, C, V> mainControl) { - mainControl.addMainControlListener(mainControlListener); + mainControl.addMapManagerListener(mainControlListener); aUndo.setEnabled(false); aRedo.setEnabled(false); } Modified: trunk/src/app/net/sf/gridarta/map/AutoValidator.java =================================================================== --- trunk/src/app/net/sf/gridarta/map/AutoValidator.java 2008-03-23 11:19:09 UTC (rev 3731) +++ trunk/src/app/net/sf/gridarta/map/AutoValidator.java 2008-03-23 12:01:32 UTC (rev 3732) @@ -25,7 +25,7 @@ import java.util.prefs.PreferenceChangeListener; import java.util.prefs.PreferenceChangeEvent; import net.sf.gridarta.MainControl; -import net.sf.gridarta.MainControlListener; +import net.sf.gridarta.MapManagerListener; import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.GameObject; import net.sf.gridarta.gui.map.MapView; @@ -67,9 +67,9 @@ private final Map<A, MapModel<G, A, R>> mapModels = new IdentityHashMap<A, MapModel<G, A, R>>(); /** - * The main control listener to track creations and deletions of maps. + * The map manager listener to track creations and deletions of maps. */ - private final MainControlListener<G, A, R, C, V> mainControlListener = new MainControlListener<G, A, R, C, V>() { + private final MapManagerListener<G, A, R, C, V> mainControlListener = new MapManagerListener<G, A, R, C, V>() { /** {@inheritDoc} */ public void currentMapChanged(final C mapControl) { @@ -185,7 +185,7 @@ prefs.addPreferenceChangeListener(preferenceChangeListener); autoValidatorProcessor = new AutoValidatorProcessor(mainControl); - mainControl.addMainControlListener(mainControlListener); + mainControl.addMapManagerListener(mainControlListener); autoValidatorProcessor.start(); if (wasEnabled) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-03-23 12:44:35
|
Revision: 3734 http://gridarta.svn.sourceforge.net/gridarta/?rev=3734&view=rev Author: akirschbaum Date: 2008-03-23 05:44:40 -0700 (Sun, 23 Mar 2008) Log Message: ----------- Remove forwarding functions from MainControl. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/CMainView.java trunk/crossfire/src/cfeditor/gui/GameObjectAttributesPanel.java trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/CMainView.java trunk/daimonin/src/daieditor/gui/GameObjectAttributesPanel.java trunk/src/app/net/sf/gridarta/CurrentMapListener.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/MainActions.java trunk/src/app/net/sf/gridarta/gui/StatusBar.java trunk/src/app/net/sf/gridarta/gui/connectionview/ConnectionControl.java trunk/src/app/net/sf/gridarta/gui/connectionview/ConnectionView.java trunk/src/app/net/sf/gridarta/gui/connectionview/LockedItemsControl.java trunk/src/app/net/sf/gridarta/gui/connectionview/LockedItemsView.java trunk/src/app/net/sf/gridarta/gui/connectionview/MonsterControl.java trunk/src/app/net/sf/gridarta/gui/connectionview/MonsterView.java trunk/src/app/net/sf/gridarta/gui/connectionview/View.java trunk/src/app/net/sf/gridarta/gui/map/GoLocationDialogManager.java trunk/src/app/net/sf/gridarta/gui/map/MapCursorActions.java trunk/src/app/net/sf/gridarta/gui/map/MapCursorControl.java trunk/src/app/net/sf/gridarta/gui/maptilelist/MapTileSelectionCache.java trunk/src/app/net/sf/gridarta/gui/selectedsquare/SelectedSquareView.java trunk/src/app/net/sf/gridarta/gui/undo/UndoControl.java trunk/src/app/net/sf/gridarta/map/AutoValidator.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-03-23 12:09:31 UTC (rev 3733) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-03-23 12:44:40 UTC (rev 3734) @@ -58,7 +58,6 @@ import net.sf.gridarta.DefaultMapManager; import net.sf.gridarta.MainControl; import net.sf.gridarta.MapManager; -import net.sf.gridarta.MapManagerListener; import net.sf.gridarta.XmlHelper; import net.sf.gridarta.gameobject.Collectable; import net.sf.gridarta.gameobject.Collector; @@ -268,7 +267,7 @@ ACTION_FACTORY.createActions(true, this, "createNew", "open", "options", "exit", "gc", "onlineHelp", "tod", "about"); mapManagerActions = new MapManagerActions<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(mapManager); mainView = new CMainView(this, mapManagerActions.getCloseAllAction()); - undoControl = new UndoControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(this); + undoControl = new UndoControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(mapManager); readGlobalSettings(); @@ -910,16 +909,6 @@ } /** {@inheritDoc} */ - public void addMapManagerListener(@NotNull final MapManagerListener<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> listener) { - mapManager.addMapManagerListener(listener); - } - - /** {@inheritDoc} */ - public void removeMapManagerListener(@NotNull final MapManagerListener<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> listener) { - mapManager.removeMapManagerListener(listener); - } - - /** {@inheritDoc} */ public void revert(@NotNull final MapControl mapControl) { if (ACTION_FACTORY.showQuestionDialog(mainView, "confirmRevertMap", mapControl.getMapFileName())) { final File mfile = mapControl.getMapFile(); Modified: trunk/crossfire/src/cfeditor/CMainView.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainView.java 2008-03-23 12:09:31 UTC (rev 3733) +++ trunk/crossfire/src/cfeditor/CMainView.java 2008-03-23 12:44:40 UTC (rev 3734) @@ -208,8 +208,8 @@ objectChooser = new InsertionObjectChooser(newMapDialogFactory, mainControl); selectedSquareControl = new SelectedSquareControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>("cfeditor", mainControl, this, mapTileListBottom, null); - final LockedItemsControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> lockedItemsControl = new LockedItemsControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(mainControl, 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, this, lockedItemsControl); + final LockedItemsControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> lockedItemsControl = new LockedItemsControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(mainControl.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); + gameObjectAttributesPanel = new GameObjectAttributesPanel(mainControl, mainControl.getMapManager(), this, lockedItemsControl); if (mapTileListBottom) { splitRightPane = new GSplitPane(JSplitPane.HORIZONTAL_SPLIT, gameObjectAttributesPanel, selectedSquareControl.getSelectedSquareView()); Modified: trunk/crossfire/src/cfeditor/gui/GameObjectAttributesPanel.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/GameObjectAttributesPanel.java 2008-03-23 12:09:31 UTC (rev 3733) +++ trunk/crossfire/src/cfeditor/gui/GameObjectAttributesPanel.java 2008-03-23 12:44:40 UTC (rev 3734) @@ -25,6 +25,7 @@ import cfeditor.map.MapArchObject; import cfeditor.map.MapControl; import net.sf.gridarta.MainControl; +import net.sf.gridarta.MapManager; import net.sf.gridarta.gui.MainView; import net.sf.gridarta.gui.connectionview.LockedItemsControl; import org.jetbrains.annotations.NotNull; @@ -42,8 +43,8 @@ private static final long serialVersionUID = 1L; /* Build Panel */ - public GameObjectAttributesPanel(final MainControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> mainControl, final MainView<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> view, final LockedItemsControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> lockedItemsControl) { - super(mainControl, view, lockedItemsControl); + public GameObjectAttributesPanel(final MainControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> mainControl, final MapManager<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> mapManager, final MainView<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> view, final LockedItemsControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> lockedItemsControl) { + super(mainControl, mapManager, view, lockedItemsControl); } /** {@inheritDoc} */ Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-03-23 12:09:31 UTC (rev 3733) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-03-23 12:44:40 UTC (rev 3734) @@ -64,7 +64,6 @@ import net.sf.gridarta.DefaultMapManager; import net.sf.gridarta.MainControl; import net.sf.gridarta.MapManager; -import net.sf.gridarta.MapManagerListener; import net.sf.gridarta.XmlHelper; import net.sf.gridarta.gameobject.Collectable; import net.sf.gridarta.gameobject.Collector; @@ -320,7 +319,7 @@ ACTION_FACTORY.createToggles(true, this, "drawDouble"); mapManagerActions = new MapManagerActions<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(mapManager); mainView = new CMainView(this, mapManagerActions.getCloseAllAction()); - undoControl = new UndoControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(this); + undoControl = new UndoControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(mapManager); Updater.startup(mainView, this); readGlobalSettings(); @@ -1056,16 +1055,6 @@ } /** {@inheritDoc} */ - public void addMapManagerListener(@NotNull final MapManagerListener<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> listener) { - mapManager.addMapManagerListener(listener); - } - - /** {@inheritDoc} */ - public void removeMapManagerListener(@NotNull final MapManagerListener<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> listener) { - mapManager.removeMapManagerListener(listener); - } - - /** {@inheritDoc} */ public void revert(@NotNull final MapControl mapControl) { if (ACTION_FACTORY.showQuestionDialog(mainView, "confirmRevertMap", mapControl.getMapFileName())) { final File mfile = mapControl.getMapFile(); Modified: trunk/daimonin/src/daieditor/CMainView.java =================================================================== --- trunk/daimonin/src/daieditor/CMainView.java 2008-03-23 12:09:31 UTC (rev 3733) +++ trunk/daimonin/src/daieditor/CMainView.java 2008-03-23 12:44:40 UTC (rev 3734) @@ -212,8 +212,8 @@ objectChooser = new InsertionObjectChooser(newMapDialogFactory, mainControl); selectedSquareControl = new SelectedSquareControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>("daieditor", mainControl, this, mapTileListBottom, GUIUtils.getSysIcon(IGUIConstants.TILE_NORTH)); - final LockedItemsControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> lockedItemsControl = new LockedItemsControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(mainControl, 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, this, lockedItemsControl); + final LockedItemsControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> lockedItemsControl = new LockedItemsControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(mainControl.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); + gameObjectAttributesPanel = new GameObjectAttributesPanel(mainControl, mainControl.getMapManager(), this, lockedItemsControl); if (mapTileListBottom) { splitRightPane = new GSplitPane(JSplitPane.HORIZONTAL_SPLIT, gameObjectAttributesPanel, selectedSquareControl.getSelectedSquareView()); Modified: trunk/daimonin/src/daieditor/gui/GameObjectAttributesPanel.java =================================================================== --- trunk/daimonin/src/daieditor/gui/GameObjectAttributesPanel.java 2008-03-23 12:09:31 UTC (rev 3733) +++ trunk/daimonin/src/daieditor/gui/GameObjectAttributesPanel.java 2008-03-23 12:44:40 UTC (rev 3734) @@ -25,6 +25,7 @@ import daieditor.map.MapArchObject; import daieditor.map.MapControl; import net.sf.gridarta.MainControl; +import net.sf.gridarta.MapManager; import net.sf.gridarta.gui.MainView; import net.sf.gridarta.gui.connectionview.LockedItemsControl; import org.jetbrains.annotations.NotNull; @@ -42,8 +43,8 @@ private static final long serialVersionUID = 1L; /* Build Panel */ - public GameObjectAttributesPanel(final MainControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> mainControl, final MainView<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> view, final LockedItemsControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> lockedItemsControl) { - super(mainControl, view, lockedItemsControl); + public GameObjectAttributesPanel(final MainControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> mainControl, final MapManager<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> mapManager, final MainView<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> view, final LockedItemsControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> lockedItemsControl) { + super(mainControl, mapManager, view, lockedItemsControl); } /** {@inheritDoc} */ Modified: trunk/src/app/net/sf/gridarta/CurrentMapListener.java =================================================================== --- trunk/src/app/net/sf/gridarta/CurrentMapListener.java 2008-03-23 12:09:31 UTC (rev 3733) +++ trunk/src/app/net/sf/gridarta/CurrentMapListener.java 2008-03-23 12:44:40 UTC (rev 3734) @@ -197,7 +197,7 @@ this.trackMapFileName = trackMapFileName; this.trackMapCursor = trackMapCursor; if (mapControl == null) { - mainControl.addMapManagerListener(mapManagerListener); + mainControl.getMapManager().addMapManagerListener(mapManagerListener); currentMap = mainControl.getMapManager().getCurrentMap(); if (currentMap != null) { currentMap.addMapControlListener(mapControlListener); @@ -222,7 +222,7 @@ */ public void closeNotify() { if (mapControl == null) { - mainControl.removeMapManagerListener(mapManagerListener); + mainControl.getMapManager().removeMapManagerListener(mapManagerListener); } if (currentMap != null) { currentMap.removeMapControlListener(mapControlListener); Modified: trunk/src/app/net/sf/gridarta/MainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/MainControl.java 2008-03-23 12:09:31 UTC (rev 3733) +++ trunk/src/app/net/sf/gridarta/MainControl.java 2008-03-23 12:44:40 UTC (rev 3734) @@ -140,18 +140,6 @@ @Nullable MapView<G, A, R, C, V> getCurrentMapView(); /** - * Register a MapManagerListener. - * @param listener MapManagerListener to register - */ - void addMapManagerListener(@NotNull MapManagerListener<G, A, R, C, V> listener); - - /** - * Remove a MapManagerListener. - * @param listener MapManagerListener to remove - */ - void removeMapManagerListener(@NotNull MapManagerListener<G, A, R, C, V> listener); - - /** * Invoked when user wants to save a map to certain file. * @param mapControl the map to be saved * @return <code>true</code> if the user confirmed saving the map and the Modified: trunk/src/app/net/sf/gridarta/gui/ErrorListView.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/ErrorListView.java 2008-03-23 12:09:31 UTC (rev 3733) +++ trunk/src/app/net/sf/gridarta/gui/ErrorListView.java 2008-03-23 12:44:40 UTC (rev 3734) @@ -36,7 +36,7 @@ import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; import net.sf.gridarta.AbstractMainControl; -import net.sf.gridarta.MainControl; +import net.sf.gridarta.MapManager; import net.sf.gridarta.MapManagerListener; import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.GameObject; @@ -140,9 +140,9 @@ /** * Create a ConnectionPanel. * - * @param mainControl The main control. + * @param mapControl the map manager */ - public ErrorListView(@NotNull final MainControl<G, A, R, C, V> mainControl) { + public ErrorListView(@NotNull final MapManager<G, A, R, C, V> mapManager) { setLayout(new BorderLayout()); final JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, new JScrollPane(errorList), new JScrollPane(errorMsg)); splitPane.setOneTouchExpandable(true); @@ -155,8 +155,8 @@ highlightEntries(errorList.getSelectedIndex()); } }); - mainControl.addMapManagerListener(mapManagerListener); - updateErrors(mainControl.getMapManager().getCurrentMap()); + mapManager.addMapManagerListener(mapManagerListener); + updateErrors(mapManager.getCurrentMap()); } /** Modified: trunk/src/app/net/sf/gridarta/gui/GameObjectAttributesPanel.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/GameObjectAttributesPanel.java 2008-03-23 12:09:31 UTC (rev 3733) +++ trunk/src/app/net/sf/gridarta/gui/GameObjectAttributesPanel.java 2008-03-23 12:44:40 UTC (rev 3734) @@ -46,6 +46,7 @@ import javax.swing.border.EtchedBorder; import net.sf.gridarta.CFArchType; import net.sf.gridarta.MainControl; +import net.sf.gridarta.MapManager; import net.sf.gridarta.MapManagerListener; import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.GameObject; @@ -111,6 +112,11 @@ private final MainControl<G, A, R, C, V> mainControl; /** + * The map manager. + */ + private final MapManager<G, A, R, C, V> mapManager; + + /** * The tabs of this GameObjectAttributesPanel. */ protected final JTabbedPane panelDesktop = new JTabbedPane(SwingConstants.TOP); @@ -262,10 +268,11 @@ * Create the GameObjectAttributesPanel. * @param mainControl MainControl to use, e.g. for accessing AnimationObjects. */ - protected GameObjectAttributesPanel(@NotNull final MainControl<G, A, R, C, V> mainControl, final MainView<G, A, R, C, V> mainView, final LockedItemsControl<G, A, R, C, V> lockedItemsControl) { + protected GameObjectAttributesPanel(@NotNull final MainControl<G, A, R, C, V> mainControl, @NotNull final MapManager<G, A, R, C, V> mapManager, final MainView<G, A, R, C, V> mainView, final LockedItemsControl<G, A, R, C, V> lockedItemsControl) { super(new BorderLayout()); this.mainControl = mainControl; - this.errorListView = new ErrorListView<G, A, R, C, V>(mainControl); + this.mapManager = mapManager; + this.errorListView = new ErrorListView<G, A, R, C, V>(mapManager); this.mainView = mainView; gameObjectTextEditor = new GameObjectTextEditor(); @@ -292,11 +299,11 @@ panelDesktop.add(errorListView, "Warnings"); refreshDisplay(); - currentMap = mainControl.getMapManager().getCurrentMap(); + currentMap = mapManager.getCurrentMap(); if (currentMap != null) { currentMap.getMapModel().addMapModelListener(mapModelListener); } - mainControl.addMapManagerListener(mapManagerListener); + mapManager.addMapManagerListener(mapManagerListener); archTextArea.setLineWrap(true); } @@ -752,7 +759,7 @@ } // Recalculate the editType value. It shall stay 100% accurate ;) - gameObject.calculateEditType(mainControl.getMapManager().getCurrentMap().getActiveEditType()); + gameObject.calculateEditType(mapManager.getCurrentMap().getActiveEditType()); mapSquare.getModel().endTransaction(); } @@ -1019,12 +1026,12 @@ } private JPanel createConnectionPanel() { - final ConnectionControl<G, A, R, C, V> connectionControl = new ConnectionControl<G, A, R, C, V>(mainControl); + final ConnectionControl<G, A, R, C, V> connectionControl = new ConnectionControl<G, A, R, C, V>(mapManager); return connectionControl.getView(); } private JPanel createMonsterPanel() { - final MonsterControl<G, A, R, C, V> monsterControl = new MonsterControl<G, A, R, C, V>(mainControl); + final MonsterControl<G, A, R, C, V> monsterControl = new MonsterControl<G, A, R, C, V>(mapManager); return monsterControl.getView(); } Modified: trunk/src/app/net/sf/gridarta/gui/MainActions.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/MainActions.java 2008-03-23 12:09:31 UTC (rev 3733) +++ trunk/src/app/net/sf/gridarta/gui/MainActions.java 2008-03-23 12:44:40 UTC (rev 3734) @@ -280,7 +280,7 @@ aCollectArches = actionFactory.createAction(true, "collectArches", this); aReloadFaces = actionFactory.createAction(true, "reloadFaces", this); aValidateMap = actionFactory.createAction(true, "validateMap", this); - mainControl.addMapManagerListener(mapManagerListener); + mainControl.getMapManager().addMapManagerListener(mapManagerListener); currentMap = mainControl.getMapManager().getCurrentMap(); currentMapView = mainControl.getCurrentMapView(); } Modified: trunk/src/app/net/sf/gridarta/gui/StatusBar.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/StatusBar.java 2008-03-23 12:09:31 UTC (rev 3733) +++ trunk/src/app/net/sf/gridarta/gui/StatusBar.java 2008-03-23 12:44:40 UTC (rev 3734) @@ -201,7 +201,7 @@ memory.setBorder(new BevelBorder(BevelBorder.LOWERED)); add(memory, gbc); - mainControl.addMapManagerListener(mapManagerListener); + mainControl.getMapManager().addMapManagerListener(mapManagerListener); new Timer(5000, statusBarUpdate).start(); } Modified: trunk/src/app/net/sf/gridarta/gui/connectionview/ConnectionControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/connectionview/ConnectionControl.java 2008-03-23 12:09:31 UTC (rev 3733) +++ trunk/src/app/net/sf/gridarta/gui/connectionview/ConnectionControl.java 2008-03-23 12:44:40 UTC (rev 3734) @@ -19,7 +19,7 @@ package net.sf.gridarta.gui.connectionview; -import net.sf.gridarta.MainControl; +import net.sf.gridarta.MapManager; import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.GameObject; import net.sf.gridarta.gui.map.MapViewBasic; @@ -37,10 +37,10 @@ /** * Create a new instance. * - * @param mainControl the main control to use + * @param mapManager the map manager */ - public ConnectionControl(@NotNull final MainControl<G, A, R, C, V> mainControl) { - super(new ConnectionView<G, A, R, C, V>(mainControl)); + public ConnectionControl(@NotNull final MapManager<G, A, R, C, V> mapManager) { + super(new ConnectionView<G, A, R, C, V>(mapManager)); } } // class ConnectionControl Modified: trunk/src/app/net/sf/gridarta/gui/connectionview/ConnectionView.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/connectionview/ConnectionView.java 2008-03-23 12:09:31 UTC (rev 3733) +++ trunk/src/app/net/sf/gridarta/gui/connectionview/ConnectionView.java 2008-03-23 12:44:40 UTC (rev 3734) @@ -19,7 +19,7 @@ package net.sf.gridarta.gui.connectionview; -import net.sf.gridarta.MainControl; +import net.sf.gridarta.MapManager; import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.GameObject; import net.sf.gridarta.gui.map.MapViewBasic; @@ -41,10 +41,10 @@ /** * Create a ConnectionView. - * @param mainControl MainControl. + * @param mapManager the map manager */ - public ConnectionView(@NotNull final MainControl<G, A, R, C, V> mainControl) { - super(mainControl); + public ConnectionView(@NotNull final MapManager<G, A, R, C, V> mapManager) { + super(mapManager); } /** {@inheritDoc} */ Modified: trunk/src/app/net/sf/gridarta/gui/connectionview/LockedItemsControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/connectionview/LockedItemsControl.java 2008-03-23 12:09:31 UTC (rev 3733) +++ trunk/src/app/net/sf/gridarta/gui/connectionview/LockedItemsControl.java 2008-03-23 12:44:40 UTC (rev 3734) @@ -19,7 +19,7 @@ package net.sf.gridarta.gui.connectionview; -import net.sf.gridarta.MainControl; +import net.sf.gridarta.MapManager; import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.GameObject; import net.sf.gridarta.gui.map.MapViewBasic; @@ -37,12 +37,12 @@ /** * Create a new instance. * - * @param mainControl the main control to use + * @param mapManager the map manager * * @param typeNumbers the type numbers to consider */ - public LockedItemsControl(@NotNull final MainControl<G, A, R, C, V> mainControl, @NotNull final int... typeNumbers) { - super(new LockedItemsView<G, A, R, C, V>(mainControl, typeNumbers)); + public LockedItemsControl(@NotNull final MapManager<G, A, R, C, V> mapManager, @NotNull final int... typeNumbers) { + super(new LockedItemsView<G, A, R, C, V>(mapManager, typeNumbers)); } } // class LockedItemsControl Modified: trunk/src/app/net/sf/gridarta/gui/connectionview/LockedItemsView.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/connectionview/LockedItemsView.java 2008-03-23 12:09:31 UTC (rev 3733) +++ trunk/src/app/net/sf/gridarta/gui/connectionview/LockedItemsView.java 2008-03-23 12:44:40 UTC (rev 3734) @@ -21,7 +21,7 @@ import java.util.HashSet; import java.util.Set; -import net.sf.gridarta.MainControl; +import net.sf.gridarta.MapManager; import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.GameObject; import net.sf.gridarta.gui.map.MapViewBasic; @@ -48,11 +48,11 @@ /** * Create a LockedItemsView. - * @param mainControl MainControl. + * @param mapManager the map manager * @param typeNumbers the type numbers to consider */ - public LockedItemsView(@NotNull final MainControl<G, A, R, C, V> mainControl, @NotNull final int... typeNumbers) { - super(mainControl); + public LockedItemsView(@NotNull final MapManager<G, A, R, C, V> mapManager, @NotNull final int... typeNumbers) { + super(mapManager); for (final int typeNumber : typeNumbers) { this.typeNumbers.add(typeNumber); } Modified: trunk/src/app/net/sf/gridarta/gui/connectionview/MonsterControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/connectionview/MonsterControl.java 2008-03-23 12:09:31 UTC (rev 3733) +++ trunk/src/app/net/sf/gridarta/gui/connectionview/MonsterControl.java 2008-03-23 12:44:40 UTC (rev 3734) @@ -19,7 +19,7 @@ package net.sf.gridarta.gui.connectionview; -import net.sf.gridarta.MainControl; +import net.sf.gridarta.MapManager; import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.GameObject; import net.sf.gridarta.gui.map.MapViewBasic; @@ -37,10 +37,10 @@ /** * Create a new instance. * - * @param mainControl the main control to use + * @param mapManager the map manager */ - public MonsterControl(@NotNull final MainControl<G, A, R, C, V> mainControl) { - super(new MonsterView<G, A, R, C, V>(mainControl)); + public MonsterControl(@NotNull final MapManager<G, A, R, C, V> mapManager) { + super(new MonsterView<G, A, R, C, V>(mapManager)); } } // class MonsterControl Modified: trunk/src/app/net/sf/gridarta/gui/connectionview/MonsterView.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/connectionview/MonsterView.java 2008-03-23 12:09:31 UTC (rev 3733) +++ trunk/src/app/net/sf/gridarta/gui/connectionview/MonsterView.java 2008-03-23 12:44:40 UTC (rev 3734) @@ -20,7 +20,7 @@ package net.sf.gridarta.gui.connectionview; import net.sf.gridarta.CFArchTypeList; -import net.sf.gridarta.MainControl; +import net.sf.gridarta.MapManager; import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.GameObject; import net.sf.gridarta.gui.map.MapViewBasic; @@ -42,10 +42,10 @@ /** * Create a MonsterView. - * @param mainControl MainControl. + * @param mapManager the map manager */ - public MonsterView(@NotNull final MainControl<G, A, R, C, V> mainControl) { - super(mainControl); + public MonsterView(@NotNull final MapManager<G, A, R, C, V> mapManager) { + super(mapManager); } /** {@inheritDoc} */ Modified: trunk/src/app/net/sf/gridarta/gui/connectionview/View.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/connectionview/View.java 2008-03-23 12:09:31 UTC (rev 3733) +++ trunk/src/app/net/sf/gridarta/gui/connectionview/View.java 2008-03-23 12:44:40 UTC (rev 3734) @@ -29,7 +29,7 @@ import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.event.ListSelectionListener; -import net.sf.gridarta.MainControl; +import net.sf.gridarta.MapManager; import net.sf.gridarta.MapManagerListener; import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.GameObject; @@ -152,13 +152,13 @@ /** * Create a panel. - * @param mainControl MainControl. + * @param mapManager the map manager */ - protected View(@NotNull final MainControl<G, A, R, C, V> mainControl) { + protected View(@NotNull final MapManager<G, A, R, C, V> mapManager) { setLayout(new BorderLayout()); connectionList.setCellRenderer(new CellRenderer()); add(new JScrollPane(connectionList)); - mainControl.addMapManagerListener(mapManagerListener); + mapManager.addMapManagerListener(mapManagerListener); } /** Modified: trunk/src/app/net/sf/gridarta/gui/map/GoLocationDialogManager.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/GoLocationDialogManager.java 2008-03-23 12:09:31 UTC (rev 3733) +++ trunk/src/app/net/sf/gridarta/gui/map/GoLocationDialogManager.java 2008-03-23 12:44:40 UTC (rev 3734) @@ -21,7 +21,7 @@ import java.util.HashMap; import java.util.Map; -import net.sf.gridarta.MainControl; +import net.sf.gridarta.MapManager; import net.sf.gridarta.MapManagerListener; import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.GameObject; @@ -81,10 +81,10 @@ /** * Create a new instance. * - * @param mainControl The main control. + * @param mapManager the map manager */ - public GoLocationDialogManager(@NotNull final MainControl<G, A, R, C, V> mainControl) { - mainControl.addMapManagerListener(mapManagerListener); + public GoLocationDialogManager(@NotNull final MapManager<G, A, R, C, V> mapManager) { + mapManager.addMapManagerListener(mapManagerListener); } /** Modified: trunk/src/app/net/sf/gridarta/gui/map/MapCursorActions.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/MapCursorActions.java 2008-03-23 12:09:31 UTC (rev 3733) +++ trunk/src/app/net/sf/gridarta/gui/map/MapCursorActions.java 2008-03-23 12:44:40 UTC (rev 3734) @@ -167,7 +167,7 @@ aSelectArchBelow = actionFactory.createAction(true, "selectArchBelow", this); aArchAttributes = actionFactory.createAction(true, "archAttributes", this); mapView = mainControl.getCurrentMapView(); - mainControl.addMapManagerListener(mapManagerListener); + mainControl.getMapManager().addMapManagerListener(mapManagerListener); refreshActions(); } Modified: trunk/src/app/net/sf/gridarta/gui/map/MapCursorControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/MapCursorControl.java 2008-03-23 12:09:31 UTC (rev 3733) +++ trunk/src/app/net/sf/gridarta/gui/map/MapCursorControl.java 2008-03-23 12:44:40 UTC (rev 3734) @@ -58,7 +58,7 @@ */ public MapCursorControl(final String key, final MainControl<G, A, R, C, V> mainControl) { this.mainControl = mainControl; - goLocationDialogManager = new GoLocationDialogManager<G, A, R, C, V>(mainControl); + goLocationDialogManager = new GoLocationDialogManager<G, A, R, C, V>(mainControl.getMapManager()); actions = new MapCursorActions<G, A, R, C, V>(key, this, mainControl); } Modified: trunk/src/app/net/sf/gridarta/gui/maptilelist/MapTileSelectionCache.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/maptilelist/MapTileSelectionCache.java 2008-03-23 12:09:31 UTC (rev 3733) +++ trunk/src/app/net/sf/gridarta/gui/maptilelist/MapTileSelectionCache.java 2008-03-23 12:44:40 UTC (rev 3734) @@ -21,7 +21,7 @@ import java.util.IdentityHashMap; import java.util.Map; -import net.sf.gridarta.MainControl; +import net.sf.gridarta.MapManager; import net.sf.gridarta.MapManagerListener; import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.GameObject; @@ -86,10 +86,10 @@ /** * Create a new instance. * - * @param mainControl the main control to check for map changes + * @param mapManager the map manager */ - public MapTileSelectionCache(@NotNull final MainControl mainControl) { - mainControl.addMapManagerListener(mapManagerListener); + public MapTileSelectionCache(@NotNull final MapManager<G, A, R, C, V> mapManager) { + mapManager.addMapManagerListener(mapManagerListener); } /** Modified: trunk/src/app/net/sf/gridarta/gui/selectedsquare/SelectedSquareView.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/selectedsquare/SelectedSquareView.java 2008-03-23 12:09:31 UTC (rev 3733) +++ trunk/src/app/net/sf/gridarta/gui/selectedsquare/SelectedSquareView.java 2008-03-23 12:44:40 UTC (rev 3734) @@ -209,7 +209,7 @@ */ 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) { this.mainControl = mainControl; - mapTileSelectionCache = new MapTileSelectionCache<G, A, R, C, V>(mainControl); + mapTileSelectionCache = new MapTileSelectionCache<G, A, R, C, V>(mainControl.getMapManager()); setLayout(new BorderLayout()); @@ -245,7 +245,7 @@ list.addMouseListener(control.getMouseListener()); list.setFocusable(false); // XXX Workaround for Mantis #0000154 This is not clean and should be removed as soon as cut/copy/paste of arches is possible - mainControl.addMapManagerListener(mapManagerListener); + mainControl.getMapManager().addMapManagerListener(mapManagerListener); } /** Modified: trunk/src/app/net/sf/gridarta/gui/undo/UndoControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/undo/UndoControl.java 2008-03-23 12:09:31 UTC (rev 3733) +++ trunk/src/app/net/sf/gridarta/gui/undo/UndoControl.java 2008-03-23 12:44:40 UTC (rev 3734) @@ -22,7 +22,7 @@ import java.util.IdentityHashMap; import java.util.Map; import javax.swing.Action; -import net.sf.gridarta.MainControl; +import net.sf.gridarta.MapManager; import net.sf.gridarta.MapManagerListener; import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.GameObject; @@ -166,10 +166,10 @@ /** * Create a new instance. * - * @param mainControl the main control + * @param mapManager the map manager */ - public UndoControl(@NotNull final MainControl<G, A, R, C, V> mainControl) { - mainControl.addMapManagerListener(mapManagerListener); + public UndoControl(@NotNull final MapManager<G, A, R, C, V> mapManager) { + mapManager.addMapManagerListener(mapManagerListener); aUndo.setEnabled(false); aRedo.setEnabled(false); } Modified: trunk/src/app/net/sf/gridarta/map/AutoValidator.java =================================================================== --- trunk/src/app/net/sf/gridarta/map/AutoValidator.java 2008-03-23 12:09:31 UTC (rev 3733) +++ trunk/src/app/net/sf/gridarta/map/AutoValidator.java 2008-03-23 12:44:40 UTC (rev 3734) @@ -185,7 +185,7 @@ prefs.addPreferenceChangeListener(preferenceChangeListener); autoValidatorProcessor = new AutoValidatorProcessor(mainControl); - mainControl.addMapManagerListener(mapManagerListener); + mainControl.getMapManager().addMapManagerListener(mapManagerListener); autoValidatorProcessor.start(); if (wasEnabled) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-03-23 13:32:30
|
Revision: 3735 http://gridarta.svn.sourceforge.net/gridarta/?rev=3735&view=rev Author: akirschbaum Date: 2008-03-23 06:32:31 -0700 (Sun, 23 Mar 2008) Log Message: ----------- Remove calls to MainControl.getMapManager(). Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/CMainView.java trunk/crossfire/src/cfeditor/MapActions.java trunk/crossfire/src/cfeditor/ViewActions.java trunk/crossfire/src/cfeditor/gui/GameObjectAttributesDialog.java trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/CMainView.java trunk/daimonin/src/daieditor/MapActions.java trunk/daimonin/src/daieditor/gui/GameObjectAttributesDialog.java trunk/src/app/net/sf/gridarta/AbstractMainControl.java trunk/src/app/net/sf/gridarta/CurrentMapListener.java trunk/src/app/net/sf/gridarta/MapImageCache.java trunk/src/app/net/sf/gridarta/gui/MainView.java trunk/src/app/net/sf/gridarta/gui/map/MapCursorActions.java trunk/src/app/net/sf/gridarta/gui/map/MapCursorControl.java trunk/src/app/net/sf/gridarta/gui/map/MapFileActions.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-03-23 12:44:40 UTC (rev 3734) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-03-23 13:32:31 UTC (rev 3735) @@ -263,10 +263,10 @@ instance = this; archetypeSet = new ArchetypeSet(this); scriptControl = new ScriptController(this); - mapCursorControl = new MapCursorControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>("cfeditor", this); + mapCursorControl = new MapCursorControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>("cfeditor", this, mapManager); ACTION_FACTORY.createActions(true, this, "createNew", "open", "options", "exit", "gc", "onlineHelp", "tod", "about"); mapManagerActions = new MapManagerActions<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(mapManager); - mainView = new CMainView(this, mapManagerActions.getCloseAllAction()); + mainView = new CMainView(this, mapManager, mapManagerActions.getCloseAllAction()); undoControl = new UndoControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(mapManager); readGlobalSettings(); @@ -762,7 +762,7 @@ // types.xml is missing! ACTION_FACTORY.showMessageDialog(mainView, "openAttrDialogNoTypes"); } else if (gameObject != null && !gameObject.hasUndefinedArchetype()) { - GameObjectAttributesDialog.showAttribDialog(typeList, gameObject, this, treasureListTree); + GameObjectAttributesDialog.showAttribDialog(typeList, gameObject, this, mapManager, treasureListTree); } else { ACTION_FACTORY.showMessageDialog(mainView, "openAttrDialogNoDefaultArch"); } Modified: trunk/crossfire/src/cfeditor/CMainView.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainView.java 2008-03-23 12:44:40 UTC (rev 3734) +++ trunk/crossfire/src/cfeditor/CMainView.java 2008-03-23 13:32:31 UTC (rev 3735) @@ -44,6 +44,7 @@ import javax.swing.JToolBar; import javax.swing.event.InternalFrameEvent; import net.sf.gridarta.MainControl; +import net.sf.gridarta.MapManager; import net.sf.gridarta.MenuHelper; import net.sf.gridarta.gui.ArchetypesActions; import net.sf.gridarta.gui.GSplitPane; @@ -87,6 +88,9 @@ /** The controller of this view. */ private final CMainControl mainControl; + /** The map manager. */ + @NotNull private final MapManager<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> mapManager; + /** The panel that contains the object chooser. */ private InsertionObjectChooser objectChooser; @@ -141,16 +145,18 @@ /** * Constructs the main view and registers the given main controller. * @param mainControl MainControl to attach to. + * @param mapManager the map manager * @param aCloseAll the action "close all map windows" */ - CMainView(@NotNull final CMainControl mainControl, @NotNull final Action aCloseAll) { - super(mainControl, ACTION_FACTORY.format("mainWindow.title")); + 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")); this.mainControl = mainControl; + this.mapManager = mapManager; aViewTreasurelists = ACTION_FACTORY.createAction(true, "viewTreasurelists", mainControl); this.aCloseAll = aCloseAll; - viewActions = new ViewActions(mainControl); - mapActions = new MapActions(mainControl); + viewActions = new ViewActions(mainControl, mapManager); + mapActions = new MapActions(mainControl, mapManager); initActions(); final ImageIcon icon = GUIUtils.getIcon(IGUIConstants.APP_ICON); @@ -208,8 +214,8 @@ objectChooser = new InsertionObjectChooser(newMapDialogFactory, mainControl); selectedSquareControl = new SelectedSquareControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>("cfeditor", mainControl, this, mapTileListBottom, null); - final LockedItemsControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> lockedItemsControl = new LockedItemsControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(mainControl.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); - gameObjectAttributesPanel = new GameObjectAttributesPanel(mainControl, mainControl.getMapManager(), this, lockedItemsControl); + 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) { splitRightPane = new GSplitPane(JSplitPane.HORIZONTAL_SPLIT, gameObjectAttributesPanel, selectedSquareControl.getSelectedSquareView()); @@ -315,7 +321,7 @@ if (!fCareAboutIconification) { try { mapView.setIcon(false); - mainControl.getMapManager().setCurrentLevel(mapView.getMapControl()); + mapManager.setCurrentLevel(mapView.getMapControl()); mapView.setVisible(true); mapView.setSelected(true); mapView.moveToFront(); @@ -329,7 +335,7 @@ } } else { try { - mainControl.getMapManager().setCurrentLevel(mapView.getMapControl()); + mapManager.setCurrentLevel(mapView.getMapControl()); mapView.setVisible(true); mapView.setSelected(true); mapView.moveToFront(); @@ -344,7 +350,7 @@ } // No non-iconified level windows found - mainControl.getMapManager().setCurrentLevel(null); + mapManager.setCurrentLevel(null); } /** Gives focus to the next window. */ @@ -428,7 +434,7 @@ generateCurrentMapViewChangedEvent(); final MapControl level = mapView.getMapControl(); level.setFocus(mapView); - mainControl.getMapManager().setCurrentLevel(level); + mapManager.setCurrentLevel(level); //statusBar.setLevelInfo(level); } @@ -438,7 +444,7 @@ /** {@inheritDoc} */ public void internalFrameClosing(final InternalFrameEvent e) { - mainControl.getMapManager().closeView((MapView<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>) e.getInternalFrame()); + mapManager.closeView((MapView<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>) e.getInternalFrame()); } /** {@inheritDoc} */ @@ -536,7 +542,7 @@ } currentMapView = newCurrentMapView; - mainControl.getMapManager().fireCurrentMapViewChangedEvent(currentMapView); + mapManager.fireCurrentMapViewChangedEvent(currentMapView); } /** Modified: trunk/crossfire/src/cfeditor/MapActions.java =================================================================== --- trunk/crossfire/src/cfeditor/MapActions.java 2008-03-23 12:44:40 UTC (rev 3734) +++ trunk/crossfire/src/cfeditor/MapActions.java 2008-03-23 13:32:31 UTC (rev 3735) @@ -34,6 +34,7 @@ import net.sf.gridarta.CommonConstants; import net.sf.gridarta.CurrentMapListener; import net.sf.gridarta.MainControl; +import net.sf.gridarta.MapManager; import net.sf.gridarta.gui.map.MapCursorEvent; import net.sf.gridarta.gui.map.MapView; import net.sf.japi.swing.ActionFactory; @@ -101,6 +102,9 @@ */ private final CMainControl mainControl; + /** The map manager. */ + private final MapManager<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> mapManager; + /** * The current map listener used to detect current map/map view changes. */ @@ -110,9 +114,12 @@ * Create a new instance. * * @param mainControl the main control to use + * + * @param mapManager the map manager */ - public MapActions(final CMainControl mainControl) { + public MapActions(final CMainControl mainControl, final MapManager<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> mapManager) { this.mainControl = mainControl; + this.mapManager = mapManager; autoJoin = prefs.getBoolean(AUTOJOIN_KEY, false); @@ -120,7 +127,7 @@ aDirections[i] = ACTION_FACTORY.createAction(true, directionsMap[i], this); } - currentMapListener = new CurrentMapListener<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(mainControl, null, false, false, true) { + currentMapListener = new CurrentMapListener<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(mainControl, mapManager, null, false, false, true) { /** {@inheritDoc} */ @Override protected void mapHasChanged() { @@ -194,7 +201,7 @@ public void mapCreateView() { final MapView<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> mapView = getCreateViewEnabled(); if (mapView != null) { - mainControl.getMapManager().mapCreateView(mapView.getMapControl(), mapView.getView().getViewPosition()); + mapManager.mapCreateView(mapView.getMapControl(), mapView.getView().getViewPosition()); } } @@ -280,7 +287,7 @@ return; } - final MapView<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> newMapView = mainControl.getMapManager().openMapFileWithView(newfile, null); // open the new map + final MapView<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> newMapView = mapManager.openMapFileWithView(newfile, null); // open the new map if (exitPos.x == 0 && exitPos.y == 0) { // use the entry point defined by the map header @@ -292,7 +299,7 @@ // Update the main view so the new map instantly pops up. mainControl.getMainView().update(mainControl.getMainView().getGraphics()); - mainControl.getMapManager().closeView(currentMapView); + mapManager.closeView(currentMapView); } if (log.isDebugEnabled()) { log.debug("exit: '" + path + "' " + exitPos.x + ", " + exitPos.y); @@ -362,14 +369,14 @@ return; } - final MapView<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> newMapView = mainControl.getMapManager().openMapFileWithView(newfile, null); + final MapView<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> newMapView = mapManager.openMapFileWithView(newfile, null); if (newMapView == null) { return; } newMapView.getView().setViewPosition(calculateNewViewPosition(currentMapView.getView(), newMapView.getView(), direction)); - mainControl.getMapManager().closeView(currentMapView); + mapManager.closeView(currentMapView); } /** Modified: trunk/crossfire/src/cfeditor/ViewActions.java =================================================================== --- trunk/crossfire/src/cfeditor/ViewActions.java 2008-03-23 12:44:40 UTC (rev 3734) +++ trunk/crossfire/src/cfeditor/ViewActions.java 2008-03-23 13:32:31 UTC (rev 3735) @@ -24,6 +24,7 @@ import cfeditor.map.MapArchObject; import cfeditor.map.MapControl; import net.sf.gridarta.CurrentMapListener; +import net.sf.gridarta.MapManager; import net.sf.gridarta.gui.GUIConstants; import net.sf.gridarta.gui.map.MapCursorEvent; import net.sf.japi.swing.ActionFactory; @@ -73,12 +74,14 @@ * Create a new instance. * * @param mainControl the main control to use + * + * @param mapManager the map manager */ - public ViewActions(@NotNull final CMainControl mainControl) { + public ViewActions(@NotNull final CMainControl mainControl, @NotNull final MapManager<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> mapManager) { this.mainControl = mainControl; ACTION_FACTORY.createActions(true, this, "resetView"); - currentMapListener = new CurrentMapListener<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(mainControl, null, false, false, false) { + currentMapListener = new CurrentMapListener<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(mainControl, mapManager, null, false, false, false) { /** {@inheritDoc} */ @Override protected void mapHasChanged() { Modified: trunk/crossfire/src/cfeditor/gui/GameObjectAttributesDialog.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/GameObjectAttributesDialog.java 2008-03-23 12:44:40 UTC (rev 3734) +++ trunk/crossfire/src/cfeditor/gui/GameObjectAttributesDialog.java 2008-03-23 13:32:31 UTC (rev 3735) @@ -37,6 +37,7 @@ import net.sf.gridarta.CFArchType; import net.sf.gridarta.CFArchTypeList; import net.sf.gridarta.MainControl; +import net.sf.gridarta.MapManager; import net.sf.gridarta.gameobject.ArchAttribType; import net.sf.gridarta.gui.AbstractGameObjectAttributesDialog; import net.sf.gridarta.gui.map.TilePanel; @@ -63,19 +64,23 @@ /** Action Factory. */ private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("cfeditor"); + /** The map manager. */ + private final MapManager<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> mapManager; + /** * Wrapper method for the constructor. * This method only creates a GameObjectAttributesDialog if there's no dialog for the same gameObject already. * @param archTypeList the list of CF type-data * @param gameObject the GameObject to be displayed by this dialog * @param mainControl main control + * @param mapManager the map manager */ - public static void showAttribDialog(final CFArchTypeList archTypeList, final GameObject gameObject, final MainControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> mainControl, @NotNull final CFTreasureListTree<GameObject, MapArchObject, Archetype> treasureListTree) { + public static void showAttribDialog(final CFArchTypeList archTypeList, final GameObject gameObject, final MainControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> mainControl, final MapManager<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> mapManager, @NotNull final CFTreasureListTree<GameObject, MapArchObject, Archetype> treasureListTree) { synchronized (dialogs) { if (dialogs.containsKey(gameObject)) { dialogs.get(gameObject).toFront(); } else { - final GameObjectAttributesDialog pane = new GameObjectAttributesDialog(archTypeList, gameObject, mainControl, treasureListTree); + final GameObjectAttributesDialog pane = new GameObjectAttributesDialog(archTypeList, gameObject, mainControl, mapManager, treasureListTree); final JDialog dialog = pane.createDialog(mainControl.getMainView(), ACTION_FACTORY.getString("attribTitle")); dialog.getRootPane().setDefaultButton(pane.okButton); dialog.setResizable(true); @@ -91,10 +96,12 @@ * @param archTypeList the list of CF type-data * @param gameObject the GameObject to be displayed by this dialog * @param mainControl main control + * @param mapManager the map manager * @param treasureListTree the treasure list tree */ - private GameObjectAttributesDialog(final CFArchTypeList archTypeList, @NotNull final GameObject gameObject, final MainControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> mainControl, @NotNull final CFTreasureListTree<GameObject, MapArchObject, Archetype> treasureListTree) { + private GameObjectAttributesDialog(final CFArchTypeList archTypeList, @NotNull final GameObject gameObject, final MainControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> mainControl, final MapManager<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> mapManager, @NotNull final CFTreasureListTree<GameObject, MapArchObject, Archetype> treasureListTree) { super(archTypeList, gameObject, mainControl, treasureListTree); + this.mapManager = mapManager; } /** {@inheritDoc} */ @@ -584,7 +591,7 @@ } // recalculate the editType value - gameObject.calculateEditType(mainControl.getMapManager().getCurrentMap().getActiveEditType()); + gameObject.calculateEditType(mapManager.getCurrentMap().getActiveEditType()); return true; // apply succeeded } Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-03-23 12:44:40 UTC (rev 3734) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-03-23 13:32:31 UTC (rev 3735) @@ -314,11 +314,11 @@ super(new DaimoninObjectsFactory()); instance = this; archetypeSet = new ArchetypeSet(this); - mapCursorControl = new MapCursorControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>("daieditor", this); + mapCursorControl = new MapCursorControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>("daieditor", this, mapManager); ACTION_FACTORY.createActions(true, this, "createNew", "open", "options", "exit", "newScript", "editScript", "controlServer", "controlClient", "cleanCompletelyBlockedSquares", "zoom", "gc", "onlineHelp", "tod", "about", "update"); ACTION_FACTORY.createToggles(true, this, "drawDouble"); mapManagerActions = new MapManagerActions<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(mapManager); - mainView = new CMainView(this, mapManagerActions.getCloseAllAction()); + mainView = new CMainView(this, mapManager, mapManagerActions.getCloseAllAction()); undoControl = new UndoControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(mapManager); Updater.startup(mainView, this); @@ -902,7 +902,7 @@ // types.xml is missing! ACTION_FACTORY.showMessageDialog(mainView, "openAttrDialogNoTypes"); } else if (gameObject != null && !gameObject.hasUndefinedArchetype()) { - GameObjectAttributesDialog.showAttribDialog(typeList, gameObject, this, treasureListTree); + GameObjectAttributesDialog.showAttribDialog(typeList, gameObject, this, mapManager, treasureListTree); } else { ACTION_FACTORY.showMessageDialog(mainView, "openAttrDialogNoDefaultArch"); } Modified: trunk/daimonin/src/daieditor/CMainView.java =================================================================== --- trunk/daimonin/src/daieditor/CMainView.java 2008-03-23 12:44:40 UTC (rev 3734) +++ trunk/daimonin/src/daieditor/CMainView.java 2008-03-23 13:32:31 UTC (rev 3735) @@ -44,6 +44,7 @@ import javax.swing.JToolBar; import javax.swing.event.InternalFrameEvent; import net.sf.gridarta.MainControl; +import net.sf.gridarta.MapManager; import net.sf.gridarta.MenuHelper; import net.sf.gridarta.gui.ArchetypesActions; import net.sf.gridarta.gui.GSplitPane; @@ -91,6 +92,9 @@ /** The controller of this view. */ private final CMainControl mainControl; + /** The map manager. */ + @NotNull private final MapManager<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> mapManager; + /** The panel that contains the object chooser. */ private InsertionObjectChooser objectChooser; @@ -145,16 +149,18 @@ /** * Constructs the main view and registers the given main controller. * @param mainControl MainControl to attach to. + * @param mapManager the map manager * @param aCloseAll the action "close all map windows" */ - CMainView(@NotNull final CMainControl mainControl, @NotNull final Action aCloseAll) { - super(mainControl, ACTION_FACTORY.format("mainWindow.title", CMainControl.getBuildNumberAsString())); + 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())); this.mainControl = mainControl; + this.mapManager = mapManager; aCollectSpells = ACTION_FACTORY.createAction(true, "collectSpells", mainControl); aViewTreasurelists = ACTION_FACTORY.createAction(true, "viewTreasurelists", mainControl); this.aCloseAll = aCloseAll; - mapActions = new MapActions(mainControl); + mapActions = new MapActions(mainControl, mapManager); initActions(); final ImageIcon icon = GUIUtils.getIcon(IGUIConstants.APP_ICON); @@ -212,8 +218,8 @@ objectChooser = new InsertionObjectChooser(newMapDialogFactory, mainControl); selectedSquareControl = new SelectedSquareControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>("daieditor", mainControl, this, mapTileListBottom, GUIUtils.getSysIcon(IGUIConstants.TILE_NORTH)); - final LockedItemsControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> lockedItemsControl = new LockedItemsControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(mainControl.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); - gameObjectAttributesPanel = new GameObjectAttributesPanel(mainControl, mainControl.getMapManager(), this, lockedItemsControl); + 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) { splitRightPane = new GSplitPane(JSplitPane.HORIZONTAL_SPLIT, gameObjectAttributesPanel, selectedSquareControl.getSelectedSquareView()); @@ -324,7 +330,7 @@ if (!fCareAboutIconification) { try { mapView.setIcon(false); - mainControl.getMapManager().setCurrentLevel(mapView.getMapControl()); + mapManager.setCurrentLevel(mapView.getMapControl()); mapView.setVisible(true); mapView.setSelected(true); mapView.moveToFront(); @@ -338,7 +344,7 @@ } } else { try { - mainControl.getMapManager().setCurrentLevel(mapView.getMapControl()); + mapManager.setCurrentLevel(mapView.getMapControl()); mapView.setVisible(true); mapView.setSelected(true); mapView.moveToFront(); @@ -353,7 +359,7 @@ } // No non-iconified level windows found - mainControl.getMapManager().setCurrentLevel(null); + mapManager.setCurrentLevel(null); } /** Gives focus to the next window. */ @@ -437,7 +443,7 @@ generateCurrentMapViewChangedEvent(); final MapControl level = mapView.getMapControl(); level.setFocus(mapView); - mainControl.getMapManager().setCurrentLevel(level); + mapManager.setCurrentLevel(level); //statusBar.setLevelInfo(level); } @@ -447,7 +453,7 @@ /** {@inheritDoc} */ public void internalFrameClosing(final InternalFrameEvent e) { - mainControl.getMapManager().closeView((MapView<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>) e.getInternalFrame()); + mapManager.closeView((MapView<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>) e.getInternalFrame()); } /** {@inheritDoc} */ @@ -545,7 +551,7 @@ } currentMapView = newCurrentMapView; - mainControl.getMapManager().fireCurrentMapViewChangedEvent(currentMapView); + mapManager.fireCurrentMapViewChangedEvent(currentMapView); } /** Modified: trunk/daimonin/src/daieditor/MapActions.java =================================================================== --- trunk/daimonin/src/daieditor/MapActions.java 2008-03-23 12:44:40 UTC (rev 3734) +++ trunk/daimonin/src/daieditor/MapActions.java 2008-03-23 13:32:31 UTC (rev 3735) @@ -34,6 +34,7 @@ import net.sf.gridarta.CommonConstants; import net.sf.gridarta.CurrentMapListener; import net.sf.gridarta.MainControl; +import net.sf.gridarta.MapManager; import net.sf.gridarta.gui.map.MapCursorEvent; import net.sf.gridarta.gui.map.MapView; import net.sf.japi.swing.ActionFactory; @@ -98,6 +99,9 @@ */ private final CMainControl mainControl; + /** The map manager. */ + private final MapManager<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> mapManager; + /** * The current map listener used to detect current map/map view changes. */ @@ -107,9 +111,12 @@ * Create a new instance. * * @param mainControl the main control to use + * + * @param mapManager the map manager */ - public MapActions(final CMainControl mainControl) { + public MapActions(final CMainControl mainControl, final MapManager<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> mapManager) { this.mainControl = mainControl; + this.mapManager = mapManager; autoJoin = prefs.getBoolean(AUTOJOIN_KEY, false); @@ -117,7 +124,7 @@ aDirections[i] = ACTION_FACTORY.createAction(true, directionsMap[i], this); } - currentMapListener = new CurrentMapListener<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(mainControl, null, false, false, true) { + currentMapListener = new CurrentMapListener<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(mainControl, mapManager, null, false, false, true) { /** {@inheritDoc} */ @Override protected void mapHasChanged() { @@ -191,7 +198,7 @@ public void mapCreateView() { final MapView<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> mapView = getCreateViewEnabled(); if (mapView != null) { - mainControl.getMapManager().mapCreateView(mapView.getMapControl(), mapView.getView().getViewPosition()); + mapManager.mapCreateView(mapView.getMapControl(), mapView.getView().getViewPosition()); } } @@ -340,7 +347,7 @@ // and after some times in buffer overflows. final MapView<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> newMapView; try { - newMapView = mainControl.getMapManager().openMapFileWithView(newfile.getCanonicalFile(), null); + newMapView = mapManager.openMapFileWithView(newfile.getCanonicalFile(), null); } catch (final IOException e) { ACTION_FACTORY.showMessageDialog(mainControl.getMainView(), "enterTileIOException", newfile.getAbsolutePath()); return; @@ -357,7 +364,7 @@ currentMapView.getView().setCursorPosition(d); if (newMapView != null && JOptionPane.YES_OPTION == ACTION_FACTORY.showOnetimeConfirmDialog(mainControl.getMainView(), JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, "enterExitClose")) { // only close current level if a new file was opened and user wants to close it - mainControl.getMapManager().closeView(currentMapView); + mapManager.closeView(currentMapView); } } Modified: trunk/daimonin/src/daieditor/gui/GameObjectAttributesDialog.java =================================================================== --- trunk/daimonin/src/daieditor/gui/GameObjectAttributesDialog.java 2008-03-23 12:44:40 UTC (rev 3734) +++ trunk/daimonin/src/daieditor/gui/GameObjectAttributesDialog.java 2008-03-23 13:32:31 UTC (rev 3735) @@ -38,6 +38,7 @@ import net.sf.gridarta.CFArchType; import net.sf.gridarta.CFArchTypeList; import net.sf.gridarta.MainControl; +import net.sf.gridarta.MapManager; import net.sf.gridarta.gameobject.ArchAttribType; import net.sf.gridarta.gui.AbstractGameObjectAttributesDialog; import net.sf.gridarta.gui.map.TilePanel; @@ -64,19 +65,23 @@ /** Action Factory. */ private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("daieditor"); + /** The map manager. */ + private final MapManager<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> mapManager; + /** * Wrapper method for the constructor. * This method only creates a GameObjectAttributesDialog if there's no dialog for the same gameObject already. * @param archTypeList the list of CF type-data * @param gameObject the GameObject to be displayed by this dialog * @param mainControl main control + * @param mapManager the map manager */ - public static void showAttribDialog(final CFArchTypeList archTypeList, final GameObject gameObject, final MainControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> mainControl, @NotNull final CFTreasureListTree<GameObject, MapArchObject, Archetype> treasureListTree) { + public static void showAttribDialog(final CFArchTypeList archTypeList, final GameObject gameObject, final MainControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> mainControl, final MapManager<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> mapManager, @NotNull final CFTreasureListTree<GameObject, MapArchObject, Archetype> treasureListTree) { synchronized (dialogs) { if (dialogs.containsKey(gameObject)) { dialogs.get(gameObject).toFront(); } else { - final GameObjectAttributesDialog pane = new GameObjectAttributesDialog(archTypeList, gameObject, mainControl, treasureListTree); + final GameObjectAttributesDialog pane = new GameObjectAttributesDialog(archTypeList, gameObject, mainControl, mapManager, treasureListTree); final JDialog dialog = pane.createDialog(mainControl.getMainView(), ACTION_FACTORY.getString("attribTitle")); dialog.getRootPane().setDefaultButton(pane.okButton); dialog.setResizable(true); @@ -92,10 +97,12 @@ * @param archTypeList the list of CF type-data * @param gameObject the GameObject to be displayed by this dialog * @param mainControl main control + * @param mapManager the map manager * @param treasureListTree the treasure list tree */ - private GameObjectAttributesDialog(final CFArchTypeList archTypeList, @NotNull final GameObject gameObject, final MainControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> mainControl, @NotNull final CFTreasureListTree<GameObject, MapArchObject, Archetype> treasureListTree) { + private GameObjectAttributesDialog(final CFArchTypeList archTypeList, @NotNull final GameObject gameObject, final MainControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> mainControl, final MapManager<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> mapManager, @NotNull final CFTreasureListTree<GameObject, MapArchObject, Archetype> treasureListTree) { super(archTypeList, gameObject, mainControl, treasureListTree); + this.mapManager = mapManager; } /** {@inheritDoc} */ @@ -518,7 +525,7 @@ } // recalculate the editType value - gameObject.calculateEditType(mainControl.getMapManager().getCurrentMap().getActiveEditType()); + gameObject.calculateEditType(mapManager.getCurrentMap().getActiveEditType()); return true; // apply succeeded } Modified: trunk/src/app/net/sf/gridarta/AbstractMainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2008-03-23 12:44:40 UTC (rev 3734) +++ trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2008-03-23 13:32:31 UTC (rev 3735) @@ -169,7 +169,7 @@ * can be created for a map. */ protected void createMapImageCache(@Nullable final File baseDir, @NotNull final ImageIcon defaultIcon, @NotNull final ImageIcon defaultPreview) { - mapImageCache = new MapImageCache<G, A, R, C, V>(this, baseDir, defaultIcon, defaultPreview); + mapImageCache = new MapImageCache<G, A, R, C, V>(this, getMapManager(), baseDir, defaultIcon, defaultPreview); mapPreviewAccessory = new MapPreviewAccessory(mapImageCache); } Modified: trunk/src/app/net/sf/gridarta/CurrentMapListener.java =================================================================== --- trunk/src/app/net/sf/gridarta/CurrentMapListener.java 2008-03-23 12:44:40 UTC (rev 3734) +++ trunk/src/app/net/sf/gridarta/CurrentMapListener.java 2008-03-23 13:32:31 UTC (rev 3735) @@ -43,6 +43,11 @@ @NotNull private final MainControl<G, A, R, C, V> mainControl; /** + * The map manager. + */ + @NotNull private final MapManager<G, A, R, C, V> mapManager; + + /** * The map control to track, or <code>null</code> if {@link #mainControl}'s * current map is tracked. */ @@ -178,6 +183,8 @@ * * @param mainControl the main control to forward actions * + * @param mapManager the map manager + * * @param mapControl the map control to check for changes, or * <code>null</code> to check <code>mainControl</code>'s current map * @@ -190,15 +197,16 @@ * @param trackMapCursor if set, notify about map cursor changes of the * current map view */ - protected CurrentMapListener(@NotNull final MainControl<G, A, R, C, V> mainControl, @Nullable final C mapControl, final boolean trackMapModified, final boolean trackMapFileName, final boolean trackMapCursor) { + protected CurrentMapListener(@NotNull final MainControl<G, A, R, C, V> mainControl, @NotNull final MapManager<G, A, R, C, V> mapManager, @Nullable final C mapControl, final boolean trackMapModified, final boolean trackMapFileName, final boolean trackMapCursor) { this.mainControl = mainControl; + this.mapManager = mapManager; this.mapControl = mapControl; this.trackMapModified = trackMapModified; this.trackMapFileName = trackMapFileName; this.trackMapCursor = trackMapCursor; if (mapControl == null) { - mainControl.getMapManager().addMapManagerListener(mapManagerListener); - currentMap = mainControl.getMapManager().getCurrentMap(); + mapManager.addMapManagerListener(mapManagerListener); + currentMap = mapManager.getCurrentMap(); if (currentMap != null) { currentMap.addMapControlListener(mapControlListener); } @@ -222,7 +230,7 @@ */ public void closeNotify() { if (mapControl == null) { - mainControl.getMapManager().removeMapManagerListener(mapManagerListener); + mapManager.removeMapManagerListener(mapManagerListener); } if (currentMap != null) { currentMap.removeMapControlListener(mapControlListener); Modified: trunk/src/app/net/sf/gridarta/MapImageCache.java =================================================================== --- trunk/src/app/net/sf/gridarta/MapImageCache.java 2008-03-23 12:44:40 UTC (rev 3734) +++ trunk/src/app/net/sf/gridarta/MapImageCache.java 2008-03-23 13:32:31 UTC (rev 3735) @@ -58,6 +58,11 @@ @NotNull private final MainControl<G, A, R, C, V> mainControl; /** + * The map manager. + */ + @NotNull private final MapManager<G, A, R, C, V> mapManager; + + /** * The directory to store cached images file. If <code>null</code> store * the image files next to the map files. */ @@ -77,6 +82,8 @@ * * @param mainControl Reference to CMainControl. * + * @param mapManager the map manager + * * @param cacheDir the directory to store cached images file; if * <code>null</code> store the image files next to the map files * @@ -86,8 +93,9 @@ * @param defaultPreview the default preview image to return if no preview * can be created for a map */ - public MapImageCache(@NotNull final MainControl<G, A, R, C, V> mainControl, @Nullable final File cacheDir, @NotNull final ImageIcon defaultIcon, @NotNull final ImageIcon defaultPreview) { + public MapImageCache(@NotNull final MainControl<G, A, R, C, V> mainControl, @NotNull final MapManager<G, A, R, C, V> mapManager, @Nullable final File cacheDir, @NotNull final ImageIcon defaultIcon, @NotNull final ImageIcon defaultPreview) { this.mainControl = mainControl; + this.mapManager = mapManager; this.cacheDir = cacheDir; defaultImages.put(Type.ICON, defaultIcon); defaultImages.put(Type.PREVIEW, defaultPreview); @@ -247,13 +255,13 @@ return defaultImages.get(type); } - final C mapControl = mainControl.getMapManager().openMapFile(mapFile, false); + final C mapControl = mapManager.openMapFile(mapFile, false); if (mapControl != null) { try { return updateCaches(mapFile, mapControl, type); } finally { if (mapControl.nViews() <= 0) { - mainControl.getMapManager().closeLevel(mapControl); + mapManager.closeLevel(mapControl); } } } Modified: trunk/src/app/net/sf/gridarta/gui/MainView.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/MainView.java 2008-03-23 12:44:40 UTC (rev 3734) +++ trunk/src/app/net/sf/gridarta/gui/MainView.java 2008-03-23 13:32:31 UTC (rev 3735) @@ -26,6 +26,7 @@ import javax.swing.JFrame; import javax.swing.event.InternalFrameListener; import net.sf.gridarta.MainControl; +import net.sf.gridarta.MapManager; import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.GameObject; import net.sf.gridarta.gui.map.MapFileActions; @@ -96,11 +97,12 @@ /** * Creates a new MainView. * @param mainControl MainControl to use. + * @param mapManager the map manager * @param title Title */ - protected MainView(@NotNull final MainControl<G, A, R, C, V> mainControl, @NotNull final String title) { + protected MainView(@NotNull final MainControl<G, A, R, C, V> mainControl, @NotNull final MapManager<G, A, R, C, V> mapManager, @NotNull final String title) { super(title); - mapFileAction = new MapFileActions<G, A, R, C, V>(mainControl, null); + mapFileAction = new MapFileActions<G, A, R, C, V>(mainControl, mapManager, null); statusBar = new StatusBar(mainControl); add(statusBar, BorderLayout.SOUTH); setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); Modified: trunk/src/app/net/sf/gridarta/gui/map/MapCursorActions.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/MapCursorActions.java 2008-03-23 12:44:40 UTC (rev 3734) +++ trunk/src/app/net/sf/gridarta/gui/map/MapCursorActions.java 2008-03-23 13:32:31 UTC (rev 3735) @@ -22,6 +22,7 @@ import javax.swing.Action; import net.sf.gridarta.CommonConstants; import net.sf.gridarta.MainControl; +import net.sf.gridarta.MapManager; import net.sf.gridarta.MapManagerListener; import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.GameObject; @@ -150,8 +151,10 @@ * @param control the map control for this instance * * @param mainControl the main control to query for current map changes + * + * @param mapManager the map manager */ - public MapCursorActions(@NotNull final String key, @NotNull final MapCursorControl control, @NotNull final MainControl<G, A, R, C, V> mainControl) { + public MapCursorActions(@NotNull final String key, @NotNull final MapCursorControl control, @NotNull final MainControl<G, A, R, C, V> mainControl, @NotNull final MapManager<G, A, R, C, V> mapManager) { actionFactory = ActionFactory.getFactory(key); this.control = control; actionFactory.createActions(true, this, directionsGo); @@ -167,7 +170,7 @@ aSelectArchBelow = actionFactory.createAction(true, "selectArchBelow", this); aArchAttributes = actionFactory.createAction(true, "archAttributes", this); mapView = mainControl.getCurrentMapView(); - mainControl.getMapManager().addMapManagerListener(mapManagerListener); + mapManager.addMapManagerListener(mapManagerListener); refreshActions(); } Modified: trunk/src/app/net/sf/gridarta/gui/map/MapCursorControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/MapCursorControl.java 2008-03-23 12:44:40 UTC (rev 3734) +++ trunk/src/app/net/sf/gridarta/gui/map/MapCursorControl.java 2008-03-23 13:32:31 UTC (rev 3735) @@ -21,6 +21,7 @@ import java.awt.Point; import net.sf.gridarta.MainControl; +import net.sf.gridarta.MapManager; import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.GameObject; import net.sf.gridarta.gui.MainView; @@ -55,11 +56,12 @@ * Create a MapCursorControl. * @param key The action factory key. * @param mainControl MainControl to use (used for getting the current map etc.) + * @param mapManager the map manager */ - public MapCursorControl(final String key, final MainControl<G, A, R, C, V> mainControl) { + public MapCursorControl(final String key, final MainControl<G, A, R, C, V> mainControl, final MapManager<G, A, R, C, V> mapManager) { this.mainControl = mainControl; - goLocationDialogManager = new GoLocationDialogManager<G, A, R, C, V>(mainControl.getMapManager()); - actions = new MapCursorActions<G, A, R, C, V>(key, this, mainControl); + goLocationDialogManager = new GoLocationDialogManager<G, A, R, C, V>(mapManager); + actions = new MapCursorActions<G, A, R, C, V>(key, this, mainControl, mapManager); } /** Modified: trunk/src/app/net/sf/gridarta/gui/map/MapFileActions.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/MapFileActions.java 2008-03-23 12:44:40 UTC (rev 3734) +++ trunk/src/app/net/sf/gridarta/gui/map/MapFileActions.java 2008-03-23 13:32:31 UTC (rev 3735) @@ -22,6 +22,7 @@ import javax.swing.Action; import net.sf.gridarta.CurrentMapListener; import net.sf.gridarta.MainControl; +import net.sf.gridarta.MapManager; import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.GameObject; import net.sf.gridarta.map.MapArchObject; @@ -74,12 +75,14 @@ * * @param mainControl the main control to forward actions * + * @param mapManager the map manager + * * @param mapControl the map control to check for changes, or * <code>null</code> to check <code>mainControl</code>'s current map */ - public MapFileActions(@NotNull final MainControl<G, A, R, C, V> mainControl, @Nullable final C mapControl) { + public MapFileActions(@NotNull final MainControl<G, A, R, C, V> mainControl, @NotNull final MapManager<G, A, R, C, V> mapManager, @Nullable final C mapControl) { this.mainControl = mainControl; - currentMapListener = new CurrentMapListener<G, A, R, C, V>(mainControl, mapControl, true, false, false) { + currentMapListener = new CurrentMapListener<G, A, R, C, V>(mainControl, mapManager, mapControl, true, false, false) { /** {@inheritDoc} */ @Override public void mapHasChanged() { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-03-23 13:47:57
|
Revision: 3736 http://gridarta.svn.sourceforge.net/gridarta/?rev=3736&view=rev Author: akirschbaum Date: 2008-03-23 06:48:01 -0700 (Sun, 23 Mar 2008) Log Message: ----------- Move CMainControl.mapManager to common code base. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/daimonin/src/daieditor/CMainControl.java trunk/src/app/net/sf/gridarta/AbstractMainControl.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-03-23 13:32:31 UTC (rev 3735) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-03-23 13:48:01 UTC (rev 3736) @@ -55,9 +55,7 @@ import net.sf.gridarta.AbstractMainControl; import net.sf.gridarta.CFArchTypeList; import net.sf.gridarta.CommonConstants; -import net.sf.gridarta.DefaultMapManager; import net.sf.gridarta.MainControl; -import net.sf.gridarta.MapManager; import net.sf.gridarta.XmlHelper; import net.sf.gridarta.gameobject.Collectable; import net.sf.gridarta.gameobject.Collector; @@ -229,9 +227,6 @@ private final MapCursorControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> mapCursorControl; - /** The map manager. */ - private final MapManager<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> mapManager = new DefaultMapManager<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(this, "cfeditor"); - /** Actions used by this instance. */ private final MainActions<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> mainActions = new MainActions<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(this, ACTION_FACTORY); @@ -259,15 +254,15 @@ * @throws RuntimeException If the controller cannot be initialized. */ public CMainControl() { - super(new CrossfireObjectsFactory()); + super(new CrossfireObjectsFactory(), "cfeditor"); instance = this; archetypeSet = new ArchetypeSet(this); scriptControl = new ScriptController(this); - mapCursorControl = new MapCursorControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>("cfeditor", this, mapManager); + 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>(mapManager); - mainView = new CMainView(this, mapManager, mapManagerActions.getCloseAllAction()); - undoControl = new UndoControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(mapManager); + mapManagerActions = new MapManagerActions<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(getMapManager()); + mainView = new CMainView(this, getMapManager(), mapManagerActions.getCloseAllAction()); + undoControl = new UndoControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(getMapManager()); readGlobalSettings(); @@ -516,7 +511,7 @@ super.setEditType(editType); - mapManager.addEditType(editType); + getMapManager().addEditType(editType); refreshCurrentMap(); } @@ -619,7 +614,7 @@ /** Refresh the active map view, if there is one. */ public void refreshCurrentMap() { - final MapControl currentMap = mapManager.getCurrentMap(); + final MapControl currentMap = getMapManager().getCurrentMap(); if (currentMap != null) { currentMap.repaint(); // update map view (if there is one) } @@ -718,7 +713,7 @@ ScriptEditControl.getInstance().openScriptFile(file.getAbsolutePath()); } else { currentDir = dir; - mapManager.openMapFileWithView(file, null); + getMapManager().openMapFileWithView(file, null); } } else if (!file.exists()) { if (isScriptFile) { @@ -743,7 +738,7 @@ if (isScriptFile) { ScriptEditControl.getInstance().openScriptFile(file.getAbsolutePath()); } else { - mapManager.openMapFileWithView(file, null); + getMapManager().openMapFileWithView(file, null); } } else if (!file.exists()) { if (isScriptFile) { @@ -762,7 +757,7 @@ // types.xml is missing! ACTION_FACTORY.showMessageDialog(mainView, "openAttrDialogNoTypes"); } else if (gameObject != null && !gameObject.hasUndefinedArchetype()) { - GameObjectAttributesDialog.showAttribDialog(typeList, gameObject, this, mapManager, treasureListTree); + GameObjectAttributesDialog.showAttribDialog(typeList, gameObject, this, getMapManager(), treasureListTree); } else { ACTION_FACTORY.showMessageDialog(mainView, "openAttrDialogNoDefaultArch"); } @@ -888,7 +883,7 @@ /** Invoked when user wants to exit from the program. */ public void exit() { - if (ScriptEditControl.getInstance().closeAllTabs() && mapManager.closeAll() && mainView.getObjectChooser().getPickmapChooserControl().canExit() && scriptControl.canExit()) { + if (ScriptEditControl.getInstance().closeAllTabs() && getMapManager().closeAll() && mainView.getObjectChooser().getPickmapChooserControl().canExit() && scriptControl.canExit()) { doExit(); } } @@ -913,13 +908,13 @@ if (ACTION_FACTORY.showQuestionDialog(mainView, "confirmRevertMap", mapControl.getMapFileName())) { final File mfile = mapControl.getMapFile(); final Point[] viewPositions = mapControl.getViewPositions(); - mapManager.closeLevel(mapControl, true); + getMapManager().closeLevel(mapControl, true); - final MapView<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> newMapView = mapManager.openMapFileWithView(mfile, viewPositions[0]); + final MapView<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> newMapView = getMapManager().openMapFileWithView(mfile, viewPositions[0]); if (newMapView != null) { final MapControl newMapControl = newMapView.getMapControl(); for (int i = 1; i < viewPositions.length; i++) { - mapManager.mapCreateView(newMapControl, viewPositions[i]); + getMapManager().mapCreateView(newMapControl, viewPositions[i]); } } @@ -1042,11 +1037,6 @@ } /** {@inheritDoc} */ - @NotNull public MapManager<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> getMapManager() { - return mapManager; - } - - /** {@inheritDoc} */ public RecentManager getRecentManager() { return recentManager; } Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-03-23 13:32:31 UTC (rev 3735) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-03-23 13:48:01 UTC (rev 3736) @@ -61,9 +61,7 @@ import net.sf.gridarta.AbstractMainControl; import net.sf.gridarta.CFArchTypeList; import net.sf.gridarta.CommonConstants; -import net.sf.gridarta.DefaultMapManager; import net.sf.gridarta.MainControl; -import net.sf.gridarta.MapManager; import net.sf.gridarta.XmlHelper; import net.sf.gridarta.gameobject.Collectable; import net.sf.gridarta.gameobject.Collector; @@ -284,9 +282,6 @@ private final MapCursorControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> mapCursorControl; - /** The map manager. */ - private final MapManager<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> mapManager = new DefaultMapManager<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(this, "daieditor"); - /** Actions used by this instance. */ private final MainActions<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> mainActions = new MainActions<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(this, ACTION_FACTORY); @@ -311,15 +306,15 @@ * @throws RuntimeException If the controller cannot be initialized. */ public CMainControl() { - super(new DaimoninObjectsFactory()); + super(new DaimoninObjectsFactory(), "daieditor"); instance = this; archetypeSet = new ArchetypeSet(this); - mapCursorControl = new MapCursorControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>("daieditor", this, mapManager); + mapCursorControl = new MapCursorControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>("daieditor", this, getMapManager()); ACTION_FACTORY.createActions(true, this, "createNew", "open", "options", "exit", "newScript", "editScript", "controlServer", "controlClient", "cleanCompletelyBlockedSquares", "zoom", "gc", "onlineHelp", "tod", "about", "update"); ACTION_FACTORY.createToggles(true, this, "drawDouble"); - mapManagerActions = new MapManagerActions<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(mapManager); - mainView = new CMainView(this, mapManager, mapManagerActions.getCloseAllAction()); - undoControl = new UndoControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(mapManager); + mapManagerActions = new MapManagerActions<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(getMapManager()); + mainView = new CMainView(this, getMapManager(), mapManagerActions.getCloseAllAction()); + undoControl = new UndoControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(getMapManager()); Updater.startup(mainView, this); readGlobalSettings(); @@ -516,7 +511,7 @@ * @fixme this implementation does not take care of multi square objects. */ @ActionMethod public void cleanCompletelyBlockedSquares() { - final MapControl currentMap = mapManager.getCurrentMap(); + final MapControl currentMap = getMapManager().getCurrentMap(); if (currentMap == null) { return; } @@ -666,7 +661,7 @@ if (state) { alphaType |= v; // XXX THIS IS A BAD HACK - mapManager.addEditType(v); + getMapManager().addEditType(v); } else { alphaType &= ~v; } @@ -767,7 +762,7 @@ /** Refresh the active map view, if there is one. */ public void refreshCurrentMap() { - final MapControl currentMap = mapManager.getCurrentMap(); + final MapControl currentMap = getMapManager().getCurrentMap(); if (currentMap != null) { currentMap.repaint(); // update map view (if there is one) } @@ -858,7 +853,7 @@ ScriptEditControl.getInstance().openScriptFile(file.getAbsolutePath()); } else { currentDir = dir; - mapManager.openMapFileWithView(file, null); + getMapManager().openMapFileWithView(file, null); } } else if (!file.exists()) { if (isScriptFile) { @@ -883,7 +878,7 @@ if (isScriptFile) { ScriptEditControl.getInstance().openScriptFile(file.getAbsolutePath()); } else { - mapManager.openMapFileWithView(file, null); + getMapManager().openMapFileWithView(file, null); } } else if (!file.exists()) { if (isScriptFile) { @@ -902,7 +897,7 @@ // types.xml is missing! ACTION_FACTORY.showMessageDialog(mainView, "openAttrDialogNoTypes"); } else if (gameObject != null && !gameObject.hasUndefinedArchetype()) { - GameObjectAttributesDialog.showAttribDialog(typeList, gameObject, this, mapManager, treasureListTree); + GameObjectAttributesDialog.showAttribDialog(typeList, gameObject, this, getMapManager(), treasureListTree); } else { ACTION_FACTORY.showMessageDialog(mainView, "openAttrDialogNoDefaultArch"); } @@ -1034,7 +1029,7 @@ /** Invoked when user wants to exit from the program. */ public void exit() { - if (ScriptEditControl.getInstance().closeAllTabs() && mapManager.closeAll() && mainView.getObjectChooser().getPickmapChooserControl().canExit()) { + if (ScriptEditControl.getInstance().closeAllTabs() && getMapManager().closeAll() && mainView.getObjectChooser().getPickmapChooserControl().canExit()) { doExit(); } } @@ -1059,13 +1054,13 @@ if (ACTION_FACTORY.showQuestionDialog(mainView, "confirmRevertMap", mapControl.getMapFileName())) { final File mfile = mapControl.getMapFile(); final Point[] viewPositions = mapControl.getViewPositions(); - mapManager.closeLevel(mapControl, true); + getMapManager().closeLevel(mapControl, true); - final MapView<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> newMapView = mapManager.openMapFileWithView(mfile, viewPositions[0]); + final MapView<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> newMapView = getMapManager().openMapFileWithView(mfile, viewPositions[0]); if (newMapView != null) { final MapControl newMapControl = newMapView.getMapControl(); for (int i = 1; i < viewPositions.length; i++) { - mapManager.mapCreateView(newMapControl, viewPositions[i]); + getMapManager().mapCreateView(newMapControl, viewPositions[i]); } } @@ -1141,7 +1136,7 @@ /** Calls for zooming preview tool. */ public void zoom() { - final MapControl currentMap = mapManager.getCurrentMap(); + final MapControl currentMap = getMapManager().getCurrentMap(); if (currentMap == null) { JOptionPane.showMessageDialog(mainView, "No map loaded! Please load a map!!", "Error", JOptionPane.ERROR_MESSAGE); return; @@ -1159,7 +1154,7 @@ /** Update wanted. */ public void update() { - if (mapManager.hasOpenedMap()) { + if (getMapManager().hasOpenedMap()) { ACTION_FACTORY.showMessageDialog(mainView, "updateCloseMaps"); } else { Updater.update(mainView, this); @@ -1211,11 +1206,6 @@ } /** {@inheritDoc} */ - @NotNull public MapManager<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> getMapManager() { - return mapManager; - } - - /** {@inheritDoc} */ public RecentManager getRecentManager() { return recentManager; } Modified: trunk/src/app/net/sf/gridarta/AbstractMainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2008-03-23 13:32:31 UTC (rev 3735) +++ trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2008-03-23 13:48:01 UTC (rev 3736) @@ -87,8 +87,16 @@ /** The autojoin lists. */ private final AutojoinLists<G, A, R> autojoinLists = new AutojoinLists<G, A, R>(); - /** Create an AbstractMainControl. */ - protected AbstractMainControl(@NotNull final GridartaObjectsFactory<G, A, R, C, V> gridartaObjectsFactory) { + /** The map manager. */ + private final MapManager<G, A, R, C, V> mapManager; + + /** + * Creates a new instance. + * @param gridartaObjectsFactory the gridarta objects factory + * @param key The action factory key + */ + protected AbstractMainControl(@NotNull final GridartaObjectsFactory<G, A, R, C, V> gridartaObjectsFactory, @NotNull final String key) { + mapManager = new DefaultMapManager<G, A, R, C, V>(this, key); this.gridartaObjectsFactory = gridartaObjectsFactory; setInstance(this); PathManager.setMainControl(this); @@ -197,4 +205,9 @@ return autojoinLists; } + /** {@inheritDoc} */ + @NotNull public MapManager<G, A, R, C, V> getMapManager() { + return mapManager; + } + } // class AbstractMainControl This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-03-23 14:04:17
|
Revision: 3738 http://gridarta.svn.sourceforge.net/gridarta/?rev=3738&view=rev Author: akirschbaum Date: 2008-03-23 07:04:19 -0700 (Sun, 23 Mar 2008) Log Message: ----------- Move CMainControl.refreshCurrentMap() to common code base. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/map/MapControl.java trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/map/MapControl.java trunk/src/app/net/sf/gridarta/DefaultMapManager.java trunk/src/app/net/sf/gridarta/MapManager.java trunk/src/app/net/sf/gridarta/map/AbstractMapControl.java trunk/src/app/net/sf/gridarta/map/MapControl.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-03-23 13:59:22 UTC (rev 3737) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-03-23 14:04:19 UTC (rev 3738) @@ -512,7 +512,7 @@ super.setEditType(editType); getMapManager().addEditType(editType); - refreshCurrentMap(); + getMapManager().refreshCurrentMap(); } /** {@inheritDoc} */ @@ -522,7 +522,7 @@ } super.unsetEditType(editType); - refreshCurrentMap(); + getMapManager().refreshCurrentMap(); } public void onlineHelp() { @@ -612,14 +612,6 @@ return loadFromArchive; } - /** Refresh the active map view, if there is one. */ - public void refreshCurrentMap() { - final MapControl currentMap = getMapManager().getCurrentMap(); - if (currentMap != null) { - currentMap.repaint(); // update map view (if there is one) - } - } - /** * Returns the main view. * @return the main view Modified: trunk/crossfire/src/cfeditor/map/MapControl.java =================================================================== --- trunk/crossfire/src/cfeditor/map/MapControl.java 2008-03-23 13:59:22 UTC (rev 3737) +++ trunk/crossfire/src/cfeditor/map/MapControl.java 2008-03-23 14:04:19 UTC (rev 3738) @@ -80,9 +80,7 @@ init(); } - /** - * Repaints all views. - */ + /** {@inheritDoc} */ public void repaint() { for (final MapView<GameObject, MapArchObject, Archetype, ?, ?> mapView : getMapViewFrames()) { ((CMapViewBasic) mapView.getView()).getRenderer().forceRepaint(); Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-03-23 13:59:22 UTC (rev 3737) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-03-23 14:04:19 UTC (rev 3738) @@ -546,7 +546,7 @@ */ public void setDrawDouble(final boolean drawDouble) { this.drawDouble = drawDouble; - refreshCurrentMap(); + getMapManager().refreshCurrentMap(); } /** @@ -665,13 +665,13 @@ } else { alphaType &= ~v; } - refreshCurrentMap(); + getMapManager().refreshCurrentMap(); } /** Clear the transparency. */ public void clearAlpha() { alphaType = 0; - refreshCurrentMap(); + getMapManager().refreshCurrentMap(); } public void onlineHelp() { @@ -760,14 +760,6 @@ return loadFromArchive; } - /** Refresh the active map view, if there is one. */ - public void refreshCurrentMap() { - final MapControl currentMap = getMapManager().getCurrentMap(); - if (currentMap != null) { - currentMap.repaint(); // update map view (if there is one) - } - } - /** * Returns the main view. * @return the main view Modified: trunk/daimonin/src/daieditor/map/MapControl.java =================================================================== --- trunk/daimonin/src/daieditor/map/MapControl.java 2008-03-23 13:59:22 UTC (rev 3737) +++ trunk/daimonin/src/daieditor/map/MapControl.java 2008-03-23 14:04:19 UTC (rev 3738) @@ -80,9 +80,7 @@ init(); } - /** - * Repaints all views. - */ + /** {@inheritDoc} */ public void repaint() { for (final MapView<GameObject, MapArchObject, Archetype, ?, ?> mapView : getMapViewFrames()) { ((CMapViewBasic) mapView.getView()).getRenderer().forceRepaint(); Modified: trunk/src/app/net/sf/gridarta/DefaultMapManager.java =================================================================== --- trunk/src/app/net/sf/gridarta/DefaultMapManager.java 2008-03-23 13:59:22 UTC (rev 3737) +++ trunk/src/app/net/sf/gridarta/DefaultMapManager.java 2008-03-23 14:04:19 UTC (rev 3738) @@ -443,4 +443,11 @@ listenerList.remove(MapManagerListener.class, listener); } + /** {@inheritDoc} */ + public void refreshCurrentMap() { + if (currentMap != null) { + currentMap.repaint(); + } + } + } // class DefaultMapManager Modified: trunk/src/app/net/sf/gridarta/MapManager.java =================================================================== --- trunk/src/app/net/sf/gridarta/MapManager.java 2008-03-23 13:59:22 UTC (rev 3737) +++ trunk/src/app/net/sf/gridarta/MapManager.java 2008-03-23 14:04:19 UTC (rev 3738) @@ -186,4 +186,9 @@ */ void fireCurrentMapViewChangedEvent(@Nullable MapView<G, A, R, C, V> currentMapView); + /** + * Refreshes all map view of the active map. Does nothing if no map is opened. + */ + void refreshCurrentMap(); + } // interface MapManager Modified: trunk/src/app/net/sf/gridarta/map/AbstractMapControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/map/AbstractMapControl.java 2008-03-23 13:59:22 UTC (rev 3737) +++ trunk/src/app/net/sf/gridarta/map/AbstractMapControl.java 2008-03-23 14:04:19 UTC (rev 3738) @@ -570,5 +570,4 @@ } } } - } Modified: trunk/src/app/net/sf/gridarta/map/MapControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/map/MapControl.java 2008-03-23 13:59:22 UTC (rev 3737) +++ trunk/src/app/net/sf/gridarta/map/MapControl.java 2008-03-23 14:04:19 UTC (rev 3738) @@ -226,4 +226,9 @@ */ void addCopyToMap(G gameObject, Point pos, boolean allowDouble, boolean fillBelow); + /** + * Repaints all views. + */ + void repaint(); + } // interface MapControl This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-03-23 14:11:49
|
Revision: 3739 http://gridarta.svn.sourceforge.net/gridarta/?rev=3739&view=rev Author: akirschbaum Date: 2008-03-23 07:11:46 -0700 (Sun, 23 Mar 2008) Log Message: ----------- Move code from CMainControl to DefaultMapManager. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/src/app/net/sf/gridarta/DefaultMapManager.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-03-23 14:04:19 UTC (rev 3738) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-03-23 14:11:46 UTC (rev 3739) @@ -512,7 +512,6 @@ super.setEditType(editType); getMapManager().addEditType(editType); - getMapManager().refreshCurrentMap(); } /** {@inheritDoc} */ Modified: trunk/src/app/net/sf/gridarta/DefaultMapManager.java =================================================================== --- trunk/src/app/net/sf/gridarta/DefaultMapManager.java 2008-03-23 14:04:19 UTC (rev 3738) +++ trunk/src/app/net/sf/gridarta/DefaultMapManager.java 2008-03-23 14:11:46 UTC (rev 3739) @@ -81,6 +81,7 @@ for (final C mapControl : levels) { mapControl.addEditType(newType); // calculate new type } + refreshCurrentMap(); } /** {@inheritDoc} */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-03-23 16:46:45
|
Revision: 3740 http://gridarta.svn.sourceforge.net/gridarta/?rev=3740&view=rev Author: akirschbaum Date: 2008-03-23 09:46:47 -0700 (Sun, 23 Mar 2008) Log Message: ----------- Implement "Save All" for saving all opened maps. Modified Paths: -------------- trunk/crossfire/ChangeLog trunk/crossfire/src/cfeditor/action.properties trunk/daimonin/ChangeLog trunk/daimonin/src/daieditor/action.properties trunk/src/app/net/sf/gridarta/DefaultMapManager.java trunk/src/app/net/sf/gridarta/MapManager.java trunk/src/app/net/sf/gridarta/gui/MapManagerActions.java trunk/src/app/net/sf/gridarta/gui/map/MapFileActions.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-03-23 14:11:46 UTC (rev 3739) +++ trunk/crossfire/ChangeLog 2008-03-23 16:46:47 UTC (rev 3740) @@ -1,3 +1,7 @@ +2008-03-23 Andreas Kirschbaum + + * Implement "Save All" for saving all opened maps. + 2008-03-21 Andreas Kirschbaum * Fix #1879228 (More details in warning). Modified: trunk/crossfire/src/cfeditor/action.properties =================================================================== --- trunk/crossfire/src/cfeditor/action.properties 2008-03-23 14:11:46 UTC (rev 3739) +++ trunk/crossfire/src/cfeditor/action.properties 2008-03-23 16:46:47 UTC (rev 3740) @@ -28,7 +28,7 @@ # Menus main.menubar=file edit map archetypes pickmaps resources tools analyze view plugins window help -file.menu=createNew open recent close - save saveAs revert createImage - options - exit +file.menu=createNew open recent close - save saveAs saveAll revert createImage - options - exit edit.menu=undo redo - clear cut copy paste - shift - replace fillAbove fillBelow randFillAbove randFillBelow floodfill - selectAll map.menu=autoJoin - gridVisible enterExit enterNorthMap enterEastMap enterSouthMap enterWestMap tileShow - mapCreateView mapProperties archetypes.menu=displayObjectNames findArchetypes Modified: trunk/daimonin/ChangeLog =================================================================== --- trunk/daimonin/ChangeLog 2008-03-23 14:11:46 UTC (rev 3739) +++ trunk/daimonin/ChangeLog 2008-03-23 16:46:47 UTC (rev 3740) @@ -1,3 +1,7 @@ +2008-03-23 Andreas Kirschbaum + + * Implement "Save All" for saving all opened maps. + 2008-03-19 Andreas Kirschbaum * Add setup option to hide the main window's toolbar. Modified: trunk/daimonin/src/daieditor/action.properties =================================================================== --- trunk/daimonin/src/daieditor/action.properties 2008-03-23 14:11:46 UTC (rev 3739) +++ trunk/daimonin/src/daieditor/action.properties 2008-03-23 16:46:47 UTC (rev 3740) @@ -27,7 +27,7 @@ ######## # Menus main.menubar=file edit map archetypes pickmaps resources tools view window help -file.menu=createNew open recent close - save saveAs revert createImage - options - exit +file.menu=createNew open recent close - save saveAs saveAll revert createImage - options - exit edit.menu=undo redo - clear cut copy paste - shift - replace fillAbove fillBelow randFillAbove randFillBelow floodfill - selectAll map.menu=enterExit enterNorthMap enterEastMap enterSouthMap enterWestMap enterNorthEastMap enterSouthEastMap enterSouthWestMap enterNorthWestMap - mapCreateView mapProperties archetypes.menu=displayObjectNames findArchetypes Modified: trunk/src/app/net/sf/gridarta/DefaultMapManager.java =================================================================== --- trunk/src/app/net/sf/gridarta/DefaultMapManager.java 2008-03-23 14:11:46 UTC (rev 3739) +++ trunk/src/app/net/sf/gridarta/DefaultMapManager.java 2008-03-23 16:46:47 UTC (rev 3740) @@ -151,12 +151,8 @@ if (!forced && mapControl.isModified()) { final int result = actionFactory.showConfirmDialog(mainControl.getMainView(), JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE, "confirmSaveChanges", mapControl.getMapModel().getMapArchObject().getMapDisplayName()); if (result == JOptionPane.YES_OPTION) { - if (mapControl.isPlainSaveEnabled()) { - mapControl.save(); - } else { - if (!mainControl.saveLevelAsWanted(mapControl)) { - return false; - } + if (!save(mapControl)) { + return false; } } else if (result == JOptionPane.CANCEL_OPTION || result == JOptionPane.CLOSED_OPTION) { return false; @@ -451,4 +447,14 @@ } } + /** {@inheritDoc} */ + public boolean save(@NotNull final C mapControl) { + if (mapControl.isPlainSaveEnabled()) { + mapControl.save(); + return true; + } else { + return mainControl.saveLevelAsWanted(mapControl); + } + } + } // class DefaultMapManager Modified: trunk/src/app/net/sf/gridarta/MapManager.java =================================================================== --- trunk/src/app/net/sf/gridarta/MapManager.java 2008-03-23 14:11:46 UTC (rev 3739) +++ trunk/src/app/net/sf/gridarta/MapManager.java 2008-03-23 16:46:47 UTC (rev 3740) @@ -191,4 +191,12 @@ */ void refreshCurrentMap(); + /** + * Save one map. + * @param mapControl the map + * @return <code>false</code> if the user cancelled the save, + * <code>true</code> otherwise + */ + boolean save(@NotNull final C mapControl); + } // interface MapManager Modified: trunk/src/app/net/sf/gridarta/gui/MapManagerActions.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/MapManagerActions.java 2008-03-23 14:11:46 UTC (rev 3739) +++ trunk/src/app/net/sf/gridarta/gui/MapManagerActions.java 2008-03-23 16:46:47 UTC (rev 3740) @@ -38,14 +38,21 @@ /** Action Factory. */ private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("net.sf.gridarta"); + /** The map manager. */ + private final MapManager<G, A, R, C, V> mapManager; + /** Action for "close all map windows". */ private final Action aCloseAll; + /** The action for "save all". */ + private final Action aSaveAll = ACTION_FACTORY.createAction(true, "saveAll", this); + /** * Creates a new instance. * @param mapManager the map manager to forward to */ public MapManagerActions(@NotNull final MapManager<G, A, R, C, V> mapManager) { + this.mapManager = mapManager; aCloseAll = ACTION_FACTORY.createAction(true, "closeAll", mapManager); } @@ -56,4 +63,15 @@ return aCloseAll; } + /** + * Invoked when the user wants to save all map files. + */ + public void saveAll() { + for (final C mapControl : mapManager.getOpenedMaps()) { + if (mapControl.isModified() && !mapManager.save(mapControl)) { + return; + } + } + } + } // class MapManagerActions Modified: trunk/src/app/net/sf/gridarta/gui/map/MapFileActions.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/MapFileActions.java 2008-03-23 14:11:46 UTC (rev 3739) +++ trunk/src/app/net/sf/gridarta/gui/map/MapFileActions.java 2008-03-23 16:46:47 UTC (rev 3740) @@ -19,6 +19,8 @@ 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; @@ -48,6 +50,11 @@ @NotNull private final MainControl<G, A, R, C, V> mainControl; /** + * The map manager. + */ + @NotNull private final MapManager<G, A, R, C, V> mapManager; + + /** * The action callback functions. */ private final Actions actions = new Actions(); @@ -82,6 +89,7 @@ */ public MapFileActions(@NotNull final MainControl<G, A, R, C, V> mainControl, @NotNull final MapManager<G, A, R, C, V> mapManager, @Nullable final C mapControl) { this.mainControl = mainControl; + this.mapManager = mapManager; currentMapListener = new CurrentMapListener<G, A, R, C, V>(mainControl, mapManager, mapControl, true, false, false) { /** {@inheritDoc} */ @@ -181,11 +189,7 @@ public void save() { final C mapControl = getSaveEnabled(); if (mapControl != null) { - if (mapControl.isPlainSaveEnabled()) { - mapControl.save(); - } else { - mainControl.saveLevelAsWanted(mapControl); - } + mapManager.save(mapControl); } } Modified: trunk/src/app/net/sf/gridarta/messages.properties =================================================================== --- trunk/src/app/net/sf/gridarta/messages.properties 2008-03-23 14:11:46 UTC (rev 3739) +++ trunk/src/app/net/sf/gridarta/messages.properties 2008-03-23 16:46:47 UTC (rev 3740) @@ -93,7 +93,11 @@ closeAll.mnemonic=L closeAll.accel=ctrl shift pressed W +saveAll.text=Save All +saveAll.shortdescription=Save all maps +saveAll.longdescription=Saves all opened maps + # Dialogs pickmapExists.title=Cannot Create Pickmap pickmapExists.message=A pickmap named {0} already exists.\nEither remove the existing one or choose a different name. Modified: trunk/src/app/net/sf/gridarta/messages_de.properties =================================================================== --- trunk/src/app/net/sf/gridarta/messages_de.properties 2008-03-23 14:11:46 UTC (rev 3739) +++ trunk/src/app/net/sf/gridarta/messages_de.properties 2008-03-23 16:46:47 UTC (rev 3740) @@ -81,7 +81,11 @@ closeAll.longdescription=Schlie\xDFt alle ge\xF6ffneten Karten. closeAll.mnemonic=A +saveAll.text=Alle speichern +saveAll.shortdescription=Alle Karten speichern +saveAll.longdescription=Speichert alle ge\xF6ffneten Karten. + # Dialogs pickmapExists.title=Kann Pickmap nicht erstellen pickmapExists.message=Die Pickmap ''{0}'' existiert bereits.\nSie m\xFCssen die existierende Pickmap erst l\xF6schen oder einen anderen Namen w\xE4hlen. Modified: trunk/src/app/net/sf/gridarta/messages_fr.properties =================================================================== --- trunk/src/app/net/sf/gridarta/messages_fr.properties 2008-03-23 14:11:46 UTC (rev 3739) +++ trunk/src/app/net/sf/gridarta/messages_fr.properties 2008-03-23 16:46:47 UTC (rev 3740) @@ -80,7 +80,11 @@ #closeAll.longdescription= closeAll.mnemonic=T +#saveAll.text= +#saveAll.shortdescription= +#saveAll.longdescription= + # Dialogs #pickmapExists.title= #pickmapExists.message= Modified: trunk/src/app/net/sf/gridarta/messages_sv.properties =================================================================== --- trunk/src/app/net/sf/gridarta/messages_sv.properties 2008-03-23 14:11:46 UTC (rev 3739) +++ trunk/src/app/net/sf/gridarta/messages_sv.properties 2008-03-23 16:46:47 UTC (rev 3740) @@ -80,7 +80,11 @@ closeAll.longdescription=St\xE4nger alla \xF6ppnade kartor closeAll.mnemonic=S +#saveAll.text= +#saveAll.shortdescription= +#saveAll.longdescription= + # Dialogs pickmapExists.title=Kan inte skapa plockkarta pickmapExists.message=En plockkarta med namnet {0} finns redan.\nTa antingen bort den tidigare plockkartan eller v\xE4lj ett annat namn. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-03-23 16:57:03
|
Revision: 3741 http://gridarta.svn.sourceforge.net/gridarta/?rev=3741&view=rev Author: akirschbaum Date: 2008-03-23 09:55:55 -0700 (Sun, 23 Mar 2008) Log Message: ----------- Make flood fill work again. Modified Paths: -------------- trunk/crossfire/ChangeLog trunk/daimonin/ChangeLog trunk/src/app/net/sf/gridarta/CopyBuffer.java Modified: trunk/crossfire/ChangeLog =================================================================== --- trunk/crossfire/ChangeLog 2008-03-23 16:46:47 UTC (rev 3740) +++ trunk/crossfire/ChangeLog 2008-03-23 16:55:55 UTC (rev 3741) @@ -1,5 +1,7 @@ 2008-03-23 Andreas Kirschbaum + * Make flood fill work again. + * Implement "Save All" for saving all opened maps. 2008-03-21 Andreas Kirschbaum Modified: trunk/daimonin/ChangeLog =================================================================== --- trunk/daimonin/ChangeLog 2008-03-23 16:46:47 UTC (rev 3740) +++ trunk/daimonin/ChangeLog 2008-03-23 16:55:55 UTC (rev 3741) @@ -1,5 +1,7 @@ 2008-03-23 Andreas Kirschbaum + * Make flood fill work again. + * Implement "Save All" for saving all opened maps. 2008-03-19 Andreas Kirschbaum Modified: trunk/src/app/net/sf/gridarta/CopyBuffer.java =================================================================== --- trunk/src/app/net/sf/gridarta/CopyBuffer.java 2008-03-23 16:46:47 UTC (rev 3740) +++ trunk/src/app/net/sf/gridarta/CopyBuffer.java 2008-03-23 16:55:55 UTC (rev 3741) @@ -268,7 +268,7 @@ } final MapSquare cursorSquare = mapViewBasic.getCursorSquare(); - if (cursorSquare == null || cursorSquare.isEmpty()) { + if (cursorSquare == null || !cursorSquare.isEmpty()) { return; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-03-24 21:20:45
|
Revision: 3743 http://gridarta.svn.sourceforge.net/gridarta/?rev=3743&view=rev Author: akirschbaum Date: 2008-03-24 14:20:04 -0700 (Mon, 24 Mar 2008) Log Message: ----------- Whitespace changes. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchData.java trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchData.java Modified: trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchData.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchData.java 2008-03-23 17:11:35 UTC (rev 3742) +++ trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchData.java 2008-03-24 21:20:04 UTC (rev 3743) @@ -92,7 +92,21 @@ private static JTextField inputOptions; // FIXME: This should NOT BE HERE. Instead, it should be read from types.xml. - private static final String[] allEventTypes = new String[]{"apply", "attack", "death", "drop", "pickup", "say", "stop", "time", "throw", "trigger", "close", "timer", "destroy"}; + private static final String[] allEventTypes = new String[] { + "apply", + "attack", + "death", + "drop", + "pickup", + "say", + "stop", + "time", + "throw", + "trigger", + "close", + "timer", + "destroy", + }; private final GameObject owner; Modified: trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchData.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchData.java 2008-03-23 17:11:35 UTC (rev 3742) +++ trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchData.java 2008-03-24 21:20:04 UTC (rev 3743) @@ -93,7 +93,21 @@ private static JTextField inputOptions; // FIXME: This should NOT BE HERE. Instead, it should be read from types.xml. - private static final String[] allEventTypes = new String[]{"apply", "attack", "death", "drop", "pickup", "say", "stop", "time (don't use)", "throw", "trigger", "close", "examine", "talk"}; + private static final String[] allEventTypes = new String[] { + "apply", + "attack", + "death", + "drop", + "pickup", + "say", + "stop", + "time (don't use)", + "throw", + "trigger", + "close", + "examine", + "talk", + }; private final GameObject owner; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-03-27 19:02:30
|
Revision: 3745 http://gridarta.svn.sourceforge.net/gridarta/?rev=3745&view=rev Author: akirschbaum Date: 2008-03-27 12:02:33 -0700 (Thu, 27 Mar 2008) Log Message: ----------- Move Updater to common code base. Modified Paths: -------------- trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/gui/prefs/UpdatePrefs.java 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/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/updater/ trunk/src/app/net/sf/gridarta/updater/Updater.java Removed Paths: ------------- trunk/daimonin/src/daieditor/Updater.java Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-03-27 18:27:07 UTC (rev 3744) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-03-27 19:02:33 UTC (rev 3745) @@ -111,6 +111,7 @@ import net.sf.gridarta.textedit.scripteditor.ScriptEditControl; import net.sf.gridarta.treasurelist.CFTreasureListTree; import net.sf.gridarta.treasurelist.TreasureLocation; +import net.sf.gridarta.updater.Updater; import net.sf.japi.swing.ActionFactory; import net.sf.japi.swing.ActionMethod; import net.sf.japi.swing.misc.Progress; @@ -315,7 +316,7 @@ mapManagerActions = new MapManagerActions<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(getMapManager()); mainView = new CMainView(this, getMapManager(), mapManagerActions.getCloseAllAction()); undoControl = new UndoControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(getMapManager()); - Updater.startup(mainView, this); + Updater.startup(mainView, this, "daieditor"); readGlobalSettings(); @@ -1149,7 +1150,7 @@ if (getMapManager().hasOpenedMap()) { ACTION_FACTORY.showMessageDialog(mainView, "updateCloseMaps"); } else { - Updater.update(mainView, this); + Updater.update(mainView, this, "daieditor"); } } Deleted: trunk/daimonin/src/daieditor/Updater.java =================================================================== --- trunk/daimonin/src/daieditor/Updater.java 2008-03-27 18:27:07 UTC (rev 3744) +++ trunk/daimonin/src/daieditor/Updater.java 2008-03-27 19:02:33 UTC (rev 3745) @@ -1,319 +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; - -import java.awt.Component; -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.InterruptedIOException; -import java.io.OutputStream; -import java.net.Proxy; -import java.net.URL; -import java.net.URLConnection; -import java.net.UnknownHostException; -import java.util.MissingResourceException; -import java.util.PropertyResourceBundle; -import java.util.ResourceBundle; -import java.util.logging.Level; -import java.util.logging.Logger; -import java.util.prefs.Preferences; -import javax.swing.JOptionPane; -import javax.swing.ProgressMonitor; -import javax.swing.ProgressMonitorInputStream; -import net.sf.gridarta.MainControl; -import net.sf.japi.swing.ActionFactory; - -/** - * This class handles updating the map editor. - * @author <a href="mailto:ch...@ri...">Christian.Hujer</a> - * @fixme the updater fails on windows, the user is notified of this but still it isn't nice. - * The updater should be a separate application. - * @todo move the updater to JAPI - */ -public final class Updater implements Runnable { - - /** Action Factory. */ - private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("daieditor"); - - /** Logger. */ - private static final Logger log = Logger.getLogger("daieditor"); - - /** Preferences. */ - private static final Preferences PREFS = Preferences.userNodeForPackage(MainControl.class); - - /** Preferences key whether to automatically check for updates. */ - public static final String AUTO_CHECK_KEY = "UpdaterAutoCheck"; - - /** Preferences default value for AUTO_CHECK_KEY. */ - public static final boolean AUTO_CHECK_DEFAULT = false; - - /** Preferences key for selected update interval. */ - public static final String INTERVAL_KEY = "UpdaterInterval"; - - /** Preferences default value for INTERVAL_KEY. */ - public static final int INTERVAL_DEFAULT = 2; - - /** Preferences key for last update. */ - public static final String LAST_UPDATE_KEY = "UpdateTimestamp"; - - /** The parentComponent to show dialogs on. */ - private final Component parentComponent; - - /** The main control. */ - private final MainControl mainControl; - - /** Buffer size. */ - private static final int BUF_SIZE = 4096; - - /** The times for update calculation. */ - private static final long[] UPDATE_TIMES = { - 0L, // Every startup - 86400000L, // Once a day - 604800000L, // Once a week - 2419200000L, // Once a month - }; - - /** - * Create an Updater. - * @param parentComponent Component to show dialogs on - * @param mainControl The main control. - */ - private Updater(final Component parentComponent, final MainControl mainControl) { - this.parentComponent = parentComponent; - this.mainControl = mainControl; - if (parentComponent != null) { - parentComponent.setEnabled(false); - } - } - - /** - * Eventually perform an update during startup. - * @param parentComponent Component to show dialogs on - * @param mainControl The main control. - */ - public static void startup(final Component parentComponent, final MainControl mainControl) { - if (!PREFS.getBoolean(AUTO_CHECK_KEY, AUTO_CHECK_DEFAULT)) { - return; - } - final long timeDifference = UPDATE_TIMES[PREFS.getInt(INTERVAL_KEY, INTERVAL_DEFAULT)]; - final long lastUpdate = PREFS.getLong(LAST_UPDATE_KEY, 0); - if (System.currentTimeMillis() > lastUpdate + timeDifference) { - update(parentComponent, mainControl); - } - } - - /** - * Perform an update. - * @param parentComponent Component to show dialogs on - * @param mainControl MainControl, used for graceful exit in case the update was successful. - */ - public static void update(final Component parentComponent, final MainControl mainControl) { - new Thread(new Updater(parentComponent, mainControl)).start(); - } - - /** {@inheritDoc} */ - public void run() { - try { - final String propUrl = ACTION_FACTORY.getString("update.url"); - final InputStream pin = openStream(propUrl); - try { - final ResourceBundle updateBundle = new PropertyResourceBundle(pin); - final String downloadUrl = updateBundle.getString("update.url"); - final VersionInfo update = new VersionInfo(updateBundle, "update"); - VersionInfo active = VersionInfo.UNAVAILABLE; - try { - active = new VersionInfo(ResourceBundle.getBundle("build"), "build"); - } catch (final MissingResourceException e) { - ACTION_FACTORY.showMessageDialog(parentComponent, "updateActiveVersionUnavailable"); - } - PREFS.putLong(LAST_UPDATE_KEY, System.currentTimeMillis()); - if (active == null || update.isNewerThan(active)) { - if (askIfUserWantsUpdate(active, update, propUrl, downloadUrl)) { - downloadAndInstallUpdate(downloadUrl); - } - } else { - noNewUpdate(active, update, propUrl, downloadUrl); - } - } finally { - pin.close(); - } - } catch (final UnknownHostException e) { - ACTION_FACTORY.showMessageDialog(parentComponent, "updateError", e.getLocalizedMessage()); - } catch (final Exception e) { - log.log(Level.WARNING, "updateError", e); - ACTION_FACTORY.showMessageDialog(parentComponent, "updateError", e); - } finally { - if (parentComponent != null) { - parentComponent.setEnabled(true); - } - } - } - - /** - * Ask the user whether he wants to update. - * @param active VersionInfo of currently installed version - * @param update VersionInfo of available update version - * @param propUrl URL where properties were downloaded from - * @param downloadUrl URL where the update would be downloaded from - * @return <code>true</code> if the user chose that he wants to update, otherwise <code>false</code> - */ - private boolean askIfUserWantsUpdate(final VersionInfo active, final VersionInfo update, final String propUrl, final String downloadUrl) { - return - ACTION_FACTORY.showConfirmDialog(parentComponent, JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, "updateAvailable", - active.version, update.version, - active.developer, update.developer, - active.tstamp, update.tstamp, - propUrl, downloadUrl - ) == JOptionPane.YES_OPTION; - } - - /** - * Tell the user there is no update. - * @param active VersionInfo of currently installed version - * @param update VersionInfo of available update version - * @param propUrl URL where properties were downloaded from - * @param downloadUrl URL where the update would be downloaded from - */ - private void noNewUpdate(final VersionInfo active, final VersionInfo update, final String propUrl, final String downloadUrl) { - ACTION_FACTORY.showMessageDialog(parentComponent, "updateUnavailable", - active.version, update.version, - active.developer, update.developer, - active.tstamp, update.tstamp, - propUrl, downloadUrl - ); - } - - /** - * Download and install an update. - * @param url URL to get update from - */ - private void downloadAndInstallUpdate(final String url) { - final File download = new File("DaimoninEditor.jar.tmp"); // TODO: print error message if file already exists - final File backup = new File("DaimoninEditor.jar.bak"); - final File orig = new File("DaimoninEditor.jar"); - try { - final InputStream in = openStream(url); - try { - final OutputStream out = new FileOutputStream(download); - try { - final byte[] buf = new byte[BUF_SIZE]; - for (int bytesRead; (bytesRead = in.read(buf)) != -1; out.write(buf, 0, bytesRead)) { - ; - } - out.close(); - if (/* !backup.delete() || */ !orig.renameTo(backup)) { - ACTION_FACTORY.showMessageDialog(parentComponent, "updateFailedNoBackup"); - } else if (!download.renameTo(orig)) { - backup.renameTo(orig); - ACTION_FACTORY.showMessageDialog(parentComponent, "updateFailedNoDownload"); - } else { - ACTION_FACTORY.showMessageDialog(parentComponent, "updateRestart"); - mainControl.doExit(); - } - } finally { - out.close(); - } - } finally { - in.close(); - } - } catch (final InterruptedIOException e) { - ACTION_FACTORY.showMessageDialog(parentComponent, "updateAborted"); - } catch (final Exception e) { - log.log(Level.WARNING, "updateError", e); - ACTION_FACTORY.showMessageDialog(parentComponent, "updateError", e); - } - } - - /** - * Open an InputStream on a URL. - * @param url URL to open InputStream on - * @return InputStream for URL - * @throws IOException in case of I/O problems - */ - // The stream is closed by caller - @SuppressWarnings({"IOResourceOpenedButNotSafelyClosed"}) - private InputStream openStream(final String url) throws IOException { - final URLConnection con = new URL(url).openConnection(Proxy.NO_PROXY); - final ProgressMonitorInputStream stream = new ProgressMonitorInputStream(parentComponent, ACTION_FACTORY.getString("updateProgress.title"), con.getInputStream()); - final ProgressMonitor monitor = stream.getProgressMonitor(); - monitor.setMaximum(con.getContentLength()); - monitor.setNote(ACTION_FACTORY.getString("updateProgress")); - monitor.setMillisToDecideToPopup(10); - monitor.setMillisToPopup(10); - return stream; - } - - /** Class for holding version information and quickly comparing it. */ - private static final class VersionInfo { - - /** Update information: Version of update version, usually the build number. */ - private final String version; - - /** Update information: Time stamp of update version. */ - private final String tstamp; - - /** Update information: Developer that created the update version. */ - private final String developer; - - /** Special Version "unavailable". */ - private static final VersionInfo UNAVAILABLE = new VersionInfo(); - - /** Private constructor used for unavailable versions. */ - private VersionInfo() { - this("unavailable", "unavailable", "unavailable"); - } - - /** - * Private constructor to map the strings. - * @param version Version - * @param tstamp Timestamp - * @param developer Developer - */ - private VersionInfo(final String version, final String tstamp, final String developer) { - this.version = version; - this.tstamp = tstamp; - this.developer = developer; - } - - /** - * Create update information from a ResourceBundle. - * The ResourceBundle should have Strings for <var>prefix</var> + <code>.number</code>, <code>.tstamp</code> and <code>.developer</code>. - * @param bundle ResourceBundle to create update information from - * @param prefix Prefix for update information within the resource bundle - */ - VersionInfo(final ResourceBundle bundle, final String prefix) { - this(bundle.getString(prefix + ".number"), bundle.getString(prefix + ".tstamp"), bundle.getString(prefix + ".developer")); - } - - /** - * Check whether this version is newer than another version. - * @param other Other version information to compare to - * @return <code>true</code> if this versionis newer than <var>other</var>, otherwise <code>false</code> - */ - @SuppressWarnings({"ObjectEquality"}) - boolean isNewerThan(final VersionInfo other) { - return this != UNAVAILABLE && (other == UNAVAILABLE || tstamp.compareTo(other.tstamp) > 0); - } - - } // class VersionInfo - -} // class Updater Modified: trunk/daimonin/src/daieditor/gui/prefs/UpdatePrefs.java =================================================================== --- trunk/daimonin/src/daieditor/gui/prefs/UpdatePrefs.java 2008-03-27 18:27:07 UTC (rev 3744) +++ trunk/daimonin/src/daieditor/gui/prefs/UpdatePrefs.java 2008-03-27 19:02:33 UTC (rev 3745) @@ -19,7 +19,6 @@ package daieditor.gui.prefs; -import daieditor.Updater; import java.awt.Component; import java.util.prefs.Preferences; import javax.swing.Box; @@ -30,6 +29,7 @@ import javax.swing.border.TitledBorder; import net.sf.gridarta.MainControl; import net.sf.gridarta.gui.GUIConstants; +import net.sf.gridarta.updater.Updater; import net.sf.japi.swing.ActionFactory; import net.sf.japi.swing.prefs.AbstractPrefs; Modified: trunk/daimonin/src/daieditor/messages.properties =================================================================== --- trunk/daimonin/src/daieditor/messages.properties 2008-03-27 18:27:07 UTC (rev 3744) +++ trunk/daimonin/src/daieditor/messages.properties 2008-03-27 19:02:33 UTC (rev 3745) @@ -498,33 +498,6 @@ aboutRuntimeProperties.title=Runtime properties aboutBuildProperties.title=Build properties -update.text=Update... -update.mnemonic=U -update.accel=ctrl pressed U -update.title=Updating -updateCloseMaps.title=Error while updating -updateCloseMaps.message=You have to close all files before running the update feature. -update.message=Check for updates? -updateError.title=Error while updating -updateError.message=Error while updating:\n{0}\n\nPlease update manually. -updateUnavailable.title=No update available -updateUnavailable.message=<html><style type="text/css">.cell'{border-width:1px;border-style:solid;border-color:#000000;background-color:#FFFFFF;color:#000000;}'</style><table><tr><td></td><th class="cell">Installed</th><th class="cell">Available</th></tr><tr><th class="cell">Version</th><td class="cell">{0}</td><td class="cell">{1}</td></tr><tr><th class="cell">Developer</th><td class="cell">{2}</td><td class="cell">{3}</td></tr><tr><th class="cell">Timestamp</th><td class="cell">{4}</td><td class="cell">{5}</td></tr></table><p align="center">No newer version available.</p><p>Source: {6}<br>Download: {7}</p></html> -updateAvailable.title=Update available! -updateAvailable.message=<html><style type="text/css">.cell'{border-width:1px;border-style:solid;border-color:#000000;background-color:#FFFFFF;color:#000000;}'</style><table><tr><td></td><th class="cell">Installed</th><th class="cell">Available</th></tr><tr><th class="cell">Version</th><td class="cell">{0}</td><td class="cell">{1}</td></tr><tr><th class="cell">Developer</th><td class="cell">{2}</td><td class="cell">{3}</td></tr><tr><th class="cell">Timestamp</th><td class="cell">{4}</td><td class="cell">{5}</td></tr></table><p align="center">A newer version is available. Install update?</p><p>Note: This will only update DaimoninEditor.jar. Your arches will not be updated.</p><p>(The editor will not be useable while the update is in progress)</p><p>Source: {6}<br>Download: {7}</p></html> -updateFailedNoBackup.title=Update failed -updateFailedNoBackup.message=<html>Could not create backup, update failed.<br>Please do the following steps manually after exiting the editor:<ol><li>rename DaimoninEditor.jar to DaimoninEditor.jar.bak<li>rename DaimoninEditor.jar.tmp to DaimoninEditor.jar</ol></html> -updateFailedNoDownload.title=Update failed -updateFailedNoDownload.message=Could not use download, update failed. -updateRestart.title=Update successful -updateRestart.message=Update successful.\nI have stored a backup of the previous version under "DaimoninEditor.jar.bak".\n\nThe editor automatically exits after updating.\nYou have to restart it yourself in case you want to use it now. -updateAborted.title=Update aborted -updateAborted.message=Update aborted on your request. -updateProgress.title=Update -updateProgress=Update in progress -updateActiveVersionUnavailable.title=Update warning -updateActiveVersionUnavailable.message=I was unable to determine my version.\nI will assume that the update is newer than your current version. - - ############ # Map window Modified: trunk/daimonin/src/daieditor/messages_de.properties =================================================================== --- trunk/daimonin/src/daieditor/messages_de.properties 2008-03-27 18:27:07 UTC (rev 3744) +++ trunk/daimonin/src/daieditor/messages_de.properties 2008-03-27 19:02:33 UTC (rev 3745) @@ -457,32 +457,6 @@ aboutRuntimeProperties.title=Laufzeitparameter #aboutBuildProperties.title= -update.text=Update... -update.mnemonic=U -update.title=Update -update.message=Nach Update suchen? -updateCloseMaps.title=Fehler beim Update -updateCloseMaps.message=Alle Dateien m\xFCssen geschlossen werden, bevor ein Update durchgef\xFChrt werden kann. -updateError.title=Fehler beim Update -updateError.message=Fehler beim Update:\n{0}\n\nBitte manuell aktualisieren. -updateUnavailable.title=Kein Update verf\xFCgbar -updateUnavailable.message=<html><style type="text/css">.cell'{border-width:1px;border-style:solid;border-color:#000000;background-color:#FFFFFF;color:#000000;}'</style><table><tr><td></td><th class="cell">Installiert</th><th class="cell">Verf\xFCgbar</th></tr><tr><th class="cell">Version</th><td class="cell">{0}</td><td class="cell">{1}</td></tr><tr><th class="cell">Entwickler</th><td class="cell">{2}</td><td class="cell">{3}</td></tr><tr><th class="cell">Datum</th><td class="cell">{4}</td><td class="cell">{5}</td></tr></table><p align="center">Keine neuere Version verf\xFCgbar.</p><p>Quelle: {6}<br>Download: {7}</p></html> -updateAvailable.title=Update verf\xFCgbar! -updateAvailable.message=<html><style type="text/css">.cell'{border-width:1px;border-style:solid;border-color:#000000;background-color:#FFFFFF;color:#000000;}'</style><table><tr><td></td><th class="cell">Installiert</th><th class="cell">Verf\xFCgbar</th></tr><tr><th class="cell">Version</th><td class="cell">{1}</td><td class="cell">{2}</td></tr><tr><th class="cell">Entwickler</th><td class="cell">{3}</td><td class="cell">{4}</td></tr><tr><th class="cell">Datum</th><td class="cell">{5}</td><td class="cell">{6}</td></tr></table><p align="center">Eine neuere Version des Editors ist verf\xFCgbar. Update installieren?</p><p>Anmerkung: Es wird nur DaimoninEditor.jar aktualisiert. Die Archetypen werden nicht aktualisiert.</p><p>(Der Editor kann nicht benutzt werden, solange die Aktualisierung l\xE4uft)</p><p>Quelle: {7}<br>Download: {8}</p></html> -updateFailedNoBackup.title=Aktualisierung fehlgeschlagen -updateFailedNoBackup.message=<html>Konnte keine Backup-Datei anlegen, Aktualisierung fehlgeschlagen.<br>Bitte f\xFChren Sie folgende Schritte manuell aus, nachdem Sie den Editor geschlossen haben:<ol><li>Nennen Sie DaimoninEditor.jar in DaimoninEditor.jar.bak um<li>Nennen Sie DaimoninEditor.jar.tmp in DaimoninEditor.jar um</ol></html> -updateFailedNoDownload.title=Aktualisierung fehlgeschlagen -updateFailedNoDownload.message=Download fehlgeschlagen, Aktualisierung fehlgeschlagen. -updateRestart.title=Aktualisierung erfolgreich -updateRestart.message=Aktualisierung erfolgreich.\nDie vorherige Version des Editors ist als "DaimoninEditor.jar.bak" verf\xFCgbar.\n\nDer Editor beendet sich jetzt automatisch.\nBitte starten Sie ihn erneut. -updateAborted.title=Aktualisierung abgebrochen -updateAborted.message=Sie haben die Aktualisierung abgebrochen. -updateProgress.title=Aktualisierung -updateProgress=Aktualisierung wird durchgef\xFChrt -updateActiveVersionUnavailable.title=Warnung -updateActiveVersionUnavailable.message=Die aktuelle Editor-Version konnte nicht ermittelt werden.\nDas verf\xFCgbare Update wird installiert. - - ############ # Map window Modified: trunk/daimonin/src/daieditor/messages_fr.properties =================================================================== --- trunk/daimonin/src/daieditor/messages_fr.properties 2008-03-27 18:27:07 UTC (rev 3744) +++ trunk/daimonin/src/daieditor/messages_fr.properties 2008-03-27 19:02:33 UTC (rev 3745) @@ -454,32 +454,6 @@ #aboutRuntimeProperties.title= #aboutBuildProperties.title= -#update.text= -#update.mnemonic= -#update.title= -#updateCloseMaps.title= -#updateCloseMaps.message= -#update.message= -#updateError.title= -#updateError.message= -#updateUnavailable.title= -#updateUnavailable.message=<html><style type="text/css">.cell'{border-width:1px;border-style:solid;border-color:#000000;background-color:#FFFFFF;color:#000000;}'</style><table><tr><td></td><th class="cell">Installed</th><th class="cell">Available</th></tr><tr><th class="cell">Version</th><td class="cell">{0}</td><td class="cell">{1}</td></tr><tr><th class="cell">Developer</th><td class="cell">{2}</td><td class="cell">{3}</td></tr><tr><th class="cell">Timestamp</th><td class="cell">{4}</td><td class="cell">{5}</td></tr></table><p align= -#updateAvailable.title= -#updateAvailable.message=<html><style type="text/css">.cell'{border-width:1px;border-style:solid;border-color:#000000;background-color:#FFFFFF;color:#000000;}'</style><table><tr><td></td><th class="cell">Installed</th><th class="cell">Available</th></tr><tr><th class="cell">Version</th><td class="cell">{0}</td><td class="cell">{1}</td></tr><tr><th class="cell">Developer</th><td class="cell">{2}</td><td class="cell">{3}</td></tr><tr><th class="cell">Timestamp</th><td class="cell">{4}</td><td class="cell">{5}</td></tr></table><p align= -#updateFailedNoBackup.title= -#updateFailedNoBackup.message= -#updateFailedNoDownload.title= -#updateFailedNoDownload.message= -#updateRestart.title= -#updateRestart.message= -#updateAborted.title= -#updateAborted.message= -#updateProgress.title= -#updateProgress= -#updateActiveVersionUnavailable.title= -#updateActiveVersionUnavailable.message= - - ############ # Map window Modified: trunk/daimonin/src/daieditor/messages_sv.properties =================================================================== --- trunk/daimonin/src/daieditor/messages_sv.properties 2008-03-27 18:27:07 UTC (rev 3744) +++ trunk/daimonin/src/daieditor/messages_sv.properties 2008-03-27 19:02:33 UTC (rev 3745) @@ -459,32 +459,6 @@ aboutRuntimeProperties.title=Runtime properties aboutBuildProperties.title=Build properties -update.text=Uppdatera... -update.mnemonic=U -update.title=Uppdaterar -updateCloseMaps.title=Fel i uppdatering -updateCloseMaps.message=Du m\xE5ste st\xE4nga alla \xF6ppna filer innan uppdatering. -update.message=Leta efter uppdateringar? -updateError.title=Fel under uppdatering -updateError.message=Fel under uppdatering:\n{0}\n\nVar v\xE4nlig uppdatera manuellt. -updateUnavailable.title=Ingen ny uppdatering tillg\xE4nglig -updateUnavailable.message=<html><style type="text/css">.cell'{border-width:1px;border-style:solid;border-color:#000000;background-color:#FFFFFF;color:#000000;}'</style><table><tr><td></td><th class="cell">Installerad</th><th class="cell">Tillg\xE4nglig</th></tr><tr><th class="cell">Version</th><td class="cell">{0}</td><td class="cell">{1}</td></tr><tr><th class="cell">Utvecklare</th><td class="cell">{2}</td><td class="cell">{3}</td></tr><tr><th class="cell">Datum</th><td class="cell">{4}</td><td class="cell">{5}</td></tr></table><p align="center">Ingen nyare version hittad.</p><p>K\xE4lla: {6}<br>Ladda ner: {7}</p></html> -updateAvailable.title=Uppdatering tillg\xE4nglig! -updateAvailable.message=<html><style type="text/css">.cell'{border-width:1px;border-style:solid;border-color:#000000;background-color:#FFFFFF;color:#000000;}'</style><table><tr><td></td><th class="cell">Installerad</th><th class="cell">Tillg\xE4nglig</th></tr><tr><th class="cell">Version</th><td class="cell">{0}</td><td class="cell">{1}</td></tr><tr><th class="cell">Utvecklare</th><td class="cell">{2}</td><td class="cell">{3}</td></tr><tr><th class="cell">Datum</th><td class="cell">{4}</td><td class="cell">{5}</td></tr></table><p align="center">En nyare version \xE4r tillg\xE4nglig. Installera uppdatering?</p><p>OBS: Detta uppdaterar enbart DaimoninEditor.jar. Dina arketypfiler kommer inte att uppdateras.</p><p>(Editorn kan inte anv\xE4ndas medan uppdatering p\xE5g\xE5r)</p><p>K\xE4lla: {6}<br>Nerladdning: {7}</p></html> -updateFailedNoBackup.title=Uppdatering misslyckades -updateFailedNoBackup.message=<html>Kunde inte skapa s\xE4kerhetskopia, updatering misslyckades.<br>Var v\xE4nlig utf\xF6r f\xF6ljande steg manuellt efter att avslutat editorn:<ol><li>d\xF6p om DaimoninEditor.jar till DaimoninEditor.jar.bak<li>d\xF6p om DaimoninEditor.jar.tmp till DaimoninEditor.jar</ol></html> -updateFailedNoDownload.title=Uppdatering misslyckades -updateFailedNoDownload.message=Kunde inte anv\xE4nda den nerladdade filen. -updateRestart.title=Uppdatering lyckades -updateRestart.message=Uppdatering lyckades.\nJag har lagrat en s\xE4kerhetskopia av den gamla versionen som "DaimoninEditor.jar.bak".\n\nEditorn kommer nu att avslutas automatiskt.\nDu m\xE5ste starta om den sj\xE4lv om du vill forts\xE4tta arbeta med den nya versionen. -updateAborted.title=Uppdatering avbruten -updateAborted.message=Uppdatering avbruten p\xE5 din beg\xE4ran. -#updateProgress.title= -updateProgress=Uppdatering p\xE5g\xE5r -updateActiveVersionUnavailable.title=Uppdateringsvarning -updateActiveVersionUnavailable.message=Jag kunde inte best\xE4mma min nuvarande version.\nJag kommer att anta att uppdateringen \xE4r nyare \xE4n den nuvarande installationen. - - ############ # Map window Modified: trunk/src/app/net/sf/gridarta/messages.properties =================================================================== --- trunk/src/app/net/sf/gridarta/messages.properties 2008-03-27 18:27:07 UTC (rev 3744) +++ trunk/src/app/net/sf/gridarta/messages.properties 2008-03-27 19:02:33 UTC (rev 3745) @@ -813,3 +813,32 @@ findArchetypesScrollDown.accel=pressed DOWN findArchetypesScrollUp.text=- findArchetypesScrollUp.accel=pressed UP + + +######### +# Updater +update.text=Update... +update.mnemonic=U +update.accel=ctrl pressed U +update.title=Updating +updateCloseMaps.title=Error while updating +updateCloseMaps.message=You have to close all files before running the update feature. +update.message=Check for updates? +updateError.title=Error while updating +updateError.message=Error while updating:\n{0}\n\nPlease update manually. +updateUnavailable.title=No update available +updateUnavailable.message=<html><style type="text/css">.cell'{border-width:1px;border-style:solid;border-color:#000000;background-color:#FFFFFF;color:#000000;}'</style><table><tr><td></td><th class="cell">Installed</th><th class="cell">Available</th></tr><tr><th class="cell">Version</th><td class="cell">{0}</td><td class="cell">{1}</td></tr><tr><th class="cell">Developer</th><td class="cell">{2}</td><td class="cell">{3}</td></tr><tr><th class="cell">Timestamp</th><td class="cell">{4}</td><td class="cell">{5}</td></tr></table><p align="center">No newer version available.</p><p>Source: {6}<br>Download: {7}</p></html> +updateAvailable.title=Update available! +updateAvailable.message=<html><style type="text/css">.cell'{border-width:1px;border-style:solid;border-color:#000000;background-color:#FFFFFF;color:#000000;}'</style><table><tr><td></td><th class="cell">Installed</th><th class="cell">Available</th></tr><tr><th class="cell">Version</th><td class="cell">{0}</td><td class="cell">{1}</td></tr><tr><th class="cell">Developer</th><td class="cell">{2}</td><td class="cell">{3}</td></tr><tr><th class="cell">Timestamp</th><td class="cell">{4}</td><td class="cell">{5}</td></tr></table><p align="center">A newer version is available. Install update?</p><p>Note: This will only update DaimoninEditor.jar. Your arches will not be updated.</p><p>(The editor will not be useable while the update is in progress)</p><p>Source: {6}<br>Download: {7}</p></html> +updateFailedNoBackup.title=Update failed +updateFailedNoBackup.message=<html>Could not create backup, update failed.<br>Please do the following steps manually after exiting the editor:<ol><li>rename DaimoninEditor.jar to DaimoninEditor.jar.bak<li>rename DaimoninEditor.jar.tmp to DaimoninEditor.jar</ol></html> +updateFailedNoDownload.title=Update failed +updateFailedNoDownload.message=Could not use download, update failed. +updateRestart.title=Update successful +updateRestart.message=Update successful.\nI have stored a backup of the previous version under "DaimoninEditor.jar.bak".\n\nThe editor automatically exits after updating.\nYou have to restart it yourself in case you want to use it now. +updateAborted.title=Update aborted +updateAborted.message=Update aborted on your request. +updateProgress.title=Update +updateProgress=Update in progress +updateActiveVersionUnavailable.title=Update warning +updateActiveVersionUnavailable.message=I was unable to determine my version.\nI will assume that the update is newer than your current version. Modified: trunk/src/app/net/sf/gridarta/messages_de.properties =================================================================== --- trunk/src/app/net/sf/gridarta/messages_de.properties 2008-03-27 18:27:07 UTC (rev 3744) +++ trunk/src/app/net/sf/gridarta/messages_de.properties 2008-03-27 19:02:33 UTC (rev 3745) @@ -680,3 +680,31 @@ findArchetypesColumnFolder=Ort findArchetypesScrollDown.text=- findArchetypesScrollUp.text=- + + +######### +# Updater +update.text=Update... +update.mnemonic=U +update.title=Update +update.message=Nach Update suchen? +updateCloseMaps.title=Fehler beim Update +updateCloseMaps.message=Alle Dateien m\xFCssen geschlossen werden, bevor ein Update durchgef\xFChrt werden kann. +updateError.title=Fehler beim Update +updateError.message=Fehler beim Update:\n{0}\n\nBitte manuell aktualisieren. +updateUnavailable.title=Kein Update verf\xFCgbar +updateUnavailable.message=<html><style type="text/css">.cell'{border-width:1px;border-style:solid;border-color:#000000;background-color:#FFFFFF;color:#000000;}'</style><table><tr><td></td><th class="cell">Installiert</th><th class="cell">Verf\xFCgbar</th></tr><tr><th class="cell">Version</th><td class="cell">{0}</td><td class="cell">{1}</td></tr><tr><th class="cell">Entwickler</th><td class="cell">{2}</td><td class="cell">{3}</td></tr><tr><th class="cell">Datum</th><td class="cell">{4}</td><td class="cell">{5}</td></tr></table><p align="center">Keine neuere Version verf\xFCgbar.</p><p>Quelle: {6}<br>Download: {7}</p></html> +updateAvailable.title=Update verf\xFCgbar! +updateAvailable.message=<html><style type="text/css">.cell'{border-width:1px;border-style:solid;border-color:#000000;background-color:#FFFFFF;color:#000000;}'</style><table><tr><td></td><th class="cell">Installiert</th><th class="cell">Verf\xFCgbar</th></tr><tr><th class="cell">Version</th><td class="cell">{1}</td><td class="cell">{2}</td></tr><tr><th class="cell">Entwickler</th><td class="cell">{3}</td><td class="cell">{4}</td></tr><tr><th class="cell">Datum</th><td class="cell">{5}</td><td class="cell">{6}</td></tr></table><p align="center">Eine neuere Version des Editors ist verf\xFCgbar. Update installieren?</p><p>Anmerkung: Es wird nur DaimoninEditor.jar aktualisiert. Die Archetypen werden nicht aktualisiert.</p><p>(Der Editor kann nicht benutzt werden, solange die Aktualisierung l\xE4uft)</p><p>Quelle: {7}<br>Download: {8}</p></html> +updateFailedNoBackup.title=Aktualisierung fehlgeschlagen +updateFailedNoBackup.message=<html>Konnte keine Backup-Datei anlegen, Aktualisierung fehlgeschlagen.<br>Bitte f\xFChren Sie folgende Schritte manuell aus, nachdem Sie den Editor geschlossen haben:<ol><li>Nennen Sie DaimoninEditor.jar in DaimoninEditor.jar.bak um<li>Nennen Sie DaimoninEditor.jar.tmp in DaimoninEditor.jar um</ol></html> +updateFailedNoDownload.title=Aktualisierung fehlgeschlagen +updateFailedNoDownload.message=Download fehlgeschlagen, Aktualisierung fehlgeschlagen. +updateRestart.title=Aktualisierung erfolgreich +updateRestart.message=Aktualisierung erfolgreich.\nDie vorherige Version des Editors ist als "DaimoninEditor.jar.bak" verf\xFCgbar.\n\nDer Editor beendet sich jetzt automatisch.\nBitte starten Sie ihn erneut. +updateAborted.title=Aktualisierung abgebrochen +updateAborted.message=Sie haben die Aktualisierung abgebrochen. +updateProgress.title=Aktualisierung +updateProgress=Aktualisierung wird durchgef\xFChrt +updateActiveVersionUnavailable.title=Warnung +updateActiveVersionUnavailable.message=Die aktuelle Editor-Version konnte nicht ermittelt werden.\nDas verf\xFCgbare Update wird installiert. Modified: trunk/src/app/net/sf/gridarta/messages_fr.properties =================================================================== --- trunk/src/app/net/sf/gridarta/messages_fr.properties 2008-03-27 18:27:07 UTC (rev 3744) +++ trunk/src/app/net/sf/gridarta/messages_fr.properties 2008-03-27 19:02:33 UTC (rev 3745) @@ -679,3 +679,31 @@ #findArchetypesColumnFolder= findArchetypesScrollDown.text=- findArchetypesScrollUp.text=- + + +######### +# Updater +#update.text= +#update.mnemonic= +#update.title= +#updateCloseMaps.title= +#updateCloseMaps.message= +#update.message= +#updateError.title= +#updateError.message= +#updateUnavailable.title= +#updateUnavailable.message=<html><style type="text/css">.cell'{border-width:1px;border-style:solid;border-color:#000000;background-color:#FFFFFF;color:#000000;}'</style><table><tr><td></td><th class="cell">Installed</th><th class="cell">Available</th></tr><tr><th class="cell">Version</th><td class="cell">{0}</td><td class="cell">{1}</td></tr><tr><th class="cell">Developer</th><td class="cell">{2}</td><td class="cell">{3}</td></tr><tr><th class="cell">Timestamp</th><td class="cell">{4}</td><td class="cell">{5}</td></tr></table><p align= +#updateAvailable.title= +#updateAvailable.message=<html><style type="text/css">.cell'{border-width:1px;border-style:solid;border-color:#000000;background-color:#FFFFFF;color:#000000;}'</style><table><tr><td></td><th class="cell">Installed</th><th class="cell">Available</th></tr><tr><th class="cell">Version</th><td class="cell">{0}</td><td class="cell">{1}</td></tr><tr><th class="cell">Developer</th><td class="cell">{2}</td><td class="cell">{3}</td></tr><tr><th class="cell">Timestamp</th><td class="cell">{4}</td><td class="cell">{5}</td></tr></table><p align= +#updateFailedNoBackup.title= +#updateFailedNoBackup.message= +#updateFailedNoDownload.title= +#updateFailedNoDownload.message= +#updateRestart.title= +#updateRestart.message= +#updateAborted.title= +#updateAborted.message= +#updateProgress.title= +#updateProgress= +#updateActiveVersionUnavailable.title= +#updateActiveVersionUnavailable.message= Modified: trunk/src/app/net/sf/gridarta/messages_sv.properties =================================================================== --- trunk/src/app/net/sf/gridarta/messages_sv.properties 2008-03-27 18:27:07 UTC (rev 3744) +++ trunk/src/app/net/sf/gridarta/messages_sv.properties 2008-03-27 19:02:33 UTC (rev 3745) @@ -678,3 +678,31 @@ #findArchetypesColumnFolder= findArchetypesScrollDown.text=- findArchetypesScrollUp.text=- + + +######### +# Updater +update.text=Uppdatera... +update.mnemonic=U +update.title=Uppdaterar +updateCloseMaps.title=Fel i uppdatering +updateCloseMaps.message=Du m\xE5ste st\xE4nga alla \xF6ppna filer innan uppdatering. +update.message=Leta efter uppdateringar? +updateError.title=Fel under uppdatering +updateError.message=Fel under uppdatering:\n{0}\n\nVar v\xE4nlig uppdatera manuellt. +updateUnavailable.title=Ingen ny uppdatering tillg\xE4nglig +updateUnavailable.message=<html><style type="text/css">.cell'{border-width:1px;border-style:solid;border-color:#000000;background-color:#FFFFFF;color:#000000;}'</style><table><tr><td></td><th class="cell">Installerad</th><th class="cell">Tillg\xE4nglig</th></tr><tr><th class="cell">Version</th><td class="cell">{0}</td><td class="cell">{1}</td></tr><tr><th class="cell">Utvecklare</th><td class="cell">{2}</td><td class="cell">{3}</td></tr><tr><th class="cell">Datum</th><td class="cell">{4}</td><td class="cell">{5}</td></tr></table><p align="center">Ingen nyare version hittad.</p><p>K\xE4lla: {6}<br>Ladda ner: {7}</p></html> +updateAvailable.title=Uppdatering tillg\xE4nglig! +updateAvailable.message=<html><style type="text/css">.cell'{border-width:1px;border-style:solid;border-color:#000000;background-color:#FFFFFF;color:#000000;}'</style><table><tr><td></td><th class="cell">Installerad</th><th class="cell">Tillg\xE4nglig</th></tr><tr><th class="cell">Version</th><td class="cell">{0}</td><td class="cell">{1}</td></tr><tr><th class="cell">Utvecklare</th><td class="cell">{2}</td><td class="cell">{3}</td></tr><tr><th class="cell">Datum</th><td class="cell">{4}</td><td class="cell">{5}</td></tr></table><p align="center">En nyare version \xE4r tillg\xE4nglig. Installera uppdatering?</p><p>OBS: Detta uppdaterar enbart DaimoninEditor.jar. Dina arketypfiler kommer inte att uppdateras.</p><p>(Editorn kan inte anv\xE4ndas medan uppdatering p\xE5g\xE5r)</p><p>K\xE4lla: {6}<br>Nerladdning: {7}</p></html> +updateFailedNoBackup.title=Uppdatering misslyckades +updateFailedNoBackup.message=<html>Kunde inte skapa s\xE4kerhetskopia, updatering misslyckades.<br>Var v\xE4nlig utf\xF6r f\xF6ljande steg manuellt efter att avslutat editorn:<ol><li>d\xF6p om DaimoninEditor.jar till DaimoninEditor.jar.bak<li>d\xF6p om DaimoninEditor.jar.tmp till DaimoninEditor.jar</ol></html> +updateFailedNoDownload.title=Uppdatering misslyckades +updateFailedNoDownload.message=Kunde inte anv\xE4nda den nerladdade filen. +updateRestart.title=Uppdatering lyckades +updateRestart.message=Uppdatering lyckades.\nJag har lagrat en s\xE4kerhetskopia av den gamla versionen som "DaimoninEditor.jar.bak".\n\nEditorn kommer nu att avslutas automatiskt.\nDu m\xE5ste starta om den sj\xE4lv om du vill forts\xE4tta arbeta med den nya versionen. +updateAborted.title=Uppdatering avbruten +updateAborted.message=Uppdatering avbruten p\xE5 din beg\xE4ran. +#updateProgress.title= +updateProgress=Uppdatering p\xE5g\xE5r +updateActiveVersionUnavailable.title=Uppdateringsvarning +updateActiveVersionUnavailable.message=Jag kunde inte best\xE4mma min nuvarande version.\nJag kommer att anta att uppdateringen \xE4r nyare \xE4n den nuvarande installationen. Copied: trunk/src/app/net/sf/gridarta/updater/Updater.java (from rev 3743, trunk/daimonin/src/daieditor/Updater.java) =================================================================== --- trunk/src/app/net/sf/gridarta/updater/Updater.java (rev 0) +++ trunk/src/app/net/sf/gridarta/updater/Updater.java 2008-03-27 19:02:33 UTC (rev 3745) @@ -0,0 +1,323 @@ +/* + * 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.updater; + +import java.awt.Component; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.InterruptedIOException; +import java.io.OutputStream; +import java.net.Proxy; +import java.net.URL; +import java.net.URLConnection; +import java.net.UnknownHostException; +import java.util.MissingResourceException; +import java.util.PropertyResourceBundle; +import java.util.ResourceBundle; +import java.util.logging.Level; +import java.util.logging.Logger; +import java.util.prefs.Preferences; +import javax.swing.JOptionPane; +import javax.swing.ProgressMonitor; +import javax.swing.ProgressMonitorInputStream; +import net.sf.gridarta.MainControl; +import net.sf.japi.swing.ActionFactory; + +/** + * This class handles updating the map editor. + * @author <a href="mailto:ch...@ri...">Christian.Hujer</a> + * @fixme the updater fails on windows, the user is notified of this but still it isn't nice. + * The updater should be a separate application. + * @todo move the updater to JAPI + */ +public final class Updater implements Runnable { + + /** Action Factory. */ + private final ActionFactory ACTION_FACTORY; + + /** Logger. */ + private static final Logger log = Logger.getLogger("daieditor"); + + /** Preferences. */ + private static final Preferences PREFS = Preferences.userNodeForPackage(MainControl.class); + + /** Preferences key whether to automatically check for updates. */ + public static final String AUTO_CHECK_KEY = "UpdaterAutoCheck"; + + /** Preferences default value for AUTO_CHECK_KEY. */ + public static final boolean AUTO_CHECK_DEFAULT = false; + + /** Preferences key for selected update interval. */ + public static final String INTERVAL_KEY = "UpdaterInterval"; + + /** Preferences default value for INTERVAL_KEY. */ + public static final int INTERVAL_DEFAULT = 2; + + /** Preferences key for last update. */ + public static final String LAST_UPDATE_KEY = "UpdateTimestamp"; + + /** The parentComponent to show dialogs on. */ + private final Component parentComponent; + + /** The main control. */ + private final MainControl mainControl; + + /** Buffer size. */ + private static final int BUF_SIZE = 4096; + + /** The times for update calculation. */ + private static final long[] UPDATE_TIMES = { + 0L, // Every startup + 86400000L, // Once a day + 604800000L, // Once a week + 2419200000L, // Once a month + }; + + /** + * Create an Updater. + * @param parentComponent Component to show dialogs on + * @param mainControl The main control. + * @param key the action factory key + */ + private Updater(final Component parentComponent, final MainControl mainControl, final String key) { + ACTION_FACTORY = ActionFactory.getFactory(key); + this.parentComponent = parentComponent; + this.mainControl = mainControl; + if (parentComponent != null) { + parentComponent.setEnabled(false); + } + } + + /** + * Eventually perform an update during startup. + * @param parentComponent Component to show dialogs on + * @param mainControl The main control. + * @param key the action factory key + */ + public static void startup(final Component parentComponent, final MainControl mainControl, final String key) { + if (!PREFS.getBoolean(AUTO_CHECK_KEY, AUTO_CHECK_DEFAULT)) { + return; + } + final long timeDifference = UPDATE_TIMES[PREFS.getInt(INTERVAL_KEY, INTERVAL_DEFAULT)]; + final long lastUpdate = PREFS.getLong(LAST_UPDATE_KEY, 0); + if (System.currentTimeMillis() > lastUpdate + timeDifference) { + update(parentComponent, mainControl, key); + } + } + + /** + * Perform an update. + * @param parentComponent Component to show dialogs on + * @param mainControl MainControl, used for graceful exit in case the update was successful. + * @param key the action factory key + */ + public static void update(final Component parentComponent, final MainControl mainControl, final String key) { + new Thread(new Updater(parentComponent, mainControl, key)).start(); + } + + /** {@inheritDoc} */ + public void run() { + try { + final String propUrl = ACTION_FACTORY.getString("update.url"); + final InputStream pin = openStream(propUrl); + try { + final ResourceBundle updateBundle = new PropertyResourceBundle(pin); + final String downloadUrl = updateBundle.getString("update.url"); + final VersionInfo update = new VersionInfo(updateBundle, "update"); + VersionInfo active = VersionInfo.UNAVAILABLE; + try { + active = new VersionInfo(ResourceBundle.getBundle("build"), "build"); + } catch (final MissingResourceException e) { + ACTION_FACTORY.showMessageDialog(parentComponent, "updateActiveVersionUnavailable"); + } + PREFS.putLong(LAST_UPDATE_KEY, System.currentTimeMillis()); + if (active == null || update.isNewerThan(active)) { + if (askIfUserWantsUpdate(active, update, propUrl, downloadUrl)) { + downloadAndInstallUpdate(downloadUrl); + } + } else { + noNewUpdate(active, update, propUrl, downloadUrl); + } + } finally { + pin.close(); + } + } catch (final UnknownHostException e) { + ACTION_FACTORY.showMessageDialog(parentComponent, "updateError", e.getLocalizedMessage()); + } catch (final Exception e) { + log.log(Level.WARNING, "updateError", e); + ACTION_FACTORY.showMessageDialog(parentComponent, "updateError", e); + } finally { + if (parentComponent != null) { + parentComponent.setEnabled(true); + } + } + } + + /** + * Ask the user whether he wants to update. + * @param active VersionInfo of currently installed version + * @param update VersionInfo of available update version + * @param propUrl URL where properties were downloaded from + * @param downloadUrl URL where the update would be downloaded from + * @return <code>true</code> if the user chose that he wants to update, otherwise <code>false</code> + */ + private boolean askIfUserWantsUpdate(final VersionInfo active, final VersionInfo update, final String propUrl, final String downloadUrl) { + return + ACTION_FACTORY.showConfirmDialog(parentComponent, JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, "updateAvailable", + active.version, update.version, + active.developer, update.developer, + active.tstamp, update.tstamp, + propUrl, downloadUrl + ) == JOptionPane.YES_OPTION; + } + + /** + * Tell the user there is no update. + * @param active VersionInfo of currently installed version + * @param update VersionInfo of available update version + * @param propUrl URL where properties were downloaded from + * @param downloadUrl URL where the update would be downloaded from + */ + private void noNewUpdate(final VersionInfo active, final VersionInfo update, final String propUrl, final String downloadUrl) { + ACTION_FACTORY.showMessageDialog(parentComponent, "updateUnavailable", + active.version, update.version, + active.developer, update.developer, + active.tstamp, update.tstamp, + propUrl, downloadUrl + ); + } + + /** + * Download and install an update. + * @param url URL to get update from + */ + private void downloadAndInstallUpdate(final String url) { + final File download = new File("DaimoninEditor.jar.tmp"); // TODO: print error message if file already exists + final File backup = new File("DaimoninEditor.jar.bak"); + final File orig = new File("DaimoninEditor.jar"); + try { + final InputStream in = openStream(url); + try { + final OutputStream out = new FileOutputStream(download); + try { + final byte[] buf = new byte[BUF_SIZE]; + for (int bytesRead; (bytesRead = in.read(buf)) != -1; out.write(buf, 0, bytesRead)) { + ; + } + out.close(); + if (/* !backup.delete() || */ !orig.renameTo(backup)) { + ACTION_FACTORY.showMessageDialog(parentComponent, "updateFailedNoBackup"); + } else if (!download.renameTo(orig)) { + backup.renameTo(orig); + ACTION_FACTORY.showMessageDialog(parentComponent, "updateFailedNoDownload"); + } else { + ACTION_FACTORY.showMessageDialog(parentComponent, "updateRestart"); + mainControl.doExit(); + } + } finally { + out.close(); + } + } finally { + in.close(); + } + } catch (final InterruptedIOException e) { + ACTION_FACTORY.showMessageDialog(parentComponent, "updateAborted"); + } catch (final Exception e) { + log.log(Level.WARNING, "updateError", e); + ACTION_FACTORY.showMessageDialog(parentComponent, "updateError", e); + } + } + + /** + * Open an InputStream on a URL. + * @param url URL to open InputStream on + * @return InputStream for URL + * @throws IOException in case of I/O problems + */ + // The stream is closed by caller + @SuppressWarnings({"IOResourceOpenedButNotSafelyClosed"}) + private InputStream openStream(final String url) throws IOException { + final URLConnection con = new URL(url).openConnection(Proxy.NO_PROXY); + final ProgressMonitorInputStream stream = new ProgressMonitorInputStream(parentComponent, ACTION_FACTORY.getString("updateProgress.title"), con.getInputStream()); + final ProgressMonitor monitor = stream.getProgressMonitor(); + monitor.setMaximum(con.getContentLength()); + monitor.setNote(ACTION_FACTORY.getString("updateProgress")); + monitor.setMillisToDecideToPopup(10); + monitor.setMillisToPopup(10); + return stream; + } + + /** Class for holding version information and quickly comparing it. */ + private static final class VersionInfo { + + /** Update information: Version of update version, usually the build number. */ + private final String version; + + /** Update information: Time stamp of update version. */ + private final String tstamp; + + /** Update information: Developer that created the update version. */ + private final String developer; + + /** Special Version "unavailable". */ + private static final VersionInfo UNAVAILABLE = new VersionInfo(); + + /** Private constructor used for unavailable versions. */ + private VersionInfo() { + this("unavailable", "unavailable", "unavailable"); + } + + /** + * Private constructor to map the strings. + * @param version Version + * @param tstamp Timestamp + * @param developer Developer + */ + private VersionInfo(final String version, final String tstamp, final String developer) { + this.version = version; + this.tstamp = tstamp; + this.developer = developer; + } + + /** + * Create update information from a ResourceBundle. + * The ResourceBundle should have Strings for <var>prefix</var> + <code>.number</code>, <code>.tstamp</code> and <code>.developer</code>. + * @param bundle ResourceBundle to create update information from + * @param prefix Prefix for update information within the resource bundle + */ + VersionInfo(final ResourceBundle bundle, final String prefix) { + this(bundle.getString(prefix + ".number"), bundle.getString(prefix + ".tstamp"), bundle.getString(prefix + ".developer")); + } + + /** + * Check whether this version is newer than another version. + * @param other Other version information to compare to + * @return <code>true</code> if this versionis newer than <var>other</var>, otherwise <code>false</code> + */ + @SuppressWarnings({"ObjectEquality"}) + boolean isNewerThan(final VersionInfo other) { + return this != UNAVAILABLE && (other == UNAVAILABLE || tstamp.compareTo(other.tstamp) > 0); + } + + } // class VersionInfo + +} // class Updater This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-03-27 20:55:40
|
Revision: 3750 http://gridarta.svn.sourceforge.net/gridarta/?rev=3750&view=rev Author: akirschbaum Date: 2008-03-27 13:55:05 -0700 (Thu, 27 Mar 2008) Log Message: ----------- Split Updater into Updater+UpdaterManager. Modified Paths: -------------- trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/gui/prefs/UpdatePrefs.java trunk/src/app/net/sf/gridarta/updater/Updater.java Added Paths: ----------- trunk/src/app/net/sf/gridarta/updater/UpdaterManager.java Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-03-27 20:38:09 UTC (rev 3749) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-03-27 20:55:05 UTC (rev 3750) @@ -111,7 +111,7 @@ import net.sf.gridarta.textedit.scripteditor.ScriptEditControl; import net.sf.gridarta.treasurelist.CFTreasureListTree; import net.sf.gridarta.treasurelist.TreasureLocation; -import net.sf.gridarta.updater.Updater; +import net.sf.gridarta.updater.UpdaterManager; import net.sf.japi.swing.ActionFactory; import net.sf.japi.swing.ActionMethod; import net.sf.japi.swing.misc.Progress; @@ -316,7 +316,7 @@ mapManagerActions = new MapManagerActions<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(getMapManager()); mainView = new CMainView(this, getMapManager(), mapManagerActions.getCloseAllAction()); undoControl = new UndoControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(getMapManager()); - Updater.startup(mainView, this, "daieditor"); + UpdaterManager.startup(mainView, this, "daieditor"); readGlobalSettings(); @@ -1150,7 +1150,7 @@ if (getMapManager().hasOpenedMap()) { ACTION_FACTORY.showMessageDialog(mainView, "updateCloseMaps"); } else { - Updater.update(mainView, this, "daieditor"); + UpdaterManager.update(mainView, this, "daieditor"); } } Modified: trunk/daimonin/src/daieditor/gui/prefs/UpdatePrefs.java =================================================================== --- trunk/daimonin/src/daieditor/gui/prefs/UpdatePrefs.java 2008-03-27 20:38:09 UTC (rev 3749) +++ trunk/daimonin/src/daieditor/gui/prefs/UpdatePrefs.java 2008-03-27 20:55:05 UTC (rev 3750) @@ -29,7 +29,7 @@ import javax.swing.border.TitledBorder; import net.sf.gridarta.MainControl; import net.sf.gridarta.gui.GUIConstants; -import net.sf.gridarta.updater.Updater; +import net.sf.gridarta.updater.UpdaterManager; import net.sf.japi.swing.ActionFactory; import net.sf.japi.swing.prefs.AbstractPrefs; @@ -75,27 +75,27 @@ /** {@inheritDoc} */ public void apply() { - PREFS.putBoolean(Updater.AUTO_CHECK_KEY, autoUpdate.isSelected()); - PREFS.putInt(Updater.INTERVAL_KEY, interval.getSelectedIndex()); + PREFS.putBoolean(UpdaterManager.AUTO_CHECK_KEY, autoUpdate.isSelected()); + PREFS.putInt(UpdaterManager.INTERVAL_KEY, interval.getSelectedIndex()); } /** {@inheritDoc} */ public void revert() { - autoUpdate.setSelected(PREFS.getBoolean(Updater.AUTO_CHECK_KEY, Updater.AUTO_CHECK_DEFAULT)); - interval.setSelectedIndex(PREFS.getInt(Updater.INTERVAL_KEY, Updater.INTERVAL_DEFAULT)); + autoUpdate.setSelected(PREFS.getBoolean(UpdaterManager.AUTO_CHECK_KEY, UpdaterManager.AUTO_CHECK_DEFAULT)); + interval.setSelectedIndex(PREFS.getInt(UpdaterManager.INTERVAL_KEY, UpdaterManager.INTERVAL_DEFAULT)); } /** {@inheritDoc} */ public void defaults() { - autoUpdate.setSelected(Updater.AUTO_CHECK_DEFAULT); - interval.setSelectedIndex(Updater.INTERVAL_DEFAULT); + autoUpdate.setSelected(UpdaterManager.AUTO_CHECK_DEFAULT); + interval.setSelectedIndex(UpdaterManager.INTERVAL_DEFAULT); } /** {@inheritDoc} */ public boolean isChanged() { return !( - autoUpdate.isSelected() == PREFS.getBoolean(Updater.AUTO_CHECK_KEY, Updater.AUTO_CHECK_DEFAULT) - && interval.getSelectedIndex() == PREFS.getInt(Updater.INTERVAL_KEY, Updater.INTERVAL_DEFAULT) + autoUpdate.isSelected() == PREFS.getBoolean(UpdaterManager.AUTO_CHECK_KEY, UpdaterManager.AUTO_CHECK_DEFAULT) + && interval.getSelectedIndex() == PREFS.getInt(UpdaterManager.INTERVAL_KEY, UpdaterManager.INTERVAL_DEFAULT) ); } @@ -107,7 +107,7 @@ final Box updatePanel = Box.createVerticalBox(); updatePanel.setBorder(createTitledBorder("optionsUpdate")); autoUpdate = new JCheckBox(ACTION_FACTORY.createToggle(false, "autoUpdate", this)); - autoUpdate.setSelected(PREFS.getBoolean(Updater.AUTO_CHECK_KEY, Updater.AUTO_CHECK_DEFAULT)); + autoUpdate.setSelected(PREFS.getBoolean(UpdaterManager.AUTO_CHECK_KEY, UpdaterManager.AUTO_CHECK_DEFAULT)); updatePanel.add(autoUpdate); updatePanel.add(createComboBox()); return updatePanel; @@ -142,8 +142,8 @@ }; interval = new JComboBox(items); interval.setEditable(false); - interval.setSelectedIndex(PREFS.getInt(Updater.INTERVAL_KEY, Updater.INTERVAL_DEFAULT)); - interval.setEnabled(PREFS.getBoolean(Updater.AUTO_CHECK_KEY, Updater.AUTO_CHECK_DEFAULT)); + interval.setSelectedIndex(PREFS.getInt(UpdaterManager.INTERVAL_KEY, UpdaterManager.INTERVAL_DEFAULT)); + interval.setEnabled(PREFS.getBoolean(UpdaterManager.AUTO_CHECK_KEY, UpdaterManager.AUTO_CHECK_DEFAULT)); return interval; } Modified: trunk/src/app/net/sf/gridarta/updater/Updater.java =================================================================== --- trunk/src/app/net/sf/gridarta/updater/Updater.java 2008-03-27 20:38:09 UTC (rev 3749) +++ trunk/src/app/net/sf/gridarta/updater/Updater.java 2008-03-27 20:55:05 UTC (rev 3750) @@ -59,18 +59,6 @@ /** Preferences. */ private static final Preferences PREFS = Preferences.userNodeForPackage(MainControl.class); - /** Preferences key whether to automatically check for updates. */ - public static final String AUTO_CHECK_KEY = "UpdaterAutoCheck"; - - /** Preferences default value for AUTO_CHECK_KEY. */ - public static final boolean AUTO_CHECK_DEFAULT = false; - - /** Preferences key for selected update interval. */ - public static final String INTERVAL_KEY = "UpdaterInterval"; - - /** Preferences default value for INTERVAL_KEY. */ - public static final int INTERVAL_DEFAULT = 2; - /** Preferences key for last update. */ public static final String LAST_UPDATE_KEY = "UpdateTimestamp"; @@ -83,21 +71,13 @@ /** Buffer size. */ private static final int BUF_SIZE = 4096; - /** The times for update calculation. */ - private static final long[] UPDATE_TIMES = { - 0L, // Every startup - 86400000L, // Once a day - 604800000L, // Once a week - 2419200000L, // Once a month - }; - /** * Create an Updater. * @param parentComponent Component to show dialogs on * @param mainControl The main control. * @param key the action factory key */ - private Updater(final Component parentComponent, final MainControl mainControl, final String key) { + public Updater(final Component parentComponent, final MainControl mainControl, final String key) { ACTION_FACTORY = ActionFactory.getFactory(key); this.parentComponent = parentComponent; this.mainControl = mainControl; @@ -106,33 +86,6 @@ } } - /** - * Eventually perform an update during startup. - * @param parentComponent Component to show dialogs on - * @param mainControl The main control. - * @param key the action factory key - */ - public static void startup(final Component parentComponent, final MainControl mainControl, final String key) { - if (!PREFS.getBoolean(AUTO_CHECK_KEY, AUTO_CHECK_DEFAULT)) { - return; - } - final long timeDifference = UPDATE_TIMES[PREFS.getInt(INTERVAL_KEY, INTERVAL_DEFAULT)]; - final long lastUpdate = PREFS.getLong(LAST_UPDATE_KEY, 0); - if (System.currentTimeMillis() > lastUpdate + timeDifference) { - update(parentComponent, mainControl, key); - } - } - - /** - * Perform an update. - * @param parentComponent Component to show dialogs on - * @param mainControl MainControl, used for graceful exit in case the update was successful. - * @param key the action factory key - */ - public static void update(final Component parentComponent, final MainControl mainControl, final String key) { - new Thread(new Updater(parentComponent, mainControl, key)).start(); - } - /** {@inheritDoc} */ public void run() { try { Copied: trunk/src/app/net/sf/gridarta/updater/UpdaterManager.java (from rev 3749, trunk/src/app/net/sf/gridarta/updater/Updater.java) =================================================================== --- trunk/src/app/net/sf/gridarta/updater/UpdaterManager.java (rev 0) +++ trunk/src/app/net/sf/gridarta/updater/UpdaterManager.java 2008-03-27 20:55:05 UTC (rev 3750) @@ -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.updater; + +import java.awt.Component; +import java.util.prefs.Preferences; +import net.sf.gridarta.MainControl; + +/** + * This class handles updating the map editor. + * @author <a href="mailto:ch...@ri...">Christian.Hujer</a> + */ +public final class UpdaterManager { + + /** Preferences. */ + private static final Preferences PREFS = Preferences.userNodeForPackage(MainControl.class); + + /** Preferences key whether to automatically check for updates. */ + public static final String AUTO_CHECK_KEY = "UpdaterAutoCheck"; + + /** Preferences default value for AUTO_CHECK_KEY. */ + public static final boolean AUTO_CHECK_DEFAULT = false; + + /** Preferences key for selected update interval. */ + public static final String INTERVAL_KEY = "UpdaterInterval"; + + /** Preferences default value for INTERVAL_KEY. */ + public static final int INTERVAL_DEFAULT = 2; + + /** The times for update calculation. */ + private static final long[] UPDATE_TIMES = { + 0L, // Every startup + 86400000L, // Once a day + 604800000L, // Once a week + 2419200000L, // Once a month + }; + + private UpdaterManager() { + } + + /** + * Eventually perform an update during startup. + * @param parentComponent Component to show dialogs on + * @param mainControl The main control. + * @param key the action factory key + */ + public static void startup(final Component parentComponent, final MainControl mainControl, final String key) { + if (!PREFS.getBoolean(AUTO_CHECK_KEY, AUTO_CHECK_DEFAULT)) { + return; + } + final long timeDifference = UPDATE_TIMES[PREFS.getInt(INTERVAL_KEY, INTERVAL_DEFAULT)]; + final long lastUpdate = PREFS.getLong(Updater.LAST_UPDATE_KEY, 0); + if (System.currentTimeMillis() > lastUpdate + timeDifference) { + update(parentComponent, mainControl, key); + } + } + + /** + * Perform an update. + * @param parentComponent Component to show dialogs on + * @param mainControl MainControl, used for graceful exit in case the update was successful. + * @param key the action factory key + */ + public static void update(final Component parentComponent, final MainControl mainControl, final String key) { + new Thread(new Updater(parentComponent, mainControl, key)).start(); + } + +} // class UpdaterManager This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-03-27 21:24:44
|
Revision: 3751 http://gridarta.svn.sourceforge.net/gridarta/?rev=3751&view=rev Author: akirschbaum Date: 2008-03-27 14:24:46 -0700 (Thu, 27 Mar 2008) Log Message: ----------- Convert UpdaterManager from utility class to 'normal' class. Modified Paths: -------------- trunk/daimonin/src/daieditor/CMainControl.java trunk/src/app/net/sf/gridarta/AbstractMainControl.java trunk/src/app/net/sf/gridarta/updater/UpdaterManager.java Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-03-27 20:55:05 UTC (rev 3750) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-03-27 21:24:46 UTC (rev 3751) @@ -316,7 +316,8 @@ mapManagerActions = new MapManagerActions<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(getMapManager()); mainView = new CMainView(this, getMapManager(), mapManagerActions.getCloseAllAction()); undoControl = new UndoControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(getMapManager()); - UpdaterManager.startup(mainView, this, "daieditor"); + updaterManager = new UpdaterManager("daieditor", this, mainView); + updaterManager.startup(); readGlobalSettings(); @@ -1150,7 +1151,7 @@ if (getMapManager().hasOpenedMap()) { ACTION_FACTORY.showMessageDialog(mainView, "updateCloseMaps"); } else { - UpdaterManager.update(mainView, this, "daieditor"); + updaterManager.update(); } } Modified: trunk/src/app/net/sf/gridarta/AbstractMainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2008-03-27 20:55:05 UTC (rev 3750) +++ trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2008-03-27 21:24:46 UTC (rev 3751) @@ -32,6 +32,7 @@ import net.sf.gridarta.io.PathManager; import net.sf.gridarta.map.MapArchObject; import net.sf.gridarta.map.MapControl; +import net.sf.gridarta.updater.UpdaterManager; import net.sf.japi.swing.ActionFactory; import net.sf.japi.util.filter.file.EndingFileFilter; import org.jetbrains.annotations.NotNull; @@ -90,6 +91,9 @@ /** The map manager. */ private final MapManager<G, A, R, C, V> mapManager; + /** The updater instance. */ + protected UpdaterManager updaterManager = null; + /** * Creates a new instance. * @param gridartaObjectsFactory the gridarta objects factory Modified: trunk/src/app/net/sf/gridarta/updater/UpdaterManager.java =================================================================== --- trunk/src/app/net/sf/gridarta/updater/UpdaterManager.java 2008-03-27 20:55:05 UTC (rev 3750) +++ trunk/src/app/net/sf/gridarta/updater/UpdaterManager.java 2008-03-27 21:24:46 UTC (rev 3751) @@ -52,33 +52,51 @@ 2419200000L, // Once a month }; - private UpdaterManager() { + /** + * The action factory key. + */ + private final String key; + + /** + * The main control. + */ + private final MainControl mainControl; + + /** + * The component to show dialogs on. + */ + private final Component parentComponent; + + /** + * Creates a new instance. + * @param key the action factory key + * @param mainControl The main control. + * @param parentComponent Component to show dialogs on + */ + public UpdaterManager(final String key, final MainControl mainControl, final Component parentComponent) { + this.key = key; + this.mainControl = mainControl; + this.parentComponent = parentComponent; } /** * Eventually perform an update during startup. - * @param parentComponent Component to show dialogs on - * @param mainControl The main control. - * @param key the action factory key */ - public static void startup(final Component parentComponent, final MainControl mainControl, final String key) { + public void startup() { if (!PREFS.getBoolean(AUTO_CHECK_KEY, AUTO_CHECK_DEFAULT)) { return; } final long timeDifference = UPDATE_TIMES[PREFS.getInt(INTERVAL_KEY, INTERVAL_DEFAULT)]; final long lastUpdate = PREFS.getLong(Updater.LAST_UPDATE_KEY, 0); if (System.currentTimeMillis() > lastUpdate + timeDifference) { - update(parentComponent, mainControl, key); + update(); } } /** * Perform an update. - * @param parentComponent Component to show dialogs on - * @param mainControl MainControl, used for graceful exit in case the update was successful. - * @param key the action factory key */ - public static void update(final Component parentComponent, final MainControl mainControl, final String key) { + public void update() { new Thread(new Updater(parentComponent, mainControl, key)).start(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |