Gridarta Editor
MapMenuUtils.java
Go to the documentation of this file.
1 /*
2  * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games.
3  * Copyright (C) 2000-2023 The Gridarta Developers.
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License along
16  * with this program; if not, write to the Free Software Foundation, Inc.,
17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18  */
19 
20 package net.sf.gridarta.gui.mapmenu;
21 
22 import javax.swing.tree.DefaultMutableTreeNode;
23 import javax.swing.tree.MutableTreeNode;
25 import org.jetbrains.annotations.NotNull;
26 
31 public class MapMenuUtils {
32 
36  private MapMenuUtils() {
37  }
38 
45  public static void removeMap(@NotNull final MutableTreeNode treeNode, @NotNull final MapFile mapFile) {
46  for (int i = treeNode.getChildCount() - 1; i >= 0; i--) {
47  final DefaultMutableTreeNode treeNode2 = (DefaultMutableTreeNode) treeNode.getChildAt(i);
48  final MapMenuEntry mapMenuEntry = (MapMenuEntry) treeNode2.getUserObject();
49  if (mapMenuEntry instanceof MapMenuEntryMap) {
50  final MapMenuEntryMap mapMenuEntryMap = (MapMenuEntryMap) mapMenuEntry;
51  if (mapMenuEntryMap.getMapFile().equals(mapFile)) {
52  treeNode.remove(i);
53  }
54  }
55  }
56  }
57 
58 }
net.sf.gridarta.gui.mapmenu.MapMenuEntry
Abstract base class for recent and bookmark menu entries.
Definition: MapMenuEntry.java:29
net.sf.gridarta
Base package of all Gridarta classes.
net.sf
net.sf.gridarta.model.mapmodel
Definition: AboveFloorInsertionMode.java:20
net.sf.gridarta.gui.mapmenu.MapMenuUtils
Utility class for MapMenu related functions.
Definition: MapMenuUtils.java:31
net.sf.gridarta.model.mapmodel.MapFile.equals
boolean equals(@Nullable final Object obj)
Definition: MapFile.java:122
net
net.sf.gridarta.gui.mapmenu.MapMenuUtils.removeMap
static void removeMap(@NotNull final MutableTreeNode treeNode, @NotNull final MapFile mapFile)
Removes all entries for a given map file.
Definition: MapMenuUtils.java:45
net.sf.gridarta.gui.mapmenu.MapMenuUtils.MapMenuUtils
MapMenuUtils()
Private constructor to prevent instantiation.
Definition: MapMenuUtils.java:36
net.sf.gridarta.model.mapmodel.MapFile
The location of a map file with a map directory.
Definition: MapFile.java:31
net.sf.gridarta.gui.mapmenu.MapMenuEntryMap.getMapFile
MapFile getMapFile()
Returns the map file.
Definition: MapMenuEntryMap.java:57
net.sf.gridarta.model
net.sf.gridarta.gui.mapmenu.MapMenuEntryMap
A MapMenuEntry that represents a map.
Definition: MapMenuEntryMap.java:29