Skip to content

Commit 93df4f6

Browse files
committed
'jnotify' dependency was removed
fix process launch on mac settings and downloads moved to user.documents
1 parent 255c090 commit 93df4f6

File tree

14 files changed

+239
-123
lines changed

14 files changed

+239
-123
lines changed

launcher.sh renamed to adda-gui.sh

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
message()
1010
{
11-
TITLE="Cannot start IntelliJ IDEA"
11+
TITLE="Cannot start ADDA GUI"
1212
if [ -n "$(command -v zenity)" ]; then
1313
zenity --error --title="$TITLE" --text="$1" --no-wrap
1414
elif [ -n "$(command -v kdialog)" ]; then
@@ -44,17 +44,14 @@ IDE_BIN_HOME=$(dirname "$(realpath "$0")")
4444
#IDE_HOME=$(dirname "${IDE_BIN_HOME}")
4545
IDE_HOME="$IDE_BIN_HOME"
4646
PRODUCT_VENDOR="adda-gui"
47-
JAR_PATH="$IDE_HOME/$PRODUCT_VENDOR.jar"
47+
JAR_PATH="$IDE_HOME/lib/$PRODUCT_VENDOR.jar"
4848

4949

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

5956
BITS=""
6057

@@ -81,31 +78,31 @@ else
8178
JAVA_BIN="$JRE/bin/java"
8279
fi
8380

84-
if [ -z "$JAVA_BIN" ] || [ ! -x "$JAVA_BIN" ]; then
81+
if [ -z "$JAVA_BIN" ]; then
8582
X86_JRE_URL="https://download.jetbrains.com/idea/jbr-for-211.7628.21-linux-x86.tar.gz"
8683
# shellcheck disable=SC2166
8784
if [ -n "$X86_JRE_URL" ] && [ ! -d "$IDE_HOME/jbr-x86" ] && [ "$OS_ARCH" = "i386" -o "$OS_ARCH" = "i686" ]; then
88-
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."
85+
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."
8986
else
9087
message "No JRE found. Please make sure \$IDEA_JDK, \$JDK_HOME, or \$JAVA_HOME point to valid JRE installation."
9188
fi
9289
exit 1
9390
fi
9491

92+
if [ ! -x "$JAVA_BIN" ]; then
93+
# shellcheck disable=SC2166
94+
echo "please set java as executable file:"
95+
echo "sudo chmod +x $JAVA_BIN"
96+
message "\"$JAVA_BIN\" is not executable"
97+
exit 1
98+
fi
99+
95100
if [ -n "$JRE" ] && [ -r "$JRE/release" ]; then
96101
egrep -q -E -e "OS_ARCH=\"(x86_64|amd64)\"" "$JRE/release" && BITS="64" || BITS=""
97102
else
98103
test "${OS_ARCH}" = "x86_64" && BITS="64" || BITS=""
99104
fi
100105

101-
JNOTIFY_LIB="$IDE_HOME/lib"
102-
103-
if [ "$BITS" = "64"]; then
104-
JNOTIFY_LIB="$JNOTIFY_LIB/64bit"
105-
fi
106-
107-
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$JNOTIFY_LIB
108-
109106
# ---------------------------------------------------------------------
110107
# Run the ADDA GUI
111108
# ---------------------------------------------------------------------
@@ -114,6 +111,6 @@ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$JNOTIFY_LIB
114111
IFS="$(printf '\n\t')"
115112
# shellcheck disable=SC2086
116113
"$JAVA_BIN" \
117-
-jar "JAR_PATH" \
114+
-cp "$JAR_PATH" adda.Main\
118115
"$@"
119116

build.gradle

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,17 @@ dependencies {
2121
compile group: 'com.github.jiconfont', name: 'jiconfont-swing', version: '1.0.0'
2222
compile group: 'com.github.jiconfont', name: 'jiconfont-font_awesome', version: '4.7.0.1'
2323
compile group: 'com.formdev', name: 'flatlaf', version: '0.35'
24-
compile group: 'net.contentobjects.jnotify', name: 'jnotify', version: '0.94'
2524
compile group: 'net.java.balloontip', name: 'balloontip', version: '1.2.4.1'
2625
compile group: 'javax.help', name: 'javahelp', version: '2.0.05'
2726
compile group: 'org.jfree', name: 'jfreechart', version: '1.5.3'
2827
compile group: 'net.lingala.zip4j', name: 'zip4j', version: '2.9.0'
29-
compile fileTree(dir: 'lib', include: ['*'])
28+
compile group: 'org.slf4j', name: 'slf4j-api', version: '1.7.31'
29+
compile group: 'io.methvin', name: 'directory-watcher', version: '0.15.0'
30+
//compile group: 'sh.tak.appbundler', name: 'appbundle-maven-plugin', version: '1.2.0'
31+
32+
33+
34+
//compile fileTree(dir: 'lib', include: ['*'])
3035
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.3.1'
3136
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.3.1'
3237
//implementation 'org.junit.jupiter:junit-jupiter'
@@ -42,6 +47,9 @@ manifest {
4247
launch4j {
4348
mainClassName = 'adda.Main'
4449
icon = "${projectDir}/help/en/adda_logo.ico"
50+
//bundledJrePath = "c:\\Program Files\\JetBrains\\IntelliJ IDEA 2019.3.4\\jbr"
51+
bundledJrePath = "jbr"
52+
bundledJre64Bit = true
4553
}
4654

4755
sourceSets {
@@ -61,3 +69,34 @@ test {
6169
useJUnitPlatform()
6270
}
6371

72+
task packageExecutableDistribution(type: Zip) {
73+
archiveFileName = "adda-gui_win64.zip"
74+
destinationDirectory = file("$projectDir/releases")
75+
76+
from "$buildDir/launch4j"
77+
}
78+
79+
task addJreToDistributable(type: Copy) {
80+
from('c:\\Program Files\\JetBrains\\IntelliJ IDEA 2019.3.4\\jbr')
81+
destinationDir = file("$buildDir/launch4j/jbr")
82+
}
83+
84+
task addAddaBinToDistributable(type: Copy) {
85+
from('bin') {
86+
include '**/*.*'
87+
}
88+
destinationDir = file("$buildDir/launch4j/bin")
89+
}
90+
91+
task addHelpToDistributable(type: Copy) {
92+
from('help') {
93+
include '**/*.*'
94+
}
95+
destinationDir = file("$buildDir/launch4j/help")
96+
}
97+
98+
packageExecutableDistribution.dependsOn createExe
99+
packageExecutableDistribution.dependsOn addJreToDistributable
100+
packageExecutableDistribution.dependsOn addAddaBinToDistributable
101+
packageExecutableDistribution.dependsOn addHelpToDistributable
102+

build.xml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project name="ADDA GUI" default="adda-gui-bundle" basedir=".">
3+
<taskdef name="bundleapp"
4+
classname="com.oracle.appbundler.AppBundlerTask"
5+
classpath="lib/appbundler-1.1.0.jar" />
6+
<target name="adda-gui-bundle">
7+
<bundleapp outputdirectory="out"
8+
name="adda-gui"
9+
displayname="ADDA GUI"
10+
identifier="adda-gui"
11+
mainclassname="adda.Main">
12+
<runtime dir="d:\projects\java\adda-gui\jbr\Contents\Home\"/>
13+
<classpath file="out/artifacts/adda_gui/adda-gui.jar" />
14+
</bundleapp>
15+
</target>
16+
</project>

help/en/HelpSet.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"http://java.sun.com/products/javahelp/helpset_1_0.dtd">
55

66
<helpset version="1.0">
7-
<title>ADDA GUI Help [beta version, under developing]</title>
7+
<title>ADDA GUI Help [beta version, under development]</title>
88
<maps>
99
<mapref location="Map.jhm"/>
1010
<homeID>introduction</homeID>
@@ -29,7 +29,7 @@
2929
<size width="1024" height="700" />
3030
<location x="200" y="200" />
3131
<image>icon</image>
32-
<title>ADDA GUI Help [beta version, under developing]</title>
32+
<title>ADDA GUI Help [beta version, under development]</title>
3333
<toolbar>
3434
<helpaction>javax.help.BackAction</helpaction>
3535
<helpaction>javax.help.ForwardAction</helpaction>

src/main/java/adda/Context.java

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import adda.settings.formatters.plaintext.PlainTextFormatter;
1313
import adda.settings.serializer.AddaSerializer;
1414
import adda.settings.serializer.ISerializer;
15+
import adda.utils.OsUtils;
1516

1617
import javax.help.CSH;
1718
import javax.help.HelpBroker;
@@ -21,11 +22,12 @@
2122
import java.awt.event.ActionListener;
2223
import java.io.File;
2324
import java.net.MalformedURLException;
25+
import java.net.URISyntaxException;
2426
import java.net.URL;
2527

2628
public class Context {
2729

28-
public static final String VERSION = "beta0.2.3";
30+
public static final String VERSION = "beta0.3.0";
2931

3032
protected JFrame mainFrame;
3133

@@ -104,9 +106,18 @@ public IModel getChildModelFromSelectedBox(Class<?> clazz) {
104106
return null;
105107
}
106108

107-
public HelpSet getHelpSet() throws MalformedURLException, HelpSetException {
109+
public HelpSet getHelpSet() throws MalformedURLException, HelpSetException, URISyntaxException {
108110
String lang = "en";
109-
URL hsURL = new URL((new File(".")).toURL(), "help/" + lang +"/HelpSet.hs");
111+
URL hsURL;
112+
File file = new File(Main.class.getProtectionDomain().getCodeSource().getLocation()
113+
.toURI().getPath()).getParentFile().getParentFile();
114+
115+
if (!(new File(file.toPath().toAbsolutePath() + "/help/" + lang +"/HelpSet.hs").exists())) {
116+
file = new File(".");
117+
}
118+
119+
hsURL = new URL( file.toURI().toURL(), "help/" + lang +"/HelpSet.hs");
120+
110121
return new HelpSet(null, hsURL);
111122
}
112123

@@ -115,7 +126,7 @@ public HelpBroker getHelpBroker() {
115126
try {
116127
HelpSet hs = getHelpSet();
117128
hb = hs.createHelpBroker();
118-
} catch (MalformedURLException | HelpSetException e) {
129+
} catch (MalformedURLException | HelpSetException | URISyntaxException e) {
119130
e.printStackTrace();
120131
}
121132
return hb;

src/main/java/adda/Main.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ public class Main {
2828
public static void main(String[] args) {
2929
javax.swing.SwingUtilities.invokeLater(new Runnable() {
3030
public void run() {
31+
if (OsUtils.isMac()) System.setProperty( "jdk.lang.Process.launchMechanism", "FORK" );
3132
try {
3233
UIManager.setLookAndFeel(new FlatLightLaf());
3334
UIManager.getLookAndFeel().getDefaults().put("TextField.disabledBackground", new Color(-855310));

src/main/java/adda/application/SettingDialog.java

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -172,15 +172,15 @@ public void actionPerformed(ActionEvent actionEvent) {
172172
String finalZipUrl = zipUrl;
173173
javax.swing.SwingUtilities.invokeLater(() -> textArea.append("Latest release is " + finalZipUrl + "\n"));
174174

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

178178
Date now = new Date();
179179
SimpleDateFormat pattern = new SimpleDateFormat("MMddHHmmss");
180-
String path = downloadDir + "/adda_release_" + pattern.format(now);
180+
String path = downloadDir + File.separator + "adda_release_" + pattern.format(now);
181181
OsUtils.createFolder(path);
182182

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

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

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

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

232238
textArea.append("---------------- \n");
233239
textArea.append("\n");
234240
if (OsUtils.isMac()) {
235-
textArea.append("brew install gcc \n");
241+
textArea.append("brew install gcc \n");
236242
textArea.append("brew install make \n");
237243
textArea.append("cd " + srcPath + " \n");
238244
textArea.append("make seq OPTIONS=\"FFT_TEMPERTON\" FORT_LIB_PATH=/usr/local/gfortran/lib\n");
@@ -247,6 +253,12 @@ public void actionPerformed(ActionEvent actionEvent) {
247253

248254
textArea.append("\n");
249255
textArea.append("---------------- \n");
256+
257+
if (OsUtils.isMac()) {
258+
textArea.append("IMPORTANT! if you have a problem with gfortran please visit this page\n");
259+
textArea.append("https://github.com/Homebrew/legacy-homebrew/issues/8539 \n");
260+
261+
}
250262
});
251263

252264

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

270+
258271
try {
259-
cmd("gnome-terminal", seqPath);
272+
cmd(OsUtils.isMac() ? "open" : "gnome-terminal", seqPath);
260273
} catch (Exception ignored) {
261274
cmd(System.getenv().get("TERM"), seqPath);
262275
}
276+
277+
263278
}
264279
}
265280

src/main/java/adda/item/root/numberedText/NumberedTextModel.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@
66
import adda.base.models.IModelObserver;
77
import adda.base.models.ModelBase;
88
import adda.item.root.projectTree.ProjectTreeModel;
9-
import net.contentobjects.jnotify.JNotify;
10-
import net.contentobjects.jnotify.JNotifyException;
11-
import net.contentobjects.jnotify.JNotifyListener;
9+
1210

1311
import java.io.BufferedReader;
1412
import java.io.FileReader;

src/main/java/adda/item/root/projectArea/ProjectAreaModel.java

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import adda.item.tab.shape.selector.params.bicoated.BicoatedModel;
1919
import adda.settings.AppSetting;
2020
import adda.settings.SettingsManager;
21+
import adda.utils.OsUtils;
2122
import adda.utils.OutputDisplayer;
2223
import adda.utils.StringHelper;
2324

@@ -400,25 +401,35 @@ public void start() {
400401
}
401402
}
402403

403-
List<String> args = new ArrayList<String>();
404-
405-
406-
args.add(appSetting.getAddaExecSeq());
407-
408-
final List<String> params = Arrays.asList(optionsModel.getActualCommandLine().split(" "));
409-
args.addAll(params);
410-
411-
args.add("-dir");
412-
args.add(pathToState);
413-
414-
args.add("-so_buf");
415-
args.add("line");
416-
417-
ProcessBuilder builder = new ProcessBuilder(args);
418-
builder.redirectErrorStream(true);
419404

420405
try {
421-
Process addaProcess = builder.start();
406+
Process addaProcess;
407+
List<String> args = new ArrayList<String>();
408+
args.add(appSetting.getAddaExecSeq());
409+
final List<String> params = Arrays.asList(optionsModel.getActualCommandLine().split(" "));
410+
args.addAll(params);
411+
args.add("-dir");
412+
args.add(pathToState);
413+
args.add("-so_buf");
414+
args.add("line");
415+
if (OsUtils.isMac()) {
416+
// StringBuilder builder = new StringBuilder();
417+
// builder.append(appSetting.getAddaExecSeq());
418+
// builder.append(" ");
419+
// builder.append(optionsModel.getActualCommandLine());
420+
// builder.append(" -so_buf line");
421+
// builder.append(" -dir ");
422+
// builder.append("\"");
423+
// builder.append(pathToState);
424+
// builder.append("\"");
425+
// String command = builder.toString();
426+
// System.out.println(args);
427+
addaProcess = Runtime.getRuntime().exec(args.stream().toArray(String[]::new));
428+
} else {
429+
ProcessBuilder builder = new ProcessBuilder(args);
430+
builder.redirectErrorStream(true);
431+
addaProcess = builder.start();
432+
}
422433
outputDisplayer.commence(addaProcess, () -> javax.swing.SwingUtilities.invokeLater(() -> setSuccessfullyFinished(true)));
423434
} catch (IOException e) {
424435
setRunning(false);

0 commit comments

Comments
 (0)