Gridarta Editor
MapFolderTreeAction.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.mapfiles;
21 
22 import java.awt.event.ActionEvent;
23 import javax.swing.AbstractAction;
24 import javax.swing.AbstractButton;
28 import org.jetbrains.annotations.NotNull;
29 import org.jetbrains.annotations.Nullable;
30 
36 public class MapFolderTreeAction<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> extends AbstractAction {
37 
41  private static final long serialVersionUID = 1L;
42 
46  @NotNull
48 
52  @NotNull
54 
58  @NotNull
59  private final AbstractButton menuItem;
60 
67  public MapFolderTreeAction(@NotNull final MapFolderTree<G, A, R> mapFolderTree, @NotNull final MapFolder<G, A, R> mapFolder, @NotNull final AbstractButton menuItem) {
68  super(mapFolder.getName());
69  this.mapFolderTree = mapFolderTree;
70  this.mapFolder = mapFolder;
71  this.menuItem = menuItem;
72  }
73 
74  @Override
75  public void actionPerformed(@NotNull final ActionEvent e) {
78  }
79 
80  @Override
81  public boolean equals(@Nullable final Object obj) {
82  return obj instanceof MapFolderTreeAction && mapFolder == ((MapFolderTreeAction<?, ?, ?>) obj).mapFolder;
83  }
84 
85  @Override
86  public int hashCode() {
87  return mapFolder.getDir().hashCode();
88  }
89 
90  @NotNull
91  @Override
93  try {
94  //noinspection unchecked
95  return (MapFolderTreeAction<G, A, R>) super.clone();
96  } catch (final CloneNotSupportedException ex) {
97  throw new AssertionError(ex);
98  }
99  }
100 
101 }
net.sf.gridarta.gui.mapfiles.MapFolderTreeAction.mapFolder
final MapFolder< G, A, R > mapFolder
The folder to activate.
Definition: MapFolderTreeAction.java:53
net.sf.gridarta.gui.mapfiles.MapFolderTreeAction.menuItem
final AbstractButton menuItem
The associated menu item.
Definition: MapFolderTreeAction.java:59
net.sf.gridarta
Base package of all Gridarta classes.
net.sf.gridarta.gui.mapfiles.MapFolderTree< G, A, R >
net.sf
net.sf.gridarta.gui.mapfiles.MapFolderTreeAction.hashCode
int hashCode()
Definition: MapFolderTreeAction.java:86
net.sf.gridarta.gui.mapfiles.MapFolderTreeAction.serialVersionUID
static final long serialVersionUID
The serial version UID.
Definition: MapFolderTreeAction.java:41
net.sf.gridarta.gui.mapfiles.MapFolderTreeAction.equals
boolean equals(@Nullable final Object obj)
Definition: MapFolderTreeAction.java:81
net.sf.gridarta.model.archetype
Definition: AbstractArchetype.java:20
net.sf.gridarta.model.gameobject.GameObject
Reflects a game object (object on a map).
Definition: GameObject.java:36
net.sf.gridarta.gui.mapfiles.MapFolderTreeAction.actionPerformed
void actionPerformed(@NotNull final ActionEvent e)
Definition: MapFolderTreeAction.java:75
net.sf.gridarta.gui.mapfiles.MapFolder.getDir
File getDir()
Returns the base directory.
Definition: MapFolder.java:143
net.sf.gridarta.model.gameobject
GameObjects are the objects based on Archetypes found on maps.
Definition: AbstractGameObject.java:20
net
net.sf.gridarta.gui.mapfiles.MapFolderTreeAction.clone
MapFolderTreeAction< G, A, R > clone()
Definition: MapFolderTreeAction.java:92
net.sf.gridarta.gui.mapfiles.MapFolder.getName
String getName()
Returns the name.
Definition: MapFolder.java:130
net.sf.gridarta.model.maparchobject.MapArchObject
Interface for MapArchObjects.
Definition: MapArchObject.java:40
net.sf.gridarta.gui.mapfiles.MapFolder< G, A, R >
net.sf.gridarta.gui.mapfiles.MapFolderTreeAction.mapFolderTree
final MapFolderTree< G, A, R > mapFolderTree
The model the mapFolder is part of.
Definition: MapFolderTreeAction.java:47
net.sf.gridarta.gui.mapfiles.MapFolderTreeAction.MapFolderTreeAction
MapFolderTreeAction(@NotNull final MapFolderTree< G, A, R > mapFolderTree, @NotNull final MapFolder< G, A, R > mapFolder, @NotNull final AbstractButton menuItem)
Creates a new instance.
Definition: MapFolderTreeAction.java:67
net.sf.gridarta.model
net.sf.gridarta.model.archetype.Archetype
Reflects an Archetype.
Definition: Archetype.java:41
net.sf.gridarta.gui.mapfiles.MapFolderTree.getActiveMapFolder
MapFolder< G, A, R > getActiveMapFolder()
Returns the active map folder.
Definition: MapFolderTree.java:147
net.sf.gridarta.model.maparchobject
Definition: AbstractMapArchObject.java:20
net.sf.gridarta.gui.mapfiles.MapFolderTree.setActiveMapFolder
synchronized void setActiveMapFolder(@NotNull final MapFolder< G, A, R > mapFolder)
Sets the active map folder.
Definition: MapFolderTree.java:157
net.sf.gridarta.gui.mapfiles.MapFolderTreeAction
An action for the entry in the pickmaps folder menu.
Definition: MapFolderTreeAction.java:36