20 package net.sf.gridarta.gui.dialog.findarchetypes;
22 import java.util.ArrayList;
23 import java.util.Arrays;
24 import java.util.Comparator;
25 import java.util.List;
26 import javax.swing.table.AbstractTableModel;
32 import net.
sf.japi.swing.action.ActionBuilder;
33 import net.
sf.japi.swing.action.ActionBuilderFactory;
34 import org.jetbrains.annotations.NotNull;
35 import org.jetbrains.annotations.Nullable;
59 private static final ActionBuilder
ACTION_BUILDER = ActionBuilderFactory.getInstance().getActionBuilder(
"net.sf.gridarta");
93 private final Comparator<Integer>
comparator =
new Comparator<Integer>() {
96 public int compare(
final Integer o1,
final Integer o2) {
101 if (cmpBestName != 0) {
106 if (cmpArchetypeName != 0) {
107 return cmpArchetypeName;
135 public void add(@NotNull
final R archetype) {
136 archetypes.add(archetype);
145 @SuppressWarnings(
"TypeMayBeWeakened")
146 public R
get(final
int index) {
147 return archetypes.get(sorting[index]);
162 public Object
getValueAt(
final int rowIndex,
final int columnIndex) {
164 switch (columnIndex) {
178 throw new IllegalArgumentException();
186 }
catch (
final ArrayIndexOutOfBoundsException ignored) {
187 return super.getColumnName(column);
196 for (
int i = 0; i <
sorting.length; i++) {
211 throw new IllegalStateException();
214 fireTableDataChanged();
224 if (archetype != null) {
225 final int archetypeIndex =
archetypes.indexOf(archetype);
226 if (archetypeIndex != -1) {
227 for (
final Integer index :
sorting) {
228 if (archetypeIndex == sorting[index]) {
void sortTable()
Sort the table contents by name.
Manages ArchetypeType instances, list, and bitmask definitions.
R get(final int index)
Return one archetype.
The model for displaying a set of archetypes.
void clear()
Clear the model's contents.
String getArchetypeName()
Returns the name of this archetype.
String getEditorFolder()
Returns the editor folder.
final Comparator< Integer > comparator
Comparator for sorting the model's contents.
void add(@NotNull final R archetype)
Add an archetype to the model.
static String getString(@NotNull final ActionBuilder actionBuilder, @NotNull final String key, @NotNull final String defaultValue)
Returns the value of a key.
Base package of all Gridarta classes.
Reflects a game object (object on a map).
static final String [] COLUMN_NAME
The column titles.
static final ActionBuilder ACTION_BUILDER
Action Builder.
GameObjects are the objects based on Archetypes found on maps.
Object getValueAt(final int rowIndex, final int columnIndex)
String getColumnName(final int column)
String getBestName()
Returns the name which is best appropriate to describe this GameObject.
final List< R > archetypes
The model's contents.
static final long serialVersionUID
The serial version UID.
void finishUpdate()
Finish updating the model's contents.
Utility class for ActionBuilder related functions.
Integer [] sorting
Reflects the current sorting of the model's contents.
TableModel(@NotNull final ArchetypeTypeSet archetypeTypeSet)
Creates a new instance.
final ArchetypeTypeSet archetypeTypeSet
The instance for looking up archetype types.
int findTableIndex(@Nullable final R archetype)
Return the row index of an archetype.
String getDisplayName(@NotNull final BaseObject<?, ?, ?, ?> baseObject)
Returns a description of this type.
Defines types of GameObjects with corresponding attributes.
Interface for MapArchObjects.