Go to the documentation of this file.
20 package net.sf.gridarta.gui.panel.gameobjectattributes;
22 import java.awt.BorderLayout;
23 import java.awt.Component;
24 import java.awt.Container;
25 import java.awt.GridLayout;
26 import java.util.Collection;
27 import java.util.HashSet;
28 import java.util.IdentityHashMap;
30 import java.util.Map.Entry;
32 import java.util.concurrent.CopyOnWriteArrayList;
33 import javax.swing.Action;
34 import javax.swing.JButton;
35 import javax.swing.JLabel;
36 import javax.swing.JPanel;
37 import javax.swing.JTabbedPane;
38 import javax.swing.SwingConstants;
62 import net.
sf.japi.swing.action.ActionBuilder;
63 import net.
sf.japi.swing.action.ActionBuilderFactory;
64 import net.
sf.japi.swing.action.ActionMethod;
65 import org.jetbrains.annotations.NotNull;
66 import org.jetbrains.annotations.Nullable;
84 private static final ActionBuilder
ACTION_BUILDER = ActionBuilderFactory.getInstance().getActionBuilder(
"net.sf.gridarta");
121 private final JTabbedPane
panelDesktop =
new JTabbedPane(SwingConstants.TOP);
134 private final Collection<GameObjectAttributesControlListener>
listeners =
new CopyOnWriteArrayList<>();
175 private final Collection<GameObjectAttributesTab<G, A, R>>
tabs =
new HashSet<>();
181 private final Map<GameObjectAttributesTab<G, A, R>, Integer>
tabIndex =
new IdentityHashMap<>();
187 private final Map<Component, GameObjectAttributesTab<G, A, R>>
componentTabs =
new IdentityHashMap<>();
223 public void mapCreated(@NotNull
final MapControl<G, A, R> mapControl,
final boolean interactive) {
246 public void mapSizeChanged(@NotNull
final Size2D newSize) {
257 for (
final Iterable<G> mapSquare : mapSquares) {
258 for (
final G gameObject : mapSquare) {
259 if (gameObject == topGameObject) {
267 public void mapObjectsChanged(@NotNull
final Set<G> gameObjects, @NotNull
final Set<G> transientGameObjects) {
281 public void mapFileChanged(@Nullable
final MapFile oldMapFile) {
286 public void modifiedChanged() {
301 public void preBeginTransaction() {
307 public void beginTransaction(@NotNull
final String
name) {
317 public void postEndTransaction() {
330 public void selectionChanged(@Nullable
final MapSquare<G, A, R> mapSquare, @Nullable
final G gameObject) {
350 public void refreshSelectedGameObject() {
368 public void apply() {
386 public GameObjectAttributesControl(@NotNull
final GameObjectAttributesModel<G, A, R> gameObjectAttributesModel, @NotNull
final GameObjectAttributesDialogFactory<G, A, R> gameObjectAttributesDialogFactory, @NotNull
final ObjectChooser<G, A, R> objectChooser, @NotNull
final MapManager<G, A, R> mapManager, @NotNull
final SelectedSquareModel<G, A, R> selectedSquareModel, @NotNull
final GameObjectFactory<G, A, R> gameObjectFactory, @NotNull
final MapViewSettings mapViewSettings) {
387 super(
new BorderLayout());
395 final Container mapArchPanel =
new JPanel();
396 mapArchPanel.setLayout(
new BorderLayout());
397 add(mapArchPanel, BorderLayout.CENTER);
400 buttonPanel.setLayout(
new GridLayout(0, 1));
401 mapArchPanel.add(buttonPanel, BorderLayout.WEST);
460 if (!
tabs.contains(tab)) {
461 throw new IllegalArgumentException(
"undefined tab: " + tab);
473 final Component component =
panelDesktop.getSelectedComponent();
485 final Integer index =
tabIndex.get(tab);
491 final JLabel title =
new JLabel(
panelDesktop.getTitleAt(index));
492 title.setForeground(tabSeverity.getColor());
495 Severity mainSeverity = tabSeverity;
497 final Severity tmpSeverity = pair2.getKey().getTabSeverity();
499 mainSeverity = tmpSeverity;
507 listener.severityChanged(mainSeverity);
553 if (gameObject ==
null) {
578 if (baseObject ==
null) {
583 if (prevGameObject ==
null) {
592 if (insertedGameObject !=
null) {
594 insertedGameObject.addLast(prevGameObject);
625 if (gameObject ==
null) {
630 if (mapSquare ==
null) {
636 boolean canApply =
false;
638 if (tab.canApply()) {
651 if (tab.canApply()) {
666 final Container buttonPanel =
new JPanel();
final SelectedSquareModel< G, A, R > selectedSquareModel
final Action aMapArchAttribute
final JTabbedPane panelDesktop
static final ActionBuilder ACTION_BUILDER
G insertArchToMap(@NotNull BaseObject< G, A, R, ?> templateBaseObject, @Nullable G nextGameObject, @NotNull Point pos, boolean join)
MapSquare< G, A, R > getMapSquareOptional()
final GameObjectAttributesDialogFactory< G, A, R > gameObjectAttributesDialogFactory
void addGameObjectAttributesControlListener(@NotNull final GameObjectAttributesControlListener listener)
MapSquare< G, A, R > getMapSquare()
void addGameObjectAttributesModelListener(@NotNull final GameObjectAttributesModelListener< G, A, R > listener)
MapModel< G, A, R > getMapModel()
void autoApplyArchPanelChanges()
final MapModelListener< G, A, R > mapModelListener
void showAttributeDialog(@NotNull final G gameObject)
MapSquare< G, A, R > getMapSquare()
final ObjectChooser< G, A, R > objectChooser
void removeMapTransactionListener(@NotNull MapTransactionListener< G, A, R > listener)
void fireRefreshSelectedGameObject()
GameObjectAttributesTab< G, A, R > getSelectedTab()
final SelectedSquareModelListener< G, A, R > selectedSquareModelListener
void createInventory(@NotNull GameObject< G, A, R > gameObject, @NotNull Iterable< G > archetype)
final MapTransactionListener< G, A, R > mapTransactionListener
Container createButtonPanel()
final Collection< GameObjectAttributesTab< G, A, R > > tabs
void beginTransaction(@NotNull String name)
final GameObjectAttributesModel< G, A, R > gameObjectAttributesModel
final MapManagerListener< G, A, R > mapManagerListener
void setTabSeverity(@NotNull final GameObjectAttributesTab< G, A, R > tab, @NotNull final Severity tabSeverity)
final Action aMapArchAddEnv
void removeGameObject(@NotNull G gameObject, boolean join)
void applyArchPanelChanges()
void removeGameObjectAttributesControlListener(@NotNull final GameObjectAttributesControlListener listener)
void addLast(@NotNull G gameObject)
GameObjectAttributesControl(@NotNull final GameObjectAttributesModel< G, A, R > gameObjectAttributesModel, @NotNull final GameObjectAttributesDialogFactory< G, A, R > gameObjectAttributesDialogFactory, @NotNull final ObjectChooser< G, A, R > objectChooser, @NotNull final MapManager< G, A, R > mapManager, @NotNull final SelectedSquareModel< G, A, R > selectedSquareModel, @NotNull final GameObjectFactory< G, A, R > gameObjectFactory, @NotNull final MapViewSettings mapViewSettings)
void addTabInt(final GameObjectAttributesTab< G, A, R > tab)
void removeMapModelListener(@NotNull MapModelListener< G, A, R > listener)
final Action aMapArchAddInv
final Map< GameObjectAttributesTab< G, A, R >, Integer > tabIndex
final Map< Component, GameObjectAttributesTab< G, A, R > > componentTabs
static String getString(@NotNull final ActionBuilder actionBuilder, @NotNull final String key, @NotNull final String defaultValue)
void setSelectedGameObject(@Nullable final G gameObject)
final GameObjectAttributesModelListener< G, A, R > gameObjectAttributesModelListener
boolean isInMapTransaction
boolean isInAutoApplyArchPanelChanges
final GameObjectFactory< G, A, R > gameObjectFactory
BaseObject< G, A, R, ?> getSelection()
final GameObjectAttributesTabListener< G, A, R > gameObjectAttributesTabListener
MapControl< G, A, R > currentMapControl
void addMapModelListener(@NotNull MapModelListener< G, A, R > listener)
void addSelectedSquareListener(@NotNull final SelectedSquareModelListener< G, A, R > listener)
void addTab(@NotNull final GameObjectAttributesTab< G, A, R > tab)
void addMapTransactionListener(@NotNull MapTransactionListener< G, A, R > listener)
final MapViewSettings mapViewSettings
void setSelectedGameObject(@Nullable final G selectedGameObject)
MapModel< G, A, R > getMapModel()
final Collection< GameObjectAttributesControlListener > listeners
static final long serialVersionUID
void selectTab(@NotNull final GameObjectAttributesTab< G, A, R > tab)
void addGameObjectAttributesTabListener(@NotNull GameObjectAttributesTabListener< G, A, R > listener)
G getSelectedGameObject()