Gridarta Editor
AbstractPickmapSettings.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.model.pickmapsettings;
21 
23 import org.jetbrains.annotations.NotNull;
24 
29 public abstract class AbstractPickmapSettings implements PickmapSettings {
30 
34  @NotNull
36 
40  private boolean locked = loadLocked();
41 
42  @Override
43  public void addPickmapSettingsListener(@NotNull final PickmapSettingsListener listener) {
44  listenerList.add(listener);
45  }
46 
47  @Override
48  public void removePickmapSettingsListener(@NotNull final PickmapSettingsListener listener) {
49  listenerList.remove(listener);
50  }
51 
52  @Override
53  public boolean isLocked() {
54  return locked;
55  }
56 
57  @Override
58  public void setLocked(final boolean locked) {
59  if (this.locked == locked) {
60  return;
61  }
62 
63  this.locked = locked;
64  saveLocked(locked);
66  }
67 
71  private void fireLockedChanged() {
72  for (final PickmapSettingsListener listener : listenerList.getListeners()) {
73  listener.lockedChanged(locked);
74  }
75  }
76 
81  protected abstract boolean loadLocked();
82 
87  protected abstract void saveLocked(boolean locked);
88 
89 }
Interface for event listeners that are interested in changes on PickmapSettings.
abstract boolean loadLocked()
Loads the default value for locked.
T [] getListeners()
Returns an array of all the listeners.
boolean isLocked()
Returns whether pickmaps are immutable.
Base package of all Gridarta classes.
abstract void saveLocked(boolean locked)
Saves the locked value.
void setLocked(final boolean locked)
Sets whether pickmaps are immutable.
void remove(@NotNull final T listener)
Removes a listener.
Abstract base class for PickmapSettings implementations.
final EventListenerList2< PickmapSettingsListener > listenerList
The MapViewSettingsListeners to inform of changes.
void add(@NotNull final T listener)
Adds a listener.
void fireLockedChanged()
Informs all registered listeners that the immutable state has changed.
Type-safe version of EventListenerList.
void removePickmapSettingsListener(@NotNull final PickmapSettingsListener listener)
Removes a PickmapSettingsListener to be notified about changes.
void addPickmapSettingsListener(@NotNull final PickmapSettingsListener listener)
Adds a PickmapSettingsListener to be notified about changes.
Container for settings that affect pickmaps.