mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-22 08:02:06 +02:00
added Resourcemanager
This commit is contained in:
@@ -43,6 +43,8 @@
|
||||
#include "Poco/WebWidgets/ExtJS/ExtJS.h"
|
||||
#include "Poco/WebWidgets/Form.h"
|
||||
#include "Poco/WebWidgets/LookAndFeel.h"
|
||||
#include "Poco/WebWidgets/ResourceManager.h"
|
||||
#include "Poco/Path.h"
|
||||
#include "Poco/WebWidgets/JavaScriptEvent.h"
|
||||
#include <ostream>
|
||||
#include <list>
|
||||
@@ -66,6 +68,9 @@ public:
|
||||
static void initialize(LookAndFeel::Ptr ptr);
|
||||
/// Initializes the LookAndFeel object to use ExtJS renderers
|
||||
|
||||
static void initialize(ResourceManager::Ptr ptr, const Poco::Path& extJSDir);
|
||||
/// Initializes the ResourceManager object to include ExtJS resources
|
||||
|
||||
static LookAndFeel& getDefaultRenderers();
|
||||
/// Returns the defaultrenderers;
|
||||
|
||||
|
@@ -92,7 +92,7 @@ void FrameRenderer::renderBody(const Renderable* pRenderable, const RenderContex
|
||||
void FrameRenderer::writeProperties(const Frame* pFrame, std::ostream& ostr)
|
||||
{
|
||||
Utility::writeRenderableProperties(pFrame, ostr);
|
||||
ostr << ",frame:true";
|
||||
ostr << ",frame:true,header:true";
|
||||
if (pFrame->getWidth() > 0)
|
||||
ostr << ",width:" << pFrame->getWidth();
|
||||
if (pFrame->getHeight() > 0)
|
||||
|
@@ -73,18 +73,41 @@ void PageRenderer::renderHead(const Renderable* pRenderable, const RenderContext
|
||||
const Page* pPage = static_cast<const Poco::WebWidgets::Page*>(pRenderable);
|
||||
poco_assert_dbg (WebApplication::instance().getCurrentPage().get() == pPage);
|
||||
const LookAndFeel& laf = context.lookAndFeel();
|
||||
ResourceManager::Ptr pRM = context.application().getResourceManager();
|
||||
|
||||
ostr << STRO_HTML << STRO_HEAD << STRO_TITLE;
|
||||
ostr << pPage->getName();
|
||||
ostr << STRC_TITLE;
|
||||
//include javascript files: TODO: use ResourceManager
|
||||
ostr << "<script type=\"text/javascript\" src=\"ext-base.js\"></script>";
|
||||
ostr << "<script type=\"text/javascript\" src=\"ext-all.js\"></script>";
|
||||
ostr << "<script type=\"text/javascript\" src=\"DDView.js\"></script>";
|
||||
ostr << "<script type=\"text/javascript\" src=\"MultiSelect.js\"></script>";
|
||||
ostr << "<link rel=\"stylesheet\" type=\"text/css\" href=\"resources/css/ext-all.css\">";
|
||||
ostr << "<link rel=\"stylesheet\" type=\"text/css\" href=\"MultiSelect.css\">";
|
||||
//include javascript files:
|
||||
const ResourceManager::Includes& jsIncl = pRM->jsIncludes();
|
||||
ResourceManager::Includes::const_iterator itJS = jsIncl.begin();
|
||||
for (; itJS != jsIncl.end(); ++itJS)
|
||||
{
|
||||
ostr << "<script type=\"text/javascript\" src=\"" << (*itJS) << "\"></script>";
|
||||
}
|
||||
const ResourceManager::Includes& myJSIncl = pPage->resourceManager().jsIncludes();
|
||||
ResourceManager::Includes::const_iterator itMyJS = myJSIncl.begin();
|
||||
for (; itMyJS != myJSIncl.end(); ++itMyJS)
|
||||
{
|
||||
ostr << "<script type=\"text/javascript\" src=\"" << (*itMyJS) << "\"></script>";
|
||||
}
|
||||
|
||||
// write css includes
|
||||
const ResourceManager::Includes& cssIncl = pRM->cssIncludes();
|
||||
ResourceManager::Includes::const_iterator itCSS = cssIncl.begin();
|
||||
for (; itCSS != cssIncl.end(); ++itCSS)
|
||||
{
|
||||
ostr << "<link rel=\"stylesheet\" type=\"text/css\" href=\"" << (*itCSS) << "\">";
|
||||
}
|
||||
const ResourceManager::Includes& myCSSIncl = pPage->resourceManager().cssIncludes();
|
||||
ResourceManager::Includes::const_iterator itMyCSS = myCSSIncl.begin();
|
||||
for (; itMyCSS != myCSSIncl.end(); ++itMyCSS)
|
||||
{
|
||||
ostr << "<link rel=\"stylesheet\" type=\"text/css\" href=\"" << (*itMyCSS) << "\">";
|
||||
}
|
||||
// extra css for label
|
||||
ostr << "<style type=\"text/css\">.lbl {font:normal 12px tahoma, verdana, helvetica}</style>";
|
||||
|
||||
if (!pPage->empty())
|
||||
{
|
||||
//start inline javascript block
|
||||
@@ -97,14 +120,10 @@ void PageRenderer::renderHead(const Renderable* pRenderable, const RenderContext
|
||||
{
|
||||
ostr << ",listeners:{";
|
||||
bool written = Utility::writeJSEvent(ostr, EV_BEFORERENDER, pPage->beforeRender.jsDelegates());
|
||||
//auto-show all windows
|
||||
JavaScriptEvent<Page*>::JSDelegates js = pPage->afterRender.jsDelegates();
|
||||
js.push_front(jsDelegate("function(){Ext.WindowMgr.each( function(w) {w.show(this);});}"));
|
||||
if (written && !js.empty())
|
||||
{
|
||||
if (written)
|
||||
ostr << ",";
|
||||
}
|
||||
Utility::writeJSEvent(ostr, EV_AFTERRENDER, js);
|
||||
|
||||
Utility::writeJSEvent(ostr, EV_AFTERRENDER, pPage->afterRender.jsDelegates());
|
||||
ostr << "}";
|
||||
}
|
||||
if (pPage->getHeight() > 0)
|
||||
|
@@ -79,6 +79,7 @@ void TableRenderer::renderHead(const Renderable* pRenderable, const RenderContex
|
||||
bool editable = false;
|
||||
for (Table::TableColumns::const_iterator it = cols.begin(); it != cols.end() && !editable; ++it)
|
||||
{
|
||||
if ((*it) && (*it)->getCell())
|
||||
editable |= (*it)->isEditable();
|
||||
}
|
||||
if (editable)
|
||||
@@ -156,6 +157,7 @@ void TableRenderer::renderProperties(const Table* pTable, const RenderContext& c
|
||||
bool editable = false;
|
||||
for (Table::TableColumns::const_iterator it = cols.begin(); it != cols.end() && !editable; ++it)
|
||||
{
|
||||
if ((*it) && (*it)->getCell())
|
||||
editable |= (*it)->isEditable();
|
||||
}
|
||||
ostr << ",listeners:{";
|
||||
@@ -279,7 +281,7 @@ void TableRenderer::renderStore(const Table* pTable, std::ostream& ostr)
|
||||
{
|
||||
if (i != 0)
|
||||
ostr << ",";
|
||||
if ((*it)->getCell()->type() == typeid(Poco::WebWidgets::DateFieldCell))
|
||||
if ((*it)->getCell() && (*it)->getCell()->type() == typeid(Poco::WebWidgets::DateFieldCell))
|
||||
{
|
||||
Poco::WebWidgets::DateFieldCell::Ptr pDf = (*it)->getCell().cast<Poco::WebWidgets::DateFieldCell>();
|
||||
|
||||
|
@@ -134,6 +134,27 @@ void Utility::initialize(LookAndFeel::Ptr ptr)
|
||||
}
|
||||
|
||||
|
||||
void Utility::initialize(ResourceManager::Ptr ptr, const Poco::Path& extJSDir)
|
||||
{
|
||||
Poco::Path aDir(extJSDir);
|
||||
aDir.makeDirectory();
|
||||
aDir.setFileName("ext-base.js");
|
||||
ptr->appendJSInclude(aDir);
|
||||
aDir.setFileName("ext-all.js");
|
||||
ptr->appendJSInclude(aDir);
|
||||
aDir.setFileName("DDView.js");
|
||||
ptr->appendJSInclude(aDir);
|
||||
aDir.setFileName("MultiSelect.js");
|
||||
ptr->appendJSInclude(aDir);
|
||||
|
||||
Poco::Path cssAll("resources/css/ext-all.css");
|
||||
cssAll.makeFile();
|
||||
|
||||
ptr->appendCSSInclude(Poco::Path(extJSDir, cssAll));
|
||||
ptr->appendCSSInclude(Poco::Path(extJSDir, "MultiSelect.css"));
|
||||
}
|
||||
|
||||
|
||||
const std::string& Utility::getTmpID()
|
||||
{
|
||||
static const std::string tmp("tmp");
|
||||
|
@@ -68,6 +68,7 @@
|
||||
#include "Poco/WebWidgets/TextEditCell.h"
|
||||
#include "Poco/WebWidgets/SimpleTableModel.h"
|
||||
#include "Poco/WebWidgets/JSDelegate.h"
|
||||
#include "Poco/WebWidgets/ResourceManager.h"
|
||||
#include "Poco/TeeStream.h"
|
||||
#include "Poco/DateTimeFormat.h"
|
||||
#include "Poco/DateTime.h"
|
||||
@@ -92,7 +93,9 @@ ExtJSTest::~ExtJSTest()
|
||||
|
||||
void ExtJSTest::testPage()
|
||||
{
|
||||
WebApplication webApp(Poco::URI("/"));
|
||||
ResourceManager::Ptr pRM(new ResourceManager());
|
||||
Utility::initialize(pRM, Poco::Path());
|
||||
WebApplication webApp(Poco::URI("/"), pRM);
|
||||
LookAndFeel::Ptr laf(new LookAndFeel());
|
||||
webApp.setLookAndFeel(laf);
|
||||
RenderContext context(*laf, webApp);
|
||||
@@ -119,7 +122,9 @@ void ExtJSTest::testPage()
|
||||
|
||||
void ExtJSTest::testPage2()
|
||||
{
|
||||
WebApplication webApp(Poco::URI("/"));
|
||||
ResourceManager::Ptr pRM(new ResourceManager());
|
||||
Utility::initialize(pRM, Poco::Path());
|
||||
WebApplication webApp(Poco::URI("/"), pRM);
|
||||
LookAndFeel::Ptr laf(new LookAndFeel());
|
||||
webApp.setLookAndFeel(laf);
|
||||
RenderContext context(*laf, webApp);
|
||||
@@ -152,7 +157,9 @@ void ExtJSTest::testPage2()
|
||||
|
||||
void ExtJSTest::testButton()
|
||||
{
|
||||
WebApplication webApp(Poco::URI("/"));
|
||||
ResourceManager::Ptr pRM(new ResourceManager());
|
||||
Utility::initialize(pRM, Poco::Path());
|
||||
WebApplication webApp(Poco::URI("/"), pRM);
|
||||
LookAndFeel::Ptr laf(new LookAndFeel());
|
||||
webApp.setLookAndFeel(laf);
|
||||
RenderContext context(*laf, webApp);
|
||||
@@ -194,7 +201,9 @@ void ExtJSTest::testButton()
|
||||
|
||||
void ExtJSTest::testFormTextField()
|
||||
{
|
||||
WebApplication webApp(Poco::URI("/"));
|
||||
ResourceManager::Ptr pRM(new ResourceManager());
|
||||
Utility::initialize(pRM, Poco::Path());
|
||||
WebApplication webApp(Poco::URI("/"), pRM);
|
||||
LookAndFeel::Ptr laf(new LookAndFeel());
|
||||
webApp.setLookAndFeel(laf);
|
||||
RenderContext context(*laf, webApp);
|
||||
@@ -241,7 +250,7 @@ void ExtJSTest::testFormTextField()
|
||||
|
||||
void ExtJSTest::testFormTimeField()
|
||||
{
|
||||
WebApplication webApp(Poco::URI("/"));
|
||||
ResourceManager::Ptr pRM(new ResourceManager());Utility::initialize(pRM, Poco::Path());WebApplication webApp(Poco::URI("/"), pRM);
|
||||
LookAndFeel::Ptr laf(new LookAndFeel());
|
||||
webApp.setLookAndFeel(laf);
|
||||
RenderContext context(*laf, webApp);
|
||||
@@ -276,7 +285,7 @@ void ExtJSTest::testFormTimeField()
|
||||
|
||||
void ExtJSTest::testFormDateField()
|
||||
{
|
||||
WebApplication webApp(Poco::URI("/"));
|
||||
ResourceManager::Ptr pRM(new ResourceManager());Utility::initialize(pRM, Poco::Path());WebApplication webApp(Poco::URI("/"), pRM);
|
||||
LookAndFeel::Ptr laf(new LookAndFeel());
|
||||
webApp.setLookAndFeel(laf);
|
||||
RenderContext context(*laf, webApp);
|
||||
@@ -314,7 +323,7 @@ void ExtJSTest::testFormDateField()
|
||||
|
||||
void ExtJSTest::testFormPassword()
|
||||
{
|
||||
WebApplication webApp(Poco::URI("/"));
|
||||
ResourceManager::Ptr pRM(new ResourceManager());Utility::initialize(pRM, Poco::Path());WebApplication webApp(Poco::URI("/"), pRM);
|
||||
LookAndFeel::Ptr laf(new LookAndFeel());
|
||||
webApp.setLookAndFeel(laf);
|
||||
RenderContext context(*laf, webApp);
|
||||
@@ -348,7 +357,7 @@ void ExtJSTest::testFormPassword()
|
||||
|
||||
void ExtJSTest::testFormNumberField()
|
||||
{
|
||||
WebApplication webApp(Poco::URI("/"));
|
||||
ResourceManager::Ptr pRM(new ResourceManager());Utility::initialize(pRM, Poco::Path());WebApplication webApp(Poco::URI("/"), pRM);
|
||||
LookAndFeel::Ptr laf(new LookAndFeel());
|
||||
webApp.setLookAndFeel(laf);
|
||||
RenderContext context(*laf, webApp);
|
||||
@@ -383,7 +392,7 @@ void ExtJSTest::testFormNumberField()
|
||||
|
||||
void ExtJSTest::testFormComboBox()
|
||||
{
|
||||
WebApplication webApp(Poco::URI("/"));
|
||||
ResourceManager::Ptr pRM(new ResourceManager());Utility::initialize(pRM, Poco::Path());WebApplication webApp(Poco::URI("/"), pRM);
|
||||
LookAndFeel::Ptr laf(new LookAndFeel());
|
||||
webApp.setLookAndFeel(laf);
|
||||
RenderContext context(*laf, webApp);
|
||||
@@ -426,7 +435,7 @@ void ExtJSTest::testFormComboBox()
|
||||
|
||||
void ExtJSTest::testFormImageButton()
|
||||
{
|
||||
WebApplication webApp(Poco::URI("/"));
|
||||
ResourceManager::Ptr pRM(new ResourceManager());Utility::initialize(pRM, Poco::Path());WebApplication webApp(Poco::URI("/"), pRM);
|
||||
LookAndFeel::Ptr laf(new LookAndFeel());
|
||||
webApp.setLookAndFeel(laf);
|
||||
RenderContext context(*laf, webApp);
|
||||
@@ -475,7 +484,7 @@ void ExtJSTest::testFormImageButton()
|
||||
|
||||
void ExtJSTest::testFormTextEdit()
|
||||
{
|
||||
WebApplication webApp(Poco::URI("/"));
|
||||
ResourceManager::Ptr pRM(new ResourceManager());Utility::initialize(pRM, Poco::Path());WebApplication webApp(Poco::URI("/"), pRM);
|
||||
LookAndFeel::Ptr laf(new LookAndFeel());
|
||||
webApp.setLookAndFeel(laf);
|
||||
RenderContext context(*laf, webApp);
|
||||
@@ -522,7 +531,7 @@ void ExtJSTest::testFormTextEdit()
|
||||
|
||||
void ExtJSTest::testFormCheckButton()
|
||||
{
|
||||
WebApplication webApp(Poco::URI("/"));
|
||||
ResourceManager::Ptr pRM(new ResourceManager());Utility::initialize(pRM, Poco::Path());WebApplication webApp(Poco::URI("/"), pRM);
|
||||
LookAndFeel::Ptr laf(new LookAndFeel());
|
||||
webApp.setLookAndFeel(laf);
|
||||
RenderContext context(*laf, webApp);
|
||||
@@ -554,7 +563,7 @@ void ExtJSTest::testFormCheckButton()
|
||||
|
||||
void ExtJSTest::testFormRadioButton()
|
||||
{
|
||||
WebApplication webApp(Poco::URI("/"));
|
||||
ResourceManager::Ptr pRM(new ResourceManager());Utility::initialize(pRM, Poco::Path());WebApplication webApp(Poco::URI("/"), pRM);
|
||||
LookAndFeel::Ptr laf(new LookAndFeel());
|
||||
webApp.setLookAndFeel(laf);
|
||||
RenderContext context(*laf, webApp);
|
||||
@@ -586,7 +595,7 @@ void ExtJSTest::testFormRadioButton()
|
||||
|
||||
void ExtJSTest::testFormGridLayout()
|
||||
{
|
||||
WebApplication webApp(Poco::URI("/"));
|
||||
ResourceManager::Ptr pRM(new ResourceManager());Utility::initialize(pRM, Poco::Path());WebApplication webApp(Poco::URI("/"), pRM);
|
||||
LookAndFeel::Ptr laf(new LookAndFeel());
|
||||
webApp.setLookAndFeel(laf);
|
||||
RenderContext context(*laf, webApp);
|
||||
@@ -619,7 +628,7 @@ void ExtJSTest::testFormGridLayout()
|
||||
|
||||
void ExtJSTest::testFormHorizontalLayout()
|
||||
{
|
||||
WebApplication webApp(Poco::URI("/"));
|
||||
ResourceManager::Ptr pRM(new ResourceManager());Utility::initialize(pRM, Poco::Path());WebApplication webApp(Poco::URI("/"), pRM);
|
||||
LookAndFeel::Ptr laf(new LookAndFeel());
|
||||
webApp.setLookAndFeel(laf);
|
||||
RenderContext context(*laf, webApp);
|
||||
@@ -652,7 +661,7 @@ void ExtJSTest::testFormHorizontalLayout()
|
||||
|
||||
void ExtJSTest::testFormVerticalLayout()
|
||||
{
|
||||
WebApplication webApp(Poco::URI("/"));
|
||||
ResourceManager::Ptr pRM(new ResourceManager());Utility::initialize(pRM, Poco::Path());WebApplication webApp(Poco::URI("/"), pRM);
|
||||
LookAndFeel::Ptr laf(new LookAndFeel());
|
||||
webApp.setLookAndFeel(laf);
|
||||
RenderContext context(*laf, webApp);
|
||||
@@ -685,7 +694,7 @@ void ExtJSTest::testFormVerticalLayout()
|
||||
|
||||
void ExtJSTest::testFormFrameGridLayout()
|
||||
{
|
||||
WebApplication webApp(Poco::URI("/"));
|
||||
ResourceManager::Ptr pRM(new ResourceManager());Utility::initialize(pRM, Poco::Path());WebApplication webApp(Poco::URI("/"), pRM);
|
||||
LookAndFeel::Ptr laf(new LookAndFeel());
|
||||
webApp.setLookAndFeel(laf);
|
||||
RenderContext context(*laf, webApp);
|
||||
@@ -720,7 +729,7 @@ void ExtJSTest::testFormFrameGridLayout()
|
||||
|
||||
void ExtJSTest::testFormFrameHorizontalLayout()
|
||||
{
|
||||
WebApplication webApp(Poco::URI("/"));
|
||||
ResourceManager::Ptr pRM(new ResourceManager());Utility::initialize(pRM, Poco::Path());WebApplication webApp(Poco::URI("/"), pRM);
|
||||
LookAndFeel::Ptr laf(new LookAndFeel());
|
||||
webApp.setLookAndFeel(laf);
|
||||
RenderContext context(*laf, webApp);
|
||||
@@ -755,7 +764,7 @@ void ExtJSTest::testFormFrameHorizontalLayout()
|
||||
|
||||
void ExtJSTest::testFormFrameVerticalLayout()
|
||||
{
|
||||
WebApplication webApp(Poco::URI("/"));
|
||||
ResourceManager::Ptr pRM(new ResourceManager());Utility::initialize(pRM, Poco::Path());WebApplication webApp(Poco::URI("/"), pRM);
|
||||
LookAndFeel::Ptr laf(new LookAndFeel());
|
||||
webApp.setLookAndFeel(laf);
|
||||
RenderContext context(*laf, webApp);
|
||||
@@ -790,7 +799,7 @@ void ExtJSTest::testFormFrameVerticalLayout()
|
||||
|
||||
void ExtJSTest::testFormGridLayoutNullElements()
|
||||
{
|
||||
WebApplication webApp(Poco::URI("/"));
|
||||
ResourceManager::Ptr pRM(new ResourceManager());Utility::initialize(pRM, Poco::Path());WebApplication webApp(Poco::URI("/"), pRM);
|
||||
LookAndFeel::Ptr laf(new LookAndFeel());
|
||||
webApp.setLookAndFeel(laf);
|
||||
RenderContext context(*laf, webApp);
|
||||
@@ -823,7 +832,7 @@ void ExtJSTest::testFormGridLayoutNullElements()
|
||||
|
||||
void ExtJSTest::testFormImage()
|
||||
{
|
||||
WebApplication webApp(Poco::URI("/"));
|
||||
ResourceManager::Ptr pRM(new ResourceManager());Utility::initialize(pRM, Poco::Path());WebApplication webApp(Poco::URI("/"), pRM);
|
||||
LookAndFeel::Ptr laf(new LookAndFeel());
|
||||
webApp.setLookAndFeel(laf);
|
||||
RenderContext context(*laf, webApp);
|
||||
@@ -859,7 +868,7 @@ void ExtJSTest::testFormImage()
|
||||
|
||||
void ExtJSTest::testTabView()
|
||||
{
|
||||
WebApplication webApp(Poco::URI("/"));
|
||||
ResourceManager::Ptr pRM(new ResourceManager());Utility::initialize(pRM, Poco::Path());WebApplication webApp(Poco::URI("/"), pRM);
|
||||
LookAndFeel::Ptr laf(new LookAndFeel());
|
||||
webApp.setLookAndFeel(laf);
|
||||
RenderContext context(*laf, webApp);
|
||||
@@ -903,7 +912,7 @@ void ExtJSTest::testTabView()
|
||||
|
||||
void ExtJSTest::testCollapsible()
|
||||
{
|
||||
WebApplication webApp(Poco::URI("/"));
|
||||
ResourceManager::Ptr pRM(new ResourceManager());Utility::initialize(pRM, Poco::Path());WebApplication webApp(Poco::URI("/"), pRM);
|
||||
LookAndFeel::Ptr laf(new LookAndFeel());
|
||||
webApp.setLookAndFeel(laf);
|
||||
RenderContext context(*laf, webApp);
|
||||
@@ -937,7 +946,7 @@ void ExtJSTest::testCollapsible()
|
||||
|
||||
void ExtJSTest::testCollapsible2()
|
||||
{
|
||||
WebApplication webApp(Poco::URI("/"));
|
||||
ResourceManager::Ptr pRM(new ResourceManager());Utility::initialize(pRM, Poco::Path());WebApplication webApp(Poco::URI("/"), pRM);
|
||||
LookAndFeel::Ptr laf(new LookAndFeel());
|
||||
webApp.setLookAndFeel(laf);
|
||||
RenderContext context(*laf, webApp);
|
||||
@@ -972,7 +981,7 @@ void ExtJSTest::testCollapsible2()
|
||||
|
||||
void ExtJSTest::testPanel()
|
||||
{
|
||||
WebApplication webApp(Poco::URI("/"));
|
||||
ResourceManager::Ptr pRM(new ResourceManager());Utility::initialize(pRM, Poco::Path());WebApplication webApp(Poco::URI("/"), pRM);
|
||||
LookAndFeel::Ptr laf(new LookAndFeel());
|
||||
webApp.setLookAndFeel(laf);
|
||||
RenderContext context(*laf, webApp);
|
||||
@@ -1011,7 +1020,7 @@ void ExtJSTest::testPanel()
|
||||
|
||||
void ExtJSTest::testRootPanel()
|
||||
{
|
||||
WebApplication webApp(Poco::URI("/"));
|
||||
ResourceManager::Ptr pRM(new ResourceManager());Utility::initialize(pRM, Poco::Path());WebApplication webApp(Poco::URI("/"), pRM);
|
||||
LookAndFeel::Ptr laf(new LookAndFeel());
|
||||
webApp.setLookAndFeel(laf);
|
||||
RenderContext context(*laf, webApp);
|
||||
@@ -1047,7 +1056,7 @@ void ExtJSTest::testRootPanel()
|
||||
|
||||
void ExtJSTest::testNestedPanels()
|
||||
{
|
||||
WebApplication webApp(Poco::URI("/"));
|
||||
ResourceManager::Ptr pRM(new ResourceManager());Utility::initialize(pRM, Poco::Path());WebApplication webApp(Poco::URI("/"), pRM);
|
||||
LookAndFeel::Ptr laf(new LookAndFeel());
|
||||
webApp.setLookAndFeel(laf);
|
||||
RenderContext context(*laf, webApp);
|
||||
@@ -1087,7 +1096,7 @@ void ExtJSTest::testNestedPanels()
|
||||
|
||||
void ExtJSTest::testListBox()
|
||||
{
|
||||
WebApplication webApp(Poco::URI("/"));
|
||||
ResourceManager::Ptr pRM(new ResourceManager());Utility::initialize(pRM, Poco::Path());WebApplication webApp(Poco::URI("/"), pRM);
|
||||
LookAndFeel::Ptr laf(new LookAndFeel());
|
||||
webApp.setLookAndFeel(laf);
|
||||
RenderContext context(*laf, webApp);
|
||||
@@ -1159,7 +1168,7 @@ void ExtJSTest::testFunction()
|
||||
|
||||
void ExtJSTest::testTable()
|
||||
{
|
||||
WebApplication webApp(Poco::URI("/"));
|
||||
ResourceManager::Ptr pRM(new ResourceManager());Utility::initialize(pRM, Poco::Path());WebApplication webApp(Poco::URI("/"), pRM);
|
||||
LookAndFeel::Ptr laf(new LookAndFeel());
|
||||
webApp.setLookAndFeel(laf);
|
||||
RenderContext context(*laf, webApp);
|
||||
@@ -1190,7 +1199,7 @@ void ExtJSTest::testTable()
|
||||
|
||||
void ExtJSTest::testTableEdit()
|
||||
{
|
||||
WebApplication webApp(Poco::URI("/"));
|
||||
ResourceManager::Ptr pRM(new ResourceManager());Utility::initialize(pRM, Poco::Path());WebApplication webApp(Poco::URI("/"), pRM);
|
||||
LookAndFeel::Ptr laf(new LookAndFeel());
|
||||
webApp.setLookAndFeel(laf);
|
||||
RenderContext context(*laf, webApp);
|
||||
@@ -1221,7 +1230,7 @@ void ExtJSTest::testTableEdit()
|
||||
|
||||
void ExtJSTest::testTableComboBox()
|
||||
{
|
||||
WebApplication webApp(Poco::URI("/"));
|
||||
ResourceManager::Ptr pRM(new ResourceManager());Utility::initialize(pRM, Poco::Path());WebApplication webApp(Poco::URI("/"), pRM);
|
||||
LookAndFeel::Ptr laf(new LookAndFeel());
|
||||
webApp.setLookAndFeel(laf);
|
||||
RenderContext context(*laf, webApp);
|
||||
@@ -1256,7 +1265,7 @@ void ExtJSTest::testTableComboBox()
|
||||
|
||||
void ExtJSTest::testTableButton()
|
||||
{
|
||||
WebApplication webApp(Poco::URI("/"));
|
||||
ResourceManager::Ptr pRM(new ResourceManager());Utility::initialize(pRM, Poco::Path());WebApplication webApp(Poco::URI("/"), pRM);
|
||||
LookAndFeel::Ptr laf(new LookAndFeel());
|
||||
webApp.setLookAndFeel(laf);
|
||||
RenderContext context(*laf, webApp);
|
||||
@@ -1287,7 +1296,7 @@ void ExtJSTest::testTableButton()
|
||||
|
||||
void ExtJSTest::testTableImageButton()
|
||||
{
|
||||
WebApplication webApp(Poco::URI("/"));
|
||||
ResourceManager::Ptr pRM(new ResourceManager());Utility::initialize(pRM, Poco::Path());WebApplication webApp(Poco::URI("/"), pRM);
|
||||
LookAndFeel::Ptr laf(new LookAndFeel());
|
||||
webApp.setLookAndFeel(laf);
|
||||
RenderContext context(*laf, webApp);
|
||||
|
@@ -22,7 +22,7 @@ objects = Renderable Renderer RenderContext LookAndFeel Type Event Delegate \
|
||||
TableModel TableColumn SimpleTableModel \
|
||||
PasswordField PasswordFieldCell TimeField TimeFieldCell \
|
||||
WebApplication RequestProcessor RequestHandler \
|
||||
SubmitButton SubmitButtonCell
|
||||
SubmitButton SubmitButtonCell ResourceManager
|
||||
|
||||
target = PocoWebWidgets
|
||||
target_version = $(LIBVERSION)
|
||||
|
@@ -265,6 +265,10 @@
|
||||
RelativePath=".\include\Poco\WebWidgets\RequestProcessor.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\Poco\WebWidgets\ResourceManager.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\Poco\WebWidgets\Type.h"
|
||||
>
|
||||
@@ -329,6 +333,10 @@
|
||||
RelativePath=".\src\RequestProcessor.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\ResourceManager.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\Type.cpp"
|
||||
>
|
||||
|
@@ -264,6 +264,10 @@
|
||||
RelativePath=".\include\Poco\WebWidgets\RequestProcessor.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\Poco\WebWidgets\ResourceManager.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\Poco\WebWidgets\Type.h"
|
||||
>
|
||||
@@ -328,6 +332,10 @@
|
||||
RelativePath=".\src\RequestProcessor.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\ResourceManager.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\Type.cpp"
|
||||
>
|
||||
|
@@ -42,6 +42,7 @@
|
||||
|
||||
#include "Poco/WebWidgets/ContainerView.h"
|
||||
#include "Poco/WebWidgets/JavaScriptEvent.h"
|
||||
#include "Poco/WebWidgets/ResourceManager.h"
|
||||
|
||||
|
||||
namespace Poco {
|
||||
@@ -71,6 +72,12 @@ public:
|
||||
|
||||
std::string getText() const;
|
||||
|
||||
ResourceManager& resourceManager();
|
||||
/// Returns the ResourceManager
|
||||
|
||||
const ResourceManager& resourceManager() const;
|
||||
/// Returns the ResourceManager
|
||||
|
||||
protected:
|
||||
Page(const std::string& name, const std::type_info& type);
|
||||
/// Creates a Page and assigns it the given name.
|
||||
@@ -83,9 +90,26 @@ protected:
|
||||
|
||||
private:
|
||||
std::string _text;
|
||||
ResourceManager _rm;
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// Inlines
|
||||
//
|
||||
|
||||
inline ResourceManager& Page::resourceManager()
|
||||
{
|
||||
return _rm;
|
||||
}
|
||||
|
||||
|
||||
inline const ResourceManager& Page::resourceManager() const
|
||||
{
|
||||
return _rm;
|
||||
}
|
||||
|
||||
|
||||
} } // namespace Poco::WebWidgets
|
||||
|
||||
|
||||
|
124
WebWidgets/include/Poco/WebWidgets/ResourceManager.h
Normal file
124
WebWidgets/include/Poco/WebWidgets/ResourceManager.h
Normal file
@@ -0,0 +1,124 @@
|
||||
//
|
||||
// ResourceManager.h
|
||||
//
|
||||
// $Id: //poco/Main/WebWidgets/include/Poco/WebWidgets/ResourceManager.h#2 $
|
||||
//
|
||||
// Library: WebWidgets
|
||||
// Package: Core
|
||||
// Module: ResourceManager
|
||||
//
|
||||
// Definition of the ResourceManager class.
|
||||
//
|
||||
// Copyright (c) 2008, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#ifndef WebWidgets_ResourceManager_INCLUDED
|
||||
#define WebWidgets_ResourceManager_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/WebWidgets/WebWidgets.h"
|
||||
#include "Poco/RefCountedObject.h"
|
||||
#include "Poco/AutoPtr.h"
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
|
||||
namespace Poco {
|
||||
|
||||
class Path;
|
||||
|
||||
namespace WebWidgets {
|
||||
|
||||
|
||||
class WebApplication;
|
||||
|
||||
|
||||
class WebWidgets_API ResourceManager: public Poco::RefCountedObject
|
||||
/// The ResourceManager manages JS and CSS includes. Please note that there are two ResourceManagers:
|
||||
/// There is a global ResourceManager that provides common includes for all WebPages (like the rendering JS library),
|
||||
/// and there is a local ResourceManager on a per WebPage that allows to define additional includes.
|
||||
///
|
||||
/// TODO: It would be nice if it also provides some sort of automatic
|
||||
/// mapping from local files to web uris, i.e you provide the server root dir
|
||||
/// and it converts local files automatically to a relative web server path.
|
||||
///
|
||||
/// - how to handle requests to files inside Zips?
|
||||
///
|
||||
/// - how to handle requests to files outside the root dir?
|
||||
/// (would be nice to have a tool that collects all the referenced files into one bundle and have requests
|
||||
/// only into zip, or alternatively: simply copy all the files into one directory, decompress ZIP files
|
||||
/// where requested)
|
||||
{
|
||||
public:
|
||||
typedef std::vector<std::string> Includes;
|
||||
typedef Poco::AutoPtr<ResourceManager> Ptr;
|
||||
|
||||
ResourceManager();
|
||||
/// Creates the ResourceManager,
|
||||
|
||||
~ResourceManager();
|
||||
/// Destroys the ResourceManager.
|
||||
|
||||
void appendJSInclude(const Poco::Path& aPath);
|
||||
/// Adds a JS include, no check for duplicates
|
||||
|
||||
void appendCSSInclude(const Poco::Path& aPath);
|
||||
/// Adds a CSS include, no check for duplicates
|
||||
|
||||
const Includes& jsIncludes() const;
|
||||
/// Returns all JS includes
|
||||
|
||||
const Includes& cssIncludes() const;
|
||||
/// Returns all CSS includes
|
||||
|
||||
private:
|
||||
|
||||
Includes _js;
|
||||
Includes _css;
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// Inlines
|
||||
//
|
||||
|
||||
inline const ResourceManager::Includes& ResourceManager::jsIncludes() const
|
||||
{
|
||||
return _js;
|
||||
}
|
||||
|
||||
|
||||
inline const ResourceManager::Includes& ResourceManager::cssIncludes() const
|
||||
{
|
||||
return _css;
|
||||
}
|
||||
|
||||
|
||||
} } // namespace Poco::WebWidgets
|
||||
|
||||
|
||||
#endif // WebWidgets_ResourceManager_INCLUDED
|
@@ -43,6 +43,7 @@
|
||||
#include "Poco/WebWidgets/WebWidgets.h"
|
||||
#include "Poco/WebWidgets/Page.h"
|
||||
#include "Poco/WebWidgets/LookAndFeel.h"
|
||||
#include "Poco/WebWidgets/ResourceManager.h"
|
||||
#include "Poco/ThreadLocal.h"
|
||||
#include "Poco/URI.h"
|
||||
#include <map>
|
||||
@@ -62,7 +63,7 @@ class WebWidgets_API WebApplication
|
||||
/// WebApplication class
|
||||
{
|
||||
public:
|
||||
WebApplication(const Poco::URI& uri);
|
||||
WebApplication(const Poco::URI& uri, ResourceManager::Ptr pRM);
|
||||
/// Creates the WebApplication.
|
||||
|
||||
virtual ~WebApplication();
|
||||
@@ -80,6 +81,12 @@ public:
|
||||
Page::Ptr getCurrentPage() const;
|
||||
/// Returns the currently active page.
|
||||
|
||||
void setResourceManager(ResourceManager::Ptr pRM);
|
||||
/// Sets the ResourceManager
|
||||
|
||||
ResourceManager::Ptr getResourceManager() const;
|
||||
/// Gets the ResourceManager
|
||||
|
||||
void registerFormProcessor(const std::string& fieldName, RequestProcessor* pProc);
|
||||
/// Registers a RequestProcessor for a given form field.
|
||||
|
||||
@@ -111,6 +118,7 @@ private:
|
||||
|
||||
typedef std::map<std::string, RequestProcessor* > RequestProcessorMap;
|
||||
|
||||
ResourceManager::Ptr _pResource;
|
||||
LookAndFeel::Ptr _pLookAndFeel;
|
||||
Page::Ptr _pCurrentPage;
|
||||
Poco::URI _uri;
|
||||
@@ -141,6 +149,19 @@ inline const Poco::URI& WebApplication::getURI() const
|
||||
}
|
||||
|
||||
|
||||
inline void WebApplication::setResourceManager(ResourceManager::Ptr pRM)
|
||||
{
|
||||
poco_check_ptr (pRM);
|
||||
_pResource = pRM;
|
||||
}
|
||||
|
||||
|
||||
inline ResourceManager::Ptr WebApplication::getResourceManager() const
|
||||
{
|
||||
return _pResource;
|
||||
}
|
||||
|
||||
|
||||
} } // namespace Poco::WebWidgets
|
||||
|
||||
|
||||
|
@@ -42,25 +42,33 @@ namespace WebWidgets {
|
||||
|
||||
|
||||
Page::Page():
|
||||
ContainerView(typeid(Page))
|
||||
ContainerView(typeid(Page)),
|
||||
_text(),
|
||||
_rm()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
Page::Page(const std::string& name):
|
||||
ContainerView(name, typeid(Page))
|
||||
ContainerView(name, typeid(Page)),
|
||||
_text(),
|
||||
_rm()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
Page::Page(const std::string& name, const std::type_info& type):
|
||||
ContainerView(name, type)
|
||||
ContainerView(name, type),
|
||||
_text(),
|
||||
_rm()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
Page::Page(const std::type_info& type):
|
||||
ContainerView(type)
|
||||
ContainerView(type),
|
||||
_text(),
|
||||
_rm()
|
||||
{
|
||||
}
|
||||
|
||||
|
69
WebWidgets/src/ResourceManager.cpp
Normal file
69
WebWidgets/src/ResourceManager.cpp
Normal file
@@ -0,0 +1,69 @@
|
||||
//
|
||||
// ResourceManager.cpp
|
||||
//
|
||||
// $Id: //poco/Main/WebWidgets/src/ResourceManager.cpp#4 $
|
||||
//
|
||||
// Library: WebWidgets
|
||||
// Package: Core
|
||||
// Module: ResourceManager
|
||||
//
|
||||
// Definition of the ResourceManager class.
|
||||
//
|
||||
// Copyright (c) 2008, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#include "Poco/WebWidgets/ResourceManager.h"
|
||||
#include "Poco/Path.h"
|
||||
|
||||
|
||||
namespace Poco {
|
||||
namespace WebWidgets {
|
||||
|
||||
|
||||
ResourceManager::ResourceManager()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
ResourceManager::~ResourceManager()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void ResourceManager::appendJSInclude(const Poco::Path& aPath)
|
||||
{
|
||||
_js.push_back(aPath.toString(Path::PATH_UNIX));
|
||||
}
|
||||
|
||||
|
||||
void ResourceManager::appendCSSInclude(const Poco::Path& aPath)
|
||||
{
|
||||
_css.push_back(aPath.toString(Path::PATH_UNIX));
|
||||
}
|
||||
|
||||
|
||||
} } // namespace Poco::WebWidgets
|
@@ -46,11 +46,13 @@ namespace WebWidgets {
|
||||
Poco::ThreadLocal<WebApplication*> WebApplication::_pInstance;
|
||||
|
||||
|
||||
WebApplication::WebApplication(const Poco::URI& uri):
|
||||
WebApplication::WebApplication(const Poco::URI& uri,ResourceManager::Ptr pRM):
|
||||
_pResource(pRM),
|
||||
_pLookAndFeel(),
|
||||
_pCurrentPage(),
|
||||
_uri(uri)
|
||||
{
|
||||
poco_check_ptr (pRM);
|
||||
attachToThread();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user