 |
Gridarta Editor
|
Go to the documentation of this file.
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 = (o1, o2) -> {
98 if (cmpBestName != 0) {
103 if (cmpArchetypeName != 0) {
104 return cmpArchetypeName;
130 public void add(@NotNull
final R archetype) {
140 public R
get(
final int index) {
156 public Object
getValueAt(
final int rowIndex,
final int columnIndex) {
158 switch (columnIndex) {
172 throw new IllegalArgumentException(
"invalid column index: " + columnIndex);
180 }
catch (
final ArrayIndexOutOfBoundsException ignored) {
181 return super.getColumnName(column);
190 for (
int i = 0; i <
sorting.length; i++) {
205 throw new IllegalStateException(
"archetypes are not sorted");
208 fireTableDataChanged();
218 if (archetype !=
null) {
219 final int archetypeIndex =
archetypes.indexOf(archetype);
220 if (archetypeIndex != -1) {
221 for (
final Integer index :
sorting) {
222 if (archetypeIndex ==
sorting[index]) {
static final ActionBuilder ACTION_BUILDER
Action Builder.
Defines types of GameObjects with corresponding attributes.
void finishUpdate()
Finish updating the model's contents.
String getArchetypeName()
Returns the name of this archetype.
Object getValueAt(final int rowIndex, final int columnIndex)
Integer[] sorting
Reflects the current sorting of the model's contents.
Base package of all Gridarta classes.
final ArchetypeTypeSet archetypeTypeSet
The instance for looking up archetype types.
String getDisplayName(@NotNull final BaseObject<?, ?, ?, ?> baseObject)
Returns a description of this type.
String getEditorFolder()
Returns the editor folder.
Reflects a game object (object on a map).
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.
Manages ArchetypeType instances, list, and bitmask definitions.
The model for displaying a set of archetypes.
GameObjects are the objects based on Archetypes found on maps.
TableModel(@NotNull final ArchetypeTypeSet archetypeTypeSet)
Creates a new instance.
int findTableIndex(@Nullable final R archetype)
Return the row index of an archetype.
Interface for MapArchObjects.
void sortTable()
Sort the table contents by name.
static String getString(@NotNull final ActionBuilder actionBuilder, @NotNull final String key, @NotNull final String defaultValue)
Returns the value of a key.
void clear()
Clear the model's contents.
void add(@NotNull final R archetype)
Add an archetype to the model.
final Comparator< Integer > comparator
Comparator for sorting the model's contents.
Utility class for ActionBuilder related functions.
String getColumnName(final int column)
static final String[] COLUMN_NAME
The column titles.