/// <summary> /// refreshes the listbox /// </summary> private void RefreshList() { ListBoxServers.Items.Clear(); ServersConfig cnf = ServersConfig.GetInstance(); Iterator <ServerDetails> itsd = cnf.GetServerDetails(); while (itsd.HasNext()) { ServerDetails sd = itsd.GetNext(); ListBoxServers.Items.Add(sd.GetName()); } }
// ================================================================= // UI Events // ================================================================= /// <summary> /// When creating a new repository two things need to happen. The /// server needs to setup a bare repo and the local directory needs /// to be linked to the remote repo. /// </summary> private void ButtonAccept_Click(object sender, EventArgs e) { // error checks string repoName = TextBoxRepoName.Text; if (repoName == null) { return; } if (repoName.Equals("")) { return; } if (repoName.Equals("Repository Name")) { return; } string localDir = TextBoxLocalDirectory.Text; if (localDir == null) { return; } if (localDir.Equals("")) { return; } string server = ComboBoxSelectServer.GetItemText(ComboBoxSelectServer.SelectedItem); if (server == null) { return; } if (server.Equals("")) { return; } localDir = localDir.Replace(@"\", "/") + "/" + repoName; // get server details ListItem listitem = (ListItem)(ComboBoxSelectServer.SelectedItem); ServerDetails sd = listitem.Details; // connect to server to setup the remote repo RemoteManager rman = RemoteManager.GetInstance(); IRemote remote = rman.Connect(sd); if (!remote.IsConnected()) // error { DialogUtil.Message("Error: Cannot connect to remote repository"); return; } IStream stream = remote.GetStream(); string repoLoc = sd.GetLocation() + "/" + repoName; stream.Execute("mkdir -p " + repoLoc); stream.Execute("cd " + repoLoc); bool success = stream.Execute("git init --bare"); if (!success) // error { DialogUtil.Message("Error: Could not execute command"); return; } // make local directory Directory.CreateDirectory(localDir); if (!Directory.Exists(localDir)) // error { DialogUtil.Message("Error: Could not create local repository"); return; } // make and run the script for initializing a new local repo string remoteDir = sd.GetServerLoginString() + "/" + repoName; RepoDetails repo = new RepoDetails(repoName, sd.GetName(), remoteDir, localDir); string script = ScriptBuilder.NewScript(repo); Executable exe = new Executable("expect.exe", script).Start(); exe.WaitForExit(); // add new repo to configuration ReposConfig.GetInstance().AddRepoDetails(repo, false); ReposConfig.GetInstance().Save(); // done. now close and fire refresh event EventManager.Fire(EventCode.REFRESH_REPOS); ProperClose(); }
// ================================================================= // UI Events // ================================================================= private void ButtonAccept_Click(object sender, EventArgs e) { // error checks string repoName = TextBoxRepoName.Text; if (repoName == null) { return; } if (repoName.Equals("")) { return; } if (repoName.Equals("Repository Name")) { return; } string localDir = TextBoxLocalDirectory.Text; if (localDir == null) { return; } if (localDir.Equals("")) { return; } localDir = localDir.Replace(@"\", "/"); string server = ComboBoxSelectServer.GetItemText(ComboBoxSelectServer.SelectedItem); if (server == null) { return; } if (server.Equals("")) { return; } // get server details ListItem listitem = (ListItem)(ComboBoxSelectServer.SelectedItem); ServerDetails sd = listitem.Details; // check to see if sevrer is available RemoteManager rman = RemoteManager.GetInstance(); IRemote remote = rman.Connect(sd); if (!remote.IsConnected()) // error { DialogUtil.Message("Error: Cannot connect to remote repository"); return; } // make and run the script for downloading the selected repository string remoteDir = sd.GetServerLoginString() + "/" + repoName; RepoDetails repo = new RepoDetails(repoName, sd.GetName(), remoteDir, localDir); string script = ScriptBuilder.CloneScript(repo, sd); Executable exe = new Executable("expect.exe", script).Start(); exe.WaitForExit(); // add new repo to configuration ReposConfig.GetInstance().AddRepoDetails(repo, false); ReposConfig.GetInstance().Save(); // done. now close and fire refresh event EventManager.Fire(EventCode.REFRESH_REPOS); ProperClose(); }