From d6335e7f4ecb5d27d2d720a8f6b11e8b302d219a Mon Sep 17 00:00:00 2001 From: jskonst <jskonst@yandex.ru> Date: Mon, 4 Jul 2016 14:41:43 +0300 Subject: [PATCH] Little sample --- .gitignore | 11 +++ app/AppStart/UISample.js | 28 ++++++ app/AppStart/UISample.layout | 9 ++ ...thCustomImgSlider.model => UISample.model} | 0 app/AppStart/UiWithCustomImgSlider.js | 32 ------- app/AppStart/UiWithCustomImgSlider.layout | 15 ---- app/CustomWidgets/FancyWidget.js | 30 +++++++ app/CustomWidgets/FancyWidget.layout | 6 ++ app/CustomWidgets/FancyWidget.model | 3 + app/start.js | 23 +++++ application-start.html | 13 +++ login-failed.html | 10 +++ login.html | 88 +++++++++++++++++++ private.properties | 8 ++ 14 files changed, 229 insertions(+), 47 deletions(-) create mode 100644 .gitignore create mode 100644 app/AppStart/UISample.js create mode 100644 app/AppStart/UISample.layout rename app/AppStart/{UiWithCustomImgSlider.model => UISample.model} (100%) delete mode 100644 app/AppStart/UiWithCustomImgSlider.js delete mode 100644 app/AppStart/UiWithCustomImgSlider.layout create mode 100644 app/CustomWidgets/FancyWidget.js create mode 100644 app/CustomWidgets/FancyWidget.layout create mode 100644 app/CustomWidgets/FancyWidget.model create mode 100644 app/start.js create mode 100644 application-start.html create mode 100644 login-failed.html create mode 100644 login.html diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..2e1786d --- /dev/null +++ b/.gitignore @@ -0,0 +1,11 @@ +private.properties +web +WEB-INF +META-INF +pub +.DS_Store +appCache +reports +*lock.* +*.trace.db +*.war diff --git a/app/AppStart/UISample.js b/app/AppStart/UISample.js new file mode 100644 index 0000000..fb4408f --- /dev/null +++ b/app/AppStart/UISample.js @@ -0,0 +1,28 @@ +/** + * + * @author jskonst + */ +define('UISample', ['orm', 'forms', 'ui','FancyWidget'], function (Orm, Forms, Ui,FancyWidget, ModuleName) { + function module_constructor() { + var self = this + , model = Orm.loadModel(ModuleName) + , form = Forms.loadForm(ModuleName, model); + + self.show = function () { + form.show(); + }; + + var fancyWidget = new FancyWidget(); + form.pnlPlaceholder1.height = null; + form.pnlPlaceholder2.height = null; + fancyWidget.showOn(form.pnlPlaceholder1); + + form.pnlPlaceholder2.element.innerHTML ='<p> this plcae can be replaced</p>'; + + model.requery(function () { + // TODO : place your code here + }); + + } + return module_constructor; +}); diff --git a/app/AppStart/UISample.layout b/app/AppStart/UISample.layout new file mode 100644 index 0000000..c7f9aad --- /dev/null +++ b/app/AppStart/UISample.layout @@ -0,0 +1,9 @@ +<?xml version="1.0" encoding="UTF-8"?><layout title="" view="view"> + <AnchorsPane background="#ffffff" cursor="0" name="view" prefHeight="300px" prefWidth="400px"/> + <BoxPane background="#e71414" cursor="0" name="pnlPlaceholder1" parent="view" prefHeight="50px" prefWidth="200px"> + <AnchorsPaneConstraints height="50px" left="10px" top="10px" width="200px"/> + </BoxPane> + <BoxPane background="#dfb40f" cursor="0" name="pnlPlaceholder2" orientation="1" parent="view" prefHeight="70px" prefWidth="200px"> + <AnchorsPaneConstraints height="70px" left="10px" top="90px" width="200px"/> + </BoxPane> +</layout> diff --git a/app/AppStart/UiWithCustomImgSlider.model b/app/AppStart/UISample.model similarity index 100% rename from app/AppStart/UiWithCustomImgSlider.model rename to app/AppStart/UISample.model diff --git a/app/AppStart/UiWithCustomImgSlider.js b/app/AppStart/UiWithCustomImgSlider.js deleted file mode 100644 index f06e558..0000000 --- a/app/AppStart/UiWithCustomImgSlider.js +++ /dev/null @@ -1,32 +0,0 @@ -/** - * - * @author spidergrasp - */ -define(['orm', 'forms', 'ui'], function (Orm, Forms, Ui, ModuleName) { - function module_constructor() { - var self = this - , model = Orm.loadModel(ModuleName) - , form = Forms.loadForm(ModuleName, model); - - self.show = function () { - form.show(); - }; - - /* - * Here we have browser executable module using our custom widget - ImgSlider - * Note that in module dependencies we did not writen anything about it (like usualy Platypus UI widgets work the same way) - * Also we have not any code for ImgSlider cause we already have it in layout (open it with text editor to see XML - */ - - /* - * We can use ImgSlider events - * banner is instance of ImgSlider - */ - - form.banner.onActionPerformed = function(evt) { - //do smth - }; - - } - return module_constructor; -}); diff --git a/app/AppStart/UiWithCustomImgSlider.layout b/app/AppStart/UiWithCustomImgSlider.layout deleted file mode 100644 index dd40c8d..0000000 --- a/app/AppStart/UiWithCustomImgSlider.layout +++ /dev/null @@ -1,15 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?><layout title="" view="view"> - <AnchorsPane background="#ffffff" cursor="0" name="view" prefHeight="300px" prefWidth="400px"/> - - <!-- - Here goes all juicy stuff :) - We use ImgSlider like usual PlatypusJS component here with all his properties - Let's assume that our model has entity called 'goods' and there is 'picture' field containing path to image - --> - - <ImgSlider cursor="0" data="goods" imgField="picture" name="banner" parent="view" prefHeight="19px" prefWidth="100px"> - <AnchorsPaneConstraints height="19px" left="200px" top="140px" width="100px"/> - </ImgSlider> - - -</layout> diff --git a/app/CustomWidgets/FancyWidget.js b/app/CustomWidgets/FancyWidget.js new file mode 100644 index 0000000..e0e0daa --- /dev/null +++ b/app/CustomWidgets/FancyWidget.js @@ -0,0 +1,30 @@ +/** + * + * @author jskonst + */ +define('FancyWidget', ['orm', 'forms', 'ui'], function (Orm, Forms, Ui, ModuleName) { + function FancyButton() { + var self = this + , model = Orm.loadModel(ModuleName) + , form = Forms.loadForm(ModuleName, model); + + + self.show = function () { + form.show(); + }; + + model.requery(function () { + // TODO : place your code here + }); + + self.showOn = function (aPanel) { + aPanel.add(form.view); + }; + + form.button.onActionPerformed = function(){ + alert("Here"); + }; + + } + return FancyButton; +}); diff --git a/app/CustomWidgets/FancyWidget.layout b/app/CustomWidgets/FancyWidget.layout new file mode 100644 index 0000000..c7f22d2 --- /dev/null +++ b/app/CustomWidgets/FancyWidget.layout @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="UTF-8"?><layout title="" view="view"> + <AnchorsPane background="#1bee25" cursor="0" name="view" prefHeight="52px" prefWidth="268px"/> + <Button cursor="0" name="button" parent="view" prefHeight="30px" prefWidth="100px" text="button"> + <AnchorsPaneConstraints height="30px" left="10px" top="10px" width="100px"/> + </Button> +</layout> diff --git a/app/CustomWidgets/FancyWidget.model b/app/CustomWidgets/FancyWidget.model new file mode 100644 index 0000000..217f1a5 --- /dev/null +++ b/app/CustomWidgets/FancyWidget.model @@ -0,0 +1,3 @@ +<?xml version="1.0" encoding="UTF-8" standalone="yes"?> +<datamodel> +</datamodel> diff --git a/app/start.js b/app/start.js new file mode 100644 index 0000000..756e615 --- /dev/null +++ b/app/start.js @@ -0,0 +1,23 @@ +/** + * Do not edit this file manually, it will be overwritten by + * Platypus Application Designer. + */ +require(['environment', 'logger'], function (F, Logger) { + var global = this; + //F.cacheBust(true); + //F.export(global); + require('UISample', function(UISample){ + var m = new UISample(); + m.show(); + }, function(e){ + Logger.severe(e); + if(global.document){ + var messageParagraph = global.document.createElement('p'); + global.document.body.appendChild(messageParagraph); + messageParagraph.innerHTML = 'An error occured while require(\'UISample\'). Error: ' + e; + messageParagraph.style.margin = '10px'; + messageParagraph.style.fontFamily = 'Arial'; + messageParagraph.style.fontSize = '14pt'; + } + }); +}); \ No newline at end of file diff --git a/application-start.html b/application-start.html new file mode 100644 index 0000000..ebd6d2e --- /dev/null +++ b/application-start.html @@ -0,0 +1,13 @@ +<!DOCTYPE html> +<html> + <head> + <meta http-equiv='Content-Type' content='text/html; charset=utf-8'> + <title>Platypus client start page</title> + <link rel="stylesheet" type="text/css" href="web/pwc/reset.css" /> + <link rel="stylesheet" type="text/css" href="web/pwc/theme.css" /> + <link rel="stylesheet" type="text/css" href="web/pwc/flaticon.css" /> + </head> + <body> + <script type="text/javascript" src="web/pwc/pwc.nocache.js" source-path="app" entry-point="start"></script> + </body> +</html> diff --git a/login-failed.html b/login-failed.html new file mode 100644 index 0000000..54dfe51 --- /dev/null +++ b/login-failed.html @@ -0,0 +1,10 @@ +<!DOCTYPE html> +<html> + <head> + <link rel="stylesheet" type="text/css" href="web/pwc/reset.css" /> + <title>Platypus Application login fail.</title> + </head> + <body> + <div>Incorrect password or username entered.</div> + </body> +</html> diff --git a/login.html b/login.html new file mode 100644 index 0000000..b3c92bc --- /dev/null +++ b/login.html @@ -0,0 +1,88 @@ +<!DOCTYPE html> +<html> + <head> + <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> + <title>Platypus application login page</title> + <style> + body{ + font-family:"Lucida Grande", "Lucida Sans Unicode", Verdana, Arial, Helvetica, sans-serif; + font-size:12px; + } + p, h1, form, button{border:0; margin:0; padding:0;} + .spacer{clear:both; height:1px;} + .myform{ + margin:0 auto; + width:400px; + padding:14px; + } + #stylized{ + border:solid 2px #b7ddf2; + background:#ebf4fb; + } + #stylized h1 { + font-size:14px; + font-weight:bold; + margin-bottom:8px; + } + #stylized p{ + font-size:11px; + color:#666666; + margin-bottom:20px; + border-bottom:solid 1px #b7ddf2; + padding-bottom:10px; + } + #stylized label{ + display:block; + margin-top: 6px; + font-weight:bold; + text-align:right; + width:140px; + float:left; + } + #stylized .small{ + color:#666666; + display:block; + font-size:11px; + font-weight:normal; + text-align:right; + width:140px; + } + #stylized input{ + float:left; + font-size:12px; + padding:4px 2px; + border:solid 1px #aacfe4; + width:200px; + margin:2px 0 20px 10px; + } + #stylized button{ + clear:both; + margin-left:150px; + width:125px; + height:31px; + background:#666666; + text-align:center; + line-height:31px; + color:#FFFFFF; + font-size:11px; + font-weight:bold; + } + </style> + </head> + <body> + <div id="stylized" class="myform"> + <form id="form" name="form" action="j_security_check" method="POST" enctype="application/x-www-form-urlencoded"> + <h1>Login to Application</h1> + <p>Powered by Platypus.js</p> + <label>Username + </label> + <input type="text" name="j_username" id="name" /> + <label>Password + </label> + <input type="password" name="j_password" id="password" /> + <button type="submit">Login</button> + </form> + </div> + </body> +</html> + diff --git a/private.properties b/private.properties index e69de29..6f5742c 100644 --- a/private.properties +++ b/private.properties @@ -0,0 +1,8 @@ +clientLogLevel=INFO +serverLogLevel=INFO +debugClientPort=8900 +debugServerPort=8901 +j2eeServerId=tomcat80:home=/home/jskonst/apache-tomcat-8.0.30 +runUser= +platypus-js-version=5.10.70 +browserCacheBusting=false