Skip to content

Commit 9281e64

Browse files
author
Olga Shiryaeva
authored
Update README.md
1 parent 3379973 commit 9281e64

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

README.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ dependencies {
3030

3131
Previously, I’ve already told you about our experience with Vaadin in the blog post: https://vaadin.com/blog/cuba-studio-how-we-use-vaadin-for-our-web-development-tool
3232

33-
For me, It is battle proven Java framework that enables us to build complex UI without a single line of HTML and JS. Let’s employ it as a basis for our UI.
33+
For me, it is battle-proven Java framework that enables us to build complex UI without a single line of HTML and JS. Let’s employ it as a basis for our UI.
3434

3535
I will create a simple Vaadin application from scratch. First, we need to add necessary dependencies to build.gradle script, enable `war` and `gretty` plugins:
3636
```java
@@ -100,7 +100,7 @@ Open http://localhost:8080/app in your favorite web browser. That was easy!
100100

101101
![Vaadin UI](/images/image1.png)
102102

103-
At the moment we have pretty standard web application, it can be deployed to server or we can give it to Desktop users along with servlet container (Tomcat, for instance) and make them use it from a web browser.
103+
At the moment we have a pretty standard web application, it can be deployed to server or we can give it to Desktop users along with a servlet container (Tomcat, for instance) and make them use it from a web browser.
104104

105105
## How to embed Jetty into Java applications
106106

@@ -134,7 +134,7 @@ mainClassName = 'demo.Launcher'
134134

135135
I’ve added jetty jars to the project dependencies and replaced `war` and `gretty` plugins with `application` plugin. The only thing left to do is to implement `demo.Launcher` class.
136136

137-
That’s quite easy task because the process of Jetty embedding is already described in the official manual: http://www.eclipse.org/jetty/documentation/current/embedding-jetty.html
137+
That’s quite an easy task because the process of Jetty embedding is already described in the official manual: http://www.eclipse.org/jetty/documentation/current/embedding-jetty.html
138138

139139
Thus, our Launcher will look as follows:
140140
```java
@@ -183,7 +183,7 @@ At this stage, we will create simple electron application without our server sid
183183
}
184184
```
185185

186-
We will show stub HTML page `src/main/electron/index.html`:
186+
We will show the stub HTML page `src/main/electron/index.html`:
187187

188188
```html
189189
<h1>
@@ -239,7 +239,7 @@ NPM will download and install electron to your PC. Let’s start it!
239239
240240
![Electron UI](/images/image2.png)
241241

242-
At the moment, we got all the pieces of the puzzle sitting right there on the table. Now all we have to do is put them in the right order.
242+
At the moment, we've got all the pieces of the puzzle sitting right there on the table. Now all we have to do is put them in the right order.
243243

244244
## Bring all together
245245

@@ -309,11 +309,11 @@ const startUp = function () {
309309
startUp();
310310
```
311311

312-
Here we use `minimal-request-promise` package to check if an application has started, install it using NPM (we call npm/npx commands from `src/main/electron` directory):
312+
Here we use the `minimal-request-promise` package to check if an application has started, install it using NPM (we call npm/npx commands from `src/main/electron` directory):
313313

314314
> npm install minimal-request-promise
315315
316-
In order to stop the Java part we will use `tree-kill` package. Install it:
316+
In order to stop the Java part, we will use `tree-kill` package. Install it:
317317

318318
> npm install tree-kill
319319
@@ -345,7 +345,7 @@ In fact, any Java application can be started using this approach, you can run yo
345345

346346
Well, it seems that this really simple example does work, but how we can employ peripheral devices or communicate with OS?
347347

348-
Since we have full featured Java process we can easily write/read local files and use all the features of OS. For instance, let’s print OS info to a local printer.
348+
Since we have full-featured Java process, we can easily write/read local files and use all the features of OS. For instance, let’s print OS info to a local printer.
349349

350350
1) First, we create a text document with OS information
351351

@@ -400,7 +400,7 @@ if (services.length == 0) {
400400
}
401401
```
402402

403-
4) Finally, document printing method will be:
403+
4) Finally, the document printing method will be:
404404

405405
```java
406406
private void printDocument(Doc doc, PrintRequestAttributeSet aset,
@@ -426,7 +426,7 @@ private void printDocument(Doc doc, PrintRequestAttributeSet aset,
426426

427427
Moreover, there are well-known APIs in Java for calling functions from native libraries, such as JNI or JNA. Thus, there are no restrictions for our application in comparison with web-only apps.
428428

429-
Implementation of the offline mode for this application essentially the same as for any Desktop application - cache data locally using an embedded database, e.g. HSQL, route business logic calls to local data in case of unavailable network and voila!
429+
Implementation of the offline mode for this application essentially the same as for any Desktop application - cache data locally using an embedded database, e.g. HSQL, route business logic calls to local data in case of unavailable network, and voila!
430430

431431
The full code of the tutorial is available on GitHub: https://github.com/cuba-labs/java-electron-tutorial
432432

@@ -469,7 +469,7 @@ private void callElectronUiApi(String[] args) {
469469

470470
### Use WebSocket for UI to speed up communication and strip useless HTTP headers.
471471

472-
Each time our application handles user event it sends and receives HTTP headers. They are almost useless in our application. Besides, it opens/closes HTTP connection between UI and Java part. We can speed up the communication between browser part and Java UI using WebSocket protocol.
472+
Each time our application handles a user event, it sends and receives HTTP headers. They are almost useless in our application. Besides, it opens/closes HTTP connection between UI and Java part. We can speed up the communication between browser part and Java UI using WebSocket protocol.
473473

474474
Add org.eclipse.jetty.websocket:websocket-server dependency to build.gradle:
475475

@@ -495,15 +495,15 @@ Thanks to Vaadin, that is really easy!
495495

496496
Our application still sends all the static resources through Java servlets using network layer. We can make Electron read them from a file system directly!
497497

498-
As it is described here: https://github.com/electron/electron/blob/master/docs/api/protocol.md we can register custom protocol handler that will intercept requests to /VAADIN/ static files and read them from disk. Remember to unpack static files from jars on build stage!
498+
As it is described here: https://github.com/electron/electron/blob/master/docs/api/protocol.md We can register custom protocol handler that will intercept requests to /VAADIN/ static files and read them from disk. Remember to unpack static files from jars on build stage!
499499

500500
See full example in:
501501
- https://github.com/jreznot/electron-java-app/blob/master/build.gradle#L75
502502
- https://github.com/jreznot/electron-java-app/blob/master/electron-src/main.js#L70
503503

504504
### Use Gradle Node.JS plugin com.moowork.node instead of manual Node installation
505505

506-
It is much easier to manage Node.js from build script than maintaining separate installation of it on developer machines. See example in: https://github.com/jreznot/electron-java-app/blob/master/build.gradle
506+
It is much easier to manage Node.js from build script than maintaining separate installation of it on developer machines. See example on: https://github.com/jreznot/electron-java-app/blob/master/build.gradle
507507

508508
## Real-life application
509509

0 commit comments

Comments
 (0)