mirror of
https://github.com/OMGeeky/ATCS.git
synced 2025-12-26 23:57:25 +01:00
add more ListModel to CustomListModel changes
This commit is contained in:
@@ -29,6 +29,7 @@ public abstract class CustomListModel<S, E> implements ListModel<E> {
|
||||
return getItems().get(index);
|
||||
}
|
||||
|
||||
public void addObject(E item) {addItem(item);}
|
||||
public void addItem(E item) {
|
||||
if (getItems() == null) {
|
||||
setItems(new ArrayList<E>());
|
||||
@@ -40,6 +41,7 @@ public abstract class CustomListModel<S, E> implements ListModel<E> {
|
||||
}
|
||||
}
|
||||
|
||||
public void removeObject(E item) {removeItem(item);}
|
||||
public void removeItem(E item) {
|
||||
int index = getItems().indexOf(item);
|
||||
getItems().remove(item);
|
||||
@@ -69,6 +71,7 @@ public abstract class CustomListModel<S, E> implements ListModel<E> {
|
||||
}
|
||||
}
|
||||
|
||||
public void objectChanged(E item) {itemChanged(item);}
|
||||
public void itemChanged(E item) {
|
||||
int index = getItems().indexOf(item);
|
||||
for (ListDataListener l : listeners) {
|
||||
|
||||
@@ -31,16 +31,9 @@ import com.gpl.rpg.atcontentstudio.ATContentStudio;
|
||||
import com.gpl.rpg.atcontentstudio.model.GameDataElement;
|
||||
import com.gpl.rpg.atcontentstudio.model.Project;
|
||||
import com.gpl.rpg.atcontentstudio.model.ProjectTreeNode;
|
||||
import com.gpl.rpg.atcontentstudio.model.gamedata.ActorCondition;
|
||||
import com.gpl.rpg.atcontentstudio.model.gamedata.Common;
|
||||
import com.gpl.rpg.atcontentstudio.model.gamedata.Item;
|
||||
import com.gpl.rpg.atcontentstudio.model.gamedata.ItemCategory;
|
||||
import com.gpl.rpg.atcontentstudio.model.gamedata.*;
|
||||
import com.gpl.rpg.atcontentstudio.model.sprites.Spritesheet;
|
||||
import com.gpl.rpg.atcontentstudio.ui.CollapsiblePanel;
|
||||
import com.gpl.rpg.atcontentstudio.ui.DefaultIcons;
|
||||
import com.gpl.rpg.atcontentstudio.ui.FieldUpdateListener;
|
||||
import com.gpl.rpg.atcontentstudio.ui.IntegerBasedCheckBox;
|
||||
import com.gpl.rpg.atcontentstudio.ui.OverlayIcon;
|
||||
import com.gpl.rpg.atcontentstudio.ui.*;
|
||||
import com.jidesoft.swing.JideBoxLayout;
|
||||
|
||||
public class ItemEditor extends JSONElementEditor {
|
||||
@@ -1185,127 +1178,34 @@ public class ItemEditor extends JSONElementEditor {
|
||||
}
|
||||
|
||||
|
||||
public static class SourceTimedConditionsListModel implements ListModel<Common.TimedConditionEffect> {
|
||||
|
||||
Common.DeathEffect source;
|
||||
|
||||
public static class SourceTimedConditionsListModel extends CustomListModel<Common.DeathEffect , Common.TimedConditionEffect> {
|
||||
public SourceTimedConditionsListModel(Common.DeathEffect effect) {
|
||||
this.source = effect;;
|
||||
super(effect);;
|
||||
}
|
||||
@Override
|
||||
protected List<Common.TimedConditionEffect> getItems() {
|
||||
return source.conditions_source;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSize() {
|
||||
if (source.conditions_source == null) return 0;
|
||||
return source.conditions_source.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Common.TimedConditionEffect getElementAt(int index) {
|
||||
if (source.conditions_source == null) return null;
|
||||
return source.conditions_source.get(index);
|
||||
}
|
||||
|
||||
public void addItem(Common.TimedConditionEffect item) {
|
||||
if (source.conditions_source == null) {
|
||||
source.conditions_source = new ArrayList<Common.TimedConditionEffect>();
|
||||
}
|
||||
source.conditions_source.add(item);
|
||||
int index = source.conditions_source.indexOf(item);
|
||||
for (ListDataListener l : listeners) {
|
||||
l.intervalAdded(new ListDataEvent(this, ListDataEvent.INTERVAL_ADDED, index, index));
|
||||
}
|
||||
}
|
||||
|
||||
public void removeItem(Common.TimedConditionEffect item) {
|
||||
int index = source.conditions_source.indexOf(item);
|
||||
source.conditions_source.remove(item);
|
||||
if (source.conditions_source.isEmpty()) {
|
||||
source.conditions_source = null;
|
||||
}
|
||||
for (ListDataListener l : listeners) {
|
||||
l.intervalRemoved(new ListDataEvent(this, ListDataEvent.INTERVAL_REMOVED, index, index));
|
||||
}
|
||||
}
|
||||
|
||||
public void itemChanged(Common.TimedConditionEffect item) {
|
||||
int index = source.conditions_source.indexOf(item);
|
||||
for (ListDataListener l : listeners) {
|
||||
l.contentsChanged(new ListDataEvent(this, ListDataEvent.CONTENTS_CHANGED, 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);
|
||||
protected void setItems(List<Common.TimedConditionEffect> items) {
|
||||
source.conditions_source = items;
|
||||
}
|
||||
}
|
||||
|
||||
public static class TargetTimedConditionsListModel implements ListModel<Common.TimedConditionEffect> {
|
||||
|
||||
Common.HitEffect source;
|
||||
|
||||
public static class TargetTimedConditionsListModel extends CustomListModel<Common.HitEffect,Common.TimedConditionEffect> {
|
||||
public TargetTimedConditionsListModel(Common.HitEffect effect) {
|
||||
this.source = effect;;
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSize() {
|
||||
if (source.conditions_target == null) return 0;
|
||||
return source.conditions_target.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Common.TimedConditionEffect getElementAt(int index) {
|
||||
if (source.conditions_target == null) return null;
|
||||
return source.conditions_target.get(index);
|
||||
}
|
||||
|
||||
public void addItem(Common.TimedConditionEffect item) {
|
||||
if (source.conditions_target == null) {
|
||||
source.conditions_target = new ArrayList<Common.TimedConditionEffect>();
|
||||
}
|
||||
source.conditions_target.add(item);
|
||||
int index = source.conditions_target.indexOf(item);
|
||||
for (ListDataListener l : listeners) {
|
||||
l.intervalAdded(new ListDataEvent(this, ListDataEvent.INTERVAL_ADDED, index, index));
|
||||
}
|
||||
}
|
||||
|
||||
public void removeItem(Common.TimedConditionEffect item) {
|
||||
int index = source.conditions_target.indexOf(item);
|
||||
source.conditions_target.remove(item);
|
||||
if (source.conditions_target.isEmpty()) {
|
||||
source.conditions_target = null;
|
||||
}
|
||||
for (ListDataListener l : listeners) {
|
||||
l.intervalRemoved(new ListDataEvent(this, ListDataEvent.INTERVAL_REMOVED, index, index));
|
||||
}
|
||||
protected List<Common.TimedConditionEffect> getItems() {
|
||||
return source.conditions_target;
|
||||
}
|
||||
|
||||
public void itemChanged(Common.TimedConditionEffect item) {
|
||||
int index = source.conditions_target.indexOf(item);
|
||||
for (ListDataListener l : listeners) {
|
||||
l.contentsChanged(new ListDataEvent(this, ListDataEvent.CONTENTS_CHANGED, 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);
|
||||
protected void setItems(List<Common.TimedConditionEffect> items) {
|
||||
source.conditions_target = items;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1343,65 +1243,19 @@ public class ItemEditor extends JSONElementEditor {
|
||||
}
|
||||
}
|
||||
|
||||
public static class ConditionsListModel implements ListModel<Common.ConditionEffect> {
|
||||
|
||||
Item.EquipEffect source;
|
||||
|
||||
public static class ConditionsListModel extends CustomListModel<Item.EquipEffect, Common.ConditionEffect> {
|
||||
public ConditionsListModel(Item.EquipEffect equipEffect) {
|
||||
this.source = equipEffect;
|
||||
super(equipEffect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSize() {
|
||||
if (source.conditions == null) return 0;
|
||||
return source.conditions.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Common.ConditionEffect getElementAt(int index) {
|
||||
if (source.conditions == null) return null;
|
||||
return source.conditions.get(index);
|
||||
}
|
||||
|
||||
public void addItem(Common.ConditionEffect item) {
|
||||
if (source.conditions == null) {
|
||||
source.conditions = new ArrayList<Common.ConditionEffect>();
|
||||
}
|
||||
source.conditions.add(item);
|
||||
int index = source.conditions.indexOf(item);
|
||||
for (ListDataListener l : listeners) {
|
||||
l.intervalAdded(new ListDataEvent(this, ListDataEvent.INTERVAL_ADDED, index, index));
|
||||
}
|
||||
}
|
||||
|
||||
public void removeItem(Common.ConditionEffect item) {
|
||||
int index = source.conditions.indexOf(item);
|
||||
source.conditions.remove(item);
|
||||
if (source.conditions.isEmpty()) {
|
||||
source.conditions = null;
|
||||
}
|
||||
for (ListDataListener l : listeners) {
|
||||
l.intervalRemoved(new ListDataEvent(this, ListDataEvent.INTERVAL_REMOVED, index, index));
|
||||
}
|
||||
protected List<Common.ConditionEffect> getItems() {
|
||||
return source.conditions;
|
||||
}
|
||||
|
||||
public void itemChanged(Common.ConditionEffect item) {
|
||||
int index = source.conditions.indexOf(item);
|
||||
for (ListDataListener l : listeners) {
|
||||
l.contentsChanged(new ListDataEvent(this, ListDataEvent.CONTENTS_CHANGED, 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);
|
||||
protected void setItems(List<Common.ConditionEffect> conditions) {
|
||||
source.conditions = conditions;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -34,11 +34,7 @@ import com.gpl.rpg.atcontentstudio.model.Project;
|
||||
import com.gpl.rpg.atcontentstudio.model.ProjectTreeNode;
|
||||
import com.gpl.rpg.atcontentstudio.model.gamedata.*;
|
||||
import com.gpl.rpg.atcontentstudio.model.sprites.Spritesheet;
|
||||
import com.gpl.rpg.atcontentstudio.ui.CollapsiblePanel;
|
||||
import com.gpl.rpg.atcontentstudio.ui.DefaultIcons;
|
||||
import com.gpl.rpg.atcontentstudio.ui.FieldUpdateListener;
|
||||
import com.gpl.rpg.atcontentstudio.ui.IntegerBasedCheckBox;
|
||||
import com.gpl.rpg.atcontentstudio.ui.OverlayIcon;
|
||||
import com.gpl.rpg.atcontentstudio.ui.*;
|
||||
import com.gpl.rpg.atcontentstudio.ui.gamedataeditors.dialoguetree.DialogueGraphView;
|
||||
import com.jidesoft.swing.JideBoxLayout;
|
||||
|
||||
@@ -1025,127 +1021,35 @@ public class NPCEditor extends JSONElementEditor {
|
||||
deathSourceConditionForever.setEnabled(!clear);
|
||||
}
|
||||
|
||||
public static class TargetTimedConditionsListModel implements ListModel<Common.TimedConditionEffect> {
|
||||
|
||||
Common.HitEffect source;
|
||||
|
||||
public static class TargetTimedConditionsListModel extends CustomListModel<Common.HitEffect,Common.TimedConditionEffect> {
|
||||
public TargetTimedConditionsListModel(Common.HitEffect effect) {
|
||||
this.source = effect;
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSize() {
|
||||
if (source.conditions_target == null) return 0;
|
||||
return source.conditions_target.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Common.TimedConditionEffect getElementAt(int index) {
|
||||
if (source.conditions_target == null) return null;
|
||||
return source.conditions_target.get(index);
|
||||
protected List<Common.TimedConditionEffect> getItems() {
|
||||
return source.conditions_target;
|
||||
}
|
||||
|
||||
public void addItem(Common.TimedConditionEffect item) {
|
||||
if (source.conditions_target == null) {
|
||||
source.conditions_target = new ArrayList<Common.TimedConditionEffect>();
|
||||
}
|
||||
source.conditions_target.add(item);
|
||||
int index = source.conditions_target.indexOf(item);
|
||||
for (ListDataListener l : listeners) {
|
||||
l.intervalAdded(new ListDataEvent(this, ListDataEvent.INTERVAL_ADDED, index, index));
|
||||
}
|
||||
}
|
||||
|
||||
public void removeItem(Common.TimedConditionEffect item) {
|
||||
int index = source.conditions_target.indexOf(item);
|
||||
source.conditions_target.remove(item);
|
||||
if (source.conditions_target.isEmpty()) {
|
||||
source.conditions_target = null;
|
||||
}
|
||||
for (ListDataListener l : listeners) {
|
||||
l.intervalRemoved(new ListDataEvent(this, ListDataEvent.INTERVAL_REMOVED, index, index));
|
||||
}
|
||||
}
|
||||
|
||||
public void itemChanged(Common.TimedConditionEffect item) {
|
||||
int index = source.conditions_target.indexOf(item);
|
||||
for (ListDataListener l : listeners) {
|
||||
l.contentsChanged(new ListDataEvent(this, ListDataEvent.CONTENTS_CHANGED, 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);
|
||||
protected void setItems(List<Common.TimedConditionEffect> items) {
|
||||
source.conditions_target = items;
|
||||
}
|
||||
}
|
||||
|
||||
public static class SourceTimedConditionsListModel implements ListModel<Common.TimedConditionEffect> {
|
||||
|
||||
Common.DeathEffect source;
|
||||
|
||||
public static class SourceTimedConditionsListModel extends CustomListModel<Common.DeathEffect, Common.TimedConditionEffect> {
|
||||
public SourceTimedConditionsListModel(Common.DeathEffect effect) {
|
||||
this.source = effect;
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSize() {
|
||||
if (source.conditions_source == null) return 0;
|
||||
return source.conditions_source.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Common.TimedConditionEffect getElementAt(int index) {
|
||||
if (source.conditions_source == null) return null;
|
||||
return source.conditions_source.get(index);
|
||||
}
|
||||
|
||||
public void addItem(Common.TimedConditionEffect item) {
|
||||
if (source.conditions_source == null) {
|
||||
source.conditions_source = new ArrayList<Common.TimedConditionEffect>();
|
||||
}
|
||||
source.conditions_source.add(item);
|
||||
int index = source.conditions_source.indexOf(item);
|
||||
for (ListDataListener l : listeners) {
|
||||
l.intervalAdded(new ListDataEvent(this, ListDataEvent.INTERVAL_ADDED, index, index));
|
||||
}
|
||||
}
|
||||
|
||||
public void removeItem(Common.TimedConditionEffect item) {
|
||||
int index = source.conditions_source.indexOf(item);
|
||||
source.conditions_source.remove(item);
|
||||
if (source.conditions_source.isEmpty()) {
|
||||
source.conditions_source = null;
|
||||
}
|
||||
for (ListDataListener l : listeners) {
|
||||
l.intervalRemoved(new ListDataEvent(this, ListDataEvent.INTERVAL_REMOVED, index, index));
|
||||
}
|
||||
protected List<Common.TimedConditionEffect> getItems() {
|
||||
return source.conditions_source;
|
||||
}
|
||||
|
||||
public void itemChanged(Common.TimedConditionEffect item) {
|
||||
int index = source.conditions_source.indexOf(item);
|
||||
for (ListDataListener l : listeners) {
|
||||
l.contentsChanged(new ListDataEvent(this, ListDataEvent.CONTENTS_CHANGED, 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);
|
||||
protected void setItems(List<Common.TimedConditionEffect> items) {
|
||||
source.conditions_source = items;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -28,12 +28,10 @@ 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.CollapsiblePanel;
|
||||
import com.gpl.rpg.atcontentstudio.ui.DefaultIcons;
|
||||
import com.gpl.rpg.atcontentstudio.ui.FieldUpdateListener;
|
||||
import com.gpl.rpg.atcontentstudio.ui.IntegerBasedCheckBox;
|
||||
import com.gpl.rpg.atcontentstudio.ui.*;
|
||||
import com.jidesoft.swing.JideBoxLayout;
|
||||
|
||||
public class QuestEditor extends JSONElementEditor {
|
||||
@@ -183,88 +181,21 @@ public class QuestEditor extends JSONElementEditor {
|
||||
pane.revalidate();
|
||||
pane.repaint();
|
||||
}
|
||||
|
||||
public static class StagesListModel implements ListModel<QuestStage> {
|
||||
|
||||
Quest source;
|
||||
|
||||
public static class StagesListModel extends CustomListModel<Quest, QuestStage> {
|
||||
public StagesListModel(Quest quest) {
|
||||
this.source = quest;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getSize() {
|
||||
if (source.stages == null) return 0;
|
||||
return source.stages.size();
|
||||
super(quest);
|
||||
}
|
||||
|
||||
@Override
|
||||
public QuestStage getElementAt(int index) {
|
||||
if (source.stages == null) return null;
|
||||
return source.stages.get(index);
|
||||
}
|
||||
|
||||
public void addItem(QuestStage item) {
|
||||
if (source.stages == null) {
|
||||
source.stages = new ArrayList<QuestStage>();
|
||||
}
|
||||
source.stages.add(item);
|
||||
int index = source.stages.indexOf(item);
|
||||
for (ListDataListener l : listeners) {
|
||||
l.intervalAdded(new ListDataEvent(this, ListDataEvent.INTERVAL_ADDED, index, index));
|
||||
}
|
||||
}
|
||||
|
||||
public void removeItem(QuestStage item) {
|
||||
int index = source.stages.indexOf(item);
|
||||
source.stages.remove(item);
|
||||
if (source.stages.isEmpty()) {
|
||||
source.stages = null;
|
||||
}
|
||||
for (ListDataListener l : listeners) {
|
||||
l.intervalRemoved(new ListDataEvent(this, ListDataEvent.INTERVAL_REMOVED, index, index));
|
||||
}
|
||||
}
|
||||
|
||||
public void itemChanged(QuestStage item) {
|
||||
int index = source.stages.indexOf(item);
|
||||
for (ListDataListener l : listeners) {
|
||||
l.contentsChanged(new ListDataEvent(this, ListDataEvent.CONTENTS_CHANGED, index, index));
|
||||
}
|
||||
}
|
||||
|
||||
public void moveUp(QuestStage item) {
|
||||
int index = source.stages.indexOf(item);
|
||||
QuestStage exchanged = source.stages.get(index - 1);
|
||||
source.stages.set(index, exchanged);
|
||||
source.stages.set(index - 1, item);
|
||||
for (ListDataListener l : listeners) {
|
||||
l.contentsChanged(new ListDataEvent(this, ListDataEvent.CONTENTS_CHANGED, index - 1, index));
|
||||
}
|
||||
}
|
||||
|
||||
public void moveDown(QuestStage item) {
|
||||
int index = source.stages.indexOf(item);
|
||||
QuestStage exchanged = source.stages.get(index + 1);
|
||||
source.stages.set(index, exchanged);
|
||||
source.stages.set(index + 1, item);
|
||||
for (ListDataListener l : listeners) {
|
||||
l.contentsChanged(new ListDataEvent(this, ListDataEvent.CONTENTS_CHANGED, index, index + 1));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
List<ListDataListener> listeners = new CopyOnWriteArrayList<ListDataListener>();
|
||||
|
||||
@Override
|
||||
public void addListDataListener(ListDataListener l) {
|
||||
listeners.add(l);
|
||||
protected List<QuestStage> getItems() {
|
||||
return source.stages;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeListDataListener(ListDataListener l) {
|
||||
listeners.remove(l);
|
||||
protected void setItems(List<QuestStage> items) {
|
||||
source.stages = items;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -62,6 +62,7 @@ import javax.swing.tree.DefaultTreeCellRenderer;
|
||||
import javax.swing.tree.TreeModel;
|
||||
import javax.swing.tree.TreePath;
|
||||
|
||||
import com.gpl.rpg.atcontentstudio.ui.*;
|
||||
import org.fife.ui.rsyntaxtextarea.RSyntaxTextArea;
|
||||
import org.fife.ui.rsyntaxtextarea.SyntaxConstants;
|
||||
|
||||
@@ -95,13 +96,6 @@ import com.gpl.rpg.atcontentstudio.model.maps.SignArea;
|
||||
import com.gpl.rpg.atcontentstudio.model.maps.SpawnArea;
|
||||
import com.gpl.rpg.atcontentstudio.model.maps.TMXMap;
|
||||
import com.gpl.rpg.atcontentstudio.model.sprites.Spritesheet;
|
||||
import com.gpl.rpg.atcontentstudio.ui.BooleanBasedCheckBox;
|
||||
import com.gpl.rpg.atcontentstudio.ui.CollapsiblePanel;
|
||||
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.IntegerBasedCheckBox;
|
||||
import com.gpl.rpg.atcontentstudio.ui.ScrollablePanel;
|
||||
import com.gpl.rpg.atcontentstudio.utils.DesktopIntegration;
|
||||
import com.gpl.rpg.atcontentstudio.utils.FileUtils;
|
||||
import com.jidesoft.swing.JideBoxLayout;
|
||||
@@ -1286,58 +1280,20 @@ public class TMXMapEditor extends Editor implements TMXMap.MapChangedOnDiskListe
|
||||
}
|
||||
}
|
||||
|
||||
public class MapObjectsListModel implements ListModel<MapObject> {
|
||||
|
||||
public MapObjectGroup group;
|
||||
|
||||
public class MapObjectsListModel extends CustomListModel<MapObjectGroup, MapObject> {
|
||||
public MapObjectsListModel(MapObjectGroup group) {
|
||||
this.group = group;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSize() {
|
||||
return group.mapObjects.size();
|
||||
super(group);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MapObject getElementAt(int index) {
|
||||
return group.mapObjects.get(index);
|
||||
}
|
||||
|
||||
public void objectChanged(MapObject area) {
|
||||
for (ListDataListener l : listeners) {
|
||||
l.contentsChanged(new ListDataEvent(groupObjectsList, ListDataEvent.CONTENTS_CHANGED, group.mapObjects.indexOf(area), group.mapObjects.indexOf(area)));
|
||||
}
|
||||
}
|
||||
|
||||
public void addObject(MapObject area) {
|
||||
group.mapObjects.add(area);
|
||||
int index = group.mapObjects.indexOf(area);
|
||||
for (ListDataListener l : listeners) {
|
||||
l.intervalAdded(new ListDataEvent(groupObjectsList, ListDataEvent.INTERVAL_ADDED, index, index));
|
||||
}
|
||||
}
|
||||
|
||||
public void removeObject(MapObject area) {
|
||||
int index = group.mapObjects.indexOf(area);
|
||||
group.mapObjects.remove(area);
|
||||
for (ListDataListener l : listeners) {
|
||||
l.intervalRemoved(new ListDataEvent(groupObjectsList, ListDataEvent.INTERVAL_REMOVED, index, index));
|
||||
}
|
||||
}
|
||||
|
||||
List<ListDataListener> listeners = new CopyOnWriteArrayList<ListDataListener>();
|
||||
|
||||
@Override
|
||||
public void addListDataListener(ListDataListener l) {
|
||||
listeners.add(l);
|
||||
protected List<MapObject> getItems() {
|
||||
return source.mapObjects;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeListDataListener(ListDataListener l) {
|
||||
listeners.remove(l);
|
||||
protected void setItems(List<MapObject> items) {
|
||||
source.mapObjects = items;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class GroupObjectsRenderer extends DefaultListCellRenderer {
|
||||
|
||||
Reference in New Issue
Block a user