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: <chr...@us...> - 2006-12-23 21:16:51
|
Revision: 1234 http://svn.sourceforge.net/gridarta/?rev=1234&view=rev Author: christianhujer Date: 2006-12-23 13:16:52 -0800 (Sat, 23 Dec 2006) Log Message: ----------- Changed project SDK from idea to generic 1.5. Modified Paths: -------------- trunk/gridarta.ipr Modified: trunk/gridarta.ipr =================================================================== --- trunk/gridarta.ipr 2006-12-23 21:16:12 UTC (rev 1233) +++ trunk/gridarta.ipr 2006-12-23 21:16:52 UTC (rev 1234) @@ -1932,7 +1932,7 @@ <module fileurl="file://$PROJECT_DIR$/gridarta.iml" filepath="$PROJECT_DIR$/gridarta.iml" /> </modules> </component> - <component name="ProjectRootManager" version="2" assert-keyword="true" jdk-15="true" project-jdk-name="IDEA 6107" project-jdk-type="IDEA JDK" /> + <component name="ProjectRootManager" version="2" assert-keyword="true" jdk-15="true" project-jdk-name="1.5" project-jdk-type="JavaSDK" /> <component name="ProjectRunConfigurationManager" /> <component name="RMI Configuration"> <Server /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-12-23 21:16:11
|
Revision: 1233 http://svn.sourceforge.net/gridarta/?rev=1233&view=rev Author: christianhujer Date: 2006-12-23 13:16:12 -0800 (Sat, 23 Dec 2006) Log Message: ----------- Minor unificiation. Modified Paths: -------------- trunk/daimonin/src/daieditor/CFArchType.java Modified: trunk/daimonin/src/daieditor/CFArchType.java =================================================================== --- trunk/daimonin/src/daieditor/CFArchType.java 2006-12-23 21:08:19 UTC (rev 1232) +++ trunk/daimonin/src/daieditor/CFArchType.java 2006-12-23 21:16:12 UTC (rev 1233) @@ -124,7 +124,7 @@ final List<String> secNames = new ArrayList<String>(); // list of section names final Map<String, String> ignoreTable = new HashMap<String, String>(); // ignore list - if ("default_type".equalsIgnoreCase(root.getNodeName())) { + if (root.getNodeName().equalsIgnoreCase("default_type")) { // special case: default type (this one contains the default attribs) typenr = -1; typeName = "default"; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2006-12-23 21:08:19
|
Revision: 1232 http://svn.sourceforge.net/gridarta/?rev=1232&view=rev Author: akirschbaum Date: 2006-12-23 13:08:19 -0800 (Sat, 23 Dec 2006) Log Message: ----------- Use event callbacks to update map tile panel (cfeditor only). Modified Paths: -------------- trunk/crossfire/ChangeLog trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/CMainView.java trunk/crossfire/src/cfeditor/CMapArchPanel.java trunk/crossfire/src/cfeditor/CMapViewBasic.java trunk/crossfire/src/cfeditor/CopyBuffer.java trunk/crossfire/src/cfeditor/MapViewIFrame.java trunk/crossfire/src/cfeditor/ReplaceDialog.java trunk/crossfire/src/cfeditor/gui/map/MapCursorControl.java trunk/crossfire/src/cfeditor/gui/maptilelist/MapTileListControl.java trunk/crossfire/src/cfeditor/gui/maptilelist/MapTileListView.java trunk/crossfire/src/cfeditor/map/DefaultMapModel.java trunk/crossfire/src/cfeditor/map/MapControl.java trunk/daimonin/src/daieditor/CMainControl.java trunk/src/app/net/sf/gridarta/MainControlListener.java trunk/src/app/net/sf/gridarta/gui/ConnectionView.java trunk/src/app/net/sf/gridarta/map/MapControl.java Added Paths: ----------- trunk/src/app/net/sf/gridarta/gui/maptilelist/ trunk/src/app/net/sf/gridarta/gui/maptilelist/MapTileSelection.java trunk/src/app/net/sf/gridarta/gui/maptilelist/MapTileSelectionCache.java Modified: trunk/crossfire/ChangeLog =================================================================== --- trunk/crossfire/ChangeLog 2006-12-23 20:54:30 UTC (rev 1231) +++ trunk/crossfire/ChangeLog 2006-12-23 21:08:19 UTC (rev 1232) @@ -1,3 +1,7 @@ +2006-12-23 Andreas Kirschbaum + + * Properly update map tile panel after changes. + 2006-12-22 Andreas Kirschbaum * Use bold font for top-level entries in treasure list viewer. Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2006-12-23 20:54:30 UTC (rev 1231) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2006-12-23 21:08:19 UTC (rev 1232) @@ -587,14 +587,6 @@ mainView.showArchPanelQuickObject(gameObject); } - @Nullable public GameObject insertArchToMap(final GameObject newarch, final String archname, final GameObject next, final Point pos, final boolean join) { - return currentMap.insertArchToMap(newarch, archname, next, pos, join); - } - - public void deleteMapArch(final GameObject gameObject, final Point pos, final boolean join) { - currentMap.deleteMapArch(gameObject, pos, join); - } - public GameObject getMapArch(final GameObject gameObject, final Point pos) { return currentMap.getMapArch(gameObject, pos); } @@ -721,6 +713,7 @@ // Create a new level control and set the level view from that final MapControl map = new MapControl(this, objects, maparch, false, initial); + fireMapCreatedEvent(map); if (view) { map.addMapGridListener(mainActions); map.addMapCursorListener(mainActions); @@ -841,13 +834,14 @@ } } + fireMapClosingEvent(level); + if (level.isPickmap()) { // special case: close a pickmap CPickmapPanel.getInstance().closePickmap(level); level.levelCloseNotify(); } else { // Notify the level about the closing - mainView.setMapTileList(null, null); level.levelCloseNotify(); mainView.removeLevelView(level.getMapViewFrame()); levels.remove(level); @@ -1519,6 +1513,34 @@ } /** + * Notify all listeners about a created map. + * + * @param mapControl the created map + */ + private void fireMapCreatedEvent(@NotNull final MapControl mapControl) { + final Object[] listeners = listenerList.getListenerList(); + for (int i = listeners.length - 2; i >= 0; i -= 2) { + //noinspection ObjectEquality + if (listeners[i] == MainControlListener.class) { + ((MainControlListener) listeners[i + 1]).mapCreated(mapControl); + } + } + } + + /** + * Notify all listeners about a map to be closed. + */ + private void fireMapClosingEvent(@NotNull final MapControl mapControl) { + final Object[] listeners = listenerList.getListenerList(); + for (int i = listeners.length - 2; i >= 0; i -= 2) { + //noinspection ObjectEquality + if (listeners[i] == MainControlListener.class) { + ((MainControlListener) listeners[i + 1]).mapClosing(mapControl); + } + } + } + + /** * Notify all listeners about a changed current map. */ private void fireCurrentMapChangedEvent() { @@ -1615,10 +1637,6 @@ void appExitNotify() { mainView.appExitNotify(); // notify main view - if (currentMap != null) { - mainView.setMapTileList(null, null); - } - // save settings CSettings.getInstance(IGUIConstants.APP_NAME).saveSettings(); } @@ -1893,6 +1911,16 @@ } /** {@inheritDoc} */ + public void mapCreated(@NotNull final net.sf.gridarta.map.MapControl mapControl) { + // ignore: a current map changed event will be generated + } + + /** {@inheritDoc} */ + public void mapClosing(@NotNull final net.sf.gridarta.map.MapControl mapControl) { + // ignore: a current map changed event will be generated + } + + /** {@inheritDoc} */ public void mapGridChanged(@NotNull final MapGridEvent e) { refreshMenus(); // selection state may have changed } Modified: trunk/crossfire/src/cfeditor/CMainView.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainView.java 2006-12-23 20:54:30 UTC (rev 1231) +++ trunk/crossfire/src/cfeditor/CMainView.java 2006-12-23 21:08:19 UTC (rev 1232) @@ -374,15 +374,6 @@ return mapArchPanel.getMapArchPanelObject(); } - // access mape tile list ... - public void setMapTileList(final MapControl map, final GameObject gameObject) { - mapTileListControl.setMapTileList(map, gameObject); - } - - public void refreshMapTileList() { - mapTileListControl.refresh(); - } - public GameObject getMapTileSelection() { return mapTileListControl.getMapTileSelection(); } @@ -467,7 +458,6 @@ */ void refreshMenusAndToolbars() { archPanel.refresh(); - mapTileListControl.refresh(); mapArchPanel.refresh(); statusBar.refresh(); Modified: trunk/crossfire/src/cfeditor/CMapArchPanel.java =================================================================== --- trunk/crossfire/src/cfeditor/CMapArchPanel.java 2006-12-23 20:54:30 UTC (rev 1231) +++ trunk/crossfire/src/cfeditor/CMapArchPanel.java 2006-12-23 21:08:19 UTC (rev 1232) @@ -281,20 +281,10 @@ mainControl.getArchetypeParser().postParseGameObject(invnew, 0); inv.addLast(invnew); - mainControl.getMainView().setMapTileList(mainControl.getCurrentMap(), inv); mainControl.getCurrentMap().setLevelChangedFlag(); // the map has been modified } public void updateMapTileList() { - GameObject inv = mainView.getMapTileSelection(); - if (inv == null) { - return; - } - - // if this is a multi-tail, we put the new arch into the head's inv. - inv = inv.getHead(); - - mainControl.getMainView().setMapTileList(mainControl.getCurrentMap(), inv); mainControl.getCurrentMap().setLevelChangedFlag(); // the map has been modified } @@ -445,7 +435,6 @@ updateMapTileList(); // if needed (due to face changes), we also redraw the map - mainControl.getMainView().refreshMapTileList(); if (needRedraw) { mainControl.getCurrentMap().repaint(); } Modified: trunk/crossfire/src/cfeditor/CMapViewBasic.java =================================================================== --- trunk/crossfire/src/cfeditor/CMapViewBasic.java 2006-12-23 20:54:30 UTC (rev 1231) +++ trunk/crossfire/src/cfeditor/CMapViewBasic.java 2006-12-23 21:08:19 UTC (rev 1232) @@ -385,10 +385,6 @@ if (!(selChange == mapCursor.isActive())) { CMainControl.getInstance().getMainView().refreshMenus(); } - - if (!e.isShiftDown() && !e.isControlDown()) { - selectTile(mapLoc); - } } else { // middle mouse button: delete arch // (I intenionally used "else" here. BUTTON2_MASK seems not to work for some systems) @@ -397,7 +393,6 @@ } } else { mapCursor.setLocation(mapLoc); - mainControl.getMainView().setMapTileList(null, null); // for secure... } /* UndoAndRedo.getInstance(mapControl).add(new CPaintOp(previewRect, aOrigData, (short)mapControl.getSelectedTile())); @@ -456,9 +451,7 @@ mapCursor.setLocation(temp); // Right Mouse Button: Arches get inserted all the way - if (temp == null) { - mainControl.getMainView().setMapTileList(null, null); - } else { + if (temp != null) { mapControl.insertSelArchToMap(temp, false); } } else { @@ -466,9 +459,7 @@ // Middle Mouse Button: Arches get deleted all the way - if (temp == null) { - mainControl.getMainView().setMapTileList(null, null); - } else { + if (temp != null) { // delete the topmost arch (matching the view settings) // on that square and redraw the map GameObject tmpArch = null; @@ -521,24 +512,10 @@ } else { insertArchName = "nothing"; } - - mainControl.getMainView().setMapTileList(mainControl.getCurrentMap(), null); } } } - private void selectTile(final Point mapLoc) { - if (mapLoc.x == -1 || mapLoc.y == -1) { - if (!mapControl.isPickmap()) { - mainControl.getMainView().setMapTileList(null, null); - } - } else { - if (!mapControl.isPickmap()) { - mainControl.getMainView().setMapTileList(mainControl.getCurrentMap(), null); - } - } - } - private void deleteObject(final Point mapLoc) { if (mapLoc.x != -1 && mapLoc.y != -1) { // delete the topmost arch (matching the view settings) on that square @@ -554,9 +531,6 @@ if (tmpArch != null) { mapControl.calcArchRedraw(tmpArch); // get redraw info mapControl.deleteMapArch(tmpArch, mapLoc, MapModel.JOIN_ENABLE); - - // update mapArch panel - mainControl.getMainView().setMapTileList(mainControl.getCurrentMap(), null); } } } @@ -730,4 +704,12 @@ mapCursor.addMapCursorListener(listener); } + /** + * Unregister a MapCursorListener. + * @param listener MapCursorListener to unregister + */ + public void removeMapCursorListener(final MapCursorListener listener) { + mapCursor.removeMapCursorListener(listener); + } + } // class CMapViewBasic Modified: trunk/crossfire/src/cfeditor/CopyBuffer.java =================================================================== --- trunk/crossfire/src/cfeditor/CopyBuffer.java 2006-12-23 20:54:30 UTC (rev 1231) +++ trunk/crossfire/src/cfeditor/CopyBuffer.java 2006-12-23 21:08:19 UTC (rev 1232) @@ -223,9 +223,6 @@ } } mapControl.getMapModel().endTransaction(); - - // now the toolbars must be redrawn - mainControl.getMainView().refreshMapTileList(); } /** @@ -256,7 +253,6 @@ addArchToMap(mapControl, gameObject, p, false, fillBelow); } mapControl.getMapModel().endTransaction(); - mainControl.getMainView().refreshMapTileList(); } /** @@ -282,7 +278,6 @@ mapControl.getMapModel().beginTransaction("Floodfill"); // TODO: I18N/L10N floodfill(mapControl, cursor.x, cursor.y, arch); mapControl.getMapModel().endTransaction(); - mainControl.getMainView().refreshMapTileList(); } /** Modified: trunk/crossfire/src/cfeditor/MapViewIFrame.java =================================================================== --- trunk/crossfire/src/cfeditor/MapViewIFrame.java 2006-12-23 20:54:30 UTC (rev 1231) +++ trunk/crossfire/src/cfeditor/MapViewIFrame.java 2006-12-23 21:08:19 UTC (rev 1232) @@ -39,6 +39,7 @@ import net.sf.gridarta.gui.map.MapCursorListener; import net.sf.gridarta.gui.map.MapGridListener; import net.sf.japi.swing.ActionFactory; +import org.jetbrains.annotations.NotNull; /** * The <code>MapViewIFrame</code> is mainly a wrapper class which creates a @@ -231,10 +232,18 @@ * Register a MapCursorListener. * @param listener MapCursorListener to register */ - public void addMapCursorListener(final MapCursorListener listener) { + public void addMapCursorListener(@NotNull final MapCursorListener listener) { view.addMapCursorListener(listener); } + /** + * Unregister a MapCursorListener. + * @param listener MapCursorListener to unregister + */ + public void removeMapCursorListener(@NotNull final MapCursorListener listener) { + view.removeMapCursorListener(listener); + } + /** Action class for selecting this window. */ public final class WindowAction extends AbstractAction { Modified: trunk/crossfire/src/cfeditor/ReplaceDialog.java =================================================================== --- trunk/crossfire/src/cfeditor/ReplaceDialog.java 2006-12-23 20:54:30 UTC (rev 1231) +++ trunk/crossfire/src/cfeditor/ReplaceDialog.java 2006-12-23 21:08:19 UTC (rev 1232) @@ -336,7 +336,6 @@ } mapControl.getMapModel().endTransaction(); - mainControl.getMainView().refreshMapTileList(); return replaceCount; } Modified: trunk/crossfire/src/cfeditor/gui/map/MapCursorControl.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/map/MapCursorControl.java 2006-12-23 20:54:30 UTC (rev 1231) +++ trunk/crossfire/src/cfeditor/gui/map/MapCursorControl.java 2006-12-23 21:08:19 UTC (rev 1232) @@ -143,35 +143,19 @@ } public void insertArch() { - final MapControl mapControl = mainControl.getCurrentMap(); - assert mapControl != null; - final MapCursor mapCursor = mapControl.getMapCursor(); - assert mapCursor != null; - if (mapCursor.isActive()) { - mapControl.insertSelArchToMap(mapCursor.getLocation(), true); - mainControl.getMainView().setMapTileList(mapControl, null); - } + final CMainView mainView = mainControl.getMainView(); + assert mainView != null; + final MapTileListControl mapTileListControl = mainView.getMapTileListControl(); + assert mapTileListControl != null; + mapTileListControl.insertGameObjectFromArchPanel(); } public void deleteArch() { - final MapControl mapControl = mainControl.getCurrentMap(); - assert mapControl != null; - final MapCursor mapCursor = mapControl.getMapCursor(); - assert mapCursor != null; - if (mapCursor.isActive()) { - final CMainView mainView = mainControl.getMainView(); - assert mainView != null; - final MapTileListControl mapTileListControl = mainView.getMapTileListControl(); - assert mapTileListControl != null; - final GameObject arch = mapTileListControl.getMapTileSelection(); - if (arch != null) { - final Point pos = mapCursor.getLocation(); - assert pos != null; - arch.remove(); - // TODO: re-select next object after the removed one - mainControl.getMainView().setMapTileList(mapControl, null); - } - } + final CMainView mainView = mainControl.getMainView(); + assert mainView != null; + final MapTileListControl mapTileListControl = mainView.getMapTileListControl(); + assert mapTileListControl != null; + mapTileListControl.deleteSelection(); } private void selectTile(final MapGrid.SelectionMode mode) { Modified: trunk/crossfire/src/cfeditor/gui/maptilelist/MapTileListControl.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/maptilelist/MapTileListControl.java 2006-12-23 20:54:30 UTC (rev 1231) +++ trunk/crossfire/src/cfeditor/gui/maptilelist/MapTileListControl.java 2006-12-23 21:08:19 UTC (rev 1232) @@ -41,6 +41,7 @@ import java.util.Date; import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; +import net.sf.gridarta.map.MapSquare; import org.jetbrains.annotations.Nullable; /** @@ -63,9 +64,6 @@ private GameObject lastClickGameObject = null; - /** The currently selected MapSquare. */ - private transient Point currentSquare = null; - /** The view for this controller. */ private final MapTileListView view; @@ -87,7 +85,6 @@ final GameObject arch = getMapTileSelection(); if (arch != null) { arch.moveDown(); - refresh(); } } }; @@ -99,7 +96,6 @@ final GameObject arch = getMapTileSelection(); if (arch != null) { arch.moveUp(); - refresh(); } } }; @@ -133,30 +129,10 @@ lastClickGameObject = getMapTileSelection(); } else if ((e.getModifiers() & InputEvent.BUTTON3_MASK) != 0 || ((e.getModifiers() & InputEvent.BUTTON1_MASK) != 0 && e.isShiftDown())) { // --- right mouse button: insert arch --- - - if (currentSquare != null && mainControl.getArchPanelHighlight() != null) { - mainControl.getCurrentMap().getMapModel().beginTransaction("Insert"); // TODO; I18N/L10N - final int listIndex = view.getListIndex(e); - if (listIndex >= view.getModelSize()) { - mainControl.insertArchToMap(mainControl.getArchPanelHighlight(), mainControl.getPanelArchName(), null, currentSquare, MapModel.JOIN_ENABLE); - } else { - final GameObject entry = view.getListGameObject(listIndex); - mainControl.insertArchToMap(mainControl.getArchPanelHighlight(), mainControl.getPanelArchName(), entry, currentSquare, MapModel.JOIN_ENABLE); - } - mainControl.getCurrentMap().getMapModel().endTransaction(); - - // refresh - mainControl.getCurrentMap().setLevelChangedFlag(); // the map has been modified - mainControl.getMainView().refreshMapTileList(); // update tile window - } + insertGameObjectFromArchPanel(view.getListIndex(e)); } else { // --- middle mouse button: delete arch --- - final int listIndex = view.getListIndex(e); - if (listIndex < view.getModelSize()) { - mainControl.getCurrentMap().getMapModel().beginTransaction("Delete"); // TODO; I18N/L10N - deleteIndexFromList(listIndex); - mainControl.getCurrentMap().getMapModel().endTransaction(); - } + deleteIndex(view.getListIndex(e)); } } }; @@ -179,33 +155,96 @@ } /** + * Delete the currently selected game object. + */ + public void deleteSelection() { + deleteIndex(view.getSelectedIndex()); + } + + /** * Delete an GameObject with a specific list index. * @param index List index of GameObject */ - private void deleteIndexFromList(final int index) { - if (index < 0) { + private void deleteIndex(final int index) { + if (index < 0 || index >= view.getModelSize()) { return; - } // index is -1 for empty lists, so an IndexOutOfBoundsException would be thrown - final GameObject temp = getMapTileSelection(); + } + + final MapControl mapControl = view.getCurrentMapControl(); + if (mapControl == null) { + return; + } + + final MapSquare<GameObject> mapSquare = view.getCurrentMapSquare(); + if (mapSquare == null) { + return; + } + + mapControl.getMapModel().beginTransaction("Delete"); // TODO; I18N/L10N final GameObject entry = view.getListGameObject(index); if (entry != null) { - mainControl.deleteMapArch(entry, currentSquare, MapModel.JOIN_ENABLE); - setMapTileList(mainControl.getCurrentMap(), temp); + mapControl.deleteMapArch(entry, new Point(mapSquare.getMapX(), mapSquare.getMapY()), MapModel.JOIN_ENABLE); + + if (index + 1 < view.getModelSize()) { + view.setSelectedGameObject(view.getListGameObject(index + 1)); + } else if (index > 0) { + view.setSelectedGameObject(view.getListGameObject(index - 1)); + } else { + view.setSelectedGameObject(null); + } } + mapControl.getMapModel().endTransaction(); } - public void refresh() { - setMapTileList(mainControl.getCurrentMap(), getMapTileSelection()); - view.repaint(); + /** + * Insert a new game object. + */ + public void insertGameObjectFromArchPanel() { + insertGameObjectFromArchPanel(view.getSelectedIndex()); } /** + * Insert a new game object. + * + * @param index the list index to insert at + */ + public void insertGameObjectFromArchPanel(final int index) { + final GameObject gameObject = mainControl.getArchPanelHighlight(); + if (gameObject == null) { + return; + } + + final MapControl currentMapControl = view.getCurrentMapControl(); + if (currentMapControl == null) { + return; + } + + final MapSquare<GameObject> currentMapSquare = view.getCurrentMapSquare(); + if (currentMapSquare == null) { + return; + } + + currentMapControl.getMapModel().beginTransaction("Insert"); // TODO; I18N/L10N + final GameObject insertedGameObject; + if (index >= view.getModelSize()) { + insertedGameObject = currentMapControl.insertArchToMap(gameObject, mainControl.getPanelArchName(), null, new Point(currentMapSquare.getMapX(), currentMapSquare.getMapY()), MapModel.JOIN_ENABLE); + } else { + final GameObject entry = view.getListGameObject(index); + insertedGameObject = currentMapControl.insertArchToMap(gameObject, mainControl.getPanelArchName(), entry, new Point(currentMapSquare.getMapX(), currentMapSquare.getMapY()), MapModel.JOIN_ENABLE); + } + view.setSelectedGameObject(insertedGameObject); + currentMapControl.getMapModel().endTransaction(); + + // refresh + currentMapControl.setLevelChangedFlag(); // the map has been modified + } + + /** * Set the display to the currently selected map tile. * @param mapControl Map to get display for (includes selection information) * @param gameObject selected GameObject */ public void setMapTileList(final MapControl mapControl, final GameObject gameObject) { - view.setMapTileList(mapControl, gameObject); // refresh the MapArchPanel to display the new arch mainView.refreshMapArchPanel(); @@ -220,22 +259,4 @@ return view; } - /** - * Return the currently selected MapSquare. - * - * @return the currently selected MapSquare - */ - @Nullable Point getCurrentSquare() { - return currentSquare; - } - - /** - * Set the currently selected MapSquare. - * - * @param point the selected MapSquare - */ - void setCurrentSquare(@Nullable Point point) { - currentSquare = point; - } - } // class MapTileListControl Modified: trunk/crossfire/src/cfeditor/gui/maptilelist/MapTileListView.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/maptilelist/MapTileListView.java 2006-12-23 20:54:30 UTC (rev 1231) +++ trunk/crossfire/src/cfeditor/gui/maptilelist/MapTileListView.java 2006-12-23 21:08:19 UTC (rev 1232) @@ -33,6 +33,7 @@ import java.awt.BorderLayout; import java.awt.Color; import java.awt.GridLayout; +import java.awt.Point; import java.awt.Rectangle; import java.awt.event.MouseEvent; import javax.swing.BorderFactory; @@ -45,9 +46,15 @@ import static javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER; import javax.swing.SwingConstants; import static javax.swing.JViewport.SIMPLE_SCROLL_MODE; -import net.sf.gridarta.gameobject.GameObjectContainer; +import net.sf.gridarta.MainControlListener; import net.sf.gridarta.gui.map.MapCursorEvent; import net.sf.gridarta.gui.map.MapCursorListener; +import net.sf.gridarta.gui.maptilelist.MapTileSelection; +import net.sf.gridarta.gui.maptilelist.MapTileSelectionCache; +import net.sf.gridarta.map.MapModelEvent; +import net.sf.gridarta.map.MapModelListener; +import net.sf.gridarta.map.MapSquare; +import org.apache.log4j.Logger; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -56,13 +63,13 @@ * @author <a href="mailto:mic...@no...">Michael Toennies</a> * @author <a href="mailto:and...@gm...">Andreas Vogl</a> */ -public final class MapTileListView extends JPanel implements MapCursorListener { +public final class MapTileListView extends JPanel implements MainControlListener<MapControl>, MapCursorListener, MapModelListener<GameObject> { /** Serial Version UID. */ private static final long serialVersionUID = 1L; - /** The controller for this view. */ - @NotNull final MapTileListControl control; + /** The Logger for printing log messages. */ + private static final Logger log = Logger.getLogger(MapTileListView.class); /** The main control for this view. */ @NotNull final CMainControl mainControl; @@ -75,6 +82,16 @@ private int listCounter = 0; /** + * The cache to store selections for each map control. + */ + @NotNull private final MapTileSelectionCache<GameObject, MapControl> mapTileSelectionCache = new MapTileSelectionCache<GameObject, MapControl>(); + + /** + * The currently selected map tile. + */ + @Nullable private MapTileSelection<GameObject, MapControl> selectedMapTile = null; + + /** * Create a new instance. * * @param control the controller for this view @@ -85,7 +102,6 @@ * bottom or on the top of the main view */ MapTileListView(@NotNull final MapTileListControl control, @NotNull final CMainControl mainControl, final boolean mapTileListBottom) { - this.control = control; this.mainControl = mainControl; setLayout(new BorderLayout()); @@ -137,9 +153,31 @@ * listen for mouse events in the panel */ list.addMouseListener(control.getMouseListener()); + + mainControl.addMainControlListener(this); } /** + * Return the currently selected map control. + * + * @return the currently selected map control, or <code>null</code> if no + * tile is selected + */ + @Nullable public MapControl getCurrentMapControl() { + return selectedMapTile == null ? null : selectedMapTile.getMapControl(); + } + + /** + * Return the currently selected map square. + * + * @return the currently selected map square, or <code>null</code> if no + * tile is selected + */ + @Nullable public MapSquare<GameObject> getCurrentMapSquare() { + return selectedMapTile == null ? null : selectedMapTile.getMapSquare(); + } + + /** * Determine the list index for a given mouse event. This function differs * from <code>list.locationTopIndex(e.getPoint())</code> in that it always * returns a valid list index, or the list size (i.e., one element past the @@ -171,50 +209,51 @@ * @return the currently selected GameObject */ @Nullable public GameObject getMapTileSelection() { - return (GameObject) list.getSelectedValue(); - } + final GameObject gameObject = (GameObject) list.getSelectedValue(); - private int getTileArch(final int oldindex) { - final int index; - if (oldindex == -1) { - index = list.getFirstVisibleIndex(); - } else if (getModelSize() <= oldindex) { - index = oldindex; - } else { - index = -1; + if (selectedMapTile != null) { + selectedMapTile.setGameObject(gameObject); + selectedMapTile.setIndex(list.getSelectedIndex()); } - if (index != -1 && getModelSize() > 0) { - list.setSelectedIndex(index); - } - return list.getSelectedIndex(); + + return gameObject; } /** - * Set the display to the currently selected map tile. - * @param mapControl Map to get display for (includes selection information) - * @param gameObject selected GameObject + * Re-display the map tile panel for {@link #selectedMapTile}. Possibly updates + * information in <code>selectedMapTile</code>. */ - void setMapTileList(final MapControl mapControl, final GameObject gameObject) { + private void refresh() { + final MapControl mapControl; + final MapSquare<GameObject> mapSquare; + final GameObject gameObject; + if (selectedMapTile == null) { + mapControl = null; + mapSquare = null; + gameObject = null; + } else { + mapControl = selectedMapTile.getMapControl(); + mapSquare = selectedMapTile.getMapSquare(); + gameObject = selectedMapTile.getGameObject(); + } + list.setEnabled(false); model.removeAllElements(); if (mapControl == null) { - // mouse has been clicked outside the mapview - control.setCurrentSquare(null); - getTileArch(-1); + list.setSelectedIndex(0); list.setEnabled(true); return; } listCounter = 0; - control.setCurrentSquare(mapControl.getMapCursor().getLocation()); int postSelect = -1; boolean foundSIndex = false; - int sIndex = 0; + int sIndex = -1; // Now go through the list backwards and put all arches // on the panel in this order - if (control.getCurrentSquare() != null) { - for (final GameObject node : mapControl.getMapModel().getMapSquare(control.getCurrentSquare()).reverse()) { + if (mapSquare != null) { + for (final GameObject node : mapSquare.reverse()) { // add the node if (node == gameObject) { postSelect = listCounter; @@ -236,11 +275,16 @@ } if (postSelect != -1) { - list.setSelectedIndex(postSelect); - } else { + setSelectedIndex(postSelect); + } else if (sIndex != -1) { // Per default, the topmost arch matching the view settings is selected. // (With no view settings applied, the very topmost arch is selected.) - list.setSelectedIndex(sIndex); + setSelectedIndex(sIndex); + } else if (selectedMapTile != null){ + // use last known good index + setSelectedIndex(selectedMapTile.getIndex()); + } else { + setSelectedIndex(0); } list.setEnabled(true); @@ -250,7 +294,7 @@ * Add inventory objects to an arch in the MapTileListView recursively. * @param node the arch where the inventory gets added * @param gameObject selected GameObject - * @return <code>-1</code> if <var>selArch</var> was found, else <var>listCounter</var> of the arch + * @return <code>listCounter</code> for <var>gameObject</var>, or <code>-1</code> if not found */ private int addInvObjects(final GameObject node, final GameObject gameObject) { int selListCounter = -1; @@ -270,22 +314,124 @@ } /** {@inheritDoc} */ + public void currentMapChanged(@Nullable final MapControl mapControl) { + if (setSelectedMapTile(mapTileSelectionCache.findOrCreate(mapControl))) { + refresh(); + } + } + + /** {@inheritDoc} */ + public void mapCreated(@NotNull final MapControl mapControl) { + mapControl.addMapCursorListener(this); + mapControl.addMapModelListener(this); + } + + /** {@inheritDoc} */ + public void mapClosing(@NotNull final MapControl mapControl) { + mapControl.removeMapModelListener(this); + mapControl.removeMapCursorListener(this); + + final MapTileSelection<GameObject, MapControl> closedMapTile = mapTileSelectionCache.find(mapControl); + if (selectedMapTile != null && selectedMapTile == closedMapTile) { + if (setSelectedMapTile(null)) { + refresh(); + } + } + } + + /** {@inheritDoc} */ public void mapCursorChangedPos(@NotNull final MapCursorEvent e) { - if (e.getSource().isActive()) { - // Position changed - setMapTileList(mainControl.getCurrentMap(), null); - } else { - // Cursor was disabled - setMapTileList(null, null); + if (selectedMapTile == null) { + return; } + + final MapControl mapControl = selectedMapTile.getMapControl(); + + final Point cursorPos = e.getSource().getLocation(); + if (cursorPos == null || !mapControl.isPointValid(cursorPos)) { + if (setSelectedMapSquare(null)) { + refresh(); + } + return; + } + + final MapSquare mapSquare = mapControl.getMapModel().getMapSquare(cursorPos); + if (setSelectedMapSquare(mapSquare)) { + refresh(); + } } /** {@inheritDoc} */ public void mapCursorChangedMode(@NotNull final MapCursorEvent e) { - // A mode change can be ignored + // ignore } + /** {@inheritDoc} */ + public void mapSizeChanged(final MapModelEvent<GameObject> e) { + if (selectedMapTile != null && selectedMapTile.getMapControl().getMapModel() == e.getMapModel() && selectedMapTile.validateMapSquare()) { + refresh(); + } + } + + /** {@inheritDoc} */ + public void mapSquaresChanged(final MapModelEvent<GameObject> e) { + if (selectedMapTile == null) { + return; + } + + for (final MapSquare mapSquare : e.getSquares()) { + if (selectedMapTile.checkForChangedMapSquare(mapSquare)) { + refresh(); + break; + } + } + } + + /** {@inheritDoc} */ + public void mapObjectsChanged(final MapModelEvent<GameObject> e) { + if (selectedMapTile == null) { + return; + } + + for (final GameObject gameObject : e.getGameObjects()) { + final MapSquare mapSquare = gameObject.getMapSquare(); + if (mapSquare != null && selectedMapTile.checkForChangedMapSquare(mapSquare)) { + refresh(); + break; + } + } + } + /** + * Set a map tile selection. + * + * @return <code>true</code> if the selected map tile has changed + */ + private boolean setSelectedMapTile(@Nullable final MapTileSelection<GameObject, MapControl> mapTileSelection) { + if (mapTileSelection == selectedMapTile) { + return false; + } + + selectedMapTile = mapTileSelection; + return true; + } + + /** + * Set the currently selected map square. + * + * @param mapSquare the selected map square + * + * @return <code>true</code> if the state has changed + */ + private boolean setSelectedMapSquare(@Nullable final MapSquare mapSquare) { + if (selectedMapTile == null) { + return false; + } + + return selectedMapTile.setMapSquare(mapSquare); + } + + /** * Return a game object from the list. * * @param index the index in the list @@ -293,7 +439,8 @@ * @return the game object, or <code>null</code> if the index is invalid */ @Nullable GameObject getListGameObject(final int index) { - return (GameObject) model.getElementAt(index); + final int actualIndex = getValidIndex(index); + return actualIndex < model.getSize() ? (GameObject) model.getElementAt(actualIndex) : null; } /** @@ -306,6 +453,33 @@ } /** + * Set the selected game object. + * + * @param gameObject the game object to select, or <code>null</code> to + * unselect it + */ + void setSelectedGameObject(@Nullable final GameObject gameObject) { + if (selectedMapTile == null) { + return; + } + + if (gameObject != null) { + final MapSquare<GameObject> mapSquare = gameObject.getTopContainer().getMapSquare(); + if (mapSquare == null) { + log.warn("setSelectedGameObject: gameObject " + gameObject + " is not part of a map"); + return; + } + if (selectedMapTile.getMapControl().getMapModel() != mapSquare.getModel()) { + return; + } + + setSelectedMapSquare(mapSquare); + } + + selectedMapTile.setGameObject(gameObject); + } + + /** * Return the currently selected list index. * * @return the currently selected list index @@ -321,13 +495,28 @@ * @param index the index to select */ void setSelectedIndex(final int index) { + final int actualIndex = getValidIndex(index); + list.setSelectedIndex(actualIndex); + if (selectedMapTile != null) { + selectedMapTile.setIndex(actualIndex); + } + } + + /** + * Determine a valid list index near a given index. + * + * @param index the index to look up + * + * @return a valid index, or 0 if the list is empty + */ + private int getValidIndex(final int index) { if (index < 0) { - list.setSelectedIndex(0); - } else if (index >= getModelSize()) { - list.setSelectedIndex(Math.max(0, getModelSize() - 1)); - } else { - list.setSelectedIndex(index); + return 0; } + if (index >= getModelSize()) { + return Math.max(0, getModelSize() - 1); + } + return index; } } // class MapTileListView Modified: trunk/crossfire/src/cfeditor/map/DefaultMapModel.java =================================================================== --- trunk/crossfire/src/cfeditor/map/DefaultMapModel.java 2006-12-23 20:54:30 UTC (rev 1231) +++ trunk/crossfire/src/cfeditor/map/DefaultMapModel.java 2006-12-23 21:08:19 UTC (rev 1232) @@ -304,7 +304,6 @@ next.getContainer().addLast(newGameObject); mainControl.getArchetypeParser().postParseGameObject(newGameObject, mapControl.getActiveEditType()); - mainControl.getMainView().setMapTileList(mainControl.getCurrentMap(), newGameObject); } setLevelChangedFlag(); // the map has been modified @@ -383,7 +382,7 @@ } /** {@inheritDoc} */ - public void deleteMapArch(final GameObject gameObject, final Point pos, final boolean join) { + public void deleteMapArch(final GameObject gameObject, @NotNull final Point pos, final boolean join) { // first, try to find the tile we had selected for (final GameObject node : getMapSquare(pos)) { if (node == gameObject) { Modified: trunk/crossfire/src/cfeditor/map/MapControl.java =================================================================== --- trunk/crossfire/src/cfeditor/map/MapControl.java 2006-12-23 20:54:30 UTC (rev 1231) +++ trunk/crossfire/src/cfeditor/map/MapControl.java 2006-12-23 21:08:19 UTC (rev 1232) @@ -36,6 +36,7 @@ import net.sf.gridarta.gui.map.MapCursorListener; import net.sf.gridarta.gui.map.MapGrid; import net.sf.gridarta.gui.map.MapGridListener; +import net.sf.gridarta.map.MapModelListener; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -44,7 +45,7 @@ * @author <a href="mailto:mic...@no...">Michael Toennies</a> * @author <a href="mailto:and...@gm...">Andreas Vogl</a> */ -public final class MapControl implements net.sf.gridarta.map.MapControl { +public final class MapControl implements net.sf.gridarta.map.MapControl<GameObject, MapArchObject> { /** * The main controller of this subcontroller. @@ -214,7 +215,7 @@ mapModel.addGameObjectToMap(arch, false); } - public void deleteMapArch(final GameObject gameObject, final Point pos, final boolean join) { + public void deleteMapArch(final GameObject gameObject, @NotNull final Point pos, final boolean join) { mapModel.deleteMapArch(gameObject, pos, join); } @@ -612,8 +613,32 @@ * Register a MapCursorListener. * @param listener MapCursorListener to register */ - public void addMapCursorListener(final MapCursorListener listener) { + public void addMapCursorListener(@NotNull final MapCursorListener listener) { mapViewFrame.addMapCursorListener(listener); } + /** + * Unregister a MapCursorListener. + * @param listener MapCursorListener to unregister + */ + public void removeMapCursorListener(@NotNull final MapCursorListener listener) { + mapViewFrame.removeMapCursorListener(listener); + } + + /** + * Register a MapModelListener. + * @param listener MapModelListener to register + */ + public void addMapModelListener(@NotNull final MapModelListener listener) { + mapModel.addMapModelListener(listener); + } + + /** + * Unregister a MapModelListener. + * @param listener MapModelListener to unregister + */ + public void removeMapModelListener(@NotNull final MapModelListener listener) { + mapModel.removeMapModelListener(listener); + } + } // class MapControl Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2006-12-23 20:54:30 UTC (rev 1231) +++ trunk/daimonin/src/daieditor/CMainControl.java 2006-12-23 21:08:19 UTC (rev 1232) @@ -884,6 +884,7 @@ setStatusText("Creating new map " + maparch.getMapName()); } final MapControl map = new MapControl(this, objects, maparch, false, view); + fireMapCreatedEvent(map); levels.add(map); if (view) { map.addMapGridListener(mainActions); @@ -1006,6 +1007,8 @@ } } + fireMapClosingEvent(level); + if (level.isPickmap()) { // special case: close a pickmap CPickmapPanel.getInstance().closePickmap(level); @@ -1705,6 +1708,34 @@ } /** + * Notify all listeners about a created map. + * + * @param mapControl the created map + */ + private void fireMapCreatedEvent(@NotNull final MapControl mapControl) { + final Object[] listeners = listenerList.getListenerList(); + for (int i = listeners.length - 2; i >= 0; i -= 2) { + //noinspection ObjectEquality + if (listeners[i] == MainControlListener.class) { + ((MainControlListener) listeners[i + 1]).mapCreated(mapControl); + } + } + } + + /** + * Notify all listeners about a map to be closed. + */ + private void fireMapClosingEvent(@NotNull final MapControl mapControl) { + final Object[] listeners = listenerList.getListenerList(); + for (int i = listeners.length - 2; i >= 0; i -= 2) { + //noinspection ObjectEquality + if (listeners[i] == MainControlListener.class) { + ((MainControlListener) listeners[i + 1]).mapClosing(mapControl); + } + } + } + + /** * Notify all listeners about a changed current map. */ private void fireCurrentMapChangedEvent() { @@ -2189,6 +2220,16 @@ aSelectAll.setEnabled(isSelectAllEnabled()); } + /** {@inheritDoc} */ + public void mapCreated(@NotNull final net.sf.gridarta.map.MapControl mapControl) { + // ignore: a current map changed event will be generated + } + + /** {@inheritDoc} */ + public void mapClosing(@NotNull final net.sf.gridarta.map.MapControl mapControl) { + // ignore: a current map changed event will be generated + } + /* {@inheritDoc} */ public void currentMapChanged(@Nullable final net.sf.gridarta.map.MapControl mapControl) { refreshMenus(); Modified: trunk/src/app/net/sf/gridarta/MainControlListener.java =================================================================== --- trunk/src/app/net/sf/gridarta/MainControlListener.java 2006-12-23 20:54:30 UTC (rev 1231) +++ trunk/src/app/net/sf/gridarta/MainControlListener.java 2006-12-23 21:08:19 UTC (rev 1232) @@ -22,6 +22,7 @@ import java.util.EventListener; import net.sf.gridarta.map.MapControl; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; /** @@ -29,7 +30,7 @@ * * @author Andreas Kirschbaum */ -public interface MainControlListener extends EventListener { +public interface MainControlListener<C extends MapControl> extends EventListener { /** * This event handler is called when the current map has changed. @@ -37,6 +38,20 @@ * @param mapControl the new map control, or <code>null</code> if no opened * map exists */ - void currentMapChanged(@Nullable MapControl mapControl); + void currentMapChanged(@Nullable C mapControl); + /** + * This event handler is called when a map was created. + * + * @param mapControl the created map control + */ + void mapCreated(@NotNull C mapControl); + + /** + * This event handler is called when a map is to be closed. + * + * @param mapControl the map control that is to be closed + */ + void mapClosing(@NotNull C mapControl); + } Modified: trunk/src/app/net/sf/gridarta/gui/ConnectionView.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/ConnectionView.java 2006-12-23 20:54:30 UTC (rev 1231) +++ trunk/src/app/net/sf/gridarta/gui/ConnectionView.java 2006-12-23 21:08:19 UTC (rev 1232) @@ -37,6 +37,7 @@ import net.sf.gridarta.map.MapModelEvent; import net.sf.gridarta.map.MapModelListener; import net.sf.gridarta.map.MapSquare; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; /** @@ -87,6 +88,16 @@ scanMapForConnections(mapControl == null ? null : mapControl.getMapModel()); } + /** {@inheritDoc} */ + public void mapCreated(@NotNull final MapControl mapControl) { + // ignore: a current map changed event will be generated + } + + /** {@inheritDoc} */ + public void mapClosing(@NotNull final MapControl mapControl) { + // ignore: a current map changed event will be generated + } + /** * Scans a map for the contained connections. * @param model Model of map to scan Added: trunk/src/app/net/sf/gridarta/gui/maptilelist/MapTileSelection.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/maptilelist/MapTileSelection.java (rev 0) +++ trunk/src/app/net/sf/gridarta/gui/maptilelist/MapTileSelection.java 2006-12-23 21:08:19 UTC (rev 1232) @@ -0,0 +1,194 @@ +/* + * Gridarta Java Editor. + * Copyright (C) 2006 The Gridarta Developers + * + * (code based on: Gridder. 2D grid based level editor. (C) 2000 Pasi Keränen) + * + * 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., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + */ + +package net.sf.gridarta.gui.maptilelist; + +import java.awt.Point; +import net.sf.gridarta.gameobject.GameObject; +import net.sf.gridarta.map.MapControl; +import net.sf.gridarta.map.MapSquare; +import org.apache.log4j.Logger; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * The class <code>MapTileSelection</code> holds the selection state for one + * {@link MapControl}. It consists of a {@link MapSquare}, a {@link GameObject} + * in this map square, and a selection index. + * + * <p/>The game object and the selection index is redundant. This redundancy is + * used to retain the selection when the map square changes. + * + * @author Andreas Kirschbaum + */ +public class MapTileSelection<G extends GameObject<G>, C extends MapControl> { + + /** The Logger for printing log messages. */ + private static final Logger log = Logger.getLogger(MapTileSelection.class.getName()); + + /** + * The corresponding map control. + */ + @NotNull private final C mapControl; + + /** + * The currently selected map square. It is set to <code>null</code> if no + * map tile is selected. + */ + @Nullable private MapSquare<G> mapSquare = null; + + /** + * The currently selected game object. It is part of {@link #mapSquare}. It + * is set to <code>null</code> if not game object is selected (or if + * <code>mapSquare</code> is <code>null</code>). + */ + @Nullable private G gameObject = null; + + /** + * The index in the map tile list that corresponds to {@link gameObject}. + * It is set to zero if <code>gameObject</code> is <code>null</code>. + */ + private int index = 0; + + /** + * Create a new instance. + * + * @param mapControl the corresponding map control + */ + public MapTileSelection(@NotNull final C mapControl) { + this.mapControl = mapControl; + } + + /** + * Select a map square. If it is different from the previously selected map + * square, the state ({@link #gameObject} and {@link #index}) is reset. + * + * @param mapSquare the selected map square + * + * @return <code>true</code> if the state has changed + */ + public boolean setMapSquare(@Nullable MapSquare<G> mapSquare) { + if (this.mapSquare == mapSquare) { + return false; + } + + this.mapSquare = mapSquare; + gameObject = null; + index = 0; + return true; + } + + /** + * Validate that the selected map square is still valid. + * + * @return <code>true</code> if the state has changed + */ + public boolean validateMapSquare() { + if (mapSquare == null) { + return false; + } + + if (mapControl.isPointValid(new Point(mapSquare.getMapX(), mapSquare.getMapY()))) { + return false; + } + + return setMapSquare(null); + } + + /** + * Check if the currently selected map square is affected by a change in a + * given map square. + * + * @param changedMapSquare the map square that has changed + * + * @return <code>true</code> if the state was updated + */ + public boolean checkForChangedMapSquare(@NotNull final MapSquare<G> changedMapSquare) { + return mapSquare != null && mapSquare == changedMapSquare; + } + + /** + * Reset the state. + */ + private void reset() { + mapSquare = null; + gameObject = null; + index = 0; + } + + /** + * Return the associated map control. + * + * @return the associated map control. + */ + @NotNull public C getMapControl() { + return mapControl; + } + + /** + * Return the selected map square. + * + * @return the selected map square if any + */ + public @Nullable MapSquare<G> getMapSquare() { + return mapSquare; + } + + /** + * Return the selected game object. + * + * @return the selected game object if any + */ + public @Nullable G getGameObject() { + return gameObject; + } + + /** + * Set the selected game object. + * + * @param gameObject the selected game object, or <code>null</code> to + * unselect it + */ + public void setGameObject(@Nullable final G gameObject) { + this.gameObject = gameObject; + index = 0; + } + + /** + * Return the selected index. + * + * @return the selected index + */ + public int getIndex() { + return index; + } + + /** + * Set the selected index. + * + * @param index the selected index + */ + public void setIndex(final int index) { + this.index = index; + } + +} Property changes on: trunk/src/app/net/sf/gridarta/gui/maptilelist/MapTileSelection.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF Added: trunk/src/app/net/sf/gridarta/gui/maptilelist/MapTileSelectionCache.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/maptilelist/MapTileSelectionCache.java (rev 0) +++ trunk/src/app/net/sf/gridarta/gui/maptilelist/MapTileSelectionCache.java 2006-12-23 21:08:19 UTC (rev 1232) @@ -0,0 +1,70 @@ +/* $Id$ */ + +package net.sf.gridarta.gui.maptilelist; + +import java.util.Map; +import java.util.WeakHashMap; +import net.sf.gridarta.gameobject.GameObject; +import net.sf.gridarta.map.MapControl; +import org.apache.log4j.Logger; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * The class <code>MapTileSelectionCache</code> manages a cache that contains + * one {@link MapTileSelection} instance for each {@link MapControl} instance. + */ +public class MapTileSelectionCache<G extends GameObject<G>, C extends MapControl> { + + /** The Logger for printing log messages. */ + private static final Logger log = Logger.getLogger(MapTileSelectionCache.class.getName()); + + /** + * The cache to map {@link MapControl} instances to {@link + * MapTileSelection} instances. + */ + @NotNull private final Map<C, MapTileSelection<G, C>> cache = new WeakHashMap<C, MapTileSelection<G, C>>(); + + /** + * Return the {@link MapTileSelection} instance associated to a {@link + * MapControl} instance. If no instance exists, a new one is created. + * + * @param mapControl the map control to look up; it may be + * <code>null</code> in which case <code>null</code> is returned + * + * @return the associated map tile selection instance, or <code>null</code> + * if <code>null</code> was passed in + */ + public MapTileSelection<G, C> findOrCreate(@Nullable final C mapControl) { + if (mapControl == null) { + return null; + } + + synchronized(cache) { + final MapTileSelection<G, C> existingMapTileSelection = cache.get(mapControl); + if (existingMapTileSelection != null) { + return existingMapTileSelection; + } + + final MapTileSelection<G, C> newMapTileSelection = new MapTileSelection(mapControl); + cache.put(mapControl, newMapTileSelection); + return newMapTileSelection; + } + } + + /** + * Return the {@link MapTileSelection} instance associated to a {@link + * MapControl} instance. + * + * @param mapControl the map control to look up + * + * @return the associated map tile selection instance, or <code>null</code> + * if no associated instance exists + */ + public MapTileSelection<G, C> find(@NotNull final C mapControl) { + synchronized(cache) { + return cache.get(mapControl); + } + } + +} Property changes on: trunk/src/app/net/sf/gridarta/gui/maptilelist/MapTileSelectionCache.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF Modified: trunk/src/app/net/sf/gridarta/map/MapControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/map/MapControl.java 2006-12-23 20:54:30 UTC (rev 1231) +++ trunk/src/app/net/sf/gridarta/map/MapControl.java 2006-12-23 21:08:19 UTC (rev 1232) @@ -1,6 +1,7 @@ package net.sf.gridarta.map; import java.awt.Point; +import net.sf.gridarta.gameobject.GameObject; import net.sf.gridarta.gui.map.MapCursor; import org.jetbrains.annotations.NotNull; @@ -9,7 +10,7 @@ * @author <a href="mailto:ch...@ri...">Christian Hujer</a> * @author Andreas Kirschbaum */ -public interface MapControl { +public interface MapControl<G extends GameObject<G>, A extends MapArchObject> { /** * Return flag that indicates whether this is a pickmap or not. @@ -21,7 +22,7 @@ * Returns model (= map data of this level). * @return model (= map data of this level) */ - MapModel getMapModel(); + MapModel<G, A> getMapModel(); /** * Check if the coordinate is valid (located within the borders of the This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-12-23 20:54:33
|
Revision: 1231 http://svn.sourceforge.net/gridarta/?rev=1231&view=rev Author: christianhujer Date: 2006-12-23 12:54:30 -0800 (Sat, 23 Dec 2006) Log Message: ----------- Unified CFArchAttrib. Also fixes a bug in cfeditor.CFArchAttrib. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CFArchAttrib.java trunk/daimonin/src/daieditor/CFArchAttrib.java Modified: trunk/crossfire/src/cfeditor/CFArchAttrib.java =================================================================== --- trunk/crossfire/src/cfeditor/CFArchAttrib.java 2006-12-23 20:49:43 UTC (rev 1230) +++ trunk/crossfire/src/cfeditor/CFArchAttrib.java 2006-12-23 20:54:30 UTC (rev 1231) @@ -153,7 +153,7 @@ dataType = ArchAttribType.FLOAT; } else if (atype.equalsIgnoreCase("string")) { dataType = ArchAttribType.STRING; - } else if (atype.equalsIgnoreCase("text")) { + } else if (atype.equalsIgnoreCase("facename")) { dataType = ArchAttribType.FACENAME; } else if (atype.equalsIgnoreCase("animname")) { dataType = ArchAttribType.ANIMNAME; Modified: trunk/daimonin/src/daieditor/CFArchAttrib.java =================================================================== --- trunk/daimonin/src/daieditor/CFArchAttrib.java 2006-12-23 20:49:43 UTC (rev 1230) +++ trunk/daimonin/src/daieditor/CFArchAttrib.java 2006-12-23 20:54:30 UTC (rev 1231) @@ -128,9 +128,9 @@ } // which type of attribute is it? - if ("bool".equalsIgnoreCase(atype)) { + if (atype.equalsIgnoreCase("bool")) { dataType = ArchAttribType.BOOL; // normal bool - } else if ("bool_special".equalsIgnoreCase(atype)) { + } else if (atype.equalsIgnoreCase("bool_special")) { // customized boolean type: dataType = ArchAttribType.BOOL_SPEC; @@ -140,24 +140,24 @@ if (a1 == null || a2 == null) { log.error("In '" + IGUIConstants.TYPEDEF_FILE + "': Type " + typeName + " has bool_special attribute missing 'true' or 'false' value."); return false; - } else { - misc = new String[2]; // 'misc' string contains the values - misc[0] = a1.getValue().trim(); // string for true - misc[1] = a2.getValue().trim(); // string for false } - } else if ("int".equalsIgnoreCase(atype)) { + + misc = new String[2]; // 'misc' string contains the values + misc[0] = a1.getValue().trim(); // string for true + misc[1] = a2.getValue().trim(); // string for false + } else if (atype.equalsIgnoreCase("int")) { dataType = ArchAttribType.INT; - } else if ("long".equalsIgnoreCase(atype)) { + } else if (atype.equalsIgnoreCase("long")) { dataType = ArchAttribType.LONG; - } else if ("float".equalsIgnoreCase(atype)) { + } else if (atype.equalsIgnoreCase("float")) { dataType = ArchAttribType.FLOAT; - } else if ("string".equalsIgnoreCase(atype)) { + } else if (atype.equalsIgnoreCase("string")) { dataType = ArchAttribType.STRING; - } else if ("facename".equalsIgnoreCase(atype)) { + } else if (atype.equalsIgnoreCase("facename")) { dataType = ArchAttribType.FACENAME; - } else if ("animname".equalsIgnoreCase(atype)) { + } else if (atype.equalsIgnoreCase("animname")) { dataType = ArchAttribType.ANIMNAME; - } else if ("text".equalsIgnoreCase(atype)) { + } else if (atype.equalsIgnoreCase("text")) { dataType = ArchAttribType.TEXT; // for text data, the terminating string has to be read too if ((a1 = root.getAttributeNode(XML_KEY_ARCH_BEGIN)) != null) { @@ -222,7 +222,7 @@ log.error(key); } } - } else if (atype.startsWith("doublelist")) { + } else if ("doublelist".startsWith(atype)) { // got a doublelist attribute final String listNames = atype.substring(11).trim(); final int seppos = listNames.indexOf(','); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-12-23 20:49:43
|
Revision: 1230 http://svn.sourceforge.net/gridarta/?rev=1230&view=rev Author: christianhujer Date: 2006-12-23 12:49:43 -0800 (Sat, 23 Dec 2006) Log Message: ----------- Removed unused CDialogBase class. Removed Paths: ------------- trunk/crossfire/src/cfeditor/CDialogBase.java Deleted: trunk/crossfire/src/cfeditor/CDialogBase.java =================================================================== --- trunk/crossfire/src/cfeditor/CDialogBase.java 2006-12-23 20:26:58 UTC (rev 1229) +++ trunk/crossfire/src/cfeditor/CDialogBase.java 2006-12-23 20:49:43 UTC (rev 1230) @@ -1,74 +0,0 @@ -/* - * Crossfire Java Editor. - * Copyright (C) 2000 Michael Toennies - * Copyright (C) 2001 Andreas Vogl - * - * (code based on: Gridder. 2D grid based level editor. (C) 2000 Pasi Keränen) - * - * 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., 59 Temple Place - Suite 330, Boston, MA - * 02111-1307, USA. - * - */ - -package cfeditor; - -import java.awt.Dimension; -import java.awt.Frame; -import java.awt.Rectangle; -import java.awt.Toolkit; -import java.awt.Window; -import javax.swing.JDialog; -import javax.swing.JOptionPane; - -/** - * <code>CDialogBase</code> is the baseclass for dialogs that center - * on to their parent or to the screen if no parent is given. - * @author <a href="mailto:mic...@no...">Michael Toennies</a> - * @author <a href="mailto:Mic...@ha...">Michael Keuchen</a> - * @deprecated This class shouldn't be used any longer, instead, {@link JOptionPane} should be used, as it not only centers, but also handles escape key, default button etc.. - */ -@Deprecated public abstract class CDialogBase extends JDialog { - - private static final long serialVersionUID = 1L; - - /** - * Create a CDialogBase. - * @param parentFrame Frame to center on - * @param title Title for dialog window - */ - protected CDialogBase(final Frame parentFrame, final String title) { - super(parentFrame, title); - } - - /** Centers this dialog when showing. */ - @Override public void setVisible(final boolean visible) { - if (visible) { - final Window owner = getOwner(); - final Rectangle ownerBounds; - if (owner != null) { - ownerBounds = owner.getBounds(); - } else { - ownerBounds = new Rectangle(Toolkit.getDefaultToolkit().getScreenSize()); - } - final Dimension ownSize = getSize(); - final Rectangle ownBounds = new Rectangle(ownSize); - ownBounds.x = ownerBounds.x + (ownerBounds.width - ownSize.width >> 1); - ownBounds.y = ownerBounds.y + (ownerBounds.height - ownSize.height >> 1); - setBounds(ownBounds); - } - super.setVisible(visible); - } - -} // class CDialogBase This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-12-23 20:27:07
|
Revision: 1229 http://svn.sourceforge.net/gridarta/?rev=1229&view=rev Author: christianhujer Date: 2006-12-23 12:26:58 -0800 (Sat, 23 Dec 2006) Log Message: ----------- Documented some Nullability. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/CMapViewBasic.java trunk/crossfire/src/cfeditor/map/MapControl.java trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/CMapViewBasic.java trunk/daimonin/src/daieditor/map/MapArchObject.java trunk/daimonin/src/daieditor/map/MapControl.java trunk/daimonin/src/test/daieditor/gui/map/MapCursorTest.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2006-12-23 19:09:38 UTC (rev 1228) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2006-12-23 20:26:58 UTC (rev 1229) @@ -1537,7 +1537,7 @@ } /** {@inheritDoc} */ - public void removeMainControlListener(final MainControlListener listener) { + public void removeMainControlListener(@NotNull final MainControlListener listener) { listenerList.remove(MainControlListener.class, listener); } Modified: trunk/crossfire/src/cfeditor/CMapViewBasic.java =================================================================== --- trunk/crossfire/src/cfeditor/CMapViewBasic.java 2006-12-23 19:09:38 UTC (rev 1228) +++ trunk/crossfire/src/cfeditor/CMapViewBasic.java 2006-12-23 20:26:58 UTC (rev 1229) @@ -104,9 +104,9 @@ private boolean gridVisible = false; - private MapCursor mapCursor; + @NotNull private final MapCursor mapCursor; - private MapGrid mapGrid; + @NotNull private final MapGrid mapGrid; // interface for the mapview frame private final MapView frame; @@ -186,7 +186,7 @@ * Get MapCursor of this view. * @return MapCursor of this view. */ - public MapCursor getMapCursor() { + @NotNull public MapCursor getMapCursor() { return mapCursor; } Modified: trunk/crossfire/src/cfeditor/map/MapControl.java =================================================================== --- trunk/crossfire/src/cfeditor/map/MapControl.java 2006-12-23 19:09:38 UTC (rev 1228) +++ trunk/crossfire/src/cfeditor/map/MapControl.java 2006-12-23 20:26:58 UTC (rev 1229) @@ -299,12 +299,12 @@ } /** {@inheritDoc} */ - public MapCursor getMapCursor() { + @NotNull public MapCursor getMapCursor() { assert mapViewFrame != null; return mapViewFrame.getBasicView().getMapCursor(); } - public MapGrid getMapGrid() { + @NotNull public MapGrid getMapGrid() { assert mapViewFrame != null; return mapViewFrame.getBasicView().getMapGrid(); } Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2006-12-23 19:09:38 UTC (rev 1228) +++ trunk/daimonin/src/daieditor/CMainControl.java 2006-12-23 20:26:58 UTC (rev 1229) @@ -1723,7 +1723,7 @@ } /** {@inheritDoc} */ - public void removeMainControlListener(final MainControlListener listener) { + public void removeMainControlListener(@NotNull final MainControlListener listener) { listenerList.remove(MainControlListener.class, listener); } Modified: trunk/daimonin/src/daieditor/CMapViewBasic.java =================================================================== --- trunk/daimonin/src/daieditor/CMapViewBasic.java 2006-12-23 19:09:38 UTC (rev 1228) +++ trunk/daimonin/src/daieditor/CMapViewBasic.java 2006-12-23 20:26:58 UTC (rev 1229) @@ -101,9 +101,9 @@ /** The tile palette renderer. */ private final DefaultLevelRenderer renderer; - private MapCursor mapCursor; + @NotNull private final MapCursor mapCursor; - private MapGrid mapGrid; + @NotNull private final MapGrid mapGrid; /** The MapSquares that are known to contain errors. */ private Map<MapSquare<? extends net.sf.gridarta.gameobject.GameObject>, ValidationError> erraneousMapSquares = new HashMap<MapSquare<? extends net.sf.gridarta.gameobject.GameObject>, ValidationError>(); @@ -161,7 +161,7 @@ * Get MapGrid of this view. * @return MapGrid of this view. */ - public MapGrid getMapGrid() { + @NotNull public MapGrid getMapGrid() { return mapGrid; } @@ -169,7 +169,7 @@ * Get MapCursor of this view. * @return MapCursor of this view. */ - public MapCursor getMapCursor() { + @NotNull public MapCursor getMapCursor() { return mapCursor; } Modified: trunk/daimonin/src/daieditor/map/MapArchObject.java =================================================================== --- trunk/daimonin/src/daieditor/map/MapArchObject.java 2006-12-23 19:09:38 UTC (rev 1228) +++ trunk/daimonin/src/daieditor/map/MapArchObject.java 2006-12-23 20:26:58 UTC (rev 1229) @@ -129,7 +129,7 @@ * Get the background music that is attached to the map name. * @return background music or <code>null</code> if no background music */ - public String getBackgroundMusic() { + @Nullable public String getBackgroundMusic() { final int t1 = getMapName().indexOf("§"); final int t2 = getMapName().indexOf("|"); return t1 > 0 && t2 > t1 ? getMapName().substring(t1 + 1, t2) : null; Modified: trunk/daimonin/src/daieditor/map/MapControl.java =================================================================== --- trunk/daimonin/src/daieditor/map/MapControl.java 2006-12-23 19:09:38 UTC (rev 1228) +++ trunk/daimonin/src/daieditor/map/MapControl.java 2006-12-23 20:26:58 UTC (rev 1229) @@ -55,6 +55,7 @@ import net.sf.gridarta.map.MapSquare; import net.sf.japi.swing.ActionFactory; import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.NotNull; /** * The <code>MapControl</code>. @@ -383,12 +384,12 @@ } /** {@inheritDoc} */ - public MapCursor getMapCursor() { + @NotNull public MapCursor getMapCursor() { assert mapViewFrame != null; return mapViewFrame.getBasicView().getMapCursor(); } - public MapGrid getMapGrid() { + @NotNull public MapGrid getMapGrid() { assert mapViewFrame != null; return mapViewFrame.getBasicView().getMapGrid(); } Modified: trunk/daimonin/src/test/daieditor/gui/map/MapCursorTest.java =================================================================== --- trunk/daimonin/src/test/daieditor/gui/map/MapCursorTest.java 2006-12-23 19:09:38 UTC (rev 1228) +++ trunk/daimonin/src/test/daieditor/gui/map/MapCursorTest.java 2006-12-23 20:26:58 UTC (rev 1229) @@ -261,27 +261,18 @@ offset.width = p.x - start.x; offset.height = p.y - start.y; assertEquals("Wrong offset", offset, cursor.getDragOffset()); - checkPreSelection(start, p); + assertPreSelection(start, p); } - private void checkPreSelection(final Point start, final Point end) { - final int minX, maxX, minY, maxY; - if (start.x < end.x) { - minX = start.x; - maxX = end.x; - } else { - minX = end.x; - maxX = start.x; - } - if (start.y < end.y) { - minY = start.y; - maxY = end.y; - } else { - minY = end.y; - maxY = start.y; - } - for (int j = 0; j < gridSize.getHeight(); j++) { - for (int i = 0; i < gridSize.getWidth(); i++) { + private void assertPreSelection(final Point start, final Point end) { + final int minX = Math.min(start.x, end.x); + final int maxX = Math.max(start.x, end.x); + final int minY = Math.min(start.y, end.y); + final int maxY = Math.max(start.y, end.y); + final int height = gridSize.getHeight(); + final int width = gridSize.getWidth(); + for (int j = 0; j < height; j++) { + for (int i = 0; i < width; i++) { if (i < minX || i > maxX || j < minY || j > maxY) { //Not preselected assertFalse("Preselection", (grid.getFlags(i, j) & MapGrid.GRID_FLAG_SELECTING) > 0); @@ -294,22 +285,11 @@ } } - private void checkSelection(final Point start, final Point end, final boolean flag) { - final int minX, maxX, minY, maxY; - if (start.x < end.x) { - minX = start.x; - maxX = end.x; - } else { - minX = end.x; - maxX = start.x; - } - if (start.y < end.y) { - minY = start.y; - maxY = end.y; - } else { - minY = end.y; - maxY = start.y; - } + private void assertSelection(final Point start, final Point end, final boolean flag) { + final int minX = Math.min(start.x, end.x); + final int maxX = Math.max(start.x, end.x); + final int minY = Math.min(start.y, end.y); + final int maxY = Math.max(start.y, end.y); for (int j = minY; j <= maxY; j++) { for (int i = minX; i <= maxX; i++) { assertSame("Selection", flag, (grid.getFlags(i, j) & MapGrid.GRID_FLAG_SELECTION) > 0); @@ -351,12 +331,12 @@ cursor.dragTo(end); testEvents(1, 0); assertTrue("MapCursor should be in drag mode.", cursor.isDragging()); - checkSelection(new Point(0, 0), gridMaxIndex, false); + assertSelection(new Point(0, 0), gridMaxIndex, false); cursor.dragSelect(MapGrid.SelectionMode.ADD); testEvents(0, 1); - checkSelection(start, end, true); + assertSelection(start, end, true); //Check if nothing is preselected - checkPreSelection(new Point(-1, -1), new Point(-1, -1)); + assertPreSelection(new Point(-1, -1), new Point(-1, -1)); cursor.setLocation(start); testEvents(1, 0); cursor.dragStart(); @@ -365,7 +345,7 @@ testEvents(1, 0); cursor.dragSelect(MapGrid.SelectionMode.SUB); testEvents(0, 1); - checkSelection(new Point(0, 0), gridMaxIndex, false); + assertSelection(new Point(0, 0), gridMaxIndex, false); cursor.setLocation(start); testEvents(1, 0); cursor.dragStart(); @@ -374,7 +354,7 @@ testEvents(1, 0); cursor.dragSelect(MapGrid.SelectionMode.FLIP); testEvents(0, 1); - checkSelection(start, end, true); + assertSelection(start, end, true); start.setLocation(3, 4); end.setLocation(5, 1); cursor.setLocation(start); @@ -385,12 +365,12 @@ testEvents(1, 0); cursor.dragSelect(MapGrid.SelectionMode.FLIP); testEvents(0, 1); - checkSelection(start, new Point(4, 4), false); - checkSelection(new Point (3, 2), end, true); - checkSelection(new Point (5, 3), new Point (5, 4), true); + assertSelection(start, new Point(4, 4), false); + assertSelection(new Point (3, 2), end, true); + assertSelection(new Point (5, 3), new Point (5, 4), true); cursor.deactivate(); testEvents(1, 1); - checkSelection(new Point(0, 0), gridMaxIndex, false); + assertSelection(new Point(0, 0), gridMaxIndex, false); } @AfterClass public static void deleteCursor() { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2006-12-23 19:09:38
|
Revision: 1228 http://svn.sourceforge.net/gridarta/?rev=1228&view=rev Author: akirschbaum Date: 2006-12-23 11:09:38 -0800 (Sat, 23 Dec 2006) Log Message: ----------- Return the newly inserted game object from MapModel.insertArchToMap(). Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/map/DefaultMapModel.java trunk/crossfire/src/cfeditor/map/MapControl.java trunk/crossfire/src/cfeditor/map/MapModel.java trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/map/DefaultMapModel.java trunk/daimonin/src/daieditor/map/MapModel.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2006-12-23 15:39:22 UTC (rev 1227) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2006-12-23 19:09:38 UTC (rev 1228) @@ -587,7 +587,7 @@ mainView.showArchPanelQuickObject(gameObject); } - public boolean insertArchToMap(final GameObject newarch, final String archname, final GameObject next, final Point pos, final boolean join) { + @Nullable public GameObject insertArchToMap(final GameObject newarch, final String archname, final GameObject next, final Point pos, final boolean join) { return currentMap.insertArchToMap(newarch, archname, next, pos, join); } Modified: trunk/crossfire/src/cfeditor/map/DefaultMapModel.java =================================================================== --- trunk/crossfire/src/cfeditor/map/DefaultMapModel.java 2006-12-23 15:39:22 UTC (rev 1227) +++ trunk/crossfire/src/cfeditor/map/DefaultMapModel.java 2006-12-23 19:09:38 UTC (rev 1228) @@ -245,12 +245,13 @@ /** * {@inheritDoc} */ - public boolean insertArchToMap(GameObject newObject, String archName, final GameObject next, final Point pos, final boolean join) { + @Nullable public GameObject insertArchToMap(GameObject newObject, String archName, final GameObject next, final Point pos, final boolean join) { // map coords must be valid if (!isPointValid(pos)) { - return false; + return null; } + final GameObject newGameObject; if (next == null || !next.isInContainer()) { // put arch on the map @@ -261,7 +262,7 @@ } // insert a new instance of the default arch (number 'archName') if (!addArchToMap(archName, pos, true, join, false)) { - return false; + return null; } } else { // insert the given 'newObject' (multis not allowed here yet - sorry) @@ -269,11 +270,11 @@ newObject = newObject.createClone(pos.x, pos.y); // create a clone addGameObjectToMap(newObject, false); // insert it to the map } else { - return false; // tried to insert multi (probably from pickmap) + return null; // tried to insert multi (probably from pickmap) } } - final GameObject node = mapGrid[pos.x][pos.y].getLast(); + newGameObject = mapGrid[pos.x][pos.y].getLast(); int position = 0; for (final GameObject search : mapGrid[pos.x][pos.y].reverse()) { if (search == next) { @@ -282,33 +283,32 @@ position++; } for(int i = 0; i < position - 1; i++) { - node.moveDown(); + newGameObject.moveDown(); } } else { // insert the new arch into the inventory of a map arch - final GameObject invnew; // new arch to be inserted if (newObject == null || newObject.isArchetype()) { if (newObject != null && newObject.isArchetype()) { archName = newObject.getArchetypeName(); } // create a new copy of a default arch - invnew = getArchetype(archName).createArch(); + newGameObject = getArchetype(archName).createArch(); } else { // create clone from a pickmap if (!newObject.isMulti()) { - invnew = newObject.createClone(pos.x, pos.y); + newGameObject = newObject.createClone(pos.x, pos.y); } else { - return false; + return null; } } - next.getContainer().addLast(invnew); - mainControl.getArchetypeParser().postParseGameObject(invnew, mapControl.getActiveEditType()); - mainControl.getMainView().setMapTileList(mainControl.getCurrentMap(), invnew); + next.getContainer().addLast(newGameObject); + mainControl.getArchetypeParser().postParseGameObject(newGameObject, mapControl.getActiveEditType()); + mainControl.getMainView().setMapTileList(mainControl.getCurrentMap(), newGameObject); } setLevelChangedFlag(); // the map has been modified - return true; + return newGameObject; } /** {@inheritDoc} */ Modified: trunk/crossfire/src/cfeditor/map/MapControl.java =================================================================== --- trunk/crossfire/src/cfeditor/map/MapControl.java 2006-12-23 15:39:22 UTC (rev 1227) +++ trunk/crossfire/src/cfeditor/map/MapControl.java 2006-12-23 19:09:38 UTC (rev 1228) @@ -202,7 +202,7 @@ return addArchToMap(archname, pos, allowDouble, join, false); } - public boolean insertArchToMap(final GameObject newarch, final String archname, final GameObject next, final Point pos, final boolean join) { + @Nullable public GameObject insertArchToMap(final GameObject newarch, final String archname, final GameObject next, final Point pos, final boolean join) { return mapModel.insertArchToMap(newarch, archname, next, pos, join); } Modified: trunk/crossfire/src/cfeditor/map/MapModel.java =================================================================== --- trunk/crossfire/src/cfeditor/map/MapModel.java 2006-12-23 15:39:22 UTC (rev 1227) +++ trunk/crossfire/src/cfeditor/map/MapModel.java 2006-12-23 19:09:38 UTC (rev 1228) @@ -61,9 +61,9 @@ * -> 'next' must be an arch from the map! (or null) * @param pos map position to insert the new arch * @param join if set to JOIN_ENABLE auto-joining is supported - * @return true if insertion was successful + * @return the inserted game object, or <code>null</code> if an error occurred */ - boolean insertArchToMap(GameObject newObject, String archName, GameObject next, Point pos, boolean join); + @Nullable GameObject insertArchToMap(GameObject newObject, String archName, GameObject next, Point pos, boolean join); /** * Delete an existing arch from the map. (If the specified arch doesn't Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2006-12-23 15:39:22 UTC (rev 1227) +++ trunk/daimonin/src/daieditor/CMainControl.java 2006-12-23 19:09:38 UTC (rev 1228) @@ -783,7 +783,7 @@ mainView.showArchPanelQuickObject(gameObject); } - public boolean insertArchToMap(final GameObject newarch, final String archname, final GameObject next, final Point point) { + @Nullable public GameObject insertArchToMap(final GameObject newarch, final String archname, final GameObject next, final Point point) { return currentMap.getMapModel().insertArchToMap(newarch, archname, next, point); } Modified: trunk/daimonin/src/daieditor/map/DefaultMapModel.java =================================================================== --- trunk/daimonin/src/daieditor/map/DefaultMapModel.java 2006-12-23 15:39:22 UTC (rev 1227) +++ trunk/daimonin/src/daieditor/map/DefaultMapModel.java 2006-12-23 19:09:38 UTC (rev 1228) @@ -172,12 +172,13 @@ * {@inheritDoc} * @xxx I'm too complex */ - public boolean insertArchToMap(GameObject newObject, String archName, final GameObject next, final Point pos) { + @Nullable public GameObject insertArchToMap(GameObject newObject, String archName, final GameObject next, final Point pos) { // map coords must be valid if (!isPointValid(pos)) { - return false; + return null; } + final GameObject newGameObject; if (next == null || !next.isInContainer()) { // put arch on the map @@ -188,7 +189,7 @@ } // insert a new instance of the default arch (number 'archName') if (!addArchToMap(archName, pos, true, false)) { - return false; + return null; } } else { // insert the given 'newObject' (multis not allowed here yet - sorry) @@ -196,11 +197,11 @@ newObject = newObject.createClone(pos.x, pos.y); // create a clone addGameObjectToMap(newObject, false); // insert it to the map } else { - return false; // tried to insert multi (probably from pickmap) + return null; // tried to insert multi (probably from pickmap) } } - final GameObject node = mapGrid[pos.x][pos.y].getLast(); + newGameObject = mapGrid[pos.x][pos.y].getLast(); int position = 0; for (final GameObject search : mapGrid[pos.x][pos.y].reverse()) { // This is okay because next is on the desired square. @@ -211,33 +212,32 @@ position++; } for(int i = 0; i < position - 1; i++) { - node.moveDown(); + newGameObject.moveDown(); } } else { // insert the new arch into the inventory of a map arch - final GameObject invnew; // new arch to be inserted if (newObject == null || newObject.isArchetype()) { if (newObject != null && newObject.isArchetype()) { archName = newObject.getArchetypeName(); } // create a new copy of a default arch - invnew = getArchetype(archName).createArch(); + newGameObject = getArchetype(archName).createArch(); } else { // create clone from a pickmap if (!newObject.isMulti()) { - invnew = newObject.createClone(pos.x, pos.y); + newGameObject = newObject.createClone(pos.x, pos.y); } else { - return false; + return null; } } - next.getContainer().addLast(invnew); - invnew.setObjectFace(); - mainControl.getArchetypeParser().postParseGameObject(invnew, mapControl.getActiveEditType()); - mainControl.getMainView().setMapTileList(mainControl.getCurrentMap(), invnew); + next.getContainer().addLast(newGameObject); + newGameObject.setObjectFace(); + mainControl.getArchetypeParser().postParseGameObject(newGameObject, mapControl.getActiveEditType()); + mainControl.getMainView().setMapTileList(mainControl.getCurrentMap(), newGameObject); } - return true; + return newGameObject; } /** {@inheritDoc} */ Modified: trunk/daimonin/src/daieditor/map/MapModel.java =================================================================== --- trunk/daimonin/src/daieditor/map/MapModel.java 2006-12-23 15:39:22 UTC (rev 1227) +++ trunk/daimonin/src/daieditor/map/MapModel.java 2006-12-23 19:09:38 UTC (rev 1228) @@ -61,9 +61,9 @@ * ('next'==null) the arch gets inserted at bottom * -> 'next' must be an arch from the map! (or null) * @param pos map position to insert the new arch - * @return true if insertion was successful + * @return the inserted game object, or <code>null</code> if an error occurred */ - boolean insertArchToMap(GameObject newObject, String archName, GameObject next, Point pos); + @Nullable GameObject insertArchToMap(GameObject newObject, String archName, GameObject next, Point pos); /** * Get the first exit on the MapSquare described by <var>hspot</var>. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-12-23 15:39:24
|
Revision: 1227 http://svn.sourceforge.net/gridarta/?rev=1227&view=rev Author: christianhujer Date: 2006-12-23 07:39:22 -0800 (Sat, 23 Dec 2006) Log Message: ----------- Fixed javadoc and similar issues. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CArchPanelPan.java trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java trunk/crossfire/src/cfeditor/gui/maptilelist/CellRenderer.java trunk/daimonin/src/daieditor/CArchPanelPan.java trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java trunk/daimonin/src/daieditor/gui/maptilelist/CellRenderer.java trunk/daimonin/src/test/daieditor/gui/map/MapCursorTest.java trunk/daimonin/src/test/daieditor/map/validation/AbstractValidatorTest.java trunk/src/app/net/sf/gridarta/gameobject/ArchetypeParser.java trunk/src/test/net/sf/gridarta/gui/HideFileFilterProxyTest.java Modified: trunk/crossfire/src/cfeditor/CArchPanelPan.java =================================================================== --- trunk/crossfire/src/cfeditor/CArchPanelPan.java 2006-12-23 15:14:35 UTC (rev 1226) +++ trunk/crossfire/src/cfeditor/CArchPanelPan.java 2006-12-23 15:39:22 UTC (rev 1227) @@ -47,6 +47,7 @@ import org.jetbrains.annotations.NotNull; /** + * Panel for Archetypes. * @author unknown * @author Andreas Kirschbaum */ @@ -80,7 +81,7 @@ private final CArchPanel archPanel; /** - * Comparator used to sort entries shown in {@link archList}. + * Comparator used to sort entries shown in {@link #archList}. */ private static final Comparator<GameObject> archComparator = new Comparator<GameObject>() { Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2006-12-23 15:14:35 UTC (rev 1226) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2006-12-23 15:39:22 UTC (rev 1227) @@ -623,7 +623,7 @@ * * @deprecated this has nothing to do with MainControl and should be refactored */ - public void addArchPanelArchetype(@NotNull final String panelName, @NotNull final String folderName, @NotNull final GameObject arch) { + @Deprecated public void addArchPanelArchetype(@NotNull final String panelName, @NotNull final String folderName, @NotNull final GameObject arch) { mainView.addArchPanelArchetype(panelName, folderName, arch); } Modified: trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java 2006-12-23 15:14:35 UTC (rev 1226) +++ trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java 2006-12-23 15:39:22 UTC (rev 1227) @@ -196,9 +196,9 @@ } /** - * This method loads the arches & faces recursively by looping through - * the arch folder, collecting all the trash. + * Loads all archetypes and faces by recursing through the <code>arch/</code> directory tree. * @param f file path where we currently are + * @param folderLevel level of the folder * @param panelName the panel to add archetypes to * @param folderName the folder to add archetypes to */ Modified: trunk/crossfire/src/cfeditor/gui/maptilelist/CellRenderer.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/maptilelist/CellRenderer.java 2006-12-23 15:14:35 UTC (rev 1226) +++ trunk/crossfire/src/cfeditor/gui/maptilelist/CellRenderer.java 2006-12-23 15:39:22 UTC (rev 1227) @@ -34,6 +34,7 @@ /** * CellRenderer for rendering ArchObjects on a certain map tile in a list. + * @author Andreas Kirschbaum */ public final class CellRenderer extends DefaultListCellRenderer { Modified: trunk/daimonin/src/daieditor/CArchPanelPan.java =================================================================== --- trunk/daimonin/src/daieditor/CArchPanelPan.java 2006-12-23 15:14:35 UTC (rev 1226) +++ trunk/daimonin/src/daieditor/CArchPanelPan.java 2006-12-23 15:39:22 UTC (rev 1227) @@ -52,6 +52,7 @@ import org.jetbrains.annotations.NotNull; /** + * Panel for Archetypes. * @author unknown * @author Andreas Kirschbaum */ @@ -92,7 +93,7 @@ private final CArchPanel archPanel; /** - * Comparator used to sort entries shown in {@link archList}. + * Comparator used to sort entries shown in {@link #archList}. */ private static final Comparator<GameObject> archComparator = new Comparator<GameObject>() { Modified: trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java 2006-12-23 15:14:35 UTC (rev 1226) +++ trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java 2006-12-23 15:39:22 UTC (rev 1227) @@ -314,11 +314,12 @@ private File currentFile; /** - * This method loads the arches & faces recursively by looping through - * the arch folder, collecting all the face, arc and png files.. - * @param f file path where we currently are - * @param index counter for arches - * @param noPanel if <var>true</var> no arch panels will be generated + * Loads all archetypes and faces by recursing through the <code>arch/</code> directory tree. + * @param f file path where we currently are + * @param folderLevel level of the folder + * @param panelName the panel to add archetypes to + * @param folderName the folder to add archetypes to + * @param noPanel set this to true if the file should be omitted from the panel. */ private void loadArchFromFiles(final File f, final int folderLevel, @NotNull final String panelName, @NotNull final String folderName, final boolean noPanel) { final String name = f.getName(); @@ -369,7 +370,7 @@ /** * This method loads animations that are separately defined by looping * through all files that were previously collected by {@link - * #loadArchFromFiles(File,int,boolean)}. Do not invoke this method if + * #loadArchFromFiles(File, int, String, String, boolean)}. Do not invoke this method if * loadArchFromFiles() wasn't invoked. */ private void loadAnimsFromFiles() { Modified: trunk/daimonin/src/daieditor/gui/maptilelist/CellRenderer.java =================================================================== --- trunk/daimonin/src/daieditor/gui/maptilelist/CellRenderer.java 2006-12-23 15:14:35 UTC (rev 1226) +++ trunk/daimonin/src/daieditor/gui/maptilelist/CellRenderer.java 2006-12-23 15:39:22 UTC (rev 1227) @@ -33,6 +33,7 @@ /** * CellRenderer for rendering ArchObjects on a certain map tile in a list. + * @author Andreas Kirschbaum */ public final class CellRenderer extends DefaultListCellRenderer { Modified: trunk/daimonin/src/test/daieditor/gui/map/MapCursorTest.java =================================================================== --- trunk/daimonin/src/test/daieditor/gui/map/MapCursorTest.java 2006-12-23 15:14:35 UTC (rev 1226) +++ trunk/daimonin/src/test/daieditor/gui/map/MapCursorTest.java 2006-12-23 15:39:22 UTC (rev 1227) @@ -182,7 +182,7 @@ testEvents(0, 0); } - @Test public void isOnGrid() { + @Test public void testIsOnGrid() { final Point p = new Point(); for (int j = -2; j < gridSize.getHeight() + 2; j++) { for (int i = -2; i < gridSize.getWidth() + 2; i++) { @@ -197,7 +197,7 @@ assertFalse("Null should not be on the grid.", cursor.isOnGrid(null)); } - @Test public void go() { + @Test public void testGoTo() { for (int dir = 0; dir < 8; dir++) { assertFalse("go(" + dir + ") should return false.", cursor.goTo(dir)); testEvents(0, 0); @@ -407,6 +407,8 @@ /** * Test if number of events fired is correct. + * @param nPos number of position events. + * @param nMode number of mode events. */ private void testEvents(final int nPos, final int nMode) { assertEquals("Position change event", nPos, changedPosCounter); Modified: trunk/daimonin/src/test/daieditor/map/validation/AbstractValidatorTest.java =================================================================== --- trunk/daimonin/src/test/daieditor/map/validation/AbstractValidatorTest.java 2006-12-23 15:14:35 UTC (rev 1226) +++ trunk/daimonin/src/test/daieditor/map/validation/AbstractValidatorTest.java 2006-12-23 15:39:22 UTC (rev 1227) @@ -47,7 +47,7 @@ } /** Test case for {@link AbstractValidator#setEnabled(boolean)}. */ - public void testEnabled() throws Exception { + public void testEnabled() { oUT.setEnabled(false); assertFalse(oUT.isEnabled()); oUT.setEnabled(true); Modified: trunk/src/app/net/sf/gridarta/gameobject/ArchetypeParser.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/ArchetypeParser.java 2006-12-23 15:14:35 UTC (rev 1226) +++ trunk/src/app/net/sf/gridarta/gameobject/ArchetypeParser.java 2006-12-23 15:39:22 UTC (rev 1227) @@ -53,7 +53,7 @@ GameObject parseArchetypeFromStream(BufferedReader in, @Nullable G prototype, @Nullable String line, @Nullable String archName, @NotNull String panelName, @NotNull String folderName, String fname) throws IOException; /** - * Short form of {@link #parseArchetypeFromStream(BufferedReader, GameObject, String, String, int, String)}. + * Short form of {@link #parseArchetypeFromStream(BufferedReader, GameObject, String, String, String, String, String)}. * @param in <code>BufferedReader</code> file stream of archetype data * @param panelName the panel name to add the archetype to * @param folderName the folder name to add the archetype to Modified: trunk/src/test/net/sf/gridarta/gui/HideFileFilterProxyTest.java =================================================================== --- trunk/src/test/net/sf/gridarta/gui/HideFileFilterProxyTest.java 2006-12-23 15:14:35 UTC (rev 1226) +++ trunk/src/test/net/sf/gridarta/gui/HideFileFilterProxyTest.java 2006-12-23 15:39:22 UTC (rev 1227) @@ -16,17 +16,17 @@ private HideFileFilterProxy oUT; /** Test case for {@link HideFileFilterProxy#HideFileFilterProxy(AbstractFileFilter)}. */ - @Test public void testHideFileFilterProxy() throws Exception { + @Test public void testHideFileFilterProxy() { fail("Test is not implemented"); // TODO: Test goes here... } /** Test case for {@link HideFileFilterProxy#getDescription()}. */ - @Test public void testGetDescription() throws Exception { + @Test public void testGetDescription() { fail("Test is not implemented"); // TODO: Test goes here... } /** Test case for {@link HideFileFilterProxy#accept(File)}. */ - @Test public void testAccept() throws Exception { + @Test public void testAccept() { fail("Test is not implemented"); // TODO: Test goes here... } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2006-12-23 15:14:36
|
Revision: 1226 http://svn.sourceforge.net/gridarta/?rev=1226&view=rev Author: akirschbaum Date: 2006-12-23 07:14:35 -0800 (Sat, 23 Dec 2006) Log Message: ----------- Add getMapCursor() to common MapControl interface. Modified Paths: -------------- trunk/crossfire/src/cfeditor/map/MapControl.java trunk/daimonin/src/daieditor/map/MapControl.java trunk/src/app/net/sf/gridarta/map/MapControl.java Modified: trunk/crossfire/src/cfeditor/map/MapControl.java =================================================================== --- trunk/crossfire/src/cfeditor/map/MapControl.java 2006-12-23 15:14:13 UTC (rev 1225) +++ trunk/crossfire/src/cfeditor/map/MapControl.java 2006-12-23 15:14:35 UTC (rev 1226) @@ -298,6 +298,7 @@ return mapModel; } + /** {@inheritDoc} */ public MapCursor getMapCursor() { assert mapViewFrame != null; return mapViewFrame.getBasicView().getMapCursor(); Modified: trunk/daimonin/src/daieditor/map/MapControl.java =================================================================== --- trunk/daimonin/src/daieditor/map/MapControl.java 2006-12-23 15:14:13 UTC (rev 1225) +++ trunk/daimonin/src/daieditor/map/MapControl.java 2006-12-23 15:14:35 UTC (rev 1226) @@ -382,6 +382,7 @@ return mapModel; } + /** {@inheritDoc} */ public MapCursor getMapCursor() { assert mapViewFrame != null; return mapViewFrame.getBasicView().getMapCursor(); Modified: trunk/src/app/net/sf/gridarta/map/MapControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/map/MapControl.java 2006-12-23 15:14:13 UTC (rev 1225) +++ trunk/src/app/net/sf/gridarta/map/MapControl.java 2006-12-23 15:14:35 UTC (rev 1226) @@ -1,6 +1,8 @@ package net.sf.gridarta.map; import java.awt.Point; +import net.sf.gridarta.gui.map.MapCursor; +import org.jetbrains.annotations.NotNull; /** * Currently nothing more than a marker interface for unification. @@ -30,4 +32,10 @@ */ boolean isPointValid(final Point pos); + /** + * Return the map cursor of this map. + * @return the map cursor of this map + */ + @NotNull MapCursor getMapCursor(); + } // interface MapControl This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-12-23 15:14:13
|
Revision: 1225 http://svn.sourceforge.net/gridarta/?rev=1225&view=rev Author: christianhujer Date: 2006-12-23 07:14:13 -0800 (Sat, 23 Dec 2006) Log Message: ----------- Added missing @Deprecated annotation. Modified Paths: -------------- trunk/daimonin/src/daieditor/CMainControl.java Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2006-12-23 14:07:07 UTC (rev 1224) +++ trunk/daimonin/src/daieditor/CMainControl.java 2006-12-23 15:14:13 UTC (rev 1225) @@ -811,7 +811,7 @@ * * @deprecated this has nothing to do with MainControl and should be refactored */ - public void addArchPanelArchetype(@NotNull final String panelName, @NotNull final String folderName, @NotNull final GameObject arch) { + @Deprecated public void addArchPanelArchetype(@NotNull final String panelName, @NotNull final String folderName, @NotNull final GameObject arch) { mainView.addArchPanelArchetype(panelName, folderName, arch); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2006-12-23 14:07:07
|
Revision: 1224 http://svn.sourceforge.net/gridarta/?rev=1224&view=rev Author: akirschbaum Date: 2006-12-23 06:07:07 -0800 (Sat, 23 Dec 2006) Log Message: ----------- Add isPointValid() to common MapControl interface. Modified Paths: -------------- trunk/crossfire/src/cfeditor/map/MapControl.java trunk/daimonin/src/daieditor/map/MapControl.java trunk/src/app/net/sf/gridarta/map/MapControl.java Modified: trunk/crossfire/src/cfeditor/map/MapControl.java =================================================================== --- trunk/crossfire/src/cfeditor/map/MapControl.java 2006-12-23 13:36:24 UTC (rev 1223) +++ trunk/crossfire/src/cfeditor/map/MapControl.java 2006-12-23 14:07:07 UTC (rev 1224) @@ -520,12 +520,7 @@ } } - /** - * Check if the coordinates posx, posy are valid (located within the - * borders of the map). - * @param pos coordinate to check - * @return true if this point is located within the map boundaries - */ + /* {@inheritDoc} */ public boolean isPointValid(final Point pos) { return mapModel.isPointValid(pos); } Modified: trunk/daimonin/src/daieditor/map/MapControl.java =================================================================== --- trunk/daimonin/src/daieditor/map/MapControl.java 2006-12-23 13:36:24 UTC (rev 1223) +++ trunk/daimonin/src/daieditor/map/MapControl.java 2006-12-23 14:07:07 UTC (rev 1224) @@ -268,13 +268,7 @@ return mapModel.getMapSize(); } - /** - * Check if the coordinates posx, posy are valid (located within the - * borders of the map). - * @param pos the x-coordinate - * @return <code>true</code> if this point is located within the map - * boundaries - */ + /** {@inheritDoc} */ public boolean isPointValid(final Point pos) { return mapModel.isPointValid(pos); } Modified: trunk/src/app/net/sf/gridarta/map/MapControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/map/MapControl.java 2006-12-23 13:36:24 UTC (rev 1223) +++ trunk/src/app/net/sf/gridarta/map/MapControl.java 2006-12-23 14:07:07 UTC (rev 1224) @@ -1,5 +1,7 @@ package net.sf.gridarta.map; +import java.awt.Point; + /** * Currently nothing more than a marker interface for unification. * @author <a href="mailto:ch...@ri...">Christian Hujer</a> @@ -19,4 +21,13 @@ */ MapModel getMapModel(); + /** + * Check if the coordinate is valid (located within the borders of the + * map). + * @param pos the coordinate to check + * @return <code>true</code> if this point is located within the map + * boundaries + */ + boolean isPointValid(final Point pos); + } // interface MapControl This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2006-12-23 13:36:27
|
Revision: 1223 http://svn.sourceforge.net/gridarta/?rev=1223&view=rev Author: akirschbaum Date: 2006-12-23 05:36:24 -0800 (Sat, 23 Dec 2006) Log Message: ----------- Whitespace changes. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gui/maptilelist/MapTileListView.java Modified: trunk/crossfire/src/cfeditor/gui/maptilelist/MapTileListView.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/maptilelist/MapTileListView.java 2006-12-23 13:09:46 UTC (rev 1222) +++ trunk/crossfire/src/cfeditor/gui/maptilelist/MapTileListView.java 2006-12-23 13:36:24 UTC (rev 1223) @@ -114,18 +114,14 @@ scrollPane2.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); // don't show the border } - final CFancyButton buttonDown = new CFancyButton(null, "Move Tile Position Down", - IGUIConstants.MOVE_DOWN_ICON, - control.getButtonDownActionListener()); + final CFancyButton buttonDown = new CFancyButton(null, "Move Tile Position Down", IGUIConstants.MOVE_DOWN_ICON, control.getButtonDownActionListener()); buttonDown.setVerticalTextPosition(SwingConstants.BOTTOM); buttonDown.setHorizontalTextPosition(SwingConstants.CENTER); if (!mapTileListBottom) { arrows.add(buttonDown, BorderLayout.EAST); } - final CFancyButton buttonUp = new CFancyButton(null, "Move Tile Position Up", - IGUIConstants.MOVE_UP_ICON, - control.getButtonUpActionListener()); + final CFancyButton buttonUp = new CFancyButton(null, "Move Tile Position Up", IGUIConstants.MOVE_UP_ICON, control.getButtonUpActionListener()); buttonUp.setVerticalTextPosition(SwingConstants.BOTTOM); buttonUp.setHorizontalTextPosition(SwingConstants.CENTER); if (!mapTileListBottom) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2006-12-23 13:09:46
|
Revision: 1222 http://svn.sourceforge.net/gridarta/?rev=1222&view=rev Author: akirschbaum Date: 2006-12-23 05:09:46 -0800 (Sat, 23 Dec 2006) Log Message: ----------- Move cell renderer class of MapTileListView into separate java file. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gui/maptilelist/MapTileListView.java trunk/daimonin/src/daieditor/gui/maptilelist/MapTileListView.java Added Paths: ----------- trunk/crossfire/src/cfeditor/gui/maptilelist/CellRenderer.java trunk/daimonin/src/daieditor/gui/maptilelist/CellRenderer.java Added: trunk/crossfire/src/cfeditor/gui/maptilelist/CellRenderer.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/maptilelist/CellRenderer.java (rev 0) +++ trunk/crossfire/src/cfeditor/gui/maptilelist/CellRenderer.java 2006-12-23 13:09:46 UTC (rev 1222) @@ -0,0 +1,110 @@ +/* + * Gridarta Java Editor. + * Copyright (C) 2006 The Gridarta Developers + * + * (code based on: Gridder. 2D grid based level editor. (C) 2000 Pasi Keränen) + * + * 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., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + */ + +package cfeditor.gui.maptilelist; + +import cfeditor.CMainControl; +import cfeditor.gameobject.ArchetypeSet; +import cfeditor.gameobject.GameObject; +import java.awt.Component; +import javax.swing.BorderFactory; +import javax.swing.DefaultListCellRenderer; +import javax.swing.JList; +import net.sf.gridarta.gameobject.GameObjectContainer; +import org.jetbrains.annotations.NotNull; + +/** + * CellRenderer for rendering ArchObjects on a certain map tile in a list. + */ +public final class CellRenderer extends DefaultListCellRenderer { + + /** Serial Version UID. */ + private static final long serialVersionUID = 1L; + + /** The archetype set. */ + @NotNull private final ArchetypeSet archetypeSet; + + public CellRenderer(@NotNull final ArchetypeSet archetypeSet) { + this.archetypeSet = archetypeSet; + } + + /** {@inheritDoc} */ + @Override public Component getListCellRendererComponent(final JList list, final Object value, final int index, final boolean isSelected, final boolean cellHasFocus) { + super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); + + GameObject arch = (GameObject) value; + + // arch == null should not happen, but it *can* happen when the active + // window gets changed by user and java is still blitting here + if (arch != null) { + arch = arch.getHead(); + + if (!arch.hasArchetype()) { + setIcon(CMainControl.getNoarchTileIcon()); + } else if (arch.getFaceFlag()) { + setIcon(CMainControl.getNofaceTileIcon()); + } else if (arch.getFaceNr() == -1) { + setIcon(CMainControl.getUnknownTileIcon()); + } else { + setIcon(archetypeSet.getFace(arch.getFaceNr())); + } + + // In the map-tile-window the object names are displayed + // next to the icons + if (arch.getObjName() != null && arch.getObjName().length() > 0) { + setText(arch.getObjName()); // special name + } else { + final String defname; + if (arch.hasArchetype()) { + defname = arch.getArchetype().getObjName(); + } else { + defname = null; + } + + if (defname != null && defname.length() > 0) { + setText(defname); // default name + } else { + setText(arch.getArchetypeName()); // arch name + } + } + } else { + setIcon(CMainControl.getUnknownTileIcon()); + setText("?"); + } + + int indent = 0; + for (;;) { + final GameObjectContainer<GameObject> env = arch.getContainer(); + if (env == null || !(env instanceof GameObject)) { + break; + } + arch = (GameObject) env; + indent++; + } + if (indent > 1) { + setBorder(BorderFactory.createEmptyBorder(0, (indent - 1) * 16, 0, 0)); // indentation + } + + return this; + } + +} // class CellRenderer Property changes on: trunk/crossfire/src/cfeditor/gui/maptilelist/CellRenderer.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF Modified: trunk/crossfire/src/cfeditor/gui/maptilelist/MapTileListView.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/maptilelist/MapTileListView.java 2006-12-23 12:45:27 UTC (rev 1221) +++ trunk/crossfire/src/cfeditor/gui/maptilelist/MapTileListView.java 2006-12-23 13:09:46 UTC (rev 1222) @@ -32,12 +32,10 @@ import cfeditor.map.MapControl; import java.awt.BorderLayout; import java.awt.Color; -import java.awt.Component; import java.awt.GridLayout; import java.awt.Rectangle; import java.awt.event.MouseEvent; import javax.swing.BorderFactory; -import javax.swing.DefaultListCellRenderer; import javax.swing.DefaultListModel; import javax.swing.JList; import javax.swing.JPanel; @@ -94,7 +92,7 @@ model = new DefaultListModel(); list = new JList(model); - list.setCellRenderer(new MyCellRenderer()); + list.setCellRenderer(new CellRenderer(mainControl.getArchetypeSet())); list.setBackground(Color.lightGray); final JScrollPane scrollPane = new JScrollPane(list); scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); @@ -336,72 +334,4 @@ } } - /** CellRenderer for rendering ArchObjects on a certain map tile in a list. */ - private final class MyCellRenderer extends DefaultListCellRenderer { - - /** Serial Version UID. */ - private static final long serialVersionUID = 1L; - - /** {@inheritDoc} */ - @Override public Component getListCellRendererComponent(final JList list, final Object value, final int index, final boolean isSelected, final boolean cellHasFocus) { - super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); - - GameObject arch = (GameObject) value; - - // arch == null should not happen, but it *can* happen when the active - // window gets changed by user and java is still blitting here - if (arch != null) { - arch = arch.getHead(); - - if (!arch.hasArchetype()) { - setIcon(CMainControl.getNoarchTileIcon()); - } else if (arch.getFaceFlag()) { - setIcon(CMainControl.getNofaceTileIcon()); - } else if (arch.getFaceNr() == -1) { - setIcon(CMainControl.getUnknownTileIcon()); - } else { - setIcon(mainControl.getFace(arch.getFaceNr())); - } - - // In the map-tile-window the object names are displayed - // next to the icons - if (arch.getObjName() != null && arch.getObjName().length() > 0) { - setText(arch.getObjName()); // special name - } else { - final String defname; - if (arch.hasArchetype()) { - defname = arch.getArchetype().getObjName(); - } else { - defname = null; - } - - if (defname != null && defname.length() > 0) { - setText(defname); // default name - } else { - setText(arch.getArchetypeName()); // arch name - } - } - } else { - setIcon(CMainControl.getUnknownTileIcon()); - setText("?"); - } - - int indent = 0; - for (;;) { - final GameObjectContainer<GameObject> env = arch.getContainer(); - if (env == null || !(env instanceof GameObject)) { - break; - } - arch = (GameObject) env; - indent++; - } - if (indent > 1) { - setBorder(BorderFactory.createEmptyBorder(0, (indent - 1) * 16, 0, 0)); // indentation - } - - return this; - } - - } // class MyCellRenderer - } // class MapTileListView Added: trunk/daimonin/src/daieditor/gui/maptilelist/CellRenderer.java =================================================================== --- trunk/daimonin/src/daieditor/gui/maptilelist/CellRenderer.java (rev 0) +++ trunk/daimonin/src/daieditor/gui/maptilelist/CellRenderer.java 2006-12-23 13:09:46 UTC (rev 1222) @@ -0,0 +1,93 @@ +/* + * Gridarta Java Editor. + * Copyright (C) 2006 The Gridarta Developers + * + * (code based on: Gridder. 2D grid based level editor. (C) 2000 Pasi Keränen) + * + * 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., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + */ + +package daieditor.gui.maptilelist; + +import daieditor.CMainControl; +import daieditor.gameobject.ArchetypeSet; +import daieditor.gameobject.GameObject; +import java.awt.Component; +import javax.swing.DefaultListCellRenderer; +import javax.swing.ImageIcon; +import javax.swing.JList; +import org.jetbrains.annotations.NotNull; + +/** + * CellRenderer for rendering ArchObjects on a certain map tile in a list. + */ +public final class CellRenderer extends DefaultListCellRenderer { + + /** Serial Version UID. */ + private static final long serialVersionUID = 1L; + + /** The archetype set. */ + @NotNull private final ArchetypeSet archetypeSet; + + public CellRenderer(@NotNull final ArchetypeSet archetypeSet) { + this.archetypeSet = archetypeSet; + } + + /** {@inheritDoc} */ + @Override public Component getListCellRendererComponent(final JList list, final Object value, final int index, final boolean isSelected, final boolean cellHasFocus) { + super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); + + GameObject arch = (GameObject) value; + + // arch == null should not happen, but it *can* happen when the active + // window gets changed by user and java is still blitting here + if (arch != null) { + arch = arch.getHead(); + + if (!arch.hasArchetype()) { + setIcon(CMainControl.getNoarchTileIcon()); + } else if (arch.hasFaceObject()) { + setIcon(CMainControl.getNofaceTileIcon()); + } else { + final String faceObjName = arch.getFaceObjName(); + final ImageIcon icon = faceObjName != null ? archetypeSet.getFace(faceObjName) : null; + setIcon(icon != null ? icon : CMainControl.getUnknownTileIcon()); + } + + // In the map-tile-window the object names are displayed + // next to the icons + if (arch.getObjName() != null && arch.getObjName().length() > 0) { + setText(arch.getObjName()); // special name + } else { + final String defname; + if (arch.hasArchetype()) { + defname = arch.getArchetype().getObjName(); + } else { + defname = null; + } + + if (defname != null && defname.length() > 0) { + setText(defname); // default name + } else { + setText(arch.getArchetypeName()); // arch name + } + } + } + + return this; + } + +} // class CellRenderer Property changes on: trunk/daimonin/src/daieditor/gui/maptilelist/CellRenderer.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF Modified: trunk/daimonin/src/daieditor/gui/maptilelist/MapTileListView.java =================================================================== --- trunk/daimonin/src/daieditor/gui/maptilelist/MapTileListView.java 2006-12-23 12:45:27 UTC (rev 1221) +++ trunk/daimonin/src/daieditor/gui/maptilelist/MapTileListView.java 2006-12-23 13:09:46 UTC (rev 1222) @@ -33,14 +33,11 @@ import daieditor.map.MapControl; import java.awt.BorderLayout; import java.awt.Color; -import java.awt.Component; import java.awt.GridLayout; import java.awt.Insets; import java.awt.Rectangle; import java.awt.event.MouseEvent; -import javax.swing.DefaultListCellRenderer; import javax.swing.DefaultListModel; -import javax.swing.ImageIcon; import javax.swing.JButton; import javax.swing.JLabel; import javax.swing.JList; @@ -100,7 +97,7 @@ model = new DefaultListModel(); list = new JList(model); - list.setCellRenderer(new MyCellRenderer()); + list.setCellRenderer(new CellRenderer(mainControl.getArchetypeSet())); list.setBackground(Color.lightGray); final JScrollPane scrollPane = new JScrollPane(list); scrollPane.setHorizontalScrollBarPolicy(HORIZONTAL_SCROLLBAR_NEVER); @@ -318,56 +315,4 @@ } } - /** CellRenderer for rendering ArchObjects on a certain map tile in a list. */ - private final class MyCellRenderer extends DefaultListCellRenderer { - - /** Serial Version UID. */ - private static final long serialVersionUID = 1L; - - /** {@inheritDoc} */ - @Override public Component getListCellRendererComponent(final JList list, final Object value, final int index, final boolean isSelected, final boolean cellHasFocus) { - super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); - - GameObject arch = (GameObject) value; - - // arch == null should not happen, but it *can* happen when the active - // window gets changed by user and java is still blitting here - if (arch != null) { - arch = arch.getHead(); - - if (!arch.hasArchetype()) { - setIcon(CMainControl.getNoarchTileIcon()); - } else if (arch.hasFaceObject()) { - setIcon(CMainControl.getNofaceTileIcon()); - } else { - final String faceObjName = arch.getFaceObjName(); - final ImageIcon icon = faceObjName != null ? mainControl.getArchetypeSet().getFace(faceObjName) : null; - setIcon(icon != null ? icon : CMainControl.getUnknownTileIcon()); - } - - // In the map-tile-window the object names are displayed - // next to the icons - if (arch.getObjName() != null && arch.getObjName().length() > 0) { - setText(arch.getObjName()); // special name - } else { - final String defname; - if (arch.hasArchetype()) { - defname = arch.getArchetype().getObjName(); - } else { - defname = null; - } - - if (defname != null && defname.length() > 0) { - setText(defname); // default name - } else { - setText(arch.getArchetypeName()); // arch name - } - } - } - - return this; - } - - } // class MyCellRenderer - } // class MapTileListView This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2006-12-23 12:45:27
|
Revision: 1221 http://svn.sourceforge.net/gridarta/?rev=1221&view=rev Author: akirschbaum Date: 2006-12-23 04:45:27 -0800 (Sat, 23 Dec 2006) Log Message: ----------- Remove unused import statements. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CArchPanelPan.java trunk/crossfire/src/cfeditor/gameobject/ArchetypeParser.java trunk/crossfire/src/cfeditor/gui/maptilelist/MapTileListControl.java trunk/crossfire/src/cfeditor/map/MapControl.java trunk/daimonin/src/daieditor/CArchPanelPan.java trunk/daimonin/src/daieditor/gui/maptilelist/MapTileListControl.java trunk/daimonin/src/daieditor/gui/maptilelist/MapTileListView.java Modified: trunk/crossfire/src/cfeditor/CArchPanelPan.java =================================================================== --- trunk/crossfire/src/cfeditor/CArchPanelPan.java 2006-12-23 12:26:23 UTC (rev 1220) +++ trunk/crossfire/src/cfeditor/CArchPanelPan.java 2006-12-23 12:45:27 UTC (rev 1221) @@ -25,7 +25,6 @@ package cfeditor; -import cfeditor.gameobject.ArchetypeSet; import cfeditor.gameobject.GameObject; import java.awt.BorderLayout; import java.awt.Component; @@ -46,7 +45,6 @@ import javax.swing.event.ListSelectionListener; import org.apache.log4j.Logger; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; /** * @author unknown Modified: trunk/crossfire/src/cfeditor/gameobject/ArchetypeParser.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/ArchetypeParser.java 2006-12-23 12:26:23 UTC (rev 1220) +++ trunk/crossfire/src/cfeditor/gameobject/ArchetypeParser.java 2006-12-23 12:45:27 UTC (rev 1221) @@ -25,17 +25,12 @@ package cfeditor.gameobject; import cfeditor.CMainControl; -import cfeditor.IGUIConstants; import java.io.BufferedReader; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; -import java.util.HashMap; -import java.util.List; -import java.util.Map; import net.sf.gridarta.gameobject.AbstractArchetypeParser; import net.sf.gridarta.gameobject.anim.DuplicateAnimationException; -import net.sf.gridarta.io.IOUtils; import org.apache.log4j.Logger; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; Modified: trunk/crossfire/src/cfeditor/gui/maptilelist/MapTileListControl.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/maptilelist/MapTileListControl.java 2006-12-23 12:26:23 UTC (rev 1220) +++ trunk/crossfire/src/cfeditor/gui/maptilelist/MapTileListControl.java 2006-12-23 12:45:27 UTC (rev 1221) @@ -39,11 +39,8 @@ import java.awt.event.MouseEvent; import java.awt.event.MouseListener; import java.util.Date; -import javax.swing.JList; -import javax.swing.JPanel; import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; -import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; /** Modified: trunk/crossfire/src/cfeditor/map/MapControl.java =================================================================== --- trunk/crossfire/src/cfeditor/map/MapControl.java 2006-12-23 12:26:23 UTC (rev 1220) +++ trunk/crossfire/src/cfeditor/map/MapControl.java 2006-12-23 12:45:27 UTC (rev 1221) @@ -25,7 +25,6 @@ package cfeditor.map; import cfeditor.CMainControl; -import cfeditor.CMapViewBasic; import cfeditor.IGUIConstants; import cfeditor.MapViewIFrame; import cfeditor.gameobject.GameObject; Modified: trunk/daimonin/src/daieditor/CArchPanelPan.java =================================================================== --- trunk/daimonin/src/daieditor/CArchPanelPan.java 2006-12-23 12:26:23 UTC (rev 1220) +++ trunk/daimonin/src/daieditor/CArchPanelPan.java 2006-12-23 12:45:27 UTC (rev 1221) @@ -25,7 +25,6 @@ package daieditor; -import daieditor.gameobject.ArchetypeSet; import daieditor.gameobject.GameObject; import java.awt.BorderLayout; import java.awt.Component; @@ -51,7 +50,6 @@ import net.sf.japi.swing.ActionFactory; import org.apache.log4j.Logger; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; /** * @author unknown Modified: trunk/daimonin/src/daieditor/gui/maptilelist/MapTileListControl.java =================================================================== --- trunk/daimonin/src/daieditor/gui/maptilelist/MapTileListControl.java 2006-12-23 12:26:23 UTC (rev 1220) +++ trunk/daimonin/src/daieditor/gui/maptilelist/MapTileListControl.java 2006-12-23 12:45:27 UTC (rev 1221) @@ -27,11 +27,9 @@ package daieditor.gui.maptilelist; import daieditor.CopyBuffer; -import daieditor.CGUIUtils; import daieditor.CMainControl; import daieditor.CMainView; import daieditor.CPickmapPanel; -import daieditor.IGUIConstants; import daieditor.gameobject.GameObject; import daieditor.map.MapControl; import java.awt.Point; @@ -44,9 +42,7 @@ import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; import net.sf.gridarta.map.MapSquare; -import net.sf.japi.swing.ActionFactory; import net.sf.japi.swing.ActionMethod; -import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; /** Modified: trunk/daimonin/src/daieditor/gui/maptilelist/MapTileListView.java =================================================================== --- trunk/daimonin/src/daieditor/gui/maptilelist/MapTileListView.java 2006-12-23 12:26:23 UTC (rev 1220) +++ trunk/daimonin/src/daieditor/gui/maptilelist/MapTileListView.java 2006-12-23 12:45:27 UTC (rev 1221) @@ -26,10 +26,8 @@ package daieditor.gui.maptilelist; -import daieditor.CopyBuffer; import daieditor.CGUIUtils; import daieditor.CMainControl; -import daieditor.CPickmapPanel; import daieditor.IGUIConstants; import daieditor.gameobject.GameObject; import daieditor.map.MapControl; @@ -39,12 +37,7 @@ import java.awt.GridLayout; import java.awt.Insets; import java.awt.Rectangle; -import static java.awt.event.InputEvent.SHIFT_MASK; import java.awt.event.MouseEvent; -import static java.awt.event.MouseEvent.BUTTON1; -import static java.awt.event.MouseEvent.BUTTON2; -import static java.awt.event.MouseEvent.BUTTON3; -import java.awt.event.MouseListener; import javax.swing.DefaultListCellRenderer; import javax.swing.DefaultListModel; import javax.swing.ImageIcon; @@ -55,13 +48,9 @@ import javax.swing.JScrollPane; import javax.swing.JViewport; import static javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER; -import javax.swing.event.ListSelectionEvent; -import javax.swing.event.ListSelectionListener; import net.sf.gridarta.gui.map.MapCursorEvent; import net.sf.gridarta.gui.map.MapCursorListener; -import net.sf.gridarta.map.MapSquare; import net.sf.japi.swing.ActionFactory; -import net.sf.japi.swing.ActionMethod; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2006-12-23 12:26:23
|
Revision: 1220 http://svn.sourceforge.net/gridarta/?rev=1220&view=rev Author: akirschbaum Date: 2006-12-23 04:26:23 -0800 (Sat, 23 Dec 2006) Log Message: ----------- Split MapTileList into control and view. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainView.java trunk/crossfire/src/cfeditor/CMapViewBasic.java trunk/crossfire/src/cfeditor/gui/maptilelist/MapTileListControl.java trunk/daimonin/src/daieditor/CMainView.java trunk/daimonin/src/daieditor/CMapViewBasic.java trunk/daimonin/src/daieditor/gui/maptilelist/MapTileListControl.java Added Paths: ----------- trunk/crossfire/src/cfeditor/gui/maptilelist/MapTileListView.java trunk/daimonin/src/daieditor/gui/maptilelist/MapTileListView.java Modified: trunk/crossfire/src/cfeditor/CMainView.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainView.java 2006-12-23 09:53:58 UTC (rev 1219) +++ trunk/crossfire/src/cfeditor/CMainView.java 2006-12-23 12:26:23 UTC (rev 1220) @@ -225,7 +225,7 @@ if (!mapTileListBottom) { // the map tile list is on the right side - splitRightPane = new GSplitPane(JSplitPane.HORIZONTAL_SPLIT, mapDesktop, mapTileListControl); + splitRightPane = new GSplitPane(JSplitPane.HORIZONTAL_SPLIT, mapDesktop, mapTileListControl.getMapTileListView()); splitRightPane.setDividerLocation(divLocationRight); splitRightPane.setDividerSize(BORDER_SIZE); @@ -248,7 +248,7 @@ } else { // the map tile list is merged into the bottom panel mapArchPanel = new CMapArchPanel(mainControl, this); - splitRightPane = new GSplitPane(JSplitPane.HORIZONTAL_SPLIT, mapArchPanel, mapTileListControl); + splitRightPane = new GSplitPane(JSplitPane.HORIZONTAL_SPLIT, mapArchPanel, mapTileListControl.getMapTileListView()); splitRightPane.setDividerLocation(divLocationRight); splitRightPane.setDividerSize(BORDER_SIZE); @@ -518,7 +518,7 @@ // set bounds to maximum size if (!mapTileListBottom) { - mapView.setBounds(0, 0, mapTileListControl.getX() - BORDER_SIZE - 2, mapArchPanel.getY() - BORDER_SIZE - 4); + mapView.setBounds(0, 0, mapTileListControl.getMapTileListView().getX() - BORDER_SIZE - 2, mapArchPanel.getY() - BORDER_SIZE - 4); } else { mapView.setBounds(0, 0, mapDesktop.getWidth() - 2, mapDesktop.getHeight() - 2); } Modified: trunk/crossfire/src/cfeditor/CMapViewBasic.java =================================================================== --- trunk/crossfire/src/cfeditor/CMapViewBasic.java 2006-12-23 09:53:58 UTC (rev 1219) +++ trunk/crossfire/src/cfeditor/CMapViewBasic.java 2006-12-23 12:26:23 UTC (rev 1220) @@ -128,7 +128,7 @@ mapCursor = new MapCursor(mapGrid); mapCursor.addMapCursorListener(this); if (!mapControl.isPickmap()) { - mapCursor.addMapCursorListener(mainControl.getMainView().getMapTileListControl()); + mapCursor.addMapCursorListener(mainControl.getMainView().getMapTileListControl().getMapTileListView()); mapCursor.addMapCursorListener(mainControl.getMainView().getStatusBar()); mapCursor.addMapCursorListener(mainControl.getMapCursorControl()); } Modified: trunk/crossfire/src/cfeditor/gui/maptilelist/MapTileListControl.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/maptilelist/MapTileListControl.java 2006-12-23 09:53:58 UTC (rev 1219) +++ trunk/crossfire/src/cfeditor/gui/maptilelist/MapTileListControl.java 2006-12-23 12:26:23 UTC (rev 1220) @@ -25,41 +25,24 @@ package cfeditor.gui.maptilelist; -import cfeditor.CFancyButton; import cfeditor.CMainControl; import cfeditor.CMainView; import cfeditor.IGUIConstants; import cfeditor.gameobject.GameObject; import cfeditor.map.MapControl; import cfeditor.map.MapModel; -import java.awt.BorderLayout; -import java.awt.Color; -import java.awt.Component; -import java.awt.GridLayout; import java.awt.Point; -import java.awt.Rectangle; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.InputEvent; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; import java.util.Date; -import javax.swing.BorderFactory; -import javax.swing.DefaultListCellRenderer; -import javax.swing.DefaultListModel; import javax.swing.JList; import javax.swing.JPanel; -import javax.swing.JScrollPane; -import static javax.swing.JViewport.SIMPLE_SCROLL_MODE; -import javax.swing.ScrollPaneConstants; -import static javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER; -import static javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER; -import javax.swing.SwingConstants; import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; -import net.sf.gridarta.gameobject.GameObjectContainer; -import net.sf.gridarta.gui.map.MapCursorEvent; -import net.sf.gridarta.gui.map.MapCursorListener; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -68,23 +51,13 @@ * @author <a href="mailto:mic...@no...">Michael Toennies</a> * @author <a href="mailto:and...@gm...">Andreas Vogl</a> */ -public final class MapTileListControl extends JPanel implements MapCursorListener { +public final class MapTileListControl { - /** Serial Version UID. */ - private static final long serialVersionUID = 1L; - /** Controller of this subview. */ private final CMainControl mainControl; private final CMainView mainView; - /** The "Import..." button. */ - private final JList list; - - private final DefaultListModel model; - - private int listCounter = 0; - /** * Time of last click in the panel (value in msec by Date.getTime()) * and arch-ID of arch that received last click. @@ -96,6 +69,9 @@ /** The currently selected MapSquare. */ private transient Point currentSquare = null; + /** The view for this controller. */ + private final MapTileListView view; + /** * Create a MapTileListControl. * @param mainControl MainControl, used for icons @@ -104,79 +80,44 @@ public MapTileListControl(final CMainControl mainControl, final CMainView mainView) { this.mainControl = mainControl; this.mainView = mainView; - setLayout(new BorderLayout()); - model = new DefaultListModel(); - list = new JList(model); - list.setCellRenderer(new MyCellRenderer()); - list.setBackground(Color.lightGray); - final JScrollPane scrollPane = new JScrollPane(list); - scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); - scrollPane.getViewport().setScrollMode(SIMPLE_SCROLL_MODE); - add(scrollPane, BorderLayout.CENTER); + view = new MapTileListView(this, mainControl, mainView.isMapTileListBottom()); + } - final JPanel arrows = new JPanel(); - if (mainView.isMapTileListBottom()) { - arrows.setLayout(new GridLayout(2, 1)); - } - final JScrollPane scrollPane2 = new JScrollPane(arrows); - scrollPane2.setVerticalScrollBarPolicy(VERTICAL_SCROLLBAR_NEVER); - scrollPane2.setHorizontalScrollBarPolicy(HORIZONTAL_SCROLLBAR_NEVER); - scrollPane2.getViewport().setScrollMode(SIMPLE_SCROLL_MODE); - if (!mainView.isMapTileListBottom()) { - add(scrollPane2, BorderLayout.SOUTH); // put up/down buttons south - } else { - add(scrollPane2, BorderLayout.WEST); // put up/down buttons west - scrollPane2.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); // don't show the border - } - - final CFancyButton buttonDown = new CFancyButton(null, "Move Tile Position Down", - IGUIConstants.MOVE_DOWN_ICON, - new ActionListener() { - public void actionPerformed(final ActionEvent event) { - final GameObject arch = getMapTileSelection(); - if (arch != null) { - arch.moveDown(); - refresh(); - } + ActionListener getButtonDownActionListener() { + return new ActionListener() { + public void actionPerformed(final ActionEvent event) { + final GameObject arch = getMapTileSelection(); + if (arch != null) { + arch.moveDown(); + refresh(); } - }); - buttonDown.setVerticalTextPosition(SwingConstants.BOTTOM); - buttonDown.setHorizontalTextPosition(SwingConstants.CENTER); - if (!mainView.isMapTileListBottom()) { - arrows.add(buttonDown, BorderLayout.EAST); - } + } + }; + } - final CFancyButton buttonUp = new CFancyButton(null, "Move Tile Position Up", - IGUIConstants.MOVE_UP_ICON, - new ActionListener() { - public void actionPerformed(final ActionEvent event) { - final GameObject arch = getMapTileSelection(); - if (arch != null) { - arch.moveUp(); - refresh(); - } + ActionListener getButtonUpActionListener() { + return new ActionListener() { + public void actionPerformed(final ActionEvent event) { + final GameObject arch = getMapTileSelection(); + if (arch != null) { + arch.moveUp(); + refresh(); } - }); - buttonUp.setVerticalTextPosition(SwingConstants.BOTTOM); - buttonUp.setHorizontalTextPosition(SwingConstants.CENTER); - if (!mainView.isMapTileListBottom()) { - arrows.add(buttonUp, BorderLayout.WEST); - } else { - arrows.add(buttonUp); - arrows.add(buttonDown); - } + } + }; + } - list.addListSelectionListener(new ListSelectionListener() { - public void valueChanged(final ListSelectionEvent e) { - mainView.setMapArchPanelObject(getMapTileSelection()); - } - }); + ListSelectionListener getListSelectionListener() { + return new ListSelectionListener() { + public void valueChanged(final ListSelectionEvent e) { + mainView.setMapArchPanelObject(getMapTileSelection()); + } + }; + } - /** - * listen for mouse events in the panel - */ - list.addMouseListener(new MouseAdapter() { + MouseListener getMouseListener() { + return new MouseAdapter() { @Override public void mousePressed(final MouseEvent e) { if (e.getModifiers() == InputEvent.BUTTON1_MASK && !e.isShiftDown() && !e.isControlDown()) { // --- left mouse button: select arch --- @@ -198,11 +139,11 @@ if (currentSquare != null && mainControl.getArchPanelHighlight() != null) { mainControl.getCurrentMap().getMapModel().beginTransaction("Insert"); // TODO; I18N/L10N - final int listIndex = getListIndex(e); - if (listIndex >= list.getModel().getSize()) { + final int listIndex = view.getListIndex(e); + if (listIndex >= view.getModelSize()) { mainControl.insertArchToMap(mainControl.getArchPanelHighlight(), mainControl.getPanelArchName(), null, currentSquare, MapModel.JOIN_ENABLE); } else { - final GameObject entry = (GameObject) model.getElementAt(listIndex); + final GameObject entry = view.getListGameObject(listIndex); mainControl.insertArchToMap(mainControl.getArchPanelHighlight(), mainControl.getPanelArchName(), entry, currentSquare, MapModel.JOIN_ENABLE); } mainControl.getCurrentMap().getMapModel().endTransaction(); @@ -213,61 +154,31 @@ } } else { // --- middle mouse button: delete arch --- - final int listIndex = getListIndex(e); - if (listIndex < list.getModel().getSize()) { + final int listIndex = view.getListIndex(e); + if (listIndex < view.getModelSize()) { mainControl.getCurrentMap().getMapModel().beginTransaction("Delete"); // TODO; I18N/L10N deleteIndexFromList(listIndex); mainControl.getCurrentMap().getMapModel().endTransaction(); } } } - }); + }; } public void selectArchBelow() { - list.setSelectedIndex(list.getSelectedIndex() + 1); + view.setSelectedIndex(view.getSelectedIndex() + 1); } public void selectArchAbove() { - final int index = list.getSelectedIndex(); - if (index > 0) { - list.setSelectedIndex(index - 1); - } + view.setSelectedIndex(view.getSelectedIndex() - 1); } /** - * Determine the list index for a given mouse event. This function differs - * from <code>list.locationTopIndex(e.getPoint())</code> in that it always - * returns a valid list index, or the list size (i.e., one element past the - * last list index) if the point is after the end of the list. - * - * @param e the mouse event containing the position to check - * - * @return the selected list index - */ - private int getListIndex(final MouseEvent e) { - final int lastIndex = list.getModel().getSize() - 1; - if (lastIndex < 0) { - return 0; - } - - final Rectangle bounds = list.getCellBounds(lastIndex, lastIndex); - final int lowestY = (int) (bounds.getY() + bounds.getHeight()); - if ((int) (e.getPoint().getY()) >= lowestY) { - return lastIndex + 1; - } - - final int listIndex = list.locationToIndex(e.getPoint()); - assert listIndex >= 0; // -1 is returned only if the list is empty, but this was already checked - return listIndex; - } - - /** * Return the currently selected GameObject within this list (currently selected MapSquare). * @return the currently selected GameObject */ @Nullable public GameObject getMapTileSelection() { - return (GameObject) list.getSelectedValue(); + return view.getMapTileSelection(); } /** @@ -279,38 +190,16 @@ return; } // index is -1 for empty lists, so an IndexOutOfBoundsException would be thrown final GameObject temp = getMapTileSelection(); - final GameObject entry = (GameObject) model.getElementAt(index); + final GameObject entry = view.getListGameObject(index); if (entry != null) { mainControl.deleteMapArch(entry, currentSquare, MapModel.JOIN_ENABLE); setMapTileList(mainControl.getCurrentMap(), temp); } } - public int getTileArch(final int oldindex) { - final int index; - if (oldindex == -1) { - index = list.getFirstVisibleIndex(); - } else if (list.getModel().getSize() <= oldindex) { - index = oldindex; - } else { - index = -1; - } - if (index != -1 && list.getModel().getSize() > 0) { - list.setSelectedIndex(index); - } - return list.getSelectedIndex(); - } - public void refresh() { - final GameObject gameObject; - final GameObject sel = getMapTileSelection(); - if (sel != null) { - gameObject = getMapTileSelection(); - } else { - gameObject = null; - } - mainView.setMapTileList(mainControl.getCurrentMap(), gameObject); - repaint(); + setMapTileList(mainControl.getCurrentMap(), getMapTileSelection()); + view.repaint(); } /** @@ -319,166 +208,37 @@ * @param gameObject selected GameObject */ public void setMapTileList(final MapControl mapControl, final GameObject gameObject) { - list.setEnabled(false); - model.removeAllElements(); - if (mapControl == null) { - // mouse has been clicked outside the mapview - currentSquare = null; - getTileArch(-1); - list.setEnabled(true); - mainView.refreshMapArchPanel(); - return; - } + view.setMapTileList(mapControl, gameObject); - listCounter = 0; - currentSquare = mapControl.getMapCursor().getLocation(); - int postSelect = -1; - boolean foundSIndex = false; - int sIndex = 0; - - // Now go through the list backwards and put all arches - // on the panel in this order - if (currentSquare != null) { - for (final GameObject node : mapControl.getMapModel().getMapSquare(currentSquare).reverse()) { - // add the node - if (node == gameObject) { - postSelect = listCounter; - } - listCounter++; - model.addElement(node); - - // if view-settings are applied, mark topmost "visible" tile for selection - if (mainControl.isTileEditSet() && !foundSIndex && mainControl.isTileEdit(node.getEditType())) { - sIndex = listCounter - 1; // select this tile - foundSIndex = true; // this is it - don't select any other tile - } - - final int tmpSelect = addInvObjects(node.getHead(), gameObject); - if (postSelect == -1 && tmpSelect != -1) { - postSelect = tmpSelect; - } - } - } - - if (postSelect != -1) { - list.setSelectedIndex(postSelect); - } else { - // Per default, the topmost arch matching the view settings is selected. - // (With no view settings applied, the very topmost arch is selected.) - list.setSelectedIndex(sIndex); - } - // refresh the MapArchPanel to display the new arch mainView.refreshMapArchPanel(); - - list.setEnabled(true); } /** - * Add inventory objects to an arch in the MapTileList recursively. - * @param node the arch where the inventory gets added - * @param gameObject selected GameObject - * @return <code>-1</code> if <var>selArch</var> was found, else <var>listCounter</var> of the arch + * Return the view for this controller. + * + * @return the view for this controller */ - private int addInvObjects(final GameObject node, final GameObject gameObject) { - int selListCounter = -1; - for (final GameObject invObject : node.getHead()) { - if (invObject == gameObject) { - selListCounter = listCounter; - } - listCounter++; - model.addElement(invObject); - - final int tmpListCounter = addInvObjects(invObject, gameObject); - if (tmpListCounter != -1) { - selListCounter = tmpListCounter; - } - } - return selListCounter; + public MapTileListView getMapTileListView() { + return view; } - /** {@inheritDoc} */ - public void mapCursorChangedPos(@NotNull final MapCursorEvent e) { - if (e.getSource().isActive()) { - // Position changed - setMapTileList(mainControl.getCurrentMap(), null); - } else { - // Cursor was disabled - setMapTileList(null, null); - } + /** + * Return the currently selected MapSquare. + * + * @return the currently selected MapSquare + */ + @Nullable Point getCurrentSquare() { + return currentSquare; } - /** {@inheritDoc} */ - public void mapCursorChangedMode(@NotNull final MapCursorEvent e) { - // A mode change can be ignored + /** + * Set the currently selected MapSquare. + * + * @param point the selected MapSquare + */ + void setCurrentSquare(@Nullable Point point) { + currentSquare = point; } - /** CellRenderer for rendering ArchObjects on a certain map tile in a list. */ - private final class MyCellRenderer extends DefaultListCellRenderer { - - /** Serial Version UID. */ - private static final long serialVersionUID = 1L; - - /** {@inheritDoc} */ - @Override public Component getListCellRendererComponent(final JList list, final Object value, final int index, final boolean isSelected, final boolean cellHasFocus) { - super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); - - GameObject arch = (GameObject) value; - - // arch == null should not happen, but it *can* happen when the active - // window gets changed by user and java is still blitting here - if (arch != null) { - arch = arch.getHead(); - - if (!arch.hasArchetype()) { - setIcon(CMainControl.getNoarchTileIcon()); - } else if (arch.getFaceFlag()) { - setIcon(CMainControl.getNofaceTileIcon()); - } else if (arch.getFaceNr() == -1) { - setIcon(CMainControl.getUnknownTileIcon()); - } else { - setIcon(mainControl.getFace(arch.getFaceNr())); - } - - // In the map-tile-window the object names are displayed - // next to the icons - if (arch.getObjName() != null && arch.getObjName().length() > 0) { - setText(arch.getObjName()); // special name - } else { - final String defname; - if (arch.hasArchetype()) { - defname = arch.getArchetype().getObjName(); - } else { - defname = null; - } - - if (defname != null && defname.length() > 0) { - setText(defname); // default name - } else { - setText(arch.getArchetypeName()); // arch name - } - } - } else { - setIcon(CMainControl.getUnknownTileIcon()); - setText("?"); - } - - int indent = 0; - for (;;) { - final GameObjectContainer<GameObject> env = arch.getContainer(); - if (env == null || !(env instanceof GameObject)) { - break; - } - arch = (GameObject) env; - indent++; - } - if (indent > 1) { - setBorder(BorderFactory.createEmptyBorder(0, (indent - 1) * 16, 0, 0)); // indentation - } - - return this; - } - - } // class MyCellRenderer - } // class MapTileListControl Copied: trunk/crossfire/src/cfeditor/gui/maptilelist/MapTileListView.java (from rev 1219, trunk/crossfire/src/cfeditor/gui/maptilelist/MapTileListControl.java) =================================================================== --- trunk/crossfire/src/cfeditor/gui/maptilelist/MapTileListView.java (rev 0) +++ trunk/crossfire/src/cfeditor/gui/maptilelist/MapTileListView.java 2006-12-23 12:26:23 UTC (rev 1220) @@ -0,0 +1,407 @@ +/* + * Crossfire Java Editor. + * Copyright (C) 2000 Michael Toennies + * Copyright (C) 2001 Andreas Vogl + * Copyright (C) 2006 The Gridarta Developers + * + * (code based on: Gridder. 2D grid based level editor. (C) 2000 Pasi Keränen) + * + * 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., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + * + */ + +package cfeditor.gui.maptilelist; + +import cfeditor.CFancyButton; +import cfeditor.CMainControl; +import cfeditor.IGUIConstants; +import cfeditor.gameobject.GameObject; +import cfeditor.map.MapControl; +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Component; +import java.awt.GridLayout; +import java.awt.Rectangle; +import java.awt.event.MouseEvent; +import javax.swing.BorderFactory; +import javax.swing.DefaultListCellRenderer; +import javax.swing.DefaultListModel; +import javax.swing.JList; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.ScrollPaneConstants; +import static javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER; +import static javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER; +import javax.swing.SwingConstants; +import static javax.swing.JViewport.SIMPLE_SCROLL_MODE; +import net.sf.gridarta.gameobject.GameObjectContainer; +import net.sf.gridarta.gui.map.MapCursorEvent; +import net.sf.gridarta.gui.map.MapCursorListener; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * The panel that displays the arches of the currently selected map square. + * @author <a href="mailto:mic...@no...">Michael Toennies</a> + * @author <a href="mailto:and...@gm...">Andreas Vogl</a> + */ +public final class MapTileListView extends JPanel implements MapCursorListener { + + /** Serial Version UID. */ + private static final long serialVersionUID = 1L; + + /** The controller for this view. */ + @NotNull final MapTileListControl control; + + /** The main control for this view. */ + @NotNull final CMainControl mainControl; + + /** The "Import..." button. */ + private final JList list; + + private final DefaultListModel model; + + private int listCounter = 0; + + /** + * Create a new instance. + * + * @param control the controller for this view + * + * @param mainControl the main controller for this view + * + * @param mapTileListBottom set if the map tile list should be at the + * bottom or on the top of the main view + */ + MapTileListView(@NotNull final MapTileListControl control, @NotNull final CMainControl mainControl, final boolean mapTileListBottom) { + this.control = control; + this.mainControl = mainControl; + + setLayout(new BorderLayout()); + + model = new DefaultListModel(); + list = new JList(model); + list.setCellRenderer(new MyCellRenderer()); + list.setBackground(Color.lightGray); + final JScrollPane scrollPane = new JScrollPane(list); + scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); + scrollPane.getViewport().setScrollMode(SIMPLE_SCROLL_MODE); + add(scrollPane, BorderLayout.CENTER); + + final JPanel arrows = new JPanel(); + if (mapTileListBottom) { + arrows.setLayout(new GridLayout(2, 1)); + } + final JScrollPane scrollPane2 = new JScrollPane(arrows); + scrollPane2.setVerticalScrollBarPolicy(VERTICAL_SCROLLBAR_NEVER); + scrollPane2.setHorizontalScrollBarPolicy(HORIZONTAL_SCROLLBAR_NEVER); + scrollPane2.getViewport().setScrollMode(SIMPLE_SCROLL_MODE); + if (!mapTileListBottom) { + add(scrollPane2, BorderLayout.SOUTH); // put up/down buttons south + } else { + add(scrollPane2, BorderLayout.WEST); // put up/down buttons west + scrollPane2.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); // don't show the border + } + + final CFancyButton buttonDown = new CFancyButton(null, "Move Tile Position Down", + IGUIConstants.MOVE_DOWN_ICON, + control.getButtonDownActionListener()); + buttonDown.setVerticalTextPosition(SwingConstants.BOTTOM); + buttonDown.setHorizontalTextPosition(SwingConstants.CENTER); + if (!mapTileListBottom) { + arrows.add(buttonDown, BorderLayout.EAST); + } + + final CFancyButton buttonUp = new CFancyButton(null, "Move Tile Position Up", + IGUIConstants.MOVE_UP_ICON, + control.getButtonUpActionListener()); + buttonUp.setVerticalTextPosition(SwingConstants.BOTTOM); + buttonUp.setHorizontalTextPosition(SwingConstants.CENTER); + if (!mapTileListBottom) { + arrows.add(buttonUp, BorderLayout.WEST); + } else { + arrows.add(buttonUp); + arrows.add(buttonDown); + } + + list.addListSelectionListener(control.getListSelectionListener()); + + /** + * listen for mouse events in the panel + */ + list.addMouseListener(control.getMouseListener()); + } + + /** + * Determine the list index for a given mouse event. This function differs + * from <code>list.locationTopIndex(e.getPoint())</code> in that it always + * returns a valid list index, or the list size (i.e., one element past the + * last list index) if the point is after the end of the list. + * + * @param e the mouse event containing the position to check + * + * @return the selected list index + */ + int getListIndex(final MouseEvent e) { + final int lastIndex = getModelSize() - 1; + if (lastIndex < 0) { + return 0; + } + + final Rectangle bounds = list.getCellBounds(lastIndex, lastIndex); + final int lowestY = (int) (bounds.getY() + bounds.getHeight()); + if ((int) (e.getPoint().getY()) >= lowestY) { + return lastIndex + 1; + } + + final int listIndex = list.locationToIndex(e.getPoint()); + assert listIndex >= 0; // -1 is returned only if the list is empty, but this was already checked + return listIndex; + } + + /** + * Return the currently selected GameObject within this list (currently selected MapSquare). + * @return the currently selected GameObject + */ + @Nullable public GameObject getMapTileSelection() { + return (GameObject) list.getSelectedValue(); + } + + private int getTileArch(final int oldindex) { + final int index; + if (oldindex == -1) { + index = list.getFirstVisibleIndex(); + } else if (getModelSize() <= oldindex) { + index = oldindex; + } else { + index = -1; + } + if (index != -1 && getModelSize() > 0) { + list.setSelectedIndex(index); + } + return list.getSelectedIndex(); + } + + /** + * Set the display to the currently selected map tile. + * @param mapControl Map to get display for (includes selection information) + * @param gameObject selected GameObject + */ + void setMapTileList(final MapControl mapControl, final GameObject gameObject) { + list.setEnabled(false); + model.removeAllElements(); + if (mapControl == null) { + // mouse has been clicked outside the mapview + control.setCurrentSquare(null); + getTileArch(-1); + list.setEnabled(true); + return; + } + + listCounter = 0; + control.setCurrentSquare(mapControl.getMapCursor().getLocation()); + int postSelect = -1; + boolean foundSIndex = false; + int sIndex = 0; + + // Now go through the list backwards and put all arches + // on the panel in this order + if (control.getCurrentSquare() != null) { + for (final GameObject node : mapControl.getMapModel().getMapSquare(control.getCurrentSquare()).reverse()) { + // add the node + if (node == gameObject) { + postSelect = listCounter; + } + listCounter++; + model.addElement(node); + + // if view-settings are applied, mark topmost "visible" tile for selection + if (mainControl.isTileEditSet() && !foundSIndex && mainControl.isTileEdit(node.getEditType())) { + sIndex = listCounter - 1; // select this tile + foundSIndex = true; // this is it - don't select any other tile + } + + final int tmpSelect = addInvObjects(node.getHead(), gameObject); + if (postSelect == -1 && tmpSelect != -1) { + postSelect = tmpSelect; + } + } + } + + if (postSelect != -1) { + list.setSelectedIndex(postSelect); + } else { + // Per default, the topmost arch matching the view settings is selected. + // (With no view settings applied, the very topmost arch is selected.) + list.setSelectedIndex(sIndex); + } + + list.setEnabled(true); + } + + /** + * Add inventory objects to an arch in the MapTileListView recursively. + * @param node the arch where the inventory gets added + * @param gameObject selected GameObject + * @return <code>-1</code> if <var>selArch</var> was found, else <var>listCounter</var> of the arch + */ + private int addInvObjects(final GameObject node, final GameObject gameObject) { + int selListCounter = -1; + for (final GameObject invObject : node.getHead()) { + if (invObject == gameObject) { + selListCounter = listCounter; + } + listCounter++; + model.addElement(invObject); + + final int tmpListCounter = addInvObjects(invObject, gameObject); + if (tmpListCounter != -1) { + selListCounter = tmpListCounter; + } + } + return selListCounter; + } + + /** {@inheritDoc} */ + public void mapCursorChangedPos(@NotNull final MapCursorEvent e) { + if (e.getSource().isActive()) { + // Position changed + setMapTileList(mainControl.getCurrentMap(), null); + } else { + // Cursor was disabled + setMapTileList(null, null); + } + } + + /** {@inheritDoc} */ + public void mapCursorChangedMode(@NotNull final MapCursorEvent e) { + // A mode change can be ignored + } + + /** + * Return a game object from the list. + * + * @param index the index in the list + * + * @return the game object, or <code>null</code> if the index is invalid + */ + @Nullable GameObject getListGameObject(final int index) { + return (GameObject) model.getElementAt(index); + } + + /** + * Return the number of currently shown game objects. + * + * @return the number of currently shown game objects + */ + int getModelSize() { + return model.getSize(); + } + + /** + * Return the currently selected list index. + * + * @return the currently selected list index + */ + int getSelectedIndex() { + return list.getSelectedIndex(); + } + + /** + * 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 + */ + void setSelectedIndex(final int index) { + if (index < 0) { + list.setSelectedIndex(0); + } else if (index >= getModelSize()) { + list.setSelectedIndex(Math.max(0, getModelSize() - 1)); + } else { + list.setSelectedIndex(index); + } + } + + /** CellRenderer for rendering ArchObjects on a certain map tile in a list. */ + private final class MyCellRenderer extends DefaultListCellRenderer { + + /** Serial Version UID. */ + private static final long serialVersionUID = 1L; + + /** {@inheritDoc} */ + @Override public Component getListCellRendererComponent(final JList list, final Object value, final int index, final boolean isSelected, final boolean cellHasFocus) { + super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); + + GameObject arch = (GameObject) value; + + // arch == null should not happen, but it *can* happen when the active + // window gets changed by user and java is still blitting here + if (arch != null) { + arch = arch.getHead(); + + if (!arch.hasArchetype()) { + setIcon(CMainControl.getNoarchTileIcon()); + } else if (arch.getFaceFlag()) { + setIcon(CMainControl.getNofaceTileIcon()); + } else if (arch.getFaceNr() == -1) { + setIcon(CMainControl.getUnknownTileIcon()); + } else { + setIcon(mainControl.getFace(arch.getFaceNr())); + } + + // In the map-tile-window the object names are displayed + // next to the icons + if (arch.getObjName() != null && arch.getObjName().length() > 0) { + setText(arch.getObjName()); // special name + } else { + final String defname; + if (arch.hasArchetype()) { + defname = arch.getArchetype().getObjName(); + } else { + defname = null; + } + + if (defname != null && defname.length() > 0) { + setText(defname); // default name + } else { + setText(arch.getArchetypeName()); // arch name + } + } + } else { + setIcon(CMainControl.getUnknownTileIcon()); + setText("?"); + } + + int indent = 0; + for (;;) { + final GameObjectContainer<GameObject> env = arch.getContainer(); + if (env == null || !(env instanceof GameObject)) { + break; + } + arch = (GameObject) env; + indent++; + } + if (indent > 1) { + setBorder(BorderFactory.createEmptyBorder(0, (indent - 1) * 16, 0, 0)); // indentation + } + + return this; + } + + } // class MyCellRenderer + +} // class MapTileListView Modified: trunk/daimonin/src/daieditor/CMainView.java =================================================================== --- trunk/daimonin/src/daieditor/CMainView.java 2006-12-23 09:53:58 UTC (rev 1219) +++ trunk/daimonin/src/daieditor/CMainView.java 2006-12-23 12:26:23 UTC (rev 1220) @@ -225,11 +225,11 @@ mapArchPanel = new CMapArchPanel(mainControl, this); if (mapTileListBottom) { - splitRightPane = new GSplitPane(HORIZONTAL_SPLIT, mapArchPanel, mapTileListControl); + splitRightPane = new GSplitPane(HORIZONTAL_SPLIT, mapArchPanel, mapTileListControl.getMapTileListView()); splitRightPane.setDividerLocation(divLocationRight); splitDownPane = new GSplitPane(VERTICAL_SPLIT, mapDesktop, splitRightPane); } else { - splitRightPane = new GSplitPane(HORIZONTAL_SPLIT, mapDesktop, mapTileListControl); + splitRightPane = new GSplitPane(HORIZONTAL_SPLIT, mapDesktop, mapTileListControl.getMapTileListView()); splitRightPane.setDividerLocation(divLocationRight); splitDownPane = new GSplitPane(VERTICAL_SPLIT, splitRightPane, mapArchPanel); } Modified: trunk/daimonin/src/daieditor/CMapViewBasic.java =================================================================== --- trunk/daimonin/src/daieditor/CMapViewBasic.java 2006-12-23 09:53:58 UTC (rev 1219) +++ trunk/daimonin/src/daieditor/CMapViewBasic.java 2006-12-23 12:26:23 UTC (rev 1220) @@ -124,7 +124,7 @@ mapCursor = new MapCursor(mapGrid); mapCursor.addMapCursorListener(this); if (!mapControl.isPickmap()) { - mapCursor.addMapCursorListener(mainControl.getMainView().getMapTileListControl()); + mapCursor.addMapCursorListener(mainControl.getMainView().getMapTileListControl().getMapTileListView()); mapCursor.addMapCursorListener(mainControl.getMainView().getStatusBar()); mapCursor.addMapCursorListener(mainControl.getMapCursorControl()); } Modified: trunk/daimonin/src/daieditor/gui/maptilelist/MapTileListControl.java =================================================================== --- trunk/daimonin/src/daieditor/gui/maptilelist/MapTileListControl.java 2006-12-23 09:53:58 UTC (rev 1219) +++ trunk/daimonin/src/daieditor/gui/maptilelist/MapTileListControl.java 2006-12-23 12:26:23 UTC (rev 1220) @@ -3,6 +3,7 @@ * Copyright (C) 2000 Michael Toennies * Copyright (C) 2001 Andreas Vogl * Copyright (C) 2005 Christian Hujer + * Copyright (C) 2006 The Gridarta Developers * * (code based on: Gridder. 2D grid based level editor. (C) 2000 Pasi Keränen) * @@ -33,33 +34,15 @@ import daieditor.IGUIConstants; import daieditor.gameobject.GameObject; import daieditor.map.MapControl; -import java.awt.BorderLayout; -import java.awt.Color; -import java.awt.Component; -import java.awt.GridLayout; -import java.awt.Insets; import java.awt.Point; -import java.awt.Rectangle; import static java.awt.event.InputEvent.SHIFT_MASK; import java.awt.event.MouseEvent; import static java.awt.event.MouseEvent.BUTTON1; import static java.awt.event.MouseEvent.BUTTON2; import static java.awt.event.MouseEvent.BUTTON3; import java.awt.event.MouseListener; -import javax.swing.DefaultListCellRenderer; -import javax.swing.DefaultListModel; -import javax.swing.ImageIcon; -import javax.swing.JButton; -import javax.swing.JLabel; -import javax.swing.JList; -import javax.swing.JPanel; -import javax.swing.JScrollPane; -import javax.swing.JViewport; -import static javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER; import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; -import net.sf.gridarta.gui.map.MapCursorEvent; -import net.sf.gridarta.gui.map.MapCursorListener; import net.sf.gridarta.map.MapSquare; import net.sf.japi.swing.ActionFactory; import net.sf.japi.swing.ActionMethod; @@ -73,29 +56,19 @@ * @author <a href="mailto:ch...@ri...">Christian Hujer</a> * @todo turn this into a tree */ -public final class MapTileListControl extends JPanel implements ListSelectionListener, MouseListener, MapCursorListener { +public final class MapTileListControl implements ListSelectionListener, MouseListener { - /** Serial Version UID. */ - private static final long serialVersionUID = 1L; - - /** Action Factory. */ - private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("daieditor"); - /** Controller of this subview. */ private final CMainControl mainControl; private final CMainView mainView; - /** The "Import..." button. */ - private final JList list; - - private final DefaultListModel model; - - private int listCounter = 0; - /** The currently selected MapSquare. */ private transient MapSquare<GameObject> currentSquare; + /** The view for this controller. */ + private final MapTileListView view; + /** * Create a MapTileListControl. * @param mainControl MainControl, used for icons @@ -104,35 +77,8 @@ public MapTileListControl(final CMainControl mainControl, final CMainView mainView) { this.mainControl = mainControl; this.mainView = mainView; - setLayout(new BorderLayout()); - model = new DefaultListModel(); - list = new JList(model); - list.setCellRenderer(new MyCellRenderer()); - list.setBackground(Color.lightGray); - final JScrollPane scrollPane = new JScrollPane(list); - scrollPane.setHorizontalScrollBarPolicy(HORIZONTAL_SCROLLBAR_NEVER); - scrollPane.getViewport().setScrollMode(JViewport.SIMPLE_SCROLL_MODE); - add(scrollPane, BorderLayout.CENTER); - - final JPanel arrows = new JPanel(); - if (mainView.isMapTileListBottom()) { - arrows.setLayout(new GridLayout(4, 1)); - add(arrows, BorderLayout.WEST); // put up/down buttons west - } else { - add(arrows, BorderLayout.SOUTH); // put up/down buttons south - } - for (final String keyPostfix : new String[] { "Top", "Up", "Down", "Bottom" }) { - final JButton button = new JButton(ACTION_FACTORY.createAction(true, "moveTile" + keyPostfix, this)); - arrows.add(button); - button.setMargin(new Insets(0, 0, 0, 0)); - } - final JPanel compass = new JPanel(); - compass.add(new JLabel(CGUIUtils.getSysIcon(IGUIConstants.TILE_NORTH))); - add(compass, BorderLayout.NORTH); - list.addListSelectionListener(this); - list.addMouseListener(this); - list.setFocusable(false); // XXX Workaround for Mantis #0000154 This is not clean and should be removed as soon as cut/copy/paste of arches is possible + view = new MapTileListView(this, mainControl, mainView.isMapTileListBottom()); } /** {@inheritDoc} */ @@ -185,14 +131,11 @@ } public void selectArchBelow() { - list.setSelectedIndex(list.getSelectedIndex() + 1); + view.setSelectedIndex(view.getSelectedIndex() + 1); } public void selectArchAbove() { - final int index = list.getSelectedIndex(); - if (index > 0) { - list.setSelectedIndex(index - 1); - } + view.setSelectedIndex(view.getSelectedIndex() - 1); } /** {@inheritDoc} */ @@ -217,11 +160,11 @@ } } - final int listIndex = getListIndex(e); - if (listIndex >= list.getModel().getSize()) { + final int listIndex = view.getListIndex(e); + if (listIndex >= view.getModelSize()) { mainControl.insertArchToMap(newarch, archname, null, new Point(currentSquare.getMapX(), currentSquare.getMapY())); } else { - final GameObject entry = (GameObject) model.getElementAt(listIndex); + final GameObject entry = view.getListGameObject(listIndex); mainControl.insertArchToMap(newarch, archname, entry, new Point(currentSquare.getMapX(), currentSquare.getMapY())); } @@ -231,8 +174,8 @@ setMapTileList(mainControl.getCurrentMap(), null); } else if (e.getButton() == BUTTON2 || (e.getModifiers() & SHIFT_MASK) == SHIFT_MASK && e.getButton() == BUTTON3) { // MMB // --- middle mouse button: delete arch --- - final int listIndex = getListIndex(e); - if (listIndex < list.getModel().getSize()) { + final int listIndex = view.getListIndex(e); + if (listIndex < view.getModelSize()) { deleteIndexFromList(listIndex); } } @@ -259,38 +202,11 @@ } /** - * Determine the list index for a given mouse event. This function differs - * from <code>list.locationTopIndex(e.getPoint())</code> in that it always - * returns a valid list index, or the list size (i.e., one element past the - * last list index) if the point is after the end of the list. - * - * @param e the mouse event containing the position to check - * - * @return the selected list index - */ - private int getListIndex(final MouseEvent e) { - final int lastIndex = list.getModel().getSize() - 1; - if (lastIndex < 0) { - return 0; - } - - final Rectangle bounds = list.getCellBounds(lastIndex, lastIndex); - final int lowestY = (int) (bounds.getY() + bounds.getHeight()); - if ((int) (e.getPoint().getY()) >= lowestY) { - return lastIndex + 1; - } - - final int listIndex = list.locationToIndex(e.getPoint()); - assert listIndex >= 0; // -1 is returned only if the list is empty, but this was already checked - return listIndex; - } - - /** * Return the currently selected GameObject within this list (currently selected MapSquare). * @return the currently selected GameObject */ @Nullable public GameObject getMapTileSelection() { - return (GameObject) list.getSelectedValue(); + return view.getMapTileSelection(); } /** @@ -302,7 +218,7 @@ return; } // index is -1 for empty lists, so an IndexOutOfBoundsException would be thrown final GameObject temp = getMapTileSelection(); - final GameObject entry = (GameObject) model.getElementAt(index); + final GameObject entry = view.getListGameObject(index); if (entry != null) { entry.remove(); // TODO: refresh map @@ -310,24 +226,9 @@ } } - public int getTileArch(final int oldindex) { - final int index; - if (oldindex == -1) { - index = list.getFirstVisibleIndex(); - } else if (list.getModel().getSize() <= oldindex) { - index = oldindex; - } else { - index = -1; - } - if (index != -1 && list.getModel().getSize() > 0) { - list.setSelectedIndex(index); - } - return list.getSelectedIndex(); - } - public void refresh() { setMapTileList(mainControl.getCurrentMap(), getMapTileSelection()); - repaint(); + view.repaint(); } /** @@ -336,150 +237,37 @@ * @param gameObject selected GameObject */ public void setMapTileList(final MapControl mapControl, final GameObject gameObject) { - list.setEnabled(false); - model.removeAllElements(); - if (mapControl == null) { - // mouse has been clicked outside the mapview - currentSquare = null; - getTileArch(-1); - list.setEnabled(true); - mainView.refreshMapArchPanel(); - return; - } + view.setMapTileList(mapControl, gameObject); - listCounter = 0; - currentSquare = mapControl.getMapModel().getMouseRightPosObject(); - int postSelect = -1; - boolean foundSIndex = false; - int sIndex = 0; - - // Now go through the list backwards and put all arches - // on the panel in this order - if (currentSquare != null) { - for (final GameObject node : currentSquare.reverse()) { - // add the node - if (node == gameObject) { - postSelect = listCounter; - } - listCounter++; - model.addElement(node); - - // if view-settings are applied, mark topmost "visible" tile for selection - if (mainControl.isTileEditSet() && !foundSIndex && mainControl.isTileEdit(node.getEditType())) { - sIndex = listCounter - 1; // select this tile - foundSIndex = true; // this is it - don't select any other tile - } - - final int tmpSelect = addInvObjects(node.getHead(), gameObject); - if (postSelect == -1 && tmpSelect != -1) { - postSelect = tmpSelect; - } - } - } - - if (postSelect != -1) { - list.setSelectedIndex(postSelect); - } else { - // Per default, the topmost arch matching the view settings is selected. - // (With no view settings applied, the very topmost arch is selected.) - list.setSelectedIndex(sIndex); - } - // refresh the MapArchPanel to display the new arch mainView.refreshMapArchPanel(); - - list.setEnabled(true); } /** - * Add inventory objects to an arch in the MapTileListControl recursively. - * @param node the arch where the inventory gets added - * @param gameObject selected GameObject - * @return <code>-1</code> if <var>selArch</var> was found, else <var>listCounter</var> of the arch + * Return the view for this controller. + * + * @return the view for this controller */ - private int addInvObjects(final GameObject node, final GameObject gameObject) { - int selListCounter = -1; - for (final GameObject invObject : node.reverse()) { - if (invObject == gameObject) { - selListCounter = listCounter; - } - listCounter++; - model.addElement(invObject); - - final int tmpListCounter = addInvObjects(invObject, gameObject); - if (tmpListCounter != -1) { - selListCounter = tmpListCounter; - } - } - return selListCounter; + public MapTileListView getMapTileListView() { + return view; } - /** {@inheritDoc} */ - public void mapCursorChangedPos(@NotNull final MapCursorEvent e) { - if (e.getSource().isActive()) { - // Position changed - setMapTileList(mainControl.getCurrentMap(), null); - } else { - // Cursor was disabled - setMapTileList(null, null); - } + /** + * Return the currently selected MapSquare. + * + * @return the currently selected MapSquare + */ + @Nullable MapSquare<GameObject> getCurrentSquare() { + return currentSquare; } - /** {@inheritDoc} */ - public void mapCursorChangedMode(@NotNull final MapCursorEvent e) { - // A mode change can be ignored + /** + * Set the currently selected MapSquare. + * + * @param mapSquare the selected MapSquare + */ + void setCurrentSquare(@Nullable MapSquare<GameObject> mapSquare) { + currentSquare = mapSquare; } - /** CellRenderer for rendering ArchObjects on a certain map tile in a list. */ - private final class MyCellRenderer extends DefaultListCellRenderer { - - /** Serial Version UID. */ - private static final long serialVersionUID = 1L; - - /** {@inheritDoc} */ - @Override public Component getListCellRendererComponent(final JList list, final Object value, final int index, final boolean isSelected, final boolean cellHasFocus) { - super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); - - GameObject arch = (GameObject) value; - - // arch == null should not happen, but it *can* happen when the active - // window gets changed by user and java is still blitting here - if (arch != null) { - arch = arch.getHead(); - - if (!arch.hasArchetype()) { - setIcon(CMainControl.getNoarchTileIcon()); - } else if (arch.hasFaceObject()) { - setIcon(CMainControl.getNofaceTileIcon()); - } else { - final String faceObjName = arch.getFaceObjName(); - final ImageIcon icon = faceObjName != null ? mainControl.getArchetypeSet().getFace(faceObjName) : null; - setIcon(icon != null ? icon : CMainControl.getUnknownTileIcon()); - } - - // In the map-tile-window the object names are displayed - // next to the icons - if (arch.getObjName() != null && arch.getObjName().length() > 0) { - setText(arch.getObjName()); // special name - } else { - final String defname; - if (arch.hasArchetype()) { - defname = arch.getArchetype().getObjName(); - } else { - defname = null; - } - - if (defname != null && defname.length() > 0) { - setText(defname); // default name - } else { - setText(arch.getArchetypeName()); // arch name - } - } - } - - return this; - } - - } // class MyCellRenderer - } // class MapTileListControl Copied: trunk/daimonin/src/daieditor/gui/maptilelist/MapTileListView.java (from rev 1219, trunk/daimonin/src/daieditor/gui/maptilelist/MapTileListControl.java) =================================================================== --- trunk/daimonin/src/daieditor/gui/maptilelist/MapTileListView.java (rev 0) +++ trunk/daimonin/src/daieditor/gui/maptilelist/MapTileListView.java 2006-12-23 12:26:23 UTC (rev 1220) @@ -0,0 +1,384 @@ +/* + * Daimonin Java Editor. + * Copyright (C) 2000 Michael Toennies + * Copyright (C) 2001 Andreas Vogl + * Copyright (C) 2005 Christian Hujer + * Copyright (C) 2006 The Gridarta Developers + * + * (code based on: Gridder. 2D grid based level editor. (C) 2000 Pasi Keränen) + * + * 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., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + * + */ + +package daieditor.gui.maptilelist; + +import daieditor.CopyBuffer; +import daieditor.CGUIUtils; +import daieditor.CMainControl; +import daieditor.CPickmapPanel; +import daieditor.IGUIConstants; +import daieditor.gameobject.GameObject; +import daieditor.map.MapControl; +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Component; +import java.awt.GridLayout; +import java.awt.Insets; +import java.awt.Rectangle; +import static java.awt.event.InputEvent.SHIFT_MASK; +import java.awt.event.MouseEvent; +import static java.awt.event.MouseEvent.BUTTON1; +import static java.awt.event.MouseEvent.BUTTON2; +import static java.awt.event.MouseEvent.BUTTON3; +import java.awt.event.MouseListener; +import javax.swing.DefaultListCellRenderer; +import javax.swing.DefaultListModel; +import javax.swing.ImageIcon; +import javax.swing.JButton; +import javax.swing.JLabel; +import javax.swing.JList; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JViewport; +import static javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER; +import javax.swing.event.ListSelectionEvent; +import javax.swing.event.ListSelectionListener; +import net.sf.gridarta.gui.map.MapCursorEvent; +import net.sf.gridarta.gui.map.MapCursorListener; +import net.sf.gridarta.map.MapSquare; +import net.sf.japi.swing.ActionFactory; +import net.sf.japi.swing.ActionMethod; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * The panel that displays the arches of the currently selected map square. + * @author <a href="mailto:mic...@no...">Michael Toennies</a> + * @author <a href="mailto:and...@gm...">Andreas Vogl</a> + * @author <a href="mailto:ch...@ri...">Christia... [truncated message content] |
From: <aki...@us...> - 2006-12-23 09:53:58
|
Revision: 1219 http://svn.sourceforge.net/gridarta/?rev=1219&view=rev Author: akirschbaum Date: 2006-12-23 01:53:58 -0800 (Sat, 23 Dec 2006) Log Message: ----------- Rename *editor.CMapTileList to *editor.gui.maptilelist.MapTileListControl. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/CMainView.java trunk/crossfire/src/cfeditor/CMapViewBasic.java trunk/crossfire/src/cfeditor/gui/map/MapCursorControl.java trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/CMainView.java trunk/daimonin/src/daieditor/CMapViewBasic.java trunk/daimonin/src/daieditor/gui/map/MapCursorControl.java Added Paths: ----------- trunk/crossfire/src/cfeditor/gui/maptilelist/ trunk/crossfire/src/cfeditor/gui/maptilelist/MapTileListControl.java trunk/daimonin/src/daieditor/gui/maptilelist/ trunk/daimonin/src/daieditor/gui/maptilelist/MapTileListControl.java Removed Paths: ------------- trunk/crossfire/src/cfeditor/CMapTileList.java trunk/daimonin/src/daieditor/CMapTileList.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2006-12-22 22:24:55 UTC (rev 1218) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2006-12-23 09:53:58 UTC (rev 1219) @@ -587,7 +587,7 @@ mainView.showArchPanelQuickObject(gameObject); } - boolean insertArchToMap(final GameObject newarch, final String archname, final GameObject next, final Point pos, final boolean join) { + public boolean insertArchToMap(final GameObject newarch, final String archname, final GameObject next, final Point pos, final boolean join) { return currentMap.insertArchToMap(newarch, archname, next, pos, join); } Modified: trunk/crossfire/src/cfeditor/CMainView.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainView.java 2006-12-22 22:24:55 UTC (rev 1218) +++ trunk/crossfire/src/cfeditor/CMainView.java 2006-12-23 09:53:58 UTC (rev 1219) @@ -25,6 +25,7 @@ package cfeditor; import cfeditor.gameobject.GameObject; +import cfeditor.gui.maptilelist.MapTileListControl; import cfeditor.map.MapControl; import cfeditor.menu.AggregateMenuLocation; import cfeditor.menu.MenuManager; @@ -139,7 +140,7 @@ private final List<MapViewIFrame> mapViews = new ArrayList<MapViewIFrame>(); /** List of objects on map (right side). */ - private CMapTileList mapTileList; + private MapTileListControl mapTileListControl; /** Attributes panel (bottom). */ private CMapArchPanel mapArchPanel; @@ -219,12 +220,12 @@ // Build the placeholder for tile palette archPanel = new CArchPanel(mainControl); - mapTileList = new CMapTileList(mainControl, this); + mapTileListControl = new MapTileListControl(mainControl, this); mapDesktop = new JDesktopPane(); if (!mapTileListBottom) { // the map tile list is on the right side - splitRightPane = new GSplitPane(JSplitPane.HORIZONTAL_SPLIT, mapDesktop, mapTileList); + splitRightPane = new GSplitPane(JSplitPane.HORIZONTAL_SPLIT, mapDesktop, mapTileListControl); splitRightPane.setDividerLocation(divLocationRight); splitRightPane.setDividerSize(BORDER_SIZE); @@ -247,7 +248,7 @@ } else { // the map tile list is merged into the bottom panel mapArchPanel = new CMapArchPanel(mainControl, this); - splitRightPane = new GSplitPane(JSplitPane.HORIZONTAL_SPLIT, mapArchPanel, mapTileList); + splitRightPane = new GSplitPane(JSplitPane.HORIZONTAL_SPLIT, mapArchPanel, mapTileListControl); splitRightPane.setDividerLocation(divLocationRight); splitRightPane.setDividerSize(BORDER_SIZE); @@ -375,15 +376,15 @@ // access mape tile list ... public void setMapTileList(final MapControl map, final GameObject gameObject) { - mapTileList.setMapTileList(map, gameObject); + mapTileListControl.setMapTileList(map, gameObject); } public void refreshMapTileList() { - mapTileList.refresh(); + mapTileListControl.refresh(); } public GameObject getMapTileSelection() { - return mapTileList.getMapTileSelection(); + return mapTileListControl.getMapTileSelection(); } /** @@ -466,7 +467,7 @@ */ void refreshMenusAndToolbars() { archPanel.refresh(); - mapTileList.refresh(); + mapTileListControl.refresh(); mapArchPanel.refresh(); statusBar.refresh(); @@ -474,7 +475,7 @@ } /** Refresh the map arch panel (bottom window). */ - void refreshMapArchPanel() { + public void refreshMapArchPanel() { mapArchPanel.refresh(); } @@ -517,7 +518,7 @@ // set bounds to maximum size if (!mapTileListBottom) { - mapView.setBounds(0, 0, mapTileList.getX() - BORDER_SIZE - 2, mapArchPanel.getY() - BORDER_SIZE - 4); + mapView.setBounds(0, 0, mapTileListControl.getX() - BORDER_SIZE - 2, mapArchPanel.getY() - BORDER_SIZE - 4); } else { mapView.setBounds(0, 0, mapDesktop.getWidth() - 2, mapDesktop.getHeight() - 2); } @@ -941,8 +942,8 @@ MenuManager.getMenuManager().addMenuLocation(currentmapLocation); } - public CMapTileList getMapTileList() { - return mapTileList; + public MapTileListControl getMapTileListControl() { + return mapTileListControl; } private final class LookAndFeelAction extends AbstractAction { Deleted: trunk/crossfire/src/cfeditor/CMapTileList.java =================================================================== --- trunk/crossfire/src/cfeditor/CMapTileList.java 2006-12-22 22:24:55 UTC (rev 1218) +++ trunk/crossfire/src/cfeditor/CMapTileList.java 2006-12-23 09:53:58 UTC (rev 1219) @@ -1,479 +0,0 @@ -/* - * Crossfire Java Editor. - * Copyright (C) 2000 Michael Toennies - * Copyright (C) 2001 Andreas Vogl - * - * (code based on: Gridder. 2D grid based level editor. (C) 2000 Pasi Keränen) - * - * 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., 59 Temple Place - Suite 330, Boston, MA - * 02111-1307, USA. - * - */ - -package cfeditor; - -import cfeditor.gameobject.GameObject; -import cfeditor.map.MapControl; -import cfeditor.map.MapModel; -import java.awt.BorderLayout; -import java.awt.Color; -import java.awt.Component; -import java.awt.GridLayout; -import java.awt.Point; -import java.awt.Rectangle; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.InputEvent; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.util.Date; -import javax.swing.BorderFactory; -import javax.swing.DefaultListCellRenderer; -import javax.swing.DefaultListModel; -import javax.swing.JList; -import javax.swing.JPanel; -import javax.swing.JScrollPane; -import static javax.swing.JViewport.SIMPLE_SCROLL_MODE; -import javax.swing.ScrollPaneConstants; -import static javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER; -import static javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER; -import javax.swing.SwingConstants; -import javax.swing.event.ListSelectionEvent; -import javax.swing.event.ListSelectionListener; -import net.sf.gridarta.gameobject.GameObjectContainer; -import net.sf.gridarta.gui.map.MapCursorEvent; -import net.sf.gridarta.gui.map.MapCursorListener; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -/** - * The panel that displays the arches of the currently selected map square. - * @author <a href="mailto:mic...@no...">Michael Toennies</a> - * @author <a href="mailto:and...@gm...">Andreas Vogl</a> - */ -public final class CMapTileList extends JPanel implements MapCursorListener { - - /** Serial Version UID. */ - private static final long serialVersionUID = 1L; - - /** Controller of this subview. */ - private final CMainControl mainControl; - - private final CMainView mainView; - - /** The "Import..." button. */ - private final JList list; - - private final DefaultListModel model; - - private int listCounter = 0; - - /** - * Time of last click in the panel (value in msec by Date.getTime()) - * and arch-ID of arch that received last click. - */ - private long lastClick = -1; - - private GameObject lastClickGameObject = null; - - /** The currently selected MapSquare. */ - private transient Point currentSquare = null; - - /** - * Create a CMapTileList. - * @param mainControl MainControl, used for icons - * @param mainView MainView, used for updating UI - */ - public CMapTileList(final CMainControl mainControl, final CMainView mainView) { - this.mainControl = mainControl; - this.mainView = mainView; - setLayout(new BorderLayout()); - - model = new DefaultListModel(); - list = new JList(model); - list.setCellRenderer(new MyCellRenderer()); - list.setBackground(Color.lightGray); - final JScrollPane scrollPane = new JScrollPane(list); - scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); - scrollPane.getViewport().setScrollMode(SIMPLE_SCROLL_MODE); - add(scrollPane, BorderLayout.CENTER); - - final JPanel arrows = new JPanel(); - if (mainView.isMapTileListBottom()) { - arrows.setLayout(new GridLayout(2, 1)); - } - final JScrollPane scrollPane2 = new JScrollPane(arrows); - scrollPane2.setVerticalScrollBarPolicy(VERTICAL_SCROLLBAR_NEVER); - scrollPane2.setHorizontalScrollBarPolicy(HORIZONTAL_SCROLLBAR_NEVER); - scrollPane2.getViewport().setScrollMode(SIMPLE_SCROLL_MODE); - if (!mainView.isMapTileListBottom()) { - add(scrollPane2, BorderLayout.SOUTH); // put up/down buttons south - } else { - add(scrollPane2, BorderLayout.WEST); // put up/down buttons west - scrollPane2.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); // don't show the border - } - - final CFancyButton buttonDown = new CFancyButton(null, "Move Tile Position Down", - IGUIConstants.MOVE_DOWN_ICON, - new ActionListener() { - public void actionPerformed(final ActionEvent event) { - final GameObject arch = getMapTileSelection(); - if (arch != null) { - arch.moveDown(); - refresh(); - } - } - }); - buttonDown.setVerticalTextPosition(SwingConstants.BOTTOM); - buttonDown.setHorizontalTextPosition(SwingConstants.CENTER); - if (!mainView.isMapTileListBottom()) { - arrows.add(buttonDown, BorderLayout.EAST); - } - - final CFancyButton buttonUp = new CFancyButton(null, "Move Tile Position Up", - IGUIConstants.MOVE_UP_ICON, - new ActionListener() { - public void actionPerformed(final ActionEvent event) { - final GameObject arch = getMapTileSelection(); - if (arch != null) { - arch.moveUp(); - refresh(); - } - } - }); - buttonUp.setVerticalTextPosition(SwingConstants.BOTTOM); - buttonUp.setHorizontalTextPosition(SwingConstants.CENTER); - if (!mainView.isMapTileListBottom()) { - arrows.add(buttonUp, BorderLayout.WEST); - } else { - arrows.add(buttonUp); - arrows.add(buttonDown); - } - - list.addListSelectionListener(new ListSelectionListener() { - public void valueChanged(final ListSelectionEvent e) { - mainView.setMapArchPanelObject(getMapTileSelection()); - } - }); - - /** - * listen for mouse events in the panel - */ - list.addMouseListener(new MouseAdapter() { - @Override public void mousePressed(final MouseEvent e) { - if (e.getModifiers() == InputEvent.BUTTON1_MASK && !e.isShiftDown() && !e.isControlDown()) { - // --- left mouse button: select arch --- - // first, check if this is a doubleclick - final long thisClick = (new Date()).getTime(); - if (thisClick - lastClick < IGUIConstants.DOUBLECLICK_MS && lastClickGameObject != null && lastClickGameObject == getMapTileSelection()) { - // doubleclick: open attribute window - mainControl.openAttrDialog(getMapTileSelection()); - } else { - // single click: now make this arch selected - mainView.setMapArchPanelObject(getMapTileSelection()); - } - - // save values for next click - lastClick = thisClick; - lastClickGameObject = getMapTileSelection(); - } else if ((e.getModifiers() & InputEvent.BUTTON3_MASK) != 0 || ((e.getModifiers() & InputEvent.BUTTON1_MASK) != 0 && e.isShiftDown())) { - // --- right mouse button: insert arch --- - - if (currentSquare != null && mainControl.getArchPanelHighlight() != null) { - mainControl.getCurrentMap().getMapModel().beginTransaction("Insert"); // TODO; I18N/L10N - final int listIndex = getListIndex(e); - if (listIndex >= list.getModel().getSize()) { - mainControl.insertArchToMap(mainControl.getArchPanelHighlight(), mainControl.getPanelArchName(), null, currentSquare, MapModel.JOIN_ENABLE); - } else { - final GameObject entry = (GameObject) model.getElementAt(listIndex); - mainControl.insertArchToMap(mainControl.getArchPanelHighlight(), mainControl.getPanelArchName(), entry, currentSquare, MapModel.JOIN_ENABLE); - } - mainControl.getCurrentMap().getMapModel().endTransaction(); - - // refresh - mainControl.getCurrentMap().setLevelChangedFlag(); // the map has been modified - mainControl.getMainView().refreshMapTileList(); // update tile window - } - } else { - // --- middle mouse button: delete arch --- - final int listIndex = getListIndex(e); - if (listIndex < list.getModel().getSize()) { - mainControl.getCurrentMap().getMapModel().beginTransaction("Delete"); // TODO; I18N/L10N - deleteIndexFromList(listIndex); - mainControl.getCurrentMap().getMapModel().endTransaction(); - } - } - } - }); - } - - public void selectArchBelow() { - list.setSelectedIndex(list.getSelectedIndex() + 1); - } - - public void selectArchAbove() { - final int index = list.getSelectedIndex(); - if (index > 0) { - list.setSelectedIndex(index - 1); - } - } - - /** - * Determine the list index for a given mouse event. This function differs - * from <code>list.locationTopIndex(e.getPoint())</code> in that it always - * returns a valid list index, or the list size (i.e., one element past the - * last list index) if the point is after the end of the list. - * - * @param e the mouse event containing the position to check - * - * @return the selected list index - */ - private int getListIndex(final MouseEvent e) { - final int lastIndex = list.getModel().getSize() - 1; - if (lastIndex < 0) { - return 0; - } - - final Rectangle bounds = list.getCellBounds(lastIndex, lastIndex); - final int lowestY = (int) (bounds.getY() + bounds.getHeight()); - if ((int) (e.getPoint().getY()) >= lowestY) { - return lastIndex + 1; - } - - final int listIndex = list.locationToIndex(e.getPoint()); - assert listIndex >= 0; // -1 is returned only if the list is empty, but this was already checked - return listIndex; - } - - /** - * Return the currently selected GameObject within this list (currently selected MapSquare). - * @return the currently selected GameObject - */ - @Nullable public GameObject getMapTileSelection() { - return (GameObject) list.getSelectedValue(); - } - - /** - * Delete an GameObject with a specific list index. - * @param index List index of GameObject - */ - private void deleteIndexFromList(final int index) { - if (index < 0) { - return; - } // index is -1 for empty lists, so an IndexOutOfBoundsException would be thrown - final GameObject temp = getMapTileSelection(); - final GameObject entry = (GameObject) model.getElementAt(index); - if (entry != null) { - mainControl.deleteMapArch(entry, currentSquare, MapModel.JOIN_ENABLE); - setMapTileList(mainControl.getCurrentMap(), temp); - } - } - - public int getTileArch(final int oldindex) { - final int index; - if (oldindex == -1) { - index = list.getFirstVisibleIndex(); - } else if (list.getModel().getSize() <= oldindex) { - index = oldindex; - } else { - index = -1; - } - if (index != -1 && list.getModel().getSize() > 0) { - list.setSelectedIndex(index); - } - return list.getSelectedIndex(); - } - - void refresh() { - final GameObject gameObject; - final GameObject sel = getMapTileSelection(); - if (sel != null) { - gameObject = getMapTileSelection(); - } else { - gameObject = null; - } - mainView.setMapTileList(mainControl.getCurrentMap(), gameObject); - repaint(); - } - - /** - * Set the display to the currently selected map tile. - * @param mapControl Map to get display for (includes selection information) - * @param gameObject selected GameObject - */ - public void setMapTileList(final MapControl mapControl, final GameObject gameObject) { - list.setEnabled(false); - model.removeAllElements(); - if (mapControl == null) { - // mouse has been clicked outside the mapview - currentSquare = null; - getTileArch(-1); - list.setEnabled(true); - mainView.refreshMapArchPanel(); - return; - } - - listCounter = 0; - currentSquare = mapControl.getMapCursor().getLocation(); - int postSelect = -1; - boolean foundSIndex = false; - int sIndex = 0; - - // Now go through the list backwards and put all arches - // on the panel in this order - if (currentSquare != null) { - for (final GameObject node : mapControl.getMapModel().getMapSquare(currentSquare).reverse()) { - // add the node - if (node == gameObject) { - postSelect = listCounter; - } - listCounter++; - model.addElement(node); - - // if view-settings are applied, mark topmost "visible" tile for selection - if (mainControl.isTileEditSet() && !foundSIndex && mainControl.isTileEdit(node.getEditType())) { - sIndex = listCounter - 1; // select this tile - foundSIndex = true; // this is it - don't select any other tile - } - - final int tmpSelect = addInvObjects(node.getHead(), gameObject); - if (postSelect == -1 && tmpSelect != -1) { - postSelect = tmpSelect; - } - } - } - - if (postSelect != -1) { - list.setSelectedIndex(postSelect); - } else { - // Per default, the topmost arch matching the view settings is selected. - // (With no view settings applied, the very topmost arch is selected.) - list.setSelectedIndex(sIndex); - } - - // refresh the MapArchPanel to display the new arch - mainView.refreshMapArchPanel(); - - list.setEnabled(true); - } - - /** - * Add inventory objects to an arch in the MapTileList recursively. - * @param node the arch where the inventory gets added - * @param gameObject selected GameObject - * @return <code>-1</code> if <var>selArch</var> was found, else <var>listCounter</var> of the arch - */ - private int addInvObjects(final GameObject node, final GameObject gameObject) { - int selListCounter = -1; - for (final GameObject invObject : node.getHead()) { - if (invObject == gameObject) { - selListCounter = listCounter; - } - listCounter++; - model.addElement(invObject); - - final int tmpListCounter = addInvObjects(invObject, gameObject); - if (tmpListCounter != -1) { - selListCounter = tmpListCounter; - } - } - return selListCounter; - } - - /** {@inheritDoc} */ - public void mapCursorChangedPos(@NotNull final MapCursorEvent e) { - if (e.getSource().isActive()) { - // Position changed - setMapTileList(mainControl.getCurrentMap(), null); - } else { - // Cursor was disabled - setMapTileList(null, null); - } - } - - /** {@inheritDoc} */ - public void mapCursorChangedMode(@NotNull final MapCursorEvent e) { - // A mode change can be ignored - } - - /** CellRenderer for rendering ArchObjects on a certain map tile in a list. */ - private final class MyCellRenderer extends DefaultListCellRenderer { - - /** Serial Version UID. */ - private static final long serialVersionUID = 1L; - - /** {@inheritDoc} */ - @Override public Component getListCellRendererComponent(final JList list, final Object value, final int index, final boolean isSelected, final boolean cellHasFocus) { - super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); - - GameObject arch = (GameObject) value; - - // arch == null should not happen, but it *can* happen when the active - // window gets changed by user and java is still blitting here - if (arch != null) { - arch = arch.getHead(); - - if (!arch.hasArchetype()) { - setIcon(CMainControl.getNoarchTileIcon()); - } else if (arch.getFaceFlag()) { - setIcon(CMainControl.getNofaceTileIcon()); - } else if (arch.getFaceNr() == -1) { - setIcon(CMainControl.getUnknownTileIcon()); - } else { - setIcon(mainControl.getFace(arch.getFaceNr())); - } - - // In the map-tile-window the object names are displayed - // next to the icons - if (arch.getObjName() != null && arch.getObjName().length() > 0) { - setText(arch.getObjName()); // special name - } else { - final String defname; - if (arch.hasArchetype()) { - defname = arch.getArchetype().getObjName(); - } else { - defname = null; - } - - if (defname != null && defname.length() > 0) { - setText(defname); // default name - } else { - setText(arch.getArchetypeName()); // arch name - } - } - } else { - setIcon(CMainControl.getUnknownTileIcon()); - setText("?"); - } - - int indent = 0; - for (;;) { - final GameObjectContainer<GameObject> env = arch.getContainer(); - if (env == null || !(env instanceof GameObject)) { - break; - } - arch = (GameObject) env; - indent++; - } - if (indent > 1) { - setBorder(BorderFactory.createEmptyBorder(0, (indent - 1) * 16, 0, 0)); // indentation - } - - return this; - } - - } // class MyCellRenderer - -} // class CMapTileList Modified: trunk/crossfire/src/cfeditor/CMapViewBasic.java =================================================================== --- trunk/crossfire/src/cfeditor/CMapViewBasic.java 2006-12-22 22:24:55 UTC (rev 1218) +++ trunk/crossfire/src/cfeditor/CMapViewBasic.java 2006-12-23 09:53:58 UTC (rev 1219) @@ -128,7 +128,7 @@ mapCursor = new MapCursor(mapGrid); mapCursor.addMapCursorListener(this); if (!mapControl.isPickmap()) { - mapCursor.addMapCursorListener(mainControl.getMainView().getMapTileList()); + mapCursor.addMapCursorListener(mainControl.getMainView().getMapTileListControl()); mapCursor.addMapCursorListener(mainControl.getMainView().getStatusBar()); mapCursor.addMapCursorListener(mainControl.getMapCursorControl()); } Modified: trunk/crossfire/src/cfeditor/gui/map/MapCursorControl.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/map/MapCursorControl.java 2006-12-22 22:24:55 UTC (rev 1218) +++ trunk/crossfire/src/cfeditor/gui/map/MapCursorControl.java 2006-12-23 09:53:58 UTC (rev 1219) @@ -23,9 +23,9 @@ import cfeditor.CMainControl; import cfeditor.CMainView; -import cfeditor.CMapTileList; import cfeditor.IGUIConstants; import cfeditor.gameobject.GameObject; +import cfeditor.gui.maptilelist.MapTileListControl; import cfeditor.map.MapControl; import java.awt.Point; import javax.swing.Action; @@ -161,9 +161,9 @@ if (mapCursor.isActive()) { final CMainView mainView = mainControl.getMainView(); assert mainView != null; - final CMapTileList mapTileList = mainView.getMapTileList(); - assert mapTileList != null; - final GameObject arch = mapTileList.getMapTileSelection(); + final MapTileListControl mapTileListControl = mainView.getMapTileListControl(); + assert mapTileListControl != null; + final GameObject arch = mapTileListControl.getMapTileSelection(); if (arch != null) { final Point pos = mapCursor.getLocation(); assert pos != null; @@ -216,12 +216,12 @@ if (getMapCursor().isActive()) { final CMainView mainView = mainControl.getMainView(); assert mainView != null; - final CMapTileList mapTileList = mainView.getMapTileList(); - assert mapTileList != null; + final MapTileListControl mapTileListControl = mainView.getMapTileListControl(); + assert mapTileListControl != null; if (above) { - mapTileList.selectArchAbove(); + mapTileListControl.selectArchAbove(); } else { - mapTileList.selectArchBelow(); + mapTileListControl.selectArchBelow(); } } } @@ -230,9 +230,9 @@ if (getMapCursor().isActive()) { final CMainView mainView = mainControl.getMainView(); assert mainView != null; - final CMapTileList mapTileList = mainView.getMapTileList(); - assert mapTileList != null; - final GameObject arch = mapTileList.getMapTileSelection(); + final MapTileListControl mapTileListControl = mainView.getMapTileListControl(); + assert mapTileListControl != null; + final GameObject arch = mapTileListControl.getMapTileSelection(); if (arch != null) { mainControl.openAttrDialog(arch); } Copied: trunk/crossfire/src/cfeditor/gui/maptilelist/MapTileListControl.java (from rev 1218, trunk/crossfire/src/cfeditor/CMapTileList.java) =================================================================== --- trunk/crossfire/src/cfeditor/gui/maptilelist/MapTileListControl.java (rev 0) +++ trunk/crossfire/src/cfeditor/gui/maptilelist/MapTileListControl.java 2006-12-23 09:53:58 UTC (rev 1219) @@ -0,0 +1,484 @@ +/* + * Crossfire Java Editor. + * Copyright (C) 2000 Michael Toennies + * Copyright (C) 2001 Andreas Vogl + * Copyright (C) 2006 The Gridarta Developers + * + * (code based on: Gridder. 2D grid based level editor. (C) 2000 Pasi Keränen) + * + * 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., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + * + */ + +package cfeditor.gui.maptilelist; + +import cfeditor.CFancyButton; +import cfeditor.CMainControl; +import cfeditor.CMainView; +import cfeditor.IGUIConstants; +import cfeditor.gameobject.GameObject; +import cfeditor.map.MapControl; +import cfeditor.map.MapModel; +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Component; +import java.awt.GridLayout; +import java.awt.Point; +import java.awt.Rectangle; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.InputEvent; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.util.Date; +import javax.swing.BorderFactory; +import javax.swing.DefaultListCellRenderer; +import javax.swing.DefaultListModel; +import javax.swing.JList; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import static javax.swing.JViewport.SIMPLE_SCROLL_MODE; +import javax.swing.ScrollPaneConstants; +import static javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER; +import static javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER; +import javax.swing.SwingConstants; +import javax.swing.event.ListSelectionEvent; +import javax.swing.event.ListSelectionListener; +import net.sf.gridarta.gameobject.GameObjectContainer; +import net.sf.gridarta.gui.map.MapCursorEvent; +import net.sf.gridarta.gui.map.MapCursorListener; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * The panel that displays the arches of the currently selected map square. + * @author <a href="mailto:mic...@no...">Michael Toennies</a> + * @author <a href="mailto:and...@gm...">Andreas Vogl</a> + */ +public final class MapTileListControl extends JPanel implements MapCursorListener { + + /** Serial Version UID. */ + private static final long serialVersionUID = 1L; + + /** Controller of this subview. */ + private final CMainControl mainControl; + + private final CMainView mainView; + + /** The "Import..." button. */ + private final JList list; + + private final DefaultListModel model; + + private int listCounter = 0; + + /** + * Time of last click in the panel (value in msec by Date.getTime()) + * and arch-ID of arch that received last click. + */ + private long lastClick = -1; + + private GameObject lastClickGameObject = null; + + /** The currently selected MapSquare. */ + private transient Point currentSquare = null; + + /** + * Create a MapTileListControl. + * @param mainControl MainControl, used for icons + * @param mainView MainView, used for updating UI + */ + public MapTileListControl(final CMainControl mainControl, final CMainView mainView) { + this.mainControl = mainControl; + this.mainView = mainView; + setLayout(new BorderLayout()); + + model = new DefaultListModel(); + list = new JList(model); + list.setCellRenderer(new MyCellRenderer()); + list.setBackground(Color.lightGray); + final JScrollPane scrollPane = new JScrollPane(list); + scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); + scrollPane.getViewport().setScrollMode(SIMPLE_SCROLL_MODE); + add(scrollPane, BorderLayout.CENTER); + + final JPanel arrows = new JPanel(); + if (mainView.isMapTileListBottom()) { + arrows.setLayout(new GridLayout(2, 1)); + } + final JScrollPane scrollPane2 = new JScrollPane(arrows); + scrollPane2.setVerticalScrollBarPolicy(VERTICAL_SCROLLBAR_NEVER); + scrollPane2.setHorizontalScrollBarPolicy(HORIZONTAL_SCROLLBAR_NEVER); + scrollPane2.getViewport().setScrollMode(SIMPLE_SCROLL_MODE); + if (!mainView.isMapTileListBottom()) { + add(scrollPane2, BorderLayout.SOUTH); // put up/down buttons south + } else { + add(scrollPane2, BorderLayout.WEST); // put up/down buttons west + scrollPane2.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); // don't show the border + } + + final CFancyButton buttonDown = new CFancyButton(null, "Move Tile Position Down", + IGUIConstants.MOVE_DOWN_ICON, + new ActionListener() { + public void actionPerformed(final ActionEvent event) { + final GameObject arch = getMapTileSelection(); + if (arch != null) { + arch.moveDown(); + refresh(); + } + } + }); + buttonDown.setVerticalTextPosition(SwingConstants.BOTTOM); + buttonDown.setHorizontalTextPosition(SwingConstants.CENTER); + if (!mainView.isMapTileListBottom()) { + arrows.add(buttonDown, BorderLayout.EAST); + } + + final CFancyButton buttonUp = new CFancyButton(null, "Move Tile Position Up", + IGUIConstants.MOVE_UP_ICON, + new ActionListener() { + public void actionPerformed(final ActionEvent event) { + final GameObject arch = getMapTileSelection(); + if (arch != null) { + arch.moveUp(); + refresh(); + } + } + }); + buttonUp.setVerticalTextPosition(SwingConstants.BOTTOM); + buttonUp.setHorizontalTextPosition(SwingConstants.CENTER); + if (!mainView.isMapTileListBottom()) { + arrows.add(buttonUp, BorderLayout.WEST); + } else { + arrows.add(buttonUp); + arrows.add(buttonDown); + } + + list.addListSelectionListener(new ListSelectionListener() { + public void valueChanged(final ListSelectionEvent e) { + mainView.setMapArchPanelObject(getMapTileSelection()); + } + }); + + /** + * listen for mouse events in the panel + */ + list.addMouseListener(new MouseAdapter() { + @Override public void mousePressed(final MouseEvent e) { + if (e.getModifiers() == InputEvent.BUTTON1_MASK && !e.isShiftDown() && !e.isControlDown()) { + // --- left mouse button: select arch --- + // first, check if this is a doubleclick + final long thisClick = (new Date()).getTime(); + if (thisClick - lastClick < IGUIConstants.DOUBLECLICK_MS && lastClickGameObject != null && lastClickGameObject == getMapTileSelection()) { + // doubleclick: open attribute window + mainControl.openAttrDialog(getMapTileSelection()); + } else { + // single click: now make this arch selected + mainView.setMapArchPanelObject(getMapTileSelection()); + } + + // save values for next click + lastClick = thisClick; + lastClickGameObject = getMapTileSelection(); + } else if ((e.getModifiers() & InputEvent.BUTTON3_MASK) != 0 || ((e.getModifiers() & InputEvent.BUTTON1_MASK) != 0 && e.isShiftDown())) { + // --- right mouse button: insert arch --- + + if (currentSquare != null && mainControl.getArchPanelHighlight() != null) { + mainControl.getCurrentMap().getMapModel().beginTransaction("Insert"); // TODO; I18N/L10N + final int listIndex = getListIndex(e); + if (listIndex >= list.getModel().getSize()) { + mainControl.insertArchToMap(mainControl.getArchPanelHighlight(), mainControl.getPanelArchName(), null, currentSquare, MapModel.JOIN_ENABLE); + } else { + final GameObject entry = (GameObject) model.getElementAt(listIndex); + mainControl.insertArchToMap(mainControl.getArchPanelHighlight(), mainControl.getPanelArchName(), entry, currentSquare, MapModel.JOIN_ENABLE); + } + mainControl.getCurrentMap().getMapModel().endTransaction(); + + // refresh + mainControl.getCurrentMap().setLevelChangedFlag(); // the map has been modified + mainControl.getMainView().refreshMapTileList(); // update tile window + } + } else { + // --- middle mouse button: delete arch --- + final int listIndex = getListIndex(e); + if (listIndex < list.getModel().getSize()) { + mainControl.getCurrentMap().getMapModel().beginTransaction("Delete"); // TODO; I18N/L10N + deleteIndexFromList(listIndex); + mainControl.getCurrentMap().getMapModel().endTransaction(); + } + } + } + }); + } + + public void selectArchBelow() { + list.setSelectedIndex(list.getSelectedIndex() + 1); + } + + public void selectArchAbove() { + final int index = list.getSelectedIndex(); + if (index > 0) { + list.setSelectedIndex(index - 1); + } + } + + /** + * Determine the list index for a given mouse event. This function differs + * from <code>list.locationTopIndex(e.getPoint())</code> in that it always + * returns a valid list index, or the list size (i.e., one element past the + * last list index) if the point is after the end of the list. + * + * @param e the mouse event containing the position to check + * + * @return the selected list index + */ + private int getListIndex(final MouseEvent e) { + final int lastIndex = list.getModel().getSize() - 1; + if (lastIndex < 0) { + return 0; + } + + final Rectangle bounds = list.getCellBounds(lastIndex, lastIndex); + final int lowestY = (int) (bounds.getY() + bounds.getHeight()); + if ((int) (e.getPoint().getY()) >= lowestY) { + return lastIndex + 1; + } + + final int listIndex = list.locationToIndex(e.getPoint()); + assert listIndex >= 0; // -1 is returned only if the list is empty, but this was already checked + return listIndex; + } + + /** + * Return the currently selected GameObject within this list (currently selected MapSquare). + * @return the currently selected GameObject + */ + @Nullable public GameObject getMapTileSelection() { + return (GameObject) list.getSelectedValue(); + } + + /** + * Delete an GameObject with a specific list index. + * @param index List index of GameObject + */ + private void deleteIndexFromList(final int index) { + if (index < 0) { + return; + } // index is -1 for empty lists, so an IndexOutOfBoundsException would be thrown + final GameObject temp = getMapTileSelection(); + final GameObject entry = (GameObject) model.getElementAt(index); + if (entry != null) { + mainControl.deleteMapArch(entry, currentSquare, MapModel.JOIN_ENABLE); + setMapTileList(mainControl.getCurrentMap(), temp); + } + } + + public int getTileArch(final int oldindex) { + final int index; + if (oldindex == -1) { + index = list.getFirstVisibleIndex(); + } else if (list.getModel().getSize() <= oldindex) { + index = oldindex; + } else { + index = -1; + } + if (index != -1 && list.getModel().getSize() > 0) { + list.setSelectedIndex(index); + } + return list.getSelectedIndex(); + } + + public void refresh() { + final GameObject gameObject; + final GameObject sel = getMapTileSelection(); + if (sel != null) { + gameObject = getMapTileSelection(); + } else { + gameObject = null; + } + mainView.setMapTileList(mainControl.getCurrentMap(), gameObject); + repaint(); + } + + /** + * Set the display to the currently selected map tile. + * @param mapControl Map to get display for (includes selection information) + * @param gameObject selected GameObject + */ + public void setMapTileList(final MapControl mapControl, final GameObject gameObject) { + list.setEnabled(false); + model.removeAllElements(); + if (mapControl == null) { + // mouse has been clicked outside the mapview + currentSquare = null; + getTileArch(-1); + list.setEnabled(true); + mainView.refreshMapArchPanel(); + return; + } + + listCounter = 0; + currentSquare = mapControl.getMapCursor().getLocation(); + int postSelect = -1; + boolean foundSIndex = false; + int sIndex = 0; + + // Now go through the list backwards and put all arches + // on the panel in this order + if (currentSquare != null) { + for (final GameObject node : mapControl.getMapModel().getMapSquare(currentSquare).reverse()) { + // add the node + if (node == gameObject) { + postSelect = listCounter; + } + listCounter++; + model.addElement(node); + + // if view-settings are applied, mark topmost "visible" tile for selection + if (mainControl.isTileEditSet() && !foundSIndex && mainControl.isTileEdit(node.getEditType())) { + sIndex = listCounter - 1; // select this tile + foundSIndex = true; // this is it - don't select any other tile + } + + final int tmpSelect = addInvObjects(node.getHead(), gameObject); + if (postSelect == -1 && tmpSelect != -1) { + postSelect = tmpSelect; + } + } + } + + if (postSelect != -1) { + list.setSelectedIndex(postSelect); + } else { + // Per default, the topmost arch matching the view settings is selected. + // (With no view settings applied, the very topmost arch is selected.) + list.setSelectedIndex(sIndex); + } + + // refresh the MapArchPanel to display the new arch + mainView.refreshMapArchPanel(); + + list.setEnabled(true); + } + + /** + * Add inventory objects to an arch in the MapTileList recursively. + * @param node the arch where the inventory gets added + * @param gameObject selected GameObject + * @return <code>-1</code> if <var>selArch</var> was found, else <var>listCounter</var> of the arch + */ + private int addInvObjects(final GameObject node, final GameObject gameObject) { + int selListCounter = -1; + for (final GameObject invObject : node.getHead()) { + if (invObject == gameObject) { + selListCounter = listCounter; + } + listCounter++; + model.addElement(invObject); + + final int tmpListCounter = addInvObjects(invObject, gameObject); + if (tmpListCounter != -1) { + selListCounter = tmpListCounter; + } + } + return selListCounter; + } + + /** {@inheritDoc} */ + public void mapCursorChangedPos(@NotNull final MapCursorEvent e) { + if (e.getSource().isActive()) { + // Position changed + setMapTileList(mainControl.getCurrentMap(), null); + } else { + // Cursor was disabled + setMapTileList(null, null); + } + } + + /** {@inheritDoc} */ + public void mapCursorChangedMode(@NotNull final MapCursorEvent e) { + // A mode change can be ignored + } + + /** CellRenderer for rendering ArchObjects on a certain map tile in a list. */ + private final class MyCellRenderer extends DefaultListCellRenderer { + + /** Serial Version UID. */ + private static final long serialVersionUID = 1L; + + /** {@inheritDoc} */ + @Override public Component getListCellRendererComponent(final JList list, final Object value, final int index, final boolean isSelected, final boolean cellHasFocus) { + super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); + + GameObject arch = (GameObject) value; + + // arch == null should not happen, but it *can* happen when the active + // window gets changed by user and java is still blitting here + if (arch != null) { + arch = arch.getHead(); + + if (!arch.hasArchetype()) { + setIcon(CMainControl.getNoarchTileIcon()); + } else if (arch.getFaceFlag()) { + setIcon(CMainControl.getNofaceTileIcon()); + } else if (arch.getFaceNr() == -1) { + setIcon(CMainControl.getUnknownTileIcon()); + } else { + setIcon(mainControl.getFace(arch.getFaceNr())); + } + + // In the map-tile-window the object names are displayed + // next to the icons + if (arch.getObjName() != null && arch.getObjName().length() > 0) { + setText(arch.getObjName()); // special name + } else { + final String defname; + if (arch.hasArchetype()) { + defname = arch.getArchetype().getObjName(); + } else { + defname = null; + } + + if (defname != null && defname.length() > 0) { + setText(defname); // default name + } else { + setText(arch.getArchetypeName()); // arch name + } + } + } else { + setIcon(CMainControl.getUnknownTileIcon()); + setText("?"); + } + + int indent = 0; + for (;;) { + final GameObjectContainer<GameObject> env = arch.getContainer(); + if (env == null || !(env instanceof GameObject)) { + break; + } + arch = (GameObject) env; + indent++; + } + if (indent > 1) { + setBorder(BorderFactory.createEmptyBorder(0, (indent - 1) * 16, 0, 0)); // indentation + } + + return this; + } + + } // class MyCellRenderer + +} // class MapTileListControl Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2006-12-22 22:24:55 UTC (rev 1218) +++ trunk/daimonin/src/daieditor/CMainControl.java 2006-12-23 09:53:58 UTC (rev 1219) @@ -783,7 +783,7 @@ mainView.showArchPanelQuickObject(gameObject); } - boolean insertArchToMap(final GameObject newarch, final String archname, final GameObject next, final Point point) { + public boolean insertArchToMap(final GameObject newarch, final String archname, final GameObject next, final Point point) { return currentMap.getMapModel().insertArchToMap(newarch, archname, next, point); } @@ -1012,7 +1012,7 @@ level.levelCloseNotify(); } else { // Notify the level about the closing - mainView.getMapTileList().setMapTileList(null, null); + mainView.getMapTileListControl().setMapTileList(null, null); level.levelCloseNotify(); while (level.getMapViewFrame() != null) { level.closeView(level.getMapViewFrame()); Modified: trunk/daimonin/src/daieditor/CMainView.java =================================================================== --- trunk/daimonin/src/daieditor/CMainView.java 2006-12-22 22:24:55 UTC (rev 1218) +++ trunk/daimonin/src/daieditor/CMainView.java 2006-12-23 09:53:58 UTC (rev 1219) @@ -26,6 +26,7 @@ import daieditor.gameobject.GameObject; import daieditor.gui.AboutDialog; +import daieditor.gui.maptilelist.MapTileListControl; import daieditor.map.MapControl; import daieditor.map.validation.ErrorCollector; import daieditor.map.validation.ErrorHandler; @@ -141,7 +142,7 @@ private final List<MapViewIFrame> mapViews = synchronizedList(new ArrayList<MapViewIFrame>()); /** List of objects on map (right side). */ - private CMapTileList mapTileList; + private MapTileListControl mapTileListControl; /** Attributes panel (bottom). */ private CMapArchPanel mapArchPanel; @@ -219,16 +220,16 @@ statusBar = new CMainStatusbar(mainControl); archPanel = new CArchPanel(mainControl); - mapTileList = new CMapTileList(mainControl, this); + mapTileListControl = new MapTileListControl(mainControl, this); mapDesktop = new JDesktopPane(); mapArchPanel = new CMapArchPanel(mainControl, this); if (mapTileListBottom) { - splitRightPane = new GSplitPane(HORIZONTAL_SPLIT, mapArchPanel, mapTileList); + splitRightPane = new GSplitPane(HORIZONTAL_SPLIT, mapArchPanel, mapTileListControl); splitRightPane.setDividerLocation(divLocationRight); splitDownPane = new GSplitPane(VERTICAL_SPLIT, mapDesktop, splitRightPane); } else { - splitRightPane = new GSplitPane(HORIZONTAL_SPLIT, mapDesktop, mapTileList); + splitRightPane = new GSplitPane(HORIZONTAL_SPLIT, mapDesktop, mapTileListControl); splitRightPane.setDividerLocation(divLocationRight); splitDownPane = new GSplitPane(VERTICAL_SPLIT, splitRightPane, mapArchPanel); } @@ -351,21 +352,21 @@ } // show a arch in the arch map panel - void setMapArchPanelObject(final GameObject arch) { + public void setMapArchPanelObject(final GameObject arch) { mapArchPanel.setMapArchPanelObject(arch); } // access mape tile list ... public void setMapTileList(final MapControl map, final GameObject gameObject) { - mapTileList.setMapTileList(map, gameObject); + mapTileListControl.setMapTileList(map, gameObject); } public void refreshMapTileList() { - mapTileList.refresh(); + mapTileListControl.refresh(); } public GameObject getMapTileSelection() { - return mapTileList.getMapTileSelection(); + return mapTileListControl.getMapTileSelection(); } /** @@ -447,7 +448,7 @@ */ void refreshMenusAndToolbars() { archPanel.refresh(); - //mapTileList.refresh(); + //mapTileListControl.refresh(); mapArchPanel.refresh(); statusBar.refresh(); @@ -455,7 +456,7 @@ } /** Refresh the map arch panel (bottom window). */ - void refreshMapArchPanel() { + public void refreshMapArchPanel() { mapArchPanel.refresh(); } @@ -827,8 +828,8 @@ return statusBar; } - public CMapTileList getMapTileList() { - return mapTileList; + public MapTileListControl getMapTileListControl() { + return mapTileListControl; } /** {@inheritDoc} */ Deleted: trunk/daimonin/src/daieditor/CMapTileList.java =================================================================== --- trunk/daimonin/src/daieditor/CMapTileList.java 2006-12-22 22:24:55 UTC (rev 1218) +++ trunk/daimonin/src/daieditor/CMapTileList.java 2006-12-23 09:53:58 UTC (rev 1219) @@ -1,479 +0,0 @@ -/* - * Daimonin Java Editor. - * Copyright (C) 2000 Michael Toennies - * Copyright (C) 2001 Andreas Vogl - * Copyright (C) 2005 Christian Hujer - * - * (code based on: Gridder. 2D grid based level editor. (C) 2000 Pasi Keränen) - * - * 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., 59 Temple Place - Suite 330, Boston, MA - * 02111-1307, USA. - * - */ - -package daieditor; - -import daieditor.gameobject.GameObject; -import daieditor.map.MapControl; -import java.awt.BorderLayout; -import java.awt.Color; -import java.awt.Component; -import java.awt.GridLayout; -import java.awt.Insets; -import java.awt.Point; -import java.awt.Rectangle; -import static java.awt.event.InputEvent.SHIFT_MASK; -import java.awt.event.MouseEvent; -import static java.awt.event.MouseEvent.BUTTON1; -import static java.awt.event.MouseEvent.BUTTON2; -import static java.awt.event.MouseEvent.BUTTON3; -import java.awt.event.MouseListener; -import javax.swing.DefaultListCellRenderer; -import javax.swing.DefaultListModel; -import javax.swing.ImageIcon; -import javax.swing.JButton; -import javax.swing.JLabel; -import javax.swing.JList; -import javax.swing.JPanel; -import javax.swing.JScrollPane; -import javax.swing.JViewport; -import static javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER; -import javax.swing.event.ListSelectionEvent; -import javax.swing.event.ListSelectionListener; -import net.sf.gridarta.gui.map.MapCursorEvent; -import net.sf.gridarta.gui.map.MapCursorListener; -import net.sf.gridarta.map.MapSquare; -import net.sf.japi.swing.ActionFactory; -import net.sf.japi.swing.ActionMethod; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -/** - * The panel that displays the arches of the currently selected map square. - * @author <a href="mailto:mic...@no...">Michael Toennies</a> - * @author <a href="mailto:and...@gm...">Andreas Vogl</a> - * @author <a href="mailto:ch...@ri...">Christian Hujer</a> - * @todo turn this into a tree - */ -public final class CMapTileList extends JPanel implements ListSelectionListener, MouseListener, MapCursorListener { - - /** Serial Version UID. */ - private static final long serialVersionUID = 1L; - - /** Action Factory. */ - private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("daieditor"); - - /** Controller of this subview. */ - private final CMainControl mainControl; - - private final CMainView mainView; - - /** The "Import..." button. */ - private final JList list; - - private final DefaultListModel model; - - private int listCounter = 0; - - /** The currently selected MapSquare. */ - private transient MapSquare<GameObject> currentSquare; - - /** - * Create a CMapTileList. - * @param mainControl MainControl, used for icons - * @param mainView MainView, used for updating UI - */ - public CMapTileList(final CMainControl mainControl, final CMainView mainView) { - this.mainControl = mainControl; - this.mainView = mainView; - setLayout(new BorderLayout()); - - model = new DefaultListModel(); - list = new JList(model); - list.setCellRenderer(new MyCellRenderer()); - list.setBackground(Color.lightGray); - final JScrollPane scrollPane = new JScrollPane(list); - scrollPane.setHorizontalScrollBarPolicy(HORIZONTAL_SCROLLBAR_NEVER); - scrollPane.getViewport().setScrollMode(JViewport.SIMPLE_SCROLL_MODE); - add(scrollPane, BorderLayout.CENTER); - - final JPanel arrows = new JPanel(); - if (mainView.isMapTileListBottom()) { - arrows.setLayout(new GridLayout(4, 1)); - add(arrows, BorderLayout.WEST); // put up/down buttons west - } else { - add(arrows, BorderLayout.SOUTH); // put up/down buttons south - } - for (final String keyPostfix : new String[] { "Top", "Up", "Down", "Bottom" }) { - final JButton button = new JButton(ACTION_FACTORY.createAction(true, "moveTile" + keyPostfix, this)); - arrows.add(button); - button.setMargin(new Insets(0, 0, 0, 0)); - } - final JPanel compass = new JPanel(); - compass.add(new JLabel(CGUIUtils.getSysIcon(IGUIConstants.TILE_NORTH))); - add(compass, BorderLayout.NORTH); - list.addListSelectionListener(this); - list.addMouseListener(this); - list.setFocusable(false); // XXX Workaround for Mantis #0000154 This is not clean and should be removed as soon as cut/copy/paste of arches is possible - } - - /** {@inheritDoc} */ - public void valueChanged(final ListSelectionEvent e) { - mainView.setMapArchPanelObject(getMapTileSelection()); - } - - /** - * Action method for moving an arch topmost within its tile. - */ - @ActionMethod public void moveTileTop() { - final GameObject arch = getMapTileSelection(); - if (arch != null) { - arch.moveTop(); - } - refresh(); - } - - /** - * Action method for moving an arch up within its tile. - */ - @ActionMethod public void moveTileUp() { - final GameObject arch = getMapTileSelection(); - if (arch != null) { - arch.moveUp(); - } - refresh(); - } - - /** - * Action method for moving an arch down within its tile. - */ - @ActionMethod public void moveTileDown() { - final GameObject a... [truncated message content] |
From: <aki...@us...> - 2006-12-22 22:24:54
|
Revision: 1218 http://svn.sourceforge.net/gridarta/?rev=1218&view=rev Author: akirschbaum Date: 2006-12-22 14:24:55 -0800 (Fri, 22 Dec 2006) Log Message: ----------- Remove variable that is always false. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMapViewBasic.java Modified: trunk/crossfire/src/cfeditor/CMapViewBasic.java =================================================================== --- trunk/crossfire/src/cfeditor/CMapViewBasic.java 2006-12-22 22:07:00 UTC (rev 1217) +++ trunk/crossfire/src/cfeditor/CMapViewBasic.java 2006-12-22 22:24:55 UTC (rev 1218) @@ -106,8 +106,6 @@ private MapCursor mapCursor; - private final boolean[] needMpanelUpdate; // indicates that the mapArchPanel needs - private MapGrid mapGrid; // interface for the mapview frame @@ -137,11 +135,6 @@ this.mainControl = mainControl; frame = fi; - needMpanelUpdate = new boolean[3]; - needMpanelUpdate[0] = false; - needMpanelUpdate[1] = false; - needMpanelUpdate[2] = false; - if (isPickmap()) { setBackground(IGUIConstants.BG_COLOR); } @@ -435,13 +428,6 @@ } else { buttonNr = 1; // middle } - - // We update the mapArchPanel here and not in the dragging method, - // because it would considerably slow down the dragging-action. - if (needMpanelUpdate[buttonNr]) { - mainControl.getMainView().setMapTileList(mainControl.getCurrentMap(), null); - needMpanelUpdate[buttonNr] = false; - } } /** {@inheritDoc} */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2006-12-22 22:07:03
|
Revision: 1217 http://svn.sourceforge.net/gridarta/?rev=1217&view=rev Author: akirschbaum Date: 2006-12-22 14:07:00 -0800 (Fri, 22 Dec 2006) Log Message: ----------- Do not crash when user selects 'revert'. Modified Paths: -------------- trunk/src/app/net/sf/gridarta/gui/ConnectionView.java Modified: trunk/src/app/net/sf/gridarta/gui/ConnectionView.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/ConnectionView.java 2006-12-22 22:00:27 UTC (rev 1216) +++ trunk/src/app/net/sf/gridarta/gui/ConnectionView.java 2006-12-22 22:07:00 UTC (rev 1217) @@ -57,6 +57,9 @@ /** The List with the connections. */ private JList connectionList = new JList(); + /** Map control corresponding to {@link #connectionList}. */ + private MapControl mapControl = null; + /** Create a ConnectionPanel. */ public ConnectionView() { setLayout(new BorderLayout()); @@ -80,7 +83,8 @@ /** {@inheritDoc} */ public void currentMapChanged(@Nullable final MapControl mapControl) { - scanMapForConnections(mapControl.getMapModel()); + this.mapControl = mapControl; + scanMapForConnections(mapControl == null ? null : mapControl.getMapModel()); } /** @@ -89,16 +93,18 @@ */ public void scanMapForConnections(final MapModel model) { connections.clear(); - for (final MapSquare<? extends GameObject> mapSquare : (MapModel<? extends GameObject, MapArchObject>) model) { - for (final GameObject archObject : mapSquare) { - final String connectionSpec = archObject.getAttributeString("connected", false); - if (connectionSpec != null && connectionSpec.matches("\\d+(, *\\d+)*")) { - for (String s : connectionSpec.trim().split(",\\s*")) { - final Integer connection = Integer.valueOf(s); - if (!connections.containsKey(connection)) { - connections.put(connection, new ArrayList<GameObject>()); + if (model != null && mapControl != null && mapControl.getMapModel() == model) { + for (final MapSquare<? extends GameObject> mapSquare : (MapModel<? extends GameObject, MapArchObject>) model) { + for (final GameObject archObject : mapSquare) { + final String connectionSpec = archObject.getAttributeString("connected", false); + if (connectionSpec != null && connectionSpec.matches("\\d+(, *\\d+)*")) { + for (String s : connectionSpec.trim().split(",\\s*")) { + final Integer connection = Integer.valueOf(s); + if (!connections.containsKey(connection)) { + connections.put(connection, new ArrayList<GameObject>()); + } + connections.get(connection).add(archObject); } - connections.get(connection).add(archObject); } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2006-12-22 22:00:31
|
Revision: 1216 http://svn.sourceforge.net/gridarta/?rev=1216&view=rev Author: akirschbaum Date: 2006-12-22 14:00:27 -0800 (Fri, 22 Dec 2006) Log Message: ----------- Use ActionFactor to create toolbar. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainView.java trunk/crossfire/src/cfeditor/action.properties trunk/crossfire/src/cfeditor/messages.properties trunk/crossfire/src/cfeditor/messages_de.properties Added Paths: ----------- trunk/crossfire/resource/icons/navigation/ trunk/crossfire/resource/icons/navigation/Back16.gif trunk/crossfire/resource/icons/navigation/Forward16.gif Removed Paths: ------------- trunk/crossfire/src/cfeditor/CMainToolbar.java Added: trunk/crossfire/resource/icons/navigation/Back16.gif =================================================================== (Binary files differ) Property changes on: trunk/crossfire/resource/icons/navigation/Back16.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/crossfire/resource/icons/navigation/Forward16.gif =================================================================== (Binary files differ) Property changes on: trunk/crossfire/resource/icons/navigation/Forward16.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Deleted: trunk/crossfire/src/cfeditor/CMainToolbar.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainToolbar.java 2006-12-22 21:32:21 UTC (rev 1215) +++ trunk/crossfire/src/cfeditor/CMainToolbar.java 2006-12-22 22:00:27 UTC (rev 1216) @@ -1,341 +0,0 @@ -/* - * Crossfire Java Editor. - * Copyright (C) 2000 Michael Toennies - * Copyright (C) 2001 Andreas Vogl - * - * (code based on: Gridder. 2D grid based level editor. (C) 2000 Pasi Keränen) - * - * 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., 59 Temple Place - Suite 330, Boston, MA - * 02111-1307, USA. - * - */ - -package cfeditor; - -import java.awt.Dimension; -import java.awt.Insets; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.InputEvent; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.util.Enumeration; -import java.util.Vector; -import javax.swing.ButtonGroup; -import javax.swing.JButton; -import javax.swing.JPopupMenu; -import javax.swing.JRadioButtonMenuItem; -import javax.swing.JToolBar; -import javax.swing.SwingConstants; -import org.jetbrains.annotations.Nullable; - -/** - * <code>CMainTolbar</code> implements the main toolbar of the application. - * @author <a href="mailto:mic...@no...">Michael Toennies</a> - * @author <a href="mailto:and...@gm...">Andreas Vogl</a> - */ -public final class CMainToolbar extends JToolBar { - - /** The key used to store the icons/labels setting to the INI file. */ - public static final String SHOW_ICONS_AND_LABELS_KEY = "MainToolbar.iconsAndLabels"; - - /** Enumerated icons/labels mode. Shows both icons and labels. */ - public static final int SHOW_ICONS_AND_LABELS = 0; - - /** Enumerated icons/labels mode. Shows only icons. */ - public static final int SHOW_ICONS_ONLY = 1; - - /** Enumerated icons/labels mode. Shows only labels. */ - public static final int SHOW_LABELS_ONLY = 2; - - /** The controller of this toolbar view. */ - private final CMainControl mainControl; - - /** The current icon/labels mode. */ - private int eIconAndLabelVisibility = SHOW_ICONS_ONLY; - - /** The popup menu. */ - private final CPopupMenu popupMenu; - - private JButton save; - - private JButton saveAs; - - private static final long serialVersionUID = 1L; - - /** - * Constructs a new toolbar. - * @param mainControl The controller of this toolbar. - */ - CMainToolbar(final CMainControl mainControl) { - super(SwingConstants.VERTICAL); // construct with vertical alignment - this.mainControl = mainControl; - - eIconAndLabelVisibility = Integer.parseInt(CSettings.getInstance(IGUIConstants.APP_NAME).getProperty(SHOW_ICONS_AND_LABELS_KEY, "" + SHOW_ICONS_ONLY)); - popupMenu = new CPopupMenu(); - addMouseListener( - new MouseAdapter() { - @Override public void mousePressed(final MouseEvent event) { - if ((event.getModifiers() & InputEvent.META_MASK) != 0) { - popupMenu.show(CMainToolbar.this, event.getX(), event.getY()); - } - } - }); - - rebuild(); - } - - /** - * Returns the text if it should be visible, otherwise <code>null</code>. - * @param label The label text. - * @return The label text or null if labels should not be visible. - */ - @Nullable private String filterLabel(final String label) { - return eIconAndLabelVisibility == SHOW_ICONS_ONLY ? null : label; - } - - /** - * Returns the icon name if it should be visible, otherwise <code>null</code>. - * @param iconName The icon name. - * @return The icon name or null if icons should not be visible. - */ - @Nullable private String filterIconName(final String iconName) { - return eIconAndLabelVisibility == SHOW_LABELS_ONLY ? null : iconName; - } - - /** - * Rebuilds the toolbar by first removing the buttons and - * then adding them again. - */ - private void rebuild() { - removeAll(); - - setMargin(new Insets(IGUIConstants.DIALOG_INSETS, 0, IGUIConstants.DIALOG_INSETS, IGUIConstants.DIALOG_INSETS)); - - final Vector<JButton> buttons = new Vector<JButton>(10, 2); - final JButton newButton = new CFancyButton( - filterLabel("New"), - "New Map", - filterIconName(IGUIConstants.NEW_LEVEL_ICON), - new ActionListener() { - public void actionPerformed(final ActionEvent event) { - mainControl.createNew(); - } - }); - newButton.setVerticalTextPosition(SwingConstants.BOTTOM); - newButton.setHorizontalTextPosition(SwingConstants.CENTER); - buttons.addElement(newButton); - add(newButton); - - final JButton open = new CFancyButton( - filterLabel("Open"), - "Open Map File", - filterIconName(IGUIConstants.OPEN_LEVEL_ICON), - new ActionListener() { - public void actionPerformed(final ActionEvent event) { - mainControl.open(); - } - }); - open.setVerticalTextPosition(SwingConstants.BOTTOM); - open.setHorizontalTextPosition(SwingConstants.CENTER); - buttons.addElement(open); - add(open); - - save = new CFancyButton( - filterLabel("Save"), - "Save Map File", - filterIconName(IGUIConstants.SAVE_LEVEL_ICON), - new ActionListener() { - public void actionPerformed(final ActionEvent event) { - mainControl.save(); - } - }); - save.setVerticalTextPosition(SwingConstants.BOTTOM); - save.setHorizontalTextPosition(SwingConstants.CENTER); - buttons.addElement(save); - add(save); - - saveAs = new CFancyButton( - filterLabel("Save As"), - "Save Map File As", - filterIconName(IGUIConstants.SAVE_LEVEL_AS_ICON), - new ActionListener() { - public void actionPerformed(final ActionEvent event) { - mainControl.saveAs(); - } - }); - saveAs.setVerticalTextPosition(SwingConstants.BOTTOM); - saveAs.setHorizontalTextPosition(SwingConstants.CENTER); - buttons.addElement(saveAs); - add(saveAs); - - addSeparator(); - - final JButton prevWindow = new CFancyButton( - filterLabel("Prev"), - "Show Previous Window", - filterIconName(IGUIConstants.PREVIOUS_WINDOW_ICON), - new ActionListener() { - public void actionPerformed(final ActionEvent event) { - mainControl.prevWindow(); - } - }); - prevWindow.setVerticalTextPosition(SwingConstants.BOTTOM); - prevWindow.setHorizontalTextPosition(SwingConstants.CENTER); - buttons.addElement(prevWindow); - add(prevWindow); - - final JButton nextWindow = new CFancyButton( - filterLabel("Next"), - "Show Next Window", - filterIconName(IGUIConstants.NEXT_WINDOW_ICON), - new ActionListener() { - public void actionPerformed(final ActionEvent event) { - mainControl.nextWindow(); - } - }); - nextWindow.setVerticalTextPosition(SwingConstants.BOTTOM); - nextWindow.setHorizontalTextPosition(SwingConstants.CENTER); - buttons.addElement(nextWindow); - add(nextWindow); - - doLayout(); - - // If icons and labels are visible make buttons square shaped - if (eIconAndLabelVisibility == SHOW_ICONS_AND_LABELS) { - int maxWidth = 16; - for (Enumeration<JButton> enu = buttons.elements(); - enu.hasMoreElements();) { - final JButton button = enu.nextElement(); - maxWidth = Math.max(maxWidth, button.getWidth()); - } - - for (final Enumeration<JButton> enu = buttons.elements(); enu.hasMoreElements();) { - final JButton button = enu.nextElement(); - final Dimension size = new Dimension(maxWidth, maxWidth); - button.setSize(size); - button.setMinimumSize(size); - button.setMaximumSize(size); - button.setPreferredSize(size); - } - } - - refresh(); - doLayout(); - repaint(); - mainControl.refreshMainView(); - } - - /** - * Sets the icon and label visibility. - * @param eVisibility One of the enumerated SHOW_xxx values. - */ - void setIconAndLabelVisibility(final int eVisibility) { - switch (eVisibility) { - case SHOW_ICONS_AND_LABELS: - case SHOW_ICONS_ONLY: - case SHOW_LABELS_ONLY: - eIconAndLabelVisibility = eVisibility; - CSettings.getInstance(IGUIConstants.APP_NAME).setProperty(SHOW_ICONS_AND_LABELS_KEY, "" + eVisibility); - break; - - default: - return; - } - - rebuild(); - } - - /** Refreshes the state of items in this toolbar. */ - void refresh() { - final boolean fLevelEdited = mainControl.isLevelEdited(); - save.setEnabled(mainControl.isPlainSaveEnabled()); - saveAs.setEnabled(fLevelEdited); - } - - /** - * The popup menu that is shown on right click - * upon this toolbar. - */ - public final class CPopupMenu extends JPopupMenu { - - final JRadioButtonMenuItem iconsAndLabels; - - final JRadioButtonMenuItem iconsOnly; - - final JRadioButtonMenuItem labelsOnly; - - final ButtonGroup group; - - private static final long serialVersionUID = 1L; - - /** Constructs the popup menu with the appropriate menuitems. */ - public CPopupMenu() { - group = new ButtonGroup(); - iconsAndLabels = new JRadioButtonMenuItem("Icons&Labels"); - iconsAndLabels.addActionListener( - new ActionListener() { - public void actionPerformed(final ActionEvent event) { - setIconAndLabelVisibility(SHOW_ICONS_AND_LABELS); - } - }); - group.add(iconsAndLabels); - add(iconsAndLabels); - iconsOnly = new JRadioButtonMenuItem("Icons"); - iconsOnly.addActionListener( - new ActionListener() { - public void actionPerformed(final ActionEvent event) { - setIconAndLabelVisibility(SHOW_ICONS_ONLY); - } - }); - group.add(iconsOnly); - add(iconsOnly); - labelsOnly = new JRadioButtonMenuItem("Labels"); - labelsOnly.addActionListener( - new ActionListener() { - public void actionPerformed(final ActionEvent event) { - setIconAndLabelVisibility(SHOW_LABELS_ONLY); - } - }); - group.add(labelsOnly); - add(labelsOnly); - - refresh(); - } - - /** Refreshes the states of the menuitems. */ - void refresh() { - switch (eIconAndLabelVisibility) { - case SHOW_ICONS_AND_LABELS: - group.setSelected(iconsAndLabels.getModel(), true); - group.setSelected(iconsOnly.getModel(), false); - group.setSelected(labelsOnly.getModel(), false); - break; - - case SHOW_ICONS_ONLY: - group.setSelected(iconsAndLabels.getModel(), false); - group.setSelected(iconsOnly.getModel(), true); - group.setSelected(labelsOnly.getModel(), false); - break; - - case SHOW_LABELS_ONLY: - group.setSelected(iconsAndLabels.getModel(), false); - group.setSelected(iconsOnly.getModel(), false); - group.setSelected(labelsOnly.getModel(), true); - break; - } - } - } -} Modified: trunk/crossfire/src/cfeditor/CMainView.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainView.java 2006-12-22 21:32:21 UTC (rev 1215) +++ trunk/crossfire/src/cfeditor/CMainView.java 2006-12-22 22:00:27 UTC (rev 1216) @@ -117,9 +117,6 @@ /** The controller of this view. */ private static final CMainControl mainControl = CMainControl.getInstance(); - /** The main toolbar. */ - private CMainToolbar toolBar; - /** The main statusbar. */ private CMainStatusbar statusBar; @@ -276,9 +273,7 @@ mainControl.getFilterControl().createMenuEntries(menuAnalyze); } - toolBar = new CMainToolbar(mainControl); - //getContentPane().add(toolBar, BorderLayout.NORTH); - getContentPane().add(toolBar, BorderLayout.WEST); // put it left + add(ACTION_FACTORY.createToolBar("main"), BorderLayout.NORTH); // set bounds (location and size) of the main frame setBounds(x, y, width, height); @@ -473,7 +468,6 @@ archPanel.refresh(); mapTileList.refresh(); mapArchPanel.refresh(); - toolBar.refresh(); statusBar.refresh(); refresh3(); @@ -828,7 +822,7 @@ private final String[] directionsMap = {"enterNorthMap", "enterEastMap", "enterSouthMap", "enterWestMap", "enterUpperMap", "enterLowerMap"}; private void initActions() { - ACTION_FACTORY.createActions(true, mainControl, "createNew", "open", "options", "exit", "gc", "onlineHelp", "about"); + ACTION_FACTORY.createActions(true, mainControl, "createNew", "open", "options", "exit", "gc", "prevWindow", "nextWindow", "onlineHelp", "about"); ACTION_FACTORY.createActions(true, mainControl.getScriptController().getView(), "editPlugins", "savePlugins", "exportPluginAs", "importPlugin"); ACTION_FACTORY.createActions(true, mainControl, directionsMap); ACTION_FACTORY.createActions(true, this, "resetView"); Modified: trunk/crossfire/src/cfeditor/action.properties =================================================================== --- trunk/crossfire/src/cfeditor/action.properties 2006-12-22 21:32:21 UTC (rev 1215) +++ trunk/crossfire/src/cfeditor/action.properties 2006-12-22 22:00:27 UTC (rev 1216) @@ -30,6 +30,10 @@ mapwindowCursor.menu=moveCursor - selectTile startStopDrag addToSelection subFromSelection releaseDrag - insertArch deleteArch - selectArchAbove selectArchBelow - archAttributes mapwindowView.menu=showMonster showExit showBackground showDoor showWall showEquipment showTreasure showConnected resetView +########## +# ToolBars +main.toolbar=createNew open save saveAs - prevWindow nextWindow + ####### # File @@ -108,6 +112,11 @@ importPlugin.icon=ImportPluginSmallIcon +nextWindow.icon=navigation/Forward16 + +prevWindow.icon=navigation/Back16 + + onlineHelp.icon=general/Help16 about.icon=general/About16 Modified: trunk/crossfire/src/cfeditor/messages.properties =================================================================== --- trunk/crossfire/src/cfeditor/messages.properties 2006-12-22 21:32:21 UTC (rev 1215) +++ trunk/crossfire/src/cfeditor/messages.properties 2006-12-22 22:00:27 UTC (rev 1216) @@ -406,6 +406,14 @@ window.text=Window window.mnemonic=W +nextWindow.text=Next Window +nextWindow.shortdescription=Display next window +nextWindow.accel=shift pressed PAGE_UP + +prevWindow.text=Previous Window +prevWindow.shortdescription=Display previous window +prevWindow.accel=shift pressed PAGE_DOWN + closeAll.text=Close All closeAll.shortdescription=Close all maps closeAll.longdescription=Closes all opened maps Modified: trunk/crossfire/src/cfeditor/messages_de.properties =================================================================== --- trunk/crossfire/src/cfeditor/messages_de.properties 2006-12-22 21:32:21 UTC (rev 1215) +++ trunk/crossfire/src/cfeditor/messages_de.properties 2006-12-22 22:00:27 UTC (rev 1216) @@ -630,6 +630,14 @@ window.text=Fenster window.mnemonic=F +nextWindow.text=N\xE4chstes Fenster +nextWindow.shortdescription=Zeige das n\xE4chste Fenster +nextWindow.accel=shift pressed PAGE_UP + +prevWindow.text=Vorheriges Fenster +prevWindow.shortdescription=Zeige das vorherige Fenster +prevWindow.accel=shift pressed PAGE_DOWN + closeAll.text=Alle schlie\xDFen closeAll.shortdescription=Alle Karten schlie\xDFen closeAll.longdescription=Schlie\xDFt alle ge\xF6ffneten Karten. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2006-12-22 21:32:23
|
Revision: 1215 http://svn.sourceforge.net/gridarta/?rev=1215&view=rev Author: akirschbaum Date: 2006-12-22 13:32:21 -0800 (Fri, 22 Dec 2006) Log Message: ----------- Remove unused code. Modified Paths: -------------- trunk/crossfire/src/cfeditor/menu/MenuEntry.java Removed Paths: ------------- trunk/crossfire/src/cfeditor/menu/BasicAction.java trunk/crossfire/src/cfeditor/menu/BasicMenuEntry.java trunk/crossfire/src/cfeditor/menu/CheckBoxMenuEntry.java trunk/crossfire/src/cfeditor/menu/FilterCheckBoxEntry.java trunk/crossfire/src/cfeditor/menu/LocationMenuEntry.java trunk/crossfire/src/cfeditor/menu/MenuGroup.java trunk/crossfire/src/cfeditor/menu/MenuHelper.java trunk/crossfire/src/cfeditor/menu/SeparatorMenuEntry.java trunk/crossfire/src/cfeditor/menu/SimpleMenuEntry.java trunk/crossfire/src/cfeditor/menu/SwitchedMenuEntry.java Deleted: trunk/crossfire/src/cfeditor/menu/BasicAction.java =================================================================== --- trunk/crossfire/src/cfeditor/menu/BasicAction.java 2006-12-22 21:25:53 UTC (rev 1214) +++ trunk/crossfire/src/cfeditor/menu/BasicAction.java 2006-12-22 21:32:21 UTC (rev 1215) @@ -1,71 +0,0 @@ -/* - * Created on 18-déc.-2004 - * - * To change the template for this generated file go to - * Window>Preferences>Java>Code Generation>Code and Comments - */ - -package cfeditor.menu; - -import java.awt.event.ActionEvent; -import javax.swing.AbstractAction; -import javax.swing.Icon; -import javax.swing.KeyStroke; -import org.apache.log4j.Logger; - -public class BasicAction extends AbstractAction { - - private static final Logger log = Logger.getLogger(BasicAction.class); - - private final BasicMenuEntry entry; - - private static final long serialVersionUID = -9018592526345334501L; - - public BasicAction(final BasicMenuEntry entry) { - super(); - this.entry = entry; - } - - public BasicAction(final BasicMenuEntry entry, final String name) { - super(name); - this.entry = entry; - } - - public BasicAction(final BasicMenuEntry entry, final String name, final Icon icon) { - super(name, icon); - this.entry = entry; - } - - public void actionPerformed(final ActionEvent e) { - log.debug("ActionPerformed: " + e); - entry.actionPerformed(e); - } - - public void setName(final String name) { - putValue(NAME, name); - } - - public void setKeyStroke(final KeyStroke key) { - putValue(ACCELERATOR_KEY, key); - } - - public void setActionCommand(final String command) { - putValue(ACTION_COMMAND_KEY, command); - } - - public void setIcon(final Icon icon) { - putValue(SMALL_ICON, icon); - } - - public void setMnemonic(final int key) { - putValue(MNEMONIC_KEY, new Integer(key)); - } - - @Override public Object getValue(final String key) { - if (log.isDebugEnabled()) { - log.debug("getValue(" + key + ") -> " + super.getValue(key)); - } - - return super.getValue(key); - } -} Deleted: trunk/crossfire/src/cfeditor/menu/BasicMenuEntry.java =================================================================== --- trunk/crossfire/src/cfeditor/menu/BasicMenuEntry.java 2006-12-22 21:25:53 UTC (rev 1214) +++ trunk/crossfire/src/cfeditor/menu/BasicMenuEntry.java 2006-12-22 21:32:21 UTC (rev 1215) @@ -1,185 +0,0 @@ -/* - * Created on 12-déc.-2004 - * - * To change the template for this generated file go to - * Window>Preferences>Java>Code Generation>Code and Comments - */ - -package cfeditor.menu; - -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.lang.ref.Reference; -import java.lang.ref.ReferenceQueue; -import java.lang.ref.WeakReference; -import java.util.ArrayList; -import javax.swing.AbstractButton; -import javax.swing.ButtonModel; -import javax.swing.JComponent; -import javax.swing.JMenuItem; -import javax.swing.KeyStroke; -import org.apache.log4j.Logger; - -public abstract class BasicMenuEntry extends MenuEntry implements ActionListener { - - private static final Logger log = Logger.getLogger(BasicMenuEntry.class); - - private KeyStroke accelerator; - - private char mnemonic; - - private final ArrayList<ActionListener> listeners = new ArrayList<ActionListener>(); - - private final ArrayList<WeakReference<JComponent>> refs = new ArrayList<WeakReference<JComponent>>(); - - private final ReferenceQueue<JComponent> componentQueue = new ReferenceQueue<JComponent>(); - - private String name; - - private ButtonModel model; - - private BasicAction action; - - private boolean enabled = true; - - protected BasicMenuEntry(final String name) { - setName(name); - } - - public void setAccelerator(final KeyStroke accelerator) { - this.accelerator = accelerator; - fireUpdate(); - } - - public void setMnemonic(final char mnemonic) { - this.mnemonic = mnemonic; - fireUpdate(); - } - - public void addActionListener(final ActionListener listener) { - synchronized (listeners) { - listeners.add(listener); - } - } - - protected void initItem(final AbstractButton item) { - log.debug("initItem()"); - item.setAction(getBasicAction()); - updateItem(item); - referenceItem(item); - } - - protected BasicAction getBasicAction() { - if (action == null) { - synchronized (this) { - if (action == null) { - action = new BasicAction(this, getName()); - } - } - } - return action; - } - - private void referenceItem(final JComponent item) { - log.debug("referenceMenuItem()"); - synchronized (refs) { - refs.add(new WeakReference<JComponent>(item, componentQueue)); - } - } - - protected abstract void updateItem(JComponent item); - - protected abstract void update(); - - protected void defaultUpdateItem(final JComponent item) { - log.debug("defaultUpdateJMenuItem"); - if (log.isDebugEnabled()) { - log.debug("item " + item.getClass() + ": " + name + " (" + mnemonic + ") -> " + accelerator); - } - if (item instanceof AbstractButton) { - //((AbstractButton)item).setText(getName()); - item.setVisible(isVisible()); - item.setEnabled(isEnabled()); - //((AbstractButton)item).setMnemonic(mnemonic); - //((AbstractButton)item).setActionCommand(getName()); - } - if (item instanceof JMenuItem) { - //((JMenuItem)item).setAccelerator(accelerator); - } - } - - public void actionPerformed(final ActionEvent e) { - synchronized (listeners) { - for (final ActionListener listener : listeners) { - log.debug("One more actionPerformed Listerner"); - listener.actionPerformed(e); - } - } - log.debug("Acton performed done"); - } - - @Override protected void fireUpdate() { - log.debug("fireUpdate()"); - getBasicAction().setName(getName()); - getBasicAction().setActionCommand(getName()); - getBasicAction().setMnemonic(getMnemonic()); - getBasicAction().setKeyStroke(getAccelerator()); - getBasicAction().setEnabled(isEnabled()); - update(); - cleanUpQueue(componentQueue); - synchronized (refs) { - for (final WeakReference<JComponent> wf : refs) { - final JComponent item = wf.get(); - if (log.isDebugEnabled()) { - log.debug("Updating item: " + item); - } - if (item != null) { - updateItem(item); - } - } - } - } - - private void cleanUpQueue(final ReferenceQueue queue) { - Reference r; - synchronized (refs) { - while ((r = queue.poll()) != null) { - // This suspicious remove call is okay. - // The reference queue in context will return a Reference. - // Refs is a collection of WeakReferences. - //noinspection SuspiciousMethodCalls - refs.remove(r); - } - } - } - - public String getName() { - return name; - } - - public void setName(final String name) { - if (log.isDebugEnabled()) { - log.debug("setName(" + name + ")"); - } - - this.name = name; - fireUpdate(); - } - - public KeyStroke getAccelerator() { - return accelerator; - } - - public char getMnemonic() { - return mnemonic; - } - - public boolean isEnabled() { - return enabled; - } - - public void setEnabled(final boolean enabled) { - this.enabled = enabled; - fireUpdate(); - } -} Deleted: trunk/crossfire/src/cfeditor/menu/CheckBoxMenuEntry.java =================================================================== --- trunk/crossfire/src/cfeditor/menu/CheckBoxMenuEntry.java 2006-12-22 21:25:53 UTC (rev 1214) +++ trunk/crossfire/src/cfeditor/menu/CheckBoxMenuEntry.java 2006-12-22 21:32:21 UTC (rev 1215) @@ -1,117 +0,0 @@ -/* - * Created on 12-déc.-2004 - * - * To change the template for this generated file go to - * Window>Preferences>Java>Code Generation>Code and Comments - */ - -package cfeditor.menu; - -import java.awt.event.ActionEvent; -import javax.swing.AbstractButton; -import javax.swing.ButtonModel; -import javax.swing.JCheckBoxMenuItem; -import javax.swing.JComponent; -import javax.swing.JPanel; -import javax.swing.JToggleButton; -import org.apache.log4j.Logger; - -public class CheckBoxMenuEntry extends BasicMenuEntry { - - private final Logger log = Logger.getLogger(CheckBoxMenuEntry.class); - - private ButtonModel model; - - private boolean checked = false; - - private MenuGroup group = null; - - /** - * Creates a CheckBoxMenuEntry. - * @param name Name for this CheckBoxMenuEntry. - */ - public CheckBoxMenuEntry(final String name) { - super(name); - } - - public boolean isChecked() { - return checked; - } - - public void setChecked(final boolean checked) { - if (group == null) { - final boolean oldChecked = this.checked; - this.checked = checked; - if (this.checked != oldChecked) { - fireUpdate(); - } - } else if (checked) { - group.setChecked(this); - } else { - log.warn("Explicit call to setChecked(false) on a group owned entry"); - } - } - - @Override protected void update() { - //getModel().setSelected(isChecked()); - } - - @Override protected void updateItem(final JComponent item) { - defaultUpdateItem(item); - if (item instanceof JCheckBoxMenuItem) { - ((JCheckBoxMenuItem) item).setSelected(isChecked()); - log.debug("set state to " + isChecked()); - } else if (item instanceof JToggleButton) { - ((JToggleButton) item).setSelected(isChecked()); - } - } - - @Override public JComponent getMenuBarComponent() { - return new JPanel(); // no supported - } - - @Override public JComponent getMenuItemComponent() { - log.debug("getMenuItemComponent()"); - final JCheckBoxMenuItem chk = new JCheckBoxMenuItem(); - initItem(chk); - chk.setSelected(isChecked()); - return chk; - } - - @Override public JComponent getToolbarComponent() { - final JToggleButton tgl = new JToggleButton("some"); - initItem(tgl); - tgl.setSelected(isChecked()); - return tgl; - } - - @Override public void actionPerformed(final ActionEvent e) { - if (e.getSource() instanceof AbstractButton) { - final AbstractButton b = (AbstractButton) e.getSource(); - if (group != null && !b.getModel().isSelected()) { - log.debug("canceling an uncheck on " + getName()); - /*this was a click to uncheck. Forbid and don't spread this even*/ - b.getModel().setSelected(true); - return; - } else { - setChecked(b.getModel().isSelected()); - } - } - super.actionPerformed(e); - } - - public void setGroup(final MenuGroup group) { - this.group = group; - if (isChecked()) { - group.setChecked(this); - } - } - - protected void setChecked(final CheckBoxMenuEntry entry) { - final boolean oldChecked = checked; - checked = entry == this; - if (checked != oldChecked) { - fireUpdate(); - } - } -} Deleted: trunk/crossfire/src/cfeditor/menu/FilterCheckBoxEntry.java =================================================================== --- trunk/crossfire/src/cfeditor/menu/FilterCheckBoxEntry.java 2006-12-22 21:25:53 UTC (rev 1214) +++ trunk/crossfire/src/cfeditor/menu/FilterCheckBoxEntry.java 2006-12-22 21:32:21 UTC (rev 1215) @@ -1,30 +0,0 @@ -/* - * Created on 29-déc.-2004 - * - * To change the template for this generated file go to - * Window>Preferences>Java>Code Generation>Code and Comments - */ - -package cfeditor.menu; - -import cfeditor.filter.FilterConfig; - -public class FilterCheckBoxEntry extends CheckBoxMenuEntry { - - private final FilterConfig config; - - public FilterCheckBoxEntry(final FilterConfig config) { - super("<<set me>>"); - this.config = config; - setChecked(config.isEnabled()); - } - - @Override public void setChecked(final boolean checked) { - if (checked == isChecked()) { - return; - } - super.setChecked(checked); - config.setEnabled(checked); - } - -} // class FilterCheckBoxEntry Deleted: trunk/crossfire/src/cfeditor/menu/LocationMenuEntry.java =================================================================== --- trunk/crossfire/src/cfeditor/menu/LocationMenuEntry.java 2006-12-22 21:25:53 UTC (rev 1214) +++ trunk/crossfire/src/cfeditor/menu/LocationMenuEntry.java 2006-12-22 21:32:21 UTC (rev 1215) @@ -1,112 +0,0 @@ -/* -* Java class "LocationMenuEntry.java" generated from Poseidon for UML. -* Poseidon for UML is developed by <A HREF="http://www.gentleware.com">Gentleware</A>. -* Generated with <A HREF="http://jakarta.apache.org/velocity/">velocity</A> template engine. -*/ - -package cfeditor.menu; - -import java.util.Set; -import javax.swing.JComponent; -import javax.swing.JMenu; -import javax.swing.JMenuItem; -import javax.swing.JPanel; -import org.apache.log4j.Logger; - -/** - * This menu entry map all existing Menu entries at a given location. - * If any of the entries at that location changes, LocationMenuEntry - * notifies the Manager it has changed too. - * @author unknown (probably tchize). - */ -public class LocationMenuEntry extends BasicMenuEntry implements MenuListener { - - private final String location; - - private static final Logger log = Logger.getLogger(LocationMenuEntry.class); - - private void populateComponent(final JMenuItem menu) { - if (log.isDebugEnabled()) { - log.debug("populateComponent"); - } - - final MenuManager menuManager = getMenuManager(); - if (menuManager == null) { - return; - } - - log.debug("Menu Manager is not null"); - final MenuLocation loc = menuManager.getMenuLocation(location); - if (log.isDebugEnabled()) { - log.debug("Got location " + loc + " for uri " + location); - } - - if (loc == null) { - return; - } - - final Set entries = loc.getMenuEntries(); - for (final Object entry : entries) { - log.debug("One more item added"); - menu.add(((MenuEntry) entry).getMenuItemComponent()); - } - log.debug("returning..."); - } - - @Override public void setMenuManager(final MenuManager manager) { - if (manager != super.getMenuManager()) { - super.setMenuManager(manager); - manager.addMenuListener(getMenuLocation(), this); - } - } - - /** - * Returns the MenuLocation name this entry maps. - * @return The MenuLocation name this entry maps. - */ - public String getMenuLocation() { - return location; - } - - /** - * Constructor. Takes a location to map and the name of MenuEntry. - * @param location The location to map - * @param name The name of MenuEntry - */ - public LocationMenuEntry(final String location, final String name) { - super(name); - this.location = location; - } - - public void menuChanged(final MenuChangeEvent event) { - if (event.getLocation() != null && (event.getLocation().getName().equals(location))) { - getMenuManager().fireMenuEntryChange(this, MenuChangeEvent.CHANGE_CONTENT); - } - } - - @Override protected void update() { - // nothing special - } - - @Override protected void updateItem(final JComponent item) { - defaultUpdateItem(item); - } - - @Override public JComponent getMenuBarComponent() { - final JMenu menu = new JMenu(getName()); - menu.setMnemonic(getMnemonic()); - populateComponent(menu); - return menu; - } - - @Override public JComponent getMenuItemComponent() { - final JMenuItem menu = new JMenuItem(getName()); - populateComponent(menu); - return menu; - } - - @Override public JComponent getToolbarComponent() { - return new JPanel(); - //TODO shouldn't it be a button invoking a popup?? - } -} Modified: trunk/crossfire/src/cfeditor/menu/MenuEntry.java =================================================================== --- trunk/crossfire/src/cfeditor/menu/MenuEntry.java 2006-12-22 21:25:53 UTC (rev 1214) +++ trunk/crossfire/src/cfeditor/menu/MenuEntry.java 2006-12-22 21:32:21 UTC (rev 1215) @@ -21,9 +21,6 @@ /** Should this menu be shown. */ private boolean visible = true; - /** A special entry designing a separator. */ - private static final MenuEntry separator = new SeparatorMenuEntry(); - /** * Set the menu manager associated with this menu entry. This menu manager * should be notified if this menu's content changes. @@ -101,13 +98,5 @@ return visible; } - /** - * Get a special MenuEntry representing a separator. - * @return the separator MenuEntry - */ - public static MenuEntry getSeparator() { - return separator; - } - protected abstract void fireUpdate(); } Deleted: trunk/crossfire/src/cfeditor/menu/MenuGroup.java =================================================================== --- trunk/crossfire/src/cfeditor/menu/MenuGroup.java 2006-12-22 21:25:53 UTC (rev 1214) +++ trunk/crossfire/src/cfeditor/menu/MenuGroup.java 2006-12-22 21:32:21 UTC (rev 1215) @@ -1,29 +0,0 @@ -/* - * Created on 19-déc.-2004 - * - * To change the template for this generated file go to - * Window>Preferences>Java>Code Generation>Code and Comments - */ - -package cfeditor.menu; - -public class MenuGroup { - - private CheckBoxMenuEntry checked = null; - - public void add(final CheckBoxMenuEntry entry) { - entry.setGroup(this); - } - - public synchronized void setChecked(final CheckBoxMenuEntry entry) { - if (checked == entry) { - return; - } - - if (checked != null) { - checked.setChecked(entry); - } - checked = entry; - entry.setChecked(entry); - } -} Deleted: trunk/crossfire/src/cfeditor/menu/MenuHelper.java =================================================================== --- trunk/crossfire/src/cfeditor/menu/MenuHelper.java 2006-12-22 21:25:53 UTC (rev 1214) +++ trunk/crossfire/src/cfeditor/menu/MenuHelper.java 2006-12-22 21:32:21 UTC (rev 1215) @@ -1,32 +0,0 @@ -/* - * Created on 17-déc.-2004 - * - * To change the template for this generated file go to - * Window>Preferences>Java>Code Generation>Code and Comments - */ - -package cfeditor.menu; - -import java.util.Set; -import javax.swing.JMenuBar; - -public class MenuHelper { - - private MenuHelper() { - // It's a helper class, no instance can be created - } - - /** - * This creates a JMenuBar from the MenuEntries at a given location. - * @param location The MenuLocation to create the JMenuBar for. - * @return the newly created JMenuBar - */ - public static JMenuBar getLocationBar(final MenuLocation location) { - final JMenuBar menuBar = new JMenuBar(); - final Set s = location.getMenuEntries(); - for (final Object value : s) { - menuBar.add(((MenuEntry) value).getMenuBarComponent()); - } - return menuBar; - } -} Deleted: trunk/crossfire/src/cfeditor/menu/SeparatorMenuEntry.java =================================================================== --- trunk/crossfire/src/cfeditor/menu/SeparatorMenuEntry.java 2006-12-22 21:25:53 UTC (rev 1214) +++ trunk/crossfire/src/cfeditor/menu/SeparatorMenuEntry.java 2006-12-22 21:32:21 UTC (rev 1215) @@ -1,47 +0,0 @@ -/* - * Created on 07-déc.-2004 - * - * To change the template for this generated file go to - * Window>Preferences>Java>Code Generation>Code and Comments - */ - -package cfeditor.menu; - -import javax.swing.JComponent; -import javax.swing.JSeparator; -import javax.swing.SwingConstants; - -public class SeparatorMenuEntry extends MenuEntry { - - /** - * Returns a simple JMenu separator. - * @return A simple JMenu separator. - */ - @Override public JComponent getMenuBarComponent() { - return new JSeparator(SwingConstants.VERTICAL); - } - - /** - * Returns a simple JMenu separator. - * @return A simple JMenu separator. - */ - @Override public JComponent getMenuItemComponent() { - // TODO Auto-generated method stub - return new JSeparator(); - } - - /** - * Returns a simple JMenu separator. - * @return A simple JMenu separator. - */ - @Override public JComponent getToolbarComponent() { - // TODO Auto-generated method stub - return new JSeparator(); - } - - @Override protected void fireUpdate() { - /* no parameter influence JSeparator, - * not even the visibility - */ - } -} Deleted: trunk/crossfire/src/cfeditor/menu/SimpleMenuEntry.java =================================================================== --- trunk/crossfire/src/cfeditor/menu/SimpleMenuEntry.java 2006-12-22 21:25:53 UTC (rev 1214) +++ trunk/crossfire/src/cfeditor/menu/SimpleMenuEntry.java 2006-12-22 21:32:21 UTC (rev 1215) @@ -1,62 +0,0 @@ -/* - * Created on 12-déc.-2004 - * - * To change the template for this generated file go to - * Window>Preferences>Java>Code Generation>Code and Comments - */ - -package cfeditor.menu; - -import javax.swing.Icon; -import javax.swing.JButton; -import javax.swing.JComponent; -import javax.swing.JMenuItem; -import org.apache.log4j.Logger; -import org.jetbrains.annotations.Nullable; - -public class SimpleMenuEntry extends BasicMenuEntry { - - private Icon icon; - - private static final Logger log = Logger.getLogger(SimpleMenuEntry.class); - - public SimpleMenuEntry(final String name) { - super(name); - } - - @Override public JComponent getMenuItemComponent() { - log.debug("getMenuComponent()"); - final JMenuItem menu = new JMenuItem(); - menu.setIcon(icon); - initItem(menu); - return menu; - } - - @Override public JComponent getMenuBarComponent() { - log.debug("getMenuBarComponent()"); - final JMenuItem menu = new JMenuItem(); - initItem(menu); - menu.setAccelerator(null); - return menu; - } - - @Override @Nullable public JComponent getToolbarComponent() { - log.debug("getToolbarComponent()"); - final JButton button = new JButton(); - initItem(button); - return null; - } - - public void setIcon(final Icon icon) { - this.icon = icon; - fireUpdate(); - } - - @Override protected void updateItem(final JComponent item) { - defaultUpdateItem(item); - } - - @Override protected void update() { - getBasicAction().setIcon(icon); - } -} Deleted: trunk/crossfire/src/cfeditor/menu/SwitchedMenuEntry.java =================================================================== --- trunk/crossfire/src/cfeditor/menu/SwitchedMenuEntry.java 2006-12-22 21:25:53 UTC (rev 1214) +++ trunk/crossfire/src/cfeditor/menu/SwitchedMenuEntry.java 2006-12-22 21:32:21 UTC (rev 1215) @@ -1,61 +0,0 @@ -/* -* Java class "SwitchedMenuEntry.java" generated from Poseidon for UML. -* Poseidon for UML is developed by <A HREF="http://www.gentleware.com">Gentleware</A>. -* Generated with <A HREF="http://jakarta.apache.org/velocity/">velocity</A> template engine. -*/ - -package cfeditor.menu; - -import javax.swing.JComponent; - -public class SwitchedMenuEntry extends MenuEntry { - - private MenuEntry menuEntry; - - private boolean visible = false; - - /** - * Set the real MenuEntry which will be used by this - * wrapping MenuEntry. - * @param menuEntry The menuEntry to delegate calls to - */ - public void setMenuEntry(final MenuEntry menuEntry) { - this.menuEntry = menuEntry; - MenuManager.getMenuManager().fireMenuEntryChange(this, MenuChangeEvent.CHANGE_CONTENT); - updateVisibility(); - } - - /** - * Get the real MenuEntry which will be used by this wrapping MenuEntry. - * @return the MenuEntry calls are currently delegated to - */ - private MenuEntry getMenuEntry() { - return menuEntry; - } - - @Override public void setVisible(final boolean visible) { - this.visible = visible; - updateVisibility(); - } - - private void updateVisibility() { - super.setVisible(visible && menuEntry.isVisible()); - } - - @Override protected void fireUpdate() { - updateVisibility(); - menuEntry.fireUpdate(); - } - - @Override public JComponent getMenuBarComponent() { - return menuEntry.getMenuBarComponent(); - } - - @Override public JComponent getMenuItemComponent() { - return menuEntry.getMenuItemComponent(); - } - - @Override public JComponent getToolbarComponent() { - return menuEntry.getToolbarComponent(); - } -} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2006-12-22 21:25:53
|
Revision: 1214 http://svn.sourceforge.net/gridarta/?rev=1214&view=rev Author: akirschbaum Date: 2006-12-22 13:25:53 -0800 (Fri, 22 Dec 2006) Log Message: ----------- Remove unused code. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/IGUIConstants.java trunk/crossfire/src/cfeditor/gameobject/ArchetypeParser.java Removed Paths: ------------- trunk/crossfire/resource/conf/typenumbers.xml Deleted: trunk/crossfire/resource/conf/typenumbers.xml =================================================================== --- trunk/crossfire/resource/conf/typenumbers.xml 2006-12-22 21:25:11 UTC (rev 1213) +++ trunk/crossfire/resource/conf/typenumbers.xml 2006-12-22 21:25:53 UTC (rev 1214) @@ -1,162 +0,0 @@ -<?xml version="1.0" standalone="yes" ?> -<!-- - ################################################################# - # This file contains the typenumbers with their associated # - # names, from the file "define.h" in the crossfire package. # - # This file should be updated when new types have been defined. # - ################################################################# ---> -<!DOCTYPE typenumbers [ - <!ELEMENT typenumbers (type*)> - - <!ELEMENT type EMPTY> - <!ATTLIST type number CDATA #REQUIRED - name CDATA #REQUIRED> -]> - -<typenumbers> - <type number="0" name="*NONE*" /> - <type number="1" name="PLAYER" /> - <type number="2" name="TRANSPORT" /> - <type number="3" name="ROD" /> - <type number="4" name="TREASURE" /> - <type number="5" name="POTION" /> - <type number="6" name="FOOD" /> - <type number="7" name="POISON" /> - <type number="8" name="BOOK" /> - <type number="9" name="CLOCK" /> - <!--<type number="10" name="FBULLET" />--> - <!--<type number="11" name="FBALL" />--> - <type number="12" name="LIGHTNING" /> - <type number="13" name="ARROW" /> - <type number="14" name="BOW" /> - <type number="15" name="WEAPON" /> - <type number="16" name="ARMOUR" /> - <type number="17" name="PEDESTAL" /> - <type number="18" name="ALTAR" /> - <!--<type number="19" name="CONFUSION" />--> - <type number="20" name="LOCKED_DOOR" /> - <type number="21" name="SPECIAL_KEY" /> - <type number="22" name="MAP" /> - <type number="23" name="DOOR" /> - <type number="24" name="KEY" /> - <!--<type number="25" name="MMISSILE" />--> - <type number="26" name="TIMED_GATE" /> - <type number="27" name="TRIGGER" /> - <type number="28" name="GRIMREAPER" /> - <type number="29" name="MAGIC_EAR" /> - <type number="30" name="TRIGGER_BUTTON" /> - <type number="31" name="TRIGGER_ALTAR" /> - <type number="32" name="TRIGGER_PEDESTAL" /> - <type number="33" name="SHIELD" /> - <type number="34" name="HELMET" /> - <type number="35" name="HORN" /> - <type number="36" name="MONEY" /> - <type number="37" name="CLASS" /> - <type number="38" name="GRAVESTONE" /> - <type number="39" name="AMULET" /> - <type number="40" name="PLAYERMOVER" /> - <type number="41" name="TELEPORTER" /> - <type number="42" name="CREATOR" /> - <type number="43" name="SKILL" /> - <type number="44" name="EXPERIENCE" /> - <type number="45" name="EARTHWALL" /> - <type number="46" name="GOLEM" /> - <!--<type number="47" name="BOMB" />--> - <type number="48" name="THROWN_OBJ" /> - <type number="49" name="BLINDNESS" /> - <type number="50" name="GOD" /> - <type number="51" name="DETECTOR" /> - <type number="52" name="TRIGGER_MARKER" /> - <type number="53" name="DEAD_OBJECT" /> - <type number="54" name="DRINK" /> - <type number="55" name="MARKER" /> - <type number="56" name="HOLY_ALTAR" /> - <type number="57" name="PLAYER_CHANGER" /> - <type number="58" name="BATTLEGROUND" /> - <type number="59" name="PEACEMAKER" /> - <type number="60" name="GEM" /> - <!--<type number="61" name="FIRECHEST" />--> - <type number="62" name="FIREWALL" /> - <type number="63" name="ANVIL" /> - <type number="64" name="CHECK_INV" /> - <type number="65" name="MOOD_FLOOR" /> - <type number="66" name="EXIT" /> - <type number="67" name="ENCOUNTER" /> - <type number="68" name="SHOP_FLOOR" /> - <type number="69" name="SHOP_MAT" /> - <type number="70" name="RING" /> - <type number="71" name="FLOOR" /> - <type number="72" name="FLESH" /> - <type number="73" name="INORGANIC" /> - <type number="74" name="SKILL_TOOL" /> - <type number="75" name="LIGHTER" /> - <type number="76" name="TRAP_PART" /> - <type number="77" name="WALL" /> - <type number="78" name="LIGHT_SOURCE" /> - <type number="79" name="MISC_OBJECT" /> - <type number="80" name="MONSTER" /> - <type number="81" name="SPAWN_GENERATOR" /> - <type number="82" name="LAMP" /> - <type number="83" name="DUPLICATOR" /> - <type number="84" name="TOOL" /> - <type number="85" name="SPELLBOOK" /> - <type number="86" name="BUILDFAC" /> - <type number="87" name="CLOAK" /> - <!--<type number="88" name="CONE" />--> - <!--<type number="89" name="AURA" />--> - <type number="90" name="SPINNER" /> - <type number="91" name="GATE" /> - <type number="92" name="BUTTON" /> - <type number="93" name="CF_HANDLE" /> - <type number="94" name="HOLE" /> - <type number="95" name="TRAPDOOR" /> - <!--<type number="96" name="WORD_OF_RECALL" />--> - <!--<type number="97" name="PARAIMAGE" />--> - <type number="98" name="SIGN" /> - <type number="99" name="BOOTS" /> - <type number="100" name="GLOVES" /> - <type number="101" name="SPELL" /> - <type number="102" name="SPELL_EFFECT" /> - <type number="103" name="CONVERTER" /> - <type number="104" name="BRACERS" /> - <type number="105" name="POISONING" /> - <type number="106" name="SAVEBED" /> - <type number="107" name="POISONCLOUD" /> - <type number="108" name="FIREHOLES" /> - <type number="109" name="WAND" /> - <!--<type number="110" name="ABILITY" />--> - <type number="111" name="SCROLL" /> - <type number="112" name="DIRECTOR" /> - <type number="113" name="GIRDLE" /> - <type number="114" name="FORCE" /> - <type number="115" name="POTION_EFFECT" /> - - <type number="121" name="CLOSE_CON" /> - <type number="122" name="CONTAINER" /> - <type number="123" name="ARMOUR_IMPROVER" /> - <type number="124" name="WEAPON_IMPROVER" /> - - <type number="130" name="SKILLSCROLL" /> - - <type number="138" name="DEEP_SWAMP" /> - <type number="139" name="IDENTIFY_ALTAR" /> - - <!--<type number="141" name="CANCELLATION" />--> - - <type number="150" name="MENU" /> - <!--<type number="151" name="BALL_LIGHTNING" />--> - - <!--<type number="153" name="SWARM_SPELL" />--> - <type number="154" name="RUNE" /> - <type number="155" name="TRAP" /> - <type number="156" name="POWER_CRYSTAL" /> - <type number="157" name="CORPSE" /> - <type number="158" name="DISEASE" /> - <type number="159" name="SYMPTOM" /> - <type number="160" name="BUILDER" /> - <type number="161" name="MATERIAL" /> - <type number="162" name="GPS" /> - <type number="163" name="ITEM_TRANSFORMER" /> - <type number="164" name="QUEST" /> -</typenumbers> Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2006-12-22 21:25:11 UTC (rev 1213) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2006-12-22 21:25:53 UTC (rev 1214) @@ -253,10 +253,6 @@ animationObjects = new AnimationObjects(); faceObjects = new FaceObjects(); - // read in the type & type field definitions - archetypeParser.loadTypeNumbers(); - //loadTypeDef(); - // load the list with archtype-data from "types.txt" typeList = new CFArchTypeList(); Modified: trunk/crossfire/src/cfeditor/IGUIConstants.java =================================================================== --- trunk/crossfire/src/cfeditor/IGUIConstants.java 2006-12-22 21:25:11 UTC (rev 1213) +++ trunk/crossfire/src/cfeditor/IGUIConstants.java 2006-12-22 21:25:53 UTC (rev 1214) @@ -141,8 +141,6 @@ // name of the configuration files: String SPELL_FILE = "spells.xml"; // spell-numbers - String TYPENR_FILE = "typenumbers.xml"; // type-numbers - String TYPEDEF_FILE = "types.xml"; // type-definitions String ARCH_FILE = "archetypes"; // file with all arches Modified: trunk/crossfire/src/cfeditor/gameobject/ArchetypeParser.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/ArchetypeParser.java 2006-12-22 21:25:11 UTC (rev 1213) +++ trunk/crossfire/src/cfeditor/gameobject/ArchetypeParser.java 2006-12-22 21:25:53 UTC (rev 1214) @@ -37,11 +37,6 @@ import net.sf.gridarta.gameobject.anim.DuplicateAnimationException; import net.sf.gridarta.io.IOUtils; import org.apache.log4j.Logger; -import org.jdom.DataConversionException; -import org.jdom.Document; -import org.jdom.Element; -import org.jdom.JDOMException; -import org.jdom.input.SAXBuilder; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -59,9 +54,6 @@ /** Logger. */ private static final Logger log = Logger.getLogger(ArchetypeParser.class); - // table with type numbers as keys (Integer), and type names as values (String) - private Map<Integer,String> archTypeNumbers; - private final CMainControl mainControl; /** @@ -70,86 +62,8 @@ */ public ArchetypeParser(final CMainControl mainControl) { this.mainControl = mainControl; - archTypeNumbers = null; } - /** - * Parse the typenumbers file (associate names with type numbers) - * Type numbers and names are stored as key-value pairs in the - * Hashtable 'archTypeNumbers'. - */ - public void loadTypeNumbers() { - archTypeNumbers = new HashMap<Integer,String>(); - - try { - // open reading stream to the spells xml file - final String baseDir = IGUIConstants.CONFIG_DIR; - final BufferedReader reader = IOUtils.createReader(baseDir, IGUIConstants.TYPENR_FILE); - try { - - // parse xml document - final SAXBuilder builder = new SAXBuilder(); - builder.setValidation(true); - final Document doc = builder.build(reader); - - // retrieve the spell data from the xml - final Element root = doc.getRootElement(); - if (root == null || !"typenumbers".equalsIgnoreCase(root.getName())) { - log.warn("File '" + IGUIConstants.TYPENR_FILE + "' lacks root element 'typenumbers'."); - } else { - final List types = root.getChildren("type"); - if (types == null || types.size() == 0) { - log.warn("File '" + IGUIConstants.TYPENR_FILE + "' has no content."); - } else { - // process all 'type' elements from the xml file - int i; - for (i = 0; i < types.size(); i++) { - final Element typeElem = (Element) types.get(i); - - if (typeElem.getAttribute("number") == null) { - log.warn("In File '" + IGUIConstants.TYPENR_FILE + "': Found 'type' element without 'number'"); - } else if (typeElem.getAttribute("name") == null) { - log.warn("In File '" + IGUIConstants.TYPENR_FILE + "': Found 'type' element without 'name'"); - } else { - try { - // parse type number and -name, then add it to the table 'archTypeNumbers' - archTypeNumbers.put(typeElem.getAttribute("number").getIntValue(), typeElem.getAttribute("name").getValue()); - } catch (final DataConversionException de) { - log.error("In '" + IGUIConstants.TYPENR_FILE + "':\n type number '" + typeElem.getAttribute("number").getValue() + "' is not an integer."); - } - } - } - - // loading successful - if (log.isInfoEnabled()) { - log.info("" + i + " typenumbers loaded."); - } - } - } - } finally { - reader.close(); - } - } catch (final JDOMException e) { - log.error("Parsing error in '" + IGUIConstants.TYPENR_FILE + "'", e); - } catch (final FileNotFoundException e) { - log.error("Cannot read file '" + IGUIConstants.TYPENR_FILE + "'!", e); - } catch (final IOException e) { - log.error("Error while reading file '" + IGUIConstants.TYPENR_FILE + "'!", e); - } - } - - /** - * Lookup the name of an archtype. - * @param index type number - * @return name of this type, as defined in "typenumbers.xml" - */ - public String getArchTypeName(final int index) { - if (archTypeNumbers != null && archTypeNumbers.containsKey(index)) { - return archTypeNumbers.get(index); - } - return "*UNKNOWN" + index + "*"; // this type is unknown - } - /** {@inheritDoc} */ public void parseArchetype(final String fname, @NotNull final String panelName, @NotNull final String folderName) { //Open the file for reading This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2006-12-22 21:25:14
|
Revision: 1213 http://svn.sourceforge.net/gridarta/?rev=1213&view=rev Author: akirschbaum Date: 2006-12-22 13:25:11 -0800 (Fri, 22 Dec 2006) Log Message: ----------- Remove commented code. Modified Paths: -------------- trunk/daimonin/src/daieditor/CMainControl.java Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2006-12-22 21:19:33 UTC (rev 1212) +++ trunk/daimonin/src/daieditor/CMainControl.java 2006-12-22 21:25:11 UTC (rev 1213) @@ -430,9 +430,6 @@ animationObjects = new AnimationObjects(); faceObjects = new FaceObjects(); - // read in the type & type field definitions - //loadTypeDef(); - // load the list with archtype-data from "types.txt" typeList = new CFArchTypeList(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2006-12-22 21:19:33
|
Revision: 1212 http://svn.sourceforge.net/gridarta/?rev=1212&view=rev Author: akirschbaum Date: 2006-12-22 13:19:33 -0800 (Fri, 22 Dec 2006) Log Message: ----------- Remove unused variable. Modified Paths: -------------- trunk/daimonin/src/daieditor/IGUIConstants.java Modified: trunk/daimonin/src/daieditor/IGUIConstants.java =================================================================== --- trunk/daimonin/src/daieditor/IGUIConstants.java 2006-12-22 21:14:00 UTC (rev 1211) +++ trunk/daimonin/src/daieditor/IGUIConstants.java 2006-12-22 21:19:33 UTC (rev 1212) @@ -136,8 +136,6 @@ // name of the configuration files: String SPELL_FILE = "spells.xml"; // spell-numbers - String TYPENR_FILE = "typenumbers.xml"; // type-numbers - String TYPEDEF_FILE = "types.xml"; // type-definitions String ARCHDEF_FILE = "archdef.dat"; // position-data of multiparts This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2006-12-22 21:14:04
|
Revision: 1211 http://svn.sourceforge.net/gridarta/?rev=1211&view=rev Author: akirschbaum Date: 2006-12-22 13:14:00 -0800 (Fri, 22 Dec 2006) Log Message: ----------- Unify code. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CFTreasureListTree.java Modified: trunk/crossfire/src/cfeditor/CFTreasureListTree.java =================================================================== --- trunk/crossfire/src/cfeditor/CFTreasureListTree.java 2006-12-22 21:12:21 UTC (rev 1210) +++ trunk/crossfire/src/cfeditor/CFTreasureListTree.java 2006-12-22 21:14:00 UTC (rev 1211) @@ -260,7 +260,7 @@ // set accurate type of treausrelist (one/multi) node.getTreasureObj().setType(realNode.getTreasureObj().getType()); - for (Enumeration clist = realNode.children(); clist != null && clist.hasMoreElements();) { + for (Enumeration clist = realNode.children(); clist.hasMoreElements();) { node.add(((TreasureTreeNode) clist.nextElement()).getClone()); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2006-12-22 21:12:20
|
Revision: 1210 http://svn.sourceforge.net/gridarta/?rev=1210&view=rev Author: akirschbaum Date: 2006-12-22 13:12:21 -0800 (Fri, 22 Dec 2006) Log Message: ----------- Unify code. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CFTreasureListTree.java trunk/daimonin/src/daieditor/CFTreasureListTree.java Modified: trunk/crossfire/src/cfeditor/CFTreasureListTree.java =================================================================== --- trunk/crossfire/src/cfeditor/CFTreasureListTree.java 2006-12-22 21:07:13 UTC (rev 1209) +++ trunk/crossfire/src/cfeditor/CFTreasureListTree.java 2006-12-22 21:12:21 UTC (rev 1210) @@ -59,6 +59,7 @@ import javax.swing.tree.TreePath; import net.sf.gridarta.help.Help; import net.sf.gridarta.io.IOUtils; +import net.sf.japi.util.EnumerationIterator; import net.sf.japi.swing.ActionFactory; import org.apache.log4j.Logger; import org.jetbrains.annotations.Nullable; @@ -244,8 +245,8 @@ // set accurate type of treausrelist (one/multi) node.getTreasureObj().setType(realNode.getTreasureObj().getType()); - for (Enumeration clist = realNode.children(); clist != null && clist.hasMoreElements();) { - node.add(((TreasureTreeNode) clist.nextElement()).getClone()); + for (final TreasureTreeNode ttn : new EnumerationIterator<TreasureTreeNode>(realNode.children())) { + node.add(ttn.getClone()); } } } Modified: trunk/daimonin/src/daieditor/CFTreasureListTree.java =================================================================== --- trunk/daimonin/src/daieditor/CFTreasureListTree.java 2006-12-22 21:07:13 UTC (rev 1209) +++ trunk/daimonin/src/daieditor/CFTreasureListTree.java 2006-12-22 21:12:21 UTC (rev 1210) @@ -233,12 +233,9 @@ // set accurate type of treausrelist (one/multi) node.getTreasureObj().setType(realNode.getTreasureObj().getType()); - for (TreasureTreeNode ttn : new EnumerationIterator<TreasureTreeNode>(realNode.children())) { + for (final TreasureTreeNode ttn : new EnumerationIterator<TreasureTreeNode>(realNode.children())) { node.add(ttn.getClone()); } -// for (Enumeration clist = realNode.children(); clist != null & clist.hasMoreElements();) { -// node.add(((TreasureTreeNode) clist.nextElement()).getClone()); -// } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |