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.ListSelectionEvent;
39 import javax.swing.event.ListSelectionListener;
53 import org.jetbrains.annotations.NotNull;
54 import org.jetbrains.annotations.Nullable;
71 private final JList<ValidationError<G, A, R>>
errorList =
new JList<>();
77 private final JEditorPane
errorMsg =
new JEditorPane(
"text/html",
"");
83 private final Collection<ErrorListViewListener>
listeners =
new CopyOnWriteArrayList<>();
96 private Vector<ValidationError<G, A, R>>
errors;
111 public void valueChanged(
final ListSelectionEvent e) {
112 if (e.getValueIsAdjusting()) {
127 public void mapSizeChanged(@NotNull
final Size2D newSize) {
137 public void mapObjectsChanged(@NotNull
final Set<G> gameObjects, @NotNull
final Set<G> transientGameObjects) {
147 public void mapFileChanged(@Nullable
final MapFile oldMapFile) {
152 public void modifiedChanged() {
192 setLayout(
new BorderLayout());
193 final JSplitPane splitPane =
new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,
new JScrollPane(
errorList),
new JScrollPane(
errorMsg));
194 splitPane.setOneTouchExpandable(
true);
195 add(splitPane, BorderLayout.CENTER);
199 errorList.addMouseListener(
new MouseAdapter() {
202 public void mousePressed(
final MouseEvent e) {
207 mapView = mapViewManager.getActiveMapView();
249 error =
errors.elementAt(index);
250 }
catch (
final ArrayIndexOutOfBoundsException ignored) {
258 if (tmpMapView !=
null) {
259 final Iterator<G> gameObjectIterator = error.
getGameObjects().iterator();
260 if (gameObjectIterator.hasNext()) {
261 final G gameObject = gameObjectIterator.next();
264 final Iterator<MapSquare<G, A, R>> mapSquareIterator = error.
getMapSquares().iterator();
265 if (mapSquareIterator.hasNext()) {
294 errorList.setModel(
new DefaultListModel<>());
304 final List<ValidationError<G, A, R>> errorVector =
new ArrayList<>();
306 errorVector.add(validationError);
308 this.errors =
new Vector<>(errorVector);