Upgraded outlaw editor to Java 17, had to remove OSGi plugin support (we never used it)
This commit is contained in:
parent
c2bf0cd744
commit
37a9d805fd
|
@ -1 +1 @@
|
|||
1.8
|
||||
graalvm64-17.0.6
|
||||
|
|
|
@ -1,71 +0,0 @@
|
|||
<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>
|
||||
|
||||
<groupId>org.badvision</groupId>
|
||||
<artifactId>OutlawPluginExample</artifactId>
|
||||
<version>0.1</version>
|
||||
<packaging>bundle</packaging>
|
||||
|
||||
<name>Outlaw Plugin Example</name>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<maven.compiler.source>1.8</maven.compiler.source>
|
||||
<maven.compiler.target>1.8</maven.compiler.target>
|
||||
</properties>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.felix</groupId>
|
||||
<artifactId>maven-bundle-plugin</artifactId>
|
||||
<version>3.0.1</version>
|
||||
<extensions>true</extensions>
|
||||
<configuration>
|
||||
<instructions>
|
||||
<Export-Package>org.badvision.outlaw.plugin.example</Export-Package>
|
||||
<Bundle-Activator>org.badvision.outlaw.plugin.example.Activator</Bundle-Activator>
|
||||
<Export-Service>*</Export-Service>
|
||||
</instructions>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.felix</groupId>
|
||||
<artifactId>maven-scr-plugin</artifactId>
|
||||
<version>1.22.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>generate-scr-scrdescriptor</id>
|
||||
<goals>
|
||||
<goal>scr</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<properties>
|
||||
<service.vendor>8-Bit Bunch</service.vendor>
|
||||
</properties>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.badvision</groupId>
|
||||
<artifactId>OutlawEditor</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.felix</groupId>
|
||||
<artifactId>org.apache.felix.scr.annotations</artifactId>
|
||||
<version>1.10.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.felix</groupId>
|
||||
<artifactId>org.apache.felix.main</artifactId>
|
||||
<version>5.4.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
|
@ -1,47 +0,0 @@
|
|||
package org.badvision.outlaw.plugin.example;
|
||||
|
||||
import org.badvision.outlaweditor.api.ApplicationState;
|
||||
import org.osgi.framework.BundleActivator;
|
||||
import org.osgi.framework.BundleContext;
|
||||
|
||||
/**
|
||||
* This is an example activator class, provided to demonstrate basic bundle lifecycle events.
|
||||
* Since we're using declarative servies (Felix SCR), all the messy bits of service registration
|
||||
* and reference passing are managed for us. Otherwise we'd be doing that here. Fortunately,
|
||||
* we don't have to do all that.
|
||||
*
|
||||
* Still, this is a useful mechanism if you have some one-time setup or shutdown concerns that apply
|
||||
* to your whole bundle, such as reading configuration data from a file or whatever.
|
||||
*
|
||||
* @author blurry
|
||||
*/
|
||||
public class Activator implements BundleActivator {
|
||||
@Override
|
||||
public void start(BundleContext bc) throws Exception {
|
||||
System.out.println("Hello, plugin!");
|
||||
checkReferences();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stop(BundleContext bc) throws Exception {
|
||||
System.out.println("Goodbye, plugin!");
|
||||
}
|
||||
|
||||
private void checkReferences() {
|
||||
// Note that our activator is not a component, so we can't use the @Reference
|
||||
// annotation to inject app automatically. ApplicationState has a convenience
|
||||
// method to get around this in just such events, but it's a hack.
|
||||
// Ultimately it's not a good idea to rely on this too much as it follows
|
||||
// some bad practices behind the scene that leave unclosed references, etc.
|
||||
// I'll have to come up with a safer way to inject dependencies without
|
||||
// causing housekeeping issues for OSGi.
|
||||
ApplicationState app = ApplicationState.getInstance();
|
||||
if (app == null) {
|
||||
System.out.println("App is null?!?!");
|
||||
} else if (app.getCurrentPlatform() == null) {
|
||||
System.out.println("Current platform is null?");
|
||||
} else {
|
||||
System.out.println("Current platform is " + app.getCurrentPlatform());
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,72 +0,0 @@
|
|||
package org.badvision.outlaw.plugin.example;
|
||||
|
||||
import javafx.event.ActionEvent;
|
||||
import javax.xml.bind.JAXB;
|
||||
import org.apache.felix.scr.annotations.Activate;
|
||||
import org.apache.felix.scr.annotations.Component;
|
||||
import org.apache.felix.scr.annotations.Deactivate;
|
||||
import org.apache.felix.scr.annotations.Reference;
|
||||
import org.apache.felix.scr.annotations.Service;
|
||||
import org.badvision.outlaweditor.api.ApplicationState;
|
||||
import org.badvision.outlaweditor.api.MenuAction;
|
||||
import org.badvision.outlaweditor.ui.UIAction;
|
||||
import org.osgi.framework.BundleContext;
|
||||
|
||||
/**
|
||||
* This registers a simple plugin that does nothing more than print a message to
|
||||
* the console when executed. However, this plugin also demonstrates how to
|
||||
* inject dependencies to more useful features, specifically the
|
||||
* ApplicationState which in turn provides all game data, etc.
|
||||
*
|
||||
* @author blurry
|
||||
*/
|
||||
@Component(immediate = true)
|
||||
@Service(MenuAction.class)
|
||||
public class ExamplePlugin implements MenuAction {
|
||||
|
||||
// Note: Because ApplicationState is already a defined service, this will automatically be bound.
|
||||
// Hence, it is not necessary to worry about passing it it.
|
||||
@Reference
|
||||
ApplicationState app;
|
||||
|
||||
// This is called when our plugin is starting
|
||||
@Activate
|
||||
public void activate() throws Exception {
|
||||
System.out.println("Hello, menu!");
|
||||
checkReferences();
|
||||
}
|
||||
|
||||
// This is called when our plugin is stopping
|
||||
@Deactivate
|
||||
public void stop(BundleContext bc) throws Exception {
|
||||
System.out.println("Goodbye, menu!");
|
||||
}
|
||||
|
||||
// This identifies the menu item label
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Example action";
|
||||
}
|
||||
|
||||
// This method is called when the user selects the menu item
|
||||
@Override
|
||||
public void handle(ActionEvent event) {
|
||||
System.out.println("Clicked!");
|
||||
JAXB.marshal(ApplicationState.getInstance().getGameData(), System.out);
|
||||
checkReferences();
|
||||
UIAction.confirm("Did you mean to click that?",
|
||||
() -> UIAction.alert("Well isn't that special?"),
|
||||
() -> UIAction.alert("You should be more careful next time then."));
|
||||
}
|
||||
|
||||
private void checkReferences() {
|
||||
// app = ApplicationState.getInstance();
|
||||
if (app == null) {
|
||||
System.out.println("App is null?!?!");
|
||||
} else if (app.getCurrentPlatform() == null) {
|
||||
System.out.println("Current platform is null?");
|
||||
} else {
|
||||
System.out.println("Current platform is " + app.getCurrentPlatform());
|
||||
}
|
||||
}
|
||||
}
|
|
@ -5,11 +5,13 @@
|
|||
<artifactId>OutlawEditor</artifactId>
|
||||
<name>OutlawEditor</name>
|
||||
<packaging>jar</packaging>
|
||||
<version>2.0-SNAPSHOT</version>
|
||||
<version>3.0-SNAPSHOT</version>
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<mainClass>org.badvision.outlaweditor.Application</mainClass>
|
||||
<netbeans.hint.license>apache20</netbeans.hint.license>
|
||||
<javafx.version>21-ea+31</javafx.version>
|
||||
<poi.version>5.2.3</poi.version>
|
||||
</properties>
|
||||
|
||||
<organization>
|
||||
|
@ -20,110 +22,61 @@
|
|||
<finalName>OutlawEditor</finalName>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.felix</groupId>
|
||||
<artifactId>maven-scr-plugin</artifactId>
|
||||
<version>1.26.4</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>generate-scr-scrdescriptor</id>
|
||||
<goals>
|
||||
<goal>scr</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<properties>
|
||||
<service.vendor>8-Bit Bunch</service.vendor>
|
||||
</properties>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.felix</groupId>
|
||||
<artifactId>maven-bundle-plugin</artifactId>
|
||||
<version>5.1.2</version>
|
||||
<extensions>true</extensions>
|
||||
<groupId>com.gluonhq</groupId>
|
||||
<artifactId>gluonfx-maven-plugin</artifactId>
|
||||
<version>1.0.19</version>
|
||||
<configuration>
|
||||
<instructions>
|
||||
<Private-Package>org.badvision.outlaweditor,org.badvision.outlaweditor.ui.impl,org.badvision.outlaweditor.ui.apple</Private-Package>
|
||||
<Export-Package>org.badvision.outlaweditor.api,org.badvision.outlaweditor.data.xml,org.badvision.outlaweditor.data,org.badvision.outlaweditor.ui</Export-Package>
|
||||
</instructions>
|
||||
<mainClass>${mainClass}</mainClass>
|
||||
<options>
|
||||
<option>--add-exports</option>
|
||||
<option>javafx.base/com.sun.javafx.event=org.controlsfx.controls</option>
|
||||
<option>--add-exports</option>
|
||||
<option>javafx.controls/com.sun.javafx.scene.control.behavior=org.controlsfx.controls</option>
|
||||
</options>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-dependency-plugin</artifactId>
|
||||
<version>3.1.2</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>unpack-dependencies</id>
|
||||
<phase>prepare-package</phase>
|
||||
<goals>
|
||||
<goal>unpack-dependencies</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<excludes>META-INF/*.SF,META-INF/*.DSA,META-INF/*.RSA</excludes>
|
||||
<excludeScope>system</excludeScope>
|
||||
<excludeGroupIds>junit,org.mockito,org.hamcrest</excludeGroupIds>
|
||||
<outputDirectory>${project.build.directory}/classes</outputDirectory>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<groupId>org.openjfx</groupId>
|
||||
<artifactId>javafx-maven-plugin</artifactId>
|
||||
<version>0.0.8</version>
|
||||
<configuration>
|
||||
<archive>
|
||||
<manifest>
|
||||
<mainClass>${mainClass}</mainClass>
|
||||
</manifest>
|
||||
</archive>
|
||||
<mainClass>${mainClass}</mainClass>
|
||||
<options>
|
||||
<option>--add-exports</option>
|
||||
<option>javafx.base/com.sun.javafx.event=org.controlsfx.controls</option>
|
||||
<option>--add-exports</option>
|
||||
<option>javafx.controls/com.sun.javafx.scene.control.behavior=org.controlsfx.controls</option>
|
||||
</options>
|
||||
</configuration>
|
||||
<version>3.2.0</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
<source>17</source>
|
||||
<target>17</target>
|
||||
</configuration>
|
||||
<version>3.8.1</version>
|
||||
<version>3.11.0</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.jvnet.jaxb2.maven2</groupId>
|
||||
<artifactId>maven-jaxb2-plugin</artifactId>
|
||||
<version>0.14.0</version>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>jaxb2-maven-plugin</artifactId>
|
||||
<version>3.1.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>xjc</id>
|
||||
<goals>
|
||||
<goal>generate</goal>
|
||||
<goal>xjc</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<schemaIncludes>
|
||||
<include>jaxb/OutlawSchema/*.xsd</include>
|
||||
</schemaIncludes>
|
||||
<episodeFile>${project.build.directory}/generated-sources/xjc/META-INF/jaxb-OutlawSchema.episode</episodeFile>
|
||||
<generatePackage>org.badvision.outlaweditor.data.xml</generatePackage>
|
||||
<args>
|
||||
<arg>-Xcopyable</arg>
|
||||
<arg>-Xmergeable</arg>
|
||||
</args>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.jvnet.jaxb2_commons</groupId>
|
||||
<artifactId>jaxb2-basics</artifactId>
|
||||
<version>0.12.0</version>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</configuration>
|
||||
<id>jaxb-generate-OutlawSchema</id>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<sources>src/main/resources/jaxb</sources>
|
||||
<packageName>org.badvision.outlaweditor.data.xml</packageName>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
|
@ -133,44 +86,45 @@
|
|||
<type>jar</type>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jvnet.jaxb2_commons</groupId>
|
||||
<artifactId>jaxb2-basics</artifactId>
|
||||
<version>0.12.0</version>
|
||||
<groupId>jakarta.xml.bind</groupId>
|
||||
<artifactId>jakarta.xml.bind-api</artifactId>
|
||||
<version>4.0.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.felix</groupId>
|
||||
<artifactId>org.apache.felix.framework</artifactId>
|
||||
<version>5.6.10</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.felix</groupId>
|
||||
<artifactId>org.apache.felix.main</artifactId>
|
||||
<version>5.6.10</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.felix</groupId>
|
||||
<artifactId>org.apache.felix.scr.annotations</artifactId>
|
||||
<version>1.12.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.felix</groupId>
|
||||
<artifactId>org.apache.felix.scr</artifactId>
|
||||
<version>2.1.26</version>
|
||||
</dependency>
|
||||
<groupId>com.sun.xml.bind</groupId>
|
||||
<artifactId>jaxb-impl</artifactId>
|
||||
<version>4.0.3</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi</artifactId>
|
||||
<version>5.0.0</version>
|
||||
<version>${poi.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi-ooxml</artifactId>
|
||||
<version>5.0.0</version>
|
||||
<version>${poi.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.controlsfx</groupId>
|
||||
<artifactId>controlsfx</artifactId>
|
||||
<version>8.40.18</version>
|
||||
<version>11.1.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.openjfx</groupId>
|
||||
<artifactId>javafx-controls</artifactId>
|
||||
<version>${javafx.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.openjfx</groupId>
|
||||
<artifactId>javafx-web</artifactId>
|
||||
<version>${javafx.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.openjfx</groupId>
|
||||
<artifactId>javafx-fxml</artifactId>
|
||||
<version>${javafx.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
|
@ -0,0 +1,21 @@
|
|||
module outlaweditor {
|
||||
requires org.controlsfx.controls;
|
||||
requires javafx.controls;
|
||||
requires javafx.graphics;
|
||||
requires jdk.jsobject;
|
||||
requires javafx.web;
|
||||
requires javafx.media;
|
||||
requires javafx.fxml;
|
||||
requires java.logging;
|
||||
requires java.desktop;
|
||||
requires java.scripting;
|
||||
requires java.xml;
|
||||
requires jakarta.xml.bind;
|
||||
requires org.apache.poi.ooxml;
|
||||
|
||||
opens org.badvision.outlaweditor to javafx.graphics, javafx.fxml, javafx.web, org.apache.poi.ooxml;
|
||||
opens org.badvision.outlaweditor.ui to javafx.fxml;
|
||||
opens org.badvision.outlaweditor.ui.impl to javafx.fxml;
|
||||
opens org.badvision.outlaweditor.data to jakarta.xml.bind;
|
||||
opens org.badvision.outlaweditor.data.xml to javafx.base, jakarta.xml.bind, javafx.web;
|
||||
}
|
|
@ -10,54 +10,59 @@
|
|||
package org.badvision.outlaweditor;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.badvision.outlaweditor.api.ApplicationState;
|
||||
import org.badvision.outlaweditor.api.Platform;
|
||||
import org.badvision.outlaweditor.data.xml.GameData;
|
||||
import org.badvision.outlaweditor.ui.ApplicationUIController;
|
||||
|
||||
import javafx.fxml.FXMLLoader;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.layout.AnchorPane;
|
||||
import javafx.stage.Stage;
|
||||
import javafx.stage.WindowEvent;
|
||||
import org.apache.felix.framework.Felix;
|
||||
import org.apache.felix.framework.util.FelixConstants;
|
||||
import org.apache.felix.main.AutoProcessor;
|
||||
import org.apache.felix.scr.annotations.Component;
|
||||
import org.apache.felix.scr.annotations.Service;
|
||||
import org.apache.felix.scr.impl.Activator;
|
||||
import org.badvision.outlaweditor.api.ApplicationState;
|
||||
import org.badvision.outlaweditor.api.MenuAction;
|
||||
import org.badvision.outlaweditor.api.Platform;
|
||||
import org.badvision.outlaweditor.data.xml.GameData;
|
||||
import org.badvision.outlaweditor.ui.ApplicationUIController;
|
||||
import org.osgi.framework.BundleActivator;
|
||||
import org.osgi.framework.BundleContext;
|
||||
import org.osgi.framework.BundleException;
|
||||
import org.osgi.framework.launch.Framework;
|
||||
import org.osgi.util.tracker.ServiceTracker;
|
||||
// import org.apache.felix.scr.annotations.Component;
|
||||
// import org.apache.felix.scr.annotations.Service;
|
||||
// import org.apache.felix.scr.impl.Activator;
|
||||
// import org.badvision.outlaweditor.api.ApplicationState;
|
||||
// import org.badvision.outlaweditor.api.MenuAction;
|
||||
// import org.badvision.outlaweditor.api.Platform;
|
||||
// import org.badvision.outlaweditor.data.xml.GameData;
|
||||
// import org.badvision.outlaweditor.ui.ApplicationUIController;
|
||||
// import org.apache.felix.framework.Felix;
|
||||
// import org.apache.felix.framework.util.FelixConstants;
|
||||
// import org.apache.felix.main.AutoProcessor;
|
||||
// import org.osgi.framework.BundleActivator;
|
||||
// import org.osgi.framework.BundleContext;
|
||||
// import org.osgi.framework.BundleException;
|
||||
// import org.osgi.framework.launch.Framework;
|
||||
// import org.osgi.util.tracker.ServiceTracker;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author brobert
|
||||
*/
|
||||
@Component
|
||||
@Service(org.badvision.outlaweditor.api.ApplicationState.class)
|
||||
public class Application extends javafx.application.Application implements ApplicationState, BundleActivator {
|
||||
// @Component
|
||||
// @Service(org.badvision.outlaweditor.api.ApplicationState.class)
|
||||
public class Application extends javafx.application.Application implements ApplicationState/*, BundleActivator*/ {
|
||||
|
||||
public static Framework felix;
|
||||
// public static Framework felix;
|
||||
private GameData gameData = new GameData();
|
||||
private Platform currentPlatform = Platform.AppleII;
|
||||
private ApplicationUIController controller;
|
||||
private Stage primaryStage;
|
||||
|
||||
public static void shutdown() {
|
||||
/*
|
||||
try {
|
||||
felix.stop();
|
||||
felix.waitForStop(0L);
|
||||
} catch (BundleException | InterruptedException ex) {
|
||||
Logger.getLogger(Application.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
*/
|
||||
}
|
||||
public static ApplicationState applicationStateSingleton;
|
||||
|
||||
@Override
|
||||
public GameData getGameData() {
|
||||
|
@ -96,16 +101,17 @@ public class Application extends javafx.application.Application implements Appli
|
|||
|
||||
@Override
|
||||
public void start(Stage primaryStage) {
|
||||
applicationStateSingleton = this;
|
||||
this.primaryStage = primaryStage;
|
||||
javafx.application.Platform.setImplicitExit(true);
|
||||
|
||||
/*
|
||||
try {
|
||||
startPluginContainer();
|
||||
} catch (Exception ex) {
|
||||
Logger.getLogger(Application.class.getName()).log(Level.SEVERE, null, ex);
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
|
||||
*/
|
||||
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/ApplicationUI.fxml"));
|
||||
fxmlLoader.setResources(null);
|
||||
try {
|
||||
|
@ -135,6 +141,7 @@ public class Application extends javafx.application.Application implements Appli
|
|||
launch(args);
|
||||
}
|
||||
|
||||
/*
|
||||
ServiceTracker tracker;
|
||||
private void startPluginContainer() throws BundleException, Exception {
|
||||
Map<String, String> config = new HashMap<>();
|
||||
|
@ -175,4 +182,5 @@ public class Application extends javafx.application.Application implements Appli
|
|||
@Override
|
||||
public void stop(BundleContext bc) throws Exception {
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
|
|
@ -13,12 +13,13 @@ package org.badvision.outlaweditor;
|
|||
import java.util.LinkedList;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import javafx.scene.layout.Pane;
|
||||
import javax.xml.bind.JAXBException;
|
||||
|
||||
import org.badvision.outlaweditor.data.DataObserver;
|
||||
import org.badvision.outlaweditor.data.DataProducer;
|
||||
import org.badvision.outlaweditor.data.xml.Script;
|
||||
import org.jvnet.jaxb2_commons.lang.CopyTo2;
|
||||
|
||||
import jakarta.xml.bind.JAXBException;
|
||||
import javafx.scene.layout.Pane;
|
||||
|
||||
/**
|
||||
* Extremely generic editor abstraction -- useful for uniform edit features
|
||||
|
@ -107,8 +108,8 @@ public abstract class Editor<T, D> implements DataObserver<T> {
|
|||
|
||||
public void undo() {
|
||||
if (!undoStates.isEmpty()) {
|
||||
CopyTo2 undoState = (CopyTo2) undoStates.removeFirst();
|
||||
undoState.copyTo(getEntity());
|
||||
T undoState = undoStates.removeFirst();
|
||||
setEntity(undoState);
|
||||
onEntityUpdated();
|
||||
redraw();
|
||||
}
|
||||
|
|
|
@ -17,6 +17,18 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
|||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.badvision.outlaweditor.api.ApplicationState;
|
||||
import org.badvision.outlaweditor.data.TileMap;
|
||||
import org.badvision.outlaweditor.data.TileUtils;
|
||||
import org.badvision.outlaweditor.data.xml.Map;
|
||||
import org.badvision.outlaweditor.data.xml.Script;
|
||||
import org.badvision.outlaweditor.data.xml.Scripts;
|
||||
import org.badvision.outlaweditor.data.xml.Tile;
|
||||
import org.badvision.outlaweditor.ui.TileSelectModal;
|
||||
import org.badvision.outlaweditor.ui.ToolType;
|
||||
|
||||
import jakarta.xml.bind.JAXBException;
|
||||
import javafx.application.Platform;
|
||||
import javafx.beans.property.SimpleStringProperty;
|
||||
import javafx.beans.property.StringProperty;
|
||||
|
@ -42,16 +54,6 @@ import javafx.scene.paint.Color;
|
|||
import javafx.scene.paint.Paint;
|
||||
import javafx.scene.shape.Rectangle;
|
||||
import javafx.stage.Stage;
|
||||
import javax.xml.bind.JAXBException;
|
||||
import org.badvision.outlaweditor.api.ApplicationState;
|
||||
import org.badvision.outlaweditor.data.TileMap;
|
||||
import org.badvision.outlaweditor.data.TileUtils;
|
||||
import org.badvision.outlaweditor.data.xml.Map;
|
||||
import org.badvision.outlaweditor.data.xml.Script;
|
||||
import org.badvision.outlaweditor.data.xml.Scripts;
|
||||
import org.badvision.outlaweditor.data.xml.Tile;
|
||||
import org.badvision.outlaweditor.ui.TileSelectModal;
|
||||
import org.badvision.outlaweditor.ui.ToolType;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -101,7 +103,7 @@ public class MapEditor extends Editor<Map, MapEditor.DrawMode> implements EventH
|
|||
this.drawMode = drawMode;
|
||||
switch (drawMode) {
|
||||
case TileEraser:
|
||||
ImageCursor cursor = new ImageCursor(new Image("images/eraser.png"));
|
||||
ImageCursor cursor = new ImageCursor(new Image(MapEditor.class.getResourceAsStream("/images/eraser.png")));
|
||||
drawCanvas.setCursor(cursor);
|
||||
break;
|
||||
case Select:
|
||||
|
|
|
@ -13,9 +13,7 @@ import java.io.ByteArrayInputStream;
|
|||
import java.io.IOException;
|
||||
import java.io.StringWriter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.logging.Level;
|
||||
|
@ -23,19 +21,12 @@ import java.util.logging.Logger;
|
|||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
import javafx.fxml.FXMLLoader;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.layout.AnchorPane;
|
||||
import javafx.stage.Stage;
|
||||
import javafx.stage.WindowEvent;
|
||||
import javax.xml.bind.JAXBContext;
|
||||
import javax.xml.bind.JAXBElement;
|
||||
import javax.xml.bind.JAXBException;
|
||||
import javax.xml.bind.Unmarshaller;
|
||||
|
||||
import javax.xml.namespace.QName;
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
|
||||
import org.badvision.outlaweditor.api.ApplicationState;
|
||||
import static org.badvision.outlaweditor.data.DataUtilities.extract;
|
||||
import static org.badvision.outlaweditor.data.DataUtilities.extractFirst;
|
||||
|
@ -56,6 +47,16 @@ import org.badvision.outlaweditor.ui.MythosScriptEditorController;
|
|||
import org.w3c.dom.Document;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
import jakarta.xml.bind.JAXBContext;
|
||||
import jakarta.xml.bind.JAXBElement;
|
||||
import jakarta.xml.bind.JAXBException;
|
||||
import jakarta.xml.bind.Unmarshaller;
|
||||
import javafx.fxml.FXMLLoader;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.layout.AnchorPane;
|
||||
import javafx.stage.Stage;
|
||||
import javafx.stage.WindowEvent;
|
||||
|
||||
/**
|
||||
* Mythos Scripting Editor
|
||||
*
|
||||
|
@ -80,9 +81,6 @@ public class MythosEditor {
|
|||
public void show() {
|
||||
primaryStage = new Stage();
|
||||
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/MythosScriptEditor.fxml"));
|
||||
Map<String, String> properties = new HashMap<>();
|
||||
properties.put(MythosScriptEditorController.ONLOAD_SCRIPT, generateLoadScript());
|
||||
fxmlLoader.setResources(MythosScriptEditorController.createResourceBundle(properties));
|
||||
try {
|
||||
AnchorPane node = (AnchorPane) fxmlLoader.load();
|
||||
controller = fxmlLoader.getController();
|
||||
|
|
|
@ -12,7 +12,16 @@ package org.badvision.outlaweditor;
|
|||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
import javafx.scene.ImageCursor;
|
||||
|
||||
import javax.xml.namespace.QName;
|
||||
|
||||
import org.badvision.outlaweditor.ui.ToolType;
|
||||
|
||||
import jakarta.xml.bind.JAXBContext;
|
||||
import jakarta.xml.bind.JAXBElement;
|
||||
import jakarta.xml.bind.JAXBException;
|
||||
import jakarta.xml.bind.Marshaller;
|
||||
import jakarta.xml.bind.util.JAXBSource;
|
||||
import javafx.scene.Node;
|
||||
import javafx.scene.input.ClipboardContent;
|
||||
import javafx.scene.input.DataFormat;
|
||||
|
@ -20,14 +29,6 @@ import javafx.scene.input.DragEvent;
|
|||
import javafx.scene.input.Dragboard;
|
||||
import javafx.scene.input.MouseEvent;
|
||||
import javafx.scene.input.TransferMode;
|
||||
import javax.xml.bind.JAXBContext;
|
||||
import javax.xml.bind.JAXBElement;
|
||||
import javax.xml.bind.JAXBException;
|
||||
import javax.xml.bind.Marshaller;
|
||||
import javax.xml.bind.util.JAXBSource;
|
||||
import javax.xml.namespace.QName;
|
||||
import org.badvision.outlaweditor.data.xml.Script;
|
||||
import org.badvision.outlaweditor.ui.ToolType;
|
||||
|
||||
/**
|
||||
* Simplify management of drag/drop operations
|
||||
|
|
|
@ -15,12 +15,12 @@
|
|||
*/
|
||||
package org.badvision.outlaweditor.api;
|
||||
|
||||
import javafx.stage.Stage;
|
||||
import org.badvision.outlaweditor.Application;
|
||||
import org.badvision.outlaweditor.data.xml.GameData;
|
||||
import org.badvision.outlaweditor.ui.ApplicationUIController;
|
||||
import org.osgi.framework.BundleContext;
|
||||
import org.osgi.framework.FrameworkUtil;
|
||||
|
||||
import javafx.stage.Stage;
|
||||
// import org.osgi.framework.BundleContext;
|
||||
// import org.osgi.framework.FrameworkUtil;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -40,7 +40,7 @@ public interface ApplicationState {
|
|||
public ApplicationUIController getController();
|
||||
|
||||
public Stage getPrimaryStage();
|
||||
|
||||
/*
|
||||
static public BundleContext getBundleContext() {
|
||||
if (Application.felix != null) {
|
||||
return Application.felix.getBundleContext();
|
||||
|
@ -53,5 +53,9 @@ public interface ApplicationState {
|
|||
BundleContext bc = getBundleContext();
|
||||
return bc.getService(bc.getServiceReference(ApplicationState.class));
|
||||
}
|
||||
*/
|
||||
public static ApplicationState getInstance() {
|
||||
return org.badvision.outlaweditor.Application.applicationStateSingleton;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -27,15 +27,15 @@ import javafx.beans.property.adapter.JavaBeanStringPropertyBuilder;
|
|||
public class PropertyHelper {
|
||||
|
||||
public static JavaBeanIntegerProperty intProp(Object t, String fieldName) throws NoSuchMethodException {
|
||||
return new JavaBeanIntegerPropertyBuilder().bean(t).name(fieldName).build();
|
||||
return JavaBeanIntegerPropertyBuilder.create().bean(t).name(fieldName).build();
|
||||
}
|
||||
|
||||
public static JavaBeanBooleanProperty boolProp(Object t, String fieldName) throws NoSuchMethodException {
|
||||
return new JavaBeanBooleanPropertyBuilder().bean(t).name(fieldName).build();
|
||||
return JavaBeanBooleanPropertyBuilder.create().bean(t).name(fieldName).build();
|
||||
}
|
||||
|
||||
public static JavaBeanStringProperty stringProp(Object t, String fieldName) throws NoSuchMethodException {
|
||||
return new JavaBeanStringPropertyBuilder().bean(t).name(fieldName).build();
|
||||
return JavaBeanStringPropertyBuilder.create().bean(t).name(fieldName).build();
|
||||
}
|
||||
|
||||
private static final Map<Property, Property> boundProperties = new HashMap<>();
|
||||
|
|
|
@ -17,11 +17,7 @@ import java.util.HashSet;
|
|||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import javafx.scene.control.Alert;
|
||||
import javafx.scene.image.WritableImage;
|
||||
import javafx.scene.paint.Color;
|
||||
import javax.xml.bind.JAXBElement;
|
||||
import org.badvision.outlaweditor.Application;
|
||||
|
||||
import org.badvision.outlaweditor.api.ApplicationState;
|
||||
import org.badvision.outlaweditor.api.Platform;
|
||||
import org.badvision.outlaweditor.data.xml.Map;
|
||||
|
@ -33,6 +29,11 @@ import org.badvision.outlaweditor.data.xml.Scripts;
|
|||
import org.badvision.outlaweditor.data.xml.Tile;
|
||||
import org.badvision.outlaweditor.ui.UIAction;
|
||||
|
||||
import jakarta.xml.bind.JAXBElement;
|
||||
import javafx.scene.control.Alert;
|
||||
import javafx.scene.image.WritableImage;
|
||||
import javafx.scene.paint.Color;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author brobert
|
||||
|
|
|
@ -10,17 +10,14 @@
|
|||
package org.badvision.outlaweditor.spelling;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.URL;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.badvision.outlaweditor.data.DataUtilities;
|
||||
|
||||
/**
|
||||
|
@ -54,22 +51,18 @@ public class SpellChecker {
|
|||
|
||||
private static void loadDictionary() {
|
||||
if (dictionary == null) {
|
||||
URL dictionaryPath = SpellChecker.class.getResource("/mythos/dictionary.txt");
|
||||
try {
|
||||
BufferedReader content = new BufferedReader(new InputStreamReader((InputStream) dictionaryPath.getContent()));
|
||||
dictionary = new HashMap<>();
|
||||
content.lines().forEach((String word)-> {
|
||||
String lower = word.toLowerCase();
|
||||
Set<String> words = dictionary.get(lower.charAt(0));
|
||||
if (words == null) {
|
||||
words = new LinkedHashSet<>();
|
||||
dictionary.put(lower.charAt(0), words);
|
||||
}
|
||||
words.add(word);
|
||||
});
|
||||
} catch (IOException ex) {
|
||||
Logger.getLogger(SpellChecker.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
InputStream dictionaryStream = SpellChecker.class.getResourceAsStream("/mythos/dictionary.txt");
|
||||
BufferedReader content = new BufferedReader(new InputStreamReader(dictionaryStream));
|
||||
dictionary = new HashMap<>();
|
||||
content.lines().forEach((String word)-> {
|
||||
String lower = word.toLowerCase();
|
||||
Set<String> words = dictionary.get(lower.charAt(0));
|
||||
if (words == null) {
|
||||
words = new LinkedHashSet<>();
|
||||
dictionary.put(lower.charAt(0), words);
|
||||
}
|
||||
words.add(word);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
|
||||
package org.badvision.outlaweditor.ui;
|
||||
|
||||
import com.sun.glass.ui.Application;
|
||||
import java.beans.BeanInfo;
|
||||
import java.beans.IntrospectionException;
|
||||
import java.beans.Introspector;
|
||||
|
@ -23,6 +22,9 @@ import java.util.Optional;
|
|||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import static org.badvision.outlaweditor.data.DataUtilities.uppercaseFirst;
|
||||
|
||||
import javafx.application.Platform;
|
||||
import javafx.beans.property.adapter.JavaBeanStringPropertyBuilder;
|
||||
import javafx.beans.value.ObservableValue;
|
||||
|
@ -43,7 +45,6 @@ import javafx.scene.layout.GridPane;
|
|||
import javafx.scene.layout.HBox;
|
||||
import javafx.scene.layout.VBox;
|
||||
import javafx.util.Callback;
|
||||
import static org.badvision.outlaweditor.data.DataUtilities.uppercaseFirst;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -98,7 +99,7 @@ public class ModalEditor {
|
|||
TableColumn<T, S> col = new TableColumn<>(uppercaseFirst(colName));
|
||||
col.setCellValueFactory((TableColumn.CellDataFeatures<T, S> param) -> {
|
||||
try {
|
||||
return (ObservableValue<S>) new JavaBeanStringPropertyBuilder().bean(param.getValue()).name(colName).build();
|
||||
return (ObservableValue<S>) JavaBeanStringPropertyBuilder.create().bean(param.getValue()).name(colName).build();
|
||||
} catch (NoSuchMethodException ex) {
|
||||
Logger.getLogger(ModalEditor.class.getName()).log(Level.SEVERE, null, ex);
|
||||
throw new RuntimeException(ex);
|
||||
|
@ -116,7 +117,7 @@ public class ModalEditor {
|
|||
addButton.setOnAction((event) -> {
|
||||
try {
|
||||
rows.add(rowType.newInstance());
|
||||
Application.invokeLater(() -> {
|
||||
Platform.runLater(() -> {
|
||||
try {
|
||||
Thread.sleep(100);
|
||||
} catch (InterruptedException ex) {
|
||||
|
@ -210,8 +211,7 @@ public class ModalEditor {
|
|||
descriptor.getWriteMethod().invoke(sourceObject, control.getValue());
|
||||
} else {
|
||||
Object val = descriptor.getReadMethod().invoke(sourceObject);
|
||||
if (val instanceof List) {
|
||||
List sourceList = (List) val;
|
||||
if (val instanceof List sourceList) {
|
||||
sourceList.clear();
|
||||
sourceList.addAll((Collection) control.getValue());
|
||||
}
|
||||
|
|
|
@ -10,10 +10,10 @@
|
|||
package org.badvision.outlaweditor.ui;
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.ListResourceBundle;
|
||||
import java.util.Map;
|
||||
import java.util.ResourceBundle;
|
||||
import java.util.Set;
|
||||
|
||||
import org.badvision.outlaweditor.MythosEditor;
|
||||
|
||||
import javafx.application.Platform;
|
||||
import javafx.beans.value.ObservableValue;
|
||||
import javafx.concurrent.Worker.State;
|
||||
|
@ -25,13 +25,11 @@ import javafx.scene.web.PromptData;
|
|||
import javafx.scene.web.WebView;
|
||||
import javafx.stage.Stage;
|
||||
import netscape.javascript.JSObject;
|
||||
import org.badvision.outlaweditor.MythosEditor;
|
||||
|
||||
public class MythosScriptEditorController
|
||||
implements Initializable {
|
||||
|
||||
public static final String MYTHOS_EDITOR = "/mythos/mythos-editor/html/editor.html";
|
||||
public static final String ONLOAD_SCRIPT = "onloadScript";
|
||||
// This is tied to the Mythos object defined in mythos_uncompressed
|
||||
JSObject mythos;
|
||||
|
||||
|
@ -60,6 +58,26 @@ public class MythosScriptEditorController
|
|||
|
||||
public void setEditor(MythosEditor editor) {
|
||||
this.editor = editor;
|
||||
final String loadScript = editor.generateLoadScript();
|
||||
if (loadScript != null) {
|
||||
editorView.getEngine().getLoadWorker().stateProperty().addListener(
|
||||
(value, old, newState) -> {
|
||||
if (newState == State.SUCCEEDED) {
|
||||
mythos = (JSObject) editorView.getEngine().executeScript("Mythos");
|
||||
mythos.setMember("editor", editor);
|
||||
editorView.getEngine().executeScript(loadScript);
|
||||
editorView.getEngine().executeScript("window.dispatchEvent(new Event('resize'));");
|
||||
}
|
||||
});
|
||||
|
||||
editorView.getEngine().setPromptHandler((PromptData prompt) -> {
|
||||
return UIAction.getText(prompt.getMessage(), prompt.getDefaultValue());
|
||||
});
|
||||
}
|
||||
|
||||
//TODO: Verify the path conversion works in Win7 with a jar file
|
||||
// Affected by https://bugs.openjdk.java.net/browse/JDK-8136466
|
||||
editorView.getEngine().load(getClass().getResource(MYTHOS_EDITOR).toExternalForm());
|
||||
}
|
||||
|
||||
// Handler for MenuItem[fx:id="menuItemAbortChanges"] onAction
|
||||
|
@ -92,6 +110,11 @@ public class MythosScriptEditorController
|
|||
public void onUndoSelected(ActionEvent event) {
|
||||
// handle the event here
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param fxmlFileLocation
|
||||
* @param resources
|
||||
*/
|
||||
|
||||
@Override // This method is called by the FXMLLoader when initialization is complete
|
||||
public void initialize(URL fxmlFileLocation, ResourceBundle resources) {
|
||||
|
@ -103,23 +126,6 @@ public class MythosScriptEditorController
|
|||
assert menuItemRedo != null : "fx:id=\"menuItemRedo\" was not injected: check your FXML file 'MythosScriptEditor.fxml'.";
|
||||
assert menuItemUndo != null : "fx:id=\"menuItemUndo\" was not injected: check your FXML file 'MythosScriptEditor.fxml'.";
|
||||
|
||||
final String loadScript = resources.getString(ONLOAD_SCRIPT);
|
||||
if (loadScript != null) {
|
||||
editorView.getEngine().getLoadWorker().stateProperty().addListener(
|
||||
(value, old, newState) -> {
|
||||
if (newState == State.SUCCEEDED) {
|
||||
mythos = (JSObject) editorView.getEngine().executeScript("Mythos");
|
||||
mythos.setMember("editor", editor);
|
||||
editorView.getEngine().executeScript(loadScript);
|
||||
editorView.getEngine().executeScript("window.dispatchEvent(new Event('resize'));");
|
||||
}
|
||||
});
|
||||
|
||||
editorView.getEngine().setPromptHandler((PromptData prompt) -> {
|
||||
return UIAction.getText(prompt.getMessage(), prompt.getDefaultValue());
|
||||
});
|
||||
}
|
||||
|
||||
// JavaFX8 has a bug where stage maximize events do not trigger resize events to webview components
|
||||
Platform.runLater(() -> {
|
||||
Stage stage = (Stage) editorView.getScene().getWindow();
|
||||
|
@ -129,26 +135,6 @@ public class MythosScriptEditorController
|
|||
});
|
||||
}
|
||||
});
|
||||
|
||||
//TODO: Verify the path conversion works in Win7 with a jar file
|
||||
// Affected by https://bugs.openjdk.java.net/browse/JDK-8136466
|
||||
editorView.getEngine().load(getClass().getResource(MYTHOS_EDITOR).toExternalForm());
|
||||
}
|
||||
|
||||
public static ResourceBundle createResourceBundle(final Map<String, String> input) {
|
||||
return new ListResourceBundle() {
|
||||
@Override
|
||||
protected Object[][] getContents() {
|
||||
Object[][] output = new Object[input.size()][2];
|
||||
Set<String> keys = input.keySet();
|
||||
int i = 0;
|
||||
for (String key : keys) {
|
||||
output[i] = new Object[]{key, input.get(key)};
|
||||
i++;
|
||||
}
|
||||
return output;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public String getScriptXml() {
|
||||
|
|
|
@ -11,14 +11,15 @@
|
|||
package org.badvision.outlaweditor.ui;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import javafx.scene.image.Image;
|
||||
|
||||
public enum ToolType {
|
||||
ERASER("images/eraser.png"), FILL(null), SELECT(null), MOVE(null), DRAW(null);
|
||||
ERASER("/images/eraser.png"), FILL(null), SELECT(null), MOVE(null), DRAW(null);
|
||||
|
||||
ToolType(String iconPath) {
|
||||
if (iconPath != null) {
|
||||
icon = Optional.of(new Image(iconPath));
|
||||
icon = Optional.of(new Image(ToolType.class.getResourceAsStream(iconPath)));
|
||||
} else {
|
||||
icon = Optional.empty();
|
||||
}
|
||||
|
|
|
@ -19,6 +19,26 @@ import java.util.Map;
|
|||
import java.util.Optional;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.badvision.outlaweditor.Application;
|
||||
import org.badvision.outlaweditor.FileUtils;
|
||||
import org.badvision.outlaweditor.MythosEditor;
|
||||
import org.badvision.outlaweditor.SheetEditor;
|
||||
import org.badvision.outlaweditor.api.ApplicationState;
|
||||
import org.badvision.outlaweditor.apple.ImageDitherEngine;
|
||||
import org.badvision.outlaweditor.data.DataUtilities;
|
||||
import org.badvision.outlaweditor.data.TilesetUtils;
|
||||
import org.badvision.outlaweditor.data.xml.GameData;
|
||||
import org.badvision.outlaweditor.data.xml.Global;
|
||||
import org.badvision.outlaweditor.data.xml.Scope;
|
||||
import org.badvision.outlaweditor.data.xml.Script;
|
||||
import org.badvision.outlaweditor.data.xml.Sheet;
|
||||
import org.badvision.outlaweditor.data.xml.UserType;
|
||||
import org.badvision.outlaweditor.data.xml.Variable;
|
||||
import org.badvision.outlaweditor.data.xml.Variables;
|
||||
import org.badvision.outlaweditor.ui.impl.ImageConversionWizardController;
|
||||
|
||||
import jakarta.xml.bind.JAXB;
|
||||
import javafx.animation.FadeTransition;
|
||||
import javafx.application.Platform;
|
||||
import javafx.event.ActionEvent;
|
||||
|
@ -41,32 +61,14 @@ import javafx.scene.image.Image;
|
|||
import javafx.scene.image.ImageView;
|
||||
import javafx.scene.image.WritableImage;
|
||||
import javafx.scene.layout.AnchorPane;
|
||||
import javafx.scene.layout.HBoxBuilder;
|
||||
import javafx.scene.layout.VBoxBuilder;
|
||||
import javafx.scene.layout.HBox;
|
||||
import javafx.scene.layout.VBox;
|
||||
import javafx.scene.text.Text;
|
||||
import javafx.stage.Modality;
|
||||
import javafx.stage.Stage;
|
||||
import javafx.util.Callback;
|
||||
import javafx.util.Duration;
|
||||
import javafx.util.converter.DefaultStringConverter;
|
||||
import javax.xml.bind.JAXB;
|
||||
import org.badvision.outlaweditor.Application;
|
||||
import org.badvision.outlaweditor.FileUtils;
|
||||
import org.badvision.outlaweditor.MythosEditor;
|
||||
import org.badvision.outlaweditor.SheetEditor;
|
||||
import org.badvision.outlaweditor.api.ApplicationState;
|
||||
import org.badvision.outlaweditor.apple.ImageDitherEngine;
|
||||
import org.badvision.outlaweditor.data.DataUtilities;
|
||||
import org.badvision.outlaweditor.data.TilesetUtils;
|
||||
import org.badvision.outlaweditor.data.xml.GameData;
|
||||
import org.badvision.outlaweditor.data.xml.Global;
|
||||
import org.badvision.outlaweditor.data.xml.Scope;
|
||||
import org.badvision.outlaweditor.data.xml.Script;
|
||||
import org.badvision.outlaweditor.data.xml.Sheet;
|
||||
import org.badvision.outlaweditor.data.xml.UserType;
|
||||
import org.badvision.outlaweditor.data.xml.Variable;
|
||||
import org.badvision.outlaweditor.data.xml.Variables;
|
||||
import org.badvision.outlaweditor.ui.impl.ImageConversionWizardController;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -184,7 +186,7 @@ public class UIAction {
|
|||
|
||||
public static WritableImage getBadImage(int width, int height) {
|
||||
if (badImage == null) {
|
||||
badImage = new Image("images/icon_brokenLink.png");
|
||||
badImage = new Image(UIAction.class.getResourceAsStream("/images/icon_brokenLink.png"));
|
||||
}
|
||||
WritableImage img = new WritableImage(width, height);
|
||||
img.getPixelWriter().setPixels(0, 0, (int) badImage.getWidth(), (int) badImage.getHeight(), badImage.getPixelReader(), 0, 0);
|
||||
|
@ -214,7 +216,10 @@ public class UIAction {
|
|||
public static void choose(String message, Choice... choices) {
|
||||
final Stage dialogStage = new Stage();
|
||||
|
||||
HBoxBuilder options = HBoxBuilder.create().alignment(Pos.CENTER).spacing(10.0).padding(new Insets(5));
|
||||
HBox hbox = new HBox();
|
||||
hbox.setAlignment(Pos.CENTER);
|
||||
hbox.setSpacing(10.0);
|
||||
hbox.setPadding(new Insets(5));
|
||||
List<Button> buttons = new ArrayList<>();
|
||||
for (final Choice c : choices) {
|
||||
Button b = new Button(c.text);
|
||||
|
@ -226,11 +231,13 @@ public class UIAction {
|
|||
});
|
||||
buttons.add(b);
|
||||
}
|
||||
options.children(buttons);
|
||||
hbox.getChildren().addAll(buttons);
|
||||
dialogStage.initModality(Modality.WINDOW_MODAL);
|
||||
dialogStage.setScene(new Scene(VBoxBuilder.create().
|
||||
children(new Text(message), options.build()).
|
||||
alignment(Pos.CENTER).padding(new Insets(5)).build()));
|
||||
VBox vbox = new VBox();
|
||||
vbox.getChildren().addAll(new Text(message), hbox);
|
||||
vbox.setAlignment(Pos.CENTER);
|
||||
vbox.setPadding(new Insets(5));
|
||||
dialogStage.setScene(new Scene(vbox));
|
||||
dialogStage.show();
|
||||
}
|
||||
|
||||
|
@ -238,7 +245,7 @@ public class UIAction {
|
|||
TextInputDialog dialog = new TextInputDialog(defaultValue);
|
||||
dialog.setTitle("MythosScript Editor");
|
||||
dialog.setHeaderText("Respond and press OK, or Cancel to abort");
|
||||
ImageView graphic = new ImageView(new Image("images/revolver_icon.png"));
|
||||
ImageView graphic = new ImageView(new Image(UIAction.class.getResourceAsStream("/images/revolver_icon.png")));
|
||||
graphic.setFitHeight(50.0);
|
||||
graphic.setFitWidth(50.0);
|
||||
graphic.setSmooth(true);
|
||||
|
|
|
@ -13,19 +13,18 @@ package org.badvision.outlaweditor.ui.impl;
|
|||
import java.io.IOException;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import javafx.event.ActionEvent;
|
||||
import javafx.scene.control.MenuItem;
|
||||
import org.badvision.outlaweditor.Application;
|
||||
|
||||
import org.badvision.outlaweditor.Editor;
|
||||
import org.badvision.outlaweditor.api.ApplicationState;
|
||||
import org.badvision.outlaweditor.api.MenuAction;
|
||||
import org.badvision.outlaweditor.api.Platform;
|
||||
import org.badvision.outlaweditor.apple.AppleTileRenderer;
|
||||
import org.badvision.outlaweditor.ui.ApplicationMenuController;
|
||||
import org.badvision.outlaweditor.ui.ApplicationUIController;
|
||||
import org.badvision.outlaweditor.ui.UIAction;
|
||||
import org.osgi.framework.BundleContext;
|
||||
import org.osgi.framework.InvalidSyntaxException;
|
||||
|
||||
import javafx.event.ActionEvent;
|
||||
// import org.osgi.framework.BundleContext;
|
||||
// import org.osgi.framework.InvalidSyntaxException;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -34,7 +33,6 @@ import org.osgi.framework.InvalidSyntaxException;
|
|||
public class ApplicationMenuControllerImpl extends ApplicationMenuController {
|
||||
@Override
|
||||
public void initalize() {
|
||||
setupPluginMenu();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -152,20 +150,4 @@ public class ApplicationMenuControllerImpl extends ApplicationMenuController {
|
|||
editor.undo();
|
||||
}
|
||||
}
|
||||
|
||||
private void setupPluginMenu() {
|
||||
System.out.println("Setting up extras menu");
|
||||
|
||||
BundleContext bc = ApplicationState.getBundleContext();
|
||||
try {
|
||||
bc.getServiceReferences(MenuAction.class, null).stream().map(bc::getService).forEach((MenuAction a) -> {
|
||||
System.out.println("Adding menu item " + a.getName());
|
||||
MenuItem item = new MenuItem(a.getName());
|
||||
item.setOnAction(a);
|
||||
extraMenu.getItems().add(item);
|
||||
});
|
||||
} catch (InvalidSyntaxException ex) {
|
||||
Logger.getLogger(ApplicationUIControllerImpl.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|