Index: /applications/editors/josm/plugins/CommandLine/build.xml
===================================================================
--- /applications/editors/josm/plugins/CommandLine/build.xml	(revision 25043)
+++ /applications/editors/josm/plugins/CommandLine/build.xml	(revision 25044)
@@ -3,5 +3,5 @@
 
     <!-- enter the SVN commit message -->
-    <property name="commit.message" value="Initial commit" />
+    <property name="commit.message" value="Icons with menu and panel support" />
     <!-- enter the *lowest* JOSM version this plugin is currently compatible with -->
     <property name="plugin.main.version" value="3751" />
Index: /applications/editors/josm/plugins/CommandLine/src/CommandLine/Command.java
===================================================================
--- /applications/editors/josm/plugins/CommandLine/src/CommandLine/Command.java	(revision 25043)
+++ /applications/editors/josm/plugins/CommandLine/src/CommandLine/Command.java	(revision 25044)
@@ -2,5 +2,5 @@
  *      Command.java
  *      
- *      Copyright 2010 Hind <foxhind@gmail.com>
+ *      Copyright 2011 Hind <foxhind@gmail.com>
  *      
  */
@@ -22,4 +22,5 @@
 	public String name;						// Command name
 	public String run;						// Executable file with arguments ("nya.exe {arg1} {arg2} ... {argn}")
+	public String icon;						// Icon file name
 	public ArrayList<Parameter> parameters;	// Required parameters list
 	public ArrayList<Parameter> optParameters;	// Optional parameters list
@@ -27,5 +28,5 @@
 	public boolean tracks;
 	
-	public Command () {	parameters = new ArrayList<Parameter>(); optParameters = new ArrayList<Parameter>(); currentParameterNum = 0; tracks = false; }
+	public Command () {	parameters = new ArrayList<Parameter>(); optParameters = new ArrayList<Parameter>(); currentParameterNum = 0; tracks = false; icon = ""; }
 
 	public boolean loadObject(Object obj) {
Index: /applications/editors/josm/plugins/CommandLine/src/CommandLine/CommandAction.java
===================================================================
--- /applications/editors/josm/plugins/CommandLine/src/CommandLine/CommandAction.java	(revision 25044)
+++ /applications/editors/josm/plugins/CommandLine/src/CommandLine/CommandAction.java	(revision 25044)
@@ -0,0 +1,62 @@
+/*
+ *      CommandAction.java
+ *
+ *      Copyright 2011 Hind <foxhind@gmail.com>
+ *
+ */
+
+package CommandLine;
+
+import static org.openstreetmap.josm.tools.I18n.tr;
+
+import java.awt.event.ActionEvent;
+import java.awt.AWTEvent;
+import java.awt.Cursor;
+import java.awt.EventQueue;
+import java.awt.event.AWTEventListener;
+import java.awt.event.KeyEvent;
+import java.awt.event.MouseEvent;
+import java.awt.Point;
+import java.awt.Toolkit;
+import java.util.Collection;
+import javax.swing.Action;
+import javax.swing.JOptionPane;
+
+import org.openstreetmap.josm.Main;
+import org.openstreetmap.josm.actions.JosmAction;
+import org.openstreetmap.josm.data.coor.LatLon;
+import org.openstreetmap.josm.data.osm.DataSet;
+import org.openstreetmap.josm.data.osm.Way;
+import org.openstreetmap.josm.data.osm.OsmPrimitive;
+import org.openstreetmap.josm.data.osm.PrimitiveId;
+import org.openstreetmap.josm.gui.MapFrame;
+import org.openstreetmap.josm.tools.ImageProvider;
+
+public class CommandAction extends JosmAction {
+	private CommandLine parentPlugin;
+	private Command parentCommand;
+	public CommandAction(Command parentCommand, CommandLine parentPlugin) {
+		super(tr(parentCommand.name), "blankmenu", tr(parentCommand.name), null, false, false);
+		if (!parentCommand.icon.equals("")) {
+			try {
+				putValue(Action.SMALL_ICON, ImageProvider.get("/../plugins/CommandLine/", parentCommand.icon));
+				putValue(Action.LARGE_ICON_KEY, ImageProvider.get("/../plugins/CommandLine/", parentCommand.icon));
+			}
+			catch (NullPointerException e) {
+				putValue(Action.SMALL_ICON, ImageProvider.get("blankmenu"));
+				putValue(Action.LARGE_ICON_KEY, ImageProvider.get("blankmenu"));
+			}
+		}
+		putValue("toolbar", parentCommand.name);
+		Main.toolbar.register(this);
+		installAdapters();
+
+		this.parentCommand = parentCommand;
+		this.parentPlugin = parentPlugin;
+	}
+
+	public void actionPerformed(ActionEvent e) {
+		parentPlugin.startCommand(parentCommand);
+		parentPlugin.history.addItem(parentCommand.name);
+	}
+}
Index: /applications/editors/josm/plugins/CommandLine/src/CommandLine/CommandLine.java
===================================================================
--- /applications/editors/josm/plugins/CommandLine/src/CommandLine/CommandLine.java	(revision 25043)
+++ /applications/editors/josm/plugins/CommandLine/src/CommandLine/CommandLine.java	(revision 25044)
@@ -2,5 +2,5 @@
  *      CommandLine.java
  *      
- *      Copyright 2010 Hind <foxhind@gmail.com>
+ *      Copyright 2011 Hind <foxhind@gmail.com>
  *      
  *      This program is free software; you can redistribute it and/or modify
@@ -22,5 +22,7 @@
 package CommandLine;
 
+import static org.openstreetmap.josm.gui.help.HelpUtil.ht;
 import static org.openstreetmap.josm.tools.I18n.tr;
+import static org.openstreetmap.josm.tools.I18n.marktr;
 
 import java.awt.BorderLayout;
@@ -43,4 +45,6 @@
 import java.util.regex.*;
 import javax.swing.JTextField;
+import javax.swing.JMenu;
+import javax.swing.JMenuItem;
 
 import org.openstreetmap.josm.Main;
@@ -76,9 +80,10 @@
 	private Mode mode;
 	private ArrayList<Command> commands;
+	private JMenu commandMenu;
 	protected Command currentCommand;
 	protected String commandSymbol;
-	private History history;
-	private MapFrame currentMapFrame;
-	private MapMode previousMode;
+	protected History history;
+	protected MapFrame currentMapFrame;
+	protected MapMode previousMode;
 
 	public CommandLine(PluginInformation info) {
@@ -104,12 +109,5 @@
 								Command command = findCommand(commandText, true);
 								if (command != null) {
-									currentCommand = command;
-									currentCommand.resetLoading();
-									parseSelection(Main.main.getCurrentDataSet().getSelected());
-									previousMode = Main.map.mapMode;
-									if (currentCommand.currentParameterNum < currentCommand.parameters.size())
-										setMode(Mode.SELECTION);
-									else
-										runTool();
+									startCommand(command);
 								}
 								else
@@ -193,7 +191,35 @@
 		};
 
-		MainMenu.add(Main.main.menu.toolsMenu, new CommandLineAction(this));
+		if ( Main.main.menu != null ) {
+			commandMenu = Main.main.menu.addMenu(marktr("Commands") , KeyEvent.VK_C, Main.main.menu.defaultMenuPos, ht("/Plugin/CommandLine"));
+			MainMenu.add(Main.main.menu.toolsMenu, new CommandLineAction(this));
+		}
 		loadCommands();
 		setMode(Mode.IDLE);
+	}
+
+	public void startCommand(String commandName) {
+		Command command = findCommand(commandName, true);
+		if (command != null) {
+			startCommand(command);
+		}
+	}
+
+	protected void startCommand(Command command) {
+		if (Main.map == null)
+			return;
+		DataSet ds = Main.main.getCurrentDataSet();
+		if (ds == null)
+			return;
+		currentCommand = command;
+		currentCommand.resetLoading();
+		parseSelection(ds.getSelected());
+		if (!(Main.map.mapMode instanceof AnyAction || Main.map.mapMode instanceof DummyAction || Main.map.mapMode instanceof LengthAction || Main.map.mapMode instanceof NodeAction || Main.map.mapMode instanceof PointAction || Main.map.mapMode instanceof RelationAction || Main.map.mapMode instanceof WayAction)) {
+			previousMode = Main.map.mapMode;
+		}
+		if (currentCommand.currentParameterNum < currentCommand.parameters.size())
+			setMode(Mode.SELECTION);
+		else
+			runTool();
 	}
 
@@ -209,4 +235,8 @@
 		Loader loader = new Loader(getPluginDir());
 		commands = loader.load(); // lol
+
+		for (Command command : commands) {
+			commandMenu.add(new CommandAction(command, this));
+		}
 	}
 
@@ -227,5 +257,5 @@
 	}
 	
-	private void setMode(Mode targetMode) {
+	protected void setMode(Mode targetMode) {
 		DataSet currentDataSet = Main.main.getCurrentDataSet();
 		if (currentDataSet != null) {
@@ -295,5 +325,4 @@
 	public void endInput() {
 		setMode(Mode.IDLE);
-		//System.out.print(String.valueOf());
 		Main.map.selectMapMode(previousMode);
 		Main.map.mapView.repaint();
Index: /applications/editors/josm/plugins/CommandLine/src/CommandLine/Loader.java
===================================================================
--- /applications/editors/josm/plugins/CommandLine/src/CommandLine/Loader.java	(revision 25043)
+++ /applications/editors/josm/plugins/CommandLine/src/CommandLine/Loader.java	(revision 25044)
@@ -2,5 +2,5 @@
  *	  Loader.java
  *	  
- *	  Copyright 2010 Hind <foxhind@gmail.com>
+ *	  Copyright 2011 Hind <foxhind@gmail.com>
  *	  
  */
@@ -79,7 +79,11 @@
 				else if (Name.equals("run"))
 					currentCommand.run = Value;
-				else if (Name.equals("tracks"))
+				else if (Name.equals("tracks")) {
 					if (Value.equals("bbox"))
 						currentCommand.tracks = true;
+				}
+				else if (Name.equals("icon")) {
+					currentCommand.icon = Value;
+				}
 			}
 		}
