Create View
All views in Eclipse Dirigible are loaded via the ide-view extension point. List with all extension points can be found at the Extensions Overview page. To develop a new view, extension, view definition and frontend resources should be created. The following example is using AngularJS and Fundamental Library.
Steps
Start Eclipse Dirigible.
INFO
You can find more information on how to do that by following:
- Getting Started section.
- Setup section.
Go to the
Projectsperspective and createNew Project.- Enter
my-viewfor the name of the project. - The project will appear under the projects list.
- Enter
Create view extension:
- Right click on the
my-viewproject and select New -> Folder. - Enter
viewfor the name of the folder. - Create
view.extensionandview.jsfiles.
view.extension
- Right click on the
viewfolder and select New -> Extension. - Enter
view.extensionfor the name of the file. - Right click on the
view.extensionfile and select Open With -> Code Editor. - Replace the content with the following definition:
json{ "module": "my-view/view/view.js", "extensionPoint": "ide-view", "description": "My View" }- Save the changes and close the Code Editor.
- (optional) Double click on the
view.extensionfile to open the extension with the Extension Editor.
view.js
- Right click on the
viewfolder and select New -> JavaScript CJS Service. - Enter
view.jsfor the name of the file. - Double click on the
view.jsfile to open it with the Code Editor. - Replace the content with the following code:
javascriptconst viewData = { id: "my-view", label: "My View", factory: "frame", region: "bottom", link: "../my-view/index.html", }; if (typeof exports !== 'undefined') { exports.getView = function () { return viewData; } }- Save the changes and close the Code Editor.
- Right click on the
Create view frontend resources:
- Create
index.htmlandcontroller.jsfiles.
index.html
- Right click on the
my-viewproject and select New -> HTML5 Page. - Enter
index.htmlfor the name of the file. - Double click on the
index.htmlfile to open it with the Code Editor. - Replace the content with the following code:
html<!DOCTYPE HTML> <html lang="en" xmlns="http://www.w3.org/1999/xhtml" ng-app="myView" ng-controller="MyViewController as mvc"> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1"> <!-- Fake favicon to silent console errors and not waste a get request --> <link rel="icon" sizes="any" href="data:;base64,iVBORw0KGgo="> <!-- Title directive --> <title dg-view-title></title> <!-- jQuery --> <script type="text/javascript" src="/webjars/jquery/3.6.0/jquery.min.js"></script> <!-- AngularJS --> <script type="text/javascript" src="/webjars/angularjs/1.8.2/angular.min.js"></script> <script type="text/javascript" src="/webjars/angularjs/1.8.2/angular-resource.min.js"></script> <script type="text/javascript" src="/webjars/angular-aria/1.8.2/angular-aria.min.js"></script> <!-- Fundamental-styles --> <link type="text/css" rel="stylesheet" href="/webjars/fundamental-styles/0.24.0/dist/fundamental-styles.css"> <theme></theme> <!-- Dirigible styles --> <link type="text/css" rel="stylesheet" href="/services/v4/web/resources/styles/core.css" /> <link type="text/css" rel="stylesheet" href="/services/v4/web/resources/styles/widgets.css" /> <!-- MessageHub --> <script type="text/javascript" src="/services/v4/web/ide-core/core/message-hub.js"></script> <script type="text/javascript" src="/services/v4/web/ide-core/core/ide-message-hub.js"></script> <!-- IDE Core UI --> <script type="text/javascript" src="/services/v4/web/ide-core/ui/theming.js"></script> <script type="text/javascript" src="/services/v4/web/ide-core/ui/widgets.js"></script> <script type="text/javascript" src="/services/v4/web/ide-core/ui/view.js"></script> <!-- Project-specific stuff --> <script type="text/javascript" src="controller.js"></script> </head> <body class="fd-scrollbar" dg-contextmenu="contextMenuContent"> <fd-fieldset> <fd-form-group dg-header="My Form"> <fd-form-item horizontal="true"> <fd-form-label for="idName" dg-required="true" dg-colon="true">Name</fd-form-label> <fd-input id="idName" type="text" placeholder="Enter name here" ng-model="inputData.name"> </fd-input> </fd-form-item> <fd-form-item horizontal="true"> <fd-form-label for="idEmail" dg-required="true" dg-colon="true">Email</fd-form-label> <fd-input id="idEmail" type="text" placeholder="Enter email here" ng-model="inputData.email"> </fd-input> </fd-form-item> </fd-form-group> </fd-fieldset> <button class="fd-button fd-button--emphasized" ng-click="saveForm()" style="margin: 6px;">Save</button> <table fd-table display-mode="compact" style="margin-top: 20px"> <thead fd-table-header> <tr fd-table-row> <th fd-table-header-cell>Name</th> <th fd-table-header-cell>Email</th> </tr> </thead> <tbody fd-table-body> <tr fd-table-row hoverable="true" ng-repeat="next in data"> <td fd-table-cell>{{next.name}}</td> <td fd-table-cell activable="true"><a class="fd-link">{{next.email}}</a></td> </tr> </tbody> </table> </body> </html>- Save the changes and close the Code Editor.
controller.js
- Right click on the
my-viewproject and select New -> File. - Enter
controller.jsfor the name of the file. - Double click on the
controller.jsfile to open it with the Code Editor. - Replace the content with the following code:
javascriptlet myView = angular.module("myView", ["ideUI", "ideView"]); myView.config(["messageHubProvider", function (messageHubProvider) { messageHubProvider.eventIdPrefix = "myView"; }]); myView.controller("MyViewController", ["$scope", "$http", "messageHub", function ($scope, $http, messageHub) { $scope.inputData = {}; $scope.data = [{ name: "John Doe", email: "john.doe@email.com" }, { name: "Jane Doe", email: "jane.doe@email.com" }]; $scope.saveForm = function () { messageHub.showAlertInfo( "Form Successfully Save", `Name: ${$scope.inputData.name}, Email: ${$scope.inputData.email}` ); }; }]);- Save the changes and close the Code Editor.
- Create
Refresh the browser.
INFO
In some cases you may want to go to Theme -> Reset to clean Web IDE state.
Go to Window -> Show View -> My View to open the new view.