2 // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
4 #include "bbwtCommandButton.h"
5 #include "bbwtPackage.h"
6 #include "bbtkInterpreter.h"
7 #include "bbtkExecuter.h"
11 //---------------------------------------------------------------------------------
12 class CommandButtonWidget : public Wt::WContainerWidget
15 CommandButtonWidget(CommandButton* box,
16 Wt::WContainerWidget *parent,
18 ~CommandButtonWidget();
19 void OnCommandButton();
20 void SetLabel(Wt::WString nLabel);
26 Wt::WPushButton *mwtPushButton;
28 //--------------------------------------------------------------------------
29 //--------------------------------------------------------------------------
30 CommandButtonWidget::CommandButtonWidget(CommandButton* box,
31 Wt::WContainerWidget *parent,
34 Wt::WContainerWidget(parent),
37 Wt::WContainerWidget *container = this;
38 mwtPushButton = new Wt::WPushButton(label,parent);
39 mwtPushButton->setMinimumSize(170,30);
40 mwtPushButton->clicked().connect(this, &CommandButtonWidget::OnCommandButton);
41 container->addWidget(mwtPushButton);
43 //--------------------------------------------------------------------------
44 //--------------------------------------------------------------------------
45 CommandButtonWidget::~CommandButtonWidget()
48 //--------------------------------------------------------------------------
49 //--------------------------------------------------------------------------
50 void CommandButtonWidget::OnCommandButton()
52 bbtk::Interpreter::Pointer I;
53 bbtk::VirtualExec::Pointer E;
54 if (mBox->bbGetParent() != 0)
56 bbtk::Factory::Pointer f = boost::dynamic_pointer_cast<bbtk::ComplexBlackBoxDescriptor>(mBox->bbGetParent()->bbGetDescriptor())->GetFactory();
61 I = E->GetInterpreter();
66 // bbtkError("CommandButton::DoProcess() : could not find interpreter");
69 // If no executer : create a totally independant interpreter
70 I = bbtk::Interpreter::New();
74 // If executer : create an interpreter using E
75 I = bbtk::Interpreter::New(E);
79 std::string commandstr(mBox->bbGetInputIn());
81 // bbtk::Interpreter::mGlobalInterpreter->InterpretLine( commandstr );
85 pos2 = commandstr.find(";",pos1);
92 ccommand=commandstr.substr(pos1,commandstr.length()-pos1 );
96 ccommand=commandstr.substr(pos1,pos2-pos1);
98 for ( i=0 ; i < ccommand.length() ; i++)
100 if (ccommand[i]==39) // '
105 I->InterpretLine( ccommand );
107 pos2 = commandstr.find(";",pos2+1);
111 mBox->bbSignalOutputModification();
114 //--------------------------------------------------------------------------
115 //--------------------------------------------------------------------------
116 void CommandButtonWidget::SetLabel(Wt::WString nLabel)
118 mwtPushButton->setText(nLabel);
121 BBTK_ADD_BLACK_BOX_TO_PACKAGE(wt,CommandButton)
122 BBTK_BLACK_BOX_IMPLEMENTATION(CommandButton,bbtk::WtBlackBox);
124 // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
126 void CommandButton::Process()
129 CommandButtonWidget* w = (CommandButtonWidget*)bbGetOutputWidget();
137 // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
139 void CommandButton::CreateWidget(Wt::WContainerWidget* parent)
142 bbSetOutputWidget( new CommandButtonWidget(this,
144 bbtk::std2wt(bbGetInputLabel())
149 //--------------------------------------------------------------------------------------
150 void CommandButton::UpdateLabel()
152 CommandButtonWidget* wtWidget = (CommandButtonWidget*)bbGetOutputWidget();
153 wtWidget->SetLabel( bbtk::std2wt( bbGetInputLabel() ) );
157 // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
159 void CommandButton::bbUserSetDefaultValues()
163 bbSetOutputWidget(0);
167 // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
169 void CommandButton::bbUserInitializeProcessing()
174 // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
176 void CommandButton::bbUserFinalizeProcessing()