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-06 19:37:18
|
Revision: 8185 http://gridarta.svn.sourceforge.net/gridarta/?rev=8185&view=rev Author: akirschbaum Date: 2010-06-06 19:37:12 +0000 (Sun, 06 Jun 2010) Log Message: ----------- Add @NotNull annotation. Modified Paths: -------------- trunk/src/app/net/sf/gridarta/validation/checks/AbstractShopSquareChecker.java Modified: trunk/src/app/net/sf/gridarta/validation/checks/AbstractShopSquareChecker.java =================================================================== --- trunk/src/app/net/sf/gridarta/validation/checks/AbstractShopSquareChecker.java 2010-06-06 19:26:02 UTC (rev 8184) +++ trunk/src/app/net/sf/gridarta/validation/checks/AbstractShopSquareChecker.java 2010-06-06 19:37:12 UTC (rev 8185) @@ -45,6 +45,7 @@ * @param matcher the matcher to use * @return the array */ + @NotNull protected boolean[][] findMatchingSquares(@NotNull final MapModel<G, A, R> mapModel, @NotNull final GameObjectMatcher matcher) { final Size2D mapSize = mapModel.getMapSize(); final int mapWidth = mapSize.getWidth(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-06-06 19:26:10
|
Revision: 8184 http://gridarta.svn.sourceforge.net/gridarta/?rev=8184&view=rev Author: akirschbaum Date: 2010-06-06 19:26:02 +0000 (Sun, 06 Jun 2010) Log Message: ----------- Fix "reload faces". Modified Paths: -------------- trunk/atrinik/ChangeLog trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/maincontrol/DefaultEditorFactory.java trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/model/archetype/ArchetypeSet.java trunk/atrinik/src/test/net/sf/gridarta/var/atrinik/model/archetype/ArchetypeParserTest.java trunk/crossfire/ChangeLog trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/maincontrol/DefaultEditorFactory.java trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/model/archetype/ArchetypeSet.java trunk/daimonin/ChangeLog trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/maincontrol/DefaultEditorFactory.java trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/model/archetype/ArchetypeSet.java trunk/src/app/net/sf/gridarta/gui/archetypechooser/ArchetypeChooserView.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java trunk/src/app/net/sf/gridarta/gui/replacedialog/ReplaceDialog.java trunk/src/app/net/sf/gridarta/gui/selectedsquare/SelectedSquareView.java trunk/src/app/net/sf/gridarta/gui/treasurelist/CFTreasureListTree.java trunk/src/app/net/sf/gridarta/gui/utils/AnimTreeChooseAction.java trunk/src/app/net/sf/gridarta/gui/utils/FaceTreeChooseAction.java trunk/src/app/net/sf/gridarta/maincontrol/EditorFactory.java trunk/src/app/net/sf/gridarta/maincontrol/GridartaEditor.java trunk/src/app/net/sf/gridarta/maincontrol/ImageCreatorFactory.java trunk/src/app/net/sf/gridarta/mapmanager/AbstractMapManager.java trunk/src/app/net/sf/gridarta/mapmanager/DefaultMapManager.java trunk/src/app/net/sf/gridarta/mapmanager/DefaultPickmapManager.java trunk/src/app/net/sf/gridarta/model/archetype/AbstractArchetypeSet.java trunk/src/app/net/sf/gridarta/model/baseobject/AbstractBaseObject.java trunk/src/app/net/sf/gridarta/model/baseobject/BaseObject.java trunk/src/app/net/sf/gridarta/model/face/FaceObjectProviders.java trunk/src/app/net/sf/gridarta/model/gameobject/DefaultIsoGameObject.java trunk/src/app/net/sf/gridarta/model/map/mapmodel/DefaultMapModel.java trunk/src/app/net/sf/gridarta/model/map/mapmodel/MapModel.java trunk/src/test/net/sf/gridarta/gui/map/test/TestMapControlCreator.java trunk/src/test/net/sf/gridarta/model/archetype/ArchetypeParserTest.java trunk/src/test/net/sf/gridarta/model/archetype/TestArchetypeSet.java trunk/src/test/net/sf/gridarta/model/artifact/ArtifactParserTest.java Added Paths: ----------- trunk/src/app/net/sf/gridarta/model/face/FaceObjectProvidersListener.java Modified: trunk/atrinik/ChangeLog =================================================================== --- trunk/atrinik/ChangeLog 2010-06-06 18:43:50 UTC (rev 8183) +++ trunk/atrinik/ChangeLog 2010-06-06 19:26:02 UTC (rev 8184) @@ -1,5 +1,7 @@ 2010-06-06 Andreas Kirschbaum + * Fix "reload faces". + * Fix NullPointerException in "paste exit" when connecting to an unsaved map. 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-06-06 18:43:50 UTC (rev 8183) +++ trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/maincontrol/DefaultEditorFactory.java 2010-06-06 19:26:02 UTC (rev 8184) @@ -279,8 +279,8 @@ */ @NotNull @Override - public ArchetypeSet newArchetypeSet(@NotNull final GlobalSettings globalSettings, @NotNull final ArchetypeFactory<GameObject, MapArchObject, Archetype> archetypeFactory, @NotNull final GameObjectParser<GameObject, MapArchObject, Archetype> gameObjectParser) { - return new ArchetypeSet(archetypeFactory); + public ArchetypeSet newArchetypeSet(@NotNull final GlobalSettings globalSettings, @NotNull final ArchetypeFactory<GameObject, MapArchObject, Archetype> archetypeFactory, @NotNull final GameObjectParser<GameObject, MapArchObject, Archetype> gameObjectParser, @NotNull final FaceObjectProviders faceObjectProviders) { + return new ArchetypeSet(archetypeFactory, faceObjectProviders); } /** Modified: trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/model/archetype/ArchetypeSet.java =================================================================== --- trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/model/archetype/ArchetypeSet.java 2010-06-06 18:43:50 UTC (rev 8183) +++ trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/model/archetype/ArchetypeSet.java 2010-06-06 19:26:02 UTC (rev 8184) @@ -23,6 +23,7 @@ import java.io.Writer; import net.sf.gridarta.model.archetype.AbstractArchetypeSet; import net.sf.gridarta.model.archetype.ArchetypeFactory; +import net.sf.gridarta.model.face.FaceObjectProviders; import net.sf.gridarta.var.atrinik.IGUIConstants; import net.sf.gridarta.var.atrinik.model.gameobject.GameObject; import net.sf.gridarta.var.atrinik.model.maparchobject.MapArchObject; @@ -40,9 +41,10 @@ /** * Create the ArchetypeSet. * @param archetypeFactory the archetype factory instance to use + * @param faceObjectProviders the face object providers */ - public ArchetypeSet(@NotNull final ArchetypeFactory<GameObject, MapArchObject, Archetype> archetypeFactory) { - super(archetypeFactory, IGUIConstants.ARCH_FILE); + public ArchetypeSet(@NotNull final ArchetypeFactory<GameObject, MapArchObject, Archetype> archetypeFactory, @NotNull final FaceObjectProviders faceObjectProviders) { + super(archetypeFactory, IGUIConstants.ARCH_FILE, faceObjectProviders); } /** Modified: 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 2010-06-06 18:43:50 UTC (rev 8183) +++ trunk/atrinik/src/test/net/sf/gridarta/var/atrinik/model/archetype/ArchetypeParserTest.java 2010-06-06 19:26:02 UTC (rev 8184) @@ -107,7 +107,7 @@ 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 = new ArchetypeSet(archetypeFactory, faceObjectProviders); archetypeSet.setLoadedFromArchive(true); assert archetypeSet != null; final IsoMapSquareInfo isoMapSquareInfo = new IsoMapSquareInfo(1, 1, 1, 1); Modified: trunk/crossfire/ChangeLog =================================================================== --- trunk/crossfire/ChangeLog 2010-06-06 18:43:50 UTC (rev 8183) +++ trunk/crossfire/ChangeLog 2010-06-06 19:26:02 UTC (rev 8184) @@ -1,5 +1,7 @@ 2010-06-06 Andreas Kirschbaum + * Fix "reload faces". + * Fix NullPointerException in "paste exit" when connecting to an unsaved map. Modified: trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/maincontrol/DefaultEditorFactory.java =================================================================== --- trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/maincontrol/DefaultEditorFactory.java 2010-06-06 18:43:50 UTC (rev 8183) +++ trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/maincontrol/DefaultEditorFactory.java 2010-06-06 19:26:02 UTC (rev 8184) @@ -229,8 +229,8 @@ */ @NotNull @Override - public ArchetypeSet newArchetypeSet(@NotNull final GlobalSettings globalSettings, @NotNull final ArchetypeFactory<GameObject, MapArchObject, Archetype> archetypeFactory, @NotNull final GameObjectParser<GameObject, MapArchObject, Archetype> gameObjectParser) { - return new ArchetypeSet(globalSettings.getImageSet(), archetypeFactory, gameObjectParser); + public ArchetypeSet newArchetypeSet(@NotNull final GlobalSettings globalSettings, @NotNull final ArchetypeFactory<GameObject, MapArchObject, Archetype> archetypeFactory, @NotNull final GameObjectParser<GameObject, MapArchObject, Archetype> gameObjectParser, @NotNull final FaceObjectProviders faceObjectProviders) { + return new ArchetypeSet(globalSettings.getImageSet(), archetypeFactory, gameObjectParser, faceObjectProviders); } /** Modified: trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/model/archetype/ArchetypeSet.java =================================================================== --- trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/model/archetype/ArchetypeSet.java 2010-06-06 18:43:50 UTC (rev 8183) +++ trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/model/archetype/ArchetypeSet.java 2010-06-06 19:26:02 UTC (rev 8184) @@ -23,6 +23,7 @@ import java.io.Writer; import net.sf.gridarta.model.archetype.AbstractArchetypeSet; import net.sf.gridarta.model.archetype.ArchetypeFactory; +import net.sf.gridarta.model.face.FaceObjectProviders; import net.sf.gridarta.model.io.GameObjectParser; import net.sf.gridarta.var.crossfire.IGUIConstants; import net.sf.gridarta.var.crossfire.model.gameobject.GameObject; @@ -55,9 +56,10 @@ * @param imageSet the image set to use * @param archetypeFactory the archetype factory to use * @param gameObjectParser the game object parser to use + * @param faceObjectProviders the face object providers */ - public ArchetypeSet(@NotNull final String imageSet, @NotNull final ArchetypeFactory<GameObject, MapArchObject, Archetype> archetypeFactory, @NotNull final GameObjectParser<GameObject, MapArchObject, Archetype> gameObjectParser) { - super(archetypeFactory, IGUIConstants.ARCH_FILE); + public ArchetypeSet(@NotNull final String imageSet, @NotNull final ArchetypeFactory<GameObject, MapArchObject, Archetype> archetypeFactory, @NotNull final GameObjectParser<GameObject, MapArchObject, Archetype> gameObjectParser, @NotNull final FaceObjectProviders faceObjectProviders) { + super(archetypeFactory, IGUIConstants.ARCH_FILE, faceObjectProviders); this.imageSet = imageSet.equals("none") ? null : imageSet; this.gameObjectParser = gameObjectParser; } Modified: trunk/daimonin/ChangeLog =================================================================== --- trunk/daimonin/ChangeLog 2010-06-06 18:43:50 UTC (rev 8183) +++ trunk/daimonin/ChangeLog 2010-06-06 19:26:02 UTC (rev 8184) @@ -1,5 +1,7 @@ 2010-06-06 Andreas Kirschbaum + * Fix "reload faces". + * Fix NullPointerException in "paste exit" when connecting to an unsaved map. 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-06-06 18:43:50 UTC (rev 8183) +++ trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/maincontrol/DefaultEditorFactory.java 2010-06-06 19:26:02 UTC (rev 8184) @@ -280,8 +280,8 @@ */ @NotNull @Override - public ArchetypeSet newArchetypeSet(@NotNull final GlobalSettings globalSettings, @NotNull final ArchetypeFactory<GameObject, MapArchObject, Archetype> archetypeFactory, @NotNull final GameObjectParser<GameObject, MapArchObject, Archetype> gameObjectParser) { - return new ArchetypeSet(archetypeFactory); + public ArchetypeSet newArchetypeSet(@NotNull final GlobalSettings globalSettings, @NotNull final ArchetypeFactory<GameObject, MapArchObject, Archetype> archetypeFactory, @NotNull final GameObjectParser<GameObject, MapArchObject, Archetype> gameObjectParser, @NotNull final FaceObjectProviders faceObjectProviders) { + return new ArchetypeSet(archetypeFactory, faceObjectProviders); } /** Modified: trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/model/archetype/ArchetypeSet.java =================================================================== --- trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/model/archetype/ArchetypeSet.java 2010-06-06 18:43:50 UTC (rev 8183) +++ trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/model/archetype/ArchetypeSet.java 2010-06-06 19:26:02 UTC (rev 8184) @@ -23,6 +23,7 @@ import java.io.Writer; import net.sf.gridarta.model.archetype.AbstractArchetypeSet; import net.sf.gridarta.model.archetype.ArchetypeFactory; +import net.sf.gridarta.model.face.FaceObjectProviders; import net.sf.gridarta.var.daimonin.IGUIConstants; import net.sf.gridarta.var.daimonin.model.gameobject.GameObject; import net.sf.gridarta.var.daimonin.model.maparchobject.MapArchObject; @@ -40,9 +41,10 @@ /** * Create the ArchetypeSet. * @param archetypeFactory the archetype factory instance to use + * @param faceObjectProviders the face object providers */ - public ArchetypeSet(@NotNull final ArchetypeFactory<GameObject, MapArchObject, Archetype> archetypeFactory) { - super(archetypeFactory, IGUIConstants.ARCH_FILE); + public ArchetypeSet(@NotNull final ArchetypeFactory<GameObject, MapArchObject, Archetype> archetypeFactory, @NotNull final FaceObjectProviders faceObjectProviders) { + super(archetypeFactory, IGUIConstants.ARCH_FILE, faceObjectProviders); } /** Modified: trunk/src/app/net/sf/gridarta/gui/archetypechooser/ArchetypeChooserView.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/archetypechooser/ArchetypeChooserView.java 2010-06-06 18:43:50 UTC (rev 8183) +++ trunk/src/app/net/sf/gridarta/gui/archetypechooser/ArchetypeChooserView.java 2010-06-06 19:26:02 UTC (rev 8184) @@ -37,6 +37,7 @@ import net.sf.gridarta.model.archetypechooser.ArchetypeChooserModel; import net.sf.gridarta.model.archetypechooser.ArchetypeChooserPanel; import net.sf.gridarta.model.face.FaceObjectProviders; +import net.sf.gridarta.model.face.FaceObjectProvidersListener; import net.sf.gridarta.model.gameobject.GameObject; import net.sf.gridarta.model.map.maparchobject.MapArchObject; import net.sf.gridarta.utils.ActionUtils; @@ -169,6 +170,23 @@ displayModeGameObjectNames = new DisplayNameCellRenderer<G, A, R>(faceObjectProviders); displayModeArchetypeNames = new ArchetypeNameCellRenderer<G, A, R>(faceObjectProviders); displayModeIconsOnly = new ArchetypeIconCellRenderer<G, A, R>(faceObjectProviders); + + final FaceObjectProvidersListener faceObjectProvidersListener = new FaceObjectProvidersListener() { + + @Override + public void facesReloaded() { + final ArchetypeChooserPanel<G, A, R> archetypeChooserPanel = archetypeChooserModel.getSelectedPanel(); + if (archetypeChooserPanel != null) { + final ArchetypePanel<G, A, R> archetypePanel = findPanel(archetypeChooserPanel.getName()); + if (archetypePanel != null) { + archetypePanel.repaint(); + } + } + } + + }; + faceObjectProviders.addFaceObjectProvidersListener(faceObjectProvidersListener); + final ButtonGroup buttonGroup = new ButtonGroup(); buttonGroup.add(buttonDisplayGameObjectNames); buttonGroup.add(buttonDisplayArchetypeNames); Modified: trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java 2010-06-06 18:43:50 UTC (rev 8183) +++ trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java 2010-06-06 19:26:02 UTC (rev 8184) @@ -111,6 +111,7 @@ import net.sf.gridarta.model.archetypetype.AttributeBitmask; import net.sf.gridarta.model.baseobject.BaseObject; import net.sf.gridarta.model.face.FaceObjectProviders; +import net.sf.gridarta.model.face.FaceObjectProvidersListener; import net.sf.gridarta.model.face.FaceObjects; import net.sf.gridarta.model.gameobject.GameObject; import net.sf.gridarta.model.gameobject.GameObjectUtils; @@ -751,6 +752,22 @@ }; /** + * The {@link FaceObjectProvidersListener} for detecting reloaded faces. + */ + @NotNull + private final FaceObjectProvidersListener faceObjectProvidersListener = new FaceObjectProvidersListener() { + + /** + * {@inheritDoc} + */ + @Override + public void facesReloaded() { + faceLabel.setIcon(getFace(gameObject)); + } + + }; + + /** * Create an AbstractGameObjectAttributesDialog. * @param gameObjectAttributesDialogFactory the associated factory * @param archetypeTypeSet Reference to the list of archetype types. @@ -846,6 +863,8 @@ summaryTextStyle = summaryTextPane.getStyle(StyleContext.DEFAULT_STYLE); StyleConstants.setForeground(summaryTextStyle, Color.black); + faceObjectProviders.addFaceObjectProvidersListener(faceObjectProvidersListener); + setMessage(contentPanel); } @@ -873,6 +892,7 @@ gameObjectAttributesDialogFactory.hideAttributeDialog(gameObject); mapModel.removeMapModelListener(mapModelListener); mapManager.removeMapManagerListener(mapManagerListener); + faceObjectProviders.removeFaceObjectProvidersListener(faceObjectProvidersListener); } } Modified: trunk/src/app/net/sf/gridarta/gui/replacedialog/ReplaceDialog.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/replacedialog/ReplaceDialog.java 2010-06-06 18:43:50 UTC (rev 8183) +++ trunk/src/app/net/sf/gridarta/gui/replacedialog/ReplaceDialog.java 2010-06-06 19:26:02 UTC (rev 8184) @@ -50,6 +50,7 @@ import net.sf.gridarta.model.archetype.Archetype; import net.sf.gridarta.model.baseobject.BaseObject; import net.sf.gridarta.model.face.FaceObjectProviders; +import net.sf.gridarta.model.face.FaceObjectProvidersListener; import net.sf.gridarta.model.gameobject.GameObject; import net.sf.gridarta.model.map.maparchobject.MapArchObject; import net.sf.gridarta.model.map.mapcontrol.MapControl; @@ -224,6 +225,19 @@ }; /** + * The {@link FaceObjectProvidersListener} for detecting reloaded faces. + */ + @NotNull + private final FaceObjectProvidersListener faceObjectProvidersListener = new FaceObjectProvidersListener() { + + @Override + public void facesReloaded() { + updateArchSelection(objectChooser.getSelection(), false); + } + + }; + + /** * Creates a new instance. * @param parent the parent component for dialogs * @param copyBuffer the copy buffer's @@ -242,6 +256,7 @@ this.objectChooser = objectChooser; this.faceObjectProviders = faceObjectProviders; objectChooser.addObjectChooserListener(objectChooserListener); + faceObjectProviders.addFaceObjectProvidersListener(faceObjectProvidersListener); } /** Modified: trunk/src/app/net/sf/gridarta/gui/selectedsquare/SelectedSquareView.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/selectedsquare/SelectedSquareView.java 2010-06-06 18:43:50 UTC (rev 8183) +++ trunk/src/app/net/sf/gridarta/gui/selectedsquare/SelectedSquareView.java 2010-06-06 19:26:02 UTC (rev 8184) @@ -139,7 +139,7 @@ /** {@inheritDoc} */ @Override public void mapObjectsChanged(@NotNull final Set<G> gameObjects, @NotNull final Set<G> transientGameObjects) { - if (selectedSquareModel.isSelectedGameObjects(gameObjects)) { + if (selectedSquareModel.isSelectedGameObjects(gameObjects) || selectedSquareModel.isSelectedGameObjects(transientGameObjects)) { refresh(); } } Modified: trunk/src/app/net/sf/gridarta/gui/treasurelist/CFTreasureListTree.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/treasurelist/CFTreasureListTree.java 2010-06-06 18:43:50 UTC (rev 8183) +++ trunk/src/app/net/sf/gridarta/gui/treasurelist/CFTreasureListTree.java 2010-06-06 19:26:02 UTC (rev 8184) @@ -44,6 +44,7 @@ import net.sf.gridarta.model.archetype.Archetype; import net.sf.gridarta.model.archetype.ArchetypeSet; import net.sf.gridarta.model.face.FaceObjectProviders; +import net.sf.gridarta.model.face.FaceObjectProvidersListener; import net.sf.gridarta.model.gameobject.GameObject; import net.sf.gridarta.model.map.maparchobject.MapArchObject; import net.sf.gridarta.model.treasurelist.FolderTreasureObj; @@ -133,6 +134,16 @@ this.treasureTree = treasureTree; this.parent = parent; + final FaceObjectProvidersListener faceObjectProvidersListener = new FaceObjectProvidersListener() { + + @Override + public void facesReloaded() { + repaint(); + } + + }; + faceObjectProviders.addFaceObjectProvidersListener(faceObjectProvidersListener); + putClientProperty("JTree.lineStyle", "Angled"); setCellRenderer(new TreasureCellRenderer<G, A, R>(archetypeSet, treasureTree.getRoot(), faceObjectProviders, systemIcons)); Modified: trunk/src/app/net/sf/gridarta/gui/utils/AnimTreeChooseAction.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/utils/AnimTreeChooseAction.java 2010-06-06 18:43:50 UTC (rev 8183) +++ trunk/src/app/net/sf/gridarta/gui/utils/AnimTreeChooseAction.java 2010-06-06 19:26:02 UTC (rev 8184) @@ -27,6 +27,7 @@ import net.sf.gridarta.model.anim.AnimationObjects; import net.sf.gridarta.model.data.NamedObject; import net.sf.gridarta.model.face.FaceObjectProviders; +import net.sf.gridarta.model.face.FaceObjectProvidersListener; import org.jetbrains.annotations.NotNull; /** @@ -90,6 +91,17 @@ this.faceObjectProviders = faceObjectProviders; this.unknownSquareIcon = unknownSquareIcon; this.noFaceSquareIcon = noFaceSquareIcon; + + final FaceObjectProvidersListener faceObjectProvidersListener = new FaceObjectProvidersListener() { + + @Override + public void facesReloaded() { + updateIconLabel(); + } + + }; + faceObjectProviders.addFaceObjectProvidersListener(faceObjectProvidersListener); + updateIconLabel(); } Modified: trunk/src/app/net/sf/gridarta/gui/utils/FaceTreeChooseAction.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/utils/FaceTreeChooseAction.java 2010-06-06 18:43:50 UTC (rev 8183) +++ trunk/src/app/net/sf/gridarta/gui/utils/FaceTreeChooseAction.java 2010-06-06 19:26:02 UTC (rev 8184) @@ -27,6 +27,7 @@ import net.sf.gridarta.model.data.NamedObject; import net.sf.gridarta.model.data.NamedObjects; import net.sf.gridarta.model.face.FaceObjectProviders; +import net.sf.gridarta.model.face.FaceObjectProvidersListener; import org.jetbrains.annotations.NotNull; /** @@ -79,8 +80,19 @@ super(text, textComponent, namedObjects, faceObjectProviders); this.icon = icon; this.faceObjectProviders = faceObjectProviders; + this.noFaceSquareIcon = noFaceSquareIcon; this.unknownSquareIcon = unknownSquareIcon; - this.noFaceSquareIcon = noFaceSquareIcon; + + final FaceObjectProvidersListener faceObjectProvidersListener = new FaceObjectProvidersListener() { + + @Override + public void facesReloaded() { + updateIconLabel(); + } + + }; + faceObjectProviders.addFaceObjectProvidersListener(faceObjectProvidersListener); + updateIconLabel(); } Modified: trunk/src/app/net/sf/gridarta/maincontrol/EditorFactory.java =================================================================== --- trunk/src/app/net/sf/gridarta/maincontrol/EditorFactory.java 2010-06-06 18:43:50 UTC (rev 8183) +++ trunk/src/app/net/sf/gridarta/maincontrol/EditorFactory.java 2010-06-06 19:26:02 UTC (rev 8184) @@ -179,10 +179,11 @@ * @param globalSettings the global settings to use * @param archetypeFactory the archetype factory to use * @param gameObjectParser the game object parser to use + * @param faceObjectProviders the face object providers to use * @return the new instance */ @NotNull - ArchetypeSet<G, A, R> newArchetypeSet(@NotNull GlobalSettings globalSettings, @NotNull ArchetypeFactory<G, A, R> archetypeFactory, @NotNull GameObjectParser<G, A, R> gameObjectParser); + ArchetypeSet<G, A, R> newArchetypeSet(@NotNull GlobalSettings globalSettings, @NotNull ArchetypeFactory<G, A, R> archetypeFactory, @NotNull GameObjectParser<G, A, R> gameObjectParser, @NotNull FaceObjectProviders faceObjectProviders); /** * Creates a new {@link MapControlFactory} instance. Modified: trunk/src/app/net/sf/gridarta/maincontrol/GridartaEditor.java =================================================================== --- trunk/src/app/net/sf/gridarta/maincontrol/GridartaEditor.java 2010-06-06 18:43:50 UTC (rev 8183) +++ trunk/src/app/net/sf/gridarta/maincontrol/GridartaEditor.java 2010-06-06 19:26:02 UTC (rev 8184) @@ -234,7 +234,7 @@ final GameObjectParserFactory<G, A, R> gameObjectParserFactory = editorFactory.newGameObjectParserFactory(gameObjectFactory, gameObjectMatchers); final GameObjectParser<G, A, R> gameObjectParser = gameObjectParserFactory.newGameObjectParser(); final ArchetypeFactory<G, A, R> archetypeFactory = editorFactory.newArchetypeFactory(faceObjectProviders, animationObjects); - final ArchetypeSet<G, A, R> archetypeSet = editorFactory.newArchetypeSet(globalSettings, archetypeFactory, gameObjectParser); + final ArchetypeSet<G, A, R> archetypeSet = editorFactory.newArchetypeSet(globalSettings, archetypeFactory, gameObjectParser, faceObjectProviders); final MapArchObjectFactory<A> mapArchObjectFactory = editorFactory.newMapArchObjectFactory(globalSettings); final MapArchObjectParserFactory<A> mapArchObjectParserFactory = editorFactory.newMapArchObjectParserFactory(); final DefaultMapReaderFactory<G, A, R> mapReaderFactory = new DefaultMapReaderFactory<G, A, R>(mapArchObjectFactory, mapArchObjectParserFactory, gameObjectParserFactory, archetypeSet, mapViewSettings); @@ -243,8 +243,8 @@ final AutojoinLists<G, A, R> autojoinLists = new AutojoinLists<G, A, R>(mapViewSettings); final MapWriter<G, A, R> mapWriter = new DefaultMapWriter<G, A, R>(mapArchObjectParserFactory, gameObjectParser); final MapControlFactory<G, A, R> mapControlFactory = editorFactory.newMapControlFactory(archetypeChooserModel, autojoinLists, mapViewSettings, mapWriter, gameObjectFactory, gameObjectMatchers, globalSettings, topmostInsertionMode); - final AbstractMapManager<G, A, R> mapManager = new DefaultMapManager<G, A, R>(mapReaderFactory, mapControlFactory, globalSettings); - final MapManager<G, A, R> pickmapManager = new DefaultPickmapManager<G, A, R>(mapReaderFactory, mapControlFactory, globalSettings); + final AbstractMapManager<G, A, R> mapManager = new DefaultMapManager<G, A, R>(mapReaderFactory, mapControlFactory, globalSettings, faceObjectProviders); + final MapManager<G, A, R> pickmapManager = new DefaultPickmapManager<G, A, R>(mapReaderFactory, mapControlFactory, globalSettings, faceObjectProviders); final ScriptModel<G, A, R> scriptModel = new ScriptModel<G, A, R>(); final DelegatingMapValidator<G, A, R> validators = new DelegatingMapValidator<G, A, R>(); final ScriptedEventEditor<G, A, R> scriptedEventEditor = new ScriptedEventEditor<G, A, R>(globalSettings); Modified: trunk/src/app/net/sf/gridarta/maincontrol/ImageCreatorFactory.java =================================================================== --- trunk/src/app/net/sf/gridarta/maincontrol/ImageCreatorFactory.java 2010-06-06 18:43:50 UTC (rev 8183) +++ trunk/src/app/net/sf/gridarta/maincontrol/ImageCreatorFactory.java 2010-06-06 19:26:02 UTC (rev 8184) @@ -102,7 +102,7 @@ final GameObjectParserFactory<G, A, R> gameObjectParserFactory = editorFactory.newGameObjectParserFactory(gameObjectFactory, gameObjectMatchers); final ArchetypeFactory<G, A, R> archetypeFactory = editorFactory.newArchetypeFactory(faceObjectProviders, animationObjects); final GameObjectParser<G, A, R> gameObjectParser = gameObjectParserFactory.newGameObjectParser(); - final ArchetypeSet<G, A, R> archetypeSet = editorFactory.newArchetypeSet(globalSettings, archetypeFactory, gameObjectParser); + final ArchetypeSet<G, A, R> archetypeSet = editorFactory.newArchetypeSet(globalSettings, archetypeFactory, gameObjectParser, faceObjectProviders); final MapViewSettings mapViewSettings = new MapViewSettings(); final MapReaderFactory<G, A> mapReaderFactory = new DefaultMapReaderFactory<G, A, R>(mapArchObjectFactory, mapArchObjectParserFactory, gameObjectParserFactory, archetypeSet, mapViewSettings); final MapWriter<G, A, R> mapWriter = new DefaultMapWriter<G, A, R>(mapArchObjectParserFactory, gameObjectParser); @@ -110,7 +110,7 @@ final ArchetypeChooserModel<G, A, R> archetypeChooserModel = new ArchetypeChooserModel<G, A, R>(); final InsertionMode<G, A, R> topmostInsertionMode = new TopmostInsertionMode<G, A, R>(); final MapControlFactory<G, A, R> mapControlFactory = editorFactory.newMapControlFactory(archetypeChooserModel, autojoinLists, mapViewSettings, mapWriter, gameObjectFactory, gameObjectMatchers, globalSettings, topmostInsertionMode); - final MapManager<G, A, R> mapManager = new DefaultMapManager<G, A, R>(mapReaderFactory, mapControlFactory, globalSettings); + final MapManager<G, A, R> mapManager = new DefaultMapManager<G, A, R>(mapReaderFactory, mapControlFactory, globalSettings, faceObjectProviders); final Set<NamedGameObjectMatcher> matchers = new HashSet<NamedGameObjectMatcher>(); final NamedFilter defaultNamedFilterList = new NamedFilter(matchers); final FilterControl<G, A, R> filterControl = new DefaultFilterControl<G, A, R>(defaultNamedFilterList); Modified: trunk/src/app/net/sf/gridarta/mapmanager/AbstractMapManager.java =================================================================== --- trunk/src/app/net/sf/gridarta/mapmanager/AbstractMapManager.java 2010-06-06 18:43:50 UTC (rev 8183) +++ trunk/src/app/net/sf/gridarta/mapmanager/AbstractMapManager.java 2010-06-06 19:26:02 UTC (rev 8184) @@ -26,6 +26,8 @@ import java.util.Iterator; import java.util.List; import net.sf.gridarta.model.archetype.Archetype; +import net.sf.gridarta.model.face.FaceObjectProviders; +import net.sf.gridarta.model.face.FaceObjectProvidersListener; import net.sf.gridarta.model.gameobject.GameObject; import net.sf.gridarta.model.io.MapReader; import net.sf.gridarta.model.io.MapReaderFactory; @@ -100,10 +102,23 @@ * Create a new map manager. * @param mapReaderFactory the map reader factory instance * @param globalSettings the global settings instance + * @param faceObjectProviders the face object providers */ - protected AbstractMapManager(@NotNull final MapReaderFactory<G, A> mapReaderFactory, @NotNull final GlobalSettings globalSettings) { + protected AbstractMapManager(@NotNull final MapReaderFactory<G, A> mapReaderFactory, @NotNull final GlobalSettings globalSettings, @NotNull final FaceObjectProviders faceObjectProviders) { this.globalSettings = globalSettings; this.mapReaderFactory = mapReaderFactory; + + final FaceObjectProvidersListener faceObjectProvidersListener = new FaceObjectProvidersListener() { + + @Override + public void facesReloaded() { + for (final MapControl<G, A, R> mapControl : mapControls) { + mapControl.getMapModel().facesReloaded(); + } + } + + }; + faceObjectProviders.addFaceObjectProvidersListener(faceObjectProvidersListener); } @Deprecated Modified: trunk/src/app/net/sf/gridarta/mapmanager/DefaultMapManager.java =================================================================== --- trunk/src/app/net/sf/gridarta/mapmanager/DefaultMapManager.java 2010-06-06 18:43:50 UTC (rev 8183) +++ trunk/src/app/net/sf/gridarta/mapmanager/DefaultMapManager.java 2010-06-06 19:26:02 UTC (rev 8184) @@ -22,6 +22,7 @@ import java.io.File; import java.util.List; import net.sf.gridarta.model.archetype.Archetype; +import net.sf.gridarta.model.face.FaceObjectProviders; import net.sf.gridarta.model.gameobject.GameObject; import net.sf.gridarta.model.io.MapReaderFactory; import net.sf.gridarta.model.map.maparchobject.MapArchObject; @@ -48,9 +49,10 @@ * @param mapReaderFactory the map reader factory instance * @param mapControlFactory the map control factory instance * @param globalSettings the global settings instance + * @param faceObjectProviders the face object providers */ - public DefaultMapManager(@NotNull final MapReaderFactory<G, A> mapReaderFactory, @NotNull final MapControlFactory<G, A, R> mapControlFactory, @NotNull final GlobalSettings globalSettings) { - super(mapReaderFactory, globalSettings); + public DefaultMapManager(@NotNull final MapReaderFactory<G, A> mapReaderFactory, @NotNull final MapControlFactory<G, A, R> mapControlFactory, @NotNull final GlobalSettings globalSettings, @NotNull final FaceObjectProviders faceObjectProviders) { + super(mapReaderFactory, globalSettings, faceObjectProviders); this.mapControlFactory = mapControlFactory; } Modified: trunk/src/app/net/sf/gridarta/mapmanager/DefaultPickmapManager.java =================================================================== --- trunk/src/app/net/sf/gridarta/mapmanager/DefaultPickmapManager.java 2010-06-06 18:43:50 UTC (rev 8183) +++ trunk/src/app/net/sf/gridarta/mapmanager/DefaultPickmapManager.java 2010-06-06 19:26:02 UTC (rev 8184) @@ -22,6 +22,7 @@ import java.io.File; import java.util.List; import net.sf.gridarta.model.archetype.Archetype; +import net.sf.gridarta.model.face.FaceObjectProviders; import net.sf.gridarta.model.gameobject.GameObject; import net.sf.gridarta.model.io.MapReaderFactory; import net.sf.gridarta.model.map.maparchobject.MapArchObject; @@ -48,9 +49,10 @@ * @param mapReaderFactory the map reader factory instance * @param mapControlFactory the map control factory instance * @param globalSettings the global settings instance + * @param faceObjectProviders the face object providers */ - public DefaultPickmapManager(@NotNull final MapReaderFactory<G, A> mapReaderFactory, @NotNull final MapControlFactory<G, A, R> mapControlFactory, @NotNull final GlobalSettings globalSettings) { - super(mapReaderFactory, globalSettings); + public DefaultPickmapManager(@NotNull final MapReaderFactory<G, A> mapReaderFactory, @NotNull final MapControlFactory<G, A, R> mapControlFactory, @NotNull final GlobalSettings globalSettings, @NotNull final FaceObjectProviders faceObjectProviders) { + super(mapReaderFactory, globalSettings, faceObjectProviders); this.mapControlFactory = mapControlFactory; } Modified: trunk/src/app/net/sf/gridarta/model/archetype/AbstractArchetypeSet.java =================================================================== --- trunk/src/app/net/sf/gridarta/model/archetype/AbstractArchetypeSet.java 2010-06-06 18:43:50 UTC (rev 8183) +++ trunk/src/app/net/sf/gridarta/model/archetype/AbstractArchetypeSet.java 2010-06-06 19:26:02 UTC (rev 8184) @@ -33,6 +33,8 @@ import java.util.Map; import java.util.TreeMap; import net.sf.gridarta.model.baseobject.BaseObject; +import net.sf.gridarta.model.face.FaceObjectProviders; +import net.sf.gridarta.model.face.FaceObjectProvidersListener; import net.sf.gridarta.model.gameobject.GameObject; import net.sf.gridarta.model.map.maparchobject.MapArchObject; import net.sf.gridarta.utils.EventListenerList2; @@ -102,10 +104,21 @@ * Create an AbstractArchetypeSet. * @param archetypeFactory the archetype factory to use * @param archFile the collected archetypes file name + * @param faceObjectProviders the face object providers */ - protected AbstractArchetypeSet(@NotNull final ArchetypeFactory<G, A, R> archetypeFactory, @NotNull final String archFile) { + protected AbstractArchetypeSet(@NotNull final ArchetypeFactory<G, A, R> archetypeFactory, @NotNull final String archFile, @NotNull final FaceObjectProviders faceObjectProviders) { this.archetypeFactory = archetypeFactory; this.archFile = archFile; + + final FaceObjectProvidersListener faceObjectProvidersListener = new FaceObjectProvidersListener() { + + @Override + public void facesReloaded() { + connectFaces(); + } + + }; + faceObjectProviders.addFaceObjectProvidersListener(faceObjectProvidersListener); } /** Modified: trunk/src/app/net/sf/gridarta/model/baseobject/AbstractBaseObject.java =================================================================== --- trunk/src/app/net/sf/gridarta/model/baseobject/AbstractBaseObject.java 2010-06-06 18:43:50 UTC (rev 8183) +++ trunk/src/app/net/sf/gridarta/model/baseobject/AbstractBaseObject.java 2010-06-06 19:26:02 UTC (rev 8184) @@ -873,7 +873,7 @@ * Records that this game object has changed but need not be restored by * undo/redo actions. */ - private void transientGameObjectChange() { + protected void transientGameObjectChange() { if (multi == null) { notifyTransientChange(); } else { @@ -1073,6 +1073,15 @@ } /** + * {@inheritDoc} + */ + @Override + public void facesReloaded() { + normalFace = null; + transientGameObjectChange(); + } + + /** * Returns <code>this</code> as its real type. * @return <code>this<c/code> */ Modified: trunk/src/app/net/sf/gridarta/model/baseobject/BaseObject.java =================================================================== --- trunk/src/app/net/sf/gridarta/model/baseobject/BaseObject.java 2010-06-06 18:43:50 UTC (rev 8183) +++ trunk/src/app/net/sf/gridarta/model/baseobject/BaseObject.java 2010-06-06 19:26:02 UTC (rev 8184) @@ -547,4 +547,9 @@ */ boolean usesDirection(); + /** + * Will be called whenever the archetype faces have been reloaded. + */ + void facesReloaded(); + } // interface BaseObject Modified: trunk/src/app/net/sf/gridarta/model/face/FaceObjectProviders.java =================================================================== --- trunk/src/app/net/sf/gridarta/model/face/FaceObjectProviders.java 2010-06-06 18:43:50 UTC (rev 8183) +++ trunk/src/app/net/sf/gridarta/model/face/FaceObjectProviders.java 2010-06-06 19:26:02 UTC (rev 8184) @@ -29,6 +29,7 @@ import net.sf.gridarta.model.gameobject.GameObject; import net.sf.gridarta.model.map.maparchobject.MapArchObject; import net.sf.gridarta.utils.AlphaImageFilterInstance; +import net.sf.gridarta.utils.EventListenerList2; import net.sf.gridarta.utils.SystemIcons; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -162,6 +163,13 @@ private final SystemIcons systemIcons; /** + * The {@link FaceObjectProvidersListener FaceObjectProvidersListeners} to + * notify about changes. + */ + @NotNull + private final EventListenerList2<FaceObjectProvidersListener> faceObjectProvidersListeners = new EventListenerList2<FaceObjectProvidersListener>(FaceObjectProvidersListener.class); + + /** * Creates a new instance. * @param doubleFaceOffset the offset for shifting double faces * @param faceObjects the face objects instance @@ -175,6 +183,22 @@ } /** + * Adds a {@link FaceObjectProvidersListener} to be notified about changes. + * @param listener the listener + */ + public void addFaceObjectProvidersListener(@NotNull final FaceObjectProvidersListener listener) { + faceObjectProvidersListeners.add(listener); + } + + /** + * Removes a {@link FaceObjectProvidersListener} to be notified about changes. + * @param listener the listener + */ + public void removeFaceObjectProvidersListener(@NotNull final FaceObjectProvidersListener listener) { + faceObjectProvidersListeners.remove(listener); + } + + /** * Reloads all providers provided by this FaceObjects. */ public void reloadAll() { @@ -184,6 +208,10 @@ for (final FaceProvider faceProvider : new FaceProvider[] { GRAY, RED, GREEN, BLUE, ALPHA, GRID, doubleFaceProvider, doubleAlphaFaceProvider }) { faceProvider.reload(); } + + for (final FaceObjectProvidersListener faceObjectProvidersListener : faceObjectProvidersListeners.getListeners()) { + faceObjectProvidersListener.facesReloaded(); + } } /** Added: trunk/src/app/net/sf/gridarta/model/face/FaceObjectProvidersListener.java =================================================================== --- trunk/src/app/net/sf/gridarta/model/face/FaceObjectProvidersListener.java (rev 0) +++ trunk/src/app/net/sf/gridarta/model/face/FaceObjectProvidersListener.java 2010-06-06 19:26:02 UTC (rev 8184) @@ -0,0 +1,36 @@ +/* + * 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.face; + +import java.util.EventListener; + +/** + * Interface for listeners interested in {@link FaceObjectProviders} related + * events. + * @author Andreas Kirschbaum + */ +public interface FaceObjectProvidersListener extends EventListener { + + /** + * Called whenever the faces have been reloaded. + */ + void facesReloaded(); + +} // interface FaceObjectProvidersListener Property changes on: trunk/src/app/net/sf/gridarta/model/face/FaceObjectProvidersListener.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF Modified: trunk/src/app/net/sf/gridarta/model/gameobject/DefaultIsoGameObject.java =================================================================== --- trunk/src/app/net/sf/gridarta/model/gameobject/DefaultIsoGameObject.java 2010-06-06 18:43:50 UTC (rev 8183) +++ trunk/src/app/net/sf/gridarta/model/gameobject/DefaultIsoGameObject.java 2010-06-06 19:26:02 UTC (rev 8184) @@ -99,10 +99,10 @@ */ @Override public void setObjectFace() { - super.setObjectFace(); transFace = null; doubleFace = null; transDoubleFace = null; + super.setObjectFace(); } /** @@ -184,4 +184,15 @@ } } + /** + * {@inheritDoc} + */ + @Override + public void facesReloaded() { + transFace = null; + doubleFace = null; + transDoubleFace = null; + super.facesReloaded(); + } + } // class DefaultIsoGameObject Modified: trunk/src/app/net/sf/gridarta/model/map/mapmodel/DefaultMapModel.java =================================================================== --- trunk/src/app/net/sf/gridarta/model/map/mapmodel/DefaultMapModel.java 2010-06-06 18:43:50 UTC (rev 8183) +++ trunk/src/app/net/sf/gridarta/model/map/mapmodel/DefaultMapModel.java 2010-06-06 19:26:02 UTC (rev 8184) @@ -1040,6 +1040,23 @@ } /** + * {@inheritDoc} + */ + @Override + public void facesReloaded() { + beginTransaction("reload faces"); + try { + for (final Iterable<G> mapSquare : this) { + for (final G gameObject : mapSquare) { + gameObject.facesReloaded(); + } + } + } finally { + endTransaction(); + } + } + + /** * Marks the map as being modified. */ private void setModified() { Modified: trunk/src/app/net/sf/gridarta/model/map/mapmodel/MapModel.java =================================================================== --- trunk/src/app/net/sf/gridarta/model/map/mapmodel/MapModel.java 2010-06-06 18:43:50 UTC (rev 8183) +++ trunk/src/app/net/sf/gridarta/model/map/mapmodel/MapModel.java 2010-06-06 19:26:02 UTC (rev 8184) @@ -458,4 +458,9 @@ */ void resetModified(); + /** + * Will be called whenever the archetype faces have been reloaded. + */ + void facesReloaded(); + } // interface MapModel Modified: trunk/src/test/net/sf/gridarta/gui/map/test/TestMapControlCreator.java =================================================================== --- trunk/src/test/net/sf/gridarta/gui/map/test/TestMapControlCreator.java 2010-06-06 18:43:50 UTC (rev 8183) +++ trunk/src/test/net/sf/gridarta/gui/map/test/TestMapControlCreator.java 2010-06-06 19:26:02 UTC (rev 8184) @@ -229,12 +229,12 @@ final GameObjectMatcher exitGameObjectMatcher = new TypeNrsGameObjectMatcher(EXIT_TYPE); exitMatcher = new ExitMatcher<TestGameObject, TestMapArchObject, TestArchetype>(exitGameObjectMatcher); final ArchetypeFactory<TestGameObject, TestMapArchObject, TestArchetype> archetypeFactory = new TestArchetypeFactory(); - archetypeSet = new TestArchetypeSet(archetypeFactory, "archetypes"); + final FaceObjectProviders faceObjectProviders = newFaceObjectProviders(); + archetypeSet = new TestArchetypeSet(archetypeFactory, "archetypes", faceObjectProviders); final MapReaderFactory<TestGameObject, TestMapArchObject> mapReaderFactory = new TestMapReaderFactory(); globalSettings = new TestGlobalSettings(); mapViewSettings = new MapViewSettings(); final MapWriter<TestGameObject, TestMapArchObject, TestArchetype> mapWriter = new TestMapWriter(); - final FaceObjectProviders faceObjectProviders = newFaceObjectProviders(); final AutojoinLists<TestGameObject, TestMapArchObject, TestArchetype> autojoinLists = new AutojoinLists<TestGameObject, TestMapArchObject, TestArchetype>(mapViewSettings); final ArchetypeChooserModel<TestGameObject, TestMapArchObject, TestArchetype> archetypeChooserModel = new ArchetypeChooserModel<TestGameObject, TestMapArchObject, TestArchetype>(); pathManager = new PathManager(globalSettings); @@ -244,10 +244,10 @@ insertionModeSet = new InsertionModeSet<TestGameObject, TestMapArchObject, TestArchetype>(topmostInsertionMode); insertionModeSet.init(new TypeNrsGameObjectMatcher(), new TypeNrsGameObjectMatcher(), new TypeNrsGameObjectMatcher()); mapControlFactory = new TestMapControlFactory(mapWriter, autojoinLists, archetypeChooserModel, gameObjectFactory, globalSettings, gameObjectMatchers, topmostInsertionMode); - final AbstractMapManager<TestGameObject, TestMapArchObject, TestArchetype> tmpMapManager = new DefaultMapManager<TestGameObject, TestMapArchObject, TestArchetype>(mapReaderFactory, mapControlFactory, globalSettings); + final AbstractMapManager<TestGameObject, TestMapArchObject, TestArchetype> tmpMapManager = new DefaultMapManager<TestGameObject, TestMapArchObject, TestArchetype>(mapReaderFactory, mapControlFactory, globalSettings, faceObjectProviders); tmpMapManager.setFileControl(fileControl); mapManager = tmpMapManager; - final AbstractMapManager<TestGameObject, TestMapArchObject, TestArchetype> tmpPickmapManager = new DefaultMapManager<TestGameObject, TestMapArchObject, TestArchetype>(mapReaderFactory, mapControlFactory, globalSettings); + final AbstractMapManager<TestGameObject, TestMapArchObject, TestArchetype> tmpPickmapManager = new DefaultMapManager<TestGameObject, TestMapArchObject, TestArchetype>(mapReaderFactory, mapControlFactory, globalSettings, faceObjectProviders); tmpPickmapManager.setFileControl(fileControl); pickmapManager = tmpPickmapManager; Modified: trunk/src/test/net/sf/gridarta/model/archetype/ArchetypeParserTest.java =================================================================== --- trunk/src/test/net/sf/gridarta/model/archetype/ArchetypeParserTest.java 2010-06-06 18:43:50 UTC (rev 8183) +++ trunk/src/test/net/sf/gridarta/model/archetype/ArchetypeParserTest.java 2010-06-06 19:26:02 UTC (rev 8184) @@ -135,7 +135,7 @@ final TestGameObjectFactory gameObjectFactory = new TestGameObjectFactory(faceObjectProviders, animationObjects); final TestArchetypeBuilder archetypeBuilder = new TestArchetypeBuilder(gameObjectFactory); final TestArchetypeFactory archetypeFactory = new TestArchetypeFactory(); - archetypeSet = new TestArchetypeSet(archetypeFactory, "archetypes"); + archetypeSet = new TestArchetypeSet(archetypeFactory, "archetypes", faceObjectProviders); archetypeSet.setLoadedFromArchive(true); assert archetypeSet != null; return new TestArchetypeParser(archetypeBuilder, animationObjects, archetypeSet); Modified: trunk/src/test/net/sf/gridarta/model/archetype/TestArchetypeSet.java =================================================================== --- trunk/src/test/net/sf/gridarta/model/archetype/TestArchetypeSet.java 2010-06-06 18:43:50 UTC (rev 8183) +++ trunk/src/test/net/sf/gridarta/model/archetype/TestArchetypeSet.java 2010-06-06 19:26:02 UTC (rev 8184) @@ -21,6 +21,7 @@ import java.io.IOException; import java.io.Writer; +import net.sf.gridarta.model.face.FaceObjectProviders; import net.sf.gridarta.model.gameobject.TestGameObject; import net.sf.gridarta.model.map.maparchobject.TestMapArchObject; import org.jetbrains.annotations.NotNull; @@ -36,9 +37,10 @@ * Create an AbstractArchetypeSet. * @param archetypeFactory the archetype factory to use * @param archFile the collected archetypes file name + * @param faceObjectProviders the face object providers */ - public TestArchetypeSet(@NotNull final ArchetypeFactory<TestGameObject, TestMapArchObject, TestArchetype> archetypeFactory, @NotNull final String archFile) { - super(archetypeFactory, archFile); + public TestArchetypeSet(@NotNull final ArchetypeFactory<TestGameObject, TestMapArchObject, TestArchetype> archetypeFactory, @NotNull final String archFile, @NotNull final FaceObjectProviders faceObjectProviders) { + super(archetypeFactory, archFile, faceObjectProviders); } /** Modified: trunk/src/test/net/sf/gridarta/model/artifact/ArtifactParserTest.java =================================================================== --- trunk/src/test/net/sf/gridarta/model/artifact/ArtifactParserTest.java 2010-06-06 18:43:50 UTC (rev 8183) +++ trunk/src/test/net/sf/gridarta/model/artifact/ArtifactParserTest.java 2010-06-06 19:26:02 UTC (rev 8184) @@ -67,12 +67,12 @@ @Test public void testMissingObject() throws DuplicateArchetypeException, IOException, UndefinedArchetypeException { final TestArchetypeFactory archetypeFactory = new TestArchetypeFactory(); - final TestArchetypeSet archetypeSet = new TestArchetypeSet(archetypeFactory, "archetypes"); - final ArchFaceProvider archFaceProvider = new ArchFaceProvider(); final GUIUtils guiUtils = new GUIUtils(); final SystemIcons systemIcons = new SystemIcons(guiUtils); + final ArchFaceProvider archFaceProvider = new ArchFaceProvider(); final FaceObjects faceObjects = new DefaultFaceObjects("png", "facetree", Pattern.compile(".*"), "", archFaceProvider); final FaceObjectProviders faceObjectProviders = new FaceObjectProviders(0, faceObjects, systemIcons); + final TestArchetypeSet archetypeSet = new TestArchetypeSet(archetypeFactory, "archetypes", faceObjectProviders); final AnimationObjects animationObjects = new DefaultAnimationObjects("animtree"); final TestArchetype baseArchetype = new TestArchetype("base", faceObjectProviders, animationObjects); baseArchetype.setObjectText("sp 2\n"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-06-06 18:43:57
|
Revision: 8183 http://gridarta.svn.sourceforge.net/gridarta/?rev=8183&view=rev Author: akirschbaum Date: 2010-06-06 18:43:50 +0000 (Sun, 06 Jun 2010) Log Message: ----------- Remove dependency GameObjectAttributesDialog -> SystemIcons. Modified Paths: -------------- trunk/gridarta.ipr trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/GameObjectAttributesDialogFactory.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/FaceTab.java trunk/src/app/net/sf/gridarta/gui/utils/AnimTreeChooseAction.java trunk/src/app/net/sf/gridarta/gui/utils/AnimationComponent.java trunk/src/app/net/sf/gridarta/gui/utils/FaceComponent.java trunk/src/app/net/sf/gridarta/gui/utils/FaceTreeChooseAction.java trunk/src/app/net/sf/gridarta/maincontrol/GUIMainControl.java Modified: trunk/gridarta.ipr =================================================================== --- trunk/gridarta.ipr 2010-06-06 18:24:34 UTC (rev 8182) +++ trunk/gridarta.ipr 2010-06-06 18:43:50 UTC (rev 8183) @@ -52,7 +52,6 @@ <option name="BLANK_LINES_AFTER_CLASS_HEADER" value="1" /> <option name="SPACE_WITHIN_ARRAY_INITIALIZER_BRACES" value="true" /> <option name="SPACE_BEFORE_ARRAY_INITIALIZER_LBRACE" value="true" /> - <option name="PREFER_LONGER_NAMES" value="false" /> <option name="GENERATE_FINAL_LOCALS" value="true" /> <option name="GENERATE_FINAL_PARAMETERS" value="true" /> <option name="USE_FQ_CLASS_NAMES_IN_JAVADOC" value="false" /> Modified: trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java 2010-06-06 18:24:34 UTC (rev 8182) +++ trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java 2010-06-06 18:43:50 UTC (rev 8183) @@ -134,7 +134,6 @@ import net.sf.gridarta.utils.CommonConstants; import net.sf.gridarta.utils.Size2D; import net.sf.gridarta.utils.StringUtils; -import net.sf.gridarta.utils.SystemIcons; import net.sf.japi.swing.action.ActionBuilder; import net.sf.japi.swing.action.ActionBuilderFactory; import net.sf.japi.swing.action.ActionMethod; @@ -250,12 +249,18 @@ private final TreasureTree treasureTree; /** - * The {@link SystemIcons} for creating icons. + * The {@link ImageIcon} for no animations. */ @NotNull - private final SystemIcons systemIcons; + private final ImageIcon noFaceSquareIcon; /** + * The {@link ImageIcon} for undefined animations. + */ + @NotNull + private final ImageIcon unknownSquareIcon; + + /** * The {@link GameObjectMatchers} to use. */ @NotNull @@ -402,7 +407,7 @@ public void visit(@NotNull final ArchetypeAttributeAnimationName archetypeAttribute) { final String attributeName = archetypeAttribute.getArchetypeAttributeName(); final String defaultText = gameObject.getAttributeString(attributeName); - final AnimationComponent input = new AnimationComponent(defaultText, animationObjects, faceObjectProviders, systemIcons); + final AnimationComponent input = new AnimationComponent(defaultText, animationObjects, faceObjectProviders, noFaceSquareIcon, unknownSquareIcon); final JLabel cLabel = new JLabel(archetypeAttribute.getAttributeName() + ": "); guiInfo = new GuiInfo<G, A, R, ArchetypeAttributeAnimationName>(new DialogAttributeAnimationName<G, A, R>(archetypeAttribute, input), cLabel, input, null, null, false); } @@ -460,7 +465,7 @@ public void visit(@NotNull final ArchetypeAttributeFaceName archetypeAttribute) { final String attributeName = archetypeAttribute.getArchetypeAttributeName(); final String defaultText = gameObject.getAttributeString(attributeName); - final FaceComponent input = new FaceComponent(defaultText, faceObjects, faceObjectProviders, systemIcons); + final FaceComponent input = new FaceComponent(defaultText, faceObjects, faceObjectProviders, noFaceSquareIcon, unknownSquareIcon); final JLabel cLabel = new JLabel(archetypeAttribute.getAttributeName() + ":"); guiInfo = new GuiInfo<G, A, R, ArchetypeAttributeFaceName>(new DialogAttributeFaceName<G, A, R>(archetypeAttribute, input), cLabel, input, null, null, false); } @@ -765,12 +770,13 @@ * @param numberSpells the numbered spells to use * @param undefinedSpellIndex the index for "no spell" * @param treasureTree the treasure tree to use - * @param systemIcons the system icons for creating icons + * @param noFaceSquareIcon the image icon for no animations + * @param unknownSquareIcon the image icon for undefined animations * @param gameObjectMatchers the game object matchers to use * @param textAreaDefaults the text area defaults for text fields * @param mapManager the map manager instance */ - public GameObjectAttributesDialog(@NotNull final GameObjectAttributesDialogFactory<G, A, R> gameObjectAttributesDialogFactory, final ArchetypeTypeSet archetypeTypeSet, @NotNull final G gameObject, @NotNull final JFrame parent, @NotNull final CFTreasureListTree<G, A, R> treasureListTree, @NotNull final FaceObjectProviders faceObjectProviders, @NotNull final AnimationObjects animationObjects, @NotNull final GlobalSettings globalSettings, @NotNull final FileFilter mapFileFilter, @NotNull final FileFilter scriptFileFilter, @NotNull final FaceObjects faceObjects, @NotNull final Spells<GameObjectSpell<G, A, R>> gameObjectSpells, @NotNull final Spells<NumberSpell> numberSpells, final int undefinedSpellIndex, @NotNull final TreasureTree treasureTree, @NotNull final SystemIcons systemIcons, @NotNull final GameObjectMatchers gameObjectMatchers, @NotNull final TextAreaDefaults textAreaDefaults, @NotNull final MapManager<G, A, R> mapManager) { + public GameObjectAttributesDialog(@NotNull final GameObjectAttributesDialogFactory<G, A, R> gameObjectAttributesDialogFactory, final ArchetypeTypeSet archetypeTypeSet, @NotNull final G gameObject, @NotNull final JFrame parent, @NotNull final CFTreasureListTree<G, A, R> treasureListTree, @NotNull final FaceObjectProviders faceObjectProviders, @NotNull final AnimationObjects animationObjects, @NotNull final GlobalSettings globalSettings, @NotNull final FileFilter mapFileFilter, @NotNull final FileFilter scriptFileFilter, @NotNull final FaceObjects faceObjects, @NotNull final Spells<GameObjectSpell<G, A, R>> gameObjectSpells, @NotNull final Spells<NumberSpell> numberSpells, final int undefinedSpellIndex, @NotNull final TreasureTree treasureTree, @NotNull final ImageIcon noFaceSquareIcon, @NotNull final ImageIcon unknownSquareIcon, @NotNull final GameObjectMatchers gameObjectMatchers, @NotNull final TextAreaDefaults textAreaDefaults, @NotNull final MapManager<G, A, R> mapManager) { this.gameObjectAttributesDialogFactory = gameObjectAttributesDialogFactory; this.archetypeTypeSet = archetypeTypeSet; this.gameObject = gameObject; @@ -786,7 +792,8 @@ this.numberSpells = numberSpells; this.undefinedSpellIndex = undefinedSpellIndex; this.treasureTree = treasureTree; - this.systemIcons = systemIcons; + this.noFaceSquareIcon = noFaceSquareIcon; + this.unknownSquareIcon = unknownSquareIcon; this.gameObjectMatchers = gameObjectMatchers; this.textAreaDefaults = textAreaDefaults; this.mapManager = mapManager; Modified: trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/GameObjectAttributesDialogFactory.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/GameObjectAttributesDialogFactory.java 2010-06-06 18:24:34 UTC (rev 8182) +++ trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/GameObjectAttributesDialogFactory.java 2010-06-06 18:43:50 UTC (rev 8183) @@ -22,6 +22,7 @@ import java.awt.Window; import java.util.HashMap; import java.util.Map; +import javax.swing.ImageIcon; import javax.swing.JDialog; import javax.swing.JFrame; import javax.swing.filechooser.FileFilter; @@ -41,7 +42,6 @@ import net.sf.gridarta.model.spells.Spells; import net.sf.gridarta.model.treasurelist.TreasureTree; import net.sf.gridarta.textedit.textarea.TextAreaDefaults; -import net.sf.gridarta.utils.SystemIcons; import net.sf.japi.swing.action.ActionBuilder; import net.sf.japi.swing.action.ActionBuilderFactory; import org.jetbrains.annotations.NotNull; @@ -137,12 +137,18 @@ private final TreasureTree treasureTree; /** - * The {@link SystemIcons} for creating icons. + * The {@link ImageIcon} for no animations. */ @NotNull - private final SystemIcons systemIcons; + private final ImageIcon noFaceSquareIcon; /** + * The {@link ImageIcon} for undefined animations. + */ + @NotNull + private final ImageIcon unknownSquareIcon; + + /** * The {@link GameObjectMatchers} to use. */ @NotNull @@ -177,11 +183,12 @@ * @param numberSpells the numbered spells to use * @param undefinedSpellIndex the index for "no spell" * @param treasureTree the treasure tree to use - * @param systemIcons the system icons for creating icons + * @param noFaceSquareIcon the image icon for no animations + * @param unknownSquareIcon the image icon for undefined animations * @param gameObjectMatchers the game object matchers to use * @param mapManager the map manager instance */ - public GameObjectAttributesDialogFactory(@NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final JFrame parent, @NotNull final CFTreasureListTree<G, A, R> treasureListTree, @NotNull final FaceObjectProviders faceObjectProviders, @NotNull final AnimationObjects animationObjects, @NotNull final GlobalSettings globalSettings, @NotNull final FileFilter mapFileFilter, @NotNull final FileFilter scriptFileFilter, @NotNull final FaceObjects faceObjects, @NotNull final Spells<GameObjectSpell<G, A, R>> gameObjectSpells, @NotNull final Spells<NumberSpell> numberSpells, final int undefinedSpellIndex, @NotNull final TreasureTree treasureTree, @NotNull final SystemIcons systemIcons, @NotNull final GameObjectMatchers gameObjectMatchers, @NotNull final MapManager<G, A, R> mapManager) { + public GameObjectAttributesDialogFactory(@NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final JFrame parent, @NotNull final CFTreasureListTree<G, A, R> treasureListTree, @NotNull final FaceObjectProviders faceObjectProviders, @NotNull final AnimationObjects animationObjects, @NotNull final GlobalSettings globalSettings, @NotNull final FileFilter mapFileFilter, @NotNull final FileFilter scriptFileFilter, @NotNull final FaceObjects faceObjects, @NotNull final Spells<GameObjectSpell<G, A, R>> gameObjectSpells, @NotNull final Spells<NumberSpell> numberSpells, final int undefinedSpellIndex, @NotNull final TreasureTree treasureTree, @NotNull final ImageIcon noFaceSquareIcon, @NotNull final ImageIcon unknownSquareIcon, @NotNull final GameObjectMatchers gameObjectMatchers, @NotNull final MapManager<G, A, R> mapManager) { this.archetypeTypeSet = archetypeTypeSet; this.parent = parent; this.treasureListTree = treasureListTree; @@ -195,7 +202,8 @@ this.numberSpells = numberSpells; this.undefinedSpellIndex = undefinedSpellIndex; this.treasureTree = treasureTree; - this.systemIcons = systemIcons; + this.unknownSquareIcon = unknownSquareIcon; + this.noFaceSquareIcon = noFaceSquareIcon; this.gameObjectMatchers = gameObjectMatchers; this.mapManager = mapManager; } @@ -222,7 +230,7 @@ if (dialogs.containsKey(head)) { dialogs.get(head).toFront(); } else { - final GameObjectAttributesDialog<G, A, R> pane = new GameObjectAttributesDialog<G, A, R>(this, archetypeTypeSet, head, parent, treasureListTree, faceObjectProviders, animationObjects, globalSettings, mapFileFilter, scriptFileFilter, faceObjects, gameObjectSpells, numberSpells, undefinedSpellIndex, treasureTree, systemIcons, gameObjectMatchers, textAreaDefaults, mapManager); + final GameObjectAttributesDialog<G, A, R> pane = new GameObjectAttributesDialog<G, A, R>(this, archetypeTypeSet, head, parent, treasureListTree, faceObjectProviders, animationObjects, globalSettings, mapFileFilter, scriptFileFilter, faceObjects, gameObjectSpells, numberSpells, undefinedSpellIndex, treasureTree, noFaceSquareIcon, unknownSquareIcon, gameObjectMatchers, textAreaDefaults, mapManager); final JDialog dialog = pane.createDialog(); dialogs.put(head, dialog); } Modified: trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/FaceTab.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/FaceTab.java 2010-06-06 18:24:34 UTC (rev 8182) +++ trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/FaceTab.java 2010-06-06 18:43:50 UTC (rev 8183) @@ -24,6 +24,7 @@ import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import javax.swing.AbstractButton; +import javax.swing.ImageIcon; import javax.swing.JCheckBox; import javax.swing.JComponent; import javax.swing.JLabel; @@ -45,7 +46,6 @@ import net.sf.gridarta.model.map.maparchobject.MapArchObject; import net.sf.gridarta.model.map.mapmodel.MapModel; import net.sf.gridarta.model.map.mapmodel.MapSquare; -import net.sf.gridarta.utils.SystemIcons; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -160,14 +160,15 @@ * @param faceObjects the face objects for looking up faces * @param faceObjectProviders the face object providers to use * @param animationObjects the animation objects for looking up animations - * @param systemIcons the system icons for creating icons + * @param noFaceSquareIcon the image icon for no animations + * @param unknownSquareIcon the image icon for undefined animations */ - public FaceTab(@NotNull final GameObjectAttributesModel<G, A, R> gameObjectAttributesModel, @NotNull final FaceObjects faceObjects, @NotNull final FaceObjectProviders faceObjectProviders, @NotNull final AnimationObjects animationObjects, @NotNull final SystemIcons systemIcons) { + public FaceTab(@NotNull final GameObjectAttributesModel<G, A, R> gameObjectAttributesModel, @NotNull final FaceObjects faceObjects, @NotNull final FaceObjectProviders faceObjectProviders, @NotNull final AnimationObjects animationObjects, @NotNull final ImageIcon noFaceSquareIcon, @NotNull final ImageIcon unknownSquareIcon) { super(gameObjectAttributesModel); this.faceObjects = faceObjects; this.animationObjects = animationObjects; - faceComponent = new FaceComponent("", faceObjects, faceObjectProviders, systemIcons); - animationComponent = new AnimationComponent("", animationObjects, faceObjectProviders, systemIcons); + faceComponent = new FaceComponent("", faceObjects, faceObjectProviders, noFaceSquareIcon, unknownSquareIcon); + animationComponent = new AnimationComponent("", animationObjects, faceObjectProviders, noFaceSquareIcon, unknownSquareIcon); final GridBagLayout gridBagLayout = new GridBagLayout(); final GridBagConstraints gbc = new GridBagConstraints(); Modified: trunk/src/app/net/sf/gridarta/gui/utils/AnimTreeChooseAction.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/utils/AnimTreeChooseAction.java 2010-06-06 18:24:34 UTC (rev 8182) +++ trunk/src/app/net/sf/gridarta/gui/utils/AnimTreeChooseAction.java 2010-06-06 18:43:50 UTC (rev 8183) @@ -22,11 +22,11 @@ import java.awt.event.ActionEvent; import javax.swing.AbstractButton; import javax.swing.Icon; +import javax.swing.ImageIcon; import javax.swing.text.JTextComponent; import net.sf.gridarta.model.anim.AnimationObjects; import net.sf.gridarta.model.data.NamedObject; import net.sf.gridarta.model.face.FaceObjectProviders; -import net.sf.gridarta.utils.SystemIcons; import org.jetbrains.annotations.NotNull; /** @@ -59,12 +59,18 @@ private final FaceObjectProviders faceObjectProviders; /** - * The {@link SystemIcons} for creating icons. + * The {@link ImageIcon} for no animations. */ @NotNull - private final SystemIcons systemIcons; + private final ImageIcon noFaceSquareIcon; /** + * The {@link ImageIcon} for undefined animations. + */ + @NotNull + private final ImageIcon unknownSquareIcon; + + /** * Create a TreeChooseAction. * @param text the text for the button * @param textComponent the text component that holds the current animation @@ -74,14 +80,16 @@ * names tree * @param faceObjectProviders the face object providers for looking up * faces - * @param systemIcons the system icons for creating icons + * @param noFaceSquareIcon the image icon for no animations + * @param unknownSquareIcon the image icon for undefined animations */ - public AnimTreeChooseAction(@NotNull final String text, @NotNull final JTextComponent textComponent, @NotNull final AbstractButton icon, @NotNull final AnimationObjects animationObjects, @NotNull final FaceObjectProviders faceObjectProviders, @NotNull final SystemIcons systemIcons) { + public AnimTreeChooseAction(@NotNull final String text, @NotNull final JTextComponent textComponent, @NotNull final AbstractButton icon, @NotNull final AnimationObjects animationObjects, @NotNull final FaceObjectProviders faceObjectProviders, @NotNull final ImageIcon noFaceSquareIcon, @NotNull final ImageIcon unknownSquareIcon) { super(text, textComponent, animationObjects, faceObjectProviders); this.icon = icon; this.animationObjects = animationObjects; this.faceObjectProviders = faceObjectProviders; - this.systemIcons = systemIcons; + this.unknownSquareIcon = unknownSquareIcon; + this.noFaceSquareIcon = noFaceSquareIcon; updateIconLabel(); } @@ -101,14 +109,14 @@ final String animationName = getFaceName(); final Icon face; if (animationName.isEmpty() || animationName.equals("NONE")) { - face = systemIcons.getNoFaceSquareIcon(); + face = noFaceSquareIcon; } else { final NamedObject animationObject = animationObjects.get(animationName); if (animationObject == null) { - face = systemIcons.getUnknownSquareIcon(); + face = unknownSquareIcon; } else { final Icon tmp = animationObject.getDisplayIcon(faceObjectProviders); - face = tmp == null ? systemIcons.getUnknownSquareIcon() : tmp; + face = tmp == null ? unknownSquareIcon : tmp; } } icon.setIcon(face); Modified: trunk/src/app/net/sf/gridarta/gui/utils/AnimationComponent.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/utils/AnimationComponent.java 2010-06-06 18:24:34 UTC (rev 8182) +++ trunk/src/app/net/sf/gridarta/gui/utils/AnimationComponent.java 2010-06-06 18:43:50 UTC (rev 8183) @@ -26,12 +26,12 @@ import java.awt.event.FocusEvent; import java.awt.event.FocusListener; import javax.swing.AbstractButton; +import javax.swing.ImageIcon; import javax.swing.JButton; import javax.swing.JPanel; import javax.swing.JTextField; import net.sf.gridarta.model.anim.AnimationObjects; import net.sf.gridarta.model.face.FaceObjectProviders; -import net.sf.gridarta.utils.SystemIcons; import org.jetbrains.annotations.NotNull; /** @@ -63,16 +63,17 @@ * @param animationObjects the animation objects to use * @param faceObjectProviders the face object providers for looking up * faces - * @param systemIcons the system icons for creating icons + * @param noFaceSquareIcon the image icon for no animations + * @param unknownSquareIcon the image icon for undefined animations */ - public AnimationComponent(@NotNull final String animationName, @NotNull final AnimationObjects animationObjects, @NotNull final FaceObjectProviders faceObjectProviders, @NotNull final SystemIcons systemIcons) { + public AnimationComponent(@NotNull final String animationName, @NotNull final AnimationObjects animationObjects, @NotNull final FaceObjectProviders faceObjectProviders, @NotNull final ImageIcon noFaceSquareIcon, @NotNull final ImageIcon unknownSquareIcon) { super(new GridBagLayout()); textField.setText(animationName); textField.setColumns(8); final AbstractButton label = new JButton(); label.setMargin(new Insets(0, 0, 0, 0)); - animTreeChooseAction = new AnimTreeChooseAction("...", textField, label, animationObjects, faceObjectProviders, systemIcons); + animTreeChooseAction = new AnimTreeChooseAction("...", textField, label, animationObjects, faceObjectProviders, noFaceSquareIcon, unknownSquareIcon); label.addActionListener(animTreeChooseAction); final AbstractButton button = new JButton(animTreeChooseAction); button.setMargin(new Insets(0, 1, 0, 1)); Modified: trunk/src/app/net/sf/gridarta/gui/utils/FaceComponent.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/utils/FaceComponent.java 2010-06-06 18:24:34 UTC (rev 8182) +++ trunk/src/app/net/sf/gridarta/gui/utils/FaceComponent.java 2010-06-06 18:43:50 UTC (rev 8183) @@ -26,12 +26,12 @@ import java.awt.event.FocusEvent; import java.awt.event.FocusListener; import javax.swing.AbstractButton; +import javax.swing.ImageIcon; import javax.swing.JButton; import javax.swing.JPanel; import javax.swing.JTextField; import net.sf.gridarta.model.face.FaceObjectProviders; import net.sf.gridarta.model.face.FaceObjects; -import net.sf.gridarta.utils.SystemIcons; import org.jetbrains.annotations.NotNull; /** @@ -63,16 +63,17 @@ * @param faceObjects the face objects to use * @param faceObjectProviders the face object providers for looking up * faces - * @param systemIcons the system icons for creating icons + * @param noFaceSquareIcon the image icon for no animations + * @param unknownSquareIcon the image icon for undefined animations */ - public FaceComponent(@NotNull final String faceName, @NotNull final FaceObjects faceObjects, @NotNull final FaceObjectProviders faceObjectProviders, @NotNull final SystemIcons systemIcons) { + public FaceComponent(@NotNull final String faceName, @NotNull final FaceObjects faceObjects, @NotNull final FaceObjectProviders faceObjectProviders, @NotNull final ImageIcon noFaceSquareIcon, @NotNull final ImageIcon unknownSquareIcon) { super(new GridBagLayout()); textField.setText(faceName); textField.setColumns(8); final AbstractButton label = new JButton(); label.setMargin(new Insets(0, 0, 0, 0)); - faceTreeChooseAction = new FaceTreeChooseAction("...", textField, label, faceObjects, faceObjectProviders, systemIcons); + faceTreeChooseAction = new FaceTreeChooseAction("...", textField, label, faceObjects, faceObjectProviders, noFaceSquareIcon, unknownSquareIcon); label.addActionListener(faceTreeChooseAction); final AbstractButton button = new JButton(faceTreeChooseAction); button.setMargin(new Insets(0, 1, 0, 1)); Modified: trunk/src/app/net/sf/gridarta/gui/utils/FaceTreeChooseAction.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/utils/FaceTreeChooseAction.java 2010-06-06 18:24:34 UTC (rev 8182) +++ trunk/src/app/net/sf/gridarta/gui/utils/FaceTreeChooseAction.java 2010-06-06 18:43:50 UTC (rev 8183) @@ -22,11 +22,11 @@ import java.awt.event.ActionEvent; import javax.swing.AbstractButton; import javax.swing.Icon; +import javax.swing.ImageIcon; import javax.swing.text.JTextComponent; import net.sf.gridarta.model.data.NamedObject; import net.sf.gridarta.model.data.NamedObjects; import net.sf.gridarta.model.face.FaceObjectProviders; -import net.sf.gridarta.utils.SystemIcons; import org.jetbrains.annotations.NotNull; /** @@ -53,12 +53,18 @@ private final FaceObjectProviders faceObjectProviders; /** - * The {@link SystemIcons} for creating icons. + * The {@link ImageIcon} for no animations. */ @NotNull - private final SystemIcons systemIcons; + private final ImageIcon noFaceSquareIcon; /** + * The {@link ImageIcon} for undefined animations. + */ + @NotNull + private final ImageIcon unknownSquareIcon; + + /** * Create a TreeChooseAction. * @param text the text for the button * @param textComponent the text component that holds the current @@ -66,13 +72,15 @@ * @param icon the label showing the icon * @param namedObjects the named objects providing the face names tree * @param faceObjectProviders the face provider for looking up icons - * @param systemIcons the system icons for creating icons + * @param noFaceSquareIcon the image icon for no animations + * @param unknownSquareIcon the image icon for undefined animations */ - public FaceTreeChooseAction(@NotNull final String text, @NotNull final JTextComponent textComponent, @NotNull final AbstractButton icon, @NotNull final NamedObjects<? extends NamedObject> namedObjects, @NotNull final FaceObjectProviders faceObjectProviders, @NotNull final SystemIcons systemIcons) { + public FaceTreeChooseAction(@NotNull final String text, @NotNull final JTextComponent textComponent, @NotNull final AbstractButton icon, @NotNull final NamedObjects<? extends NamedObject> namedObjects, @NotNull final FaceObjectProviders faceObjectProviders, @NotNull final ImageIcon noFaceSquareIcon, @NotNull final ImageIcon unknownSquareIcon) { super(text, textComponent, namedObjects, faceObjectProviders); this.icon = icon; this.faceObjectProviders = faceObjectProviders; - this.systemIcons = systemIcons; + this.unknownSquareIcon = unknownSquareIcon; + this.noFaceSquareIcon = noFaceSquareIcon; updateIconLabel(); } @@ -92,10 +100,10 @@ final String faceName = getFaceName(); final Icon face; if (faceName.isEmpty() || faceName.equals("NONE")) { - face = systemIcons.getNoFaceSquareIcon(); + face = noFaceSquareIcon; } else { final Icon tmp = faceObjectProviders.getImageIconForFacename(faceName); - face = tmp == null ? systemIcons.getUnknownSquareIcon() : tmp; + face = tmp == null ? unknownSquareIcon : tmp; } icon.setIcon(face); } Modified: trunk/src/app/net/sf/gridarta/maincontrol/GUIMainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/maincontrol/GUIMainControl.java 2010-06-06 18:24:34 UTC (rev 8182) +++ trunk/src/app/net/sf/gridarta/maincontrol/GUIMainControl.java 2010-06-06 18:43:50 UTC (rev 8183) @@ -460,12 +460,14 @@ pickmapChooserControl = new PickmapChooserControl<G, A, R>(pickmapChooserModel, newMapDialogFactory, mapArchObjectFactory, mapReaderFactory, mapFolderTree, mapManager, mainViewFrame, pickmapManager, mapViewsManager); newMapDialogFactory.setPickmapChooserControl(pickmapChooserControl); final CFTreasureListTree<G, A, R> treasureListTree = new CFTreasureListTree<G, A, R>(treasureTree, mainViewFrame, archetypeSet, faceObjectProviders, systemIcons); - final GameObjectAttributesDialogFactory<G, A, R> gameObjectAttributesDialogFactory = new GameObjectAttributesDialogFactory<G, A, R>(archetypeTypeSet, mainViewFrame, treasureListTree, faceObjectProviders, animationObjects, globalSettings, mapFileFilter, scriptFileFilter, faceObjects, gameObjectSpells, numberSpells, undefinedSpellIndex, treasureTree, systemIcons, gameObjectMatchers, mapManager); + final ImageIcon noFaceSquareIcon = systemIcons.getNoFaceSquareIcon(); + final ImageIcon unknownSquareIcon = systemIcons.getUnknownSquareIcon(); + final GameObjectAttributesDialogFactory<G, A, R> gameObjectAttributesDialogFactory = new GameObjectAttributesDialogFactory<G, A, R>(archetypeTypeSet, mainViewFrame, treasureListTree, faceObjectProviders, animationObjects, globalSettings, mapFileFilter, scriptFileFilter, faceObjects, gameObjectSpells, numberSpells, undefinedSpellIndex, treasureTree, noFaceSquareIcon, unknownSquareIcon, gameObjectMatchers, mapManager); final DefaultObjectChooser<G, A, R> objectChooser = new DefaultObjectChooser<G, A, R>(archetypeChooserControl, pickmapChooserControl, archetypeChooserModel, pickmapChooserModel, archetypeTypeSet); newMapDialogFactory.setObjectChooser(objectChooser); final SelectedSquareModel<G, A, R> selectedSquareModel = new SelectedSquareModel<G, A, R>(); final SelectedSquareActions<G, A, R> selectedSquareActions = new SelectedSquareActions<G, A, R>(selectedSquareModel); - final SelectedSquareControl<G, A, R> selectedSquareControl = new SelectedSquareControl<G, A, R>(selectedSquareModel, selectedSquareActions, gameObjectAttributesDialogFactory, objectChooser, mapManager, mapViewManager, mapViewSettings, compassIcon, faceObjectProviders, systemIcons.getUnknownSquareIcon()); + final SelectedSquareControl<G, A, R> selectedSquareControl = new SelectedSquareControl<G, A, R>(selectedSquareModel, selectedSquareActions, gameObjectAttributesDialogFactory, objectChooser, mapManager, mapViewManager, mapViewSettings, compassIcon, faceObjectProviders, unknownSquareIcon); 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); @@ -582,7 +584,7 @@ gameObjectAttributesControl.addTab(new ArchTab<G, A, R>(archetypeTypeSet, gameObjectAttributesModel)); gameObjectAttributesControl.addTab(new MsgTextTab<G, A, R>(gameObjectAttributesModel)); gameObjectAttributesControl.addTab(new EventsTab<G, A, R>(mainViewFrame, mapManager, gameObjectAttributesModel, scriptArchEditor, scriptArchData, scriptArchDataUtils, scriptArchUtils)); - gameObjectAttributesControl.addTab(new FaceTab<G, A, R>(gameObjectAttributesModel, faceObjects, faceObjectProviders, animationObjects, systemIcons)); + gameObjectAttributesControl.addTab(new FaceTab<G, A, R>(gameObjectAttributesModel, faceObjects, faceObjectProviders, animationObjects, noFaceSquareIcon, unknownSquareIcon)); gameObjectAttributesControl.addTab(textEditorTab); mainView.addTab(new Tab("monsters", new MonsterControl<G, A, R>(mapViewManager, delayedMapModelListenerManager, monsterMatcher).getView(), Location.BOTTOM, 4, false)); mainView.addTab(new Tab("connections", new ConnectionControl<G, A, R>(mapViewManager, delayedMapModelListenerManager).getView(), Location.BOTTOM, 5, false)); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-06-06 18:24:40
|
Revision: 8182 http://gridarta.svn.sourceforge.net/gridarta/?rev=8182&view=rev Author: akirschbaum Date: 2010-06-06 18:24:34 +0000 (Sun, 06 Jun 2010) Log Message: ----------- Add final modifiers. Modified Paths: -------------- trunk/src/app/net/sf/gridarta/gui/utils/AnimTreeChooseAction.java trunk/src/app/net/sf/gridarta/gui/utils/FaceTreeChooseAction.java Modified: trunk/src/app/net/sf/gridarta/gui/utils/AnimTreeChooseAction.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/utils/AnimTreeChooseAction.java 2010-06-06 16:44:08 UTC (rev 8181) +++ trunk/src/app/net/sf/gridarta/gui/utils/AnimTreeChooseAction.java 2010-06-06 18:24:34 UTC (rev 8182) @@ -97,7 +97,7 @@ /** * Updates the icon of {@link #icon} to reflect the current animation name. */ - public void updateIconLabel() { + public final void updateIconLabel() { final String animationName = getFaceName(); final Icon face; if (animationName.isEmpty() || animationName.equals("NONE")) { Modified: trunk/src/app/net/sf/gridarta/gui/utils/FaceTreeChooseAction.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/utils/FaceTreeChooseAction.java 2010-06-06 16:44:08 UTC (rev 8181) +++ trunk/src/app/net/sf/gridarta/gui/utils/FaceTreeChooseAction.java 2010-06-06 18:24:34 UTC (rev 8182) @@ -88,7 +88,7 @@ /** * Updates the icon of {@link #icon} to reflect the current face name. */ - public void updateIconLabel() { + public final void updateIconLabel() { final String faceName = getFaceName(); final Icon face; if (faceName.isEmpty() || faceName.equals("NONE")) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-06-06 16:44:15
|
Revision: 8181 http://gridarta.svn.sourceforge.net/gridarta/?rev=8181&view=rev Author: akirschbaum Date: 2010-06-06 16:44:08 +0000 (Sun, 06 Jun 2010) Log Message: ----------- Properly fix "paste exit" when connecting to an unsaved map. Modified Paths: -------------- trunk/src/app/net/sf/gridarta/exitconnector/ExitConnectorActions.java trunk/src/app/net/sf/gridarta/model/exitconnector/ExitLocation.java trunk/src/test/net/sf/gridarta/exitconnector/ExitConnectorActionsTest.java Modified: trunk/src/app/net/sf/gridarta/exitconnector/ExitConnectorActions.java =================================================================== --- trunk/src/app/net/sf/gridarta/exitconnector/ExitConnectorActions.java 2010-06-06 16:20:42 UTC (rev 8180) +++ trunk/src/app/net/sf/gridarta/exitconnector/ExitConnectorActions.java 2010-06-06 16:44:08 UTC (rev 8181) @@ -161,9 +161,6 @@ } final File targetMapFile = targetMapModel.getMapFile(); - if (targetMapFile == null) { - return false; - } if (targetExit != null) { // paste into existing exit @@ -326,12 +323,13 @@ * @param gameObject the exit game object to paste into * @param mapModel the map model to paste into * @param exitLocation the exit information to paste - * @param mapFile the map file to path + * @param gameObjectMapFile the map file of <code>gameObject</code> or + * <code>null</code> if on an unsaved map */ - private void pasteExit(@NotNull final BaseObject<?, ?, ?, ?> gameObject, @NotNull final MapModel<G, A, R> mapModel, @NotNull final ExitLocation exitLocation, @NotNull final File mapFile) { + private void pasteExit(@NotNull final BaseObject<?, ?, ?, ?> gameObject, @NotNull final MapModel<G, A, R> mapModel, @NotNull final ExitLocation exitLocation, @Nullable final File gameObjectMapFile) { mapModel.beginTransaction("paste exit"); try { - exitLocation.updateExitObject(gameObject, exitConnectorModel.isPasteExitName(), mapFile); + exitLocation.updateExitObject(gameObject, exitConnectorModel.isPasteExitName(), gameObjectMapFile); } finally { mapModel.endTransaction(); } @@ -343,10 +341,11 @@ * @param mapModel the map model to insert into * @param archetype the archetype to insert * @param exitLocation the exit information to use - * @param mapFile the map file to paste + * @param mapFile the map file to insert into or <code>null</code> for + * unsaved maps * @return whether insertion was successful */ - private boolean pasteExit(@NotNull final Point location, @NotNull final MapModel<G, A, R> mapModel, @NotNull final BaseObject<G, A, R, ?> archetype, @NotNull final ExitLocation exitLocation, @NotNull final File mapFile) { + private boolean pasteExit(@NotNull final Point location, @NotNull final MapModel<G, A, R> mapModel, @NotNull final BaseObject<G, A, R, ?> archetype, @NotNull final ExitLocation exitLocation, @Nullable final File mapFile) { mapModel.beginTransaction("paste exit"); try { final BaseObject<G, A, R, ?> newExit = mapModel.insertBaseObject(archetype, location, true, false, insertionModeSet.getTopmostInsertionMode()); Modified: trunk/src/app/net/sf/gridarta/model/exitconnector/ExitLocation.java =================================================================== --- trunk/src/app/net/sf/gridarta/model/exitconnector/ExitLocation.java 2010-06-06 16:20:42 UTC (rev 8180) +++ trunk/src/app/net/sf/gridarta/model/exitconnector/ExitLocation.java 2010-06-06 16:44:08 UTC (rev 8181) @@ -89,21 +89,25 @@ * @param gameObject the exit game object to update * @param updateName whether the exit's name should be updated * @param sourceMapFile the file of the map containing - * <code>gameObject</code> + * <code>gameObject</code> or <code>null</code> if on an unsaved map */ - public void updateExitObject(@NotNull final BaseObject<?, ?, ?, ?> gameObject, final boolean updateName, @NotNull final File sourceMapFile) { - final String sourceMapPath = pathManager.getMapPath(sourceMapFile); + public void updateExitObject(@NotNull final BaseObject<?, ?, ?, ?> gameObject, final boolean updateName, @Nullable final File sourceMapFile) { final String targetMapPath = pathManager.getMapPath(file); - - final String sourceMapComponent = getMapComponent(sourceMapPath); - final String targetMapComponent = getMapComponent(targetMapPath); final String mapPath; - if (sourceMapComponent == null ? targetMapComponent == null : sourceMapComponent.equals(targetMapComponent)) { - // relative reference - mapPath = PathManager.absoluteToRelative(sourceMapPath, targetMapPath); + if (sourceMapFile == null) { + // unsaved source map => absolute reference + mapPath = targetMapPath; } else { - // absolute reference - mapPath = targetMapPath; + final String sourceMapPath = pathManager.getMapPath(sourceMapFile); + final String sourceMapComponent = getMapComponent(sourceMapPath); + final String targetMapComponent = getMapComponent(targetMapPath); + if (sourceMapComponent == null ? targetMapComponent == null : sourceMapComponent.equals(targetMapComponent)) { + // relative reference + mapPath = PathManager.absoluteToRelative(sourceMapPath, targetMapPath); + } else { + // absolute reference + mapPath = targetMapPath; + } } gameObject.setAttributeString("slaying", mapPath); gameObject.setAttributeString("hp", Integer.toString(x)); Modified: trunk/src/test/net/sf/gridarta/exitconnector/ExitConnectorActionsTest.java =================================================================== --- trunk/src/test/net/sf/gridarta/exitconnector/ExitConnectorActionsTest.java 2010-06-06 16:20:42 UTC (rev 8180) +++ trunk/src/test/net/sf/gridarta/exitconnector/ExitConnectorActionsTest.java 2010-06-06 16:44:08 UTC (rev 8181) @@ -175,12 +175,11 @@ model.setAutoCreateExit(true); - // paste must fail for unsaved map + // copy must fail for unsaved map mapModel1.setMapFile(null); // pretend unsaved map - Assert.assertFalse(actions.doExitPaste(true, mapControl1, point1)); + Assert.assertFalse(actions.doExitCopy(true, mapControl1, point1)); - // paste must succeed for saved map - mapModel1.setMapFile(MAP_FILE1); // pretend saved map + // paste must succeed for unsaved map Assert.assertTrue(actions.doExitPaste(true, mapControl1, point1)); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-06-06 16:20:49
|
Revision: 8180 http://gridarta.svn.sourceforge.net/gridarta/?rev=8180&view=rev Author: akirschbaum Date: 2010-06-06 16:20:42 +0000 (Sun, 06 Jun 2010) Log Message: ----------- Remove unused code. Modified Paths: -------------- trunk/src/app/net/sf/gridarta/model/io/PathManager.java Modified: trunk/src/app/net/sf/gridarta/model/io/PathManager.java =================================================================== --- trunk/src/app/net/sf/gridarta/model/io/PathManager.java 2010-06-06 16:19:37 UTC (rev 8179) +++ trunk/src/app/net/sf/gridarta/model/io/PathManager.java 2010-06-06 16:20:42 UTC (rev 8180) @@ -52,27 +52,6 @@ } /** - * Create arch path. Replaces all occurrences of '\' with '/' and removes - * the path to the arch directory (absolute, relative or canonical) from the - * path. - * @param path to create arch path from - * @return fixed path - */ - @NotNull - public String getArchPath(@NotNull final String path) { - final String archDirName = globalSettings.getArchDirectory().getPath(); - String archPath = path.replace('\\', '/'); - if (archPath.startsWith(archDirName)) { - archPath = archPath.substring(archDirName.length()); - } - if (archPath.startsWith(new File(archDirName).getAbsolutePath())) { - archPath = archPath.substring(new File(archDirName).getAbsolutePath().length()); - } - archPath = archPath.replace('\\', '/'); - return archPath; - } - - /** * Returns a map path for a {@link File}. * @param file the file * @return the map path This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-06-06 16:19:43
|
Revision: 8179 http://gridarta.svn.sourceforge.net/gridarta/?rev=8179&view=rev Author: akirschbaum Date: 2010-06-06 16:19:37 +0000 (Sun, 06 Jun 2010) Log Message: ----------- Add @NotNull annotations. Modified Paths: -------------- trunk/src/app/net/sf/gridarta/model/io/PathManager.java Modified: trunk/src/app/net/sf/gridarta/model/io/PathManager.java =================================================================== --- trunk/src/app/net/sf/gridarta/model/io/PathManager.java 2010-06-06 16:18:42 UTC (rev 8178) +++ trunk/src/app/net/sf/gridarta/model/io/PathManager.java 2010-06-06 16:19:37 UTC (rev 8179) @@ -58,6 +58,7 @@ * @param path to create arch path from * @return fixed path */ + @NotNull public String getArchPath(@NotNull final String path) { final String archDirName = globalSettings.getArchDirectory().getPath(); String archPath = path.replace('\\', '/'); @@ -76,6 +77,7 @@ * @param file the file * @return the map path */ + @NotNull public String getMapPath(@NotNull final File file) { return getMapPath(file.getPath()); } @@ -87,6 +89,7 @@ * @param path to create map path from * @return fixed path */ + @NotNull public String getMapPath(@NotNull final String path) { final String mapDirName = globalSettings.getMapsDirectory().getPath(); String mapPath = path.replace('\\', '/'); @@ -141,6 +144,7 @@ * @param relative destination file with relative path * @return absolute path from the base directory */ + @NotNull public static String relativeToAbsolute(@NotNull final String reference, @NotNull final String relative) { final String normalizedReference = reference.replace('\\', '/'); final String normalizedRelative = relative.replace('\\', '/'); @@ -165,6 +169,7 @@ * @param absolute destination file with relative path * @return absolute path from the base directory */ + @NotNull public static String absoluteToRelative(@NotNull final String reference, @NotNull final String absolute) { final String normalizedReference = reference.replace('\\', '/'); final String normalizedAbsolute = absolute.replace('\\', '/'); @@ -231,6 +236,7 @@ * @param str String to create path from * @return path */ + @NotNull public static String path(@NotNull final String str) { String path = str.replaceAll("\\\\", "/"); path = path.endsWith("/") ? path.substring(0, path.length() - 1) : path; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-06-06 16:18:48
|
Revision: 8178 http://gridarta.svn.sourceforge.net/gridarta/?rev=8178&view=rev Author: akirschbaum Date: 2010-06-06 16:18:42 +0000 (Sun, 06 Jun 2010) Log Message: ----------- Rename variable name. Modified Paths: -------------- trunk/src/app/net/sf/gridarta/model/io/PathManager.java Modified: trunk/src/app/net/sf/gridarta/model/io/PathManager.java =================================================================== --- trunk/src/app/net/sf/gridarta/model/io/PathManager.java 2010-06-06 16:17:48 UTC (rev 8177) +++ trunk/src/app/net/sf/gridarta/model/io/PathManager.java 2010-06-06 16:18:42 UTC (rev 8178) @@ -100,7 +100,7 @@ if (mapPath.startsWith(new File(mapDirName).getCanonicalPath())) { mapPath = mapPath.substring(new File(mapDirName).getCanonicalPath().length()); } - } catch (final IOException ex) { + } catch (final IOException ignored) { // ignore } mapPath = mapPath.replace('\\', '/'); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-06-06 16:17:54
|
Revision: 8177 http://gridarta.svn.sourceforge.net/gridarta/?rev=8177&view=rev Author: akirschbaum Date: 2010-06-06 16:17:48 +0000 (Sun, 06 Jun 2010) Log Message: ----------- Use proper map transactions in regression tests. Modified Paths: -------------- trunk/src/test/net/sf/gridarta/exitconnector/ExitConnectorActionsTest.java Modified: trunk/src/test/net/sf/gridarta/exitconnector/ExitConnectorActionsTest.java =================================================================== --- trunk/src/test/net/sf/gridarta/exitconnector/ExitConnectorActionsTest.java 2010-06-06 16:13:56 UTC (rev 8176) +++ trunk/src/test/net/sf/gridarta/exitconnector/ExitConnectorActionsTest.java 2010-06-06 16:17:48 UTC (rev 8177) @@ -125,14 +125,24 @@ // no exit at cursor and no auto-create ==> disabled Assert.assertFalse(actions.doExitPaste(false, mapControl, point1)); - assert testMapControlCreator != null; - testMapControlCreator.insertFloor(mapModel, point1); + mapModel.beginTransaction("TEST"); + try { + assert testMapControlCreator != null; + testMapControlCreator.insertFloor(mapModel, point1); + } finally { + mapModel.endTransaction(); + } // no exit at cursor and no auto-create ==> disabled Assert.assertFalse(actions.doExitPaste(false, mapControl, point1)); - assert testMapControlCreator != null; - testMapControlCreator.insertExit(mapModel, point1); + mapModel.beginTransaction("TEST"); + try { + assert testMapControlCreator != null; + testMapControlCreator.insertExit(mapModel, point1); + } finally { + mapModel.endTransaction(); + } // exit at cursor ==> enabled Assert.assertTrue(actions.doExitPaste(false, mapControl, point1)); @@ -201,20 +211,35 @@ // no exit at cursor and no auto-create ==> disabled Assert.assertFalse(actions.doExitConnect(false, mapControl1, point1)); - assert testMapControlCreator != null; - testMapControlCreator.insertFloor(mapModel1, point1); + mapModel1.beginTransaction("TEST"); + try { + assert testMapControlCreator != null; + testMapControlCreator.insertFloor(mapModel1, point1); + } finally { + mapModel1.endTransaction(); + } // no exit at cursor and no auto-create ==> disabled Assert.assertFalse(actions.doExitConnect(false, mapControl1, point1)); - assert testMapControlCreator != null; - testMapControlCreator.insertExit(mapModel1, point1); + mapModel1.beginTransaction("TEST"); + try { + assert testMapControlCreator != null; + testMapControlCreator.insertExit(mapModel1, point1); + } finally { + mapModel1.endTransaction(); + } // no exit at source and no auto-create ==> disabled Assert.assertFalse(actions.doExitConnect(false, mapControl1, point1)); - assert testMapControlCreator != null; - testMapControlCreator.insertExit(mapModel2, point2); + mapModel2.beginTransaction("TEST"); + try { + assert testMapControlCreator != null; + testMapControlCreator.insertExit(mapModel2, point2); + } finally { + mapModel2.endTransaction(); + } // exit at source and cursor ==> enabled Assert.assertTrue(actions.doExitConnect(false, mapControl1, point1)); @@ -324,8 +349,13 @@ assert testMapControlCreator != null; model.setExitLocation(new ExitLocation(mapFileTo, pointTo, MAP_NAME2, testMapControlCreator.getPathManager())); - assert testMapControlCreator != null; - testMapControlCreator.insertExit(mapModel, pointFrom); + mapModel.beginTransaction("TEST"); + try { + assert testMapControlCreator != null; + testMapControlCreator.insertExit(mapModel, pointFrom); + } finally { + mapModel.endTransaction(); + } // perform connect Assert.assertTrue(actions.doExitPaste(true, mapControl, pointFrom)); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-06-06 16:14:02
|
Revision: 8176 http://gridarta.svn.sourceforge.net/gridarta/?rev=8176&view=rev Author: akirschbaum Date: 2010-06-06 16:13:56 +0000 (Sun, 06 Jun 2010) Log Message: ----------- Make regression tests independent on editor settings. Modified Paths: -------------- trunk/src/app/net/sf/gridarta/maincontrol/GUIMainControl.java trunk/src/app/net/sf/gridarta/model/exitconnector/ExitConnectorModel.java trunk/src/test/net/sf/gridarta/exitconnector/ExitConnectorActionsTest.java Added Paths: ----------- trunk/src/app/net/sf/gridarta/model/exitconnector/AbstractExitConnectorModel.java trunk/src/app/net/sf/gridarta/model/exitconnector/DefaultExitConnectorModel.java trunk/src/test/net/sf/gridarta/model/exitconnector/ trunk/src/test/net/sf/gridarta/model/exitconnector/TestExitConnectorModel.java Modified: trunk/src/app/net/sf/gridarta/maincontrol/GUIMainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/maincontrol/GUIMainControl.java 2010-06-06 15:47:38 UTC (rev 8175) +++ trunk/src/app/net/sf/gridarta/maincontrol/GUIMainControl.java 2010-06-06 16:13:56 UTC (rev 8176) @@ -130,6 +130,7 @@ import net.sf.gridarta.model.baseobject.GameObjectContainer; import net.sf.gridarta.model.errorview.ErrorView; import net.sf.gridarta.model.errorview.ErrorViewCollector; +import net.sf.gridarta.model.exitconnector.DefaultExitConnectorModel; import net.sf.gridarta.model.exitconnector.ExitConnectorModel; import net.sf.gridarta.model.exitconnector.ExitMatcher; import net.sf.gridarta.model.face.FaceObjectProviders; @@ -547,7 +548,7 @@ mainView.addTab(new Tab("selectedSquare", selectedSquareView, Location.RIGHT, 1, true)); mainView.addTab(new Tab("tools", toolPalette, Location.LEFT, 2, false)); mainView.addTab(new Tab("objects", objectChooser, Location.LEFT, 3, true)); - exitConnectorModel = new ExitConnectorModel(); // XXX: should be part of DefaultMainControl + exitConnectorModel = new DefaultExitConnectorModel(); // 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); Copied: trunk/src/app/net/sf/gridarta/model/exitconnector/AbstractExitConnectorModel.java (from rev 8173, trunk/src/app/net/sf/gridarta/model/exitconnector/ExitConnectorModel.java) =================================================================== --- trunk/src/app/net/sf/gridarta/model/exitconnector/AbstractExitConnectorModel.java (rev 0) +++ trunk/src/app/net/sf/gridarta/model/exitconnector/AbstractExitConnectorModel.java 2010-06-06 16:13:56 UTC (rev 8176) @@ -0,0 +1,210 @@ +/* + * 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.exitconnector; + +import net.sf.gridarta.utils.EventListenerList2; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * Stores information needed by the exit connector. + * @author Andreas Kirschbaum + */ +public abstract class AbstractExitConnectorModel implements ExitConnectorModel { + + /** + * The listeners to notify. + */ + private final EventListenerList2<ExitConnectorModelListener> listeners = new EventListenerList2<ExitConnectorModelListener>(ExitConnectorModelListener.class); + + /** + * Whether an exit has been remembered. Set to <code>null</code> if no exit + * location has been remembered. + */ + @Nullable + private ExitLocation exitLocation = null; + + /** + * Whether the exit's name should be set when pasted. + */ + private boolean pasteExitName = loadPasteExitName(); + + /** + * Whether exit game objects should be auto-created when needed. + */ + private boolean autoCreateExit = loadAutoCreateExit(); + + /** + * The archetype to insert when creating new exit game objects. + */ + @NotNull + private String exitArchetypeName = loadExitArchetypeName(); + + /** + * {@inheritDoc} + */ + @Override + @Nullable + public ExitLocation getExitLocation() { + return exitLocation; + } + + /** + * {@inheritDoc} + */ + @Override + public void setExitLocation(@Nullable final ExitLocation exitLocation) { + if (exitLocation == null ? this.exitLocation == null : exitLocation.equals(this.exitLocation)) { + return; + } + + this.exitLocation = exitLocation; + for (final ExitConnectorModelListener listener : listeners.getListeners()) { + listener.exitLocationChanged(exitLocation); + } + } + + /** + * {@inheritDoc} + */ + @Override + public boolean isPasteExitName() { + return pasteExitName; + } + + /** + * {@inheritDoc} + */ + @Override + public void setPasteExitName(final boolean pasteExitName) { + if (this.pasteExitName == pasteExitName) { + return; + } + + this.pasteExitName = pasteExitName; + savePasteExitName(pasteExitName); + for (final ExitConnectorModelListener listener : listeners.getListeners()) { + listener.pasteExitNameChanged(pasteExitName); + } + } + + /** + * {@inheritDoc} + */ + @Override + public boolean isAutoCreateExit() { + return autoCreateExit; + } + + /** + * {@inheritDoc} + */ + @Override + public void setAutoCreateExit(final boolean autoCreateExit) { + if (this.autoCreateExit == autoCreateExit) { + return; + } + + this.autoCreateExit = autoCreateExit; + saveAutoCreateExit(autoCreateExit); + for (final ExitConnectorModelListener listener : listeners.getListeners()) { + listener.autoCreateExitChanged(autoCreateExit); + } + } + + /** + * {@inheritDoc} + */ + @Override + @NotNull + public String getExitArchetypeName() { + return exitArchetypeName; + } + + /** + * {@inheritDoc} + */ + @Override + public void setExitArchetypeName(@NotNull final String exitArchetypeName) { + if (this.exitArchetypeName.equals(exitArchetypeName)) { + return; + } + + this.exitArchetypeName = exitArchetypeName; + saveExitArchetypeName(exitArchetypeName); + for (final ExitConnectorModelListener listener : listeners.getListeners()) { + listener.exitArchetypeNameChanged(exitArchetypeName); + } + } + + /** + * {@inheritDoc} + */ + @Override + public void addExitConnectorModelListener(@NotNull final ExitConnectorModelListener listener) { + listeners.add(listener); + } + + /** + * {@inheritDoc} + */ + @Override + public void removeExitConnectorModelListener(@NotNull final ExitConnectorModelListener listener) { + listeners.remove(listener); + } + + /** + * Returns the stored attribute value for {@link #pasteExitName}. + * @return the attribute value + */ + protected abstract boolean loadPasteExitName(); + + /** + * Sets the stored attribute value for {@link #pasteExitName}. + * @param pasteExitName the attribute value + */ + protected abstract void savePasteExitName(final boolean pasteExitName); + + /** + * Returns the stored attribute value for {@link #autoCreateExit}. + * @return the attribute value + */ + protected abstract boolean loadAutoCreateExit(); + + /** + * Sets the stored attribute value for {@link #isAutoCreateExit()}. + * @param autoCreateExit the attribute value + */ + protected abstract void saveAutoCreateExit(final boolean autoCreateExit); + + /** + * Returns the stored attribute value for {@link #exitArchetypeName}. + * @return the attribute value + */ + @NotNull + protected abstract String loadExitArchetypeName(); + + /** + * Sets the stored attribute value for {@link #setExitArchetypeName(String)}. + * @param exitArchetypeName the attribute value + */ + protected abstract void saveExitArchetypeName(@NotNull final String exitArchetypeName); + +} // class ExitConnectorModel Added: trunk/src/app/net/sf/gridarta/model/exitconnector/DefaultExitConnectorModel.java =================================================================== --- trunk/src/app/net/sf/gridarta/model/exitconnector/DefaultExitConnectorModel.java (rev 0) +++ trunk/src/app/net/sf/gridarta/model/exitconnector/DefaultExitConnectorModel.java 2010-06-06 16:13:56 UTC (rev 8176) @@ -0,0 +1,117 @@ +/* + * 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.exitconnector; + +import java.util.prefs.Preferences; +import net.sf.gridarta.MainControl; +import org.jetbrains.annotations.NotNull; + +/** + * Default {@link ExitConnectorModel} implementation. It saves and restores + * attribute values to/from preferences. + * @author Andreas Kirschbaum + */ +public class DefaultExitConnectorModel extends AbstractExitConnectorModel { + + /** + * The preferences key for "paste exit name". + */ + private static final String PASTE_EXIT_NAME_KEY = "exitConnectorPasteExitName"; + + /** + * The default value for {@link #PASTE_EXIT_NAME_KEY}. + */ + public static final boolean PASTE_EXIT_NAME_DEFAULT = true; + + /** + * The preferences key for "auto create exit". + */ + private static final String AUTO_CREATE_EXIT_KEY = "exitConnectorAutoCreateExit"; + + /** + * The default value for {@link #AUTO_CREATE_EXIT_KEY}. + */ + public static final boolean AUTO_CREATE_EXIT_DEFAULT = true; + + /** + * The preferences key for "exit archetype". + */ + private static final String EXIT_ARCHETYPE_NAME_KEY = "exitConnectorExitArchetypeName"; + + /** + * The default value for {@link #EXIT_ARCHETYPE_NAME_KEY}. + */ + public static final String EXIT_ARCHETYPE_NAME_DEFAULT = "invis_exit"; + + /** + * The {@link Preferences}. + */ + private static final Preferences preferences = Preferences.userNodeForPackage(MainControl.class); + + /** + * {@inheritDoc} + */ + @Override + protected boolean loadPasteExitName() { + return preferences.getBoolean(PASTE_EXIT_NAME_KEY, PASTE_EXIT_NAME_DEFAULT); + } + + /** + * {@inheritDoc} + */ + @Override + protected void savePasteExitName(final boolean pasteExitName) { + preferences.putBoolean(PASTE_EXIT_NAME_KEY, pasteExitName); + } + + /** + * {@inheritDoc} + */ + @Override + protected boolean loadAutoCreateExit() { + return preferences.getBoolean(AUTO_CREATE_EXIT_KEY, AUTO_CREATE_EXIT_DEFAULT); + } + + /** + * {@inheritDoc} + */ + @Override + protected void saveAutoCreateExit(final boolean autoCreateExit) { + preferences.putBoolean(AUTO_CREATE_EXIT_KEY, autoCreateExit); + } + + /** + * {@inheritDoc} + */ + @NotNull + @Override + protected String loadExitArchetypeName() { + return preferences.get(EXIT_ARCHETYPE_NAME_KEY, EXIT_ARCHETYPE_NAME_DEFAULT); + } + + /** + * {@inheritDoc} + */ + @Override + protected void saveExitArchetypeName(@NotNull final String exitArchetypeName) { + preferences.put(EXIT_ARCHETYPE_NAME_KEY, exitArchetypeName); + } + +} // class DefaultExitConnectorModel Property changes on: trunk/src/app/net/sf/gridarta/model/exitconnector/DefaultExitConnectorModel.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF Modified: trunk/src/app/net/sf/gridarta/model/exitconnector/ExitConnectorModel.java =================================================================== --- trunk/src/app/net/sf/gridarta/model/exitconnector/ExitConnectorModel.java 2010-06-06 15:47:38 UTC (rev 8175) +++ trunk/src/app/net/sf/gridarta/model/exitconnector/ExitConnectorModel.java 2010-06-06 16:13:56 UTC (rev 8176) @@ -19,9 +19,6 @@ package net.sf.gridarta.model.exitconnector; -import java.util.prefs.Preferences; -import net.sf.gridarta.MainControl; -import net.sf.gridarta.utils.EventListenerList2; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -29,183 +26,84 @@ * Stores information needed by the exit connector. * @author Andreas Kirschbaum */ -public class ExitConnectorModel { +public interface ExitConnectorModel { /** - * The preferences key for "paste exit name". + * The default value for {@link #isPasteExitName()}. */ - private static final String PASTE_EXIT_NAME_KEY = "exitConnectorPasteExitName"; + boolean PASTE_EXIT_NAME_DEFAULT = true; /** - * The default value for {@link #PASTE_EXIT_NAME_KEY}. + * The default value for {@link #isAutoCreateExit()}. */ - public static final boolean PASTE_EXIT_NAME_DEFAULT = true; + boolean AUTO_CREATE_EXIT_DEFAULT = true; /** - * The preferences key for "auto create exit". + * The default value for {@link #getExitArchetypeName()}. */ - private static final String AUTO_CREATE_EXIT_KEY = "exitConnectorAutoCreateExit"; + String EXIT_ARCHETYPE_NAME_DEFAULT = "invis_exit"; /** - * The default value for {@link #AUTO_CREATE_EXIT_KEY}. - */ - public static final boolean AUTO_CREATE_EXIT_DEFAULT = true; - - /** - * The preferences key for "exit archetype". - */ - private static final String EXIT_ARCHETYPE_NAME_KEY = "exitConnectorExitArchetypeName"; - - /** - * The default value for {@link #EXIT_ARCHETYPE_NAME_KEY}. - */ - public static final String EXIT_ARCHETYPE_NAME_DEFAULT = "invis_exit"; - - /** - * The {@link Preferences}. - */ - private static final Preferences preferences = Preferences.userNodeForPackage(MainControl.class); - - /** - * The listeners to notify. - */ - private final EventListenerList2<ExitConnectorModelListener> listeners = new EventListenerList2<ExitConnectorModelListener>(ExitConnectorModelListener.class); - - /** - * Whether an exit has been remembered. Set to <code>null</code> if no exit - * location has been remembered. - */ - @Nullable - private ExitLocation exitLocation = null; - - /** - * Whether the exit's name should be set when pasted. - */ - private boolean pasteExitName = preferences.getBoolean(PASTE_EXIT_NAME_KEY, PASTE_EXIT_NAME_DEFAULT); - - /** - * Whether exit game objects should be auto-created when needed. - */ - private boolean autoCreateExit = preferences.getBoolean(AUTO_CREATE_EXIT_KEY, AUTO_CREATE_EXIT_DEFAULT); - - /** - * The archetype to insert when creating new exit game objects. - */ - @NotNull - private String exitArchetypeName = preferences.get(EXIT_ARCHETYPE_NAME_KEY, EXIT_ARCHETYPE_NAME_DEFAULT); - - /** * Returns the remembered exit location. * @return the exit location or <code>null</code> */ @Nullable - public ExitLocation getExitLocation() { - return exitLocation; - } + ExitLocation getExitLocation(); /** * Sets the remembered exit location. * @param exitLocation the exit location or <code>null</code> */ - public void setExitLocation(@Nullable final ExitLocation exitLocation) { - if (exitLocation == null ? this.exitLocation == null : exitLocation.equals(this.exitLocation)) { - return; - } + void setExitLocation(@Nullable ExitLocation exitLocation); - this.exitLocation = exitLocation; - for (final ExitConnectorModelListener listener : listeners.getListeners()) { - listener.exitLocationChanged(exitLocation); - } - } - /** * Returns whether the exit name should be updated. * @return whether the exit name should be updated */ - public boolean isPasteExitName() { - return pasteExitName; - } + boolean isPasteExitName(); /** * Sets whether the exit name should be updated. * @param pasteExitName whether the exit name should be updated */ - public void setPasteExitName(final boolean pasteExitName) { - if (this.pasteExitName == pasteExitName) { - return; - } + void setPasteExitName(boolean pasteExitName); - this.pasteExitName = pasteExitName; - preferences.putBoolean(PASTE_EXIT_NAME_KEY, pasteExitName); - for (final ExitConnectorModelListener listener : listeners.getListeners()) { - listener.pasteExitNameChanged(pasteExitName); - } - } - /** * Returns whether exit game objects should be auto-created when needed. * @return whether exit game objects should be auto-created when needed */ - public boolean isAutoCreateExit() { - return autoCreateExit; - } + boolean isAutoCreateExit(); /** * Sets whether exit game objects should be auto-created when needed. * @param autoCreateExit whether exit game objects should be auto-created * when needed */ - public void setAutoCreateExit(final boolean autoCreateExit) { - if (this.autoCreateExit == autoCreateExit) { - return; - } + void setAutoCreateExit(boolean autoCreateExit); - this.autoCreateExit = autoCreateExit; - preferences.putBoolean(AUTO_CREATE_EXIT_KEY, autoCreateExit); - for (final ExitConnectorModelListener listener : listeners.getListeners()) { - listener.autoCreateExitChanged(autoCreateExit); - } - } - /** * Returns the archetype name when creating exit game objects. * @return the archetype name */ @NotNull - public String getExitArchetypeName() { - return exitArchetypeName; - } + String getExitArchetypeName(); /** * Sets the archetype name for creating exit game objects. * @param exitArchetypeName the archetype name */ - public void setExitArchetypeName(@NotNull final String exitArchetypeName) { - if (this.exitArchetypeName.equals(exitArchetypeName)) { - return; - } + void setExitArchetypeName(@NotNull String exitArchetypeName); - this.exitArchetypeName = exitArchetypeName; - preferences.put(EXIT_ARCHETYPE_NAME_KEY, exitArchetypeName); - for (final ExitConnectorModelListener listener : listeners.getListeners()) { - listener.exitArchetypeNameChanged(exitArchetypeName); - } - } - /** * Adds an {@link ExitConnectorModelListener} to be notified of changes. * @param listener the listener */ - public void addExitConnectorModelListener(@NotNull final ExitConnectorModelListener listener) { - listeners.add(listener); - } + void addExitConnectorModelListener(@NotNull ExitConnectorModelListener listener); /** * Removes an {@link ExitConnectorModelListener} to be notified of changes. * @param listener the listener */ - public void removeExitConnectorModelListener(@NotNull final ExitConnectorModelListener listener) { - listeners.remove(listener); - } + void removeExitConnectorModelListener(@NotNull ExitConnectorModelListener listener); -} // class ExitConnectorModel +} // interface ExitConnectorModel Modified: trunk/src/test/net/sf/gridarta/exitconnector/ExitConnectorActionsTest.java =================================================================== --- trunk/src/test/net/sf/gridarta/exitconnector/ExitConnectorActionsTest.java 2010-06-06 15:47:38 UTC (rev 8175) +++ trunk/src/test/net/sf/gridarta/exitconnector/ExitConnectorActionsTest.java 2010-06-06 16:13:56 UTC (rev 8176) @@ -28,6 +28,7 @@ import net.sf.gridarta.model.baseobject.BaseObject; import net.sf.gridarta.model.exitconnector.ExitConnectorModel; import net.sf.gridarta.model.exitconnector.ExitLocation; +import net.sf.gridarta.model.exitconnector.TestExitConnectorModel; import net.sf.gridarta.model.gameobject.TestGameObject; import net.sf.gridarta.model.map.maparchobject.TestMapArchObject; import net.sf.gridarta.model.map.mapcontrol.MapControl; @@ -79,7 +80,7 @@ */ @Test public void testExitCopy1() { - final ExitConnectorModel model = new ExitConnectorModel(); + final ExitConnectorModel model = new TestExitConnectorModel(); final ExitConnectorActions<TestGameObject, TestMapArchObject, TestArchetype> actions = createActions(model); final Size2D mapSize = new Size2D(5, 5); assert testMapControlCreator != null; @@ -108,7 +109,7 @@ */ @Test public void testExitPaste1() { - final ExitConnectorModel model = new ExitConnectorModel(); + final ExitConnectorModel model = new TestExitConnectorModel(); final ExitConnectorActions<TestGameObject, TestMapArchObject, TestArchetype> actions = createActions(model); final Size2D mapSize = new Size2D(5, 5); assert testMapControlCreator != null; @@ -148,7 +149,7 @@ */ @Test public void testExitPaste2() { - final ExitConnectorModel model = new ExitConnectorModel(); + final ExitConnectorModel model = new TestExitConnectorModel(); final ExitConnectorActions<TestGameObject, TestMapArchObject, TestArchetype> actions = createActions(model); final Size2D mapSize = new Size2D(5, 5); @@ -163,7 +164,6 @@ model.setExitLocation(new ExitLocation(MAP_FILE2, point2, MAP_NAME2, testMapControlCreator.getPathManager())); model.setAutoCreateExit(true); - model.setExitArchetypeName("exit"); // paste must fail for unsaved map mapModel1.setMapFile(null); // pretend unsaved map @@ -180,7 +180,7 @@ */ @Test public void testExitConnect1() { - final ExitConnectorModel model = new ExitConnectorModel(); + final ExitConnectorModel model = new TestExitConnectorModel(); final ExitConnectorActions<TestGameObject, TestMapArchObject, TestArchetype> actions = createActions(model); final Size2D mapSize = new Size2D(5, 5); @@ -233,7 +233,7 @@ */ @Test public void testExitConnectAuto1() { - final ExitConnectorModel model = new ExitConnectorModel(); + final ExitConnectorModel model = new TestExitConnectorModel(); final ExitConnectorActions<TestGameObject, TestMapArchObject, TestArchetype> actions = createActions(model); final Size2D mapSize = new Size2D(5, 5); @@ -252,6 +252,8 @@ model.setExitLocation(new ExitLocation(MAP_FILE2, point2, MAP_NAME2, testMapControlCreator.getPathManager())); model.setAutoCreateExit(true); + model.setExitArchetypeName("undefined"); + // fails due to undefined archetype Assert.assertFalse(actions.doExitConnect(true, mapControl1, point1)); checkExit(mapModel1, point1, 0, null, null); @@ -304,7 +306,7 @@ * @param expectedExitPath the expected map in the exit object */ private void testPath(@NotNull final String mapPathFrom, @NotNull final String mapPathTo, @NotNull final String expectedExitPath) { - final ExitConnectorModel model = new ExitConnectorModel(); + final ExitConnectorModel model = new TestExitConnectorModel(); final ExitConnectorActions<TestGameObject, TestMapArchObject, TestArchetype> actions = createActions(model); assert testMapControlCreator != null; Added: trunk/src/test/net/sf/gridarta/model/exitconnector/TestExitConnectorModel.java =================================================================== --- trunk/src/test/net/sf/gridarta/model/exitconnector/TestExitConnectorModel.java (rev 0) +++ trunk/src/test/net/sf/gridarta/model/exitconnector/TestExitConnectorModel.java 2010-06-06 16:13:56 UTC (rev 8176) @@ -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.exitconnector; + +import org.jetbrains.annotations.NotNull; + +/** + * {@link ExitConnectorModel} implementation for regression tests. It does not + * retain attribute values. + * @author Andreas Kirschbaum + */ +public class TestExitConnectorModel extends AbstractExitConnectorModel { + + /** + * {@inheritDoc} + */ + @Override + protected boolean loadPasteExitName() { + return true; + } + + /** + * {@inheritDoc} + */ + @Override + protected void savePasteExitName(final boolean pasteExitName) { + // ignore + } + + /** + * {@inheritDoc} + */ + @Override + protected boolean loadAutoCreateExit() { + return false; + } + + /** + * {@inheritDoc} + */ + @Override + protected void saveAutoCreateExit(final boolean autoCreateExit) { + // ignore + } + + /** + * {@inheritDoc} + */ + @NotNull + @Override + protected String loadExitArchetypeName() { + return "exit"; + } + + /** + * {@inheritDoc} + */ + @Override + protected void saveExitArchetypeName(@NotNull final String exitArchetypeName) { + // ignore + } + +} // class TestExitConnectorModel Property changes on: trunk/src/test/net/sf/gridarta/model/exitconnector/TestExitConnectorModel.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-06-06 15:47:45
|
Revision: 8175 http://gridarta.svn.sourceforge.net/gridarta/?rev=8175&view=rev Author: akirschbaum Date: 2010-06-06 15:47:38 +0000 (Sun, 06 Jun 2010) Log Message: ----------- Fix NullPointerException in "paste exit" when connecting to an unsaved map. Modified Paths: -------------- trunk/atrinik/ChangeLog trunk/crossfire/ChangeLog trunk/daimonin/ChangeLog trunk/src/app/net/sf/gridarta/exitconnector/ExitConnectorActions.java trunk/src/app/net/sf/gridarta/model/exitconnector/ExitLocation.java trunk/src/test/net/sf/gridarta/exitconnector/ExitConnectorActionsTest.java Modified: trunk/atrinik/ChangeLog =================================================================== --- trunk/atrinik/ChangeLog 2010-06-06 13:47:41 UTC (rev 8174) +++ trunk/atrinik/ChangeLog 2010-06-06 15:47:38 UTC (rev 8175) @@ -1,3 +1,8 @@ +2010-06-06 Andreas Kirschbaum + + * Fix NullPointerException in "paste exit" when connecting to an + unsaved map. + 2010-06-05 Andreas Kirschbaum * Fix direction chooser in archetype chooser. Now it is enabled Modified: trunk/crossfire/ChangeLog =================================================================== --- trunk/crossfire/ChangeLog 2010-06-06 13:47:41 UTC (rev 8174) +++ trunk/crossfire/ChangeLog 2010-06-06 15:47:38 UTC (rev 8175) @@ -1,3 +1,8 @@ +2010-06-06 Andreas Kirschbaum + + * Fix NullPointerException in "paste exit" when connecting to an + unsaved map. + 2010-06-05 Andreas Kirschbaum * Do not duplicate bookmarks when saving maps. Modified: trunk/daimonin/ChangeLog =================================================================== --- trunk/daimonin/ChangeLog 2010-06-06 13:47:41 UTC (rev 8174) +++ trunk/daimonin/ChangeLog 2010-06-06 15:47:38 UTC (rev 8175) @@ -1,3 +1,8 @@ +2010-06-06 Andreas Kirschbaum + + * Fix NullPointerException in "paste exit" when connecting to an + unsaved map. + 2010-06-05 Andreas Kirschbaum * Fix direction chooser in archetype chooser. Now it is enabled Modified: trunk/src/app/net/sf/gridarta/exitconnector/ExitConnectorActions.java =================================================================== --- trunk/src/app/net/sf/gridarta/exitconnector/ExitConnectorActions.java 2010-06-06 13:47:41 UTC (rev 8174) +++ trunk/src/app/net/sf/gridarta/exitconnector/ExitConnectorActions.java 2010-06-06 15:47:38 UTC (rev 8175) @@ -160,11 +160,16 @@ return false; } + final File targetMapFile = targetMapModel.getMapFile(); + if (targetMapFile == null) { + return false; + } + if (targetExit != null) { // paste into existing exit if (performAction) { - pasteExit(targetExit, targetMapModel, sourceExitLocation); + pasteExit(targetExit, targetMapModel, sourceExitLocation, targetMapFile); } } else { // paste into newly created exit game object @@ -177,7 +182,7 @@ } if (performAction) { - if (!pasteExit(targetLocation, targetMapModel, targetArchetype, sourceExitLocation)) { + if (!pasteExit(targetLocation, targetMapModel, targetArchetype, sourceExitLocation, targetMapFile)) { return false; } } @@ -296,18 +301,18 @@ if (performAction) { final ExitLocation targetExitLocation = new ExitLocation(targetMapFile, targetLocation, targetMapModel.getMapArchObject().getMapName(), pathManager); if (sourceExit != null) { - pasteExit(sourceExit, sourceMapModel, targetExitLocation); + pasteExit(sourceExit, sourceMapModel, targetExitLocation, sourceMapFile); } else { - if (!pasteExit(sourceLocation, sourceMapModel, sourceArchetype, targetExitLocation)) { + if (!pasteExit(sourceLocation, sourceMapModel, sourceArchetype, targetExitLocation, sourceMapFile)) { return false; } } if (targetExit != null) { - pasteExit(targetExit, targetMapModel, sourceExitLocation); + pasteExit(targetExit, targetMapModel, sourceExitLocation, targetMapFile); } else { assert targetArchetype != null; - if (!pasteExit(targetLocation, targetMapModel, targetArchetype, sourceExitLocation)) { + if (!pasteExit(targetLocation, targetMapModel, targetArchetype, sourceExitLocation, targetMapFile)) { return false; } } @@ -321,11 +326,12 @@ * @param gameObject the exit game object to paste into * @param mapModel the map model to paste into * @param exitLocation the exit information to paste + * @param mapFile the map file to path */ - private void pasteExit(@NotNull final BaseObject<?, ?, ?, ?> gameObject, @NotNull final MapModel<G, A, R> mapModel, @NotNull final ExitLocation exitLocation) { + private void pasteExit(@NotNull final BaseObject<?, ?, ?, ?> gameObject, @NotNull final MapModel<G, A, R> mapModel, @NotNull final ExitLocation exitLocation, @NotNull final File mapFile) { mapModel.beginTransaction("paste exit"); try { - exitLocation.updateExitObject(gameObject, exitConnectorModel.isPasteExitName(), mapModel.getMapFile()); + exitLocation.updateExitObject(gameObject, exitConnectorModel.isPasteExitName(), mapFile); } finally { mapModel.endTransaction(); } @@ -337,9 +343,10 @@ * @param mapModel the map model to insert into * @param archetype the archetype to insert * @param exitLocation the exit information to use + * @param mapFile the map file to paste * @return whether insertion was successful */ - private boolean pasteExit(@NotNull final Point location, @NotNull final MapModel<G, A, R> mapModel, @NotNull final BaseObject<G, A, R, ?> archetype, @NotNull final ExitLocation exitLocation) { + private boolean pasteExit(@NotNull final Point location, @NotNull final MapModel<G, A, R> mapModel, @NotNull final BaseObject<G, A, R, ?> archetype, @NotNull final ExitLocation exitLocation, @NotNull final File mapFile) { mapModel.beginTransaction("paste exit"); try { final BaseObject<G, A, R, ?> newExit = mapModel.insertBaseObject(archetype, location, true, false, insertionModeSet.getTopmostInsertionMode()); @@ -347,7 +354,7 @@ return false; } - exitLocation.updateExitObject(newExit, exitConnectorModel.isPasteExitName(), mapModel.getMapFile()); + exitLocation.updateExitObject(newExit, exitConnectorModel.isPasteExitName(), mapFile); } finally { mapModel.endTransaction(); } Modified: trunk/src/app/net/sf/gridarta/model/exitconnector/ExitLocation.java =================================================================== --- trunk/src/app/net/sf/gridarta/model/exitconnector/ExitLocation.java 2010-06-06 13:47:41 UTC (rev 8174) +++ trunk/src/app/net/sf/gridarta/model/exitconnector/ExitLocation.java 2010-06-06 15:47:38 UTC (rev 8175) @@ -91,7 +91,7 @@ * @param sourceMapFile the file of the map containing * <code>gameObject</code> */ - public void updateExitObject(@NotNull final BaseObject<?, ?, ?, ?> gameObject, final boolean updateName, @Nullable final File sourceMapFile) { + public void updateExitObject(@NotNull final BaseObject<?, ?, ?, ?> gameObject, final boolean updateName, @NotNull final File sourceMapFile) { final String sourceMapPath = pathManager.getMapPath(sourceMapFile); final String targetMapPath = pathManager.getMapPath(file); Modified: trunk/src/test/net/sf/gridarta/exitconnector/ExitConnectorActionsTest.java =================================================================== --- trunk/src/test/net/sf/gridarta/exitconnector/ExitConnectorActionsTest.java 2010-06-06 13:47:41 UTC (rev 8174) +++ trunk/src/test/net/sf/gridarta/exitconnector/ExitConnectorActionsTest.java 2010-06-06 15:47:38 UTC (rev 8175) @@ -143,6 +143,38 @@ } /** + * Checks that {@link ExitConnectorActions#doExitPaste(boolean, MapControl, + * Point)} does not crash when connecting to an unsaved map. + */ + @Test + public void testExitPaste2() { + final ExitConnectorModel model = new ExitConnectorModel(); + final ExitConnectorActions<TestGameObject, TestMapArchObject, TestArchetype> actions = createActions(model); + final Size2D mapSize = new Size2D(5, 5); + + assert testMapControlCreator != null; + final MapControl<TestGameObject, TestMapArchObject, TestArchetype> mapControl1 = testMapControlCreator.newMapControl(MAP_FILE1, MAP_NAME1, mapSize); + final MapModel<TestGameObject, TestMapArchObject, TestArchetype> mapModel1 = mapControl1.getMapModel(); + + final Point point1 = new Point(3, 4); + final Point point2 = new Point(1, 2); + + assert testMapControlCreator != null; + model.setExitLocation(new ExitLocation(MAP_FILE2, point2, MAP_NAME2, testMapControlCreator.getPathManager())); + + model.setAutoCreateExit(true); + model.setExitArchetypeName("exit"); + + // paste must fail for unsaved map + mapModel1.setMapFile(null); // pretend unsaved map + Assert.assertFalse(actions.doExitPaste(true, mapControl1, point1)); + + // paste must succeed for saved map + mapModel1.setMapFile(MAP_FILE1); // pretend saved map + Assert.assertTrue(actions.doExitPaste(true, mapControl1, point1)); + } + + /** * Checks that {@link ExitConnectorActions#doExitConnect(boolean, * MapControl, Point)} does work. */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-06-06 14:47:42
|
Revision: 8171 http://gridarta.svn.sourceforge.net/gridarta/?rev=8171&view=rev Author: akirschbaum Date: 2010-06-06 12:16:52 +0000 (Sun, 06 Jun 2010) Log Message: ----------- Merge duplicated code. Fix behavior of Events tab within game object attributes panel. Modified Paths: -------------- trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/EventsTab.java Modified: trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/EventsTab.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/EventsTab.java 2010-06-06 10:49:18 UTC (rev 8170) +++ trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/EventsTab.java 2010-06-06 12:16:52 UTC (rev 8171) @@ -30,8 +30,12 @@ import javax.swing.JList; import javax.swing.JPanel; import javax.swing.JScrollPane; +import javax.swing.ListModel; +import javax.swing.ListSelectionModel; import javax.swing.ScrollPaneConstants; import javax.swing.border.EtchedBorder; +import javax.swing.event.ListSelectionEvent; +import javax.swing.event.ListSelectionListener; import net.sf.gridarta.gui.scripts.ScriptArchDataUtils; import net.sf.gridarta.gui.scripts.ScriptArchEditor; import net.sf.gridarta.gui.scripts.ScriptTask; @@ -184,6 +188,16 @@ panel.add(buttons, BorderLayout.EAST); panel.setPreferredSize(new Dimension(100, 40)); + eventList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); + final ListSelectionListener listSelectionListener = new ListSelectionListener() { + + @Override + public void valueChanged(final ListSelectionEvent e) { + updateActions(); + } + + }; + eventList.addListSelectionListener(listSelectionListener); refresh(gameObjectAttributesModel.getSelectedGameObject()); } @@ -229,26 +243,29 @@ selectedGameObject = gameObject; if (gameObject == null || !gameObject.isScripted()) { setTabSeverity(Severity.DEFAULT); - if (eventList.getModel() != null && eventList.getModel().getSize() > 0) { + final ListModel listModel = eventList.getModel(); + if (listModel != null && listModel.getSize() > 0) { eventList.setModel(new DefaultListModel()); } - - aEventAddNew.setEnabled(gameObject != null); - aEventEditData.setEnabled(false); - aEventEdit.setEnabled(false); - aEventRemove.setEnabled(false); } else { setTabSeverity(Severity.MODIFIED); eventList.removeAll(); scriptArchUtils.addEventsToJList(eventList, gameObject); - aEventAddNew.setEnabled(true); - aEventEditData.setEnabled(true); - aEventEdit.setEnabled(true); - aEventRemove.setEnabled(true); } + updateActions(); } /** + * Updates the enabled state of all actions. + */ + private void updateActions() { + aEventAddNew.setEnabled(doAddNewEvent(false)); + aEventEditData.setEnabled(doEditEvent(ScriptTask.EVENT_EDIT_PATH, false)); + aEventEdit.setEnabled(doEditEvent(ScriptTask.EVENT_OPEN, false)); + aEventRemove.setEnabled(doEditEvent(ScriptTask.EVENT_REMOVE, false)); + } + + /** * {@inheritDoc} */ @Override @@ -260,7 +277,7 @@ */ @ActionMethod public void eventAddNew() { - addNewEvent(); + doAddNewEvent(true); } /** @@ -268,7 +285,7 @@ */ @ActionMethod public void eventEditData() { - editEvent(ScriptTask.EVENT_EDIT_PATH); + doEditEvent(ScriptTask.EVENT_EDIT_PATH, true); } /** @@ -276,7 +293,7 @@ */ @ActionMethod public void eventEdit() { - editEvent(ScriptTask.EVENT_OPEN); + doEditEvent(ScriptTask.EVENT_OPEN, true); } /** @@ -284,15 +301,22 @@ */ @ActionMethod public void eventRemove() { - editEvent(ScriptTask.EVENT_REMOVE); + doEditEvent(ScriptTask.EVENT_REMOVE, true); } /** * This method is invoked when the user pressed the "new event" button. + * @param performAction whether the action should be performed + * @return whether the action was or can be performed */ - public void addNewEvent() { - if (selectedGameObject != null) { - final G selectedHead = selectedGameObject.getHead(); + private boolean doAddNewEvent(final boolean performAction) { + final GameObject<G, A, R> gameObject = selectedGameObject; + if (gameObject == null) { + return false; + } + + if (performAction) { + final G selectedHead = gameObject.getHead(); final MapSquare<G, A, R> mapSquare = selectedHead.getMapSquare(); assert mapSquare != null; final MapModel<G, A, R> mapModel = mapSquare.getMapModel(); @@ -310,6 +334,8 @@ mapModel.endTransaction(); } } + + return true; } /** @@ -318,32 +344,42 @@ * selection in the event list, the appropriate action for this event is * triggered. * @param task the task to execute + * @param performAction whether the action should be performed + * @return whether the action was or can be performed */ - private void editEvent(@NotNull final ScriptTask task) { - if (selectedGameObject == null) { - return; + private boolean doEditEvent(@NotNull final ScriptTask task, final boolean performAction) { + final GameObject<G, A, R> gameObject = selectedGameObject; + if (gameObject == null) { + return false; } - final G selectedHead = selectedGameObject.getHead(); - // check for a valid selection in the event list - if (eventList.getModel() != null && eventList.getModel().getSize() > 0 && eventList.getSelectedIndex() >= 0) { - // there - final int index = eventList.getSelectedIndex(); - if (index >= 0) { - final MapSquare<G, A, R> mapSquare = selectedHead.getMapSquare(); - assert mapSquare != null; - final MapModel<G, A, R> mapModel = mapSquare.getMapModel(); - mapModel.beginTransaction("Modify event"); - try { - scriptArchDataUtils.modifyEventScript(index, task, eventList, mapManager, parent, selectedHead); - if (scriptArchData.isEmpty(selectedHead)) { - setEventPanelButtonState(true, false, false, false); - } - } finally { - mapModel.endTransaction(); + final ListModel listModel = eventList.getModel(); + if (listModel == null || listModel.getSize() <= 0) { + return false; + } + + final int index = eventList.getSelectedIndex(); + if (index < 0) { + return false; + } + + if (performAction) { + final G selectedHead = gameObject.getHead(); + final MapSquare<G, A, R> mapSquare = selectedHead.getMapSquare(); + assert mapSquare != null; + final MapModel<G, A, R> mapModel = mapSquare.getMapModel(); + mapModel.beginTransaction("Modify event"); + try { + scriptArchDataUtils.modifyEventScript(index, task, eventList, mapManager, parent, selectedHead); + if (scriptArchData.isEmpty(selectedHead)) { + setEventPanelButtonState(true, false, false, false); } + } finally { + mapModel.endTransaction(); } } + + return true; } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-06-06 13:47:48
|
Revision: 8174 http://gridarta.svn.sourceforge.net/gridarta/?rev=8174&view=rev Author: akirschbaum Date: 2010-06-06 13:47:41 +0000 (Sun, 06 Jun 2010) Log Message: ----------- Revert previous commit as it creates maps not supported by the server. Modified Paths: -------------- trunk/atrinik/ChangeLog trunk/crossfire/ChangeLog trunk/daimonin/ChangeLog trunk/src/app/net/sf/gridarta/gui/scripts/DefaultScriptArchEditor.java Modified: trunk/atrinik/ChangeLog =================================================================== --- trunk/atrinik/ChangeLog 2010-06-06 12:53:04 UTC (rev 8173) +++ trunk/atrinik/ChangeLog 2010-06-06 13:47:41 UTC (rev 8174) @@ -1,8 +1,3 @@ -2010-06-06 Andreas Kirschbaum - - * Allow to create more than one event script for the same type in - game object attributes panel. - 2010-06-05 Andreas Kirschbaum * Fix direction chooser in archetype chooser. Now it is enabled Modified: trunk/crossfire/ChangeLog =================================================================== --- trunk/crossfire/ChangeLog 2010-06-06 12:53:04 UTC (rev 8173) +++ trunk/crossfire/ChangeLog 2010-06-06 13:47:41 UTC (rev 8174) @@ -1,8 +1,3 @@ -2010-06-06 Andreas Kirschbaum - - * Allow to create more than one event script for the same type in - game object attributes panel. - 2010-06-05 Andreas Kirschbaum * Do not duplicate bookmarks when saving maps. Modified: trunk/daimonin/ChangeLog =================================================================== --- trunk/daimonin/ChangeLog 2010-06-06 12:53:04 UTC (rev 8173) +++ trunk/daimonin/ChangeLog 2010-06-06 13:47:41 UTC (rev 8174) @@ -1,8 +1,3 @@ -2010-06-06 Andreas Kirschbaum - - * Allow to create more than one event script for the same type in - game object attributes panel. - 2010-06-05 Andreas Kirschbaum * Fix direction chooser in archetype chooser. Now it is enabled Modified: trunk/src/app/net/sf/gridarta/gui/scripts/DefaultScriptArchEditor.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/scripts/DefaultScriptArchEditor.java 2010-06-06 12:53:04 UTC (rev 8173) +++ trunk/src/app/net/sf/gridarta/gui/scripts/DefaultScriptArchEditor.java 2010-06-06 13:47:41 UTC (rev 8174) @@ -314,6 +314,16 @@ final File localMapDir = mapManager.getLocalMapDir(); + // first check if that event type is not already in use + final GameObject<G, A, R> replaceObject = scriptArchData.getScriptedEvent(eventType, gameObject); + if (replaceObject != null) { + // collision with existing event -> ask user: replace? + if (JOptionPane.showConfirmDialog(frame, "An event of type \"" + scriptArchUtils.typeName(eventType) + "\" already exists for this object.\n" + "Do you want to replace the existing event?", "Event exists", JOptionPane.YES_NO_OPTION, JOptionPane.INFORMATION_MESSAGE) == JOptionPane.NO_OPTION) { + // bail out + return; + } + } + String absScriptPath; if (scriptPath.length() > 0 && scriptPath.charAt(0) == '/') { // script path is absolute @@ -349,6 +359,9 @@ JOptionPane.showMessageDialog(frame, "Cannot create event of type " + eventType + ":\n" + ex.getMessage() + ".", "Cannot create event", JOptionPane.ERROR_MESSAGE); return; } + if (replaceObject != null) { + replaceObject.remove(); + } gameObject.addLast(event.getEventArch()); frame.setVisible(false); // close dialog } @@ -388,6 +401,9 @@ JOptionPane.showMessageDialog(frame, "Cannot create event of type " + eventType + ":\n" + ex.getMessage() + ".", "Cannot create event", JOptionPane.ERROR_MESSAGE); return; } + if (replaceObject != null) { + replaceObject.remove(); + } gameObject.addLast(event.getEventArch()); frame.setVisible(false); // close dialog This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-06-06 12:53:10
|
Revision: 8173 http://gridarta.svn.sourceforge.net/gridarta/?rev=8173&view=rev Author: akirschbaum Date: 2010-06-06 12:53:04 +0000 (Sun, 06 Jun 2010) Log Message: ----------- Add @NotNull/@Nullable annotations. Modified Paths: -------------- trunk/src/app/net/sf/gridarta/gui/scripts/DefaultScriptArchEditor.java Modified: trunk/src/app/net/sf/gridarta/gui/scripts/DefaultScriptArchEditor.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/scripts/DefaultScriptArchEditor.java 2010-06-06 12:41:31 UTC (rev 8172) +++ trunk/src/app/net/sf/gridarta/gui/scripts/DefaultScriptArchEditor.java 2010-06-06 12:53:04 UTC (rev 8173) @@ -69,6 +69,7 @@ /** * Action Builder. */ + @NotNull private static final ActionBuilder ACTION_BUILDER = ActionBuilderFactory.getInstance().getActionBuilder("net.sf.gridarta"); /** @@ -80,6 +81,7 @@ /** * The ending for scripts. */ + @NotNull private final String scriptEnding; /** @@ -94,8 +96,10 @@ @Nullable private ScriptEditControl scriptEditControl = null; + @NotNull private final JComboBox eventTypeBox; + @NotNull private final FileFilter scriptFileFilter; /** @@ -110,18 +114,24 @@ @NotNull private final MapManager<?, ?, ?> mapManager; + @NotNull private final JComboBox pluginNameBox; // popup frame for new scripts: + @Nullable private JDialog newScriptFrame; + @NotNull private JLabel headingLabel; + @NotNull private JTextComponent inputScriptPath; + @NotNull private JTextComponent inputOptions; + @NotNull private PathButtonListener<G, A, R> nsOkListener; /** @@ -296,7 +306,7 @@ * {@inheritDoc} */ @Override - public void createNewEvent(final JDialog frame, final ScriptArchData<G, A, R> scriptArchData, @NotNull final G gameObject) { + public void createNewEvent(@NotNull final JDialog frame, @NotNull final ScriptArchData<G, A, R> scriptArchData, @NotNull final G gameObject) { final StringBuilder scriptPath = new StringBuilder(inputScriptPath.getText().trim().replace('\\', '/')); final String options = inputOptions.getText().trim(); final int eventType = scriptArchUtils.indexToEventType(eventTypeBox.getSelectedIndex()); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-06-06 12:41:37
|
Revision: 8172 http://gridarta.svn.sourceforge.net/gridarta/?rev=8172&view=rev Author: akirschbaum Date: 2010-06-06 12:41:31 +0000 (Sun, 06 Jun 2010) Log Message: ----------- Allow to create more than one event script for the same type in game object attributes panel. Modified Paths: -------------- trunk/atrinik/ChangeLog trunk/crossfire/ChangeLog trunk/daimonin/ChangeLog trunk/src/app/net/sf/gridarta/gui/scripts/DefaultScriptArchEditor.java Modified: trunk/atrinik/ChangeLog =================================================================== --- trunk/atrinik/ChangeLog 2010-06-06 12:16:52 UTC (rev 8171) +++ trunk/atrinik/ChangeLog 2010-06-06 12:41:31 UTC (rev 8172) @@ -1,3 +1,8 @@ +2010-06-06 Andreas Kirschbaum + + * Allow to create more than one event script for the same type in + game object attributes panel. + 2010-06-05 Andreas Kirschbaum * Fix direction chooser in archetype chooser. Now it is enabled Modified: trunk/crossfire/ChangeLog =================================================================== --- trunk/crossfire/ChangeLog 2010-06-06 12:16:52 UTC (rev 8171) +++ trunk/crossfire/ChangeLog 2010-06-06 12:41:31 UTC (rev 8172) @@ -1,3 +1,8 @@ +2010-06-06 Andreas Kirschbaum + + * Allow to create more than one event script for the same type in + game object attributes panel. + 2010-06-05 Andreas Kirschbaum * Do not duplicate bookmarks when saving maps. Modified: trunk/daimonin/ChangeLog =================================================================== --- trunk/daimonin/ChangeLog 2010-06-06 12:16:52 UTC (rev 8171) +++ trunk/daimonin/ChangeLog 2010-06-06 12:41:31 UTC (rev 8172) @@ -1,3 +1,8 @@ +2010-06-06 Andreas Kirschbaum + + * Allow to create more than one event script for the same type in + game object attributes panel. + 2010-06-05 Andreas Kirschbaum * Fix direction chooser in archetype chooser. Now it is enabled Modified: trunk/src/app/net/sf/gridarta/gui/scripts/DefaultScriptArchEditor.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/scripts/DefaultScriptArchEditor.java 2010-06-06 12:16:52 UTC (rev 8171) +++ trunk/src/app/net/sf/gridarta/gui/scripts/DefaultScriptArchEditor.java 2010-06-06 12:41:31 UTC (rev 8172) @@ -304,16 +304,6 @@ final File localMapDir = mapManager.getLocalMapDir(); - // first check if that event type is not already in use - final GameObject<G, A, R> replaceObject = scriptArchData.getScriptedEvent(eventType, gameObject); - if (replaceObject != null) { - // collision with existing event -> ask user: replace? - if (JOptionPane.showConfirmDialog(frame, "An event of type \"" + scriptArchUtils.typeName(eventType) + "\" already exists for this object.\n" + "Do you want to replace the existing event?", "Event exists", JOptionPane.YES_NO_OPTION, JOptionPane.INFORMATION_MESSAGE) == JOptionPane.NO_OPTION) { - // bail out - return; - } - } - String absScriptPath; if (scriptPath.length() > 0 && scriptPath.charAt(0) == '/') { // script path is absolute @@ -349,9 +339,6 @@ JOptionPane.showMessageDialog(frame, "Cannot create event of type " + eventType + ":\n" + ex.getMessage() + ".", "Cannot create event", JOptionPane.ERROR_MESSAGE); return; } - if (replaceObject != null) { - replaceObject.remove(); - } gameObject.addLast(event.getEventArch()); frame.setVisible(false); // close dialog } @@ -391,9 +378,6 @@ JOptionPane.showMessageDialog(frame, "Cannot create event of type " + eventType + ":\n" + ex.getMessage() + ".", "Cannot create event", JOptionPane.ERROR_MESSAGE); return; } - if (replaceObject != null) { - replaceObject.remove(); - } gameObject.addLast(event.getEventArch()); frame.setVisible(false); // close dialog This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-06-06 10:49:24
|
Revision: 8170 http://gridarta.svn.sourceforge.net/gridarta/?rev=8170&view=rev Author: akirschbaum Date: 2010-06-06 10:49:18 +0000 (Sun, 06 Jun 2010) Log Message: ----------- Rename variable names. Modified Paths: -------------- trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/EventsTab.java Modified: trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/EventsTab.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/EventsTab.java 2010-06-06 10:48:05 UTC (rev 8169) +++ trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/EventsTab.java 2010-06-06 10:49:18 UTC (rev 8170) @@ -109,7 +109,7 @@ * The {@link JScrollPane} displaying all event.s */ @NotNull - private final JScrollPane ssa; + private final JScrollPane scrollPane; /** * The action for "add new event". @@ -167,21 +167,21 @@ this.scriptArchDataUtils = scriptArchDataUtils; this.scriptArchUtils = scriptArchUtils; - ssa = new JScrollPane(eventList); - ssa.setBorder(new EtchedBorder()); - ssa.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED); - ssa.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); - ssa.setPreferredSize(new Dimension(80, 40)); + scrollPane = new JScrollPane(eventList); + scrollPane.setBorder(new EtchedBorder()); + scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED); + scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); + scrollPane.setPreferredSize(new Dimension(80, 40)); - final Container grid = new JPanel(new GridLayout(4, 1)); - grid.add(new JButton(aEventAddNew)); - grid.add(new JButton(aEventEditData)); - grid.add(new JButton(aEventEdit)); - grid.add(new JButton(aEventRemove)); + final Container buttons = new JPanel(new GridLayout(4, 1)); + buttons.add(new JButton(aEventAddNew)); + buttons.add(new JButton(aEventEditData)); + buttons.add(new JButton(aEventEdit)); + buttons.add(new JButton(aEventRemove)); panel.setLayout(new BorderLayout()); - panel.add(ssa, BorderLayout.CENTER); - panel.add(grid, BorderLayout.EAST); + panel.add(scrollPane, BorderLayout.CENTER); + panel.add(buttons, BorderLayout.EAST); panel.setPreferredSize(new Dimension(100, 40)); refresh(gameObjectAttributesModel.getSelectedGameObject()); @@ -218,7 +218,7 @@ */ @Override public void requestFocus() { - ssa.requestFocusInWindow(); + scrollPane.requestFocusInWindow(); } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-06-06 10:48:11
|
Revision: 8169 http://gridarta.svn.sourceforge.net/gridarta/?rev=8169&view=rev Author: akirschbaum Date: 2010-06-06 10:48:05 +0000 (Sun, 06 Jun 2010) Log Message: ----------- Remove duplicated code. Modified Paths: -------------- trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/EventsTab.java Modified: trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/EventsTab.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/EventsTab.java 2010-06-06 10:47:47 UTC (rev 8168) +++ trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/EventsTab.java 2010-06-06 10:48:05 UTC (rev 8169) @@ -179,12 +179,6 @@ grid.add(new JButton(aEventEdit)); grid.add(new JButton(aEventRemove)); - // disable all the buttons in the beginning - aEventAddNew.setEnabled(false); - aEventEditData.setEnabled(false); - aEventEdit.setEnabled(false); - aEventRemove.setEnabled(false); - panel.setLayout(new BorderLayout()); panel.add(ssa, BorderLayout.CENTER); panel.add(grid, BorderLayout.EAST); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-06-06 10:47:54
|
Revision: 8168 http://gridarta.svn.sourceforge.net/gridarta/?rev=8168&view=rev Author: akirschbaum Date: 2010-06-06 10:47:47 +0000 (Sun, 06 Jun 2010) Log Message: ----------- Add comments. Modified Paths: -------------- trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/EventsTab.java Modified: trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/EventsTab.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/EventsTab.java 2010-06-06 10:43:45 UTC (rev 8167) +++ trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/EventsTab.java 2010-06-06 10:47:47 UTC (rev 8168) @@ -57,10 +57,8 @@ */ public class EventsTab<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> extends AbstractGameObjectAttributesTab<G, A, R> { - // constants for the 'task' parameter in editEvent() - /** - * The action builder. + * The {@link ActionBuilder}. */ @NotNull private static final ActionBuilder ACTION_BUILDER = ActionBuilderFactory.getInstance().getActionBuilder("net.sf.gridarta"); @@ -72,7 +70,7 @@ private final Frame parent; /** - * The map manager. + * The {@link MapManager}. */ @NotNull private final MapManager<G, A, R> mapManager; @@ -113,23 +111,39 @@ @NotNull private final JScrollPane ssa; + /** + * The action for "add new event". + */ @NotNull private final Action aEventAddNew = ACTION_BUILDER.createAction(false, "eventAddNew", this); + /** + * The action for "edit event parameters". + */ @NotNull private final Action aEventEditData = ACTION_BUILDER.createAction(false, "eventEditData", this); + /** + * The action for "edit event code". + */ @NotNull private final Action aEventEdit = ACTION_BUILDER.createAction(false, "eventEdit", this); + /** + * The action for "remove event". + */ @NotNull private final Action aEventRemove = ACTION_BUILDER.createAction(false, "eventRemove", this); + /** + * The {@link JList} that shows all events. + */ @NotNull private final JList eventList = new JList(); /** - * The currently selected game object. + * The currently selected game object. Set to <code>null</code> if none is + * selected. */ @Nullable private GameObject<G, A, R> selectedGameObject = null; @@ -153,14 +167,12 @@ this.scriptArchDataUtils = scriptArchDataUtils; this.scriptArchUtils = scriptArchUtils; - // create ScrollPane for list scrolling ssa = new JScrollPane(eventList); ssa.setBorder(new EtchedBorder()); ssa.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED); ssa.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); ssa.setPreferredSize(new Dimension(80, 40)); - // create buttons final Container grid = new JPanel(new GridLayout(4, 1)); grid.add(new JButton(aEventAddNew)); grid.add(new JButton(aEventEditData)); @@ -354,4 +366,4 @@ aEventRemove.setEnabled(removeButton); } -} +} // class EventsTab This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-06-06 10:43:51
|
Revision: 8167 http://gridarta.svn.sourceforge.net/gridarta/?rev=8167&view=rev Author: akirschbaum Date: 2010-06-06 10:43:45 +0000 (Sun, 06 Jun 2010) Log Message: ----------- Replace int constants with enum. Modified Paths: -------------- trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/EventsTab.java trunk/src/app/net/sf/gridarta/gui/scripts/ScriptArchDataUtils.java Added Paths: ----------- trunk/src/app/net/sf/gridarta/gui/scripts/ScriptTask.java Modified: trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/EventsTab.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/EventsTab.java 2010-06-06 10:36:43 UTC (rev 8166) +++ trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/EventsTab.java 2010-06-06 10:43:45 UTC (rev 8167) @@ -34,6 +34,7 @@ import javax.swing.border.EtchedBorder; import net.sf.gridarta.gui.scripts.ScriptArchDataUtils; import net.sf.gridarta.gui.scripts.ScriptArchEditor; +import net.sf.gridarta.gui.scripts.ScriptTask; import net.sf.gridarta.gui.utils.Severity; import net.sf.gridarta.mapmanager.MapManager; import net.sf.gridarta.model.archetype.Archetype; @@ -58,12 +59,6 @@ // constants for the 'task' parameter in editEvent() - public static final int EVENT_OPEN = 0; - - public static final int EVENT_EDIT_PATH = 1; - - public static final int EVENT_REMOVE = 2; - /** * The action builder. */ @@ -267,7 +262,7 @@ */ @ActionMethod public void eventEditData() { - editEvent(EVENT_EDIT_PATH); + editEvent(ScriptTask.EVENT_EDIT_PATH); } /** @@ -275,7 +270,7 @@ */ @ActionMethod public void eventEdit() { - editEvent(EVENT_OPEN); + editEvent(ScriptTask.EVENT_OPEN); } /** @@ -283,7 +278,7 @@ */ @ActionMethod public void eventRemove() { - editEvent(EVENT_REMOVE); + editEvent(ScriptTask.EVENT_REMOVE); } /** @@ -316,9 +311,9 @@ * event"/"path"/"remove" button from the event panel. If there is a valid * selection in the event list, the appropriate action for this event is * triggered. - * @param task event type to edit (?). + * @param task the task to execute */ - private void editEvent(final int task) { + private void editEvent(@NotNull final ScriptTask task) { if (selectedGameObject == null) { return; } Modified: trunk/src/app/net/sf/gridarta/gui/scripts/ScriptArchDataUtils.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/scripts/ScriptArchDataUtils.java 2010-06-06 10:36:43 UTC (rev 8166) +++ trunk/src/app/net/sf/gridarta/gui/scripts/ScriptArchDataUtils.java 2010-06-06 10:43:45 UTC (rev 8167) @@ -22,7 +22,6 @@ import java.awt.Frame; import javax.swing.JList; import javax.swing.JOptionPane; -import net.sf.gridarta.gui.gameobjectattributespanel.EventsTab; import net.sf.gridarta.mapmanager.MapManager; import net.sf.gridarta.model.archetype.Archetype; import net.sf.gridarta.model.gameobject.GameObject; @@ -89,14 +88,14 @@ * If there is a scripted event of the specified type, the script pad is * opened and the appropriate script displayed. * @param eventIndex index of event in the owner's inventory - * @param task ID number for task (open script/ edit path/ remove) + * @param task the task to execute * @param panelList JList from the MapArchPanel (script tab) which displays * the events * @param mapManager the map manager instance * @param parent the parent frame for dialog boxes * @param gameObject the game object to operate on */ - public void modifyEventScript(final int eventIndex, final int task, @NotNull final JList panelList, @NotNull final MapManager<?, ?, ?> mapManager, @NotNull final Frame parent, @NotNull final Iterable<G> gameObject) { + public void modifyEventScript(final int eventIndex, final ScriptTask task, @NotNull final JList panelList, @NotNull final MapManager<?, ?, ?> mapManager, @NotNull final Frame parent, @NotNull final Iterable<G> gameObject) { G oldEvent = null; /* Find the event object */ @@ -113,18 +112,21 @@ if (oldEvent != null) { final ScriptedEvent<G, A, R> event = scriptedEventFactory.newScriptedEvent(oldEvent); - // now decide what to do: - if (task == EventsTab.EVENT_OPEN) { + switch (task) { + case EVENT_OPEN: scriptedEventEditor.openScript(mapManager, event.getScriptPath(), parent); - } else if (task == EventsTab.EVENT_EDIT_PATH) { + break; + + case EVENT_EDIT_PATH: scriptedEventEditor.editParameters(event, parent); - } else if (task == EventsTab.EVENT_REMOVE) { - // first ask for confirmation + break; + + case EVENT_REMOVE: if (JOptionPane.showConfirmDialog(panelList, "Are you sure you want to remove this \"" + scriptArchUtils.typeName(event.getEventType()) + "\" event which is\n" + "linked to the script: '" + event.getScriptPath() + "'?\n" + "(The script file itself is not going to be deleted)", "Confirm", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE) == JOptionPane.YES_OPTION) { - // remove this event from the GameObject oldEvent.remove(); - scriptArchUtils.addEventsToJList(panelList, gameObject); // update panel JList + scriptArchUtils.addEventsToJList(panelList, gameObject); } + break; } } else { log.error("Error in modifyEventScript(): No event selected?"); Added: trunk/src/app/net/sf/gridarta/gui/scripts/ScriptTask.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/scripts/ScriptTask.java (rev 0) +++ trunk/src/app/net/sf/gridarta/gui/scripts/ScriptTask.java 2010-06-06 10:43:45 UTC (rev 8167) @@ -0,0 +1,48 @@ +/* + * 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.scripts; + +import java.awt.Frame; +import javax.swing.JList; +import net.sf.gridarta.mapmanager.MapManager; + +/** + * Parameter for operation to perform in {@link ScriptArchDataUtils#modifyEventScript(int, + * int, JList, MapManager, Frame, Iterable)}. + * @author Andreas Kirschbaum + */ +public enum ScriptTask { + + /** + * Opens an editor for the script code. + */ + EVENT_OPEN, + + /** + * Opens a dialog to edit the script parameters. + */ + EVENT_EDIT_PATH, + + /** + * Removes the event object. + */ + EVENT_REMOVE + +} // enum ScriptTask Property changes on: trunk/src/app/net/sf/gridarta/gui/scripts/ScriptTask.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-06-06 10:36:52
|
Revision: 8166 http://gridarta.svn.sourceforge.net/gridarta/?rev=8166&view=rev Author: akirschbaum Date: 2010-06-06 10:36:43 +0000 (Sun, 06 Jun 2010) Log Message: ----------- Add @NotNull annotations. Modified Paths: -------------- trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/EventsTab.java Modified: trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/EventsTab.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/EventsTab.java 2010-06-06 10:35:51 UTC (rev 8165) +++ trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/EventsTab.java 2010-06-06 10:36:43 UTC (rev 8166) @@ -67,6 +67,7 @@ /** * The action builder. */ + @NotNull private static final ActionBuilder ACTION_BUILDER = ActionBuilderFactory.getInstance().getActionBuilder("net.sf.gridarta"); /** @@ -117,14 +118,19 @@ @NotNull private final JScrollPane ssa; + @NotNull private final Action aEventAddNew = ACTION_BUILDER.createAction(false, "eventAddNew", this); + @NotNull private final Action aEventEditData = ACTION_BUILDER.createAction(false, "eventEditData", this); + @NotNull private final Action aEventEdit = ACTION_BUILDER.createAction(false, "eventEdit", this); + @NotNull private final Action aEventRemove = ACTION_BUILDER.createAction(false, "eventRemove", this); + @NotNull private final JList eventList = new JList(); /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-06-06 10:35:57
|
Revision: 8165 http://gridarta.svn.sourceforge.net/gridarta/?rev=8165&view=rev Author: akirschbaum Date: 2010-06-06 10:35:51 +0000 (Sun, 06 Jun 2010) Log Message: ----------- Do not ignore caught exception. Modified Paths: -------------- trunk/src/app/net/sf/gridarta/gui/gameobjecttexteditor/GameObjectTextEditor.java Modified: trunk/src/app/net/sf/gridarta/gui/gameobjecttexteditor/GameObjectTextEditor.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/gameobjecttexteditor/GameObjectTextEditor.java 2010-06-06 10:33:56 UTC (rev 8164) +++ trunk/src/app/net/sf/gridarta/gui/gameobjecttexteditor/GameObjectTextEditor.java 2010-06-06 10:35:51 UTC (rev 8165) @@ -141,8 +141,8 @@ StyleConstants.setForeground(currentAttributes, Color.black); document.insertString(document.getLength(), AttributeListUtils.diffArchTextKeys(gameObject, gameObject.getArchetype()), currentAttributes); - } catch (final BadLocationException e) { - assert false; + } catch (final BadLocationException ex) { + throw new AssertionError(ex); } } archEdit.setCaretPosition(0); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-06-06 10:34:03
|
Revision: 8164 http://gridarta.svn.sourceforge.net/gridarta/?rev=8164&view=rev Author: akirschbaum Date: 2010-06-06 10:33:56 +0000 (Sun, 06 Jun 2010) Log Message: ----------- Add final modifiers. Modified Paths: -------------- trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/ArchTab.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/EventsTab.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/FaceTab.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/MsgTextTab.java Modified: trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/ArchTab.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/ArchTab.java 2010-06-06 10:32:43 UTC (rev 8163) +++ trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/ArchTab.java 2010-06-06 10:33:56 UTC (rev 8164) @@ -269,7 +269,7 @@ * {@inheritDoc} */ @Override - protected void refresh(@Nullable final G gameObject) { + protected final void refresh(@Nullable final G gameObject) { setTabSeverity(gameObject == null ? Severity.DEFAULT : Severity.MODIFIED); // archNameField Modified: trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/EventsTab.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/EventsTab.java 2010-06-06 10:32:43 UTC (rev 8163) +++ trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/EventsTab.java 2010-06-06 10:33:56 UTC (rev 8164) @@ -218,7 +218,7 @@ * {@inheritDoc} */ @Override - protected void refresh(@Nullable final G gameObject) { + protected final void refresh(@Nullable final G gameObject) { selectedGameObject = gameObject; if (gameObject == null || !gameObject.isScripted()) { setTabSeverity(Severity.DEFAULT); Modified: trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/FaceTab.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/FaceTab.java 2010-06-06 10:32:43 UTC (rev 8163) +++ trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/FaceTab.java 2010-06-06 10:33:56 UTC (rev 8164) @@ -215,7 +215,7 @@ * {@inheritDoc} */ @Override - protected void refresh(@Nullable final G gameObject) { + protected final void refresh(@Nullable final G gameObject) { Severity severity = Severity.DEFAULT; final String faceName; Modified: trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/MsgTextTab.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/MsgTextTab.java 2010-06-06 10:32:43 UTC (rev 8163) +++ trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/MsgTextTab.java 2010-06-06 10:33:56 UTC (rev 8164) @@ -102,7 +102,7 @@ * {@inheritDoc} */ @Override - protected void refresh(@Nullable final G gameObject) { + protected final void refresh(@Nullable final G gameObject) { final boolean hasMessage; if (gameObject == null) { setArchTextArea("", Color.black); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-06-06 10:32:49
|
Revision: 8163 http://gridarta.svn.sourceforge.net/gridarta/?rev=8163&view=rev Author: akirschbaum Date: 2010-06-06 10:32:43 +0000 (Sun, 06 Jun 2010) Log Message: ----------- Do not ignore overridden function. Modified Paths: -------------- trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/AbstractGameObjectAttributesTab.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/EventsTab.java Modified: trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/AbstractGameObjectAttributesTab.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/AbstractGameObjectAttributesTab.java 2010-06-06 01:46:44 UTC (rev 8162) +++ trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/AbstractGameObjectAttributesTab.java 2010-06-06 10:32:43 UTC (rev 8163) @@ -146,14 +146,6 @@ * {@inheritDoc} */ @Override - public boolean canApply() { - return false; - } - - /** - * {@inheritDoc} - */ - @Override public void apply() { if (selectedGameObject != null) { apply(selectedGameObject); Modified: trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/EventsTab.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/EventsTab.java 2010-06-06 01:46:44 UTC (rev 8162) +++ trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/EventsTab.java 2010-06-06 10:32:43 UTC (rev 8163) @@ -202,6 +202,14 @@ * {@inheritDoc} */ @Override + public boolean canApply() { + return false; + } + + /** + * {@inheritDoc} + */ + @Override public void requestFocus() { ssa.requestFocusInWindow(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-06-06 01:46:50
|
Revision: 8162 http://gridarta.svn.sourceforge.net/gridarta/?rev=8162&view=rev Author: akirschbaum Date: 2010-06-06 01:46:44 +0000 (Sun, 06 Jun 2010) Log Message: ----------- Rename variable name. Modified Paths: -------------- trunk/src/app/net/sf/gridarta/model/archetype/AbstractArchetypeSet.java Modified: trunk/src/app/net/sf/gridarta/model/archetype/AbstractArchetypeSet.java =================================================================== --- trunk/src/app/net/sf/gridarta/model/archetype/AbstractArchetypeSet.java 2010-06-06 01:40:49 UTC (rev 8161) +++ trunk/src/app/net/sf/gridarta/model/archetype/AbstractArchetypeSet.java 2010-06-06 01:46:44 UTC (rev 8162) @@ -229,8 +229,8 @@ */ @Override public void connectFaces() { - for (final BaseObject<G, A, R, ?> arch : getArchetypes()) { - arch.setObjectFace(); + for (final BaseObject<G, A, R, ?> archetype : getArchetypes()) { + archetype.setObjectFace(); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-06-06 01:40:55
|
Revision: 8161 http://gridarta.svn.sourceforge.net/gridarta/?rev=8161&view=rev Author: akirschbaum Date: 2010-06-06 01:40:49 +0000 (Sun, 06 Jun 2010) Log Message: ----------- Disable debug message to console. Modified Paths: -------------- trunk/src/app/net/sf/gridarta/model/face/AbstractFaceProvider.java Modified: trunk/src/app/net/sf/gridarta/model/face/AbstractFaceProvider.java =================================================================== --- trunk/src/app/net/sf/gridarta/model/face/AbstractFaceProvider.java 2010-06-05 19:45:56 UTC (rev 8160) +++ trunk/src/app/net/sf/gridarta/model/face/AbstractFaceProvider.java 2010-06-06 01:40:49 UTC (rev 8161) @@ -71,8 +71,8 @@ */ @Override public void reload() { - if (log.isInfoEnabled()) { - log.info("Clearing image cache."); + if (log.isDebugEnabled()) { + log.debug("Clearing image cache."); } cache.clear(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |