Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to Java 17 and Maven libraries #1

Open
wants to merge 6 commits into
base: fx
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .mvn/extensions.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<extensions>
<extension>
<groupId>org.eclipse.tycho.extras</groupId>
<artifactId>tycho-pomless</artifactId>
<version>1.5.1</version>
</extension>
</extensions>
67 changes: 64 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,67 @@
# e4-cookbook-basic-recipe
The basic recipe of the Eclipse RCP cookbook.
The basic recipe of the Eclipse RCP cookbook extended for integrating JavaFX.

The corresponding blog post can be found here: https://blog.codecentric.de/en/2015/02/eclipse-rcp-cookbook-basic-recipe/
This example has been updated to Java 17 using the following approach:

This repository is intended to be used as basis for further recipes.
To use JavaFX, add the following to your target platform:

<location includeDependencyDepth="infinite" includeDependencyScopes="compile,runtime" includeSource="true" label="Tools Platform Libs" missingManifest="generate" type="Maven">
<dependencies>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>22-ea+16</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-fxml</artifactId>
<version>22-ea+16</version>
<type>jar</type>
</dependency>
</dependencies>
</location>

Unfortunately the JavaFX SWT libraries is not available via Maven artifacts, you have to extract it from the the zip file.
This is platform specific:

Windows: Contained in JAR file of Javafx controls
Linux: Contained in the JAR file of Javafx graphics jar
The JAR files in which the JAR file is included is located in .m2/repository/org/openjfx/compoent/version for example: .m2/repository/org/openjfx/javafx-graphics/21

Unfortunately the target platform downloads the platform specific artifacts from Maven using the same bundle name. PDE resolves in some cases (this seems to be platform and library version specific) to the bundle which does not contain the implementation. Therefore, you might have to copy the JAR files into your project and add them to the MANIFEST.MF file.

image

Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Inverter
Bundle-SymbolicName: org.fipro.eclipse.tutorial.inverter
Bundle-Version: 1.0.0.qualifier
Bundle-RequiredExecutionEnvironment: JavaSE-17
Require-Bundle: org.eclipse.swt;bundle-version="3.103.1",
org.eclipse.jface;bundle-version="3.10.1",
javax.annotation;bundle-version="1.2.0",
javax.inject;bundle-version="1.0.0"
Automatic-Module-Name: org.fipro.eclipse.tutorial.inverter
Bundle-ClassPath: .,
lib/javafx-base-17.0.9.jar,
lib/javafx-base-17.0.9-linux.jar,
lib/javafx-fxml-17.0.9.jar,
lib/javafx-fxml-17.0.9-linux.jar,
lib/javafx-graphics-17.0.9.jar,
lib/javafx-graphics-17.0.9-linux.jar,
lib/javafx-swt.jar,
lib/javafx-controls-17.0.9.jar,
lib/javafx-controls-17.0.9-linux.jar



The blog post for the basic recipe can be found here:\
https://blog.codecentric.de/en/2015/02/eclipse-rcp-cookbook-basic-recipe/

The original blog post for the JavaFX integration can be found here:\
https://blog.codecentric.de/en/2015/04/add-javafx-controls-swt-eclipse-4-application-eclipse-rcp-cookbook/

The updated blog post for the current version of the JavaFX integration can be found here:\
http://blog.vogella.com/2019/11/15/add-javafx-controls-to-a-swt-eclipse-4-application-eclipse-rcp-cookbook-update/
23 changes: 16 additions & 7 deletions org.fipro.eclipse.tutorial.inverter/.classpath
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry exported="true" kind="lib" path="lib/javafx-controls-17.0.9.jar"/>
<classpathentry exported="true" kind="lib" path="lib/javafx-controls-17.0.9-linux.jar"/>
<classpathentry exported="true" kind="lib" path="lib/javafx-base-17.0.9.jar"/>
<classpathentry exported="true" kind="lib" path="lib/javafx-base-17.0.9-linux.jar"/>
<classpathentry exported="true" kind="lib" path="lib/javafx-fxml-17.0.9.jar"/>
<classpathentry exported="true" kind="lib" path="lib/javafx-fxml-17.0.9-linux.jar"/>
<classpathentry exported="true" kind="lib" path="lib/javafx-graphics-17.0.9.jar"/>
<classpathentry exported="true" kind="lib" path="lib/javafx-graphics-17.0.9-linux.jar"/>
<classpathentry exported="true" kind="lib" path="lib/javafx-swt.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-17"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>
12 changes: 11 additions & 1 deletion org.fipro.eclipse.tutorial.inverter/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,19 @@ Bundle-ManifestVersion: 2
Bundle-Name: Inverter
Bundle-SymbolicName: org.fipro.eclipse.tutorial.inverter
Bundle-Version: 1.0.0.qualifier
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Bundle-RequiredExecutionEnvironment: JavaSE-17
Require-Bundle: org.eclipse.swt;bundle-version="3.103.1",
org.eclipse.jface;bundle-version="3.10.1",
javax.annotation;bundle-version="1.2.0",
javax.inject;bundle-version="1.0.0"
Automatic-Module-Name: org.fipro.eclipse.tutorial.inverter
Bundle-ClassPath: .,
lib/javafx-base-17.0.9.jar,
lib/javafx-base-17.0.9-linux.jar,
lib/javafx-fxml-17.0.9.jar,
lib/javafx-fxml-17.0.9-linux.jar,
lib/javafx-graphics-17.0.9.jar,
lib/javafx-graphics-17.0.9-linux.jar,
lib/javafx-swt.jar,
lib/javafx-controls-17.0.9.jar,
lib/javafx-controls-17.0.9-linux.jar
11 changes: 10 additions & 1 deletion org.fipro.eclipse.tutorial.inverter/build.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.
.,\
lib/javafx-base-17.0.9.jar,\
lib/javafx-base-17.0.9-linux.jar,\
lib/javafx-fxml-17.0.9.jar,\
lib/javafx-fxml-17.0.9-linux.jar,\
lib/javafx-graphics-17.0.9.jar,\
lib/javafx-graphics-17.0.9-linux.jar,\
lib/javafx-swt.jar,\
lib/javafx-controls-17.0.9.jar,\
lib/javafx-controls-17.0.9-linux.jar
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,15 @@
import org.eclipse.swt.widgets.Text;
import org.fipro.eclipse.tutorial.inverter.helper.StringInverter;

import javafx.animation.ParallelTransition;
import javafx.animation.RotateTransition;
import javafx.animation.ScaleTransition;
import javafx.embed.swt.FXCanvas;
import javafx.scene.Scene;
import javafx.scene.layout.BorderPane;
import javafx.scene.paint.Color;
import javafx.util.Duration;

public class InverterPart {

@PostConstruct
Expand All @@ -36,22 +45,57 @@ public void postConstruct(Composite parent) {
outputLabel.setText("Inverted String:");
GridDataFactory.fillDefaults().applyTo(outputLabel);

final Text output = new Text(parent, SWT.READ_ONLY | SWT.WRAP);
GridDataFactory.fillDefaults().grab(true, true).span(2, 1).applyTo(output);
// add FXCanvas for adding JavaFX controls to the UI
FXCanvas canvas = new FXCanvas(parent, SWT.NONE);
GridDataFactory
.fillDefaults()
.grab(true, true)
.span(3, 1)
.applyTo(canvas);

// create the root layout pane
BorderPane layout = new BorderPane();

// create a Scene instance
// set the layout container as root
// set the background fill to the background color of the shell
Scene scene = new Scene(layout, Color.rgb(
parent.getShell().getBackground().getRed(),
parent.getShell().getBackground().getGreen(),
parent.getShell().getBackground().getBlue()));

// set the Scene to the FXCanvas
canvas.setScene(scene);

javafx.scene.control.Label output = new javafx.scene.control.Label();
layout.setCenter(output);

RotateTransition rotateTransition = new RotateTransition(Duration.seconds(1), output);
rotateTransition.setByAngle(360);

ScaleTransition scaleTransition = new ScaleTransition(Duration.seconds(1), output);
scaleTransition.setFromX(1.0);
scaleTransition.setFromY(1.0);
scaleTransition.setToX(4.0);
scaleTransition.setToY(4.0);

ParallelTransition parallelTransition = new ParallelTransition(rotateTransition, scaleTransition);

button.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
output.setText(StringInverter.invert(input.getText()));
parallelTransition.play();
}
});

input.addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(KeyEvent e) {
if (e.keyCode == SWT.CR
|| e.keyCode == SWT.KEYPAD_CR) {
output.setText(StringInverter.invert(input.getText()));
parallelTransition.play();
}
}
});
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?xml version="1.0" encoding="UTF-8"?>
<?pde version="3.5"?>

<product name="E4 RCP Tutorial App" uid="org.fipro.eclipse.tutorial" id="org.fipro.eclipse.tutorial.app.product" application="org.eclipse.e4.ui.workbench.swt.E4Application" version="1.0.0" useFeatures="true" includeLaunchers="true">

<configIni use="default">
</configIni>

<launcherArgs>
<programArgs>-clearPersistedState
</programArgs>
<vmArgsMac>-XstartOnFirstThread -Dorg.eclipse.swt.internal.carbon.smallFonts
</vmArgsMac>
</launcherArgs>

<launcher>
<win useIco="false">
<bmp/>
</win>
</launcher>

<vm>
</vm>

<plugins>
</plugins>

<features>
<feature id="org.eclipse.e4.rcp"/>
<feature id="org.eclipse.emf.ecore"/>
<feature id="org.eclipse.emf.common"/>
<feature id="org.eclipse.fx.runtime.min.feature" installMode="root"/>
<feature id="org.fipro.eclipse.tutorial.feature" installMode="root"/>
<feature id="openjfx.media.feature" installMode="root"/>
<feature id="openjfx.standard.feature" installMode="root"/>
<feature id="openjfx.swt.feature" installMode="root"/>
<feature id="openjfx.web.feature" installMode="root"/>
</features>

<configurations>
<plugin id="org.apache.felix.scr" autoStart="true" startLevel="2" />
<plugin id="org.eclipse.core.runtime" autoStart="true" startLevel="0" />
<plugin id="org.eclipse.equinox.common" autoStart="true" startLevel="2" />
<plugin id="org.eclipse.equinox.event" autoStart="true" startLevel="2" />
<plugin id="org.eclipse.equinox.simpleconfigurator" autoStart="true" startLevel="1" />
</configurations>

</product>
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<?pde version="3.5"?>

<product name="E4 RCP Tutorial App" uid="org.fipro.eclipse.tutorial" id="org.fipro.eclipse.tutorial.app.product" application="org.eclipse.e4.ui.workbench.swt.E4Application" version="1.0.0" useFeatures="true" includeLaunchers="true">
<product name="E4 RCP Tutorial App" uid="org.fipro.eclipse.tutorial" id="org.fipro.eclipse.tutorial.app.product" application="org.eclipse.e4.ui.workbench.swt.E4Application" version="1.0.0" type="features" includeLaunchers="true" autoIncludeRequirements="true">

<configIni use="default">
</configIni>
Expand Down Expand Up @@ -29,15 +29,24 @@
<feature id="org.eclipse.e4.rcp"/>
<feature id="org.eclipse.emf.ecore"/>
<feature id="org.eclipse.emf.common"/>
<feature id="org.eclipse.fx.target.rcp4.feature" installMode="root"/>
<feature id="org.eclipse.equinox.p2.core.feature" installMode="root"/>
<feature id="org.eclipse.ecf.core.feature" installMode="root"/>
<feature id="org.eclipse.ecf.filetransfer.feature" installMode="root"/>
<feature id="org.eclipse.emf.edit" installMode="root"/>
<feature id="org.fipro.eclipse.tutorial.feature" installMode="root"/>
<feature id="openjfx.media.feature" installMode="root"/>
<feature id="openjfx.standard.feature" installMode="root"/>
<feature id="openjfx.swing.feature" installMode="root"/>
<feature id="openjfx.swt.feature" installMode="root"/>
<feature id="openjfx.web.feature" installMode="root"/>
</features>

<configurations>
<plugin id="org.apache.felix.scr" autoStart="true" startLevel="2" />
<plugin id="org.eclipse.core.runtime" autoStart="true" startLevel="0" />
<plugin id="org.eclipse.equinox.common" autoStart="true" startLevel="2" />
<plugin id="org.eclipse.equinox.ds" autoStart="true" startLevel="2" />
<plugin id="org.eclipse.equinox.event" autoStart="true" startLevel="2" />
<plugin id="org.eclipse.equinox.p2.reconciler.dropins" autoStart="true" startLevel="0" />
<plugin id="org.eclipse.equinox.simpleconfigurator" autoStart="true" startLevel="1" />
</configurations>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,35 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?pde?>
<!-- generated with https://github.com/eclipse-cbi/targetplatform-dsl -->
<target name="E4 Cookbook Target Platform" sequenceNumber="1568034040">
<locations>
<location includeMode="planner" includeAllPlatforms="false" includeSource="true" includeConfigurePhase="false" type="InstallableUnit">
<unit id="org.eclipse.equinox.executable.feature.group" version="3.8.400.v20190515-0925"/>
<unit id="org.eclipse.sdk.feature.group" version="4.12.0.v20190605-1801"/>
<repository location="http://download.eclipse.org/releases/2019-06"/>
</location>
</locations>
</target>
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?pde?>
<target name="E4 Cookbook Target Platform">
<locations>
<location includeAllPlatforms="false" includeConfigurePhase="false" includeMode="planner" includeSource="true" type="InstallableUnit">
<repository location="http://download.eclipse.org/releases/2023-09"/>
<unit id="org.eclipse.equinox.executable.feature.group" version="0.0.0"/>
<unit id="org.eclipse.sdk.feature.group" version="0.0.0"/>
<unit id="org.eclipse.equinox.p2.core.feature.feature.group" version="0.0.0"/>
<unit id="org.eclipse.emf.edit.feature.group" version="0.0.0"/>
</location>
<location includeDependencyDepth="infinite" includeDependencyScopes="compile,runtime" includeSource="true" label="Tools Platform Libs" missingManifest="generate" type="Maven">
<dependencies>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>17.0.9</version>

</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-fxml</artifactId>
<version>17.0.9</version>

</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-base</artifactId>
<version>17.0.9</version>

</dependency>
</dependencies>
</location>
</locations>
</target>

This file was deleted.

Loading