def __init__(self, parent, *args, **kwargs):
        TreeListCtrl.__init__(self,
                              parent,
                              *args,
                              style=wx.TR_DEFAULT_STYLE
                              | wx.TR_FULL_ROW_HIGHLIGHT | wx.TR_HIDE_ROOT,
                              **kwargs)

        self.root = None
        self.resource_labels = []

        self.col_name = 0
        self.AddColumn('Name', 200)
        self.col_r = 1
        self.AddColumn('R', 24)
        self.col_w = 2
        self.AddColumn('W', 24)
        self.col_units = 3
        self.AddColumn('Units', 50)
        self.col_label = 4
        self.AddColumn('Label', 200, edit=True)
        self.col_value = 5
        self.AddColumn('Value', 400, edit=True)

        # Extra 50 for nesting.
        self.SetMinSize((950, -1))

        self.Bind(wx.EVT_TREE_ITEM_EXPANDED, self.OnItemExpanded)
        self.Bind(wx.EVT_TREE_BEGIN_LABEL_EDIT, self.OnBeginLabelEdit)
        self.Bind(wx.EVT_TREE_END_LABEL_EDIT, self.OnEndLabelEdit)
        self.Bind(wx.EVT_TREE_ITEM_ACTIVATED, self.OnActivated)
Esempio n. 2
0
	def __init__(self, parent, *args, **kwargs):
		TreeListCtrl.__init__(self, parent, *args,
				style=wx.TR_DEFAULT_STYLE|wx.TR_FULL_ROW_HIGHLIGHT|wx.TR_HIDE_ROOT,
				**kwargs)

		self.root = None
		self.resource_labels = []

		self.col_name = 0
		self.AddColumn('Name', 200)
		self.col_r = 1
		self.AddColumn('R', 24)
		self.col_w = 2
		self.AddColumn('W', 24)
		self.col_units = 3
		self.AddColumn('Units', 50)
		self.col_label = 4
		self.AddColumn('Label', 200, edit=True)
		self.col_value = 5
		self.AddColumn('Value', 400, edit=True)

		# Extra 50 for nesting.
		self.SetMinSize((950, -1))

		self.Bind(wx.EVT_TREE_ITEM_EXPANDED, self.OnItemExpanded)
		self.Bind(wx.EVT_TREE_BEGIN_LABEL_EDIT, self.OnBeginLabelEdit)
		self.Bind(wx.EVT_TREE_END_LABEL_EDIT, self.OnEndLabelEdit)
		self.Bind(wx.EVT_TREE_ITEM_ACTIVATED, self.OnActivated)
Esempio n. 3
0
 def _newEventList(self, parent):
     tree = TreeListCtrl(parent,
                         -1,
                         style=wx.TR_HIDE_ROOT | wx.TR_NO_BUTTONS
                         | wx.TR_ROW_LINES | wx.TR_FULL_ROW_HIGHLIGHT)
     self._initEventList(tree)
     return tree
Esempio n. 4
0
    def __init__(self, *args, **kwds):
        # begin wxGlade: wxITI1480AMainFrame.__init__
        kwds["style"] = wx.DEFAULT_FRAME_STYLE
        wx.Frame.__init__(self, *args, **kwds)
        
        # Menu Bar
        self.menubar = wx.MenuBar()
        wxglade_tmp_menu = wx.Menu()
        wxglade_tmp_menu.Append(wx.ID_OPEN, "&Open", "Open file", wx.ITEM_NORMAL)
        wxglade_tmp_menu.Append(wx.ID_SAVE, "&Save", "Save current capture", wx.ITEM_NORMAL)
        wxglade_tmp_menu.AppendSeparator()
        wxglade_tmp_menu.Append(wx.ID_EXIT, "&Exit", "", wx.ITEM_NORMAL)
        self.menubar.Append(wxglade_tmp_menu, "&File")
        wxglade_tmp_menu = wx.Menu()
        wxglade_tmp_menu.Append(4, "&Start", "", wx.ITEM_NORMAL)
        wxglade_tmp_menu.Append(5, "&Pause", "", wx.ITEM_NORMAL)
        wxglade_tmp_menu.Append(wx.ID_STOP, "S&top", "", wx.ITEM_NORMAL)
        self.menubar.Append(wxglade_tmp_menu, "&Capture")
        self.SetMenuBar(self.menubar)
        # Menu Bar end
        self.statusbar = self.CreateStatusBar(3, 0)
        
        # Tool Bar
        self.toolbar = wx.ToolBar(self, -1, style=wx.TB_HORIZONTAL | wx.TB_FLAT | wx.TB_DOCKABLE | wx.TB_TEXT)
        self.SetToolBar(self.toolbar)
        self.toolbar.AddLabelTool(wx.ID_OPEN, "Open", wx.Bitmap("images/fileopen.png", wx.BITMAP_TYPE_ANY), wx.NullBitmap, wx.ITEM_NORMAL, "Open file", "")
        self.toolbar.AddLabelTool(wx.ID_SAVE, "Save", wx.Bitmap("images/filesave.png", wx.BITMAP_TYPE_ANY), wx.NullBitmap, wx.ITEM_NORMAL, "Save current capture", "")
        self.toolbar.AddSeparator()
        self.toolbar.AddLabelTool(4, "Start", wx.Bitmap("images/player_play.png", wx.BITMAP_TYPE_ANY), wx.NullBitmap, wx.ITEM_NORMAL, "Start cature", "")
        self.toolbar.AddLabelTool(5, "Pause", wx.Bitmap("images/player_pause.png", wx.BITMAP_TYPE_ANY), wx.NullBitmap, wx.ITEM_CHECK, "Pause/continue capture", "")
        self.toolbar.AddLabelTool(wx.ID_STOP, "Stop", wx.Bitmap("images/player_stop.png", wx.BITMAP_TYPE_ANY), wx.NullBitmap, wx.ITEM_NORMAL, "Terminate capture", "")
        # Tool Bar end
        self.device_notebook = wx.Notebook(self, -1, style=0)
        self.capture_list = TreeListCtrl(self.device_notebook, -1, style=wx.TR_HIDE_ROOT | wx.TR_NO_BUTTONS | wx.TR_ROW_LINES | wx.TR_FULL_ROW_HIGHLIGHT)
        self.bus_list = TreeListCtrl(self.device_notebook, -1, style=wx.TR_HIDE_ROOT | wx.TR_NO_BUTTONS | wx.TR_ROW_LINES | wx.TR_FULL_ROW_HIGHLIGHT)
        self.error_list = TreeListCtrl(self.device_notebook, -1, style=wx.TR_HIDE_ROOT | wx.TR_NO_BUTTONS | wx.TR_ROW_LINES | wx.TR_FULL_ROW_HIGHLIGHT)

        self.__set_properties()
        self.__do_layout()

        self.Bind(wx.EVT_MENU, self.onOpen, id=wx.ID_OPEN)
        self.Bind(wx.EVT_MENU, self.onSave, id=wx.ID_SAVE)
        self.Bind(wx.EVT_MENU, self.onExit, id=wx.ID_EXIT)
        self.Bind(wx.EVT_MENU, self.onStart, id=4)
        self.Bind(wx.EVT_MENU, self.onPause, id=5)
        self.Bind(wx.EVT_MENU, self.onStop, id=wx.ID_STOP)
Esempio n. 5
0
 def __init__(self, parent, pos=wx.DefaultPosition):
     """!List of layers to be imported (dxf, shp...)"""
     self.parent = parent
     
     TreeListCtrl.__init__(self, parent, wx.ID_ANY,
                           style = wx.TR_DEFAULT_STYLE | wx.TR_HIDE_ROOT |
                           wx.TR_FULL_ROW_HIGHLIGHT | wx.TR_MULTIPLE)
     
     # setup mixins
     listmix.ListCtrlAutoWidthMixin.__init__(self)
     
     self.AddColumn(_('Layer / Style'))
     self.AddColumn(_('Title'))
     self.SetMainColumn(0) # column with the tree
     self.SetColumnWidth(0, 175)
     
     self.root = None
Esempio n. 6
0
    def __init__(self, scene, *args, **kwargs):
        """__init__(scene, *args, **kwargs) 
        
Special kwargs:
    style: style applied to the wx.gizmos.TreeListCtrl. Default is 
                      wx.TR_HIDE_ROOT \
                    | wx.TR_DEFAULT_STYLE \
                    | wx.TR_HAS_BUTTONS  \
                    | wx.TR_FULL_ROW_HIGHLIGHT \
                    | wx.TR_SINGLE \
                    | wx.TR_NO_LINES
"""
        style = kwargs.pop('style',-1)
        if style is -1:
            style = wx.TR_HIDE_ROOT \
                    | wx.TR_DEFAULT_STYLE \
                    | wx.TR_HAS_BUTTONS  \
                    | wx.TR_FULL_ROW_HIGHLIGHT \
                    | wx.TR_SINGLE \
                    | wx.TR_NO_LINES
            # can't figure out how to make the list single selection
            # hacked below
        TreeListCtrl.__init__(self, style=style, *args, **kwargs)
        # columns
        self.Indent = 0 # doesn't seem to work
        self.AddColumn("gname")
        self.AddColumn("class")
        self.AddColumn("layer")
        self.SetColumnWidth(0,80)
        self.set_object(scene)
        self.refresh_tree()
        self.Bind(wx.EVT_TREE_SEL_CHANGED, self.on_sel_changed)
        self.Bind(wx.EVT_TREE_ITEM_ACTIVATED, self.on_activated)
        self.Bind(wx.EVT_TREE_ITEM_RIGHT_CLICK, self.on_right_click)
        self.menu_up = wx.NewId()
        self.menu_down = wx.NewId()
        self.menu_top = wx.NewId()
        self.menu_bottom = wx.NewId()
        self.Bind(wx.EVT_MENU, self.move_up, id=self.menu_up)
        self.Bind(wx.EVT_MENU, self.move_down, id=self.menu_down)
        self.Bind(wx.EVT_MENU, self.move_top, id=self.menu_top)
        self.Bind(wx.EVT_MENU, self.move_bottom, id=self.menu_bottom)
        self.right_clicked = None
        wx.GetApp().register_selection_watcher(self)
        from pug.syswx.pugframe import PugFrame
        self.PugFrame = PugFrame
Esempio n. 7
0
    def __init__(self, scene, *args, **kwargs):
        """__init__(scene, *args, **kwargs) 
        
Special kwargs:
    style: style applied to the wx.gizmos.TreeListCtrl. Default is 
                      wx.TR_HIDE_ROOT \
                    | wx.TR_DEFAULT_STYLE \
                    | wx.TR_HAS_BUTTONS  \
                    | wx.TR_FULL_ROW_HIGHLIGHT \
                    | wx.TR_SINGLE \
                    | wx.TR_NO_LINES
"""
        style = kwargs.pop('style', -1)
        if style is -1:
            style = wx.TR_HIDE_ROOT \
                    | wx.TR_DEFAULT_STYLE \
                    | wx.TR_HAS_BUTTONS  \
                    | wx.TR_FULL_ROW_HIGHLIGHT \
                    | wx.TR_SINGLE \
                    | wx.TR_NO_LINES
            # can't figure out how to make the list single selection
            # hacked below
        TreeListCtrl.__init__(self, style=style, *args, **kwargs)
        # columns
        self.Indent = 0  # doesn't seem to work
        self.AddColumn("gname")
        self.AddColumn("class")
        self.AddColumn("layer")
        self.SetColumnWidth(0, 80)
        self.set_object(scene)
        self.refresh_tree()
        self.Bind(wx.EVT_TREE_SEL_CHANGED, self.on_sel_changed)
        self.Bind(wx.EVT_TREE_ITEM_ACTIVATED, self.on_activated)
        self.Bind(wx.EVT_TREE_ITEM_RIGHT_CLICK, self.on_right_click)
        self.menu_up = wx.NewId()
        self.menu_down = wx.NewId()
        self.menu_top = wx.NewId()
        self.menu_bottom = wx.NewId()
        self.Bind(wx.EVT_MENU, self.move_up, id=self.menu_up)
        self.Bind(wx.EVT_MENU, self.move_down, id=self.menu_down)
        self.Bind(wx.EVT_MENU, self.move_top, id=self.menu_top)
        self.Bind(wx.EVT_MENU, self.move_bottom, id=self.menu_bottom)
        self.right_clicked = None
        wx.GetApp().register_selection_watcher(self)
        from pug.syswx.pugframe import PugFrame
        self.PugFrame = PugFrame
Esempio n. 8
0
    def __init__(self, parent, web_service, style, pos=wx.DefaultPosition):
        """List of layers and styles available in capabilities file
        """
        self.parent = parent
        self.ws = web_service

        TreeListCtrl.__init__(self, parent=parent, id=wx.ID_ANY, style=style)

        # setup mixins
        listmix.ListCtrlAutoWidthMixin.__init__(self)
        if self.ws != 'OnEarth':
            self.AddColumn(_('Name'))
            self.AddColumn(_('Type'))
        else:
            self.AddColumn(_('Layer name'))

        self.SetMainColumn(0)  # column with the tree
        self.setResizeColumn(0)

        self.root = None
        self.Bind(wx.EVT_TREE_SEL_CHANGING, self.OnListSelChanging)

        self.layerSelected = Signal('LayersList.layerSelected')
Esempio n. 9
0
    def __init__(self, parent, web_service, style, pos=wx.DefaultPosition):
        """List of layers and styles available in capabilities file
        """
        self.parent = parent
        self.ws = web_service

        TreeListCtrl.__init__(self, parent = parent, id = wx.ID_ANY, style = style)

        # setup mixins
        listmix.ListCtrlAutoWidthMixin.__init__(self)
        if self.ws != 'OnEarth':
            self.AddColumn(_('Name'))
            self.AddColumn(_('Type'))
        else:
            self.AddColumn(_('Layer name'))

        self.SetMainColumn(0) # column with the tree
        self.setResizeColumn(0)

        self.root = None
        self.Bind(wx.EVT_TREE_SEL_CHANGING, self.OnListSelChanging)

        self.layerSelected = Signal('LayersList.layerSelected')
    def __init__(self, parent, ID, title,size=wx.Size(450,300),callback=None):
        wx.Frame.__init__(self, parent, ID, title,
                         wx.DefaultPosition, size=size)
                         
        self.callback = callback
        self.Center()
        self.SetTitle(title)
        self.SetIcon(icons.getAGIconIcon())
        self.serviceManagers = []
        self.nodeServiceHandle = None

        self.app = Toolkit.Application.instance()

        menuBar = wx.MenuBar()

        ## FILE menu
        self.fileMenu = wx.Menu()
        self.fileMenu.Append(ID_FILE_ATTACH, "Connect to Node...", 
                             "Connect to a NodeService")
        self.fileMenu.AppendSeparator()
        self.fileMenu.Append(ID_FILE_LOAD_CONFIG, "Load Configuration...", 
                             "Load a NodeService Configuration")
        self.fileMenu.Append(ID_FILE_STORE_CONFIG, "Store Configuration...", 
                             "Store a NodeService Configuration")
        self.fileMenu.AppendSeparator()
        self.fileMenu.Append(ID_FILE_EXIT, "E&xit", "Terminate the program")
        menuBar.Append(self.fileMenu, "&File");

        ## SERVICE MANAGERS menu
        self.serviceManagersMenu = BuildServiceManagerMenu()
        menuBar.Append(self.serviceManagersMenu, "&ServiceManager");
        
        ## SERVICE menu

        self.serviceMenu = BuildServiceMenu()
        menuBar.Append(self.serviceMenu, "&Service");
        
        ## HELP menu
        self.helpMenu = wx.Menu()
        self.helpMenu.Append(ID_HELP_ABOUT, "&About",
                    "More information about this program")
        menuBar.Append(self.helpMenu, "&Help");

        self.SetMenuBar(menuBar)

        self.tree = TreeListCtrl(self,-1,
                                   style = wx.TR_MULTIPLE|wx.TR_HIDE_ROOT|wx.TR_TWIST_BUTTONS)
        self.tree.AddColumn("Name")
        self.tree.AddColumn("Resource")
        self.tree.AddColumn("Status")
        self.tree.SetMainColumn(0)
        
        self.tree.SetColumnWidth(0,175)
        self.tree.SetColumnWidth(1,175)
        self.tree.SetColumnWidth(2,90)
        
        
        wx.EVT_TREE_ITEM_RIGHT_CLICK(self, self.tree.GetId(), self.PopupThatMenu)
        wx.EVT_TREE_ITEM_ACTIVATED(self, self.tree.GetId(), self.DoubleClickCB )

        wx.InitAllImageHandlers()

        imageSize = 22
        imageList = wx.ImageList(imageSize,imageSize)

        bm = icons.getComputerBitmap()
        self.smImage = imageList.Add(bm)

        bm = icons.getDefaultServiceBitmap()
        self.svcImage = imageList.Add(bm)
        
        self.tree.SetImageList(imageList)
        self.imageList = imageList
                

        # Create the status bar
        self.CreateStatusBar(2)
        self.SetStatusText("Not Connected",1)

        # Associate menu items with callbacks
        wx.EVT_MENU(self, ID_FILE_ATTACH            ,  self.Attach )
        wx.EVT_MENU(self, ID_FILE_EXIT              ,  self.TimeToQuit )
        wx.EVT_MENU(self, ID_FILE_LOAD_CONFIG       ,  self.LoadConfiguration )
        wx.EVT_MENU(self, ID_FILE_STORE_CONFIG      ,  self.StoreConfiguration )
        wx.EVT_MENU(self, ID_HELP_ABOUT             ,  self.OnAbout)
        wx.EVT_MENU(self, ID_HOST_ADD               ,  self.AddHost )
        wx.EVT_MENU(self, ID_HOST_REMOVE            ,  self.RemoveServiceManager )
        wx.EVT_MENU(self, ID_SERVICE_ADD_SERVICE    ,  self.AddService )
        wx.EVT_MENU(self, ID_SERVICE_CONFIGURE      ,  self.ConfigureService )
        wx.EVT_MENU(self, ID_SERVICE_REMOVE         ,  self.RemoveService )
        wx.EVT_MENU(self, ID_SERVICE_ENABLE         ,  self.EnableServices )
        wx.EVT_MENU(self, ID_SERVICE_ENABLE_ONE     ,  self.EnableService )
        wx.EVT_MENU(self, ID_SERVICE_DISABLE        ,  self.DisableServices )
        wx.EVT_MENU(self, ID_SERVICE_DISABLE_ONE    ,  self.DisableService )
        
        wx.EVT_TREE_KEY_DOWN(self.tree, self.tree.GetId(), self.OnKeyDown)
    
        self.menuBar = menuBar
        
        self.EnableMenus(False)
            
        self.recentNodeServiceList = []
        self.recentServiceManagerList = []
class NodeManagementClientFrame(wx.Frame):
    """
    The main UI frame for Node Management
    """
    def __init__(self, parent, ID, title,size=wx.Size(450,300),callback=None):
        wx.Frame.__init__(self, parent, ID, title,
                         wx.DefaultPosition, size=size)
                         
        self.callback = callback
        self.Center()
        self.SetTitle(title)
        self.SetIcon(icons.getAGIconIcon())
        self.serviceManagers = []
        self.nodeServiceHandle = None

        self.app = Toolkit.Application.instance()

        menuBar = wx.MenuBar()

        ## FILE menu
        self.fileMenu = wx.Menu()
        self.fileMenu.Append(ID_FILE_ATTACH, "Connect to Node...", 
                             "Connect to a NodeService")
        self.fileMenu.AppendSeparator()
        self.fileMenu.Append(ID_FILE_LOAD_CONFIG, "Load Configuration...", 
                             "Load a NodeService Configuration")
        self.fileMenu.Append(ID_FILE_STORE_CONFIG, "Store Configuration...", 
                             "Store a NodeService Configuration")
        self.fileMenu.AppendSeparator()
        self.fileMenu.Append(ID_FILE_EXIT, "E&xit", "Terminate the program")
        menuBar.Append(self.fileMenu, "&File");

        ## SERVICE MANAGERS menu
        self.serviceManagersMenu = BuildServiceManagerMenu()
        menuBar.Append(self.serviceManagersMenu, "&ServiceManager");
        
        ## SERVICE menu

        self.serviceMenu = BuildServiceMenu()
        menuBar.Append(self.serviceMenu, "&Service");
        
        ## HELP menu
        self.helpMenu = wx.Menu()
        self.helpMenu.Append(ID_HELP_ABOUT, "&About",
                    "More information about this program")
        menuBar.Append(self.helpMenu, "&Help");

        self.SetMenuBar(menuBar)

        self.tree = TreeListCtrl(self,-1,
                                   style = wx.TR_MULTIPLE|wx.TR_HIDE_ROOT|wx.TR_TWIST_BUTTONS)
        self.tree.AddColumn("Name")
        self.tree.AddColumn("Resource")
        self.tree.AddColumn("Status")
        self.tree.SetMainColumn(0)
        
        self.tree.SetColumnWidth(0,175)
        self.tree.SetColumnWidth(1,175)
        self.tree.SetColumnWidth(2,90)
        
        
        wx.EVT_TREE_ITEM_RIGHT_CLICK(self, self.tree.GetId(), self.PopupThatMenu)
        wx.EVT_TREE_ITEM_ACTIVATED(self, self.tree.GetId(), self.DoubleClickCB )

        wx.InitAllImageHandlers()

        imageSize = 22
        imageList = wx.ImageList(imageSize,imageSize)

        bm = icons.getComputerBitmap()
        self.smImage = imageList.Add(bm)

        bm = icons.getDefaultServiceBitmap()
        self.svcImage = imageList.Add(bm)
        
        self.tree.SetImageList(imageList)
        self.imageList = imageList
                

        # Create the status bar
        self.CreateStatusBar(2)
        self.SetStatusText("Not Connected",1)

        # Associate menu items with callbacks
        wx.EVT_MENU(self, ID_FILE_ATTACH            ,  self.Attach )
        wx.EVT_MENU(self, ID_FILE_EXIT              ,  self.TimeToQuit )
        wx.EVT_MENU(self, ID_FILE_LOAD_CONFIG       ,  self.LoadConfiguration )
        wx.EVT_MENU(self, ID_FILE_STORE_CONFIG      ,  self.StoreConfiguration )
        wx.EVT_MENU(self, ID_HELP_ABOUT             ,  self.OnAbout)
        wx.EVT_MENU(self, ID_HOST_ADD               ,  self.AddHost )
        wx.EVT_MENU(self, ID_HOST_REMOVE            ,  self.RemoveServiceManager )
        wx.EVT_MENU(self, ID_SERVICE_ADD_SERVICE    ,  self.AddService )
        wx.EVT_MENU(self, ID_SERVICE_CONFIGURE      ,  self.ConfigureService )
        wx.EVT_MENU(self, ID_SERVICE_REMOVE         ,  self.RemoveService )
        wx.EVT_MENU(self, ID_SERVICE_ENABLE         ,  self.EnableServices )
        wx.EVT_MENU(self, ID_SERVICE_ENABLE_ONE     ,  self.EnableService )
        wx.EVT_MENU(self, ID_SERVICE_DISABLE        ,  self.DisableServices )
        wx.EVT_MENU(self, ID_SERVICE_DISABLE_ONE    ,  self.DisableService )
        
        wx.EVT_TREE_KEY_DOWN(self.tree, self.tree.GetId(), self.OnKeyDown)
    
        self.menuBar = menuBar
        
        self.EnableMenus(False)
            
        self.recentNodeServiceList = []
        self.recentServiceManagerList = []
        
    def OnKeyDown(self,event):
        key = event.GetKeyCode()
      
        if key == wx.WXK_DELETE:

            dlg = wx.MessageDialog(self, "Delete selected items?" , "Confirm",
                                  style = wx.ICON_INFORMATION | wx.OK | wx.CANCEL)
            ret = dlg.ShowModal()
            dlg.Destroy()
            if ret == wx.ID_OK:
                self.RemoveSelectedItems()
            
        elif key == wx.WXK_F5:
            self.UpdateUI()
        
    def Connected(self):
        try:
            self.nodeServiceHandle.IsValid()
            return 1
        except:
            return 0


    def EnableMenus(self, flag):
        self.fileMenu.Enable(ID_FILE_LOAD_CONFIG,flag)
        self.fileMenu.Enable(ID_FILE_STORE_CONFIG,flag)
        self.menuBar.EnableTop(1,flag)
        self.menuBar.EnableTop(2,flag)
        self.menuBar.EnableTop(3,flag)
        
    

    ############################
    ## FILE menu
    ############################

    def Attach( self, event ):
        """
        Attach to a node service
        """

        dlg = ServiceChoiceDialog(self,-1,'NodeService Dialog',
                                  self.recentNodeServiceList,
                                  AGNodeService.ServiceType,
                                  'Select a Node Service URL from the list, or enter the hostname or \nservice URL of the Node Service')
        dlg.Center()
        ret = dlg.ShowModal()


        if ret == wx.ID_OK:
            url = dlg.GetValue()
            dlg.Destroy()
            
            url = BuildServiceUrl(url,'http',11000,'NodeService')
            
            if url not in self.recentNodeServiceList:
                self.recentNodeServiceList.append(url)
            
            # Attach (or fail)
            wx.BeginBusyCursor()
            self.AttachToNode(AGNodeServiceIW(url))

            if not self.Connected():
                self.Error( "Could not attach to AGNodeService at " + url  )
                wx.EndBusyCursor()
                return

            # Update the servicemanager and service lists
            self.UpdateUI()
            wx.EndBusyCursor()
        else:
            dlg.Destroy()
            
    def AttachToNode( self, nodeService ):
        """
        This method does the real work of attaching to a node service
        """

        # self.CheckCredentials()

        # Get proxy to the node service, if the url validates
        self.nodeServiceHandle = nodeService

        if self.nodeServiceHandle and self.nodeServiceHandle.IsValid():
            self.SetStatusText("Connected",1)
            self.EnableMenus(True)
      
    def LoadConfiguration( self, event ):
        """
        Load a configuration for the node service
        """
        configs = self.nodeServiceHandle.GetConfigurations()

        # Map display name to configurations
        sysConfigs = []
        userConfigs = []
        configMap = {}
        for c in configs:
            displayName = c.name+" ("+c.type+")"
            configMap[displayName] = c
            
            if c.type == 'system':
                sysConfigs.append(displayName)
            elif c.type == 'user':
                userConfigs.append(displayName)

        sysConfigs.sort()
        userConfigs.sort()
        displayNames = sysConfigs + userConfigs

        d = wx.SingleChoiceDialog( self, "Select a configuration file to load", 
                                  "Load Configuration Dialog", displayNames)
        ret = d.ShowModal()

        if ret == wx.ID_OK:
            conf = d.GetStringSelection()

            if len( conf ) == 0:
                self.Error( "No selection made" )
                return

            # Get correct config name
            if configMap.has_key:
                conf = configMap[conf].name

            config = None
            for c in configs:
                if conf == c.name:
                    config = c

            try:
                wx.BeginBusyCursor()
                self.nodeServiceHandle.LoadConfiguration( config )
            except:
                log.exception("NodeManagementClientFrame.LoadConfiguration: Can not load configuration from node service")
                self.Error("Error loading node configuration %s" % (conf,))

            self.UpdateUI()
            
            if self.callback:
                try:
                    self.callback('load_config')
                except:
                    log.exception('exception from registered callback')
            
            wx.EndBusyCursor()

    def StoreConfiguration( self, event ):
        """
        Store a node service configuration
        """

        # Get known configurations from the Node Service
        configs = self.nodeServiceHandle.GetConfigurations()

        # Prompt user to name the configuration
        d = StoreConfigDialog(self,-1,"Store Configuration", configs)
        ret = d.ShowModal()

        if ret == wx.ID_OK:
            ret = d.GetValue()
            if ret:
                (configName,isDefault,isSystem) = ret
                
                # Handle error cases
                if len( configName ) == 0:
                    self.Error( "Invalid config name specified (%s)" % (configName,) )
                    return
                     
                # Confirm overwrite
                if configName in map(lambda x: x.name, configs): #configs:
                    text ="Overwrite %s?" % (configName,)
                    dlg = wx.MessageDialog(self, text, "Confirm",
                                          style = wx.ICON_INFORMATION | wx.OK | wx.CANCEL)
                    ret = dlg.ShowModal()
                    dlg.Destroy()
                    if ret != wx.ID_OK:
                        return

                config = None
             
                for c in configs:
                    if configName == c.name:
                        config = c

                if not config:
                    # Create a new configuration
                    config = NodeConfigDescription(configName, NodeConfigDescription.USER)

                if isSystem:
                    config.type = NodeConfigDescription.SYSTEM
                                    
                # Store the configuration
                try:
                    wx.BeginBusyCursor()
                    self.nodeServiceHandle.StoreConfiguration( config )
                except:
                    log.exception("Error storing node configuration %s" % (configName,))
                    self.Error("Error storing node configuration %s" % (configName,))

                # Set the default configuration
                if isDefault:
                    prefs = self.app.GetPreferences()
                    prefs.SetPreference(Preferences.NODE_CONFIG,configName)
                    prefs.SetPreference(Preferences.NODE_CONFIG_TYPE,config.type)
                    prefs.StorePreferences()

                if self.callback:
                    try:
                        self.callback('store_config')
                    except:
                        log.exception('exception from registered callback')
                    
                wx.EndBusyCursor()

        d.Destroy()


    def TimeToQuit(self, event):
        """
        Exit
        """
        self.Close(True)

    ############################
    ## VIEW menu
    ############################

    def UpdateUI( self, event=None ):
        """
        Update the service list (bring it into sync with the node service)
        """
        
        selections = self.GetSelectedItems()
        selectionUrls = []
        if len(selections)>0:
            selectionUrls = map( lambda x: x.uri, selections)

        self.serviceManagers = self.nodeServiceHandle.GetServiceManagers()

        import urlparse
        self.tree.DeleteAllItems()
        root = self.tree.AddRoot("")    
        if self.serviceManagers:
            for serviceManager in self.serviceManagers:
                name = urlparse.urlsplit(serviceManager.uri)[1]
                sm = self.tree.AppendItem(root,name)
                self.tree.SetItemImage(sm, self.smImage,which=wx.TreeItemIcon_Normal)
                self.tree.SetItemImage(sm, self.smImage, which=wx.TreeItemIcon_Expanded)
                self.tree.SetItemData(sm,wx.TreeItemData(serviceManager))
                services = serviceManager.GetObject().GetServices()
                        
                if services: 
                    for service in services:
                        s = self.tree.AppendItem(sm,service.name)
                        self.tree.SetItemImage(s, self.svcImage, which = wx.TreeItemIcon_Normal)
                        self.tree.SetItemData(s,wx.TreeItemData(service))
                        resource = service.GetObject().GetResource()
                        if resource:
                            self.tree.SetItemText(s,resource.name,1)
                        if service.GetObject().GetEnabled():
                            status = "Enabled"
                        else:
                            status = "Disabled"
                        self.tree.SetItemText(s,status,2)
                
                        if service.uri in selectionUrls:
                            self.tree.SelectItem(s)
                
                    self.tree.Expand(sm)
                else:
                    s = self.tree.AppendItem(sm,'No services')
                    self.tree.Collapse(sm)
            
                if serviceManager.uri in selectionUrls:
                    self.tree.SelectItem(sm)
                    
                if not self.tree.GetSelections():
                    self.SelectDefault()

            self.tree.Expand(root)
    
    ############################
    ## HOST menu
    ############################
    def AddHost( self, event ):
        """
        Add a service manager to the node service
        """

        dlg = ServiceChoiceDialog(self,-1,'Service Manager Dialog',
                                  self.recentServiceManagerList,
                                  AGServiceManager.ServiceType,
                                  'Select a Service Manager URL from the list, or enter the hostname or \nservice URL of the Service Manager')
        dlg.Center()
        ret = dlg.ShowModal()
        if ret == wx.ID_OK:

            url = dlg.GetValue()
            dlg.Destroy()

            url = BuildServiceUrl(url,'http',11000,'ServiceManager')

            if url not in self.recentServiceManagerList:
                self.recentServiceManagerList.append(url)
            try:
                wx.BeginBusyCursor()
                self.nodeServiceHandle.AddServiceManager( url )
            except (socket.gaierror,socket.error),e:
                log.exception("Exception in AddHost")
                self.Error("Can not add service manager to node service:\n%s"%(e.args[1]))
            except: