From: David ‘Bombe’ Roden Date: Tue, 28 Aug 2012 08:47:47 +0000 (+0200) Subject: Use SortedListModel from utils. X-Git-Tag: 0.11^2~19^2 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=ea076c18c3ebebc991f4075320a1db9bdba543c9;p=jSite.git Use SortedListModel from utils. --- diff --git a/src/main/java/de/todesbaum/jsite/gui/ProjectPage.java b/src/main/java/de/todesbaum/jsite/gui/ProjectPage.java index 98ad847..9345dbf 100644 --- a/src/main/java/de/todesbaum/jsite/gui/ProjectPage.java +++ b/src/main/java/de/todesbaum/jsite/gui/ProjectPage.java @@ -57,12 +57,12 @@ import javax.swing.text.BadLocationException; import javax.swing.text.Document; import javax.swing.text.DocumentFilter; +import net.pterodactylus.util.swing.SortedListModel; import de.todesbaum.jsite.application.Freenet7Interface; import de.todesbaum.jsite.application.KeyDialog; import de.todesbaum.jsite.application.Project; import de.todesbaum.jsite.i18n.I18n; import de.todesbaum.jsite.i18n.I18nContainer; -import de.todesbaum.util.swing.SortedListModel; import de.todesbaum.util.swing.TLabel; import de.todesbaum.util.swing.TWizard; import de.todesbaum.util.swing.TWizardPage; diff --git a/src/main/java/de/todesbaum/util/swing/SortedListModel.java b/src/main/java/de/todesbaum/util/swing/SortedListModel.java deleted file mode 100644 index 39a5ce2..0000000 --- a/src/main/java/de/todesbaum/util/swing/SortedListModel.java +++ /dev/null @@ -1,250 +0,0 @@ -/* - * jSite - SortedListModel.java - Copyright © 2006–2012 David Roden - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -package de.todesbaum.util.swing; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.Iterator; -import java.util.List; -import java.util.ListIterator; - -import javax.swing.AbstractListModel; - -/** - * @param - * The type of the elements - * @author David Roden <droden@gmail.com> - */ -public class SortedListModel> extends AbstractListModel implements List { - - /** The elements. */ - private List elements = new ArrayList(); - - /** - * {@inheritDoc} - */ - public int getSize() { - return size(); - } - - /** - * {@inheritDoc} - */ - public Object getElementAt(int index) { - return elements.get(index); - } - - /** - * {@inheritDoc} - */ - public void add(int index, T element) { - elements.add(index, element); - Collections.sort(elements); - fireContentsChanged(this, 0, size()); - } - - /** - * {@inheritDoc} - */ - public boolean add(T o) { - boolean result = elements.add(o); - Collections.sort(elements); - fireContentsChanged(this, 0, size()); - return result; - } - - /** - * {@inheritDoc} - */ - public boolean addAll(Collection c) { - boolean result = elements.addAll(c); - Collections.sort(elements); - fireContentsChanged(this, 0, size()); - return result; - } - - /** - * {@inheritDoc} - */ - public boolean addAll(int index, Collection c) { - boolean result = elements.addAll(index, c); - Collections.sort(elements); - fireContentsChanged(this, 0, size()); - return result; - } - - /** - * {@inheritDoc} - */ - public void clear() { - elements.clear(); - fireContentsChanged(this, 0, size()); - } - - /** - * {@inheritDoc} - */ - public boolean contains(Object o) { - return elements.contains(o); - } - - /** - * {@inheritDoc} - */ - public boolean containsAll(Collection c) { - return elements.containsAll(c); - } - - /** - * {@inheritDoc} - */ - @Override - public boolean equals(Object o) { - return elements.equals(o); - } - - /** - * {@inheritDoc} - */ - public T get(int index) { - return elements.get(index); - } - - /** - * {@inheritDoc} - */ - @Override - public int hashCode() { - return elements.hashCode(); - } - - /** - * {@inheritDoc} - */ - public int indexOf(Object o) { - return elements.indexOf(o); - } - - /** - * {@inheritDoc} - */ - public boolean isEmpty() { - return elements.isEmpty(); - } - - /** - * {@inheritDoc} - */ - public Iterator iterator() { - return elements.iterator(); - } - - /** - * {@inheritDoc} - */ - public int lastIndexOf(Object o) { - return elements.lastIndexOf(o); - } - - /** - * {@inheritDoc} - */ - public ListIterator listIterator() { - return elements.listIterator(); - } - - /** - * {@inheritDoc} - */ - public ListIterator listIterator(int index) { - return elements.listIterator(index); - } - - /** - * {@inheritDoc} - */ - public T remove(int index) { - fireContentsChanged(this, 0, size()); - return elements.remove(index); - } - - /** - * {@inheritDoc} - */ - public boolean remove(Object o) { - fireContentsChanged(this, 0, size()); - return elements.remove(o); - } - - /** - * {@inheritDoc} - */ - public boolean removeAll(Collection c) { - fireContentsChanged(this, 0, size()); - return elements.removeAll(c); - } - - /** - * {@inheritDoc} - */ - public boolean retainAll(Collection c) { - fireContentsChanged(this, 0, size()); - return elements.retainAll(c); - } - - /** - * {@inheritDoc} - */ - public T set(int index, T element) { - T result = elements.set(index, element); - Collections.sort(elements); - fireContentsChanged(this, 0, size()); - return result; - } - - /** - * {@inheritDoc} - */ - public int size() { - return elements.size(); - } - - /** - * {@inheritDoc} - */ - public List subList(int fromIndex, int toIndex) { - return elements.subList(fromIndex, toIndex); - } - - /** - * {@inheritDoc} - */ - public Object[] toArray() { - return elements.toArray(); - } - - /** - * {@inheritDoc} - */ - public U[] toArray(U[] a) { - return elements.toArray(a); - } - -}