Gridarta Editor
ReplaceDialogManager.java
Go to the documentation of this file.
1 /*
2  * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games.
3  * Copyright (C) 2000-2015 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.dialog.replace;
21 
22 import java.awt.Component;
33 import org.jetbrains.annotations.NotNull;
34 import org.jetbrains.annotations.Nullable;
35 
40 public class ReplaceDialogManager<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> {
41 
45  @Nullable
47 
51  @NotNull
52  private final Component parent;
53 
57  @NotNull
59 
63  @NotNull
65 
69  @NotNull
71 
75  @NotNull
77 
88  public ReplaceDialogManager(@NotNull final Component parent, @NotNull final CopyBuffer<G, A, R> copyBuffer, @NotNull final ObjectChooser<G, A, R> objectChooser, @NotNull final MapViewManager<G, A, R> mapViewManager, @NotNull final FaceObjectProviders faceObjectProviders, @NotNull final InsertionModeSet<G, A, R> insertionModeSet) {
89  this.parent = parent;
90  this.copyBuffer = copyBuffer;
91  this.objectChooser = objectChooser;
92  this.faceObjectProviders = faceObjectProviders;
93  this.insertionModeSet = insertionModeSet;
94 
95  final MapViewManagerListener<G, A, R> mapViewManagerListener = new MapViewManagerListener<G, A, R>() {
96 
97  @Override
98  public void activeMapViewChanged(@Nullable final MapView<G, A, R> mapView) {
99  // ignore
100  }
101 
102  @Override
103  public void mapViewCreated(@NotNull final MapView<G, A, R> mapView) {
104  // ignore
105  }
106 
107  @Override
108  public void mapViewClosing(@NotNull final MapView<G, A, R> mapView) {
109  disposeDialog(mapView);
110  }
111 
112  };
113  mapViewManager.addMapViewManagerListener(mapViewManagerListener);
114  }
115 
121  private void disposeDialog(@NotNull final MapView<G, A, R> mapView) {
122  if (instance != null) {
123  instance.dispose(mapView);
124  }
125  }
126 
131  public void showDialog(@NotNull final MapView<G, A, R> mapView) {
132  if (instance == null) {
134  }
135  instance.display(mapView);
136  }
137 
138 }
Graphical User Interface of Gridarta.
void disposeDialog(@NotNull final MapView< G, A, R > mapView)
Dispose the replace dialog.
void display(@NotNull final MapView< G, A, R > mapView)
Replace objects on the map.
void dispose(@NotNull final MapView< G, A, R > mapView)
Disposes the replace dialog.
Base package of all Gridarta classes.
Reflects a game object (object on a map).
Definition: GameObject.java:36
GameObjects are the objects based on Archetypes found on maps.
final InsertionModeSet< G, A, R > insertionModeSet
The InsertionModeSet to use.
final FaceObjectProviders faceObjectProviders
The FaceObjectProviders for looking up faces.
Interface for listeners interested in events related to MapViewManager instances. ...
void showDialog(@NotNull final MapView< G, A, R > mapView)
Displays the replace dialog.
Base classes for rendering maps.
ReplaceDialog< G, A, R > instance
Singleton Instance.
ReplaceDialogManager(@NotNull final Component parent, @NotNull final CopyBuffer< G, A, R > copyBuffer, @NotNull final ObjectChooser< G, A, R > objectChooser, @NotNull final MapViewManager< G, A, R > mapViewManager, @NotNull final FaceObjectProviders faceObjectProviders, @NotNull final InsertionModeSet< G, A, R > insertionModeSet)
Creates a new instance.
final CopyBuffer< G, A, R > copyBuffer
The CopyBuffer.
Provider for faces of GameObjects and Archetypes.
final ObjectChooser< G, A, R > objectChooser
The ObjectChooser to use.
The face is the appearance of an object.
A map view consists of a map grid and a map cursor, and is attached to a map control.
Definition: MapView.java:43
Common base interface for ObjectChoosers.
final Component parent
The parent component for dialogs.
Common base implementation of CopyBuffer.
Definition: CopyBuffer.java:52