Uwd.System.Desktop.ContextMenu = function(config) {
	
	Uwd.System.Desktop.ContextMenu.superclass.constructor.call(this, config);
	this.addTools();
	this.addSystemTools();
	
};

Ext.extend(Uwd.System.Desktop.ContextMenu, Ext.menu.Menu, {
		   
	
	show : function(e) {
		var xy = e.getXY();
		e.stopEvent();
		this.showAt(xy);
	},
	
	addTools : function() {
		// Programmmenus bilden
		Ext.each(Uwd.System.ProgramStack.getStack(), function(module){
			if (module.getIsTool() === true) {
				this.add({
					id: 'tb-' + module.getId() + '-' + module.getName(),
					iconCls: module.getIconClass(), // icon and text class
					text: module.getName(),
					handler: function() {
						module.openWindow();
					}.createDelegate(this),
					scope: this
				});
			}
		}.createDelegate(this));
	},
	
	addSystemTools : function() {
		this.add({
			id: 'tb_restart',
			iconCls: 'icon_cm_restart', // icon and text class
			text: Uwd.System.SystemLanguage.reboot,
			handler: function() {
				var restartApp = new Uwd.System.Restart();
			},
			scope: this
		});

		this.add({
			id: 'tb_quit',
			iconCls: 'icon_cm_logout', // icon and text class
			text: Uwd.System.SystemLanguage.logout,
			handler: function() {
				var logoutApp = new Uwd.System.Logout();
			},
			scope: this
		});
	}
	
});