From: <aki...@us...> - 2008-08-02 20:26:08
|
Revision: 4718 http://gridarta.svn.sourceforge.net/gridarta/?rev=4718&view=rev Author: akirschbaum Date: 2008-08-02 20:25:45 +0000 (Sat, 02 Aug 2008) Log Message: ----------- Move object chooser related classes into separate package. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/CrossfireObjectsFactory.java trunk/crossfire/src/cfeditor/gui/GameObjectAttributesPanel.java trunk/crossfire/src/cfeditor/gui/script/parameter/ArchComboBox.java trunk/crossfire/src/cfeditor/gui/script/parameter/ArchComboBoxEditor.java trunk/crossfire/src/cfeditor/gui/script/parameter/ArchParameterView.java trunk/crossfire/src/cfeditor/script/parameter/ArchParameter.java trunk/crossfire/src/cfeditor/script/parameter/PluginParameterFactory.java trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/DaimoninObjectsFactory.java trunk/daimonin/src/daieditor/gui/GameObjectAttributesPanel.java trunk/src/app/net/sf/gridarta/GridartaObjectsFactory.java trunk/src/app/net/sf/gridarta/MainControl.java trunk/src/app/net/sf/gridarta/gui/ArchetypesActions.java trunk/src/app/net/sf/gridarta/gui/GameObjectAttributesPanel.java trunk/src/app/net/sf/gridarta/gui/MainActions.java trunk/src/app/net/sf/gridarta/gui/MainView.java trunk/src/app/net/sf/gridarta/gui/ObjectChoiceDisplay.java trunk/src/app/net/sf/gridarta/gui/ReplaceDialog.java trunk/src/app/net/sf/gridarta/gui/ReplaceDialogManager.java trunk/src/app/net/sf/gridarta/gui/findarchetypes/FindArchetypesDialog.java trunk/src/app/net/sf/gridarta/gui/map/tools/DeletionTool.java trunk/src/app/net/sf/gridarta/gui/map/tools/InsertionTool.java trunk/src/app/net/sf/gridarta/gui/map/tools/SelectionTool.java trunk/src/app/net/sf/gridarta/gui/map/tools/ToolPalette.java trunk/src/app/net/sf/gridarta/gui/map/tools/ToolSelector.java trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java Added Paths: ----------- trunk/src/app/net/sf/gridarta/gui/objectchooser/ trunk/src/app/net/sf/gridarta/gui/objectchooser/ArchNPickChangeListener.java trunk/src/app/net/sf/gridarta/gui/objectchooser/DefaultObjectChooser.java trunk/src/app/net/sf/gridarta/gui/objectchooser/ObjectChooser.java Removed Paths: ------------- trunk/src/app/net/sf/gridarta/gui/ArchNPickChangeListener.java trunk/src/app/net/sf/gridarta/gui/DefaultObjectChooser.java trunk/src/app/net/sf/gridarta/gui/ObjectChooser.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-08-02 20:19:26 UTC (rev 4717) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-08-02 20:25:45 UTC (rev 4718) @@ -68,14 +68,12 @@ import net.sf.gridarta.gameobject.scripts.AbstractScriptArchEditor; import net.sf.gridarta.gameobject.scripts.ScriptedEventEditor; import net.sf.gridarta.gui.About; -import net.sf.gridarta.gui.DefaultObjectChooser; import net.sf.gridarta.gui.HideFileFilterProxy; import net.sf.gridarta.gui.MainActions; import net.sf.gridarta.gui.MainView; import net.sf.gridarta.gui.MapFileFilter; import net.sf.gridarta.gui.MapManagerActions; import net.sf.gridarta.gui.MapPreview; -import net.sf.gridarta.gui.ObjectChooser; import net.sf.gridarta.gui.RecentManager; import net.sf.gridarta.gui.ReplaceDialogManager; import net.sf.gridarta.gui.StatusBar; @@ -87,6 +85,8 @@ import net.sf.gridarta.gui.map.MapView; import net.sf.gridarta.gui.map.tools.DeletionTool; import net.sf.gridarta.gui.newmap.NewMapDialogFactory; +import net.sf.gridarta.gui.objectchooser.DefaultObjectChooser; +import net.sf.gridarta.gui.objectchooser.ObjectChooser; import net.sf.gridarta.gui.pickmapchooser.PickmapChooserControl; import net.sf.gridarta.gui.prefs.MapValidatorPrefs; import net.sf.gridarta.gui.prefs.MiscPrefs; Modified: trunk/crossfire/src/cfeditor/CrossfireObjectsFactory.java =================================================================== --- trunk/crossfire/src/cfeditor/CrossfireObjectsFactory.java 2008-08-02 20:19:26 UTC (rev 4717) +++ trunk/crossfire/src/cfeditor/CrossfireObjectsFactory.java 2008-08-02 20:25:45 UTC (rev 4718) @@ -44,11 +44,11 @@ import net.sf.gridarta.gameobject.ArchetypeSet; import net.sf.gridarta.gameobject.face.FaceObjects; import net.sf.gridarta.gameobject.match.GameObjectMatchersInstance; -import net.sf.gridarta.gui.DefaultObjectChooser; -import net.sf.gridarta.gui.ObjectChooser; import net.sf.gridarta.gui.archetypechooser.ArchetypeChooserControl; import net.sf.gridarta.gui.map.LevelRenderer; import net.sf.gridarta.gui.map.MapView; +import net.sf.gridarta.gui.objectchooser.DefaultObjectChooser; +import net.sf.gridarta.gui.objectchooser.ObjectChooser; import net.sf.gridarta.gui.selectedsquare.SelectedSquareView; import net.sf.gridarta.io.DefaultMapReader; import net.sf.gridarta.io.MapReader; Modified: trunk/crossfire/src/cfeditor/gui/GameObjectAttributesPanel.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/GameObjectAttributesPanel.java 2008-08-02 20:19:26 UTC (rev 4717) +++ trunk/crossfire/src/cfeditor/gui/GameObjectAttributesPanel.java 2008-08-02 20:25:45 UTC (rev 4718) @@ -29,8 +29,8 @@ import net.sf.gridarta.archtype.ArchetypeTypeSet; import net.sf.gridarta.gameobject.anim.AnimationObjects; import net.sf.gridarta.gameobject.match.GameObjectMatcher; -import net.sf.gridarta.gui.ObjectChooser; import net.sf.gridarta.gui.connectionview.LockedItemsControl; +import net.sf.gridarta.gui.objectchooser.ObjectChooser; import net.sf.gridarta.gui.selectedsquare.SelectedSquareControl; import net.sf.gridarta.gui.selectedsquare.SelectedSquareView; import org.jetbrains.annotations.NotNull; Modified: trunk/crossfire/src/cfeditor/gui/script/parameter/ArchComboBox.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/script/parameter/ArchComboBox.java 2008-08-02 20:19:26 UTC (rev 4717) +++ trunk/crossfire/src/cfeditor/gui/script/parameter/ArchComboBox.java 2008-08-02 20:25:45 UTC (rev 4718) @@ -27,7 +27,7 @@ import java.awt.Dimension; import javax.swing.JComboBox; import net.sf.gridarta.gui.GameObjectAttributesPanel; -import net.sf.gridarta.gui.ObjectChooser; +import net.sf.gridarta.gui.objectchooser.ObjectChooser; import org.apache.log4j.Logger; import org.jetbrains.annotations.NotNull; Modified: trunk/crossfire/src/cfeditor/gui/script/parameter/ArchComboBoxEditor.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/script/parameter/ArchComboBoxEditor.java 2008-08-02 20:19:26 UTC (rev 4717) +++ trunk/crossfire/src/cfeditor/gui/script/parameter/ArchComboBoxEditor.java 2008-08-02 20:25:45 UTC (rev 4718) @@ -45,7 +45,7 @@ import javax.swing.event.DocumentListener; import net.sf.gridarta.CommonConstants; import net.sf.gridarta.gui.GameObjectAttributesPanel; -import net.sf.gridarta.gui.ObjectChooser; +import net.sf.gridarta.gui.objectchooser.ObjectChooser; import org.jetbrains.annotations.Nullable; public class ArchComboBoxEditor implements ComboBoxEditor { Modified: trunk/crossfire/src/cfeditor/gui/script/parameter/ArchParameterView.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/script/parameter/ArchParameterView.java 2008-08-02 20:19:26 UTC (rev 4717) +++ trunk/crossfire/src/cfeditor/gui/script/parameter/ArchParameterView.java 2008-08-02 20:25:45 UTC (rev 4718) @@ -31,7 +31,7 @@ import javax.swing.JComponent; import javax.swing.JPanel; import net.sf.gridarta.gui.GameObjectAttributesPanel; -import net.sf.gridarta.gui.ObjectChooser; +import net.sf.gridarta.gui.objectchooser.ObjectChooser; import org.jetbrains.annotations.NotNull; public class ArchParameterView implements PluginParameterView { Modified: trunk/crossfire/src/cfeditor/script/parameter/ArchParameter.java =================================================================== --- trunk/crossfire/src/cfeditor/script/parameter/ArchParameter.java 2008-08-02 20:19:26 UTC (rev 4717) +++ trunk/crossfire/src/cfeditor/script/parameter/ArchParameter.java 2008-08-02 20:25:45 UTC (rev 4718) @@ -27,7 +27,7 @@ import cfeditor.gui.script.parameter.PluginParameterView; import cfeditor.map.MapArchObject; import net.sf.gridarta.gui.GameObjectAttributesPanel; -import net.sf.gridarta.gui.ObjectChooser; +import net.sf.gridarta.gui.objectchooser.ObjectChooser; import org.jdom.Element; import org.jetbrains.annotations.NotNull; Modified: trunk/crossfire/src/cfeditor/script/parameter/PluginParameterFactory.java =================================================================== --- trunk/crossfire/src/cfeditor/script/parameter/PluginParameterFactory.java 2008-08-02 20:19:26 UTC (rev 4717) +++ trunk/crossfire/src/cfeditor/script/parameter/PluginParameterFactory.java 2008-08-02 20:25:45 UTC (rev 4718) @@ -28,7 +28,7 @@ import java.util.Map; import net.sf.gridarta.MapManager; import net.sf.gridarta.gui.GameObjectAttributesPanel; -import net.sf.gridarta.gui.ObjectChooser; +import net.sf.gridarta.gui.objectchooser.ObjectChooser; import org.apache.log4j.Logger; import org.jdom.Element; import org.jetbrains.annotations.NotNull; Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-08-02 20:19:26 UTC (rev 4717) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-08-02 20:25:45 UTC (rev 4718) @@ -76,7 +76,6 @@ import net.sf.gridarta.gameobject.scripts.AbstractScriptArchEditor; import net.sf.gridarta.gameobject.scripts.ScriptedEventEditor; import net.sf.gridarta.gui.About; -import net.sf.gridarta.gui.DefaultObjectChooser; import net.sf.gridarta.gui.GUIUtils; import net.sf.gridarta.gui.HideFileFilterProxy; import net.sf.gridarta.gui.MainActions; @@ -84,7 +83,6 @@ import net.sf.gridarta.gui.MapFileFilter; import net.sf.gridarta.gui.MapManagerActions; import net.sf.gridarta.gui.MapPreview; -import net.sf.gridarta.gui.ObjectChooser; import net.sf.gridarta.gui.RecentManager; import net.sf.gridarta.gui.ReplaceDialogManager; import net.sf.gridarta.gui.StatusBar; @@ -96,6 +94,8 @@ import net.sf.gridarta.gui.map.MapView; import net.sf.gridarta.gui.map.tools.DeletionTool; import net.sf.gridarta.gui.newmap.NewMapDialogFactory; +import net.sf.gridarta.gui.objectchooser.DefaultObjectChooser; +import net.sf.gridarta.gui.objectchooser.ObjectChooser; import net.sf.gridarta.gui.pickmapchooser.PickmapChooserControl; import net.sf.gridarta.gui.prefs.MapValidatorPrefs; import net.sf.gridarta.gui.prefs.MiscPrefs; Modified: trunk/daimonin/src/daieditor/DaimoninObjectsFactory.java =================================================================== --- trunk/daimonin/src/daieditor/DaimoninObjectsFactory.java 2008-08-02 20:19:26 UTC (rev 4717) +++ trunk/daimonin/src/daieditor/DaimoninObjectsFactory.java 2008-08-02 20:25:45 UTC (rev 4718) @@ -44,11 +44,11 @@ import net.sf.gridarta.gameobject.ArchetypeSet; import net.sf.gridarta.gameobject.face.FaceObjects; import net.sf.gridarta.gameobject.match.GameObjectMatchersInstance; -import net.sf.gridarta.gui.DefaultObjectChooser; -import net.sf.gridarta.gui.ObjectChooser; import net.sf.gridarta.gui.archetypechooser.ArchetypeChooserControl; import net.sf.gridarta.gui.map.LevelRenderer; import net.sf.gridarta.gui.map.MapView; +import net.sf.gridarta.gui.objectchooser.DefaultObjectChooser; +import net.sf.gridarta.gui.objectchooser.ObjectChooser; import net.sf.gridarta.gui.selectedsquare.SelectedSquareView; import net.sf.gridarta.io.DefaultMapReader; import net.sf.gridarta.io.MapReader; Modified: trunk/daimonin/src/daieditor/gui/GameObjectAttributesPanel.java =================================================================== --- trunk/daimonin/src/daieditor/gui/GameObjectAttributesPanel.java 2008-08-02 20:19:26 UTC (rev 4717) +++ trunk/daimonin/src/daieditor/gui/GameObjectAttributesPanel.java 2008-08-02 20:25:45 UTC (rev 4718) @@ -29,8 +29,8 @@ import net.sf.gridarta.archtype.ArchetypeTypeSet; import net.sf.gridarta.gameobject.anim.AnimationObjects; import net.sf.gridarta.gameobject.match.GameObjectMatcher; -import net.sf.gridarta.gui.ObjectChooser; import net.sf.gridarta.gui.connectionview.LockedItemsControl; +import net.sf.gridarta.gui.objectchooser.ObjectChooser; import net.sf.gridarta.gui.selectedsquare.SelectedSquareControl; import net.sf.gridarta.gui.selectedsquare.SelectedSquareView; import org.jetbrains.annotations.NotNull; Modified: trunk/src/app/net/sf/gridarta/GridartaObjectsFactory.java =================================================================== --- trunk/src/app/net/sf/gridarta/GridartaObjectsFactory.java 2008-08-02 20:19:26 UTC (rev 4717) +++ trunk/src/app/net/sf/gridarta/GridartaObjectsFactory.java 2008-08-02 20:25:45 UTC (rev 4718) @@ -29,11 +29,11 @@ import net.sf.gridarta.gameobject.ArchetypeSet; import net.sf.gridarta.gameobject.GameObject; import net.sf.gridarta.gameobject.face.FaceObjects; -import net.sf.gridarta.gui.ObjectChooser; import net.sf.gridarta.gui.archetypechooser.ArchetypeChooserControl; import net.sf.gridarta.gui.map.LevelRenderer; import net.sf.gridarta.gui.map.MapView; import net.sf.gridarta.gui.map.MapViewBasic; +import net.sf.gridarta.gui.objectchooser.ObjectChooser; import net.sf.gridarta.gui.selectedsquare.SelectedSquareView; import net.sf.gridarta.io.GameObjectParser; import net.sf.gridarta.io.MapArchObjectParser; Modified: trunk/src/app/net/sf/gridarta/MainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/MainControl.java 2008-08-02 20:19:26 UTC (rev 4717) +++ trunk/src/app/net/sf/gridarta/MainControl.java 2008-08-02 20:25:45 UTC (rev 4718) @@ -23,9 +23,9 @@ import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.GameObject; import net.sf.gridarta.gui.MainView; -import net.sf.gridarta.gui.ObjectChooser; import net.sf.gridarta.gui.map.MapView; import net.sf.gridarta.gui.map.MapViewBasic; +import net.sf.gridarta.gui.objectchooser.ObjectChooser; import net.sf.gridarta.map.MapArchObject; import net.sf.gridarta.map.MapControl; import net.sf.gridarta.map.MapModel; Deleted: trunk/src/app/net/sf/gridarta/gui/ArchNPickChangeListener.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/ArchNPickChangeListener.java 2008-08-02 20:19:26 UTC (rev 4717) +++ trunk/src/app/net/sf/gridarta/gui/ArchNPickChangeListener.java 2008-08-02 20:25:45 UTC (rev 4718) @@ -1,61 +0,0 @@ -/* - * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. - * Copyright (C) 2000-2007 The Gridarta Developers. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -package net.sf.gridarta.gui; - -import javax.swing.JTabbedPane; -import javax.swing.event.ChangeEvent; -import javax.swing.event.ChangeListener; -import org.jetbrains.annotations.NotNull; - -/** - * In the left-side panel, archlist and pickmaps are exclusive (only the one - * being displayed is active). This listener gets to know which of them is - * active and keeps the object chooser informed whenever the state changes. - * @author Andreas Kirschbaum - */ -public final class ArchNPickChangeListener implements ChangeListener { - - /** The Object Chooser to inform about changes. */ - private final ObjectChooser<?, ?, ?> objectChooser; - - private final JTabbedPane tabpane; // parent pane for archlist & pickmaps - - private int selectedIndex; // current state of selection - - /** - * Create an ArchNPickChangeListener. - * @param objectChooser The Object Chooser to inform about changes. - * @param pane the JTabbedPane containing both archlist and pickmaps - */ - public ArchNPickChangeListener(@NotNull final ObjectChooser<?, ?, ?> objectChooser, @NotNull final JTabbedPane pane) { - this.objectChooser = objectChooser; - tabpane = pane; - selectedIndex = tabpane.getSelectedIndex(); - } - - public void stateChanged(final ChangeEvent e) { - if (tabpane.getSelectedIndex() != selectedIndex) { - // the state has changed, user has switched panels - objectChooser.setPickmapActive(tabpane.getSelectedIndex() != 0); - selectedIndex = tabpane.getSelectedIndex(); // save new state - } - } - -} // class ArchNPickChangeListener Modified: trunk/src/app/net/sf/gridarta/gui/ArchetypesActions.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/ArchetypesActions.java 2008-08-02 20:19:26 UTC (rev 4717) +++ trunk/src/app/net/sf/gridarta/gui/ArchetypesActions.java 2008-08-02 20:25:45 UTC (rev 4718) @@ -27,6 +27,7 @@ import net.sf.gridarta.gui.archetypechooser.ArchetypeChooserListener; import net.sf.gridarta.gui.findarchetypes.FindArchetypesDialog; import net.sf.gridarta.gui.map.MapViewBasic; +import net.sf.gridarta.gui.objectchooser.ObjectChooser; import net.sf.gridarta.map.MapArchObject; import net.sf.japi.swing.ActionFactory; import net.sf.japi.swing.ToggleAction; Deleted: trunk/src/app/net/sf/gridarta/gui/DefaultObjectChooser.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/DefaultObjectChooser.java 2008-08-02 20:19:26 UTC (rev 4717) +++ trunk/src/app/net/sf/gridarta/gui/DefaultObjectChooser.java 2008-08-02 20:25:45 UTC (rev 4718) @@ -1,208 +0,0 @@ -/* - * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. - * Copyright (C) 2000-2007 The Gridarta Developers. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -package net.sf.gridarta.gui; - -import java.awt.BorderLayout; -import java.awt.Point; -import java.util.List; -import javax.swing.JMenu; -import javax.swing.JPanel; -import javax.swing.JSplitPane; -import javax.swing.JTabbedPane; -import javax.swing.SwingConstants; -import net.sf.gridarta.CopyBuffer; -import net.sf.gridarta.EditTypes; -import net.sf.gridarta.MainControl; -import net.sf.gridarta.archtype.ArchetypeTypeSet; -import net.sf.gridarta.gameobject.Archetype; -import net.sf.gridarta.gameobject.GameObject; -import net.sf.gridarta.gui.archetypechooser.ArchetypeChooserControl; -import net.sf.gridarta.gui.archetypechooser.ArchetypeChooserListener; -import net.sf.gridarta.gui.map.MapViewBasic; -import net.sf.gridarta.gui.map.tools.ToolPalette; -import net.sf.gridarta.gui.pickmapchooser.PickmapChooserControl; -import net.sf.gridarta.gui.pickmapchooser.PickmapChooserListener; -import net.sf.gridarta.gui.selectedsquare.SelectedSquareView; -import net.sf.gridarta.map.InsertionMode; -import net.sf.gridarta.map.MapArchObject; -import net.sf.gridarta.map.MapModel; -import net.sf.japi.swing.ActionFactory; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -/** - * The object Chooser implementation. - * @author Andreas Kirschbaum - */ -public class DefaultObjectChooser<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>, V extends MapViewBasic<G, A, R, V>> extends JPanel implements ObjectChooser<G, A, R> { - - /** Action Factory. */ - private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("net.sf.gridarta"); - - /** The serial version UID. */ - private static final long serialVersionUID = 1; - - /** The archetype chooser control. */ - private final ArchetypeChooserControl<G, A, R, V> archetypeChooserControl; - - /** The archetype chooser control. */ - private final PickmapChooserControl<G, A, R, V> pickmapChooserControl; - - /** ToolSelector of this subview. */ - private final ToolPalette<G, A, R, V> toolPalette; - - /** Panel holding both archlist and pickmaps. */ - private final JTabbedPane archAndPickPane = new JTabbedPane(SwingConstants.TOP); - - /** The data/view of selected objects in tab panel. */ - private final ObjectChoiceDisplay<G, A, R, V> objectChoiceDisplay; - - /** - * The listener attached to {@link #pickmapChooserControl}. - */ - private final PickmapChooserListener pickmapChooserListener = new PickmapChooserListener() { - - /** {@inheritDoc} */ - public void activePickmapChanged() { - showObjectChooserQuickObject(null); - } - - }; - - /** - * <code>true</code> if the PickmapChooser is active, <code>false</code> if - * the Archetype Chooser is active. - */ - private boolean pickmapActive = false; - - /** - * Creates a new instance. - * @param mainControl the main control - * @param archetypeTypeSet the archetype type set - * @param editTypes the edit types instance - * @param archetypeChooserControl the archetype chooser control - * @param pickmapChooserControl the pickmap chooser control - * @param copyBuffer the copy buffer instance to use - */ - public DefaultObjectChooser(final MainControl<G, A, R, V> mainControl, @NotNull final ReplaceDialogManager<G, A, R, V> replaceDialogManager, @NotNull final ArchetypeTypeSet<G, A, R> archetypeTypeSet, @NotNull final EditTypes<G, A, R, V> editTypes, @NotNull final SelectedSquareView<G, A, R, V> selectedSquareView, @NotNull final ArchetypeChooserControl<G, A, R, V> archetypeChooserControl, @NotNull final PickmapChooserControl<G, A, R, V> pickmapChooserControl, @NotNull final CopyBuffer<G, A, R, V> copyBuffer) { - super(new BorderLayout()); - this.archetypeChooserControl = archetypeChooserControl; - this.pickmapChooserControl = pickmapChooserControl; - archetypeChooserControl.addArchetypeChooserListener(new ArchetypeChooserListener<G, A, R>() { - /** {@inheritDoc} */ - public void selectedArchetypeChanged(@Nullable final G archetype) { - showObjectChooserQuickObject(archetype); - } - - /** {@inheritDoc} */ - public void displayObjectNamesChanged(final boolean displayObjectNames) { - // ignore - } - }); - toolPalette = new ToolPalette<G, A, R, V>(mainControl, editTypes, selectedSquareView, this, pickmapChooserControl, copyBuffer); - - objectChoiceDisplay = new ObjectChoiceDisplay<G, A, R, V>(replaceDialogManager, archetypeTypeSet, this); - - // archAndPickPane is the panel containing both archpanel and pickmaps - archAndPickPane.addTab(ACTION_FACTORY.getString("objectChooser.archetypesTabTitle"), archetypeChooserControl.getArchetypePanel()); - archAndPickPane.addTab(ACTION_FACTORY.getString("objectChooser.pickmapsTabTitle"), pickmapChooserControl.getPickmapPanel()); - // this listener informs the mainview which panel is active: archlist or pickmaps? - archAndPickPane.addChangeListener(new ArchNPickChangeListener(this, archAndPickPane)); - - // TODO: introduce a tool registry - final JSplitPane splitPane = new GSplitPane(JSplitPane.VERTICAL_SPLIT, toolPalette, archAndPickPane); - splitPane.setContinuousLayout(true); - add(splitPane, BorderLayout.CENTER); - add(objectChoiceDisplay, BorderLayout.SOUTH); - } - - /** {@inheritDoc} */ - public void setPickmapActive(final boolean pickmapActive) { - this.pickmapActive = pickmapActive; - pickmapChooserControl.setActive(pickmapActive); - } - - /** {@inheritDoc} */ - public boolean isPickmapActive() { - return pickmapActive; - } - - /** {@inheritDoc} */ - public void setPickmapFoldersMenu(@Nullable final JMenu folderMenu) { - pickmapChooserControl.setPickmapFoldersMenu(folderMenu); - } - - /** - * Returns whether a given game object matches the selection. - * @param gameObject the game object to check - * @return whether the game object matches - */ - public boolean isMatching(final G gameObject) { - return pickmapActive ? pickmapChooserControl.isMatching(gameObject) : archetypeChooserControl.isMatching(gameObject); - } - - /** {@inheritDoc} */ - @Nullable - public G insertSelectedObject(@NotNull final MapModel<G, A, R> mapModel, @NotNull final Point pos, final boolean allowMany, final InsertionMode insertionMode) { - return pickmapActive ? pickmapChooserControl.insertSelectedObject(mapModel, pos, allowMany, insertionMode) : archetypeChooserControl.insertSelectedArchetype(mapModel, pos, allowMany, insertionMode); - } - - /** {@inheritDoc} */ - public void moveArchetypeChooserToFront() { - archAndPickPane.setSelectedIndex(0); - } - - /** {@inheritDoc} */ - public void movePickmapChooserToFront() { - archAndPickPane.setSelectedIndex(1); - } - - /** {@inheritDoc} */ - public void showObjectChooserQuickObject(@Nullable final G gameObject) { - objectChoiceDisplay.showObjectChooserQuickObject(gameObject); - } - - /** {@inheritDoc} */ - @Nullable - public G getObjectChooserHighlight() { - return pickmapActive ? pickmapChooserControl.getSelection() : archetypeChooserControl.getSelection(); - } - - /** {@inheritDoc} */ - @NotNull - public List<G> getObjectChooserSelection() { - return pickmapActive ? pickmapChooserControl.getSelections() : archetypeChooserControl.getSelections(); - } - - /** - * Returns the tool selector pane. - * @return The tool selector pane. - */ - public ToolPalette<G, A, R, V> getToolSelectorPane() { - return toolPalette; - } - - /** {@inheritDoc} */ - public void selectArchetype(final R archetype) { - moveArchetypeChooserToFront(); - archetypeChooserControl.selectArchetype(archetype); - } - -} // class AbstractObjectChooser Modified: trunk/src/app/net/sf/gridarta/gui/GameObjectAttributesPanel.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/GameObjectAttributesPanel.java 2008-08-02 20:19:26 UTC (rev 4717) +++ trunk/src/app/net/sf/gridarta/gui/GameObjectAttributesPanel.java 2008-08-02 20:25:45 UTC (rev 4718) @@ -60,6 +60,7 @@ import net.sf.gridarta.gui.gameobjecttexteditor.GameObjectTextEditor; import net.sf.gridarta.gui.map.MapView; import net.sf.gridarta.gui.map.MapViewBasic; +import net.sf.gridarta.gui.objectchooser.ObjectChooser; import net.sf.gridarta.gui.selectedsquare.SelectedSquareControl; import net.sf.gridarta.gui.selectedsquare.SelectedSquareListener; import net.sf.gridarta.gui.selectedsquare.SelectedSquareView; Modified: trunk/src/app/net/sf/gridarta/gui/MainActions.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/MainActions.java 2008-08-02 20:19:26 UTC (rev 4717) +++ trunk/src/app/net/sf/gridarta/gui/MainActions.java 2008-08-02 20:25:45 UTC (rev 4718) @@ -45,6 +45,7 @@ import net.sf.gridarta.gui.map.MapGridListener; import net.sf.gridarta.gui.map.MapView; import net.sf.gridarta.gui.map.MapViewBasic; +import net.sf.gridarta.gui.objectchooser.ObjectChooser; import net.sf.gridarta.gui.pickmapchooser.PickmapChooserControl; import net.sf.gridarta.map.InsertionMode; import net.sf.gridarta.map.MapArchObject; Modified: trunk/src/app/net/sf/gridarta/gui/MainView.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/MainView.java 2008-08-02 20:19:26 UTC (rev 4717) +++ trunk/src/app/net/sf/gridarta/gui/MainView.java 2008-08-02 20:25:45 UTC (rev 4718) @@ -52,6 +52,7 @@ import net.sf.gridarta.gui.map.MapView; import net.sf.gridarta.gui.map.MapViewBasic; import net.sf.gridarta.gui.map.ViewActions; +import net.sf.gridarta.gui.objectchooser.DefaultObjectChooser; import net.sf.gridarta.gui.selectedsquare.SelectedSquareView; import net.sf.gridarta.help.Help; import net.sf.gridarta.map.MapArchObject; Modified: trunk/src/app/net/sf/gridarta/gui/ObjectChoiceDisplay.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/ObjectChoiceDisplay.java 2008-08-02 20:19:26 UTC (rev 4717) +++ trunk/src/app/net/sf/gridarta/gui/ObjectChoiceDisplay.java 2008-08-02 20:25:45 UTC (rev 4718) @@ -29,6 +29,7 @@ import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.GameObject; import net.sf.gridarta.gui.map.MapViewBasic; +import net.sf.gridarta.gui.objectchooser.ObjectChooser; import net.sf.gridarta.map.MapArchObject; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; Deleted: trunk/src/app/net/sf/gridarta/gui/ObjectChooser.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/ObjectChooser.java 2008-08-02 20:19:26 UTC (rev 4717) +++ trunk/src/app/net/sf/gridarta/gui/ObjectChooser.java 2008-08-02 20:25:45 UTC (rev 4718) @@ -1,119 +0,0 @@ -/* - * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. - * Copyright (C) 2000-2007 The Gridarta Developers. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -package net.sf.gridarta.gui; - -import java.awt.Point; -import java.util.List; -import javax.swing.JMenu; -import net.sf.gridarta.gameobject.Archetype; -import net.sf.gridarta.gameobject.GameObject; -import net.sf.gridarta.map.InsertionMode; -import net.sf.gridarta.map.MapArchObject; -import net.sf.gridarta.map.MapModel; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -/** - * Common base interface for ObjectChoosers. - * @author <a href="mailto:ch...@ri...">Christian Hujer</a> - */ -public interface ObjectChooser<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> { - - /** - * Return if the Pickmap Chooser is active. - * @return <code>true</code> if the Pickmap Chooser is active, or - * <code>false</code> if the Archetype Chooser is active. - */ - boolean isPickmapActive(); - - /** - * Set whether the Pickmap Chooser is active. - * @param pickmapActive <code>true</code> if the Pickmap Chooser is active, - * <code>false</code> if the Archetype Chooser is active. - */ - void setPickmapActive(boolean pickmapActive); - - /** - * Show the given game object's attributes in the quick panel. - * @param gameObject the game object to show, or <code>null</code> to clear - * the attributes - */ - void showObjectChooserQuickObject(@Nullable G gameObject); - - /** Move the Archetype Chooser in front of the Pickmap Chooser. */ - void moveArchetypeChooserToFront(); - - /** Move the Pickmap Chooser in front of the Archetype Chooser. */ - void movePickmapChooserToFront(); - - /** - * Returns the active arch in the left-side panel. This can either be a - * default arch from the archlist, or a custom arch from a pickmap. - * IMPORTANT: The returned GameObject is not a clone. A copy must be - * generated before inserting such an arch to the map. - * @return the active arch in the left-side panel - */ - @Nullable - G getObjectChooserHighlight(); - - /** - * Returns the selected arches in the left-side panel. This can either be - * default arches, or custom arches from a pickmap. IMPORTANT: The returned - * GameObject list contains no clone. A copy must be generated before - * inserting such arches to the map. - * @return the selected arches in the left-side panel - */ - @NotNull - List<G> getObjectChooserSelection(); - - /** - * Select an archetype in the archetype chooser. If necessary, activates - * archetype chooser. - * @param archetype The archetype to selected. - */ - void selectArchetype(R archetype); - - /** - * Add the selected game object to the map. - * @param mapModel the map model to add to - * @param pos The location to add to. - * @param allowMany Whether to allow multiple copies of the inserted game - * object. - * @param insertionMode the insertion mode to use - * @return The inserted game object, or <code>null</code> if nothing was - * inserted. - */ - @Nullable - G insertSelectedObject(@NotNull final MapModel<G, A, R> mapModel, @NotNull Point pos, boolean allowMany, InsertionMode insertionMode); - - /** - * Sets the pickmap folders menu to manage. - * @param folderMenu the pickmap folders menu - */ - void setPickmapFoldersMenu(@Nullable JMenu folderMenu); - - /** - * Returns whether the current selection matches a given game object. - * @param gameObject the game object to match - * @return whether the game object matches the selection - */ - boolean isMatching(final G gameObject); - -} // interface ObjectChooser Modified: trunk/src/app/net/sf/gridarta/gui/ReplaceDialog.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/ReplaceDialog.java 2008-08-02 20:19:26 UTC (rev 4717) +++ trunk/src/app/net/sf/gridarta/gui/ReplaceDialog.java 2008-08-02 20:25:45 UTC (rev 4718) @@ -45,6 +45,7 @@ import net.sf.gridarta.gameobject.GameObject; import net.sf.gridarta.gui.map.MapView; import net.sf.gridarta.gui.map.MapViewBasic; +import net.sf.gridarta.gui.objectchooser.ObjectChooser; import net.sf.gridarta.map.InsertionMode; import net.sf.gridarta.map.MapArchObject; import net.sf.gridarta.map.MapControl; Modified: trunk/src/app/net/sf/gridarta/gui/ReplaceDialogManager.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/ReplaceDialogManager.java 2008-08-02 20:19:26 UTC (rev 4717) +++ trunk/src/app/net/sf/gridarta/gui/ReplaceDialogManager.java 2008-08-02 20:25:45 UTC (rev 4718) @@ -6,6 +6,7 @@ import net.sf.gridarta.gameobject.ArchetypeSet; import net.sf.gridarta.gameobject.GameObject; import net.sf.gridarta.gui.map.MapViewBasic; +import net.sf.gridarta.gui.objectchooser.ObjectChooser; import net.sf.gridarta.map.MapArchObject; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; Modified: trunk/src/app/net/sf/gridarta/gui/findarchetypes/FindArchetypesDialog.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/findarchetypes/FindArchetypesDialog.java 2008-08-02 20:19:26 UTC (rev 4717) +++ trunk/src/app/net/sf/gridarta/gui/findarchetypes/FindArchetypesDialog.java 2008-08-02 20:25:45 UTC (rev 4718) @@ -47,8 +47,8 @@ import net.sf.gridarta.archtype.ArchetypeTypeSet; import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.GameObject; -import net.sf.gridarta.gui.ObjectChooser; import net.sf.gridarta.gui.archetypechooser.ArchetypeChooserControl; +import net.sf.gridarta.gui.objectchooser.ObjectChooser; import net.sf.gridarta.map.MapArchObject; import net.sf.japi.swing.ActionFactory; import org.jetbrains.annotations.NotNull; Modified: trunk/src/app/net/sf/gridarta/gui/map/tools/DeletionTool.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/tools/DeletionTool.java 2008-08-02 20:19:26 UTC (rev 4717) +++ trunk/src/app/net/sf/gridarta/gui/map/tools/DeletionTool.java 2008-08-02 20:25:45 UTC (rev 4718) @@ -31,10 +31,10 @@ import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.GameObject; import net.sf.gridarta.gameobject.match.GameObjectMatcher; -import net.sf.gridarta.gui.ObjectChooser; import net.sf.gridarta.gui.map.MapCursor; import net.sf.gridarta.gui.map.MapViewBasic; import net.sf.gridarta.gui.map.event.MouseOpEvent; +import net.sf.gridarta.gui.objectchooser.ObjectChooser; import net.sf.gridarta.gui.pickmapchooser.PickmapChooserControl; import net.sf.gridarta.gui.undo.SwingUtils; import net.sf.gridarta.map.MapArchObject; Modified: trunk/src/app/net/sf/gridarta/gui/map/tools/InsertionTool.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/tools/InsertionTool.java 2008-08-02 20:19:26 UTC (rev 4717) +++ trunk/src/app/net/sf/gridarta/gui/map/tools/InsertionTool.java 2008-08-02 20:25:45 UTC (rev 4718) @@ -27,10 +27,10 @@ import javax.swing.JPanel; import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.GameObject; -import net.sf.gridarta.gui.ObjectChooser; import net.sf.gridarta.gui.map.MapCursor; import net.sf.gridarta.gui.map.MapViewBasic; import net.sf.gridarta.gui.map.event.MouseOpEvent; +import net.sf.gridarta.gui.objectchooser.ObjectChooser; import net.sf.gridarta.gui.pickmapchooser.PickmapChooserControl; import net.sf.gridarta.gui.selectedsquare.SelectedSquareView; import net.sf.gridarta.gui.undo.SwingUtils; Modified: trunk/src/app/net/sf/gridarta/gui/map/tools/SelectionTool.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/tools/SelectionTool.java 2008-08-02 20:19:26 UTC (rev 4717) +++ trunk/src/app/net/sf/gridarta/gui/map/tools/SelectionTool.java 2008-08-02 20:25:45 UTC (rev 4718) @@ -29,11 +29,11 @@ import net.sf.gridarta.CopyBuffer; import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.GameObject; -import net.sf.gridarta.gui.ObjectChooser; import net.sf.gridarta.gui.map.MapCursor; import net.sf.gridarta.gui.map.MapGrid; import net.sf.gridarta.gui.map.MapViewBasic; import net.sf.gridarta.gui.map.event.MouseOpEvent; +import net.sf.gridarta.gui.objectchooser.ObjectChooser; import net.sf.gridarta.gui.undo.SwingUtils; import net.sf.gridarta.map.InsertionMode; import net.sf.gridarta.map.MapArchObject; Modified: trunk/src/app/net/sf/gridarta/gui/map/tools/ToolPalette.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/tools/ToolPalette.java 2008-08-02 20:19:26 UTC (rev 4717) +++ trunk/src/app/net/sf/gridarta/gui/map/tools/ToolPalette.java 2008-08-02 20:25:45 UTC (rev 4718) @@ -30,9 +30,9 @@ import net.sf.gridarta.MainControl; import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.GameObject; -import net.sf.gridarta.gui.ObjectChooser; import net.sf.gridarta.gui.map.MapViewBasic; import net.sf.gridarta.gui.map.event.MouseOpEvent; +import net.sf.gridarta.gui.objectchooser.ObjectChooser; import net.sf.gridarta.gui.pickmapchooser.PickmapChooserControl; import net.sf.gridarta.gui.selectedsquare.SelectedSquareView; import net.sf.gridarta.map.MapArchObject; Modified: trunk/src/app/net/sf/gridarta/gui/map/tools/ToolSelector.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/tools/ToolSelector.java 2008-08-02 20:19:26 UTC (rev 4717) +++ trunk/src/app/net/sf/gridarta/gui/map/tools/ToolSelector.java 2008-08-02 20:25:45 UTC (rev 4718) @@ -37,8 +37,8 @@ import net.sf.gridarta.MainControl; import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.GameObject; -import net.sf.gridarta.gui.ObjectChooser; import net.sf.gridarta.gui.map.MapViewBasic; +import net.sf.gridarta.gui.objectchooser.ObjectChooser; import net.sf.gridarta.gui.pickmapchooser.PickmapChooserControl; import net.sf.gridarta.gui.selectedsquare.SelectedSquareView; import net.sf.gridarta.map.MapArchObject; Copied: trunk/src/app/net/sf/gridarta/gui/objectchooser/ArchNPickChangeListener.java (from rev 4717, trunk/src/app/net/sf/gridarta/gui/ArchNPickChangeListener.java) =================================================================== --- trunk/src/app/net/sf/gridarta/gui/objectchooser/ArchNPickChangeListener.java (rev 0) +++ trunk/src/app/net/sf/gridarta/gui/objectchooser/ArchNPickChangeListener.java 2008-08-02 20:25:45 UTC (rev 4718) @@ -0,0 +1,61 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2007 The Gridarta Developers. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package net.sf.gridarta.gui.objectchooser; + +import javax.swing.JTabbedPane; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; +import org.jetbrains.annotations.NotNull; + +/** + * In the left-side panel, archlist and pickmaps are exclusive (only the one + * being displayed is active). This listener gets to know which of them is + * active and keeps the object chooser informed whenever the state changes. + * @author Andreas Kirschbaum + */ +public final class ArchNPickChangeListener implements ChangeListener { + + /** The Object Chooser to inform about changes. */ + private final ObjectChooser<?, ?, ?> objectChooser; + + private final JTabbedPane tabpane; // parent pane for archlist & pickmaps + + private int selectedIndex; // current state of selection + + /** + * Create an ArchNPickChangeListener. + * @param objectChooser The Object Chooser to inform about changes. + * @param pane the JTabbedPane containing both archlist and pickmaps + */ + public ArchNPickChangeListener(@NotNull final ObjectChooser<?, ?, ?> objectChooser, @NotNull final JTabbedPane pane) { + this.objectChooser = objectChooser; + tabpane = pane; + selectedIndex = tabpane.getSelectedIndex(); + } + + public void stateChanged(final ChangeEvent e) { + if (tabpane.getSelectedIndex() != selectedIndex) { + // the state has changed, user has switched panels + objectChooser.setPickmapActive(tabpane.getSelectedIndex() != 0); + selectedIndex = tabpane.getSelectedIndex(); // save new state + } + } + +} // class ArchNPickChangeListener Property changes on: trunk/src/app/net/sf/gridarta/gui/objectchooser/ArchNPickChangeListener.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:mergeinfo + Added: svn:eol-style + LF Copied: trunk/src/app/net/sf/gridarta/gui/objectchooser/DefaultObjectChooser.java (from rev 4716, trunk/src/app/net/sf/gridarta/gui/DefaultObjectChooser.java) =================================================================== --- trunk/src/app/net/sf/gridarta/gui/objectchooser/DefaultObjectChooser.java (rev 0) +++ trunk/src/app/net/sf/gridarta/gui/objectchooser/DefaultObjectChooser.java 2008-08-02 20:25:45 UTC (rev 4718) @@ -0,0 +1,211 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2007 The Gridarta Developers. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package net.sf.gridarta.gui.objectchooser; + +import java.awt.BorderLayout; +import java.awt.Point; +import java.util.List; +import javax.swing.JMenu; +import javax.swing.JPanel; +import javax.swing.JSplitPane; +import javax.swing.JTabbedPane; +import javax.swing.SwingConstants; +import net.sf.gridarta.CopyBuffer; +import net.sf.gridarta.EditTypes; +import net.sf.gridarta.MainControl; +import net.sf.gridarta.archtype.ArchetypeTypeSet; +import net.sf.gridarta.gameobject.Archetype; +import net.sf.gridarta.gameobject.GameObject; +import net.sf.gridarta.gui.GSplitPane; +import net.sf.gridarta.gui.ObjectChoiceDisplay; +import net.sf.gridarta.gui.ReplaceDialogManager; +import net.sf.gridarta.gui.archetypechooser.ArchetypeChooserControl; +import net.sf.gridarta.gui.archetypechooser.ArchetypeChooserListener; +import net.sf.gridarta.gui.map.MapViewBasic; +import net.sf.gridarta.gui.map.tools.ToolPalette; +import net.sf.gridarta.gui.pickmapchooser.PickmapChooserControl; +import net.sf.gridarta.gui.pickmapchooser.PickmapChooserListener; +import net.sf.gridarta.gui.selectedsquare.SelectedSquareView; +import net.sf.gridarta.map.InsertionMode; +import net.sf.gridarta.map.MapArchObject; +import net.sf.gridarta.map.MapModel; +import net.sf.japi.swing.ActionFactory; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * The object Chooser implementation. + * @author Andreas Kirschbaum + */ +public class DefaultObjectChooser<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>, V extends MapViewBasic<G, A, R, V>> extends JPanel implements ObjectChooser<G, A, R> { + + /** Action Factory. */ + private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("net.sf.gridarta"); + + /** The serial version UID. */ + private static final long serialVersionUID = 1; + + /** The archetype chooser control. */ + private final ArchetypeChooserControl<G, A, R, V> archetypeChooserControl; + + /** The archetype chooser control. */ + private final PickmapChooserControl<G, A, R, V> pickmapChooserControl; + + /** ToolSelector of this subview. */ + private final ToolPalette<G, A, R, V> toolPalette; + + /** Panel holding both archlist and pickmaps. */ + private final JTabbedPane archAndPickPane = new JTabbedPane(SwingConstants.TOP); + + /** The data/view of selected objects in tab panel. */ + private final ObjectChoiceDisplay<G, A, R, V> objectChoiceDisplay; + + /** + * The listener attached to {@link #pickmapChooserControl}. + */ + private final PickmapChooserListener pickmapChooserListener = new PickmapChooserListener() { + + /** {@inheritDoc} */ + public void activePickmapChanged() { + showObjectChooserQuickObject(null); + } + + }; + + /** + * <code>true</code> if the PickmapChooser is active, <code>false</code> if + * the Archetype Chooser is active. + */ + private boolean pickmapActive = false; + + /** + * Creates a new instance. + * @param mainControl the main control + * @param archetypeTypeSet the archetype type set + * @param editTypes the edit types instance + * @param archetypeChooserControl the archetype chooser control + * @param pickmapChooserControl the pickmap chooser control + * @param copyBuffer the copy buffer instance to use + */ + public DefaultObjectChooser(final MainControl<G, A, R, V> mainControl, @NotNull final ReplaceDialogManager<G, A, R, V> replaceDialogManager, @NotNull final ArchetypeTypeSet<G, A, R> archetypeTypeSet, @NotNull final EditTypes<G, A, R, V> editTypes, @NotNull final SelectedSquareView<G, A, R, V> selectedSquareView, @NotNull final ArchetypeChooserControl<G, A, R, V> archetypeChooserControl, @NotNull final PickmapChooserControl<G, A, R, V> pickmapChooserControl, @NotNull final CopyBuffer<G, A, R, V> copyBuffer) { + super(new BorderLayout()); + this.archetypeChooserControl = archetypeChooserControl; + this.pickmapChooserControl = pickmapChooserControl; + archetypeChooserControl.addArchetypeChooserListener(new ArchetypeChooserListener<G, A, R>() { + /** {@inheritDoc} */ + public void selectedArchetypeChanged(@Nullable final G archetype) { + showObjectChooserQuickObject(archetype); + } + + /** {@inheritDoc} */ + public void displayObjectNamesChanged(final boolean displayObjectNames) { + // ignore + } + }); + toolPalette = new ToolPalette<G, A, R, V>(mainControl, editTypes, selectedSquareView, this, pickmapChooserControl, copyBuffer); + + objectChoiceDisplay = new ObjectChoiceDisplay<G, A, R, V>(replaceDialogManager, archetypeTypeSet, this); + + // archAndPickPane is the panel containing both archpanel and pickmaps + archAndPickPane.addTab(ACTION_FACTORY.getString("objectChooser.archetypesTabTitle"), archetypeChooserControl.getArchetypePanel()); + archAndPickPane.addTab(ACTION_FACTORY.getString("objectChooser.pickmapsTabTitle"), pickmapChooserControl.getPickmapPanel()); + // this listener informs the mainview which panel is active: archlist or pickmaps? + archAndPickPane.addChangeListener(new ArchNPickChangeListener(this, archAndPickPane)); + + // TODO: introduce a tool registry + final JSplitPane splitPane = new GSplitPane(JSplitPane.VERTICAL_SPLIT, toolPalette, archAndPickPane); + splitPane.setContinuousLayout(true); + add(splitPane, BorderLayout.CENTER); + add(objectChoiceDisplay, BorderLayout.SOUTH); + } + + /** {@inheritDoc} */ + public void setPickmapActive(final boolean pickmapActive) { + this.pickmapActive = pickmapActive; + pickmapChooserControl.setActive(pickmapActive); + } + + /** {@inheritDoc} */ + public boolean isPickmapActive() { + return pickmapActive; + } + + /** {@inheritDoc} */ + public void setPickmapFoldersMenu(@Nullable final JMenu folderMenu) { + pickmapChooserControl.setPickmapFoldersMenu(folderMenu); + } + + /** + * Returns whether a given game object matches the selection. + * @param gameObject the game object to check + * @return whether the game object matches + */ + public boolean isMatching(final G gameObject) { + return pickmapActive ? pickmapChooserControl.isMatching(gameObject) : archetypeChooserControl.isMatching(gameObject); + } + + /** {@inheritDoc} */ + @Nullable + public G insertSelectedObject(@NotNull final MapModel<G, A, R> mapModel, @NotNull final Point pos, final boolean allowMany, final InsertionMode insertionMode) { + return pickmapActive ? pickmapChooserControl.insertSelectedObject(mapModel, pos, allowMany, insertionMode) : archetypeChooserControl.insertSelectedArchetype(mapModel, pos, allowMany, insertionMode); + } + + /** {@inheritDoc} */ + public void moveArchetypeChooserToFront() { + archAndPickPane.setSelectedIndex(0); + } + + /** {@inheritDoc} */ + public void movePickmapChooserToFront() { + archAndPickPane.setSelectedIndex(1); + } + + /** {@inheritDoc} */ + public void showObjectChooserQuickObject(@Nullable final G gameObject) { + objectChoiceDisplay.showObjectChooserQuickObject(gameObject); + } + + /** {@inheritDoc} */ + @Nullable + public G getObjectChooserHighlight() { + return pickmapActive ? pickmapChooserControl.getSelection() : archetypeChooserControl.getSelection(); + } + + /** {@inheritDoc} */ + @NotNull + public List<G> getObjectChooserSelection() { + return pickmapActive ? pickmapChooserControl.getSelections() : archetypeChooserControl.getSelections(); + } + + /** + * Returns the tool selector pane. + * @return The tool selector pane. + */ + public ToolPalette<G, A, R, V> getToolSelectorPane() { + return toolPalette; + } + + /** {@inheritDoc} */ + public void selectArchetype(final R archetype) { + moveArchetypeChooserToFront(); + archetypeChooserControl.selectArchetype(archetype); + } + +} // class AbstractObjectChooser Copied: trunk/src/app/net/sf/gridarta/gui/objectchooser/ObjectChooser.java (from rev 4716, trunk/src/app/net/sf/gridarta/gui/ObjectChooser.java) =================================================================== --- trunk/src/app/net/sf/gridarta/gui/objectchooser/ObjectChooser.java (rev 0) +++ trunk/src/app/net/sf/gridarta/gui/objectchooser/ObjectChooser.java 2008-08-02 20:25:45 UTC (rev 4718) @@ -0,0 +1,119 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2007 The Gridarta Developers. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package net.sf.gridarta.gui.objectchooser; + +import java.awt.Point; +import java.util.List; +import javax.swing.JMenu; +import net.sf.gridarta.gameobject.Archetype; +import net.sf.gridarta.gameobject.GameObject; +import net.sf.gridarta.map.InsertionMode; +import net.sf.gridarta.map.MapArchObject; +import net.sf.gridarta.map.MapModel; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * Common base interface for ObjectChoosers. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + */ +public interface ObjectChooser<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> { + + /** + * Return if the Pickmap Chooser is active. + * @return <code>true</code> if the Pickmap Chooser is active, or + * <code>false</code> if the Archetype Chooser is active. + */ + boolean isPickmapActive(); + + /** + * Set whether the Pickmap Chooser is active. + * @param pickmapActive <code>true</code> if the Pickmap Chooser is active, + * <code>false</code> if the Archetype Chooser is active. + */ + void setPickmapActive(boolean pickmapActive); + + /** + * Show the given game object's attributes in the quick panel. + * @param gameObject the game object to show, or <code>null</code> to clear + * the attributes + */ + void showObjectChooserQuickObject(@Nullable G gameObject); + + /** Move the Archetype Chooser in front of the Pickmap Chooser. */ + void moveArchetypeChooserToFront(); + + /** Move the Pickmap Chooser in front of the Archetype Chooser. */ + void movePickmapChooserToFront(); + + /** + * Returns the active arch in the left-side panel. This can either be a + * default arch from the archlist, or a custom arch from a pickmap. + * IMPORTANT: The returned GameObject is not a clone. A copy must be + * generated before inserting such an arch to the map. + * @return the active arch in the left-side panel + */ + @Nullable + G getObjectChooserHighlight(); + + /** + * Returns the selected arches in the left-side panel. This can either be + * default arches, or custom arches from a pickmap. IMPORTANT: The returned + * GameObject list contains no clone. A copy must be generated before + * inserting such arches to the map. + * @return the selected arches in the left-side panel + */ + @NotNull + List<G> getObjectChooserSelection(); + + /** + * Select an archetype in the archetype chooser. If necessary, activates + * archetype chooser. + * @param archetype The archetype to selected. + */ + void selectArchetype(R archetype); + + /** + * Add the selected game object to the map. + * @param mapModel the map model to add to + * @param pos The location to add to. + * @param allowMany Whether to allow multiple copies of the inserted game + * object. + * @param insertionMode the insertion mode to use + * @return The inserted game object, or <code>null</code> if nothing was + * inserted. + */ + @Nullable + G insertSelectedObject(@NotNull final MapModel<G, A, R> mapModel, @NotNull Point pos, boolean allowMany, InsertionMode insertionMode); + + /** + * Sets the pickmap folders menu to manage. + * @param folderMenu the pickmap folders menu + */ + void setPickmapFoldersMenu(@Nullable JMenu folderMenu); + + /** + * Returns whether the current selection matches a given game object. + * @param gameObject the game object to match + * @return whether the game object matches the selection + */ + boolean isMatching(final G gameObject); + +} // interface ObjectChooser Property changes on: trunk/src/app/net/sf/gridarta/gui/objectchooser/ObjectChooser.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:mergeinfo + Added: svn:eol-style + LF Modified: trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java =================================================================== --- trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java 2008-08-02 20:19:26 UTC (rev 4717) +++ trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java 2008-08-02 20:25:45 UTC (rev 4718) @@ -53,11 +53,11 @@ import net.sf.gridarta.gameobject.match.GameObjectMatcher; import net.sf.gridarta.gui.GameObjectAttributesPanel; import net.sf.gridarta.gui.MainView; -import net.sf.gridarta.gui.ObjectChooser; import net.sf.gridarta.gui.archetypechooser.ArchetypeChooserControl; import net.sf.gridarta.gui.map.LevelRenderer; import net.sf.gridarta.gui.map.MapView; import net.sf.gridarta.gui.map.MapViewBasic; +import net.sf.gridarta.gui.objectchooser.ObjectChooser; import net.sf.gridarta.gui.selectedsquare.SelectedSquareView; import net.sf.gridarta.io.GameObjectPars... [truncated message content] |