void ConfirmDialog::OnProjectNotFoundClicked( wxHyperlinkEvent& event )
{
    ImportProjectDialog ipd(this);
	ipd.ShowModal();
	ipd.Destroy();

    UpdateProjectList();
}
void ConfirmDialog::ConfirmNewSession(const wxString & equipment_id)
{
	if(m_gridMetadata->GetNumberRows()<2)
	{
		ResetGridMetadata();
	}

    // update project list
    UpdateProjectList();

	// update current date time
	m_gridMetadata->SetCellValue (0, 0, wxDateTime::Now().FormatISOCombined());
	
	// update equipment id
	m_gridMetadata->SetCellValue (1, 0, equipment_id);
	
	// retrieve booking information here
	Show(true);
	SetFocus();
}
Ejemplo n.º 3
0
void CSimpleProjectPanel::UpdateInterface() {
    int n, count = -1;
    bool b_needMenuRebuild = false;
    wxString str = wxEmptyString;
    wxString projName = wxEmptyString;
    CMainDocument* pDoc = wxGetApp().GetDocument();

    wxASSERT(pDoc);

    // Should we display the synchronize button instead of the
    //   attach to project button?
    if ( pDoc->IsConnected() ) {
        CC_STATUS       status;
        int             is_acct_mgr_detected = 0;

        pDoc->GetCoreClientStatus(status);

        if (pDoc->m_iAcct_mgr_info_rpc_result == 0) {
            // We use an integer rather than a bool to force action the first time
            is_acct_mgr_detected = pDoc->ami.acct_mgr_url.size() ? 1 : 0;
            
            if ((m_UsingAccountManager != is_acct_mgr_detected) || (!m_TaskAddProjectButton->IsEnabled())) {
                m_UsingAccountManager = is_acct_mgr_detected;
                if (is_acct_mgr_detected) {
                    m_TaskAddProjectButton->SetLabel(m_sSynchronizeString);
                    m_TaskAddProjectButton->Enable();
                    m_TaskAddProjectButton->SetToolTip(m_sSynchronizeToolTip);
                } else {
                    m_TaskAddProjectButton->SetLabel(m_sAddProjectString);
                    if (!status.disallow_attach) {
                        m_TaskAddProjectButton->Enable();
                        m_TaskAddProjectButton->SetToolTip(m_sAddProjectToolTip);
                   }
                }
                this->Layout();
            }
        } else {
            m_TaskAddProjectButton->Disable();
        }

        UpdateProjectList();
        
        count = m_ProjectSelectionCtrl->GetCount();
    }
    if (count > 0) {
        n = m_ProjectSelectionCtrl->GetSelection();
        if ((n < 0) || (n > count -1)) {
            m_ProjectSelectionCtrl->SetSelection(0);
            n = 0;
        }
        
        // Check to see if we need to rebuild the menu
        char* ctrl_url = ((ProjectSelectionData*)m_ProjectSelectionCtrl->GetClientData(n))->project_url;
        if (strcmp(m_CurrentSelectedProjectURL, ctrl_url)) {
            b_needMenuRebuild = true;
            strncpy(m_CurrentSelectedProjectURL, ctrl_url, sizeof(m_CurrentSelectedProjectURL));
        }
        
        PROJECT* project = pDoc->state.lookup_project(ctrl_url);
        if ( project != NULL && project->last_rpc_time > m_Project_last_rpc_time ) {
            b_needMenuRebuild = true;
            m_Project_last_rpc_time = project->last_rpc_time;
        }
        
        if (b_needMenuRebuild) {
            m_ProjectWebSitesButton->RebuildMenu();
        }

        m_ProjectWebSitesButton->Enable();
        m_ProjectCommandsButton->Enable();
        
        if (m_fDisplayedCredit != project->user_total_credit) {
            str.Printf(wxT("%s: %s"),
                m_sTotalWorkDoneString.c_str(),
                format_number(project->user_total_credit, 0)
            );
            UpdateStaticText(&m_TotalCreditValue, str);
            m_TotalCreditValue->SetName(str);   // For accessibility on Windows
        }
        projName = m_ProjectSelectionCtrl->GetStringSelection();
        str.Printf(_("Pop up a menu of web sites for project %s"), projName.c_str());
        m_ProjectWebSitesButton->SetToolTip(str);
        str.Printf(_("Pop up a menu of commands to apply to project %s"), projName.c_str());
        m_ProjectCommandsButton->SetToolTip(str);
    } else {
        m_ProjectWebSitesButton->Disable();
        m_ProjectCommandsButton->Disable();
        m_CurrentSelectedProjectURL[0] = '\0';
        m_fDisplayedCredit = -1.0;
        UpdateStaticText(&m_TotalCreditValue, wxEmptyString);
        m_TotalCreditValue->SetName(wxEmptyString);   // For accessibility on Windows
        m_ProjectWebSitesButton->SetToolTip(wxEmptyString);
        m_ProjectCommandsButton->SetToolTip(wxEmptyString);
    }
}
ConfirmDialog::ConfirmDialog( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxDialog( parent, id, title, pos, size, style )
{
	this->SetSizeHints( wxDefaultSize, wxDefaultSize );
	
	m_sizerMain = new wxFlexGridSizer( 5, 1, 0, 0 );
	m_sizerMain->AddGrowableCol( 0 );
	m_sizerMain->AddGrowableRow( 3 );
	m_sizerMain->SetFlexibleDirection( wxBOTH );
	m_sizerMain->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
	
	m_panelBackground = new wxPanel( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
	m_panelBackground->SetBackgroundColour( wxColour( 255, 255, 128 ) );
	
	wxBoxSizer* sizerWarning;
	sizerWarning = new wxBoxSizer( wxVERTICAL );
	
	wxBoxSizer* sizerWarningMiddle;
	sizerWarningMiddle = new wxBoxSizer( wxHORIZONTAL );
	
	wxStaticBitmap* bitmapWarning;
	bitmapWarning = new wxStaticBitmap( m_panelBackground, wxID_ANY, wxArtProvider::GetBitmap( wxART_WARNING, wxART_OTHER ), wxDefaultPosition, wxSize( -1,-1 ), 0 );
	sizerWarningMiddle->Add( bitmapWarning, 0, 0, 0 );
	
	wxStaticText* labelWarning;
	labelWarning = new wxStaticText( m_panelBackground, wxID_ANY, wxT("Warning: Can not connect to server"), wxDefaultPosition, wxDefaultSize, 0 );
	labelWarning->Wrap( -1 );
	sizerWarningMiddle->Add( labelWarning, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
	
	sizerWarning->Add( sizerWarningMiddle, 1, wxALIGN_CENTER, 0 );
	
	m_panelBackground->SetSizer( sizerWarning );
	m_panelBackground->Layout();
	sizerWarning->Fit( m_panelBackground );
	m_sizerMain->Add( m_panelBackground, 1, wxEXPAND | wxALL, 0 );
	
	
	m_sizerMain->Add( 0, 0, 1, wxALL|wxEXPAND, 10 );
	
	wxStaticText* labelTitle;
	labelTitle = new wxStaticText( this, wxID_ANY, wxT("Confirm Research Project"), wxDefaultPosition, wxDefaultSize, 0 );
	labelTitle->Wrap( -1 );
	
	m_sizerMain->Add( labelTitle, 0, wxALL|wxEXPAND, 5 );
	
	wxFlexGridSizer* sizerMiddle;
	sizerMiddle = new wxFlexGridSizer( 3, 3, 0, 0 );
	sizerMiddle->AddGrowableCol( 1 );
	sizerMiddle->AddGrowableRow( 2 );
	sizerMiddle->SetFlexibleDirection( wxBOTH );
	sizerMiddle->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
	
	wxStaticText* labelProject;
	labelProject = new wxStaticText( this, wxID_ANY, wxT("Research Project"), wxDefaultPosition, wxDefaultSize, 0 );
	labelProject->Wrap( -1 );
	sizerMiddle->Add( labelProject, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
	
	wxString m_choiceProjectChoices[] = { wxEmptyString, wxT("- Not a registered research project -") };
	int m_choiceProjectNChoices = sizeof( m_choiceProjectChoices ) / sizeof( wxString );
	m_choiceProject = new wxChoice( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, m_choiceProjectNChoices, m_choiceProjectChoices, 0 );
	sizerMiddle->Add( m_choiceProject, 0, wxALL|wxEXPAND, 5 );
	
	wxStaticText* staticText10;
	staticText10 = new wxStaticText( this, wxID_ANY, wxT("*"), wxDefaultPosition, wxDefaultSize, 0 );
	staticText10->Wrap( -1 );
	sizerMiddle->Add( staticText10, 0, wxALL, 5 );
	
	
	sizerMiddle->Add( 0, 0, 1, wxEXPAND, 5 );

	wxFlexGridSizer* fgSizer6;
	fgSizer6 = new wxFlexGridSizer( 1, 2, 0, 0 );
	fgSizer6->AddGrowableCol( 0 );
	fgSizer6->AddGrowableRow( 0 );
	fgSizer6->SetFlexibleDirection( wxHORIZONTAL );
	fgSizer6->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
	

	
	m_labelTips = new wxStaticText( this, wxID_ANY, wxT("Please identify your research project ."), wxDefaultPosition, wxDefaultSize, 0 );
	m_labelTips->Wrap( -1 );
	fgSizer6->Add( m_labelTips, 0, wxALL|wxEXPAND, 5 );
	
	m_linkProjNotFound = new wxHyperlinkCtrl(
		this, wxID_ANY,
		"Project Not Found?",
		wxEmptyString, wxDefaultPosition, wxDefaultSize, wxHL_DEFAULT_STYLE );
	m_linkProjNotFound->SetToolTip( "Click to import your project" );
	
	fgSizer6->Add( m_linkProjNotFound, 0, wxALL, 5 );
	
	sizerMiddle->Add( fgSizer6, 1, wxEXPAND, 5 );
	
	sizerMiddle->Add( 0, 0, 1, wxEXPAND, 5 );
	
	wxStaticText* staticTextMetadata;
	staticTextMetadata = new wxStaticText( this, wxID_ANY, wxT("Metadata"), wxDefaultPosition, wxDefaultSize, 0 );
	staticTextMetadata->Wrap( -1 );
	sizerMiddle->Add( staticTextMetadata, 0, wxALIGN_TOP|wxALL, 5 );
	
	m_gridMetadata = new wxGrid( this, wxID_ANY, wxDefaultPosition, wxSize( 400,250 ), 0 );
	
	// Grid
	m_gridMetadata->CreateGrid( 0, 1 );
	m_gridMetadata->EnableEditing( true );
	m_gridMetadata->EnableGridLines( true );
	m_gridMetadata->EnableDragGridSize( false );
	m_gridMetadata->SetMargins( 0, 0 );
	
	// Columns
	m_gridMetadata->SetColSize( 0, 250 );
	m_gridMetadata->EnableDragColMove( false );
	m_gridMetadata->EnableDragColSize( true );
	m_gridMetadata->SetColLabelSize( 30 );
	m_gridMetadata->SetColLabelValue( 0, wxT("Value") );
	m_gridMetadata->SetColLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE );
	
	// Rows
	m_gridMetadata->EnableDragRowSize( false );
	m_gridMetadata->SetRowLabelSize( 250 );
	m_gridMetadata->SetRowLabelAlignment( wxALIGN_LEFT, wxALIGN_CENTRE );
	
	// Label Appearance
	
	// Cell Defaults
	m_gridMetadata->SetDefaultCellAlignment( wxALIGN_LEFT, wxALIGN_TOP );
	sizerMiddle->Add( m_gridMetadata, 0, wxALL|wxEXPAND, 5 );
	
	
	sizerMiddle->Add( 0, 0, 1, wxEXPAND, 5 );
	
	m_sizerMain->Add( sizerMiddle, 1, wxALL|wxEXPAND, 20 );
	
	wxFlexGridSizer* fgSizer4;
	fgSizer4 = new wxFlexGridSizer( 1, 2, 0, 0 );
	fgSizer4->AddGrowableCol( 0 );
	fgSizer4->AddGrowableRow( 0 );
	fgSizer4->SetFlexibleDirection( wxBOTH );
	fgSizer4->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
	
	wxStaticText* staticText11;
	staticText11 = new wxStaticText( this, wxID_ANY, wxT("* Mandatory item"), wxDefaultPosition, wxDefaultSize, 0 );
	staticText11->Wrap( -1 );
	staticText11->SetForegroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_3DDKSHADOW ) );
	
	fgSizer4->Add( staticText11, 0, wxALIGN_CENTER_VERTICAL|wxALL, 10 );
	
	wxBoxSizer* bSizer5;
	bSizer5 = new wxBoxSizer( wxHORIZONTAL );
	
	m_buttonCancel = new wxButton( this, wxID_CANCEL, wxT("Cancel"), wxDefaultPosition, wxDefaultSize, 0 );
	bSizer5->Add( m_buttonCancel, 0, wxALL, 5 );
	
	m_buttonLaunch = new wxButton( this, wxID_ANY, wxT("Start"), wxDefaultPosition, wxDefaultSize, 0 );
	m_buttonLaunch->SetDefault(); 
	bSizer5->Add( m_buttonLaunch, 0, wxALL, 5 );
	
	fgSizer4->Add( bSizer5, 1, wxALL|wxEXPAND, 5 );
	
	m_sizerMain->Add( fgSizer4, 1, wxEXPAND, 5 );
	
	this->SetSizer( m_sizerMain );
	this->Layout();
	m_sizerMain->Fit( this );
	
	this->Centre( wxBOTH );
	
	// Connect Events
	m_choiceProject->Connect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( ConfirmDialog::OnProjectChoice ), NULL, this );
	m_gridMetadata->Connect( wxEVT_SIZE, wxSizeEventHandler( ConfirmDialog::OnSize ), NULL, this );
	m_buttonLaunch->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( ConfirmDialog::OnLaunch ), NULL, this );
	m_linkProjNotFound->Connect( wxEVT_COMMAND_HYPERLINK, wxHyperlinkEventHandler( ConfirmDialog::OnProjectNotFoundClicked ), NULL, this );
	


	/**
	 * Extra code not imported from wxFormBuilder
	 * Make sure not overwritten by update on form builder
	 */
	// set up icon
	this->SetIcon(icon_xpm);
	m_sizerMain->Hide(m_panelBackground);

    UpdateProjectList();

}