Wt examples  4.0.3
Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
JWtHome Class Reference

#include <JWtHome.h>

Inheritance diagram for JWtHome:
Inheritance graph
[legend]

Public Member Functions

 JWtHome (const WEnvironment &env, Dbo::SqlConnectionPool &blogDb)
 
- Public Member Functions inherited from Home
 Home (const WEnvironment &env, Dbo::SqlConnectionPool &blogDb, const std::string &title, const std::string &resourceBundle, const std::string &cssPath)
 
virtual ~Home ()
 
void googleAnalyticsLogger ()
 

Protected Member Functions

virtual std::unique_ptr< WWidget > examples ()
 
virtual std::unique_ptr< WWidget > createQuoteForm ()
 
virtual std::unique_ptr< WWidget > sourceViewer (const std::string &deployPath)
 
virtual std::string filePrefix () const
 
std::unique_ptr< WWidget > wrapView (std::unique_ptr< WWidget >(JWtHome::*createFunction)())
 
- Protected Member Functions inherited from Home
void init ()
 
void addLanguage (const Lang &l)
 
std::unique_ptr< WWidget > linkSourceBrowser (const std::string &examplePath)
 
WString tr (const char *key)
 
std::string href (const std::string &url, const std::string &description)
 
void readReleases (WTable *releaseTable)
 

Private Member Functions

std::unique_ptr< WWidget > example (const char *textKey, const std::string &sourceDir)
 
std::unique_ptr< WWidget > helloWorldExample ()
 
std::unique_ptr< WWidget > chartExample ()
 
std::unique_ptr< WWidget > composerExample ()
 
std::unique_ptr< WWidget > treeviewExample ()
 
std::unique_ptr< WWidget > chatExample ()
 
std::unique_ptr< WWidget > figtreeExample ()
 
std::unique_ptr< WWidget > widgetGalleryExample ()
 

Private Attributes

std::string jwtExamplePath_
 

Additional Inherited Members

- Protected Attributes inherited from Home
WTabWidget * examplesMenu_
 
WTable * releases_
 

Detailed Description

Definition at line 16 of file JWtHome.h.

Constructor & Destructor Documentation

◆ JWtHome()

JWtHome::JWtHome ( const WEnvironment &  env,
Dbo::SqlConnectionPool &  blogDb 
)

Definition at line 27 of file JWtHome.C.

28  : Home(env, blogDb,
29  "JWt, Java Web Toolkit",
30  "jwt-home", "css/jwt")
31 {
32  addLanguage(Lang("en", "/", "en", "English"));
33 
34  char* jwtExamplePath = getenv("JWT_EXAMPLE_PATH");
35  if (jwtExamplePath)
36  jwtExamplePath_ = jwtExamplePath;
37  else
38  jwtExamplePath_ = "/home/pieter/projects/jwt/wt-port/java/examples/";
39 
40  init();
41 }
Definition: Home.h:23
std::string jwtExamplePath_
Definition: JWtHome.h:40
void init()
Definition: Home.C:63
Home(const WEnvironment &env, Dbo::SqlConnectionPool &blogDb, const std::string &title, const std::string &resourceBundle, const std::string &cssPath)
Definition: Home.C:40
void addLanguage(const Lang &l)
Definition: Home.h:86

Member Function Documentation

◆ chartExample()

std::unique_ptr< WWidget > JWtHome::chartExample ( )
private

Definition at line 119 of file JWtHome.C.

120 {
121  return std::move(example("home.examples.chart", "charts"));
122 }
std::unique_ptr< WWidget > example(const char *textKey, const std::string &sourceDir)
Definition: JWtHome.C:106

◆ chatExample()

std::unique_ptr< WWidget > JWtHome::chatExample ( )
private

Definition at line 134 of file JWtHome.C.

135 {
136  return std::move(example("home.examples.chat", "simplechat"));
137 }
std::unique_ptr< WWidget > example(const char *textKey, const std::string &sourceDir)
Definition: JWtHome.C:106

◆ composerExample()

std::unique_ptr< WWidget > JWtHome::composerExample ( )
private

Definition at line 129 of file JWtHome.C.

130 {
131  return std::move(example("home.examples.composer", "composer"));
132 }
std::unique_ptr< WWidget > example(const char *textKey, const std::string &sourceDir)
Definition: JWtHome.C:106

◆ createQuoteForm()

std::unique_ptr< WWidget > JWtHome::createQuoteForm ( )
protectedvirtual

Implements Home.

Definition at line 92 of file JWtHome.C.

93 {
94 #ifdef WT_EMWEB_BUILD
95  return cpp14::make_unique<QuoteForm>(QuoteForm::JWt);
96 #else
97  return nullptr;
98 #endif
99 }

◆ example()

std::unique_ptr< WWidget > JWtHome::example ( const char *  textKey,
const std::string &  sourceDir 
)
private

Definition at line 106 of file JWtHome.C.

107 {
108  std::unique_ptr<WContainerWidget> result = cpp14::make_unique<WContainerWidget>();
109  result->addWidget(cpp14::make_unique<WText>(tr(textKey)));
110  result->addWidget(linkSourceBrowser(sourceDir));
111  return std::move(result);
112 }
std::unique_ptr< WWidget > linkSourceBrowser(const std::string &examplePath)
Definition: Home.C:202
WString tr(const char *key)
Definition: Home.C:425

◆ examples()

std::unique_ptr< WWidget > JWtHome::examples ( )
protectedvirtual

Implements Home.

Definition at line 43 of file JWtHome.C.

44 {
45  std::unique_ptr<WContainerWidget> result(cpp14::make_unique<WContainerWidget>());
46 
47  std::unique_ptr<WText> intro(cpp14::make_unique<WText>(tr("home.examples")));
48  intro->setInternalPathEncoding(true);
49  result->addWidget(std::move(intro));
50 
51  examplesMenu_ = result->addWidget(cpp14::make_unique<WTabWidget>());
52  WAnimation animation(AnimationEffect::SlideInFromRight, TimingFunction::EaseIn);
53  examplesMenu_->contentsStack()->setTransitionAnimation(animation, true);
54 
55  /*
56  * The following code is functionally equivalent to:
57  *
58  * examplesMenu_->addTab(helloWorldExample(), "Hello world");
59  *
60  * However, we optimize here for memory consumption (it is a homepage
61  * after all, and we hope to be slashdotted some day)
62  *
63  * Therefore, we wrap all the static content (including the tree
64  * widgets), into WViewWidgets with static models. In this way the
65  * widgets are not actually stored in memory on the server.
66  */
67 
68  // The call ->setPathComponent() is to use "/examples/" instead of
69  // "/examples/hello_world" as internal path
71  tr("hello-world"))->setPathComponent("");
73  tr("widget-gallery"));
74  examplesMenu_->addTab(std::move(wrapView(&JWtHome::chartExample)),
75  tr("charts"));
76  examplesMenu_->addTab(std::move(wrapView(&JWtHome::treeviewExample)),
77  tr("treeview"));
78  examplesMenu_->addTab(std::move(wrapView(&JWtHome::composerExample)),
79  tr("mail-composer"));
80  examplesMenu_->addTab(std::move(wrapView(&JWtHome::chatExample)),
81  tr("chat"));
82  examplesMenu_->addTab(std::move(wrapView(&JWtHome::figtreeExample)),
83  tr("figtree"));
84 
85  // Enable internal paths for the example menu
86  examplesMenu_->setInternalPathEnabled("/examples");
87  examplesMenu_->currentChanged().connect(this, &Home::googleAnalyticsLogger);
88 
89  return std::move(result);
90 }
std::unique_ptr< WWidget > figtreeExample()
Definition: JWtHome.C:139
std::unique_ptr< WWidget > chatExample()
Definition: JWtHome.C:134
std::unique_ptr< WWidget > chartExample()
Definition: JWtHome.C:119
WString tr(const char *key)
Definition: Home.C:425
std::unique_ptr< WWidget > wrapView(std::unique_ptr< WWidget >(JWtHome::*createFunction)())
Definition: JWtHome.C:152
std::unique_ptr< WWidget > helloWorldExample()
Definition: JWtHome.C:114
std::unique_ptr< WWidget > widgetGalleryExample()
Definition: JWtHome.C:147
WTabWidget * examplesMenu_
Definition: Home.h:89
std::unique_ptr< WWidget > treeviewExample()
Definition: JWtHome.C:124
std::unique_ptr< WWidget > composerExample()
Definition: JWtHome.C:129
void googleAnalyticsLogger()
Definition: Home.C:430

◆ figtreeExample()

std::unique_ptr< WWidget > JWtHome::figtreeExample ( )
private

Definition at line 139 of file JWtHome.C.

140 {
141  std::unique_ptr<WContainerWidget> result(cpp14::make_unique<WContainerWidget>());
142  WText *text = result->addWidget(cpp14::make_unique<WText>(tr("home.examples.figtree")));
143  text->setInternalPathEncoding(true);
144  return std::move(result);
145 }
WString tr(const char *key)
Definition: Home.C:425

◆ filePrefix()

virtual std::string JWtHome::filePrefix ( ) const
inlineprotectedvirtual

Implements Home.

Definition at line 25 of file JWtHome.h.

25 { return "jwt-"; }

◆ helloWorldExample()

std::unique_ptr< WWidget > JWtHome::helloWorldExample ( )
private

Definition at line 114 of file JWtHome.C.

115 {
116  return std::move(example("home.examples.hello", "hello"));
117 }
std::unique_ptr< WWidget > example(const char *textKey, const std::string &sourceDir)
Definition: JWtHome.C:106

◆ sourceViewer()

std::unique_ptr< WWidget > JWtHome::sourceViewer ( const std::string &  deployPath)
protectedvirtual

Implements Home.

Definition at line 101 of file JWtHome.C.

102 {
103  return cpp14::make_unique<ExampleSourceViewer>(deployPath, jwtExamplePath_ + "/", "JAVA");
104 }
std::string jwtExamplePath_
Definition: JWtHome.h:40

◆ treeviewExample()

std::unique_ptr< WWidget > JWtHome::treeviewExample ( )
private

Definition at line 124 of file JWtHome.C.

125 {
126  return std::move(example("home.examples.treeview", "treeviewdragdrop"));
127 }
std::unique_ptr< WWidget > example(const char *textKey, const std::string &sourceDir)
Definition: JWtHome.C:106

◆ widgetGalleryExample()

std::unique_ptr< WWidget > JWtHome::widgetGalleryExample ( )
private

Definition at line 147 of file JWtHome.C.

148 {
149  return std::move(example("home.examples.widgetgallery", "widgetgallery"));
150 }
std::unique_ptr< WWidget > example(const char *textKey, const std::string &sourceDir)
Definition: JWtHome.C:106

◆ wrapView()

std::unique_ptr< WWidget > JWtHome::wrapView ( std::unique_ptr< WWidget >(JWtHome::*)()  createFunction)
protected

Definition at line 152 of file JWtHome.C.

153 {
154  return makeStaticModel(std::bind(createWidget, this));
155 }
std::unique_ptr< Wt::WApplication > createWidget(const Wt::WEnvironment &env, SimpleChatServer &server)
Definition: simpleChat.C:148

Member Data Documentation

◆ jwtExamplePath_

std::string JWtHome::jwtExamplePath_
private

Definition at line 40 of file JWtHome.h.


The documentation for this class was generated from the following files:

Generated on Mon Jul 23 2018 for the C++ Web Toolkit (Wt) by doxygen 1.8.14