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...> - 2013-07-09 07:10:20
|
Revision: 9285 http://sourceforge.net/p/gridarta/code/9285 Author: akirschbaum Date: 2013-07-09 07:10:17 +0000 (Tue, 09 Jul 2013) Log Message: ----------- Extract ReleaseDragAction from MapCursorActions. Modified Paths: -------------- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/mapcursor/MapCursorActions.java trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/GUIMainControl.java Added Paths: ----------- trunk/src/gridarta/src/main/java/net/sf/gridarta/action/ReleaseDragAction.java Added: trunk/src/gridarta/src/main/java/net/sf/gridarta/action/ReleaseDragAction.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/action/ReleaseDragAction.java (rev 0) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/action/ReleaseDragAction.java 2013-07-09 07:10:17 UTC (rev 9285) @@ -0,0 +1,106 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2011 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.action; + +import java.awt.Point; +import javax.swing.Action; +import net.sf.gridarta.gui.map.mapview.MapViewManager; +import net.sf.gridarta.model.archetype.Archetype; +import net.sf.gridarta.model.gameobject.GameObject; +import net.sf.gridarta.model.maparchobject.MapArchObject; +import net.sf.gridarta.model.mapcursor.MapCursor; +import net.sf.gridarta.utils.EditorAction; +import net.sf.japi.swing.action.ActionMethod; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * An {@link EditorAction} that finishes a selction process when the mouse button is released. + * @author Andreas Kirschbaum + */ +public class ReleaseDragAction<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> extends AbstractMapCursorAction<G, A, R> implements EditorAction { + + /** + * The {@link Action} associated with this editor action. Set to {@code + * null} if no action is associated. + */ + @Nullable + private Action action; + + /** + * Creates a new instance. + * @param mapViewManager the map view manager + */ + public ReleaseDragAction(@NotNull final MapViewManager<G, A, R> mapViewManager) { + super(mapViewManager); + } + + /** + * {@inheritDoc} + */ + @Override + public void setAction(@NotNull final Action action, @NotNull final String name) { + this.action = action; + } + + /** + * Action method for "release drag". + */ + @ActionMethod + public void insertArch() { + doReleaseDrag(true); + } + + /** + * Executes the "release drag" action. + * @param performAction whether the action should be performed + * @return whether the action was or can be performed + */ + private boolean doReleaseDrag(final boolean performAction) { + final MapCursor<G, A, R> mapCursor = getActiveMapCursor(); + if (mapCursor == null) { + return false; + } + + if (performAction) { + if (mapCursor.isDragging()) { + mapCursor.dragRelease(); + } else { + final Point location = mapCursor.getLocation(); + mapCursor.deactivate(); + mapCursor.setLocation(location); + } + } + + return true; + } + + /** + * {@inheritDoc} + */ + @Override + protected void updateAction() { + if (action != null) { + //noinspection ConstantConditions + action.setEnabled(doReleaseDrag(false)); + } + } + +} Property changes on: trunk/src/gridarta/src/main/java/net/sf/gridarta/action/ReleaseDragAction.java ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +LF \ No newline at end of property Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/mapcursor/MapCursorActions.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/mapcursor/MapCursorActions.java 2013-07-09 07:04:39 UTC (rev 9284) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/mapcursor/MapCursorActions.java 2013-07-09 07:10:17 UTC (rev 9285) @@ -96,12 +96,6 @@ private Action aStartStopDrag; /** - * Action for "release drag". - */ - @Nullable - private Action aReleaseDrag; - - /** * The {@link GoLocationDialogManager} to track go location dialog * instances. */ @@ -279,14 +273,6 @@ } /** - * Action method for "release drag". - */ - @ActionMethod - public void releaseDrag() { - doReleaseDrag(true); - } - - /** * Return the map cursor of the current map view if it is active. * @return the map cursor, or <code>null</code> if the cursor is not active, * or if no map view exists @@ -339,10 +325,6 @@ //noinspection ConstantConditions aStartStopDrag.setEnabled(doStartStopDrag(false)); } - if (aReleaseDrag != null) { - //noinspection ConstantConditions - aReleaseDrag.setEnabled(doReleaseDrag(false)); - } } private void selectSquare(@NotNull final MapCursor<G, A, R> mapCursor, final SelectionMode mode) { @@ -470,30 +452,6 @@ } /** - * Executes the "release drag" action. - * @param performAction whether the action should be performed - * @return whether the action was or can be performed - */ - private boolean doReleaseDrag(final boolean performAction) { - final MapCursor<G, A, R> mapCursor = getActiveMapCursor(); - if (mapCursor == null) { - return false; - } - - if (performAction) { - if (mapCursor.isDragging()) { - mapCursor.dragRelease(); - } else { - final Point location = mapCursor.getLocation(); - mapCursor.deactivate(); - mapCursor.setLocation(location); - } - } - - return true; - } - - /** * {@inheritDoc} */ @Override @@ -520,8 +478,6 @@ aSubFromSelection = action; } else if (name.equals("startStopDrag")) { aStartStopDrag = action; - } else if (name.equals("releaseDrag")) { - aReleaseDrag = action; } else { throw new IllegalArgumentException(); } Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/GUIMainControl.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/GUIMainControl.java 2013-07-09 07:04:39 UTC (rev 9284) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/GUIMainControl.java 2013-07-09 07:10:17 UTC (rev 9285) @@ -56,6 +56,7 @@ import net.sf.gridarta.action.MoveSquareTopAction; import net.sf.gridarta.action.MoveSquareUpAction; import net.sf.gridarta.action.OptionsAction; +import net.sf.gridarta.action.ReleaseDragAction; import net.sf.gridarta.action.ReloadFacesAction; import net.sf.gridarta.action.SelectArchAboveAction; import net.sf.gridarta.action.SelectArchBelowAction; @@ -558,7 +559,7 @@ createAction("addToSelection", "Map Cursor,Map/Selection", mapCursorActions); createAction("subFromSelection", "Map Cursor,Map/Selection", mapCursorActions); createAction("startStopDrag", "Map Cursor,Map/Selection", mapCursorActions); - createAction("releaseDrag", "Map Cursor,Map/Selection", mapCursorActions); + createAction("releaseDrag", "Map Cursor,Map/Selection", new ReleaseDragAction<G, A, R>(mapViewManager)); createAction("insertArch", "Map Cursor,Map", new InsertArchAction<G, A, R>(mapViewManager, objectChooser)); createAction("deleteArch", "Map Cursor,Map", new DeleteArchAction<G, A, R>(mapViewManager)); createAction("selectArchAbove", "Map Cursor,Selected Square View", new SelectArchBelowAction<G, A, R>(mapViewManager)); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2013-07-09 07:04:50
|
Revision: 9284 http://sourceforge.net/p/gridarta/code/9284 Author: akirschbaum Date: 2013-07-09 07:04:39 +0000 (Tue, 09 Jul 2013) Log Message: ----------- Extract InsertArchAction from MapCursorActions. Modified Paths: -------------- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/mapcursor/MapCursorActions.java trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/GUIMainControl.java Added Paths: ----------- trunk/src/gridarta/src/main/java/net/sf/gridarta/action/InsertArchAction.java Added: trunk/src/gridarta/src/main/java/net/sf/gridarta/action/InsertArchAction.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/action/InsertArchAction.java (rev 0) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/action/InsertArchAction.java 2013-07-09 07:04:39 UTC (rev 9284) @@ -0,0 +1,102 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2011 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.action; + +import javax.swing.Action; +import net.sf.gridarta.gui.map.mapview.MapViewManager; +import net.sf.gridarta.gui.panel.objectchooser.ObjectChooser; +import net.sf.gridarta.model.archetype.Archetype; +import net.sf.gridarta.model.baseobject.BaseObject; +import net.sf.gridarta.model.gameobject.GameObject; +import net.sf.gridarta.model.maparchobject.MapArchObject; +import net.sf.gridarta.model.mapcursor.MapCursor; +import net.sf.gridarta.utils.EditorAction; +import net.sf.japi.swing.action.ActionMethod; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * An {@link EditorAction} that inserts a new game object into the current map. + * @author Andreas Kirschbaum + */ +public class InsertArchAction<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> extends AbstractMapCursorAction<G, A, R> implements EditorAction { + + /** + * The object chooser. + */ + @NotNull + private final ObjectChooser<G, A, R> objectChooser; + + /** + * The {@link Action} associated with this editor action. Set to {@code + * null} if no action is associated. + */ + @Nullable + private Action action; + + /** + * Creates a new instance. + * @param mapViewManager the map view manager + * @param objectChooser the object chooser + */ + public InsertArchAction(@NotNull final MapViewManager<G, A, R> mapViewManager, @NotNull final ObjectChooser<G, A, R> objectChooser) { + super(mapViewManager); + this.objectChooser = objectChooser; + } + + /** + * {@inheritDoc} + */ + @Override + public void setAction(@NotNull final Action action, @NotNull final String name) { + this.action = action; + } + + /** + * Action method for "insert arch". + */ + @ActionMethod + public void insertArch() { + doInsertArch(true); + } + + /** + * Executes the "insert arch" action. + * @param performAction whether the action should be performed + * @return whether the action was or can be performed + */ + private boolean doInsertArch(final boolean performAction) { + final MapCursor<G, A, R> mapCursor = getActiveMapCursor(); + final BaseObject<G, A, R, ?> gameObject = objectChooser.getSelection(); + return mapCursor != null && gameObject != null && mapCursor.insertGameObject(performAction, gameObject, false, true); + } + + /** + * {@inheritDoc} + */ + @Override + protected void updateAction() { + if (action != null) { + //noinspection ConstantConditions + action.setEnabled(doInsertArch(false)); + } + } + +} Property changes on: trunk/src/gridarta/src/main/java/net/sf/gridarta/action/InsertArchAction.java ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +LF \ No newline at end of property Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/mapcursor/MapCursorActions.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/mapcursor/MapCursorActions.java 2013-07-09 05:22:40 UTC (rev 9283) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/mapcursor/MapCursorActions.java 2013-07-09 07:04:39 UTC (rev 9284) @@ -28,9 +28,7 @@ import net.sf.gridarta.gui.map.mapview.MapViewManager; import net.sf.gridarta.gui.map.mapview.MapViewManagerListener; import net.sf.gridarta.gui.map.renderer.MapRenderer; -import net.sf.gridarta.gui.panel.objectchooser.ObjectChooser; import net.sf.gridarta.model.archetype.Archetype; -import net.sf.gridarta.model.baseobject.BaseObject; import net.sf.gridarta.model.direction.Direction; import net.sf.gridarta.model.gameobject.GameObject; import net.sf.gridarta.model.maparchobject.MapArchObject; @@ -56,12 +54,6 @@ private static final int BORDER = 3; /** - * The object chooser. - */ - @NotNull - private final ObjectChooser<G, A, R> objectChooser; - - /** * All {@link Direction Directions}. */ @NotNull @@ -110,12 +102,6 @@ private Action aReleaseDrag; /** - * Action for "insert arch". - */ - @Nullable - private Action aInsertArch; - - /** * The {@link GoLocationDialogManager} to track go location dialog * instances. */ @@ -178,11 +164,9 @@ /** * Create a new instance. - * @param objectChooser the object chooser * @param mapViewManager the map view manager */ - public MapCursorActions(@NotNull final ObjectChooser<G, A, R> objectChooser, @NotNull final MapViewManager<G, A, R> mapViewManager) { - this.objectChooser = objectChooser; + public MapCursorActions(@NotNull final MapViewManager<G, A, R> mapViewManager) { goLocationDialogManager = new GoLocationDialogManager<G, A, R>(mapViewManager); aMoveCursor = new Action[directions.length]; mapViewManager.addMapViewManagerListener(mapViewManagerListener); @@ -303,14 +287,6 @@ } /** - * Action method for "insert arch". - */ - @ActionMethod - public void insertArch() { - doInsertArch(true); - } - - /** * Return the map cursor of the current map view if it is active. * @return the map cursor, or <code>null</code> if the cursor is not active, * or if no map view exists @@ -367,10 +343,6 @@ //noinspection ConstantConditions aReleaseDrag.setEnabled(doReleaseDrag(false)); } - if (aInsertArch != null) { - //noinspection ConstantConditions - aInsertArch.setEnabled(doInsertArch(false)); - } } private void selectSquare(@NotNull final MapCursor<G, A, R> mapCursor, final SelectionMode mode) { @@ -522,17 +494,6 @@ } /** - * Executes the "insert arch" action. - * @param performAction whether the action should be performed - * @return whether the action was or can be performed - */ - private boolean doInsertArch(final boolean performAction) { - final MapCursor<G, A, R> mapCursor = getActiveMapCursor(); - final BaseObject<G, A, R, ?> gameObject = objectChooser.getSelection(); - return mapCursor != null && gameObject != null && mapCursor.insertGameObject(performAction, gameObject, false, true); - } - - /** * {@inheritDoc} */ @Override @@ -561,8 +522,6 @@ aStartStopDrag = action; } else if (name.equals("releaseDrag")) { aReleaseDrag = action; - } else if (name.equals("insertArch")) { - aInsertArch = action; } else { throw new IllegalArgumentException(); } Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/GUIMainControl.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/GUIMainControl.java 2013-07-09 05:22:40 UTC (rev 9283) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/GUIMainControl.java 2013-07-09 07:04:39 UTC (rev 9284) @@ -45,6 +45,7 @@ import net.sf.gridarta.action.DisplayIconsOnlyAction; import net.sf.gridarta.action.ExitAction; import net.sf.gridarta.action.GcAction; +import net.sf.gridarta.action.InsertArchAction; import net.sf.gridarta.action.LightVisibleAction; import net.sf.gridarta.action.MoveSquareBottomAction; import net.sf.gridarta.action.MoveSquareDownAction; @@ -444,7 +445,7 @@ //noinspection ResultOfObjectAllocationIgnored new FindArchetypesDialogManager<G, A, R>(parent, archetypeChooserControl, objectChooser, archetypeTypeSet); final EditorAction mainActions = new MainActions<G, A, R>(findDialogManager, replaceDialogManager, mainViewFrame, globalSettings, mapViewSettings, archetypeSet, copyBuffer, objectChooser, mapManager, mapViewManager, resources, insertionModeSet, exiter); - final EditorAction mapCursorActions = new MapCursorActions<G, A, R>(objectChooser, mapViewManager); + final EditorAction mapCursorActions = new MapCursorActions<G, A, R>(mapViewManager); final Action moveSquareDownAction = createAction("moveSquareDown", "Selected Square View", new MoveSquareDownAction<G, A, R>(selectedSquareModel, mapManager)); final Action moveSquareUpAction = createAction("moveSquareUp", "Selected Square View", new MoveSquareUpAction<G, A, R>(selectedSquareModel, mapManager)); final Action moveSquareBottomAction = createAction("moveSquareBottom", "Selected Square View", new MoveSquareBottomAction<G, A, R>(selectedSquareModel, mapManager)); @@ -558,7 +559,7 @@ createAction("subFromSelection", "Map Cursor,Map/Selection", mapCursorActions); createAction("startStopDrag", "Map Cursor,Map/Selection", mapCursorActions); createAction("releaseDrag", "Map Cursor,Map/Selection", mapCursorActions); - createAction("insertArch", "Map Cursor,Map", mapCursorActions); + createAction("insertArch", "Map Cursor,Map", new InsertArchAction<G, A, R>(mapViewManager, objectChooser)); createAction("deleteArch", "Map Cursor,Map", new DeleteArchAction<G, A, R>(mapViewManager)); createAction("selectArchAbove", "Map Cursor,Selected Square View", new SelectArchBelowAction<G, A, R>(mapViewManager)); createAction("selectArchBelow", "Map Cursor,Selected Square View", new SelectArchAboveAction<G, A, R>(mapViewManager)); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2013-07-09 05:22:45
|
Revision: 9283 http://sourceforge.net/p/gridarta/code/9283 Author: akirschbaum Date: 2013-07-09 05:22:40 +0000 (Tue, 09 Jul 2013) Log Message: ----------- Extract DeleteArchAction from MapCursorActions. Modified Paths: -------------- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/mapcursor/MapCursorActions.java trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/GUIMainControl.java Added Paths: ----------- trunk/src/gridarta/src/main/java/net/sf/gridarta/action/DeleteArchAction.java Added: trunk/src/gridarta/src/main/java/net/sf/gridarta/action/DeleteArchAction.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/action/DeleteArchAction.java (rev 0) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/action/DeleteArchAction.java 2013-07-09 05:22:40 UTC (rev 9283) @@ -0,0 +1,91 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2011 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.action; + +import javax.swing.Action; +import net.sf.gridarta.gui.map.mapview.MapViewManager; +import net.sf.gridarta.model.archetype.Archetype; +import net.sf.gridarta.model.gameobject.GameObject; +import net.sf.gridarta.model.maparchobject.MapArchObject; +import net.sf.gridarta.model.mapcursor.MapCursor; +import net.sf.gridarta.utils.EditorAction; +import net.sf.japi.swing.action.ActionMethod; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * An {@link EditorAction} that deletes the currently selected game object. + * @author Andreas Kirschbaum + */ +public class DeleteArchAction<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> extends AbstractMapCursorAction<G, A, R> implements EditorAction { + + /** + * The {@link Action} associated with this editor action. Set to {@code + * null} if no action is associated. + */ + @Nullable + private Action action; + + /** + * Creates a new instance. + * @param mapViewManager the map view manager + */ + public DeleteArchAction(@NotNull final MapViewManager<G, A, R> mapViewManager) { + super(mapViewManager); + } + + /** + * {@inheritDoc} + */ + @Override + public void setAction(@NotNull final Action action, @NotNull final String name) { + this.action = action; + } + + /** + * Action method for "delete arch". + */ + @ActionMethod + public void deleteArch() { + doDeleteArch(true); + } + + /** + * Executes the "delete arch" action. + * @param performAction whether the action should be performed + * @return whether the action was or can be performed + */ + private boolean doDeleteArch(final boolean performAction) { + final MapCursor<G, A, R> mapCursor = getActiveMapCursor(); + return mapCursor != null && mapCursor.deleteSelectedGameObject(performAction); + } + + /** + * {@inheritDoc} + */ + @Override + protected void updateAction() { + if (action != null) { + //noinspection ConstantConditions + action.setEnabled(doDeleteArch(false)); + } + } + +} Property changes on: trunk/src/gridarta/src/main/java/net/sf/gridarta/action/DeleteArchAction.java ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +LF \ No newline at end of property Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/mapcursor/MapCursorActions.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/mapcursor/MapCursorActions.java 2013-07-09 05:15:02 UTC (rev 9282) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/mapcursor/MapCursorActions.java 2013-07-09 05:22:40 UTC (rev 9283) @@ -116,12 +116,6 @@ private Action aInsertArch; /** - * Action for "delete arch". - */ - @Nullable - private Action aDeleteArch; - - /** * The {@link GoLocationDialogManager} to track go location dialog * instances. */ @@ -317,14 +311,6 @@ } /** - * Action method for "delete arch". - */ - @ActionMethod - public void deleteArch() { - doDeleteArch(true); - } - - /** * Return the map cursor of the current map view if it is active. * @return the map cursor, or <code>null</code> if the cursor is not active, * or if no map view exists @@ -385,10 +371,6 @@ //noinspection ConstantConditions aInsertArch.setEnabled(doInsertArch(false)); } - if (aDeleteArch != null) { - //noinspection ConstantConditions - aDeleteArch.setEnabled(doDeleteArch(false)); - } } private void selectSquare(@NotNull final MapCursor<G, A, R> mapCursor, final SelectionMode mode) { @@ -551,16 +533,6 @@ } /** - * Executes the "delete arch" action. - * @param performAction whether the action should be performed - * @return whether the action was or can be performed - */ - private boolean doDeleteArch(final boolean performAction) { - final MapCursor<G, A, R> mapCursor = getActiveMapCursor(); - return mapCursor != null && mapCursor.deleteSelectedGameObject(performAction); - } - - /** * {@inheritDoc} */ @Override @@ -591,8 +563,6 @@ aReleaseDrag = action; } else if (name.equals("insertArch")) { aInsertArch = action; - } else if (name.equals("deleteArch")) { - aDeleteArch = action; } else { throw new IllegalArgumentException(); } Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/GUIMainControl.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/GUIMainControl.java 2013-07-09 05:15:02 UTC (rev 9282) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/GUIMainControl.java 2013-07-09 05:22:40 UTC (rev 9283) @@ -39,6 +39,7 @@ import net.sf.gridarta.action.CollectSpellsAction; import net.sf.gridarta.action.ControlClientAction; import net.sf.gridarta.action.ControlServerAction; +import net.sf.gridarta.action.DeleteArchAction; import net.sf.gridarta.action.DisplayArchetypeNamesAction; import net.sf.gridarta.action.DisplayGameObjectNamesAction; import net.sf.gridarta.action.DisplayIconsOnlyAction; @@ -558,7 +559,7 @@ createAction("startStopDrag", "Map Cursor,Map/Selection", mapCursorActions); createAction("releaseDrag", "Map Cursor,Map/Selection", mapCursorActions); createAction("insertArch", "Map Cursor,Map", mapCursorActions); - createAction("deleteArch", "Map Cursor,Map", mapCursorActions); + createAction("deleteArch", "Map Cursor,Map", new DeleteArchAction<G, A, R>(mapViewManager)); createAction("selectArchAbove", "Map Cursor,Selected Square View", new SelectArchBelowAction<G, A, R>(mapViewManager)); createAction("selectArchBelow", "Map Cursor,Selected Square View", new SelectArchAboveAction<G, A, R>(mapViewManager)); createAction("archAttributes", "Map", new ArchAttributesAction<G, A, R>(mapViewManager, gameObjectAttributesDialogFactory)); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2013-07-09 05:15:07
|
Revision: 9282 http://sourceforge.net/p/gridarta/code/9282 Author: akirschbaum Date: 2013-07-09 05:15:02 +0000 (Tue, 09 Jul 2013) Log Message: ----------- Extract SelectArchBelowAction from MapCursorActions. Modified Paths: -------------- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/mapcursor/MapCursorActions.java trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/GUIMainControl.java Added Paths: ----------- trunk/src/gridarta/src/main/java/net/sf/gridarta/action/SelectArchBelowAction.java Added: trunk/src/gridarta/src/main/java/net/sf/gridarta/action/SelectArchBelowAction.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/action/SelectArchBelowAction.java (rev 0) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/action/SelectArchBelowAction.java 2013-07-09 05:15:02 UTC (rev 9282) @@ -0,0 +1,92 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2011 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.action; + +import javax.swing.Action; +import net.sf.gridarta.gui.map.mapview.MapViewManager; +import net.sf.gridarta.model.archetype.Archetype; +import net.sf.gridarta.model.gameobject.GameObject; +import net.sf.gridarta.model.maparchobject.MapArchObject; +import net.sf.gridarta.model.mapcursor.MapCursor; +import net.sf.gridarta.utils.EditorAction; +import net.sf.japi.swing.action.ActionMethod; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * An {@link EditorAction} that selects the game object below the current game + * object. + * @author Andreas Kirschbaum + */ +public class SelectArchBelowAction<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> extends AbstractMapCursorAction<G, A, R> implements EditorAction { + + /** + * The {@link Action} associated with this editor action. Set to {@code + * null} if no action is associated. + */ + @Nullable + private Action action; + + /** + * Creates a new instance. + * @param mapViewManager the map view manager + */ + public SelectArchBelowAction(@NotNull final MapViewManager<G, A, R> mapViewManager) { + super(mapViewManager); + } + + /** + * {@inheritDoc} + */ + @Override + public void setAction(@NotNull final Action action, @NotNull final String name) { + this.action = action; + } + + /** + * Action method for "select arch above". + */ + @ActionMethod + public void selectArchAbove() { + doSelectArchBelow(true); + } + + /** + * Executes the "select arch below" action. + * @param performAction whether the action should be performed + * @return whether the action was or can be performed + */ + private boolean doSelectArchBelow(final boolean performAction) { + final MapCursor<G, A, R> mapCursor = getActiveMapCursor(); + return mapCursor != null && mapCursor.selectBelow(performAction); + } + + /** + * {@inheritDoc} + */ + @Override + protected void updateAction() { + if (action != null) { + //noinspection ConstantConditions + action.setEnabled(doSelectArchBelow(false)); + } + } + +} Property changes on: trunk/src/gridarta/src/main/java/net/sf/gridarta/action/SelectArchBelowAction.java ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +LF \ No newline at end of property Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/mapcursor/MapCursorActions.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/mapcursor/MapCursorActions.java 2013-07-09 05:09:02 UTC (rev 9281) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/mapcursor/MapCursorActions.java 2013-07-09 05:15:02 UTC (rev 9282) @@ -122,12 +122,6 @@ private Action aDeleteArch; /** - * Action for "select arch below". - */ - @Nullable - private Action aSelectArchBelow; - - /** * The {@link GoLocationDialogManager} to track go location dialog * instances. */ @@ -331,14 +325,6 @@ } /** - * Action method for "select arch below". - */ - @ActionMethod - public void selectArchBelow() { - doSelectArchBelow(true); - } - - /** * Return the map cursor of the current map view if it is active. * @return the map cursor, or <code>null</code> if the cursor is not active, * or if no map view exists @@ -403,10 +389,6 @@ //noinspection ConstantConditions aDeleteArch.setEnabled(doDeleteArch(false)); } - if (aSelectArchBelow != null) { - //noinspection ConstantConditions - aSelectArchBelow.setEnabled(doSelectArchBelow(false)); - } } private void selectSquare(@NotNull final MapCursor<G, A, R> mapCursor, final SelectionMode mode) { @@ -579,16 +561,6 @@ } /** - * Executes the "select arch below" action. - * @param performAction whether the action should be performed - * @return whether the action was or can be performed - */ - private boolean doSelectArchBelow(final boolean performAction) { - final MapCursor<G, A, R> mapCursor = getActiveMapCursor(); - return mapCursor != null && mapCursor.selectBelow(performAction); - } - - /** * {@inheritDoc} */ @Override @@ -621,8 +593,6 @@ aInsertArch = action; } else if (name.equals("deleteArch")) { aDeleteArch = action; - } else if (name.equals("selectArchBelow")) { - aSelectArchBelow = action; } else { throw new IllegalArgumentException(); } Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/GUIMainControl.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/GUIMainControl.java 2013-07-09 05:09:02 UTC (rev 9281) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/GUIMainControl.java 2013-07-09 05:15:02 UTC (rev 9282) @@ -56,6 +56,7 @@ import net.sf.gridarta.action.OptionsAction; import net.sf.gridarta.action.ReloadFacesAction; import net.sf.gridarta.action.SelectArchAboveAction; +import net.sf.gridarta.action.SelectArchBelowAction; import net.sf.gridarta.action.ShortcutsAction; import net.sf.gridarta.action.ShowHelpAction; import net.sf.gridarta.action.TipOfTheDayAction; @@ -558,7 +559,7 @@ createAction("releaseDrag", "Map Cursor,Map/Selection", mapCursorActions); createAction("insertArch", "Map Cursor,Map", mapCursorActions); createAction("deleteArch", "Map Cursor,Map", mapCursorActions); - createAction("selectArchAbove", "Map Cursor,Selected Square View", mapCursorActions); + createAction("selectArchAbove", "Map Cursor,Selected Square View", new SelectArchBelowAction<G, A, R>(mapViewManager)); createAction("selectArchBelow", "Map Cursor,Selected Square View", new SelectArchAboveAction<G, A, R>(mapViewManager)); createAction("archAttributes", "Map", new ArchAttributesAction<G, A, R>(mapViewManager, gameObjectAttributesDialogFactory)); createAction("newScript", "Script", scriptEditControl); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2013-07-09 05:09:05
|
Revision: 9281 http://sourceforge.net/p/gridarta/code/9281 Author: akirschbaum Date: 2013-07-09 05:09:02 +0000 (Tue, 09 Jul 2013) Log Message: ----------- Extract SelectArchAboveAction from MapCursorActions. Modified Paths: -------------- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/mapcursor/MapCursorActions.java trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/GUIMainControl.java Added Paths: ----------- trunk/src/gridarta/src/main/java/net/sf/gridarta/action/AbstractMapCursorAction.java trunk/src/gridarta/src/main/java/net/sf/gridarta/action/SelectArchAboveAction.java Added: trunk/src/gridarta/src/main/java/net/sf/gridarta/action/AbstractMapCursorAction.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/action/AbstractMapCursorAction.java (rev 0) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/action/AbstractMapCursorAction.java 2013-07-09 05:09:02 UTC (rev 9281) @@ -0,0 +1,132 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2011 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.action; + +import java.awt.Point; +import net.sf.gridarta.gui.map.mapview.MapView; +import net.sf.gridarta.gui.map.mapview.MapViewManager; +import net.sf.gridarta.gui.map.mapview.MapViewManagerListener; +import net.sf.gridarta.model.archetype.Archetype; +import net.sf.gridarta.model.gameobject.GameObject; +import net.sf.gridarta.model.maparchobject.MapArchObject; +import net.sf.gridarta.model.mapcursor.MapCursor; +import net.sf.gridarta.model.mapcursor.MapCursorListener; +import net.sf.gridarta.model.mapmodel.MapSquare; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * Abstract base class for actions that have to track the current map cursor. + * @author Andreas Kirschbaum + */ +public abstract class AbstractMapCursorAction<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> { + + /** + * The active map view, or <code>null</code> if no map view exists. + */ + @Nullable + private MapView<G, A, R> currentMapView; + + /** + * The map view manager listener used to detect changed current maps. + */ + @NotNull + private final MapViewManagerListener<G, A, R> mapViewManagerListener = new MapViewManagerListener<G, A, R>() { + + @Override + public void activeMapViewChanged(@Nullable final MapView<G, A, R> mapView) { + currentMapView = mapView; + updateAction(); + } + + @Override + public void mapViewCreated(@NotNull final MapView<G, A, R> mapView) { + mapView.getMapCursor().addMapCursorListener(mapCursorListener); + } + + @Override + public void mapViewClosing(@NotNull final MapView<G, A, R> mapView) { + mapView.getMapCursor().removeMapCursorListener(mapCursorListener); + } + + }; + + /** + * The map cursor listener used to detect cursor state changes in {@link + * #currentMapView}. + */ + @NotNull + private final MapCursorListener<G, A, R> mapCursorListener = new MapCursorListener<G, A, R>() { + + @Override + public void mapCursorChangedPos(@Nullable final Point location) { + updateAction(); + } + + @Override + public void mapCursorChangedMode() { + updateAction(); + } + + @Override + public void mapCursorChangedGameObject(@Nullable final MapSquare<G, A, R> mapSquare, @Nullable final G gameObject) { + // ignore + } + + }; + + /** + * Creates a new instance. + * @param mapViewManager the map view manager + */ + protected AbstractMapCursorAction(@NotNull final MapViewManager<G, A, R> mapViewManager) { + mapViewManager.addMapViewManagerListener(mapViewManagerListener); + currentMapView = mapViewManager.getActiveMapView(); + } + + /** + * Return the map cursor of the current map view if it is active. + * @return the map cursor, or <code>null</code> if the cursor is not active, + * or if no map view exists + */ + @Nullable + protected MapCursor<G, A, R> getActiveMapCursor() { + final MapView<G, A, R> mapView = currentMapView; + return mapView == null ? null : getActiveMapCursor(mapView); + } + + /** + * Return the map cursor of a map view if it is active. + * @param mapView the map view + * @return the map cursor, or <code>null</code> if the cursor is not active, + * or if no map view exists + */ + @Nullable + private MapCursor<G, A, R> getActiveMapCursor(@NotNull final MapView<G, A, R> mapView) { + final MapCursor<G, A, R> mapCursor = mapView.getMapCursor(); + return mapCursor.isActive() ? mapCursor : null; + } + + /** + * Called whenever the current map cursor has changed. + */ + protected abstract void updateAction(); + +} Property changes on: trunk/src/gridarta/src/main/java/net/sf/gridarta/action/AbstractMapCursorAction.java ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +LF \ No newline at end of property Added: trunk/src/gridarta/src/main/java/net/sf/gridarta/action/SelectArchAboveAction.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/action/SelectArchAboveAction.java (rev 0) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/action/SelectArchAboveAction.java 2013-07-09 05:09:02 UTC (rev 9281) @@ -0,0 +1,92 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2011 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.action; + +import javax.swing.Action; +import net.sf.gridarta.gui.map.mapview.MapViewManager; +import net.sf.gridarta.model.archetype.Archetype; +import net.sf.gridarta.model.gameobject.GameObject; +import net.sf.gridarta.model.maparchobject.MapArchObject; +import net.sf.gridarta.model.mapcursor.MapCursor; +import net.sf.gridarta.utils.EditorAction; +import net.sf.japi.swing.action.ActionMethod; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * An {@link EditorAction} that selects the game object above the current game + * object. + * @author Andreas Kirschbaum + */ +public class SelectArchAboveAction<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> extends AbstractMapCursorAction<G, A, R> implements EditorAction { + + /** + * The {@link Action} associated with this editor action. Set to {@code + * null} if no action is associated. + */ + @Nullable + private Action action; + + /** + * Creates a new instance. + * @param mapViewManager the map view manager + */ + public SelectArchAboveAction(@NotNull final MapViewManager<G, A, R> mapViewManager) { + super(mapViewManager); + } + + /** + * {@inheritDoc} + */ + @Override + public void setAction(@NotNull final Action action, @NotNull final String name) { + this.action = action; + } + + /** + * Action method for "select arch above". + */ + @ActionMethod + public void selectArchAbove() { + doSelectArchAbove(true); + } + + /** + * Executes the "select arch above" action. + * @param performAction whether the action should be performed + * @return whether the action was or can be performed + */ + private boolean doSelectArchAbove(final boolean performAction) { + final MapCursor<G, A, R> mapCursor = getActiveMapCursor(); + return mapCursor != null && mapCursor.selectAbove(performAction); + } + + /** + * {@inheritDoc} + */ + @Override + protected void updateAction() { + if (action != null) { + //noinspection ConstantConditions + action.setEnabled(doSelectArchAbove(false)); + } + } + +} Property changes on: trunk/src/gridarta/src/main/java/net/sf/gridarta/action/SelectArchAboveAction.java ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +LF \ No newline at end of property Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/mapcursor/MapCursorActions.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/mapcursor/MapCursorActions.java 2013-07-09 04:54:17 UTC (rev 9280) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/mapcursor/MapCursorActions.java 2013-07-09 05:09:02 UTC (rev 9281) @@ -122,12 +122,6 @@ private Action aDeleteArch; /** - * Action for "select arch above". - */ - @Nullable - private Action aSelectArchAbove; - - /** * Action for "select arch below". */ @Nullable @@ -337,14 +331,6 @@ } /** - * Action method for "select arch above". - */ - @ActionMethod - public void selectArchAbove() { - doSelectArchAbove(true); - } - - /** * Action method for "select arch below". */ @ActionMethod @@ -417,10 +403,6 @@ //noinspection ConstantConditions aDeleteArch.setEnabled(doDeleteArch(false)); } - if (aSelectArchAbove != null) { - //noinspection ConstantConditions - aSelectArchAbove.setEnabled(doSelectArchAbove(false)); - } if (aSelectArchBelow != null) { //noinspection ConstantConditions aSelectArchBelow.setEnabled(doSelectArchBelow(false)); @@ -597,16 +579,6 @@ } /** - * Executes the "select arch above" action. - * @param performAction whether the action should be performed - * @return whether the action was or can be performed - */ - private boolean doSelectArchAbove(final boolean performAction) { - final MapCursor<G, A, R> mapCursor = getActiveMapCursor(); - return mapCursor != null && mapCursor.selectAbove(performAction); - } - - /** * Executes the "select arch below" action. * @param performAction whether the action should be performed * @return whether the action was or can be performed @@ -649,8 +621,6 @@ aInsertArch = action; } else if (name.equals("deleteArch")) { aDeleteArch = action; - } else if (name.equals("selectArchAbove")) { - aSelectArchAbove = action; } else if (name.equals("selectArchBelow")) { aSelectArchBelow = action; } else { Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/GUIMainControl.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/GUIMainControl.java 2013-07-09 04:54:17 UTC (rev 9280) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/GUIMainControl.java 2013-07-09 05:09:02 UTC (rev 9281) @@ -55,6 +55,7 @@ import net.sf.gridarta.action.MoveSquareUpAction; import net.sf.gridarta.action.OptionsAction; import net.sf.gridarta.action.ReloadFacesAction; +import net.sf.gridarta.action.SelectArchAboveAction; import net.sf.gridarta.action.ShortcutsAction; import net.sf.gridarta.action.ShowHelpAction; import net.sf.gridarta.action.TipOfTheDayAction; @@ -558,7 +559,7 @@ createAction("insertArch", "Map Cursor,Map", mapCursorActions); createAction("deleteArch", "Map Cursor,Map", mapCursorActions); createAction("selectArchAbove", "Map Cursor,Selected Square View", mapCursorActions); - createAction("selectArchBelow", "Map Cursor,Selected Square View", mapCursorActions); + createAction("selectArchBelow", "Map Cursor,Selected Square View", new SelectArchAboveAction<G, A, R>(mapViewManager)); createAction("archAttributes", "Map", new ArchAttributesAction<G, A, R>(mapViewManager, gameObjectAttributesDialogFactory)); createAction("newScript", "Script", scriptEditControl); createAction("editScript", "Script", fileControl); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2013-07-09 04:54:24
|
Revision: 9280 http://sourceforge.net/p/gridarta/code/9280 Author: akirschbaum Date: 2013-07-09 04:54:17 +0000 (Tue, 09 Jul 2013) Log Message: ----------- Simplify code. Modified Paths: -------------- trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/GUIMainControl.java Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/GUIMainControl.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/GUIMainControl.java 2013-07-09 04:49:05 UTC (rev 9279) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/GUIMainControl.java 2013-07-09 04:54:17 UTC (rev 9280) @@ -423,7 +423,6 @@ final MapMenu mapMenu = bookmarksMapMenuPreferences.getMapMenu(); @Nullable final MapMenuManager<G, A, R> bookmarksMapMenuManager = new MapMenuManager<G, A, R>(mapMenu, mapViewsManager, fileControl, mapImageCache); final EditorAction bookmarkActions = new BookmarkActions<G, A, R>(bookmarksMapMenuPreferences, mapMenu, mapViewManager, parent, mapImageCache); - final EditorAction serverActions = editorFactory.newServerActions(mapViewManager, fileControl, pathManager); final ExitConnectorActions<G, A, R> exitConnectorActions = new ExitConnectorActions<G, A, R>(exitConnectorModel, exitMatcher, archetypeSet, mapManager, fileControl, pathManager, insertionModeSet); // XXX: should be part of DefaultMainControl final EditorAction exitConnectorController = new ExitConnectorController<G, A, R>(exitConnectorActions, exitConnectorModel, mapViewManager); final Action displayGameObjectNamesAction = createAction("displayGameObjectNames", "Archetype Chooser", new DisplayGameObjectNamesAction<G, A, R>(archetypeChooserModel, displayModeArchetypeNames)); @@ -569,9 +568,7 @@ createAction("gameObjectTextEditor", "Tool", new MainViewActions<G, A, R>(mainView, gameObjectAttributesControl, gameObjectTab, textEditorTab)); createAction("manageBookmarks", "Bookmarks", bookmarkActions); createAction("addBookmark", "Bookmarks", bookmarkActions); - if (serverActions != null) { - createAction("openInClient", "Map", serverActions); - } + createActionOptional("openInClient", "Map", editorFactory.newServerActions(mapViewManager, fileControl, pathManager)); createAction("exitCopy", "Exit Connector", exitConnectorController); createAction("exitPaste", "Exit Connector", exitConnectorController); createAction("exitConnect", "Exit Connector", exitConnectorController); @@ -775,6 +772,19 @@ * Initializes a new action. * @param name the name of the action * @param category the category of the action + * @param editorAction the editor to initialize or {@code null} to do + * nothing + * @return the action + */ + @Nullable + private static Action createActionOptional(@NotNull final String name, @NotNull final String category, @Nullable final EditorAction editorAction) { + return editorAction == null ? null : ActionUtils.newAction(ACTION_BUILDER, category, editorAction, name); + } + + /** + * Initializes a new action. + * @param name the name of the action + * @param category the category of the action * @param editorAction the editor to initialize * @return the action */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2013-07-09 04:49:13
|
Revision: 9279 http://sourceforge.net/p/gridarta/code/9279 Author: akirschbaum Date: 2013-07-09 04:49:05 +0000 (Tue, 09 Jul 2013) Log Message: ----------- Extract ValidateMapAction from MainActions. Modified Paths: -------------- trunk/src/gridarta/src/main/java/net/sf/gridarta/mainactions/MainActions.java trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/GUIMainControl.java Added Paths: ----------- trunk/src/gridarta/src/main/java/net/sf/gridarta/action/ValidateMapAction.java Added: trunk/src/gridarta/src/main/java/net/sf/gridarta/action/ValidateMapAction.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/action/ValidateMapAction.java (rev 0) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/action/ValidateMapAction.java 2013-07-09 04:49:05 UTC (rev 9279) @@ -0,0 +1,149 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2011 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.action; + +import javax.swing.Action; +import net.sf.gridarta.model.archetype.Archetype; +import net.sf.gridarta.model.gameobject.GameObject; +import net.sf.gridarta.model.maparchobject.MapArchObject; +import net.sf.gridarta.model.mapcontrol.MapControl; +import net.sf.gridarta.model.mapmanager.MapManager; +import net.sf.gridarta.model.mapmanager.MapManagerListener; +import net.sf.gridarta.model.validation.DelegatingMapValidator; +import net.sf.gridarta.utils.EditorAction; +import net.sf.japi.swing.action.ActionMethod; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * An {@link EditorAction} that runs the map validator on the current map. + * @author Andreas Kirschbaum + */ +public class ValidateMapAction<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> implements EditorAction { + + /** + * The map validators. + */ + @NotNull + private final DelegatingMapValidator<G, A, R> validators; + + /** + * The {@link Action} associated with this editor action. Set to {@code + * null} if no action is associated. + */ + @Nullable + private Action action; + + /** + * The last known active map, or <code>null</code> if no map is active. + */ + @Nullable + private MapControl<G, A, R> currentMapControl; + + /** + * Creates a new {@link MapManagerListener} that refreshes the actions when + * the current map changes. + * @return the map manager listener + */ + @NotNull + private MapManagerListener<G, A, R> newMapManagerListener() { + final MapManagerListener<G, A, R> mapManagerListener = new MapManagerListener<G, A, R>() { + + @Override + public void currentMapChanged(@Nullable final MapControl<G, A, R> mapControl) { + currentMapControl = mapControl; + updateActions(); + } + + @Override + public void mapCreated(@NotNull final MapControl<G, A, R> mapControl, final boolean interactive) { + // ignore: a current map changed event will be generated + } + + @Override + public void mapClosing(@NotNull final MapControl<G, A, R> mapControl) { + // ignore: a current map changed event will be generated + } + + @Override + public void mapClosed(@NotNull final MapControl<G, A, R> mapControl) { + // ignore: a current map changed event will be generated + } + + }; + return mapManagerListener; + } + + /** + * Creates a new instance. + * @param validators the map validators + * @param mapManager the map manager instance + */ + public ValidateMapAction(@NotNull final DelegatingMapValidator<G, A, R> validators, @NotNull final MapManager<G, A, R> mapManager) { + this.validators = validators; + mapManager.addMapManagerListener(newMapManagerListener()); + currentMapControl = mapManager.getCurrentMap(); + } + + /** + * Runs the map validator on the current map. + */ + @ActionMethod + public void validateMap() { + doValidateMap(true); + } + + /** + * {@inheritDoc} + */ + @Override + public void setAction(@NotNull final Action action, @NotNull final String name) { + this.action = action; + } + + /** + * Executes the "validate map" action. + * @param performAction whether the action should be performed + * @return whether the action was or can be performed + */ + private boolean doValidateMap(final boolean performAction) { + final MapControl<G, A, R> mapControl = currentMapControl; + if (mapControl == null) { + return false; + } + + if (performAction) { + validators.validateAll(mapControl.getMapModel()); + } + + return true; + } + + /** + * Updates the state of the {@link #action}. + */ + private void updateActions() { + if (action != null) { + //noinspection ConstantConditions + action.setEnabled(doValidateMap(false)); + } + } + +} Property changes on: trunk/src/gridarta/src/main/java/net/sf/gridarta/action/ValidateMapAction.java ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +LF \ No newline at end of property Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/mainactions/MainActions.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/mainactions/MainActions.java 2013-07-08 21:25:33 UTC (rev 9278) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/mainactions/MainActions.java 2013-07-09 04:49:05 UTC (rev 9279) @@ -62,7 +62,6 @@ import net.sf.gridarta.model.mapviewsettings.MapViewSettings; import net.sf.gridarta.model.resource.AbstractResources; import net.sf.gridarta.model.settings.GlobalSettings; -import net.sf.gridarta.model.validation.DelegatingMapValidator; import net.sf.gridarta.model.validation.ErrorCollector; import net.sf.gridarta.utils.ActionBuilderUtils; import net.sf.gridarta.utils.EditorAction; @@ -122,12 +121,6 @@ private final GlobalSettings globalSettings; /** - * The map validators. - */ - @NotNull - private final DelegatingMapValidator<G, A, R> validators; - - /** * The map view settings instance. */ @NotNull @@ -338,12 +331,6 @@ private Action aCollectArches; /** - * Action called for "validate map". - */ - @Nullable - private Action aValidateMap; - - /** * The {@link RandomFillDialog} instance. */ @NotNull @@ -416,7 +403,6 @@ * @param replaceDialogManager the replace dialog manager to use * @param parent the parent component for dialog windows * @param globalSettings the global settings instance - * @param validators the map validators * @param mapViewSettings the map view settings instance * @param archetypeSet the archetype set * @param copyBuffer the copy buffer instance @@ -427,12 +413,11 @@ * @param insertionModeSet the insertion mode set to use * @param exiter the exiter instance */ - public MainActions(@NotNull final FindDialogManager<G, A, R> findDialogManager, @NotNull final ReplaceDialogManager<G, A, R> replaceDialogManager, @NotNull final JFrame parent, @NotNull final GlobalSettings globalSettings, @NotNull final DelegatingMapValidator<G, A, R> validators, @NotNull final MapViewSettings mapViewSettings, @NotNull final ArchetypeSet<G, A, R> archetypeSet, @NotNull final CopyBuffer<G, A, R> copyBuffer, @NotNull final ObjectChooser<G, A, R> objectChooser, @NotNull final MapManager<G, A, R> mapManager, @NotNull final MapViewManager<G, A, R> mapViewManager, @NotNull final AbstractResources<G, A, R> resources, @NotNull final InsertionModeSet<G, A, R> insertionModeSet, @NotNull final Exiter exiter) { + public MainActions(@NotNull final FindDialogManager<G, A, R> findDialogManager, @NotNull final ReplaceDialogManager<G, A, R> replaceDialogManager, @NotNull final JFrame parent, @NotNull final GlobalSettings globalSettings, @NotNull final MapViewSettings mapViewSettings, @NotNull final ArchetypeSet<G, A, R> archetypeSet, @NotNull final CopyBuffer<G, A, R> copyBuffer, @NotNull final ObjectChooser<G, A, R> objectChooser, @NotNull final MapManager<G, A, R> mapManager, @NotNull final MapViewManager<G, A, R> mapViewManager, @NotNull final AbstractResources<G, A, R> resources, @NotNull final InsertionModeSet<G, A, R> insertionModeSet, @NotNull final Exiter exiter) { this.findDialogManager = findDialogManager; this.replaceDialogManager = replaceDialogManager; this.parent = parent; this.globalSettings = globalSettings; - this.validators = validators; this.mapViewSettings = mapViewSettings; this.copyBuffer = copyBuffer; this.objectChooser = objectChooser; @@ -736,10 +721,6 @@ //noinspection ConstantConditions aCollectArches.setEnabled(doCollectArches(false)); } - if (aValidateMap != null) { - //noinspection ConstantConditions - aValidateMap.setEnabled(doValidateMap(false)); - } } /** @@ -984,14 +965,6 @@ } /** - * Invoked when "validate map" was selected. - */ - @ActionMethod - public void validateMap() { - doValidateMap(true); - } - - /** * Determine if the current map has a selection. * @return the map view if a selection exists, or <code>null</code> * otherwise @@ -1603,24 +1576,6 @@ } /** - * Executes the "validate map" action. - * @param performAction whether the action should be performed - * @return whether the action was or can be performed - */ - private boolean doValidateMap(final boolean performAction) { - final MapControl<G, A, R> mapControl = currentMapControl; - if (mapControl == null) { - return false; - } - - if (performAction) { - validators.validateAll(mapControl.getMapModel()); - } - - return true; - } - - /** * "Fill" was selected from the Edit menu. * @param mapView the map view to fill * @param insertionMode the insertion mode to use @@ -1709,8 +1664,6 @@ aShrinkSelection = action; } else if (name.equals("collectArches")) { aCollectArches = action; - } else if (name.equals("validateMap")) { - aValidateMap = action; } else { throw new IllegalArgumentException(); } Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/GUIMainControl.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/GUIMainControl.java 2013-07-08 21:25:33 UTC (rev 9278) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/GUIMainControl.java 2013-07-09 04:49:05 UTC (rev 9279) @@ -58,6 +58,7 @@ import net.sf.gridarta.action.ShortcutsAction; import net.sf.gridarta.action.ShowHelpAction; import net.sf.gridarta.action.TipOfTheDayAction; +import net.sf.gridarta.action.ValidateMapAction; import net.sf.gridarta.action.ZoomAction; import net.sf.gridarta.actions.ExitConnectorActions; import net.sf.gridarta.gui.autovalidator.AutoValidator; @@ -440,7 +441,7 @@ final PluginController<G, A, R> pluginControl = new PluginController<G, A, R>(filterControl, pluginParameters, parent, pluginParameterViewFactory, scriptsFile, pluginModel, pluginParameterFactory, pluginExecutor, systemIcons); //noinspection ResultOfObjectAllocationIgnored new FindArchetypesDialogManager<G, A, R>(parent, archetypeChooserControl, objectChooser, archetypeTypeSet); - final EditorAction mainActions = new MainActions<G, A, R>(findDialogManager, replaceDialogManager, mainViewFrame, globalSettings, validators, mapViewSettings, archetypeSet, copyBuffer, objectChooser, mapManager, mapViewManager, resources, insertionModeSet, exiter); + final EditorAction mainActions = new MainActions<G, A, R>(findDialogManager, replaceDialogManager, mainViewFrame, globalSettings, mapViewSettings, archetypeSet, copyBuffer, objectChooser, mapManager, mapViewManager, resources, insertionModeSet, exiter); final EditorAction mapCursorActions = new MapCursorActions<G, A, R>(objectChooser, mapViewManager); final Action moveSquareDownAction = createAction("moveSquareDown", "Selected Square View", new MoveSquareDownAction<G, A, R>(selectedSquareModel, mapManager)); final Action moveSquareUpAction = createAction("moveSquareUp", "Selected Square View", new MoveSquareUpAction<G, A, R>(selectedSquareModel, mapManager)); @@ -527,7 +528,7 @@ createAction("shrinkSelection", "Map/Selection", mainActions); createAction("collectArches", "Tool", mainActions); createAction("reloadFaces", "Image,Tool", new ReloadFacesAction<G, A, R>(archetypeSet, faceObjectProviders)); - createAction("validateMap", "Map,Tool", mainActions); + createAction("validateMap", "Map,Tool", new ValidateMapAction<G, A, R>(validators, mapManager)); final Action helpAction = createAction("showHelp", "Help", new ShowHelpAction(parent)); createAction("tipOfTheDay", "Help", new TipOfTheDayAction(parent)); createAction("newMap", "Map", newMapDialogFactory); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2013-07-08 21:25:40
|
Revision: 9278 http://sourceforge.net/p/gridarta/code/9278 Author: akirschbaum Date: 2013-07-08 21:25:33 +0000 (Mon, 08 Jul 2013) Log Message: ----------- Extract LightVisibleAction from MapActions. Modified Paths: -------------- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/map/mapactions/MapActions.java trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/GUIMainControl.java Added Paths: ----------- trunk/src/gridarta/src/main/java/net/sf/gridarta/action/LightVisibleAction.java Added: trunk/src/gridarta/src/main/java/net/sf/gridarta/action/LightVisibleAction.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/action/LightVisibleAction.java (rev 0) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/action/LightVisibleAction.java 2013-07-08 21:25:33 UTC (rev 9278) @@ -0,0 +1,155 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2011 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.action; + +import javax.swing.Action; +import net.sf.gridarta.model.mapviewsettings.MapViewSettings; +import net.sf.gridarta.model.mapviewsettings.MapViewSettingsListener; +import net.sf.gridarta.utils.EditorAction; +import net.sf.japi.swing.action.ActionMethod; +import net.sf.japi.swing.action.ToggleAction; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * An {@link EditorAction} that toggles whether map lighting is visible. + * @author Andreas Kirschbaum + */ +public class LightVisibleAction implements EditorAction { + + /** + * The {@link MapViewSettings} instance to use. + */ + @NotNull + private final MapViewSettings mapViewSettings; + + /** + * The {@link ToggleAction} associated with this editor action. Set to + * {@code null} if no action is associated. + */ + @Nullable + private ToggleAction action; + + /** + * The {@link MapViewSettingsListener} attached to {@link + * #mapViewSettings}. + */ + @NotNull + private final MapViewSettingsListener mapViewSettingsListener = new MapViewSettingsListener() { + + @Override + public void gridVisibleChanged(final boolean gridVisible) { + } + + @Override + public void lightVisibleChanged(final boolean lightVisible) { + updateAction(); + } + + @Override + public void smoothingChanged(final boolean smoothing) { + } + + @Override + public void doubleFacesChanged(final boolean doubleFaces) { + } + + @Override + public void alphaTypeChanged(final int alphaType) { + } + + @Override + public void editTypeChanged(final int editType) { + } + + @Override + public void autojoinChanged(final boolean autojoin) { + } + + }; + + /** + * Creates a new instance. + * @param mapViewSettings the map view settings instance to use + */ + public LightVisibleAction(@NotNull final MapViewSettings mapViewSettings) { + this.mapViewSettings = mapViewSettings; + mapViewSettings.addMapViewSettingsListener(mapViewSettingsListener); + } + + /** + * Action method for "light visible". + * @return <code>true</code> if the light is visible, or <code>false</code> + * if the light is invisible + */ + @ActionMethod + public boolean isLightVisible() { + return doLightVisible(false, false) && mapViewSettings.isLightVisible(); + } + + /** + * Sets whether the light of the current map should be visible. + * @param lightVisible new visibility of light in current map, + * <code>true</code> if the light should be visible, <code>false</code> if + * invisible + * @see #isLightVisible() + */ + @ActionMethod + public void setLightVisible(final boolean lightVisible) { + doLightVisible(true, lightVisible); + } + + /** + * {@inheritDoc} + */ + @Override + public void setAction(@NotNull final Action action, @NotNull final String name) { + this.action = (ToggleAction) action; + } + + /** + * Executes the "light visible" action. + * @param performAction whether the action should be performed + * @param lightVisible whether the light should be visible; ignored unless + * <code>performAction</code> is set + * @return whether the action was or can be performed + * @noinspection SameReturnValue + */ + private boolean doLightVisible(final boolean performAction, final boolean lightVisible) { + if (performAction) { + mapViewSettings.setLightVisible(lightVisible); + } + + return true; + } + + /** + * Updates the {@link #action}'s state. + */ + private void updateAction() { + if (action != null) { + //noinspection ConstantConditions + action.setEnabled(doLightVisible(false, false)); + //noinspection ConstantConditions + action.setSelected(isLightVisible()); + } + } + +} Property changes on: trunk/src/gridarta/src/main/java/net/sf/gridarta/action/LightVisibleAction.java ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +LF \ No newline at end of property Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/map/mapactions/MapActions.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/map/mapactions/MapActions.java 2013-07-08 20:39:00 UTC (rev 9277) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/map/mapactions/MapActions.java 2013-07-08 21:25:33 UTC (rev 9278) @@ -76,12 +76,6 @@ private ToggleAction aGridVisible; /** - * Action for "light visible". - */ - @Nullable - private ToggleAction aLightVisible; - - /** * Action for "smoothing". */ @Nullable @@ -428,28 +422,6 @@ } /** - * Action method for "light visible". - * @return <code>true</code> if the light is visible, or <code>false</code> - * if the light is invisible - */ - @ActionMethod - public boolean isLightVisible() { - return doLightVisible(false, false) && mapViewSettings.isLightVisible(); - } - - /** - * Sets whether the light of the current map should be visible. - * @param lightVisible new visibility of light in current map, - * <code>true</code> if the light should be visible, <code>false</code> if - * invisible - * @see #isLightVisible() - */ - @ActionMethod - public void setLightVisible(final boolean lightVisible) { - doLightVisible(true, lightVisible); - } - - /** * Action method for "smoothing". * @return <code>true</code> if smoothing is active, or <code>false</code> * if smoothing is disabled @@ -687,12 +659,6 @@ //noinspection ConstantConditions aGridVisible.setSelected(isGridVisible()); } - if (aLightVisible != null) { - //noinspection ConstantConditions - aLightVisible.setEnabled(doLightVisible(false, false)); - //noinspection ConstantConditions - aLightVisible.setSelected(isLightVisible()); - } if (aSmoothing != null) { //noinspection ConstantConditions aSmoothing.setEnabled(doSmoothing(false, false)); @@ -769,22 +735,6 @@ } /** - * Executes the "light visible" action. - * @param performAction whether the action should be performed - * @param lightVisible whether the light should be visible; ignored unless - * <code>performAction</code> is set - * @return whether the action was or can be performed - * @noinspection SameReturnValue - */ - private boolean doLightVisible(final boolean performAction, final boolean lightVisible) { - if (performAction) { - mapViewSettings.setLightVisible(lightVisible); - } - - return true; - } - - /** * Executes the "smoothing" action. * @param performAction whether the action should be performed * @param smoothing whether smoothing should be performed; ignored unless @@ -1052,8 +1002,6 @@ aDeleteUnknownObjects = action; } else if (name.equals("gridVisible")) { aGridVisible = (ToggleAction) action; - } else if (name.equals("lightVisible")) { - aLightVisible = (ToggleAction) action; } else if (name.equals("smoothing")) { aSmoothing = (ToggleAction) action; } else if (name.equals("doubleFaces")) { Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/GUIMainControl.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/GUIMainControl.java 2013-07-08 20:39:00 UTC (rev 9277) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/GUIMainControl.java 2013-07-08 21:25:33 UTC (rev 9278) @@ -44,6 +44,7 @@ import net.sf.gridarta.action.DisplayIconsOnlyAction; import net.sf.gridarta.action.ExitAction; import net.sf.gridarta.action.GcAction; +import net.sf.gridarta.action.LightVisibleAction; import net.sf.gridarta.action.MoveSquareBottomAction; import net.sf.gridarta.action.MoveSquareDownAction; import net.sf.gridarta.action.MoveSquareEnvAction; @@ -474,7 +475,7 @@ createAction("enterSouthWestMap", "Map Navigation", mapActions); createAction("enterNorthWestMap", "Map Navigation", mapActions); createToggleAction("gridVisible", "Map Navigation", mapActions); - createToggleAction("lightVisible", "Map Navigation", mapActions); + createToggleAction("lightVisible", "Map Navigation", new LightVisibleAction(mapViewSettings)); createToggleAction("smoothing", "Map Navigation", mapActions); createToggleAction("doubleFaces", "Map Navigation", mapActions); createToggleAction("tileShow", "Map Navigation", mapActions); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2013-07-08 20:39:04
|
Revision: 9277 http://sourceforge.net/p/gridarta/code/9277 Author: akirschbaum Date: 2013-07-08 20:39:00 +0000 (Mon, 08 Jul 2013) Log Message: ----------- Extract ReloadFacesAction from MainActions. Modified Paths: -------------- trunk/src/gridarta/src/main/java/net/sf/gridarta/mainactions/MainActions.java trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/GUIMainControl.java Added Paths: ----------- trunk/src/gridarta/src/main/java/net/sf/gridarta/action/ReloadFacesAction.java Added: trunk/src/gridarta/src/main/java/net/sf/gridarta/action/ReloadFacesAction.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/action/ReloadFacesAction.java (rev 0) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/action/ReloadFacesAction.java 2013-07-08 20:39:00 UTC (rev 9277) @@ -0,0 +1,112 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2011 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.action; + +import javax.swing.Action; +import net.sf.gridarta.model.archetype.Archetype; +import net.sf.gridarta.model.archetypeset.ArchetypeSet; +import net.sf.gridarta.model.face.FaceObjectProviders; +import net.sf.gridarta.model.gameobject.GameObject; +import net.sf.gridarta.model.maparchobject.MapArchObject; +import net.sf.gridarta.utils.EditorAction; +import net.sf.japi.swing.action.ActionMethod; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * An {@link EditorAction} that reloads all images from disk. + * @author Andreas Kirschbaum + */ +public class ReloadFacesAction<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> implements EditorAction { + + /** + * The archetype set instance. + */ + @NotNull + private final ArchetypeSet<G, A, R> archetypeSet; + + /** + * The {@link FaceObjectProviders} for looking up faces. + */ + @NotNull + private final FaceObjectProviders faceObjectProviders; + + /** + * The {@link Action} associated to this editor action. Set to {@code null} + * if none is associated. + */ + @Nullable + private Action action; + + /** + * Creates a new instance. + * @param archetypeSet the archetype set instance + * @param faceObjectProviders the face object providers for looking up + * faces + */ + public ReloadFacesAction(@NotNull final ArchetypeSet<G, A, R> archetypeSet, @NotNull final FaceObjectProviders faceObjectProviders) { + this.archetypeSet = archetypeSet; + this.faceObjectProviders = faceObjectProviders; + } + + /** + * Invoked when the user wants to reload the images. + */ + @ActionMethod + public void reloadFaces() { + doReloadFaces(true); + } + + /** + * {@inheritDoc} + */ + @Override + public void setAction(@NotNull final Action action, @NotNull final String name) { + this.action = action; + } + + /** + * Updates the enabled state of {@link #action}. + */ + private void updateAction() { + if (action != null) { + //noinspection ConstantConditions + action.setEnabled(doReloadFaces(false)); + } + } + + /** + * Executes the action. + * @param performAction whether the action should be performed + * @return whether the action was or can be performed + */ + private boolean doReloadFaces(final boolean performAction) { + if (archetypeSet.isLoadedFromArchive()) { + return false; + } + + if (performAction) { + faceObjectProviders.reloadAll(); + } + + return true; + } + +} Property changes on: trunk/src/gridarta/src/main/java/net/sf/gridarta/action/ReloadFacesAction.java ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +LF \ No newline at end of property Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/mainactions/MainActions.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/mainactions/MainActions.java 2013-07-08 20:29:23 UTC (rev 9276) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/mainactions/MainActions.java 2013-07-08 20:39:00 UTC (rev 9277) @@ -43,7 +43,6 @@ import net.sf.gridarta.model.archetype.ArchetypeSetListener; import net.sf.gridarta.model.archetypeset.ArchetypeSet; import net.sf.gridarta.model.direction.Direction; -import net.sf.gridarta.model.face.FaceObjectProviders; import net.sf.gridarta.model.floodfill.FillUtils; import net.sf.gridarta.model.gameobject.GameObject; import net.sf.gridarta.model.maparchobject.MapArchObject; @@ -135,12 +134,6 @@ private final MapViewSettings mapViewSettings; /** - * The archetype set instance. - */ - @NotNull - private final ArchetypeSet<G, A, R> archetypeSet; - - /** * The copy buffer instance. */ @NotNull @@ -159,12 +152,6 @@ private final AbstractResources<G, A, R> resources; /** - * The {@link FaceObjectProviders} for looking up faces. - */ - @NotNull - private final FaceObjectProviders faceObjectProviders; - - /** * The {@link InsertionModeSet} to use. */ @NotNull @@ -351,12 +338,6 @@ private Action aCollectArches; /** - * Action called for "reload faces". - */ - @Nullable - private Action aReloadFaces; - - /** * Action called for "validate map". */ @Nullable @@ -443,23 +424,19 @@ * @param mapManager the map manager instance * @param mapViewManager the map view manager instance * @param resources the resources to collect - * @param faceObjectProviders the face object providers for looking up - * faces * @param insertionModeSet the insertion mode set to use * @param exiter the exiter instance */ - public MainActions(@NotNull final FindDialogManager<G, A, R> findDialogManager, @NotNull final ReplaceDialogManager<G, A, R> replaceDialogManager, @NotNull final JFrame parent, @NotNull final GlobalSettings globalSettings, @NotNull final DelegatingMapValidator<G, A, R> validators, @NotNull final MapViewSettings mapViewSettings, @NotNull final ArchetypeSet<G, A, R> archetypeSet, @NotNull final CopyBuffer<G, A, R> copyBuffer, @NotNull final ObjectChooser<G, A, R> objectChooser, @NotNull final MapManager<G, A, R> mapManager, @NotNull final MapViewManager<G, A, R> mapViewManager, @NotNull final AbstractResources<G, A, R> resources, @NotNull final FaceObjectProviders faceObjectProviders, @NotNull final InsertionModeSet<G, A, R> insertionModeSet, @NotNull final Exiter exiter) { + public MainActions(@NotNull final FindDialogManager<G, A, R> findDialogManager, @NotNull final ReplaceDialogManager<G, A, R> replaceDialogManager, @NotNull final JFrame parent, @NotNull final GlobalSettings globalSettings, @NotNull final DelegatingMapValidator<G, A, R> validators, @NotNull final MapViewSettings mapViewSettings, @NotNull final ArchetypeSet<G, A, R> archetypeSet, @NotNull final CopyBuffer<G, A, R> copyBuffer, @NotNull final ObjectChooser<G, A, R> objectChooser, @NotNull final MapManager<G, A, R> mapManager, @NotNull final MapViewManager<G, A, R> mapViewManager, @NotNull final AbstractResources<G, A, R> resources, @NotNull final InsertionModeSet<G, A, R> insertionModeSet, @NotNull final Exiter exiter) { this.findDialogManager = findDialogManager; this.replaceDialogManager = replaceDialogManager; this.parent = parent; this.globalSettings = globalSettings; this.validators = validators; this.mapViewSettings = mapViewSettings; - this.archetypeSet = archetypeSet; this.copyBuffer = copyBuffer; this.objectChooser = objectChooser; this.resources = resources; - this.faceObjectProviders = faceObjectProviders; this.insertionModeSet = insertionModeSet; mapManager.addMapManagerListener(newMapManagerListener()); @@ -759,10 +736,6 @@ //noinspection ConstantConditions aCollectArches.setEnabled(doCollectArches(false)); } - if (aReloadFaces != null) { - //noinspection ConstantConditions - aReloadFaces.setEnabled(doReloadFaces(false)); - } if (aValidateMap != null) { //noinspection ConstantConditions aValidateMap.setEnabled(doValidateMap(false)); @@ -1011,14 +984,6 @@ } /** - * Invoked when the user wants to reload the images. - */ - @ActionMethod - public void reloadFaces() { - doReloadFaces(true); - } - - /** * Invoked when "validate map" was selected. */ @ActionMethod @@ -1638,23 +1603,6 @@ } /** - * Executes the "reload faces" action. - * @param performAction whether the action should be performed - * @return whether the action was or can be performed - */ - private boolean doReloadFaces(final boolean performAction) { - if (archetypeSet.isLoadedFromArchive()) { - return false; - } - - if (performAction) { - faceObjectProviders.reloadAll(); - } - - return true; - } - - /** * Executes the "validate map" action. * @param performAction whether the action should be performed * @return whether the action was or can be performed @@ -1761,8 +1709,6 @@ aShrinkSelection = action; } else if (name.equals("collectArches")) { aCollectArches = action; - } else if (name.equals("reloadFaces")) { - aReloadFaces = action; } else if (name.equals("validateMap")) { aValidateMap = action; } else { Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/GUIMainControl.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/GUIMainControl.java 2013-07-08 20:29:23 UTC (rev 9276) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/GUIMainControl.java 2013-07-08 20:39:00 UTC (rev 9277) @@ -53,6 +53,7 @@ import net.sf.gridarta.action.MoveSquareTopAction; import net.sf.gridarta.action.MoveSquareUpAction; import net.sf.gridarta.action.OptionsAction; +import net.sf.gridarta.action.ReloadFacesAction; import net.sf.gridarta.action.ShortcutsAction; import net.sf.gridarta.action.ShowHelpAction; import net.sf.gridarta.action.TipOfTheDayAction; @@ -438,7 +439,7 @@ final PluginController<G, A, R> pluginControl = new PluginController<G, A, R>(filterControl, pluginParameters, parent, pluginParameterViewFactory, scriptsFile, pluginModel, pluginParameterFactory, pluginExecutor, systemIcons); //noinspection ResultOfObjectAllocationIgnored new FindArchetypesDialogManager<G, A, R>(parent, archetypeChooserControl, objectChooser, archetypeTypeSet); - final EditorAction mainActions = new MainActions<G, A, R>(findDialogManager, replaceDialogManager, mainViewFrame, globalSettings, validators, mapViewSettings, archetypeSet, copyBuffer, objectChooser, mapManager, mapViewManager, resources, faceObjectProviders, insertionModeSet, exiter); + final EditorAction mainActions = new MainActions<G, A, R>(findDialogManager, replaceDialogManager, mainViewFrame, globalSettings, validators, mapViewSettings, archetypeSet, copyBuffer, objectChooser, mapManager, mapViewManager, resources, insertionModeSet, exiter); final EditorAction mapCursorActions = new MapCursorActions<G, A, R>(objectChooser, mapViewManager); final Action moveSquareDownAction = createAction("moveSquareDown", "Selected Square View", new MoveSquareDownAction<G, A, R>(selectedSquareModel, mapManager)); final Action moveSquareUpAction = createAction("moveSquareUp", "Selected Square View", new MoveSquareUpAction<G, A, R>(selectedSquareModel, mapManager)); @@ -524,7 +525,7 @@ createAction("growSelection", "Map/Selection", mainActions); createAction("shrinkSelection", "Map/Selection", mainActions); createAction("collectArches", "Tool", mainActions); - createAction("reloadFaces", "Image,Tool", mainActions); + createAction("reloadFaces", "Image,Tool", new ReloadFacesAction<G, A, R>(archetypeSet, faceObjectProviders)); createAction("validateMap", "Map,Tool", mainActions); final Action helpAction = createAction("showHelp", "Help", new ShowHelpAction(parent)); createAction("tipOfTheDay", "Help", new TipOfTheDayAction(parent)); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2013-07-08 20:29:33
|
Revision: 9276 http://sourceforge.net/p/gridarta/code/9276 Author: akirschbaum Date: 2013-07-08 20:29:23 +0000 (Mon, 08 Jul 2013) Log Message: ----------- Weaken types. Modified Paths: -------------- trunk/src/gridarta/src/main/java/net/sf/gridarta/action/ControlClientAction.java trunk/src/gridarta/src/main/java/net/sf/gridarta/action/ControlServerAction.java trunk/src/utils/src/main/java/net/sf/gridarta/utils/ProcessRunner.java Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/action/ControlClientAction.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/action/ControlClientAction.java 2013-07-08 20:26:31 UTC (rev 9275) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/action/ControlClientAction.java 2013-07-08 20:29:23 UTC (rev 9276) @@ -19,8 +19,8 @@ package net.sf.gridarta.action; +import java.awt.Frame; import javax.swing.Action; -import javax.swing.JFrame; import net.sf.gridarta.gui.dialog.prefs.AppPreferencesModel; import net.sf.gridarta.utils.EditorAction; import net.sf.gridarta.utils.ProcessRunner; @@ -37,7 +37,7 @@ private final AppPreferencesModel appPreferencesModel; @NotNull - private final JFrame parent; + private final Frame parent; /** * The {@link ProcessRunner} instance that controls the client. Set to @@ -49,7 +49,7 @@ /** * Creates a new instance. */ - public ControlClientAction(@NotNull final AppPreferencesModel appPreferencesModel, @NotNull final JFrame parent) { + public ControlClientAction(@NotNull final AppPreferencesModel appPreferencesModel, @NotNull final Frame parent) { this.appPreferencesModel = appPreferencesModel; this.parent = parent; } Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/action/ControlServerAction.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/action/ControlServerAction.java 2013-07-08 20:26:31 UTC (rev 9275) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/action/ControlServerAction.java 2013-07-08 20:29:23 UTC (rev 9276) @@ -19,8 +19,8 @@ package net.sf.gridarta.action; +import java.awt.Frame; import javax.swing.Action; -import javax.swing.JFrame; import javax.swing.JOptionPane; import net.sf.gridarta.gui.dialog.prefs.AppPreferencesModel; import net.sf.gridarta.utils.EditorAction; @@ -45,7 +45,7 @@ private final AppPreferencesModel appPreferencesModel; @NotNull - private final JFrame parent; + private final Frame parent; /** * The {@link ProcessRunner} instance that controls the server. Set to @@ -57,7 +57,7 @@ /** * Creates a new instance. */ - public ControlServerAction(@NotNull final AppPreferencesModel appPreferencesModel, @NotNull final JFrame parent) { + public ControlServerAction(@NotNull final AppPreferencesModel appPreferencesModel, @NotNull final Frame parent) { this.appPreferencesModel = appPreferencesModel; this.parent = parent; } Modified: trunk/src/utils/src/main/java/net/sf/gridarta/utils/ProcessRunner.java =================================================================== --- trunk/src/utils/src/main/java/net/sf/gridarta/utils/ProcessRunner.java 2013-07-08 20:26:31 UTC (rev 9275) +++ trunk/src/utils/src/main/java/net/sf/gridarta/utils/ProcessRunner.java 2013-07-08 20:29:23 UTC (rev 9276) @@ -23,6 +23,7 @@ import java.awt.Color; import java.awt.Component; import java.awt.Font; +import java.awt.Frame; import java.awt.Window; import java.io.File; import java.io.IOException; @@ -31,7 +32,6 @@ import java.util.concurrent.ConcurrentLinkedQueue; import javax.swing.Action; import javax.swing.JDialog; -import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JTextArea; @@ -186,7 +186,7 @@ * Show a dialog if not already visible. * @param parent owner frame to display on */ - public void showDialog(@NotNull final JFrame parent) { + public void showDialog(@NotNull final Frame parent) { if (dialog == null || dialog.getOwner() != parent) { createDialog(parent); } @@ -200,7 +200,7 @@ * Create the dialog. * @param parent owner frame to display on */ - private void createDialog(@NotNull final JFrame parent) { + private void createDialog(@NotNull final Frame parent) { dialog = new JDialog(parent, ActionBuilderUtils.getString(ACTION_BUILDER, key + ".title")); dialog.add(this); assert dialog != null; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2013-07-08 20:26:34
|
Revision: 9275 http://sourceforge.net/p/gridarta/code/9275 Author: akirschbaum Date: 2013-07-08 20:26:31 +0000 (Mon, 08 Jul 2013) Log Message: ----------- Extract ArchAttributesAction from MapCursorActions. Modified Paths: -------------- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/mapcursor/MapCursorActions.java trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/GUIMainControl.java Added Paths: ----------- trunk/src/gridarta/src/main/java/net/sf/gridarta/action/ArchAttributesAction.java Added: trunk/src/gridarta/src/main/java/net/sf/gridarta/action/ArchAttributesAction.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/action/ArchAttributesAction.java (rev 0) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/action/ArchAttributesAction.java 2013-07-08 20:26:31 UTC (rev 9275) @@ -0,0 +1,191 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2011 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.action; + +import java.awt.Point; +import javax.swing.Action; +import net.sf.gridarta.gui.dialog.gameobjectattributes.GameObjectAttributesDialogFactory; +import net.sf.gridarta.gui.map.mapview.MapView; +import net.sf.gridarta.gui.map.mapview.MapViewManager; +import net.sf.gridarta.gui.map.mapview.MapViewManagerListener; +import net.sf.gridarta.model.archetype.Archetype; +import net.sf.gridarta.model.gameobject.GameObject; +import net.sf.gridarta.model.maparchobject.MapArchObject; +import net.sf.gridarta.model.mapcursor.MapCursor; +import net.sf.gridarta.model.mapcursor.MapCursorListener; +import net.sf.gridarta.model.mapmodel.MapSquare; +import net.sf.gridarta.utils.EditorAction; +import net.sf.japi.swing.action.ActionMethod; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * An {@link EditorAction} that opens the game object attributes dialog for the + * currently selected game object. + * @author Andreas Kirschbaum + */ +public class ArchAttributesAction<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> implements EditorAction { + + /** + * The factory for creating game object attributes dialog instances. + */ + @NotNull + private final GameObjectAttributesDialogFactory<G, A, R> gameObjectAttributesDialogFactory; + + /** + * The active map view, or <code>null</code> if no map view exists. + */ + @Nullable + private MapView<G, A, R> currentMapView; + + /** + * The associated {@link Action}. Set to {@code null} if none is + * associated. + */ + @Nullable + private Action action; + + /** + * The map view manager listener used to detect changed current maps. + */ + @NotNull + private final MapViewManagerListener<G, A, R> mapViewManagerListener = new MapViewManagerListener<G, A, R>() { + + @Override + public void activeMapViewChanged(@Nullable final MapView<G, A, R> mapView) { + currentMapView = mapView; + updateActions(); + } + + @Override + public void mapViewCreated(@NotNull final MapView<G, A, R> mapView) { + mapView.getMapCursor().addMapCursorListener(mapCursorListener); + } + + @Override + public void mapViewClosing(@NotNull final MapView<G, A, R> mapView) { + mapView.getMapCursor().removeMapCursorListener(mapCursorListener); + } + + }; + + /** + * The map cursor listener used to detect cursor state changes in {@link + * #currentMapView}. + */ + @NotNull + private final MapCursorListener<G, A, R> mapCursorListener = new MapCursorListener<G, A, R>() { + + @Override + public void mapCursorChangedPos(@Nullable final Point location) { + updateActions(); + } + + @Override + public void mapCursorChangedMode() { + updateActions(); + } + + @Override + public void mapCursorChangedGameObject(@Nullable final MapSquare<G, A, R> mapSquare, @Nullable final G gameObject) { + // ignore + } + + }; + + /** + * Creates a new instance. + * @param mapViewManager the map view manager + * @param gameObjectAttributesDialogFactory the factory for creating game + * object attributes dialog instances + */ + public ArchAttributesAction(@NotNull final MapViewManager<G, A, R> mapViewManager, @NotNull final GameObjectAttributesDialogFactory<G, A, R> gameObjectAttributesDialogFactory) { + this.gameObjectAttributesDialogFactory = gameObjectAttributesDialogFactory; + mapViewManager.addMapViewManagerListener(mapViewManagerListener); + currentMapView = mapViewManager.getActiveMapView(); + updateActions(); + } + + /** + * Action method for "arch attributes". + */ + @ActionMethod + public void archAttributes() { + doArchAttributes(true); + } + + /** + * {@inheritDoc} + */ + @Override + public void setAction(@NotNull final Action action, @NotNull final String name) { + this.action = action; + } + + /** + * Updates the enabled state of {@link #action}. + */ + private void updateActions() { + if (action != null) { + //noinspection ConstantConditions + action.setEnabled(doArchAttributes(false)); + } + } + + /** + * Executes the "arch attributes" action. + * @param performAction whether the action should be performed + * @return whether the action was or can be performed + */ + private boolean doArchAttributes(final boolean performAction) { + if (currentMapView == null) { + return false; + } + + final MapCursor<G, A, R> mapCursor = getActiveMapCursor(currentMapView); + if (mapCursor == null) { + return false; + } + + final G gameObject = mapCursor.getGameObject(); + if (gameObject == null) { + return false; + } + + if (performAction) { + gameObjectAttributesDialogFactory.showAttributeDialog(gameObject); + } + + return true; + } + + /** + * Return the map cursor of a map view if it is active. + * @param mapView the map view + * @return the map cursor, or <code>null</code> if the cursor is not active, + * or if no map view exists + */ + @Nullable + private MapCursor<G, A, R> getActiveMapCursor(@NotNull final MapView<G, A, R> mapView) { + final MapCursor<G, A, R> mapCursor = mapView.getMapCursor(); + return mapCursor.isActive() ? mapCursor : null; + } + +} Property changes on: trunk/src/gridarta/src/main/java/net/sf/gridarta/action/ArchAttributesAction.java ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +LF \ No newline at end of property Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/mapcursor/MapCursorActions.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/mapcursor/MapCursorActions.java 2013-07-08 20:04:27 UTC (rev 9274) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/mapcursor/MapCursorActions.java 2013-07-08 20:26:31 UTC (rev 9275) @@ -21,7 +21,6 @@ import java.awt.Point; import javax.swing.Action; -import net.sf.gridarta.gui.dialog.gameobjectattributes.GameObjectAttributesDialogFactory; import net.sf.gridarta.gui.dialog.golocation.GoLocationDialog; import net.sf.gridarta.gui.dialog.golocation.GoLocationDialogManager; import net.sf.gridarta.gui.map.AbstractPerMapDialogManager; @@ -135,19 +134,6 @@ private Action aSelectArchBelow; /** - * Action for "arch attributes". - */ - @Nullable - private Action aArchAttributes; - - /** - * The factory for creating game object attributes dialog instances. - */ - @NotNull - - private final GameObjectAttributesDialogFactory<G, A, R> gameObjectAttributesDialogFactory; - - /** * The {@link GoLocationDialogManager} to track go location dialog * instances. */ @@ -211,13 +197,10 @@ /** * Create a new instance. * @param objectChooser the object chooser - * @param gameObjectAttributesDialogFactory the factory for creating game - * object attributes dialog instances * @param mapViewManager the map view manager */ - public MapCursorActions(@NotNull final ObjectChooser<G, A, R> objectChooser, @NotNull final GameObjectAttributesDialogFactory<G, A, R> gameObjectAttributesDialogFactory, @NotNull final MapViewManager<G, A, R> mapViewManager) { + public MapCursorActions(@NotNull final ObjectChooser<G, A, R> objectChooser, @NotNull final MapViewManager<G, A, R> mapViewManager) { this.objectChooser = objectChooser; - this.gameObjectAttributesDialogFactory = gameObjectAttributesDialogFactory; goLocationDialogManager = new GoLocationDialogManager<G, A, R>(mapViewManager); aMoveCursor = new Action[directions.length]; mapViewManager.addMapViewManagerListener(mapViewManagerListener); @@ -370,14 +353,6 @@ } /** - * Action method for "arch attributes". - */ - @ActionMethod - public void archAttributes() { - doArchAttributes(true); - } - - /** * Return the map cursor of the current map view if it is active. * @return the map cursor, or <code>null</code> if the cursor is not active, * or if no map view exists @@ -450,10 +425,6 @@ //noinspection ConstantConditions aSelectArchBelow.setEnabled(doSelectArchBelow(false)); } - if (aArchAttributes != null) { - //noinspection ConstantConditions - aArchAttributes.setEnabled(doArchAttributes(false)); - } } private void selectSquare(@NotNull final MapCursor<G, A, R> mapCursor, final SelectionMode mode) { @@ -646,29 +617,6 @@ } /** - * Executes the "arch attributes" action. - * @param performAction whether the action should be performed - * @return whether the action was or can be performed - */ - private boolean doArchAttributes(final boolean performAction) { - final MapCursor<G, A, R> mapCursor = getActiveMapCursor(); - if (mapCursor == null) { - return false; - } - - final G gameObject = mapCursor.getGameObject(); - if (gameObject == null) { - return false; - } - - if (performAction) { - gameObjectAttributesDialogFactory.showAttributeDialog(gameObject); - } - - return true; - } - - /** * {@inheritDoc} */ @Override @@ -705,8 +653,6 @@ aSelectArchAbove = action; } else if (name.equals("selectArchBelow")) { aSelectArchBelow = action; - } else if (name.equals("archAttributes")) { - aArchAttributes = action; } else { throw new IllegalArgumentException(); } Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/GUIMainControl.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/GUIMainControl.java 2013-07-08 20:04:27 UTC (rev 9274) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/GUIMainControl.java 2013-07-08 20:26:31 UTC (rev 9275) @@ -34,6 +34,7 @@ import javax.swing.JMenuBar; import javax.swing.filechooser.FileFilter; import net.sf.gridarta.MainControl; +import net.sf.gridarta.action.ArchAttributesAction; import net.sf.gridarta.action.CleanCompletelyBlockedSquaresAction; import net.sf.gridarta.action.CollectSpellsAction; import net.sf.gridarta.action.ControlClientAction; @@ -438,7 +439,7 @@ //noinspection ResultOfObjectAllocationIgnored new FindArchetypesDialogManager<G, A, R>(parent, archetypeChooserControl, objectChooser, archetypeTypeSet); final EditorAction mainActions = new MainActions<G, A, R>(findDialogManager, replaceDialogManager, mainViewFrame, globalSettings, validators, mapViewSettings, archetypeSet, copyBuffer, objectChooser, mapManager, mapViewManager, resources, faceObjectProviders, insertionModeSet, exiter); - final EditorAction mapCursorActions = new MapCursorActions<G, A, R>(objectChooser, gameObjectAttributesDialogFactory, mapViewManager); + final EditorAction mapCursorActions = new MapCursorActions<G, A, R>(objectChooser, mapViewManager); final Action moveSquareDownAction = createAction("moveSquareDown", "Selected Square View", new MoveSquareDownAction<G, A, R>(selectedSquareModel, mapManager)); final Action moveSquareUpAction = createAction("moveSquareUp", "Selected Square View", new MoveSquareUpAction<G, A, R>(selectedSquareModel, mapManager)); final Action moveSquareBottomAction = createAction("moveSquareBottom", "Selected Square View", new MoveSquareBottomAction<G, A, R>(selectedSquareModel, mapManager)); @@ -556,7 +557,7 @@ createAction("deleteArch", "Map Cursor,Map", mapCursorActions); createAction("selectArchAbove", "Map Cursor,Selected Square View", mapCursorActions); createAction("selectArchBelow", "Map Cursor,Selected Square View", mapCursorActions); - createAction("archAttributes", "Map", mapCursorActions); + createAction("archAttributes", "Map", new ArchAttributesAction<G, A, R>(mapViewManager, gameObjectAttributesDialogFactory)); createAction("newScript", "Script", scriptEditControl); createAction("editScript", "Script", fileControl); createAction("openFile", "Map", fileControl); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2013-07-08 20:04:31
|
Revision: 9274 http://sourceforge.net/p/gridarta/code/9274 Author: akirschbaum Date: 2013-07-08 20:04:27 +0000 (Mon, 08 Jul 2013) Log Message: ----------- Fix Javadoc issue. Modified Paths: -------------- trunk/src/gridarta/src/main/java/net/sf/gridarta/action/ControlClientAction.java Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/action/ControlClientAction.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/action/ControlClientAction.java 2013-07-08 19:59:22 UTC (rev 9273) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/action/ControlClientAction.java 2013-07-08 20:04:27 UTC (rev 9274) @@ -47,7 +47,7 @@ private ProcessRunner controlClient; /** - * {@inheritDoc} + * Creates a new instance. */ public ControlClientAction(@NotNull final AppPreferencesModel appPreferencesModel, @NotNull final JFrame parent) { this.appPreferencesModel = appPreferencesModel; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2013-07-08 19:59:25
|
Revision: 9273 http://sourceforge.net/p/gridarta/code/9273 Author: akirschbaum Date: 2013-07-08 19:59:22 +0000 (Mon, 08 Jul 2013) Log Message: ----------- Reorder code. Modified Paths: -------------- trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/GUIMainControl.java Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/GUIMainControl.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/GUIMainControl.java 2013-07-08 19:53:16 UTC (rev 9272) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/GUIMainControl.java 2013-07-08 19:59:22 UTC (rev 9273) @@ -428,6 +428,9 @@ final ArchetypeChooserView<G, A, R> archetypeChooserView = new ArchetypeChooserView<G, A, R>(createDirectionPane, archetypeChooserModel, faceObjectProviders, displayGameObjectNamesAction, displayArchetypeNamesAction, displayIconsOnlyAction, displayModeGameObjectNames, displayModeArchetypeNames, displayModeIconsOnly); final ArchetypeChooserControl<G, A, R> archetypeChooserControl = new ArchetypeChooserControl<G, A, R>(archetypeChooserModel, archetypeChooserView, createDirectionPane, faceObjectProviders); final DefaultObjectChooser<G, A, R> objectChooser = new DefaultObjectChooser<G, A, R>(archetypeChooserControl, pickmapChooserControl, archetypeChooserModel, pickmapChooserModel, archetypeTypeSet); + final ToolPalette<G, A, R> toolPalette = new ToolPalette<G, A, R>(mapViewSettings, selectedSquareModel, objectChooser, pickmapSettings, floorMatcher, wallMatcher, monsterMatcher, insertionModeSet); + final GameObjectAttributesControl<G, A, R> gameObjectAttributesControl = new GameObjectAttributesControl<G, A, R>(gameObjectAttributesModel, gameObjectAttributesDialogFactory, objectChooser, mapManager, selectedSquareModel, gameObjectFactory); + final GameObjectTab<G, A, R> gameObjectTab = new GameObjectTab<G, A, R>("gameObject", gameObjectAttributesControl, Location.BOTTOM, false, 0, true); newMapDialogFactory.setObjectChooser(objectChooser); final ReplaceDialogManager<G, A, R> replaceDialogManager = new ReplaceDialogManager<G, A, R>(parent, copyBuffer, objectChooser, mapViewManager, faceObjectProviders, insertionModeSet); final PluginParameterViewFactory<G, A, R> pluginParameterViewFactory = new PluginParameterViewFactory<G, A, R>(archetypeSet, gameObjectAttributesModel, objectChooser, mapManager, faceObjectProviders); @@ -444,10 +447,6 @@ final Action moveSquareTopAction = createAction("moveSquareTop", "Selected Square View", new MoveSquareTopAction<G, A, R>(selectedSquareModel, mapManager)); createAction("moveSquarePrev", "Selected Square View", new MoveSquarePrevAction<G, A, R>(selectedSquareModel, mapManager)); createAction("moveSquareNext", "Selected Square View", new MoveSquareNextAction<G, A, R>(selectedSquareModel, mapManager)); - final SelectedSquareView<G, A, R> selectedSquareView = new SelectedSquareView<G, A, R>(selectedSquareModel, gameObjectAttributesDialogFactory, objectChooser, mapViewManager, mapViewSettings, compassIcon, faceObjectProviders, unknownSquareIcon, moveSquareUpAction, moveSquareDownAction, moveSquareTopAction, moveSquareBottomAction, moveSquareEnvAction, moveSquareInvAction); - final GameObjectAttributesControl<G, A, R> gameObjectAttributesControl = new GameObjectAttributesControl<G, A, R>(gameObjectAttributesModel, gameObjectAttributesDialogFactory, objectChooser, mapManager, selectedSquareModel, gameObjectFactory); - final ToolPalette<G, A, R> toolPalette = new ToolPalette<G, A, R>(mapViewSettings, selectedSquareModel, objectChooser, pickmapSettings, floorMatcher, wallMatcher, monsterMatcher, insertionModeSet); - final GameObjectTab<G, A, R> gameObjectTab = new GameObjectTab<G, A, R>("gameObject", gameObjectAttributesControl, Location.BOTTOM, false, 0, true); createAction("prevWindow", "Map,Window", mapDesktop); createAction("nextWindow", "Map,Window", mapDesktop); createAction("addNewPickmap", "Pickmap", pickmapChooserControl); @@ -578,7 +577,7 @@ mainViewFrame.add(new MainToolbar(globalSettings).getComponent(), BorderLayout.NORTH); mainViewFrame.add(statusBar, BorderLayout.SOUTH); mainView.addTab(gameObjectTab); - mainView.addTab(new Tab("selectedSquare", selectedSquareView, Location.RIGHT, false, 1, true)); + mainView.addTab(new Tab("selectedSquare", new SelectedSquareView<G, A, R>(selectedSquareModel, gameObjectAttributesDialogFactory, objectChooser, mapViewManager, mapViewSettings, compassIcon, faceObjectProviders, unknownSquareIcon, moveSquareUpAction, moveSquareDownAction, moveSquareTopAction, moveSquareBottomAction, moveSquareEnvAction, moveSquareInvAction), Location.RIGHT, false, 1, true)); mainView.addTab(new Tab("tools", toolPalette, Location.LEFT, false, 2, false)); mainView.addTab(new Tab("objects", objectChooser, Location.LEFT, false, 3, true)); final JMenu windowMenu = MenuUtils.getMenu(menuBar, "window"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2013-07-08 19:53:23
|
Revision: 9272 http://sourceforge.net/p/gridarta/code/9272 Author: akirschbaum Date: 2013-07-08 19:53:16 +0000 (Mon, 08 Jul 2013) Log Message: ----------- Remove SelectedSquareView.setSelectedGameObject(). Modified Paths: -------------- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/panel/gameobjectattributes/GameObjectAttributesControl.java trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/panel/selectedsquare/SelectedSquareView.java trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/panel/tools/InsertionTool.java trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/panel/tools/ToolPalette.java trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/panel/tools/ToolSelector.java trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/GUIMainControl.java Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/panel/gameobjectattributes/GameObjectAttributesControl.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/panel/gameobjectattributes/GameObjectAttributesControl.java 2013-07-08 19:30:13 UTC (rev 9271) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/panel/gameobjectattributes/GameObjectAttributesControl.java 2013-07-08 19:53:16 UTC (rev 9272) @@ -38,7 +38,6 @@ import net.sf.gridarta.gui.panel.objectchooser.ObjectChooser; import net.sf.gridarta.gui.panel.selectedsquare.SelectedSquareModel; import net.sf.gridarta.gui.panel.selectedsquare.SelectedSquareModelListener; -import net.sf.gridarta.gui.panel.selectedsquare.SelectedSquareView; import net.sf.gridarta.gui.utils.Severity; import net.sf.gridarta.model.archetype.Archetype; import net.sf.gridarta.model.baseobject.BaseObject; @@ -93,10 +92,10 @@ private final ObjectChooser<G, A, R> objectChooser; /** - * The {@link SelectedSquareView} to update. + * The {@link SelectedSquareModel} to update. */ @NotNull - private final SelectedSquareView<G, A, R> selectedSquareView; + private final SelectedSquareModel<G, A, R> selectedSquareModel; /** * The {@link GameObjectFactory} for creating new {@link GameObject @@ -370,16 +369,15 @@ * @param objectChooser the object chooser instance * @param mapManager the map manager instance * @param selectedSquareModel the selected square model instance - * @param selectedSquareView the selected square view to update * @param gameObjectFactory the game object factory for creating new game * objects */ - public GameObjectAttributesControl(@NotNull final GameObjectAttributesModel<G, A, R> gameObjectAttributesModel, @NotNull final GameObjectAttributesDialogFactory<G, A, R> gameObjectAttributesDialogFactory, @NotNull final ObjectChooser<G, A, R> objectChooser, @NotNull final MapManager<G, A, R> mapManager, @NotNull final SelectedSquareModel<G, A, R> selectedSquareModel, @NotNull final SelectedSquareView<G, A, R> selectedSquareView, @NotNull final GameObjectFactory<G, A, R> gameObjectFactory) { + public GameObjectAttributesControl(@NotNull final GameObjectAttributesModel<G, A, R> gameObjectAttributesModel, @NotNull final GameObjectAttributesDialogFactory<G, A, R> gameObjectAttributesDialogFactory, @NotNull final ObjectChooser<G, A, R> objectChooser, @NotNull final MapManager<G, A, R> mapManager, @NotNull final SelectedSquareModel<G, A, R> selectedSquareModel, @NotNull final GameObjectFactory<G, A, R> gameObjectFactory) { super(new BorderLayout()); this.gameObjectAttributesModel = gameObjectAttributesModel; this.gameObjectAttributesDialogFactory = gameObjectAttributesDialogFactory; this.objectChooser = objectChooser; - this.selectedSquareView = selectedSquareView; + this.selectedSquareModel = selectedSquareModel; this.gameObjectFactory = gameObjectFactory; final Container mapArchPanel = new JPanel(); @@ -582,7 +580,7 @@ if (insertedGameObject != null) { mapModel.removeGameObject(prevGameObject, true); insertedGameObject.addLast(prevGameObject); - selectedSquareView.setSelectedGameObject(insertedGameObject); + selectedSquareModel.setSelectedGameObject(insertedGameObject); } } finally { mapModel.endTransaction(); Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/panel/selectedsquare/SelectedSquareView.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/panel/selectedsquare/SelectedSquareView.java 2013-07-08 19:30:13 UTC (rev 9271) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/panel/selectedsquare/SelectedSquareView.java 2013-07-08 19:53:16 UTC (rev 9272) @@ -418,15 +418,6 @@ } /** - * Set the selected game object. - * @param gameObject the game object to select, or <code>null</code> to - * deselect it - */ - public void setSelectedGameObject(@Nullable final G gameObject) { - selectedSquareModel.setSelectedGameObject(gameObject); - } - - /** * Set the currently selected list index. If an invalid index is given, the * nearest valid index is used instead. * @param index the index to select Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/panel/tools/InsertionTool.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/panel/tools/InsertionTool.java 2013-07-08 19:30:13 UTC (rev 9271) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/panel/tools/InsertionTool.java 2013-07-08 19:53:16 UTC (rev 9272) @@ -29,7 +29,6 @@ import net.sf.gridarta.gui.map.event.MouseOpEvent; import net.sf.gridarta.gui.panel.objectchooser.ObjectChooser; import net.sf.gridarta.gui.panel.selectedsquare.SelectedSquareModel; -import net.sf.gridarta.gui.panel.selectedsquare.SelectedSquareView; import net.sf.gridarta.gui.utils.SwingUtils; import net.sf.gridarta.model.archetype.Archetype; import net.sf.gridarta.model.baseobject.BaseObject; @@ -90,12 +89,6 @@ private final JComboBox modeComboBox = createModeComboBox(); /** - * The {@link SelectedSquareView}. - */ - @NotNull - private final SelectedSquareView<G, A, R> selectedSquareView; - - /** * The {@link SelectedSquareModel}. */ @NotNull @@ -121,15 +114,13 @@ /** * Create a BasicAbstractTool. - * @param selectedSquareView the selected square view * @param selectedSquareModel the selected square model * @param objectChooser the ObjectChooser to use * @param pickmapSettings the pickmap settings to use * @param insertionModeSet the insertion mode set to use */ - public InsertionTool(@NotNull final SelectedSquareView<G, A, R> selectedSquareView, @NotNull final SelectedSquareModel<G, A, R> selectedSquareModel, @NotNull final ObjectChooser<G, A, R> objectChooser, @NotNull final PickmapSettings pickmapSettings, @NotNull final InsertionModeSet<G, A, R> insertionModeSet) { + public InsertionTool(@NotNull final SelectedSquareModel<G, A, R> selectedSquareModel, @NotNull final ObjectChooser<G, A, R> objectChooser, @NotNull final PickmapSettings pickmapSettings, @NotNull final InsertionModeSet<G, A, R> insertionModeSet) { super("insertion"); - this.selectedSquareView = selectedSquareView; this.selectedSquareModel = selectedSquareModel; this.objectChooser = objectChooser; this.pickmapSettings = pickmapSettings; @@ -236,7 +227,7 @@ final BaseObject<G, A, R, ?> selectedArchetype = objectChooser.getSelection(); insertedObject = selectedArchetype == null ? null : mapModel.insertBaseObject(selectedArchetype, p, isPressed || modeIndex == MODE_AUTO, true, insertionMode); } - selectedSquareView.setSelectedGameObject(insertedObject); + selectedSquareModel.setSelectedGameObject(insertedObject); } finally { mapModel.endTransaction(); } Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/panel/tools/ToolPalette.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/panel/tools/ToolPalette.java 2013-07-08 19:30:13 UTC (rev 9271) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/panel/tools/ToolPalette.java 2013-07-08 19:53:16 UTC (rev 9272) @@ -29,7 +29,6 @@ import net.sf.gridarta.gui.map.event.MouseOpListener; import net.sf.gridarta.gui.panel.objectchooser.ObjectChooser; import net.sf.gridarta.gui.panel.selectedsquare.SelectedSquareModel; -import net.sf.gridarta.gui.panel.selectedsquare.SelectedSquareView; import net.sf.gridarta.model.archetype.Archetype; import net.sf.gridarta.model.gameobject.GameObject; import net.sf.gridarta.model.maparchobject.MapArchObject; @@ -78,7 +77,6 @@ /** * Create a ToolPalette. * @param mapViewSettings the map view settings instance - * @param selectedSquareView the selected square view * @param selectedSquareModel the selected square model * @param objectChooser the object chooser to use * @param pickmapSettings the pickmap settings to use @@ -87,11 +85,11 @@ * @param monsterGameObjectMatcher the monster matcher to use * @param insertionModeSet the insertion mode set to use */ - public ToolPalette(@NotNull final MapViewSettings mapViewSettings, @NotNull final SelectedSquareView<G, A, R> selectedSquareView, @NotNull final SelectedSquareModel<G, A, R> selectedSquareModel, @NotNull final ObjectChooser<G, A, R> objectChooser, @NotNull final PickmapSettings pickmapSettings, @Nullable final GameObjectMatcher floorGameObjectMatcher, @Nullable final GameObjectMatcher wallGameObjectMatcher, @Nullable final GameObjectMatcher monsterGameObjectMatcher, @NotNull final InsertionModeSet<G, A, R> insertionModeSet) { + public ToolPalette(@NotNull final MapViewSettings mapViewSettings, @NotNull final SelectedSquareModel<G, A, R> selectedSquareModel, @NotNull final ObjectChooser<G, A, R> objectChooser, @NotNull final PickmapSettings pickmapSettings, @Nullable final GameObjectMatcher floorGameObjectMatcher, @Nullable final GameObjectMatcher wallGameObjectMatcher, @Nullable final GameObjectMatcher monsterGameObjectMatcher, @NotNull final InsertionModeSet<G, A, R> insertionModeSet) { super(new BorderLayout()); - lmbSelector = new ToolSelector<G, A, R>("selection", mapViewSettings, selectedSquareView, selectedSquareModel, objectChooser, pickmapSettings, floorGameObjectMatcher, wallGameObjectMatcher, monsterGameObjectMatcher, insertionModeSet); - mmbSelector = new ToolSelector<G, A, R>("deletion", mapViewSettings, selectedSquareView, selectedSquareModel, objectChooser, pickmapSettings, floorGameObjectMatcher, wallGameObjectMatcher, monsterGameObjectMatcher, insertionModeSet); - rmbSelector = new ToolSelector<G, A, R>("insertion", mapViewSettings, selectedSquareView, selectedSquareModel, objectChooser, pickmapSettings, floorGameObjectMatcher, wallGameObjectMatcher, monsterGameObjectMatcher, insertionModeSet); + lmbSelector = new ToolSelector<G, A, R>("selection", mapViewSettings, selectedSquareModel, objectChooser, pickmapSettings, floorGameObjectMatcher, wallGameObjectMatcher, monsterGameObjectMatcher, insertionModeSet); + mmbSelector = new ToolSelector<G, A, R>("deletion", mapViewSettings, selectedSquareModel, objectChooser, pickmapSettings, floorGameObjectMatcher, wallGameObjectMatcher, monsterGameObjectMatcher, insertionModeSet); + rmbSelector = new ToolSelector<G, A, R>("insertion", mapViewSettings, selectedSquareModel, objectChooser, pickmapSettings, floorGameObjectMatcher, wallGameObjectMatcher, monsterGameObjectMatcher, insertionModeSet); add(ActionBuilderUtils.newLabel(ACTION_BUILDER, "mouse"), BorderLayout.NORTH); final Container mouseTabs = new JTabbedPane(); mouseTabs.add(ActionBuilderUtils.getString(ACTION_BUILDER, "left"), lmbSelector); Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/panel/tools/ToolSelector.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/panel/tools/ToolSelector.java 2013-07-08 19:30:13 UTC (rev 9271) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/panel/tools/ToolSelector.java 2013-07-08 19:53:16 UTC (rev 9272) @@ -37,7 +37,6 @@ import net.sf.gridarta.gui.map.event.MouseOpListener; import net.sf.gridarta.gui.panel.objectchooser.ObjectChooser; import net.sf.gridarta.gui.panel.selectedsquare.SelectedSquareModel; -import net.sf.gridarta.gui.panel.selectedsquare.SelectedSquareView; import net.sf.gridarta.model.archetype.Archetype; import net.sf.gridarta.model.gameobject.GameObject; import net.sf.gridarta.model.maparchobject.MapArchObject; @@ -112,7 +111,6 @@ * Creates a new instance. * @param defaultTool name of the tool that should be selected by default * @param mapViewSettings the map view settings instance - * @param selectedSquareView the selected square view * @param selectedSquareModel the selected square model * @param objectChooser the object chooser to use * @param pickmapSettings the pickmap settings to use @@ -121,12 +119,12 @@ * @param monsterGameObjectMatcher the monster matcher to use * @param insertionModeSet the insertion mode set to use */ - public ToolSelector(@NotNull final String defaultTool, @NotNull final MapViewSettings mapViewSettings, @NotNull final SelectedSquareView<G, A, R> selectedSquareView, @NotNull final SelectedSquareModel<G, A, R> selectedSquareModel, @NotNull final ObjectChooser<G, A, R> objectChooser, @NotNull final PickmapSettings pickmapSettings, @Nullable final GameObjectMatcher floorGameObjectMatcher, @Nullable final GameObjectMatcher wallGameObjectMatcher, @Nullable final GameObjectMatcher monsterGameObjectMatcher, @NotNull final InsertionModeSet<G, A, R> insertionModeSet) { + public ToolSelector(@NotNull final String defaultTool, @NotNull final MapViewSettings mapViewSettings, @NotNull final SelectedSquareModel<G, A, R> selectedSquareModel, @NotNull final ObjectChooser<G, A, R> objectChooser, @NotNull final PickmapSettings pickmapSettings, @Nullable final GameObjectMatcher floorGameObjectMatcher, @Nullable final GameObjectMatcher wallGameObjectMatcher, @Nullable final GameObjectMatcher monsterGameObjectMatcher, @NotNull final InsertionModeSet<G, A, R> insertionModeSet) { createUI(); addTool(new VoidTool<G, A, R>(), defaultTool); addTool(new SelectionTool<G, A, R>(objectChooser, insertionModeSet), defaultTool); addTool(new DeletionTool<G, A, R>(mapViewSettings, objectChooser, pickmapSettings, floorGameObjectMatcher, wallGameObjectMatcher, monsterGameObjectMatcher), defaultTool); - addTool(new InsertionTool<G, A, R>(selectedSquareView, selectedSquareModel, objectChooser, pickmapSettings, insertionModeSet), defaultTool); + addTool(new InsertionTool<G, A, R>(selectedSquareModel, objectChooser, pickmapSettings, insertionModeSet), defaultTool); } /** Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/GUIMainControl.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/GUIMainControl.java 2013-07-08 19:30:13 UTC (rev 9271) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/GUIMainControl.java 2013-07-08 19:53:16 UTC (rev 9272) @@ -445,8 +445,8 @@ createAction("moveSquarePrev", "Selected Square View", new MoveSquarePrevAction<G, A, R>(selectedSquareModel, mapManager)); createAction("moveSquareNext", "Selected Square View", new MoveSquareNextAction<G, A, R>(selectedSquareModel, mapManager)); final SelectedSquareView<G, A, R> selectedSquareView = new SelectedSquareView<G, A, R>(selectedSquareModel, gameObjectAttributesDialogFactory, objectChooser, mapViewManager, mapViewSettings, compassIcon, faceObjectProviders, unknownSquareIcon, moveSquareUpAction, moveSquareDownAction, moveSquareTopAction, moveSquareBottomAction, moveSquareEnvAction, moveSquareInvAction); - final GameObjectAttributesControl<G, A, R> gameObjectAttributesControl = new GameObjectAttributesControl<G, A, R>(gameObjectAttributesModel, gameObjectAttributesDialogFactory, objectChooser, mapManager, selectedSquareModel, selectedSquareView, gameObjectFactory); - final ToolPalette<G, A, R> toolPalette = new ToolPalette<G, A, R>(mapViewSettings, selectedSquareView, selectedSquareModel, objectChooser, pickmapSettings, floorMatcher, wallMatcher, monsterMatcher, insertionModeSet); + final GameObjectAttributesControl<G, A, R> gameObjectAttributesControl = new GameObjectAttributesControl<G, A, R>(gameObjectAttributesModel, gameObjectAttributesDialogFactory, objectChooser, mapManager, selectedSquareModel, gameObjectFactory); + final ToolPalette<G, A, R> toolPalette = new ToolPalette<G, A, R>(mapViewSettings, selectedSquareModel, objectChooser, pickmapSettings, floorMatcher, wallMatcher, monsterMatcher, insertionModeSet); final GameObjectTab<G, A, R> gameObjectTab = new GameObjectTab<G, A, R>("gameObject", gameObjectAttributesControl, Location.BOTTOM, false, 0, true); createAction("prevWindow", "Map,Window", mapDesktop); createAction("nextWindow", "Map,Window", mapDesktop); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2013-07-08 19:30:17
|
Revision: 9271 http://sourceforge.net/p/gridarta/code/9271 Author: akirschbaum Date: 2013-07-08 19:30:13 +0000 (Mon, 08 Jul 2013) Log Message: ----------- Reorder code. Modified Paths: -------------- trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/GUIMainControl.java Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/GUIMainControl.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/GUIMainControl.java 2013-07-08 19:15:43 UTC (rev 9270) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/GUIMainControl.java 2013-07-08 19:30:13 UTC (rev 9271) @@ -354,11 +354,8 @@ final DisplayMode<G, A, R> displayModeGameObjectNames = new DisplayNameCellRenderer<G, A, R>(faceObjectProviders); final DisplayMode<G, A, R> displayModeArchetypeNames = new ArchetypeNameCellRenderer<G, A, R>(faceObjectProviders); final DisplayMode<G, A, R> displayModeIconsOnly = new ArchetypeIconCellRenderer<G, A, R>(faceObjectProviders); - final Action displayGameObjectNamesAction = createAction("displayGameObjectNames", "Archetype Chooser", new DisplayGameObjectNamesAction<G, A, R>(archetypeChooserModel, displayModeArchetypeNames)); - final Action displayArchetypeNamesAction = createAction("displayArchetypeNames", "Archetype Chooser", new DisplayArchetypeNamesAction<G, A, R>(archetypeChooserModel, displayModeGameObjectNames)); - final Action displayIconsOnlyAction = createAction("displayIconsOnly", "Archetype Chooser", new DisplayIconsOnlyAction<G, A, R>(archetypeChooserModel, displayModeIconsOnly)); - final ArchetypeChooserView<G, A, R> archetypeChooserView = new ArchetypeChooserView<G, A, R>(createDirectionPane, archetypeChooserModel, faceObjectProviders, displayGameObjectNamesAction, displayArchetypeNamesAction, displayIconsOnlyAction, displayModeGameObjectNames, displayModeArchetypeNames, displayModeIconsOnly); - final ArchetypeChooserControl<G, A, R> archetypeChooserControl = new ArchetypeChooserControl<G, A, R>(archetypeChooserModel, archetypeChooserView, createDirectionPane, faceObjectProviders); + final ExitConnectorModel exitConnectorModel = new DefaultExitConnectorModel(); + final ShortcutsManager shortcutsManager = new ShortcutsManager(ACTION_BUILDER); final ImageCreator<G, A, R> imageCreator = new ImageCreator<G, A, R>(mapManager, rendererFactory); final ImageCreator2<G, A, R> imageCreator2 = new ImageCreator2<G, A, R>(globalSettings, imageCreator); final SpellsUtils spellUtils = spellFile != null ? new SpellsUtils(spellFile) : null; @@ -367,8 +364,6 @@ final StatusBar<G, A, R> statusBar = new StatusBar<G, A, R>(mapManager, mapViewManager, archetypeSet, faceObjects); final MapImageCache<G, A, R> mapImageCache = new MapImageCache<G, A, R>(mapManager, systemIcons.getDefaultIcon(), systemIcons.getDefaultPreview(), rendererFactory, cacheFiles); final MapDesktop<G, A, R> mapDesktop = new MapDesktop<G, A, R>(mapViewManager, mapManager, mapImageCache, mapViewsManager); - createAction("prevWindow", "Map,Window", mapDesktop); - createAction("nextWindow", "Map,Window", mapDesktop); final MapFolderTree<G, A, R> mapFolderTree = new MapFolderTree<G, A, R>(globalSettings.getPickmapDir()); final ImageIcon icon = systemIcons.getAppIcon(); mainViewFrame = new JFrame(ACTION_BUILDER.format("mainWindow.title", getBuildNumberAsString())); @@ -377,29 +372,12 @@ final PickmapChooserModel<G, A, R> pickmapChooserModel = new PickmapChooserModel<G, A, R>(); final PickmapSettings pickmapSettings = new DefaultPickmapSettings(); final PickmapChooserControl<G, A, R> pickmapChooserControl = new PickmapChooserControl<G, A, R>(pickmapChooserModel, pickmapSettings, newMapDialogFactory, mapArchObjectFactory, mapReaderFactory, mapFolderTree, mapManager, parent, pickmapManager, mapViewsManager); - createAction("addNewPickmap", "Pickmap", pickmapChooserControl); - createAction("openPickmapMap", "Pickmap", pickmapChooserControl); - createAction("deletePickmap", "Pickmap", pickmapChooserControl); - createAction("savePickmap", "Pickmap", pickmapChooserControl); - createAction("revertPickmap", "Pickmap", pickmapChooserControl); newMapDialogFactory.setPickmapChooserControl(pickmapChooserControl); final CFTreasureListTree treasureListTree = new CFTreasureListTree(treasureTree, parent, archetypeSet, faceObjectProviders, systemIcons); - createAction("viewTreasurelists", "Tool", treasureListTree); final ImageIcon noFaceSquareIcon = systemIcons.getNoFaceSquareIcon(); final ImageIcon unknownSquareIcon = systemIcons.getUnknownSquareIcon(); final GameObjectAttributesDialogFactory<G, A, R> gameObjectAttributesDialogFactory = new GameObjectAttributesDialogFactory<G, A, R>(archetypeTypeSet, parent, treasureListTree, faceObjectProviders, animationObjects, globalSettings, mapFileFilter, scriptFileFilter, faceObjects, gameObjectSpells, numberSpells, undefinedSpellIndex, treasureTree, noFaceSquareIcon, unknownSquareIcon, 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 Action moveSquareDownAction = createAction("moveSquareDown", "Selected Square View", new MoveSquareDownAction<G, A, R>(selectedSquareModel, mapManager)); - final Action moveSquareUpAction = createAction("moveSquareUp", "Selected Square View", new MoveSquareUpAction<G, A, R>(selectedSquareModel, mapManager)); - final Action moveSquareBottomAction = createAction("moveSquareBottom", "Selected Square View", new MoveSquareBottomAction<G, A, R>(selectedSquareModel, mapManager)); - final Action moveSquareEnvAction = createAction("moveSquareEnv", "Selected Square View", new MoveSquareEnvAction<G, A, R>(selectedSquareModel, mapManager)); - final Action moveSquareInvAction = createAction("moveSquareInv", "Selected Square View", new MoveSquareInvAction<G, A, R>(selectedSquareModel, mapManager)); - createAction("moveSquarePrev", "Selected Square View", new MoveSquarePrevAction<G, A, R>(selectedSquareModel, mapManager)); - createAction("moveSquareNext", "Selected Square View", new MoveSquareNextAction<G, A, R>(selectedSquareModel, mapManager)); - final Action moveSquareTopAction = createAction("moveSquareTop", "Selected Square View", new MoveSquareTopAction<G, A, R>(selectedSquareModel, mapManager)); - final SelectedSquareView<G, A, R> selectedSquareView = new SelectedSquareView<G, A, R>(selectedSquareModel, gameObjectAttributesDialogFactory, objectChooser, mapViewManager, mapViewSettings, compassIcon, faceObjectProviders, unknownSquareIcon, moveSquareUpAction, moveSquareDownAction, moveSquareTopAction, moveSquareBottomAction, moveSquareEnvAction, moveSquareInvAction); final GameObjectMatcher floorMatcher = gameObjectMatchers.getMatcher("system_floor", "floor"); final GameObjectMatcher wallMatcher = gameObjectMatchers.getMatcher("system_wall", "wall"); final ErrorViewCollector gameObjectMatchersErrorViewCollector = new ErrorViewCollector(errorView, new File(globalSettings.getConfigurationDirectory(), "GameObjectMatchers.xml")); @@ -408,7 +386,6 @@ final InsertionModeSet<G, A, R> insertionModeSet = new InsertionModeSet<G, A, R>(topmostInsertionMode, floorMatcher, wallMatcher, belowFloorMatcher, systemObjectMatcher); final CopyBuffer<G, A, R> copyBuffer = new CopyBuffer<G, A, R>(mapViewSettings, gameObjectFactory, mapArchObjectFactory, mapModelFactory, insertionModeSet); final FindDialogManager<G, A, R> findDialogManager = new FindDialogManager<G, A, R>(parent, mapViewManager); - final ReplaceDialogManager<G, A, R> replaceDialogManager = new ReplaceDialogManager<G, A, R>(parent, copyBuffer, objectChooser, mapViewManager, faceObjectProviders, insertionModeSet); final Exiter exiter = new DefaultExiter(parent); scriptEditControl = new ScriptEditControl(scriptFileFilter, scriptExtension, parent, globalSettings.getMapsDirectory(), preferences, exiter); final TextAreaDefaults textAreaDefaults = new TextAreaDefaults(scriptEditControl); @@ -430,6 +407,55 @@ final Control<?, G, A, R> lockedItemsControl = new LockedItemsControl<G, A, R>(mapViewManager, delayedMapModelListenerManager, lockedItemsTypeNumbers); final EnterMap<G, A, R> enterMap = new EnterMap<G, A, R>(parent, directionMap, mapPathNormalizer, fileControl, mapViewsManager); final EditorAction mapActions = new MapActions<G, A, R>(parent, mapManager, mapViewManager, exitMatcher, GuiFileFilters.mapFileFilter, selectedSquareModel, allowRandomMapParameters, mapPropertiesDialogFactory, mapViewSettings, mapViewsManager, enterMap); + final GameObjectAttributesModel<G, A, R> gameObjectAttributesModel = new GameObjectAttributesModel<G, A, R>(); + final File scriptsFile = new File(globalSettings.getMapsDirectory(), scriptsDir); + updaterManager = new UpdaterManager(exiter, mapManager, parent, gridartaJarFilename); + final TextEditorTab<G, A, R> textEditorTab = new TextEditorTab<G, A, R>(gameObjectAttributesModel, archetypeTypeSet); + final EditorAction undoControl = new UndoControl<G, A, R>(mapManager, gameObjectFactory, gameObjectMatchers); + final MapFolderTreeActions<G, A, R> mapFolderTreeActions = new MapFolderTreeActions<G, A, R>(mapFolderTree, pickmapSettings, newMapDialogFactory, "createPickmapFolder", "deletePickmapFolder", "confirmDeletePickmapFolder", "deletePickmapFolderNotEmpty"); + final ViewActions<G, A, R> viewActions = new ViewActions<G, A, R>(mapViewSettings, mapManager); + final EditorAction mapFileActions = new MapFileActions<G, A, R>(imageCreator2, mapManager, mapViewsManager, mapViewManager, fileControl, parent); + final BookmarksMapMenuPreferences bookmarksMapMenuPreferences = new BookmarksMapMenuPreferences(); + final MapMenu mapMenu = bookmarksMapMenuPreferences.getMapMenu(); + @Nullable final MapMenuManager<G, A, R> bookmarksMapMenuManager = new MapMenuManager<G, A, R>(mapMenu, mapViewsManager, fileControl, mapImageCache); + final EditorAction bookmarkActions = new BookmarkActions<G, A, R>(bookmarksMapMenuPreferences, mapMenu, mapViewManager, parent, mapImageCache); + final EditorAction serverActions = editorFactory.newServerActions(mapViewManager, fileControl, pathManager); + final ExitConnectorActions<G, A, R> exitConnectorActions = new ExitConnectorActions<G, A, R>(exitConnectorModel, exitMatcher, archetypeSet, mapManager, fileControl, pathManager, insertionModeSet); // XXX: should be part of DefaultMainControl + final EditorAction exitConnectorController = new ExitConnectorController<G, A, R>(exitConnectorActions, exitConnectorModel, mapViewManager); + final Action displayGameObjectNamesAction = createAction("displayGameObjectNames", "Archetype Chooser", new DisplayGameObjectNamesAction<G, A, R>(archetypeChooserModel, displayModeArchetypeNames)); + final Action displayArchetypeNamesAction = createAction("displayArchetypeNames", "Archetype Chooser", new DisplayArchetypeNamesAction<G, A, R>(archetypeChooserModel, displayModeGameObjectNames)); + final Action displayIconsOnlyAction = createAction("displayIconsOnly", "Archetype Chooser", new DisplayIconsOnlyAction<G, A, R>(archetypeChooserModel, displayModeIconsOnly)); + final ArchetypeChooserView<G, A, R> archetypeChooserView = new ArchetypeChooserView<G, A, R>(createDirectionPane, archetypeChooserModel, faceObjectProviders, displayGameObjectNamesAction, displayArchetypeNamesAction, displayIconsOnlyAction, displayModeGameObjectNames, displayModeArchetypeNames, displayModeIconsOnly); + final ArchetypeChooserControl<G, A, R> archetypeChooserControl = new ArchetypeChooserControl<G, A, R>(archetypeChooserModel, archetypeChooserView, createDirectionPane, faceObjectProviders); + final DefaultObjectChooser<G, A, R> objectChooser = new DefaultObjectChooser<G, A, R>(archetypeChooserControl, pickmapChooserControl, archetypeChooserModel, pickmapChooserModel, archetypeTypeSet); + newMapDialogFactory.setObjectChooser(objectChooser); + final ReplaceDialogManager<G, A, R> replaceDialogManager = new ReplaceDialogManager<G, A, R>(parent, copyBuffer, objectChooser, mapViewManager, faceObjectProviders, insertionModeSet); + final PluginParameterViewFactory<G, A, R> pluginParameterViewFactory = new PluginParameterViewFactory<G, A, R>(archetypeSet, gameObjectAttributesModel, objectChooser, mapManager, faceObjectProviders); + final PluginController<G, A, R> pluginControl = new PluginController<G, A, R>(filterControl, pluginParameters, parent, pluginParameterViewFactory, scriptsFile, pluginModel, pluginParameterFactory, pluginExecutor, systemIcons); + //noinspection ResultOfObjectAllocationIgnored + new FindArchetypesDialogManager<G, A, R>(parent, archetypeChooserControl, objectChooser, archetypeTypeSet); + final EditorAction mainActions = new MainActions<G, A, R>(findDialogManager, replaceDialogManager, mainViewFrame, globalSettings, validators, mapViewSettings, archetypeSet, copyBuffer, objectChooser, mapManager, mapViewManager, resources, faceObjectProviders, insertionModeSet, exiter); + final EditorAction mapCursorActions = new MapCursorActions<G, A, R>(objectChooser, gameObjectAttributesDialogFactory, mapViewManager); + final Action moveSquareDownAction = createAction("moveSquareDown", "Selected Square View", new MoveSquareDownAction<G, A, R>(selectedSquareModel, mapManager)); + final Action moveSquareUpAction = createAction("moveSquareUp", "Selected Square View", new MoveSquareUpAction<G, A, R>(selectedSquareModel, mapManager)); + final Action moveSquareBottomAction = createAction("moveSquareBottom", "Selected Square View", new MoveSquareBottomAction<G, A, R>(selectedSquareModel, mapManager)); + final Action moveSquareEnvAction = createAction("moveSquareEnv", "Selected Square View", new MoveSquareEnvAction<G, A, R>(selectedSquareModel, mapManager)); + final Action moveSquareInvAction = createAction("moveSquareInv", "Selected Square View", new MoveSquareInvAction<G, A, R>(selectedSquareModel, mapManager)); + final Action moveSquareTopAction = createAction("moveSquareTop", "Selected Square View", new MoveSquareTopAction<G, A, R>(selectedSquareModel, mapManager)); + createAction("moveSquarePrev", "Selected Square View", new MoveSquarePrevAction<G, A, R>(selectedSquareModel, mapManager)); + createAction("moveSquareNext", "Selected Square View", new MoveSquareNextAction<G, A, R>(selectedSquareModel, mapManager)); + final SelectedSquareView<G, A, R> selectedSquareView = new SelectedSquareView<G, A, R>(selectedSquareModel, gameObjectAttributesDialogFactory, objectChooser, mapViewManager, mapViewSettings, compassIcon, faceObjectProviders, unknownSquareIcon, moveSquareUpAction, moveSquareDownAction, moveSquareTopAction, moveSquareBottomAction, moveSquareEnvAction, moveSquareInvAction); + final GameObjectAttributesControl<G, A, R> gameObjectAttributesControl = new GameObjectAttributesControl<G, A, R>(gameObjectAttributesModel, gameObjectAttributesDialogFactory, objectChooser, mapManager, selectedSquareModel, selectedSquareView, gameObjectFactory); + final ToolPalette<G, A, R> toolPalette = new ToolPalette<G, A, R>(mapViewSettings, selectedSquareView, selectedSquareModel, objectChooser, pickmapSettings, floorMatcher, wallMatcher, monsterMatcher, insertionModeSet); + final GameObjectTab<G, A, R> gameObjectTab = new GameObjectTab<G, A, R>("gameObject", gameObjectAttributesControl, Location.BOTTOM, false, 0, true); + createAction("prevWindow", "Map,Window", mapDesktop); + createAction("nextWindow", "Map,Window", mapDesktop); + createAction("addNewPickmap", "Pickmap", pickmapChooserControl); + createAction("openPickmapMap", "Pickmap", pickmapChooserControl); + createAction("deletePickmap", "Pickmap", pickmapChooserControl); + createAction("savePickmap", "Pickmap", pickmapChooserControl); + createAction("revertPickmap", "Pickmap", pickmapChooserControl); + createAction("viewTreasurelists", "Tool", treasureListTree); createAction("mapCreateView", "Map,Window", mapActions); createAction("mapProperties", "Map", mapActions); createToggleAction("autoJoin", "Map", mapActions); @@ -451,40 +477,23 @@ createToggleAction("smoothing", "Map Navigation", mapActions); createToggleAction("doubleFaces", "Map Navigation", mapActions); createToggleAction("tileShow", "Map Navigation", mapActions); - final GameObjectAttributesModel<G, A, R> gameObjectAttributesModel = new GameObjectAttributesModel<G, A, R>(); - final GameObjectAttributesControl<G, A, R> gameObjectAttributesControl = new GameObjectAttributesControl<G, A, R>(gameObjectAttributesModel, gameObjectAttributesDialogFactory, objectChooser, mapManager, selectedSquareModel, selectedSquareView, gameObjectFactory); - final PluginParameterViewFactory<G, A, R> pluginParameterViewFactory = new PluginParameterViewFactory<G, A, R>(archetypeSet, gameObjectAttributesModel, objectChooser, mapManager, faceObjectProviders); - final File scriptsFile = new File(globalSettings.getMapsDirectory(), scriptsDir); - final PluginController<G, A, R> pluginControl = new PluginController<G, A, R>(filterControl, pluginParameters, parent, pluginParameterViewFactory, scriptsFile, pluginModel, pluginParameterFactory, pluginExecutor, systemIcons); createAction("editPlugins", "Plugin", new PluginManagerFactory<G, A, R>(pluginControl, pluginModel, pluginParameterViewFactory, pluginParameterFactory, systemIcons)); createAction("savePlugins", "Plugin", pluginControl); createAction("importPlugin", "Plugin", pluginControl); - final ToolPalette<G, A, R> toolPalette = new ToolPalette<G, A, R>(mapViewSettings, selectedSquareView, selectedSquareModel, objectChooser, pickmapSettings, floorMatcher, wallMatcher, monsterMatcher, insertionModeSet); - updaterManager = new UpdaterManager(exiter, mapManager, parent, gridartaJarFilename); createAction("update", "Tool", updaterManager); - - final TextEditorTab<G, A, R> textEditorTab = new TextEditorTab<G, A, R>(gameObjectAttributesModel, archetypeTypeSet); - final GameObjectTab<G, A, R> gameObjectTab = new GameObjectTab<G, A, R>("gameObject", gameObjectAttributesControl, Location.BOTTOM, false, 0, true); - createAction("about", "Help", new About(parent)); - //noinspection ResultOfObjectAllocationIgnored - new FindArchetypesDialogManager<G, A, R>(parent, archetypeChooserControl, objectChooser, archetypeTypeSet); - final EditorAction undoControl = new UndoControl<G, A, R>(mapManager, gameObjectFactory, gameObjectMatchers); createAction("undo", "Undo", undoControl); createAction("redo", "Undo", undoControl); final Action exitAction = createAction("exit", "Other", new ExitAction(exiter, scriptEditControl, fileControl, pickmapChooserControl, pluginControl)); - final MapFolderTreeActions<G, A, R> mapFolderTreeActions = new MapFolderTreeActions<G, A, R>(mapFolderTree, pickmapSettings, newMapDialogFactory, "createPickmapFolder", "deletePickmapFolder", "confirmDeletePickmapFolder", "deletePickmapFolderNotEmpty"); + mainView = new MainView(mainViewFrame, exitAction, mapDesktop, icon, exiter); createAction("createPickmapFolder", "Pickmap", mapFolderTreeActions); createAction("deletePickmapFolder", "Pickmap", mapFolderTreeActions); - final ViewActions<G, A, R> viewActions = new ViewActions<G, A, R>(mapViewSettings, mapManager); createAction("resetView", "Map", viewActions); - final EditorAction mapFileActions = new MapFileActions<G, A, R>(imageCreator2, mapManager, mapViewsManager, mapViewManager, fileControl, parent); createAction("saveMap", "Map", mapFileActions); createAction("saveMapAs", "Map", mapFileActions); createAction("createImage", "Map,Image", mapFileActions); createAction("reloadMap", "Map", mapFileActions); createAction("closeMap", "Map", mapFileActions); - final EditorAction mainActions = new MainActions<G, A, R>(findDialogManager, replaceDialogManager, mainViewFrame, globalSettings, validators, mapViewSettings, archetypeSet, copyBuffer, objectChooser, mapManager, mapViewManager, resources, faceObjectProviders, insertionModeSet, exiter); createAction("clear", "Copy Buffer", mainActions); createAction("cut", "Copy Buffer", mainActions); createAction("copy", "Copy Buffer", mainActions); @@ -519,8 +528,6 @@ createAction("validateMap", "Map,Tool", mainActions); final Action helpAction = createAction("showHelp", "Help", new ShowHelpAction(parent)); createAction("tipOfTheDay", "Help", new TipOfTheDayAction(parent)); - final ExitConnectorModel exitConnectorModel = new DefaultExitConnectorModel(); - final ShortcutsManager shortcutsManager = new ShortcutsManager(ACTION_BUILDER); createAction("newMap", "Map", newMapDialogFactory); createAction("goMap", "Map", new GoMapDialogManager<G, A, R>(parent, mapManager, mapViewsManager, globalSettings, exiter)); createAction("goExit", "Map Navigation", new GoExitDialogManager<G, A, R>(parent, mapManager, mapViewManager, exitGameObjectMatcher, pathManager, enterMap, faceObjectProviders)); @@ -532,7 +539,6 @@ createAction("options", "Tool", new OptionsAction<G, A, R>(editorFactory, globalSettings, validators, appPreferencesModel, exitConnectorModel, configSourceFactory, parent)); createAction("shortcuts", "Tool", new ShortcutsAction(shortcutsManager, parent)); createAction("zoom", "Tool", new ZoomAction<G, A, R>(mapManager, rendererFactory, parent)); - final EditorAction mapCursorActions = new MapCursorActions<G, A, R>(objectChooser, gameObjectAttributesDialogFactory, mapViewManager); createAction("moveCursorNorth", "Map Cursor,Map/Selection", mapCursorActions); createAction("moveCursorEast", "Map Cursor,Map/Selection", mapCursorActions); createAction("moveCursorSouth", "Map Cursor,Map/Selection", mapCursorActions); @@ -557,34 +563,24 @@ createAction("openFile", "Map", fileControl); createAction("saveAllMaps", "Map", fileControl); final Action aCloseAllMaps = createAction("closeAllMaps", "Map,Window", fileControl); - mainView = new MainView(mainViewFrame, exitAction, mapDesktop, icon, exiter); createAction("gameObjectTextEditor", "Tool", new MainViewActions<G, A, R>(mainView, gameObjectAttributesControl, gameObjectTab, textEditorTab)); - final BookmarksMapMenuPreferences bookmarksMapMenuPreferences = new BookmarksMapMenuPreferences(); - final MapMenu mapMenu = bookmarksMapMenuPreferences.getMapMenu(); - @Nullable final MapMenuManager<G, A, R> bookmarksMapMenuManager = new MapMenuManager<G, A, R>(mapMenu, mapViewsManager, fileControl, mapImageCache); - final EditorAction bookmarkActions = new BookmarkActions<G, A, R>(bookmarksMapMenuPreferences, mapMenu, mapViewManager, parent, mapImageCache); createAction("manageBookmarks", "Bookmarks", bookmarkActions); createAction("addBookmark", "Bookmarks", bookmarkActions); - final EditorAction serverActions = editorFactory.newServerActions(mapViewManager, fileControl, pathManager); if (serverActions != null) { createAction("openInClient", "Map", serverActions); } - + createAction("exitCopy", "Exit Connector", exitConnectorController); + createAction("exitPaste", "Exit Connector", exitConnectorController); + createAction("exitConnect", "Exit Connector", exitConnectorController); pickmapChooserControl.setPopupMenu(ACTION_BUILDER.createPopupMenu(true, "pickmaps")); final JMenuBar menuBar = ACTION_BUILDER.createMenuBar(true, "main"); - final MainToolbar mainToolbar = new MainToolbar(globalSettings); mainViewFrame.setJMenuBar(menuBar); - mainViewFrame.add(mainToolbar.getComponent(), BorderLayout.NORTH); + mainViewFrame.add(new MainToolbar(globalSettings).getComponent(), BorderLayout.NORTH); mainViewFrame.add(statusBar, BorderLayout.SOUTH); mainView.addTab(gameObjectTab); mainView.addTab(new Tab("selectedSquare", selectedSquareView, Location.RIGHT, false, 1, true)); mainView.addTab(new Tab("tools", toolPalette, Location.LEFT, false, 2, false)); mainView.addTab(new Tab("objects", objectChooser, Location.LEFT, false, 3, true)); - final ExitConnectorActions<G, A, R> exitConnectorActions = new ExitConnectorActions<G, A, R>(exitConnectorModel, exitMatcher, archetypeSet, mapManager, fileControl, pathManager, insertionModeSet); // XXX: should be part of DefaultMainControl - final EditorAction exitConnectorController = new ExitConnectorController<G, A, R>(exitConnectorActions, exitConnectorModel, mapViewManager); - createAction("exitCopy", "Exit Connector", exitConnectorController); - createAction("exitPaste", "Exit Connector", exitConnectorController); - createAction("exitConnect", "Exit Connector", exitConnectorController); final JMenu windowMenu = MenuUtils.getMenu(menuBar, "window"); if (windowMenu == null) { log.warn("'main' menu bar does not define 'window' menu."); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2013-07-08 19:15:49
|
Revision: 9270 http://sourceforge.net/p/gridarta/code/9270 Author: akirschbaum Date: 2013-07-08 19:15:43 +0000 (Mon, 08 Jul 2013) Log Message: ----------- Extract ShowHelpAction from HelpActions. Modified Paths: -------------- trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/GUIMainControl.java Added Paths: ----------- trunk/src/gridarta/src/main/java/net/sf/gridarta/action/ShowHelpAction.java Removed Paths: ------------- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/misc/HelpActions.java Added: trunk/src/gridarta/src/main/java/net/sf/gridarta/action/ShowHelpAction.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/action/ShowHelpAction.java (rev 0) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/action/ShowHelpAction.java 2013-07-08 19:15:43 UTC (rev 9270) @@ -0,0 +1,65 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2011 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.action; + +import java.awt.Frame; +import javax.swing.Action; +import net.sf.gridarta.gui.dialog.help.Help; +import net.sf.gridarta.utils.EditorAction; +import net.sf.japi.swing.action.ActionMethod; +import org.jetbrains.annotations.NotNull; + +/** + * An {@link EditorAction} that shows the help dialog. + * @author Andreas Kirschbaum + */ +public class ShowHelpAction implements EditorAction { + + /** + * The parent {@link Frame} for the dialog. + */ + @NotNull + private final Frame parent; + + /** + * Creates a new instance. + * @param parent the parent frame for the dialog + */ + public ShowHelpAction(@NotNull final Frame parent) { + this.parent = parent; + } + + /** + * Shows the help dialog. + */ + @ActionMethod + public void showHelp() { + new Help(parent, "start.html").setVisible(true); + } + + + /** + * {@inheritDoc} + */ + @Override + public void setAction(@NotNull final Action action, @NotNull final String name) { + } + +} Property changes on: trunk/src/gridarta/src/main/java/net/sf/gridarta/action/ShowHelpAction.java ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +LF \ No newline at end of property Deleted: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/misc/HelpActions.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/misc/HelpActions.java 2013-07-08 19:07:39 UTC (rev 9269) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/misc/HelpActions.java 2013-07-08 19:15:43 UTC (rev 9270) @@ -1,64 +0,0 @@ -/* - * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. - * Copyright (C) 2000-2011 The Gridarta Developers. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -package net.sf.gridarta.gui.misc; - -import java.awt.Frame; -import javax.swing.Action; -import net.sf.gridarta.gui.dialog.help.Help; -import net.sf.gridarta.utils.EditorAction; -import net.sf.japi.swing.action.ActionMethod; -import org.jetbrains.annotations.NotNull; - -/** - * Actions that are related to displaying help information. - * @author Andreas Kirschbaum - */ -public class HelpActions implements EditorAction { - - /** - * The main view {@link Frame}. - */ - @NotNull - private final Frame mainViewFrame; - - /** - * Creates a new instance. - * @param mainViewFrame the main view frame - */ - public HelpActions(@NotNull final Frame mainViewFrame) { - this.mainViewFrame = mainViewFrame; - } - - /** - * Action for creating a new project. - */ - @ActionMethod - public void showHelp() { - new Help(mainViewFrame, "start.html").setVisible(true); - } - - /** - * {@inheritDoc} - */ - @Override - public void setAction(@NotNull final Action action, @NotNull final String name) { - } - -} Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/GUIMainControl.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/GUIMainControl.java 2013-07-08 19:07:39 UTC (rev 9269) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/GUIMainControl.java 2013-07-08 19:15:43 UTC (rev 9270) @@ -53,6 +53,7 @@ import net.sf.gridarta.action.MoveSquareUpAction; import net.sf.gridarta.action.OptionsAction; import net.sf.gridarta.action.ShortcutsAction; +import net.sf.gridarta.action.ShowHelpAction; import net.sf.gridarta.action.TipOfTheDayAction; import net.sf.gridarta.action.ZoomAction; import net.sf.gridarta.actions.ExitConnectorActions; @@ -105,7 +106,6 @@ import net.sf.gridarta.gui.mapuserlistener.MapUserListenerManager; import net.sf.gridarta.gui.misc.About; import net.sf.gridarta.gui.misc.DefaultFileControl; -import net.sf.gridarta.gui.misc.HelpActions; import net.sf.gridarta.gui.misc.MainToolbar; import net.sf.gridarta.gui.misc.MainView; import net.sf.gridarta.gui.misc.MainViewActions; @@ -517,8 +517,7 @@ createAction("collectArches", "Tool", mainActions); createAction("reloadFaces", "Image,Tool", mainActions); createAction("validateMap", "Map,Tool", mainActions); - final HelpActions helpActions = new HelpActions(parent); - createAction("showHelp", "Help", helpActions); + final Action helpAction = createAction("showHelp", "Help", new ShowHelpAction(parent)); createAction("tipOfTheDay", "Help", new TipOfTheDayAction(parent)); final ExitConnectorModel exitConnectorModel = new DefaultExitConnectorModel(); final ShortcutsManager shortcutsManager = new ShortcutsManager(ACTION_BUILDER); @@ -630,7 +629,7 @@ if (globalSettings.isAutoPopupDocumentation()) { // do an automated help popup because the documentation version has increased // (people won't notice the documentation otherwise - nobody expects a documentation in open source) - helpActions.showHelp(); + helpAction.actionPerformed(null); globalSettings.setAutoPopupDocumentation(false); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2013-07-08 19:07:45
|
Revision: 9269 http://sourceforge.net/p/gridarta/code/9269 Author: akirschbaum Date: 2013-07-08 19:07:39 +0000 (Mon, 08 Jul 2013) Log Message: ----------- Extract TipOfTheDayAction from HelpActions. Modified Paths: -------------- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/misc/HelpActions.java trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/GUIMainControl.java Added Paths: ----------- trunk/src/gridarta/src/main/java/net/sf/gridarta/action/TipOfTheDayAction.java Added: trunk/src/gridarta/src/main/java/net/sf/gridarta/action/TipOfTheDayAction.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/action/TipOfTheDayAction.java (rev 0) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/action/TipOfTheDayAction.java 2013-07-08 19:07:39 UTC (rev 9269) @@ -0,0 +1,65 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2011 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.action; + +import java.awt.Frame; +import javax.swing.Action; +import net.sf.gridarta.utils.EditorAction; +import net.sf.japi.swing.action.ActionMethod; +import net.sf.japi.swing.tod.TipOfTheDayManager; +import org.jetbrains.annotations.NotNull; + +/** + * An {@link EditorAction} that shows the "tip of the day" dialog. + * @author Andreas Kirschbaum + */ +public class TipOfTheDayAction implements EditorAction { + + /** + * The parent {@link Frame} for the dialog. + */ + @NotNull + private final Frame parent; + + /** + * Creates a new instance. + * @param parent the parent frame for the dialog + */ + public TipOfTheDayAction(@NotNull final Frame parent) { + this.parent = parent; + } + + /** + * Shows the "tip of the day" dialog. + */ + @ActionMethod + public void tipOfTheDay() { + TipOfTheDayManager.show(parent); + } + + + /** + * {@inheritDoc} + */ + @Override + public void setAction(@NotNull final Action action, @NotNull final String name) { + } + +} Property changes on: trunk/src/gridarta/src/main/java/net/sf/gridarta/action/TipOfTheDayAction.java ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +LF \ No newline at end of property Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/misc/HelpActions.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/misc/HelpActions.java 2013-07-08 18:56:09 UTC (rev 9268) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/misc/HelpActions.java 2013-07-08 19:07:39 UTC (rev 9269) @@ -24,7 +24,6 @@ import net.sf.gridarta.gui.dialog.help.Help; import net.sf.gridarta.utils.EditorAction; import net.sf.japi.swing.action.ActionMethod; -import net.sf.japi.swing.tod.TipOfTheDayManager; import org.jetbrains.annotations.NotNull; /** @@ -56,14 +55,6 @@ } /** - * Action for creating a new project. - */ - @ActionMethod - public void tipOfTheDay() { - TipOfTheDayManager.show(mainViewFrame); - } - - /** * {@inheritDoc} */ @Override Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/GUIMainControl.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/GUIMainControl.java 2013-07-08 18:56:09 UTC (rev 9268) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/GUIMainControl.java 2013-07-08 19:07:39 UTC (rev 9269) @@ -53,6 +53,7 @@ import net.sf.gridarta.action.MoveSquareUpAction; import net.sf.gridarta.action.OptionsAction; import net.sf.gridarta.action.ShortcutsAction; +import net.sf.gridarta.action.TipOfTheDayAction; import net.sf.gridarta.action.ZoomAction; import net.sf.gridarta.actions.ExitConnectorActions; import net.sf.gridarta.gui.autovalidator.AutoValidator; @@ -518,7 +519,7 @@ createAction("validateMap", "Map,Tool", mainActions); final HelpActions helpActions = new HelpActions(parent); createAction("showHelp", "Help", helpActions); - createAction("tipOfTheDay", "Help", helpActions); + createAction("tipOfTheDay", "Help", new TipOfTheDayAction(parent)); final ExitConnectorModel exitConnectorModel = new DefaultExitConnectorModel(); final ShortcutsManager shortcutsManager = new ShortcutsManager(ACTION_BUILDER); createAction("newMap", "Map", newMapDialogFactory); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2013-07-08 18:56:21
|
Revision: 9268 http://sourceforge.net/p/gridarta/code/9268 Author: akirschbaum Date: 2013-07-08 18:56:09 +0000 (Mon, 08 Jul 2013) Log Message: ----------- Do not create Actions in SelectedSquareView. Modified Paths: -------------- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/panel/selectedsquare/SelectedSquareView.java trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/GUIMainControl.java Added Paths: ----------- trunk/src/gridarta/src/main/java/net/sf/gridarta/action/AbstractMoveSquareAction.java trunk/src/gridarta/src/main/java/net/sf/gridarta/action/MoveSquareBottomAction.java trunk/src/gridarta/src/main/java/net/sf/gridarta/action/MoveSquareDownAction.java trunk/src/gridarta/src/main/java/net/sf/gridarta/action/MoveSquareEnvAction.java trunk/src/gridarta/src/main/java/net/sf/gridarta/action/MoveSquareInvAction.java trunk/src/gridarta/src/main/java/net/sf/gridarta/action/MoveSquareNextAction.java trunk/src/gridarta/src/main/java/net/sf/gridarta/action/MoveSquarePrevAction.java trunk/src/gridarta/src/main/java/net/sf/gridarta/action/MoveSquareTopAction.java trunk/src/gridarta/src/main/java/net/sf/gridarta/action/MoveSquareUpAction.java trunk/src/gridarta/src/test/java/net/sf/gridarta/action/ trunk/src/gridarta/src/test/java/net/sf/gridarta/action/SelectedSquareActionsTest.java Removed Paths: ------------- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/panel/selectedsquare/SelectedSquareActions.java trunk/src/gridarta/src/test/java/net/sf/gridarta/gui/panel/ Added: trunk/src/gridarta/src/main/java/net/sf/gridarta/action/AbstractMoveSquareAction.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/action/AbstractMoveSquareAction.java (rev 0) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/action/AbstractMoveSquareAction.java 2013-07-08 18:56:09 UTC (rev 9268) @@ -0,0 +1,212 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2011 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.action; + +import java.io.File; +import java.util.Set; +import javax.swing.Action; +import net.sf.gridarta.gui.panel.selectedsquare.SelectedSquareModel; +import net.sf.gridarta.gui.panel.selectedsquare.SelectedSquareModelListener; +import net.sf.gridarta.model.archetype.Archetype; +import net.sf.gridarta.model.gameobject.GameObject; +import net.sf.gridarta.model.maparchobject.MapArchObject; +import net.sf.gridarta.model.mapcontrol.MapControl; +import net.sf.gridarta.model.mapmanager.MapManager; +import net.sf.gridarta.model.mapmanager.MapManagerListener; +import net.sf.gridarta.model.mapmodel.MapModel; +import net.sf.gridarta.model.mapmodel.MapModelListener; +import net.sf.gridarta.model.mapmodel.MapSquare; +import net.sf.gridarta.model.validation.ErrorCollector; +import net.sf.gridarta.utils.EditorAction; +import net.sf.gridarta.utils.Size2D; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * Abstract base class for actions that move the selected game object in the + * {@link SelectedSquareModel}. + * @author Andreas Kirschbaum + */ +public abstract class AbstractMoveSquareAction<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> implements EditorAction { + + /** + * The {@link SelectedSquareModel} that is updated. + */ + @NotNull + private final SelectedSquareModel<G, A, R> selectedSquareModel; + + /** + * The currently active {@link MapModel}. + */ + @Nullable + private MapModel<G, A, R> mapModel; + + /** + * The {@link Action} for this instance. May be {@code null}. + */ + @Nullable + private Action action; + + /** + * The map view manager listener. + */ + @NotNull + private final MapManagerListener<G, A, R> mapManagerListener = new MapManagerListener<G, A, R>() { + + @Override + public void currentMapChanged(@Nullable final MapControl<G, A, R> mapControl) { + setMapModel(mapControl == null ? null : mapControl.getMapModel()); + } + + @Override + public void mapCreated(@NotNull final MapControl<G, A, R> mapControl, final boolean interactive) { + } + + @Override + public void mapClosing(@NotNull final MapControl<G, A, R> mapControl) { + } + + @Override + public void mapClosed(@NotNull final MapControl<G, A, R> mapControl) { + } + + }; + + /** + * The {@link MapModelListener} attached to {@link #mapModel}. + */ + @NotNull + private final MapModelListener<G, A, R> mapModelListener = new MapModelListener<G, A, R>() { + + @Override + public void mapSizeChanged(@NotNull final Size2D newSize) { + updateAction(); + } + + @Override + public void mapSquaresChanged(@NotNull final Set<MapSquare<G, A, R>> mapSquares) { + if (selectedSquareModel.isSelectedMapSquares(mapSquares)) { + updateAction(); + } + } + + @Override + public void mapObjectsChanged(@NotNull final Set<G> gameObjects, @NotNull final Set<G> transientGameObjects) { + if (selectedSquareModel.isSelectedGameObjects(gameObjects) || selectedSquareModel.isSelectedGameObjects(transientGameObjects)) { + updateAction(); + } + } + + @Override + public void errorsChanged(@NotNull final ErrorCollector<G, A, R> errors) { + } + + @Override + public void mapFileChanged(@Nullable final File oldMapFile) { + } + + @Override + public void modifiedChanged() { + } + + }; + + /** + * The {@link SelectedSquareModelListener} attached to {@link + * #selectedSquareModel}. + */ + @NotNull + private final SelectedSquareModelListener<G, A, R> selectedSquareModelListener = new SelectedSquareModelListener<G, A, R>() { + + @Override + public void selectionChanged(@Nullable final MapSquare<G, A, R> mapSquare, @Nullable final G gameObject) { + updateAction(); + } + + }; + + /** + * Creates a new instance. + * @param selectedSquareModel the selected square model to update + * @param mapManager the map manager to track or {@code null} + */ + protected AbstractMoveSquareAction(@NotNull final SelectedSquareModel<G, A, R> selectedSquareModel, @Nullable final MapManager<G, A, R> mapManager) { + this.selectedSquareModel = selectedSquareModel; + selectedSquareModel.addSelectedSquareListener(selectedSquareModelListener); + if (mapManager != null) { + mapManager.addMapManagerListener(mapManagerListener); + } + } + + /** + * Executes the action. + * @param performAction whether the action should be performed + * @return whether the action was or can be performed + */ + public boolean doAction(final boolean performAction) { + return doAction(performAction, selectedSquareModel.getSelectedGameObject()); + } + + /** + * Executes the action. + * @param performAction whether the action should be performed + * @param gameObject the current game object or {@code null} if none is + * selected + * @return whether the action was or can be performed + */ + protected abstract boolean doAction(final boolean performAction, @Nullable final G gameObject); + + /** + * {@inheritDoc} + */ + @Override + public void setAction(@NotNull final Action action, @NotNull final String name) { + this.action = action; + updateAction(); + } + + /** + * Updates the enabled state of {@link #action}. + */ + private void updateAction() { + if (action != null) { + //noinspection ConstantConditions + action.setEnabled(doAction(false)); + } + } + + /** + * Called whether the current map has changed. Updates listeners attached to + * the current map. + * @param mapModel the new map model + */ + private void setMapModel(@Nullable final MapModel<G, A, R> mapModel) { + if (this.mapModel != null) { + this.mapModel.removeMapModelListener(mapModelListener); + } + this.mapModel = mapModel; + if (this.mapModel != null) { + this.mapModel.addMapModelListener(mapModelListener); + } + + updateAction(); + } + +} Property changes on: trunk/src/gridarta/src/main/java/net/sf/gridarta/action/AbstractMoveSquareAction.java ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +LF \ No newline at end of property Added: trunk/src/gridarta/src/main/java/net/sf/gridarta/action/MoveSquareBottomAction.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/action/MoveSquareBottomAction.java (rev 0) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/action/MoveSquareBottomAction.java 2013-07-08 18:56:09 UTC (rev 9268) @@ -0,0 +1,81 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2011 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.action; + +import net.sf.gridarta.gui.panel.selectedsquare.SelectedSquareModel; +import net.sf.gridarta.model.archetype.Archetype; +import net.sf.gridarta.model.gameobject.GameObject; +import net.sf.gridarta.model.maparchobject.MapArchObject; +import net.sf.gridarta.model.mapmanager.MapManager; +import net.sf.gridarta.model.mapmodel.MapModel; +import net.sf.gridarta.model.mapmodel.MapSquare; +import net.sf.japi.swing.action.ActionMethod; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * An {@link net.sf.gridarta.utils.EditorAction} that moves the selected game + * object in the {@link SelectedSquareModel} to the bottom. + * @author Andreas Kirschbaum + */ +public class MoveSquareBottomAction<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> extends AbstractMoveSquareAction<G, A, R> { + + /** + * Creates a new instance. + * @param selectedSquareModel the selected square model to update + * @param mapManager the map manager to track or {@code null} + */ + public MoveSquareBottomAction(@NotNull final SelectedSquareModel<G, A, R> selectedSquareModel, @Nullable final MapManager<G, A, R> mapManager) { + super(selectedSquareModel, mapManager); + } + + /** + * Action method that moves the selected game object to the bottom. + */ + @ActionMethod + public void moveSquareBottom() { + doAction(true); + } + + /** + * {@inheritDoc} + */ + @Override + protected boolean doAction(final boolean performAction, @Nullable final G gameObject) { + if (gameObject == null || !gameObject.isHead() || gameObject.isBottom()) { + return false; + } + + if (performAction) { + final MapSquare<G, A, R> mapSquare = gameObject.getMapSquare(); + assert mapSquare != null; + final MapModel<G, A, R> mapModel = mapSquare.getMapModel(); + mapModel.beginTransaction("Move Bottom"); + try { + gameObject.moveBottom(); + } finally { + mapModel.endTransaction(); + } + } + + return true; + } + +} Property changes on: trunk/src/gridarta/src/main/java/net/sf/gridarta/action/MoveSquareBottomAction.java ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +LF \ No newline at end of property Added: trunk/src/gridarta/src/main/java/net/sf/gridarta/action/MoveSquareDownAction.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/action/MoveSquareDownAction.java (rev 0) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/action/MoveSquareDownAction.java 2013-07-08 18:56:09 UTC (rev 9268) @@ -0,0 +1,81 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2011 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.action; + +import net.sf.gridarta.gui.panel.selectedsquare.SelectedSquareModel; +import net.sf.gridarta.model.archetype.Archetype; +import net.sf.gridarta.model.gameobject.GameObject; +import net.sf.gridarta.model.maparchobject.MapArchObject; +import net.sf.gridarta.model.mapmanager.MapManager; +import net.sf.gridarta.model.mapmodel.MapModel; +import net.sf.gridarta.model.mapmodel.MapSquare; +import net.sf.japi.swing.action.ActionMethod; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * An {@link net.sf.gridarta.utils.EditorAction} that moves the selected game + * object in the {@link SelectedSquareModel} down. + * @author Andreas Kirschbaum + */ +public class MoveSquareDownAction<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> extends AbstractMoveSquareAction<G, A, R> { + + /** + * Creates a new instance. + * @param selectedSquareModel the selected square model to update + * @param mapManager the map manager to track or {@code null} + */ + public MoveSquareDownAction(@NotNull final SelectedSquareModel<G, A, R> selectedSquareModel, @Nullable final MapManager<G, A, R> mapManager) { + super(selectedSquareModel, mapManager); + } + + /** + * Action method for moving an arch down within its square. + */ + @ActionMethod + public void moveSquareDown() { + doAction(true); + } + + /** + * {@inheritDoc} + */ + @Override + protected boolean doAction(final boolean performAction, @Nullable final G gameObject) { + if (gameObject == null || !gameObject.isHead() || gameObject.isBottom()) { + return false; + } + + if (performAction) { + final MapSquare<G, A, R> mapSquare = gameObject.getMapSquare(); + assert mapSquare != null; + final MapModel<G, A, R> mapModel = mapSquare.getMapModel(); + mapModel.beginTransaction("Move Down"); + try { + gameObject.moveDown(); + } finally { + mapModel.endTransaction(); + } + } + + return true; + } + +} Property changes on: trunk/src/gridarta/src/main/java/net/sf/gridarta/action/MoveSquareDownAction.java ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +LF \ No newline at end of property Added: trunk/src/gridarta/src/main/java/net/sf/gridarta/action/MoveSquareEnvAction.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/action/MoveSquareEnvAction.java (rev 0) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/action/MoveSquareEnvAction.java 2013-07-08 18:56:09 UTC (rev 9268) @@ -0,0 +1,102 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2011 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.action; + +import java.awt.Point; +import net.sf.gridarta.gui.panel.selectedsquare.SelectedSquareModel; +import net.sf.gridarta.model.archetype.Archetype; +import net.sf.gridarta.model.gameobject.GameObject; +import net.sf.gridarta.model.maparchobject.MapArchObject; +import net.sf.gridarta.model.mapmanager.MapManager; +import net.sf.gridarta.model.mapmodel.MapModel; +import net.sf.gridarta.model.mapmodel.MapSquare; +import net.sf.japi.swing.action.ActionMethod; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * An {@link net.sf.gridarta.utils.EditorAction} that moves the selected game + * object in the {@link SelectedSquareModel} to its environment. + * @author Andreas Kirschbaum + */ +public class MoveSquareEnvAction<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> extends AbstractMoveSquareAction<G, A, R> { + + /** + * The {@link SelectedSquareModel} that is updated. + */ + @NotNull + private final SelectedSquareModel<G, A, R> selectedSquareModel; + + /** + * Creates a new instance. + * @param selectedSquareModel the selected square model to update + * @param mapManager the map manager to track or {@code null} + */ + public MoveSquareEnvAction(@NotNull final SelectedSquareModel<G, A, R> selectedSquareModel, @Nullable final MapManager<G, A, R> mapManager) { + super(selectedSquareModel, mapManager); + this.selectedSquareModel = selectedSquareModel; + } + + /** + * Action method that moves the selected game object to its environment. + */ + @ActionMethod + public void moveSquareEnv() { + doAction(true); + } + + /** + * {@inheritDoc} + */ + @Override + protected boolean doAction(final boolean performAction, @Nullable final G gameObject) { + if (gameObject == null || !gameObject.isHead()) { + return false; + } + + final G envGameObject = gameObject.getContainerGameObject(); + if (envGameObject == null) { + return false; + } + + final MapSquare<G, A, R> mapSquare = selectedSquareModel.getSelectedMapSquare(); + if (mapSquare == null) { + return false; + } + + final MapModel<G, A, R> mapModel = mapSquare.getMapModel(); + final Point pos = mapSquare.getMapLocation(); + if (!envGameObject.isInContainer() && gameObject.getArchetype().isMulti() && !mapModel.isMultiArchFittingToMap(gameObject.getArchetype(), pos, true)) { + return false; + } + + if (performAction) { + mapModel.beginTransaction("Move To Environment"); + try { + mapModel.moveEnv(gameObject, pos, envGameObject); + } finally { + mapModel.endTransaction(); + } + } + + return true; + } + +} Property changes on: trunk/src/gridarta/src/main/java/net/sf/gridarta/action/MoveSquareEnvAction.java ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +LF \ No newline at end of property Added: trunk/src/gridarta/src/main/java/net/sf/gridarta/action/MoveSquareInvAction.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/action/MoveSquareInvAction.java (rev 0) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/action/MoveSquareInvAction.java 2013-07-08 18:56:09 UTC (rev 9268) @@ -0,0 +1,86 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2011 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.action; + +import net.sf.gridarta.gui.panel.selectedsquare.SelectedSquareModel; +import net.sf.gridarta.model.archetype.Archetype; +import net.sf.gridarta.model.gameobject.GameObject; +import net.sf.gridarta.model.maparchobject.MapArchObject; +import net.sf.gridarta.model.mapmanager.MapManager; +import net.sf.gridarta.model.mapmodel.MapModel; +import net.sf.gridarta.model.mapmodel.MapSquare; +import net.sf.japi.swing.action.ActionMethod; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * An {@link net.sf.gridarta.utils.EditorAction} that moves the selected game + * object in the {@link SelectedSquareModel} to its inventory. + * @author Andreas Kirschbaum + */ +public class MoveSquareInvAction<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> extends AbstractMoveSquareAction<G, A, R> { + + /** + * Creates a new instance. + * @param selectedSquareModel the selected square model to update + * @param mapManager the map manager to track or {@code null} + */ + public MoveSquareInvAction(@NotNull final SelectedSquareModel<G, A, R> selectedSquareModel, @Nullable final MapManager<G, A, R> mapManager) { + super(selectedSquareModel, mapManager); + } + + /** + * Action method that moves the selected game object to its inventory. + */ + @ActionMethod + public void moveSquareInv() { + doAction(true); + } + + /** + * {@inheritDoc} + */ + @Override + protected boolean doAction(final boolean performAction, @Nullable final G gameObject) { + if (gameObject == null || !gameObject.isHead()) { + return false; + } + + final GameObject<G, A, R> prevGameObject = gameObject.getPrev(); + if (prevGameObject == null) { + return false; + } + + if (performAction) { + final MapSquare<G, A, R> mapSquare = gameObject.getMapSquare(); + assert mapSquare != null; + final MapModel<G, A, R> mapModel = mapSquare.getMapModel(); + mapModel.beginTransaction("Move To Inventory"); + try { + mapModel.moveInv(gameObject, prevGameObject.getHead()); + } finally { + mapModel.endTransaction(); + } + } + + return true; + } + +} Property changes on: trunk/src/gridarta/src/main/java/net/sf/gridarta/action/MoveSquareInvAction.java ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +LF \ No newline at end of property Added: trunk/src/gridarta/src/main/java/net/sf/gridarta/action/MoveSquareNextAction.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/action/MoveSquareNextAction.java (rev 0) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/action/MoveSquareNextAction.java 2013-07-08 18:56:09 UTC (rev 9268) @@ -0,0 +1,94 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2011 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.action; + +import net.sf.gridarta.gui.panel.selectedsquare.SelectedSquareModel; +import net.sf.gridarta.model.archetype.Archetype; +import net.sf.gridarta.model.gameobject.GameObject; +import net.sf.gridarta.model.maparchobject.MapArchObject; +import net.sf.gridarta.model.mapmanager.MapManager; +import net.sf.japi.swing.action.ActionMethod; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * An {@link net.sf.gridarta.utils.EditorAction} that selects the next game + * object in the {@link SelectedSquareModel}. + * @author Andreas Kirschbaum + */ +public class MoveSquareNextAction<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> extends AbstractMoveSquareAction<G, A, R> { + + /** + * The {@link SelectedSquareModel} that is updated. + */ + @NotNull + private final SelectedSquareModel<G, A, R> selectedSquareModel; + + /** + * Creates a new instance. + * @param selectedSquareModel the selected square model to update + * @param mapManager the map manager to track or {@code null} + */ + public MoveSquareNextAction(@NotNull final SelectedSquareModel<G, A, R> selectedSquareModel, @Nullable final MapManager<G, A, R> mapManager) { + super(selectedSquareModel, mapManager); + this.selectedSquareModel = selectedSquareModel; + } + + /** + * Action method that selects the next game object. + */ + @ActionMethod + public void moveSquareNext() { + doAction(true); + } + + /** + * {@inheritDoc} + */ + @Override + protected boolean doAction(final boolean performAction, @Nullable final G gameObject) { + if (gameObject == null || !gameObject.isHead()) { + return false; + } + + G nextGameObject = gameObject.getLast(); + if (nextGameObject == null) { + nextGameObject = gameObject; + while (true) { + final G tmp = nextGameObject.getNext(); + if (tmp != null) { + nextGameObject = tmp; + break; + } + nextGameObject = nextGameObject.getContainerGameObject(); + if (nextGameObject == null) { + return false; + } + } + } + + if (performAction) { + selectedSquareModel.setSelectedGameObject(nextGameObject); + } + + return true; + } + +} Property changes on: trunk/src/gridarta/src/main/java/net/sf/gridarta/action/MoveSquareNextAction.java ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +LF \ No newline at end of property Added: trunk/src/gridarta/src/main/java/net/sf/gridarta/action/MoveSquarePrevAction.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/action/MoveSquarePrevAction.java (rev 0) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/action/MoveSquarePrevAction.java 2013-07-08 18:56:09 UTC (rev 9268) @@ -0,0 +1,94 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2011 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.action; + +import net.sf.gridarta.gui.panel.selectedsquare.SelectedSquareModel; +import net.sf.gridarta.model.archetype.Archetype; +import net.sf.gridarta.model.gameobject.GameObject; +import net.sf.gridarta.model.maparchobject.MapArchObject; +import net.sf.gridarta.model.mapmanager.MapManager; +import net.sf.japi.swing.action.ActionMethod; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * An {@link net.sf.gridarta.utils.EditorAction} that selects the previous game + * object in the {@link SelectedSquareModel}. + * @author Andreas Kirschbaum + */ +public class MoveSquarePrevAction<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> extends AbstractMoveSquareAction<G, A, R> { + + /** + * The {@link SelectedSquareModel} that is updated. + */ + @NotNull + private final SelectedSquareModel<G, A, R> selectedSquareModel; + + /** + * Creates a new instance. + * @param selectedSquareModel the selected square model to update + * @param mapManager the map manager to track or {@code null} + */ + public MoveSquarePrevAction(@NotNull final SelectedSquareModel<G, A, R> selectedSquareModel, @Nullable final MapManager<G, A, R> mapManager) { + super(selectedSquareModel, mapManager); + this.selectedSquareModel = selectedSquareModel; + } + + /** + * Action method that selects the previous game object. + */ + @ActionMethod + public void moveSquarePrev() { + doAction(true); + } + + /** + * {@inheritDoc} + */ + @Override + protected boolean doAction(final boolean performAction, @Nullable final G gameObject) { + if (gameObject == null || !gameObject.isHead()) { + return false; + } + + G prevGameObject = gameObject.getPrev(); + if (prevGameObject == null) { + prevGameObject = gameObject.getContainerGameObject(); + if (prevGameObject == null) { + return false; + } + } else if (performAction) { + while (true) { + final G tmp = prevGameObject.getFirst(); + if (tmp == null) { + break; + } + prevGameObject = tmp; + } + } + + if (performAction) { + selectedSquareModel.setSelectedGameObject(prevGameObject); + } + + return true; + } + +} Property changes on: trunk/src/gridarta/src/main/java/net/sf/gridarta/action/MoveSquarePrevAction.java ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +LF \ No newline at end of property Added: trunk/src/gridarta/src/main/java/net/sf/gridarta/action/MoveSquareTopAction.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/action/MoveSquareTopAction.java (rev 0) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/action/MoveSquareTopAction.java 2013-07-08 18:56:09 UTC (rev 9268) @@ -0,0 +1,81 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2011 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.action; + +import net.sf.gridarta.gui.panel.selectedsquare.SelectedSquareModel; +import net.sf.gridarta.model.archetype.Archetype; +import net.sf.gridarta.model.gameobject.GameObject; +import net.sf.gridarta.model.maparchobject.MapArchObject; +import net.sf.gridarta.model.mapmanager.MapManager; +import net.sf.gridarta.model.mapmodel.MapModel; +import net.sf.gridarta.model.mapmodel.MapSquare; +import net.sf.japi.swing.action.ActionMethod; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * An {@link net.sf.gridarta.utils.EditorAction} that moves the selected game + * object in the {@link SelectedSquareModel} to the top. + * @author Andreas Kirschbaum + */ +public class MoveSquareTopAction<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> extends AbstractMoveSquareAction<G, A, R> { + + /** + * Creates a new instance. + * @param selectedSquareModel the selected square model to update + * @param mapManager the map manager to track or {@code null} + */ + public MoveSquareTopAction(@NotNull final SelectedSquareModel<G, A, R> selectedSquareModel, @Nullable final MapManager<G, A, R> mapManager) { + super(selectedSquareModel, mapManager); + } + + /** + * Action method that moves the selected game object to the top. + */ + @ActionMethod + public void moveSquareTop() { + doAction(true); + } + + /** + * {@inheritDoc} + */ + @Override + protected boolean doAction(final boolean performAction, @Nullable final G gameObject) { + if (gameObject == null || !gameObject.isHead() || gameObject.isTop()) { + return false; + } + + if (performAction) { + final MapSquare<G, A, R> mapSquare = gameObject.getMapSquare(); + assert mapSquare != null; + final MapModel<G, A, R> mapModel = mapSquare.getMapModel(); + mapModel.beginTransaction("Move Top"); + try { + gameObject.moveTop(); + } finally { + mapModel.endTransaction(); + } + } + + return true; + } + +} Property changes on: trunk/src/gridarta/src/main/java/net/sf/gridarta/action/MoveSquareTopAction.java ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +LF \ No newline at end of property Added: trunk/src/gridarta/src/main/java/net/sf/gridarta/action/MoveSquareUpAction.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/action/MoveSquareUpAction.java (rev 0) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/action/MoveSquareUpAction.java 2013-07-08 18:56:09 UTC (rev 9268) @@ -0,0 +1,81 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2011 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.action; + +import net.sf.gridarta.gui.panel.selectedsquare.SelectedSquareModel; +import net.sf.gridarta.model.archetype.Archetype; +import net.sf.gridarta.model.gameobject.GameObject; +import net.sf.gridarta.model.maparchobject.MapArchObject; +import net.sf.gridarta.model.mapmanager.MapManager; +import net.sf.gridarta.model.mapmodel.MapModel; +import net.sf.gridarta.model.mapmodel.MapSquare; +import net.sf.japi.swing.action.ActionMethod; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * An {@link net.sf.gridarta.utils.EditorAction} that moves the selected game + * object in the {@link SelectedSquareModel} up. + * @author Andreas Kirschbaum + */ +public class MoveSquareUpAction<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> extends AbstractMoveSquareAction<G, A, R> { + + /** + * Creates a new instance. + * @param selectedSquareModel the selected square model to update + * @param mapManager the map manager to track or {@code null} + */ + public MoveSquareUpAction(@NotNull final SelectedSquareModel<G, A, R> selectedSquareModel, @Nullable final MapManager<G, A, R> mapManager) { + super(selectedSquareModel, mapManager); + } + + /** + * Action method for moving an arch up within its square. + */ + @ActionMethod + public void moveSquareUp() { + doAction(true); + } + + /** + * {@inheritDoc} + */ + @Override + protected boolean doAction(final boolean performAction, @Nullable final G gameObject) { + if (gameObject == null || !gameObject.isHead() || gameObject.isTop()) { + return false; + } + + if (performAction) { + final MapSquare<G, A, R> mapSquare = gameObject.getMapSquare(); + assert mapSquare != null; + final MapModel<G, A, R> mapModel = mapSquare.getMapModel(); + mapModel.beginTransaction("Move Up"); + try { + gameObject.moveUp(); + } finally { + mapModel.endTransaction(); + } + } + + return true; + } + +} Property changes on: trunk/src/gridarta/src/main/java/net/sf/gridarta/action/MoveSquareUpAction.java ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +LF \ No newline at end of property Deleted: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/panel/selectedsquare/SelectedSquareActions.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/panel/selectedsquare/SelectedSquareActions.java 2013-07-07 07:31:05 UTC (rev 9267) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/panel/selectedsquare/SelectedSquareActions.java 2013-07-08 18:56:09 UTC (rev 9268) @@ -1,309 +0,0 @@ -/* - * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. - * Copyright (C) 2000-2011 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.panel.selectedsquare; - -import java.awt.Point; -import net.sf.gridarta.model.archetype.Archetype; -import net.sf.gridarta.model.gameobject.GameObject; -import net.sf.gridarta.model.maparchobject.MapArchObject; -import net.sf.gridarta.model.mapmodel.MapModel; -import net.sf.gridarta.model.mapmodel.MapSquare; -import org.jetbrains.annotations.NotNull; - -/** - * Implementing actions that operate on {@link SelectedSquareModel - * SelectedSquareModels}. - * @author Andreas Kirschbaum - */ -public class SelectedSquareActions<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> { - - /** - * The {@link SelectedSquareModel} for this controller. - */ - @NotNull - private final SelectedSquareModel<G, A, R> selectedSquareModel; - - /** - * Creates a new instance. - * @param selectedSquareModel the selected square model to operate on - */ - public SelectedSquareActions(@NotNull final SelectedSquareModel<G, A, R> selectedSquareModel) { - this.selectedSquareModel = selectedSquareModel; - } - - /** - * Executes the "move square prev" action. - * @param performAction whether the action should be performed - * @return whether the action was or can be performed - */ - public boolean doMoveSquarePrev(final boolean performAction) { - final GameObject<G, A, R> gameObject = selectedSquareModel.getSelectedGameObject(); - if (gameObject == null || !gameObject.isHead()) { - return false; - } - - G prevGameObject = gameObject.getPrev(); - if (prevGameObject == null) { - prevGameObject = gameObject.getContainerGameObject(); - if (prevGameObject == null) { - return false; - } - } else if (performAction) { - while (true) { - final G tmp = prevGameObject.getFirst(); - if (tmp == null) { - break; - } - prevGameObject = tmp; - } - } - - if (performAction) { - selectedSquareModel.setSelectedGameObject(prevGameObject); - } - - return true; - } - - /** - * Executes the "move square next" action. - * @param performAction whether the action should be performed - * @return whether the action was or can be performed - */ - public boolean doMoveSquareNext(final boolean performAction) { - final G gameObject = selectedSquareModel.getSelectedGameObject(); - if (gameObject == null || !gameObject.isHead()) { - return false; - } - - G nextGameObject = gameObject.getLast(); - if (nextGameObject == null) { - nextGameObject = gameObject; - while (true) { - final G tmp = nextGameObject.getNext(); - if (tmp != null) { - nextGameObject = tmp; - break; - } - nextGameObject = nextGameObject.getContainerGameObject(); - if (nextGameObject == null) { - return false; - } - } - } - - if (performAction) { - selectedSquareModel.setSelectedGameObject(nextGameObject); - } - - return true; - } - - /** - * Executes the "move square top" action. - * @param performAction whether the action should be performed - * @return whether the action was or can be performed - */ - public boolean doMoveSquareTop(final boolean performAction) { - final GameObject<G, A, R> gameObject = selectedSquareModel.getSelectedGameObject(); - if (gameObject == null || !gameObject.isHead()) { - return false; - } - - if (gameObject.isTop()) { - return false; - } - - if (performAction) { - final MapSquare<G, A, R> mapSquare = gameObject.getMapSquare(); - assert mapSquare != null; - final MapModel<G, A, R> mapModel = mapSquare.getMapModel(); - mapModel.beginTransaction("Move Top"); - try { - gameObject.moveTop(); - } finally { - mapModel.endTransaction(); - } - } - - return true; - } - - /** - * Executes the "move square up" action. - * @param performAction whether the action should be performed - * @return whether the action was or can be performed - */ - public boolean doMoveSquareUp(final boolean performAction) { - final GameObject<G, A, R> gameObject = selectedSquareModel.getSelectedGameObject(); - if (gameObject == null || !gameObject.isHead()) { - return false; - } - - if (gameObject.isTop()) { - return false; - } - - if (performAction) { - final MapSquare<G, A, R> mapSquare = gameObject.getMapSquare(); - assert mapSquare != null; - final MapModel<G, A, R> mapModel = mapSquare.getMapModel(); - mapModel.beginTransaction("Move Up"); - try { - gameObject.moveUp(); - } finally { - mapModel.endTransaction(); - } - } - - return true; - } - - /** - * Executes the "move square down" action. - * @param performAction whether the action should be performed - * @return whether the action was or can be performed - */ - public boolean doMoveSquareDown(final boolean performAction) { - final GameObject<G, A, R> gameObject = selectedSquareModel.getSelectedGameObject(); - if (gameObject == null || !gameObject.isHead()) { - return false; - } - - if (gameObject.isBottom()) { - return false; - } - - if (performAction) { - final MapSquare<G, A, R> mapSquare = gameObject.getMapSquare(); - assert mapSquare != null; - final MapModel<G, A, R> mapModel = mapSquare.getMapModel(); - mapModel.beginTransaction("Move Down"); - try { - gameObject.moveDown(); - } finally { - mapModel.endTransaction(); - } - } - - return true; - } - - /** - * Executes the "move square bottom" action. - * @param performAction whether the action should be performed - * @return whether the action was or can be performed - */ - public boolean doMoveSquareBottom(final boolean performAction) { - final GameObject<G, A, R> gameObject = selectedSquareModel.getSelectedGameObject(); - if (gameObject == null || !gameObject.isHead()) { - return false; - } - - if (gameObject.isBottom()) { - return false; - } - - if (performAction) { - final MapSquare<G, A, R> mapSquare = gameObject.getMapSquare(); - assert mapSquare != null; - final MapModel<G, A, R> mapModel = mapSquare.getMapModel(); - mapModel.beginTransaction("Move Bottom"); - try { - gameObject.moveBottom(); - } finally { - mapModel.endTransaction(); - } - } - - return true; - } - - /** - * Executes the "move square env" action. - * @param performAction whether the action should be performed - * @return whether the action was or can be performed - */ - public boolean doMoveSquareEnv(final boolean performAction) { - final G gameObject = selectedSquareModel.getSelectedGameObject(); - if (gameObject == null || !gameObject.isHead()) { - return false; - } - - final G envGameObject = gameObject.getContainerGameObject(); - if (envGameObject == null) { - return false; - } - - final MapSquare<G, A, R> mapSquare = selectedSquareModel.getSelectedMapSquare(); - if (mapSquare == null) { - return false; - } - - final MapModel<G, A, R> mapModel = mapSquare.getMapModel(); - final Point pos = mapSquare.getMapLocation(); - if (!envGameObject.isInContainer() && gameObject.getArchetype().isMulti() && !mapModel.isMultiArchFittingToMap(gameObject.getArchetype(), pos, true)) { - return false; - } - - if (performAction) { - mapModel.beginTransaction("Move To Environment"); - try { - mapModel.moveEnv(gameObject, pos, envGameObject); - } finally { - mapModel.endTransaction(); - } - } - - return true; - } - - /** - * Executes the "move square inv" action. - * @param performAction whether the action should be performed - * @return whether the action was or can be performed - */ - public boolean doMoveSquareInv(final boolean performAction) { - final G gameObject = selectedSquareModel.getSelectedGameObject(); - if (gameObject == null || !gameObject.isHead()) { - return false; - } - - final GameObject<G, A, R> prevGameObject = gameObject.getPrev(); - if (prevGameObject == null) { - return false; - } - - if (performAction) { - final MapSquare<G, A, R> mapSquare = gameObject.getMapSquare(); - assert mapSquare != null; - final MapModel<G, A, R> mapModel = mapSquare.getMapModel(); - mapModel.beginTransaction("Move To Inventory"); - try { - mapModel.moveInv(gameObject, prevGameObject.getHead()); - } finally { - mapModel.endTransaction(); - } - } - - return true; - } - -} Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/panel/selectedsquare/SelectedSquareView.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/panel/selectedsquare/SelectedSquareView.java 2013-07-07 07:31:05 UTC (rev 9267) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/panel/selectedsquare/SelectedSquareView.java 2013-07-08 18:56:09 UTC (rev 9268) @@ -32,8 +32,6 @@ import java.awt.event.MouseListener; import java.awt.geom.RectangularShape; import java.io.File; -import java.util.ArrayList; -import java.util.Collection; import java.util.Set; import javax.swing.AbstractButton; import javax.swing.Action; @@ -67,9 +65,7 @@ import net.sf.gridarta.model.mapmodel.MapSquare; import net.sf.gridarta.model.mapviewsettings.MapViewSettings; import net.sf.gridarta.model.validation.ErrorCollector; -import net.sf.gridarta.utils.EditorAction; import net.sf.gridarta.utils.Size2D; -import net.sf.japi.swing.action.ActionMethod; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -82,7 +78,7 @@ * @author Andreas Kirschbaum * @todo turn this into a tree */ -public class SelectedSquareView<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> extends JPanel implements EditorAction { +public class SelectedSquareView<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> extends JPanel { /** * Serial Version UID. @@ -96,12 +92,6 @@ private final SelectedSquareModel<G, A, R> selectedSquareModel; /** - * The {@link SelectedSquareActions} for this controller. - */ - @NotNull - private final SelectedSquareActions<G, A, R> selectedSquareActions; - - /** * The {@link ModelUpdater} used for updating {@link #model}. */ @NotNull @@ -151,54 +141,6 @@ private MapCursor<G, A, R> mapCursor; /** - * The action for "move square prev". - */ - @Nullable - private Action aMoveSquarePrev; - - /** - * The action for "move square next". - */ - @Nullable - private Action aMoveSquareNext; - - /** - * The action for "move square top". - */ - @Nullable - private Action aMoveSquareTop; - - /** - * The action for "move square up". - */ - @Nullable - private Action aMoveSquareUp; - - /** - * The action for "move square down". - */ - @Nullable - private Action aMoveSquareDown; - - /** - * The action for "move square bottom". - */ - @Nullable - private Action aMoveSquareBottom; - - /** - * The action for "move square env". - */ - @Nullable - private Action aMoveSquareEnv; - - /** - * The action for "move square inv". - */ - @Nullable - private Action aMoveSquareInv; - - /** * The {@link MapModelListener} attached to {@link #mapModel}. */ @NotNull @@ -282,7 +224,6 @@ @Override public void selectionChanged(@Nullable final MapSquare<G, A, R> mapSquare, @Nullable final G gameObject) { refresh(); - updateActions(); } }; @@ -354,7 +295,6 @@ /** * Create a new instance. * @param selectedSquareModel the model for this view - * @param selectedSquareActions the selected square actions to use * @param gameObjectAttributesDialogFactory the factory for creating game * object attributes dialog instances * @param objectChooser the object chooser @@ -365,10 +305,10 @@ * @param faceObjectProviders the face object providers for looking up * faces * @param unknownSquareIcon the icon for unknown squares + * @param actions the actions to add */ - public SelectedSquareView(@NotNull final SelectedSquareModel<G, A, R> selectedSquareModel, @NotNull final SelectedSquareActions<G, A, R> selectedSquareActions, @NotNull final GameObjectAttributesDialogFactory<G, A, R> gameObjectAttributesDialogFactory, @NotNull final ObjectChooser<G, A, R> objectChooser, @NotNull final MapViewManager<G, A, R> mapViewManager, @NotNull final MapViewSettings mapViewSettings, @Nullable final ImageIcon compassIcon, @NotNull final FaceObjectProviders faceObjectProviders, @NotNull final Icon unknownSquareIcon) { + public SelectedSquareView(@NotNull final SelectedSquareModel<G, A, R> selectedSquareModel, @NotNull final GameObjectAttributesDialogFactory<G, A, R> gameObjectAttributesDialogFactory, @NotNull final ObjectChooser<G, A, R> objectChooser, @NotNull final MapViewManager<G, A, R> mapViewManager, @NotNull final MapViewSettings mapViewSettings, @Nullable final ImageIcon compassIcon, @NotNull final FaceObjectProviders faceObjectProviders, @NotNull final Icon unknownSquareIcon, @NotNull final Action... actions) { this.selectedSquareModel = selectedSquareModel; - this.selectedSquareActions = selectedSquareActions; this.gameObjectAttributesDialogFactory = gameObjectAttributesDialogFactory; this.objectChooser = objectChooser; @@ -383,6 +323,12 @@ scrollPane.getViewport().setScrollMode(JViewport.SIMPLE_SCROLL_MODE); add(scrollPane, BorderLayout.CENTER); + for (final Action tmpAction : actions) { + final AbstractButton button = new JButton(tmpAction); + button.setMargin(new Insets(0, 0, 0, 0)); + arrows.add(button); + } + updateArrows(false); if (compassIcon != null) { final Container compass = new JPanel(); @@ -395,6 +341,8 @@ mapViewManager.addMapViewManagerListener(mapViewManagerListener); selectedSquareModel.addSelectedSquareListener(selectedSquareModelListener); + + refresh(); } /** @@ -438,44 +386,6 @@ } /** - * Updates the enabled state of all actions. - */ - private void updateActions() { - if (aMoveSquarePrev != null) { - //noinspection ConstantConditions - aMoveSquarePrev.setEnabled(selectedSquareActions.doMoveSquarePrev(false)); - } - if (aMoveSquareNext != null) { - //noinspection ConstantConditions - aMoveSquareNext.setEnabled(selectedSquareActions.doMoveSquareNext(false)); - } - if (aMoveSquareTop != null) { - //noinspection ConstantConditions - aMoveSquareTop.setEnabled(selectedSquareActions.doMoveSquareTop(false)); - } - if (aMoveSquareUp != null) { - //noinspection ConstantConditions - aMoveSquareUp.setEnabled(selectedSquareActions.doMoveSquareUp(false)); - } - if (aMoveSquareDown != null) { - //noinspection ConstantConditions - aMoveSquareDown.setEnabled(selectedSquareActions.doMoveSquareDown(false)); - } - if (aMoveSquareBottom != null) { - //noinspection ConstantConditions - aMoveSquareBottom.setEnabled(selectedSquareActions.doMoveSquareBottom(false)); - } - if (aMoveSquareEnv != null) { - //noinspection ConstantConditions - aMoveSquareEnv.setEnabled(selectedSquareActions.doMoveSquareEnv(false)); - } - if (aMoveSquareInv != null) { - //noinspection ConstantConditions - aMoveSquareInv.setEnabled(selectedSquareActions.doMoveSquareInv(false)); - } - } - - /** * Re-display the map square panel for {@link SelectedSquareModel#selectedMapSquare}. * Possibly updates information in <code>selectedMapSquare</code>. */ @@ -486,7 +396,6 @@ } finally { list.setEnabled(true); } - updateActions(); } /** @@ -552,71 +461,6 @@ } /** - * Action method for selecting the previous game object. - */ - @ActionMethod - public void moveSquarePrev() { - selectedSquareActions.doMoveSquarePrev(true); - } ... [truncated message content] |
From: <aki...@us...> - 2013-07-07 07:31:18
|
Revision: 9267 http://sourceforge.net/p/gridarta/code/9267 Author: akirschbaum Date: 2013-07-07 07:31:05 +0000 (Sun, 07 Jul 2013) Log Message: ----------- Create actions in GUIMainControl. Modified Paths: -------------- trunk/src/atrinik/src/main/java/net/sf/gridarta/var/atrinik/maincontrol/DefaultEditorFactory.java trunk/src/crossfire/src/main/java/net/sf/gridarta/var/crossfire/maincontrol/DefaultEditorFactory.java trunk/src/daimonin/src/main/java/net/sf/gridarta/var/daimonin/maincontrol/DefaultEditorFactory.java trunk/src/gridarta/src/main/java/net/sf/gridarta/actions/AbstractServerActions.java trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/bookmarks/BookmarkActions.java trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/bookmarks/ManageBookmarksDialog.java trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/goexit/GoExitDialogManager.java trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gomap/GoMapDialogManager.java trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/newmap/NewMapDialogFactory.java trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/plugin/PluginController.java trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/plugin/PluginManagerFactory.java trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/shortcuts/ShortcutsManager.java trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/exitconnector/ExitConnectorController.java trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/map/MapFileActions.java trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/map/mapactions/MapActions.java trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/map/viewaction/ViewActions.java trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/mapcursor/MapCursorActions.java trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/mapdesktop/MapDesktop.java trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/mapfiles/MapFolderTreeActions.java trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/misc/About.java trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/misc/DefaultFileControl.java trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/misc/HelpActions.java trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/misc/MainViewActions.java trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/panel/archetypechooser/ArchetypeChooserControl.java trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/panel/archetypechooser/ArchetypeChooserView.java trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/panel/pickmapchooser/PickmapChooserControl.java trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/panel/selectedsquare/SelectedSquareView.java trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/treasurelist/CFTreasureListTree.java trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/undo/UndoControl.java trunk/src/gridarta/src/main/java/net/sf/gridarta/mainactions/MainActions.java trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/EditorFactory.java trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/GUIMainControl.java trunk/src/gridarta/src/main/java/net/sf/gridarta/updater/UpdaterManager.java trunk/src/textedit/src/main/java/net/sf/gridarta/textedit/scripteditor/ScriptEditControl.java trunk/src/utils/src/main/java/net/sf/gridarta/utils/ActionUtils.java Added Paths: ----------- trunk/src/gridarta/src/main/java/net/sf/gridarta/action/ trunk/src/gridarta/src/main/java/net/sf/gridarta/action/CleanCompletelyBlockedSquaresAction.java trunk/src/gridarta/src/main/java/net/sf/gridarta/action/CollectSpellsAction.java trunk/src/gridarta/src/main/java/net/sf/gridarta/action/ControlClientAction.java trunk/src/gridarta/src/main/java/net/sf/gridarta/action/ControlServerAction.java trunk/src/gridarta/src/main/java/net/sf/gridarta/action/DisplayArchetypeNamesAction.java trunk/src/gridarta/src/main/java/net/sf/gridarta/action/DisplayGameObjectNamesAction.java trunk/src/gridarta/src/main/java/net/sf/gridarta/action/DisplayIconsOnlyAction.java trunk/src/gridarta/src/main/java/net/sf/gridarta/action/ExitAction.java trunk/src/gridarta/src/main/java/net/sf/gridarta/action/GcAction.java trunk/src/gridarta/src/main/java/net/sf/gridarta/action/OptionsAction.java trunk/src/gridarta/src/main/java/net/sf/gridarta/action/ShortcutsAction.java trunk/src/gridarta/src/main/java/net/sf/gridarta/action/ZoomAction.java trunk/src/utils/src/main/java/net/sf/gridarta/utils/EditorAction.java Modified: trunk/src/atrinik/src/main/java/net/sf/gridarta/var/atrinik/maincontrol/DefaultEditorFactory.java =================================================================== --- trunk/src/atrinik/src/main/java/net/sf/gridarta/var/atrinik/maincontrol/DefaultEditorFactory.java 2013-07-06 21:50:34 UTC (rev 9266) +++ trunk/src/atrinik/src/main/java/net/sf/gridarta/var/atrinik/maincontrol/DefaultEditorFactory.java 2013-07-07 07:31:05 UTC (rev 9267) @@ -100,6 +100,7 @@ import net.sf.gridarta.plugin.PluginModel; import net.sf.gridarta.plugin.PluginParameters; import net.sf.gridarta.plugin.parameter.PluginParameterFactory; +import net.sf.gridarta.utils.EditorAction; import net.sf.gridarta.utils.GUIUtils; import net.sf.gridarta.utils.GuiFileFilters; import net.sf.gridarta.utils.IOUtils; @@ -486,9 +487,10 @@ /** * {@inheritDoc} */ + @NotNull @Override - public void newServerActions(@NotNull final MapViewManager<GameObject, MapArchObject, Archetype> mapViewManager, @NotNull final FileControl<GameObject, MapArchObject, Archetype> fileControl, @NotNull final PathManager pathManager) { - new AtrinikServerActions(mapViewManager, fileControl, pathManager); + public EditorAction newServerActions(@NotNull final MapViewManager<GameObject, MapArchObject, Archetype> mapViewManager, @NotNull final FileControl<GameObject, MapArchObject, Archetype> fileControl, @NotNull final PathManager pathManager) { + return new AtrinikServerActions(mapViewManager, fileControl, pathManager); } } Modified: trunk/src/crossfire/src/main/java/net/sf/gridarta/var/crossfire/maincontrol/DefaultEditorFactory.java =================================================================== --- trunk/src/crossfire/src/main/java/net/sf/gridarta/var/crossfire/maincontrol/DefaultEditorFactory.java 2013-07-06 21:50:34 UTC (rev 9266) +++ trunk/src/crossfire/src/main/java/net/sf/gridarta/var/crossfire/maincontrol/DefaultEditorFactory.java 2013-07-07 07:31:05 UTC (rev 9267) @@ -97,6 +97,7 @@ import net.sf.gridarta.plugin.PluginParameters; import net.sf.gridarta.plugin.parameter.PluginParameterFactory; import net.sf.gridarta.utils.ConfigFileUtils; +import net.sf.gridarta.utils.EditorAction; import net.sf.gridarta.utils.GUIUtils; import net.sf.gridarta.utils.GuiFileFilters; import net.sf.gridarta.utils.SystemIcons; @@ -398,9 +399,10 @@ /** * {@inheritDoc} */ + @Nullable @Override - public void newServerActions(@NotNull final MapViewManager<GameObject, MapArchObject, Archetype> mapViewManager, @NotNull final FileControl<GameObject, MapArchObject, Archetype> fileControl, @NotNull final PathManager pathManager) { - // do nothing: action not supported + public EditorAction newServerActions(@NotNull final MapViewManager<GameObject, MapArchObject, Archetype> mapViewManager, @NotNull final FileControl<GameObject, MapArchObject, Archetype> fileControl, @NotNull final PathManager pathManager) { + return null; // action not supported } } Modified: trunk/src/daimonin/src/main/java/net/sf/gridarta/var/daimonin/maincontrol/DefaultEditorFactory.java =================================================================== --- trunk/src/daimonin/src/main/java/net/sf/gridarta/var/daimonin/maincontrol/DefaultEditorFactory.java 2013-07-06 21:50:34 UTC (rev 9266) +++ trunk/src/daimonin/src/main/java/net/sf/gridarta/var/daimonin/maincontrol/DefaultEditorFactory.java 2013-07-07 07:31:05 UTC (rev 9267) @@ -100,6 +100,7 @@ import net.sf.gridarta.plugin.PluginModel; import net.sf.gridarta.plugin.PluginParameters; import net.sf.gridarta.plugin.parameter.PluginParameterFactory; +import net.sf.gridarta.utils.EditorAction; import net.sf.gridarta.utils.GUIUtils; import net.sf.gridarta.utils.GuiFileFilters; import net.sf.gridarta.utils.IOUtils; @@ -125,6 +126,7 @@ import org.apache.log4j.Category; import org.apache.log4j.Logger; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * An {@link EditorFactory} that creates Crossfire objects. @@ -485,9 +487,10 @@ /** * {@inheritDoc} */ + @Nullable @Override - public void newServerActions(@NotNull final MapViewManager<GameObject, MapArchObject, Archetype> mapViewManager, @NotNull final FileControl<GameObject, MapArchObject, Archetype> fileControl, @NotNull final PathManager pathManager) { - // do nothing: action not supported + public EditorAction newServerActions(@NotNull final MapViewManager<GameObject, MapArchObject, Archetype> mapViewManager, @NotNull final FileControl<GameObject, MapArchObject, Archetype> fileControl, @NotNull final PathManager pathManager) { + return null; // action not supported } } Added: trunk/src/gridarta/src/main/java/net/sf/gridarta/action/CleanCompletelyBlockedSquaresAction.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/action/CleanCompletelyBlockedSquaresAction.java (rev 0) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/action/CleanCompletelyBlockedSquaresAction.java 2013-07-07 07:31:05 UTC (rev 9267) @@ -0,0 +1,80 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2011 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.action; + +import javax.swing.Action; +import net.sf.gridarta.model.archetype.Archetype; +import net.sf.gridarta.model.baseobject.GameObjectContainer; +import net.sf.gridarta.model.gameobject.GameObject; +import net.sf.gridarta.model.maparchobject.MapArchObject; +import net.sf.gridarta.model.mapcontrol.MapControl; +import net.sf.gridarta.model.mapmanager.MapManager; +import net.sf.gridarta.model.mapmodel.MapModel; +import net.sf.gridarta.model.validation.checks.BlockedSquareChecker; +import net.sf.gridarta.utils.EditorAction; +import net.sf.japi.swing.action.ActionMethod; +import org.jetbrains.annotations.NotNull; + +/** + * @author Andreas Kirschbaum + */ +public class CleanCompletelyBlockedSquaresAction<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> implements EditorAction { + + @NotNull + private final MapManager<G, A, R> mapManager; + + /** + * Creates a new instance. + */ + public CleanCompletelyBlockedSquaresAction(@NotNull final MapManager<G, A, R> mapManager) { + this.mapManager = mapManager; + } + + /** + * The action method for "cleanCompletelyBlockedSquares". Cleans all + * completely blocked squares of a map. + * @fixme this implementation does not take care of multi square objects. + */ + @ActionMethod + public void cleanCompletelyBlockedSquares() { + final MapControl<G, A, R> mapControl = mapManager.getCurrentMap(); + if (mapControl == null) { + return; + } + + final MapModel<G, A, R> mapModel = mapControl.getMapModel(); + mapModel.beginTransaction("cleanCompletelyBlockedSquares"); // TODO: I18N/L10N + try { + for (final GameObjectContainer<G, A, R> completelyBlockedSquare : BlockedSquareChecker.findCompletelyBlockedSquares(mapModel)) { + completelyBlockedSquare.removeAll(); + } + } finally { + mapModel.endTransaction(); + } + } + + /** + * {@inheritDoc} + */ + @Override + public void setAction(@NotNull final Action action, @NotNull final String name) { + } + +} Property changes on: trunk/src/gridarta/src/main/java/net/sf/gridarta/action/CleanCompletelyBlockedSquaresAction.java ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +LF \ No newline at end of property Added: trunk/src/gridarta/src/main/java/net/sf/gridarta/action/CollectSpellsAction.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/action/CollectSpellsAction.java (rev 0) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/action/CollectSpellsAction.java 2013-07-07 07:31:05 UTC (rev 9267) @@ -0,0 +1,72 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2011 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.action; + +import java.awt.Component; +import javax.swing.Action; +import net.sf.gridarta.gui.spells.SpellsUtils; +import net.sf.gridarta.model.settings.GlobalSettings; +import net.sf.gridarta.utils.EditorAction; +import net.sf.japi.swing.action.ActionMethod; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * @author Andreas Kirschbaum + */ +public class CollectSpellsAction implements EditorAction { + + @Nullable + private final SpellsUtils spellsUtils; + + @NotNull + private final GlobalSettings globalSettings; + + @NotNull + private final Component parent; + + /** + * Creates a new instance. + */ + public CollectSpellsAction(@Nullable final SpellsUtils spellsUtils, @NotNull final GlobalSettings globalSettings, @NotNull final Component parent) { + this.spellsUtils = spellsUtils; + this.globalSettings = globalSettings; + this.parent = parent; + } + + /** + * The action method for "collectSpells". Opens the dialog to import spell + * definitions. + */ + @ActionMethod + public void collectSpells() { + if (spellsUtils != null) { + spellsUtils.importSpells(globalSettings.getConfigurationDirectory(), parent); + } + } + + /** + * {@inheritDoc} + */ + @Override + public void setAction(@NotNull final Action action, @NotNull final String name) { + } + +} Property changes on: trunk/src/gridarta/src/main/java/net/sf/gridarta/action/CollectSpellsAction.java ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +LF \ No newline at end of property Added: trunk/src/gridarta/src/main/java/net/sf/gridarta/action/ControlClientAction.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/action/ControlClientAction.java (rev 0) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/action/ControlClientAction.java 2013-07-07 07:31:05 UTC (rev 9267) @@ -0,0 +1,78 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2011 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.action; + +import javax.swing.Action; +import javax.swing.JFrame; +import net.sf.gridarta.gui.dialog.prefs.AppPreferencesModel; +import net.sf.gridarta.utils.EditorAction; +import net.sf.gridarta.utils.ProcessRunner; +import net.sf.japi.swing.action.ActionMethod; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * @author Andreas Kirschbaum + */ +public class ControlClientAction implements EditorAction { + + @NotNull + private final AppPreferencesModel appPreferencesModel; + + @NotNull + private final JFrame parent; + + /** + * The {@link ProcessRunner} instance that controls the client. Set to + * <code>null</code> if not yet created. + */ + @Nullable + private ProcessRunner controlClient; + + /** + * {@inheritDoc} + */ + public ControlClientAction(@NotNull final AppPreferencesModel appPreferencesModel, @NotNull final JFrame parent) { + this.appPreferencesModel = appPreferencesModel; + this.parent = parent; + } + + /** + * The action method for "controlClient". Opens the dialog to control the + * client. + */ + @ActionMethod + public void controlClient() { + if (controlClient == null) { + controlClient = new ProcessRunner("controlClient", new String[] { appPreferencesModel.getClient(), }); + } else { + controlClient.setCommand(new String[] { appPreferencesModel.getClient(), }); + } + controlClient.showDialog(parent); + } + + /** + * {@inheritDoc} + */ + @Override + public void setAction(@NotNull final Action action, @NotNull final String name) { + } + +} Property changes on: trunk/src/gridarta/src/main/java/net/sf/gridarta/action/ControlClientAction.java ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +LF \ No newline at end of property Added: trunk/src/gridarta/src/main/java/net/sf/gridarta/action/ControlServerAction.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/action/ControlServerAction.java (rev 0) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/action/ControlServerAction.java 2013-07-07 07:31:05 UTC (rev 9267) @@ -0,0 +1,87 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2011 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.action; + +import javax.swing.Action; +import javax.swing.JFrame; +import javax.swing.JOptionPane; +import net.sf.gridarta.gui.dialog.prefs.AppPreferencesModel; +import net.sf.gridarta.utils.EditorAction; +import net.sf.gridarta.utils.ProcessRunner; +import net.sf.japi.swing.action.ActionBuilder; +import net.sf.japi.swing.action.ActionBuilderFactory; +import net.sf.japi.swing.action.ActionMethod; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * @author Andreas Kirschbaum + */ +public class ControlServerAction implements EditorAction { + + /** + * The {@link ActionBuilder}. + */ + private static final ActionBuilder ACTION_BUILDER = ActionBuilderFactory.getInstance().getActionBuilder("net.sf.gridarta"); + + @NotNull + private final AppPreferencesModel appPreferencesModel; + + @NotNull + private final JFrame parent; + + /** + * The {@link ProcessRunner} instance that controls the server. Set to + * <code>null</code> if not yet created. + */ + @Nullable + private ProcessRunner controlServer; + + /** + * Creates a new instance. + */ + public ControlServerAction(@NotNull final AppPreferencesModel appPreferencesModel, @NotNull final JFrame parent) { + this.appPreferencesModel = appPreferencesModel; + this.parent = parent; + } + + /** + * The action method for "controlServer". Opens the dialog to control the + * server. + */ + @ActionMethod + public void controlServer() { + if (controlServer == null) { + controlServer = new ProcessRunner("controlServer", new String[] { appPreferencesModel.getServer(), }); + ACTION_BUILDER.showOnetimeMessageDialog(parent, JOptionPane.WARNING_MESSAGE, "controlServerWarning"); + } else { + controlServer.setCommand(new String[] { appPreferencesModel.getServer(), }); + } + controlServer.showDialog(parent); + } + + /** + * {@inheritDoc} + */ + @Override + public void setAction(@NotNull final Action action, @NotNull final String name) { + } + +} Property changes on: trunk/src/gridarta/src/main/java/net/sf/gridarta/action/ControlServerAction.java ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +LF \ No newline at end of property Added: trunk/src/gridarta/src/main/java/net/sf/gridarta/action/DisplayArchetypeNamesAction.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/action/DisplayArchetypeNamesAction.java (rev 0) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/action/DisplayArchetypeNamesAction.java 2013-07-07 07:31:05 UTC (rev 9267) @@ -0,0 +1,66 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2011 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.action; + +import javax.swing.Action; +import net.sf.gridarta.model.archetype.Archetype; +import net.sf.gridarta.model.archetypechooser.ArchetypeChooserModel; +import net.sf.gridarta.model.archetypechooser.DisplayMode; +import net.sf.gridarta.model.gameobject.GameObject; +import net.sf.gridarta.model.maparchobject.MapArchObject; +import net.sf.gridarta.utils.EditorAction; +import net.sf.japi.swing.action.ActionMethod; +import org.jetbrains.annotations.NotNull; + +/** + * @author Andreas Kirschbaum + */ +public class DisplayArchetypeNamesAction<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> implements EditorAction { + + @NotNull + private final ArchetypeChooserModel<G, A, R> archetypeChooserModel; + + @NotNull + private final DisplayMode<G, A, R> displayMode; + + /** + * Creates a new instance. + */ + public DisplayArchetypeNamesAction(@NotNull final ArchetypeChooserModel<G, A, R> archetypeChooserModel, @NotNull final DisplayMode<G, A, R> displayMode) { + this.archetypeChooserModel = archetypeChooserModel; + this.displayMode = displayMode; + } + + /** + * Sets whether game object names are shown. + */ + @ActionMethod + public void displayArchetypeNames() { + archetypeChooserModel.setDisplayMode(displayMode); + } + + /** + * {@inheritDoc} + */ + @Override + public void setAction(@NotNull final Action action, @NotNull final String name) { + } + +} Property changes on: trunk/src/gridarta/src/main/java/net/sf/gridarta/action/DisplayArchetypeNamesAction.java ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +LF \ No newline at end of property Added: trunk/src/gridarta/src/main/java/net/sf/gridarta/action/DisplayGameObjectNamesAction.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/action/DisplayGameObjectNamesAction.java (rev 0) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/action/DisplayGameObjectNamesAction.java 2013-07-07 07:31:05 UTC (rev 9267) @@ -0,0 +1,66 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2011 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.action; + +import javax.swing.Action; +import net.sf.gridarta.model.archetype.Archetype; +import net.sf.gridarta.model.archetypechooser.ArchetypeChooserModel; +import net.sf.gridarta.model.archetypechooser.DisplayMode; +import net.sf.gridarta.model.gameobject.GameObject; +import net.sf.gridarta.model.maparchobject.MapArchObject; +import net.sf.gridarta.utils.EditorAction; +import net.sf.japi.swing.action.ActionMethod; +import org.jetbrains.annotations.NotNull; + +/** + * @author Andreas Kirschbaum + */ +public class DisplayGameObjectNamesAction<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> implements EditorAction { + + @NotNull + private final ArchetypeChooserModel<G, A, R> archetypeChooserModel; + + @NotNull + private final DisplayMode<G, A, R> displayMode; + + /** + * Creates a new instance. + */ + public DisplayGameObjectNamesAction(@NotNull final ArchetypeChooserModel<G, A, R> archetypeChooserModel, @NotNull final DisplayMode<G, A, R> displayMode) { + this.archetypeChooserModel = archetypeChooserModel; + this.displayMode = displayMode; + } + + /** + * Sets whether game object names are shown. + */ + @ActionMethod + public void displayGameObjectNames() { + archetypeChooserModel.setDisplayMode(displayMode); + } + + /** + * {@inheritDoc} + */ + @Override + public void setAction(@NotNull final Action action, @NotNull final String name) { + } + +} Property changes on: trunk/src/gridarta/src/main/java/net/sf/gridarta/action/DisplayGameObjectNamesAction.java ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +LF \ No newline at end of property Added: trunk/src/gridarta/src/main/java/net/sf/gridarta/action/DisplayIconsOnlyAction.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/action/DisplayIconsOnlyAction.java (rev 0) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/action/DisplayIconsOnlyAction.java 2013-07-07 07:31:05 UTC (rev 9267) @@ -0,0 +1,66 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2011 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.action; + +import javax.swing.Action; +import net.sf.gridarta.model.archetype.Archetype; +import net.sf.gridarta.model.archetypechooser.ArchetypeChooserModel; +import net.sf.gridarta.model.archetypechooser.DisplayMode; +import net.sf.gridarta.model.gameobject.GameObject; +import net.sf.gridarta.model.maparchobject.MapArchObject; +import net.sf.gridarta.utils.EditorAction; +import net.sf.japi.swing.action.ActionMethod; +import org.jetbrains.annotations.NotNull; + +/** + * @author Andreas Kirschbaum + */ +public class DisplayIconsOnlyAction<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> implements EditorAction { + + @NotNull + private final ArchetypeChooserModel<G, A, R> archetypeChooserModel; + + @NotNull + private final DisplayMode<G, A, R> displayMode; + + /** + * Creates a new instance. + */ + public DisplayIconsOnlyAction(@NotNull final ArchetypeChooserModel<G, A, R> archetypeChooserModel, @NotNull final DisplayMode<G, A, R> displayMode) { + this.archetypeChooserModel = archetypeChooserModel; + this.displayMode = displayMode; + } + + /** + * Sets whether game object names are shown. + */ + @ActionMethod + public void displayIconsOnly() { + archetypeChooserModel.setDisplayMode(displayMode); + } + + /** + * {@inheritDoc} + */ + @Override + public void setAction(@NotNull final Action action, @NotNull final String name) { + } + +} Property changes on: trunk/src/gridarta/src/main/java/net/sf/gridarta/action/DisplayIconsOnlyAction.java ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +LF \ No newline at end of property Added: trunk/src/gridarta/src/main/java/net/sf/gridarta/action/ExitAction.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/action/ExitAction.java (rev 0) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/action/ExitAction.java 2013-07-07 07:31:05 UTC (rev 9267) @@ -0,0 +1,90 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2011 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.action; + +import javax.swing.Action; +import net.sf.gridarta.gui.dialog.plugin.PluginController; +import net.sf.gridarta.gui.panel.pickmapchooser.PickmapChooserControl; +import net.sf.gridarta.model.mapmanager.FileControl; +import net.sf.gridarta.textedit.scripteditor.ScriptEditControl; +import net.sf.gridarta.utils.EditorAction; +import net.sf.gridarta.utils.Exiter; +import net.sf.japi.swing.action.ActionMethod; +import org.jetbrains.annotations.NotNull; + +/** + * @author Andreas Kirschbaum + */ +public class ExitAction implements EditorAction { + + @NotNull + private final Exiter exiter; + + @NotNull + private final ScriptEditControl scriptEditControl; + + @NotNull + private final FileControl<?, ?, ?> fileControl; + + @NotNull + private final PickmapChooserControl<?, ?, ?> pickmapChooserControl; + + @NotNull + private final PluginController<?, ?, ?> pluginControl; + + /** + * Creates a new instance. + */ + public ExitAction(@NotNull final Exiter exiter, @NotNull final ScriptEditControl scriptEditControl, @NotNull final FileControl<?, ?, ?> fileControl, @NotNull final PickmapChooserControl<?, ?, ?> pickmapChooserControl, @NotNull final PluginController<?, ?, ?> pluginControl) { + this.exiter = exiter; + this.scriptEditControl = scriptEditControl; + this.fileControl = fileControl; + this.pickmapChooserControl = pickmapChooserControl; + this.pluginControl = pluginControl; + } + + /** + * The action method for "exit". Invoked when user wants to exit from the + * program. + */ + @ActionMethod + public void exit() { + if (canExit()) { + exiter.doExit(0); + } + } + + /** + * Prepares existing the application: save modified data (possibly ask the + * user if applicable). + * @return whether all modified data has been saved + */ + private boolean canExit() { + return scriptEditControl.closeAllTabs() && fileControl.closeAllMaps() && pickmapChooserControl.canExit() && pluginControl.canExit(); + } + + /** + * {@inheritDoc} + */ + @Override + public void setAction(@NotNull final Action action, @NotNull final String name) { + } + +} Property changes on: trunk/src/gridarta/src/main/java/net/sf/gridarta/action/ExitAction.java ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +LF \ No newline at end of property Added: trunk/src/gridarta/src/main/java/net/sf/gridarta/action/GcAction.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/action/GcAction.java (rev 0) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/action/GcAction.java 2013-07-07 07:31:05 UTC (rev 9267) @@ -0,0 +1,61 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2011 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.action; + +import javax.swing.Action; +import net.sf.gridarta.gui.misc.StatusBar; +import net.sf.gridarta.utils.EditorAction; +import net.sf.japi.swing.action.ActionMethod; +import org.jetbrains.annotations.NotNull; + +/** + * @author Andreas Kirschbaum + */ +public class GcAction implements EditorAction { + + @NotNull + private final StatusBar<?, ?, ?> statusBar; + + /** + * Creates a new instance. + */ + public GcAction(@NotNull final StatusBar<?, ?, ?> statusBar) { + this.statusBar = statusBar; + } + + /** + * The action method for "gc". Runs the garbage collection. + */ + @ActionMethod + public void gc() { + //noinspection CallToSystemGC + System.gc(); + System.runFinalization(); + statusBar.setStatusText("Garbage collection - done."); + } + + /** + * {@inheritDoc} + */ + @Override + public void setAction(@NotNull final Action action, @NotNull final String name) { + } + +} Property changes on: trunk/src/gridarta/src/main/java/net/sf/gridarta/action/GcAction.java ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +LF \ No newline at end of property Added: trunk/src/gridarta/src/main/java/net/sf/gridarta/action/OptionsAction.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/action/OptionsAction.java (rev 0) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/action/OptionsAction.java 2013-07-07 07:31:05 UTC (rev 9267) @@ -0,0 +1,104 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2011 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.action; + +import java.awt.Component; +import javax.swing.Action; +import net.sf.gridarta.gui.dialog.prefs.AppPreferencesModel; +import net.sf.gridarta.maincontrol.EditorFactory; +import net.sf.gridarta.model.archetype.Archetype; +import net.sf.gridarta.model.configsource.ConfigSourceFactory; +import net.sf.gridarta.model.exitconnector.ExitConnectorModel; +import net.sf.gridarta.model.gameobject.GameObject; +import net.sf.gridarta.model.maparchobject.MapArchObject; +import net.sf.gridarta.model.settings.GlobalSettings; +import net.sf.gridarta.model.validation.DelegatingMapValidator; +import net.sf.gridarta.utils.EditorAction; +import net.sf.japi.swing.action.ActionMethod; +import net.sf.japi.swing.prefs.PreferencesGroup; +import net.sf.japi.swing.prefs.PreferencesPane; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * @author Andreas Kirschbaum + */ +public class OptionsAction<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> implements EditorAction { + + @NotNull + private final EditorFactory<G, A, R> editorFactory; + + @NotNull + private final GlobalSettings globalSettings; + + @NotNull + private final DelegatingMapValidator<G, A, R> validators; + + @NotNull + private final AppPreferencesModel appPreferencesModel; + + @NotNull + private final ExitConnectorModel exitConnectorModel; + + @NotNull + private final ConfigSourceFactory configSourceFactory; + + @NotNull + private final Component parent; + + /** + * The {@link PreferencesGroup} instance. Set to <code>null</code> if not + * yet created. + */ + @Nullable + private PreferencesGroup preferencesGroup; + + /** + * Creates a new instance. + */ + public OptionsAction(@NotNull final EditorFactory<G, A, R> editorFactory, @NotNull final GlobalSettings globalSettings, @NotNull final DelegatingMapValidator<G, A, R> validators, @NotNull final AppPreferencesModel appPreferencesModel, @NotNull final ExitConnectorModel exitConnectorModel, @NotNull final ConfigSourceFactory configSourceFactory, @NotNull final Component parent) { + this.editorFactory = editorFactory; + this.globalSettings = globalSettings; + this.validators = validators; + this.appPreferencesModel = appPreferencesModel; + this.exitConnectorModel = exitConnectorModel; + this.configSourceFactory = configSourceFactory; + this.parent = parent; + } + + /** + * The action method for "options". Opens the options dialog. + */ + @ActionMethod + public void options() { + if (preferencesGroup == null) { + preferencesGroup = editorFactory.createPreferencesGroup(globalSettings, validators, appPreferencesModel, exitConnectorModel, configSourceFactory); + } + PreferencesPane.showPreferencesDialog(parent, preferencesGroup, false); + } + + /** + * {@inheritDoc} + */ + @Override + public void setAction(@NotNull final Action action, @NotNull final String name) { + } + +} Property changes on: trunk/src/gridarta/src/main/java/net/sf/gridarta/action/OptionsAction.java ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +LF \ No newline at end of property Added: trunk/src/gridarta/src/main/java/net/sf/gridarta/action/ShortcutsAction.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/action/ShortcutsAction.java (rev 0) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/action/ShortcutsAction.java 2013-07-07 07:31:05 UTC (rev 9267) @@ -0,0 +1,64 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2011 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.action; + +import java.awt.Component; +import javax.swing.Action; +import net.sf.gridarta.gui.dialog.shortcuts.ShortcutsManager; +import net.sf.gridarta.utils.EditorAction; +import net.sf.japi.swing.action.ActionMethod; +import org.jetbrains.annotations.NotNull; + +/** + * @author Andreas Kirschbaum + */ +public class ShortcutsAction implements EditorAction { + + @NotNull + private final ShortcutsManager shortcutsManager; + + @NotNull + private final Component parent; + + /** + * Creates a new instance. + */ + public ShortcutsAction(@NotNull final ShortcutsManager shortcutsManager, @NotNull final Component parent) { + this.shortcutsManager = shortcutsManager; + this.parent = parent; + } + + /** + * The action method for "shortcuts". Opens the dialog to configure keyboard + * shortcuts. + */ + @ActionMethod + public void shortcuts() { + shortcutsManager.showShortcutsDialog(parent); + } + + /** + * {@inheritDoc} + */ + @Override + public void setAction(@NotNull final Action action, @NotNull final String name) { + } + +} Property changes on: trunk/src/gridarta/src/main/java/net/sf/gridarta/action/ShortcutsAction.java ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +LF \ No newline at end of property Added: trunk/src/gridarta/src/main/java/net/sf/gridarta/action/ZoomAction.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/action/ZoomAction.java (rev 0) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/action/ZoomAction.java 2013-07-07 07:31:05 UTC (rev 9267) @@ -0,0 +1,80 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2011 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.action; + +import java.awt.Component; +import javax.swing.Action; +import javax.swing.JOptionPane; +import net.sf.gridarta.gui.map.renderer.RendererFactory; +import net.sf.gridarta.gui.misc.MapPreview; +import net.sf.gridarta.model.archetype.Archetype; +import net.sf.gridarta.model.gameobject.GameObject; +import net.sf.gridarta.model.maparchobject.MapArchObject; +import net.sf.gridarta.model.mapcontrol.MapControl; +import net.sf.gridarta.model.mapmanager.MapManager; +import net.sf.gridarta.utils.EditorAction; +import net.sf.japi.swing.action.ActionMethod; +import org.jetbrains.annotations.NotNull; + +/** + * @author Andreas Kirschbaum + */ +public class ZoomAction<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> implements EditorAction { + + @NotNull + private final MapManager<G, A, R> mapManager; + + @NotNull + private final RendererFactory<G, A, R> rendererFactory; + + @NotNull + private final Component parent; + + /** + * Creates a new instance. + */ + public ZoomAction(@NotNull final MapManager<G, A, R> mapManager, @NotNull final RendererFactory<G, A, R> rendererFactory, @NotNull final Component parent) { + this.mapManager = mapManager; + this.rendererFactory = rendererFactory; + this.parent = parent; + } + + /** + * The action method for "zoom". Opens the dialog to create zoomed images of + * the current map. + */ + @ActionMethod + public void zoom() { + final MapControl<G, A, R> mapControl = mapManager.getCurrentMap(); + if (mapControl == null) { + JOptionPane.showMessageDialog(parent, "No map loaded! Please load a map!!", "Error", JOptionPane.ERROR_MESSAGE); + return; + } + new MapPreview(rendererFactory.newSimpleMapRenderer(mapControl.getMapModel()).getFullImage()); + } + + /** + * {@inheritDoc} + */ + @Override + public void setAction(@NotNull final Action action, @NotNull final String name) { + } + +} Property changes on: trunk/src/gridarta/src/main/java/net/sf/gridarta/action/ZoomAction.java ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +LF \ No newline at end of property Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/actions/AbstractServerActions.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/actions/AbstractServerActions.java 2013-07-06 21:50:34 UTC (rev 9266) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/actions/AbstractServerActions.java 2013-07-07 07:31:05 UTC (rev 9267) @@ -33,7 +33,7 @@ import net.sf.gridarta.model.mapcontrol.MapControl; import net.sf.gridarta.model.mapmanager.FileControl; import net.sf.gridarta.model.mapmodel.MapModel; -import net.sf.gridarta.utils.ActionUtils; +import net.sf.gridarta.utils.EditorAction; import net.sf.japi.swing.action.ActionBuilder; import net.sf.japi.swing.action.ActionBuilderFactory; import net.sf.japi.swing.action.ActionMethod; @@ -45,7 +45,7 @@ * @author Andreas Kirschbaum * @noinspection AbstractClassWithOnlyOneDirectInheritor */ -public abstract class AbstractServerActions<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> { +public abstract class AbstractServerActions<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> implements EditorAction { /** * Action Builder to create Actions. @@ -75,8 +75,8 @@ * The action for "open in client". * @noinspection ThisEscapedInObjectConstruction */ - @NotNull - private final Action aOpenInClient = ActionUtils.newAction(ACTION_BUILDER, "Map", this, "openInClient"); + @Nullable + private Action aOpenInClient; /** * The map manager listener which is attached to the current map if the @@ -116,7 +116,6 @@ this.pathManager = pathManager; mapViewManager.addMapViewManagerListener(mapViewManagerListener); currentMapView = mapViewManager.getActiveMapView(); - updateActions(); } /** @@ -131,7 +130,10 @@ * Update the enabled/disabled state of all actions. */ private void updateActions() { - aOpenInClient.setEnabled(doOpenInClient(false)); + if (aOpenInClient != null) { + //noinspection ConstantConditions + aOpenInClient.setEnabled(doOpenInClient(false)); + } } /** @@ -192,4 +194,13 @@ */ protected abstract void teleportCharacterToMap(@NotNull final String mapPath, final int mapX, final int mapY) throws IOException; + /** + * {@inheritDoc} + */ + @Override + public void setAction(@NotNull final Action action, @NotNull final String name) { + aOpenInClient = action; + updateActions(); + } + } Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/bookmarks/BookmarkActions.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/bookmarks/BookmarkActions.java 2013-07-06 21:50:34 UTC (rev 9266) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/bookmarks/BookmarkActions.java 2013-07-07 07:31:05 UTC (rev 9267) @@ -34,9 +34,7 @@ import net.sf.gridarta.model.maparchobject.MapArchObject; import net.sf.gridarta.model.mapcontrol.MapControl; import net.sf.gridarta.model.mapmodel.MapModel; -import net.sf.gridarta.utils.ActionUtils; -import net.sf.japi.swing.action.ActionBuilder; -import net.sf.japi.swing.action.ActionBuilderFactory; +import net.sf.gridarta.utils.EditorAction; import net.sf.japi.swing.action.ActionMethod; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -45,15 +43,9 @@ * Implements actions for managing bookmarks. * @author Andreas Kirschbaum */ -public class BookmarkActions<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> { +public class BookmarkActions<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> implements EditorAction { /** - * The {@link ActionBuilder} instance. - */ - @NotNull - private static final ActionBuilder ACTION_BUILDER = ActionBuilderFactory.getInstance().getActionBuilder("net.sf.gridarta"); - - /** * The {@link AbstractMapMenuPreferences} for adding new bookmarks. */ @NotNull @@ -86,8 +78,8 @@ /** * The {@link Action} for "add bookmark". */ - @NotNull - private final Action aAddBookmark = ActionUtils.newAction(ACTION_BUILDER, "Bookmarks", this, "addBookmark"); + @Nullable + private Action aAddBookmark; /** * The {@link ManageBookmarksDialog} instance. Set to <code>null</code> if @@ -111,8 +103,6 @@ this.mapViewManager = mapViewManager; this.parentComponent = parentComponent; this.mapImageCache = mapImageCache; - ActionUtils.newAction(ACTION_BUILDER, "Bookmarks", this, "manageBookmarks"); - final MapViewManagerListener<G, A, R> mapViewManagerListener = new MapViewManagerListener<G, A, R>() { @Override @@ -132,8 +122,6 @@ }; mapViewManager.addMapViewManagerListener(mapViewManagerListener); - - updateActions(); } /** @@ -161,7 +149,10 @@ * Updates the enabled state of all actions. */ private void updateActions() { - aAddBookmark.setEnabled(doAddBookmark(false)); + if (aAddBookmark != null) { + //noinspection ConstantConditions + aAddBookmark.setEnabled(doAddBookmark(false)); + } } /** @@ -194,4 +185,15 @@ return true; } + /** + * {@inheritDoc} + */ + @Override + public void setAction(@NotNull final Action action, @NotNull final String name) { + if (name.equals("addBookmark")) { + aAddBookmark = action; + updateActions(); + } + } + } Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/bookmarks/ManageBookmarksDialog.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/bookmarks/ManageBookmarksDialog.java 2013-07-06 21:50:34 UTC (rev 9266) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/bookmarks/ManageBookmarksDialog.java 2013-07-07 07:31:05 UTC (rev 9267) @@ -188,8 +188,6 @@ dialog.setModal(false); dialog.setResizable(true); dialog.pack(); - - updateActions(); } /** Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/goexit/GoExitDialogManager.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/goexit/GoExitDialogManager.java 2013-07-06 21:50:34 UTC (rev 9266) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/goexit/GoExitDialogManager.java 2013-07-07 07:31:05 UTC (rev 9267) @@ -20,6 +20,7 @@ package net.sf.gridarta.gui.dialog.goexit; import java.awt.Window; +import javax.swing.Action; import net.sf.gridarta.gui.map.mapactions.EnterMap; import net.sf.gridarta.gui.map.mapview.MapView; import net.sf.gridarta.gui.map.mapview.MapViewManager; @@ -31,6 +32,7 @@ import net.sf.gridarta.model.mapcontrol.MapControl; import net.sf.gridarta.model.mapmanager.MapManager; import net.sf.gridarta.model.match.GameObjectMatcher; +import net.sf.gridarta.utils.EditorAction; import net.sf.japi.swing.action.ActionMethod; import org.jetbrains.annotations.NotNull; @@ -38,7 +40,7 @@ * Manager for {@link GoExitDialog} instances. * @author Andreas Kirschbaum */ -public class GoExitDialogManager<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> { +public class GoExitDialogManager<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> implements EditorAction { /** * The parent {@link Window} for go map dialogs. @@ -120,4 +122,11 @@ new GoExitDialog<G, A, R>(parent, mapView, exitGameObjectMatcher, pathManager, enterMap, faceObjectProviders).showDialog(); } + /** + * {@inheritDoc} + */ + @Override + public void setAction(@NotNull final Action action, @NotNull final String name) { + } + } Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gomap/GoMapDialogManager.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gomap/GoMapDialogManager.java 2013-07-06 21:50:34 UTC (rev 9266) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gomap/GoMapDialogManager.java 2013-07-07 07:31:05 UTC (rev 9267) @@ -20,6 +20,7 @@ package net.sf.gridarta.gui.dialog.gomap; import java.awt.Window; +import javax.swing.Action; import net.sf.gridarta.gui.map.mapview.MapViewsManager; import net.sf.gridarta.model.archetype.Archetype; import net.sf.gridarta.model.gameobject.GameObject; @@ -28,6 +29,7 @@ import net.sf.gridarta.model.maparchobject.MapArchObject; import net.sf.gridarta.model.mapmanager.MapManager; import net.sf.gridarta.model.settings.GlobalSettings; +import net.sf.gridarta.utils.EditorAction; import net.sf.gridarta.utils.Exiter; import net.sf.gridarta.utils.ExiterListener; import net.sf.japi.swing.action.ActionMethod; @@ -39,7 +41,7 @@ * Manager for {@link GoMapDialog} instances. * @author Andreas Kirschbaum */ -public class GoMapDialogManager<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> { +public class GoMapDialogManager<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> implements EditorAction { /** * The Logger for printing log messages. @@ -117,4 +119,11 @@ new GoMapDialog<G, A, R>(parent, mapsIndex, mapViewsManager).showDialog(); } + /** + * {@inheritDoc} + */ + @Override + public void setAction(@NotNull final Action action, @NotNull final String name) { + } + } Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/newmap/NewMapDialogFactory.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/newmap/NewMapDialogFactory.java 2013-07-06 21:50:34 UTC (rev 9266) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/newmap/NewMapDialogFactory.java 2013-07-07 07:31:05 UTC (rev 9267) @@ -20,6 +20,7 @@ p... [truncated message content] |
From: <aki...@us...> - 2013-07-06 21:50:41
|
Revision: 9266 http://sourceforge.net/p/gridarta/code/9266 Author: akirschbaum Date: 2013-07-06 21:50:34 +0000 (Sat, 06 Jul 2013) Log Message: ----------- Move displayMode field from ArchetypeChooserView to ArchetypeChooserModel. Modified Paths: -------------- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/panel/archetypechooser/ArchetypeChooserView.java trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/panel/archetypechooser/ArchetypeIconCellRenderer.java trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/panel/archetypechooser/ArchetypeNameCellRenderer.java trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/panel/archetypechooser/ArchetypePanel.java trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/panel/archetypechooser/DirectionPane.java trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/panel/archetypechooser/DisplayNameCellRenderer.java trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/panel/objectchooser/DefaultObjectChooser.java trunk/src/model/src/main/java/net/sf/gridarta/model/archetypechooser/ArchetypeChooserModel.java trunk/src/model/src/main/java/net/sf/gridarta/model/archetypechooser/ArchetypeChooserModelListener.java Added Paths: ----------- trunk/src/model/src/main/java/net/sf/gridarta/model/archetypechooser/DisplayMode.java Removed Paths: ------------- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/panel/archetypechooser/ArchetypeChooserViewListener.java trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/panel/archetypechooser/DisplayMode.java Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/panel/archetypechooser/ArchetypeChooserView.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/panel/archetypechooser/ArchetypeChooserView.java 2013-07-06 13:19:37 UTC (rev 9265) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/panel/archetypechooser/ArchetypeChooserView.java 2013-07-06 21:50:34 UTC (rev 9266) @@ -20,8 +20,6 @@ package net.sf.gridarta.gui.panel.archetypechooser; import java.awt.BorderLayout; -import java.util.ArrayList; -import java.util.Collection; import java.util.prefs.Preferences; import javax.swing.AbstractButton; import javax.swing.BorderFactory; @@ -34,8 +32,11 @@ import javax.swing.event.ChangeListener; import net.sf.gridarta.MainControl; import net.sf.gridarta.model.archetype.Archetype; +import net.sf.gridarta.model.archetypechooser.ArchetypeChooserFolder; import net.sf.gridarta.model.archetypechooser.ArchetypeChooserModel; +import net.sf.gridarta.model.archetypechooser.ArchetypeChooserModelListener; import net.sf.gridarta.model.archetypechooser.ArchetypeChooserPanel; +import net.sf.gridarta.model.archetypechooser.DisplayMode; import net.sf.gridarta.model.face.FaceObjectProviders; import net.sf.gridarta.model.face.FaceObjectProvidersListener; import net.sf.gridarta.model.gameobject.GameObject; @@ -78,12 +79,6 @@ private static final Preferences preferences = Preferences.userNodeForPackage(MainControl.class); /** - * The registered listeners. - */ - @NotNull - private final Collection<ArchetypeChooserViewListener<G, A, R>> listeners = new ArrayList<ArchetypeChooserViewListener<G, A, R>>(); - - /** * The button for "display game object names". * @serial */ @@ -119,13 +114,6 @@ private final JTabbedPane tabDesktop = new JTabbedPane(SwingConstants.TOP); /** - * Indicates whether object names are shown. - * @serial - */ - @NotNull - private DisplayMode<G, A, R> displayMode; - - /** * The list cell renderer displaying object names. * @serial */ @@ -176,6 +164,37 @@ displayModeArchetypeNames = new ArchetypeNameCellRenderer<G, A, R>(faceObjectProviders); displayModeIconsOnly = new ArchetypeIconCellRenderer<G, A, R>(faceObjectProviders); + archetypeChooserModel.addArchetypeChooserModelListener(new ArchetypeChooserModelListener<G, A, R>() { + + @Override + public void selectedPanelChanged(@NotNull final ArchetypeChooserPanel<G, A, R> selectedPanel) { + } + + @Override + public void selectedFolderChanged(@NotNull final ArchetypeChooserFolder<G, A, R> selectedFolder) { + } + + @Override + public void selectedArchetypeChanged(@Nullable final R selectedArchetype) { + } + + @Override + public void directionChanged(@Nullable final Integer direction) { + } + + @Override + public void displayModeChanged(@NotNull final DisplayMode<G, A, R> displayMode) { + if (displayMode == displayModeGameObjectNames) { + preferences.putInt(DISPLAY_MODE_KEY, 0); + } else if (displayMode == displayModeArchetypeNames) { + preferences.putInt(DISPLAY_MODE_KEY, 1); + } else if (displayMode == displayModeIconsOnly) { + preferences.putInt(DISPLAY_MODE_KEY, 2); + } + updateActions(); + } + + }); final FaceObjectProvidersListener faceObjectProvidersListener = new FaceObjectProvidersListener() { @Override @@ -200,18 +219,17 @@ switch (preferencesDisplayMode) { case 0: default: - displayMode = displayModeGameObjectNames; + archetypeChooserModel.setDisplayMode(displayModeGameObjectNames); break; case 1: - displayMode = displayModeArchetypeNames; + archetypeChooserModel.setDisplayMode(displayModeArchetypeNames); break; case 2: - displayMode = displayModeIconsOnly; + archetypeChooserModel.setDisplayMode(displayModeIconsOnly); break; } - fireDisplayObjectNamesChangedEvent(); tabDesktop.setBorder(BorderFactory.createEmptyBorder(CommonConstants.SPACE_PICKMAP_ARCHETYPE_TOP, 0, 0, 0)); add(tabDesktop); if (createDirectionPane) { @@ -241,7 +259,7 @@ } final ArchetypeChooserPanel<G, A, R> archetypeChooserPanel = archetypeChooserModel.getPanel(panelName); - final ArchetypePanel<G, A, R> newPanel = new ArchetypePanel<G, A, R>(this, archetypeChooserPanel); + final ArchetypePanel<G, A, R> newPanel = new ArchetypePanel<G, A, R>(archetypeChooserModel, archetypeChooserPanel); // insert new panel in alphabetical order int i; @@ -297,50 +315,11 @@ } /** - * Notifies all listeners that the display mode has changed. - */ - private void fireDisplayObjectNamesChangedEvent() { - if (displayMode == displayModeGameObjectNames) { - preferences.putInt(DISPLAY_MODE_KEY, 0); - } else if (displayMode == displayModeArchetypeNames) { - preferences.putInt(DISPLAY_MODE_KEY, 1); - } else if (displayMode == displayModeIconsOnly) { - preferences.putInt(DISPLAY_MODE_KEY, 2); - } - updateActions(); - for (final ArchetypeChooserViewListener<G, A, R> listener : listeners) { - listener.displayModeChanged(displayMode); - } - } - - /** - * Returns the current display mode. - * @return the current display mode - */ - @NotNull - public DisplayMode<G, A, R> getDisplayMode() { - return displayMode; - } - - /** - * Updates the display mode. - * @param displayMode the new display mode - */ - private void setDisplayMode(@NotNull final DisplayMode<G, A, R> displayMode) { - if (this.displayMode == displayMode) { - return; - } - - this.displayMode = displayMode; - fireDisplayObjectNamesChangedEvent(); - } - - /** * Sets whether game object names are shown. */ @ActionMethod public void displayGameObjectNames() { - setDisplayMode(displayModeGameObjectNames); + archetypeChooserModel.setDisplayMode(displayModeGameObjectNames); } /** @@ -348,7 +327,7 @@ */ @ActionMethod public void displayArchetypeNames() { - setDisplayMode(displayModeArchetypeNames); + archetypeChooserModel.setDisplayMode(displayModeArchetypeNames); } /** @@ -356,29 +335,14 @@ */ @ActionMethod public void displayIconsOnly() { - setDisplayMode(displayModeIconsOnly); + archetypeChooserModel.setDisplayMode(displayModeIconsOnly); } /** - * Adds a listener to be notified of events. - * @param listener the listener to add - */ - public void addArchetypeChooserViewListener(@NotNull final ArchetypeChooserViewListener<G, A, R> listener) { - listeners.add(listener); - } - - /** - * Removes a listener to be notified of events. - * @param listener the listener to remove - */ - public void removeArchetypeChooserViewListener(@NotNull final ArchetypeChooserViewListener<G, A, R> listener) { - listeners.remove(listener); - } - - /** * Update the actions' state. */ private void updateActions() { + final DisplayMode<G, A, R> displayMode = archetypeChooserModel.getDisplayMode(); if (displayMode == displayModeGameObjectNames) { buttonDisplayGameObjectNames.setSelected(true); } else if (displayMode == displayModeArchetypeNames) { Deleted: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/panel/archetypechooser/ArchetypeChooserViewListener.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/panel/archetypechooser/ArchetypeChooserViewListener.java 2013-07-06 13:19:37 UTC (rev 9265) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/panel/archetypechooser/ArchetypeChooserViewListener.java 2013-07-06 21:50:34 UTC (rev 9266) @@ -1,41 +0,0 @@ -/* - * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. - * Copyright (C) 2000-2011 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.panel.archetypechooser; - -import java.util.EventListener; -import net.sf.gridarta.model.archetype.Archetype; -import net.sf.gridarta.model.gameobject.GameObject; -import net.sf.gridarta.model.maparchobject.MapArchObject; -import org.jetbrains.annotations.NotNull; - -/** - * Interface for listeners listening to Archetype Chooser events. - * @author Andreas Kirschbaum - */ -public interface ArchetypeChooserViewListener<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> extends EventListener { - - /** - * This event handler is called when an attribute "display object names" has - * changed. - * @param displayMode the new display mode - */ - void displayModeChanged(@NotNull DisplayMode<G, A, R> displayMode); - -} Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/panel/archetypechooser/ArchetypeIconCellRenderer.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/panel/archetypechooser/ArchetypeIconCellRenderer.java 2013-07-06 13:19:37 UTC (rev 9265) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/panel/archetypechooser/ArchetypeIconCellRenderer.java 2013-07-06 21:50:34 UTC (rev 9266) @@ -22,6 +22,7 @@ import java.awt.Component; import javax.swing.JList; import net.sf.gridarta.model.archetype.Archetype; +import net.sf.gridarta.model.archetypechooser.DisplayMode; import net.sf.gridarta.model.baseobject.BaseObject; import net.sf.gridarta.model.face.FaceObjectProviders; import net.sf.gridarta.model.gameobject.GameObject; Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/panel/archetypechooser/ArchetypeNameCellRenderer.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/panel/archetypechooser/ArchetypeNameCellRenderer.java 2013-07-06 13:19:37 UTC (rev 9265) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/panel/archetypechooser/ArchetypeNameCellRenderer.java 2013-07-06 21:50:34 UTC (rev 9266) @@ -22,6 +22,7 @@ import java.awt.Component; import javax.swing.JList; import net.sf.gridarta.model.archetype.Archetype; +import net.sf.gridarta.model.archetypechooser.DisplayMode; import net.sf.gridarta.model.face.FaceObjectProviders; import net.sf.gridarta.model.gameobject.GameObject; import net.sf.gridarta.model.maparchobject.MapArchObject; Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/panel/archetypechooser/ArchetypePanel.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/panel/archetypechooser/ArchetypePanel.java 2013-07-06 13:19:37 UTC (rev 9265) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/panel/archetypechooser/ArchetypePanel.java 2013-07-06 21:50:34 UTC (rev 9266) @@ -39,8 +39,11 @@ import net.sf.gridarta.model.archetype.Archetype; import net.sf.gridarta.model.archetypechooser.ArchetypeChooserFolder; import net.sf.gridarta.model.archetypechooser.ArchetypeChooserFolderListener; +import net.sf.gridarta.model.archetypechooser.ArchetypeChooserModel; +import net.sf.gridarta.model.archetypechooser.ArchetypeChooserModelListener; import net.sf.gridarta.model.archetypechooser.ArchetypeChooserPanel; import net.sf.gridarta.model.archetypechooser.ArchetypeChooserPanelListener; +import net.sf.gridarta.model.archetypechooser.DisplayMode; import net.sf.gridarta.model.gameobject.GameObject; import net.sf.gridarta.model.maparchobject.MapArchObject; import net.sf.gridarta.utils.CommonConstants; @@ -142,10 +145,10 @@ /** * Creates a new instance. - * @param archetypeChooserView the associated archetype chooser view + * @param archetypeChooserModel the associated archetype chooser model * @param archetypeChooserPanel the associated archetype chooser panel */ - public ArchetypePanel(@NotNull final ArchetypeChooserView<G, A, R> archetypeChooserView, @NotNull final ArchetypeChooserPanel<G, A, R> archetypeChooserPanel) { + public ArchetypePanel(@NotNull final ArchetypeChooserModel<G, A, R> archetypeChooserModel, @NotNull final ArchetypeChooserPanel<G, A, R> archetypeChooserPanel) { super(new BorderLayout()); this.archetypeChooserPanel = archetypeChooserPanel; archetypeList.setFocusable(false); @@ -158,16 +161,32 @@ scrollPane.getViewport().setScrollMode(JViewport.SIMPLE_SCROLL_MODE); folders.setAutoscrolls(true); - final ArchetypeChooserViewListener<G, A, R> archetypeChooserViewListener = new ArchetypeChooserViewListener<G, A, R>() { + final ArchetypeChooserModelListener<G, A, R> archetypeChooserModelListener = new ArchetypeChooserModelListener<G, A, R>() { @Override + public void selectedPanelChanged(@NotNull final ArchetypeChooserPanel<G, A, R> selectedPanel) { + } + + @Override + public void selectedFolderChanged(@NotNull final ArchetypeChooserFolder<G, A, R> selectedFolder) { + } + + @Override + public void selectedArchetypeChanged(@Nullable final R selectedArchetype) { + } + + @Override + public void directionChanged(@Nullable final Integer direction) { + } + + @Override public void displayModeChanged(@NotNull final DisplayMode<G, A, R> displayMode) { updateCellRenderer(displayMode); } }; - archetypeChooserView.addArchetypeChooserViewListener(archetypeChooserViewListener); - updateCellRenderer(archetypeChooserView.getDisplayMode()); + archetypeChooserModel.addArchetypeChooserModelListener(archetypeChooserModelListener); + updateCellRenderer(archetypeChooserModel.getDisplayMode()); final ArchetypeChooserPanelListener<G, A, R> archetypeChooserPanelListener = new ArchetypeChooserPanelListener<G, A, R>() { Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/panel/archetypechooser/DirectionPane.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/panel/archetypechooser/DirectionPane.java 2013-07-06 13:19:37 UTC (rev 9265) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/panel/archetypechooser/DirectionPane.java 2013-07-06 21:50:34 UTC (rev 9266) @@ -25,6 +25,7 @@ import net.sf.gridarta.model.archetypechooser.ArchetypeChooserModel; import net.sf.gridarta.model.archetypechooser.ArchetypeChooserModelListener; import net.sf.gridarta.model.archetypechooser.ArchetypeChooserPanel; +import net.sf.gridarta.model.archetypechooser.DisplayMode; import net.sf.gridarta.model.baseobject.BaseObject; import net.sf.gridarta.model.gameobject.GameObject; import net.sf.gridarta.model.maparchobject.MapArchObject; @@ -79,6 +80,11 @@ updateDirection(direction); } + @Override + public void displayModeChanged(@NotNull final DisplayMode<G, A, R> displayMode) { + // ignore + } + }; /** Deleted: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/panel/archetypechooser/DisplayMode.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/panel/archetypechooser/DisplayMode.java 2013-07-06 13:19:37 UTC (rev 9265) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/panel/archetypechooser/DisplayMode.java 2013-07-06 21:50:34 UTC (rev 9266) @@ -1,54 +0,0 @@ -/* - * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. - * Copyright (C) 2000-2011 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.panel.archetypechooser; - -import java.util.Comparator; -import javax.swing.DefaultListCellRenderer; -import net.sf.gridarta.model.archetype.Archetype; -import net.sf.gridarta.model.gameobject.GameObject; -import net.sf.gridarta.model.maparchobject.MapArchObject; - -/** - * Abstract base class for classes implementing display modes of the archetype - * chooser. It defines both a {@link DefaultListCellRenderer} and a {@link - * Comparator} for sorting the list entries. - * @author Andreas Kirschbaum - * @noinspection AbstractClassExtendsConcreteClass - */ -public abstract class DisplayMode<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> extends DefaultListCellRenderer implements Comparator<Archetype<G, A, R>> { - - /** - * The serial version UID. - */ - private static final long serialVersionUID = 1L; - - /** - * Creates a new instance. - */ - protected DisplayMode() { - } - - /** - * Returns the layout orientation. See {@link javax.swing.JList#getLayoutOrientation}. - * @return the layout orientation - */ - public abstract int getLayoutOrientation(); - -} Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/panel/archetypechooser/DisplayNameCellRenderer.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/panel/archetypechooser/DisplayNameCellRenderer.java 2013-07-06 13:19:37 UTC (rev 9265) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/panel/archetypechooser/DisplayNameCellRenderer.java 2013-07-06 21:50:34 UTC (rev 9266) @@ -22,6 +22,7 @@ import java.awt.Component; import javax.swing.JList; import net.sf.gridarta.model.archetype.Archetype; +import net.sf.gridarta.model.archetypechooser.DisplayMode; import net.sf.gridarta.model.baseobject.BaseObject; import net.sf.gridarta.model.face.FaceObjectProviders; import net.sf.gridarta.model.gameobject.GameObject; Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/panel/objectchooser/DefaultObjectChooser.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/panel/objectchooser/DefaultObjectChooser.java 2013-07-06 13:19:37 UTC (rev 9265) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/panel/objectchooser/DefaultObjectChooser.java 2013-07-06 21:50:34 UTC (rev 9266) @@ -40,6 +40,7 @@ import net.sf.gridarta.model.archetypechooser.ArchetypeChooserModel; import net.sf.gridarta.model.archetypechooser.ArchetypeChooserModelListener; import net.sf.gridarta.model.archetypechooser.ArchetypeChooserPanel; +import net.sf.gridarta.model.archetypechooser.DisplayMode; import net.sf.gridarta.model.archetypetype.ArchetypeTypeSet; import net.sf.gridarta.model.baseobject.BaseObject; import net.sf.gridarta.model.gameobject.GameObject; @@ -205,6 +206,11 @@ // ignore } + @Override + public void displayModeChanged(@NotNull final DisplayMode<G, A, R> displayMode) { + // ignore + } + }; archetypeChooserModel.addArchetypeChooserModelListener(archetypeChooserModelListener); Modified: trunk/src/model/src/main/java/net/sf/gridarta/model/archetypechooser/ArchetypeChooserModel.java =================================================================== --- trunk/src/model/src/main/java/net/sf/gridarta/model/archetypechooser/ArchetypeChooserModel.java 2013-07-06 13:19:37 UTC (rev 9265) +++ trunk/src/model/src/main/java/net/sf/gridarta/model/archetypechooser/ArchetypeChooserModel.java 2013-07-06 21:50:34 UTC (rev 9266) @@ -63,6 +63,13 @@ private Integer direction; /** + * Indicates whether object names are shown. + * @serial + */ + @NotNull + private DisplayMode<G, A, R> displayMode; + + /** * The registered listeners. */ @NotNull @@ -214,6 +221,28 @@ } /** + * Returns the current display mode. + * @return the current display mode + */ + @NotNull + public DisplayMode<G, A, R> getDisplayMode() { + return displayMode; + } + + /** + * Updates the display mode. + * @param displayMode the new display mode + */ + public void setDisplayMode(@NotNull final DisplayMode<G, A, R> displayMode) { + if (this.displayMode == displayMode) { + return; + } + + this.displayMode = displayMode; + fireDisplayObjectNamesChangedEvent(); + } + + /** * Notifies all registered {@link ArchetypeChooserModelListener * ArchetypeChooserModelListeners} that the selected folder has changed. * @param selectedFolder the new selected folder @@ -236,4 +265,13 @@ } } + /** + * Notifies all listeners that the display mode has changed. + */ + private void fireDisplayObjectNamesChangedEvent() { + for (final ArchetypeChooserModelListener<G, A, R> listener : listeners.getListeners()) { + listener.displayModeChanged(displayMode); + } + } + } Modified: trunk/src/model/src/main/java/net/sf/gridarta/model/archetypechooser/ArchetypeChooserModelListener.java =================================================================== --- trunk/src/model/src/main/java/net/sf/gridarta/model/archetypechooser/ArchetypeChooserModelListener.java 2013-07-06 13:19:37 UTC (rev 9265) +++ trunk/src/model/src/main/java/net/sf/gridarta/model/archetypechooser/ArchetypeChooserModelListener.java 2013-07-06 21:50:34 UTC (rev 9266) @@ -58,4 +58,11 @@ */ void directionChanged(@Nullable Integer direction); + /** + * This event handler is called when an attribute "display object names" has + * changed. + * @param displayMode the new display mode + */ + void displayModeChanged(@NotNull DisplayMode<G, A, R> displayMode); + } Copied: trunk/src/model/src/main/java/net/sf/gridarta/model/archetypechooser/DisplayMode.java (from rev 9265, trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/panel/archetypechooser/DisplayMode.java) =================================================================== --- trunk/src/model/src/main/java/net/sf/gridarta/model/archetypechooser/DisplayMode.java (rev 0) +++ trunk/src/model/src/main/java/net/sf/gridarta/model/archetypechooser/DisplayMode.java 2013-07-06 21:50:34 UTC (rev 9266) @@ -0,0 +1,54 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2011 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.archetypechooser; + +import java.util.Comparator; +import javax.swing.DefaultListCellRenderer; +import net.sf.gridarta.model.archetype.Archetype; +import net.sf.gridarta.model.gameobject.GameObject; +import net.sf.gridarta.model.maparchobject.MapArchObject; + +/** + * Abstract base class for classes implementing display modes of the archetype + * chooser. It defines both a {@link DefaultListCellRenderer} and a {@link + * Comparator} for sorting the list entries. + * @author Andreas Kirschbaum + * @noinspection AbstractClassExtendsConcreteClass + */ +public abstract class DisplayMode<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> extends DefaultListCellRenderer implements Comparator<Archetype<G, A, R>> { + + /** + * The serial version UID. + */ + private static final long serialVersionUID = 1L; + + /** + * Creates a new instance. + */ + protected DisplayMode() { + } + + /** + * Returns the layout orientation. See {@link javax.swing.JList#getLayoutOrientation}. + * @return the layout orientation + */ + public abstract int getLayoutOrientation(); + +} Property changes on: trunk/src/model/src/main/java/net/sf/gridarta/model/archetypechooser/DisplayMode.java ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Added: svn:mergeinfo ## -0,0 +1 ## +/streams/cher-japi-update/src/app/net/sf/gridarta/gui/archetypechooser/DisplayMode.java:5966-5991 \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +LF \ No newline at end of property This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2013-07-06 13:19:40
|
Revision: 9265 http://sourceforge.net/p/gridarta/code/9265 Author: akirschbaum Date: 2013-07-06 13:19:37 +0000 (Sat, 06 Jul 2013) Log Message: ----------- Weaken types. Modified Paths: -------------- trunk/src/atrinik/src/main/java/net/sf/gridarta/var/atrinik/gui/mappropertiesdialog/DefaultMapPropertiesDialogFactory.java trunk/src/atrinik/src/main/java/net/sf/gridarta/var/atrinik/gui/mappropertiesdialog/MapPropertiesDialog.java trunk/src/crossfire/src/main/java/net/sf/gridarta/var/crossfire/gui/mappropertiesdialog/DefaultMapPropertiesDialogFactory.java trunk/src/crossfire/src/main/java/net/sf/gridarta/var/crossfire/gui/mappropertiesdialog/MapPropertiesDialog.java trunk/src/daimonin/src/main/java/net/sf/gridarta/var/daimonin/gui/mappropertiesdialog/DefaultMapPropertiesDialogFactory.java trunk/src/daimonin/src/main/java/net/sf/gridarta/var/daimonin/gui/mappropertiesdialog/MapPropertiesDialog.java trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/GameObjectAttributesDialog.java trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/GameObjectAttributesDialogFactory.java trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/mapproperties/MapPropertiesDialogFactory.java trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/map/mapactions/MapActions.java trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/treasurelist/CFTreasureListTree.java trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/GUIMainControl.java Modified: trunk/src/atrinik/src/main/java/net/sf/gridarta/var/atrinik/gui/mappropertiesdialog/DefaultMapPropertiesDialogFactory.java =================================================================== --- trunk/src/atrinik/src/main/java/net/sf/gridarta/var/atrinik/gui/mappropertiesdialog/DefaultMapPropertiesDialogFactory.java 2013-07-01 14:50:35 UTC (rev 9264) +++ trunk/src/atrinik/src/main/java/net/sf/gridarta/var/atrinik/gui/mappropertiesdialog/DefaultMapPropertiesDialogFactory.java 2013-07-06 13:19:37 UTC (rev 9265) @@ -20,7 +20,7 @@ package net.sf.gridarta.var.atrinik.gui.mappropertiesdialog; import java.awt.Component; -import javax.swing.JFrame; +import java.awt.Frame; import javax.swing.filechooser.FileFilter; import net.sf.gridarta.gui.dialog.mapproperties.MapPropertiesDialogFactory; import net.sf.gridarta.model.mapmanager.MapManager; @@ -75,7 +75,7 @@ * {@inheritDoc} */ @Override - public void showDialog(@NotNull final Component parent, @NotNull final JFrame helpParent, @NotNull final MapModel<GameObject, MapArchObject, Archetype> mapModel, @NotNull final FileFilter mapFileFilter) { + public void showDialog(@NotNull final Component parent, @NotNull final Frame helpParent, @NotNull final MapModel<GameObject, MapArchObject, Archetype> mapModel, @NotNull final FileFilter mapFileFilter) { final MapPropertiesDialog pane = new MapPropertiesDialog(helpParent, mapManager, globalSettings, mapModel, mapFileFilter, mapPathNormalizer); pane.showDialog(parent); } Modified: trunk/src/atrinik/src/main/java/net/sf/gridarta/var/atrinik/gui/mappropertiesdialog/MapPropertiesDialog.java =================================================================== --- trunk/src/atrinik/src/main/java/net/sf/gridarta/var/atrinik/gui/mappropertiesdialog/MapPropertiesDialog.java 2013-07-01 14:50:35 UTC (rev 9264) +++ trunk/src/atrinik/src/main/java/net/sf/gridarta/var/atrinik/gui/mappropertiesdialog/MapPropertiesDialog.java 2013-07-06 13:19:37 UTC (rev 9265) @@ -23,6 +23,7 @@ import java.awt.Component; import java.awt.Container; import java.awt.FlowLayout; +import java.awt.Frame; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import java.awt.GridLayout; @@ -35,7 +36,6 @@ import javax.swing.JCheckBox; import javax.swing.JComponent; import javax.swing.JDialog; -import javax.swing.JFrame; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JScrollPane; @@ -92,7 +92,7 @@ * @serial */ @NotNull - private final JFrame helpParent; + private final Frame helpParent; /** * The {@link MapModel} this dialog shows. @@ -320,7 +320,7 @@ * @param mapPathNormalizer the map path normalizer for converting map paths * to files */ - public MapPropertiesDialog(@NotNull final JFrame helpParent, @NotNull final MapManager<GameObject, MapArchObject, Archetype> mapManager, @NotNull final GlobalSettings globalSettings, @NotNull final MapModel<GameObject, MapArchObject, Archetype> mapModel, @NotNull final FileFilter mapFileFilter, @NotNull final MapPathNormalizer mapPathNormalizer) { + public MapPropertiesDialog(@NotNull final Frame helpParent, @NotNull final MapManager<GameObject, MapArchObject, Archetype> mapManager, @NotNull final GlobalSettings globalSettings, @NotNull final MapModel<GameObject, MapArchObject, Archetype> mapModel, @NotNull final FileFilter mapFileFilter, @NotNull final MapPathNormalizer mapPathNormalizer) { okButton.setDefaultCapable(true); final JButton helpButton = new JButton(ACTION_BUILDER.createAction(false, "mapHelp", this)); final JButton restoreButton = new JButton(ACTION_BUILDER.createAction(false, "mapRestore", this)); Modified: trunk/src/crossfire/src/main/java/net/sf/gridarta/var/crossfire/gui/mappropertiesdialog/DefaultMapPropertiesDialogFactory.java =================================================================== --- trunk/src/crossfire/src/main/java/net/sf/gridarta/var/crossfire/gui/mappropertiesdialog/DefaultMapPropertiesDialogFactory.java 2013-07-01 14:50:35 UTC (rev 9264) +++ trunk/src/crossfire/src/main/java/net/sf/gridarta/var/crossfire/gui/mappropertiesdialog/DefaultMapPropertiesDialogFactory.java 2013-07-06 13:19:37 UTC (rev 9265) @@ -20,7 +20,7 @@ package net.sf.gridarta.var.crossfire.gui.mappropertiesdialog; import java.awt.Component; -import javax.swing.JFrame; +import java.awt.Frame; import javax.swing.filechooser.FileFilter; import net.sf.gridarta.gui.dialog.mapproperties.MapPropertiesDialogFactory; import net.sf.gridarta.model.mapmanager.MapManager; @@ -75,7 +75,7 @@ * {@inheritDoc} */ @Override - public void showDialog(@NotNull final Component parent, @NotNull final JFrame helpParent, @NotNull final MapModel<GameObject, MapArchObject, Archetype> mapModel, @NotNull final FileFilter mapFileFilter) { + public void showDialog(@NotNull final Component parent, @NotNull final Frame helpParent, @NotNull final MapModel<GameObject, MapArchObject, Archetype> mapModel, @NotNull final FileFilter mapFileFilter) { final MapPropertiesDialog pane = new MapPropertiesDialog(helpParent, mapManager, globalSettings, mapModel, mapFileFilter, mapPathNormalizer); pane.showDialog(parent); } Modified: trunk/src/crossfire/src/main/java/net/sf/gridarta/var/crossfire/gui/mappropertiesdialog/MapPropertiesDialog.java =================================================================== --- trunk/src/crossfire/src/main/java/net/sf/gridarta/var/crossfire/gui/mappropertiesdialog/MapPropertiesDialog.java 2013-07-01 14:50:35 UTC (rev 9264) +++ trunk/src/crossfire/src/main/java/net/sf/gridarta/var/crossfire/gui/mappropertiesdialog/MapPropertiesDialog.java 2013-07-06 13:19:37 UTC (rev 9265) @@ -22,6 +22,7 @@ import java.awt.BorderLayout; import java.awt.Component; import java.awt.Container; +import java.awt.Frame; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import java.awt.Insets; @@ -30,7 +31,6 @@ import javax.swing.JButton; import javax.swing.JCheckBox; import javax.swing.JDialog; -import javax.swing.JFrame; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JTabbedPane; @@ -84,7 +84,7 @@ * @serial */ @NotNull - private final JFrame helpParent; + private final Frame helpParent; /** * The {@link MapModel} this dialog shows. @@ -363,7 +363,7 @@ * @param mapPathNormalizer the map path normalizer for converting map paths * to files */ - public MapPropertiesDialog(@NotNull final JFrame helpParent, @NotNull final MapManager<GameObject, MapArchObject, Archetype> mapManager, @NotNull final GlobalSettings globalSettings, @NotNull final MapModel<GameObject, MapArchObject, Archetype> mapModel, @NotNull final FileFilter mapFileFilter, @NotNull final MapPathNormalizer mapPathNormalizer) { + public MapPropertiesDialog(@NotNull final Frame helpParent, @NotNull final MapManager<GameObject, MapArchObject, Archetype> mapManager, @NotNull final GlobalSettings globalSettings, @NotNull final MapModel<GameObject, MapArchObject, Archetype> mapModel, @NotNull final FileFilter mapFileFilter, @NotNull final MapPathNormalizer mapPathNormalizer) { okButton.setDefaultCapable(true); final JButton helpButton = new JButton(ACTION_BUILDER.createAction(false, "mapHelp", this)); final JButton restoreButton = new JButton(ACTION_BUILDER.createAction(false, "mapRestore", this)); Modified: trunk/src/daimonin/src/main/java/net/sf/gridarta/var/daimonin/gui/mappropertiesdialog/DefaultMapPropertiesDialogFactory.java =================================================================== --- trunk/src/daimonin/src/main/java/net/sf/gridarta/var/daimonin/gui/mappropertiesdialog/DefaultMapPropertiesDialogFactory.java 2013-07-01 14:50:35 UTC (rev 9264) +++ trunk/src/daimonin/src/main/java/net/sf/gridarta/var/daimonin/gui/mappropertiesdialog/DefaultMapPropertiesDialogFactory.java 2013-07-06 13:19:37 UTC (rev 9265) @@ -20,7 +20,7 @@ package net.sf.gridarta.var.daimonin.gui.mappropertiesdialog; import java.awt.Component; -import javax.swing.JFrame; +import java.awt.Frame; import javax.swing.filechooser.FileFilter; import net.sf.gridarta.gui.dialog.mapproperties.MapPropertiesDialogFactory; import net.sf.gridarta.model.mapmanager.MapManager; @@ -75,7 +75,7 @@ * {@inheritDoc} */ @Override - public void showDialog(@NotNull final Component parent, @NotNull final JFrame helpParent, @NotNull final MapModel<GameObject, MapArchObject, Archetype> mapModel, @NotNull final FileFilter mapFileFilter) { + public void showDialog(@NotNull final Component parent, @NotNull final Frame helpParent, @NotNull final MapModel<GameObject, MapArchObject, Archetype> mapModel, @NotNull final FileFilter mapFileFilter) { final MapPropertiesDialog pane = new MapPropertiesDialog(helpParent, mapManager, globalSettings, mapModel, mapFileFilter, mapPathNormalizer); pane.showDialog(parent); } Modified: trunk/src/daimonin/src/main/java/net/sf/gridarta/var/daimonin/gui/mappropertiesdialog/MapPropertiesDialog.java =================================================================== --- trunk/src/daimonin/src/main/java/net/sf/gridarta/var/daimonin/gui/mappropertiesdialog/MapPropertiesDialog.java 2013-07-01 14:50:35 UTC (rev 9264) +++ trunk/src/daimonin/src/main/java/net/sf/gridarta/var/daimonin/gui/mappropertiesdialog/MapPropertiesDialog.java 2013-07-06 13:19:37 UTC (rev 9265) @@ -23,6 +23,7 @@ import java.awt.Component; import java.awt.Container; import java.awt.FlowLayout; +import java.awt.Frame; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import java.awt.GridLayout; @@ -36,7 +37,6 @@ import javax.swing.JComponent; import javax.swing.JDialog; import javax.swing.JFileChooser; -import javax.swing.JFrame; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JScrollPane; @@ -94,7 +94,7 @@ * @serial */ @NotNull - private final JFrame helpParent; + private final Frame helpParent; /** * The global settings instance. @@ -314,7 +314,7 @@ * @param mapPathNormalizer the map path normalizer for converting map paths * to files */ - public MapPropertiesDialog(@NotNull final JFrame helpParent, @NotNull final MapManager<GameObject, MapArchObject, Archetype> mapManager, @NotNull final GlobalSettings globalSettings, @NotNull final MapModel<GameObject, MapArchObject, Archetype> mapModel, @NotNull final FileFilter mapFileFilter, @NotNull final MapPathNormalizer mapPathNormalizer) { + public MapPropertiesDialog(@NotNull final Frame helpParent, @NotNull final MapManager<GameObject, MapArchObject, Archetype> mapManager, @NotNull final GlobalSettings globalSettings, @NotNull final MapModel<GameObject, MapArchObject, Archetype> mapModel, @NotNull final FileFilter mapFileFilter, @NotNull final MapPathNormalizer mapPathNormalizer) { okButton.setDefaultCapable(true); final JButton helpButton = new JButton(ACTION_BUILDER.createAction(false, "mapHelp", this)); final JButton restoreButton = new JButton(ACTION_BUILDER.createAction(false, "mapRestore", this)); Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/GameObjectAttributesDialog.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/GameObjectAttributesDialog.java 2013-07-01 14:50:35 UTC (rev 9264) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/GameObjectAttributesDialog.java 2013-07-06 13:19:37 UTC (rev 9265) @@ -24,6 +24,7 @@ import java.awt.Component; import java.awt.Container; import java.awt.Dimension; +import java.awt.Frame; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import java.awt.Insets; @@ -47,7 +48,6 @@ import javax.swing.JComponent; import javax.swing.JDialog; import javax.swing.JFormattedTextField; -import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JOptionPane; import javax.swing.JPanel; @@ -186,7 +186,7 @@ * @serial */ @NotNull - private final JFrame parent; + private final Frame parent; /** * The {@link CFTreasureListTree} to use. @@ -757,7 +757,7 @@ * @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 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 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 Frame parent, @NotNull final CFTreasureListTree 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 TextAreaDefaults textAreaDefaults, @NotNull final MapManager<G, A, R> mapManager) { this.gameObjectAttributesDialogFactory = gameObjectAttributesDialogFactory; this.archetypeTypeSet = archetypeTypeSet; this.gameObject = gameObject; Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/GameObjectAttributesDialogFactory.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/GameObjectAttributesDialogFactory.java 2013-07-01 14:50:35 UTC (rev 9264) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/GameObjectAttributesDialogFactory.java 2013-07-06 13:19:37 UTC (rev 9265) @@ -19,12 +19,12 @@ package net.sf.gridarta.gui.dialog.gameobjectattributes; +import java.awt.Frame; 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; import net.sf.gridarta.gui.treasurelist.CFTreasureListTree; import net.sf.gridarta.model.anim.AnimationObjects; @@ -68,7 +68,7 @@ * The parent frame for showing dialog boxes. */ @NotNull - private final JFrame parent; + private final Frame parent; /** * The {@link CFTreasureListTree} to display. @@ -180,7 +180,7 @@ * @param unknownSquareIcon the image icon for undefined animations * @param mapManager the map manager instance */ - public GameObjectAttributesDialogFactory(@NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final JFrame parent, @NotNull final CFTreasureListTree 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 MapManager<G, A, R> mapManager) { + public GameObjectAttributesDialogFactory(@NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final Frame parent, @NotNull final CFTreasureListTree 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 MapManager<G, A, R> mapManager) { this.archetypeTypeSet = archetypeTypeSet; this.parent = parent; this.treasureListTree = treasureListTree; Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/mapproperties/MapPropertiesDialogFactory.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/mapproperties/MapPropertiesDialogFactory.java 2013-07-01 14:50:35 UTC (rev 9264) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/mapproperties/MapPropertiesDialogFactory.java 2013-07-06 13:19:37 UTC (rev 9265) @@ -20,7 +20,7 @@ package net.sf.gridarta.gui.dialog.mapproperties; import java.awt.Component; -import javax.swing.JFrame; +import java.awt.Frame; import javax.swing.filechooser.FileFilter; import net.sf.gridarta.model.archetype.Archetype; import net.sf.gridarta.model.gameobject.GameObject; @@ -41,6 +41,6 @@ * @param mapModel the map to show dialog about * @param mapFileFilter the Swing file filter to use */ - void showDialog(@NotNull Component parent, @NotNull JFrame helpParent, @NotNull MapModel<G, A, R> mapModel, @NotNull FileFilter mapFileFilter); + void showDialog(@NotNull Component parent, @NotNull Frame helpParent, @NotNull MapModel<G, A, R> mapModel, @NotNull FileFilter mapFileFilter); } Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/map/mapactions/MapActions.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/map/mapactions/MapActions.java 2013-07-01 14:50:35 UTC (rev 9264) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/map/mapactions/MapActions.java 2013-07-06 13:19:37 UTC (rev 9265) @@ -19,13 +19,13 @@ package net.sf.gridarta.gui.map.mapactions; +import java.awt.Frame; import java.awt.Point; import java.io.File; import java.util.ArrayList; import java.util.Collection; import java.util.Iterator; import javax.swing.Action; -import javax.swing.JFrame; import javax.swing.filechooser.FileFilter; import net.sf.gridarta.gui.dialog.mapproperties.MapPropertiesDialogFactory; import net.sf.gridarta.gui.dialog.shrinkmapsize.ShrinkMapSizeDialogManager; @@ -171,7 +171,7 @@ * The parent frame for help windows. */ @NotNull - private final JFrame helpParent; + private final Frame helpParent; /** * The {@link ExitMatcher} for selecting exit game objects. @@ -396,7 +396,7 @@ * @param mapViewsManager the map views * @param enterMap the enter map instance to use */ - public MapActions(@NotNull final JFrame helpParent, @NotNull final MapManager<G, A, R> mapManager, @NotNull final MapViewManager<G, A, R> mapViewManager, final ExitMatcher<G, A, R> exitMatcher, final FileFilter mapFileFilter, @NotNull final SelectedSquareModel<G, A, R> selectedSquareModel, final boolean allowRandomMapParameters, @NotNull final MapPropertiesDialogFactory<G, A, R> mapPropertiesDialogFactory, @NotNull final MapViewSettings mapViewSettings, @NotNull final MapViewsManager<G, A, R> mapViewsManager, @NotNull final EnterMap<G, A, R> enterMap) { + public MapActions(@NotNull final Frame helpParent, @NotNull final MapManager<G, A, R> mapManager, @NotNull final MapViewManager<G, A, R> mapViewManager, final ExitMatcher<G, A, R> exitMatcher, final FileFilter mapFileFilter, @NotNull final SelectedSquareModel<G, A, R> selectedSquareModel, final boolean allowRandomMapParameters, @NotNull final MapPropertiesDialogFactory<G, A, R> mapPropertiesDialogFactory, @NotNull final MapViewSettings mapViewSettings, @NotNull final MapViewsManager<G, A, R> mapViewsManager, @NotNull final EnterMap<G, A, R> enterMap) { this.helpParent = helpParent; this.exitMatcher = exitMatcher; this.mapFileFilter = mapFileFilter; Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/treasurelist/CFTreasureListTree.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/treasurelist/CFTreasureListTree.java 2013-07-01 14:50:35 UTC (rev 9264) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/treasurelist/CFTreasureListTree.java 2013-07-06 13:19:37 UTC (rev 9265) @@ -22,13 +22,13 @@ import java.awt.BorderLayout; import java.awt.Component; import java.awt.Container; +import java.awt.Frame; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.AbstractButton; import javax.swing.BorderFactory; import javax.swing.JButton; import javax.swing.JDialog; -import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JSplitPane; @@ -90,7 +90,7 @@ * @serial */ @NotNull - private final JFrame parent; + private final Frame parent; /** * JDialog containing the tree. @@ -129,7 +129,7 @@ * faces * @param systemIcons the system icons for creating icons */ - public CFTreasureListTree(@NotNull final TreasureTree treasureTree, @NotNull final JFrame parent, @NotNull final ArchetypeSet<?, ?, ?> archetypeSet, @NotNull final FaceObjectProviders faceObjectProviders, @NotNull final SystemIcons systemIcons) { + public CFTreasureListTree(@NotNull final TreasureTree treasureTree, @NotNull final Frame parent, @NotNull final ArchetypeSet<?, ?, ?> archetypeSet, @NotNull final FaceObjectProviders faceObjectProviders, @NotNull final SystemIcons systemIcons) { super(treasureTree.getRoot()); this.treasureTree = treasureTree; this.parent = parent; Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/GUIMainControl.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/GUIMainControl.java 2013-07-01 14:50:35 UTC (rev 9264) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/GUIMainControl.java 2013-07-06 13:19:37 UTC (rev 9265) @@ -21,6 +21,7 @@ import java.awt.BorderLayout; import java.awt.Container; +import java.awt.Frame; import java.io.File; import java.io.IOException; import java.util.MissingResourceException; @@ -457,15 +458,16 @@ final MapFolderTree<G, A, R> mapFolderTree = new MapFolderTree<G, A, R>(globalSettings.getPickmapDir()); final ImageIcon icon = systemIcons.getAppIcon(); mainViewFrame = new JFrame(ACTION_BUILDER.format("mainWindow.title", getBuildNumberAsString())); - newMapDialogFactory = editorFactory.newNewMapDialogFactory(mapViewsManager, mapArchObjectFactory, mainViewFrame); + final Frame parent = mainViewFrame; + newMapDialogFactory = editorFactory.newNewMapDialogFactory(mapViewsManager, mapArchObjectFactory, parent); final PickmapChooserModel<G, A, R> pickmapChooserModel = new PickmapChooserModel<G, A, R>(); final PickmapSettings pickmapSettings = new DefaultPickmapSettings(); - pickmapChooserControl = new PickmapChooserControl<G, A, R>(pickmapChooserModel, pickmapSettings, newMapDialogFactory, mapArchObjectFactory, mapReaderFactory, mapFolderTree, mapManager, mainViewFrame, pickmapManager, mapViewsManager); + pickmapChooserControl = new PickmapChooserControl<G, A, R>(pickmapChooserModel, pickmapSettings, newMapDialogFactory, mapArchObjectFactory, mapReaderFactory, mapFolderTree, mapManager, parent, pickmapManager, mapViewsManager); newMapDialogFactory.setPickmapChooserControl(pickmapChooserControl); - final CFTreasureListTree treasureListTree = new CFTreasureListTree(treasureTree, mainViewFrame, archetypeSet, faceObjectProviders, systemIcons); + final CFTreasureListTree treasureListTree = new CFTreasureListTree(treasureTree, parent, archetypeSet, faceObjectProviders, systemIcons); 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, mapManager); + final GameObjectAttributesDialogFactory<G, A, R> gameObjectAttributesDialogFactory = new GameObjectAttributesDialogFactory<G, A, R>(archetypeTypeSet, parent, treasureListTree, faceObjectProviders, animationObjects, globalSettings, mapFileFilter, scriptFileFilter, faceObjects, gameObjectSpells, numberSpells, undefinedSpellIndex, treasureTree, noFaceSquareIcon, unknownSquareIcon, 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>(); @@ -478,16 +480,16 @@ final GameObjectMatcher systemObjectMatcher = gameObjectMatchers.getMatcher("system_system_object"); final InsertionModeSet<G, A, R> insertionModeSet = new InsertionModeSet<G, A, R>(topmostInsertionMode, floorMatcher, wallMatcher, belowFloorMatcher, systemObjectMatcher); final CopyBuffer<G, A, R> copyBuffer = new CopyBuffer<G, A, R>(mapViewSettings, gameObjectFactory, mapArchObjectFactory, mapModelFactory, insertionModeSet); - final FindDialogManager<G, A, R> findDialogManager = new FindDialogManager<G, A, R>(mainViewFrame, mapViewManager); - final ReplaceDialogManager<G, A, R> replaceDialogManager = new ReplaceDialogManager<G, A, R>(mainViewFrame, copyBuffer, objectChooser, mapViewManager, faceObjectProviders, insertionModeSet); - exiter = new DefaultExiter(mainViewFrame); - scriptEditControl = new ScriptEditControl(scriptFileFilter, scriptExtension, mainViewFrame, globalSettings.getMapsDirectory(), preferences, exiter); + final FindDialogManager<G, A, R> findDialogManager = new FindDialogManager<G, A, R>(parent, mapViewManager); + final ReplaceDialogManager<G, A, R> replaceDialogManager = new ReplaceDialogManager<G, A, R>(parent, copyBuffer, objectChooser, mapViewManager, faceObjectProviders, insertionModeSet); + exiter = new DefaultExiter(parent); + scriptEditControl = new ScriptEditControl(scriptFileFilter, scriptExtension, parent, globalSettings.getMapsDirectory(), preferences, exiter); final TextAreaDefaults textAreaDefaults = new TextAreaDefaults(scriptEditControl); gameObjectAttributesDialogFactory.setTextAreaDefaults(textAreaDefaults); scriptEditControl.setTextAreaDefaults(textAreaDefaults); scriptedEventEditor.setScriptEditControl(scriptEditControl); scriptArchEditor.setScriptEditControl(scriptEditControl); - fileControl = new DefaultFileControl<G, A, R>(globalSettings, mapImageCache, mapManager, mapViewsManager, mainViewFrame, GuiFileFilters.mapFileFilter, scriptFileFilter, newMapDialogFactory, scriptExtension, scriptEditControl); + fileControl = new DefaultFileControl<G, A, R>(globalSettings, mapImageCache, mapManager, mapViewsManager, parent, GuiFileFilters.mapFileFilter, scriptFileFilter, newMapDialogFactory, scriptExtension, scriptEditControl); pickmapChooserControl.setFileControl(fileControl); mapViewsManager.setFileControl(fileControl); final GameObjectMatcher monsterMatcherTmp = gameObjectMatchers.getMatcherWarn(gameObjectMatchersErrorViewCollector, "system_monster", "monster"); @@ -499,37 +501,37 @@ final MapPropertiesDialogFactory<G, A, R> mapPropertiesDialogFactory = editorFactory.newMapPropertiesDialogFactory(globalSettings, mapManager, mapPathNormalizer); final DelayedMapModelListenerManager<G, A, R> delayedMapModelListenerManager = new DelayedMapModelListenerManager<G, A, R>(mapManager, exiter); final Control<?, G, A, R> lockedItemsControl = new LockedItemsControl<G, A, R>(mapViewManager, delayedMapModelListenerManager, lockedItemsTypeNumbers); - final EnterMap<G, A, R> enterMap = new EnterMap<G, A, R>(mainViewFrame, directionMap, mapPathNormalizer, fileControl, mapViewsManager); - new MapActions<G, A, R>(mainViewFrame, mapManager, mapViewManager, exitMatcher, GuiFileFilters.mapFileFilter, selectedSquareModel, allowRandomMapParameters, mapPropertiesDialogFactory, mapViewSettings, mapViewsManager, enterMap); + final EnterMap<G, A, R> enterMap = new EnterMap<G, A, R>(parent, directionMap, mapPathNormalizer, fileControl, mapViewsManager); + new MapActions<G, A, R>(parent, mapManager, mapViewManager, exitMatcher, GuiFileFilters.mapFileFilter, selectedSquareModel, allowRandomMapParameters, mapPropertiesDialogFactory, mapViewSettings, mapViewsManager, enterMap); final GameObjectAttributesModel<G, A, R> gameObjectAttributesModel = new GameObjectAttributesModel<G, A, R>(); final GameObjectAttributesControl<G, A, R> gameObjectAttributesControl = new GameObjectAttributesControl<G, A, R>(gameObjectAttributesModel, gameObjectAttributesDialogFactory, objectChooser, mapManager, selectedSquareModel, selectedSquareView, gameObjectFactory); final PluginParameterViewFactory<G, A, R> pluginParameterViewFactory = new PluginParameterViewFactory<G, A, R>(archetypeSet, gameObjectAttributesModel, objectChooser, mapManager, faceObjectProviders); final File scriptsFile = new File(globalSettings.getMapsDirectory(), scriptsDir); - pluginControl = new PluginController<G, A, R>(filterControl, pluginParameters, mainViewFrame, pluginParameterViewFactory, scriptsFile, pluginModel, pluginParameterFactory, pluginExecutor, systemIcons); + pluginControl = new PluginController<G, A, R>(filterControl, pluginParameters, parent, pluginParameterViewFactory, scriptsFile, pluginModel, pluginParameterFactory, pluginExecutor, systemIcons); final ToolPalette<G, A, R> toolPalette = new ToolPalette<G, A, R>(mapViewSettings, selectedSquareView, selectedSquareModel, objectChooser, pickmapSettings, floorMatcher, wallMatcher, monsterMatcher, insertionModeSet); - updaterManager = new UpdaterManager(exiter, mapManager, mainViewFrame, gridartaJarFilename); + updaterManager = new UpdaterManager(exiter, mapManager, parent, gridartaJarFilename); final TextEditorTab<G, A, R> textEditorTab = new TextEditorTab<G, A, R>(gameObjectAttributesModel, archetypeTypeSet); final GameObjectTab<G, A, R> gameObjectTab = new GameObjectTab<G, A, R>("gameObject", gameObjectAttributesControl, Location.BOTTOM, false, 0, true); //noinspection ResultOfObjectAllocationIgnored - new About(mainViewFrame); + new About(parent); //noinspection ResultOfObjectAllocationIgnored - new FindArchetypesDialogManager<G, A, R>(mainViewFrame, archetypeChooserControl, objectChooser, archetypeTypeSet); + new FindArchetypesDialogManager<G, A, R>(parent, archetypeChooserControl, objectChooser, archetypeTypeSet); //noinspection ResultOfObjectAllocationIgnored new UndoControl<G, A, R>(mapManager, gameObjectFactory, gameObjectMatchers); final Action exitAction = ActionUtils.newAction(ACTION_BUILDER, "Other", this, "exit"); final MapFolderTreeActions<G, A, R> mapFolderTreeActions = new MapFolderTreeActions<G, A, R>(mapFolderTree, pickmapSettings, newMapDialogFactory, "createPickmapFolder", "deletePickmapFolder", "confirmDeletePickmapFolder", "deletePickmapFolderNotEmpty"); final ViewActions<G, A, R> viewActions = new ViewActions<G, A, R>(mapViewSettings, mapManager); //noinspection ResultOfObjectAllocationIgnored - new MapFileActions<G, A, R>(imageCreator2, mapManager, mapViewsManager, mapViewManager, fileControl, mainViewFrame); + new MapFileActions<G, A, R>(imageCreator2, mapManager, mapViewsManager, mapViewManager, fileControl, parent); //noinspection ResultOfObjectAllocationIgnored new MainActions<G, A, R>(findDialogManager, replaceDialogManager, mainViewFrame, globalSettings, validators, mapViewSettings, archetypeSet, copyBuffer, objectChooser, mapManager, mapViewManager, resources, faceObjectProviders, insertionModeSet, exiter); - final HelpActions helpActions = new HelpActions(mainViewFrame); + final HelpActions helpActions = new HelpActions(parent); ActionUtils.newActions(ACTION_BUILDER, "Map", newMapDialogFactory, "newMap"); - final GoMapDialogManager<G, A, R> goMapDialogManager = new GoMapDialogManager<G, A, R>(mainViewFrame, mapManager, mapViewsManager, globalSettings, exiter); + final GoMapDialogManager<G, A, R> goMapDialogManager = new GoMapDialogManager<G, A, R>(parent, mapManager, mapViewsManager, globalSettings, exiter); ActionUtils.newActions(ACTION_BUILDER, "Map", goMapDialogManager, "goMap"); - final GoExitDialogManager<G, A, R> goExitDialogManager = new GoExitDialogManager<G, A, R>(mainViewFrame, mapManager, mapViewManager, exitGameObjectMatcher, pathManager, enterMap, faceObjectProviders); + final GoExitDialogManager<G, A, R> goExitDialogManager = new GoExitDialogManager<G, A, R>(parent, mapManager, mapViewManager, exitGameObjectMatcher, pathManager, enterMap, faceObjectProviders); ActionUtils.newActions(ACTION_BUILDER, "Map Navigation", goExitDialogManager, "goExit"); ActionUtils.newActions(ACTION_BUILDER, "Tool", this, "cleanCompletelyBlockedSquares", "collectSpells", "controlClient", "controlServer", "gc", "options", "shortcuts", "zoom"); //noinspection ResultOfObjectAllocationIgnored @@ -544,7 +546,7 @@ final MapMenu mapMenu = bookmarksMapMenuPreferences.getMapMenu(); @Nullable final MapMenuManager<G, A, R> bookmarksMapMenuManager = new MapMenuManager<G, A, R>(mapMenu, mapViewsManager, fileControl, mapImageCache); //noinspection ResultOfObjectAllocationIgnored - new BookmarkActions<G, A, R>(bookmarksMapMenuPreferences, mapMenu, mapViewManager, mainViewFrame, mapImageCache); + new BookmarkActions<G, A, R>(bookmarksMapMenuPreferences, mapMenu, mapViewManager, parent, mapImageCache); editorFactory.newServerActions(mapViewManager, fileControl, pathManager); pickmapChooserControl.setPopupMenu(ACTION_BUILDER.createPopupMenu(true, "pickmaps")); @@ -590,7 +592,7 @@ final ErrorListView<G, A, R> errorListView = new ErrorListView<G, A, R>(mapViewManager); 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 EventsTab<G, A, R>(parent, mapManager, gameObjectAttributesModel, scriptArchEditor, scriptArchData, scriptArchDataUtils, scriptArchUtils)); 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, false, 4, false)); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sm...@us...> - 2013-07-01 14:50:38
|
Revision: 9264 http://sourceforge.net/p/gridarta/code/9264 Author: smacky Date: 2013-07-01 14:50:35 +0000 (Mon, 01 Jul 2013) Log Message: ----------- Do not check for type 68 in missing floor validator. Modified Paths: -------------- trunk/src/daimonin/ChangeLog trunk/src/daimonin/src/main/resources/net/sf/gridarta/var/daimonin/messages.properties Modified: trunk/src/daimonin/ChangeLog =================================================================== --- trunk/src/daimonin/ChangeLog 2013-06-02 21:38:45 UTC (rev 9263) +++ trunk/src/daimonin/ChangeLog 2013-07-01 14:50:35 UTC (rev 9264) @@ -1,3 +1,8 @@ +2013-07-01 Smacky + + * TYPE_SHOP_FLOOR is now a sys object, not a floor so do not check for + it in the missing floor validator. + 2013-04-27 Smacky * Do not add intern tab to Archetype Chooser panel. Modified: trunk/src/daimonin/src/main/resources/net/sf/gridarta/var/daimonin/messages.properties =================================================================== --- trunk/src/daimonin/src/main/resources/net/sf/gridarta/var/daimonin/messages.properties 2013-06-02 21:38:45 UTC (rev 9263) +++ trunk/src/daimonin/src/main/resources/net/sf/gridarta/var/daimonin/messages.properties 2013-07-01 14:50:35 UTC (rev 9264) @@ -174,7 +174,7 @@ validator.9=net.sf.gridarta.model.validation.checks.ExitChecker 66 validator.10=net.sf.gridarta.model.validation.checks.MapDifficultyChecker 1 10000 validator.11=net.sf.gridarta.model.validation.checks.MobOutsideSpawnPointChecker 80 -validator.12=net.sf.gridarta.model.validation.checks.SquareWithoutFloorChecker 71,68 +validator.12=net.sf.gridarta.model.validation.checks.SquareWithoutFloorChecker 71 validator.13=net.sf.gridarta.model.validation.checks.SysObjectNotOnLayerZeroChecker validator.14=net.sf.gridarta.model.validation.checks.TilePathsChecker 8 validator.15=net.sf.gridarta.model.validation.checks.UndefinedArchetypeChecker This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2013-06-02 21:38:52
|
Revision: 9263 http://sourceforge.net/p/gridarta/code/9263 Author: akirschbaum Date: 2013-06-02 21:38:45 +0000 (Sun, 02 Jun 2013) Log Message: ----------- Replace MapArchObject.clone() with copy constructor. Modified Paths: -------------- trunk/src/atrinik/src/main/java/net/sf/gridarta/var/atrinik/model/maparchobject/MapArchObject.java trunk/src/crossfire/src/main/java/net/sf/gridarta/var/crossfire/model/maparchobject/MapArchObject.java trunk/src/daimonin/src/main/java/net/sf/gridarta/var/daimonin/model/maparchobject/MapArchObject.java trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/undo/UndoControl.java trunk/src/model/src/main/java/net/sf/gridarta/model/maparchobject/AbstractMapArchObject.java trunk/src/model/src/main/java/net/sf/gridarta/model/maparchobject/MapArchObject.java trunk/src/model/src/test/java/net/sf/gridarta/model/maparchobject/TestMapArchObject.java Modified: trunk/src/atrinik/src/main/java/net/sf/gridarta/var/atrinik/model/maparchobject/MapArchObject.java =================================================================== --- trunk/src/atrinik/src/main/java/net/sf/gridarta/var/atrinik/model/maparchobject/MapArchObject.java 2013-06-02 19:39:24 UTC (rev 9262) +++ trunk/src/atrinik/src/main/java/net/sf/gridarta/var/atrinik/model/maparchobject/MapArchObject.java 2013-06-02 21:38:45 UTC (rev 9263) @@ -126,23 +126,56 @@ * @serial */ @NotNull - private String backgroundMusic = ""; + private String backgroundMusic; /** * The region the map is in. * @serial */ @NotNull - private String region = ""; + private String region; /** * The weather effect active on this map. * @serial */ @NotNull - private String weather = ""; + private String weather; /** + * Creates a new instance. + */ + public MapArchObject() { + backgroundMusic = ""; + region = ""; + weather = ""; + } + + /** + * Creates a new instance as a copy of another map arch object. + * @param mapArchObject the other map arch object + */ + public MapArchObject(@NotNull final MapArchObject mapArchObject) { + super(mapArchObject); + noSave = mapArchObject.noSave; + noMagic = mapArchObject.noMagic; + noPriest = mapArchObject.noPriest; + noHarm = mapArchObject.noHarm; + noSummon = mapArchObject.noSummon; + fixedLogin = mapArchObject.fixedLogin; + unique = mapArchObject.unique; + fixedResetTime = mapArchObject.fixedResetTime; + playerNoSave = mapArchObject.playerNoSave; + pvp = mapArchObject.pvp; + tilesetId = mapArchObject.tilesetId; + tilesetX = mapArchObject.tilesetX; + tilesetY = mapArchObject.tilesetY; + backgroundMusic = mapArchObject.backgroundMusic; + region = mapArchObject.region; + weather = mapArchObject.weather; + } + + /** * {@inheritDoc} */ @Override @@ -543,8 +576,8 @@ */ @NotNull @Override - public MapArchObject clone() { - return super.clone(); + public MapArchObject createClone() { + return new MapArchObject(this); } /** Modified: trunk/src/crossfire/src/main/java/net/sf/gridarta/var/crossfire/model/maparchobject/MapArchObject.java =================================================================== --- trunk/src/crossfire/src/main/java/net/sf/gridarta/var/crossfire/model/maparchobject/MapArchObject.java 2013-06-02 19:39:24 UTC (rev 9262) +++ trunk/src/crossfire/src/main/java/net/sf/gridarta/var/crossfire/model/maparchobject/MapArchObject.java 2013-06-02 21:38:45 UTC (rev 9263) @@ -47,7 +47,7 @@ * The map lore attribute. * @serial */ - private StringBuilder loreText = new StringBuilder(); + private final StringBuilder loreText = new StringBuilder(); /** * If set, this entire map is unique. @@ -108,14 +108,14 @@ * @serial */ @NotNull - private String shopItems = ""; + private String shopItems; /** * The preferred race of the shop. * @serial */ @NotNull - private String shopRace = ""; + private String shopRace; /** * The greed of the shop. @@ -140,16 +140,51 @@ * @serial */ @NotNull - private String region = ""; + private String region; /** * The background music to play. * @serial */ @NotNull - private String backgroundMusic = ""; + private String backgroundMusic; /** + * Creates a new instance. + */ + public MapArchObject() { + region = ""; + backgroundMusic = ""; + shopRace = ""; + shopItems = ""; + } + + /** + * Creates a new instance as a copy of another map arch object. + * @param mapArchObject the other map arch object + */ + public MapArchObject(@NotNull final MapArchObject mapArchObject) { + super(mapArchObject); + loreText.append(mapArchObject.loreText); + unique = mapArchObject.unique; + template = mapArchObject.template; + noSmooth = mapArchObject.noSmooth; + temperature = mapArchObject.temperature; + pressure = mapArchObject.pressure; + humidity = mapArchObject.humidity; + windSpeed = mapArchObject.windSpeed; + windDirection = mapArchObject.windDirection; + sky = mapArchObject.sky; + shopItems = mapArchObject.shopItems; + shopRace = mapArchObject.shopRace; + shopGreed = mapArchObject.shopGreed; + shopMin = mapArchObject.shopMin; + shopMax = mapArchObject.shopMax; + region = mapArchObject.region; + backgroundMusic = mapArchObject.backgroundMusic; + } + + /** * {@inheritDoc} */ @Override @@ -593,10 +628,8 @@ */ @NotNull @Override - public MapArchObject clone() { - final MapArchObject clone = super.clone(); - clone.loreText = new StringBuilder(loreText.toString()); - return clone; + public MapArchObject createClone() { + return new MapArchObject(this); } /** Modified: trunk/src/daimonin/src/main/java/net/sf/gridarta/var/daimonin/model/maparchobject/MapArchObject.java =================================================================== --- trunk/src/daimonin/src/main/java/net/sf/gridarta/var/daimonin/model/maparchobject/MapArchObject.java 2013-06-02 19:39:24 UTC (rev 9262) +++ trunk/src/daimonin/src/main/java/net/sf/gridarta/var/daimonin/model/maparchobject/MapArchObject.java 2013-06-02 21:38:45 UTC (rev 9263) @@ -126,9 +126,38 @@ * @serial */ @NotNull - private String backgroundMusic = ""; + private String backgroundMusic; /** + * Creates a new instance. + */ + public MapArchObject() { + backgroundMusic = ""; + } + + /** + * Creates a new instance as a copy of another map arch object. + * @param mapArchObject the other map arch object + */ + public MapArchObject(@NotNull final MapArchObject mapArchObject) { + super(mapArchObject); + noSave = mapArchObject.noSave; + noMagic = mapArchObject.noMagic; + noPriest = mapArchObject.noPriest; + noHarm = mapArchObject.noHarm; + noSummon = mapArchObject.noSummon; + fixedLogin = mapArchObject.fixedLogin; + permDeath = mapArchObject.permDeath; + ultraDeath = mapArchObject.ultraDeath; + ultimateDeath = mapArchObject.ultimateDeath; + pvp = mapArchObject.pvp; + tilesetId = mapArchObject.tilesetId; + tilesetX = mapArchObject.tilesetX; + tilesetY = mapArchObject.tilesetY; + backgroundMusic = mapArchObject.backgroundMusic; + } + + /** * {@inheritDoc} */ @Override @@ -481,8 +510,8 @@ */ @NotNull @Override - public MapArchObject clone() { - return super.clone(); + public MapArchObject createClone() { + return new MapArchObject(this); } /** Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/undo/UndoControl.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/undo/UndoControl.java 2013-06-02 19:39:24 UTC (rev 9262) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/undo/UndoControl.java 2013-06-02 21:38:45 UTC (rev 9263) @@ -107,7 +107,7 @@ @Override public void beginTransaction(@NotNull final MapModel<G, A, R> mapModel, @NotNull final String name) { undoModel = undoModels.get(mapModel); - undoState = new UndoState<G, A, R>(name, mapModel.getMapArchObject().clone()); + undoState = new UndoState<G, A, R>(name, mapModel.getMapArchObject().createClone()); } @Override Modified: trunk/src/model/src/main/java/net/sf/gridarta/model/maparchobject/AbstractMapArchObject.java =================================================================== --- trunk/src/model/src/main/java/net/sf/gridarta/model/maparchobject/AbstractMapArchObject.java 2013-06-02 19:39:24 UTC (rev 9262) +++ trunk/src/model/src/main/java/net/sf/gridarta/model/maparchobject/AbstractMapArchObject.java 2013-06-02 21:38:45 UTC (rev 9263) @@ -68,19 +68,19 @@ * The map text. */ @NotNull - private StringBuilder msgText = new StringBuilder(); + private final StringBuilder msgText = new StringBuilder(); /** * The size of the map reflected by this map arch object. */ @NotNull - private Size2D mapSize = Size2D.ONE; + private Size2D mapSize; /** * The name of this map. */ @NotNull - private String mapName = MAP_NAME_UNNAMED; + private String mapName; /** * The x coordinate for entering the map. @@ -129,7 +129,7 @@ * = west. 4 = northeast, 5 = southeast, 6 = southwest, 7 = northwest */ @NotNull - private String[] tilePaths = new String[Direction.values().length]; + private final String[] tilePaths; /** * The registered event listeners. @@ -161,10 +161,32 @@ * Creates a new instance. */ protected AbstractMapArchObject() { + tilePaths = new String[Direction.values().length]; Arrays.fill(tilePaths, ""); + mapSize = Size2D.ONE; + mapName = MAP_NAME_UNNAMED; } /** + * Creates a new instance as a copy of another map arch object. + * @param mapArchObject the other map arch object + */ + protected AbstractMapArchObject(@NotNull final AbstractMapArchObject<A> mapArchObject) { + msgText.append(mapArchObject.msgText); + mapSize = mapArchObject.mapSize; + mapName = mapArchObject.mapName; + enterX = mapArchObject.enterX; + enterY = mapArchObject.enterY; + outdoor = mapArchObject.outdoor; + resetTimeout = mapArchObject.resetTimeout; + swapTime = mapArchObject.swapTime; + difficulty = mapArchObject.difficulty; + fixedReset = mapArchObject.fixedReset; + darkness = mapArchObject.darkness; + tilePaths = mapArchObject.tilePaths.clone(); + } + + /** * {@inheritDoc} */ @NotNull @@ -620,25 +642,6 @@ } /** - * {@inheritDoc} - */ - @NotNull - @Override - @SuppressWarnings("unchecked") - public A clone() { - final AbstractMapArchObject<A> clone; - try { - //noinspection OverriddenMethodCallDuringObjectConstruction - clone = (AbstractMapArchObject<A>) super.clone(); - } catch (final CloneNotSupportedException ex) { - throw new AssertionError(ex); - } - clone.msgText = new StringBuilder(msgText.toString()); - clone.tilePaths = tilePaths.clone(); - return clone.getThis(); - } - - /** * Returns this map arch object cast to its real type. * @return this map arch object */ Modified: trunk/src/model/src/main/java/net/sf/gridarta/model/maparchobject/MapArchObject.java =================================================================== --- trunk/src/model/src/main/java/net/sf/gridarta/model/maparchobject/MapArchObject.java 2013-06-02 19:39:24 UTC (rev 9262) +++ trunk/src/model/src/main/java/net/sf/gridarta/model/maparchobject/MapArchObject.java 2013-06-02 21:38:45 UTC (rev 9263) @@ -34,7 +34,7 @@ * @author <a href="mailto:ch...@ri...">Christian Hujer</a> * @author Andreas Kirschbaum */ -public interface MapArchObject<A extends MapArchObject<A>> extends Cloneable, Serializable { +public interface MapArchObject<A extends MapArchObject<A>> extends Serializable { /** * Resets the state of this object to the state of the given map arch @@ -200,7 +200,7 @@ * @return the newly created clone of this object */ @NotNull - A clone(); + A createClone(); /** * Registers an event listener. Modified: trunk/src/model/src/test/java/net/sf/gridarta/model/maparchobject/TestMapArchObject.java =================================================================== --- trunk/src/model/src/test/java/net/sf/gridarta/model/maparchobject/TestMapArchObject.java 2013-06-02 19:39:24 UTC (rev 9262) +++ trunk/src/model/src/test/java/net/sf/gridarta/model/maparchobject/TestMapArchObject.java 2013-06-02 21:38:45 UTC (rev 9263) @@ -33,12 +33,27 @@ private static final long serialVersionUID = 1L; /** + * Creates a new instance. + */ + public TestMapArchObject() { + } + + /** + * Creates a new instance as a copy of another map arch object. + * @param mapArchObject the other map arch object + * @noinspection TypeMayBeWeakened + */ + public TestMapArchObject(@NotNull final TestMapArchObject mapArchObject) { + super(mapArchObject); + } + + /** * {@inheritDoc} */ @NotNull @Override - public TestMapArchObject clone() { - return super.clone(); + public TestMapArchObject createClone() { + return new TestMapArchObject(this); } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2013-06-02 19:39:30
|
Revision: 9262 http://sourceforge.net/p/gridarta/code/9262 Author: akirschbaum Date: 2013-06-02 19:39:24 +0000 (Sun, 02 Jun 2013) Log Message: ----------- Replace GameObjectText.clone() with copy constructor. Modified Paths: -------------- trunk/src/model/src/main/java/net/sf/gridarta/model/baseobject/AbstractBaseObject.java trunk/src/model/src/main/java/net/sf/gridarta/model/baseobject/GameObjectText.java Modified: trunk/src/model/src/main/java/net/sf/gridarta/model/baseobject/AbstractBaseObject.java =================================================================== --- trunk/src/model/src/main/java/net/sf/gridarta/model/baseobject/AbstractBaseObject.java 2013-06-02 19:28:21 UTC (rev 9261) +++ trunk/src/model/src/main/java/net/sf/gridarta/model/baseobject/AbstractBaseObject.java 2013-06-02 19:39:24 UTC (rev 9262) @@ -708,7 +708,7 @@ //noinspection OverriddenMethodCallDuringObjectConstruction final AbstractBaseObject<G, A, R, T> clone = (AbstractBaseObject<G, A, R, T>) super.clone(); // clone.archetype = archetype; // will NOT be cloned: archetypes are unique - clone.gameObjectText = gameObjectText.clone(); + clone.gameObjectText = new GameObjectText(gameObjectText); if (msgText != null) { clone.msgText = new StringBuilder(msgText); } Modified: trunk/src/model/src/main/java/net/sf/gridarta/model/baseobject/GameObjectText.java =================================================================== --- trunk/src/model/src/main/java/net/sf/gridarta/model/baseobject/GameObjectText.java 2013-06-02 19:28:21 UTC (rev 9261) +++ trunk/src/model/src/main/java/net/sf/gridarta/model/baseobject/GameObjectText.java 2013-06-02 19:39:24 UTC (rev 9262) @@ -30,7 +30,7 @@ * A set of key/value attributes. * @author <a href="mailto:ch...@ri...">Christian Hujer</a> */ -public class GameObjectText implements Cloneable, Serializable { +public class GameObjectText implements Serializable { /** * The serial version UID. @@ -44,16 +44,30 @@ * @serial */ @NotNull - private StringBuilder objectText = new StringBuilder(); + private final StringBuilder objectText = new StringBuilder(); /** * Map which caches attributes for faster access. Key: attribute name value: * attribute value * @serial */ - private Map<String, String> attributeCache = new HashMap<String, String>(); + private final Map<String, String> attributeCache = new HashMap<String, String>(); /** + * Creates a new instance. + */ + public GameObjectText() { + } + + /** + * Creates a new instance as a copy of another instance. + * @param gameObjectText the other instance + */ + public GameObjectText(@NotNull final GameObjectText gameObjectText) { + objectText.append(gameObjectText.objectText); + } + + /** * Clears the attribute cache. */ private void clearAttributeCache() { @@ -97,22 +111,6 @@ } /** - * {@inheritDoc} - */ - @Override - protected GameObjectText clone() { - final GameObjectText clone; - try { - clone = (GameObjectText) super.clone(); - } catch (final CloneNotSupportedException ex) { - throw new AssertionError(ex); - } - clone.objectText = new StringBuilder(objectText); - clone.attributeCache = new HashMap<String, String>(attributeCache); - return clone; - } - - /** * Returns the object text. * @return the object text */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2013-06-02 19:28:27
|
Revision: 9261 http://sourceforge.net/p/gridarta/code/9261 Author: akirschbaum Date: 2013-06-02 19:28:21 +0000 (Sun, 02 Jun 2013) Log Message: ----------- Disable warning about constructor calls from clone(). Modified Paths: -------------- trunk/gridarta.ipr trunk/src/crossfire/src/main/java/net/sf/gridarta/var/crossfire/model/maparchobject/MapArchObject.java trunk/src/model/src/main/java/net/sf/gridarta/model/baseobject/AbstractBaseObject.java trunk/src/model/src/main/java/net/sf/gridarta/model/baseobject/GameObjectText.java trunk/src/model/src/main/java/net/sf/gridarta/model/maparchobject/AbstractMapArchObject.java Modified: trunk/gridarta.ipr =================================================================== --- trunk/gridarta.ipr 2013-06-02 18:00:10 UTC (rev 9260) +++ trunk/gridarta.ipr 2013-06-02 19:28:21 UTC (rev 9261) @@ -363,7 +363,6 @@ <option name="m_maxLength" value="64" /> </inspection_tool> <inspection_tool class="ClassReferencesSubclass" enabled="true" level="WARNING" enabled_by_default="true" /> - <inspection_tool class="CloneCallsConstructors" enabled="true" level="WARNING" enabled_by_default="true" /> <inspection_tool class="CloneDeclaresCloneNotSupported" enabled="false" level="WARNING" enabled_by_default="false" /> <inspection_tool class="CloneInNonCloneableClass" enabled="true" level="WARNING" enabled_by_default="true" /> <inspection_tool class="CloneableImplementsClone" enabled="true" level="WARNING" enabled_by_default="true"> Modified: trunk/src/crossfire/src/main/java/net/sf/gridarta/var/crossfire/model/maparchobject/MapArchObject.java =================================================================== --- trunk/src/crossfire/src/main/java/net/sf/gridarta/var/crossfire/model/maparchobject/MapArchObject.java 2013-06-02 18:00:10 UTC (rev 9260) +++ trunk/src/crossfire/src/main/java/net/sf/gridarta/var/crossfire/model/maparchobject/MapArchObject.java 2013-06-02 19:28:21 UTC (rev 9261) @@ -595,7 +595,6 @@ @Override public MapArchObject clone() { final MapArchObject clone = super.clone(); - //noinspection CloneCallsConstructors clone.loreText = new StringBuilder(loreText.toString()); return clone; } Modified: trunk/src/model/src/main/java/net/sf/gridarta/model/baseobject/AbstractBaseObject.java =================================================================== --- trunk/src/model/src/main/java/net/sf/gridarta/model/baseobject/AbstractBaseObject.java 2013-06-02 18:00:10 UTC (rev 9260) +++ trunk/src/model/src/main/java/net/sf/gridarta/model/baseobject/AbstractBaseObject.java 2013-06-02 19:28:21 UTC (rev 9261) @@ -710,7 +710,6 @@ // clone.archetype = archetype; // will NOT be cloned: archetypes are unique clone.gameObjectText = gameObjectText.clone(); if (msgText != null) { - //noinspection CloneCallsConstructors clone.msgText = new StringBuilder(msgText); } clone.multi = null; Modified: trunk/src/model/src/main/java/net/sf/gridarta/model/baseobject/GameObjectText.java =================================================================== --- trunk/src/model/src/main/java/net/sf/gridarta/model/baseobject/GameObjectText.java 2013-06-02 18:00:10 UTC (rev 9260) +++ trunk/src/model/src/main/java/net/sf/gridarta/model/baseobject/GameObjectText.java 2013-06-02 19:28:21 UTC (rev 9261) @@ -107,7 +107,6 @@ } catch (final CloneNotSupportedException ex) { throw new AssertionError(ex); } - //noinspection CloneCallsConstructors clone.objectText = new StringBuilder(objectText); clone.attributeCache = new HashMap<String, String>(attributeCache); return clone; Modified: trunk/src/model/src/main/java/net/sf/gridarta/model/maparchobject/AbstractMapArchObject.java =================================================================== --- trunk/src/model/src/main/java/net/sf/gridarta/model/maparchobject/AbstractMapArchObject.java 2013-06-02 18:00:10 UTC (rev 9260) +++ trunk/src/model/src/main/java/net/sf/gridarta/model/maparchobject/AbstractMapArchObject.java 2013-06-02 19:28:21 UTC (rev 9261) @@ -633,7 +633,6 @@ } catch (final CloneNotSupportedException ex) { throw new AssertionError(ex); } - //noinspection CloneCallsConstructors clone.msgText = new StringBuilder(msgText.toString()); clone.tilePaths = tilePaths.clone(); return clone.getThis(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |