mirror of
https://github.com/OMGeeky/ATCS.git
synced 2025-12-26 23:57:25 +01:00
change more ListModel implementations to more specific implementations
like ListenerListModel, ListenerCollectionModel or OrderedListenerListModel
This commit is contained in:
@@ -15,10 +15,7 @@ import java.awt.event.MouseEvent;
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import java.util.regex.Matcher;
|
||||
|
||||
@@ -1028,7 +1025,7 @@ public abstract class Editor extends JPanel implements ProjectElementListener {
|
||||
}
|
||||
|
||||
|
||||
public static class GDEBacklinksListModel implements ListModel<GameDataElement> {
|
||||
public static class GDEBacklinksListModel implements ListenerCollectionModel<GameDataElement> {
|
||||
|
||||
GameDataElement source;
|
||||
|
||||
@@ -1046,38 +1043,19 @@ public abstract class Editor extends JPanel implements ProjectElementListener {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSize() {
|
||||
return source.getBacklinks().size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public GameDataElement getElementAt(int index) {
|
||||
for (GameDataElement gde : source.getBacklinks()) {
|
||||
if (index == 0) return gde;
|
||||
index --;
|
||||
}
|
||||
return null;
|
||||
public Collection<GameDataElement> getElements() {
|
||||
return source.getBacklinks();
|
||||
}
|
||||
|
||||
List<ListDataListener> listeners = new CopyOnWriteArrayList<ListDataListener>();
|
||||
|
||||
@Override
|
||||
public void addListDataListener(ListDataListener l) {
|
||||
listeners.add(l);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeListDataListener(ListDataListener l) {
|
||||
listeners.remove(l);
|
||||
}
|
||||
|
||||
public void fireListChanged() {
|
||||
for (ListDataListener l : listeners) {
|
||||
l.contentsChanged(new ListDataEvent(this, ListDataEvent.CONTENTS_CHANGED, 0, this.getSize()));
|
||||
}
|
||||
public List<ListDataListener> getListeners() {
|
||||
return listeners;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@SuppressWarnings({"rawtypes", "unchecked"})
|
||||
|
||||
@@ -13,6 +13,7 @@ import java.io.FileNotFoundException;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
@@ -583,46 +584,24 @@ public class JSONImportWizard extends JDialog {
|
||||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
public static class GDEListModel implements ListModel {
|
||||
public static class GDEListModel implements ListenerCollectionModel {
|
||||
|
||||
List<? extends Object> source;
|
||||
|
||||
public GDEListModel(List<? extends Object> source) {
|
||||
this.source = source;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSize() {
|
||||
return source.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getElementAt(int index) {
|
||||
for (Object obj : source) {
|
||||
if (index == 0) return obj;
|
||||
index --;
|
||||
}
|
||||
return null;
|
||||
public Collection getElements() {
|
||||
return source;
|
||||
}
|
||||
|
||||
List<ListDataListener> listeners = new CopyOnWriteArrayList<ListDataListener>();
|
||||
|
||||
@Override
|
||||
public void addListDataListener(ListDataListener l) {
|
||||
listeners.add(l);
|
||||
public List<ListDataListener> getListeners() {
|
||||
return listeners;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeListDataListener(ListDataListener l) {
|
||||
listeners.remove(l);
|
||||
}
|
||||
|
||||
public void fireListChanged() {
|
||||
for (ListDataListener l : listeners) {
|
||||
l.contentsChanged(new ListDataEvent(this, ListDataEvent.CONTENTS_CHANGED, 0, this.getSize()));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@ import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
||||
import javax.swing.ButtonGroup;
|
||||
import javax.swing.DefaultListCellRenderer;
|
||||
@@ -20,10 +19,7 @@ import javax.swing.JRadioButton;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JSpinner;
|
||||
import javax.swing.JTextField;
|
||||
import javax.swing.ListModel;
|
||||
import javax.swing.ListSelectionModel;
|
||||
import javax.swing.event.ListDataEvent;
|
||||
import javax.swing.event.ListDataListener;
|
||||
import javax.swing.event.ListSelectionEvent;
|
||||
import javax.swing.event.ListSelectionListener;
|
||||
|
||||
|
||||
@@ -6,7 +6,6 @@ import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
||||
import javax.swing.ButtonGroup;
|
||||
import javax.swing.DefaultListCellRenderer;
|
||||
@@ -21,10 +20,7 @@ import javax.swing.JRadioButton;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JSpinner;
|
||||
import javax.swing.JTextField;
|
||||
import javax.swing.ListModel;
|
||||
import javax.swing.ListSelectionModel;
|
||||
import javax.swing.event.ListDataEvent;
|
||||
import javax.swing.event.ListDataListener;
|
||||
import javax.swing.event.ListSelectionEvent;
|
||||
import javax.swing.event.ListSelectionListener;
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@ import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
||||
import javax.swing.DefaultListCellRenderer;
|
||||
import javax.swing.ImageIcon;
|
||||
@@ -18,17 +17,13 @@ import javax.swing.JScrollPane;
|
||||
import javax.swing.JSpinner;
|
||||
import javax.swing.JTextArea;
|
||||
import javax.swing.JTextField;
|
||||
import javax.swing.ListModel;
|
||||
import javax.swing.ListSelectionModel;
|
||||
import javax.swing.event.ListDataEvent;
|
||||
import javax.swing.event.ListDataListener;
|
||||
import javax.swing.event.ListSelectionEvent;
|
||||
import javax.swing.event.ListSelectionListener;
|
||||
|
||||
import com.gpl.rpg.atcontentstudio.ATContentStudio;
|
||||
import com.gpl.rpg.atcontentstudio.model.GameDataElement;
|
||||
import com.gpl.rpg.atcontentstudio.model.ProjectTreeNode;
|
||||
import com.gpl.rpg.atcontentstudio.model.gamedata.Common;
|
||||
import com.gpl.rpg.atcontentstudio.model.gamedata.Quest;
|
||||
import com.gpl.rpg.atcontentstudio.model.gamedata.QuestStage;
|
||||
import com.gpl.rpg.atcontentstudio.ui.*;
|
||||
|
||||
@@ -19,10 +19,7 @@ import java.awt.event.MouseEvent;
|
||||
import java.awt.event.MouseMotionAdapter;
|
||||
import java.awt.event.MouseMotionListener;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
||||
import javax.swing.BorderFactory;
|
||||
@@ -1071,7 +1068,7 @@ public class TMXMapEditor extends Editor implements TMXMap.MapChangedOnDiskListe
|
||||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
public class LayerListModel implements ListModel {
|
||||
public class LayerListModel implements ListenerListModel {
|
||||
|
||||
public TMXMap map;
|
||||
|
||||
@@ -1092,40 +1089,28 @@ public class TMXMapEditor extends Editor implements TMXMap.MapChangedOnDiskListe
|
||||
|
||||
public void objectChanged(tiled.core.MapLayer layer) {
|
||||
int index = map.tmxMap.getLayerIndex(layer);
|
||||
for (ListDataListener l : listeners) {
|
||||
l.contentsChanged(new ListDataEvent(this, ListDataEvent.CONTENTS_CHANGED, index, index));
|
||||
}
|
||||
notifyListeners(ListDataEvent.CONTENTS_CHANGED, index, index);
|
||||
|
||||
}
|
||||
|
||||
public void addObject(tiled.core.MapLayer layer) {
|
||||
map.addLayer(layer);
|
||||
int index = map.tmxMap.getLayerIndex(layer);
|
||||
for (ListDataListener l : listeners) {
|
||||
l.intervalAdded(new ListDataEvent(this, ListDataEvent.INTERVAL_ADDED, index, index));
|
||||
}
|
||||
notifyListeners(ListDataEvent.INTERVAL_ADDED, index, index);
|
||||
}
|
||||
|
||||
public void removeObject(tiled.core.MapLayer layer) {
|
||||
int index = map.tmxMap.getLayerIndex(layer);
|
||||
map.removeLayer(layer);
|
||||
for (ListDataListener l : listeners) {
|
||||
l.intervalRemoved(new ListDataEvent(this, ListDataEvent.INTERVAL_REMOVED, index, index));
|
||||
}
|
||||
notifyListeners(ListDataEvent.INTERVAL_REMOVED, index, index);
|
||||
}
|
||||
|
||||
List<ListDataListener> listeners = new CopyOnWriteArrayList<ListDataListener>();
|
||||
|
||||
@Override
|
||||
public void addListDataListener(ListDataListener l) {
|
||||
listeners.add(l);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeListDataListener(ListDataListener l) {
|
||||
listeners.remove(l);
|
||||
public List<ListDataListener> getListeners() {
|
||||
return listeners;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public class LayerListRenderer extends DefaultListCellRenderer {
|
||||
@@ -1534,44 +1519,22 @@ public class TMXMapEditor extends Editor implements TMXMap.MapChangedOnDiskListe
|
||||
|
||||
}
|
||||
|
||||
public static class TMXMapSpritesheetsListModel implements ListModel<Spritesheet> {
|
||||
|
||||
|
||||
public static class TMXMapSpritesheetsListModel implements ListenerCollectionModel<Spritesheet> {
|
||||
TMXMap map;
|
||||
|
||||
public TMXMapSpritesheetsListModel(TMXMap map) {
|
||||
this.map = map;
|
||||
}
|
||||
@Override
|
||||
public int getSize() {
|
||||
return map.usedSpritesheets.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Spritesheet getElementAt(int index) {
|
||||
for (Spritesheet sheet : map.usedSpritesheets) {
|
||||
if (index == 0) return sheet;
|
||||
index --;
|
||||
}
|
||||
return null;
|
||||
public Collection getElements() {
|
||||
return map.usedSpritesheets;
|
||||
}
|
||||
|
||||
List<ListDataListener> listeners = new CopyOnWriteArrayList<ListDataListener>();
|
||||
|
||||
@Override
|
||||
public void addListDataListener(ListDataListener l) {
|
||||
listeners.add(l);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeListDataListener(ListDataListener l) {
|
||||
listeners.remove(l);
|
||||
}
|
||||
|
||||
public void fireListChanged() {
|
||||
for (ListDataListener l : listeners) {
|
||||
l.contentsChanged(new ListDataEvent(this, ListDataEvent.CONTENTS_CHANGED, 0, this.getSize()));
|
||||
}
|
||||
public List<ListDataListener> getListeners() {
|
||||
return listeners;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -37,6 +37,7 @@ import javax.swing.event.ListDataListener;
|
||||
import javax.swing.event.ListSelectionEvent;
|
||||
import javax.swing.event.ListSelectionListener;
|
||||
|
||||
import com.gpl.rpg.atcontentstudio.ui.*;
|
||||
import org.fife.ui.rsyntaxtextarea.RSyntaxTextArea;
|
||||
import org.fife.ui.rsyntaxtextarea.SyntaxConstants;
|
||||
|
||||
@@ -49,10 +50,6 @@ import com.gpl.rpg.atcontentstudio.model.SaveEvent;
|
||||
import com.gpl.rpg.atcontentstudio.model.maps.TMXMap;
|
||||
import com.gpl.rpg.atcontentstudio.model.maps.Worldmap;
|
||||
import com.gpl.rpg.atcontentstudio.model.maps.WorldmapSegment;
|
||||
import com.gpl.rpg.atcontentstudio.ui.DefaultIcons;
|
||||
import com.gpl.rpg.atcontentstudio.ui.Editor;
|
||||
import com.gpl.rpg.atcontentstudio.ui.FieldUpdateListener;
|
||||
import com.gpl.rpg.atcontentstudio.ui.SaveItemsWizard;
|
||||
import com.jidesoft.swing.ComboBoxSearchable;
|
||||
import com.jidesoft.swing.JideBoxLayout;
|
||||
import com.jidesoft.swing.JideTabbedPane;
|
||||
@@ -694,7 +691,7 @@ public class WorldMapEditor extends Editor implements FieldUpdateListener {
|
||||
|
||||
}
|
||||
|
||||
public class MapSegmentMapsListModel implements ListModel<TMXMap> {
|
||||
public class MapSegmentMapsListModel implements ListenerListModel<TMXMap> {
|
||||
|
||||
WorldmapSegment segment;
|
||||
|
||||
@@ -713,27 +710,17 @@ public class WorldMapEditor extends Editor implements FieldUpdateListener {
|
||||
}
|
||||
|
||||
public void listChanged() {
|
||||
for (ListDataListener l : listeners) {
|
||||
l.contentsChanged(new ListDataEvent(this, ListDataEvent.CONTENTS_CHANGED, 0, getSize() - 1));
|
||||
}
|
||||
fireListChanged();
|
||||
}
|
||||
|
||||
List<ListDataListener> listeners = new ArrayList<ListDataListener>();
|
||||
|
||||
@Override
|
||||
public void addListDataListener(ListDataListener l) {
|
||||
listeners.add(l);
|
||||
public List<ListDataListener> getListeners() {
|
||||
return listeners;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeListDataListener(ListDataListener l) {
|
||||
listeners.remove(l);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class MapSegmentLabelMapsListModel implements ListModel<TMXMap> {
|
||||
|
||||
public class MapSegmentLabelMapsListModel implements ListenerListModel<TMXMap> {
|
||||
WorldmapSegment segment;
|
||||
WorldmapSegment.NamedArea area;
|
||||
|
||||
@@ -755,26 +742,18 @@ public class WorldMapEditor extends Editor implements FieldUpdateListener {
|
||||
}
|
||||
|
||||
public void listChanged() {
|
||||
for (ListDataListener l : listeners) {
|
||||
l.contentsChanged(new ListDataEvent(this, ListDataEvent.CONTENTS_CHANGED, 0, getSize() - 1));
|
||||
}
|
||||
fireListChanged();
|
||||
}
|
||||
|
||||
List<ListDataListener> listeners = new ArrayList<ListDataListener>();
|
||||
|
||||
@Override
|
||||
public void addListDataListener(ListDataListener l) {
|
||||
listeners.add(l);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeListDataListener(ListDataListener l) {
|
||||
listeners.remove(l);
|
||||
public List<ListDataListener> getListeners() {
|
||||
return listeners;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class MapSegmentLabelsListModel implements ListModel<WorldmapSegment.NamedArea> {
|
||||
public class MapSegmentLabelsListModel implements ListenerListModel<WorldmapSegment.NamedArea> {
|
||||
|
||||
WorldmapSegment segment;
|
||||
|
||||
@@ -793,21 +772,14 @@ public class WorldMapEditor extends Editor implements FieldUpdateListener {
|
||||
}
|
||||
|
||||
public void listChanged() {
|
||||
for (ListDataListener l : listeners) {
|
||||
l.contentsChanged(new ListDataEvent(this, ListDataEvent.CONTENTS_CHANGED, 0, getSize() - 1));
|
||||
}
|
||||
fireListChanged();
|
||||
}
|
||||
|
||||
List<ListDataListener> listeners = new ArrayList<ListDataListener>();
|
||||
|
||||
@Override
|
||||
public void addListDataListener(ListDataListener l) {
|
||||
listeners.add(l);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeListDataListener(ListDataListener l) {
|
||||
listeners.remove(l);
|
||||
public List<ListDataListener> getListeners() {
|
||||
return listeners;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -48,6 +48,7 @@ import com.gpl.rpg.atcontentstudio.model.sprites.Spritesheet;
|
||||
import com.gpl.rpg.atcontentstudio.ui.DefaultIcons;
|
||||
import com.gpl.rpg.atcontentstudio.ui.Editor;
|
||||
import com.gpl.rpg.atcontentstudio.ui.FieldUpdateListener;
|
||||
import com.gpl.rpg.atcontentstudio.ui.ListenerListModel;
|
||||
import com.gpl.rpg.atcontentstudio.utils.DesktopIntegration;
|
||||
import com.jidesoft.swing.JideBoxLayout;
|
||||
import com.jidesoft.swing.JideTabbedPane;
|
||||
@@ -351,7 +352,7 @@ public class SpritesheetEditor extends Editor {
|
||||
}
|
||||
|
||||
|
||||
public static class SpritesheetsBacklinksListModel implements ListModel<ProjectTreeNode> {
|
||||
public static class SpritesheetsBacklinksListModel implements ListenerListModel<ProjectTreeNode> {
|
||||
|
||||
Spritesheet sheet;
|
||||
|
||||
@@ -374,21 +375,10 @@ public class SpritesheetEditor extends Editor {
|
||||
}
|
||||
|
||||
List<ListDataListener> listeners = new CopyOnWriteArrayList<ListDataListener>();
|
||||
|
||||
@Override
|
||||
public void addListDataListener(ListDataListener l) {
|
||||
listeners.add(l);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeListDataListener(ListDataListener l) {
|
||||
listeners.remove(l);
|
||||
}
|
||||
|
||||
public void fireListChanged() {
|
||||
for (ListDataListener l : listeners) {
|
||||
l.contentsChanged(new ListDataEvent(this, ListDataEvent.CONTENTS_CHANGED, 0, this.getSize()));
|
||||
}
|
||||
public List<ListDataListener> getListeners() {
|
||||
return listeners;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@ package com.gpl.rpg.atcontentstudio.utils;
|
||||
|
||||
import com.gpl.rpg.atcontentstudio.ATContentStudio;
|
||||
import com.gpl.rpg.atcontentstudio.model.GameDataElement;
|
||||
import com.gpl.rpg.atcontentstudio.model.gamedata.Requirement;
|
||||
import com.gpl.rpg.atcontentstudio.ui.CollapsiblePanel;
|
||||
import com.gpl.rpg.atcontentstudio.ui.OrderedListenerListModel;
|
||||
import com.gpl.rpg.atcontentstudio.ui.DefaultIcons;
|
||||
|
||||
Reference in New Issue
Block a user