Gridarta Editor
GoMapListModel.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.dialog.gomap;
21 
22 import javax.swing.DefaultListModel;
24 
29 public class GoMapListModel extends DefaultListModel<MapFile> {
30 
34  private static final long serialVersionUID = 1L;
35 
39  private boolean enabled = true;
40 
45  private int index0;
46 
51  private int index1;
52 
53  @Override
54  protected void fireIntervalAdded(final Object source, final int index0, final int index1) {
55  if (!enabled) {
56  if (index0 < this.index0) {
57  this.index0 = index0;
58  }
59  if (index1 > this.index1) {
60  this.index1 = index1;
61  }
62  return;
63  }
64 
65  super.fireIntervalAdded(source, index0, index1);
66  }
67 
72  public void enable(final boolean enabled) {
73  if (this.enabled == enabled) {
74  return;
75  }
76 
77  this.enabled = enabled;
78  if (!enabled) {
79  index0 = Integer.MAX_VALUE;
80  index1 = Integer.MIN_VALUE;
81  } else if (index0 <= index1) {
82  super.fireIntervalAdded(this, index0, index1);
83  }
84  }
85 
86 }
net.sf.gridarta.gui.dialog.gomap.GoMapListModel.index1
int index1
The last index of the range of indexes to notify as soon enabled is set.
Definition: GoMapListModel.java:51
net.sf.gridarta
Base package of all Gridarta classes.
net.sf
net.sf.gridarta.model.mapmodel
Definition: AboveFloorInsertionMode.java:20
net
net.sf.gridarta.gui.dialog.gomap.GoMapListModel.fireIntervalAdded
void fireIntervalAdded(final Object source, final int index0, final int index1)
Definition: GoMapListModel.java:54
net.sf.gridarta.gui.dialog.gomap.GoMapListModel.index0
int index0
The first index of the range of indexes to notify as soon {} is set.
Definition: GoMapListModel.java:45
net.sf.gridarta.gui.dialog.gomap.GoMapListModel.serialVersionUID
static final long serialVersionUID
The serial version UID.
Definition: GoMapListModel.java:34
net.sf.gridarta.model.mapmodel.MapFile
The location of a map file with a map directory.
Definition: MapFile.java:31
net.sf.gridarta.gui.dialog.gomap.GoMapListModel.enable
void enable(final boolean enabled)
Enables or disables notification of listeners.
Definition: GoMapListModel.java:72
net.sf.gridarta.model
net.sf.gridarta.gui.dialog.gomap.GoMapListModel.enabled
boolean enabled
Whether this notifying listeners is enabled.
Definition: GoMapListModel.java:39
net.sf.gridarta.gui.dialog.gomap.GoMapListModel
A DefaultListModel that can be disabled during updates.
Definition: GoMapListModel.java:29