示例#1
0
BundleManager::BundleManager(wxWindow *parent, RemoteThread& remoteThread, ITmLoadBundles* syntaxHandler)
: wxDialog (parent, -1, _("Manage Bundles"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER),
  m_remoteThread(remoteThread), m_syntaxHandler(syntaxHandler), m_plistHandler(m_syntaxHandler->GetPListHandler()),
  m_allBundlesReceived(false), m_needBundleReload(false)
{
	m_repositories.push_back(RepoInfo(wxT("review mm"), wxT("http://svn.textmate.org/trunk/Review/Bundles/")));
	m_repositories.push_back(RepoInfo(wxT("macromates"), wxT("http://svn.textmate.org/trunk/Bundles/")));
	m_repositories.push_back(RepoInfo(wxT("ebundles"), wxT("http://ebundles.googlecode.com/svn/trunk/Bundles/")));

	wxImageList* imageList = new wxImageList(16, 16, true, 0);
	imageList->Add(wxIcon(empty_xpm));
	imageList->Add(wxIcon(accept_xpm));
	imageList->Add(wxIcon(exclamation_xpm));

	// Create the controls
	m_bundleList = new wxListCtrl(this, ID_BUNDLELIST, wxDefaultPosition, wxDefaultSize, wxLC_REPORT|wxLC_SINGLE_SEL);
	m_bundleList->InsertColumn(0, _("Bundles"));
	m_bundleList->SetColumnWidth(0, 400);
	m_bundleList->InsertColumn(1, _("Last Updated"));
	m_bundleList->InsertColumn(2, _("Source"));
	m_bundleList->AssignImageList(imageList, wxIMAGE_LIST_SMALL);

#ifdef __WXMSW__
	m_browser = new wxIEHtmlWin(this, ID_HTML_DESC);
#endif

	wxStaticText* statusLabel = new wxStaticText(this, wxID_ANY, _("Status: "));
	m_statusText = new wxStaticText(this, wxID_ANY, wxT(""));
	m_installButton = new wxButton(this, ID_INSTALLBUTTON, _("Install"));
	m_installButton->Hide();
	m_deleteButton = new wxButton(this, ID_DELETEBUTTON, _("Delete"));
	m_deleteButton->Hide();

	// Let the user know that we are downloading bundle info
	m_bundleList->InsertItem(0, _("Retrieving Bundles..."));
	m_bundleList->SetItemTextColour(0, *wxLIGHT_GREY);

	// Create the layout
	m_mainSizer = new wxBoxSizer(wxVERTICAL);
		m_mainSizer->Add(m_bundleList, 4, wxEXPAND|wxALL, 5);
		wxSizer* statusSizer = new wxBoxSizer(wxHORIZONTAL);
			statusSizer->Add(statusLabel, 0, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL);
			statusSizer->Add(m_statusText, 0, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL|wxLEFT, 5);
			statusSizer->AddStretchSpacer();
			statusSizer->Add(m_installButton, 0, wxALIGN_RIGHT|wxLEFT, 5);
			statusSizer->Add(m_deleteButton, 0, wxALIGN_RIGHT|wxLEFT, 5);
			m_mainSizer->Add(statusSizer, 0, wxEXPAND|wxLEFT|wxRIGHT, 5);
#ifdef __WXMSW__
		m_mainSizer->Add(m_browser, 1, wxEXPAND|wxALL, 5);
#endif

	SetSizerAndFit(m_mainSizer);
	SetSize(600, 600);
	Centre();

	LoadBundleLists();
}
示例#2
0
bool ListReposCommand::parseResponse(const std::string& raw_resp,
                                     RepoInfoList *infos)
{
    std::vector<std::string> lines = utils::split(raw_resp, '\n');
    if (lines.empty()) {
        return true;
    }
    for (size_t i = 0; i < lines.size(); i++) {
        std::string line = lines[i];
        std::vector<std::string> parts = utils::split(line, '\t');
        if (parts.size() != 5) {
            continue;
        }
        std::string repo_id, repo_name, worktree, status;
        RepoInfo::Status st;
        bool support_file_lock;

        repo_id = parts[0];
        repo_name = parts[1];
        worktree = utils::normalizedPath(parts[2]);
        status = parts[3];
        support_file_lock = parts[4] == "file-lock-supported";
        if (status == "paused") {
            st = RepoInfo::Paused;
        } else if (status == "syncing") {
            st = RepoInfo::Syncing;
        } else if (status == "error") {
            st = RepoInfo::Error;
        } else if (status == "normal") {
            st = RepoInfo::Normal;
        } else {
            // impossible
            seaf_ext_log ("bad repo status \"%s\"", status.c_str());
            continue;
        }
        // seaf_ext_log ("status for %s is \"%s\"", repo_name.c_str(), status.c_str());
        infos->push_back(RepoInfo(repo_id, repo_name, worktree, st, support_file_lock));
    }

    reposInfoTimestamp = utils::currentMSecsSinceEpoch();
    return true;

}