Skip to content

Commit

Permalink
[core] Add io.sarl.javafx library into the SDK.
Browse files Browse the repository at this point in the history
see #745
see #342

Signed-off-by: Stéphane Galland <galland@arakhne.org>
  • Loading branch information
gallandarakhneorg committed Jan 30, 2018
1 parent eedfcb6 commit 355e241
Show file tree
Hide file tree
Showing 22 changed files with 634 additions and 5 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Expand Up @@ -15,6 +15,9 @@
**/io.sarl.util/xtend-gen/
**/io.sarl.util/src-gen/
**/io.sarl.util/src/main/generated-sources/
**/io.sarl.javafx/xtend-gen/
**/io.sarl.javafx/src-gen/
**/io.sarl.javafx/src/main/generated-sources/
**/io.sarl.lang.ui/xtend-gen/
**/io.sarl.lang.ui/src/main/xtend-gen/
**/io.sarl.lang.ui/src/main/generated-sources/
Expand Down
4 changes: 2 additions & 2 deletions build-tools/scripts/generate-aggregate-javadoc.sh
@@ -1,10 +1,10 @@
#!/usr/bin/env bash

# With Janus
PLUGIN_MODULES=("./main/coreplugins/io.sarl.lang.core" "./main/apiplugins/io.sarl.core" "./main/apiplugins/io.sarl.util" "./sre/io.janusproject/io.janusproject.plugin")
PLUGIN_MODULES=("./main/coreplugins/io.sarl.lang.core" "./main/apiplugins/io.sarl.core" "./main/apiplugins/io.sarl.util" "./main/apiplugins/io.sarl.javafx" "./sre/io.janusproject/io.janusproject.plugin")

# Without Janus
#PLUGIN_MODULES=("./main/coreplugins/io.sarl.lang.core" "./main/apiplugins/io.sarl.core" "./main/apiplugins/io.sarl.util")
#PLUGIN_MODULES=("./main/coreplugins/io.sarl.lang.core" "./main/apiplugins/io.sarl.core" "./main/apiplugins/io.sarl.util" "./main/apiplugins/io.sarl.javafx")

SOURCE_PATH=""
for module in "${PLUGIN_MODULES[@]}"
Expand Down
1 change: 1 addition & 0 deletions dev-tools/eclipse_workingsets.xml
Expand Up @@ -9,6 +9,7 @@
<item elementID="=io.sarl.m2e" factoryID="org.eclipse.jdt.ui.PersistableJavaElementFactory"/>
<item elementID="=io.sarl.lang.mwe2" factoryID="org.eclipse.jdt.ui.PersistableJavaElementFactory"/>
<item elementID="=io.sarl.eclipse" factoryID="org.eclipse.jdt.ui.PersistableJavaElementFactory"/>
<item elementID="=io.sarl.javafx" factoryID="org.eclipse.jdt.ui.PersistableJavaElementFactory"/>
</workingSet>
<workingSet editPageId="org.eclipse.jdt.ui.JavaWorkingSetPage" factoryID="org.eclipse.ui.internal.WorkingSetFactory" id="1480017504015_3" label="Features" name="Features">
<item factoryID="org.eclipse.ui.internal.model.ResourceFactory" path="/io.sarl.compiler" type="4"/>
Expand Down
11 changes: 11 additions & 0 deletions main/apiplugins/io.sarl.javafx/META-INF/MANIFEST.MF
@@ -0,0 +1,11 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-SymbolicName: io.sarl.javafx;singleton:=true
Bundle-Version: 0.7.0.qualifier
Bundle-Vendor: %Bundle-Vendor
Bundle-Name: %Bundle-Name
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Export-Package: io.sarl.javafx
Require-Bundle: io.sarl.util;bundle-version="0.7.0",
io.sarl.core;bundle-version="0.7.0",
org.eclipse.osgi;bundle-version="3.12.50"
@@ -0,0 +1,3 @@
#Properties file for io.sarl.core
Bundle-Vendor = SARL.io
Bundle-Name = SARL JavaFX
10 changes: 10 additions & 0 deletions main/apiplugins/io.sarl.javafx/build.properties
@@ -0,0 +1,10 @@
source.. = src,\
src-gen
src.excludes = **/*.sarlbin
bin.includes = META-INF/,\
OSGI-INF/,\
.
bin.excludes = **/*.java._trace,\
**/*.sarlbin,\
**/*.sarl
jre.compilation.profile = JavaSE-1.8
120 changes: 120 additions & 0 deletions main/apiplugins/io.sarl.javafx/pom.xml
@@ -0,0 +1,120 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>io.sarl</groupId>
<artifactId>io.sarl.plugins.api</artifactId>
<version>0.7.0-SNAPSHOT</version>
</parent>
<artifactId>io.sarl.javafx</artifactId>
<packaging>eclipse-plugin</packaging>
<name>SDK JavaFX Library</name>

<build>
<plugins>
<plugin>
<groupId>io.sarl.maven</groupId>
<artifactId>sarl-maven-plugin</artifactId>
<!-- Maven extension mechanism seems not working due to the tycho module type.
The different goals must be explicitly provided. -->
<executions>
<execution>
<id>sarl-compiler-init</id>
<phase>initialize</phase>
<goals>
<goal>initialize</goal>
</goals>
</execution>
<execution>
<id>sarl-compiler-compile</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
<execution>
<id>sarl-compiler-clean</id>
<phase>clean</phase>
<goals>
<goal>clean</goal>
</goals>
</execution>
</executions>
<configuration>
<tycho>true</tycho>
<source>${compiler.level}</source>
<target>${compiler.level}</target>
<encoding>${project.build.sourceEncoding}</encoding>
<input>src/</input>
<output>src-gen/</output>
<runJavaCompiler>true</runJavaCompiler>
<generateInlines>true</generateInlines>
<generateStorageFiles>true</generateStorageFiles>
<generateTraceFiles>true</generateTraceFiles>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<configuration>
<sourceDirectories>
<sourceDirectory>src</sourceDirectory>
</sourceDirectories>
</configuration>
</plugin>
</plugins>
</build>

<!-- ======================================= -->
<!-- ==== Release Management === -->
<!-- ======================================= -->
<profiles>
<profile>
<id>default-profile</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-source-plugin</artifactId>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>maven-release-of-javafx-plugin</id>
<activation>
<property>
<name>publicSarlApiModuleSet</name>
<value>true</value>
</property>
</activation>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.arakhne.afc.maven</groupId>
<artifactId>tag-replacer</artifactId>
<configuration>
<sources>
<source>${project.basedir}/src</source>
<source>${project.basedir}/src-gen</source>
</sources>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<configuration>
<sourcepath>${project.build.directory}/generated-sources/java</sourcepath>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
</profile>
</profiles>

</project>
72 changes: 72 additions & 0 deletions main/apiplugins/io.sarl.javafx/src/io/sarl/javafx/FXBehavior.sarl
@@ -0,0 +1,72 @@
/*
* $Id$
*
* SARL is an general-purpose agent programming language.
* More details on http://www.sarl.io
*
* Copyright (C) 2014-2018 the original authors or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package io.sarl.javafx

import io.sarl.lang.core.Agent
import io.sarl.core.AgentKilled
import io.sarl.core.Behaviors
import io.sarl.core.InnerContextAccess
import io.sarl.core.Lifecycle

/** Specific behavior for an agent that enables it to interact with
* a JavaFX user interface.
*
* @author $Author: sgalland$
* @version $FullVersion$
* @mavengroupid $GroupId$
* @mavenartifactid $ArtifactId$
* @since 0.7
*/
behavior FXBehavior {

uses Lifecycle, InnerContextAccess, Behaviors

var exited = false

/** Constructor.
*
* @param controller the JavaFX controller to be linked to.
*/
new (owner : Agent, controller : FxViewerController) {
super(owner)
controller.UISpace.register(asEventListener)
}


/** Kill itself on Exit signal when no inner agent.
*/
on AppExit [!hasMemberAgent] {
killMe
}

/** Transmit Exit signal to all inner agent.
*/
on AppExit [!exited && hasMemberAgent] {
exited = true
innerContext.defaultSpace.emit(ID, new AppExit)
}

on AgentKilled [exited && it.inInnerDefaultSpace && !hasMemberAgent] {
killMe
}

}
@@ -0,0 +1,69 @@
/*
* $Id$
*
* SARL is an general-purpose agent programming language.
* More details on http://www.sarl.io
*
* Copyright (C) 2014-2018 the original authors or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package io.sarl.javafx

import javafx.application.Application
import javafx.fxml.FXMLLoader
import javafx.stage.Stage

/**
* Abstract implementation of a JavaFX application that is embedding SARL agents.
*
* @author $Author: sgalland$
* @version $FullVersion$
* @mavengroupid $GroupId$
* @mavenartifactid $ArtifactId$
* @since 0.7
*/
abstract class FxApplication extends Application {

/** The JavaFX loader.
*/
var loader : FXMLLoader

/** Start the JavaFX application.
*
* @param stage the JavaFX stage.
*/
final override start(stage : Stage) {
this.loader = stage.doApplicationStart
stage.show
}

/** Kill the agents and stop the JavaFX application.
*/
override stop {
if (loader !== null && loader.controller instanceof FxViewerController) {
(loader.controller as FxViewerController).safeExit
}
super.stop
}

/** Start the application. This function must be overridden within the application software
* in order to initialize the JavaFX user interface that is dedicated to the application.
*
* @param stage the JavaFX stage. That is used for initializing JavaFX.
* @return the loader of FXML, i.e. of uuser interface, that is dedicated to the application.
*/
protected abstract def doApplicationStart(stage : Stage) : FXMLLoader

}
32 changes: 32 additions & 0 deletions main/apiplugins/io.sarl.javafx/src/io/sarl/javafx/FxEvents.sarl
@@ -0,0 +1,32 @@
/*
* $Id$
*
* SARL is an general-purpose agent programming language.
* More details on http://www.sarl.io
*
* Copyright (C) 2014-2018 the original authors or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package io.sarl.javafx

/* Triggered when the JavaFX application needs to be exited.
*
* @author $Author: sgalland$
* @version $FullVersion$
* @mavengroupid $GroupId$
* @mavenartifactid $ArtifactId$
* @since 0.7
*/
event AppExit

0 comments on commit 355e241

Please sign in to comment.