Index: src/net/sf/freecol/client/gui/panel/DragListener.java
===================================================================
--- src/net/sf/freecol/client/gui/panel/DragListener.java       (revision 10463)
+++ src/net/sf/freecol/client/gui/panel/DragListener.java       (working copy)
@@ -30,6 +30,7 @@

 import net.sf.freecol.client.FreeColClient;
 import net.sf.freecol.client.gui.GUI;
+import net.sf.freecol.client.gui.panel.ColonyPanel.TilePanel.ASingleTilePanel;
 import net.sf.freecol.common.model.GoodsType;
 import net.sf.freecol.common.model.Unit;

@@ -90,6 +91,11 @@
                         ((EuropePanel) parentPanel).revalidate();
                         ((EuropePanel) parentPanel).refresh();
                     }
+                } else if (comp instanceof ASingleTilePanel
+                        || (comp.getParent() != null &&
comp.getParent() instanceof ASingleTilePanel)) {
+                    menu = new QuickActionMenu(freeColClient, gui,
parentPanel);
+                    // Also check the parent to show the popup in the
center of the colony panel tile
+                    menu.createTileMenu((ASingleTilePanel)(comp
instanceof ASingleTilePanel ? comp : comp.getParent()));
                 }
                 if (menu != null) {
                     int elements = menu.getSubElements().length;
Index: src/net/sf/freecol/client/gui/panel/ColonyPanel.java
===================================================================
--- src/net/sf/freecol/client/gui/panel/ColonyPanel.java        (revision 10463)
+++ src/net/sf/freecol/client/gui/panel/ColonyPanel.java        (working copy)
@@ -1597,6 +1597,7 @@
                 cleanup();

                 addPropertyChangeListeners();
+                addMouseListener(pressListener);
                 update();
             }

@@ -1622,7 +1623,9 @@
                     ProductionInfo info = colony.getProductionInfo(colonyTile);
                     if (info != null) {
                         for (AbstractGoods ag : info.getProduction()) {
-                            add(new
ProductionLabel(getFreeColClient(), getGUI(), ag));
+                               ProductionLabel productionLabel = new
ProductionLabel(getFreeColClient(), getGUI(), ag);
+                            productionLabel.addMouseListener(pressListener);
+                            add(productionLabel);
                         }
                     }
                 }
@@ -1841,6 +1844,10 @@
             public boolean accepts(Goods goods) {
                 return false;
             }
+
+            public ColonyTile getColonyTile() {
+                return colonyTile;
+            }
         }
     }
 }
Index: src/net/sf/freecol/client/gui/panel/QuickActionMenu.java
===================================================================
--- src/net/sf/freecol/client/gui/panel/QuickActionMenu.java    (revision 10463)
+++ src/net/sf/freecol/client/gui/panel/QuickActionMenu.java    (working copy)
@@ -40,6 +40,7 @@
 import net.sf.freecol.client.gui.GUI;
 import net.sf.freecol.client.gui.ImageLibrary;
 import net.sf.freecol.client.gui.i18n.Messages;
+import net.sf.freecol.client.gui.panel.ColonyPanel.TilePanel.ASingleTilePanel;
 import net.sf.freecol.client.gui.panel.UnitLabel.UnitAction;
 import net.sf.freecol.common.model.Ability;
 import net.sf.freecol.common.model.AbstractGoods;
@@ -53,6 +54,7 @@
 import net.sf.freecol.common.model.Location;
 import net.sf.freecol.common.model.Specification;
 import net.sf.freecol.common.model.StringTemplate;
+import net.sf.freecol.common.model.Tile;
 import net.sf.freecol.common.model.Unit;
 import net.sf.freecol.common.model.Unit.Role;
 import net.sf.freecol.common.model.Unit.UnitState;
@@ -113,7 +115,10 @@
         if (tempUnit.getLocation().getTile() != null) {
             Colony colony = tempUnit.getLocation().getTile().getColony();
             if (colony != null) {
-                if (addWorkItems(unitLabel)) {
+               if (addTileItem(unitLabel)) {
+                    this.addSeparator();
+                }
+               if (addWorkItems(unitLabel)) {
                     this.addSeparator();
                 }
                 if (addEducationItems(unitLabel)) {
@@ -600,6 +605,38 @@
         }
         return separatorNeeded;
     }
+
+    /**
+     * Creates a menu for a tile.
+     */
+    public void createTileMenu(final ASingleTilePanel singleTilePanel) {
+        if (singleTilePanel.getColonyTile() != null &&
singleTilePanel.getColonyTile().getColony() != null) {
+            addTileItem(singleTilePanel.getColonyTile().getWorkTile());
+        }
+    }
+
+    private boolean addTileItem(final UnitLabel unitLabel) {
+        final Unit unit = unitLabel.getUnit();
+        if (unit.getWorkTile() != null) {
+            final Tile tile = unit.getWorkTile().getWorkTile();
+            addTileItem(tile);
+           return true;
+        }
+        return false;
+    }
+
+    private void addTileItem(final Tile tile) {
+        if (tile != null) {
+            JMenuItem menuItem = new
JMenuItem(Messages.message(tile.getNameKey()));
+            menuItem.addActionListener(new ActionListener() {
+                public void actionPerformed(ActionEvent event) {
+                    gui.showTilePanel(tile);
+                }
+            });
+            add(menuItem);
+        }
+    }
+
     /**
      * Creates a menu for a good.
      */

------------------------------------------------------------------------------
Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
MVPs and experts. ON SALE this month only -- learn more at:
http://p.sf.net/sfu/learnmore_123012
_______________________________________________
Freecol-developers mailing list
Freecol-developers@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/freecol-developers

Reply via email to