From: <aki...@us...> - 2007-01-10 22:50:15
|
Revision: 1552 http://svn.sourceforge.net/gridarta/?rev=1552&view=rev Author: akirschbaum Date: 2007-01-10 14:50:15 -0800 (Wed, 10 Jan 2007) Log Message: ----------- Unify selected square control code. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gui/selectedsquare/SelectedSquareControl.java trunk/daimonin/src/daieditor/gui/selectedsquare/SelectedSquareControl.java trunk/daimonin/src/daieditor/gui/selectedsquare/SelectedSquareView.java Modified: trunk/crossfire/src/cfeditor/gui/selectedsquare/SelectedSquareControl.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/selectedsquare/SelectedSquareControl.java 2007-01-10 22:40:10 UTC (rev 1551) +++ trunk/crossfire/src/cfeditor/gui/selectedsquare/SelectedSquareControl.java 2007-01-10 22:50:15 UTC (rev 1552) @@ -84,6 +84,7 @@ ListSelectionListener getListSelectionListener() { return new ListSelectionListener() { + /** {@inheritDoc} */ public void valueChanged(final ListSelectionEvent e) { mainView.setMapArchPanelObject(getMapTileSelection()); } @@ -92,31 +93,26 @@ MouseListener getMouseListener() { return new MouseAdapter() { - @Override public void mousePressed(final MouseEvent e) { - if ((e.getModifiers() & InputEvent.BUTTON1_MASK) != 0) { - // --- left mouse button: select arch --- - // first, check if this is a doubleclick - final long thisClick = (new Date()).getTime(); - if (thisClick - lastClick < IGUIConstants.DOUBLECLICK_MS && lastClickGameObject != null && lastClickGameObject == getMapTileSelection()) { - // doubleclick: open attribute window - mainControl.openAttrDialog(getMapTileSelection()); + /** {@inheritDoc} */ + @Override public void mousePressed(final MouseEvent e) { + if ((e.getModifiers() & InputEvent.BUTTON1_MASK) != 0) { + final long thisClick = (new Date()).getTime(); + if (thisClick - lastClick < IGUIConstants.DOUBLECLICK_MS && lastClickGameObject != null && lastClickGameObject == getMapTileSelection()) { + mainControl.openAttrDialog(getMapTileSelection()); + } else { + mainView.setMapArchPanelObject(getMapTileSelection()); + } + + // save values for next click + lastClick = thisClick; + lastClickGameObject = getMapTileSelection(); + } else if ((e.getModifiers() & InputEvent.BUTTON3_MASK) != 0) { + insertGameObjectFromArchPanel(view.getListIndex(e)); } else { - // single click: now make this arch selected - mainView.setMapArchPanelObject(getMapTileSelection()); + deleteIndex(view.getListIndex(e)); } - - // save values for next click - lastClick = thisClick; - lastClickGameObject = getMapTileSelection(); - } else if ((e.getModifiers() & InputEvent.BUTTON3_MASK) != 0) { - // --- right mouse button: insert arch --- - insertGameObjectFromArchPanel(view.getListIndex(e)); - } else { - // --- middle mouse button: delete arch --- - deleteIndex(view.getListIndex(e)); } - } - }; + }; } /** Modified: trunk/daimonin/src/daieditor/gui/selectedsquare/SelectedSquareControl.java =================================================================== --- trunk/daimonin/src/daieditor/gui/selectedsquare/SelectedSquareControl.java 2007-01-10 22:40:10 UTC (rev 1551) +++ trunk/daimonin/src/daieditor/gui/selectedsquare/SelectedSquareControl.java 2007-01-10 22:50:15 UTC (rev 1552) @@ -35,6 +35,7 @@ import daieditor.map.MapModel; import java.awt.Point; import static java.awt.event.InputEvent.SHIFT_MASK; +import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import static java.awt.event.MouseEvent.BUTTON1; import static java.awt.event.MouseEvent.BUTTON2; @@ -54,7 +55,7 @@ * @author <a href="mailto:ch...@ri...">Christian Hujer</a> * @todo turn this into a tree */ -public final class SelectedSquareControl implements MouseListener { +public final class SelectedSquareControl { /** Controller of this subview. */ private final CMainControl mainControl; @@ -78,15 +79,30 @@ ListSelectionListener getListSelectionListener() { return new ListSelectionListener() { + /** {@inheritDoc} */ public void valueChanged(final ListSelectionEvent e) { mainView.setMapArchPanelObject(getMapTileSelection()); } }; } - /** {@inheritDoc} */ - public void valueChanged(final ListSelectionEvent e) { - mainView.setMapArchPanelObject(getMapTileSelection()); + MouseListener getMouseListener() { + return new MouseAdapter() { + /** {@inheritDoc} */ + public void mousePressed(final MouseEvent e) { + if (e.getButton() == BUTTON1) { // LMB + if (e.getClickCount() > 1) { // LMB Double click + mainControl.openAttrDialog(getMapTileSelection()); + } else { + mainView.setMapArchPanelObject(getMapTileSelection()); + } + } else if (e.getButton() == BUTTON3 && (e.getModifiers() & SHIFT_MASK) != SHIFT_MASK) { // RMB + insertGameObjectFromArchPanel(view.getListIndex(e)); + } else if (e.getButton() == BUTTON2 || (e.getModifiers() & SHIFT_MASK) == SHIFT_MASK && e.getButton() == BUTTON3) { // MMB + deleteIndex(view.getListIndex(e)); + } + } + }; } /** @@ -153,42 +169,6 @@ view.setSelectedIndex(view.getSelectedIndex() - 1); } - /** {@inheritDoc} */ - public void mousePressed(final MouseEvent e) { - if (e.getButton() == BUTTON1) { // LMB - if (e.getClickCount() > 1) { // LMB Double click - mainControl.openAttrDialog(getMapTileSelection()); - } else { - mainView.setMapArchPanelObject(getMapTileSelection()); - } - } else if (e.getButton() == BUTTON3 && (e.getModifiers() & SHIFT_MASK) != SHIFT_MASK) { // RMB - insertGameObjectFromArchPanel(view.getListIndex(e)); - } else if (e.getButton() == BUTTON2 || (e.getModifiers() & SHIFT_MASK) == SHIFT_MASK && e.getButton() == BUTTON3) { // MMB - // --- middle mouse button: delete arch --- - deleteIndex(view.getListIndex(e)); - } - } - - /** {@inheritDoc} */ - public void mouseClicked(final MouseEvent e) { - /* ignore */ - } - - /** {@inheritDoc} */ - public void mouseEntered(final MouseEvent e) { - /* ignore */ - } - - /** {@inheritDoc} */ - public void mouseExited(final MouseEvent e) { - /* ignore */ - } - - /** {@inheritDoc} */ - public void mouseReleased(final MouseEvent e) { - /* ignore */ - } - /** * Return the currently selected GameObject within this list (currently selected MapSquare). * @return the currently selected GameObject Modified: trunk/daimonin/src/daieditor/gui/selectedsquare/SelectedSquareView.java =================================================================== --- trunk/daimonin/src/daieditor/gui/selectedsquare/SelectedSquareView.java 2007-01-10 22:40:10 UTC (rev 1551) +++ trunk/daimonin/src/daieditor/gui/selectedsquare/SelectedSquareView.java 2007-01-10 22:50:15 UTC (rev 1552) @@ -141,7 +141,7 @@ compass.add(new JLabel(CGUIUtils.getSysIcon(IGUIConstants.TILE_NORTH))); add(compass, BorderLayout.NORTH); list.addListSelectionListener(control.getListSelectionListener()); - list.addMouseListener(control); + list.addMouseListener(control.getMouseListener()); list.setFocusable(false); // XXX Workaround for Mantis #0000154 This is not clean and should be removed as soon as cut/copy/paste of arches is possible mainControl.addMainControlListener(this); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |