├── .github └── workflows │ └── gradle-wrapper-validation.yml ├── .gitignore ├── .travis.yml ├── CHANGES.md ├── CONTRIBUTING.md ├── Gradle and Eclipse RCP.pptx ├── LICENSE ├── README.md ├── _imgs ├── gradlephant.png ├── project_layout.png └── titlecard.png ├── build.gradle ├── build.properties ├── com.diffplug.needs17 ├── META-INF │ └── MANIFEST.MF ├── build.gradle ├── build.properties └── src │ └── needs17 │ └── Guava17.java ├── com.diffplug.needs18 ├── META-INF │ └── MANIFEST.MF ├── build.gradle ├── build.properties └── src │ └── needs18 │ └── Guava18.java ├── com.diffplug.needsBoth ├── META-INF │ └── MANIFEST.MF ├── build.gradle ├── build.properties └── src │ └── needsboth │ └── NeedsBoth.java ├── com.diffplug.rcpdemo ├── META-INF │ └── MANIFEST.MF ├── build.gradle ├── build.properties ├── images │ ├── Goomph.icns │ ├── Goomph.ico │ ├── Goomph.xpm │ └── Goomph_256.png ├── plugin.xml ├── rcpdemo.product ├── src │ └── com │ │ └── diffplug │ │ └── rcpdemo │ │ ├── AppGui.java │ │ ├── Application.java │ │ └── HeadlessApp.java └── test │ └── com │ └── diffplug │ └── rcpdemo │ └── AppGuiTest.java ├── com.diffplug.talks.rxjava_and_swt ├── META-INF │ └── MANIFEST.MF ├── build.gradle ├── build.properties ├── src │ └── com │ │ └── diffplug │ │ └── talks │ │ └── rxjava_and_swt │ │ ├── CancelIfStale.java │ │ ├── ColorComparePanel.java │ │ ├── ColorPicker.java │ │ ├── ColorPickerApis.java │ │ ├── XkcdColorPicker.java │ │ └── XkcdColors.java ├── test │ └── com │ │ └── diffplug │ │ └── talks │ │ └── rxjava_and_swt │ │ ├── ColorPickerTest.java │ │ ├── XkcdColorPickerTest.java │ │ ├── XkcdColorsTest.java │ │ ├── YCbCrTest.java │ │ └── examples │ │ ├── EventVsFrp.java │ │ ├── EventVsFrpOneWay.java │ │ ├── EventVsFrpTwoWay.java │ │ └── Scratch.java └── xkcd_colors.txt ├── deploy └── build.gradle ├── gradle.properties ├── gradle ├── spotless │ ├── spotless.eclipseformat.xml │ ├── spotless.gradle │ ├── spotless.importorder │ └── spotless.license.java └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── ide └── build.gradle ├── settings.gradle ├── target.maven └── build.gradle ├── target.p2 └── build.gradle └── titlecard.png /.github/workflows/gradle-wrapper-validation.yml: -------------------------------------------------------------------------------- 1 | name: "Validate Gradle Wrapper" 2 | on: [push, pull_request] 3 | 4 | jobs: 5 | validation: 6 | name: "Validation" 7 | runs-on: ubuntu-latest 8 | steps: 9 | - uses: actions/checkout@v2 10 | - uses: gradle/wrapper-validation-action@v1 -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | # mac stuff 3 | *.DS_Store 4 | 5 | # gradle stuff 6 | .gradle/ 7 | build/ 8 | 9 | # Eclipse stuff 10 | .project 11 | .classpath 12 | .settings/ 13 | bin/ 14 | target.p2/workspace/ 15 | 16 | # PPT stuff 17 | ~* 18 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: java 2 | jdk: 3 | - oraclejdk8 4 | before_install: 5 | - export DISPLAY=:99.0 6 | - sh -e /etc/init.d/xvfb start 7 | -------------------------------------------------------------------------------- /CHANGES.md: -------------------------------------------------------------------------------- 1 | # Gradle and Eclipse RCP 2 | 3 | ### Version 1.1.0-SNAPSHOT TBD 4 | 5 | - `ide` now uses `thirdParty` to cleanly add a terminal and gradle syntax highlighting (e2ebf6c8cdb28b15cda881174b827201c11627e6) 6 | - improved `target.maven` configuration so that subprojects can be configured lazily (f8963f3095c3c506ddecb5dce28a59fe9a13b65b) 7 | - spotless is now applied per-project (50d4153017b65d488003907e224f764258a4f7d1) 8 | - added an example of `equinoxLaunch`. 9 | 10 | ### Version 1.0.0 - July 14th 2016 11 | 12 | This version tests that you can clone, then run 13 | 14 | - `gradlew ide` 15 | - `gradlew assemble.all` 16 | 17 | and get a nice IDE on win/mac/linux, and that it will generate launcher artifacts for win/mac/linux. 18 | 19 | It has a known bug ([#4](https://github.com/diffplug/gradle_and_eclipse_rcp/issues/4)) regarding the mac launcher when building on mac. 20 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing to this demo 2 | 3 | Pull requests are welcome, preferably against `master`. 4 | 5 | ## Build instructions 6 | 7 | - `gradlew ide` opens an IDE for manipulating this project. 8 | - `gradlew assemble.all` creates native launchers for win/mac/linux in the `deploy/build` folder. 9 | 10 | If you're getting style warnings, `gradlew spotlessApply` will apply anything necessary to fix formatting. For more info on the formatter, check out [spotless](https://github.com/diffplug/spotless). 11 | 12 | ## License 13 | 14 | By contributing your code, you agree to license your contribution under the terms of the APLv2: https://github.com/diffplug/durian/blob/master/LICENSE 15 | 16 | All files are released with the Apache 2.0 license as such: 17 | 18 | ``` 19 | Copyright 2016 DiffPlug 20 | 21 | Licensed under the Apache License, Version 2.0 (the "License"); 22 | you may not use this file except in compliance with the License. 23 | You may obtain a copy of the License at 24 | 25 | http://www.apache.org/licenses/LICENSE-2.0 26 | 27 | Unless required by applicable law or agreed to in writing, software 28 | distributed under the License is distributed on an "AS IS" BASIS, 29 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 30 | See the License for the specific language governing permissions and 31 | limitations under the License. 32 | ``` 33 | -------------------------------------------------------------------------------- /Gradle and Eclipse RCP.pptx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/diffplug/gradle-and-eclipse-rcp/0c27ca32a984f8bd6b8d37b5410546d19ef442cc/Gradle and Eclipse RCP.pptx -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Gradle and Eclipse RCP 2 | 3 | 11 | [![Latest version](https://img.shields.io/badge/latest-1.0.0-blue.svg)](https://github.com/diffplug/gradle_and_eclipse_rcp/releases/latest) 12 | [![License Apache](https://img.shields.io/badge/license-Apache-blue.svg)](https://tldrlegal.com/license/apache-license-2.0-(apache-2.0)) 13 | [![Changelog](https://img.shields.io/badge/changelog-1.0.0-brightgreen.svg)](CHANGES.md) 14 | [![Travis CI](https://travis-ci.org/diffplug/gradle_and_eclipse_rcp.svg?branch=master)](https://travis-ci.org/diffplug/gradle_and_eclipse_rcp) 15 | 16 | 17 | This example project demonstrates building an Eclipse RCP application using the following techniques: 18 | 19 | - Dependencies pulled from maven and p2 20 | - Native launchers for Win/Mac/Linux 21 | - Automatic OSGi metadata 22 | - Two versions of the same library (Guava 17 and 18 at the same time) 23 | - Generate IDE-as-build-artifact 24 | 25 | Demo project for the [goomph](https://github.com/diffplug/goomph) Gradle plugin, also makes heavy use of [bnd-platform](https://github.com/stempler/bnd-platform). 26 | 27 | ### Quickstart 28 | 29 | - `gradlew ide` opens an IDE for manipulating this project. 30 | - `gradlew assemble.all` creates native launchers for win/mac/linux in the `deploy/build` folder. 31 | 32 | ### High level layout 33 | 34 | The plugins are applied as follows: 35 | 36 | ![Project layout](_imgs/project_layout.png) 37 | 38 | ## Talks 39 | 40 | See "Gradle and Eclipse RCP.pptx" in this repo for more details. Based on a talk given at [Gradle Summit 2016](https://gradlesummit.com/schedule/gradle-and-eclipse-rcp) ([video](https://www.youtube.com/watch?v=PIC6YeRkRlo&feature=youtu.be)). 41 | 42 | A second talk based on this work will be given at [EclipseConverge 2017](https://www.eclipseconverge.org/na2017/session/gradle-and-eclipse-ide-build-artifact). 43 | 44 | ## Acknowledgements 45 | 46 | * Many thanks to Simon Templer for the excellent [bnd-platform](https://github.com/stempler/bnd-platform). 47 | * Be on the lookout for David Akehurst's work on p2 and Gradle (details in powerpoint). 48 | * Andrey Hihlovskiy's excellent [Wuff](https://github.com/akhikhl/wuff) and [Unpuzzle](https://github.com/akhikhl/unpuzzle) libraries have been a huge boon to everyone trying to get Gradle and Eclipse to collaborate. 49 | * Maintained by [DiffPlug](http://www.diffplug.com/). 50 | -------------------------------------------------------------------------------- /_imgs/gradlephant.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/diffplug/gradle-and-eclipse-rcp/0c27ca32a984f8bd6b8d37b5410546d19ef442cc/_imgs/gradlephant.png -------------------------------------------------------------------------------- /_imgs/project_layout.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/diffplug/gradle-and-eclipse-rcp/0c27ca32a984f8bd6b8d37b5410546d19ef442cc/_imgs/project_layout.png -------------------------------------------------------------------------------- /_imgs/titlecard.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/diffplug/gradle-and-eclipse-rcp/0c27ca32a984f8bd6b8d37b5410546d19ef442cc/_imgs/titlecard.png -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | repositories { 3 | // make it easy to test a snapshot version of goomph 4 | maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' } 5 | // grab dependencies from the gradle plugin portal 6 | maven { url 'https://plugins.gradle.org/m2/' } 7 | } 8 | // make sure we don't cache stale snapshot versions 9 | configurations.all { 10 | resolutionStrategy.cacheChangingModulesFor 0, 'seconds' 11 | } 12 | dependencies { 13 | // a bunch of eclipse stuff 14 | classpath "com.diffplug.gradle:goomph:${VER_GOOMPH}" 15 | // creates a targetplatform 16 | classpath "org.standardout:bnd-platform:${VER_BND_PLATFORM}" 17 | // apply spotless 18 | classpath "com.diffplug.spotless:spotless-plugin-gradle:${VER_SPOTLESS}" 19 | } 20 | } 21 | 22 | /////////// 23 | // MAVEN // 24 | /////////// 25 | repositories { 26 | mavenCentral() 27 | } 28 | 29 | apply from: rootProject.file('gradle/spotless/spotless.gradle') 30 | subprojects { 31 | apply from: rootProject.file('gradle/spotless/spotless.gradle') 32 | repositories { 33 | mavenCentral() 34 | // SNAPSHOT versions are free to rely on other SNAPSHOT libraries 35 | if (project.version.endsWith('SNAPSHOT')) { 36 | maven { 37 | url 'https://oss.sonatype.org/content/repositories/snapshots/' 38 | } 39 | } 40 | // local eclipse maven (created by Goomph) 41 | maven { 42 | url rootProject.file('target.p2/build/p2asmaven/maven') 43 | metadataSources { 44 | mavenPom() 45 | artifact() 46 | } 47 | } 48 | } 49 | } 50 | 51 | ///////////// 52 | // PLUGINS // 53 | ///////////// 54 | // tasks to clean and jar all of the plugins 55 | Closure IS_PLUGIN = { it.name.startsWith('com.diffplug') } 56 | configure(subprojects.findAll(IS_PLUGIN)) { 57 | // we need the maven repo from p2 58 | evaluationDependsOn(':target.p2') 59 | 60 | def PROJECT_NAME = it.name 61 | 62 | ////////// 63 | // JAVA // 64 | ////////// 65 | apply plugin: 'java' 66 | sourceSets { 67 | main { java { 68 | srcDir 'src' 69 | } } 70 | test { java { 71 | srcDir 'test' 72 | } } 73 | } 74 | sourceCompatibility = VER_JAVA 75 | targetCompatibility = VER_JAVA 76 | 77 | // add SWT and the appropriate platform-native SWT for building and testing 78 | dependencies { 79 | implementation "eclipse-deps:org.eclipse.swt:+" 80 | implementation "eclipse-deps:org.eclipse.swt.${com.diffplug.common.swt.os.SwtPlatform.getNative()}:+" 81 | } 82 | 83 | ////////// 84 | // OSGI // 85 | ////////// 86 | // create the manifest 87 | apply plugin: 'com.diffplug.osgi.bndmanifest' 88 | osgiBndManifest { 89 | copyTo 'META-INF/MANIFEST.MF' 90 | } 91 | // configure the OSGi bundle 92 | jar.manifest.attributes( 93 | '-exportcontents': 'com.diffplug.*', 94 | '-removeheaders': 'Bnd-LastModified,Bundle-Name,Created-By,Tool,Private-Package,Require-Capability', 95 | 'Import-Package': '!javax.annotation.*,*', 96 | 'Bundle-SymbolicName': project.name, 97 | 'Bundle-RequiredExecutionEnvironment': 'JavaSE-1.8', 98 | 'Require-Capability': 'osgi.ee;filter:="(&(osgi.ee=JavaSE)(version=1.8))"', 99 | 'Bundle-Vendor': 'DiffPlug', 100 | 'Bundle-License': "http://www.apache.org/licenses/LICENSE-2.0" 101 | ) 102 | 103 | ////////////////////// 104 | // ECLIPSE PROJECTS // 105 | ////////////////////// 106 | apply plugin: 'eclipse' 107 | // remove the build folder 108 | apply plugin: 'com.diffplug.eclipse.excludebuildfolder' 109 | // improve the project deps 110 | apply plugin: 'com.diffplug.eclipse.projectdeps' 111 | // handle build.properties correctly 112 | apply plugin: 'com.diffplug.eclipse.buildproperties' 113 | 114 | eclipse { 115 | project { 116 | natures 'org.eclipse.pde.PluginNature' 117 | natures 'org.eclipse.jdt.core.javanature' 118 | 119 | buildCommand 'org.eclipse.jdt.core.javabuilder' 120 | buildCommand 'org.eclipse.pde.ManifestBuilder' 121 | buildCommand 'org.eclipse.pde.SchemaBuilder' 122 | } 123 | classpath { 124 | downloadSources true 125 | downloadJavadoc true 126 | } 127 | jdt { 128 | sourceCompatibility VER_JAVA 129 | targetCompatibility VER_JAVA 130 | } 131 | } 132 | // always create "fresh" projects 133 | tasks.eclipse.dependsOn(cleanEclipse) 134 | } 135 | 136 | ///////////////////////////////////////////////////////// 137 | // Root eclipse project for tinkering with build files // 138 | ///////////////////////////////////////////////////////// 139 | apply plugin: 'com.diffplug.eclipse.resourcefilters' 140 | eclipseResourceFilters { 141 | exclude().folders().name('com.diffplug.*') 142 | } 143 | 144 | 145 | ///////////////////////////// 146 | // Setup a headless launch // 147 | ///////////////////////////// 148 | apply plugin: 'com.diffplug.osgi.equinoxlaunch' 149 | equinoxLaunch { 150 | codegenSetup { 151 | source.addProject(project(':com.diffplug.rcpdemo')) 152 | source.addMaven('com.google.guava:guava:17.0') 153 | source.addMaven('com.google.guava:guava:18.0') 154 | } 155 | } 156 | -------------------------------------------------------------------------------- /build.properties: -------------------------------------------------------------------------------- 1 | source.. = src/ 2 | output.. = bin/ 3 | bin.includes = META-INF/,\ 4 | .,\ 5 | bin/,\ 6 | resources/ 7 | src.excludes = test/,\ 8 | resources/ 9 | -------------------------------------------------------------------------------- /com.diffplug.needs17/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | Bundle-License: http://www.apache.org/licenses/LICENSE-2.0 3 | Bundle-ManifestVersion: 2 4 | Bundle-RequiredExecutionEnvironment: JavaSE-1.8 5 | Bundle-SymbolicName: com.diffplug.needs17 6 | Bundle-Vendor: DiffPlug 7 | Bundle-Version: 1.0.0 8 | Export-Package: needs17;version="1.0.0" 9 | Import-Package: com.google.common.base;version="[17.0,18)" 10 | 11 | -------------------------------------------------------------------------------- /com.diffplug.needs17/build.gradle: -------------------------------------------------------------------------------- 1 | dependencies { 2 | implementation "com.google.guava:guava:17.0" 3 | } 4 | jar.manifest.attributes('-exportcontents': 'needs17') 5 | -------------------------------------------------------------------------------- /com.diffplug.needs17/build.properties: -------------------------------------------------------------------------------- 1 | source.. = src/ 2 | output.. = bin/ 3 | bin.includes = META-INF/,\ 4 | . -------------------------------------------------------------------------------- /com.diffplug.needs17/src/needs17/Guava17.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 DiffPlug 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package needs17; 17 | 18 | import com.google.common.base.Enums; 19 | 20 | public class Guava17 { 21 | /** 22 | * Returns an enum value from its name, using a function which is 23 | * present in Guava 17, but absent in 18. 24 | * 25 | * http://google.github.io/guava/releases/18.0/api/diffs/changes/com.google.common.base.Enums.html#com.google.common.base.Enums.valueOfFunction_removed(java.lang.Class) 26 | */ 27 | @SuppressWarnings("deprecation") 28 | public static > T parse(Class clazz, String name) { 29 | return Enums.valueOfFunction(clazz).apply(name); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /com.diffplug.needs18/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | Bundle-License: http://www.apache.org/licenses/LICENSE-2.0 3 | Bundle-ManifestVersion: 2 4 | Bundle-RequiredExecutionEnvironment: JavaSE-1.8 5 | Bundle-SymbolicName: com.diffplug.needs18 6 | Bundle-Vendor: DiffPlug 7 | Bundle-Version: 1.0.0 8 | Export-Package: needs18;version="1.0.0" 9 | Import-Package: com.google.common.util.concurrent;version="[18.0,19)" 10 | 11 | -------------------------------------------------------------------------------- /com.diffplug.needs18/build.gradle: -------------------------------------------------------------------------------- 1 | dependencies { 2 | implementation "com.google.guava:guava:18.0" 3 | } 4 | jar.manifest.attributes('-exportcontents': 'needs18') 5 | -------------------------------------------------------------------------------- /com.diffplug.needs18/build.properties: -------------------------------------------------------------------------------- 1 | source.. = src/ 2 | output.. = bin/ 3 | bin.includes = META-INF/,\ 4 | . 5 | -------------------------------------------------------------------------------- /com.diffplug.needs18/src/needs18/Guava18.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 DiffPlug 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package needs18; 17 | 18 | import java.util.concurrent.Executor; 19 | 20 | import com.google.common.util.concurrent.MoreExecutors; 21 | 22 | public class Guava18 { 23 | /** 24 | * Returns an executor that runs immediately, which is 25 | * present in Guava 18, but absent in 17. 26 | * 27 | * http://google.github.io/guava/releases/18.0/api/diffs/changes/com.google.common.util.concurrent.MoreExecutors.html#com.google.common.util.concurrent.MoreExecutors.newDirectExecutorService_added() 28 | */ 29 | public static Executor sameThread() { 30 | return MoreExecutors.directExecutor(); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /com.diffplug.needsBoth/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | Bundle-License: http://www.apache.org/licenses/LICENSE-2.0 3 | Bundle-ManifestVersion: 2 4 | Bundle-RequiredExecutionEnvironment: JavaSE-1.8 5 | Bundle-SymbolicName: com.diffplug.needsBoth 6 | Bundle-Vendor: DiffPlug 7 | Bundle-Version: 1.0.0 8 | Export-Package: needsboth;version="1.0.0" 9 | Import-Package: needs17;version="[1.0,2)",needs18;version="[1.0,2)" 10 | 11 | -------------------------------------------------------------------------------- /com.diffplug.needsBoth/build.gradle: -------------------------------------------------------------------------------- 1 | dependencies { 2 | implementation project(':com.diffplug.needs17') 3 | implementation project(':com.diffplug.needs18') 4 | } 5 | jar.manifest.attributes('-exportcontents': 'needsboth') 6 | -------------------------------------------------------------------------------- /com.diffplug.needsBoth/build.properties: -------------------------------------------------------------------------------- 1 | source.. = src/ 2 | output.. = bin/ 3 | bin.includes = META-INF/,\ 4 | . -------------------------------------------------------------------------------- /com.diffplug.needsBoth/src/needsboth/NeedsBoth.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 DiffPlug 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package needsboth; 17 | 18 | public class NeedsBoth { 19 | static DepSystem result; 20 | 21 | public static DepSystem parse(String input) { 22 | needs18.Guava18.sameThread().execute(() -> { 23 | result = needs17.Guava17.parse(DepSystem.class, input); 24 | }); 25 | return result; 26 | } 27 | 28 | public static enum DepSystem { 29 | MAVEN, P2; 30 | 31 | public boolean supportsDiamondDependencyConflicts() { 32 | switch (this) { 33 | case MAVEN: 34 | return false; 35 | case P2: 36 | return true; 37 | default: 38 | throw new IllegalArgumentException("No such dependency management system."); 39 | } 40 | } 41 | } 42 | 43 | /** This will fail with NoSuchMethodError without OSGi magic. */ 44 | public static void main(String[] args) { 45 | System.out.println(NeedsBoth.parse("MAVEN").name()); 46 | System.out.println(NeedsBoth.parse("P2").name()); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /com.diffplug.rcpdemo/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | Bundle-License: http://www.apache.org/licenses/LICENSE-2.0 3 | Bundle-ManifestVersion: 2 4 | Bundle-RequiredExecutionEnvironment: JavaSE-1.8 5 | Bundle-SymbolicName: com.diffplug.rcpdemo;singleton:=true 6 | Bundle-Vendor: DiffPlug 7 | Bundle-Version: 1.0.0 8 | Export-Package: com.diffplug.rcpdemo;uses:="org.eclipse.equinox.app,or 9 | g.eclipse.swt.widgets";version="1.0.0" 10 | Import-Package: com.diffplug.common.base;version="[1.2,2)",com.diffplu 11 | g.common.swt;version="[2.0,3)",com.diffplug.talks.rxjava_and_swt;vers 12 | ion="[1.0,2)",com.google.common.collect;version="[18.0,19)",needsboth 13 | ;version="[1.0,2)",org.eclipse.equinox.app;version="[1.1,2)",org.ecli 14 | pse.swt.graphics,org.eclipse.swt.widgets 15 | 16 | -------------------------------------------------------------------------------- /com.diffplug.rcpdemo/build.gradle: -------------------------------------------------------------------------------- 1 | def runtimeDeps = [ 2 | 'org.eclipse.osgi', 3 | 'org.eclipse.update.configurator', 4 | 'org.eclipse.equinox.ds', 5 | 'org.eclipse.equinox.registry', 6 | 'org.eclipse.core.commands', 7 | 'javax.annotation', 8 | 'javax.inject', 9 | 'org.eclipse.core.jobs', 10 | 'org.eclipse.equinox.preferences', 11 | 'org.eclipse.core.contenttype', 12 | 'org.eclipse.equinox.util', 13 | 'org.eclipse.osgi.services' 14 | ] 15 | 16 | dependencies { 17 | implementation project(':com.diffplug.needsBoth') 18 | implementation project(':com.diffplug.talks.rxjava_and_swt') 19 | 20 | implementation "eclipse-deps:com.ibm.icu:+" 21 | implementation "eclipse-deps:org.eclipse.osgi:+" 22 | implementation "eclipse-deps:org.eclipse.equinox.app:+" 23 | implementation "eclipse-deps:org.eclipse.equinox.common:+" 24 | implementation "eclipse-deps:org.eclipse.core.runtime:+" 25 | 26 | implementation "eclipse-deps:org.eclipse.swt:+" 27 | implementation "eclipse-deps:org.eclipse.jface:+" 28 | 29 | implementation "com.diffplug.durian:durian-core:${VER_DURIAN}" 30 | implementation "com.diffplug.durian:durian-collect:${VER_DURIAN}" 31 | implementation "com.diffplug.durian:durian-swt:${VER_DURIAN_SWT}" 32 | implementation "com.google.guava:guava:17.0" 33 | testImplementation "junit:junit:${VER_JUNIT}" 34 | 35 | runtimeOnly 'com.diffplug.osgi:com.diffplug.osgi.extension.sun.misc:0.0.0' 36 | runtimeDeps.each { 37 | runtimeOnly "eclipse-deps:${it}:+" 38 | } 39 | } 40 | jar.manifest.attributes('Bundle-SymbolicName': project.name + ';singleton:=true') 41 | 42 | ////////////////////// 43 | // Run headless app // 44 | ////////////////////// 45 | def codegenSetup = tasks.getByPath(':codegenSetup') 46 | def thisLaunch = codegenSetup.launchTask(project, 'thisLaunch') 47 | thisLaunch.args = ['-consoleLog', '-application', 'com.diffplug.rcpdemo.headlessapp', 'file', 'test'] 48 | -------------------------------------------------------------------------------- /com.diffplug.rcpdemo/build.properties: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Copyright (c) 2013 IBM Corporation and others. 3 | # All rights reserved. This program and the accompanying materials 4 | # are made available under the terms of the Eclipse Public License v1.0 5 | # which accompanies this distribution, and is available at 6 | # http://www.eclipse.org/legal/epl-v10.html 7 | # 8 | # Contributors: 9 | # IBM Corporation - initial API and implementation 10 | ############################################################################### 11 | output.. = bin/ 12 | bin.includes = META-INF/,\ 13 | .,\ 14 | plugin.xml,\ 15 | images/ 16 | source.. = src/ 17 | -------------------------------------------------------------------------------- /com.diffplug.rcpdemo/images/Goomph.icns: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/diffplug/gradle-and-eclipse-rcp/0c27ca32a984f8bd6b8d37b5410546d19ef442cc/com.diffplug.rcpdemo/images/Goomph.icns -------------------------------------------------------------------------------- /com.diffplug.rcpdemo/images/Goomph.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/diffplug/gradle-and-eclipse-rcp/0c27ca32a984f8bd6b8d37b5410546d19ef442cc/com.diffplug.rcpdemo/images/Goomph.ico -------------------------------------------------------------------------------- /com.diffplug.rcpdemo/images/Goomph.xpm: -------------------------------------------------------------------------------- 1 | /* XPM */ 2 | static char *graphic[] = { 3 | /* width height num_colors chars_per_pixel */ 4 | "16 16 84 1", 5 | /* colors */ 6 | " c None", 7 | ". c #899582", 8 | "X c #93A98D", 9 | "o c #CDA274", 10 | "O c #8D9989", 11 | "+ c #A8A6B3", 12 | "@ c #488D64", 13 | "# c #719E75", 14 | "$ c #5C9A6E", 15 | "% c #8B879D", 16 | "& c #70A682", 17 | "* c #70A884", 18 | "= c #96AC8E", 19 | "- c #D4E3C4", 20 | "; c #90BA8C", 21 | ": c #554D76", 22 | "> c #554A68", 23 | ", c #96BA85", 24 | "< c #918CA7", 25 | "1 c #B5D1A2", 26 | "2 c #94A98D", 27 | "3 c #5A5379", 28 | "4 c #6E9C70", 29 | "5 c #909C8C", 30 | "6 c #B3CE9F", 31 | "7 c #C7DCB5", 32 | "8 c #68A172", 33 | "9 c #372D5A", 34 | "0 c #BDD3A9", 35 | "q c #41895E", 36 | "w c #C6D9AE", 37 | "e c #6DA27D", 38 | "r c #DBE8CB", 39 | "t c #6AA383", 40 | "y c #CBDCBA", 41 | "u c #92BB94", 42 | "i c #6AA479", 43 | "p c #96BD98", 44 | "a c #7AAD7D", 45 | "s c #AD9385", 46 | "d c #2C2255", 47 | "f c #7AAE8A", 48 | "g c #3D895F", 49 | "h c #8CB072", 50 | "j c #9690AD", 51 | "k c #C4AA59", 52 | "l c #928CA8", 53 | "z c #382F5C", 54 | "x c #73A077", 55 | "c c #D4E4C3", 56 | "v c #CADBB7", 57 | "b c #ACA9B8", 58 | "n c #79AD86", 59 | "m c #55946B", 60 | "M c #A8B794", 61 | "N c #463F67", 62 | "B c #342B59", 63 | "V c #E4AE6F", 64 | "C c #9BC091", 65 | "Z c #8CB788", 66 | "A c #6D627C", 67 | "S c #86809C", 68 | "D c #A7C590", 69 | "F c #71A982", 70 | "G c #7EAF88", 71 | "H c #879185", 72 | "J c #8F8AA6", 73 | "K c #8D87A3", 74 | "L c #B4C487", 75 | "P c #2E2455", 76 | "I c #76728C", 77 | "U c #89839E", 78 | "Y c #ABC999", 79 | "T c #6EA687", 80 | "R c #599367", 81 | "E c #8A9486", 82 | "W c #A88772", 83 | "Q c #75AA7E", 84 | "! c #539265", 85 | "~ c #CFA173", 86 | "^ c #76A984", 87 | "/ c #B3CDA3", 88 | "( c #73A97D", 89 | ") c #93BC91", 90 | /* pixels */ 91 | " ", 92 | " ", 93 | " ", 94 | " s>zBN% ", 95 | " W9ddddPI ", 96 | " VA::::::3 ", 97 | " ~S 2 | 3 | 4 | 5 | 8 | 12 | 14 | 15 | 16 | 17 | 20 | 24 | 26 | 27 | 28 | 29 | 32 | 35 | 38 | 39 | 42 | 43 | 46 | 47 | 48 | 49 | 52 | 55 | 58 | 59 | 60 | 61 | 62 | 63 | -------------------------------------------------------------------------------- /com.diffplug.rcpdemo/rcpdemo.product: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -XstartOnFirstThread -Dorg.eclipse.swt.internal.carbon.smallFonts 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | -------------------------------------------------------------------------------- /com.diffplug.rcpdemo/src/com/diffplug/rcpdemo/AppGui.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 DiffPlug 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.diffplug.rcpdemo; 17 | 18 | import org.eclipse.swt.SWT; 19 | import org.eclipse.swt.graphics.RGB; 20 | import org.eclipse.swt.widgets.Button; 21 | import org.eclipse.swt.widgets.Composite; 22 | import org.eclipse.swt.widgets.Label; 23 | import org.eclipse.swt.widgets.Text; 24 | 25 | import com.google.common.collect.ImmutableMap; 26 | 27 | import com.diffplug.common.base.StringPrinter; 28 | import com.diffplug.common.swt.Coat; 29 | import com.diffplug.common.swt.CoatMux; 30 | import com.diffplug.common.swt.Fonts; 31 | import com.diffplug.common.swt.Layouts; 32 | import com.diffplug.talks.rxjava_and_swt.XkcdColorPicker; 33 | 34 | import needsboth.NeedsBoth; 35 | 36 | public class AppGui { 37 | final ImmutableMap modes = ImmutableMap.of( 38 | "xkcd color picker", cmp -> { 39 | Layouts.setFill(cmp).margin(0); 40 | new XkcdColorPicker(cmp, new RGB(0, 0, 255)); 41 | }, 42 | "needsBoth test", this::needsBoth); 43 | 44 | public AppGui(Composite wrapped) { 45 | Layouts.setGrid(wrapped); 46 | 47 | Composite header = new Composite(wrapped, SWT.NONE); 48 | Layouts.setGridData(header).grabHorizontal(); 49 | Layouts.setGrid(header).margin(0).numColumns(modes.size()); 50 | 51 | Label sep = new Label(wrapped, SWT.SEPARATOR | SWT.HORIZONTAL); 52 | Layouts.setGridData(sep).grabHorizontal(); 53 | 54 | CoatMux content = new CoatMux(wrapped); 55 | Layouts.setGridData(content).grabAll(); 56 | 57 | modes.forEach((label, coat) -> { 58 | Button button = new Button(header, SWT.RADIO); 59 | button.setText(label); 60 | button.setFont(Fonts.systemLarge()); 61 | button.addListener(SWT.Selection, e -> { 62 | if (button.getSelection()) { 63 | content.setCoat(coat, null); 64 | } 65 | }); 66 | }); 67 | } 68 | 69 | private void needsBoth(Composite parent) { 70 | Layouts.setFill(parent); 71 | Text text = new Text(parent, SWT.BORDER | SWT.MULTI | SWT.WRAP); 72 | text.setFont(Fonts.systemLarge()); 73 | text.setText(StringPrinter.buildString(printer -> { 74 | try { 75 | printer.println("Calling NeedsBoth.parse..."); 76 | printer.println("parse MAVEN: " + NeedsBoth.parse("MAVEN")); 77 | printer.println("parse P2: " + NeedsBoth.parse("P2")); 78 | } catch (Throwable e) { 79 | e.printStackTrace(printer.toPrintWriter()); 80 | } 81 | })); 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /com.diffplug.rcpdemo/src/com/diffplug/rcpdemo/Application.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 DiffPlug 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.diffplug.rcpdemo; 17 | 18 | import org.eclipse.equinox.app.IApplication; 19 | import org.eclipse.equinox.app.IApplicationContext; 20 | import org.eclipse.swt.SWT; 21 | import org.eclipse.swt.widgets.Display; 22 | 23 | import com.diffplug.common.swt.Shells; 24 | import com.diffplug.common.swt.SwtMisc; 25 | 26 | public class Application implements IApplication { 27 | @Override 28 | public Object start(IApplicationContext context) throws Exception { 29 | Display.setAppName("RCP Demo"); 30 | Shells.builder(SWT.SHELL_TRIM, AppGui::new) 31 | .setTitle("RCP Demo") 32 | .setSize(SwtMisc.scaleByFontHeight(40, 30)) 33 | .openOnDisplayBlocking(); 34 | return IApplication.EXIT_OK; 35 | } 36 | 37 | @Override 38 | public void stop() {} 39 | } 40 | -------------------------------------------------------------------------------- /com.diffplug.rcpdemo/src/com/diffplug/rcpdemo/HeadlessApp.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 DiffPlug 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.diffplug.rcpdemo; 17 | 18 | import java.util.Arrays; 19 | 20 | import org.eclipse.equinox.app.IApplication; 21 | import org.eclipse.equinox.app.IApplicationContext; 22 | 23 | public class HeadlessApp implements IApplication { 24 | @Override 25 | public Object start(IApplicationContext context) throws Exception { 26 | String[] args = (String[]) context.getArguments().get(IApplicationContext.APPLICATION_ARGS); 27 | System.out.println(Arrays.asList(args)); 28 | return IApplication.EXIT_OK; 29 | } 30 | 31 | @Override 32 | public void stop() {} 33 | } 34 | -------------------------------------------------------------------------------- /com.diffplug.rcpdemo/test/com/diffplug/rcpdemo/AppGuiTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 DiffPlug 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.diffplug.rcpdemo; 17 | 18 | import org.junit.Test; 19 | import org.junit.experimental.categories.Category; 20 | 21 | import com.diffplug.common.swt.InteractiveTest; 22 | 23 | @Category(InteractiveTest.class) 24 | public class AppGuiTest { 25 | @Test 26 | public void test() { 27 | InteractiveTest.testCoat("AppGui", AppGui::new); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /com.diffplug.talks.rxjava_and_swt/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | Bundle-License: http://www.apache.org/licenses/LICENSE-2.0 3 | Bundle-ManifestVersion: 2 4 | Bundle-RequiredExecutionEnvironment: JavaSE-1.8 5 | Bundle-SymbolicName: com.diffplug.talks.rxjava_and_swt 6 | Bundle-Vendor: DiffPlug 7 | Bundle-Version: 1.0.0 8 | Export-Package: com.diffplug.talks.rxjava_and_swt;uses:="com.diffplug. 9 | common.swt,org.eclipse.swt.graphics,org.eclipse.swt.widgets,rx";versi 10 | on="1.0.0" 11 | Import-Package: com.diffplug.common.base;version="[1.2,2)",com.diffplu 12 | g.common.collect;version="[1.2,2)",com.diffplug.common.rx;version="[2 13 | .0,3)",com.diffplug.common.swt;version="[2.0,3)",com.diffplug.common. 14 | tree;version="[1.2,2)",org.eclipse.swt.graphics,org.eclipse.swt.widge 15 | ts,rx;version="[1.1,2)",rx.functions;version="[1.1,2)" 16 | 17 | -------------------------------------------------------------------------------- /com.diffplug.talks.rxjava_and_swt/build.gradle: -------------------------------------------------------------------------------- 1 | dependencies { 2 | implementation "com.diffplug.durian:durian-core:${VER_DURIAN}" 3 | implementation "com.diffplug.durian:durian-collect:${VER_DURIAN}" 4 | implementation "com.diffplug.durian:durian-concurrent:${VER_DURIAN}" 5 | implementation "com.diffplug.durian:durian-rx:${VER_DURIAN_RX}" 6 | implementation "com.diffplug.durian:durian-swt:${VER_DURIAN_SWT}" 7 | implementation "io.reactivex:rxjava:${VER_RXJAVA}" 8 | 9 | testImplementation "junit:junit:${VER_JUNIT}" 10 | } 11 | -------------------------------------------------------------------------------- /com.diffplug.talks.rxjava_and_swt/build.properties: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Copyright (c) 2013 IBM Corporation and others. 3 | # All rights reserved. This program and the accompanying materials 4 | # are made available under the terms of the Eclipse Public License v1.0 5 | # which accompanies this distribution, and is available at 6 | # http://www.eclipse.org/legal/epl-v10.html 7 | # 8 | # Contributors: 9 | # IBM Corporation - initial API and implementation 10 | ############################################################################### 11 | output.. = bin/ 12 | source.. = src/ 13 | bin.includes = META-INF/,\ 14 | .,\ 15 | xkcd_colors.txt 16 | -------------------------------------------------------------------------------- /com.diffplug.talks.rxjava_and_swt/src/com/diffplug/talks/rxjava_and_swt/CancelIfStale.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 DiffPlug 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.diffplug.talks.rxjava_and_swt; 17 | 18 | import java.util.concurrent.CompletableFuture; 19 | import java.util.concurrent.CompletionStage; 20 | 21 | import com.diffplug.common.base.Box; 22 | import com.diffplug.common.rx.ForwardingBox; 23 | 24 | public class CancelIfStale { 25 | private final Box> box = new ForwardingBox, Box>>(Box.of(new CompletableFuture<>())) { 26 | @Override 27 | public void set(CompletionStage obj) { 28 | delegate.get().toCompletableFuture().cancel(true); 29 | delegate.set(obj); 30 | } 31 | }; 32 | 33 | public CompletionStage filter(CompletionStage obj) { 34 | box.set(obj.toCompletableFuture()); 35 | return obj; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /com.diffplug.talks.rxjava_and_swt/src/com/diffplug/talks/rxjava_and_swt/ColorComparePanel.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 DiffPlug 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.diffplug.talks.rxjava_and_swt; 17 | 18 | import org.eclipse.swt.SWT; 19 | import org.eclipse.swt.graphics.Color; 20 | import org.eclipse.swt.graphics.RGB; 21 | import org.eclipse.swt.widgets.Composite; 22 | import org.eclipse.swt.widgets.Label; 23 | import org.eclipse.swt.widgets.Text; 24 | 25 | import com.diffplug.common.swt.ControlWrapper; 26 | import com.diffplug.common.swt.Fonts; 27 | import com.diffplug.common.swt.Layouts; 28 | import com.diffplug.common.swt.SwtMisc; 29 | import com.diffplug.common.tree.TreeStream; 30 | 31 | public class ColorComparePanel extends ControlWrapper.AroundControl { 32 | 33 | private final Label swatchActual, swatchNearest; 34 | private final Text rgbActual, rgbNearest; 35 | private final Text nameNearest; 36 | 37 | public ColorComparePanel(Composite parent) { 38 | super(new Composite(parent, SWT.NONE)); 39 | Layouts.setGrid(wrapped) 40 | .numColumns(2) 41 | .columnsEqualWidth(true) 42 | .horizontalSpacing(0); 43 | swatchActual = new Label(wrapped, SWT.NONE); 44 | swatchNearest = new Label(wrapped, SWT.NONE); 45 | Layouts.setGridData(swatchActual).grabHorizontal(); 46 | Layouts.setGridData(swatchNearest).grabHorizontal(); 47 | 48 | Label actualLbl = new Label(wrapped, SWT.NONE); 49 | actualLbl.setText("Actual"); 50 | Label nearestLbl = new Label(wrapped, SWT.NONE); 51 | nearestLbl.setText("Nearest"); 52 | 53 | rgbActual = new Text(wrapped, SWT.BORDER | SWT.READ_ONLY); 54 | rgbNearest = new Text(wrapped, SWT.BORDER | SWT.READ_ONLY); 55 | Layouts.setGridData(rgbActual).grabHorizontal(); 56 | Layouts.setGridData(rgbNearest).grabHorizontal(); 57 | 58 | nameNearest = new Text(wrapped, SWT.BORDER | SWT.READ_ONLY); 59 | Layouts.setGridData(nameNearest).horizontalSpan(2).grabHorizontal(); 60 | 61 | // set all fonts to system large 62 | TreeStream.breadthFirst(SwtMisc.treeDefControl(), parent) 63 | .forEach(ctl -> ctl.setFont(Fonts.systemLarge())); 64 | 65 | rgbActual.setText(" "); 66 | rgbNearest.setText(" "); 67 | } 68 | 69 | public void setActual(RGB rgb) { 70 | swatchActual.setBackground(new Color(wrapped.getDisplay(), rgb)); 71 | rgbActual.setText(rgb.red + " " + rgb.green + " " + rgb.blue); 72 | } 73 | 74 | public void setNearest(String name, RGB rgb) { 75 | swatchNearest.setBackground(new Color(wrapped.getDisplay(), rgb)); 76 | rgbNearest.setText(rgb.red + " " + rgb.green + " " + rgb.blue); 77 | nameNearest.setText(name); 78 | } 79 | 80 | public void setNearestEmpty() { 81 | swatchNearest.setBackground(SwtMisc.getSystemColor(SWT.COLOR_WIDGET_BACKGROUND)); 82 | rgbNearest.setText(""); 83 | nameNearest.setText(""); 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /com.diffplug.talks.rxjava_and_swt/src/com/diffplug/talks/rxjava_and_swt/ColorPicker.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 DiffPlug 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.diffplug.talks.rxjava_and_swt; 17 | 18 | import org.eclipse.swt.SWT; 19 | import org.eclipse.swt.graphics.Color; 20 | import org.eclipse.swt.graphics.GC; 21 | import org.eclipse.swt.graphics.Image; 22 | import org.eclipse.swt.graphics.Point; 23 | import org.eclipse.swt.graphics.RGB; 24 | import org.eclipse.swt.widgets.Canvas; 25 | import org.eclipse.swt.widgets.Composite; 26 | import org.eclipse.swt.widgets.Display; 27 | import org.eclipse.swt.widgets.Event; 28 | 29 | import com.diffplug.common.swt.ControlWrapper; 30 | import com.diffplug.common.swt.SwtRx; 31 | 32 | import rx.Observable; 33 | 34 | /** Shows a pane of CbCr at constant Y. */ 35 | public class ColorPicker extends ControlWrapper.AroundControl implements ColorPickerApis.Reactive { 36 | int luminance = 128; 37 | 38 | final Observable mouseDown, mouseMove; 39 | 40 | public ColorPicker(Composite parent) { 41 | super(new Canvas(parent, SWT.DOUBLE_BUFFERED)); 42 | setY(128); 43 | wrapped.addListener(SWT.Paint, e -> { 44 | Point size = wrapped.getSize(); 45 | Image img = getMapFor(e.display); 46 | e.gc.drawImage(img, 0, 0, _256, _256, 0, 0, size.x, size.y); 47 | }); 48 | mouseDown = SwtRx.addListener(wrapped, SWT.MouseDown).map(this::posToColor); 49 | mouseMove = SwtRx.addListener(wrapped, SWT.MouseMove).map(this::posToColor); 50 | } 51 | 52 | private RGB posToColor(Event e) { 53 | Point size = wrapped.getSize(); 54 | int cb = limitInt(e.x * _256 / size.x); 55 | int cr = limitInt(e.y * _256 / size.y); 56 | return fromYCbCr(luminance, cb, cr); 57 | } 58 | 59 | @Override 60 | public Observable rxMouseDown() { 61 | return mouseDown; 62 | } 63 | 64 | @Override 65 | public Observable rxMouseMove() { 66 | return mouseMove; 67 | } 68 | 69 | private static final int _256 = 256; 70 | 71 | /** Sets the luminance value of the pane. */ 72 | public void setY(int y) { 73 | this.luminance = limitInt(4 * limitRound(y / 4.0)); 74 | wrapped.redraw(); 75 | } 76 | 77 | /////////////////////////////////////////////////////// 78 | // Calculate and cache CbCr map at a given luminance // 79 | /////////////////////////////////////////////////////// 80 | private int lastLuminance = -1; 81 | private Image lastImage; 82 | 83 | private Image getMapFor(Display display) { 84 | if (luminance == lastLuminance) { 85 | return lastImage; 86 | } 87 | if (lastImage != null) { 88 | lastImage.dispose(); 89 | } 90 | lastLuminance = luminance; 91 | lastImage = new Image(display, _256, _256); 92 | GC gc = new GC(lastImage); 93 | for (int x = 0; x < _256; ++x) { 94 | for (int y = 0; y < _256; ++y) { 95 | RGB rgb = fromYCbCr(new RGB(luminance, x, y)); 96 | gc.setForeground(new Color(display, rgb)); 97 | gc.drawPoint(x, y); 98 | } 99 | } 100 | gc.dispose(); 101 | return lastImage; 102 | } 103 | 104 | //////////////////// 105 | // RGB <--> YCrCb // 106 | //////////////////// 107 | /** Converts an RGB value to YCrCb. */ 108 | public static RGB toYCbCr(RGB rgb) { 109 | return toYCbCr(rgb.red, rgb.green, rgb.blue); 110 | } 111 | 112 | /** Converts an RGB value to YCrCb. */ 113 | public static RGB toYCbCr(double r, double g, double b) { 114 | int y = limitRound(0.299 * r + 0.587 * g + 0.114 * b); 115 | int cb = limitRound(128 - 0.168736 * r - 0.331264 * g + 0.5 * b); 116 | int cr = limitRound(128 + 0.5 * r - 0.418688 * g - 0.081312 * b); 117 | return new RGB(y, cb, cr); 118 | } 119 | 120 | /** Converts a YCrCb value to RGB. */ 121 | public static RGB fromYCbCr(RGB YCbCr) { 122 | return fromYCbCr(YCbCr.red, YCbCr.green, YCbCr.blue); 123 | } 124 | 125 | /** Converts a YCrCb value to RGB. */ 126 | public static RGB fromYCbCr(double y, double cb, double cr) { 127 | int r = limitRound(y + 1.402 * (cr - 128)); 128 | int g = limitRound(y - 0.34414 * (cb - 128) - 0.71414 * (cr - 128)); 129 | int b = limitRound(y + 1.772 * (cb - 128)); 130 | return new RGB(r, g, b); 131 | } 132 | 133 | /** Rounds and limits to the range 0-255. */ 134 | private static int limitRound(double value) { 135 | return limitInt((int) Math.round(value)); 136 | } 137 | 138 | /** Limits to the range 0-255. */ 139 | private static int limitInt(int value) { 140 | if (value < 0) { 141 | return 0; 142 | } else if (value > 255) { 143 | return 255; 144 | } else { 145 | return value; 146 | } 147 | } 148 | } 149 | -------------------------------------------------------------------------------- /com.diffplug.talks.rxjava_and_swt/src/com/diffplug/talks/rxjava_and_swt/ColorPickerApis.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 DiffPlug 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.diffplug.talks.rxjava_and_swt; 17 | 18 | import org.eclipse.swt.graphics.RGB; 19 | import org.eclipse.swt.widgets.Listener; 20 | 21 | import rx.Observable; 22 | 23 | // @formatter:off 24 | // to keep the spacing tight for the slides 25 | public interface ColorPickerApis { 26 | public interface ExposeDetails { 27 | /** Adds the given listener to the color canvas (MouseMove, MouseDown, etc). */ 28 | void addListener(int eventType, Listener listener); 29 | /** Converts a coordinate to an RGB value. */ 30 | RGB toColor(int x, int y); 31 | } 32 | 33 | public interface CustomEventListenerPair { 34 | public class ColorEvent { 35 | RGB color; 36 | } 37 | public interface ColorListener { 38 | void handle(ColorEvent event); 39 | } 40 | void addMouseMoveListener(ColorListener listener); 41 | void addMouseDownListener(ColorListener listener); 42 | } 43 | 44 | public interface Reactive { 45 | Observable rxMouseMove(); 46 | Observable rxMouseDown(); 47 | } 48 | } 49 | // @formatter:on 50 | -------------------------------------------------------------------------------- /com.diffplug.talks.rxjava_and_swt/src/com/diffplug/talks/rxjava_and_swt/XkcdColorPicker.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 DiffPlug 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.diffplug.talks.rxjava_and_swt; 17 | 18 | import org.eclipse.swt.SWT; 19 | import org.eclipse.swt.graphics.RGB; 20 | import org.eclipse.swt.widgets.Composite; 21 | import org.eclipse.swt.widgets.Group; 22 | import org.eclipse.swt.widgets.Scale; 23 | 24 | import com.diffplug.common.rx.Rx; 25 | import com.diffplug.common.rx.RxBox; 26 | import com.diffplug.common.swt.ControlWrapper; 27 | import com.diffplug.common.swt.Layouts; 28 | import com.diffplug.common.swt.SwtExec; 29 | 30 | import rx.Observable; 31 | 32 | public class XkcdColorPicker extends ControlWrapper.AroundControl { 33 | public XkcdColorPicker(Composite parent, RGB initRGB) { 34 | super(new Composite(parent, SWT.NONE)); 35 | RGB initYCbCr = ColorPicker.toYCbCr(initRGB); 36 | 37 | // create a scale and bind it to an RxBox 38 | RxBox luminance = RxBox.of(initYCbCr.red); 39 | 40 | // colorpanel in the center 41 | ColorPicker cbcrPanel = new ColorPicker(wrapped); 42 | Rx.subscribe(luminance, cbcrPanel::setY); 43 | 44 | // controls at the right 45 | Composite rightCmp = new Composite(wrapped, SWT.NONE); 46 | 47 | // scale below 48 | Scale scale = new Scale(wrapped, SWT.HORIZONTAL); 49 | scale.setMinimum(0); 50 | scale.setMaximum(255); 51 | Rx.subscribe(luminance, scale::setSelection); 52 | scale.addListener(SWT.Selection, e -> { 53 | luminance.set(scale.getSelection()); 54 | }); 55 | 56 | Layouts.setGrid(wrapped).numColumns(2); 57 | Layouts.setGridData(cbcrPanel).grabAll(); 58 | Layouts.setGridData(rightCmp).grabVertical().verticalSpan(2); 59 | Layouts.setGridData(scale).grabHorizontal(); 60 | 61 | // populate the bottom 62 | Layouts.setGrid(rightCmp).margin(0); 63 | XkcdColors.Lookup xkcdLookup = new XkcdColors.Lookup(rightCmp); 64 | 65 | Group hoverGrp = new Group(rightCmp, SWT.SHADOW_ETCHED_IN); 66 | hoverGrp.setText("Hover"); 67 | createGroup(hoverGrp, cbcrPanel.rxMouseMove(), xkcdLookup); 68 | 69 | Group clickGrp = new Group(rightCmp, SWT.SHADOW_ETCHED_IN); 70 | clickGrp.setText("Click"); 71 | createGroup(clickGrp, cbcrPanel.rxMouseDown(), xkcdLookup); 72 | } 73 | 74 | private void createGroup(Composite parent, Observable rxRgb, XkcdColors.Lookup xkcdLookup) { 75 | Layouts.setFill(parent); 76 | ColorComparePanel colorCompare = new ColorComparePanel(parent); 77 | CancelIfStale cancelling = new CancelIfStale(); 78 | 79 | SwtExec.Guarded guarded = SwtExec.async().guardOn(parent); 80 | guarded.subscribe(rxRgb, rgb -> { 81 | // set raw 82 | colorCompare.setActual(rgb); 83 | // clear empty, then start to look for the answer 84 | guarded.subscribe(cancelling.filter(xkcdLookup.get(rgb)), entry -> { 85 | colorCompare.setNearest(entry.getKey(), entry.getValue()); 86 | }); 87 | }); 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /com.diffplug.talks.rxjava_and_swt/src/com/diffplug/talks/rxjava_and_swt/XkcdColors.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 DiffPlug 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.diffplug.talks.rxjava_and_swt; 17 | 18 | import java.io.BufferedReader; 19 | import java.io.IOException; 20 | import java.io.InputStream; 21 | import java.io.InputStreamReader; 22 | import java.net.URL; 23 | import java.nio.charset.StandardCharsets; 24 | import java.util.Collection; 25 | import java.util.Comparator; 26 | import java.util.HashMap; 27 | import java.util.Map; 28 | import java.util.Optional; 29 | import java.util.concurrent.CompletableFuture; 30 | import java.util.concurrent.CompletionStage; 31 | import java.util.concurrent.ExecutorService; 32 | import java.util.concurrent.Executors; 33 | 34 | import org.eclipse.swt.SWT; 35 | import org.eclipse.swt.graphics.RGB; 36 | import org.eclipse.swt.widgets.Widget; 37 | 38 | import com.diffplug.common.base.Errors; 39 | import com.diffplug.common.collect.Maps; 40 | 41 | /** 42 | * Represents the name to RGB mapping which was generated by the 43 | * XKCD 44 | * color mapping. 45 | */ 46 | public class XkcdColors { 47 | /** Loads an instance of the colors. */ 48 | public static XkcdColors load() { 49 | URL url = XkcdColors.class.getResource("/xkcd_colors.txt"); 50 | return Errors.rethrow().get(() -> new XkcdColors(url)); 51 | } 52 | 53 | private final Map colors = new HashMap<>(1024); 54 | 55 | private XkcdColors(URL url) throws IOException { 56 | try (InputStream stream = url.openStream(); 57 | BufferedReader reader = new BufferedReader(new InputStreamReader(stream, StandardCharsets.UTF_8));) { 58 | String line = reader.readLine(); 59 | while (line != null) { 60 | if (!line.startsWith("#")) { 61 | int idx = line.indexOf('\t'); 62 | String name = line.substring(0, idx); 63 | String hex = line.substring(idx + 1); 64 | colors.put(name, parse(hex)); 65 | } 66 | line = reader.readLine(); 67 | } 68 | } 69 | } 70 | 71 | /** Parses an RGB value from a hex value (e.g. {@code ff0010}). */ 72 | static RGB parse(String hex) { 73 | return new RGB( 74 | Integer.valueOf(hex.substring(0, 2), 16), 75 | Integer.valueOf(hex.substring(2, 4), 16), 76 | Integer.valueOf(hex.substring(4, 6), 16)); 77 | } 78 | 79 | /** Returns an RGB triplet which matches the given color name, if it matches any name. */ 80 | public Optional rgbForName(String name) { 81 | return Optional.ofNullable(colors.get(name)); 82 | } 83 | 84 | /** Returns the color name closest to the given RGB triplet (eventually...). */ 85 | public Collection> all() { 86 | return colors.entrySet(); 87 | } 88 | 89 | public static class Lookup { 90 | final XkcdColors colors = load(); 91 | final ExecutorService executor; 92 | 93 | public Lookup(Widget lifecycle) { 94 | this.executor = Executors.newSingleThreadExecutor(); 95 | lifecycle.addListener(SWT.Dispose, e -> { 96 | executor.shutdown(); 97 | }); 98 | } 99 | 100 | /** Returns the XkcdColor which is closest to the given RGB. */ 101 | public CompletionStage> get(RGB rgb) { 102 | return CompletableFuture.supplyAsync(() -> closestTo(rgb), executor); 103 | } 104 | 105 | /** Iterates over all XkcdColor entries to find the closest color by brute-force. */ 106 | private Map.Entry closestTo(RGB rgb) { 107 | Errors.log().run(() -> Thread.sleep(10)); 108 | return colors.all().stream() 109 | .map(entry -> Maps.immutableEntry(distance(entry.getValue(), rgb), entry)) 110 | .min(Comparator.comparing(Map.Entry::getKey)) 111 | .get().getValue(); 112 | } 113 | 114 | /** Computes the distance-squared between the two colors. */ 115 | private static int distance(RGB a, RGB b) { 116 | int deltaR = a.red - b.red; 117 | int deltaG = a.green - b.green; 118 | int deltaB = a.blue - b.blue; 119 | return (deltaR * deltaR) + deltaG * deltaG + deltaB * deltaB; 120 | } 121 | } 122 | } 123 | -------------------------------------------------------------------------------- /com.diffplug.talks.rxjava_and_swt/test/com/diffplug/talks/rxjava_and_swt/ColorPickerTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 DiffPlug 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.diffplug.talks.rxjava_and_swt; 17 | 18 | import org.eclipse.swt.SWT; 19 | import org.eclipse.swt.widgets.Scale; 20 | import org.junit.Test; 21 | import org.junit.experimental.categories.Category; 22 | 23 | import com.diffplug.common.swt.InteractiveTest; 24 | import com.diffplug.common.swt.Layouts; 25 | 26 | @Category(InteractiveTest.class) 27 | public class ColorPickerTest { 28 | @Test 29 | public void testControl() { 30 | InteractiveTest.testCoat("Should show the YCbCr plane at various values of Y", cmp -> { 31 | Layouts.setGrid(cmp); 32 | 33 | Scale scale = new Scale(cmp, SWT.HORIZONTAL); 34 | scale.setMinimum(0); 35 | scale.setMaximum(255); 36 | scale.setSelection(128); 37 | Layouts.setGridData(scale).grabHorizontal(); 38 | 39 | ColorPicker colors = new ColorPicker(cmp); 40 | Layouts.setGridData(colors).grabAll(); 41 | 42 | scale.addListener(SWT.Selection, e -> { 43 | colors.setY(scale.getSelection()); 44 | }); 45 | }); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /com.diffplug.talks.rxjava_and_swt/test/com/diffplug/talks/rxjava_and_swt/XkcdColorPickerTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 DiffPlug 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.diffplug.talks.rxjava_and_swt; 17 | 18 | import org.eclipse.swt.graphics.RGB; 19 | import org.junit.Test; 20 | import org.junit.experimental.categories.Category; 21 | 22 | import com.diffplug.common.swt.InteractiveTest; 23 | import com.diffplug.common.swt.Layouts; 24 | 25 | @Category(InteractiveTest.class) 26 | public class XkcdColorPickerTest { 27 | /** Feature for picking colors. */ 28 | @Test 29 | public void colorPicker() { 30 | final int SCALE = 4; 31 | InteractiveTest.testCoat("Selects colors using XKCD color survey data.", 16 * SCALE, 9 * SCALE, cmp -> { 32 | Layouts.setFill(cmp).margin(0); 33 | new XkcdColorPicker(cmp, new RGB(100, 50, 150)); 34 | }); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /com.diffplug.talks.rxjava_and_swt/test/com/diffplug/talks/rxjava_and_swt/XkcdColorsTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 DiffPlug 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.diffplug.talks.rxjava_and_swt; 17 | 18 | import java.util.Optional; 19 | 20 | import org.eclipse.swt.graphics.RGB; 21 | import org.junit.Assert; 22 | import org.junit.Test; 23 | 24 | public class XkcdColorsTest { 25 | @Test 26 | public void parse() { 27 | parseCase("ff0000", 255, 0, 0); 28 | parseCase("00ff00", 0, 255, 0); 29 | parseCase("0000ff", 0, 0, 255); 30 | parseCase("ff0101", 255, 1, 1); 31 | parseCase("01ff01", 1, 255, 1); 32 | parseCase("0101ff", 1, 1, 255); 33 | } 34 | 35 | private void parseCase(String hex, int r, int g, int b) { 36 | RGB actual = XkcdColors.parse(hex); 37 | RGB expected = new RGB(r, g, b); 38 | Assert.assertEquals(expected, actual); 39 | } 40 | 41 | XkcdColors xkcd = XkcdColors.load(); 42 | 43 | @Test 44 | public void load() { 45 | loadCaseEmpty("xkdkdjsdf"); 46 | loadCase("purple", 126, 30, 156); 47 | } 48 | 49 | private void loadCase(String name, int r, int g, int b) { 50 | loadCase(name, Optional.of(new RGB(r, g, b))); 51 | } 52 | 53 | private void loadCaseEmpty(String name) { 54 | loadCase(name, Optional.empty()); 55 | } 56 | 57 | private void loadCase(String name, Optional expected) { 58 | Optional actual = xkcd.rgbForName(name); 59 | Assert.assertEquals(expected, actual); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /com.diffplug.talks.rxjava_and_swt/test/com/diffplug/talks/rxjava_and_swt/YCbCrTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 DiffPlug 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.diffplug.talks.rxjava_and_swt; 17 | 18 | import org.eclipse.swt.graphics.RGB; 19 | import org.junit.Assert; 20 | import org.junit.Test; 21 | 22 | public class YCbCrTest { 23 | @Test 24 | /** Round trip every RGB color through the YCbCr color space. */ 25 | public void roundTrip() { 26 | for (int r = 0; r < 255; ++r) { 27 | for (int g = 0; g < 255; ++g) { 28 | for (int b = 0; b < 255; ++b) { 29 | roundTripTestCase(r, g, b); 30 | } 31 | } 32 | } 33 | } 34 | 35 | private void roundTripTestCase(int r, int g, int b) { 36 | RGB expected = new RGB(r, g, b); 37 | RGB yCbCr = ColorPicker.toYCbCr(expected); 38 | RGB roundTrip = ColorPicker.fromYCbCr(yCbCr); 39 | if (!expected.equals(roundTrip)) { 40 | // if they don't match exactly, allow a maximum delta of 1 for rounding errors 41 | int deltaR = Math.abs(roundTrip.red - expected.red); 42 | int deltaG = Math.abs(roundTrip.green - expected.green); 43 | int deltaB = Math.abs(roundTrip.blue - expected.blue); 44 | int maxDelta = Math.max(Math.max(deltaR, deltaG), deltaB); 45 | Assert.assertTrue(maxDelta <= 1); 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /com.diffplug.talks.rxjava_and_swt/test/com/diffplug/talks/rxjava_and_swt/examples/EventVsFrp.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 DiffPlug 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.diffplug.talks.rxjava_and_swt.examples; 17 | 18 | import org.eclipse.swt.SWT; 19 | import org.eclipse.swt.widgets.Event; 20 | import org.eclipse.swt.widgets.Widget; 21 | import org.junit.Test; 22 | 23 | import com.diffplug.common.swt.SwtRx; 24 | import com.diffplug.common.swt.jface.Actions; 25 | 26 | import rx.Observable; 27 | 28 | public class EventVsFrp { 29 | @Test(expected = ClassCastException.class) 30 | public void eventBased() { 31 | Widget widget = (Widget) new Object(); 32 | widget.addListener(SWT.KeyDown, e -> { 33 | // this is our chance to react 34 | System.out.println("keyCode=" + e.keyCode); 35 | // this is how we do filtering 36 | if (e.keyCode == 'q') { 37 | System.out.println("user wants to leave talk"); 38 | } 39 | // this is how we do mapping 40 | int accel = e.keyCode | e.stateMask; 41 | String keyPress = Actions.getAcceleratorString(accel); 42 | System.out.println(keyPress); 43 | }); 44 | } 45 | 46 | @Test(expected = ClassCastException.class) 47 | public void frpBased() { 48 | Widget widget = (Widget) new Object(); 49 | Observable keyDownStream = SwtRx.addListener(widget, SWT.KeyDown); 50 | keyDownStream.subscribe(e -> { 51 | // this is our chance to react 52 | System.out.println("keyCode=" + e.keyCode); 53 | }); 54 | // this is how we do filtering 55 | keyDownStream.filter(e -> e.keyCode == 'q').subscribe(e -> { 56 | System.out.println("user wants to leave talk"); 57 | }); 58 | // this is how we do mapping 59 | keyDownStream.map(e -> e.keyCode | e.stateMask).subscribe(accel -> { 60 | System.out.println(Actions.getAcceleratorString(accel)); 61 | }); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /com.diffplug.talks.rxjava_and_swt/test/com/diffplug/talks/rxjava_and_swt/examples/EventVsFrpOneWay.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 DiffPlug 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.diffplug.talks.rxjava_and_swt.examples; 17 | 18 | import org.eclipse.swt.SWT; 19 | import org.eclipse.swt.widgets.Composite; 20 | import org.eclipse.swt.widgets.Label; 21 | import org.eclipse.swt.widgets.Text; 22 | import org.junit.Test; 23 | import org.junit.experimental.categories.Category; 24 | 25 | import com.diffplug.common.base.Either; 26 | import com.diffplug.common.rx.Rx; 27 | import com.diffplug.common.swt.InteractiveTest; 28 | import com.diffplug.common.swt.Layouts; 29 | import com.diffplug.common.swt.SwtRx; 30 | 31 | import rx.Observable; 32 | import rx.subjects.BehaviorSubject; 33 | 34 | @Category(InteractiveTest.class) 35 | public class EventVsFrpOneWay { 36 | public static abstract class IntValue { 37 | final Text inputField; 38 | final Label outputField; 39 | 40 | public IntValue(Composite parent, int initialValue) { 41 | inputField = new Text(parent, SWT.BORDER | SWT.SINGLE); 42 | outputField = new Label(parent, SWT.NONE); 43 | 44 | inputField.setText(Integer.toString(initialValue)); 45 | outputField.setText(msgForValue(initialValue)); 46 | 47 | Layouts.setGrid(parent); 48 | Layouts.setGridData(inputField).grabHorizontal(); 49 | Layouts.setGridData(outputField).grabHorizontal(); 50 | } 51 | 52 | protected String msgForValue(int value) { 53 | return "Value = " + value; 54 | } 55 | 56 | protected String msgForError(Exception error) { 57 | return "Error = " + error.getMessage(); 58 | } 59 | } 60 | 61 | public static class EventBased extends IntValue { 62 | public EventBased(Composite parent, int initialValue) { 63 | super(parent, initialValue); 64 | inputField.addListener(SWT.Modify, e -> { 65 | try { 66 | int parsed = Integer.parseInt(inputField.getText()); 67 | outputField.setText(msgForValue(parsed)); 68 | } catch (Exception error) { 69 | outputField.setText(msgForError(error)); 70 | } 71 | }); 72 | } 73 | } 74 | 75 | public static class FrpBased extends IntValue { 76 | public FrpBased(Composite parent, int initialValue) { 77 | super(parent, initialValue); 78 | BehaviorSubject value = BehaviorSubject.create(initialValue); 79 | inputField.addListener(SWT.Modify, e -> { 80 | try { 81 | int parsed = Integer.parseInt(inputField.getText()); 82 | value.onNext(parsed); 83 | } catch (Exception error) { 84 | outputField.setText(msgForError(error)); 85 | } 86 | }); 87 | // react to the change 88 | Rx.subscribe(value.map(this::msgForValue), outputField::setText); 89 | } 90 | } 91 | 92 | public static class PureFrpBased extends IntValue { 93 | public PureFrpBased(Composite parent, int initialValue) { 94 | super(parent, initialValue); 95 | Observable> observable = SwtRx.addListener(inputField, SWT.Modify).map(event -> { 96 | try { 97 | return Either.createLeft(Integer.parseInt(inputField.getText())); 98 | } catch (Exception error) { 99 | return Either.createRight(error); 100 | } 101 | }); 102 | Rx.subscribe(observable, either -> { 103 | String msg = either.fold(this::msgForValue, this::msgForError); 104 | outputField.setText(msg); 105 | }); 106 | } 107 | } 108 | 109 | @Test 110 | public void eventBased() { 111 | InteractiveTest.testCoat("Event-based example", 20, 0, cmp -> { 112 | new EventBased(cmp, 0); 113 | }); 114 | } 115 | 116 | @Test 117 | public void frpBased() { 118 | InteractiveTest.testCoat("FRP-based example", 20, 0, cmp -> { 119 | new FrpBased(cmp, 0); 120 | }); 121 | } 122 | 123 | @Test 124 | public void pureFrpBased() { 125 | InteractiveTest.testCoat("Pure FRP-based example", 20, 0, cmp -> { 126 | new FrpBased(cmp, 0); 127 | }); 128 | } 129 | } 130 | -------------------------------------------------------------------------------- /com.diffplug.talks.rxjava_and_swt/test/com/diffplug/talks/rxjava_and_swt/examples/EventVsFrpTwoWay.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 DiffPlug 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.diffplug.talks.rxjava_and_swt.examples; 17 | 18 | import org.eclipse.swt.SWT; 19 | import org.eclipse.swt.graphics.Point; 20 | import org.eclipse.swt.widgets.Composite; 21 | import org.eclipse.swt.widgets.Label; 22 | import org.eclipse.swt.widgets.Scale; 23 | import org.eclipse.swt.widgets.Text; 24 | import org.junit.Test; 25 | import org.junit.experimental.categories.Category; 26 | 27 | import com.diffplug.common.rx.Rx; 28 | import com.diffplug.common.rx.RxBox; 29 | import com.diffplug.common.swt.InteractiveTest; 30 | import com.diffplug.common.swt.Layouts; 31 | import com.diffplug.common.swt.SwtRx; 32 | 33 | import rx.subjects.BehaviorSubject; 34 | 35 | @Category(InteractiveTest.class) 36 | public class EventVsFrpTwoWay { 37 | 38 | public static abstract class IntValue { 39 | final Text inputField; 40 | final Label outputField; 41 | final Scale scale; 42 | 43 | public IntValue(Composite parent, int initialValue) { 44 | inputField = new Text(parent, SWT.BORDER | SWT.SINGLE); 45 | outputField = new Label(parent, SWT.NONE); 46 | scale = new Scale(parent, SWT.HORIZONTAL); 47 | 48 | inputField.setText(Integer.toString(initialValue)); 49 | outputField.setText(msgForValue(initialValue)); 50 | scale.setMinimum(0); 51 | scale.setMaximum(100); 52 | scale.setSelection(initialValue); 53 | 54 | Layouts.setGrid(parent); 55 | Layouts.setGridData(inputField).grabHorizontal(); 56 | Layouts.setGridData(outputField).grabHorizontal(); 57 | Layouts.setGridData(scale).grabHorizontal(); 58 | } 59 | 60 | protected String msgForValue(int value) { 61 | return "Value = " + value; 62 | } 63 | 64 | protected String msgForError(Exception error) { 65 | return "Error = " + error.getMessage(); 66 | } 67 | } 68 | 69 | public static class EventBased extends IntValue { 70 | int value; 71 | 72 | public EventBased(Composite parent, int initialValue) { 73 | super(parent, initialValue); 74 | this.value = initialValue; 75 | inputField.addListener(SWT.Modify, e -> { 76 | try { 77 | int parsed = Integer.parseInt(inputField.getText()); 78 | setValue(parsed); 79 | } catch (Exception error) { 80 | outputField.setText(msgForError(error)); 81 | } 82 | }); 83 | 84 | scale.addListener(SWT.Selection, e -> { 85 | setValue(scale.getSelection()); 86 | }); 87 | } 88 | 89 | public void setValue(int value) { 90 | if (this.value != value) { 91 | this.value = value; 92 | Point caretPos = inputField.getSelection(); 93 | inputField.setText(Integer.toString(value)); 94 | inputField.setSelection(caretPos); 95 | outputField.setText(msgForValue(value)); 96 | scale.setSelection(value); 97 | } 98 | } 99 | 100 | public int getValue() { 101 | return value; 102 | } 103 | 104 | public void addValueListener(Object yetAnotherType) { 105 | // how many listeners will it take!! 106 | } 107 | } 108 | 109 | /** Small modification which keeps it working better. */ 110 | public static class FrpBased extends IntValue { 111 | final BehaviorSubject value; 112 | 113 | public FrpBased(Composite parent, int initialValue) { 114 | super(parent, initialValue); 115 | value = BehaviorSubject.create(initialValue); 116 | RxBox rwText = SwtRx.textImmediate(inputField); 117 | Rx.subscribe(rwText, text -> { 118 | try { 119 | int parsed = Integer.parseInt(text); 120 | value.onNext(parsed); 121 | } catch (Exception error) { 122 | outputField.setText(msgForError(error)); 123 | } 124 | }); 125 | scale.addListener(SWT.Selection, e -> { 126 | value.onNext(scale.getSelection()); 127 | }); 128 | Rx.subscribe(value.map(Object::toString), rwText::set); 129 | Rx.subscribe(value.map(this::msgForValue), outputField::setText); 130 | Rx.subscribe(value, scale::setSelection); 131 | } 132 | 133 | public BehaviorSubject rwValue() { 134 | return value; 135 | } 136 | } 137 | 138 | @Test 139 | public void eventBased() { 140 | InteractiveTest.testCoat("Event-based example", 20, 0, cmp -> { 141 | new EventBased(cmp, 10); 142 | }); 143 | } 144 | 145 | @Test 146 | public void frpBased() { 147 | InteractiveTest.testCoat("FRP-based example", 20, 0, cmp -> { 148 | new FrpBased(cmp, 10); 149 | }); 150 | } 151 | } 152 | -------------------------------------------------------------------------------- /com.diffplug.talks.rxjava_and_swt/test/com/diffplug/talks/rxjava_and_swt/examples/Scratch.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 DiffPlug 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.diffplug.talks.rxjava_and_swt.examples; 17 | 18 | import com.diffplug.common.swt.SwtExec; 19 | 20 | import rx.Subscription; 21 | 22 | // @formatter:off 23 | public class Scratch { 24 | public interface Observable { 25 | Subscription subscribe(Observer observer); 26 | } 27 | 28 | public interface Observer { 29 | /** Gets called 0 to infinity times. */ 30 | void onNext(T t); 31 | void onComplete(); 32 | void onError(Throwable e); 33 | } 34 | 35 | public static void main(String[] args) { 36 | SwtExec.async(); 37 | SwtExec.blocking(); 38 | SwtExec.immediate(); 39 | } 40 | } 41 | // @formatter:on 42 | -------------------------------------------------------------------------------- /com.diffplug.talks.rxjava_and_swt/xkcd_colors.txt: -------------------------------------------------------------------------------- 1 | # License: http://creativecommons.org/publicdomain/zero/1.0/ 2 | cloudy blue acc2d9 3 | dark pastel green 56ae57 4 | dust b2996e 5 | electric lime a8ff04 6 | fresh green 69d84f 7 | light eggplant 894585 8 | nasty green 70b23f 9 | really light blue d4ffff 10 | tea 65ab7c 11 | warm purple 952e8f 12 | yellowish tan fcfc81 13 | cement a5a391 14 | dark grass green 388004 15 | dusty teal 4c9085 16 | grey teal 5e9b8a 17 | macaroni and cheese efb435 18 | pinkish tan d99b82 19 | spruce 0a5f38 20 | strong blue 0c06f7 21 | toxic green 61de2a 22 | windows blue 3778bf 23 | blue blue 2242c7 24 | blue with a hint of purple 533cc6 25 | booger 9bb53c 26 | bright sea green 05ffa6 27 | dark green blue 1f6357 28 | deep turquoise 017374 29 | green teal 0cb577 30 | strong pink ff0789 31 | bland afa88b 32 | deep aqua 08787f 33 | lavender pink dd85d7 34 | light moss green a6c875 35 | light seafoam green a7ffb5 36 | olive yellow c2b709 37 | pig pink e78ea5 38 | deep lilac 966ebd 39 | desert ccad60 40 | dusty lavender ac86a8 41 | purpley grey 947e94 42 | purply 983fb2 43 | candy pink ff63e9 44 | light pastel green b2fba5 45 | boring green 63b365 46 | kiwi green 8ee53f 47 | light grey green b7e1a1 48 | orange pink ff6f52 49 | tea green bdf8a3 50 | very light brown d3b683 51 | egg shell fffcc4 52 | eggplant purple 430541 53 | powder pink ffb2d0 54 | reddish grey 997570 55 | baby shit brown ad900d 56 | liliac c48efd 57 | stormy blue 507b9c 58 | ugly brown 7d7103 59 | custard fffd78 60 | darkish pink da467d 61 | deep brown 410200 62 | greenish beige c9d179 63 | manilla fffa86 64 | off blue 5684ae 65 | battleship grey 6b7c85 66 | browny green 6f6c0a 67 | bruise 7e4071 68 | kelley green 009337 69 | sickly yellow d0e429 70 | sunny yellow fff917 71 | azul 1d5dec 72 | darkgreen 054907 73 | green/yellow b5ce08 74 | lichen 8fb67b 75 | light light green c8ffb0 76 | pale gold fdde6c 77 | sun yellow ffdf22 78 | tan green a9be70 79 | burple 6832e3 80 | butterscotch fdb147 81 | toupe c7ac7d 82 | dark cream fff39a 83 | indian red 850e04 84 | light lavendar efc0fe 85 | poison green 40fd14 86 | baby puke green b6c406 87 | bright yellow green 9dff00 88 | charcoal grey 3c4142 89 | squash f2ab15 90 | cinnamon ac4f06 91 | light pea green c4fe82 92 | radioactive green 2cfa1f 93 | raw sienna 9a6200 94 | baby purple ca9bf7 95 | cocoa 875f42 96 | light royal blue 3a2efe 97 | orangeish fd8d49 98 | rust brown 8b3103 99 | sand brown cba560 100 | swamp 698339 101 | tealish green 0cdc73 102 | burnt siena b75203 103 | camo 7f8f4e 104 | dusk blue 26538d 105 | fern 63a950 106 | old rose c87f89 107 | pale light green b1fc99 108 | peachy pink ff9a8a 109 | rosy pink f6688e 110 | light bluish green 76fda8 111 | light bright green 53fe5c 112 | light neon green 4efd54 113 | light seafoam a0febf 114 | tiffany blue 7bf2da 115 | washed out green bcf5a6 116 | browny orange ca6b02 117 | nice blue 107ab0 118 | sapphire 2138ab 119 | greyish teal 719f91 120 | orangey yellow fdb915 121 | parchment fefcaf 122 | straw fcf679 123 | very dark brown 1d0200 124 | terracota cb6843 125 | ugly blue 31668a 126 | clear blue 247afd 127 | creme ffffb6 128 | foam green 90fda9 129 | grey/green 86a17d 130 | light gold fddc5c 131 | seafoam blue 78d1b6 132 | topaz 13bbaf 133 | violet pink fb5ffc 134 | wintergreen 20f986 135 | yellow tan ffe36e 136 | dark fuchsia 9d0759 137 | indigo blue 3a18b1 138 | light yellowish green c2ff89 139 | pale magenta d767ad 140 | rich purple 720058 141 | sunflower yellow ffda03 142 | green/blue 01c08d 143 | leather ac7434 144 | racing green 014600 145 | vivid purple 9900fa 146 | dark royal blue 02066f 147 | hazel 8e7618 148 | muted pink d1768f 149 | booger green 96b403 150 | canary fdff63 151 | cool grey 95a3a6 152 | dark taupe 7f684e 153 | darkish purple 751973 154 | true green 089404 155 | coral pink ff6163 156 | dark sage 598556 157 | dark slate blue 214761 158 | flat blue 3c73a8 159 | mushroom ba9e88 160 | rich blue 021bf9 161 | dirty purple 734a65 162 | greenblue 23c48b 163 | icky green 8fae22 164 | light khaki e6f2a2 165 | warm blue 4b57db 166 | dark hot pink d90166 167 | deep sea blue 015482 168 | carmine 9d0216 169 | dark yellow green 728f02 170 | pale peach ffe5ad 171 | plum purple 4e0550 172 | golden rod f9bc08 173 | neon red ff073a 174 | old pink c77986 175 | very pale blue d6fffe 176 | blood orange fe4b03 177 | grapefruit fd5956 178 | sand yellow fce166 179 | clay brown b2713d 180 | dark blue grey 1f3b4d 181 | flat green 699d4c 182 | light green blue 56fca2 183 | warm pink fb5581 184 | dodger blue 3e82fc 185 | gross green a0bf16 186 | ice d6fffa 187 | metallic blue 4f738e 188 | pale salmon ffb19a 189 | sap green 5c8b15 190 | algae 54ac68 191 | bluey grey 89a0b0 192 | greeny grey 7ea07a 193 | highlighter green 1bfc06 194 | light light blue cafffb 195 | light mint b6ffbb 196 | raw umber a75e09 197 | vivid blue 152eff 198 | deep lavender 8d5eb7 199 | dull teal 5f9e8f 200 | light greenish blue 63f7b4 201 | mud green 606602 202 | pinky fc86aa 203 | red wine 8c0034 204 | shit green 758000 205 | tan brown ab7e4c 206 | darkblue 030764 207 | rosa fe86a4 208 | lipstick d5174e 209 | pale mauve fed0fc 210 | claret 680018 211 | dandelion fedf08 212 | orangered fe420f 213 | poop green 6f7c00 214 | ruby ca0147 215 | dark 1b2431 216 | greenish turquoise 00fbb0 217 | pastel red db5856 218 | piss yellow ddd618 219 | bright cyan 41fdfe 220 | dark coral cf524e 221 | algae green 21c36f 222 | darkish red a90308 223 | reddy brown 6e1005 224 | blush pink fe828c 225 | camouflage green 4b6113 226 | lawn green 4da409 227 | putty beae8a 228 | vibrant blue 0339f8 229 | dark sand a88f59 230 | purple/blue 5d21d0 231 | saffron feb209 232 | twilight 4e518b 233 | warm brown 964e02 234 | bluegrey 85a3b2 235 | bubble gum pink ff69af 236 | duck egg blue c3fbf4 237 | greenish cyan 2afeb7 238 | petrol 005f6a 239 | royal 0c1793 240 | butter ffff81 241 | dusty orange f0833a 242 | off yellow f1f33f 243 | pale olive green b1d27b 244 | orangish fc824a 245 | leaf 71aa34 246 | light blue grey b7c9e2 247 | dried blood 4b0101 248 | lightish purple a552e6 249 | rusty red af2f0d 250 | lavender blue 8b88f8 251 | light grass green 9af764 252 | light mint green a6fbb2 253 | sunflower ffc512 254 | velvet 750851 255 | brick orange c14a09 256 | lightish red fe2f4a 257 | pure blue 0203e2 258 | twilight blue 0a437a 259 | violet red a50055 260 | yellowy brown ae8b0c 261 | carnation fd798f 262 | muddy yellow bfac05 263 | dark seafoam green 3eaf76 264 | deep rose c74767 265 | dusty red b9484e 266 | grey/blue 647d8e 267 | lemon lime bffe28 268 | purple/pink d725de 269 | brown yellow b29705 270 | purple brown 673a3f 271 | wisteria a87dc2 272 | banana yellow fafe4b 273 | lipstick red c0022f 274 | water blue 0e87cc 275 | brown grey 8d8468 276 | vibrant purple ad03de 277 | baby green 8cff9e 278 | barf green 94ac02 279 | eggshell blue c4fff7 280 | sandy yellow fdee73 281 | cool green 33b864 282 | pale fff9d0 283 | blue/grey 758da3 284 | hot magenta f504c9 285 | greyblue 77a1b5 286 | purpley 8756e4 287 | baby shit green 889717 288 | brownish pink c27e79 289 | dark aquamarine 017371 290 | diarrhea 9f8303 291 | light mustard f7d560 292 | pale sky blue bdf6fe 293 | turtle green 75b84f 294 | bright olive 9cbb04 295 | dark grey blue 29465b 296 | greeny brown 696006 297 | lemon green adf802 298 | light periwinkle c1c6fc 299 | seaweed green 35ad6b 300 | sunshine yellow fffd37 301 | ugly purple a442a0 302 | medium pink f36196 303 | puke brown 947706 304 | very light pink fff4f2 305 | viridian 1e9167 306 | bile b5c306 307 | faded yellow feff7f 308 | very pale green cffdbc 309 | vibrant green 0add08 310 | bright lime 87fd05 311 | spearmint 1ef876 312 | light aquamarine 7bfdc7 313 | light sage bcecac 314 | yellowgreen bbf90f 315 | baby poo ab9004 316 | dark seafoam 1fb57a 317 | deep teal 00555a 318 | heather a484ac 319 | rust orange c45508 320 | dirty blue 3f829d 321 | fern green 548d44 322 | bright lilac c95efb 323 | weird green 3ae57f 324 | peacock blue 016795 325 | avocado green 87a922 326 | faded orange f0944d 327 | grape purple 5d1451 328 | hot green 25ff29 329 | lime yellow d0fe1d 330 | mango ffa62b 331 | shamrock 01b44c 332 | bubblegum ff6cb5 333 | purplish brown 6b4247 334 | vomit yellow c7c10c 335 | pale cyan b7fffa 336 | key lime aeff6e 337 | tomato red ec2d01 338 | lightgreen 76ff7b 339 | merlot 730039 340 | night blue 040348 341 | purpleish pink df4ec8 342 | apple 6ecb3c 343 | baby poop green 8f9805 344 | green apple 5edc1f 345 | heliotrope d94ff5 346 | yellow/green c8fd3d 347 | almost black 070d0d 348 | cool blue 4984b8 349 | leafy green 51b73b 350 | mustard brown ac7e04 351 | dusk 4e5481 352 | dull brown 876e4b 353 | frog green 58bc08 354 | vivid green 2fef10 355 | bright light green 2dfe54 356 | fluro green 0aff02 357 | kiwi 9cef43 358 | seaweed 18d17b 359 | navy green 35530a 360 | ultramarine blue 1805db 361 | iris 6258c4 362 | pastel orange ff964f 363 | yellowish orange ffab0f 364 | perrywinkle 8f8ce7 365 | tealish 24bca8 366 | dark plum 3f012c 367 | pear cbf85f 368 | pinkish orange ff724c 369 | midnight purple 280137 370 | light urple b36ff6 371 | dark mint 48c072 372 | greenish tan bccb7a 373 | light burgundy a8415b 374 | turquoise blue 06b1c4 375 | ugly pink cd7584 376 | sandy f1da7a 377 | electric pink ff0490 378 | muted purple 805b87 379 | mid green 50a747 380 | greyish a8a495 381 | neon yellow cfff04 382 | banana ffff7e 383 | carnation pink ff7fa7 384 | tomato ef4026 385 | sea 3c9992 386 | muddy brown 886806 387 | turquoise green 04f489 388 | buff fef69e 389 | fawn cfaf7b 390 | muted blue 3b719f 391 | pale rose fdc1c5 392 | dark mint green 20c073 393 | amethyst 9b5fc0 394 | blue/green 0f9b8e 395 | chestnut 742802 396 | sick green 9db92c 397 | pea a4bf20 398 | rusty orange cd5909 399 | stone ada587 400 | rose red be013c 401 | pale aqua b8ffeb 402 | deep orange dc4d01 403 | earth a2653e 404 | mossy green 638b27 405 | grassy green 419c03 406 | pale lime green b1ff65 407 | light grey blue 9dbcd4 408 | pale grey fdfdfe 409 | asparagus 77ab56 410 | blueberry 464196 411 | purple red 990147 412 | pale lime befd73 413 | greenish teal 32bf84 414 | caramel af6f09 415 | deep magenta a0025c 416 | light peach ffd8b1 417 | milk chocolate 7f4e1e 418 | ocher bf9b0c 419 | off green 6ba353 420 | purply pink f075e6 421 | lightblue 7bc8f6 422 | dusky blue 475f94 423 | golden f5bf03 424 | light beige fffeb6 425 | butter yellow fffd74 426 | dusky purple 895b7b 427 | french blue 436bad 428 | ugly yellow d0c101 429 | greeny yellow c6f808 430 | orangish red f43605 431 | shamrock green 02c14d 432 | orangish brown b25f03 433 | tree green 2a7e19 434 | deep violet 490648 435 | gunmetal 536267 436 | blue/purple 5a06ef 437 | cherry cf0234 438 | sandy brown c4a661 439 | warm grey 978a84 440 | dark indigo 1f0954 441 | midnight 03012d 442 | bluey green 2bb179 443 | grey pink c3909b 444 | soft purple a66fb5 445 | blood 770001 446 | brown red 922b05 447 | medium grey 7d7f7c 448 | berry 990f4b 449 | poo 8f7303 450 | purpley pink c83cb9 451 | light salmon fea993 452 | snot acbb0d 453 | easter purple c071fe 454 | light yellow green ccfd7f 455 | dark navy blue 00022e 456 | drab 828344 457 | light rose ffc5cb 458 | rouge ab1239 459 | purplish red b0054b 460 | slime green 99cc04 461 | baby poop 937c00 462 | irish green 019529 463 | pink/purple ef1de7 464 | dark navy 000435 465 | greeny blue 42b395 466 | light plum 9d5783 467 | pinkish grey c8aca9 468 | dirty orange c87606 469 | rust red aa2704 470 | pale lilac e4cbff 471 | orangey red fa4224 472 | primary blue 0804f9 473 | kermit green 5cb200 474 | brownish purple 76424e 475 | murky green 6c7a0e 476 | wheat fbdd7e 477 | very dark purple 2a0134 478 | bottle green 044a05 479 | watermelon fd4659 480 | deep sky blue 0d75f8 481 | fire engine red fe0002 482 | yellow ochre cb9d06 483 | pumpkin orange fb7d07 484 | pale olive b9cc81 485 | light lilac edc8ff 486 | lightish green 61e160 487 | carolina blue 8ab8fe 488 | mulberry 920a4e 489 | shocking pink fe02a2 490 | auburn 9a3001 491 | bright lime green 65fe08 492 | celadon befdb7 493 | pinkish brown b17261 494 | poo brown 885f01 495 | bright sky blue 02ccfe 496 | celery c1fd95 497 | dirt brown 836539 498 | strawberry fb2943 499 | dark lime 84b701 500 | copper b66325 501 | medium brown 7f5112 502 | muted green 5fa052 503 | robin's egg 6dedfd 504 | bright aqua 0bf9ea 505 | bright lavender c760ff 506 | ivory ffffcb 507 | very light purple f6cefc 508 | light navy 155084 509 | pink red f5054f 510 | olive brown 645403 511 | poop brown 7a5901 512 | mustard green a8b504 513 | ocean green 3d9973 514 | very dark blue 000133 515 | dusty green 76a973 516 | light navy blue 2e5a88 517 | minty green 0bf77d 518 | adobe bd6c48 519 | barney ac1db8 520 | jade green 2baf6a 521 | bright light blue 26f7fd 522 | light lime aefd6c 523 | dark khaki 9b8f55 524 | orange yellow ffad01 525 | ocre c69c04 526 | maize f4d054 527 | faded pink de9dac 528 | british racing green 05480d 529 | sandstone c9ae74 530 | mud brown 60460f 531 | light sea green 98f6b0 532 | robin egg blue 8af1fe 533 | aqua marine 2ee8bb 534 | dark sea green 11875d 535 | soft pink fdb0c0 536 | orangey brown b16002 537 | cherry red f7022a 538 | burnt yellow d5ab09 539 | brownish grey 86775f 540 | camel c69f59 541 | purplish grey 7a687f 542 | marine 042e60 543 | greyish pink c88d94 544 | pale turquoise a5fbd5 545 | pastel yellow fffe71 546 | bluey purple 6241c7 547 | canary yellow fffe40 548 | faded red d3494e 549 | sepia 985e2b 550 | coffee a6814c 551 | bright magenta ff08e8 552 | mocha 9d7651 553 | ecru feffca 554 | purpleish 98568d 555 | cranberry 9e003a 556 | darkish green 287c37 557 | brown orange b96902 558 | dusky rose ba6873 559 | melon ff7855 560 | sickly green 94b21c 561 | silver c5c9c7 562 | purply blue 661aee 563 | purpleish blue 6140ef 564 | hospital green 9be5aa 565 | shit brown 7b5804 566 | mid blue 276ab3 567 | amber feb308 568 | easter green 8cfd7e 569 | soft blue 6488ea 570 | cerulean blue 056eee 571 | golden brown b27a01 572 | bright turquoise 0ffef9 573 | red pink fa2a55 574 | red purple 820747 575 | greyish brown 7a6a4f 576 | vermillion f4320c 577 | russet a13905 578 | steel grey 6f828a 579 | lighter purple a55af4 580 | bright violet ad0afd 581 | prussian blue 004577 582 | slate green 658d6d 583 | dirty pink ca7b80 584 | dark blue green 005249 585 | pine 2b5d34 586 | yellowy green bff128 587 | dark gold b59410 588 | bluish 2976bb 589 | darkish blue 014182 590 | dull red bb3f3f 591 | pinky red fc2647 592 | bronze a87900 593 | pale teal 82cbb2 594 | military green 667c3e 595 | barbie pink fe46a5 596 | bubblegum pink fe83cc 597 | pea soup green 94a617 598 | dark mustard a88905 599 | shit 7f5f00 600 | medium purple 9e43a2 601 | very dark green 062e03 602 | dirt 8a6e45 603 | dusky pink cc7a8b 604 | red violet 9e0168 605 | lemon yellow fdff38 606 | pistachio c0fa8b 607 | dull yellow eedc5b 608 | dark lime green 7ebd01 609 | denim blue 3b5b92 610 | teal blue 01889f 611 | lightish blue 3d7afd 612 | purpley blue 5f34e7 613 | light indigo 6d5acf 614 | swamp green 748500 615 | brown green 706c11 616 | dark maroon 3c0008 617 | hot purple cb00f5 618 | dark forest green 002d04 619 | faded blue 658cbb 620 | drab green 749551 621 | light lime green b9ff66 622 | snot green 9dc100 623 | yellowish faee66 624 | light blue green 7efbb3 625 | bordeaux 7b002c 626 | light mauve c292a1 627 | ocean 017b92 628 | marigold fcc006 629 | muddy green 657432 630 | dull orange d8863b 631 | steel 738595 632 | electric purple aa23ff 633 | fluorescent green 08ff08 634 | yellowish brown 9b7a01 635 | blush f29e8e 636 | soft green 6fc276 637 | bright orange ff5b00 638 | lemon fdff52 639 | purple grey 866f85 640 | acid green 8ffe09 641 | pale lavender eecffe 642 | violet blue 510ac9 643 | light forest green 4f9153 644 | burnt red 9f2305 645 | khaki green 728639 646 | cerise de0c62 647 | faded purple 916e99 648 | apricot ffb16d 649 | dark olive green 3c4d03 650 | grey brown 7f7053 651 | green grey 77926f 652 | true blue 010fcc 653 | pale violet ceaefa 654 | periwinkle blue 8f99fb 655 | light sky blue c6fcff 656 | blurple 5539cc 657 | green brown 544e03 658 | bluegreen 017a79 659 | bright teal 01f9c6 660 | brownish yellow c9b003 661 | pea soup 929901 662 | forest 0b5509 663 | barney purple a00498 664 | ultramarine 2000b1 665 | purplish 94568c 666 | puke yellow c2be0e 667 | bluish grey 748b97 668 | dark periwinkle 665fd1 669 | dark lilac 9c6da5 670 | reddish c44240 671 | light maroon a24857 672 | dusty purple 825f87 673 | terra cotta c9643b 674 | avocado 90b134 675 | marine blue 01386a 676 | teal green 25a36f 677 | slate grey 59656d 678 | lighter green 75fd63 679 | electric green 21fc0d 680 | dusty blue 5a86ad 681 | golden yellow fec615 682 | bright yellow fffd01 683 | light lavender dfc5fe 684 | umber b26400 685 | poop 7f5e00 686 | dark peach de7e5d 687 | jungle green 048243 688 | eggshell ffffd4 689 | denim 3b638c 690 | yellow brown b79400 691 | dull purple 84597e 692 | chocolate brown 411900 693 | wine red 7b0323 694 | neon blue 04d9ff 695 | dirty green 667e2c 696 | light tan fbeeac 697 | ice blue d7fffe 698 | cadet blue 4e7496 699 | dark mauve 874c62 700 | very light blue d5ffff 701 | grey purple 826d8c 702 | pastel pink ffbacd 703 | very light green d1ffbd 704 | dark sky blue 448ee4 705 | evergreen 05472a 706 | dull pink d5869d 707 | aubergine 3d0734 708 | mahogany 4a0100 709 | reddish orange f8481c 710 | deep green 02590f 711 | vomit green 89a203 712 | purple pink e03fd8 713 | dusty pink d58a94 714 | faded green 7bb274 715 | camo green 526525 716 | pinky purple c94cbe 717 | pink purple db4bda 718 | brownish red 9e3623 719 | dark rose b5485d 720 | mud 735c12 721 | brownish 9c6d57 722 | emerald green 028f1e 723 | pale brown b1916e 724 | dull blue 49759c 725 | burnt umber a0450e 726 | medium green 39ad48 727 | clay b66a50 728 | light aqua 8cffdb 729 | light olive green a4be5c 730 | brownish orange cb7723 731 | dark aqua 05696b 732 | purplish pink ce5dae 733 | dark salmon c85a53 734 | greenish grey 96ae8d 735 | jade 1fa774 736 | ugly green 7a9703 737 | dark beige ac9362 738 | emerald 01a049 739 | pale red d9544d 740 | light magenta fa5ff7 741 | sky 82cafc 742 | light cyan acfffc 743 | yellow orange fcb001 744 | reddish purple 910951 745 | reddish pink fe2c54 746 | orchid c875c4 747 | dirty yellow cdc50a 748 | orange red fd411e 749 | deep red 9a0200 750 | orange brown be6400 751 | cobalt blue 030aa7 752 | neon pink fe019a 753 | rose pink f7879a 754 | greyish purple 887191 755 | raspberry b00149 756 | aqua green 12e193 757 | salmon pink fe7b7c 758 | tangerine ff9408 759 | brownish green 6a6e09 760 | red brown 8b2e16 761 | greenish brown 696112 762 | pumpkin e17701 763 | pine green 0a481e 764 | charcoal 343837 765 | baby pink ffb7ce 766 | cornflower 6a79f7 767 | blue violet 5d06e9 768 | chocolate 3d1c02 769 | greyish green 82a67d 770 | scarlet be0119 771 | green yellow c9ff27 772 | dark olive 373e02 773 | sienna a9561e 774 | pastel purple caa0ff 775 | terracotta ca6641 776 | aqua blue 02d8e9 777 | sage green 88b378 778 | blood red 980002 779 | deep pink cb0162 780 | grass 5cac2d 781 | moss 769958 782 | pastel blue a2bffe 783 | bluish green 10a674 784 | green blue 06b48b 785 | dark tan af884a 786 | greenish blue 0b8b87 787 | pale orange ffa756 788 | vomit a2a415 789 | forrest green 154406 790 | dark lavender 856798 791 | dark violet 34013f 792 | purple blue 632de9 793 | dark cyan 0a888a 794 | olive drab 6f7632 795 | pinkish d46a7e 796 | cobalt 1e488f 797 | neon purple bc13fe 798 | light turquoise 7ef4cc 799 | apple green 76cd26 800 | dull green 74a662 801 | wine 80013f 802 | powder blue b1d1fc 803 | off white ffffe4 804 | electric blue 0652ff 805 | dark turquoise 045c5a 806 | blue purple 5729ce 807 | azure 069af3 808 | bright red ff000d 809 | pinkish red f10c45 810 | cornflower blue 5170d7 811 | light olive acbf69 812 | grape 6c3461 813 | greyish blue 5e819d 814 | purplish blue 601ef9 815 | yellowish green b0dd16 816 | greenish yellow cdfd02 817 | medium blue 2c6fbb 818 | dusty rose c0737a 819 | light violet d6b4fc 820 | midnight blue 020035 821 | bluish purple 703be7 822 | red orange fd3c06 823 | dark magenta 960056 824 | greenish 40a368 825 | ocean blue 03719c 826 | coral fc5a50 827 | cream ffffc2 828 | reddish brown 7f2b0a 829 | burnt sienna b04e0f 830 | brick a03623 831 | sage 87ae73 832 | grey green 789b73 833 | white ffffff 834 | robin's egg blue 98eff9 835 | moss green 658b38 836 | steel blue 5a7d9a 837 | eggplant 380835 838 | light yellow fffe7a 839 | leaf green 5ca904 840 | light grey d8dcd6 841 | puke a5a502 842 | pinkish purple d648d7 843 | sea blue 047495 844 | pale purple b790d4 845 | slate blue 5b7c99 846 | blue grey 607c8e 847 | hunter green 0b4008 848 | fuchsia ed0dd9 849 | crimson 8c000f 850 | pale yellow ffff84 851 | ochre bf9005 852 | mustard yellow d2bd0a 853 | light red ff474c 854 | cerulean 0485d1 855 | pale pink ffcfdc 856 | deep blue 040273 857 | rust a83c09 858 | light teal 90e4c1 859 | slate 516572 860 | goldenrod fac205 861 | dark yellow d5b60a 862 | dark grey 363737 863 | army green 4b5d16 864 | grey blue 6b8ba4 865 | seafoam 80f9ad 866 | puce a57e52 867 | spring green a9f971 868 | dark orange c65102 869 | sand e2ca76 870 | pastel green b0ff9d 871 | mint 9ffeb0 872 | light orange fdaa48 873 | bright pink fe01b1 874 | chartreuse c1f80a 875 | deep purple 36013f 876 | dark brown 341c02 877 | taupe b9a281 878 | pea green 8eab12 879 | puke green 9aae07 880 | kelly green 02ab2e 881 | seafoam green 7af9ab 882 | blue green 137e6d 883 | khaki aaa662 884 | burgundy 610023 885 | dark teal 014d4e 886 | brick red 8f1402 887 | royal purple 4b006e 888 | plum 580f41 889 | mint green 8fff9f 890 | gold dbb40c 891 | baby blue a2cffe 892 | yellow green c0fb2d 893 | bright purple be03fd 894 | dark red 840000 895 | pale blue d0fefe 896 | grass green 3f9b0b 897 | navy 01153e 898 | aquamarine 04d8b2 899 | burnt orange c04e01 900 | neon green 0cff0c 901 | bright blue 0165fc 902 | rose cf6275 903 | light pink ffd1df 904 | mustard ceb301 905 | indigo 380282 906 | lime aaff32 907 | sea green 53fca1 908 | periwinkle 8e82fe 909 | dark pink cb416b 910 | olive green 677a04 911 | peach ffb07c 912 | pale green c7fdb5 913 | light brown ad8150 914 | hot pink ff028d 915 | black 000000 916 | lilac cea2fd 917 | navy blue 001146 918 | royal blue 0504aa 919 | beige e6daa6 920 | salmon ff796c 921 | olive 6e750e 922 | maroon 650021 923 | bright green 01ff07 924 | dark purple 35063e 925 | mauve ae7181 926 | forest green 06470c 927 | aqua 13eac9 928 | cyan 00ffff 929 | tan d1b26f 930 | dark blue 00035b 931 | lavender c79fef 932 | turquoise 06c2ac 933 | dark green 033500 934 | violet 9a0eea 935 | light purple bf77f6 936 | lime green 89fe05 937 | grey 929591 938 | sky blue 75bbfd 939 | yellow ffff14 940 | magenta c20078 941 | light green 96f97b 942 | orange f97306 943 | teal 029386 944 | light blue 95d0fc 945 | red e50000 946 | brown 653700 947 | pink ff81c0 948 | blue 0343df 949 | green 15b01a 950 | purple 7e1e9c 951 | -------------------------------------------------------------------------------- /deploy/build.gradle: -------------------------------------------------------------------------------- 1 | import com.diffplug.gradle.pde.* 2 | import com.diffplug.gradle.p2.* 3 | import com.diffplug.gradle.FileMisc 4 | import com.diffplug.gradle.ZipMisc 5 | import com.diffplug.common.swt.os.SwtPlatform 6 | 7 | //////////////////////////////////////////////// 8 | // Build our application into a P2 repository // 9 | //////////////////////////////////////////////// 10 | 11 | def P2_DIR = 'build/p2' 12 | 13 | task buildP2(type: PdeBuildTask, dependsOn: ':target.maven:bundles') { 14 | // set the base platform 15 | base(rootProject.file('target.p2/build/p2asmaven/p2runnable/eclipse-deps')) 16 | // configure where the plugins will come from 17 | addPluginPath(rootProject.file('target.maven/build')) 18 | addPluginPath(rootProject.file('target.p2/build/p2asmaven/p2runnable/eclipse-deps')) 19 | // and where they will go 20 | destination(P2_DIR) 21 | // specify that this is a product build 22 | product { 23 | id 'com.diffplug.rcpdemo.product' 24 | version rootProject.version 25 | productPluginDir rootProject.file('com.diffplug.rcpdemo') 26 | productFileWithinPlugin 'rcpdemo.product' 27 | explicitVersionPolicy({ 28 | it.resolve('com.google.guava', '17.0.0', '18.0.0').with('17.0.0', '18.0.0') 29 | }) 30 | } 31 | // set the build properties to be appropriate for p2 32 | props['p2.build.repo'] = 'file://' + project.file(P2_DIR).absolutePath 33 | props['p2.gathering'] = 'true' 34 | props['skipDirector'] = 'true' 35 | props['runPackager'] = 'false' 36 | props['groupConfigurations'] = 'true' 37 | 38 | // p2.compress doesn't work, dunno why 39 | doLast { 40 | def compressXml = { name -> 41 | File xml = project.file(P2_DIR + "/${name}.xml") 42 | File jar = project.file(P2_DIR + "/${name}.jar") 43 | ZipMisc.zip(xml, "${name}.xml", jar) 44 | xml.delete() 45 | } 46 | compressXml('artifacts') 47 | compressXml('content') 48 | } 49 | } 50 | 51 | P2Model model = new P2Model() 52 | model.addRepo(project.file(P2_DIR)) 53 | model.addIU('com.diffplug.rcpdemo.product') 54 | 55 | def createTask(SwtPlatform platform, P2Model model) { 56 | def assembleTask = project.task('assemble.' + platform) 57 | assembleTask.doLast { 58 | def dest = project.file('build/' + platform + (platform.os == 'macosx' ? '.app' : '')) 59 | FileMisc.cleanDir(dest) 60 | P2Model.DirectorApp director = model.directorApp(dest, 'RcpDemo') 61 | director.roaming() 62 | director.platform(platform) 63 | director.installFeatures() 64 | director.runUsingBootstrapper(project) 65 | } 66 | return assembleTask 67 | } 68 | def assembleAll = project.task('assemble.all') 69 | for (SwtPlatform platform : SwtPlatform.getAll()) { 70 | def assemble = createTask(platform, model) 71 | assembleAll.dependsOn(assemble) 72 | assemble.dependsOn(buildP2) 73 | } 74 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | stable=1.0.0 2 | version=1.0.0 3 | name=gradle_and_eclipse_rcp 4 | group=com.diffplug.talks 5 | description=Gradle and Eclipse RCP 6 | org=diffplug 7 | 8 | # Build requirements 9 | VER_JAVA=1.8 10 | VER_GOOMPH=3.22.0 11 | VER_BND_PLATFORM=1.7.0 12 | VER_SPOTLESS=3.28.1 13 | 14 | # The version of PDE (and eclipse platform plugins) 15 | GOOMPH_PDE_VER=4.15.0 16 | # Uncomment these to use a non-official release (e.g. nightly) 17 | #GOOMPH_PDE_UDPATE_SITE= 18 | #GOOMPH_PDE_ID= 19 | 20 | # Testing 21 | VER_JUNIT=4.12 22 | 23 | # Compile 24 | VER_DURIAN=1.2.0 25 | VER_DURIAN_RX=2.0.0 26 | VER_DURIAN_SWT=2.0.0 27 | VER_RXJAVA=1.1.0 28 | 29 | # Testing 30 | VER_JUNIT=4.12 31 | -------------------------------------------------------------------------------- /gradle/spotless/spotless.eclipseformat.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | 293 | 294 | 295 | 296 | 297 | 298 | 299 | 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | 309 | 310 | 311 | 312 | 313 | 314 | -------------------------------------------------------------------------------- /gradle/spotless/spotless.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.diffplug.gradle.spotless' 2 | spotless { 3 | if (project.plugins.hasPlugin(JavaPlugin)) { 4 | java { 5 | licenseHeaderFile rootProject.file('gradle/spotless/spotless.license.java') // License header file 6 | importOrderFile rootProject.file('gradle/spotless/spotless.importorder') // An import ordering file, exported from Eclipse 7 | eclipse().configFile rootProject.file('gradle/spotless/spotless.eclipseformat.xml') // XML file dumped out by the Eclipse formatter 8 | removeUnusedImports() 9 | } 10 | } 11 | format 'misc', { 12 | target '*.gradle', '*.md', '.gitignore' 13 | indentWithTabs() 14 | trimTrailingWhitespace() 15 | endWithNewline() 16 | } 17 | freshmark { 18 | target '*.md' 19 | propertiesFile rootProject.file('gradle.properties') 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /gradle/spotless/spotless.importorder: -------------------------------------------------------------------------------- 1 | #Organize Import Order 2 | #Fri Apr 24 02:36:28 PDT 2015 3 | 5= 4 | 4=com.diffplug 5 | 3=com 6 | 2=org 7 | 1=javax 8 | 0=java 9 | -------------------------------------------------------------------------------- /gradle/spotless/spotless.license.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 DiffPlug 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/diffplug/gradle-and-eclipse-rcp/0c27ca32a984f8bd6b8d37b5410546d19ef442cc/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | # 4 | # Copyright 2015 the original author or authors. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # https://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | 19 | ############################################################################## 20 | ## 21 | ## Gradle start up script for UN*X 22 | ## 23 | ############################################################################## 24 | 25 | # Attempt to set APP_HOME 26 | # Resolve links: $0 may be a link 27 | PRG="$0" 28 | # Need this for relative symlinks. 29 | while [ -h "$PRG" ] ; do 30 | ls=`ls -ld "$PRG"` 31 | link=`expr "$ls" : '.*-> \(.*\)$'` 32 | if expr "$link" : '/.*' > /dev/null; then 33 | PRG="$link" 34 | else 35 | PRG=`dirname "$PRG"`"/$link" 36 | fi 37 | done 38 | SAVED="`pwd`" 39 | cd "`dirname \"$PRG\"`/" >/dev/null 40 | APP_HOME="`pwd -P`" 41 | cd "$SAVED" >/dev/null 42 | 43 | APP_NAME="Gradle" 44 | APP_BASE_NAME=`basename "$0"` 45 | 46 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 47 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' 48 | 49 | # Use the maximum available, or set MAX_FD != -1 to use that value. 50 | MAX_FD="maximum" 51 | 52 | warn () { 53 | echo "$*" 54 | } 55 | 56 | die () { 57 | echo 58 | echo "$*" 59 | echo 60 | exit 1 61 | } 62 | 63 | # OS specific support (must be 'true' or 'false'). 64 | cygwin=false 65 | msys=false 66 | darwin=false 67 | nonstop=false 68 | case "`uname`" in 69 | CYGWIN* ) 70 | cygwin=true 71 | ;; 72 | Darwin* ) 73 | darwin=true 74 | ;; 75 | MINGW* ) 76 | msys=true 77 | ;; 78 | NONSTOP* ) 79 | nonstop=true 80 | ;; 81 | esac 82 | 83 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 84 | 85 | # Determine the Java command to use to start the JVM. 86 | if [ -n "$JAVA_HOME" ] ; then 87 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 88 | # IBM's JDK on AIX uses strange locations for the executables 89 | JAVACMD="$JAVA_HOME/jre/sh/java" 90 | else 91 | JAVACMD="$JAVA_HOME/bin/java" 92 | fi 93 | if [ ! -x "$JAVACMD" ] ; then 94 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 95 | 96 | Please set the JAVA_HOME variable in your environment to match the 97 | location of your Java installation." 98 | fi 99 | else 100 | JAVACMD="java" 101 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 102 | 103 | Please set the JAVA_HOME variable in your environment to match the 104 | location of your Java installation." 105 | fi 106 | 107 | # Increase the maximum file descriptors if we can. 108 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 109 | MAX_FD_LIMIT=`ulimit -H -n` 110 | if [ $? -eq 0 ] ; then 111 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 112 | MAX_FD="$MAX_FD_LIMIT" 113 | fi 114 | ulimit -n $MAX_FD 115 | if [ $? -ne 0 ] ; then 116 | warn "Could not set maximum file descriptor limit: $MAX_FD" 117 | fi 118 | else 119 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 120 | fi 121 | fi 122 | 123 | # For Darwin, add options to specify how the application appears in the dock 124 | if $darwin; then 125 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 126 | fi 127 | 128 | # For Cygwin or MSYS, switch paths to Windows format before running java 129 | if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then 130 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 131 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 132 | JAVACMD=`cygpath --unix "$JAVACMD"` 133 | 134 | # We build the pattern for arguments to be converted via cygpath 135 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 136 | SEP="" 137 | for dir in $ROOTDIRSRAW ; do 138 | ROOTDIRS="$ROOTDIRS$SEP$dir" 139 | SEP="|" 140 | done 141 | OURCYGPATTERN="(^($ROOTDIRS))" 142 | # Add a user-defined pattern to the cygpath arguments 143 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 144 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 145 | fi 146 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 147 | i=0 148 | for arg in "$@" ; do 149 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 150 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 151 | 152 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 153 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 154 | else 155 | eval `echo args$i`="\"$arg\"" 156 | fi 157 | i=`expr $i + 1` 158 | done 159 | case $i in 160 | 0) set -- ;; 161 | 1) set -- "$args0" ;; 162 | 2) set -- "$args0" "$args1" ;; 163 | 3) set -- "$args0" "$args1" "$args2" ;; 164 | 4) set -- "$args0" "$args1" "$args2" "$args3" ;; 165 | 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 166 | 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 167 | 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 168 | 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 169 | 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 170 | esac 171 | fi 172 | 173 | # Escape application args 174 | save () { 175 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 176 | echo " " 177 | } 178 | APP_ARGS=`save "$@"` 179 | 180 | # Collect all arguments for the java command, following the shell quoting and substitution rules 181 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 182 | 183 | exec "$JAVACMD" "$@" 184 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem https://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | 17 | @if "%DEBUG%" == "" @echo off 18 | @rem ########################################################################## 19 | @rem 20 | @rem Gradle startup script for Windows 21 | @rem 22 | @rem ########################################################################## 23 | 24 | @rem Set local scope for the variables with windows NT shell 25 | if "%OS%"=="Windows_NT" setlocal 26 | 27 | set DIRNAME=%~dp0 28 | if "%DIRNAME%" == "" set DIRNAME=. 29 | set APP_BASE_NAME=%~n0 30 | set APP_HOME=%DIRNAME% 31 | 32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter. 33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 34 | 35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 37 | 38 | @rem Find java.exe 39 | if defined JAVA_HOME goto findJavaFromJavaHome 40 | 41 | set JAVA_EXE=java.exe 42 | %JAVA_EXE% -version >NUL 2>&1 43 | if "%ERRORLEVEL%" == "0" goto init 44 | 45 | echo. 46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 47 | echo. 48 | echo Please set the JAVA_HOME variable in your environment to match the 49 | echo location of your Java installation. 50 | 51 | goto fail 52 | 53 | :findJavaFromJavaHome 54 | set JAVA_HOME=%JAVA_HOME:"=% 55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 56 | 57 | if exist "%JAVA_EXE%" goto init 58 | 59 | echo. 60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 61 | echo. 62 | echo Please set the JAVA_HOME variable in your environment to match the 63 | echo location of your Java installation. 64 | 65 | goto fail 66 | 67 | :init 68 | @rem Get command-line arguments, handling Windows variants 69 | 70 | if not "%OS%" == "Windows_NT" goto win9xME_args 71 | 72 | :win9xME_args 73 | @rem Slurp the command line arguments. 74 | set CMD_LINE_ARGS= 75 | set _SKIP=2 76 | 77 | :win9xME_args_slurp 78 | if "x%~1" == "x" goto execute 79 | 80 | set CMD_LINE_ARGS=%* 81 | 82 | :execute 83 | @rem Setup the command line 84 | 85 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 86 | 87 | @rem Execute Gradle 88 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 89 | 90 | :end 91 | @rem End local scope for the variables with windows NT shell 92 | if "%ERRORLEVEL%"=="0" goto mainEnd 93 | 94 | :fail 95 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 96 | rem the _cmd.exe /c_ return code! 97 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 98 | exit /b 1 99 | 100 | :mainEnd 101 | if "%OS%"=="Windows_NT" endlocal 102 | 103 | :omega 104 | -------------------------------------------------------------------------------- /ide/build.gradle: -------------------------------------------------------------------------------- 1 | /////////////// 2 | // SETUP IDE // 3 | /////////////// 4 | apply plugin: 'com.diffplug.oomph.ide' 5 | oomphIde { 6 | splash '../_imgs/titlecard.png' 7 | repoEclipseLatest() 8 | pde { 9 | targetplatform { 10 | it.installation '../target.maven/build' 11 | it.installation '../target.p2/build/p2asmaven/p2runnable/eclipse-deps' 12 | } 13 | } 14 | style { 15 | classicTheme() // oldschool cool 16 | niceText() // nice fonts and visible whitespace 17 | } 18 | eclipseIni { 19 | vmargs('-Xmx2g') // IDE can have 2 gigs of RAM, if it wants 20 | } 21 | 22 | addAllProjects() // we want a project for *everything* 23 | 24 | thirdParty { 25 | //minimalistGradleEditor {} // add syntax highlighting for gradle scripts 26 | tmTerminal {} // adds an in-eclipse terminal 27 | } 28 | } 29 | // the IDE needs the targetplatform 30 | ideSetupWorkspace.dependsOn(':target.maven:bundles') 31 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | // projects which demonstrate the value of OSGi and P2 2 | include 'com.diffplug.needs17' 3 | include 'com.diffplug.needs18' 4 | include 'com.diffplug.needsBoth' 5 | 6 | // snazzy gui to look at 7 | include 'com.diffplug.talks.rxjava_and_swt' 8 | 9 | // simple demo app 10 | include 'com.diffplug.rcpdemo' 11 | 12 | // the targetplatform we're compiling against 13 | include 'target.p2' 14 | include 'target.maven' 15 | 16 | // the directory where we build the final shipped application 17 | include 'deploy' 18 | // generate ide for the whole project 19 | include 'ide' 20 | -------------------------------------------------------------------------------- /target.maven/build.gradle: -------------------------------------------------------------------------------- 1 | ///////////////////////////// 2 | // WRAP MAVEN DEPS TO OSGI // 3 | ///////////////////////////// 4 | 5 | // find the paths of all actual projects 6 | def pluginPaths = rootProject.subprojects 7 | .collect { ':' + it.name } 8 | .grep { it.startsWith(':com.diffplug.') } 9 | 10 | // the target platform will contain every jar 11 | // which is added to the platform config, as 12 | // well as all of its transitives, with OSGi 13 | // metadata created automatically by bnd as 14 | // required. 15 | configurations { 16 | platform 17 | // no need to add the plugins from p2 18 | all*.exclude group: 'eclipse-deps' 19 | } 20 | for (pluginPath in pluginPaths) { 21 | evaluationDependsOn(pluginPath) 22 | dependencies.add('platform', project(pluginPath)) 23 | } 24 | 25 | // Download from eclipse and put it into maven 26 | apply plugin: 'org.standardout.bnd-platform' 27 | platform { 28 | determineImportVersions = true 29 | importVersionStrategy = MAJOR 30 | useBndHashQualifiers = false 31 | fetchSources = false 32 | } 33 | // don't let stale bundles lay around 34 | bundles.dependsOn(clean) 35 | // bundles relies on the underlying jars being built 36 | configurations.collectMany { it.allDependencies }.findAll { it instanceof ProjectDependency }.each { 37 | bundles.dependsOn(it.dependencyProject.path + ':jar') 38 | } 39 | 40 | // put the bundle task into the output of `gradle tasks` since Gradle 3.3 includes only tasks with a group 41 | bundles.group = 'Build' 42 | bundles.description = 'Converts maven dependencies into OSGi bundles.' 43 | 44 | dependencies { 45 | // Gradle kicks out all but the newest, and we need both 18 and 17 46 | platformaux 'com.google.guava:guava:17.0' 47 | // RxJava wants sun.misc 48 | platformaux 'com.diffplug.osgi:com.diffplug.osgi.extension.sun.misc:0.0.0' 49 | } 50 | -------------------------------------------------------------------------------- /target.p2/build.gradle: -------------------------------------------------------------------------------- 1 | import com.diffplug.gradle.pde.EclipseRelease 2 | 3 | // Download from eclipse and put it into maven 4 | apply plugin: 'com.diffplug.p2.asmaven' 5 | p2AsMaven { 6 | group 'eclipse-deps', { 7 | repoEclipse '4.5.2' 8 | feature 'org.eclipse.equinox.executable' 9 | feature 'org.eclipse.rcp.configuration' 10 | feature 'org.eclipse.platform' 11 | feature 'org.eclipse.platform.source' 12 | repo2runnable() 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /titlecard.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/diffplug/gradle-and-eclipse-rcp/0c27ca32a984f8bd6b8d37b5410546d19ef442cc/titlecard.png --------------------------------------------------------------------------------