You can subscribe to this list here.
2006 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(103) |
Jun
(121) |
Jul
(16) |
Aug
(67) |
Sep
(126) |
Oct
(161) |
Nov
(164) |
Dec
(588) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2007 |
Jan
(394) |
Feb
(181) |
Mar
(131) |
Apr
(180) |
May
(255) |
Jun
(11) |
Jul
(79) |
Aug
(70) |
Sep
(274) |
Oct
(138) |
Nov
(195) |
Dec
(8) |
2008 |
Jan
(3) |
Feb
(142) |
Mar
(162) |
Apr
(124) |
May
(148) |
Jun
(157) |
Jul
(425) |
Aug
(373) |
Sep
(264) |
Oct
(315) |
Nov
(225) |
Dec
(6) |
2009 |
Jan
(67) |
Feb
(78) |
Mar
(279) |
Apr
(294) |
May
(92) |
Jun
(65) |
Jul
(134) |
Aug
(41) |
Sep
(138) |
Oct
(125) |
Nov
(126) |
Dec
(122) |
2010 |
Jan
(15) |
Feb
(48) |
Mar
(9) |
Apr
(195) |
May
(373) |
Jun
(507) |
Jul
(42) |
Aug
(16) |
Sep
(38) |
Oct
(81) |
Nov
(64) |
Dec
(18) |
2011 |
Jan
(13) |
Feb
(12) |
Mar
(39) |
Apr
(1) |
May
(2) |
Jun
(27) |
Jul
(27) |
Aug
(31) |
Sep
(14) |
Oct
(102) |
Nov
(20) |
Dec
(37) |
2012 |
Jan
(22) |
Feb
(1) |
Mar
(1) |
Apr
(2) |
May
(2) |
Jun
(18) |
Jul
(6) |
Aug
(1) |
Sep
(1) |
Oct
|
Nov
|
Dec
|
2013 |
Jan
(1) |
Feb
(2) |
Mar
(1) |
Apr
(1) |
May
(47) |
Jun
(7) |
Jul
(107) |
Aug
|
Sep
|
Oct
(112) |
Nov
(31) |
Dec
(17) |
2014 |
Jan
(29) |
Feb
(111) |
Mar
(34) |
Apr
|
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(2) |
Nov
(18) |
Dec
(10) |
From: <aki...@us...> - 2010-06-02 07:20:47
|
Revision: 8060 http://gridarta.svn.sourceforge.net/gridarta/?rev=8060&view=rev Author: akirschbaum Date: 2010-06-02 07:20:40 +0000 (Wed, 02 Jun 2010) Log Message: ----------- Fix archetype collection: do not drop mpart_id attributes for tail parts. Modified Paths: -------------- trunk/atrinik/ChangeLog trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/model/archetype/ArchetypeParser.java trunk/build.xml trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/model/archetype/ArchetypeParser.java trunk/daimonin/ChangeLog trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/model/archetype/ArchetypeParser.java trunk/src/app/net/sf/gridarta/model/archetype/AbstractArchetypeParser.java trunk/src/test/net/sf/gridarta/model/archetype/ArchetypeParserTest.java trunk/src/test/net/sf/gridarta/model/archetype/TestArchetypeParser.java Added Paths: ----------- trunk/atrinik/src/test/net/sf/gridarta/var/atrinik/model/archetype/ trunk/atrinik/src/test/net/sf/gridarta/var/atrinik/model/archetype/ArchetypeParserTest.java trunk/src/test/net/sf/gridarta/model/archetype/AbstractArchetypeParserTest.java trunk/src/test/net/sf/gridarta/var/ trunk/src/test/net/sf/gridarta/var/atrinik/ trunk/src/test/net/sf/gridarta/var/atrinik/model/ trunk/src/test/net/sf/gridarta/var/atrinik/model/archetype/ Modified: trunk/atrinik/ChangeLog =================================================================== --- trunk/atrinik/ChangeLog 2010-05-31 17:53:34 UTC (rev 8059) +++ trunk/atrinik/ChangeLog 2010-06-02 07:20:40 UTC (rev 8060) @@ -1,3 +1,8 @@ +2010-06-02 Andreas Kirschbaum + + * Fix archetype collection: do not drop mpart_id attributes for + tail parts. + 2010-05-30 Alex Tokar * Update map header flags in map properties dialog to be in-sync Modified: trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/model/archetype/ArchetypeParser.java =================================================================== --- trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/model/archetype/ArchetypeParser.java 2010-05-31 17:53:34 UTC (rev 8059) +++ trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/model/archetype/ArchetypeParser.java 2010-06-02 07:20:40 UTC (rev 8060) @@ -130,11 +130,10 @@ * {@inheritDoc} */ @Override - protected void finishParseArchetypePart(@NotNull final Archetype firstArch, @NotNull final Archetype archetype, @NotNull final ErrorViewCollector errorViewCollector) { - // set or check mpart_nr - if (firstArch.getMultiRefCount() == 2) { - firstArch.setMultiShapeID(multiShapeID); - } else if (multiShapeID != firstArch.getMultiShapeID()) { + protected void finishParseArchetypePart(@Nullable final Archetype firstArch, @NotNull final Archetype archetype, @NotNull final ErrorViewCollector errorViewCollector) { + // set or check mpart_id + archetype.setMultiShapeID(multiShapeID); + if (firstArch != null && multiShapeID != firstArch.getMultiShapeID()) { errorViewCollector.addWarning(ErrorViewCategory.ARCHETYPE_INVALID, ACTION_BUILDER.format("logDefArchWithInvalidMpartNr", archetype.getArchetypeName(), firstArch.getArchetypeName(), Integer.toString(multiShapeID), Integer.toString(firstArch.getMultiShapeID()))); } } Added: trunk/atrinik/src/test/net/sf/gridarta/var/atrinik/model/archetype/ArchetypeParserTest.java =================================================================== --- trunk/atrinik/src/test/net/sf/gridarta/var/atrinik/model/archetype/ArchetypeParserTest.java (rev 0) +++ trunk/atrinik/src/test/net/sf/gridarta/var/atrinik/model/archetype/ArchetypeParserTest.java 2010-06-02 07:20:40 UTC (rev 8060) @@ -0,0 +1,131 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2010 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.var.atrinik.model.archetype; + +import java.io.IOException; +import java.util.regex.Pattern; +import net.sf.gridarta.model.anim.AnimationObjects; +import net.sf.gridarta.model.anim.DefaultAnimationObjects; +import net.sf.gridarta.model.archetype.AbstractArchetypeBuilder; +import net.sf.gridarta.model.archetype.AbstractArchetypeParser; +import net.sf.gridarta.model.archetype.AbstractArchetypeParserTest; +import net.sf.gridarta.model.archetype.UndefinedArchetypeException; +import net.sf.gridarta.model.archetypetype.ArchetypeTypeSet; +import net.sf.gridarta.model.face.ArchFaceProvider; +import net.sf.gridarta.model.face.DefaultFaceObjects; +import net.sf.gridarta.model.face.FaceObjectProviders; +import net.sf.gridarta.model.face.FaceObjects; +import net.sf.gridarta.model.gameobject.IsoMapSquareInfo; +import net.sf.gridarta.model.gameobject.MultiPositionData; +import net.sf.gridarta.utils.GUIUtils; +import net.sf.gridarta.utils.SystemIcons; +import net.sf.gridarta.var.atrinik.model.gameobject.DefaultGameObjectFactory; +import net.sf.gridarta.var.atrinik.model.gameobject.GameObject; +import net.sf.gridarta.var.atrinik.model.maparchobject.MapArchObject; +import net.sf.japi.swing.action.ActionBuilder; +import net.sf.japi.swing.action.ActionBuilderFactory; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.Test; + +/** + * Regression tests for {@link ArchetypeParser}. + * @author Andreas Kirschbaum + */ +public class ArchetypeParserTest extends AbstractArchetypeParserTest<GameObject, MapArchObject, Archetype> { + + /** + * The loaded archetypes. + */ + @Nullable + private ArchetypeSet archetypeSet = null; + + /** + * Checks that mpart_id fields are parsed correctly. + * @throws IOException if the test fails + * @throws UndefinedArchetypeException if the test fails + */ + @Test + public void testMpartIdOk() throws IOException, UndefinedArchetypeException { + check("Object head\nmpart_id 1\nend\nMore\nObject tail\nmpart_id 1\nend\n", false, false, 2); + Assert.assertEquals(1, getArchetypeSet().getArchetype("head").getMultiShapeID()); + Assert.assertEquals(1, getArchetypeSet().getArchetype("tail").getMultiShapeID()); + } + + /** + * Checks that mpart_id fields are parsed correctly. + * @throws IOException if the test fails + * @throws UndefinedArchetypeException if the test fails + */ + @Test + public void testMpartIdInconsistent() throws IOException, UndefinedArchetypeException { + check("Object head\nmpart_id 1\nend\nMore\nObject tail\nmpart_id 2\nend\n", false, true, 2); + Assert.assertEquals(1, getArchetypeSet().getArchetype("head").getMultiShapeID()); + Assert.assertEquals(2, getArchetypeSet().getArchetype("tail").getMultiShapeID()); + } + + /** + * Initializes the test. + */ + @BeforeClass + public static void setUp() { + final ActionBuilder actionBuilder = ActionBuilderFactory.getInstance().getActionBuilder("net.sf.gridarta"); + actionBuilder.addParent(ActionBuilderFactory.getInstance().getActionBuilder("net.sf.gridarta.var.atrinik")); + } + + /** + * {@inheritDoc} + */ + @NotNull + @Override + protected AbstractArchetypeParser<GameObject, MapArchObject, Archetype, ? extends AbstractArchetypeBuilder<GameObject, MapArchObject, Archetype>> newArchetypeParser() { + final ArchFaceProvider archFaceProvider = new ArchFaceProvider(); + final FaceObjects faceObjects = new DefaultFaceObjects("png", "facetree", Pattern.compile(".*"), "facetree.output", archFaceProvider); + final GUIUtils guiUtils = new GUIUtils(); + final SystemIcons systemIcons = new SystemIcons(guiUtils); + final FaceObjectProviders faceObjectProviders = new FaceObjectProviders(0, faceObjects, systemIcons); + final AnimationObjects animationObjects = new DefaultAnimationObjects("animtree"); + final ArchetypeTypeSet archetypeTypeSet = new ArchetypeTypeSet(); + final DefaultGameObjectFactory gameObjectFactory = new DefaultGameObjectFactory(faceObjectProviders, animationObjects, archetypeTypeSet); + final DefaultArchetypeFactory archetypeFactory = new DefaultArchetypeFactory(faceObjectProviders, animationObjects); + archetypeSet = new ArchetypeSet(archetypeFactory); + archetypeSet.setLoadedFromArchive(true); + assert archetypeSet != null; + final IsoMapSquareInfo isoMapSquareInfo = new IsoMapSquareInfo(1, 1, 1, 1); + final MultiPositionData multiPositionData = new MultiPositionData(isoMapSquareInfo); + assert archetypeSet != null; + return new ArchetypeParser(animationObjects, archetypeSet, gameObjectFactory, multiPositionData); + } + + /** + * {@inheritDoc} + */ + @NotNull + @Override + protected ArchetypeSet getArchetypeSet() { + if (archetypeSet == null) { + throw new IllegalStateException(); + } + return archetypeSet; + } + +} // class ArchetypeParserTest Property changes on: trunk/atrinik/src/test/net/sf/gridarta/var/atrinik/model/archetype/ArchetypeParserTest.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF Modified: trunk/build.xml =================================================================== --- trunk/build.xml 2010-05-31 17:53:34 UTC (rev 8059) +++ trunk/build.xml 2010-06-02 07:20:40 UTC (rev 8060) @@ -458,9 +458,13 @@ <copy todir="classes/test"> <fileset dir="resource" includes="**/*.properties,**/*.dtd"/> <fileset dir="src/test" includes="**/*.properties,**/*.testdata"/> + <fileset dir="src/app" includes="**/*.properties,**/*.testdata"/> <fileset dir="atrinik/src/test" includes="**/*.properties,**/*.testdata"/> + <fileset dir="atrinik/src/app" includes="**/*.properties,**/*.testdata"/> <fileset dir="crossfire/src/test" includes="**/*.properties,**/*.testdata"/> + <fileset dir="crossfire/src/app" includes="**/*.properties,**/*.testdata"/> <fileset dir="daimonin/src/test" includes="**/*.properties,**/*.testdata"/> + <fileset dir="daimonin/src/app" includes="**/*.properties,**/*.testdata"/> </copy> <junit printsummary="no" haltonfailure="yes"> <classpath> Modified: trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/model/archetype/ArchetypeParser.java =================================================================== --- trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/model/archetype/ArchetypeParser.java 2010-05-31 17:53:34 UTC (rev 8059) +++ trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/model/archetype/ArchetypeParser.java 2010-06-02 07:20:40 UTC (rev 8060) @@ -154,7 +154,7 @@ * {@inheritDoc} */ @Override - protected void finishParseArchetypePart(@NotNull final Archetype firstArch, @NotNull final Archetype archetype, @NotNull final ErrorViewCollector errorViewCollector) { + protected void finishParseArchetypePart(@Nullable final Archetype firstArch, @NotNull final Archetype archetype, @NotNull final ErrorViewCollector errorViewCollector) { } /** Modified: trunk/daimonin/ChangeLog =================================================================== --- trunk/daimonin/ChangeLog 2010-05-31 17:53:34 UTC (rev 8059) +++ trunk/daimonin/ChangeLog 2010-06-02 07:20:40 UTC (rev 8060) @@ -1,3 +1,8 @@ +2010-06-02 Andreas Kirschbaum + + * Fix archetype collection: do not drop mpart_id attributes for + tail parts. + 2010-05-29 Andreas Kirschbaum * Fix incorrect resource path names on Windows machines. Modified: trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/model/archetype/ArchetypeParser.java =================================================================== --- trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/model/archetype/ArchetypeParser.java 2010-05-31 17:53:34 UTC (rev 8059) +++ trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/model/archetype/ArchetypeParser.java 2010-06-02 07:20:40 UTC (rev 8060) @@ -129,11 +129,10 @@ * {@inheritDoc} */ @Override - protected void finishParseArchetypePart(@NotNull final Archetype firstArch, @NotNull final Archetype archetype, @NotNull final ErrorViewCollector errorViewCollector) { - // set or check mpart_nr - if (firstArch.getMultiRefCount() == 2) { - firstArch.setMultiShapeID(multiShapeID); - } else if (multiShapeID != firstArch.getMultiShapeID()) { + protected void finishParseArchetypePart(@Nullable final Archetype firstArch, @NotNull final Archetype archetype, @NotNull final ErrorViewCollector errorViewCollector) { + // set or check mpart_id + archetype.setMultiShapeID(multiShapeID); + if (firstArch != null && multiShapeID != firstArch.getMultiShapeID()) { errorViewCollector.addWarning(ErrorViewCategory.ARCHETYPE_INVALID, ACTION_BUILDER.format("logDefArchWithInvalidMpartNr", archetype.getArchetypeName(), firstArch.getArchetypeName(), Integer.toString(multiShapeID), Integer.toString(firstArch.getMultiShapeID()))); } } Modified: trunk/src/app/net/sf/gridarta/model/archetype/AbstractArchetypeParser.java =================================================================== --- trunk/src/app/net/sf/gridarta/model/archetype/AbstractArchetypeParser.java 2010-05-31 17:53:34 UTC (rev 8059) +++ trunk/src/app/net/sf/gridarta/model/archetype/AbstractArchetypeParser.java 2010-06-02 07:20:40 UTC (rev 8060) @@ -198,7 +198,6 @@ if (firstArch != null) { firstArch.addTailPart(archetype); - finishParseArchetypePart(firstArch, archetype, errorViewCollector); } else if (addToPanel(isInternPath, editorFolder, archetype)) { final String panel; final String folder; @@ -217,6 +216,7 @@ } else { archetype.setEditorFolder(GameObject.EDITOR_FOLDER_INTERN); } + finishParseArchetypePart(firstArch, archetype, errorViewCollector); try { archetypeSet.addArchetype(archetype); } catch (final DuplicateArchetypeException ex) { @@ -338,12 +338,13 @@ protected abstract boolean processLine(@NotNull final BufferedReader in, @NotNull final String line, @NotNull final String line2, @NotNull final B archetypeBuilder, @NotNull final ErrorViewCollector errorViewCollector, @NotNull final List<G> invObjects) throws IOException; /** - * Called after the "end" line of a tail part has been read. - * @param firstArch the head part + * Called after the "end" line of a part has been read. + * @param firstArch the head part or <code>null</code> if + * <code>archetype</code> is the head part * @param archetype the tail part * @param errorViewCollector the error view collector for reporting errors */ - protected abstract void finishParseArchetypePart(@NotNull final R firstArch, @NotNull final R archetype, @NotNull final ErrorViewCollector errorViewCollector); + protected abstract void finishParseArchetypePart(@Nullable final R firstArch, @NotNull final R archetype, @NotNull final ErrorViewCollector errorViewCollector); /** * Called after all parts of an archetype have been processed. Added: trunk/src/test/net/sf/gridarta/model/archetype/AbstractArchetypeParserTest.java =================================================================== --- trunk/src/test/net/sf/gridarta/model/archetype/AbstractArchetypeParserTest.java (rev 0) +++ trunk/src/test/net/sf/gridarta/model/archetype/AbstractArchetypeParserTest.java 2010-06-02 07:20:40 UTC (rev 8060) @@ -0,0 +1,80 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2010 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.model.archetype; + +import java.io.BufferedReader; +import java.io.File; +import java.io.IOException; +import java.io.Reader; +import java.io.StringReader; +import java.util.ArrayList; +import java.util.List; +import net.sf.gridarta.model.errorview.ErrorViewCollector; +import net.sf.gridarta.model.errorview.TestErrorView; +import net.sf.gridarta.model.gameobject.GameObject; +import net.sf.gridarta.model.map.maparchobject.MapArchObject; +import org.jetbrains.annotations.NotNull; +import org.junit.Assert; + +/** + * Abstract base class for regression tests for {@link ArchetypeParser}. + * @author Andreas Kirschbaum + */ +public abstract class AbstractArchetypeParserTest<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> { + + /** + * Creates a new archetype parser and parses the given input. + * @param input the input to parse + * @param hasErrors whether errors are expected + * @param hasWarnings whether warnings are expected + * @param archetypes the number of archetypes to expect + * @throws IOException if parsing fails + */ + protected void check(@NotNull final String input, final boolean hasErrors, final boolean hasWarnings, final int archetypes) throws IOException { + final AbstractArchetypeParser<G, A, R, ?> archetypeParser = newArchetypeParser(); + final TestErrorView errorView = new TestErrorView(); + final List<G> invObjects = new ArrayList<G>(); + final Reader reader = new StringReader(input); + final BufferedReader bufferedReader = new BufferedReader(reader); + try { + archetypeParser.parseArchetypeFromStream(bufferedReader, null, null, null, "panel", "folder", "", invObjects, new ErrorViewCollector(errorView, new File("*string*"))); + } finally { + bufferedReader.close(); + } + Assert.assertEquals(hasErrors, errorView.hasErrors()); + Assert.assertEquals(hasWarnings, errorView.hasWarnings()); + Assert.assertEquals(archetypes, getArchetypeSet().getArchetypeCount()); + } + + /** + * Creates a new {@link AbstractArchetypeParser} instance. + * @return the new instance + */ + @NotNull + protected abstract AbstractArchetypeParser<G, A, R, ? extends AbstractArchetypeBuilder<G, A, R>> newArchetypeParser(); + + /** + * Returns the {@link ArchetypeSet}. + * @return the archetype set + */ + @NotNull + protected abstract ArchetypeSet<G, A, R> getArchetypeSet(); + +} // class AbstractArchetypeParserTest Property changes on: trunk/src/test/net/sf/gridarta/model/archetype/AbstractArchetypeParserTest.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF Modified: trunk/src/test/net/sf/gridarta/model/archetype/ArchetypeParserTest.java =================================================================== --- trunk/src/test/net/sf/gridarta/model/archetype/ArchetypeParserTest.java 2010-05-31 17:53:34 UTC (rev 8059) +++ trunk/src/test/net/sf/gridarta/model/archetype/ArchetypeParserTest.java 2010-06-02 07:20:40 UTC (rev 8060) @@ -19,18 +19,10 @@ package net.sf.gridarta.model.archetype; -import java.io.BufferedReader; -import java.io.File; import java.io.IOException; -import java.io.Reader; -import java.io.StringReader; -import java.util.ArrayList; -import java.util.List; import java.util.regex.Pattern; import net.sf.gridarta.model.anim.AnimationObjects; import net.sf.gridarta.model.anim.DefaultAnimationObjects; -import net.sf.gridarta.model.errorview.ErrorViewCollector; -import net.sf.gridarta.model.errorview.TestErrorView; import net.sf.gridarta.model.face.ArchFaceProvider; import net.sf.gridarta.model.face.DefaultFaceObjects; import net.sf.gridarta.model.face.FaceObjectProviders; @@ -49,13 +41,13 @@ * Regression tests for {@link AbstractArchetypeParser}. * @author Andreas Kirschbaum */ -public class ArchetypeParserTest { +public class ArchetypeParserTest extends AbstractArchetypeParserTest<TestGameObject, TestMapArchObject, TestArchetype> { /** * The loaded archetypes. */ @Nullable - private TestArchetypeSet archetypeSet = null; + private ArchetypeSet<TestGameObject, TestMapArchObject, TestArchetype> archetypeSet = null; /** * Checks that a missing "object" line is detected. @@ -83,9 +75,7 @@ @Test public void testMsgTextEmpty() throws IOException, UndefinedArchetypeException { check("Object test\nmsg\nendmsg\nend\n", false, false, 1); - assert archetypeSet != null; - final Archetype<TestGameObject, TestMapArchObject, TestArchetype> archetype = archetypeSet.getArchetype("test"); - Assert.assertNull(archetype.getMsgText()); + Assert.assertNull(getArchetypeSet().getArchetype("test").getMsgText()); } /** @@ -96,9 +86,7 @@ @Test public void testMsgTextLines() throws IOException, UndefinedArchetypeException { check("Object test\nmsg\nabc\ndef\nghi\nendmsg\nend\n", false, false, 1); - assert archetypeSet != null; - final Archetype<TestGameObject, TestMapArchObject, TestArchetype> archetype = archetypeSet.getArchetype("test"); - Assert.assertEquals("abc\ndef\nghi\n", archetype.getMsgText()); + Assert.assertEquals("abc\ndef\nghi\n", getArchetypeSet().getArchetype("test").getMsgText()); } /** @@ -109,9 +97,7 @@ @Test public void testMsgTextTrailingWhitespace() throws IOException, UndefinedArchetypeException { check("Object test\nmsg\nabc \ndef\nghi \n\nendmsg\nend\n", false, false, 1); - assert archetypeSet != null; - final Archetype<TestGameObject, TestMapArchObject, TestArchetype> archetype = archetypeSet.getArchetype("test"); - Assert.assertEquals("abc\ndef\nghi\n\n", archetype.getMsgText()); + Assert.assertEquals("abc\ndef\nghi\n\n", getArchetypeSet().getArchetype("test").getMsgText()); } /** @@ -122,9 +108,7 @@ @Test public void testMsgTextLeadingWhitespace() throws IOException, UndefinedArchetypeException { check("Object test\nmsg\n\n abc\ndef\n ghi\nendmsg\nend\n", false, false, 1); - assert archetypeSet != null; - final Archetype<TestGameObject, TestMapArchObject, TestArchetype> archetype = archetypeSet.getArchetype("test"); - Assert.assertEquals("\n abc\ndef\n ghi\n", archetype.getMsgText()); + Assert.assertEquals("\n abc\ndef\n ghi\n", getArchetypeSet().getArchetype("test").getMsgText()); } /** @@ -137,35 +121,11 @@ } /** - * Creates a new archetype parser and parses the given input. - * @param input the input to parse - * @param hasErrors whether errors are expected - * @param hasWarnings whether warnings are expected - * @param archetypes the number of archetypes to expect - * @throws IOException if parsing fails + * {@inheritDoc} */ - private void check(@NotNull final String input, final boolean hasErrors, final boolean hasWarnings, final int archetypes) throws IOException { - final AbstractArchetypeParser<TestGameObject, TestMapArchObject, TestArchetype, TestArchetypeBuilder> archetypeParser = newArchetypeParser(); - final TestErrorView errorView = new TestErrorView(); - final List<TestGameObject> invObjects = new ArrayList<TestGameObject>(); - final Reader reader = new StringReader(input); - final BufferedReader bufferedReader = new BufferedReader(reader); - try { - archetypeParser.parseArchetypeFromStream(bufferedReader, null, null, null, "panel", "folder", "", invObjects, new ErrorViewCollector(errorView, new File("*string*"))); - } finally { - bufferedReader.close(); - } - Assert.assertEquals(hasErrors, errorView.hasErrors()); - Assert.assertEquals(hasWarnings, errorView.hasWarnings()); - assert archetypeSet != null; - Assert.assertEquals(archetypes, archetypeSet.getArchetypeCount()); - } - - /** - * Creates a new {@link TestArchetypeParser} instance. - * @return the new instance - */ - public AbstractArchetypeParser<TestGameObject, TestMapArchObject, TestArchetype, TestArchetypeBuilder> newArchetypeParser() { + @NotNull + @Override + protected AbstractArchetypeParser<TestGameObject, TestMapArchObject, TestArchetype, ? extends AbstractArchetypeBuilder<TestGameObject, TestMapArchObject, TestArchetype>> newArchetypeParser() { final ArchFaceProvider archFaceProvider = new ArchFaceProvider(); final FaceObjects faceObjects = new DefaultFaceObjects("png", "facetree", Pattern.compile(".*"), "facetree.output", archFaceProvider); final GUIUtils guiUtils = new GUIUtils(); @@ -181,4 +141,16 @@ return new TestArchetypeParser(archetypeBuilder, animationObjects, archetypeSet); } + /** + * {@inheritDoc} + */ + @NotNull + @Override + protected ArchetypeSet<TestGameObject, TestMapArchObject, TestArchetype> getArchetypeSet() { + if (archetypeSet == null) { + throw new IllegalStateException(); + } + return archetypeSet; + } + } // class ArchetypeParserTest Modified: trunk/src/test/net/sf/gridarta/model/archetype/TestArchetypeParser.java =================================================================== --- trunk/src/test/net/sf/gridarta/model/archetype/TestArchetypeParser.java 2010-05-31 17:53:34 UTC (rev 8059) +++ trunk/src/test/net/sf/gridarta/model/archetype/TestArchetypeParser.java 2010-06-02 07:20:40 UTC (rev 8060) @@ -72,7 +72,7 @@ * {@inheritDoc} */ @Override - protected void finishParseArchetypePart(@NotNull final TestArchetype firstArch, @NotNull final TestArchetype archetype, @NotNull final ErrorViewCollector errorViewCollector) { + protected void finishParseArchetypePart(@Nullable final TestArchetype firstArch, @NotNull final TestArchetype archetype, @NotNull final ErrorViewCollector errorViewCollector) { } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-05-31 17:53:42
|
Revision: 8059 http://gridarta.svn.sourceforge.net/gridarta/?rev=8059&view=rev Author: akirschbaum Date: 2010-05-31 17:53:34 +0000 (Mon, 31 May 2010) Log Message: ----------- Move recent menu related code from MapMenuManager to RecentMapMenuPreferences. Modified Paths: -------------- trunk/src/app/net/sf/gridarta/gui/mapmenu/MapMenuEntry.java trunk/src/app/net/sf/gridarta/gui/mapmenu/MapMenuManager.java trunk/src/app/net/sf/gridarta/gui/mapmenu/MapMenuPreferences.java trunk/src/app/net/sf/gridarta/gui/mapmenu/RecentMapMenuPreferences.java trunk/src/app/net/sf/gridarta/maincontrol/GUIMainControl.java Modified: trunk/src/app/net/sf/gridarta/gui/mapmenu/MapMenuEntry.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/mapmenu/MapMenuEntry.java 2010-05-30 21:26:21 UTC (rev 8058) +++ trunk/src/app/net/sf/gridarta/gui/mapmenu/MapMenuEntry.java 2010-05-31 17:53:34 UTC (rev 8059) @@ -70,12 +70,6 @@ private final FileControl<G, A, R> fileControl; /** - * The {@link MapMenuPreferences} to use. - */ - @NotNull - private final MapMenuPreferences mapMenuPreferences; - - /** * The map file. */ @NotNull @@ -85,83 +79,25 @@ * Create a MapMenuEntry. * @param title title (map name) * @param mapFile the map file - * @param mapsDirectory the maps directory * @param mapViewsManager the map views manager instance * @param mapImageCache the map image cache instance * @param fileControl the file control - * @param mapMenuPreferences the recent preferences to use + * @param shortDescription the short description for tooltips */ - MapMenuEntry(@NotNull final String title, @NotNull final File mapFile, @NotNull final File mapsDirectory, @NotNull final MapViewsManager<G, A, R> mapViewsManager, @NotNull final MapImageCache<G, A, R> mapImageCache, @NotNull final FileControl<G, A, R> fileControl, @NotNull final MapMenuPreferences mapMenuPreferences) { + public MapMenuEntry(@NotNull final String title, @NotNull final File mapFile, @NotNull final MapViewsManager<G, A, R> mapViewsManager, @NotNull final MapImageCache<G, A, R> mapImageCache, @NotNull final FileControl<G, A, R> fileControl, @NotNull final String shortDescription) { super(title); this.mapFile = mapFile; this.title = title; this.mapViewsManager = mapViewsManager; this.mapImageCache = mapImageCache; this.fileControl = fileControl; - this.mapMenuPreferences = mapMenuPreferences; - putValue(SHORT_DESCRIPTION, mapMenuPreferences.getShortDescription(title, getShortMapFile(mapsDirectory, mapFile))); + putValue(SHORT_DESCRIPTION, shortDescription); putValue(SMALL_ICON, getIcon()); putValue(NAME, title); putValue(MNEMONIC_KEY, null); } /** - * Returns the base name of a map file. - * @param mapsDirectory the maps directory - * @param mapFile the map file - * @return the base name - */ - @NotNull - private static String getShortMapFile(@NotNull final File mapsDirectory, @NotNull final File mapFile) { - String canonicalMapFile; - String canonicalMapsDirectory; - try { - canonicalMapFile = mapFile.getCanonicalPath(); - canonicalMapsDirectory = mapsDirectory.getCanonicalPath(); - } catch (final IOException ignored) { - canonicalMapFile = mapFile.getAbsolutePath(); - canonicalMapsDirectory = mapsDirectory.getAbsolutePath(); - } - - if (canonicalMapFile.startsWith(canonicalMapsDirectory)) { - return canonicalMapFile.substring(canonicalMapsDirectory.length()).replace('\\', '/'); - } else { - return canonicalMapFile.replace('\\', '/'); - } - } - - /** - * Create a MapMenuEntry from preferences. - * @param index index (starting with 1) - * @param mapsDirectory the maps directory - * @param mapViewsManager the map views manager instance - * @param mapImageCache the map image cache instance - * @param fileControl the file control - * @param mapMenuPreferences the recent preferences to use - */ - MapMenuEntry(final int index, @NotNull final File mapsDirectory, @NotNull final MapViewsManager<G, A, R> mapViewsManager, @NotNull final MapImageCache<G, A, R> mapImageCache, @NotNull final FileControl<G, A, R> fileControl, @NotNull final MapMenuPreferences mapMenuPreferences) { - this.mapViewsManager = mapViewsManager; - this.mapImageCache = mapImageCache; - this.fileControl = fileControl; - this.mapMenuPreferences = mapMenuPreferences; - title = mapMenuPreferences.getTitle(index - 1); - mapFile = mapMenuPreferences.getMapFile(index -1 ); - putValue(SHORT_DESCRIPTION, mapMenuPreferences.getShortDescription(title, getShortMapFile(mapsDirectory, mapFile))); - putValue(SMALL_ICON, getIcon()); - putValue(NAME, title); - putValue(MNEMONIC_KEY, null); - setIndex(index); - } - - /** - * Set the index used for title, key strokes and such. - * @param index index (starting with 1) - */ - public void setIndex(final int index) { - mapMenuPreferences.setInfo(index - 1, title, mapFile.getPath()); - } - - /** * {@inheritDoc} */ @Override Modified: trunk/src/app/net/sf/gridarta/gui/mapmenu/MapMenuManager.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/mapmenu/MapMenuManager.java 2010-05-30 21:26:21 UTC (rev 8058) +++ trunk/src/app/net/sf/gridarta/gui/mapmenu/MapMenuManager.java 2010-05-31 17:53:34 UTC (rev 8059) @@ -20,9 +20,9 @@ package net.sf.gridarta.gui.mapmenu; import java.io.File; +import java.io.IOException; import java.util.IdentityHashMap; -import java.util.LinkedList; -import java.util.ListIterator; +import java.util.Iterator; import java.util.Map; import java.util.Set; import javax.swing.Action; @@ -61,12 +61,6 @@ private final MapViewsManager<G, A, R> mapViewsManager; /** - * List with mapMenuEntries. - */ - @NotNull - private final LinkedList<MapMenuEntry<G, A, R>> mapMenuEntries = new LinkedList<MapMenuEntry<G, A, R>>(); - - /** * The menu to update. * @serial */ @@ -95,7 +89,7 @@ * The {@link MapMenuPreferences} to use. */ @NotNull - private final MapMenuPreferences mapMenuPreferences; + private final MapMenuPreferences<G, A, R> mapMenuPreferences; /** * Maps {@link MapControl} instances to associated {@link MapTracker} @@ -113,7 +107,7 @@ * @param fileControl the file control * @param mapMenuPreferences the recent preferences to use */ - public MapMenuManager(@NotNull final MapManager<G, A, R> mapManager, @NotNull final MapViewsManager<G, A, R> mapViewsManager, @NotNull final GlobalSettings globalSettings, @NotNull final MapImageCache<G, A, R> mapImageCache, @NotNull final FileControl<G, A, R> fileControl, @NotNull final MapMenuPreferences mapMenuPreferences) { + public MapMenuManager(@NotNull final MapManager<G, A, R> mapManager, @NotNull final MapViewsManager<G, A, R> mapViewsManager, @NotNull final GlobalSettings globalSettings, @NotNull final MapImageCache<G, A, R> mapImageCache, @NotNull final FileControl<G, A, R> fileControl, @NotNull final MapMenuPreferences<G, A, R> mapMenuPreferences) { this.mapViewsManager = mapViewsManager; this.globalSettings = globalSettings; this.mapImageCache = mapImageCache; @@ -181,19 +175,8 @@ return; } - final MapMenuEntry<G, A, R> mapMenuEntry = new MapMenuEntry<G, A, R>(title, mapFile, globalSettings.getMapsDirectory(), mapViewsManager, mapImageCache, fileControl, mapMenuPreferences); - mapMenuEntries.remove(mapMenuEntry); // remove old entry to get new entry at first pos. - mapMenuEntries.addFirst(mapMenuEntry); - // Now remove those that are too many. - // Please keep this while loop as the constant 10 might be replaced by a preferences var - int i = 0; - for (final ListIterator<MapMenuEntry<G, A, R>> it = mapMenuEntries.listIterator(); it.hasNext();) { - it.next().setIndex(it.nextIndex()); // this looks bogus but it's intentionally currentIndex + 1 - if (++i > 10) { - it.remove(); - } - } - mapMenuPreferences.setNum(mapMenuEntries.size()); + final MapMenuEntry<G, A, R> mapMenuEntry = newMapMenuEntry(title, mapFile); + mapMenuPreferences.addMapMenuEntryEntry(mapMenuEntry, true); updateRecent(); } @@ -207,7 +190,7 @@ return; } - for (final MapMenuEntry<G, A, R> mapMenuEntry : mapMenuEntries) { + for (final MapMenuEntry<G, A, R> mapMenuEntry : mapMenuPreferences) { if (mapMenuEntry.getMapFile().equals(mapFile)) { addRecent(mapModel, mapMenuEntry.getTitle()); break; @@ -225,10 +208,11 @@ return; } - for (int i = 0; i < mapMenuEntries.size(); i++) { - final MapMenuEntry<G, A, R> mapMenuEntry = mapMenuEntries.get(i); + final Iterator<MapMenuEntry<G, A, R>> it = mapMenuPreferences.iterator(); + while (it.hasNext()) { + final MapMenuEntry<G, A, R> mapMenuEntry = it.next(); if (mapMenuEntry.getMapFile().equals(mapFile)) { - mapMenuEntries.remove(i); + it.remove(); break; } } @@ -238,15 +222,53 @@ * Initializes the recent state. */ public void initRecent() { - final File mapsDirectory = globalSettings.getMapsDirectory(); final int numRecents = mapMenuPreferences.getNum(); - for (int i = 0; i < numRecents; i++) { - mapMenuEntries.add(new MapMenuEntry<G, A, R>(i + 1, mapsDirectory, mapViewsManager, mapImageCache, fileControl, mapMenuPreferences)); + for (int i = numRecents - 1; i >= 0; i--) { + final String title = mapMenuPreferences.getTitle(i); + final File mapFile = mapMenuPreferences.getMapFile(i); + final MapMenuEntry<G, A, R> mapMenuEntry = newMapMenuEntry(title, mapFile); + mapMenuPreferences.addMapMenuEntryEntry(mapMenuEntry, false); } updateRecent(); } /** + * Creates a new {@link MapMenuEntry}. + * @param title the entry's title + * @param mapFile the entry's map file + * @return the new instance + */ + @NotNull + private MapMenuEntry<G, A, R> newMapMenuEntry(@NotNull final String title, @NotNull final File mapFile) { + return new MapMenuEntry<G, A, R>(title, mapFile, mapViewsManager, mapImageCache, fileControl, mapMenuPreferences.getShortDescription(title, getShortMapFile(globalSettings.getMapsDirectory(), mapFile))); + } + + /** + * Returns the base name of a map file. + * @param mapsDirectory the maps directory + * @param mapFile the map file + * @return the base name + */ + @NotNull + private static String getShortMapFile(@NotNull final File mapsDirectory, @NotNull final File mapFile) { + String canonicalMapFile; + String canonicalMapsDirectory; + try { + canonicalMapFile = mapFile.getCanonicalPath(); + canonicalMapsDirectory = mapsDirectory.getCanonicalPath(); + } catch (final IOException ignored) { + canonicalMapFile = mapFile.getAbsolutePath(); + canonicalMapsDirectory = mapsDirectory.getAbsolutePath(); + } + + if (canonicalMapFile.startsWith(canonicalMapsDirectory)) { + return canonicalMapFile.substring(canonicalMapsDirectory.length()).replace('\\', '/'); + } else { + return canonicalMapFile.replace('\\', '/'); + } + } + + /** * Update the recent menu. */ private void updateRecent() { @@ -256,7 +278,7 @@ } MenuUtils.removeAll(menu); - for (final Action recent : mapMenuEntries) { + for (final Action recent : mapMenuPreferences) { menu.add(recent); } } Modified: trunk/src/app/net/sf/gridarta/gui/mapmenu/MapMenuPreferences.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/mapmenu/MapMenuPreferences.java 2010-05-30 21:26:21 UTC (rev 8058) +++ trunk/src/app/net/sf/gridarta/gui/mapmenu/MapMenuPreferences.java 2010-05-31 17:53:34 UTC (rev 8059) @@ -21,6 +21,9 @@ import java.io.File; import java.io.Serializable; +import net.sf.gridarta.model.archetype.Archetype; +import net.sf.gridarta.model.gameobject.GameObject; +import net.sf.gridarta.model.map.maparchobject.MapArchObject; import org.jetbrains.annotations.NotNull; /** @@ -28,7 +31,7 @@ * MapMenuManager} instances. * @author Andreas Kirschbaum */ -public interface MapMenuPreferences extends Serializable { +public interface MapMenuPreferences<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> extends Iterable<MapMenuEntry<G, A, R>>, Serializable { /** * Returns the number of active entries. @@ -37,20 +40,6 @@ int getNum(); /** - * Sets the number of active entries. - * @param num the number of active entries - */ - void setNum(int num); - - /** - * Updates information about one entry. - * @param index the entry's index - * @param title the entry's title - * @param path the entry's path - */ - void setInfo(int index, @NotNull String title, @NotNull String path); - - /** * Returns an entry's title. * @param index the entry's index * @return the entry's title @@ -73,6 +62,13 @@ * @return the short description */ @NotNull - String getShortDescription(@NotNull final String title, @NotNull final String mapFile); + String getShortDescription(@NotNull String title, @NotNull String mapFile); + /** + * Adds a {@link MapMenuEntry}. + * @param mapMenuEntry the map menu entry + * @param doSave whether to save the change to preferences + */ + void addMapMenuEntryEntry(@NotNull MapMenuEntry<G, A, R> mapMenuEntry, boolean doSave); + } // interface MapMenuPreferences Modified: trunk/src/app/net/sf/gridarta/gui/mapmenu/RecentMapMenuPreferences.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/mapmenu/RecentMapMenuPreferences.java 2010-05-30 21:26:21 UTC (rev 8058) +++ trunk/src/app/net/sf/gridarta/gui/mapmenu/RecentMapMenuPreferences.java 2010-05-31 17:53:34 UTC (rev 8059) @@ -20,8 +20,14 @@ package net.sf.gridarta.gui.mapmenu; import java.io.File; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; import java.util.prefs.Preferences; import net.sf.gridarta.MainControl; +import net.sf.gridarta.model.archetype.Archetype; +import net.sf.gridarta.model.gameobject.GameObject; +import net.sf.gridarta.model.map.maparchobject.MapArchObject; import net.sf.japi.swing.action.ActionBuilder; import net.sf.japi.swing.action.ActionBuilderFactory; import org.jetbrains.annotations.NotNull; @@ -30,7 +36,7 @@ * A {@link MapMenuPreferences} for recent menu entries. * @author Andreas Kirschbaum */ -public class RecentMapMenuPreferences implements MapMenuPreferences { +public class RecentMapMenuPreferences<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> implements MapMenuPreferences<G, A, R> { /** * The serial version UID. @@ -49,6 +55,15 @@ @NotNull private static final ActionBuilder ACTION_BUILDER = ActionBuilderFactory.getInstance().getActionBuilder("net.sf.gridarta"); + /** + * List with mapMenuEntries. + */ + @NotNull + private final List<MapMenuEntry<G, A, R>> mapMenuEntries = new LinkedList<MapMenuEntry<G, A, R>>(); + + /** + * {@inheritDoc} + */ @Override public int getNum() { return preferences.getInt("recentNum", 0); @@ -57,18 +72,19 @@ /** * {@inheritDoc} */ + @NotNull @Override - public void setNum(final int num) { - preferences.putInt("recentNum", num); + public String getTitle(final int index) { + return preferences.get("recentTitle[" + Integer.toString(index) + ']', ""); } /** * {@inheritDoc} */ + @NotNull @Override - public void setInfo(final int index, @NotNull final String title, @NotNull final String path) { - preferences.put("recentTitle[" + Integer.toString(index - 1) + ']', title); - preferences.put("recentFilename[" + Integer.toString(index - 1) + ']', path); + public File getMapFile(final int index) { + return new File(preferences.get("recentFilename[" + Integer.toString(index) + ']', "")); } /** @@ -76,26 +92,75 @@ */ @NotNull @Override - public String getTitle(final int index) { - return preferences.get("recentTitle[" + Integer.toString(index - 1) + ']', ""); + public String getShortDescription(@NotNull final String title, @NotNull final String mapFile) { + return ACTION_BUILDER.format("recentItem.shortdescriptionformat", title, mapFile); } /** * {@inheritDoc} */ - @NotNull @Override - public File getMapFile(final int index) { - return new File(preferences.get("recentFilename[" + Integer.toString(index - 1) + ']', "")); + public void addMapMenuEntryEntry(@NotNull final MapMenuEntry<G, A, R> mapMenuEntry, final boolean doSave) { + mapMenuEntries.remove(mapMenuEntry); // remove old entry to get new entry at first pos. + mapMenuEntries.add(0, mapMenuEntry); + // Now remove those that are too many. + // Please keep this while loop as the constant 10 might be replaced by a preferences var + int i = 0; + for (final Iterator<MapMenuEntry<G, A, R>> it = mapMenuEntries.iterator(); it.hasNext();) { + it.next(); + if (++i > 10) { + it.remove(); + } + } + if (doSave) { + save(); + } } /** + * Saves all entries to preferences. + */ + private void save() { + int i = 0; + for (final MapMenuEntry<G, A, R> mapMenuEntry : mapMenuEntries) { + preferences.put("recentTitle[" + Integer.toString(i) + ']', mapMenuEntry.getTitle()); + preferences.put("recentFilename[" + Integer.toString(i) + ']', mapMenuEntry.getMapFile().getPath()); + i++; + } + preferences.putInt("recentNum", i); + } + + /** * {@inheritDoc} */ @NotNull @Override - public String getShortDescription(@NotNull final String title, @NotNull final String mapFile) { - return ACTION_BUILDER.format("recentItem.shortdescriptionformat", title, mapFile); + public Iterator<MapMenuEntry<G, A, R>> iterator() { + return new Iterator<MapMenuEntry<G, A, R>>() { + + /** + * The {@link Iterator} to forward to. + */ + @NotNull + private final Iterator<MapMenuEntry<G, A, R>> it = mapMenuEntries.iterator(); + + @Override + public boolean hasNext() { + return it.hasNext(); + } + + @Override + public MapMenuEntry<G, A, R> next() { + return it.next(); + } + + @Override + public void remove() { + it.remove(); + save(); + } + + }; } } // class RecentMapMenuPreferences Modified: trunk/src/app/net/sf/gridarta/maincontrol/GUIMainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/maincontrol/GUIMainControl.java 2010-05-30 21:26:21 UTC (rev 8058) +++ trunk/src/app/net/sf/gridarta/maincontrol/GUIMainControl.java 2010-05-31 17:53:34 UTC (rev 8059) @@ -592,7 +592,7 @@ } editorFactory.deleteLibraries(mainViewFrame); - final MapMenuManager<G, A, R> recentMapMenuManager = new MapMenuManager<G, A, R>(mapManager, mapViewsManager, globalSettings, mapImageCache, fileControl, new RecentMapMenuPreferences()); + final MapMenuManager<G, A, R> recentMapMenuManager = new MapMenuManager<G, A, R>(mapManager, mapViewsManager, globalSettings, mapImageCache, fileControl, new RecentMapMenuPreferences<G, A, R>()); final JMenu recentMenu = MenuUtils.getMenu(menuBar, "recent"); if (recentMenu == null) { log.warn("'main' menu bar does not define 'recent' menu."); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-05-30 21:26:28
|
Revision: 8058 http://gridarta.svn.sourceforge.net/gridarta/?rev=8058&view=rev Author: akirschbaum Date: 2010-05-30 21:26:21 +0000 (Sun, 30 May 2010) Log Message: ----------- Add title parameter to MapMenuManager.addRecent(). Modified Paths: -------------- trunk/src/app/net/sf/gridarta/gui/mapmenu/MapMenuEntry.java trunk/src/app/net/sf/gridarta/gui/mapmenu/MapMenuManager.java trunk/src/app/net/sf/gridarta/gui/misc/RecentManager.java Modified: trunk/src/app/net/sf/gridarta/gui/mapmenu/MapMenuEntry.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/mapmenu/MapMenuEntry.java 2010-05-30 21:06:45 UTC (rev 8057) +++ trunk/src/app/net/sf/gridarta/gui/mapmenu/MapMenuEntry.java 2010-05-30 21:26:21 UTC (rev 8058) @@ -174,6 +174,15 @@ } /** + * Returns the title of this entry. + * @return the title + */ + @NotNull + public String getTitle() { + return title; + } + + /** * Get the icon of this file. * @return icon of this file */ Modified: trunk/src/app/net/sf/gridarta/gui/mapmenu/MapMenuManager.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/mapmenu/MapMenuManager.java 2010-05-30 21:06:45 UTC (rev 8057) +++ trunk/src/app/net/sf/gridarta/gui/mapmenu/MapMenuManager.java 2010-05-30 21:26:21 UTC (rev 8058) @@ -173,14 +173,14 @@ /** * Adds or updates an entry of the recent files. * @param mapModel the map model to update the entry for + * @param title the title of the menu entry */ - public void addRecent(@NotNull final MapModel<G, A, R> mapModel) { + public void addRecent(@NotNull final MapModel<G, A, R> mapModel, @NotNull final String title) { final File mapFile = mapModel.getMapFile(); if (mapFile == null) { return; } - final String title = mapModel.getMapArchObject().getMapName(); final MapMenuEntry<G, A, R> mapMenuEntry = new MapMenuEntry<G, A, R>(title, mapFile, globalSettings.getMapsDirectory(), mapViewsManager, mapImageCache, fileControl, mapMenuPreferences); mapMenuEntries.remove(mapMenuEntry); // remove old entry to get new entry at first pos. mapMenuEntries.addFirst(mapMenuEntry); @@ -198,6 +198,24 @@ } /** + * Updates information for an entry. + * @param mapModel the map model to update + */ + private void updateRecent(@NotNull final MapModel<G, A, R> mapModel) { + final File mapFile = mapModel.getMapFile(); + if (mapFile == null) { + return; + } + + for (final MapMenuEntry<G, A, R> mapMenuEntry : mapMenuEntries) { + if (mapMenuEntry.getMapFile().equals(mapFile)) { + addRecent(mapModel, mapMenuEntry.getTitle()); + break; + } + } + } + + /** * Removes a recent entry for given map file. Does nothing if no such entry * exists. * @param mapFile the map file @@ -312,7 +330,7 @@ removeRecent(oldMapFile); } - addRecent(mapModel); + updateRecent(mapModel); } /** @@ -329,7 +347,7 @@ @Override public void saved(@NotNull final DefaultMapControl<G, A, R> mapControl) { assert mapModel == mapControl.getMapModel(); - addRecent(mapModel); + updateRecent(mapModel); } } Modified: trunk/src/app/net/sf/gridarta/gui/misc/RecentManager.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/misc/RecentManager.java 2010-05-30 21:06:45 UTC (rev 8057) +++ trunk/src/app/net/sf/gridarta/gui/misc/RecentManager.java 2010-05-30 21:26:21 UTC (rev 8058) @@ -26,6 +26,7 @@ import net.sf.gridarta.model.gameobject.GameObject; import net.sf.gridarta.model.map.maparchobject.MapArchObject; import net.sf.gridarta.model.map.mapcontrol.MapControl; +import net.sf.gridarta.model.map.mapmodel.MapModel; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -53,7 +54,8 @@ @Override public void mapCreated(@NotNull final MapControl<G, A, R> mapControl, final boolean interactive) { if (interactive) { - mapMenuManager.addRecent(mapControl.getMapModel()); + final MapModel<G,A,R> mapModel = mapControl.getMapModel(); + mapMenuManager.addRecent(mapModel, mapModel.getMapArchObject().getMapName()); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-05-30 21:06:51
|
Revision: 8057 http://gridarta.svn.sourceforge.net/gridarta/?rev=8057&view=rev Author: akirschbaum Date: 2010-05-30 21:06:45 +0000 (Sun, 30 May 2010) Log Message: ----------- Add @NotNull annotations. Modified Paths: -------------- trunk/src/app/net/sf/gridarta/gui/utils/MenuUtils.java Modified: trunk/src/app/net/sf/gridarta/gui/utils/MenuUtils.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/utils/MenuUtils.java 2010-05-30 20:58:27 UTC (rev 8056) +++ trunk/src/app/net/sf/gridarta/gui/utils/MenuUtils.java 2010-05-30 21:06:45 UTC (rev 8057) @@ -54,7 +54,7 @@ * its children. * @param menuElement the menu element to process */ - public static void disposeMenuElement(final MenuElement menuElement) { + public static void disposeMenuElement(@NotNull final MenuElement menuElement) { if (menuElement instanceof AbstractButton) { ((AbstractButton) menuElement).setAction(null); } @@ -68,7 +68,7 @@ * Remove all menu entries. * @param menu the menu to remove the entries from */ - public static void removeAll(final JMenu menu) { + public static void removeAll(@NotNull final JMenu menu) { for (final MenuElement child : menu.getSubElements()) { disposeMenuElement(child); } @@ -79,7 +79,7 @@ * Remove all menu entries up to (but not including) the first separator. * @param menu the menu to remove the entries from */ - public static void removeAllToSeparator(final JMenu menu) { + public static void removeAllToSeparator(@NotNull final JMenu menu) { while (true) { final Component menuItem = menu.getMenuComponent(0); if (menuItem == null || menuItem instanceof JSeparator) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-05-30 20:58:33
|
Revision: 8056 http://gridarta.svn.sourceforge.net/gridarta/?rev=8056&view=rev Author: akirschbaum Date: 2010-05-30 20:58:27 +0000 (Sun, 30 May 2010) Log Message: ----------- Remove parameter from MapMenuManager.addRecent(). Modified Paths: -------------- trunk/src/app/net/sf/gridarta/gui/mapmenu/MapMenuManager.java trunk/src/app/net/sf/gridarta/gui/misc/RecentManager.java Modified: trunk/src/app/net/sf/gridarta/gui/mapmenu/MapMenuManager.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/mapmenu/MapMenuManager.java 2010-05-30 20:49:32 UTC (rev 8055) +++ trunk/src/app/net/sf/gridarta/gui/mapmenu/MapMenuManager.java 2010-05-30 20:58:27 UTC (rev 8056) @@ -173,13 +173,8 @@ /** * Adds or updates an entry of the recent files. * @param mapModel the map model to update the entry for - * @param oldMapFile the map file before the change */ - public void addRecent(@NotNull final MapModel<G, A, R> mapModel, @Nullable final File oldMapFile) { - if (oldMapFile != null) { - removeRecent(oldMapFile); - } - + public void addRecent(@NotNull final MapModel<G, A, R> mapModel) { final File mapFile = mapModel.getMapFile(); if (mapFile == null) { return; @@ -313,7 +308,11 @@ */ @Override public void mapFileChanged(@Nullable final File oldMapFile) { - addRecent(mapModel, oldMapFile); + if (oldMapFile != null) { + removeRecent(oldMapFile); + } + + addRecent(mapModel); } /** @@ -330,7 +329,7 @@ @Override public void saved(@NotNull final DefaultMapControl<G, A, R> mapControl) { assert mapModel == mapControl.getMapModel(); - addRecent(mapModel, null); + addRecent(mapModel); } } Modified: trunk/src/app/net/sf/gridarta/gui/misc/RecentManager.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/misc/RecentManager.java 2010-05-30 20:49:32 UTC (rev 8055) +++ trunk/src/app/net/sf/gridarta/gui/misc/RecentManager.java 2010-05-30 20:58:27 UTC (rev 8056) @@ -53,7 +53,7 @@ @Override public void mapCreated(@NotNull final MapControl<G, A, R> mapControl, final boolean interactive) { if (interactive) { - mapMenuManager.addRecent(mapControl.getMapModel(), null); + mapMenuManager.addRecent(mapControl.getMapModel()); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-05-30 20:49:39
|
Revision: 8055 http://gridarta.svn.sourceforge.net/gridarta/?rev=8055&view=rev Author: akirschbaum Date: 2010-05-30 20:49:32 +0000 (Sun, 30 May 2010) Log Message: ----------- Add MapMenuManager.setMenu(). Modified Paths: -------------- trunk/src/app/net/sf/gridarta/gui/mapmenu/MapMenuManager.java trunk/src/app/net/sf/gridarta/maincontrol/GUIMainControl.java Modified: trunk/src/app/net/sf/gridarta/gui/mapmenu/MapMenuManager.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/mapmenu/MapMenuManager.java 2010-05-30 20:41:09 UTC (rev 8054) +++ trunk/src/app/net/sf/gridarta/gui/mapmenu/MapMenuManager.java 2010-05-30 20:49:32 UTC (rev 8055) @@ -67,11 +67,11 @@ private final LinkedList<MapMenuEntry<G, A, R>> mapMenuEntries = new LinkedList<MapMenuEntry<G, A, R>>(); /** - * The "recent" menu to update. + * The menu to update. * @serial */ @Nullable - private final JMenu recentMenu; + private JMenu recentMenu = null; /** * The global settings instance. @@ -108,15 +108,13 @@ * Create a new instance. * @param mapManager the map manager instance * @param mapViewsManager the map views manager instance - * @param recentMenu menu for managing the recent entries * @param globalSettings the global settings instance * @param mapImageCache the map image cache instance * @param fileControl the file control * @param mapMenuPreferences the recent preferences to use */ - public MapMenuManager(@NotNull final MapManager<G, A, R> mapManager, @NotNull final MapViewsManager<G, A, R> mapViewsManager, @Nullable final JMenu recentMenu, @NotNull final GlobalSettings globalSettings, @NotNull final MapImageCache<G, A, R> mapImageCache, @NotNull final FileControl<G, A, R> fileControl, @NotNull final MapMenuPreferences mapMenuPreferences) { + public MapMenuManager(@NotNull final MapManager<G, A, R> mapManager, @NotNull final MapViewsManager<G, A, R> mapViewsManager, @NotNull final GlobalSettings globalSettings, @NotNull final MapImageCache<G, A, R> mapImageCache, @NotNull final FileControl<G, A, R> fileControl, @NotNull final MapMenuPreferences mapMenuPreferences) { this.mapViewsManager = mapViewsManager; - this.recentMenu = recentMenu; this.globalSettings = globalSettings; this.mapImageCache = mapImageCache; this.fileControl = fileControl; @@ -164,6 +162,15 @@ } /** + * Sets the menu to update. + * @param recentMenu the menu or <code>null</code> + */ + public void setMenu(@Nullable final JMenu recentMenu) { + this.recentMenu = recentMenu; + updateRecent(); + } + + /** * Adds or updates an entry of the recent files. * @param mapModel the map model to update the entry for * @param oldMapFile the map file before the change @@ -192,7 +199,7 @@ } } mapMenuPreferences.setNum(mapMenuEntries.size()); - updateRecent(mapMenuEntries); + updateRecent(); } /** @@ -223,21 +230,21 @@ for (int i = 0; i < numRecents; i++) { mapMenuEntries.add(new MapMenuEntry<G, A, R>(i + 1, mapsDirectory, mapViewsManager, mapImageCache, fileControl, mapMenuPreferences)); } - updateRecent(mapMenuEntries); + updateRecent(); } /** * Update the recent menu. - * @param recents current mapMenuEntries */ - private void updateRecent(@NotNull final Iterable<MapMenuEntry<G, A, R>> recents) { - if (recentMenu == null) { + private void updateRecent() { + final JMenu menu = recentMenu; + if (menu == null) { return; } - MenuUtils.removeAll(recentMenu); - for (final Action recent : recents) { - recentMenu.add(recent); + MenuUtils.removeAll(menu); + for (final Action recent : mapMenuEntries) { + menu.add(recent); } } Modified: trunk/src/app/net/sf/gridarta/maincontrol/GUIMainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/maincontrol/GUIMainControl.java 2010-05-30 20:41:09 UTC (rev 8054) +++ trunk/src/app/net/sf/gridarta/maincontrol/GUIMainControl.java 2010-05-30 20:49:32 UTC (rev 8055) @@ -592,13 +592,12 @@ } editorFactory.deleteLibraries(mainViewFrame); + final MapMenuManager<G, A, R> recentMapMenuManager = new MapMenuManager<G, A, R>(mapManager, mapViewsManager, globalSettings, mapImageCache, fileControl, new RecentMapMenuPreferences()); final JMenu recentMenu = MenuUtils.getMenu(menuBar, "recent"); - @Nullable final MapMenuManager<G, A, R> recentMapMenuManager; if (recentMenu == null) { log.warn("'main' menu bar does not define 'recent' menu."); - recentMapMenuManager = null; } else { - recentMapMenuManager = new MapMenuManager<G, A, R>(mapManager, mapViewsManager, recentMenu, globalSettings, mapImageCache, fileControl, new RecentMapMenuPreferences()); + recentMapMenuManager.setMenu(recentMenu); } final JMenu analyzeMenu = MenuUtils.getMenu(menuBar, "analyze"); if (analyzeMenu == null) { @@ -613,9 +612,7 @@ if (!pickmapChooserModel.isEmpty()) { objectChooser.movePickmapChooserToFront(); } - if (recentMapMenuManager != null) { - recentMapMenuManager.initRecent(); - } + recentMapMenuManager.initRecent(); //noinspection ResultOfObjectAllocationIgnored new RecentManager<G, A, R>(mapManager, recentMapMenuManager); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-05-30 20:41:15
|
Revision: 8054 http://gridarta.svn.sourceforge.net/gridarta/?rev=8054&view=rev Author: akirschbaum Date: 2010-05-30 20:41:09 +0000 (Sun, 30 May 2010) Log Message: ----------- Extract RecentManager from MapMenuManager. Modified Paths: -------------- trunk/src/app/net/sf/gridarta/gui/mapmenu/MapMenuManager.java trunk/src/app/net/sf/gridarta/maincontrol/GUIMainControl.java Added Paths: ----------- trunk/src/app/net/sf/gridarta/gui/misc/RecentManager.java Modified: trunk/src/app/net/sf/gridarta/gui/mapmenu/MapMenuManager.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/mapmenu/MapMenuManager.java 2010-05-30 20:13:08 UTC (rev 8053) +++ trunk/src/app/net/sf/gridarta/gui/mapmenu/MapMenuManager.java 2010-05-30 20:41:09 UTC (rev 8054) @@ -134,7 +134,6 @@ @Override public void mapCreated(@NotNull final MapControl<G, A, R> mapControl, final boolean interactive) { if (interactive) { - addRecent(mapControl.getMapModel(), null); final MapTracker mapTracker = new MapTracker(mapControl.getMapModel()); if (mapTrackers.put(mapControl, mapTracker) != null) { assert false; @@ -169,7 +168,7 @@ * @param mapModel the map model to update the entry for * @param oldMapFile the map file before the change */ - private void addRecent(@NotNull final MapModel<G, A, R> mapModel, @Nullable final File oldMapFile) { + public void addRecent(@NotNull final MapModel<G, A, R> mapModel, @Nullable final File oldMapFile) { if (oldMapFile != null) { removeRecent(oldMapFile); } Added: trunk/src/app/net/sf/gridarta/gui/misc/RecentManager.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/misc/RecentManager.java (rev 0) +++ trunk/src/app/net/sf/gridarta/gui/misc/RecentManager.java 2010-05-30 20:41:09 UTC (rev 8054) @@ -0,0 +1,76 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2010 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.misc; + +import net.sf.gridarta.gui.mapmenu.MapMenuManager; +import net.sf.gridarta.mapmanager.MapManager; +import net.sf.gridarta.mapmanager.MapManagerListener; +import net.sf.gridarta.model.archetype.Archetype; +import net.sf.gridarta.model.gameobject.GameObject; +import net.sf.gridarta.model.map.maparchobject.MapArchObject; +import net.sf.gridarta.model.map.mapcontrol.MapControl; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * Manages the recent menu. Creates new entries whenever a map is opened. + * @author Andreas Kirschbaum + */ +public class RecentManager<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> { + + /** + * Creates a new instance. + * @param mapManager the map manager to track for opened maps + * @param mapMenuManager the map menu manager to update + */ + public RecentManager(@NotNull final MapManager<G, A, R> mapManager, @NotNull final MapMenuManager<G, A, R> mapMenuManager) { + final MapManagerListener<G, A, R> mapManagerListener = new MapManagerListener<G, A, R>() { + + /** {@inheritDoc} */ + @Override + public void currentMapChanged(@Nullable final MapControl<G, A, R> mapControl) { + // ignore + } + + /** {@inheritDoc} */ + @Override + public void mapCreated(@NotNull final MapControl<G, A, R> mapControl, final boolean interactive) { + if (interactive) { + mapMenuManager.addRecent(mapControl.getMapModel(), null); + } + } + + /** {@inheritDoc} */ + @Override + public void mapClosing(@NotNull final MapControl<G, A, R> mapControl) { + // ignore + } + + /** {@inheritDoc} */ + @Override + public void mapClosed(@NotNull final MapControl<G, A, R> mapControl) { + // ignore + } + + }; + mapManager.addMapManagerListener(mapManagerListener); + } + +} // class RecentManager Property changes on: trunk/src/app/net/sf/gridarta/gui/misc/RecentManager.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF Modified: trunk/src/app/net/sf/gridarta/maincontrol/GUIMainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/maincontrol/GUIMainControl.java 2010-05-30 20:13:08 UTC (rev 8053) +++ trunk/src/app/net/sf/gridarta/maincontrol/GUIMainControl.java 2010-05-30 20:41:09 UTC (rev 8054) @@ -86,6 +86,7 @@ import net.sf.gridarta.gui.misc.MainView; import net.sf.gridarta.gui.misc.MainViewActions; import net.sf.gridarta.gui.misc.MapPreview; +import net.sf.gridarta.gui.misc.RecentManager; import net.sf.gridarta.gui.misc.StatusBar; import net.sf.gridarta.gui.newmap.NewMapDialogFactory; import net.sf.gridarta.gui.objectchooser.DefaultObjectChooser; @@ -615,7 +616,11 @@ if (recentMapMenuManager != null) { recentMapMenuManager.initRecent(); } + //noinspection ResultOfObjectAllocationIgnored + new RecentManager<G, A, R>(mapManager, recentMapMenuManager); + + //noinspection ResultOfObjectAllocationIgnored new AutoValidator<G, A, R>(validators, autoValidatorDefault, delayedMapModelListenerManager); mapManager.setFileControl(fileControl); shortcutsManager = new ShortcutsManager(ACTION_BUILDER); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-05-30 20:13:18
|
Revision: 8053 http://gridarta.svn.sourceforge.net/gridarta/?rev=8053&view=rev Author: akirschbaum Date: 2010-05-30 20:13:08 +0000 (Sun, 30 May 2010) Log Message: ----------- Rename 'recent' into 'mapmenu'. Modified Paths: -------------- trunk/src/app/net/sf/gridarta/maincontrol/GUIMainControl.java Added Paths: ----------- trunk/src/app/net/sf/gridarta/gui/mapmenu/ trunk/src/app/net/sf/gridarta/gui/mapmenu/MapMenuEntry.java trunk/src/app/net/sf/gridarta/gui/mapmenu/MapMenuManager.java trunk/src/app/net/sf/gridarta/gui/mapmenu/MapMenuPreferences.java trunk/src/app/net/sf/gridarta/gui/mapmenu/RecentMapMenuPreferences.java Removed Paths: ------------- trunk/src/app/net/sf/gridarta/gui/mapmenu/Recent.java trunk/src/app/net/sf/gridarta/gui/mapmenu/RecentManager.java trunk/src/app/net/sf/gridarta/gui/mapmenu/RecentPreferences.java trunk/src/app/net/sf/gridarta/gui/mapmenu/RecentRecentPreferences.java trunk/src/app/net/sf/gridarta/gui/recent/ Added: trunk/src/app/net/sf/gridarta/gui/mapmenu/MapMenuEntry.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/mapmenu/MapMenuEntry.java (rev 0) +++ trunk/src/app/net/sf/gridarta/gui/mapmenu/MapMenuEntry.java 2010-05-30 20:13:08 UTC (rev 8053) @@ -0,0 +1,223 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2010 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.mapmenu; + +import java.awt.event.ActionEvent; +import java.io.File; +import java.io.IOException; +import javax.swing.AbstractAction; +import javax.swing.Icon; +import javax.swing.ImageIcon; +import net.sf.gridarta.gui.map.mapview.MapViewsManager; +import net.sf.gridarta.gui.mapimagecache.MapImageCache; +import net.sf.gridarta.mapmanager.FileControl; +import net.sf.gridarta.model.archetype.Archetype; +import net.sf.gridarta.model.gameobject.GameObject; +import net.sf.gridarta.model.map.maparchobject.MapArchObject; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * An entry in a recent menu. It allows to re-open a recent map. + * @author Andreas Kirschbaum + */ +public class MapMenuEntry<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> extends AbstractAction { + + /** + * The serial version UID. + */ + private static final long serialVersionUID = 1L; + + /** + * Title = map name. + */ + @NotNull + private final String title; + + /** + * The {@link MapViewsManager} instance. + */ + @NotNull + private final MapViewsManager<G, A, R> mapViewsManager; + + /** + * The map {@link MapImageCache} to use. + */ + @NotNull + private final MapImageCache<G, A, R> mapImageCache; + + /** + * The {@link FileControl}. + */ + @NotNull + private final FileControl<G, A, R> fileControl; + + /** + * The {@link MapMenuPreferences} to use. + */ + @NotNull + private final MapMenuPreferences mapMenuPreferences; + + /** + * The map file. + */ + @NotNull + private final File mapFile; + + /** + * Create a MapMenuEntry. + * @param title title (map name) + * @param mapFile the map file + * @param mapsDirectory the maps directory + * @param mapViewsManager the map views manager instance + * @param mapImageCache the map image cache instance + * @param fileControl the file control + * @param mapMenuPreferences the recent preferences to use + */ + MapMenuEntry(@NotNull final String title, @NotNull final File mapFile, @NotNull final File mapsDirectory, @NotNull final MapViewsManager<G, A, R> mapViewsManager, @NotNull final MapImageCache<G, A, R> mapImageCache, @NotNull final FileControl<G, A, R> fileControl, @NotNull final MapMenuPreferences mapMenuPreferences) { + super(title); + this.mapFile = mapFile; + this.title = title; + this.mapViewsManager = mapViewsManager; + this.mapImageCache = mapImageCache; + this.fileControl = fileControl; + this.mapMenuPreferences = mapMenuPreferences; + putValue(SHORT_DESCRIPTION, mapMenuPreferences.getShortDescription(title, getShortMapFile(mapsDirectory, mapFile))); + putValue(SMALL_ICON, getIcon()); + putValue(NAME, title); + putValue(MNEMONIC_KEY, null); + } + + /** + * Returns the base name of a map file. + * @param mapsDirectory the maps directory + * @param mapFile the map file + * @return the base name + */ + @NotNull + private static String getShortMapFile(@NotNull final File mapsDirectory, @NotNull final File mapFile) { + String canonicalMapFile; + String canonicalMapsDirectory; + try { + canonicalMapFile = mapFile.getCanonicalPath(); + canonicalMapsDirectory = mapsDirectory.getCanonicalPath(); + } catch (final IOException ignored) { + canonicalMapFile = mapFile.getAbsolutePath(); + canonicalMapsDirectory = mapsDirectory.getAbsolutePath(); + } + + if (canonicalMapFile.startsWith(canonicalMapsDirectory)) { + return canonicalMapFile.substring(canonicalMapsDirectory.length()).replace('\\', '/'); + } else { + return canonicalMapFile.replace('\\', '/'); + } + } + + /** + * Create a MapMenuEntry from preferences. + * @param index index (starting with 1) + * @param mapsDirectory the maps directory + * @param mapViewsManager the map views manager instance + * @param mapImageCache the map image cache instance + * @param fileControl the file control + * @param mapMenuPreferences the recent preferences to use + */ + MapMenuEntry(final int index, @NotNull final File mapsDirectory, @NotNull final MapViewsManager<G, A, R> mapViewsManager, @NotNull final MapImageCache<G, A, R> mapImageCache, @NotNull final FileControl<G, A, R> fileControl, @NotNull final MapMenuPreferences mapMenuPreferences) { + this.mapViewsManager = mapViewsManager; + this.mapImageCache = mapImageCache; + this.fileControl = fileControl; + this.mapMenuPreferences = mapMenuPreferences; + title = mapMenuPreferences.getTitle(index - 1); + mapFile = mapMenuPreferences.getMapFile(index -1 ); + putValue(SHORT_DESCRIPTION, mapMenuPreferences.getShortDescription(title, getShortMapFile(mapsDirectory, mapFile))); + putValue(SMALL_ICON, getIcon()); + putValue(NAME, title); + putValue(MNEMONIC_KEY, null); + setIndex(index); + } + + /** + * Set the index used for title, key strokes and such. + * @param index index (starting with 1) + */ + public void setIndex(final int index) { + mapMenuPreferences.setInfo(index - 1, title, mapFile.getPath()); + } + + /** + * {@inheritDoc} + */ + @Override + public void actionPerformed(@NotNull final ActionEvent e) { + try { + mapViewsManager.openMapFileWithView(mapFile, null); + } catch (final IOException ex) { + fileControl.reportLoadError(mapFile, ex.getMessage()); + } + } + + /** + * Get the icon of this file. + * @return icon of this file + */ + @Nullable + private Icon getIcon() { + return new ImageIcon(mapImageCache.getOrCreateIcon(mapFile)); + } + + /** + * Returns the map file. + * @return the map file + */ + @NotNull + public File getMapFile() { + return mapFile; + } + + /** + * {@inheritDoc} + */ + @Override + public boolean equals(@Nullable final Object obj) { + return obj != null && obj instanceof MapMenuEntry && mapFile.equals(((MapMenuEntry<?, ?, ?>) obj).mapFile); + } + + /** + * {@inheritDoc} + */ + @Override + public int hashCode() { + return mapFile.hashCode(); + } + + /** + * {@inheritDoc} + */ + @NotNull + @Override + protected Object clone() { + try { + return super.clone(); + } catch (final CloneNotSupportedException ex) { + throw new AssertionError(ex); + } + } + +} // class MapMenuEntry Property changes on: trunk/src/app/net/sf/gridarta/gui/mapmenu/MapMenuEntry.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF Added: trunk/src/app/net/sf/gridarta/gui/mapmenu/MapMenuManager.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/mapmenu/MapMenuManager.java (rev 0) +++ trunk/src/app/net/sf/gridarta/gui/mapmenu/MapMenuManager.java 2010-05-30 20:13:08 UTC (rev 8053) @@ -0,0 +1,332 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2010 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.mapmenu; + +import java.io.File; +import java.util.IdentityHashMap; +import java.util.LinkedList; +import java.util.ListIterator; +import java.util.Map; +import java.util.Set; +import javax.swing.Action; +import javax.swing.JMenu; +import net.sf.gridarta.gui.map.mapview.MapViewsManager; +import net.sf.gridarta.gui.mapimagecache.MapImageCache; +import net.sf.gridarta.gui.utils.MenuUtils; +import net.sf.gridarta.mapmanager.FileControl; +import net.sf.gridarta.mapmanager.MapManager; +import net.sf.gridarta.mapmanager.MapManagerListener; +import net.sf.gridarta.model.archetype.Archetype; +import net.sf.gridarta.model.gameobject.GameObject; +import net.sf.gridarta.model.map.maparchobject.MapArchObject; +import net.sf.gridarta.model.map.mapcontrol.DefaultMapControl; +import net.sf.gridarta.model.map.mapcontrol.MapControl; +import net.sf.gridarta.model.map.mapcontrol.MapControlListener; +import net.sf.gridarta.model.map.mapmodel.MapModel; +import net.sf.gridarta.model.map.mapmodel.MapModelListener; +import net.sf.gridarta.model.map.mapmodel.MapSquare; +import net.sf.gridarta.model.map.validation.ErrorCollector; +import net.sf.gridarta.model.settings.GlobalSettings; +import net.sf.gridarta.utils.Size2D; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * Manages the recent menu entries. + * @author Andreas Kirschbaum + */ +public class MapMenuManager<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> { + + /** + * The {@link MapViewsManager} instance. + */ + @NotNull + private final MapViewsManager<G, A, R> mapViewsManager; + + /** + * List with mapMenuEntries. + */ + @NotNull + private final LinkedList<MapMenuEntry<G, A, R>> mapMenuEntries = new LinkedList<MapMenuEntry<G, A, R>>(); + + /** + * The "recent" menu to update. + * @serial + */ + @Nullable + private final JMenu recentMenu; + + /** + * The global settings instance. + */ + @NotNull + private final GlobalSettings globalSettings; + + /** + * The {@link MapImageCache} to use. + */ + @NotNull + private final MapImageCache<G, A, R> mapImageCache; + + /** + * The {@link FileControl}. + */ + @NotNull + private final FileControl<G, A, R> fileControl; + + /** + * The {@link MapMenuPreferences} to use. + */ + @NotNull + private final MapMenuPreferences mapMenuPreferences; + + /** + * Maps {@link MapControl} instances to associated {@link MapTracker} + * instances. + */ + @NotNull + private final Map<MapControl<G, A, R>, MapTracker> mapTrackers = new IdentityHashMap<MapControl<G, A, R>, MapTracker>(); + + /** + * Create a new instance. + * @param mapManager the map manager instance + * @param mapViewsManager the map views manager instance + * @param recentMenu menu for managing the recent entries + * @param globalSettings the global settings instance + * @param mapImageCache the map image cache instance + * @param fileControl the file control + * @param mapMenuPreferences the recent preferences to use + */ + public MapMenuManager(@NotNull final MapManager<G, A, R> mapManager, @NotNull final MapViewsManager<G, A, R> mapViewsManager, @Nullable final JMenu recentMenu, @NotNull final GlobalSettings globalSettings, @NotNull final MapImageCache<G, A, R> mapImageCache, @NotNull final FileControl<G, A, R> fileControl, @NotNull final MapMenuPreferences mapMenuPreferences) { + this.mapViewsManager = mapViewsManager; + this.recentMenu = recentMenu; + this.globalSettings = globalSettings; + this.mapImageCache = mapImageCache; + this.fileControl = fileControl; + this.mapMenuPreferences = mapMenuPreferences; + + final MapManagerListener<G, A, R> mapManagerListener = new MapManagerListener<G, A, R>() { + + /** {@inheritDoc} */ + @Override + public void currentMapChanged(@Nullable final MapControl<G, A, R> mapControl) { + // ignore + } + + /** {@inheritDoc} */ + @Override + public void mapCreated(@NotNull final MapControl<G, A, R> mapControl, final boolean interactive) { + if (interactive) { + addRecent(mapControl.getMapModel(), null); + final MapTracker mapTracker = new MapTracker(mapControl.getMapModel()); + if (mapTrackers.put(mapControl, mapTracker) != null) { + assert false; + } + mapControl.addMapControlListener(mapTracker); + mapControl.getMapModel().addMapModelListener(mapTracker); + } + } + + /** {@inheritDoc} */ + @Override + public void mapClosing(@NotNull final MapControl<G, A, R> mapControl) { + // ignore + } + + /** {@inheritDoc} */ + @Override + public void mapClosed(@NotNull final MapControl<G, A, R> mapControl) { + final MapTracker mapTracker = mapTrackers.remove(mapControl); + if (mapTracker != null) { + mapControl.getMapModel().removeMapModelListener(mapTracker); + mapControl.removeMapControlListener(mapTracker); + } + } + + }; + mapManager.addMapManagerListener(mapManagerListener); + } + + /** + * Adds or updates an entry of the recent files. + * @param mapModel the map model to update the entry for + * @param oldMapFile the map file before the change + */ + private void addRecent(@NotNull final MapModel<G, A, R> mapModel, @Nullable final File oldMapFile) { + if (oldMapFile != null) { + removeRecent(oldMapFile); + } + + final File mapFile = mapModel.getMapFile(); + if (mapFile == null) { + return; + } + + final String title = mapModel.getMapArchObject().getMapName(); + final MapMenuEntry<G, A, R> mapMenuEntry = new MapMenuEntry<G, A, R>(title, mapFile, globalSettings.getMapsDirectory(), mapViewsManager, mapImageCache, fileControl, mapMenuPreferences); + mapMenuEntries.remove(mapMenuEntry); // remove old entry to get new entry at first pos. + mapMenuEntries.addFirst(mapMenuEntry); + // Now remove those that are too many. + // Please keep this while loop as the constant 10 might be replaced by a preferences var + int i = 0; + for (final ListIterator<MapMenuEntry<G, A, R>> it = mapMenuEntries.listIterator(); it.hasNext();) { + it.next().setIndex(it.nextIndex()); // this looks bogus but it's intentionally currentIndex + 1 + if (++i > 10) { + it.remove(); + } + } + mapMenuPreferences.setNum(mapMenuEntries.size()); + updateRecent(mapMenuEntries); + } + + /** + * Removes a recent entry for given map file. Does nothing if no such entry + * exists. + * @param mapFile the map file + */ + private void removeRecent(@NotNull final File mapFile) { + if (mapFile.exists()) { + return; + } + + for (int i = 0; i < mapMenuEntries.size(); i++) { + final MapMenuEntry<G, A, R> mapMenuEntry = mapMenuEntries.get(i); + if (mapMenuEntry.getMapFile().equals(mapFile)) { + mapMenuEntries.remove(i); + break; + } + } + } + + /** + * Initializes the recent state. + */ + public void initRecent() { + final File mapsDirectory = globalSettings.getMapsDirectory(); + final int numRecents = mapMenuPreferences.getNum(); + for (int i = 0; i < numRecents; i++) { + mapMenuEntries.add(new MapMenuEntry<G, A, R>(i + 1, mapsDirectory, mapViewsManager, mapImageCache, fileControl, mapMenuPreferences)); + } + updateRecent(mapMenuEntries); + } + + /** + * Update the recent menu. + * @param recents current mapMenuEntries + */ + private void updateRecent(@NotNull final Iterable<MapMenuEntry<G, A, R>> recents) { + if (recentMenu == null) { + return; + } + + MenuUtils.removeAll(recentMenu); + for (final Action recent : recents) { + recentMenu.add(recent); + } + } + + /** + * Watches a {@link MapModel} for map file changes. + * @author Andreas Kirschbaum + */ + private class MapTracker implements MapControlListener<G, A, R>, MapModelListener<G, A, R> { + + /** + * The {@link MapModel} to track. + */ + @NotNull + private final MapModel<G, A, R> mapModel; + + /** + * Creates a new instance. + * @param mapModel the map model to track + */ + private MapTracker(@NotNull final MapModel<G, A, R> mapModel) { + this.mapModel = mapModel; + } + + /** + * {@inheritDoc} + */ + @Override + public void mapSizeChanged(@NotNull final MapModel<G, A, R> mapModel, @NotNull final Size2D newSize) { + // ignore + } + + /** + * {@inheritDoc} + */ + @Override + public void mapSquaresChanged(@NotNull final Set<MapSquare<G, A, R>> mapSquares) { + // ignore + } + + /** + * {@inheritDoc} + */ + @Override + public void mapObjectsChanged(@NotNull final Set<G> gameObjects, @NotNull final Set<G> transientGameObjects) { + // ignore + } + + /** + * {@inheritDoc} + */ + @Override + public void mapMetaChanged() { + // ignore + } + + /** + * {@inheritDoc} + */ + @Override + public void errorsChanged(@NotNull final ErrorCollector<G, A, R> errors) { + // ignore + } + + /** + * {@inheritDoc} + */ + @Override + public void mapFileChanged(@Nullable final File oldMapFile) { + addRecent(mapModel, oldMapFile); + } + + /** + * {@inheritDoc} + */ + @Override + public void modifiedChanged(@NotNull final MapModel<G, A, R> mapModel) { + // ignore + } + + /** + * {@inheritDoc} + */ + @Override + public void saved(@NotNull final DefaultMapControl<G, A, R> mapControl) { + assert mapModel == mapControl.getMapModel(); + addRecent(mapModel, null); + } + + } + +} // class MapMenuManager Property changes on: trunk/src/app/net/sf/gridarta/gui/mapmenu/MapMenuManager.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF Added: trunk/src/app/net/sf/gridarta/gui/mapmenu/MapMenuPreferences.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/mapmenu/MapMenuPreferences.java (rev 0) +++ trunk/src/app/net/sf/gridarta/gui/mapmenu/MapMenuPreferences.java 2010-05-30 20:13:08 UTC (rev 8053) @@ -0,0 +1,78 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2010 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.mapmenu; + +import java.io.File; +import java.io.Serializable; +import org.jetbrains.annotations.NotNull; + +/** + * Interfaces for classes providing access to preference values needed by {@link + * MapMenuManager} instances. + * @author Andreas Kirschbaum + */ +public interface MapMenuPreferences extends Serializable { + + /** + * Returns the number of active entries. + * @return the number of active entries + */ + int getNum(); + + /** + * Sets the number of active entries. + * @param num the number of active entries + */ + void setNum(int num); + + /** + * Updates information about one entry. + * @param index the entry's index + * @param title the entry's title + * @param path the entry's path + */ + void setInfo(int index, @NotNull String title, @NotNull String path); + + /** + * Returns an entry's title. + * @param index the entry's index + * @return the entry's title + */ + @NotNull + String getTitle(int index); + + /** + * Returns an entry's map path. + * @param index the entry's index + * @return the entry's map path + */ + @NotNull + File getMapFile(int index); + + /** + * Returns the short description for an entry. + * @param title the entry's title + * @param mapFile the entry's short map file + * @return the short description + */ + @NotNull + String getShortDescription(@NotNull final String title, @NotNull final String mapFile); + +} // interface MapMenuPreferences Property changes on: trunk/src/app/net/sf/gridarta/gui/mapmenu/MapMenuPreferences.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF Deleted: trunk/src/app/net/sf/gridarta/gui/mapmenu/Recent.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/recent/Recent.java 2010-05-30 12:36:47 UTC (rev 8052) +++ trunk/src/app/net/sf/gridarta/gui/mapmenu/Recent.java 2010-05-30 20:13:08 UTC (rev 8053) @@ -1,223 +0,0 @@ -/* - * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. - * Copyright (C) 2000-2010 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.recent; - -import java.awt.event.ActionEvent; -import java.io.File; -import java.io.IOException; -import javax.swing.AbstractAction; -import javax.swing.Icon; -import javax.swing.ImageIcon; -import net.sf.gridarta.gui.map.mapview.MapViewsManager; -import net.sf.gridarta.gui.mapimagecache.MapImageCache; -import net.sf.gridarta.mapmanager.FileControl; -import net.sf.gridarta.model.archetype.Archetype; -import net.sf.gridarta.model.gameobject.GameObject; -import net.sf.gridarta.model.map.maparchobject.MapArchObject; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -/** - * An entry in a recent menu. It allows to re-open a recent map. - * @author Andreas Kirschbaum - */ -public class Recent<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> extends AbstractAction { - - /** - * The serial version UID. - */ - private static final long serialVersionUID = 1L; - - /** - * Title = map name. - */ - @NotNull - private final String title; - - /** - * The {@link MapViewsManager} instance. - */ - @NotNull - private final MapViewsManager<G, A, R> mapViewsManager; - - /** - * The map {@link MapImageCache} to use. - */ - @NotNull - private final MapImageCache<G, A, R> mapImageCache; - - /** - * The {@link FileControl}. - */ - @NotNull - private final FileControl<G, A, R> fileControl; - - /** - * The {@link RecentPreferences} to use. - */ - @NotNull - private final RecentPreferences recentPreferences; - - /** - * The map file. - */ - @NotNull - private final File mapFile; - - /** - * Create a Recent. - * @param title title (map name) - * @param mapFile the map file - * @param mapsDirectory the maps directory - * @param mapViewsManager the map views manager instance - * @param mapImageCache the map image cache instance - * @param fileControl the file control - * @param recentPreferences the recent preferences to use - */ - Recent(@NotNull final String title, @NotNull final File mapFile, @NotNull final File mapsDirectory, @NotNull final MapViewsManager<G, A, R> mapViewsManager, @NotNull final MapImageCache<G, A, R> mapImageCache, @NotNull final FileControl<G, A, R> fileControl, @NotNull final RecentPreferences recentPreferences) { - super(title); - this.mapFile = mapFile; - this.title = title; - this.mapViewsManager = mapViewsManager; - this.mapImageCache = mapImageCache; - this.fileControl = fileControl; - this.recentPreferences = recentPreferences; - putValue(SHORT_DESCRIPTION, recentPreferences.getShortDescription(title, getShortMapFile(mapsDirectory, mapFile))); - putValue(SMALL_ICON, getIcon()); - putValue(NAME, title); - putValue(MNEMONIC_KEY, null); - } - - /** - * Returns the base name of a map file. - * @param mapsDirectory the maps directory - * @param mapFile the map file - * @return the base name - */ - @NotNull - private static String getShortMapFile(@NotNull final File mapsDirectory, @NotNull final File mapFile) { - String canonicalMapFile; - String canonicalMapsDirectory; - try { - canonicalMapFile = mapFile.getCanonicalPath(); - canonicalMapsDirectory = mapsDirectory.getCanonicalPath(); - } catch (final IOException ignored) { - canonicalMapFile = mapFile.getAbsolutePath(); - canonicalMapsDirectory = mapsDirectory.getAbsolutePath(); - } - - if (canonicalMapFile.startsWith(canonicalMapsDirectory)) { - return canonicalMapFile.substring(canonicalMapsDirectory.length()).replace('\\', '/'); - } else { - return canonicalMapFile.replace('\\', '/'); - } - } - - /** - * Create a Recent from preferences. - * @param index index (starting with 1) - * @param mapsDirectory the maps directory - * @param mapViewsManager the map views manager instance - * @param mapImageCache the map image cache instance - * @param fileControl the file control - * @param recentPreferences the recent preferences to use - */ - Recent(final int index, @NotNull final File mapsDirectory, @NotNull final MapViewsManager<G, A, R> mapViewsManager, @NotNull final MapImageCache<G, A, R> mapImageCache, @NotNull final FileControl<G, A, R> fileControl, @NotNull final RecentPreferences recentPreferences) { - this.mapViewsManager = mapViewsManager; - this.mapImageCache = mapImageCache; - this.fileControl = fileControl; - this.recentPreferences = recentPreferences; - title = recentPreferences.getTitle(index - 1); - mapFile = recentPreferences.getMapFile(index -1 ); - putValue(SHORT_DESCRIPTION, recentPreferences.getShortDescription(title, getShortMapFile(mapsDirectory, mapFile))); - putValue(SMALL_ICON, getIcon()); - putValue(NAME, title); - putValue(MNEMONIC_KEY, null); - setIndex(index); - } - - /** - * Set the index used for title, key strokes and such. - * @param index index (starting with 1) - */ - public void setIndex(final int index) { - recentPreferences.setInfo(index - 1, title, mapFile.getPath()); - } - - /** - * {@inheritDoc} - */ - @Override - public void actionPerformed(@NotNull final ActionEvent e) { - try { - mapViewsManager.openMapFileWithView(mapFile, null); - } catch (final IOException ex) { - fileControl.reportLoadError(mapFile, ex.getMessage()); - } - } - - /** - * Get the icon of this file. - * @return icon of this file - */ - @Nullable - private Icon getIcon() { - return new ImageIcon(mapImageCache.getOrCreateIcon(mapFile)); - } - - /** - * Returns the map file. - * @return the map file - */ - @NotNull - public File getMapFile() { - return mapFile; - } - - /** - * {@inheritDoc} - */ - @Override - public boolean equals(@Nullable final Object obj) { - return obj != null && obj instanceof Recent && mapFile.equals(((Recent<?, ?, ?>) obj).mapFile); - } - - /** - * {@inheritDoc} - */ - @Override - public int hashCode() { - return mapFile.hashCode(); - } - - /** - * {@inheritDoc} - */ - @NotNull - @Override - protected Object clone() { - try { - return super.clone(); - } catch (final CloneNotSupportedException ex) { - throw new AssertionError(ex); - } - } - -} // class Recent Deleted: trunk/src/app/net/sf/gridarta/gui/mapmenu/RecentManager.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/recent/RecentManager.java 2010-05-30 12:36:47 UTC (rev 8052) +++ trunk/src/app/net/sf/gridarta/gui/mapmenu/RecentManager.java 2010-05-30 20:13:08 UTC (rev 8053) @@ -1,332 +0,0 @@ -/* - * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. - * Copyright (C) 2000-2010 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.recent; - -import java.io.File; -import java.util.IdentityHashMap; -import java.util.LinkedList; -import java.util.ListIterator; -import java.util.Map; -import java.util.Set; -import javax.swing.Action; -import javax.swing.JMenu; -import net.sf.gridarta.gui.map.mapview.MapViewsManager; -import net.sf.gridarta.gui.mapimagecache.MapImageCache; -import net.sf.gridarta.gui.utils.MenuUtils; -import net.sf.gridarta.mapmanager.FileControl; -import net.sf.gridarta.mapmanager.MapManager; -import net.sf.gridarta.mapmanager.MapManagerListener; -import net.sf.gridarta.model.archetype.Archetype; -import net.sf.gridarta.model.gameobject.GameObject; -import net.sf.gridarta.model.map.maparchobject.MapArchObject; -import net.sf.gridarta.model.map.mapcontrol.DefaultMapControl; -import net.sf.gridarta.model.map.mapcontrol.MapControl; -import net.sf.gridarta.model.map.mapcontrol.MapControlListener; -import net.sf.gridarta.model.map.mapmodel.MapModel; -import net.sf.gridarta.model.map.mapmodel.MapModelListener; -import net.sf.gridarta.model.map.mapmodel.MapSquare; -import net.sf.gridarta.model.map.validation.ErrorCollector; -import net.sf.gridarta.model.settings.GlobalSettings; -import net.sf.gridarta.utils.Size2D; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -/** - * Manages the recent menu entries. - * @author Andreas Kirschbaum - */ -public class RecentManager<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> { - - /** - * The {@link MapViewsManager} instance. - */ - @NotNull - private final MapViewsManager<G, A, R> mapViewsManager; - - /** - * List with recents. - */ - @NotNull - private final LinkedList<Recent<G, A, R>> recents = new LinkedList<Recent<G, A, R>>(); - - /** - * The "recent" menu to update. - * @serial - */ - @Nullable - private final JMenu recentMenu; - - /** - * The global settings instance. - */ - @NotNull - private final GlobalSettings globalSettings; - - /** - * The {@link MapImageCache} to use. - */ - @NotNull - private final MapImageCache<G, A, R> mapImageCache; - - /** - * The {@link FileControl}. - */ - @NotNull - private final FileControl<G, A, R> fileControl; - - /** - * The {@link RecentPreferences} to use. - */ - @NotNull - private final RecentPreferences recentPreferences; - - /** - * Maps {@link MapControl} instances to associated {@link MapTracker} - * instances. - */ - @NotNull - private final Map<MapControl<G, A, R>, MapTracker> mapTrackers = new IdentityHashMap<MapControl<G, A, R>, MapTracker>(); - - /** - * Create a new instance. - * @param mapManager the map manager instance - * @param mapViewsManager the map views manager instance - * @param recentMenu menu for managing the recent entries - * @param globalSettings the global settings instance - * @param mapImageCache the map image cache instance - * @param fileControl the file control - * @param recentPreferences the recent preferences to use - */ - public RecentManager(@NotNull final MapManager<G, A, R> mapManager, @NotNull final MapViewsManager<G, A, R> mapViewsManager, @Nullable final JMenu recentMenu, @NotNull final GlobalSettings globalSettings, @NotNull final MapImageCache<G, A, R> mapImageCache, @NotNull final FileControl<G, A, R> fileControl, @NotNull final RecentPreferences recentPreferences) { - this.mapViewsManager = mapViewsManager; - this.recentMenu = recentMenu; - this.globalSettings = globalSettings; - this.mapImageCache = mapImageCache; - this.fileControl = fileControl; - this.recentPreferences = recentPreferences; - - final MapManagerListener<G, A, R> mapManagerListener = new MapManagerListener<G, A, R>() { - - /** {@inheritDoc} */ - @Override - public void currentMapChanged(@Nullable final MapControl<G, A, R> mapControl) { - // ignore - } - - /** {@inheritDoc} */ - @Override - public void mapCreated(@NotNull final MapControl<G, A, R> mapControl, final boolean interactive) { - if (interactive) { - addRecent(mapControl.getMapModel(), null); - final MapTracker mapTracker = new MapTracker(mapControl.getMapModel()); - if (mapTrackers.put(mapControl, mapTracker) != null) { - assert false; - } - mapControl.addMapControlListener(mapTracker); - mapControl.getMapModel().addMapModelListener(mapTracker); - } - } - - /** {@inheritDoc} */ - @Override - public void mapClosing(@NotNull final MapControl<G, A, R> mapControl) { - // ignore - } - - /** {@inheritDoc} */ - @Override - public void mapClosed(@NotNull final MapControl<G, A, R> mapControl) { - final MapTracker mapTracker = mapTrackers.remove(mapControl); - if (mapTracker != null) { - mapControl.getMapModel().removeMapModelListener(mapTracker); - mapControl.removeMapControlListener(mapTracker); - } - } - - }; - mapManager.addMapManagerListener(mapManagerListener); - } - - /** - * Adds or updates an entry of the recent files. - * @param mapModel the map model to update the entry for - * @param oldMapFile the map file before the change - */ - private void addRecent(@NotNull final MapModel<G, A, R> mapModel, @Nullable final File oldMapFile) { - if (oldMapFile != null) { - removeRecent(oldMapFile); - } - - final File mapFile = mapModel.getMapFile(); - if (mapFile == null) { - return; - } - - final String title = mapModel.getMapArchObject().getMapName(); - final Recent<G, A, R> recent = new Recent<G, A, R>(title, mapFile, globalSettings.getMapsDirectory(), mapViewsManager, mapImageCache, fileControl, recentPreferences); - recents.remove(recent); // remove old entry to get new entry at first pos. - recents.addFirst(recent); - // Now remove those that are too many. - // Please keep this while loop as the constant 10 might be replaced by a preferences var - int i = 0; - for (final ListIterator<Recent<G, A, R>> it = recents.listIterator(); it.hasNext();) { - it.next().setIndex(it.nextIndex()); // this looks bogus but it's intentionally currentIndex + 1 - if (++i > 10) { - it.remove(); - } - } - recentPreferences.setNum(recents.size()); - updateRecent(recents); - } - - /** - * Removes a recent entry for given map file. Does nothing if no such entry - * exists. - * @param mapFile the map file - */ - private void removeRecent(@NotNull final File mapFile) { - if (mapFile.exists()) { - return; - } - - for (int i = 0; i < recents.size(); i++) { - final Recent<G, A, R> recent = recents.get(i); - if (recent.getMapFile().equals(mapFile)) { - recents.remove(i); - break; - } - } - } - - /** - * Initializes the recent state. - */ - public void initRecent() { - final File mapsDirectory = globalSettings.getMapsDirectory(); - final int numRecents = recentPreferences.getNum(); - for (int i = 0; i < numRecents; i++) { - recents.add(new Recent<G, A, R>(i + 1, mapsDirectory, mapViewsManager, mapImageCache, fileControl, recentPreferences)); - } - updateRecent(recents); - } - - /** - * Update the recent menu. - * @param recents current recents - */ - private void updateRecent(@NotNull final Iterable<Recent<G, A, R>> recents) { - if (recentMenu == null) { - return; - } - - MenuUtils.removeAll(recentMenu); - for (final Action recent : recents) { - recentMenu.add(recent); - } - } - - /** - * Watches a {@link MapModel} for map file changes. - * @author Andreas Kirschbaum - */ - private class MapTracker implements MapControlListener<G, A, R>, MapModelListener<G, A, R> { - - /** - * The {@link MapModel} to track. - */ - @NotNull - private final MapModel<G, A, R> mapModel; - - /** - * Creates a new instance. - * @param mapModel the map model to track - */ - private MapTracker(@NotNull final MapModel<G, A, R> mapModel) { - this.mapModel = mapModel; - } - - /** - * {@inheritDoc} - */ - @Override - public void mapSizeChanged(@NotNull final MapModel<G, A, R> mapModel, @NotNull final Size2D newSize) { - // ignore - } - - /** - * {@inheritDoc} - */ - @Override - public void mapSquaresChanged(@NotNull final Set<MapSquare<G, A, R>> mapSquares) { - // ignore - } - - /** - * {@inheritDoc} - */ - @Override - public void mapObjectsChanged(@NotNull final Set<G> gameObjects, @NotNull final Set<G> transientGameObjects) { - // ignore - } - - /** - * {@inheritDoc} - */ - @Override - public void mapMetaChanged() { - // ignore - } - - /** - * {@inheritDoc} - */ - @Override - public void errorsChanged(@NotNull final ErrorCollector<G, A, R> errors) { - // ignore - } - - /** - * {@inheritDoc} - */ - @Override - public void mapFileChanged(@Nullable final File oldMapFile) { - addRecent(mapModel, oldMapFile); - } - - /** - * {@inheritDoc} - */ - @Override - public void modifiedChanged(@NotNull final MapModel<G, A, R> mapModel) { - // ignore - } - - /** - * {@inheritDoc} - */ - @Override - public void saved(@NotNull final DefaultMapControl<G, A, R> mapControl) { - assert mapModel == mapControl.getMapModel(); - addRecent(mapModel, null); - } - - } - -} // class RecentManager Added: trunk/src/app/net/sf/gridarta/gui/mapmenu/RecentMapMenuPreferences.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/mapmenu/RecentMapMenuPreferences.java (rev 0) +++ trunk/src/app/net/sf/gridarta/gui/mapmenu/RecentMapMenuPreferences.java 2010-05-30 20:13:08 UTC (rev 8053) @@ -0,0 +1,101 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2010 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.mapmenu; + +import java.io.File; +import java.util.prefs.Preferences; +import net.sf.gridarta.MainControl; +import net.sf.japi.swing.action.ActionBuilder; +import net.sf.japi.swing.action.ActionBuilderFactory; +import org.jetbrains.annotations.NotNull; + +/** + * A {@link MapMenuPreferences} for recent menu entries. + * @author Andreas Kirschbaum + */ +public class RecentMapMenuPreferences implements MapMenuPreferences { + + /** + * The serial version UID. + */ + private static final long serialVersionUID = 1L; + + /** + * The {@link Preferences}. + */ + @NotNull + private static final Preferences preferences = Preferences.userNodeForPackage(MainControl.class); + + /** + * The {@link ActionBuilder}. + */ + @NotNull + private static final ActionBuilder ACTION_BUILDER = ActionBuilderFactory.getInstance().getActionBuilder("net.sf.gridarta"); + + @Override + public int getNum() { + return preferences.getInt("recentNum", 0); + } + + /** + * {@inheritDoc} + */ + @Override + public void setNum(final int num) { + preferences.putInt("recentNum", num); + } + + /** + * {@inheritDoc} + */ + @Override + public void setInfo(final int index, @NotNull final String title, @NotNull final String path) { + preferences.put("recentTitle[" + Integer.toString(index - 1) + ']', title); + preferences.put("recentFilename[" + Integer.toString(index - 1) + ']', path); + } + + /** + * {@inheritDoc} + */ + @NotNull + @Override + public String getTitle(final int index) { + return preferences.get("recentTitle[" + Integer.toString(index - 1) + ']', ""); + } + + /** + * {@inheritDoc} + */ + @NotNull + @Override + public File getMapFile(final int index) { + return new File(preferences.get("recentFilename[" + Integer.toString(index - 1) + ']', "")); + } + + /** + * {@inheritDoc} + */ + @NotNull + @Override + public String getShortDescription(@NotNull final String title, @NotNull final String mapFile) { + return ACTION_BUILDER.format("recentItem.shortdescriptionformat", title, mapFile); + } + +} // class RecentMapMenuPreferences Property changes on: trunk/src/app/net/sf/gridarta/gui/mapmenu/RecentMapMenuPreferences.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF Deleted: trunk/src/app/net/sf/gridarta/gui/mapmenu/RecentPreferences.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/recent/RecentPreferences.java 2010-05-30 12:36:47 UTC (rev 8052) +++ trunk/src/app/net/sf/gridarta/gui/mapmenu/RecentPreferences.java 2010-05-30 20:13:08 UTC (rev 8053) @@ -1,78 +0,0 @@ -/* - * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. - * Copyright (C) 2000-2010 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.recent; - -import java.io.File; -import java.io.Serializable; -import org.jetbrains.annotations.NotNull; - -/** - * Interfaces for classes providing access to preference values needed by {@link - * RecentManager} instances. - * @author Andreas Kirschbaum - */ -public interface RecentPreferences extends Serializable { - - /** - * Returns the number of active entries. - * @return the number of active entries - */ - int getNum(); - - /** - * Sets the number of active entries. - * @param num the number of active entries - */ - void setNum(int num); - - /** - * Updates information about one entry. - * @param index the entry's index - * @param title the entry's title - * @param path the entry's path - */ - void setInfo(int index, @NotNull String title, @NotNull String path); - - /** - * Returns an entry's title. - * @param index the entry's index - * @return the entry's title - */ - @NotNull - String getTitle(int index); - - /** - * Returns an entry's map path. - * @param index the entry's index - * @return the entry's map path - */ - @NotNull - File getMapFile(int index); - - /** - * Returns the short description for an entry. - * @param title the entry's title - * @param mapFile the entry's short map file - * @return the short description - */ - @NotNull - String getShortDescription(@NotNull final String title, @NotNull final String mapFile); - -} // interface RecentPreferences Deleted: trunk/src/app/net/sf/gridarta/gui/mapmenu/RecentRecentPreferences.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/recent/RecentRecentPreferences.java 2010-05-30 12:36:47 UTC (rev 8052) +++ trunk/src/app/net/sf/gridarta/gui/mapmenu/RecentRecentPreferences.java 2010-05-30 20:13:08 UTC (rev 8053) @@ -1,101 +0,0 @@ -/* - * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. - * Copyright (C) 2000-2010 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.recent; - -import java.io.File; -import java.util.prefs.Preferences; -import net.sf.gridarta.MainControl; -import net.sf.japi.swing.action.ActionBuilder; -import net.sf.japi.swing.action.ActionBuilderFactory; -import org.jetbrains.annotations.NotNull; - -/** - * A {@link RecentPreferences} for recent menu entries. - * @author Andreas Kirschbaum - */ -public class RecentRecentPreferences implements RecentPreferences { - - /** - * The serial version UID. - */ - private static final long serialVersionUID = 1L; - - /** - * The {@link Preferences}. - */ - @NotNull - private static final Preferences preferences = Preferences.userNodeForPackage(MainControl.class); - - /** - * The {@link ActionBuilder}. - */ - @NotNull - private static final ActionBuilder ACTION_BUILDER = ActionBuilderFactory.getInstance().getActionBuilder("net.sf.gridarta"); - - @Override - public int getNum() { - return preferences.getInt("recentNum", 0); - } - - /** - * {@inheritDoc} - */ - @Override - public void setNum(final int num) { - preferences.putInt("recentNum", num); - } - - /** - * {@inheritDoc} - */ - @Override - public void setInfo(final int index, @NotNull final String title, @NotNull final String path) { - preferences.put("recentTitle[" + Integer.toString(index - 1) + ']', title); - preferences.put("recentFilename[" + Integer.toString(index - 1) + ']', path); - } - - /** - * {@inheritDoc} - */ - @NotNull - @Override - public String getTitle(final int index) { - return preferences.get("recentTitle[" + Integer.toString(index - 1) + ']', ""); - } - - /** - * {@inheritDoc} - */ - @NotNull - @Override - public File getMapFile(final int index) { - return new File(preferences.get("recentFilename[" + Integer.toString(index - 1) + ']', "")); - } - - /** - * {@inheritDoc} - */ - @NotNull - @Override - public String getShortDescription(@NotNull final String title, @NotNull final String mapFile) { - return ACTION_BUILDER.format("recentItem.shortdescriptionformat", title, mapFile); - } - -} // class RecentRecentPreferences Modified: trunk/src/app/net/sf/gridarta/maincontrol/GUIMainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/maincontrol/GUIMainControl.java 2010-05-30 12:36:47 UTC (rev 8052) +++ trunk/src/app/net/sf/gridarta/maincontrol/GUIMainControl.java 2010-05-30 20:13:08 UTC (rev 8053) @@ -76,6 +76,8 @@ import net.sf.gridarta.gui.mapdesktop.WindowMenuManager; import net.sf.gridarta.gui.mapfiles.MapFolderTreeActions; import net.sf.gridarta.gui.mapimagecache.MapImageCache; +import net.sf.gridarta.gui.mapmenu.MapMenuManager; +import net.sf.gridarta.gui.mapmenu.RecentMapMenuPreferences; import net.sf.gridarta.gui.mappropertiesdialog.MapPropertiesDialogFactory; import net.sf.gridarta.gui.mapuserlistener.MapUserListenerManager; import net.sf.gridarta.gui.misc.About; @@ -90,8 +92,6 @@ import net.sf.gridarta.gui.pickmapchooser.PickmapChooserControl; import net.sf.gridarta.gui.pickmapchooser.PickmapChooserModel; import net.sf.gridarta.gui.prefs.AppPreferencesModel; -import net.sf.gridarta.gui.recent.RecentManager; -import net.sf.gridarta.gui.recent.RecentRecentPreferences; import net.sf.gridarta.gui.replacedialog.ReplaceDialogManager; import net.sf.gridarta.gui.script.ScriptController; import net.sf.gridarta.gui.script.parameter.PluginParameterViewFactory; @@ -592,12 +592,12 @@ editorFactory.deleteLibraries(mainViewFrame); final JMenu recentMenu = MenuUtils.getMenu(menuBar, "recent"); - @Nullable final RecentManager<G, A, R> recentManager; + @Nullable final MapMenuManager<G, A, R> recentMapMenuManager; if (recentMenu == null) { log.warn("'main' menu bar does not define 'recent' menu."); - recentManager = null; + recentMapMenuManager = null; } else { - recentManager = new RecentManager<G, A, R>(mapManager, mapViewsManager, recentMenu, globalSettings, mapImageCache, fileControl, new RecentRecentPreferences()); + recentMapMenuManager = new MapMenuManager<G, A, R>(mapManager, mapViewsManager, recentMenu, globalSettings, mapImageCache, fileControl, new RecentMapMenuPreferences()); } final JMenu analyzeMenu = MenuUtils.getMenu(menuBar, "analyze"); if (analyzeMenu == null) { @@ -612,8 +612,8 @@ if (!pickmapChooserModel.isEmpty()) { objectChooser.movePickmapChooserToFront(); } - if (recentManager != null) { - recentManager.initRecent(); + if (recentMapMenuManager != null) { + recentMapMenuManager.initRecent(); } //noinspection ResultOfObjectAllocationIgnored new AutoValidator<G, A, R>(validators, autoValidatorDefault, delayedMapModelListenerManager); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-05-30 15:30:03
|
Revision: 8048 http://gridarta.svn.sourceforge.net/gridarta/?rev=8048&view=rev Author: akirschbaum Date: 2010-05-30 12:25:12 +0000 (Sun, 30 May 2010) Log Message: ----------- Fix typos. Modified Paths: -------------- trunk/src/app/net/sf/gridarta/maincontrol/GUIMainControl.java Modified: trunk/src/app/net/sf/gridarta/maincontrol/GUIMainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/maincontrol/GUIMainControl.java 2010-05-30 12:24:15 UTC (rev 8047) +++ trunk/src/app/net/sf/gridarta/maincontrol/GUIMainControl.java 2010-05-30 12:25:12 UTC (rev 8048) @@ -294,7 +294,7 @@ private final ImageCreator<G, A, R> imageCreator; /** - * The {@link ScriptEditControl} istance. + * The {@link ScriptEditControl} instance. */ @NotNull private final ScriptEditControl scriptEditControl; @@ -317,7 +317,7 @@ * yet created. */ @Nullable - private PreferencesGroup prefsGroup = null; + private PreferencesGroup preferencesGroup = null; /** * The {@link AppPreferencesModel} instance. @@ -665,10 +665,10 @@ */ @ActionMethod public void options() { - if (prefsGroup == null) { - prefsGroup = editorFactory.createPreferencesGroup(globalSettings, validators, appPreferencesModel, exitConnectorModel, configSourceFactory); + if (preferencesGroup == null) { + preferencesGroup = editorFactory.createPreferencesGroup(globalSettings, validators, appPreferencesModel, exitConnectorModel, configSourceFactory); } - PreferencesPane.showPreferencesDialog(mainViewFrame, prefsGroup, false); + PreferencesPane.showPreferencesDialog(mainViewFrame, preferencesGroup, false); } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-05-30 12:36:53
|
Revision: 8052 http://gridarta.svn.sourceforge.net/gridarta/?rev=8052&view=rev Author: akirschbaum Date: 2010-05-30 12:36:47 +0000 (Sun, 30 May 2010) Log Message: ----------- Suppress warnings. Modified Paths: -------------- trunk/src/app/net/sf/gridarta/maincontrol/GUIMainControl.java Modified: trunk/src/app/net/sf/gridarta/maincontrol/GUIMainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/maincontrol/GUIMainControl.java 2010-05-30 12:35:13 UTC (rev 8051) +++ trunk/src/app/net/sf/gridarta/maincontrol/GUIMainControl.java 2010-05-30 12:36:47 UTC (rev 8052) @@ -502,18 +502,25 @@ final GameObjectAttributesTab<G, A, R> textEditorTab = new TextEditorTab<G, A, R>(gameObjectAttributesModel, archetypeTypeSet); final GameObjectTab<G, A, R> gameObjectTab = new GameObjectTab<G, A, R>("gameObject", gameObjectAttributesControl, Location.BOTTOM, 0, true); + //noinspection ResultOfObjectAllocationIgnored new About(mainViewFrame); + //noinspection ResultOfObjectAllocationIgnored new FindArchetypesDialogManager<G, A, R>(mainViewFrame, archetypeChooserControl, objectChooser, archetypeTypeSet); + //noinspection ResultOfObjectAllocationIgnored new UndoControl<G, A, R>(mapManager, gameObjectFactory, gameObjectMatchers); final Action exitAction = ActionUtils.newAction(ACTION_BUILDER, "Other", this, "exit"); final MapFolderTreeActions<G, A, R> mapFolderTreeActions = new MapFolderTreeActions<G, A, R>(mapFolderTree, newMapDialogFactory, "createPickmapFolder", "deletePickmapFolder", "confirmDeletePickmapFolder", "deletePickmapFolderNotEmpty"); + //noinspection ResultOfObjectAllocationIgnored new MapActions<G, A, R>(mainViewFrame, mainViewFrame, mapManager, mapViewManager, exitMatcher, FileFilters.mapFileFilter, selectedSquareModel, directionMap, allowRandomMapParameters, mapPropertiesDialogFactory, mapViewSettings, mapPathNormalizer, mapViewsManager, fileControl); final ViewActions<G, A, R> viewActions = new ViewActions<G, A, R>(mapViewSettings, mapManager); + //noinspection ResultOfObjectAllocationIgnored new MapFileActions<G, A, R>(imageCreator2, mapManager, mapViewsManager, mapViewManager, fileControl, mainViewFrame); + //noinspection ResultOfObjectAllocationIgnored new MainActions<G, A, R>(replaceDialogManager, mainViewFrame, globalSettings, validators, mapViewSettings, archetypeSet, copyBuffer, objectChooser, mapManager, mapViewManager, resources, faceObjectProviders, insertionModeSet, exiter); final HelpActions helpActions = new HelpActions(mainViewFrame); ActionUtils.newActions(ACTION_BUILDER, "Map", newMapDialogFactory, "newMap"); ActionUtils.newActions(ACTION_BUILDER, "Tool", this, "cleanCompletelyBlockedSquares", "collectSpells", "controlClient", "controlServer", "gc", "options", "shortcuts", "zoom"); + //noinspection ResultOfObjectAllocationIgnored new MapCursorActions<G, A, R>(gameObjectAttributesDialogFactory, mapViewManager, selectedSquareControl, selectedSquareModel); ActionUtils.newAction(ACTION_BUILDER, "Script", scriptEditControl, "newScript"); ActionUtils.newAction(ACTION_BUILDER, "Script", fileControl, "editScript"); @@ -534,11 +541,13 @@ mainView.addTab(new Tab("objects", objectChooser, Location.LEFT, 3, true)); exitConnectorModel = new ExitConnectorModel(); // XXX: should be part of DefaultMainControl final ExitConnectorActions<G, A, R> exitConnectorActions = new ExitConnectorActions<G, A, R>(exitConnectorModel, exitMatcher, archetypeSet, mapManager, fileControl, pathManager, insertionModeSet); // XXX: should be part of DefaultMainControl + //noinspection ResultOfObjectAllocationIgnored new ExitConnectorController<G, A, R>(exitConnectorActions, exitConnectorModel, mapViewManager); final JMenu windowMenu = MenuUtils.getMenu(menuBar, "window"); if (windowMenu == null) { log.warn("'main' menu bar does not define 'window' menu."); } else { + //noinspection ResultOfObjectAllocationIgnored new WindowMenuManager<G, A, R>(windowMenu, mapViewManager, aCloseAllMaps, mapDesktop); } final JMenu pickmapFoldersMenu = MenuUtils.getMenu(menuBar, "pickmapFolders"); @@ -596,6 +605,7 @@ } else { filterControl.createMenuEntries(analyzeMenu); } + //noinspection ResultOfObjectAllocationIgnored new MapUserListenerManager<G, A, R>(toolPalette, mapViewsManager, mapManager, pickmapManager); new Loader<G, A, R>(errorView, mapFolderTree, mapReaderFactory, pickmapManager, mapViewsManager).load(); @@ -605,6 +615,7 @@ if (recentManager != null) { recentManager.initRecent(); } + //noinspection ResultOfObjectAllocationIgnored new AutoValidator<G, A, R>(validators, autoValidatorDefault, delayedMapModelListenerManager); mapManager.setFileControl(fileControl); shortcutsManager = new ShortcutsManager(ACTION_BUILDER); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-05-30 12:35:23
|
Revision: 8051 http://gridarta.svn.sourceforge.net/gridarta/?rev=8051&view=rev Author: akirschbaum Date: 2010-05-30 12:35:13 +0000 (Sun, 30 May 2010) Log Message: ----------- Defer creation of actions. Modified Paths: -------------- trunk/src/app/net/sf/gridarta/maincontrol/GUIMainControl.java Modified: trunk/src/app/net/sf/gridarta/maincontrol/GUIMainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/maincontrol/GUIMainControl.java 2010-05-30 12:27:22 UTC (rev 8050) +++ trunk/src/app/net/sf/gridarta/maincontrol/GUIMainControl.java 2010-05-30 12:35:13 UTC (rev 8051) @@ -465,7 +465,6 @@ final InsertionModeSet<G, A, R> insertionModeSet = new InsertionModeSet<G, A, R>(topmostInsertionMode); final CopyBuffer<G, A, R> copyBuffer = new CopyBuffer<G, A, R>(mapViewSettings, gameObjectFactory, mapArchObjectFactory, mapControlFactory, insertionModeSet); final ReplaceDialogManager<G, A, R> replaceDialogManager = new ReplaceDialogManager<G, A, R>(mainViewFrame, copyBuffer, objectChooser, mapViewManager, faceObjectProviders, insertionModeSet); - new About(mainViewFrame); exiter = new DefaultExiter(mainViewFrame); scriptEditControl = new ScriptEditControl(scriptFileFilter, scriptExtension, mainViewFrame, globalSettings.getMapsDirectory(), preferences, exiter); final TextAreaDefaults textAreaDefaults = new TextAreaDefaults(scriptEditControl); @@ -498,13 +497,14 @@ final File scriptsFile = new File(globalSettings.getMapsDirectory(), scriptsDir); scriptControl = new ScriptController<G, A, R>(filterControl, scriptParameters, mainViewFrame, pluginParameterViewFactory, scriptsFile, scriptModel, pluginParameterFactory, scriptExecutor, systemIcons); final ToolPalette<G, A, R> toolPalette = new ToolPalette<G, A, R>(mapViewSettings, selectedSquareView, selectedSquareModel, objectChooser, pickmapChooserControl, floorMatcher, wallMatcher, monsterMatcher, insertionModeSet); - new FindArchetypesDialogManager<G, A, R>(mainViewFrame, archetypeChooserControl, objectChooser, archetypeTypeSet); - new UndoControl<G, A, R>(mapManager, gameObjectFactory, gameObjectMatchers); updaterManager = new UpdaterManager(exiter, mapManager, mainViewFrame, gridartaJarFilename); final GameObjectAttributesTab<G, A, R> textEditorTab = new TextEditorTab<G, A, R>(gameObjectAttributesModel, archetypeTypeSet); final GameObjectTab<G, A, R> gameObjectTab = new GameObjectTab<G, A, R>("gameObject", gameObjectAttributesControl, Location.BOTTOM, 0, true); + new About(mainViewFrame); + new FindArchetypesDialogManager<G, A, R>(mainViewFrame, archetypeChooserControl, objectChooser, archetypeTypeSet); + new UndoControl<G, A, R>(mapManager, gameObjectFactory, gameObjectMatchers); final Action exitAction = ActionUtils.newAction(ACTION_BUILDER, "Other", this, "exit"); final MapFolderTreeActions<G, A, R> mapFolderTreeActions = new MapFolderTreeActions<G, A, R>(mapFolderTree, newMapDialogFactory, "createPickmapFolder", "deletePickmapFolder", "confirmDeletePickmapFolder", "deletePickmapFolderNotEmpty"); new MapActions<G, A, R>(mainViewFrame, mainViewFrame, mapManager, mapViewManager, exitMatcher, FileFilters.mapFileFilter, selectedSquareModel, directionMap, allowRandomMapParameters, mapPropertiesDialogFactory, mapViewSettings, mapPathNormalizer, mapViewsManager, fileControl); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-05-30 12:27:28
|
Revision: 8050 http://gridarta.svn.sourceforge.net/gridarta/?rev=8050&view=rev Author: akirschbaum Date: 2010-05-30 12:27:22 +0000 (Sun, 30 May 2010) Log Message: ----------- Remove unused code. Modified Paths: -------------- trunk/src/app/net/sf/gridarta/maincontrol/GUIMainControl.java Modified: trunk/src/app/net/sf/gridarta/maincontrol/GUIMainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/maincontrol/GUIMainControl.java 2010-05-30 12:26:06 UTC (rev 8049) +++ trunk/src/app/net/sf/gridarta/maincontrol/GUIMainControl.java 2010-05-30 12:27:22 UTC (rev 8050) @@ -21,12 +21,8 @@ import java.awt.BorderLayout; import java.awt.Container; -import java.io.BufferedReader; import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; import java.io.IOException; -import java.io.InputStreamReader; import java.util.MissingResourceException; import java.util.ResourceBundle; import java.util.prefs.Preferences; @@ -288,12 +284,6 @@ private final RendererFactory<G, A, R> rendererFactory; /** - * The {@link ImageCreator} instance. - */ - @NotNull - private final ImageCreator<G, A, R> imageCreator; - - /** * The {@link ScriptEditControl} instance. */ @NotNull @@ -450,7 +440,7 @@ this.validators = validators; this.scriptExecutor = scriptExecutor; final ArchetypeChooserControl<G, A, R> archetypeChooserControl = new ArchetypeChooserControl<G, A, R>(archetypeChooserModel, createDirectionPane, faceObjectProviders); - imageCreator = new ImageCreator<G, A, R>(mapManager, rendererFactory); + final ImageCreator<G, A, R> imageCreator = new ImageCreator<G, A, R>(mapManager, rendererFactory); final ImageCreator2<G, A, R> imageCreator2 = new ImageCreator2<G, A, R>(globalSettings, imageCreator); spellUtils = spellFile != null ? new SpellsUtils(spellFile) : null; appPreferencesModel = editorFactory.createAppPreferencesModel(); @@ -789,38 +779,6 @@ mainView.handleThrowable(t); } - public void processFile(final String fileList) throws IOException { - try { - final FileInputStream fis = new FileInputStream(fileList); - try { - final InputStreamReader isr = new InputStreamReader(fis); - try { - final BufferedReader reader = new BufferedReader(isr); - try { - while (true) { - final String in = reader.readLine(); - final String out = reader.readLine(); - if (in == null || out == null) { - log.info("done."); - return; - } - imageCreator.makeImage(new File(in), new File(out)); - } - } finally { - reader.close(); - } - } finally { - isr.close(); - } - } finally { - fis.close(); - } - } catch (final FileNotFoundException e) { - log.warn("Read error: ", e); - throw e; - } - } - /** * The action method for "collectSpells". Opens the dialog to import spell * definitions. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-05-30 12:26:13
|
Revision: 8049 http://gridarta.svn.sourceforge.net/gridarta/?rev=8049&view=rev Author: akirschbaum Date: 2010-05-30 12:26:06 +0000 (Sun, 30 May 2010) Log Message: ----------- Explicitly initialize fields. Modified Paths: -------------- trunk/src/app/net/sf/gridarta/maincontrol/GUIMainControl.java Modified: trunk/src/app/net/sf/gridarta/maincontrol/GUIMainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/maincontrol/GUIMainControl.java 2010-05-30 12:25:12 UTC (rev 8048) +++ trunk/src/app/net/sf/gridarta/maincontrol/GUIMainControl.java 2010-05-30 12:26:06 UTC (rev 8049) @@ -329,13 +329,13 @@ * The {@link ProcessRunner} instance that controls the client. Set to * <code>null</code> if not yet created. */ - private ProcessRunner controlClient; + private ProcessRunner controlClient = null; /** * The {@link ProcessRunner} instance that controls the server. Set to * <code>null</code> if not yet created. */ - private ProcessRunner controlServer; + private ProcessRunner controlServer = null; /** * The {@link SpellsUtils} instance. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-05-30 12:24:21
|
Revision: 8047 http://gridarta.svn.sourceforge.net/gridarta/?rev=8047&view=rev Author: akirschbaum Date: 2010-05-30 12:24:15 +0000 (Sun, 30 May 2010) Log Message: ----------- Add/update comments. Modified Paths: -------------- trunk/src/app/net/sf/gridarta/maincontrol/GUIMainControl.java Modified: trunk/src/app/net/sf/gridarta/maincontrol/GUIMainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/maincontrol/GUIMainControl.java 2010-05-30 12:09:54 UTC (rev 8046) +++ trunk/src/app/net/sf/gridarta/maincontrol/GUIMainControl.java 2010-05-30 12:24:15 UTC (rev 8047) @@ -188,36 +188,34 @@ import org.jetbrains.annotations.Nullable; /** - * <code>GUIMainControl</code> is a central class that's used for access on - * global data structures / collections and global functions related to the - * GUI. + * Creates the main GUI of Gridarta. * @author <a href="mailto:ch...@ri...">Christian Hujer</a> * @author Andreas Kirschbaum */ public class GUIMainControl<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> implements ThrowableHandler<Throwable> { /** - * Action Builder. + * The {@link ActionBuilder}. */ private static final ActionBuilder ACTION_BUILDER = ActionBuilderFactory.getInstance().getActionBuilder("net.sf.gridarta"); /** - * The Logger for printing log messages. + * The logger for printing log messages. */ private static final Category log = Logger.getLogger(GUIMainControl.class); /** - * Preferences. + * The {@link Preferences}. */ private static final Preferences preferences = Preferences.userNodeForPackage(MainControl.class); /** - * The status bar instance. + * The {@link StatusBar} instance. */ private final StatusBar<G, A, R> statusBar; /** - * The pickmap chooser control. + * The {@link PickmapChooserControl}. */ @NotNull private final PickmapChooserControl<G, A, R> pickmapChooserControl; @@ -229,25 +227,31 @@ private final JFrame mainViewFrame; /** - * The main view. + * The {@link MainView} instance. */ @NotNull private final MainView mainView; /** - * The script controller. + * The {@link ScriptController} instance. */ @NotNull private final ScriptController<G, A, R> scriptControl; + /** + * The {@link ScriptExecutor} instance. + */ @NotNull private final ScriptExecutor<G, A, R> scriptExecutor; + /** + * The {@link MapManager} instance. + */ @NotNull private final MapManager<G, A, R> mapManager; /** - * The {@link MapViewsManager}. + * The {@link MapViewsManager} instance. */ @NotNull private final MapViewsManager<G, A, R> mapViewsManager; @@ -258,42 +262,60 @@ @NotNull private final GlobalSettings globalSettings; + /** + * The {@link EditorFactory} instance. + */ @NotNull private final EditorFactory<G, A, R> editorFactory; + /** + * The extensions of event script files. + */ @NotNull private final String scriptExtension; + /** + * The {@link DelegatingMapValidator} instance that contains all defined map + * validators. + */ @NotNull private final DelegatingMapValidator<G, A, R> validators; + /** + * The {@link RendererFactory} instance. + */ @NotNull private final RendererFactory<G, A, R> rendererFactory; /** - * The {@link ImageCreator} to use. + * The {@link ImageCreator} instance. */ @NotNull private final ImageCreator<G, A, R> imageCreator; /** - * The {@link ScriptEditControl} to use. + * The {@link ScriptEditControl} istance. */ @NotNull private final ScriptEditControl scriptEditControl; /** - * The factory for creating new maps or pickmaps. + * The {@link NewMapDialogFactory} instance for creating new maps or + * pickmaps. */ @NotNull private final NewMapDialogFactory<G, A, R> newMapDialogFactory; /** - * The file control instance. + * The {@link FileControl} instance. */ @NotNull private final FileControl<G, A, R> fileControl; + /** + * The {@link PreferencesGroup} instance. Set to <code>null</code> if not + * yet created. + */ @Nullable private PreferencesGroup prefsGroup = null; @@ -304,38 +326,43 @@ private final AppPreferencesModel appPreferencesModel; /** - * Client Control Component. + * The {@link ProcessRunner} instance that controls the client. Set to + * <code>null</code> if not yet created. */ private ProcessRunner controlClient; /** - * Server Control Component. + * The {@link ProcessRunner} instance that controls the server. Set to + * <code>null</code> if not yet created. */ private ProcessRunner controlServer; + /** + * The {@link SpellsUtils} instance. + */ @Nullable private final SpellsUtils spellUtils; /** - * The {@link ExitConnectorModel}. + * The {@link ExitConnectorModel} instance. */ @NotNull private final ExitConnectorModel exitConnectorModel; /** - * The {@link ArchetypeSet}. + * The {@link ArchetypeSet} instance. */ @NotNull private final ArchetypeSet<G, A, R> archetypeSet; /** - * The {@link ConfigSourceFactory}. + * The {@link ConfigSourceFactory} instance. */ @NotNull private final ConfigSourceFactory configSourceFactory; /** - * The {@link Exiter} for terminating the application. + * The {@link Exiter} instance for terminating the application. */ @NotNull private final Exiter exiter; @@ -355,51 +382,60 @@ /** * Creates a new instance. * @param createDirectionPane whether the direction panel should be created - * @param mapManager the map manager - * @param pickmapManager the pickmap manager - * @param archetypeSet the archetype set - * @param faceObjects the face objects - * @param globalSettings the global settings - * @param mapViewSettings the map view settings - * @param mapControlFactory the map control factory - * @param mapReaderFactory the map reader factory - * @param mapArchObjectFactory the map arch object factory - * @param treasureTree the treasure tree - * @param archetypeTypeSet the archetype type set + * @param mapManager the map manager instance + * @param pickmapManager the pickmap manager instance + * @param archetypeSet the archetype set instance + * @param faceObjects the face objects instance + * @param globalSettings the global settings instance + * @param mapViewSettings the map view settings instance + * @param mapControlFactory the map control factory instance + * @param mapReaderFactory the map reader factory instance + * @param mapArchObjectFactory the map arch object factory instance + * @param treasureTree the treasure tree instance + * @param archetypeTypeSet the archetype type set instance * @param compassIcon the icon to display in the selected square view; * @param gridartaJarFilename the filename of the editor's .jar file * @param mapFileFilter the file filter for map files * @param scriptFileFilter the file filter for script files * @param scriptExtension the file extension for script files + * @param validators the map validators * @param resources the resources to collect + * @param gameObjectMatchers the game object matchers instance + * @param errorView the error view for reporting errors + * @param attributeRangeChecker the attribute range checker instance * @param lockedItemsTypeNumbers the type numbers of game objects being * locked items * @param scriptsDir the plugin scripts directory - * @param scriptArchEditor the script arch editor to use - * @param scriptedEventEditor the scripted event editor to use - * @param scriptArchData the script arch data to use - * @param scriptArchDataUtils the script arch data utils to use - * @param scriptArchUtils the script arch utils to use + * @param scriptModel the script model instance + * @param archetypeChooserModel the archetype chooser model instance + * @param animationObjects the animation objects instance + * @param scriptArchEditor the script arch editor instance + * @param scriptedEventEditor the scripted event editor instance + * @param scriptArchData the script arch data instance + * @param scriptArchDataUtils the script arch data utils instance + * @param scriptArchUtils the script arch utils instance * @param autoValidatorDefault whether the auto validator is enabled by + * @param spellFile the spell file instance * @param allowRandomMapParameters whether exit paths may point to random * map parameters * @param directionMap maps relative direction to map window direction - * @param editorFactory the editor factory to use + * @param editorFactory the editor factory instance * @param faceObjectProviders the face object providers for looking up * faces - * @param gameObjectFactory the game object factory to use + * @param pluginParameterFactory the plugin parameter factory instance + * @param gameObjectFactory the game object factory instance * @param pathManager the path manager for converting path names * @param cacheFiles the cache files for icon and preview images - * @param gameObjectSpells the game object spells to use - * @param numberSpells the numbered spells to use + * @param gameObjectSpells the game object spells instance + * @param numberSpells the numbered spells instance * @param undefinedSpellIndex the index for "no spell" * @param systemIcons the system icons for creating icons - * @param configSourceFactory the config source factory to use + * @param configSourceFactory the config source factory instance * @param topmostInsertionMode the "topmost" insertion mode instance - * @param rendererFactory the renderer factory to use - * @param filterControl the filter control to use - * @param scriptExecutor the script executor to use - * @param scriptParameters the script parameters to use + * @param rendererFactory the renderer factory instance + * @param filterControl the filter control instance + * @param scriptExecutor the script executor instance + * @param scriptParameters the script parameters instance */ public GUIMainControl(final boolean createDirectionPane, @NotNull final AbstractMapManager<G, A, R> mapManager, @NotNull final MapManager<G, A, R> pickmapManager, @NotNull final ArchetypeSet<G, A, R> archetypeSet, @NotNull final FaceObjects faceObjects, @NotNull final GlobalSettings globalSettings, @NotNull final MapViewSettings mapViewSettings, @NotNull final MapControlFactory<G, A, R> mapControlFactory, @NotNull final MapReaderFactory<G, A> mapReaderFactory, final MapArchObjectFactory<A> mapArchObjectFactory, @NotNull final TreasureTree treasureTree, @NotNull final ArchetypeTypeSet archetypeTypeSet, @Nullable final ImageIcon compassIcon, @NotNull final String gridartaJarFilename, @NotNull final FileFilter mapFileFilter, @NotNull final FileFilter scriptFileFilter, @NotNull final String scriptExtension, @NotNull final DelegatingMapValidator<G, A, R> validators, @NotNull final AbstractResources<G, A, R> resources, @NotNull final GameObjectMatchers gameObjectMatchers, @NotNull final ErrorView errorView, @NotNull final AttributeRangeChecker<G, A, R> attributeRangeChecker, @NotNull final int[] lockedItemsTypeNumbers, @NotNull final String scriptsDir, @NotNull final ScriptModel<G, A, R> scriptModel, @NotNull final ArchetypeChooserModel<G, A, R> archetypeChooserModel, @NotNull final AnimationObjects animationObjects, @NotNull final ScriptArchEditor<G, A, R> scriptArchEditor, @NotNull final ScriptedEventEditor<G, A, R> scriptedEventEditor, @NotNull final ScriptArchData<G, A, R> scriptArchData, @NotNull final ScriptArchDataUtils<G, A, R> scriptArchDataUtils, @NotNull final ScriptArchUtils scriptArchUtils, final boolean autoValidatorDefault, @Nullable final String spellFile, final boolean allowRandomMapParameters, @NotNull final int[] directionMap, @NotNull final EditorFactory<G, A, R> editorFactory, @NotNull final FaceObjectProviders faceObjectProviders, @NotNull final PluginParameterFactory<G, A, R> pluginParameterFactory, final GameObjectFactory<G, A, R> gameObjectFactory, @NotNull final PathManager pathManager, @NotNull final CacheFiles cacheFiles, @NotNull final Spells<GameObjectSpell<G, A, R>> gameObjectSpells, @NotNull final Spells<NumberSpell> numberSpells, final int undefinedSpellIndex, @NotNull final SystemIcons systemIcons, @NotNull final ConfigSourceFactory configSourceFactory, @NotNull final InsertionMode<G, A, R> topmostInsertionMode, @NotNull final RendererFactory<G, A, R> rendererFactory, @NotNull final FilterControl<G, A, R> filterControl, @NotNull final ScriptExecutor<G, A, R> scriptExecutor, @NotNull final ScriptParameters scriptParameters) { this.archetypeSet = archetypeSet; @@ -601,7 +637,7 @@ } /** - * Runs the garbage collection. + * The action method for "gc". Runs the garbage collection. */ @ActionMethod public void gc() { @@ -611,7 +647,8 @@ } /** - * Calls for zooming preview tool. + * The action method for "zoom". Opens the dialog to create zoomed images of + * the current map. */ @ActionMethod public void zoom() { @@ -623,6 +660,9 @@ new MapPreview(rendererFactory.newSimpleMapRenderer(mapControl.getMapModel()).getFullImage()); } + /** + * The action method for "options". Opens the options dialog. + */ @ActionMethod public void options() { if (prefsGroup == null) { @@ -632,7 +672,8 @@ } /** - * The action method for "configure shortcuts". + * The action method for "shortcuts". Opens the dialog to configure keyboard + * shortcuts. */ @ActionMethod public void shortcuts() { @@ -640,7 +681,8 @@ } /** - * Invoked when user wants to exit from the program. + * The action method for "exit". Invoked when user wants to exit from the + * program. */ @ActionMethod public void exit() { @@ -686,7 +728,8 @@ } /** - * Control the server. + * The action method for "controlServer". Opens the dialog to control the + * server. */ @ActionMethod public void controlServer() { @@ -700,7 +743,8 @@ } /** - * Control the client. + * The action method for "controlClient". Opens the dialog to control the + * client. */ @ActionMethod public void controlClient() { @@ -778,7 +822,8 @@ } /** - * Collect Spells. + * The action method for "collectSpells". Opens the dialog to import spell + * definitions. */ @ActionMethod public void collectSpells() { @@ -788,7 +833,8 @@ } /** - * Cleans all completely blocked squares of a map. + * The action method for "cleanCompletelyBlockedSquares". Cleans all + * completely blocked squares of a map. * @fixme this implementation does not take care of multi square objects. */ @ActionMethod This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-05-30 12:10:00
|
Revision: 8046 http://gridarta.svn.sourceforge.net/gridarta/?rev=8046&view=rev Author: akirschbaum Date: 2010-05-30 12:09:54 +0000 (Sun, 30 May 2010) Log Message: ----------- Rename variable name. Modified Paths: -------------- trunk/src/app/net/sf/gridarta/maincontrol/GUIMainControl.java Modified: trunk/src/app/net/sf/gridarta/maincontrol/GUIMainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/maincontrol/GUIMainControl.java 2010-05-30 12:08:38 UTC (rev 8045) +++ trunk/src/app/net/sf/gridarta/maincontrol/GUIMainControl.java 2010-05-30 12:09:54 UTC (rev 8046) @@ -595,7 +595,7 @@ private static String getBuildNumberAsString() { try { return ResourceBundle.getBundle("build").getString("build.number"); - } catch (final MissingResourceException e) { + } catch (final MissingResourceException ignored) { return "unknown version"; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-05-30 12:08:44
|
Revision: 8045 http://gridarta.svn.sourceforge.net/gridarta/?rev=8045&view=rev Author: akirschbaum Date: 2010-05-30 12:08:38 +0000 (Sun, 30 May 2010) Log Message: ----------- Catch more specific exception.?\194?\141 Modified Paths: -------------- trunk/src/app/net/sf/gridarta/maincontrol/GUIMainControl.java Modified: trunk/src/app/net/sf/gridarta/maincontrol/GUIMainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/maincontrol/GUIMainControl.java 2010-05-30 12:06:46 UTC (rev 8044) +++ trunk/src/app/net/sf/gridarta/maincontrol/GUIMainControl.java 2010-05-30 12:08:38 UTC (rev 8045) @@ -24,6 +24,7 @@ import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; +import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStreamReader; import java.util.MissingResourceException; @@ -770,7 +771,7 @@ } finally { fis.close(); } - } catch (final IOException e) { + } catch (final FileNotFoundException e) { log.warn("Read error: ", e); throw e; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-05-30 12:06:52
|
Revision: 8044 http://gridarta.svn.sourceforge.net/gridarta/?rev=8044&view=rev Author: akirschbaum Date: 2010-05-30 12:06:46 +0000 (Sun, 30 May 2010) Log Message: ----------- Rename 'archfiles' to 'archetypes'. Modified Paths: -------------- trunk/src/app/net/sf/gridarta/maincontrol/GUIMainControl.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/src/app/net/sf/gridarta/maincontrol/GUIMainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/maincontrol/GUIMainControl.java 2010-05-30 12:01:51 UTC (rev 8043) +++ trunk/src/app/net/sf/gridarta/maincontrol/GUIMainControl.java 2010-05-30 12:06:46 UTC (rev 8044) @@ -824,7 +824,7 @@ updaterManager.startup(); if (archetypeSet.getArchetypeCount() == 0) { - ACTION_BUILDER.showMessageDialog(mainViewFrame, "loadArchesNoArchfiles"); + ACTION_BUILDER.showMessageDialog(mainViewFrame, "loadArchesNoArchetypes"); } openFiles(args); Modified: trunk/src/app/net/sf/gridarta/messages.properties =================================================================== --- trunk/src/app/net/sf/gridarta/messages.properties 2010-05-30 12:01:51 UTC (rev 8043) +++ trunk/src/app/net/sf/gridarta/messages.properties 2010-05-30 12:06:46 UTC (rev 8044) @@ -470,8 +470,10 @@ shrinkMapSizeDialogSouthBreaksWestTiling=removing empty squares from the south border breaks west tiling shrinkMapSizeDialogSouthBreaksEastTiling=removing empty squares from the south border breaks east tiling -loadArchesNoArchfiles.title=No archfiles -loadArchesNoArchfiles.message=No archfiles could be found. If you have no archfiles\nyet, you need to download them. If you do, make sure\nthe path is correct under menu ''File->Options''. +loadArchesNoArchetypes.title=No Archetypes +loadArchesNoArchetypes.message=No archetypes could be found. If you have no archetypes\n\ + yet, you need to download them. If you do, make sure\n\ + the path is correct under menu ''File|Options...''. loadDuplicateFace=Duplicate face: ''{0}''; Files: ''{1}'' and ''{2}''. I will ignore this duplicate. loadIllegalFace=Illegal face: ''{0}''; File: ''{1}''. I will ignore this face. @@ -1032,7 +1034,7 @@ optionsShowMainToolbar.text=Display toolbar optionsShowMainToolbar.shortdescription=Display the main window''s toolbar. optionsResPaths=Resource Paths -optionsResArch=Archfiles +optionsResArch=Archetypes optionsResArch.shortdescription=Path name for archetype files optionsResMaps=Maps optionsResMaps.shortdescription=Path name for map files Modified: trunk/src/app/net/sf/gridarta/messages_de.properties =================================================================== --- trunk/src/app/net/sf/gridarta/messages_de.properties 2010-05-30 12:01:51 UTC (rev 8043) +++ trunk/src/app/net/sf/gridarta/messages_de.properties 2010-05-30 12:06:46 UTC (rev 8044) @@ -451,8 +451,10 @@ shrinkMapSizeDialogSouthBreaksWestTiling=l\xF6schen von leeren Feldern am s\xFCdlichen Kartenrand st\xF6rt Verbindung zu westlicher Karte shrinkMapSizeDialogSouthBreaksEastTiling=l\xF6schen von leeren Feldern am s\xFCdlichen Kartenrand st\xF6rt Verbindung zu \xF6stlicher Karte -loadArchesNoArchfiles.title=Keine Archetypen gefunden -loadArchesNoArchfiles.message=Es konnten keine Archetypen gefunden werden.\nBitte stellen Sie sicher, dass der Pfad\nunter ''Datei->Optionen...'' korrekt ist. +loadArchesNoArchetypes.title=Keine Archetypen gefunden +loadArchesNoArchetypes.message=Es konnten keine Archetypen gefunden werden.\n\ + Bitte stellen Sie sicher, dass der Pfad\n\ + unter ''Datei|Optionen...'' korrekt ist. loadDuplicateFace=Dopplete Grafik: ''{0}''; Dateien: ''{1}'' und ''{2}''. Die doppelte Grafik wird ignoriert. loadIllegalFace=Fehlerhafte Grafik: ''{0}''; Datei: ''{1}''. Die fehlerhafte Grafik wird ignoriert. Modified: trunk/src/app/net/sf/gridarta/messages_fr.properties =================================================================== --- trunk/src/app/net/sf/gridarta/messages_fr.properties 2010-05-30 12:01:51 UTC (rev 8043) +++ trunk/src/app/net/sf/gridarta/messages_fr.properties 2010-05-30 12:06:46 UTC (rev 8044) @@ -445,8 +445,8 @@ #shrinkMapSizeDialogSouthBreaksWestTiling= #shrinkMapSizeDialogSouthBreaksEastTiling= -#loadArchesNoArchfiles.title= -#loadArchesNoArchfiles.message= +#loadArchesNoArchetypes.title= +#loadArchesNoArchetypes.message= #loadDuplicateFace= #loadIllegalFace= Modified: trunk/src/app/net/sf/gridarta/messages_sv.properties =================================================================== --- trunk/src/app/net/sf/gridarta/messages_sv.properties 2010-05-30 12:01:51 UTC (rev 8043) +++ trunk/src/app/net/sf/gridarta/messages_sv.properties 2010-05-30 12:06:46 UTC (rev 8044) @@ -448,8 +448,10 @@ #shrinkMapSizeDialogSouthBreaksWestTiling= #shrinkMapSizeDialogSouthBreaksEastTiling= -loadArchesNoArchfiles.title=Inga arketypfiler -loadArchesNoArchfiles.message=Inga arketypfiler kunde hittas. Om du saknar arketypfiler\n m\xE5ste du ladda hem dom. Om du g\xF6r detta, se till\natt s\xF6kv\xE4gen under ''Arkiv->Inst\xE4llningar'' \xE4r korrekt. +loadArchesNoArchetypes.title=Inga arketypfiler +loadArchesNoArchetypes.message=Inga arketypfiler kunde hittas.\n\ + Om du saknar arketypfiler m\xE5ste du ladda hem dom. Om du g\xF6r detta,\n\ + se till att s\xF6kv\xE4gen under ''Arkiv|Inst\xE4llningar...'' \xE4r korrekt. loadDuplicateFace=Duplicerad bild: ''{0}''; Filer: ''{1}'' och ''{2}''. Jag kommer att ignorera detta duplikat. #loadIllegalFace= This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-05-30 12:01:58
|
Revision: 8043 http://gridarta.svn.sourceforge.net/gridarta/?rev=8043&view=rev Author: akirschbaum Date: 2010-05-30 12:01:51 +0000 (Sun, 30 May 2010) Log Message: ----------- Delay warnings message about no defined archetypes until the main window is shown. Modified Paths: -------------- trunk/src/app/net/sf/gridarta/maincontrol/GUIMainControl.java Modified: trunk/src/app/net/sf/gridarta/maincontrol/GUIMainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/maincontrol/GUIMainControl.java 2010-05-30 11:59:15 UTC (rev 8042) +++ trunk/src/app/net/sf/gridarta/maincontrol/GUIMainControl.java 2010-05-30 12:01:51 UTC (rev 8043) @@ -322,6 +322,12 @@ private final ExitConnectorModel exitConnectorModel; /** + * The {@link ArchetypeSet}. + */ + @NotNull + private final ArchetypeSet<G, A, R> archetypeSet; + + /** * The {@link ConfigSourceFactory}. */ @NotNull @@ -395,6 +401,7 @@ * @param scriptParameters the script parameters to use */ public GUIMainControl(final boolean createDirectionPane, @NotNull final AbstractMapManager<G, A, R> mapManager, @NotNull final MapManager<G, A, R> pickmapManager, @NotNull final ArchetypeSet<G, A, R> archetypeSet, @NotNull final FaceObjects faceObjects, @NotNull final GlobalSettings globalSettings, @NotNull final MapViewSettings mapViewSettings, @NotNull final MapControlFactory<G, A, R> mapControlFactory, @NotNull final MapReaderFactory<G, A> mapReaderFactory, final MapArchObjectFactory<A> mapArchObjectFactory, @NotNull final TreasureTree treasureTree, @NotNull final ArchetypeTypeSet archetypeTypeSet, @Nullable final ImageIcon compassIcon, @NotNull final String gridartaJarFilename, @NotNull final FileFilter mapFileFilter, @NotNull final FileFilter scriptFileFilter, @NotNull final String scriptExtension, @NotNull final DelegatingMapValidator<G, A, R> validators, @NotNull final AbstractResources<G, A, R> resources, @NotNull final GameObjectMatchers gameObjectMatchers, @NotNull final ErrorView errorView, @NotNull final AttributeRangeChecker<G, A, R> attributeRangeChecker, @NotNull final int[] lockedItemsTypeNumbers, @NotNull final String scriptsDir, @NotNull final ScriptModel<G, A, R> scriptModel, @NotNull final ArchetypeChooserModel<G, A, R> archetypeChooserModel, @NotNull final AnimationObjects animationObjects, @NotNull final ScriptArchEditor<G, A, R> scriptArchEditor, @NotNull final ScriptedEventEditor<G, A, R> scriptedEventEditor, @NotNull final ScriptArchData<G, A, R> scriptArchData, @NotNull final ScriptArchDataUtils<G, A, R> scriptArchDataUtils, @NotNull final ScriptArchUtils scriptArchUtils, final boolean autoValidatorDefault, @Nullable final String spellFile, final boolean allowRandomMapParameters, @NotNull final int[] directionMap, @NotNull final EditorFactory<G, A, R> editorFactory, @NotNull final FaceObjectProviders faceObjectProviders, @NotNull final PluginParameterFactory<G, A, R> pluginParameterFactory, final GameObjectFactory<G, A, R> gameObjectFactory, @NotNull final PathManager pathManager, @NotNull final CacheFiles cacheFiles, @NotNull final Spells<GameObjectSpell<G, A, R>> gameObjectSpells, @NotNull final Spells<NumberSpell> numberSpells, final int undefinedSpellIndex, @NotNull final SystemIcons systemIcons, @NotNull final ConfigSourceFactory configSourceFactory, @NotNull final InsertionMode<G, A, R> topmostInsertionMode, @NotNull final RendererFactory<G, A, R> rendererFactory, @NotNull final FilterControl<G, A, R> filterControl, @NotNull final ScriptExecutor<G, A, R> scriptExecutor, @NotNull final ScriptParameters scriptParameters) { + this.archetypeSet = archetypeSet; this.configSourceFactory = configSourceFactory; this.rendererFactory = rendererFactory; this.mapManager = mapManager; @@ -564,10 +571,6 @@ } new MapUserListenerManager<G, A, R>(toolPalette, mapViewsManager, mapManager, pickmapManager); - if (archetypeSet.getArchetypeCount() == 0) { - ACTION_BUILDER.showMessageDialog(mainViewFrame, "loadArchesNoArchfiles"); - } - new Loader<G, A, R>(errorView, mapFolderTree, mapReaderFactory, pickmapManager, mapViewsManager).load(); if (!pickmapChooserModel.isEmpty()) { objectChooser.movePickmapChooserToFront(); @@ -819,6 +822,11 @@ mainViewFrame.setVisible(true); TipOfTheDayManager.showAtStartup(mainViewFrame); updaterManager.startup(); + + if (archetypeSet.getArchetypeCount() == 0) { + ACTION_BUILDER.showMessageDialog(mainViewFrame, "loadArchesNoArchfiles"); + } + openFiles(args); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-05-30 11:59:22
|
Revision: 8042 http://gridarta.svn.sourceforge.net/gridarta/?rev=8042&view=rev Author: akirschbaum Date: 2010-05-30 11:59:15 +0000 (Sun, 30 May 2010) Log Message: ----------- Load pickmaps even if no archetypes are defined. Modified Paths: -------------- trunk/src/app/net/sf/gridarta/maincontrol/GUIMainControl.java Modified: trunk/src/app/net/sf/gridarta/maincontrol/GUIMainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/maincontrol/GUIMainControl.java 2010-05-30 08:48:46 UTC (rev 8041) +++ trunk/src/app/net/sf/gridarta/maincontrol/GUIMainControl.java 2010-05-30 11:59:15 UTC (rev 8042) @@ -566,12 +566,12 @@ if (archetypeSet.getArchetypeCount() == 0) { ACTION_BUILDER.showMessageDialog(mainViewFrame, "loadArchesNoArchfiles"); - } else { - new Loader<G, A, R>(errorView, mapFolderTree, mapReaderFactory, pickmapManager, mapViewsManager).load(); - if (!pickmapChooserModel.isEmpty()) { - objectChooser.movePickmapChooserToFront(); - } } + + new Loader<G, A, R>(errorView, mapFolderTree, mapReaderFactory, pickmapManager, mapViewsManager).load(); + if (!pickmapChooserModel.isEmpty()) { + objectChooser.movePickmapChooserToFront(); + } if (recentManager != null) { recentManager.initRecent(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-05-30 08:48:53
|
Revision: 8041 http://gridarta.svn.sourceforge.net/gridarta/?rev=8041&view=rev Author: akirschbaum Date: 2010-05-30 08:48:46 +0000 (Sun, 30 May 2010) Log Message: ----------- Fix typos. Modified Paths: -------------- trunk/gridarta.ipr trunk/src/app/net/sf/gridarta/maincontrol/GUIMainControl.java Modified: trunk/gridarta.ipr =================================================================== --- trunk/gridarta.ipr 2010-05-30 08:39:30 UTC (rev 8040) +++ trunk/gridarta.ipr 2010-05-30 08:48:46 UTC (rev 8041) @@ -1144,6 +1144,7 @@ <w>endmsg</w> <w>exiter</w> <w>facename</w> + <w>filenames</w> <w>filter<?, ?></w> <w>formatter</w> <w>goto</w> Modified: trunk/src/app/net/sf/gridarta/maincontrol/GUIMainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/maincontrol/GUIMainControl.java 2010-05-30 08:39:30 UTC (rev 8040) +++ trunk/src/app/net/sf/gridarta/maincontrol/GUIMainControl.java 2010-05-30 08:48:46 UTC (rev 8041) @@ -208,7 +208,7 @@ /** * Preferences. */ - private static final Preferences prefs = Preferences.userNodeForPackage(MainControl.class); + private static final Preferences preferences = Preferences.userNodeForPackage(MainControl.class); /** * The status bar instance. @@ -222,7 +222,7 @@ private final PickmapChooserControl<G, A, R> pickmapChooserControl; /** - * The main windows's {@link JFrame}. + * The main window's {@link JFrame}. */ @NotNull private final JFrame mainViewFrame; @@ -433,7 +433,7 @@ final ReplaceDialogManager<G, A, R> replaceDialogManager = new ReplaceDialogManager<G, A, R>(mainViewFrame, copyBuffer, objectChooser, mapViewManager, faceObjectProviders, insertionModeSet); new About(mainViewFrame); exiter = new DefaultExiter(mainViewFrame); - scriptEditControl = new ScriptEditControl(scriptFileFilter, scriptExtension, mainViewFrame, globalSettings.getMapsDirectory(), prefs, exiter); + scriptEditControl = new ScriptEditControl(scriptFileFilter, scriptExtension, mainViewFrame, globalSettings.getMapsDirectory(), preferences, exiter); final TextAreaDefaults textAreaDefaults = new TextAreaDefaults(scriptEditControl); gameObjectAttributesDialogFactory.setTextAreaDefaults(textAreaDefaults); scriptEditControl.setTextAreaDefaults(textAreaDefaults); @@ -541,8 +541,8 @@ new AnimationValidator(faceObjects, errorView).validate(animationObjects); if (globalSettings.isAutoPopupDocumentation()) { - // do an automated help popup because the docu version has increased - // (people won't notice the docu otherwise - nobody expects a docu in opensource) + // do an automated help popup because the documentation version has increased + // (people won't notice the documentation otherwise - nobody expects a documentation in open source) helpActions.showHelp(); globalSettings.setAutoPopupDocumentation(false); } @@ -741,9 +741,9 @@ mainView.handleThrowable(t); } - public void processFile(final String filelist) throws IOException { + public void processFile(final String fileList) throws IOException { try { - final FileInputStream fis = new FileInputStream(filelist); + final FileInputStream fis = new FileInputStream(fileList); try { final InputStreamReader isr = new InputStreamReader(fis); try { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-05-30 08:39:37
|
Revision: 8040 http://gridarta.svn.sourceforge.net/gridarta/?rev=8040&view=rev Author: akirschbaum Date: 2010-05-30 08:39:30 +0000 (Sun, 30 May 2010) Log Message: ----------- Fix disappearing recent menu entries. Modified Paths: -------------- trunk/src/app/net/sf/gridarta/gui/recent/RecentRecentPreferences.java Modified: trunk/src/app/net/sf/gridarta/gui/recent/RecentRecentPreferences.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/recent/RecentRecentPreferences.java 2010-05-30 08:08:40 UTC (rev 8039) +++ trunk/src/app/net/sf/gridarta/gui/recent/RecentRecentPreferences.java 2010-05-30 08:39:30 UTC (rev 8040) @@ -21,6 +21,7 @@ import java.io.File; import java.util.prefs.Preferences; +import net.sf.gridarta.MainControl; import net.sf.japi.swing.action.ActionBuilder; import net.sf.japi.swing.action.ActionBuilderFactory; import org.jetbrains.annotations.NotNull; @@ -40,7 +41,7 @@ * The {@link Preferences}. */ @NotNull - private static final Preferences preferences = Preferences.userNodeForPackage(RecentManager.class); + private static final Preferences preferences = Preferences.userNodeForPackage(MainControl.class); /** * The {@link ActionBuilder}. @@ -76,7 +77,7 @@ @NotNull @Override public String getTitle(final int index) { - return preferences.get("recentTitle[" + Integer.toString(index - 1) + ']', null); + return preferences.get("recentTitle[" + Integer.toString(index - 1) + ']', ""); } /** @@ -85,7 +86,7 @@ @NotNull @Override public File getMapFile(final int index) { - return new File(preferences.get("recentFilename[" + Integer.toString(index - 1) + ']', null)); + return new File(preferences.get("recentFilename[" + Integer.toString(index - 1) + ']', "")); } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-05-30 08:08:47
|
Revision: 8039 http://gridarta.svn.sourceforge.net/gridarta/?rev=8039&view=rev Author: akirschbaum Date: 2010-05-30 08:08:40 +0000 (Sun, 30 May 2010) Log Message: ----------- Add RecentPreferences. Modified Paths: -------------- trunk/src/app/net/sf/gridarta/gui/recent/Recent.java trunk/src/app/net/sf/gridarta/gui/recent/RecentManager.java trunk/src/app/net/sf/gridarta/maincontrol/GUIMainControl.java Added Paths: ----------- trunk/src/app/net/sf/gridarta/gui/recent/RecentPreferences.java trunk/src/app/net/sf/gridarta/gui/recent/RecentRecentPreferences.java Modified: trunk/src/app/net/sf/gridarta/gui/recent/Recent.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/recent/Recent.java 2010-05-30 07:43:00 UTC (rev 8038) +++ trunk/src/app/net/sf/gridarta/gui/recent/Recent.java 2010-05-30 08:08:40 UTC (rev 8039) @@ -22,7 +22,6 @@ import java.awt.event.ActionEvent; import java.io.File; import java.io.IOException; -import java.util.prefs.Preferences; import javax.swing.AbstractAction; import javax.swing.Icon; import javax.swing.ImageIcon; @@ -32,8 +31,6 @@ import net.sf.gridarta.model.archetype.Archetype; import net.sf.gridarta.model.gameobject.GameObject; import net.sf.gridarta.model.map.maparchobject.MapArchObject; -import net.sf.japi.swing.action.ActionBuilder; -import net.sf.japi.swing.action.ActionBuilderFactory; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -49,18 +46,6 @@ private static final long serialVersionUID = 1L; /** - * The {@link ActionBuilder}. - */ - @NotNull - private static final ActionBuilder ACTION_BUILDER = ActionBuilderFactory.getInstance().getActionBuilder("net.sf.gridarta"); - - /** - * The {@link Preferences}. - */ - @NotNull - private static final Preferences preferences = Preferences.userNodeForPackage(RecentManager.class); - - /** * Title = map name. */ @NotNull @@ -85,6 +70,12 @@ private final FileControl<G, A, R> fileControl; /** + * The {@link RecentPreferences} to use. + */ + @NotNull + private final RecentPreferences recentPreferences; + + /** * The map file. */ @NotNull @@ -98,15 +89,17 @@ * @param mapViewsManager the map views manager instance * @param mapImageCache the map image cache instance * @param fileControl the file control + * @param recentPreferences the recent preferences to use */ - Recent(@NotNull final String title, @NotNull final File mapFile, @NotNull final File mapsDirectory, @NotNull final MapViewsManager<G, A, R> mapViewsManager, @NotNull final MapImageCache<G, A, R> mapImageCache, @NotNull final FileControl<G, A, R> fileControl) { + Recent(@NotNull final String title, @NotNull final File mapFile, @NotNull final File mapsDirectory, @NotNull final MapViewsManager<G, A, R> mapViewsManager, @NotNull final MapImageCache<G, A, R> mapImageCache, @NotNull final FileControl<G, A, R> fileControl, @NotNull final RecentPreferences recentPreferences) { super(title); this.mapFile = mapFile; this.title = title; this.mapViewsManager = mapViewsManager; this.mapImageCache = mapImageCache; this.fileControl = fileControl; - putValue(SHORT_DESCRIPTION, ACTION_BUILDER.format("recentItem.shortdescriptionformat", title, getShortMapFile(mapsDirectory, mapFile))); + this.recentPreferences = recentPreferences; + putValue(SHORT_DESCRIPTION, recentPreferences.getShortDescription(title, getShortMapFile(mapsDirectory, mapFile))); putValue(SMALL_ICON, getIcon()); putValue(NAME, title); putValue(MNEMONIC_KEY, null); @@ -144,14 +137,16 @@ * @param mapViewsManager the map views manager instance * @param mapImageCache the map image cache instance * @param fileControl the file control + * @param recentPreferences the recent preferences to use */ - Recent(final int index, @NotNull final File mapsDirectory, @NotNull final MapViewsManager<G, A, R> mapViewsManager, @NotNull final MapImageCache<G, A, R> mapImageCache, @NotNull final FileControl<G, A, R> fileControl) { + Recent(final int index, @NotNull final File mapsDirectory, @NotNull final MapViewsManager<G, A, R> mapViewsManager, @NotNull final MapImageCache<G, A, R> mapImageCache, @NotNull final FileControl<G, A, R> fileControl, @NotNull final RecentPreferences recentPreferences) { this.mapViewsManager = mapViewsManager; this.mapImageCache = mapImageCache; this.fileControl = fileControl; - title = preferences.get("recentTitle[" + Integer.toString(index - 1) + ']', null); - mapFile = new File(preferences.get("recentFilename[" + Integer.toString(index - 1) + ']', null)); - putValue(SHORT_DESCRIPTION, ACTION_BUILDER.format("recentItem.shortdescriptionformat", title, getShortMapFile(mapsDirectory, mapFile))); + this.recentPreferences = recentPreferences; + title = recentPreferences.getTitle(index - 1); + mapFile = recentPreferences.getMapFile(index -1 ); + putValue(SHORT_DESCRIPTION, recentPreferences.getShortDescription(title, getShortMapFile(mapsDirectory, mapFile))); putValue(SMALL_ICON, getIcon()); putValue(NAME, title); putValue(MNEMONIC_KEY, null); @@ -163,8 +158,7 @@ * @param index index (starting with 1) */ public void setIndex(final int index) { - preferences.put("recentTitle[" + Integer.toString(index - 1) + ']', title); - preferences.put("recentFilename[" + Integer.toString(index - 1) + ']', mapFile.getPath()); + recentPreferences.setInfo(index - 1, title, mapFile.getPath()); } /** Modified: trunk/src/app/net/sf/gridarta/gui/recent/RecentManager.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/recent/RecentManager.java 2010-05-30 07:43:00 UTC (rev 8038) +++ trunk/src/app/net/sf/gridarta/gui/recent/RecentManager.java 2010-05-30 08:08:40 UTC (rev 8039) @@ -25,7 +25,6 @@ import java.util.ListIterator; import java.util.Map; import java.util.Set; -import java.util.prefs.Preferences; import javax.swing.Action; import javax.swing.JMenu; import net.sf.gridarta.gui.map.mapview.MapViewsManager; @@ -56,12 +55,6 @@ public class RecentManager<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> { /** - * Preferences. - */ - @NotNull - private static final Preferences preferences = Preferences.userNodeForPackage(RecentManager.class); - - /** * The {@link MapViewsManager} instance. */ @NotNull @@ -99,6 +92,12 @@ private final FileControl<G, A, R> fileControl; /** + * The {@link RecentPreferences} to use. + */ + @NotNull + private final RecentPreferences recentPreferences; + + /** * Maps {@link MapControl} instances to associated {@link MapTracker} * instances. */ @@ -113,13 +112,15 @@ * @param globalSettings the global settings instance * @param mapImageCache the map image cache instance * @param fileControl the file control + * @param recentPreferences the recent preferences to use */ - public RecentManager(@NotNull final MapManager<G, A, R> mapManager, @NotNull final MapViewsManager<G, A, R> mapViewsManager, @Nullable final JMenu recentMenu, @NotNull final GlobalSettings globalSettings, @NotNull final MapImageCache<G, A, R> mapImageCache, @NotNull final FileControl<G, A, R> fileControl) { + public RecentManager(@NotNull final MapManager<G, A, R> mapManager, @NotNull final MapViewsManager<G, A, R> mapViewsManager, @Nullable final JMenu recentMenu, @NotNull final GlobalSettings globalSettings, @NotNull final MapImageCache<G, A, R> mapImageCache, @NotNull final FileControl<G, A, R> fileControl, @NotNull final RecentPreferences recentPreferences) { this.mapViewsManager = mapViewsManager; this.recentMenu = recentMenu; this.globalSettings = globalSettings; this.mapImageCache = mapImageCache; this.fileControl = fileControl; + this.recentPreferences = recentPreferences; final MapManagerListener<G, A, R> mapManagerListener = new MapManagerListener<G, A, R>() { @@ -179,7 +180,7 @@ } final String title = mapModel.getMapArchObject().getMapName(); - final Recent<G, A, R> recent = new Recent<G, A, R>(title, mapFile, globalSettings.getMapsDirectory(), mapViewsManager, mapImageCache, fileControl); + final Recent<G, A, R> recent = new Recent<G, A, R>(title, mapFile, globalSettings.getMapsDirectory(), mapViewsManager, mapImageCache, fileControl, recentPreferences); recents.remove(recent); // remove old entry to get new entry at first pos. recents.addFirst(recent); // Now remove those that are too many. @@ -191,7 +192,7 @@ it.remove(); } } - preferences.putInt("recentNum", recents.size()); + recentPreferences.setNum(recents.size()); updateRecent(recents); } @@ -219,9 +220,9 @@ */ public void initRecent() { final File mapsDirectory = globalSettings.getMapsDirectory(); - final int numRecents = preferences.getInt("recentNum", 0); + final int numRecents = recentPreferences.getNum(); for (int i = 0; i < numRecents; i++) { - recents.add(new Recent<G, A, R>(i + 1, mapsDirectory, mapViewsManager, mapImageCache, fileControl)); + recents.add(new Recent<G, A, R>(i + 1, mapsDirectory, mapViewsManager, mapImageCache, fileControl, recentPreferences)); } updateRecent(recents); } Added: trunk/src/app/net/sf/gridarta/gui/recent/RecentPreferences.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/recent/RecentPreferences.java (rev 0) +++ trunk/src/app/net/sf/gridarta/gui/recent/RecentPreferences.java 2010-05-30 08:08:40 UTC (rev 8039) @@ -0,0 +1,78 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2010 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.recent; + +import java.io.File; +import java.io.Serializable; +import org.jetbrains.annotations.NotNull; + +/** + * Interfaces for classes providing access to preference values needed by {@link + * RecentManager} instances. + * @author Andreas Kirschbaum + */ +public interface RecentPreferences extends Serializable { + + /** + * Returns the number of active entries. + * @return the number of active entries + */ + int getNum(); + + /** + * Sets the number of active entries. + * @param num the number of active entries + */ + void setNum(int num); + + /** + * Updates information about one entry. + * @param index the entry's index + * @param title the entry's title + * @param path the entry's path + */ + void setInfo(int index, @NotNull String title, @NotNull String path); + + /** + * Returns an entry's title. + * @param index the entry's index + * @return the entry's title + */ + @NotNull + String getTitle(int index); + + /** + * Returns an entry's map path. + * @param index the entry's index + * @return the entry's map path + */ + @NotNull + File getMapFile(int index); + + /** + * Returns the short description for an entry. + * @param title the entry's title + * @param mapFile the entry's short map file + * @return the short description + */ + @NotNull + String getShortDescription(@NotNull final String title, @NotNull final String mapFile); + +} // interface RecentPreferences Property changes on: trunk/src/app/net/sf/gridarta/gui/recent/RecentPreferences.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF Added: trunk/src/app/net/sf/gridarta/gui/recent/RecentRecentPreferences.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/recent/RecentRecentPreferences.java (rev 0) +++ trunk/src/app/net/sf/gridarta/gui/recent/RecentRecentPreferences.java 2010-05-30 08:08:40 UTC (rev 8039) @@ -0,0 +1,100 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2010 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.recent; + +import java.io.File; +import java.util.prefs.Preferences; +import net.sf.japi.swing.action.ActionBuilder; +import net.sf.japi.swing.action.ActionBuilderFactory; +import org.jetbrains.annotations.NotNull; + +/** + * A {@link RecentPreferences} for recent menu entries. + * @author Andreas Kirschbaum + */ +public class RecentRecentPreferences implements RecentPreferences { + + /** + * The serial version UID. + */ + private static final long serialVersionUID = 1L; + + /** + * The {@link Preferences}. + */ + @NotNull + private static final Preferences preferences = Preferences.userNodeForPackage(RecentManager.class); + + /** + * The {@link ActionBuilder}. + */ + @NotNull + private static final ActionBuilder ACTION_BUILDER = ActionBuilderFactory.getInstance().getActionBuilder("net.sf.gridarta"); + + @Override + public int getNum() { + return preferences.getInt("recentNum", 0); + } + + /** + * {@inheritDoc} + */ + @Override + public void setNum(final int num) { + preferences.putInt("recentNum", num); + } + + /** + * {@inheritDoc} + */ + @Override + public void setInfo(final int index, @NotNull final String title, @NotNull final String path) { + preferences.put("recentTitle[" + Integer.toString(index - 1) + ']', title); + preferences.put("recentFilename[" + Integer.toString(index - 1) + ']', path); + } + + /** + * {@inheritDoc} + */ + @NotNull + @Override + public String getTitle(final int index) { + return preferences.get("recentTitle[" + Integer.toString(index - 1) + ']', null); + } + + /** + * {@inheritDoc} + */ + @NotNull + @Override + public File getMapFile(final int index) { + return new File(preferences.get("recentFilename[" + Integer.toString(index - 1) + ']', null)); + } + + /** + * {@inheritDoc} + */ + @NotNull + @Override + public String getShortDescription(@NotNull final String title, @NotNull final String mapFile) { + return ACTION_BUILDER.format("recentItem.shortdescriptionformat", title, mapFile); + } + +} // class RecentRecentPreferences Property changes on: trunk/src/app/net/sf/gridarta/gui/recent/RecentRecentPreferences.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF Modified: trunk/src/app/net/sf/gridarta/maincontrol/GUIMainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/maincontrol/GUIMainControl.java 2010-05-30 07:43:00 UTC (rev 8038) +++ trunk/src/app/net/sf/gridarta/maincontrol/GUIMainControl.java 2010-05-30 08:08:40 UTC (rev 8039) @@ -94,6 +94,7 @@ import net.sf.gridarta.gui.pickmapchooser.PickmapChooserModel; import net.sf.gridarta.gui.prefs.AppPreferencesModel; import net.sf.gridarta.gui.recent.RecentManager; +import net.sf.gridarta.gui.recent.RecentRecentPreferences; import net.sf.gridarta.gui.replacedialog.ReplaceDialogManager; import net.sf.gridarta.gui.script.ScriptController; import net.sf.gridarta.gui.script.parameter.PluginParameterViewFactory; @@ -553,7 +554,7 @@ log.warn("'main' menu bar does not define 'recent' menu."); recentManager = null; } else { - recentManager = new RecentManager<G, A, R>(mapManager, mapViewsManager, recentMenu, globalSettings, mapImageCache, fileControl); + recentManager = new RecentManager<G, A, R>(mapManager, mapViewsManager, recentMenu, globalSettings, mapImageCache, fileControl, new RecentRecentPreferences()); } final JMenu analyzeMenu = MenuUtils.getMenu(menuBar, "analyze"); if (analyzeMenu == null) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-05-30 07:43:07
|
Revision: 8038 http://gridarta.svn.sourceforge.net/gridarta/?rev=8038&view=rev Author: akirschbaum Date: 2010-05-30 07:43:00 +0000 (Sun, 30 May 2010) Log Message: ----------- Move Recent and RecentManager to different package. Modified Paths: -------------- trunk/src/app/net/sf/gridarta/maincontrol/GUIMainControl.java Added Paths: ----------- trunk/src/app/net/sf/gridarta/gui/recent/ trunk/src/app/net/sf/gridarta/gui/recent/Recent.java trunk/src/app/net/sf/gridarta/gui/recent/RecentManager.java Removed Paths: ------------- trunk/src/app/net/sf/gridarta/gui/misc/Recent.java trunk/src/app/net/sf/gridarta/gui/misc/RecentManager.java Deleted: trunk/src/app/net/sf/gridarta/gui/misc/Recent.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/misc/Recent.java 2010-05-30 07:41:54 UTC (rev 8037) +++ trunk/src/app/net/sf/gridarta/gui/misc/Recent.java 2010-05-30 07:43:00 UTC (rev 8038) @@ -1,229 +0,0 @@ -/* - * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. - * Copyright (C) 2000-2010 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.misc; - -import java.awt.event.ActionEvent; -import java.io.File; -import java.io.IOException; -import java.util.prefs.Preferences; -import javax.swing.AbstractAction; -import javax.swing.Icon; -import javax.swing.ImageIcon; -import net.sf.gridarta.gui.map.mapview.MapViewsManager; -import net.sf.gridarta.gui.mapimagecache.MapImageCache; -import net.sf.gridarta.mapmanager.FileControl; -import net.sf.gridarta.model.archetype.Archetype; -import net.sf.gridarta.model.gameobject.GameObject; -import net.sf.gridarta.model.map.maparchobject.MapArchObject; -import net.sf.japi.swing.action.ActionBuilder; -import net.sf.japi.swing.action.ActionBuilderFactory; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -/** - * An entry in a recent menu. It allows to re-open a recent map. - * @author Andreas Kirschbaum - */ -public class Recent<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> extends AbstractAction { - - /** - * The serial version UID. - */ - private static final long serialVersionUID = 1L; - - /** - * The {@link ActionBuilder}. - */ - @NotNull - private static final ActionBuilder ACTION_BUILDER = ActionBuilderFactory.getInstance().getActionBuilder("net.sf.gridarta"); - - /** - * The {@link Preferences}. - */ - @NotNull - private static final Preferences preferences = Preferences.userNodeForPackage(RecentManager.class); - - /** - * Title = map name. - */ - @NotNull - private final String title; - - /** - * The {@link MapViewsManager} instance. - */ - @NotNull - private final MapViewsManager<G, A, R> mapViewsManager; - - /** - * The map {@link MapImageCache} to use. - */ - @NotNull - private final MapImageCache<G, A, R> mapImageCache; - - /** - * The {@link FileControl}. - */ - @NotNull - private final FileControl<G, A, R> fileControl; - - /** - * The map file. - */ - @NotNull - private final File mapFile; - - /** - * Create a Recent. - * @param title title (map name) - * @param mapFile the map file - * @param mapsDirectory the maps directory - * @param mapViewsManager the map views manager instance - * @param mapImageCache the map image cache instance - * @param fileControl the file control - */ - Recent(@NotNull final String title, @NotNull final File mapFile, @NotNull final File mapsDirectory, @NotNull final MapViewsManager<G, A, R> mapViewsManager, @NotNull final MapImageCache<G, A, R> mapImageCache, @NotNull final FileControl<G, A, R> fileControl) { - super(title); - this.mapFile = mapFile; - this.title = title; - this.mapViewsManager = mapViewsManager; - this.mapImageCache = mapImageCache; - this.fileControl = fileControl; - putValue(SHORT_DESCRIPTION, ACTION_BUILDER.format("recentItem.shortdescriptionformat", title, getShortMapFile(mapsDirectory, mapFile))); - putValue(SMALL_ICON, getIcon()); - putValue(NAME, title); - putValue(MNEMONIC_KEY, null); - } - - /** - * Returns the base name of a map file. - * @param mapsDirectory the maps directory - * @param mapFile the map file - * @return the base name - */ - @NotNull - private static String getShortMapFile(@NotNull final File mapsDirectory, @NotNull final File mapFile) { - String canonicalMapFile; - String canonicalMapsDirectory; - try { - canonicalMapFile = mapFile.getCanonicalPath(); - canonicalMapsDirectory = mapsDirectory.getCanonicalPath(); - } catch (final IOException ignored) { - canonicalMapFile = mapFile.getAbsolutePath(); - canonicalMapsDirectory = mapsDirectory.getAbsolutePath(); - } - - if (canonicalMapFile.startsWith(canonicalMapsDirectory)) { - return canonicalMapFile.substring(canonicalMapsDirectory.length()).replace('\\', '/'); - } else { - return canonicalMapFile.replace('\\', '/'); - } - } - - /** - * Create a Recent from preferences. - * @param index index (starting with 1) - * @param mapsDirectory the maps directory - * @param mapViewsManager the map views manager instance - * @param mapImageCache the map image cache instance - * @param fileControl the file control - */ - Recent(final int index, @NotNull final File mapsDirectory, @NotNull final MapViewsManager<G, A, R> mapViewsManager, @NotNull final MapImageCache<G, A, R> mapImageCache, @NotNull final FileControl<G, A, R> fileControl) { - this.mapViewsManager = mapViewsManager; - this.mapImageCache = mapImageCache; - this.fileControl = fileControl; - title = preferences.get("recentTitle[" + Integer.toString(index - 1) + ']', null); - mapFile = new File(preferences.get("recentFilename[" + Integer.toString(index - 1) + ']', null)); - putValue(SHORT_DESCRIPTION, ACTION_BUILDER.format("recentItem.shortdescriptionformat", title, getShortMapFile(mapsDirectory, mapFile))); - putValue(SMALL_ICON, getIcon()); - putValue(NAME, title); - putValue(MNEMONIC_KEY, null); - setIndex(index); - } - - /** - * Set the index used for title, key strokes and such. - * @param index index (starting with 1) - */ - public void setIndex(final int index) { - preferences.put("recentTitle[" + Integer.toString(index - 1) + ']', title); - preferences.put("recentFilename[" + Integer.toString(index - 1) + ']', mapFile.getPath()); - } - - /** - * {@inheritDoc} - */ - @Override - public void actionPerformed(@NotNull final ActionEvent e) { - try { - mapViewsManager.openMapFileWithView(mapFile, null); - } catch (final IOException ex) { - fileControl.reportLoadError(mapFile, ex.getMessage()); - } - } - - /** - * Get the icon of this file. - * @return icon of this file - */ - @Nullable - private Icon getIcon() { - return new ImageIcon(mapImageCache.getOrCreateIcon(mapFile)); - } - - /** - * Returns the map file. - * @return the map file - */ - @NotNull - public File getMapFile() { - return mapFile; - } - - /** - * {@inheritDoc} - */ - @Override - public boolean equals(@Nullable final Object obj) { - return obj != null && obj instanceof Recent && mapFile.equals(((Recent<?, ?, ?>) obj).mapFile); - } - - /** - * {@inheritDoc} - */ - @Override - public int hashCode() { - return mapFile.hashCode(); - } - - /** - * {@inheritDoc} - */ - @NotNull - @Override - protected Object clone() { - try { - return super.clone(); - } catch (final CloneNotSupportedException ex) { - throw new AssertionError(ex); - } - } - -} // class Recent Deleted: trunk/src/app/net/sf/gridarta/gui/misc/RecentManager.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/misc/RecentManager.java 2010-05-30 07:41:54 UTC (rev 8037) +++ trunk/src/app/net/sf/gridarta/gui/misc/RecentManager.java 2010-05-30 07:43:00 UTC (rev 8038) @@ -1,331 +0,0 @@ -/* - * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. - * Copyright (C) 2000-2010 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.misc; - -import java.io.File; -import java.util.IdentityHashMap; -import java.util.LinkedList; -import java.util.ListIterator; -import java.util.Map; -import java.util.Set; -import java.util.prefs.Preferences; -import javax.swing.Action; -import javax.swing.JMenu; -import net.sf.gridarta.gui.map.mapview.MapViewsManager; -import net.sf.gridarta.gui.mapimagecache.MapImageCache; -import net.sf.gridarta.gui.utils.MenuUtils; -import net.sf.gridarta.mapmanager.FileControl; -import net.sf.gridarta.mapmanager.MapManager; -import net.sf.gridarta.mapmanager.MapManagerListener; -import net.sf.gridarta.model.archetype.Archetype; -import net.sf.gridarta.model.gameobject.GameObject; -import net.sf.gridarta.model.map.maparchobject.MapArchObject; -import net.sf.gridarta.model.map.mapcontrol.DefaultMapControl; -import net.sf.gridarta.model.map.mapcontrol.MapControl; -import net.sf.gridarta.model.map.mapcontrol.MapControlListener; -import net.sf.gridarta.model.map.mapmodel.MapModel; -import net.sf.gridarta.model.map.mapmodel.MapModelListener; -import net.sf.gridarta.model.map.mapmodel.MapSquare; -import net.sf.gridarta.model.map.validation.ErrorCollector; -import net.sf.gridarta.model.settings.GlobalSettings; -import net.sf.gridarta.utils.Size2D; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -/** - * Manages the recent menu entries. - * @author Andreas Kirschbaum - */ -public class RecentManager<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> { - - /** - * Preferences. - */ - @NotNull - private static final Preferences preferences = Preferences.userNodeForPackage(RecentManager.class); - - /** - * The {@link MapViewsManager} instance. - */ - @NotNull - private final MapViewsManager<G, A, R> mapViewsManager; - - /** - * List with recents. - */ - @NotNull - private final LinkedList<Recent<G, A, R>> recents = new LinkedList<Recent<G, A, R>>(); - - /** - * The "recent" menu to update. - * @serial - */ - @Nullable - private final JMenu recentMenu; - - /** - * The global settings instance. - */ - @NotNull - private final GlobalSettings globalSettings; - - /** - * The {@link MapImageCache} to use. - */ - @NotNull - private final MapImageCache<G, A, R> mapImageCache; - - /** - * The {@link FileControl}. - */ - @NotNull - private final FileControl<G, A, R> fileControl; - - /** - * Maps {@link MapControl} instances to associated {@link MapTracker} - * instances. - */ - @NotNull - private final Map<MapControl<G, A, R>, MapTracker> mapTrackers = new IdentityHashMap<MapControl<G, A, R>, MapTracker>(); - - /** - * Create a new instance. - * @param mapManager the map manager instance - * @param mapViewsManager the map views manager instance - * @param recentMenu menu for managing the recent entries - * @param globalSettings the global settings instance - * @param mapImageCache the map image cache instance - * @param fileControl the file control - */ - public RecentManager(@NotNull final MapManager<G, A, R> mapManager, @NotNull final MapViewsManager<G, A, R> mapViewsManager, @Nullable final JMenu recentMenu, @NotNull final GlobalSettings globalSettings, @NotNull final MapImageCache<G, A, R> mapImageCache, @NotNull final FileControl<G, A, R> fileControl) { - this.mapViewsManager = mapViewsManager; - this.recentMenu = recentMenu; - this.globalSettings = globalSettings; - this.mapImageCache = mapImageCache; - this.fileControl = fileControl; - - final MapManagerListener<G, A, R> mapManagerListener = new MapManagerListener<G, A, R>() { - - /** {@inheritDoc} */ - @Override - public void currentMapChanged(@Nullable final MapControl<G, A, R> mapControl) { - // ignore - } - - /** {@inheritDoc} */ - @Override - public void mapCreated(@NotNull final MapControl<G, A, R> mapControl, final boolean interactive) { - if (interactive) { - addRecent(mapControl.getMapModel(), null); - final MapTracker mapTracker = new MapTracker(mapControl.getMapModel()); - if (mapTrackers.put(mapControl, mapTracker) != null) { - assert false; - } - mapControl.addMapControlListener(mapTracker); - mapControl.getMapModel().addMapModelListener(mapTracker); - } - } - - /** {@inheritDoc} */ - @Override - public void mapClosing(@NotNull final MapControl<G, A, R> mapControl) { - // ignore - } - - /** {@inheritDoc} */ - @Override - public void mapClosed(@NotNull final MapControl<G, A, R> mapControl) { - final MapTracker mapTracker = mapTrackers.remove(mapControl); - if (mapTracker != null) { - mapControl.getMapModel().removeMapModelListener(mapTracker); - mapControl.removeMapControlListener(mapTracker); - } - } - - }; - mapManager.addMapManagerListener(mapManagerListener); - } - - /** - * Adds or updates an entry of the recent files. - * @param mapModel the map model to update the entry for - * @param oldMapFile the map file before the change - */ - private void addRecent(@NotNull final MapModel<G, A, R> mapModel, @Nullable final File oldMapFile) { - if (oldMapFile != null) { - removeRecent(oldMapFile); - } - - final File mapFile = mapModel.getMapFile(); - if (mapFile == null) { - return; - } - - final String title = mapModel.getMapArchObject().getMapName(); - final Recent<G, A, R> recent = new Recent<G, A, R>(title, mapFile, globalSettings.getMapsDirectory(), mapViewsManager, mapImageCache, fileControl); - recents.remove(recent); // remove old entry to get new entry at first pos. - recents.addFirst(recent); - // Now remove those that are too many. - // Please keep this while loop as the constant 10 might be replaced by a preferences var - int i = 0; - for (final ListIterator<Recent<G, A, R>> it = recents.listIterator(); it.hasNext();) { - it.next().setIndex(it.nextIndex()); // this looks bogus but it's intentionally currentIndex + 1 - if (++i > 10) { - it.remove(); - } - } - preferences.putInt("recentNum", recents.size()); - updateRecent(recents); - } - - /** - * Removes a recent entry for given map file. Does nothing if no such entry - * exists. - * @param mapFile the map file - */ - private void removeRecent(@NotNull final File mapFile) { - if (mapFile.exists()) { - return; - } - - for (int i = 0; i < recents.size(); i++) { - final Recent<G, A, R> recent = recents.get(i); - if (recent.getMapFile().equals(mapFile)) { - recents.remove(i); - break; - } - } - } - - /** - * Initializes the recent state. - */ - public void initRecent() { - final File mapsDirectory = globalSettings.getMapsDirectory(); - final int numRecents = preferences.getInt("recentNum", 0); - for (int i = 0; i < numRecents; i++) { - recents.add(new Recent<G, A, R>(i + 1, mapsDirectory, mapViewsManager, mapImageCache, fileControl)); - } - updateRecent(recents); - } - - /** - * Update the recent menu. - * @param recents current recents - */ - private void updateRecent(@NotNull final Iterable<Recent<G, A, R>> recents) { - if (recentMenu == null) { - return; - } - - MenuUtils.removeAll(recentMenu); - for (final Action recent : recents) { - recentMenu.add(recent); - } - } - - /** - * Watches a {@link MapModel} for map file changes. - * @author Andreas Kirschbaum - */ - private class MapTracker implements MapControlListener<G, A, R>, MapModelListener<G, A, R> { - - /** - * The {@link MapModel} to track. - */ - @NotNull - private final MapModel<G, A, R> mapModel; - - /** - * Creates a new instance. - * @param mapModel the map model to track - */ - private MapTracker(@NotNull final MapModel<G, A, R> mapModel) { - this.mapModel = mapModel; - } - - /** - * {@inheritDoc} - */ - @Override - public void mapSizeChanged(@NotNull final MapModel<G, A, R> mapModel, @NotNull final Size2D newSize) { - // ignore - } - - /** - * {@inheritDoc} - */ - @Override - public void mapSquaresChanged(@NotNull final Set<MapSquare<G, A, R>> mapSquares) { - // ignore - } - - /** - * {@inheritDoc} - */ - @Override - public void mapObjectsChanged(@NotNull final Set<G> gameObjects, @NotNull final Set<G> transientGameObjects) { - // ignore - } - - /** - * {@inheritDoc} - */ - @Override - public void mapMetaChanged() { - // ignore - } - - /** - * {@inheritDoc} - */ - @Override - public void errorsChanged(@NotNull final ErrorCollector<G, A, R> errors) { - // ignore - } - - /** - * {@inheritDoc} - */ - @Override - public void mapFileChanged(@Nullable final File oldMapFile) { - addRecent(mapModel, oldMapFile); - } - - /** - * {@inheritDoc} - */ - @Override - public void modifiedChanged(@NotNull final MapModel<G, A, R> mapModel) { - // ignore - } - - /** - * {@inheritDoc} - */ - @Override - public void saved(@NotNull final DefaultMapControl<G, A, R> mapControl) { - assert mapModel == mapControl.getMapModel(); - addRecent(mapModel, null); - } - - } - -} // class RecentManager Copied: trunk/src/app/net/sf/gridarta/gui/recent/Recent.java (from rev 8035, trunk/src/app/net/sf/gridarta/gui/misc/Recent.java) =================================================================== --- trunk/src/app/net/sf/gridarta/gui/recent/Recent.java (rev 0) +++ trunk/src/app/net/sf/gridarta/gui/recent/Recent.java 2010-05-30 07:43:00 UTC (rev 8038) @@ -0,0 +1,229 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2010 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.recent; + +import java.awt.event.ActionEvent; +import java.io.File; +import java.io.IOException; +import java.util.prefs.Preferences; +import javax.swing.AbstractAction; +import javax.swing.Icon; +import javax.swing.ImageIcon; +import net.sf.gridarta.gui.map.mapview.MapViewsManager; +import net.sf.gridarta.gui.mapimagecache.MapImageCache; +import net.sf.gridarta.mapmanager.FileControl; +import net.sf.gridarta.model.archetype.Archetype; +import net.sf.gridarta.model.gameobject.GameObject; +import net.sf.gridarta.model.map.maparchobject.MapArchObject; +import net.sf.japi.swing.action.ActionBuilder; +import net.sf.japi.swing.action.ActionBuilderFactory; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * An entry in a recent menu. It allows to re-open a recent map. + * @author Andreas Kirschbaum + */ +public class Recent<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> extends AbstractAction { + + /** + * The serial version UID. + */ + private static final long serialVersionUID = 1L; + + /** + * The {@link ActionBuilder}. + */ + @NotNull + private static final ActionBuilder ACTION_BUILDER = ActionBuilderFactory.getInstance().getActionBuilder("net.sf.gridarta"); + + /** + * The {@link Preferences}. + */ + @NotNull + private static final Preferences preferences = Preferences.userNodeForPackage(RecentManager.class); + + /** + * Title = map name. + */ + @NotNull + private final String title; + + /** + * The {@link MapViewsManager} instance. + */ + @NotNull + private final MapViewsManager<G, A, R> mapViewsManager; + + /** + * The map {@link MapImageCache} to use. + */ + @NotNull + private final MapImageCache<G, A, R> mapImageCache; + + /** + * The {@link FileControl}. + */ + @NotNull + private final FileControl<G, A, R> fileControl; + + /** + * The map file. + */ + @NotNull + private final File mapFile; + + /** + * Create a Recent. + * @param title title (map name) + * @param mapFile the map file + * @param mapsDirectory the maps directory + * @param mapViewsManager the map views manager instance + * @param mapImageCache the map image cache instance + * @param fileControl the file control + */ + Recent(@NotNull final String title, @NotNull final File mapFile, @NotNull final File mapsDirectory, @NotNull final MapViewsManager<G, A, R> mapViewsManager, @NotNull final MapImageCache<G, A, R> mapImageCache, @NotNull final FileControl<G, A, R> fileControl) { + super(title); + this.mapFile = mapFile; + this.title = title; + this.mapViewsManager = mapViewsManager; + this.mapImageCache = mapImageCache; + this.fileControl = fileControl; + putValue(SHORT_DESCRIPTION, ACTION_BUILDER.format("recentItem.shortdescriptionformat", title, getShortMapFile(mapsDirectory, mapFile))); + putValue(SMALL_ICON, getIcon()); + putValue(NAME, title); + putValue(MNEMONIC_KEY, null); + } + + /** + * Returns the base name of a map file. + * @param mapsDirectory the maps directory + * @param mapFile the map file + * @return the base name + */ + @NotNull + private static String getShortMapFile(@NotNull final File mapsDirectory, @NotNull final File mapFile) { + String canonicalMapFile; + String canonicalMapsDirectory; + try { + canonicalMapFile = mapFile.getCanonicalPath(); + canonicalMapsDirectory = mapsDirectory.getCanonicalPath(); + } catch (final IOException ignored) { + canonicalMapFile = mapFile.getAbsolutePath(); + canonicalMapsDirectory = mapsDirectory.getAbsolutePath(); + } + + if (canonicalMapFile.startsWith(canonicalMapsDirectory)) { + return canonicalMapFile.substring(canonicalMapsDirectory.length()).replace('\\', '/'); + } else { + return canonicalMapFile.replace('\\', '/'); + } + } + + /** + * Create a Recent from preferences. + * @param index index (starting with 1) + * @param mapsDirectory the maps directory + * @param mapViewsManager the map views manager instance + * @param mapImageCache the map image cache instance + * @param fileControl the file control + */ + Recent(final int index, @NotNull final File mapsDirectory, @NotNull final MapViewsManager<G, A, R> mapViewsManager, @NotNull final MapImageCache<G, A, R> mapImageCache, @NotNull final FileControl<G, A, R> fileControl) { + this.mapViewsManager = mapViewsManager; + this.mapImageCache = mapImageCache; + this.fileControl = fileControl; + title = preferences.get("recentTitle[" + Integer.toString(index - 1) + ']', null); + mapFile = new File(preferences.get("recentFilename[" + Integer.toString(index - 1) + ']', null)); + putValue(SHORT_DESCRIPTION, ACTION_BUILDER.format("recentItem.shortdescriptionformat", title, getShortMapFile(mapsDirectory, mapFile))); + putValue(SMALL_ICON, getIcon()); + putValue(NAME, title); + putValue(MNEMONIC_KEY, null); + setIndex(index); + } + + /** + * Set the index used for title, key strokes and such. + * @param index index (starting with 1) + */ + public void setIndex(final int index) { + preferences.put("recentTitle[" + Integer.toString(index - 1) + ']', title); + preferences.put("recentFilename[" + Integer.toString(index - 1) + ']', mapFile.getPath()); + } + + /** + * {@inheritDoc} + */ + @Override + public void actionPerformed(@NotNull final ActionEvent e) { + try { + mapViewsManager.openMapFileWithView(mapFile, null); + } catch (final IOException ex) { + fileControl.reportLoadError(mapFile, ex.getMessage()); + } + } + + /** + * Get the icon of this file. + * @return icon of this file + */ + @Nullable + private Icon getIcon() { + return new ImageIcon(mapImageCache.getOrCreateIcon(mapFile)); + } + + /** + * Returns the map file. + * @return the map file + */ + @NotNull + public File getMapFile() { + return mapFile; + } + + /** + * {@inheritDoc} + */ + @Override + public boolean equals(@Nullable final Object obj) { + return obj != null && obj instanceof Recent && mapFile.equals(((Recent<?, ?, ?>) obj).mapFile); + } + + /** + * {@inheritDoc} + */ + @Override + public int hashCode() { + return mapFile.hashCode(); + } + + /** + * {@inheritDoc} + */ + @NotNull + @Override + protected Object clone() { + try { + return super.clone(); + } catch (final CloneNotSupportedException ex) { + throw new AssertionError(ex); + } + } + +} // class Recent Property changes on: trunk/src/app/net/sf/gridarta/gui/recent/Recent.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF Copied: trunk/src/app/net/sf/gridarta/gui/recent/RecentManager.java (from rev 8035, trunk/src/app/net/sf/gridarta/gui/misc/RecentManager.java) =================================================================== --- trunk/src/app/net/sf/gridarta/gui/recent/RecentManager.java (rev 0) +++ trunk/src/app/net/sf/gridarta/gui/recent/RecentManager.java 2010-05-30 07:43:00 UTC (rev 8038) @@ -0,0 +1,331 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2010 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.recent; + +import java.io.File; +import java.util.IdentityHashMap; +import java.util.LinkedList; +import java.util.ListIterator; +import java.util.Map; +import java.util.Set; +import java.util.prefs.Preferences; +import javax.swing.Action; +import javax.swing.JMenu; +import net.sf.gridarta.gui.map.mapview.MapViewsManager; +import net.sf.gridarta.gui.mapimagecache.MapImageCache; +import net.sf.gridarta.gui.utils.MenuUtils; +import net.sf.gridarta.mapmanager.FileControl; +import net.sf.gridarta.mapmanager.MapManager; +import net.sf.gridarta.mapmanager.MapManagerListener; +import net.sf.gridarta.model.archetype.Archetype; +import net.sf.gridarta.model.gameobject.GameObject; +import net.sf.gridarta.model.map.maparchobject.MapArchObject; +import net.sf.gridarta.model.map.mapcontrol.DefaultMapControl; +import net.sf.gridarta.model.map.mapcontrol.MapControl; +import net.sf.gridarta.model.map.mapcontrol.MapControlListener; +import net.sf.gridarta.model.map.mapmodel.MapModel; +import net.sf.gridarta.model.map.mapmodel.MapModelListener; +import net.sf.gridarta.model.map.mapmodel.MapSquare; +import net.sf.gridarta.model.map.validation.ErrorCollector; +import net.sf.gridarta.model.settings.GlobalSettings; +import net.sf.gridarta.utils.Size2D; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * Manages the recent menu entries. + * @author Andreas Kirschbaum + */ +public class RecentManager<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> { + + /** + * Preferences. + */ + @NotNull + private static final Preferences preferences = Preferences.userNodeForPackage(RecentManager.class); + + /** + * The {@link MapViewsManager} instance. + */ + @NotNull + private final MapViewsManager<G, A, R> mapViewsManager; + + /** + * List with recents. + */ + @NotNull + private final LinkedList<Recent<G, A, R>> recents = new LinkedList<Recent<G, A, R>>(); + + /** + * The "recent" menu to update. + * @serial + */ + @Nullable + private final JMenu recentMenu; + + /** + * The global settings instance. + */ + @NotNull + private final GlobalSettings globalSettings; + + /** + * The {@link MapImageCache} to use. + */ + @NotNull + private final MapImageCache<G, A, R> mapImageCache; + + /** + * The {@link FileControl}. + */ + @NotNull + private final FileControl<G, A, R> fileControl; + + /** + * Maps {@link MapControl} instances to associated {@link MapTracker} + * instances. + */ + @NotNull + private final Map<MapControl<G, A, R>, MapTracker> mapTrackers = new IdentityHashMap<MapControl<G, A, R>, MapTracker>(); + + /** + * Create a new instance. + * @param mapManager the map manager instance + * @param mapViewsManager the map views manager instance + * @param recentMenu menu for managing the recent entries + * @param globalSettings the global settings instance + * @param mapImageCache the map image cache instance + * @param fileControl the file control + */ + public RecentManager(@NotNull final MapManager<G, A, R> mapManager, @NotNull final MapViewsManager<G, A, R> mapViewsManager, @Nullable final JMenu recentMenu, @NotNull final GlobalSettings globalSettings, @NotNull final MapImageCache<G, A, R> mapImageCache, @NotNull final FileControl<G, A, R> fileControl) { + this.mapViewsManager = mapViewsManager; + this.recentMenu = recentMenu; + this.globalSettings = globalSettings; + this.mapImageCache = mapImageCache; + this.fileControl = fileControl; + + final MapManagerListener<G, A, R> mapManagerListener = new MapManagerListener<G, A, R>() { + + /** {@inheritDoc} */ + @Override + public void currentMapChanged(@Nullable final MapControl<G, A, R> mapControl) { + // ignore + } + + /** {@inheritDoc} */ + @Override + public void mapCreated(@NotNull final MapControl<G, A, R> mapControl, final boolean interactive) { + if (interactive) { + addRecent(mapControl.getMapModel(), null); + final MapTracker mapTracker = new MapTracker(mapControl.getMapModel()); + if (mapTrackers.put(mapControl, mapTracker) != null) { + assert false; + } + mapControl.addMapControlListener(mapTracker); + mapControl.getMapModel().addMapModelListener(mapTracker); + } + } + + /** {@inheritDoc} */ + @Override + public void mapClosing(@NotNull final MapControl<G, A, R> mapControl) { + // ignore + } + + /** {@inheritDoc} */ + @Override + public void mapClosed(@NotNull final MapControl<G, A, R> mapControl) { + final MapTracker mapTracker = mapTrackers.remove(mapControl); + if (mapTracker != null) { + mapControl.getMapModel().removeMapModelListener(mapTracker); + mapControl.removeMapControlListener(mapTracker); + } + } + + }; + mapManager.addMapManagerListener(mapManagerListener); + } + + /** + * Adds or updates an entry of the recent files. + * @param mapModel the map model to update the entry for + * @param oldMapFile the map file before the change + */ + private void addRecent(@NotNull final MapModel<G, A, R> mapModel, @Nullable final File oldMapFile) { + if (oldMapFile != null) { + removeRecent(oldMapFile); + } + + final File mapFile = mapModel.getMapFile(); + if (mapFile == null) { + return; + } + + final String title = mapModel.getMapArchObject().getMapName(); + final Recent<G, A, R> recent = new Recent<G, A, R>(title, mapFile, globalSettings.getMapsDirectory(), mapViewsManager, mapImageCache, fileControl); + recents.remove(recent); // remove old entry to get new entry at first pos. + recents.addFirst(recent); + // Now remove those that are too many. + // Please keep this while loop as the constant 10 might be replaced by a preferences var + int i = 0; + for (final ListIterator<Recent<G, A, R>> it = recents.listIterator(); it.hasNext();) { + it.next().setIndex(it.nextIndex()); // this looks bogus but it's intentionally currentIndex + 1 + if (++i > 10) { + it.remove(); + } + } + preferences.putInt("recentNum", recents.size()); + updateRecent(recents); + } + + /** + * Removes a recent entry for given map file. Does nothing if no such entry + * exists. + * @param mapFile the map file + */ + private void removeRecent(@NotNull final File mapFile) { + if (mapFile.exists()) { + return; + } + + for (int i = 0; i < recents.size(); i++) { + final Recent<G, A, R> recent = recents.get(i); + if (recent.getMapFile().equals(mapFile)) { + recents.remove(i); + break; + } + } + } + + /** + * Initializes the recent state. + */ + public void initRecent() { + final File mapsDirectory = globalSettings.getMapsDirectory(); + final int numRecents = preferences.getInt("recentNum", 0); + for (int i = 0; i < numRecents; i++) { + recents.add(new Recent<G, A, R>(i + 1, mapsDirectory, mapViewsManager, mapImageCache, fileControl)); + } + updateRecent(recents); + } + + /** + * Update the recent menu. + * @param recents current recents + */ + private void updateRecent(@NotNull final Iterable<Recent<G, A, R>> recents) { + if (recentMenu == null) { + return; + } + + MenuUtils.removeAll(recentMenu); + for (final Action recent : recents) { + recentMenu.add(recent); + } + } + + /** + * Watches a {@link MapModel} for map file changes. + * @author Andreas Kirschbaum + */ + private class MapTracker implements MapControlListener<G, A, R>, MapModelListener<G, A, R> { + + /** + * The {@link MapModel} to track. + */ + @NotNull + private final MapModel<G, A, R> mapModel; + + /** + * Creates a new instance. + * @param mapModel the map model to track + */ + private MapTracker(@NotNull final MapModel<G, A, R> mapModel) { + this.mapModel = mapModel; + } + + /** + * {@inheritDoc} + */ + @Override + public void mapSizeChanged(@NotNull final MapModel<G, A, R> mapModel, @NotNull final Size2D newSize) { + // ignore + } + + /** + * {@inheritDoc} + */ + @Override + public void mapSquaresChanged(@NotNull final Set<MapSquare<G, A, R>> mapSquares) { + // ignore + } + + /** + * {@inheritDoc} + */ + @Override + public void mapObjectsChanged(@NotNull final Set<G> gameObjects, @NotNull final Set<G> transientGameObjects) { + // ignore + } + + /** + * {@inheritDoc} + */ + @Override + public void mapMetaChanged() { + // ignore + } + + /** + * {@inheritDoc} + */ + @Override + public void errorsChanged(@NotNull final ErrorCollector<G, A, R> errors) { + // ignore + } + + /** + * {@inheritDoc} + */ + @Override + public void mapFileChanged(@Nullable final File oldMapFile) { + addRecent(mapModel, oldMapFile); + } + + /** + * {@inheritDoc} + */ + @Override + public void modifiedChanged(@NotNull final MapModel<G, A, R> mapModel) { + // ignore + } + + /** + * {@inheritDoc} + */ + @Override + public void saved(@NotNull final DefaultMapControl<G, A, R> mapControl) { + assert mapModel == mapControl.getMapModel(); + addRecent(mapModel, null); + } + + } + +} // class RecentManager Property changes on: trunk/src/app/net/sf/gridarta/gui/recent/RecentManager.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF Modified: trunk/src/app/net/sf/gridarta/maincontrol/GUIMainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/maincontrol/GUIMainControl.java 2010-05-30 07:41:54 UTC (rev 8037) +++ trunk/src/app/net/sf/gridarta/maincontrol/GUIMainControl.java 2010-05-30 07:43:00 UTC (rev 8038) @@ -87,13 +87,13 @@ import net.sf.gridarta.gui.misc.MainView; import net.sf.gridarta.gui.misc.MainViewActions; import net.sf.gridarta.gui.misc.MapPreview; -import net.sf.gridarta.gui.misc.RecentManager; import net.sf.gridarta.gui.misc.StatusBar; import net.sf.gridarta.gui.newmap.NewMapDialogFactory; import net.sf.gridarta.gui.objectchooser.DefaultObjectChooser; import net.sf.gridarta.gui.pickmapchooser.PickmapChooserControl; import net.sf.gridarta.gui.pickmapchooser.PickmapChooserModel; import net.sf.gridarta.gui.prefs.AppPreferencesModel; +import net.sf.gridarta.gui.recent.RecentManager; import net.sf.gridarta.gui.replacedialog.ReplaceDialogManager; import net.sf.gridarta.gui.script.ScriptController; import net.sf.gridarta.gui.script.parameter.PluginParameterViewFactory; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-05-30 07:42:01
|
Revision: 8037 http://gridarta.svn.sourceforge.net/gridarta/?rev=8037&view=rev Author: akirschbaum Date: 2010-05-30 07:41:54 +0000 (Sun, 30 May 2010) Log Message: ----------- Order import statements. Modified Paths: -------------- trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/maincontrol/DefaultEditorFactory.java trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/maincontrol/DefaultEditorFactory.java Modified: trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/maincontrol/DefaultEditorFactory.java =================================================================== --- trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/maincontrol/DefaultEditorFactory.java 2010-05-30 07:30:21 UTC (rev 8036) +++ trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/maincontrol/DefaultEditorFactory.java 2010-05-30 07:41:54 UTC (rev 8037) @@ -35,8 +35,8 @@ import net.sf.gridarta.gui.map.renderer.RendererFactory; import net.sf.gridarta.gui.mappropertiesdialog.MapPropertiesDialogFactory; import net.sf.gridarta.gui.newmap.NewMapDialogFactory; +import net.sf.gridarta.gui.prefs.AppPreferencesModel; import net.sf.gridarta.gui.prefs.AppPrefs; -import net.sf.gridarta.gui.prefs.AppPreferencesModel; import net.sf.gridarta.gui.prefs.DevPrefs; import net.sf.gridarta.gui.prefs.GUIPrefs; import net.sf.gridarta.gui.prefs.MapValidatorPrefs; Modified: trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/maincontrol/DefaultEditorFactory.java =================================================================== --- trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/maincontrol/DefaultEditorFactory.java 2010-05-30 07:30:21 UTC (rev 8036) +++ trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/maincontrol/DefaultEditorFactory.java 2010-05-30 07:41:54 UTC (rev 8037) @@ -35,8 +35,8 @@ import net.sf.gridarta.gui.map.renderer.RendererFactory; import net.sf.gridarta.gui.mappropertiesdialog.MapPropertiesDialogFactory; import net.sf.gridarta.gui.newmap.NewMapDialogFactory; +import net.sf.gridarta.gui.prefs.AppPreferencesModel; import net.sf.gridarta.gui.prefs.AppPrefs; -import net.sf.gridarta.gui.prefs.AppPreferencesModel; import net.sf.gridarta.gui.prefs.DevPrefs; import net.sf.gridarta.gui.prefs.GUIPrefs; import net.sf.gridarta.gui.prefs.MapValidatorPrefs; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-05-30 07:30:28
|
Revision: 8036 http://gridarta.svn.sourceforge.net/gridarta/?rev=8036&view=rev Author: akirschbaum Date: 2010-05-30 07:30:21 +0000 (Sun, 30 May 2010) Log Message: ----------- Update map header flags in map properties dialog to be in-sync with the ones server knows about. Modified Paths: -------------- trunk/atrinik/ChangeLog trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/gui/mappropertiesdialog/MapPropertiesDialog.java trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/messages.properties trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/messages_de.properties trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/messages_fr.properties trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/messages_sv.properties trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/model/io/MapArchObjectParser.java trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/model/maparchobject/MapArchObject.java Modified: trunk/atrinik/ChangeLog =================================================================== --- trunk/atrinik/ChangeLog 2010-05-29 19:03:56 UTC (rev 8035) +++ trunk/atrinik/ChangeLog 2010-05-30 07:30:21 UTC (rev 8036) @@ -1,3 +1,8 @@ +2010-05-30 Alex Tokar + + * Update map header flags in map properties dialog to be in-sync + with the ones server knows about. + 2010-05-29 Andreas Kirschbaum * Fix incorrect resource path names on Windows machines. Modified: trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/gui/mappropertiesdialog/MapPropertiesDialog.java =================================================================== --- trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/gui/mappropertiesdialog/MapPropertiesDialog.java 2010-05-29 19:03:56 UTC (rev 8035) +++ trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/gui/mappropertiesdialog/MapPropertiesDialog.java 2010-05-30 07:30:21 UTC (rev 8036) @@ -161,13 +161,13 @@ private final AbstractButton checkboxNoFixedLogin = new JCheckBox(); @NotNull - private final AbstractButton checkboxPermDeath = new JCheckBox(); + private final AbstractButton checkboxUnique = new JCheckBox(); @NotNull - private final AbstractButton checkboxUltraDeath = new JCheckBox(); + private final AbstractButton checkboxFixedResetTime = new JCheckBox(); @NotNull - private final AbstractButton checkboxUltimateDeath = new JCheckBox(); + private final AbstractButton checkboxPlayerNoSave = new JCheckBox(); @NotNull private final AbstractButton checkboxPvp = new JCheckBox(); @@ -310,9 +310,9 @@ optionPanel.add(createPanelCBox(checkboxNoHarm, map.isNoHarm(), "mapNoHarm")); optionPanel.add(createPanelCBox(checkboxNoSummon, map.isNoSummon(), "mapNoSumm")); optionPanel.add(createPanelCBox(checkboxNoFixedLogin, map.isFixedLogin(), "mapFixedLogin")); - optionPanel.add(createPanelCBox(checkboxPermDeath, map.isPermDeath(), "mapPermDeath")); - optionPanel.add(createPanelCBox(checkboxUltraDeath, map.isUltraDeath(), "mapUltraDeath")); - optionPanel.add(createPanelCBox(checkboxUltimateDeath, map.isUltimateDeath(), "mapInstantDeath")); + optionPanel.add(createPanelCBox(checkboxUnique, map.isUnique(), "mapUnique")); + optionPanel.add(createPanelCBox(checkboxFixedResetTime, map.isFixedResetTime(), "mapFixedResetTime")); + optionPanel.add(createPanelCBox(checkboxPlayerNoSave, map.isPlayerNoSave(), "mapPlayerNoSave")); optionPanel.add(createPanelCBox(checkboxPvp, map.isPvp(), "mapPvP")); optionPanel.add(createPanelCBox(checkboxPlugins, map.isPlugins(), "mapPlugins")); @@ -559,9 +559,9 @@ mapArchObject.setNoHarm(checkboxNoHarm.isSelected()); mapArchObject.setNoSummon(checkboxNoSummon.isSelected()); mapArchObject.setFixedLogin(checkboxNoFixedLogin.isSelected()); - mapArchObject.setPermDeath(checkboxPermDeath.isSelected()); - mapArchObject.setUltraDeath(checkboxUltraDeath.isSelected()); - mapArchObject.setUltimateDeath(checkboxUltimateDeath.isSelected()); + mapArchObject.setUnique(checkboxUnique.isSelected()); + mapArchObject.setFixedResetTime(checkboxFixedResetTime.isSelected()); + mapArchObject.setPlayerNoSave(checkboxPlayerNoSave.isSelected()); mapArchObject.setPvp(checkboxPvp.isSelected()); mapArchObject.setPlugins(checkboxPlugins.isSelected()); @@ -625,9 +625,9 @@ checkboxNoHarm.setSelected(map.isNoHarm()); checkboxNoSummon.setSelected(map.isNoSummon()); checkboxNoFixedLogin.setSelected(map.isFixedLogin()); - checkboxPermDeath.setSelected(map.isPermDeath()); - checkboxUltraDeath.setSelected(map.isUltraDeath()); - checkboxUltimateDeath.setSelected(map.isUltimateDeath()); + checkboxUnique.setSelected(map.isUnique()); + checkboxFixedResetTime.setSelected(map.isFixedResetTime()); + checkboxPlayerNoSave.setSelected(map.isPlayerNoSave()); checkboxPvp.setSelected(map.isPvp()); checkboxPlugins.setSelected(map.isPlugins()); Modified: trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/messages.properties =================================================================== --- trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/messages.properties 2010-05-29 19:03:56 UTC (rev 8035) +++ trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/messages.properties 2010-05-30 07:30:21 UTC (rev 8036) @@ -84,9 +84,9 @@ mapNoHarm=No Harmful Spells mapNoSumm=No Summoning mapFixedLogin=Fixed Login -mapPermDeath=Permanent Death -mapUltraDeath=Ultra Death -mapInstantDeath=Instant Death +mapUnique=Unique +mapFixedResetTime=Fixed Reset Time +mapPlayerNoSave=Players Cannot Save mapPvP=PvP Enabled mapPlugins=Plugins mapText=Map Text Modified: trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/messages_de.properties =================================================================== --- trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/messages_de.properties 2010-05-29 19:03:56 UTC (rev 8035) +++ trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/messages_de.properties 2010-05-30 07:30:21 UTC (rev 8036) @@ -42,9 +42,8 @@ mapNoHarm=Keine gef\xE4hrlichen Zauber mapNoSumm=Keine Herbeirufungszauber mapFixedLogin=Login am Startpunkt -mapPermDeath=Dauerhafter Tod -mapUltraDeath=Ultra-Tod -mapInstantDeath=Sofort-Tod +mapFixedResetTime=Fixer Reset +mapPlayerNoSave=Spieler kann nicht speichern mapPvP=Spieler gegen Spieler aktiv mapPlugins=Plugins mapText=Kartentext Modified: trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/messages_fr.properties =================================================================== --- trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/messages_fr.properties 2010-05-29 19:03:56 UTC (rev 8035) +++ trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/messages_fr.properties 2010-05-30 07:30:21 UTC (rev 8036) @@ -43,9 +43,9 @@ #mapNoHarm= #mapNoSumm= #mapFixedLogin= -#mapPermDeath= -#mapUltraDeath= -#mapInstantDeath= +#mapUnique= +#mapFixedResetTime= +#mapPlayerNoSave= #mapPvP= #mapPlugins= #mapText= Modified: trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/messages_sv.properties =================================================================== --- trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/messages_sv.properties 2010-05-29 19:03:56 UTC (rev 8035) +++ trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/messages_sv.properties 2010-05-30 07:30:21 UTC (rev 8036) @@ -42,9 +42,9 @@ mapNoHarm=Inga farliga trollformler mapNoSumm=Ingen \xE5kallning mapFixedLogin=Fixerad inloggning -mapPermDeath=Permanent d\xF6d -mapUltraDeath=Ultrad\xF6d -mapInstantDeath=Omedelbar d\xF6d +#mapUnique= +#mapFixedResetTime= +#mapPlayerNoSave= mapPvP=Spelare mot Spelare #mapPlugins= mapText=Karttext Modified: trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/model/io/MapArchObjectParser.java =================================================================== --- trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/model/io/MapArchObjectParser.java 2010-05-29 19:03:56 UTC (rev 8035) +++ trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/model/io/MapArchObjectParser.java 2010-05-30 07:30:21 UTC (rev 8036) @@ -88,14 +88,14 @@ if (mapArchObject.isFixedLogin()) { appendable.append("fixed_login 1\n"); } - if (mapArchObject.isPermDeath()) { - appendable.append("perm_death 1\n"); + if (mapArchObject.isUnique()) { + appendable.append("unique 1\n"); } - if (mapArchObject.isUltraDeath()) { - appendable.append("ultra_death 1\n"); + if (mapArchObject.isFixedResetTime()) { + appendable.append("fixed_resettime 1\n"); } - if (mapArchObject.isUltimateDeath()) { - appendable.append("ultimate_death 1\n"); + if (mapArchObject.isPlayerNoSave()) { + appendable.append("player_no_save 1\n"); } if (mapArchObject.isPvp()) { appendable.append("pvp 1\n"); @@ -159,18 +159,18 @@ return true; } - if (line.startsWith("perm_death ")) { - mapArchObject.setPermDeath(NumberUtils.parseInt(line.substring(11)) != 0); + if (line.startsWith("unique ")) { + mapArchObject.setUnique(NumberUtils.parseInt(line.substring(7)) != 0); return true; } - if (line.startsWith("ultra_death ")) { - mapArchObject.setUltraDeath(NumberUtils.parseInt(line.substring(12)) != 0); + if (line.startsWith("fixed_resettime ")) { + mapArchObject.setFixedResetTime(NumberUtils.parseInt(line.substring(16)) != 0); return true; } - if (line.startsWith("ultimate_death ")) { - mapArchObject.setUltimateDeath(NumberUtils.parseInt(line.substring(15)) != 0); + if (line.startsWith("player_no_save ")) { + mapArchObject.setPlayerNoSave(NumberUtils.parseInt(line.substring(15)) != 0); return true; } Modified: trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/model/maparchobject/MapArchObject.java =================================================================== --- trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/model/maparchobject/MapArchObject.java 2010-05-29 19:03:56 UTC (rev 8035) +++ trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/model/maparchobject/MapArchObject.java 2010-05-30 07:30:21 UTC (rev 8036) @@ -74,19 +74,19 @@ private boolean fixedLogin = false; /** - * Permanent death with revivable corpses. + * Unique map. */ - private boolean permDeath = false; + private boolean unique = false; /** - * Permament death with corpses temporarily available. + * Fixed reset time. */ - private boolean ultraDeath = false; + private boolean fixedResetTime = false; /** - * Permanent death with instant character deletion. + * Players cannot save on this map. */ - private boolean ultimateDeath = false; + private boolean playerNoSave = false; /** * Player vs Player combat allowed. @@ -137,9 +137,9 @@ setNoHarm(mapArchObject.noHarm); setNoSummon(mapArchObject.noSummon); setFixedLogin(mapArchObject.fixedLogin); - setPermDeath(mapArchObject.permDeath); - setUltraDeath(mapArchObject.ultraDeath); - setUltimateDeath(mapArchObject.ultimateDeath); + setUnique(mapArchObject.unique); + setFixedResetTime(mapArchObject.fixedResetTime); + setPlayerNoSave(mapArchObject.playerNoSave); setPvp(mapArchObject.pvp); setPlugins(mapArchObject.plugins); setTilesetId(mapArchObject.tilesetId); @@ -227,42 +227,42 @@ setModified(); } - public boolean isPermDeath() { - return permDeath; + public boolean isUnique() { + return unique; } - public void setPermDeath(final boolean permDeath) { - if (this.permDeath == permDeath) { + public void setUnique(final boolean unique) { + if (this.unique == unique) { return; } - this.permDeath = permDeath; + this.unique = unique; setModified(); } - public boolean isUltraDeath() { - return ultraDeath; + public boolean isFixedResetTime() { + return fixedResetTime; } - public void setUltraDeath(final boolean ultraDeath) { - if (this.ultraDeath == ultraDeath) { + public void setFixedResetTime(final boolean fixedResetTime) { + if (this.fixedResetTime == fixedResetTime) { return; } - this.ultraDeath = ultraDeath; + this.fixedResetTime = fixedResetTime; setModified(); } - public boolean isUltimateDeath() { - return ultimateDeath; + public boolean isPlayerNoSave() { + return playerNoSave; } - public void setUltimateDeath(final boolean ultimateDeath) { - if (this.ultimateDeath == ultimateDeath) { + public void setPlayerNoSave(final boolean playerNoSave) { + if (this.playerNoSave == playerNoSave) { return; } - this.ultimateDeath = ultimateDeath; + this.playerNoSave = playerNoSave; setModified(); } @@ -388,7 +388,7 @@ return false; } final MapArchObject mapArchObject = (MapArchObject) obj; - return super.equals(obj) && mapArchObject.noSave == noSave && mapArchObject.noMagic == noMagic && mapArchObject.noPriest == noPriest && mapArchObject.noHarm == noHarm && mapArchObject.noSummon == noSummon && mapArchObject.fixedLogin == fixedLogin && mapArchObject.permDeath == permDeath && mapArchObject.ultraDeath == ultraDeath && mapArchObject.ultimateDeath == ultimateDeath && mapArchObject.pvp == pvp && mapArchObject.plugins == plugins && mapArchObject.tilesetId == tilesetId && mapArchObject.tilesetX == tilesetX && mapArchObject.tilesetY == tilesetY && mapArchObject.backgroundMusic.equals(backgroundMusic); + return super.equals(obj) && mapArchObject.noSave == noSave && mapArchObject.noMagic == noMagic && mapArchObject.noPriest == noPriest && mapArchObject.noHarm == noHarm && mapArchObject.noSummon == noSummon && mapArchObject.fixedLogin == fixedLogin && mapArchObject.unique == unique && mapArchObject.fixedResetTime == fixedResetTime && mapArchObject.playerNoSave == playerNoSave && mapArchObject.pvp == pvp && mapArchObject.plugins == plugins && mapArchObject.tilesetId == tilesetId && mapArchObject.tilesetX == tilesetX && mapArchObject.tilesetY == tilesetY && mapArchObject.backgroundMusic.equals(backgroundMusic); } /** @@ -396,7 +396,7 @@ */ @Override public int hashCode() { - return super.hashCode() + (noSave ? 2 : 0) + (noMagic ? 4 : 0) + (noPriest ? 8 : 0) + (noHarm ? 16 : 0) + (noSummon ? 32 : 0) + (fixedLogin ? 64 : 0) + (permDeath ? 128 : 0) + (ultraDeath ? 256 : 0) + (ultimateDeath ? 512 : 0) + (pvp ? 1024 : 0) + (plugins ? 2048 : 0) + tilesetId + tilesetX + tilesetY + backgroundMusic.hashCode() + region.hashCode(); + return super.hashCode() + (noSave ? 2 : 0) + (noMagic ? 4 : 0) + (noPriest ? 8 : 0) + (noHarm ? 16 : 0) + (noSummon ? 32 : 0) + (fixedLogin ? 64 : 0) + (unique ? 128 : 0) + (fixedResetTime ? 256 : 0) + (playerNoSave ? 512 : 0) + (pvp ? 1024 : 0) + (plugins ? 2048 : 0) + tilesetId + tilesetX + tilesetY + backgroundMusic.hashCode() + region.hashCode(); } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |