Skip to content

Commit

Permalink
'jnotify' dependency was removed
Browse files Browse the repository at this point in the history
fix process launch on mac
settings and downloads moved to user.documents
  • Loading branch information
dsmunev committed Jul 26, 2021
1 parent 255c090 commit 93df4f6
Show file tree
Hide file tree
Showing 14 changed files with 239 additions and 123 deletions.
29 changes: 13 additions & 16 deletions launcher.sh → adda-gui.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

message()
{
TITLE="Cannot start IntelliJ IDEA"
TITLE="Cannot start ADDA GUI"
if [ -n "$(command -v zenity)" ]; then
zenity --error --title="$TITLE" --text="$1" --no-wrap
elif [ -n "$(command -v kdialog)" ]; then
Expand Down Expand Up @@ -44,17 +44,14 @@ IDE_BIN_HOME=$(dirname "$(realpath "$0")")
#IDE_HOME=$(dirname "${IDE_BIN_HOME}")
IDE_HOME="$IDE_BIN_HOME"
PRODUCT_VENDOR="adda-gui"
JAR_PATH="$IDE_HOME/$PRODUCT_VENDOR.jar"
JAR_PATH="$IDE_HOME/lib/$PRODUCT_VENDOR.jar"


# ---------------------------------------------------------------------
# Locate a JRE installation directory command -v will be used to run the IDE.
# Try (in order): $IDEA_JDK, .../jbr[-x86], $JDK_HOME, $JAVA_HOME, "java" in $PATH.
# ---------------------------------------------------------------------
# shellcheck disable=SC2154
if [ -n "$IDEA_JDK" ] && [ -x "$IDEA_JDK/bin/java" ]; then
JRE="$IDEA_JDK"
fi

BITS=""

Expand All @@ -81,31 +78,31 @@ else
JAVA_BIN="$JRE/bin/java"
fi

if [ -z "$JAVA_BIN" ] || [ ! -x "$JAVA_BIN" ]; then
if [ -z "$JAVA_BIN" ]; then
X86_JRE_URL="https://download.jetbrains.com/idea/jbr-for-211.7628.21-linux-x86.tar.gz"
# shellcheck disable=SC2166
if [ -n "$X86_JRE_URL" ] && [ ! -d "$IDE_HOME/jbr-x86" ] && [ "$OS_ARCH" = "i386" -o "$OS_ARCH" = "i686" ]; then
message "To run IntelliJ IDEA on a 32-bit system, please download 32-bit Java runtime from \"$X86_JRE_URL\" and unpack it into \"jbr-x86\" directory."
message "To run ADDA GUI on a 32-bit system, please download 32-bit Java runtime from \"$X86_JRE_URL\" and unpack it into \"jbr-x86\" directory."
else
message "No JRE found. Please make sure \$IDEA_JDK, \$JDK_HOME, or \$JAVA_HOME point to valid JRE installation."
fi
exit 1
fi

if [ ! -x "$JAVA_BIN" ]; then
# shellcheck disable=SC2166
echo "please set java as executable file:"
echo "sudo chmod +x $JAVA_BIN"
message "\"$JAVA_BIN\" is not executable"
exit 1
fi

if [ -n "$JRE" ] && [ -r "$JRE/release" ]; then
egrep -q -E -e "OS_ARCH=\"(x86_64|amd64)\"" "$JRE/release" && BITS="64" || BITS=""
else
test "${OS_ARCH}" = "x86_64" && BITS="64" || BITS=""
fi

JNOTIFY_LIB="$IDE_HOME/lib"

if [ "$BITS" = "64"]; then
JNOTIFY_LIB="$JNOTIFY_LIB/64bit"
fi

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$JNOTIFY_LIB

# ---------------------------------------------------------------------
# Run the ADDA GUI
# ---------------------------------------------------------------------
Expand All @@ -114,6 +111,6 @@ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$JNOTIFY_LIB
IFS="$(printf '\n\t')"
# shellcheck disable=SC2086
"$JAVA_BIN" \
-jar "JAR_PATH" \
-cp "$JAR_PATH" adda.Main\
"$@"

43 changes: 41 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,17 @@ dependencies {
compile group: 'com.github.jiconfont', name: 'jiconfont-swing', version: '1.0.0'
compile group: 'com.github.jiconfont', name: 'jiconfont-font_awesome', version: '4.7.0.1'
compile group: 'com.formdev', name: 'flatlaf', version: '0.35'
compile group: 'net.contentobjects.jnotify', name: 'jnotify', version: '0.94'
compile group: 'net.java.balloontip', name: 'balloontip', version: '1.2.4.1'
compile group: 'javax.help', name: 'javahelp', version: '2.0.05'
compile group: 'org.jfree', name: 'jfreechart', version: '1.5.3'
compile group: 'net.lingala.zip4j', name: 'zip4j', version: '2.9.0'
compile fileTree(dir: 'lib', include: ['*'])
compile group: 'org.slf4j', name: 'slf4j-api', version: '1.7.31'
compile group: 'io.methvin', name: 'directory-watcher', version: '0.15.0'
//compile group: 'sh.tak.appbundler', name: 'appbundle-maven-plugin', version: '1.2.0'



//compile fileTree(dir: 'lib', include: ['*'])
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.3.1'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.3.1'
//implementation 'org.junit.jupiter:junit-jupiter'
Expand All @@ -42,6 +47,9 @@ manifest {
launch4j {
mainClassName = 'adda.Main'
icon = "${projectDir}/help/en/adda_logo.ico"
//bundledJrePath = "c:\\Program Files\\JetBrains\\IntelliJ IDEA 2019.3.4\\jbr"
bundledJrePath = "jbr"
bundledJre64Bit = true
}

sourceSets {
Expand All @@ -61,3 +69,34 @@ test {
useJUnitPlatform()
}

task packageExecutableDistribution(type: Zip) {
archiveFileName = "adda-gui_win64.zip"
destinationDirectory = file("$projectDir/releases")

from "$buildDir/launch4j"
}

task addJreToDistributable(type: Copy) {
from('c:\\Program Files\\JetBrains\\IntelliJ IDEA 2019.3.4\\jbr')
destinationDir = file("$buildDir/launch4j/jbr")
}

task addAddaBinToDistributable(type: Copy) {
from('bin') {
include '**/*.*'
}
destinationDir = file("$buildDir/launch4j/bin")
}

task addHelpToDistributable(type: Copy) {
from('help') {
include '**/*.*'
}
destinationDir = file("$buildDir/launch4j/help")
}

packageExecutableDistribution.dependsOn createExe
packageExecutableDistribution.dependsOn addJreToDistributable
packageExecutableDistribution.dependsOn addAddaBinToDistributable
packageExecutableDistribution.dependsOn addHelpToDistributable

16 changes: 16 additions & 0 deletions build.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<project name="ADDA GUI" default="adda-gui-bundle" basedir=".">
<taskdef name="bundleapp"
classname="com.oracle.appbundler.AppBundlerTask"
classpath="lib/appbundler-1.1.0.jar" />
<target name="adda-gui-bundle">
<bundleapp outputdirectory="out"
name="adda-gui"
displayname="ADDA GUI"
identifier="adda-gui"
mainclassname="adda.Main">
<runtime dir="d:\projects\java\adda-gui\jbr\Contents\Home\"/>
<classpath file="out/artifacts/adda_gui/adda-gui.jar" />
</bundleapp>
</target>
</project>
4 changes: 2 additions & 2 deletions help/en/HelpSet.hs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"http://java.sun.com/products/javahelp/helpset_1_0.dtd">

<helpset version="1.0">
<title>ADDA GUI Help [beta version, under developing]</title>
<title>ADDA GUI Help [beta version, under development]</title>
<maps>
<mapref location="Map.jhm"/>
<homeID>introduction</homeID>
Expand All @@ -29,7 +29,7 @@
<size width="1024" height="700" />
<location x="200" y="200" />
<image>icon</image>
<title>ADDA GUI Help [beta version, under developing]</title>
<title>ADDA GUI Help [beta version, under development]</title>
<toolbar>
<helpaction>javax.help.BackAction</helpaction>
<helpaction>javax.help.ForwardAction</helpaction>
Expand Down
19 changes: 15 additions & 4 deletions src/main/java/adda/Context.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import adda.settings.formatters.plaintext.PlainTextFormatter;
import adda.settings.serializer.AddaSerializer;
import adda.settings.serializer.ISerializer;
import adda.utils.OsUtils;

import javax.help.CSH;
import javax.help.HelpBroker;
Expand All @@ -21,11 +22,12 @@
import java.awt.event.ActionListener;
import java.io.File;
import java.net.MalformedURLException;
import java.net.URISyntaxException;
import java.net.URL;

public class Context {

public static final String VERSION = "beta0.2.3";
public static final String VERSION = "beta0.3.0";

protected JFrame mainFrame;

Expand Down Expand Up @@ -104,9 +106,18 @@ public IModel getChildModelFromSelectedBox(Class<?> clazz) {
return null;
}

public HelpSet getHelpSet() throws MalformedURLException, HelpSetException {
public HelpSet getHelpSet() throws MalformedURLException, HelpSetException, URISyntaxException {
String lang = "en";
URL hsURL = new URL((new File(".")).toURL(), "help/" + lang +"/HelpSet.hs");
URL hsURL;
File file = new File(Main.class.getProtectionDomain().getCodeSource().getLocation()
.toURI().getPath()).getParentFile().getParentFile();

if (!(new File(file.toPath().toAbsolutePath() + "/help/" + lang +"/HelpSet.hs").exists())) {
file = new File(".");
}

hsURL = new URL( file.toURI().toURL(), "help/" + lang +"/HelpSet.hs");

return new HelpSet(null, hsURL);
}

Expand All @@ -115,7 +126,7 @@ public HelpBroker getHelpBroker() {
try {
HelpSet hs = getHelpSet();
hb = hs.createHelpBroker();
} catch (MalformedURLException | HelpSetException e) {
} catch (MalformedURLException | HelpSetException | URISyntaxException e) {
e.printStackTrace();
}
return hb;
Expand Down
1 change: 1 addition & 0 deletions src/main/java/adda/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public class Main {
public static void main(String[] args) {
javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
if (OsUtils.isMac()) System.setProperty( "jdk.lang.Process.launchMechanism", "FORK" );
try {
UIManager.setLookAndFeel(new FlatLightLaf());
UIManager.getLookAndFeel().getDefaults().put("TextField.disabledBackground", new Color(-855310));
Expand Down
25 changes: 20 additions & 5 deletions src/main/java/adda/application/SettingDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -172,15 +172,15 @@ public void actionPerformed(ActionEvent actionEvent) {
String finalZipUrl = zipUrl;
javax.swing.SwingUtilities.invokeLater(() -> textArea.append("Latest release is " + finalZipUrl + "\n"));

String downloadDir = System.getProperty("user.dir") + "/download";
String downloadDir = OsUtils.getDefaultDirectory() + File.separator + "download";
OsUtils.createFolder(downloadDir);

Date now = new Date();
SimpleDateFormat pattern = new SimpleDateFormat("MMddHHmmss");
String path = downloadDir + "/adda_release_" + pattern.format(now);
String path = downloadDir + File.separator + "adda_release_" + pattern.format(now);
OsUtils.createFolder(path);

String zipFileName = path + "/release.zip";
String zipFileName = path + File.separator + "release.zip";

javax.swing.SwingUtilities.invokeLater(() -> textArea.append("Downloading to " + zipFileName + "\n"));
Downloader downloader = new Downloader(new URL(zipUrl), zipFileName);
Expand Down Expand Up @@ -225,14 +225,20 @@ public void actionPerformed(ActionEvent actionEvent) {

if (OsUtils.isMac()) {
textArea.append("fftw3 need to be installed for Mac, but you can apply FFT_TEMPERTON to use inner implementation of fft \n");
textArea.append("brew need to be installed for Mac, if you don`t have brew please install it via command below \n");
textArea.append("---------------- \n");
textArea.append("\n");
textArea.append("sudo /bin/bash -c \"$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)\" \n");
textArea.append("\n");
textArea.append("---------------- \n");
}

textArea.append("copy and execute next commands in the terminal line by line \n");

textArea.append("---------------- \n");
textArea.append("\n");
if (OsUtils.isMac()) {
textArea.append("brew install gcc \n");
textArea.append("brew install gcc \n");
textArea.append("brew install make \n");
textArea.append("cd " + srcPath + " \n");
textArea.append("make seq OPTIONS=\"FFT_TEMPERTON\" FORT_LIB_PATH=/usr/local/gfortran/lib\n");
Expand All @@ -247,6 +253,12 @@ public void actionPerformed(ActionEvent actionEvent) {

textArea.append("\n");
textArea.append("---------------- \n");

if (OsUtils.isMac()) {
textArea.append("IMPORTANT! if you have a problem with gfortran please visit this page\n");
textArea.append("https://github.com/Homebrew/legacy-homebrew/issues/8539 \n");

}
});


Expand All @@ -255,11 +267,14 @@ public void actionPerformed(ActionEvent actionEvent) {
seq.setText(seqPath + "/adda");
seq.setCaretPosition(seq.getText().length());


try {
cmd("gnome-terminal", seqPath);
cmd(OsUtils.isMac() ? "open" : "gnome-terminal", seqPath);
} catch (Exception ignored) {
cmd(System.getenv().get("TERM"), seqPath);
}


}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@
import adda.base.models.IModelObserver;
import adda.base.models.ModelBase;
import adda.item.root.projectTree.ProjectTreeModel;
import net.contentobjects.jnotify.JNotify;
import net.contentobjects.jnotify.JNotifyException;
import net.contentobjects.jnotify.JNotifyListener;


import java.io.BufferedReader;
import java.io.FileReader;
Expand Down
45 changes: 28 additions & 17 deletions src/main/java/adda/item/root/projectArea/ProjectAreaModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import adda.item.tab.shape.selector.params.bicoated.BicoatedModel;
import adda.settings.AppSetting;
import adda.settings.SettingsManager;
import adda.utils.OsUtils;
import adda.utils.OutputDisplayer;
import adda.utils.StringHelper;

Expand Down Expand Up @@ -400,25 +401,35 @@ public void start() {
}
}

List<String> args = new ArrayList<String>();


args.add(appSetting.getAddaExecSeq());

final List<String> params = Arrays.asList(optionsModel.getActualCommandLine().split(" "));
args.addAll(params);

args.add("-dir");
args.add(pathToState);

args.add("-so_buf");
args.add("line");

ProcessBuilder builder = new ProcessBuilder(args);
builder.redirectErrorStream(true);

try {
Process addaProcess = builder.start();
Process addaProcess;
List<String> args = new ArrayList<String>();
args.add(appSetting.getAddaExecSeq());
final List<String> params = Arrays.asList(optionsModel.getActualCommandLine().split(" "));
args.addAll(params);
args.add("-dir");
args.add(pathToState);
args.add("-so_buf");
args.add("line");
if (OsUtils.isMac()) {
// StringBuilder builder = new StringBuilder();
// builder.append(appSetting.getAddaExecSeq());
// builder.append(" ");
// builder.append(optionsModel.getActualCommandLine());
// builder.append(" -so_buf line");
// builder.append(" -dir ");
// builder.append("\"");
// builder.append(pathToState);
// builder.append("\"");
// String command = builder.toString();
// System.out.println(args);
addaProcess = Runtime.getRuntime().exec(args.stream().toArray(String[]::new));
} else {
ProcessBuilder builder = new ProcessBuilder(args);
builder.redirectErrorStream(true);
addaProcess = builder.start();
}
outputDisplayer.commence(addaProcess, () -> javax.swing.SwingUtilities.invokeLater(() -> setSuccessfullyFinished(true)));
} catch (IOException e) {
setRunning(false);
Expand Down
Loading

0 comments on commit 93df4f6

Please sign in to comment.