You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Originally from https://github.com/maven-eclipse/maven-eclipse.github.io
5
+
*Version 0.0.2; initial public release; includes full SWT API support*
6
+
7
+
It used to be that web applications were simpler and easier to build than desktop graphical applications. With the expectations of modern CSS and Javascript, this is no longer the case. Modern web applications are beautiful, but they are expensive.
8
+
9
+
Sometimes a small, fast, lightweight desktop application is just the right thing.
10
+
11
+
## Sponsor
12
+
13
+
If you find this work useful or inspiring, please sponsor me or hire me!
14
+
15
+
## What?
16
+
17
+
The Clojure Desktop Toolkit wraps Eclipse's SWT library, a cross-platform graphical toolkit utilizing native widgets on each platform. This enables developers to deliver a high-quality user experience that looks and feels native, because it is.
18
+
19
+
Clojure Desktop Toolkit also provides an idiomatic functional approach to describing graphical interfaces, greatly reducing the amount of boilerplate one must write to create a rich graphical experience.
20
+
21
+
A significant barrier to using Eclipse SWT for non-Eclipse applications has been that SWT isn't published on Maven Central. Clojure Desktop Toolkit solves this probablem by scraping SWT's jars from Eclipse.org and bundling them in our own custom Maven repository. Shell scripts make it easy to stay up to date. (This capability originally came from https://github.com/maven-eclipse/maven-eclipse.github.io)
22
+
23
+
### Example
24
+
25
+
An application that minimizes itself to the system tray and hosts several panes of information:
26
+
27
+
```clojure
28
+
defn example-app []
29
+
(application; The application hosts the display object and runs the event loop
30
+
31
+
(tray-item; Define a system tray item so we can minimize to the tray
32
+
(on e/menu-detected [props parent event] (.setVisible (:ui/tray-menu @props) true))
33
+
(on e/widget-selected [props parent event] (let [shell (:ui/shell @props)]
34
+
(.setVisible shell (not (.isVisible shell))))))
35
+
36
+
(shell
37
+
SWT/SHELL_TRIM (id!:ui/shell)
38
+
"Browser"
39
+
:layout (FillLayout.)
40
+
41
+
(on e/shell-closed [props parent event] (when-not (:closing @props)
1. A Maven repo containing SWT 4.2 to 4.31 on all supported platforms along with scripts to scrape/merge new releases as they are published at Eclipse.
8
-
2. A (WIP) Clojure deps.edn project with a functional-style SWT DSL/wrapper that makes working with SWT user interfaces straightforward from Clojure
85
+
Notice how the library automatically supplies links to Eclipse's SWT documentation. There's also a `(swtdoc)` command for interactively exploring the API from the REPL.
9
86
10
-
## Why?
87
+

11
88
12
-
Clojure needs a mature UI library with idiomatic FP-style bindings. SWT is one such UI library; this project aims to supply the bindings.
13
89
14
-
More generally:
90
+
## How do I use it?
15
91
16
-
SWT is not available in Maven Central making it difficult to use in Maven and/or Clojure projects. Existing Maven repos are either not maintained and abandoned, don't have all platforms, don't contain sources, don't contain the debug jar, or don't provide a reliable, automatic way to update or reproduce the repository.
92
+
Clojure Desktop Toolkit requires Clojure 1.12.0 or later. (We use its `add-libs` API to dynamically detect, select, and load the correct platform-specific SWT library.)
17
93
18
-
This standard Maven repo is generated by a script that automatically downloads and repackages the official SWT releases.
94
+
Currently we support `deps.edn` via the Github transport. Other artifact repositories are coming.
19
95
20
-
For more information see this [project's parent fork](https://github.com/maven-eclipse/maven-eclipse.github.io/).
See the tutorial and API documentation for more. *(Currently: WIP; in the meantime, see the tests and the examples in the `comment` forms.)*
109
+
110
+
## Project status
111
+
112
+
This project is usable, but very early. Currently, Clojure Desktop Toolkit supports 100% of the SWT API, though there are a few corner cases that require Java interop.
113
+
114
+
Here's what works well:
115
+
116
+
* SWT's Webkit-based browser widget works well. *Goodbye Electron!!!* There's also a GPL-3 community driven Chromium integration that is said to be stellar.
117
+
118
+
* The API for constructing a SWT user interface has been stable for awhile now and is unlikely to change much if at all.
119
+
120
+
### Areas of active work
121
+
122
+
The following are areas of active work; you can expect breaking changes here:
123
+
124
+
* The API is mechanically generated at compile time via Java reflection and Clojure macros. Future work will extend this mechanism to support scraping and generating APIs for custom SWT controls as well.
125
+
126
+
* Speaking of custom SWT controls, I want to include a rich library of community-written SWT controls from Eclipse's Nebula and E4 projects.
127
+
128
+
* SWT event handling is currently supported in the usual way: by adding listeners. A macro eliminates the usual Java boilerplate, and this makes it very convenient to code imperatively. 😁 LOL.
129
+
130
+
* Goals for improving this include integrating Missionary via Eclipse Databinding (I was one of Eclipse Databinding's founding engineers/architects). Maybe an Electric Clojure integration will be in order too! Hyperfiddle folks--hit me up if you're interested in helping!
131
+
132
+
* Improved error reporting. There are a few cases where root causes aren't obvious enough.
133
+
134
+
*`(swtdoc)` already provides interactive ways to explore the API. There is a lot of opportunity to improve this with, ehm, *graphical* tools as well.
135
+
136
+
### Non-goals
137
+
138
+
* Support for SWT's OpenGL APIs, unless someone else is committed to doing the work and maintaining it. (At least for now.)
139
+
140
+
# Maintaining an up-to-date SWT repository
141
+
142
+
This Maven repo is generated by a script that automatically downloads and repackages the official SWT releases. (Are you starting to detect a pattern here?)
143
+
144
+
For more information see this [project's parent-fork](https://github.com/maven-eclipse/maven-eclipse.github.io/), but the following should be enough information for someone else to update this if that should become required:
21
145
22
146
## Prerequisites
23
147
@@ -42,21 +166,18 @@ $ ./scrape-swt.sh
42
166
$ git add .&& git commit -m "your commit message"
43
167
```
44
168
45
-
## Clojure
46
-
47
-
tbd.
48
-
49
169
## Maven
50
170
51
-
Add this to your pom.xml: (Gradle, Ivy, and other builders users: The information is the same)
171
+
If you're a Java coder and you just want to use SWT in a Maven, Gradle, or Ivy project, you can do that here too!
172
+
173
+
Add this to your pom.xml: (Gradle, Ivy, and other build systems: The information is the same; adjust for your configuration style.)
52
174
53
-
> Adjust the path below to match your project checkout location:
0 commit comments