diff --git a/src/com/gpl/rpg/atcontentstudio/ui/gamedataeditors/QuestEditor.java b/src/com/gpl/rpg/atcontentstudio/ui/gamedataeditors/QuestEditor.java index 39a0b73..d16730a 100644 --- a/src/com/gpl/rpg/atcontentstudio/ui/gamedataeditors/QuestEditor.java +++ b/src/com/gpl/rpg/atcontentstudio/ui/gamedataeditors/QuestEditor.java @@ -34,6 +34,7 @@ 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.tools.CommonEditor; import com.jidesoft.swing.JideBoxLayout; public class QuestEditor extends JSONElementEditor { @@ -184,87 +185,19 @@ public class QuestEditor extends JSONElementEditor { pane.repaint(); } - public static class StagesListModel implements ListModel { - - Quest source; - + public static class StagesListModel extends CommonEditor.AtListModel { 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(); - } - 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 listeners = new CopyOnWriteArrayList(); - - @Override - public void addListDataListener(ListDataListener l) { - listeners.add(l); + protected List getInner() { + return source.stages; } @Override - public void removeListDataListener(ListDataListener l) { - listeners.remove(l); + protected void setInner(List value) { + source.stages = value; } }