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);
25 Wt::WPushButton *mwtPushButton;
27 //--------------------------------------------------------------------------
28 //--------------------------------------------------------------------------
29 CommandButtonWidget::CommandButtonWidget(CommandButton* box,
30 Wt::WContainerWidget *parent,
33 Wt::WContainerWidget(parent),
36 Wt::WContainerWidget *container = this;
37 mwtPushButton = new Wt::WPushButton(label,parent);
38 mwtPushButton->setMinimumSize(170,30);
39 mwtPushButton->clicked().connect(this, &CommandButtonWidget::OnCommandButton);
40 container->addWidget(mwtPushButton);
42 //--------------------------------------------------------------------------
43 //--------------------------------------------------------------------------
44 CommandButtonWidget::~CommandButtonWidget()
47 //--------------------------------------------------------------------------
48 //--------------------------------------------------------------------------
49 void CommandButtonWidget::OnCommandButton()
51 bbtk::Interpreter::Pointer I;
52 bbtk::VirtualExec::Pointer E;
53 if (mBox->bbGetParent() != 0)
55 bbtk::Factory::Pointer f = boost::dynamic_pointer_cast<bbtk::ComplexBlackBoxDescriptor>(mBox->bbGetParent()->bbGetDescriptor())->GetFactory();
60 I = E->GetInterpreter();
65 // bbtkError("CommandButton::DoProcess() : could not find interpreter");
68 // If no executer : create a totally independant interpreter
69 I = bbtk::Interpreter::New();
73 // If executer : create an interpreter using E
74 I = bbtk::Interpreter::New(E);
78 std::string commandstr(mBox->bbGetInputIn());
80 // bbtk::Interpreter::mGlobalInterpreter->InterpretLine( commandstr );
84 pos2 = commandstr.find(";",pos1);
91 ccommand=commandstr.substr(pos1,commandstr.length()-pos1 );
95 ccommand=commandstr.substr(pos1,pos2-pos1);
97 for ( i=0 ; i < ccommand.length() ; i++)
99 if (ccommand[i]==39) // '
104 I->InterpretLine( ccommand );
106 pos2 = commandstr.find(";",pos2+1);
110 mBox->bbSignalOutputModification();
113 //--------------------------------------------------------------------------
114 //--------------------------------------------------------------------------
115 void CommandButtonWidget::SetLabel(Wt::WString nLabel)
117 mwtPushButton->setText(nLabel);
120 BBTK_ADD_BLACK_BOX_TO_PACKAGE(wt,CommandButton)
121 BBTK_BLACK_BOX_IMPLEMENTATION(CommandButton,bbtk::WtBlackBox);
123 // 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)
125 void CommandButton::Process()
128 CommandButtonWidget* w = (CommandButtonWidget*)bbGetOutputWidget();
136 // 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)
138 void CommandButton::CreateWidget(Wt::WContainerWidget* parent)
141 bbSetOutputWidget( new CommandButtonWidget(this,
143 bbtk::std2wt(bbGetInputLabel())
148 //--------------------------------------------------------------------------------------
149 void CommandButton::UpdateLabel()
151 CommandButtonWidget* wtWidget = (CommandButtonWidget*)bbGetOutputWidget();
152 wtWidget->SetLabel( bbtk::std2wt( bbGetInputLabel() ) );
156 // 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)
158 void CommandButton::bbUserSetDefaultValues()
162 bbSetOutputWidget(0);
166 // 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)
168 void CommandButton::bbUserInitializeProcessing()
173 // 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)
175 void CommandButton::bbUserFinalizeProcessing()