//=========================================================================
+ bool wxBlackBoxEditionDialog::isValidNameForABox(std::string boxname) {
+
+ int i=0;
+ for (i = 0; i < boxname.size() ; i++) {
+ if ( (isalnum(boxname[i])==0) && (boxname.compare(i, 1, "-") != 0) && ( boxname.compare(i, 1, "_") != 0) ){
+ return false;
+ }
+ } // for
+
+ return true;
+ }
+
+ //=========================================================================
+
void wxBlackBoxEditionDialog::constructBlackBoxEditionDialog()
{
wxBoxSizer *sizerDialog = new wxBoxSizer(wxVERTICAL);
wxScrolledWindow *scrollWin = new wxScrolledWindow( this, -1, wxDefaultPosition, wxSize(200,200), wxVSCROLL);
+ wxStaticText *textBoxName = new wxStaticText(scrollWin, -1, wxT("Box Name"));
+ wxTextCtrl *valueBoxName = new wxTextCtrl(scrollWin, -1, _T(""), wxDefaultPosition,wxSize(300,25));
+ _initBoxName = _model->getBBTKName();
+ valueBoxName->SetValue(crea::std2wx(_initBoxName));
+ _boxName = valueBoxName ;
+
wxStaticText *text = new wxStaticText(scrollWin, -1, wxT("Input Ports"));
wxFont font(11, wxDEFAULT, wxNORMAL, wxBOLD);
text->SetFont(font);
-
+ textBoxName->SetFont(font);
std::vector<GPortModel*> lstInputs = _model->getInputPorts();
buts->Add(closeButton,0,wxCENTRE|wxEXPAND,5);
sizerDialog->AddSpacer(10);
+ sizerDialog->Add(textBoxName,0,wxALIGN_TOP|wxALIGN_CENTER);
+ sizerDialog->AddSpacer(10);
+ sizerDialog->Add(valueBoxName, wxSizerFlags(0).Align(0).Border(wxLEFT, 100));
+ sizerDialog->AddSpacer(10);
sizerDialog->Add(text,0,wxALIGN_TOP|wxALIGN_CENTER);
sizerDialog->AddSpacer(15);
sizerDialog->Add(sizer,0,wxALIGN_CENTER| wxEXPAND);
void wxBlackBoxEditionDialog::onClickOk(wxCommandEvent& event)
{
+ int closeok = 1;
for(int i=0;i<(int)_lstValues.size();i++)
{
std::string text = wx2std(_lstValues[i]->GetValue());
_model->setValueToInputPort(i,text);
}
}
- _parent->SaveTempActualDiagram();
- Close(true);
+ //handle box name
+ std::string boxname = wx2std(_boxName->GetValue());
+ if( boxname.compare(_initBoxName) != 0 ){
+ if (isValidNameForABox(boxname) == true){
+ if( _parent->boxNameExists(boxname) == true ){
+ closeok=0;
+ wxMessageDialog *dial = new wxMessageDialog(NULL,
+ wxT("The name already exists. Please provide another name"),
+ wxT("Change name: name already exists"), wxOK | wxICON_EXCLAMATION | wxSTAY_ON_TOP);
+ dial->ShowModal();
+ }else{
+ _model->setBBTKName(boxname);
+ }
+ }else{
+ closeok=0;
+ wxMessageDialog *dial = new wxMessageDialog(NULL, wxT("Please provide a valide name for your box (no spaces and only leters, digits, \"_\" or \"-\" allowed)"), wxT("Change name: invalid name"), wxOK | wxICON_EXCLAMATION | wxSTAY_ON_TOP);
+ dial->ShowModal();
+ }
+ }
+
+ if( closeok==1 ){
+ _parent->SaveTempActualDiagram();
+ Close(true);
+ }
}
//=========================================================================
std::string name = _tabsMgr->GetNameTabPanel();
if(name[name.length() - 1] != '*')
name = name.substr(0, name.length()-2);
- _tabsMgr->SetNameTabPanel(name);*/
\ No newline at end of file
+ _tabsMgr->SetNameTabPanel(name);*/