Added some UI niceness (connect/disconnect thing in Grid menu)

zircon^2
gareth 2007-05-19 12:22:26 +00:00
parent 338ef1473d
commit 401004ea64
5 changed files with 34 additions and 1 deletions

View File

@ -10,6 +10,7 @@ namespace OpenGridServices.Manager
{ {
private string ServerURL; private string ServerURL;
public LLUUID SessionID; public LLUUID SessionID;
public bool connected=false;
public bool Connect(string GridServerURL, string username, string password) public bool Connect(string GridServerURL, string username, string password)
{ {
@ -23,14 +24,17 @@ namespace OpenGridServices.Manager
XmlRpcRequest GridLoginReq = new XmlRpcRequest("manager_login",LoginParams); XmlRpcRequest GridLoginReq = new XmlRpcRequest("manager_login",LoginParams);
XmlRpcResponse GridResp = GridLoginReq.Send(ServerURL,3000); XmlRpcResponse GridResp = GridLoginReq.Send(ServerURL,3000);
if(GridResp.IsFault) { if(GridResp.IsFault) {
connected=false;
return false; return false;
} else { } else {
Hashtable gridrespData = (Hashtable)GridResp.Value; Hashtable gridrespData = (Hashtable)GridResp.Value;
this.SessionID = new LLUUID((string)gridrespData["session_id"]); this.SessionID = new LLUUID((string)gridrespData["session_id"]);
connected=true;
return true; return true;
} }
} catch(Exception e) { } catch(Exception e) {
Console.WriteLine(e.ToString()); Console.WriteLine(e.ToString());
connected=false;
return false; return false;
} }
} }
@ -52,6 +56,7 @@ namespace OpenGridServices.Manager
if(GridResp.IsFault) { if(GridResp.IsFault) {
return false; return false;
} else { } else {
connected=false;
return true; return true;
} }
} catch(Exception e) { } catch(Exception e) {
@ -60,5 +65,9 @@ namespace OpenGridServices.Manager
} }
} }
public void DisconnectServer()
{
this.connected=false;
}
} }
} }

View File

@ -41,6 +41,7 @@ namespace OpenGridServices.Manager
win.SetStatus("Connecting to grid server..."); win.SetStatus("Connecting to grid server...");
if(gridserverConn.Connect(operation.Split(sep)[1],operation.Split(sep)[2],operation.Split(sep)[3])) { if(gridserverConn.Connect(operation.Split(sep)[1],operation.Split(sep)[2],operation.Split(sep)[3])) {
win.SetStatus("Connected OK with session ID:" + gridserverConn.SessionID); win.SetStatus("Connected OK with session ID:" + gridserverConn.SessionID);
win.SetGridServerConnected(true);
Thread.Sleep(3000); Thread.Sleep(3000);
win.SetStatus(""); win.SetStatus("");
} else { } else {
@ -63,12 +64,18 @@ namespace OpenGridServices.Manager
win.SetStatus("Shutting down grid server..."); win.SetStatus("Shutting down grid server...");
if(gridserverConn.ShutdownServer()) { if(gridserverConn.ShutdownServer()) {
win.SetStatus("Grid server shutdown"); win.SetStatus("Grid server shutdown");
win.SetGridServerConnected(false);
Thread.Sleep(3000); Thread.Sleep(3000);
win.SetStatus(""); win.SetStatus("");
} else { } else {
win.SetStatus("Could not shutdown grid server!!!"); win.SetStatus("Could not shutdown grid server!!!");
} }
break; break;
case "disconnect_gridserver":
gridserverConn.DisconnectServer();
win.SetGridServerConnected(false);
break;
} }
} }
} }

View File

@ -15,6 +15,17 @@ namespace OpenGridServices.Manager {
this.statusbar1.Push(0,statustext); this.statusbar1.Push(0,statustext);
} }
public void SetGridServerConnected(bool connected)
{
if(connected) {
this.ConnectToGridserver.Visible=false;
this.DisconnectFromGridServer.Visible=true;
} else {
this.ConnectToGridserver.Visible=true;
this.DisconnectFromGridServer.Visible=false;
}
}
protected void OnDeleteEvent (object sender, DeleteEventArgs a) protected void OnDeleteEvent (object sender, DeleteEventArgs a)
{ {
Application.Quit (); Application.Quit ();
@ -32,7 +43,6 @@ namespace OpenGridServices.Manager {
{ {
ConnectToGridServerDialog griddialog = new ConnectToGridServerDialog (); ConnectToGridServerDialog griddialog = new ConnectToGridServerDialog ();
griddialog.Show(); griddialog.Show();
} }
protected virtual void RestartGridserverMenu(object sender, System.EventArgs e) protected virtual void RestartGridserverMenu(object sender, System.EventArgs e)
@ -45,6 +55,11 @@ namespace OpenGridServices.Manager {
MainClass.PendingOperations.Enqueue("shutdown_gridserver"); MainClass.PendingOperations.Enqueue("shutdown_gridserver");
} }
protected virtual void DisconnectGridServerMenu(object sender, System.EventArgs e)
{
MainClass.PendingOperations.Enqueue("disconnect_gridserver");
}
} }
} }

View File

@ -355,6 +355,7 @@ namespace OpenGridServices.Manager {
this.ExitGridManager.Activated += new System.EventHandler(this.QuitMenu); this.ExitGridManager.Activated += new System.EventHandler(this.QuitMenu);
this.ShutdownGridserverOnly.Activated += new System.EventHandler(this.ShutdownGridserverMenu); this.ShutdownGridserverOnly.Activated += new System.EventHandler(this.ShutdownGridserverMenu);
this.RestartGridserverOnly.Activated += new System.EventHandler(this.RestartGridserverMenu); this.RestartGridserverOnly.Activated += new System.EventHandler(this.RestartGridserverMenu);
this.DisconnectFromGridServer.Activated += new System.EventHandler(this.DisconnectGridServerMenu);
} }
} }
} }

View File

@ -129,6 +129,7 @@
<property name="ShortLabel" translatable="yes">Disconnect from grid server</property> <property name="ShortLabel" translatable="yes">Disconnect from grid server</property>
<property name="StockId">gtk-disconnect</property> <property name="StockId">gtk-disconnect</property>
<property name="Visible">False</property> <property name="Visible">False</property>
<signal name="Activated" handler="DisconnectGridServerMenu" after="yes" />
</action> </action>
<action id="UploadAsset"> <action id="UploadAsset">
<property name="Type">Action</property> <property name="Type">Action</property>