From: <chr...@us...> - 2006-12-30 15:02:12
|
Revision: 1335 http://svn.sourceforge.net/gridarta/?rev=1335&view=rev Author: christianhujer Date: 2006-12-30 07:02:11 -0800 (Sat, 30 Dec 2006) Log Message: ----------- Introduced AbstractGameObjectAttributesDialog for unification of GameObjectAttributesDialog. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gui/GameObjectAttributesDialog.java trunk/daimonin/src/daieditor/gui/GameObjectAttributesDialog.java Added Paths: ----------- trunk/src/app/net/sf/gridarta/gui/AbstractGameObjectAttributesDialog.java Modified: trunk/crossfire/src/cfeditor/gui/GameObjectAttributesDialog.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/GameObjectAttributesDialog.java 2006-12-30 14:49:37 UTC (rev 1334) +++ trunk/crossfire/src/cfeditor/gui/GameObjectAttributesDialog.java 2006-12-30 15:02:11 UTC (rev 1335) @@ -61,7 +61,6 @@ import javax.swing.BorderFactory; import javax.swing.Box; import javax.swing.BoxLayout; -import javax.swing.ComboBoxModel; import javax.swing.JButton; import javax.swing.JCheckBox; import javax.swing.JComboBox; @@ -70,7 +69,6 @@ import javax.swing.JFormattedTextField; import javax.swing.JFrame; import javax.swing.JLabel; -import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JSplitPane; @@ -93,8 +91,7 @@ import net.sf.gridarta.CommonConstants; import net.sf.gridarta.gameobject.ArchAttribType; import net.sf.gridarta.gameobject.Archetype; -import net.sf.gridarta.gameobject.NamedObject; -import net.sf.gridarta.gameobject.NamedObjects; +import net.sf.gridarta.gui.AbstractGameObjectAttributesDialog; import net.sf.gridarta.help.Help; import net.sf.gridarta.map.MapModel; import net.sf.japi.swing.ActionFactory; @@ -108,7 +105,7 @@ * @author <a href="mailto:ch...@ri...">Christian Hujer</a> * @fixme I suck */ -public final class GameObjectAttributesDialog extends JOptionPane implements FocusListener { +public final class GameObjectAttributesDialog extends AbstractGameObjectAttributesDialog implements FocusListener { private static final Logger log = Logger.getLogger(GameObjectAttributesDialog.class); @@ -1701,82 +1698,4 @@ } // class TypesBoxAL - /** - * KeySelectionManager to manage the select-per-keystroke in a JComboBox - * (The default KeySelectionManager fails because all strings start with - * whitespace ' '). - * <p/> - * Unfortunately, this class cannot be used anymore because it does not - * work together with the listener <code>TypesBoxAL</code> - */ - private static final class StringKeyManager implements JComboBox.KeySelectionManager { - - /** JComboBox reference. */ - private final JComboBox box; - - /** - * Create a StringKeyManager. - * @param box JComboBox to create StringKeyManager for - */ - private StringKeyManager(final JComboBox box) { - this.box = box; - } - - /** {@inheritDoc} */ - public int selectionForKey(final char aKey, final ComboBoxModel aModel) { - for (int i = 0; i < aModel.getSize(); i++) { - if (((String) aModel.getElementAt(i)).toLowerCase().charAt(1) == aKey) { - //typeListener.ignoreEvent = true; - box.setSelectedIndex(i); // should happen automatically, but doesn't - //typeListener.ignoreEvent = false; - //typeListener.listenAction = true; - return i; - } - } - return -1; // no match found - } - - } // class StringKeyManager - - /** Action for choosing a face or animation. */ - private static final class TreeChooseAction extends AbstractAction { - - /** JTextField to update upon tree selection. */ - private JTextField textField; - - /** Objects providing the tree. */ - private NamedObjects<? extends NamedObject> objects; - - /** - * Create a TreeChooseAction. - * @param text text for label / button - * @param textField JTextField to update upon tree selection - * @param objects NamedObjects that provide the tree - */ - private TreeChooseAction(final String text, final JTextField textField, final NamedObjects<? extends NamedObject> objects) { - super(text); - this.textField = textField; - this.objects = objects; - } - - /** {@inheritDoc} */ - public void actionPerformed(final ActionEvent e) { - String initial = textField.getText(); - final NamedObject selected = objects.get(initial); - if (selected != null) { - initial = selected.getPath(); - } - final String newValue = objects.showNodeChooserDialog(textField, initial); - if (newValue != null) { - textField.setText(newValue); - } - } - - /** {@inheritDoc} */ - @Override protected Object clone() throws CloneNotSupportedException { - return super.clone(); - } - - } // class TreeChooseAction - } // class GameObjectAttributesDialog Modified: trunk/daimonin/src/daieditor/gui/GameObjectAttributesDialog.java =================================================================== --- trunk/daimonin/src/daieditor/gui/GameObjectAttributesDialog.java 2006-12-30 14:49:37 UTC (rev 1334) +++ trunk/daimonin/src/daieditor/gui/GameObjectAttributesDialog.java 2006-12-30 15:02:11 UTC (rev 1335) @@ -60,7 +60,6 @@ import javax.swing.BorderFactory; import javax.swing.Box; import javax.swing.BoxLayout; -import javax.swing.ComboBoxModel; import javax.swing.JButton; import javax.swing.JCheckBox; import javax.swing.JComboBox; @@ -69,7 +68,6 @@ import javax.swing.JFormattedTextField; import javax.swing.JFrame; import javax.swing.JLabel; -import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JSplitPane; @@ -92,8 +90,7 @@ import net.sf.gridarta.CommonConstants; import net.sf.gridarta.gameobject.ArchAttribType; import net.sf.gridarta.gameobject.Archetype; -import net.sf.gridarta.gameobject.NamedObject; -import net.sf.gridarta.gameobject.NamedObjects; +import net.sf.gridarta.gui.AbstractGameObjectAttributesDialog; import net.sf.gridarta.help.Help; import net.sf.gridarta.map.MapModel; import net.sf.japi.swing.ActionFactory; @@ -108,7 +105,7 @@ * @author <a href="mailto:ch...@ri...">Christian Hujer</a> * @fixme I suck */ -public final class GameObjectAttributesDialog extends JOptionPane implements FocusListener { +public final class GameObjectAttributesDialog extends AbstractGameObjectAttributesDialog implements FocusListener { private static final Logger log = Logger.getLogger(GameObjectAttributesDialog.class); @@ -1677,82 +1674,4 @@ } // class TypesBoxAL - /** - * KeySelectionManager to manage the select-per-keystroke in a JComboBox - * (The default KeySelectionManager fails because all strings start with - * whitespace ' '). - * <p/> - * Unfortunately, this class cannot be used anymore because it does not - * work together with the listener <code>TypesBoxAL</code> - */ - private static final class StringKeyManager implements JComboBox.KeySelectionManager { - - /** JComboBox reference. */ - private final JComboBox box; - - /** - * Create a StringKeyManager. - * @param box JComboBox to create StringKeyManager for - */ - private StringKeyManager(final JComboBox box) { - this.box = box; - } - - /** {@inheritDoc} */ - public int selectionForKey(final char aKey, final ComboBoxModel aModel) { - for (int i = 0; i < aModel.getSize(); i++) { - if (((String) aModel.getElementAt(i)).toLowerCase().charAt(1) == aKey) { - //typeListener.ignoreEvent = true; - box.setSelectedIndex(i); // should happen automatically, but doesn't - //typeListener.ignoreEvent = false; - //typeListener.listenAction = true; - return i; - } - } - return -1; // no match found - } - - } // class StringKeyManager - - /** Action for choosing a face or animation. */ - private static final class TreeChooseAction extends AbstractAction { - - /** JTextField to update upon tree selection. */ - private JTextField textField; - - /** Objects providing the tree. */ - private NamedObjects<? extends NamedObject> objects; - - /** - * Create a TreeChooseAction. - * @param text text for label / button - * @param textField JTextField to update upon tree selection - * @param objects NamedObjects that provide the tree - */ - private TreeChooseAction(final String text, final JTextField textField, final NamedObjects<? extends NamedObject> objects) { - super(text); - this.textField = textField; - this.objects = objects; - } - - /** {@inheritDoc} */ - public void actionPerformed(final ActionEvent e) { - String initial = textField.getText(); - final NamedObject selected = objects.get(initial); - if (selected != null) { - initial = selected.getPath(); - } - final String newValue = objects.showNodeChooserDialog(textField, initial); - if (newValue != null) { - textField.setText(newValue); - } - } - - /** {@inheritDoc} */ - @Override protected Object clone() throws CloneNotSupportedException { - return super.clone(); - } - - } // class TreeChooseAction - } // class GameObjectAttributesDialog Added: trunk/src/app/net/sf/gridarta/gui/AbstractGameObjectAttributesDialog.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/AbstractGameObjectAttributesDialog.java (rev 0) +++ trunk/src/app/net/sf/gridarta/gui/AbstractGameObjectAttributesDialog.java 2006-12-30 15:02:11 UTC (rev 1335) @@ -0,0 +1,101 @@ +package net.sf.gridarta.gui; + +import java.awt.event.ActionEvent; +import javax.swing.AbstractAction; +import javax.swing.ComboBoxModel; +import javax.swing.JComboBox; +import javax.swing.JOptionPane; +import javax.swing.JTextField; +import net.sf.gridarta.gameobject.NamedObject; +import net.sf.gridarta.gameobject.NamedObjects; +import org.apache.log4j.Logger; + +/** + * Common base class for game object attributes dialogs. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + */ +public class AbstractGameObjectAttributesDialog extends JOptionPane { + + private static final Logger log = Logger.getLogger(AbstractGameObjectAttributesDialog.class); + + /** + * KeySelectionManager to manage the select-per-keystroke in a JComboBox + * (The default KeySelectionManager fails because all strings start with + * whitespace ' '). + * <p/> + * Unfortunately, this class cannot be used anymore because it does not + * work together with the listener <code>TypesBoxAL</code> + */ + protected static final class StringKeyManager implements JComboBox.KeySelectionManager { + + /** JComboBox reference. */ + private final JComboBox box; + + /** + * Create a StringKeyManager. + * @param box JComboBox to create StringKeyManager for + */ + @SuppressWarnings({"PublicConstructorInNonPublicClass"}) + public StringKeyManager(final JComboBox box) { + this.box = box; + } + + /** {@inheritDoc} */ + public int selectionForKey(final char aKey, final ComboBoxModel aModel) { + for (int i = 0; i < aModel.getSize(); i++) { + if (((String) aModel.getElementAt(i)).toLowerCase().charAt(1) == aKey) { + //typeListener.ignoreEvent = true; + box.setSelectedIndex(i); // should happen automatically, but doesn't + //typeListener.ignoreEvent = false; + //typeListener.listenAction = true; + return i; + } + } + return -1; // no match found + } + + } // class StringKeyManager + + /** Action for choosing a face or animation. */ + protected static final class TreeChooseAction extends AbstractAction { + + /** JTextField to update upon tree selection. */ + private JTextField textField; + + /** Objects providing the tree. */ + private NamedObjects<? extends NamedObject> objects; + + /** + * Create a TreeChooseAction. + * @param text text for label / button + * @param textField JTextField to update upon tree selection + * @param objects NamedObjects that provide the tree + */ + @SuppressWarnings({"PublicConstructorInNonPublicClass"}) + public TreeChooseAction(final String text, final JTextField textField, final NamedObjects<? extends NamedObject> objects) { + super(text); + this.textField = textField; + this.objects = objects; + } + + /** {@inheritDoc} */ + public void actionPerformed(final ActionEvent e) { + String initial = textField.getText(); + final NamedObject selected = objects.get(initial); + if (selected != null) { + initial = selected.getPath(); + } + final String newValue = objects.showNodeChooserDialog(textField, initial); + if (newValue != null) { + textField.setText(newValue); + } + } + + /** {@inheritDoc} */ + @Override protected Object clone() throws CloneNotSupportedException { + return super.clone(); + } + + } // class TreeChooseAction + +} // class AbstractGameObjectAttributesDialog Property changes on: trunk/src/app/net/sf/gridarta/gui/AbstractGameObjectAttributesDialog.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |