Skip to content
This repository has been archived by the owner on Jul 16, 2022. It is now read-only.

Commit

Permalink
Try to add projector support
Browse files Browse the repository at this point in the history
  • Loading branch information
miurahr committed Oct 31, 2021
1 parent d94eefe commit 114028e
Show file tree
Hide file tree
Showing 24 changed files with 69 additions and 3 deletions.
17 changes: 14 additions & 3 deletions build.gradle.kts
Expand Up @@ -18,10 +18,17 @@ plugins {

fun getProps(f: File): Properties {
val props = Properties()
props.load(FileInputStream(f))
try {
props.load(FileInputStream(f))
} catch (t: Throwable) {
println("Can't read $f: $t, assuming empty")
}
return props
}

// load local.properties when exist.
val localProperties = getProps(File(rootDir, "local.properties"))

// we handle cases without .git directory
val props = project.file("src/main/resources/version.properties")
val dotgit = project.file(".git")
Expand Down Expand Up @@ -55,7 +62,7 @@ tasks.getByName("jar") {
group = "io.github.eb4j"

application {
mainClass.set("io.github.eb4j.ebview.EBViewer")
mainClass.set("io.github.eb4j.ebview.HeadlessEBViewer")
}

application.applicationDistribution.into("") {
Expand All @@ -69,7 +76,11 @@ repositories {

dependencies {
implementation("io.github.eb4j:eb4j:2.3.0")
implementation("org.slf4j:slf4j-simple:1.7.32")
implementation("org.slf4j:slf4j-simple:1.7.30")

if (localProperties["useLocalProjectorServer"] == "true") {
implementation(fileTree(mapOf("dir" to "libs", "include" to listOf("*.jar"))))
}

implementation("commons-io:commons-io:2.11.0")
implementation("org.apache.commons:commons-lang3:3.12.0")
Expand Down
Binary file added libs/Java-WebSocket-1.5.1.jar
Binary file not shown.
Binary file added libs/annotations-13.0.jar
Binary file not shown.
Binary file added libs/dnsjava-2.1.9.jar
Binary file not shown.
Binary file added libs/javassist-3.27.0-GA.jar
Binary file not shown.
Binary file added libs/jsoup-1.13.1.jar
Binary file not shown.
Binary file added libs/kotlin-reflect-1.5.20.jar
Binary file not shown.
Binary file added libs/kotlin-stdlib-1.5.20.jar
Binary file not shown.
Binary file added libs/kotlin-stdlib-common-1.5.20.jar
Binary file not shown.
Binary file added libs/kotlin-stdlib-jdk7-1.5.20.jar
Binary file not shown.
Binary file added libs/kotlin-stdlib-jdk8-1.5.20.jar
Binary file not shown.
Binary file added libs/kotlinx-serialization-core-jvm-1.2.1.jar
Binary file not shown.
Binary file added libs/kotlinx-serialization-json-jvm-1.2.1.jar
Binary file not shown.
Binary file added libs/kotlinx-serialization-protobuf-jvm-1.2.1.jar
Binary file not shown.
Binary file added libs/projector-agent-initialization-4892def9.jar
Binary file not shown.
Binary file added libs/projector-awt-1.4.0.jar
Binary file not shown.
Binary file added libs/projector-common-jvm-4892def9.jar
Binary file not shown.
Binary file added libs/projector-server-1.4.0.jar
Binary file not shown.
Binary file added libs/projector-server-core-4892def9.jar
Binary file not shown.
Binary file added libs/projector-util-agent-4892def9.jar
Binary file not shown.
Binary file added libs/projector-util-loading-4892def9.jar
Binary file not shown.
Binary file added libs/projector-util-logging-jvm-4892def9.jar
Binary file not shown.
8 changes: 8 additions & 0 deletions local.properties
@@ -0,0 +1,8 @@
# The :projector-server:runServer task requires the following two declarations.
projectorLauncher.targetClassPath=/home/azureuser/IdeaProjects/ebviewer/build/libs/ebviewer-0.6.0-11-d94eefedee-SNAPSHOT.jar
projectorLauncher.classToLaunch=io.github.eb4j.ebview.EBViewer
#useLocalProjectorServer=true

# to enable connections via relay define both next variables
#ORG_JETBRAINS_PROJECTOR_SERVER_RELAY_URL=localhost
#ORG_JETBRAINS_PROJECTOR_SERVER_RELAY_SERVER_ID=DEFAULT_SERVER_ID
47 changes: 47 additions & 0 deletions src/main/java/io/github/eb4j/ebview/HeadlessEBViewer.java
@@ -0,0 +1,47 @@
package io.github.eb4j.ebview;

import org.jetbrains.projector.server.ProjectorLauncher;
import org.jetbrains.projector.server.ProjectorServer;
import tokyo.northside.protocol.URLProtocolHandler;

import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
import java.io.File;

public class HeadlessEBViewer extends EBViewer implements Runnable {


public HeadlessEBViewer(final File dictionaryDirectory) {
super(dictionaryDirectory);
}

/**
* Main function.
* @param args command line arguments.
*/
public static void main(final String... args) {
if (ProjectorServer.isEnabled()) {
if (!ProjectorLauncher.runProjectorServer()) {
throw new RuntimeException("Fail to start projector server");
}
}
URLProtocolHandler.install();
try {
UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
} catch (ClassNotFoundException | UnsupportedLookAndFeelException | IllegalAccessException | InstantiationException e) {
e.printStackTrace();
}
File dictionaryDirectory = null;
if (args.length == 1) {
dictionaryDirectory = new File(args[0]);
}
try {
EBViewer viewer = new HeadlessEBViewer(dictionaryDirectory);
Thread t = new Thread(viewer);
t.start();
} catch (Exception e) {
e.printStackTrace();
}
}

}

0 comments on commit 114028e

Please sign in to comment.