 |
Gridarta Editor
|
Go to the documentation of this file.
20 package net.sf.gridarta.gui.panel.gameobjectattributes;
22 import java.awt.BorderLayout;
23 import java.awt.event.MouseAdapter;
24 import java.awt.event.MouseEvent;
25 import java.util.ArrayList;
26 import java.util.Collection;
27 import java.util.Iterator;
28 import java.util.List;
30 import java.util.Vector;
31 import java.util.concurrent.CopyOnWriteArrayList;
32 import javax.swing.DefaultListModel;
33 import javax.swing.JEditorPane;
34 import javax.swing.JList;
35 import javax.swing.JPanel;
36 import javax.swing.JScrollPane;
37 import javax.swing.JSplitPane;
38 import javax.swing.event.ListSelectionListener;
52 import org.jetbrains.annotations.NotNull;
53 import org.jetbrains.annotations.Nullable;
70 private final JList<ValidationError<G, A, R>>
errorList =
new JList<>();
76 private final JEditorPane
errorMsg =
new JEditorPane(
"text/html",
"");
82 private final Collection<ErrorListViewListener>
listeners =
new CopyOnWriteArrayList<>();
95 private Vector<ValidationError<G, A, R>>
errors;
108 if (e.getValueIsAdjusting()) {
121 public void mapSizeChanged(@NotNull
final Size2D newSize) {
131 public void mapObjectsChanged(@NotNull
final Set<G> gameObjects, @NotNull
final Set<G> transientGameObjects) {
141 public void mapFileChanged(@Nullable
final MapFile oldMapFile) {
146 public void modifiedChanged() {
186 setLayout(
new BorderLayout());
187 final JSplitPane splitPane =
new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,
new JScrollPane(
errorList),
new JScrollPane(
errorMsg));
188 splitPane.setOneTouchExpandable(
true);
189 add(splitPane, BorderLayout.CENTER);
193 errorList.addMouseListener(
new MouseAdapter() {
196 public void mousePressed(
final MouseEvent e) {
201 mapView = mapViewManager.getActiveMapView();
243 error =
errors.elementAt(index);
244 }
catch (
final ArrayIndexOutOfBoundsException ignored) {
252 if (tmpMapView !=
null) {
253 final Iterator<G> gameObjectIterator = error.
getGameObjects().iterator();
254 if (gameObjectIterator.hasNext()) {
255 final G gameObject = gameObjectIterator.next();
258 final Iterator<MapSquare<G, A, R>> mapSquareIterator = error.
getMapSquares().iterator();
259 if (mapSquareIterator.hasNext()) {
288 errorList.setModel(
new DefaultListModel<>());
298 final List<ValidationError<G, A, R>> errorVector =
new ArrayList<>();
300 errorVector.add(validationError);
302 this.errors =
new Vector<>(errorVector);
A MapModel reflects the data of a map.
final ListSelectionListener listSelectionListener
The list selection listener to detect selected list entries.
Interface for listeners interested in ErrorListView related events.
MapControl< G, A, R > getMapControl()
Return the controller of this view.
Iterable< MapSquare< G, A, R > > getMapSquares()
Returns the MapSquares that caused the error.
void removeErrorListViewListener(@NotNull final ErrorListViewListener listener)
Removes an ErrorListViewListener to be notified about changes.
Base package of all Gridarta classes.
Super class of all errors that could occur during map validation.
boolean hasWarnings()
Returns whether any warnings are shown.
void fireErrorsUpdated(final boolean hasWarnings)
Notifies all listeners that the warnings may have changed.
Interface for listeners interested in events related to {} instances.
MapModel< G, A, R > currentMapModel
Last known active map.
Reflects a game object (object on a map).
void updateErrors()
Updates the displayed errors.
void addMapModelListener(@NotNull MapModelListener< G, A, R > listener)
Register a map listener.
void setGameObject(@Nullable final G gameObject)
Sets the selected GameObject.
An ErrorPanel displays errors to the user.
void activeMapViewChanged(@Nullable MapView< G, A, R > mapView)
This event handler is called when the current map view has changed.
Graphical User Interface of Gridarta.
MapCursor< G, A, R > getMapCursor()
Returns the MapCursor of this view.
ErrorCollector< G, A, R > getErrors()
Gets the errors in this map.
final MapModelListener< G, A, R > mapModelListener
The MapModelListener which is attached to {}.
final Collection< ErrorListViewListener > listeners
The registered listeners to notify.
GameObjects are the objects based on Archetypes found on maps.
final MapViewManagerListener< G, A, R > mapViewManagerListener
final JEditorPane errorMsg
The JLabel for displaying the error text.
ErrorListView(@NotNull final MapViewManager< G, A, R > mapViewManager)
Creates a new instance.
void removeMapModelListener(@NotNull MapModelListener< G, A, R > listener)
Unregister a map listener.
Interface for MapArchObjects.
An interface for classes that collect errors.
A map view consists of a map grid and a map cursor, and is attached to a map control.
void updateErrors(@NotNull final ErrorCollector< G, A, R > errors)
Updates the errors for the current map.
This package contains the framework for validating maps.
MapView< G, A, R > mapView
The MapView for displaying map errors.
The location of a map file with a map directory.
Interface for listeners listening on MapModel events.
final JList< ValidationError< G, A, R > > errorList
The list for displaying the errors.
static final long serialVersionUID
The serial version UID.
List< G > getGameObjects()
Returns the GameObjects that caused the error.
Base classes for rendering maps.
Vector< ValidationError< G, A, R > > errors
The currently displayed errors.
void setMapSquare(@Nullable final MapSquare< G, A, R > mapSquare)
Sets the selected MapSquare.
void highlightEntries(final int index)
Display an error message.
MapModel< G, A, R > getMapModel()
Returns the map model.
String getMessage()
Returns the error message for this validation error.
void addErrorListViewListener(@NotNull final ErrorListViewListener listener)
Adds an ErrorListViewListener to be notified about changes.
The class Size2D represents a 2d rectangular area.